@actant/shared 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -144,12 +144,49 @@ interface AgentBackendConfig {
144
144
  /** Optional backend-specific config (e.g. executablePath for launcher). Used in materialization and persisted on instance. */
145
145
  config?: Record<string, unknown>;
146
146
  }
147
- type AgentBackendType = "cursor" | "claude-code" | "custom";
147
+ type AgentBackendType = "cursor" | "cursor-agent" | "claude-code" | "custom" | "pi";
148
+ /** The three ways an agent backend can be opened / interacted with. */
149
+ type AgentOpenMode = "resolve" | "open" | "acp";
150
+ /** Platform-aware command specification. */
151
+ interface PlatformCommand {
152
+ win32: string;
153
+ default: string;
154
+ }
155
+ /**
156
+ * Descriptor for a registered agent backend.
157
+ * Declares which open modes are supported and provides platform-specific commands.
158
+ */
159
+ interface BackendDescriptor {
160
+ type: AgentBackendType;
161
+ /** Which open modes this backend supports. */
162
+ supportedModes: AgentOpenMode[];
163
+ /** Command for `resolve` mode (returns spawn info to external callers). */
164
+ resolveCommand?: PlatformCommand;
165
+ /** Command for `open` mode (directly opens native TUI/UI). */
166
+ openCommand?: PlatformCommand;
167
+ /** Command for `acp` mode (spawn the ACP agent process). Falls back to resolveCommand if not set. */
168
+ acpCommand?: PlatformCommand;
169
+ /**
170
+ * Custom ACP resolver — when set, takes priority over acpCommand/resolveCommand.
171
+ * Returns the full { command, args } to spawn the ACP agent process.
172
+ */
173
+ acpResolver?: (workspaceDir: string, backendConfig?: Record<string, unknown>) => {
174
+ command: string;
175
+ args: string[];
176
+ };
177
+ /**
178
+ * If true, the ACP connection owns the process lifecycle (ProcessLauncher is skipped).
179
+ * Only relevant when "acp" is in supportedModes.
180
+ */
181
+ acpOwnsProcess?: boolean;
182
+ }
148
183
  interface ModelProviderConfig {
149
184
  type: ModelProviderType;
185
+ protocol?: "http" | "websocket" | "grpc";
186
+ baseUrl?: string;
150
187
  config?: Record<string, unknown>;
151
188
  }
152
- type ModelProviderType = "anthropic" | "openai" | "custom";
189
+ type ModelProviderType = "anthropic" | "openai" | "openai-compatible" | "custom";
153
190
  interface InitializerConfig {
154
191
  steps: InitializerStep[];
155
192
  }
@@ -407,6 +444,13 @@ interface AgentResolveParams {
407
444
  };
408
445
  }
409
446
  type AgentResolveResult = ResolveResult;
