diff --git a/plugin/calendar/calendar-bridge.ts b/plugin/calendar/calendar-bridge.ts index c3a29e5..1db6b7f 100644 --- a/plugin/calendar/calendar-bridge.ts +++ b/plugin/calendar/calendar-bridge.ts @@ -29,7 +29,7 @@ import { CalendarSlotResponse, SlotAgentUpdate, SlotStatus, -} from './types'; +} from './types.js'; export interface CalendarBridgeConfig { /** HarborForge backend base URL (e.g. "https://monitor.hangman-lab.top") */ @@ -292,7 +292,7 @@ export class CalendarBridgeClient { // --------------------------------------------------------------------------- import { hostname } from 'os'; -import { getPluginConfig } from '../core/config'; +import { getPluginConfig } from '../core/config.js'; export interface CalendarPluginConfig { /** Backend URL for calendar API (overrides monitor backendUrl) */ diff --git a/plugin/calendar/index.ts b/plugin/calendar/index.ts index a829ccf..646fbb5 100644 --- a/plugin/calendar/index.ts +++ b/plugin/calendar/index.ts @@ -13,7 +13,7 @@ * • AgentWakeContext — context passed to agent when waking * * Usage in plugin/index.ts: - * import { createCalendarBridgeClient, createCalendarScheduler } from './calendar'; + * import { createCalendarBridgeClient, createCalendarScheduler } from './calendar.js'; * * const agentId = process.env.AGENT_ID || 'unknown'; * const calendar = createCalendarBridgeClient(api, 'https://monitor.hangman-lab.top', agentId); @@ -28,7 +28,7 @@ * scheduler.start(); */ -export * from './types'; -export * from './calendar-bridge'; -export * from './scheduler'; -export * from './schedule-cache'; +export * from './types.js'; +export * from './calendar-bridge.js'; +export * from './scheduler.js'; +export * from './schedule-cache.js'; diff --git a/plugin/calendar/scheduler.ts b/plugin/calendar/scheduler.ts index bb0675f..14e5a89 100644 --- a/plugin/calendar/scheduler.ts +++ b/plugin/calendar/scheduler.ts @@ -18,7 +18,7 @@ import { writeFileSync, readFileSync, existsSync, mkdirSync } from 'fs'; import { join, dirname } from 'path'; -import { CalendarBridgeClient } from './calendar-bridge'; +import { CalendarBridgeClient } from './calendar-bridge.js'; import { CalendarSlotResponse, SlotStatus, @@ -26,7 +26,7 @@ import { SlotAgentUpdate, CalendarEventDataJob, CalendarEventDataSystemEvent, -} from './types'; +} from './types.js'; export interface CalendarSchedulerConfig { /** Calendar bridge client for backend communication */ diff --git a/plugin/hooks/gateway-start.ts b/plugin/hooks/gateway-start.ts index 26aee53..76499b5 100644 --- a/plugin/hooks/gateway-start.ts +++ b/plugin/hooks/gateway-start.ts @@ -1,6 +1,6 @@ import { hostname } from 'os'; -import { getPluginConfig } from '../core/config'; -import { startManagedMonitor } from '../core/managed-monitor'; +import { getPluginConfig } from '../core/config.js'; +import { startManagedMonitor } from '../core/managed-monitor.js'; export function registerGatewayStartHook(api: any, deps: { logger: any; diff --git a/plugin/hooks/gateway-stop.ts b/plugin/hooks/gateway-stop.ts index 04dce16..95d3a47 100644 --- a/plugin/hooks/gateway-stop.ts +++ b/plugin/hooks/gateway-stop.ts @@ -1,4 +1,4 @@ -import { stopManagedMonitor } from '../core/managed-monitor'; +import { stopManagedMonitor } from '../core/managed-monitor.js'; export function registerGatewayStopHook(api: any, deps: { logger: any; diff --git a/plugin/index.ts b/plugin/index.ts index f9da985..47481ca 100644 --- a/plugin/index.ts +++ b/plugin/index.ts @@ -11,18 +11,20 @@ * served directly by the plugin when Monitor queries via the * local monitor_port communication path. */ -import { hostname, freemem, totalmem, uptime, loadavg, platform } from 'os'; -import { getPluginConfig } from './core/config'; -import { MonitorBridgeClient, type OpenClawMeta } from './core/monitor-bridge'; -import type { OpenClawAgentInfo } from './core/openclaw-agents'; -import { registerGatewayStartHook } from './hooks/gateway-start'; -import { registerGatewayStopHook } from './hooks/gateway-stop'; +import { hostname, freemem, totalmem, uptime, loadavg, platform } from 'node:os'; +import { definePluginEntry } from 'openclaw/plugin-sdk/plugin-entry'; +import { MultiAgentScheduleCache } from './calendar/schedule-cache.js'; +import { getPluginConfig } from './core/config.js'; +import { MonitorBridgeClient, type OpenClawMeta } from './core/monitor-bridge.js'; +import type { OpenClawAgentInfo } from './core/openclaw-agents.js'; +import { registerGatewayStartHook } from './hooks/gateway-start.js'; +import { registerGatewayStopHook } from './hooks/gateway-stop.js'; import { createCalendarBridgeClient, createCalendarScheduler, CalendarScheduler, AgentWakeContext, -} from './calendar'; +} from './calendar/index.js'; interface PluginAPI { logger: { @@ -53,10 +55,7 @@ interface PluginAPI { getAgentStatus?: () => Promise<{ status: string } | null>; } -export default { - id: 'harbor-forge', - name: 'HarborForge', - register(api: PluginAPI) { +function register(api: PluginAPI): void { const logger = api.logger || { info: (...args: any[]) => console.log('[HarborForge]', ...args), error: (...args: any[]) => console.error('[HarborForge]', ...args), @@ -290,7 +289,6 @@ export default { ); // Multi-agent sync + check loop - const { MultiAgentScheduleCache } = require('./calendar/schedule-cache') as typeof import('./calendar/schedule-cache'); const scheduleCache = new MultiAgentScheduleCache(); const SYNC_INTERVAL_MS = 300_000; // 5 min @@ -595,5 +593,16 @@ export default { })); logger.info('HarborForge plugin registered (id: harbor-forge)'); - }, -}; +} + +// HarborForge's local PluginAPI is broader than the standard OpenClawPluginApi +// (it surfaces optional `version`/`runtime`/`spawn` accessors that older +// OpenClaw builds exposed). The cast at the definePluginEntry boundary +// acknowledges that gap — the runtime api object is whatever the gateway +// passes us, and each access is guarded with optional chaining / fallbacks. +export default definePluginEntry({ + id: 'harbor-forge', + name: 'HarborForge', + description: 'HarborForge plugin for OpenClaw - project management, monitoring, and CLI integration', + register: register as (api: any) => void, +}); diff --git a/plugin/openclaw.plugin.json b/plugin/openclaw.plugin.json index 186c986..9acecef 100644 --- a/plugin/openclaw.plugin.json +++ b/plugin/openclaw.plugin.json @@ -1,9 +1,19 @@ { "id": "harbor-forge", "name": "HarborForge", - "version": "0.2.0", "description": "HarborForge plugin for OpenClaw - project management, monitoring, and CLI integration", - "entry": "./dist/index.js", + "activation": { + "onStartup": true + }, + "contracts": { + "tools": [ + "harborforge_status", + "harborforge_telemetry", + "harborforge_monitor_telemetry", + "harborforge_calendar_status", + "harborforge_calendar_complete" + ] + }, "configSchema": { "type": "object", "additionalProperties": false, diff --git a/plugin/package.json b/plugin/package.json index c7ba015..37a353f 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -2,6 +2,7 @@ "name": "harbor-forge-plugin", "version": "0.2.0", "description": "OpenClaw plugin for HarborForge monitor bridge and CLI integration", + "type": "module", "main": "dist/index.js", "scripts": { "clean": "rm -rf dist", diff --git a/plugin/tsconfig.json b/plugin/tsconfig.json index b095193..4880004 100644 --- a/plugin/tsconfig.json +++ b/plugin/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "ES2022", - "module": "CommonJS", - "moduleResolution": "node", + "module": "nodenext", + "moduleResolution": "nodenext", "esModuleInterop": true, "strict": true, "skipLibCheck": true,