447
+ interface AgentOpenParams {
448
+ name: string;
449
+ }
450
+ interface AgentOpenResult {
451
+ command: string;
452
+ args: string[];
453
+ }
410
454
  interface AgentAttachParams {
411
455
  name: string;
412
456
  pid: number;
@@ -719,6 +763,10 @@ interface RpcMethodMap {
719
763
  params: AgentResolveParams;
720
764
  result: AgentResolveResult;
721
765
  };
766
+ "agent.open": {
767
+ params: AgentOpenParams;
768
+ result: AgentOpenResult;
769
+ };
722
770
  "agent.attach": {
723
771
  params: AgentAttachParams;
724
772
  result: AgentAttachResult;
@@ -1060,10 +1108,10 @@ declare function createLogger(module: string): Logger;
1060
1108
  * Returns the platform-appropriate IPC path for daemon communication.
1061
1109
  *
1062
1110
  * - macOS/Linux: Unix domain socket at `~/.actant/actant.sock`
1063
- * - Windows: Named pipe at `\\.\pipe\actant`
1111
+ * - Windows: Named pipe derived from homeDir (e.g. `\\.\pipe\actant-...`)
1064
1112
  *
1065
- * Named pipes are the standard Windows IPC mechanism and work with
1066
- * Node.js `net.createServer` / `net.createConnection` transparently.
1113
+ * Delegates to {@link getIpcPath} to ensure CLI and daemon always
1114
+ * resolve to the same path for a given homeDir.
1067
1115
  */
1068
1116
  declare function getDefaultIpcPath(homeDir?: string): string;
1069
1117
  /**
@@ -1093,4 +1141,4 @@ declare function isWindows(): boolean;
1093
1141
  */
1094
1142
  declare function isSingleExecutable(): boolean;
1095
1143
 
1096
- export { ActantError, type AgentAdoptParams, type AgentAdoptResult, AgentAlreadyAttachedError, AgentAlreadyRunningError, type AgentAttachParams, type AgentAttachResult, type AgentBackendConfig, type AgentBackendType, type AgentCreateParams, type AgentCreateResult, type AgentDestroyParams, type AgentDestroyResult, type AgentDetachParams, type AgentDetachResult, type AgentDispatchParams, type AgentDispatchResult, type AgentInstanceMeta, AgentLaunchError, type AgentListParams, type AgentListResult, type AgentLogsParams, type AgentLogsResult, AgentNotAttachedError, AgentNotFoundError, type AgentPromptParams, type AgentPromptResult, type AgentResolveParams, type AgentResolveResult, type AgentRunParams, type AgentRunResult, type AgentStartParams, type AgentStartResult, type AgentStatus, type AgentStatusParams, type AgentStatusResult, type AgentStopParams, type AgentStopResult, type AgentTasksParams, type AgentTasksResult, type AgentTemplate, type AgentUpdatePermissionsParams, type AgentUpdatePermissionsResult, CircularReferenceError, type ComponentAddParams, type ComponentAddResult, type ComponentExportParams, type ComponentExportResult, type ComponentImportParams, type ComponentImportResult, type ComponentOrigin, type ComponentOriginType, ComponentReferenceError, type ComponentRemoveParams, type ComponentRemoveResult, type ComponentUpdateParams, type ComponentUpdateResult, ConfigNotFoundError, ConfigValidationError, type ConfigValidationResult, type DaemonPingParams, type DaemonPingResult, type DaemonShutdownParams, type DaemonShutdownResult, type DetachResult, type DomainContextConfig, type ErrorCategory, type GitHubSourceConfig, type InitializerConfig, type InitializerStep, InstanceCorruptedError, type LaunchMode, type LocalSourceConfig, type Logger, type McpGetParams, type McpGetResult, type McpListParams, type McpListResult, type McpServerDefinition, type McpServerRef, type ModelProviderConfig, type ModelProviderType, type PackageManifest, type PermissionMode, type PermissionPreset, type PermissionsConfig, type PermissionsInput, type PluginDefinition, type PluginGetParams, type PluginGetResult, type PluginListParams, type PluginListResult, type PresetApplyParams, type PresetApplyResult, type PresetDefinition, type PresetListParams, type PresetListResult, type PresetShowParams, type PresetShowResult, type ProcessOwnership, type PromptDefinition, type PromptGetParams, type PromptGetResult, type PromptListParams, type PromptListResult, type ProxyConnectParams, type ProxyConnectResult, type ProxyDisconnectParams, type ProxyDisconnectResult, type ProxyForwardParams, type ProxyForwardResult, type ProxySession, RPC_ERROR_CODES, type ResolveResult, type RpcError, type RpcErrorCode, type RpcMethod, type RpcMethodMap, type RpcRequest, type RpcResponse, type SandboxConfig, type SandboxNetworkConfig, type ScheduleListParams, type ScheduleListResult, type SessionCancelParams, type SessionCancelResult, type SessionCloseParams, type SessionCloseResult, type SessionCreateParams, type SessionCreateResult, type SessionLeaseInfo, type SessionListParams, type SessionListResult, type SessionPromptParams, type SessionPromptResult, type SkillDefinition, type SkillGetParams, type SkillGetResult, type SkillListParams, type SkillListResult, SkillReferenceError, type SourceAddParams, type SourceAddResult, type SourceConfig, type SourceEntry, type SourceListParams, type SourceListResult, type SourceRemoveParams, type SourceRemoveResult, type SourceSyncParams, type SourceSyncResult, type TemplateGetParams, type TemplateGetResult, type TemplateListParams, type TemplateListResult, type TemplateLoadParams, type TemplateLoadResult, TemplateNotFoundError, type TemplateUnloadParams, type TemplateUnloadResult, type TemplateValidateParams, type TemplateValidateResult, type ValidationIssue, type ValidationSeverity, type VersionedComponent, type WorkDirConflict, type WorkflowDefinition, type WorkflowGetParams, type WorkflowGetResult, type WorkflowListParams, type WorkflowListResult, WorkspaceInitError, type WorkspacePolicy, createLogger, getDefaultIpcPath, getIpcPath, ipcRequiresFileCleanup, isSingleExecutable, isWindows, onShutdownSignal };
1144
+ export { ActantError, type AgentAdoptParams, type AgentAdoptResult, AgentAlreadyAttachedError, AgentAlreadyRunningError, type AgentAttachParams, type AgentAttachResult, type AgentBackendConfig, type AgentBackendType, type AgentCreateParams, type AgentCreateResult, type AgentDestroyParams, type AgentDestroyResult, type AgentDetachParams, type AgentDetachResult, type AgentDispatchParams, type AgentDispatchResult, type AgentInstanceMeta, AgentLaunchError, type AgentListParams, type AgentListResult, type AgentLogsParams, type AgentLogsResult, AgentNotAttachedError, AgentNotFoundError, type AgentOpenMode, type AgentOpenParams, type AgentOpenResult, type AgentPromptParams, type AgentPromptResult, type AgentResolveParams, type AgentResolveResult, type AgentRunParams, type AgentRunResult, type AgentStartParams, type AgentStartResult, type AgentStatus, type AgentStatusParams, type AgentStatusResult, type AgentStopParams, type AgentStopResult, type AgentTasksParams, type AgentTasksResult, type AgentTemplate, type AgentUpdatePermissionsParams, type AgentUpdatePermissionsResult, type BackendDescriptor, CircularReferenceError, type ComponentAddParams, type ComponentAddResult, type ComponentExportParams, type ComponentExportResult, type ComponentImportParams, type ComponentImportResult, type ComponentOrigin, type ComponentOriginType, ComponentReferenceError, type ComponentRemoveParams, type ComponentRemoveResult, type ComponentUpdateParams, type ComponentUpdateResult, ConfigNotFoundError, ConfigValidationError, type ConfigValidationResult, type DaemonPingParams, type DaemonPingResult, type DaemonShutdownParams, type DaemonShutdownResult, type DetachResult, type DomainContextConfig, type ErrorCategory, type GitHubSourceConfig, type InitializerConfig, type InitializerStep, InstanceCorruptedError, type LaunchMode, type LocalSourceConfig, type Logger, type McpGetParams, type McpGetResult, type McpListParams, type McpListResult, type McpServerDefinition, type McpServerRef, type ModelProviderConfig, type ModelProviderType, type PackageManifest, type PermissionMode, type PermissionPreset, type PermissionsConfig, type PermissionsInput, type PlatformCommand, type PluginDefinition, type PluginGetParams, type PluginGetResult, type PluginListParams, type PluginListResult, type PresetApplyParams, type PresetApplyResult, type PresetDefinition, type PresetListParams, type PresetListResult, type PresetShowParams, type PresetShowResult, type ProcessOwnership, type PromptDefinition, type PromptGetParams, type PromptGetResult, type PromptListParams, type PromptListResult, type ProxyConnectParams, type ProxyConnectResult, type ProxyDisconnectParams, type ProxyDisconnectResult, type ProxyForwardParams, type ProxyForwardResult, type ProxySession, RPC_ERROR_CODES, type ResolveResult, type RpcError, type RpcErrorCode, type RpcMethod, type RpcMethodMap, type RpcRequest, type RpcResponse, type SandboxConfig, type SandboxNetworkConfig, type ScheduleListParams, type ScheduleListResult, type SessionCancelParams, type SessionCancelResult, type SessionCloseParams, type SessionCloseResult, type SessionCreateParams, type SessionCreateResult, type SessionLeaseInfo, type SessionListParams, type SessionListResult, type SessionPromptParams, type SessionPromptResult, type SkillDefinition, type SkillGetParams, type SkillGetResult, type SkillListParams, type SkillListResult, SkillReferenceError, type SourceAddParams, type SourceAddResult, type SourceConfig, type SourceEntry, type SourceListParams, type SourceListResult, type SourceRemoveParams, type SourceRemoveResult, type SourceSyncParams, type SourceSyncResult, type TemplateGetParams, type TemplateGetResult, type TemplateListParams, type TemplateListResult, type TemplateLoadParams, type TemplateLoadResult, TemplateNotFoundError, type TemplateUnloadParams, type TemplateUnloadResult, type TemplateValidateParams, type TemplateValidateResult, type ValidationIssue, type ValidationSeverity, type VersionedComponent, type WorkDirConflict, type WorkflowDefinition, type WorkflowGetParams, type WorkflowGetResult, type WorkflowListParams, type WorkflowListResult, WorkspaceInitError, type WorkspacePolicy, createLogger, getDefaultIpcPath, getIpcPath, ipcRequiresFileCleanup, isSingleExecutable, isWindows, onShutdownSignal };
package/dist/index.js CHANGED
@@ -177,11 +177,8 @@ import { join } from "path";
177
177
  import { homedir } from "os";
178
178
  var IS_WINDOWS = process.platform === "win32";
179
179
  function getDefaultIpcPath(homeDir) {
180
- if (IS_WINDOWS) {
181
- return "\\\\.\\pipe\\actant";
182
- }
183
180
  const base = homeDir ?? join(homedir(), ".actant");
184
- return join(base, "actant.sock");
181
+ return getIpcPath(base);
185
182
  }
186
183
  function getIpcPath(homeDir) {
187
184
  if (IS_WINDOWS) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/rpc.types.ts","../src/errors/base-error.ts","../src/errors/config-errors.ts","../src/errors/lifecycle-errors.ts","../src/logger/logger.ts","../src/platform/platform.ts"],"sourcesContent":["import type { AgentTemplate, PermissionsInput, PermissionsConfig } from \"./template.types\";\nimport type { AgentInstanceMeta, LaunchMode, WorkspacePolicy, ResolveResult, DetachResult } from \"./agent.types\";\nimport type { SkillDefinition, PromptDefinition, McpServerDefinition, WorkflowDefinition, PluginDefinition } from \"./domain-component.types\";\nimport type { SourceEntry, SourceConfig, PresetDefinition } from \"./source.types\";\n\n// ---------------------------------------------------------------------------\n// JSON-RPC 2.0 base types\n// ---------------------------------------------------------------------------\n\nexport interface RpcRequest {\n jsonrpc: \"2.0\";\n id: number | string;\n method: string;\n params?: Record<string, unknown>;\n}\n\nexport interface RpcResponse {\n jsonrpc: \"2.0\";\n id: number | string;\n result?: unknown;\n error?: RpcError;\n}\n\nexport interface RpcError {\n code: number;\n message: string;\n data?: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Error codes — maps ActantError codes to JSON-RPC error codes\n// ---------------------------------------------------------------------------\n\nexport const RPC_ERROR_CODES = {\n PARSE_ERROR: -32700,\n INVALID_REQUEST: -32600,\n METHOD_NOT_FOUND: -32601,\n INVALID_PARAMS: -32602,\n INTERNAL_ERROR: -32603,\n\n TEMPLATE_NOT_FOUND: -32001,\n CONFIG_VALIDATION: -32002,\n AGENT_NOT_FOUND: -32003,\n AGENT_ALREADY_RUNNING: -32004,\n WORKSPACE_INIT: -32005,\n COMPONENT_REFERENCE: -32006,\n INSTANCE_CORRUPTED: -32007,\n AGENT_LAUNCH: -32008,\n AGENT_ALREADY_ATTACHED: -32009,\n AGENT_NOT_ATTACHED: -32010,\n GENERIC_BUSINESS: -32000,\n} as const;\n\nexport type RpcErrorCode = (typeof RPC_ERROR_CODES)[keyof typeof RPC_ERROR_CODES];\n\n// ---------------------------------------------------------------------------\n// Method-specific param/result types\n// ---------------------------------------------------------------------------\n\n// template.*\n\nexport type TemplateListParams = Record<string, never>;\n\nexport type TemplateListResult = AgentTemplate[];\n\nexport interface TemplateGetParams {\n name: string;\n}\n\nexport type TemplateGetResult = AgentTemplate;\n\nexport interface TemplateLoadParams {\n filePath: string;\n}\n\nexport type TemplateLoadResult = AgentTemplate;\n\nexport interface TemplateUnloadParams {\n name: string;\n}\n\nexport interface TemplateUnloadResult {\n success: boolean;\n}\n\nexport interface TemplateValidateParams {\n filePath: string;\n}\n\nexport interface TemplateValidateResult {\n valid: boolean;\n template?: AgentTemplate;\n errors?: Array<{ path: string; message: string }>;\n /** Warnings that don't prevent loading but indicate potential issues (#119) */\n warnings?: Array<{ path: string; message: string }>;\n}\n\n// agent.*\n\nexport type WorkDirConflict = \"error\" | \"overwrite\" | \"append\";\n\nexport interface AgentCreateParams {\n name: string;\n template: string;\n overrides?: {\n launchMode?: LaunchMode;\n workspacePolicy?: WorkspacePolicy;\n /** Absolute path to use as workspace directory instead of the default {instancesDir}/{name}. */\n workDir?: string;\n /** Behavior when workDir already exists. Default: \"error\". */\n workDirConflict?: WorkDirConflict;\n /** Override template permissions. Completely replaces template.permissions when set. */\n permissions?: PermissionsInput;\n metadata?: Record<string, string>;\n };\n}\n\nexport type AgentCreateResult = AgentInstanceMeta;\n\nexport interface AgentStartParams {\n name: string;\n}\n\nexport type AgentStartResult = AgentInstanceMeta;\n\nexport interface AgentStopParams {\n name: string;\n}\n\nexport type AgentStopResult = AgentInstanceMeta;\n\nexport interface AgentDestroyParams {\n name: string;\n}\n\nexport interface AgentDestroyResult {\n success: boolean;\n}\n\nexport interface AgentStatusParams {\n name: string;\n}\n\nexport type AgentStatusResult = AgentInstanceMeta;\n\nexport type AgentListParams = Record<string, never>;\n\nexport type AgentListResult = AgentInstanceMeta[];\n\nexport interface AgentUpdatePermissionsParams {\n name: string;\n permissions: PermissionsInput;\n}\n\nexport interface AgentUpdatePermissionsResult {\n effectivePermissions: PermissionsConfig;\n}\n\nexport interface AgentAdoptParams {\n path: string;\n rename?: string;\n}\n\nexport interface AgentAdoptResult {\n name: string;\n template: string;\n workspacePath: string;\n location: \"builtin\" | \"external\";\n createdAt: string;\n status: \"stopped\" | \"running\" | \"orphaned\";\n}\n\n// agent.resolve / agent.attach / agent.detach (external spawn)\n\nexport interface AgentResolveParams {\n name: string;\n template?: string;\n overrides?: {\n launchMode?: LaunchMode;\n workspacePolicy?: WorkspacePolicy;\n metadata?: Record<string, string>;\n };\n}\n\nexport type AgentResolveResult = ResolveResult;\n\nexport interface AgentAttachParams {\n name: string;\n pid: number;\n metadata?: Record<string, string>;\n}\n\nexport type AgentAttachResult = AgentInstanceMeta;\n\nexport interface AgentDetachParams {\n name: string;\n cleanup?: boolean;\n}\n\nexport type AgentDetachResult = DetachResult;\n\n// agent.run\n\nexport interface AgentRunParams {\n name: string;\n prompt: string;\n options?: {\n systemPromptFile?: string;\n appendSystemPrompt?: string;\n sessionId?: string;\n timeoutMs?: number;\n maxTurns?: number;\n model?: string;\n };\n}\n\nexport interface AgentRunResult {\n text: string;\n sessionId?: string;\n}\n\n// agent.dispatch\n\nexport interface AgentDispatchParams {\n name: string;\n prompt: string;\n priority?: string;\n}\nexport interface AgentDispatchResult {\n queued: boolean;\n}\n\n// agent.tasks\n\nexport interface AgentTasksParams {\n name: string;\n}\nexport interface AgentTasksResult {\n queued: number;\n processing: boolean;\n tasks: unknown[];\n}\n\n// agent.logs\n\nexport interface AgentLogsParams {\n name: string;\n limit?: number;\n}\nexport type AgentLogsResult = unknown[];\n\n// schedule.list\n\nexport interface ScheduleListParams {\n name: string;\n}\nexport interface ScheduleListResult {\n sources: Array<{ id: string; type: string; active: boolean }>;\n running: boolean;\n}\n\n// agent.prompt (ACP session)\n\nexport interface AgentPromptParams {\n name: string;\n message: string;\n sessionId?: string;\n}\n\nexport interface AgentPromptResult {\n response: string;\n sessionId: string;\n}\n\n// session.* (Session Lease mode)\n\nexport interface SessionCreateParams {\n agentName: string;\n clientId: string;\n idleTtlMs?: number;\n}\n\nexport interface SessionLeaseInfo {\n sessionId: string;\n agentName: string;\n clientId: string | null;\n state: \"active\" | \"idle\" | \"expired\";\n createdAt: string;\n lastActivityAt: string;\n idleTtlMs: number;\n}\n\nexport type SessionCreateResult = SessionLeaseInfo;\n\nexport interface SessionPromptParams {\n sessionId: string;\n text: string;\n}\n\nexport interface SessionPromptResult {\n stopReason: string;\n text: string;\n}\n\nexport interface SessionCancelParams {\n sessionId: string;\n}\n\nexport interface SessionCancelResult {\n ok: boolean;\n}\n\nexport interface SessionCloseParams {\n sessionId: string;\n}\n\nexport interface SessionCloseResult {\n ok: boolean;\n}\n\nexport interface SessionListParams {\n agentName?: string;\n}\n\nexport type SessionListResult = SessionLeaseInfo[];\n\n// proxy.* (legacy)\n\nexport interface ProxyConnectParams {\n agentName: string;\n envPassthrough?: boolean;\n}\n\nexport interface ProxySession {\n sessionId: string;\n agentName: string;\n envPassthrough: boolean;\n connectedAt: string;\n}\n\nexport type ProxyConnectResult = ProxySession;\n\nexport interface ProxyDisconnectParams {\n sessionId: string;\n}\n\nexport interface ProxyDisconnectResult {\n ok: boolean;\n}\n\nexport interface ProxyForwardParams {\n sessionId: string;\n acpMessage: Record<string, unknown>;\n}\n\nexport type ProxyForwardResult = Record<string, unknown>;\n\n// skill.*\n\nexport type SkillListParams = Record<string, never>;\nexport type SkillListResult = SkillDefinition[];\n\nexport interface SkillGetParams {\n name: string;\n}\nexport type SkillGetResult = SkillDefinition;\n\n// prompt.*\n\nexport type PromptListParams = Record<string, never>;\nexport type PromptListResult = PromptDefinition[];\n\nexport interface PromptGetParams {\n name: string;\n}\nexport type PromptGetResult = PromptDefinition;\n\n// mcp.*\n\nexport type McpListParams = Record<string, never>;\nexport type McpListResult = McpServerDefinition[];\n\nexport interface McpGetParams {\n name: string;\n}\nexport type McpGetResult = McpServerDefinition;\n\n// workflow.*\n\nexport type WorkflowListParams = Record<string, never>;\nexport type WorkflowListResult = WorkflowDefinition[];\n\nexport interface WorkflowGetParams {\n name: string;\n}\nexport type WorkflowGetResult = WorkflowDefinition;\n\n// plugin.*\n\nexport type PluginListParams = Record<string, never>;\nexport type PluginListResult = PluginDefinition[];\n\nexport interface PluginGetParams {\n name: string;\n}\nexport type PluginGetResult = PluginDefinition;\n\n// daemon.*\n\nexport type DaemonPingParams = Record<string, never>;\n\nexport interface DaemonPingResult {\n version: string;\n uptime: number;\n agents: number;\n}\n\nexport type DaemonShutdownParams = Record<string, never>;\n\nexport interface DaemonShutdownResult {\n success: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Gateway lease — request an ACP Gateway socket for Session Lease\n// ---------------------------------------------------------------------------\n\nexport interface GatewayLeaseParams {\n agentName: string;\n}\n\nexport interface GatewayLeaseResult {\n socketPath: string;\n}\n\nexport interface ComponentAddParams {\n component: Record<string, unknown>;\n}\n\nexport interface ComponentAddResult {\n name: string;\n}\n\nexport interface ComponentUpdateParams {\n name: string;\n patch: Record<string, unknown>;\n}\n\nexport interface ComponentUpdateResult {\n name: string;\n}\n\nexport interface ComponentRemoveParams {\n name: string;\n}\n\nexport interface ComponentRemoveResult {\n success: boolean;\n}\n\nexport interface ComponentImportParams {\n filePath: string;\n}\n\nexport interface ComponentImportResult {\n name: string;\n}\n\nexport interface ComponentExportParams {\n name: string;\n filePath: string;\n}\n\nexport interface ComponentExportResult {\n success: boolean;\n}\n\nexport type SourceListParams = Record<string, never>;\nexport type SourceListResult = SourceEntry[];\n\nexport interface SourceAddParams {\n name: string;\n config: SourceConfig;\n}\n\nexport interface SourceAddResult {\n name: string;\n components: { skills: number; prompts: number; mcp: number; workflows: number; presets: number };\n}\n\nexport interface SourceRemoveParams {\n name: string;\n}\n\nexport interface SourceRemoveResult {\n success: boolean;\n}\n\nexport interface SourceSyncParams {\n name?: string;\n}\n\nexport interface SourceSyncResult {\n synced: string[];\n /** Sync report summary (aggregated when syncing multiple sources). */\n report?: {\n addedCount: number;\n updatedCount: number;\n removedCount: number;\n hasBreakingChanges: boolean;\n };\n}\n\nexport interface PresetListParams {\n packageName?: string;\n}\n\nexport type PresetListResult = PresetDefinition[];\n\nexport interface PresetShowParams {\n qualifiedName: string;\n}\n\nexport type PresetShowResult = PresetDefinition;\n\nexport interface PresetApplyParams {\n qualifiedName: string;\n templateName: string;\n}\n\nexport type PresetApplyResult = AgentTemplate;\n\n// ---------------------------------------------------------------------------\n// Method registry type — maps method name to params/result for type safety\n// ---------------------------------------------------------------------------\n\nexport interface RpcMethodMap {\n \"template.list\": { params: TemplateListParams; result: TemplateListResult };\n \"template.get\": { params: TemplateGetParams; result: TemplateGetResult };\n \"template.load\": { params: TemplateLoadParams; result: TemplateLoadResult };\n \"template.unload\": { params: TemplateUnloadParams; result: TemplateUnloadResult };\n \"template.validate\": { params: TemplateValidateParams; result: TemplateValidateResult };\n \"agent.create\": { params: AgentCreateParams; result: AgentCreateResult };\n \"agent.start\": { params: AgentStartParams; result: AgentStartResult };\n \"agent.stop\": { params: AgentStopParams; result: AgentStopResult };\n \"agent.destroy\": { params: AgentDestroyParams; result: AgentDestroyResult };\n \"agent.status\": { params: AgentStatusParams; result: AgentStatusResult };\n \"agent.list\": { params: AgentListParams; result: AgentListResult };\n \"agent.updatePermissions\": { params: AgentUpdatePermissionsParams; result: AgentUpdatePermissionsResult };\n \"agent.adopt\": { params: AgentAdoptParams; result: AgentAdoptResult };\n \"agent.resolve\": { params: AgentResolveParams; result: AgentResolveResult };\n \"agent.attach\": { params: AgentAttachParams; result: AgentAttachResult };\n \"agent.detach\": { params: AgentDetachParams; result: AgentDetachResult };\n \"agent.run\": { params: AgentRunParams; result: AgentRunResult };\n \"agent.prompt\": { params: AgentPromptParams; result: AgentPromptResult };\n \"agent.dispatch\": { params: AgentDispatchParams; result: AgentDispatchResult };\n \"agent.tasks\": { params: AgentTasksParams; result: AgentTasksResult };\n \"agent.logs\": { params: AgentLogsParams; result: AgentLogsResult };\n \"schedule.list\": { params: ScheduleListParams; result: ScheduleListResult };\n \"session.create\": { params: SessionCreateParams; result: SessionCreateResult };\n \"session.prompt\": { params: SessionPromptParams; result: SessionPromptResult };\n \"session.cancel\": { params: SessionCancelParams; result: SessionCancelResult };\n \"session.close\": { params: SessionCloseParams; result: SessionCloseResult };\n \"session.list\": { params: SessionListParams; result: SessionListResult };\n \"proxy.connect\": { params: ProxyConnectParams; result: ProxyConnectResult };\n \"proxy.disconnect\": { params: ProxyDisconnectParams; result: ProxyDisconnectResult };\n \"proxy.forward\": { params: ProxyForwardParams; result: ProxyForwardResult };\n \"skill.list\": { params: SkillListParams; result: SkillListResult };\n \"skill.get\": { params: SkillGetParams; result: SkillGetResult };\n \"skill.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"skill.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"skill.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"skill.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"skill.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"prompt.list\": { params: PromptListParams; result: PromptListResult };\n \"prompt.get\": { params: PromptGetParams; result: PromptGetResult };\n \"prompt.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"prompt.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"prompt.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"prompt.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"prompt.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"mcp.list\": { params: McpListParams; result: McpListResult };\n \"mcp.get\": { params: McpGetParams; result: McpGetResult };\n \"mcp.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"mcp.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"mcp.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"mcp.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"mcp.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"workflow.list\": { params: WorkflowListParams; result: WorkflowListResult };\n \"workflow.get\": { params: WorkflowGetParams; result: WorkflowGetResult };\n \"workflow.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"workflow.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"workflow.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"workflow.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"workflow.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"plugin.list\": { params: PluginListParams; result: PluginListResult };\n \"plugin.get\": { params: PluginGetParams; result: PluginGetResult };\n \"plugin.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"plugin.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"plugin.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"plugin.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"plugin.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"source.list\": { params: SourceListParams; result: SourceListResult };\n \"source.add\": { params: SourceAddParams; result: SourceAddResult };\n \"source.remove\": { params: SourceRemoveParams; result: SourceRemoveResult };\n \"source.sync\": { params: SourceSyncParams; result: SourceSyncResult };\n \"preset.list\": { params: PresetListParams; result: PresetListResult };\n \"preset.show\": { params: PresetShowParams; result: PresetShowResult };\n \"preset.apply\": { params: PresetApplyParams; result: PresetApplyResult };\n \"daemon.ping\": { params: DaemonPingParams; result: DaemonPingResult };\n \"daemon.shutdown\": { params: DaemonShutdownParams; result: DaemonShutdownResult };\n \"gateway.lease\": { params: GatewayLeaseParams; result: GatewayLeaseResult };\n}\n\nexport type RpcMethod = keyof RpcMethodMap;\n","export type ErrorCategory =\n | \"configuration\"\n | \"lifecycle\"\n | \"communication\"\n | \"cli\";\n\nexport abstract class ActantError extends Error {\n abstract readonly code: string;\n abstract readonly category: ErrorCategory;\n readonly timestamp: Date;\n readonly context?: Record<string, unknown>;\n\n constructor(message: string, context?: Record<string, unknown>) {\n super(message);\n this.name = this.constructor.name;\n this.timestamp = new Date();\n this.context = context;\n }\n}\n","import { ActantError, type ErrorCategory } from \"./base-error\";\nimport type { ValidationIssue } from \"../types/validation.types\";\n\nexport class ConfigNotFoundError extends ActantError {\n readonly code = \"CONFIG_NOT_FOUND\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(configPath: string) {\n super(`Configuration file not found: ${configPath}`, { configPath });\n }\n}\n\nexport class ConfigValidationError extends ActantError {\n readonly code = \"CONFIG_VALIDATION_ERROR\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(\n message: string,\n public readonly validationErrors: Array<{\n path: string;\n message: string;\n }>,\n /** Structured validation issues with severity (#119) */\n public readonly issues?: ValidationIssue[],\n ) {\n super(message, { validationErrors });\n }\n}\n\nexport class TemplateNotFoundError extends ActantError {\n readonly code = \"TEMPLATE_NOT_FOUND\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(templateName: string) {\n super(`Template \"${templateName}\" not found in registry`, {\n templateName,\n });\n }\n}\n\nexport class SkillReferenceError extends ActantError {\n readonly code = \"SKILL_REFERENCE_ERROR\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(skillName: string) {\n super(`Skill \"${skillName}\" not found in registry`, { skillName });\n }\n}\n\nexport class ComponentReferenceError extends ActantError {\n readonly code = \"COMPONENT_REFERENCE_ERROR\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(componentType: string, componentName: string) {\n super(`${componentType} \"${componentName}\" not found in registry`, {\n componentType,\n componentName,\n });\n }\n}\n\nexport class CircularReferenceError extends ActantError {\n readonly code = \"CIRCULAR_REFERENCE\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(cyclePath: string[]) {\n super(`Circular reference detected: ${cyclePath.join(\" → \")}`, {\n cyclePath,\n });\n }\n}\n","import { ActantError, type ErrorCategory } from \"./base-error\";\n\nexport class AgentLaunchError extends ActantError {\n readonly code = \"AGENT_LAUNCH_ERROR\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string, cause?: Error) {\n super(`Failed to launch agent \"${instanceName}\"`, {\n instanceName,\n cause: cause?.message,\n });\n if (cause) this.cause = cause;\n }\n}\n\nexport class AgentNotFoundError extends ActantError {\n readonly code = \"AGENT_NOT_FOUND\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string) {\n super(`Agent instance \"${instanceName}\" not found`, { instanceName });\n }\n}\n\nexport class AgentAlreadyRunningError extends ActantError {\n readonly code = \"AGENT_ALREADY_RUNNING\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string) {\n super(`Agent \"${instanceName}\" is already running`, { instanceName });\n }\n}\n\nexport class AgentAlreadyAttachedError extends ActantError {\n readonly code = \"AGENT_ALREADY_ATTACHED\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string) {\n super(`Agent \"${instanceName}\" already has an attached process`, { instanceName });\n }\n}\n\nexport class AgentNotAttachedError extends ActantError {\n readonly code = \"AGENT_NOT_ATTACHED\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string) {\n super(`Agent \"${instanceName}\" has no attached process`, { instanceName });\n }\n}\n\nexport class InstanceCorruptedError extends ActantError {\n readonly code = \"INSTANCE_CORRUPTED\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string, reason: string) {\n super(\n `Agent instance \"${instanceName}\" is corrupted: ${reason}`,\n { instanceName, reason },\n );\n }\n}\n\nexport class WorkspaceInitError extends ActantError {\n readonly code = \"WORKSPACE_INIT_ERROR\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(workspacePath: string, cause?: Error) {\n super(`Failed to initialize workspace at \"${workspacePath}\"`, {\n workspacePath,\n cause: cause?.message,\n });\n if (cause) this.cause = cause;\n }\n}\n","import pino from \"pino\";\n\nexport type Logger = pino.Logger;\n\nfunction resolveLogLevel(): string {\n if (process.env[\"LOG_LEVEL\"]) return process.env[\"LOG_LEVEL\"];\n if (process.env[\"VITEST\"] || process.env[\"NODE_ENV\"] === \"test\") return \"silent\";\n return \"info\";\n}\n\nexport function createLogger(module: string): Logger {\n return pino({\n name: module,\n level: resolveLogLevel(),\n formatters: {\n level(label: string) {\n return { level: label };\n },\n },\n timestamp: pino.stdTimeFunctions.isoTime,\n });\n}\n","import { join } from \"node:path\";\nimport { homedir } from \"node:os\";\n\nconst IS_WINDOWS = process.platform === \"win32\";\n\n/**\n * Returns the platform-appropriate IPC path for daemon communication.\n *\n * - macOS/Linux: Unix domain socket at `~/.actant/actant.sock`\n * - Windows: Named pipe at `\\\\.\\pipe\\actant`\n *\n * Named pipes are the standard Windows IPC mechanism and work with\n * Node.js `net.createServer` / `net.createConnection` transparently.\n */\nexport function getDefaultIpcPath(homeDir?: string): string {\n if (IS_WINDOWS) {\n return \"\\\\\\\\.\\\\pipe\\\\actant\";\n }\n const base = homeDir ?? join(homedir(), \".actant\");\n return join(base, \"actant.sock\");\n}\n\n/**\n * Returns the IPC path for a given home directory.\n * Used by AppContext when homeDir is explicitly provided.\n */\nexport function getIpcPath(homeDir: string): string {\n if (IS_WINDOWS) {\n const safeName = homeDir.replace(/[^a-zA-Z0-9._-]/g, \"_\");\n return `\\\\\\\\.\\\\pipe\\\\actant-${safeName}`;\n }\n return join(homeDir, \"actant.sock\");\n}\n\n/**\n * Whether the current platform uses file-based IPC (Unix sockets)\n * that may need cleanup (unlink) before listening.\n */\nexport function ipcRequiresFileCleanup(): boolean {\n return !IS_WINDOWS;\n}\n\n/**\n * Registers graceful shutdown handlers that work across all platforms.\n *\n * - Unix: SIGINT, SIGTERM\n * - Windows: SIGINT (Ctrl+C in terminal), SIGBREAK (Ctrl+Break)\n *\n * SIGTERM is not reliably delivered on Windows, so we also listen for\n * SIGBREAK which is the closest equivalent.\n */\nexport function onShutdownSignal(handler: () => void | Promise<void>): void {\n const wrappedHandler = () => {\n void Promise.resolve(handler());\n };\n\n process.on(\"SIGINT\", wrappedHandler);\n\n if (IS_WINDOWS) {\n process.on(\"SIGBREAK\", wrappedHandler);\n } else {\n process.on(\"SIGTERM\", wrappedHandler);\n }\n}\n\nexport function isWindows(): boolean {\n return IS_WINDOWS;\n}\n\nlet _isSea = false;\nlet _isSeaChecked = false;\n\n/**\n * Detects if the process is running as a Node.js Single Executable Application.\n * Uses `node:sea` module (Node 20+) with a fallback heuristic.\n */\nexport function isSingleExecutable(): boolean {\n if (_isSeaChecked) return _isSea;\n _isSeaChecked = true;\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const sea = require(\"node:sea\");\n _isSea = typeof sea.isSea === \"function\" ? sea.isSea() : false;\n } catch {\n _isSea = false;\n }\n return _isSea;\n}\n"],"mappings":";;;;;;;;AAiCO,IAAM,kBAAkB;AAAA,EAC7B,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB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AAkC;AAChD,SAAO,CAAC;AACV;AAWO,SAAS,iBAAiB,SAA2C;AAC1E,QAAM,iBAAiB,MAAM;AAC3B,SAAK,QAAQ,QAAQ,QAAQ,CAAC;AAAA,EAChC;AAEA,UAAQ,GAAG,UAAU,cAAc;AAEnC,MAAI,YAAY;AACd,YAAQ,GAAG,YAAY,cAAc;AAAA,EACvC,OAAO;AACL,YAAQ,GAAG,WAAW,cAAc;AAAA,EACtC;AACF;AAEO,SAAS,YAAqB;AACnC,SAAO;AACT;AAEA,IAAI,SAAS;AACb,IAAI,gBAAgB;AAMb,SAAS,qBAA8B;AAC5C,MAAI,cAAe,QAAO;AAC1B,kBAAgB;AAChB,MAAI;AAEF,UAAM,MAAM,UAAQ,KAAU;AAC9B,aAAS,OAAO,IAAI,UAAU,aAAa,IAAI,MAAM,IAAI;AAAA,EAC3D,QAAQ;AACN,aAAS;AAAA,EACX;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/types/rpc.types.ts","../src/errors/base-error.ts","../src/errors/config-errors.ts","../src/errors/lifecycle-errors.ts","../src/logger/logger.ts","../src/platform/platform.ts"],"sourcesContent":["import type { AgentTemplate, PermissionsInput, PermissionsConfig } from \"./template.types\";\nimport type { AgentInstanceMeta, LaunchMode, WorkspacePolicy, ResolveResult, DetachResult } from \"./agent.types\";\nimport type { SkillDefinition, PromptDefinition, McpServerDefinition, WorkflowDefinition, PluginDefinition } from \"./domain-component.types\";\nimport type { SourceEntry, SourceConfig, PresetDefinition } from \"./source.types\";\n\n// ---------------------------------------------------------------------------\n// JSON-RPC 2.0 base types\n// ---------------------------------------------------------------------------\n\nexport interface RpcRequest {\n jsonrpc: \"2.0\";\n id: number | string;\n method: string;\n params?: Record<string, unknown>;\n}\n\nexport interface RpcResponse {\n jsonrpc: \"2.0\";\n id: number | string;\n result?: unknown;\n error?: RpcError;\n}\n\nexport interface RpcError {\n code: number;\n message: string;\n data?: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Error codes — maps ActantError codes to JSON-RPC error codes\n// ---------------------------------------------------------------------------\n\nexport const RPC_ERROR_CODES = {\n PARSE_ERROR: -32700,\n INVALID_REQUEST: -32600,\n METHOD_NOT_FOUND: -32601,\n INVALID_PARAMS: -32602,\n INTERNAL_ERROR: -32603,\n\n TEMPLATE_NOT_FOUND: -32001,\n CONFIG_VALIDATION: -32002,\n AGENT_NOT_FOUND: -32003,\n AGENT_ALREADY_RUNNING: -32004,\n WORKSPACE_INIT: -32005,\n COMPONENT_REFERENCE: -32006,\n INSTANCE_CORRUPTED: -32007,\n AGENT_LAUNCH: -32008,\n AGENT_ALREADY_ATTACHED: -32009,\n AGENT_NOT_ATTACHED: -32010,\n GENERIC_BUSINESS: -32000,\n} as const;\n\nexport type RpcErrorCode = (typeof RPC_ERROR_CODES)[keyof typeof RPC_ERROR_CODES];\n\n// ---------------------------------------------------------------------------\n// Method-specific param/result types\n// ---------------------------------------------------------------------------\n\n// template.*\n\nexport type TemplateListParams = Record<string, never>;\n\nexport type TemplateListResult = AgentTemplate[];\n\nexport interface TemplateGetParams {\n name: string;\n}\n\nexport type TemplateGetResult = AgentTemplate;\n\nexport interface TemplateLoadParams {\n filePath: string;\n}\n\nexport type TemplateLoadResult = AgentTemplate;\n\nexport interface TemplateUnloadParams {\n name: string;\n}\n\nexport interface TemplateUnloadResult {\n success: boolean;\n}\n\nexport interface TemplateValidateParams {\n filePath: string;\n}\n\nexport interface TemplateValidateResult {\n valid: boolean;\n template?: AgentTemplate;\n errors?: Array<{ path: string; message: string }>;\n /** Warnings that don't prevent loading but indicate potential issues (#119) */\n warnings?: Array<{ path: string; message: string }>;\n}\n\n// agent.*\n\nexport type WorkDirConflict = \"error\" | \"overwrite\" | \"append\";\n\nexport interface AgentCreateParams {\n name: string;\n template: string;\n overrides?: {\n launchMode?: LaunchMode;\n workspacePolicy?: WorkspacePolicy;\n /** Absolute path to use as workspace directory instead of the default {instancesDir}/{name}. */\n workDir?: string;\n /** Behavior when workDir already exists. Default: \"error\". */\n workDirConflict?: WorkDirConflict;\n /** Override template permissions. Completely replaces template.permissions when set. */\n permissions?: PermissionsInput;\n metadata?: Record<string, string>;\n };\n}\n\nexport type AgentCreateResult = AgentInstanceMeta;\n\nexport interface AgentStartParams {\n name: string;\n}\n\nexport type AgentStartResult = AgentInstanceMeta;\n\nexport interface AgentStopParams {\n name: string;\n}\n\nexport type AgentStopResult = AgentInstanceMeta;\n\nexport interface AgentDestroyParams {\n name: string;\n}\n\nexport interface AgentDestroyResult {\n success: boolean;\n}\n\nexport interface AgentStatusParams {\n name: string;\n}\n\nexport type AgentStatusResult = AgentInstanceMeta;\n\nexport type AgentListParams = Record<string, never>;\n\nexport type AgentListResult = AgentInstanceMeta[];\n\nexport interface AgentUpdatePermissionsParams {\n name: string;\n permissions: PermissionsInput;\n}\n\nexport interface AgentUpdatePermissionsResult {\n effectivePermissions: PermissionsConfig;\n}\n\nexport interface AgentAdoptParams {\n path: string;\n rename?: string;\n}\n\nexport interface AgentAdoptResult {\n name: string;\n template: string;\n workspacePath: string;\n location: \"builtin\" | \"external\";\n createdAt: string;\n status: \"stopped\" | \"running\" | \"orphaned\";\n}\n\n// agent.resolve / agent.attach / agent.detach (external spawn)\n\nexport interface AgentResolveParams {\n name: string;\n template?: string;\n overrides?: {\n launchMode?: LaunchMode;\n workspacePolicy?: WorkspacePolicy;\n metadata?: Record<string, string>;\n };\n}\n\nexport type AgentResolveResult = ResolveResult;\n\nexport interface AgentOpenParams {\n name: string;\n}\n\nexport interface AgentOpenResult {\n command: string;\n args: string[];\n}\n\nexport interface AgentAttachParams {\n name: string;\n pid: number;\n metadata?: Record<string, string>;\n}\n\nexport type AgentAttachResult = AgentInstanceMeta;\n\nexport interface AgentDetachParams {\n name: string;\n cleanup?: boolean;\n}\n\nexport type AgentDetachResult = DetachResult;\n\n// agent.run\n\nexport interface AgentRunParams {\n name: string;\n prompt: string;\n options?: {\n systemPromptFile?: string;\n appendSystemPrompt?: string;\n sessionId?: string;\n timeoutMs?: number;\n maxTurns?: number;\n model?: string;\n };\n}\n\nexport interface AgentRunResult {\n text: string;\n sessionId?: string;\n}\n\n// agent.dispatch\n\nexport interface AgentDispatchParams {\n name: string;\n prompt: string;\n priority?: string;\n}\nexport interface AgentDispatchResult {\n queued: boolean;\n}\n\n// agent.tasks\n\nexport interface AgentTasksParams {\n name: string;\n}\nexport interface AgentTasksResult {\n queued: number;\n processing: boolean;\n tasks: unknown[];\n}\n\n// agent.logs\n\nexport interface AgentLogsParams {\n name: string;\n limit?: number;\n}\nexport type AgentLogsResult = unknown[];\n\n// schedule.list\n\nexport interface ScheduleListParams {\n name: string;\n}\nexport interface ScheduleListResult {\n sources: Array<{ id: string; type: string; active: boolean }>;\n running: boolean;\n}\n\n// agent.prompt (ACP session)\n\nexport interface AgentPromptParams {\n name: string;\n message: string;\n sessionId?: string;\n}\n\nexport interface AgentPromptResult {\n response: string;\n sessionId: string;\n}\n\n// session.* (Session Lease mode)\n\nexport interface SessionCreateParams {\n agentName: string;\n clientId: string;\n idleTtlMs?: number;\n}\n\nexport interface SessionLeaseInfo {\n sessionId: string;\n agentName: string;\n clientId: string | null;\n state: \"active\" | \"idle\" | \"expired\";\n createdAt: string;\n lastActivityAt: string;\n idleTtlMs: number;\n}\n\nexport type SessionCreateResult = SessionLeaseInfo;\n\nexport interface SessionPromptParams {\n sessionId: string;\n text: string;\n}\n\nexport interface SessionPromptResult {\n stopReason: string;\n text: string;\n}\n\nexport interface SessionCancelParams {\n sessionId: string;\n}\n\nexport interface SessionCancelResult {\n ok: boolean;\n}\n\nexport interface SessionCloseParams {\n sessionId: string;\n}\n\nexport interface SessionCloseResult {\n ok: boolean;\n}\n\nexport interface SessionListParams {\n agentName?: string;\n}\n\nexport type SessionListResult = SessionLeaseInfo[];\n\n// proxy.* (legacy)\n\nexport interface ProxyConnectParams {\n agentName: string;\n envPassthrough?: boolean;\n}\n\nexport interface ProxySession {\n sessionId: string;\n agentName: string;\n envPassthrough: boolean;\n connectedAt: string;\n}\n\nexport type ProxyConnectResult = ProxySession;\n\nexport interface ProxyDisconnectParams {\n sessionId: string;\n}\n\nexport interface ProxyDisconnectResult {\n ok: boolean;\n}\n\nexport interface ProxyForwardParams {\n sessionId: string;\n acpMessage: Record<string, unknown>;\n}\n\nexport type ProxyForwardResult = Record<string, unknown>;\n\n// skill.*\n\nexport type SkillListParams = Record<string, never>;\nexport type SkillListResult = SkillDefinition[];\n\nexport interface SkillGetParams {\n name: string;\n}\nexport type SkillGetResult = SkillDefinition;\n\n// prompt.*\n\nexport type PromptListParams = Record<string, never>;\nexport type PromptListResult = PromptDefinition[];\n\nexport interface PromptGetParams {\n name: string;\n}\nexport type PromptGetResult = PromptDefinition;\n\n// mcp.*\n\nexport type McpListParams = Record<string, never>;\nexport type McpListResult = McpServerDefinition[];\n\nexport interface McpGetParams {\n name: string;\n}\nexport type McpGetResult = McpServerDefinition;\n\n// workflow.*\n\nexport type WorkflowListParams = Record<string, never>;\nexport type WorkflowListResult = WorkflowDefinition[];\n\nexport interface WorkflowGetParams {\n name: string;\n}\nexport type WorkflowGetResult = WorkflowDefinition;\n\n// plugin.*\n\nexport type PluginListParams = Record<string, never>;\nexport type PluginListResult = PluginDefinition[];\n\nexport interface PluginGetParams {\n name: string;\n}\nexport type PluginGetResult = PluginDefinition;\n\n// daemon.*\n\nexport type DaemonPingParams = Record<string, never>;\n\nexport interface DaemonPingResult {\n version: string;\n uptime: number;\n agents: number;\n}\n\nexport type DaemonShutdownParams = Record<string, never>;\n\nexport interface DaemonShutdownResult {\n success: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Gateway lease — request an ACP Gateway socket for Session Lease\n// ---------------------------------------------------------------------------\n\nexport interface GatewayLeaseParams {\n agentName: string;\n}\n\nexport interface GatewayLeaseResult {\n socketPath: string;\n}\n\nexport interface ComponentAddParams {\n component: Record<string, unknown>;\n}\n\nexport interface ComponentAddResult {\n name: string;\n}\n\nexport interface ComponentUpdateParams {\n name: string;\n patch: Record<string, unknown>;\n}\n\nexport interface ComponentUpdateResult {\n name: string;\n}\n\nexport interface ComponentRemoveParams {\n name: string;\n}\n\nexport interface ComponentRemoveResult {\n success: boolean;\n}\n\nexport interface ComponentImportParams {\n filePath: string;\n}\n\nexport interface ComponentImportResult {\n name: string;\n}\n\nexport interface ComponentExportParams {\n name: string;\n filePath: string;\n}\n\nexport interface ComponentExportResult {\n success: boolean;\n}\n\nexport type SourceListParams = Record<string, never>;\nexport type SourceListResult = SourceEntry[];\n\nexport interface SourceAddParams {\n name: string;\n config: SourceConfig;\n}\n\nexport interface SourceAddResult {\n name: string;\n components: { skills: number; prompts: number; mcp: number; workflows: number; presets: number };\n}\n\nexport interface SourceRemoveParams {\n name: string;\n}\n\nexport interface SourceRemoveResult {\n success: boolean;\n}\n\nexport interface SourceSyncParams {\n name?: string;\n}\n\nexport interface SourceSyncResult {\n synced: string[];\n /** Sync report summary (aggregated when syncing multiple sources). */\n report?: {\n addedCount: number;\n updatedCount: number;\n removedCount: number;\n hasBreakingChanges: boolean;\n };\n}\n\nexport interface PresetListParams {\n packageName?: string;\n}\n\nexport type PresetListResult = PresetDefinition[];\n\nexport interface PresetShowParams {\n qualifiedName: string;\n}\n\nexport type PresetShowResult = PresetDefinition;\n\nexport interface PresetApplyParams {\n qualifiedName: string;\n templateName: string;\n}\n\nexport type PresetApplyResult = AgentTemplate;\n\n// ---------------------------------------------------------------------------\n// Method registry type — maps method name to params/result for type safety\n// ---------------------------------------------------------------------------\n\nexport interface RpcMethodMap {\n \"template.list\": { params: TemplateListParams; result: TemplateListResult };\n \"template.get\": { params: TemplateGetParams; result: TemplateGetResult };\n \"template.load\": { params: TemplateLoadParams; result: TemplateLoadResult };\n \"template.unload\": { params: TemplateUnloadParams; result: TemplateUnloadResult };\n \"template.validate\": { params: TemplateValidateParams; result: TemplateValidateResult };\n \"agent.create\": { params: AgentCreateParams; result: AgentCreateResult };\n \"agent.start\": { params: AgentStartParams; result: AgentStartResult };\n \"agent.stop\": { params: AgentStopParams; result: AgentStopResult };\n \"agent.destroy\": { params: AgentDestroyParams; result: AgentDestroyResult };\n \"agent.status\": { params: AgentStatusParams; result: AgentStatusResult };\n \"agent.list\": { params: AgentListParams; result: AgentListResult };\n \"agent.updatePermissions\": { params: AgentUpdatePermissionsParams; result: AgentUpdatePermissionsResult };\n \"agent.adopt\": { params: AgentAdoptParams; result: AgentAdoptResult };\n \"agent.resolve\": { params: AgentResolveParams; result: AgentResolveResult };\n \"agent.open\": { params: AgentOpenParams; result: AgentOpenResult };\n \"agent.attach\": { params: AgentAttachParams; result: AgentAttachResult };\n \"agent.detach\": { params: AgentDetachParams; result: AgentDetachResult };\n \"agent.run\": { params: AgentRunParams; result: AgentRunResult };\n \"agent.prompt\": { params: AgentPromptParams; result: AgentPromptResult };\n \"agent.dispatch\": { params: AgentDispatchParams; result: AgentDispatchResult };\n \"agent.tasks\": { params: AgentTasksParams; result: AgentTasksResult };\n \"agent.logs\": { params: AgentLogsParams; result: AgentLogsResult };\n \"schedule.list\": { params: ScheduleListParams; result: ScheduleListResult };\n \"session.create\": { params: SessionCreateParams; result: SessionCreateResult };\n \"session.prompt\": { params: SessionPromptParams; result: SessionPromptResult };\n \"session.cancel\": { params: SessionCancelParams; result: SessionCancelResult };\n \"session.close\": { params: SessionCloseParams; result: SessionCloseResult };\n \"session.list\": { params: SessionListParams; result: SessionListResult };\n \"proxy.connect\": { params: ProxyConnectParams; result: ProxyConnectResult };\n \"proxy.disconnect\": { params: ProxyDisconnectParams; result: ProxyDisconnectResult };\n \"proxy.forward\": { params: ProxyForwardParams; result: ProxyForwardResult };\n \"skill.list\": { params: SkillListParams; result: SkillListResult };\n \"skill.get\": { params: SkillGetParams; result: SkillGetResult };\n \"skill.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"skill.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"skill.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"skill.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"skill.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"prompt.list\": { params: PromptListParams; result: PromptListResult };\n \"prompt.get\": { params: PromptGetParams; result: PromptGetResult };\n \"prompt.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"prompt.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"prompt.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"prompt.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"prompt.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"mcp.list\": { params: McpListParams; result: McpListResult };\n \"mcp.get\": { params: McpGetParams; result: McpGetResult };\n \"mcp.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"mcp.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"mcp.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"mcp.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"mcp.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"workflow.list\": { params: WorkflowListParams; result: WorkflowListResult };\n \"workflow.get\": { params: WorkflowGetParams; result: WorkflowGetResult };\n \"workflow.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"workflow.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"workflow.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"workflow.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"workflow.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"plugin.list\": { params: PluginListParams; result: PluginListResult };\n \"plugin.get\": { params: PluginGetParams; result: PluginGetResult };\n \"plugin.add\": { params: ComponentAddParams; result: ComponentAddResult };\n \"plugin.update\": { params: ComponentUpdateParams; result: ComponentUpdateResult };\n \"plugin.remove\": { params: ComponentRemoveParams; result: ComponentRemoveResult };\n \"plugin.import\": { params: ComponentImportParams; result: ComponentImportResult };\n \"plugin.export\": { params: ComponentExportParams; result: ComponentExportResult };\n \"source.list\": { params: SourceListParams; result: SourceListResult };\n \"source.add\": { params: SourceAddParams; result: SourceAddResult };\n \"source.remove\": { params: SourceRemoveParams; result: SourceRemoveResult };\n \"source.sync\": { params: SourceSyncParams; result: SourceSyncResult };\n \"preset.list\": { params: PresetListParams; result: PresetListResult };\n \"preset.show\": { params: PresetShowParams; result: PresetShowResult };\n \"preset.apply\": { params: PresetApplyParams; result: PresetApplyResult };\n \"daemon.ping\": { params: DaemonPingParams; result: DaemonPingResult };\n \"daemon.shutdown\": { params: DaemonShutdownParams; result: DaemonShutdownResult };\n \"gateway.lease\": { params: GatewayLeaseParams; result: GatewayLeaseResult };\n}\n\nexport type RpcMethod = keyof RpcMethodMap;\n","export type ErrorCategory =\n | \"configuration\"\n | \"lifecycle\"\n | \"communication\"\n | \"cli\";\n\nexport abstract class ActantError extends Error {\n abstract readonly code: string;\n abstract readonly category: ErrorCategory;\n readonly timestamp: Date;\n readonly context?: Record<string, unknown>;\n\n constructor(message: string, context?: Record<string, unknown>) {\n super(message);\n this.name = this.constructor.name;\n this.timestamp = new Date();\n this.context = context;\n }\n}\n","import { ActantError, type ErrorCategory } from \"./base-error\";\nimport type { ValidationIssue } from \"../types/validation.types\";\n\nexport class ConfigNotFoundError extends ActantError {\n readonly code = \"CONFIG_NOT_FOUND\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(configPath: string) {\n super(`Configuration file not found: ${configPath}`, { configPath });\n }\n}\n\nexport class ConfigValidationError extends ActantError {\n readonly code = \"CONFIG_VALIDATION_ERROR\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(\n message: string,\n public readonly validationErrors: Array<{\n path: string;\n message: string;\n }>,\n /** Structured validation issues with severity (#119) */\n public readonly issues?: ValidationIssue[],\n ) {\n super(message, { validationErrors });\n }\n}\n\nexport class TemplateNotFoundError extends ActantError {\n readonly code = \"TEMPLATE_NOT_FOUND\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(templateName: string) {\n super(`Template \"${templateName}\" not found in registry`, {\n templateName,\n });\n }\n}\n\nexport class SkillReferenceError extends ActantError {\n readonly code = \"SKILL_REFERENCE_ERROR\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(skillName: string) {\n super(`Skill \"${skillName}\" not found in registry`, { skillName });\n }\n}\n\nexport class ComponentReferenceError extends ActantError {\n readonly code = \"COMPONENT_REFERENCE_ERROR\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(componentType: string, componentName: string) {\n super(`${componentType} \"${componentName}\" not found in registry`, {\n componentType,\n componentName,\n });\n }\n}\n\nexport class CircularReferenceError extends ActantError {\n readonly code = \"CIRCULAR_REFERENCE\";\n readonly category: ErrorCategory = \"configuration\";\n\n constructor(cyclePath: string[]) {\n super(`Circular reference detected: ${cyclePath.join(\" → \")}`, {\n cyclePath,\n });\n }\n}\n","import { ActantError, type ErrorCategory } from \"./base-error\";\n\nexport class AgentLaunchError extends ActantError {\n readonly code = \"AGENT_LAUNCH_ERROR\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string, cause?: Error) {\n super(`Failed to launch agent \"${instanceName}\"`, {\n instanceName,\n cause: cause?.message,\n });\n if (cause) this.cause = cause;\n }\n}\n\nexport class AgentNotFoundError extends ActantError {\n readonly code = \"AGENT_NOT_FOUND\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string) {\n super(`Agent instance \"${instanceName}\" not found`, { instanceName });\n }\n}\n\nexport class AgentAlreadyRunningError extends ActantError {\n readonly code = \"AGENT_ALREADY_RUNNING\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string) {\n super(`Agent \"${instanceName}\" is already running`, { instanceName });\n }\n}\n\nexport class AgentAlreadyAttachedError extends ActantError {\n readonly code = \"AGENT_ALREADY_ATTACHED\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string) {\n super(`Agent \"${instanceName}\" already has an attached process`, { instanceName });\n }\n}\n\nexport class AgentNotAttachedError extends ActantError {\n readonly code = \"AGENT_NOT_ATTACHED\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string) {\n super(`Agent \"${instanceName}\" has no attached process`, { instanceName });\n }\n}\n\nexport class InstanceCorruptedError extends ActantError {\n readonly code = \"INSTANCE_CORRUPTED\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(instanceName: string, reason: string) {\n super(\n `Agent instance \"${instanceName}\" is corrupted: ${reason}`,\n { instanceName, reason },\n );\n }\n}\n\nexport class WorkspaceInitError extends ActantError {\n readonly code = \"WORKSPACE_INIT_ERROR\";\n readonly category: ErrorCategory = \"lifecycle\";\n\n constructor(workspacePath: string, cause?: Error) {\n super(`Failed to initialize workspace at \"${workspacePath}\"`, {\n workspacePath,\n cause: cause?.message,\n });\n if (cause) this.cause = cause;\n }\n}\n","import pino from \"pino\";\n\nexport type Logger = pino.Logger;\n\nfunction resolveLogLevel(): string {\n if (process.env[\"LOG_LEVEL\"]) return process.env[\"LOG_LEVEL\"];\n if (process.env[\"VITEST\"] || process.env[\"NODE_ENV\"] === \"test\") return \"silent\";\n return \"info\";\n}\n\nexport function createLogger(module: string): Logger {\n return pino({\n name: module,\n level: resolveLogLevel(),\n formatters: {\n level(label: string) {\n return { level: label };\n },\n },\n timestamp: pino.stdTimeFunctions.isoTime,\n });\n}\n","import { join } from \"node:path\";\nimport { homedir } from \"node:os\";\n\nconst IS_WINDOWS = process.platform === \"win32\";\n\n/**\n * Returns the platform-appropriate IPC path for daemon communication.\n *\n * - macOS/Linux: Unix domain socket at `~/.actant/actant.sock`\n * - Windows: Named pipe derived from homeDir (e.g. `\\\\.\\pipe\\actant-...`)\n *\n * Delegates to {@link getIpcPath} to ensure CLI and daemon always\n * resolve to the same path for a given homeDir.\n */\nexport function getDefaultIpcPath(homeDir?: string): string {\n const base = homeDir ?? join(homedir(), \".actant\");\n return getIpcPath(base);\n}\n\n/**\n * Returns the IPC path for a given home directory.\n * Used by AppContext when homeDir is explicitly provided.\n */\nexport function getIpcPath(homeDir: string): string {\n if (IS_WINDOWS) {\n const safeName = homeDir.replace(/[^a-zA-Z0-9._-]/g, \"_\");\n return `\\\\\\\\.\\\\pipe\\\\actant-${safeName}`;\n }\n return join(homeDir, \"actant.sock\");\n}\n\n/**\n * Whether the current platform uses file-based IPC (Unix sockets)\n * that may need cleanup (unlink) before listening.\n */\nexport function ipcRequiresFileCleanup(): boolean {\n return !IS_WINDOWS;\n}\n\n/**\n * Registers graceful shutdown handlers that work across all platforms.\n *\n * - Unix: SIGINT, SIGTERM\n * - Windows: SIGINT (Ctrl+C in terminal), SIGBREAK (Ctrl+Break)\n *\n * SIGTERM is not reliably delivered on Windows, so we also listen for\n * SIGBREAK which is the closest equivalent.\n */\nexport function onShutdownSignal(handler: () => void | Promise<void>): void {\n const wrappedHandler = () => {\n void Promise.resolve(handler());\n };\n\n process.on(\"SIGINT\", wrappedHandler);\n\n if (IS_WINDOWS) {\n process.on(\"SIGBREAK\", wrappedHandler);\n } else {\n process.on(\"SIGTERM\", wrappedHandler);\n }\n}\n\nexport function isWindows(): boolean {\n return IS_WINDOWS;\n}\n\nlet _isSea = false;\nlet _isSeaChecked = false;\n\n/**\n * Detects if the process is running as a Node.js Single Executable Application.\n * Uses `node:sea` module (Node 20+) with a fallback heuristic.\n */\nexport function isSingleExecutable(): boolean {\n if (_isSeaChecked) return _isSea;\n _isSeaChecked = true;\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const sea = require(\"node:sea\");\n _isSea = typeof sea.isSea === \"function\" ? sea.isSea() : false;\n } catch {\n _isSea = false;\n }\n return _isSea;\n}\n"],"mappings":";;;;;;;;AAiCO,IAAM,kBAAkB;AAAA,EAC7B,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAEhB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,uBAAuB;AAAA,EACvB,gBAAgB;AAAA,EAChB,qBAAqB;AAAA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AAY;AACd,YAAQ,GAAG,YAAY,cAAc;AAAA,EACvC,OAAO;AACL,YAAQ,GAAG,WAAW,cAAc;AAAA,EACtC;AACF;AAEO,SAAS,YAAqB;AACnC,SAAO;AACT;AAEA,IAAI,SAAS;AACb,IAAI,gBAAgB;AAMb,SAAS,qBAA8B;AAC5C,MAAI,cAAe,QAAO;AAC1B,kBAAgB;AAChB,MAAI;AAEF,UAAM,MAAM,UAAQ,KAAU;AAC9B,aAAS,OAAO,IAAI,UAAU,aAAa,IAAI,MAAM,IAAI;AAAA,EAC3D,QAAQ;AACN,aAAS;AAAA,EACX;AACA,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actant/shared",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Shared utilities and types for the Actant AI agent platform",
5
5
  "type": "module",
6
6
  "license": "MIT",