@actant/core 0.2.1 → 0.2.2

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
@@ -1,4 +1,4 @@
1
- import { AgentBackendType, SkillDefinition, PromptDefinition, McpServerDefinition, PluginDefinition, WorkflowDefinition, PermissionsInput, Logger, ConfigValidationResult, DomainContextConfig, AgentBackendConfig, ModelProviderConfig, AgentTemplate, AgentInstanceMeta, LaunchMode, WorkspacePolicy, WorkDirConflict, InitializerStep, AgentStatus, ResolveResult, DetachResult, BackendDescriptor, AgentOpenMode, PermissionsConfig, SourceConfig, PackageManifest, PresetDefinition, GitHubSourceConfig, LocalSourceConfig, SourceEntry, ModelProviderDescriptor } from '@actant/shared';
1
+ import { AgentBackendType, SkillDefinition, PromptDefinition, McpServerDefinition, PluginDefinition, WorkflowDefinition, PermissionsInput, Logger, ConfigValidationResult, DomainContextConfig, AgentBackendConfig, ModelProviderConfig, AgentTemplate, AgentInstanceMeta, LaunchMode, WorkspacePolicy, WorkDirConflict, InitializerStep, OpenSpawnOptions, AgentStatus, ResolveResult, DetachResult, BackendDefinition, AgentOpenMode, PlatformCommand, BackendInstallMethod, BackendDescriptor, PermissionsConfig, SourceConfig, PackageManifest, PresetDefinition, GitHubSourceConfig, LocalSourceConfig, SourceEntry, ModelProviderDescriptor } from '@actant/shared';
2
2
  import { z } from 'zod/v4';
3
3
  import { EventEmitter } from 'node:events';
4
4
  import { Writable, Readable } from 'node:stream';
@@ -1158,13 +1158,7 @@ declare const AgentInstanceMetaSchema: z.ZodObject<{
1158
1158
  name: z.ZodString;
1159
1159
  templateName: z.ZodString;
1160
1160
  templateVersion: z.ZodString;
1161
- backendType: z.ZodDefault<z.ZodEnum<{
1162
- cursor: "cursor";
1163
- "cursor-agent": "cursor-agent";
1164
- "claude-code": "claude-code";
1165
- custom: "custom";
1166
- pi: "pi";
1167
- }>>;
1161
+ backendType: z.ZodDefault<z.ZodString>;
1168
1162
  backendConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1169
1163
  providerConfig: z.ZodOptional<z.ZodObject<{
1170
1164
  type: z.ZodString;
@@ -1305,6 +1299,46 @@ interface AgentLauncher {
1305
1299
  terminate(process: AgentProcess): Promise<void>;
1306
1300
  }
1307
1301
 
1302
+ interface ResolvedBackend {
1303
+ command: string;
1304
+ args: string[];
1305
+ /** npm package providing the binary (for auto-resolution when not on PATH). */
1306
+ resolvePackage?: string;
1307
+ /** Working directory for the spawned process. */
1308
+ cwd?: string;
1309
+ /** Declarative spawn options for `open` mode (from BackendDescriptor). */
1310
+ openSpawnOptions?: OpenSpawnOptions;
1311
+ }
1312
+ /**
1313
+ * Whether a backend type supports the ACP protocol for Actant-managed control.
1314
+ * Replaces the old hardcoded `isAcpBackend()`.
1315
+ */
1316
+ declare function isAcpBackend(backendType: AgentBackendType): boolean;
1317
+ /**
1318
+ * Whether a backend's ACP connection owns the process lifecycle.
1319
+ * When true, ProcessLauncher.launch() is skipped — only AcpConnectionManager spawns the process.
1320
+ */
1321
+ declare function isAcpOnlyBackend(backendType: AgentBackendType): boolean;
1322
+ /**
1323
+ * Resolve the executable command and arguments for spawning a backend (resolve mode).
1324
+ * @throws if the backend does not support "resolve" mode.
1325
+ */
1326
+ declare function resolveBackend(backendType: AgentBackendType, workspaceDir: string, backendConfig?: Record<string, unknown>): ResolvedBackend;
1327
+ /**
1328
+ * Resolve the open command for directly launching a backend's native TUI/UI.
1329
+ * `openWorkspaceDir` is consumed here to build `args`/`cwd`; the returned
1330
+ * `openSpawnOptions` maps 1:1 to `child_process.SpawnOptions` so the CLI
1331
+ * can spread it as-is with zero branching.
1332
+ */
1333
+ declare function openBackend(backendType: AgentBackendType, workspaceDir: string): ResolvedBackend;
1334
+ /**
1335
+ * Resolve the ACP spawn command for a backend.
1336
+ * For ACP backends, this returns the command used by AcpConnectionManager to spawn the agent process.
1337
+ * Checks acpCommand first, then falls back to resolveCommand.
1338
+ * @throws if the backend does not support "acp" mode.
1339
+ */
1340
+ declare function resolveAcpBackend(backendType: AgentBackendType, workspaceDir: string, backendConfig?: Record<string, unknown>): ResolvedBackend;
1341
+
1308
1342
  interface RestartPolicy {
1309
1343
  /** Maximum number of restarts before giving up. Default: 5 */
1310
1344
  maxRestarts: number;
@@ -1392,6 +1426,7 @@ interface AcpConnectionManagerLike {
1392
1426
  command: string;
1393
1427
  args: string[];
1394
1428
  cwd: string;
1429
+ resolvePackage?: string;
1395
1430
  connectionOptions?: {
1396
1431
  autoApprove?: boolean;
1397
1432
  env?: Record<string, string>;
@@ -1485,10 +1520,7 @@ declare class AgentManager {
1485
1520
  * Requires the backend to support "open" mode.
1486
1521
  * @throws if backend does not support "open" mode
1487
1522
  */
1488
- openAgent(name: string): Promise<{
1489
- command: string;
1490
- args: string[];
1491
- }>;
1523
+ openAgent(name: string): Promise<ResolvedBackend>;
1492
1524
  /**
1493
1525
  * Register an externally-spawned process with the manager.
1494
1526
  * Sets processOwnership to "external" and registers ProcessWatcher monitoring.
@@ -1658,55 +1690,62 @@ interface LauncherConfig {
1658
1690
  */
1659
1691
  declare function createLauncher(config?: Partial<LauncherConfig>): AgentLauncher;
1660
1692
 
1661
- interface ResolvedBackend {
1693
+ type AcpResolverFn = (workspaceDir: string, backendConfig?: Record<string, unknown>) => {
1662
1694
  command: string;
1663
1695
  args: string[];
1664
- }
1665
- /**
1666
- * Whether a backend type supports the ACP protocol for Actant-managed control.
1667
- * Replaces the old hardcoded `isAcpBackend()`.
1668
- */
1669
- declare function isAcpBackend(backendType: AgentBackendType): boolean;
1670
- /**
1671
- * Whether a backend's ACP connection owns the process lifecycle.
1672
- * When true, ProcessLauncher.launch() is skipped — only AcpConnectionManager spawns the process.
1673
- */
1674
- declare function isAcpOnlyBackend(backendType: AgentBackendType): boolean;
1675
- /**
1676
- * Resolve the executable command and arguments for spawning a backend (resolve mode).
1677
- * @throws if the backend does not support "resolve" mode.
1678
- */
1679
- declare function resolveBackend(backendType: AgentBackendType, workspaceDir: string, backendConfig?: Record<string, unknown>): ResolvedBackend;
1680
- /**
1681
- * Resolve the open command for directly launching a backend's native TUI/UI.
1682
- * @throws if the backend does not support "open" mode.
1683
- */
1684
- declare function openBackend(backendType: AgentBackendType, workspaceDir: string): ResolvedBackend;
1696
+ };
1685
1697
  /**
1686
- * Resolve the ACP spawn command for a backend.
1687
- * For ACP backends, this returns the command used by AcpConnectionManager to spawn the agent process.
1688
- * Checks acpCommand first, then falls back to resolveCommand.
1689
- * @throws if the backend does not support "acp" mode.
1698
+ * Manages backend definitions as VersionedComponents.
1699
+ *
1700
+ * Pure-data definitions are stored in the component registry (JSON-serializable,
1701
+ * loadable from `~/.actant/configs/backends/`). Non-serializable behavioral
1702
+ * extensions (acpResolver) are stored in a separate Map keyed by backend name.
1690
1703
  */
1691
- declare function resolveAcpBackend(backendType: AgentBackendType, workspaceDir: string, backendConfig?: Record<string, unknown>): ResolvedBackend;
1704
+ declare class BackendManager extends BaseComponentManager<BackendDefinition> {
1705
+ protected readonly componentType = "Backend";
1706
+ private readonly acpResolvers;
1707
+ constructor();
1708
+ registerAcpResolver(backendName: string, resolver: AcpResolverFn): void;
1709
+ getAcpResolver(backendName: string): AcpResolverFn | undefined;
1710
+ supportsMode(backendName: string, mode: AgentOpenMode): boolean;
1711
+ requireMode(backendName: string, mode: AgentOpenMode): void;
1712
+ getPlatformCommand(cmd: PlatformCommand): string;
1713
+ /**
1714
+ * Probe whether a backend binary is available on the system.
1715
+ * Uses the `existenceCheck` field. Returns `{ available, version? }`.
1716
+ * If no `existenceCheck` is configured, returns `{ available: true }` (assume ok).
1717
+ */
1718
+ checkAvailability(backendName: string): Promise<BackendAvailability>;
1719
+ /**
1720
+ * Get platform-appropriate install methods for a backend.
1721
+ * Filters by `platforms` field; returns all methods if no platform restriction.
1722
+ */
1723
+ getInstallMethods(backendName: string): BackendInstallMethod[];
1724
+ validate(data: unknown, _source: string): ConfigValidationResult<BackendDefinition>;
1725
+ }
1726
+ interface BackendAvailability {
1727
+ available: boolean;
1728
+ version?: string;
1729
+ error?: string;
1730
+ }
1692
1731
 
1732
+ /** Access the singleton BackendManager for advanced operations (CRUD, persistence, directory loading). */
1733
+ declare function getBackendManager(): BackendManager;
1693
1734
  /**
1694
- * Register a backend descriptor.
1695
- * Call at startup for built-in backends and from external packages (e.g. @actant/pi).
1735
+ * Register a backend descriptor (legacy API).
1736
+ * Converts `BackendDescriptor.type` `BackendDefinition.name` and
1737
+ * extracts `acpResolver` into the behavioral registry.
1696
1738
  */
1697
1739
  declare function registerBackend(descriptor: BackendDescriptor): void;
1698
1740
  /**
1699
- * Retrieve the descriptor for a backend type.
1700
- * @throws if the type has not been registered.
1741
+ * Register a BackendDefinition directly (new API).
1742
+ * For behavioral extensions, use `getBackendManager().registerAcpResolver()`.
1701
1743
  */
1702
- declare function getBackendDescriptor(type: AgentBackendType): BackendDescriptor;
1703
- /** Check whether a backend supports a specific open mode. */
1744
+ declare function registerBackendDefinition(definition: BackendDefinition): void;
1745
+ declare function getBackendDescriptor(type: AgentBackendType): BackendDefinition;
1704
1746
  declare function supportsMode(type: AgentBackendType, mode: AgentOpenMode): boolean;
1705
- /**
1706
- * Assert that a backend supports a mode, throwing a descriptive error if not.
1707
- * Used as a guard in manager methods before executing mode-specific logic.
1708
- */
1709
1747
  declare function requireMode(type: AgentBackendType, mode: AgentOpenMode): void;
1748
+ declare function getInstallHint(type: AgentBackendType): string | undefined;
1710
1749
 
1711
1750
  /**
1712
1751
  * Check whether a process with the given PID is still alive.
@@ -1952,6 +1991,7 @@ interface FetchResult {
1952
1991
  prompts: PromptDefinition[];
1953
1992
  mcpServers: McpServerDefinition[];
1954
1993
  workflows: WorkflowDefinition[];
1994
+ backends: BackendDefinition[];
1955
1995
  presets: PresetDefinition[];
1956
1996
  templates: AgentTemplate[];
1957
1997
  }
@@ -2027,6 +2067,7 @@ interface SourceManagerDeps {
2027
2067
  promptManager: BaseComponentManager<PromptDefinition>;
2028
2068
  mcpConfigManager: BaseComponentManager<McpServerDefinition>;
2029
2069
  workflowManager: BaseComponentManager<WorkflowDefinition>;
2070
+ backendManager?: BaseComponentManager<BackendDefinition>;
2030
2071
  templateRegistry?: TemplateRegistry;
2031
2072
  }
2032
2073
  /**
@@ -2164,4 +2205,4 @@ declare const BUILTIN_PROVIDERS: readonly ModelProviderDescriptor[];
2164
2205
  /** Register all built-in providers into the singleton registry. */
2165
2206
  declare function registerBuiltinProviders(): void;
2166
2207
 
2167
- export { AgentBackendSchema, type AgentCommunicator, AgentInitializer, AgentInstanceMetaSchema, type AgentLauncher, AgentManager, type AgentProcess, AgentStatusSchema, type AgentTask, type AgentTemplateInput, type AgentTemplateOutput, AgentTemplateSchema, type AuditEntry, BUILTIN_PROVIDERS, type BackendBuilder, BaseComponentManager, ClaudeCodeBuilder, ClaudeCodeCommunicator, type CommunicatorFactory, type CompatMode, ComponentOriginSchema, type ComponentSource, type ComponentTypeHandler, ContextMaterializer, type CreateSessionOptions, type CronConfig, CronConfigSchema, CronInput, CursorBuilder, CursorCommunicator, CustomBuilder, type CustomBuilderConfig, DEFAULT_RESTART_POLICY, DEFAULT_SOURCE_CONFIG, DEFAULT_SOURCE_NAME, DomainContextSchema, type DomainManagers$1 as DomainManagers, EmployeeScheduler, ExecStep, ExecutionLog, type ExecutionRecord, type FetchResult, FileCopyStep, GitCloneStep, GitHubSource, type HeartbeatConfig, HeartbeatConfigSchema, HeartbeatInput, type HookConfig, HookConfigSchema, HookInput, InitializationPipeline, type InitializerOptions, InitializerSchema, InitializerStepExecutor, InitializerStepSchema, InputRouter, type InputSource, type InstanceOverrides, InstanceRegistry, type InstanceRegistryAdapter, type InstanceRegistryData, type InstanceRegistryEntry, type LaunchModeHandler, LaunchModeSchema, type LauncherConfig, type LauncherMode, LocalSource, type ManagerOptions, McpConfigManager, McpServerRefSchema, MkdirStep, MockLauncher, ModelProviderRegistry, ModelProviderSchema, type NamedComponent, NpmInstallStep, type PermissionAuditEvent, PermissionAuditLogger, PermissionPolicyEnforcer, PermissionPresetSchema, PermissionsInputSchema, PermissionsObjectSchema, type PipelineOptions, type PipelineResult, PluginManager, type PolicyAction, type PolicyDecision, type ProcessExitAction, type ProcessExitHandler, type ProcessExitInfo, ProcessLauncher, type ProcessLauncherOptions, ProcessLogWriter, type ProcessLogWriterOptions, ProcessWatcher, type ProcessWatcherOptions, type PromptAgentFn, PromptManager, type PromptResult, type RecoveryAction, type RegistryOptions, type ResolvedBackend, type RestartDecision, type RestartPolicy, RestartTracker, type RunPromptOptions, type ScheduleConfig, type ScheduleConfigInput, ScheduleConfigSchema, type SessionLease, SessionRegistry, type SessionRegistryOptions, type SessionState, SkillManager, SourceManager, type SourceManagerDeps, type SourceManagerOptions, type SourceValidationIssue, type SourceValidationReport, SourceValidator, type StepContext, StepRegistry, type StepResult, type StepValidationResult, type StreamChunk, type TaskCallback, TaskDispatcher, type TaskPriority, TaskQueue, type TaskStatus, TemplateFileWatcher, type TemplateFileWatcherOptions, TemplateLoader, TemplateRegistry, type ToolCallInfo, type ValidateOptions, type VerifyResult, WorkflowManager, type WorkspaceBuildResult, WorkspaceBuilder, createCommunicator, createDefaultStepRegistry, createLauncher, getBackendDescriptor, getLaunchModeHandler, globMatch, isAcpBackend, isAcpOnlyBackend, isProcessAlive, metaFilePath, modelProviderRegistry, openBackend, readInstanceMeta, registerBackend, registerBuiltinProviders, registerCommunicator, requireMode, resolveAcpBackend, resolveBackend, resolvePermissions, resolvePermissionsWithMcp, scanInstances, supportsMode, toAgentTemplate, updateInstanceMeta, validateBackendConfig, validateDomainContextConfig, validatePermissionsConfig, validateProviderConfig, validateScheduleConfig, validateTemplate, writeInstanceMeta };
2208
+ export { type AcpResolverFn, AgentBackendSchema, type AgentCommunicator, AgentInitializer, AgentInstanceMetaSchema, type AgentLauncher, AgentManager, type AgentProcess, AgentStatusSchema, type AgentTask, type AgentTemplateInput, type AgentTemplateOutput, AgentTemplateSchema, type AuditEntry, BUILTIN_PROVIDERS, type BackendAvailability, type BackendBuilder, BackendManager, BaseComponentManager, ClaudeCodeBuilder, ClaudeCodeCommunicator, type CommunicatorFactory, type CompatMode, ComponentOriginSchema, type ComponentSource, type ComponentTypeHandler, ContextMaterializer, type CreateSessionOptions, type CronConfig, CronConfigSchema, CronInput, CursorBuilder, CursorCommunicator, CustomBuilder, type CustomBuilderConfig, DEFAULT_RESTART_POLICY, DEFAULT_SOURCE_CONFIG, DEFAULT_SOURCE_NAME, DomainContextSchema, type DomainManagers$1 as DomainManagers, EmployeeScheduler, ExecStep, ExecutionLog, type ExecutionRecord, type FetchResult, FileCopyStep, GitCloneStep, GitHubSource, type HeartbeatConfig, HeartbeatConfigSchema, HeartbeatInput, type HookConfig, HookConfigSchema, HookInput, InitializationPipeline, type InitializerOptions, InitializerSchema, InitializerStepExecutor, InitializerStepSchema, InputRouter, type InputSource, type InstanceOverrides, InstanceRegistry, type InstanceRegistryAdapter, type InstanceRegistryData, type InstanceRegistryEntry, type LaunchModeHandler, LaunchModeSchema, type LauncherConfig, type LauncherMode, LocalSource, type ManagerOptions, McpConfigManager, McpServerRefSchema, MkdirStep, MockLauncher, ModelProviderRegistry, ModelProviderSchema, type NamedComponent, NpmInstallStep, type PermissionAuditEvent, PermissionAuditLogger, PermissionPolicyEnforcer, PermissionPresetSchema, PermissionsInputSchema, PermissionsObjectSchema, type PipelineOptions, type PipelineResult, PluginManager, type PolicyAction, type PolicyDecision, type ProcessExitAction, type ProcessExitHandler, type ProcessExitInfo, ProcessLauncher, type ProcessLauncherOptions, ProcessLogWriter, type ProcessLogWriterOptions, ProcessWatcher, type ProcessWatcherOptions, type PromptAgentFn, PromptManager, type PromptResult, type RecoveryAction, type RegistryOptions, type ResolvedBackend, type RestartDecision, type RestartPolicy, RestartTracker, type RunPromptOptions, type ScheduleConfig, type ScheduleConfigInput, ScheduleConfigSchema, type SessionLease, SessionRegistry, type SessionRegistryOptions, type SessionState, SkillManager, SourceManager, type SourceManagerDeps, type SourceManagerOptions, type SourceValidationIssue, type SourceValidationReport, SourceValidator, type StepContext, StepRegistry, type StepResult, type StepValidationResult, type StreamChunk, type TaskCallback, TaskDispatcher, type TaskPriority, TaskQueue, type TaskStatus, TemplateFileWatcher, type TemplateFileWatcherOptions, TemplateLoader, TemplateRegistry, type ToolCallInfo, type ValidateOptions, type VerifyResult, WorkflowManager, type WorkspaceBuildResult, WorkspaceBuilder, createCommunicator, createDefaultStepRegistry, createLauncher, getBackendDescriptor, getBackendManager, getInstallHint, getLaunchModeHandler, globMatch, isAcpBackend, isAcpOnlyBackend, isProcessAlive, metaFilePath, modelProviderRegistry, openBackend, readInstanceMeta, registerBackend, registerBackendDefinition, registerBuiltinProviders, registerCommunicator, requireMode, resolveAcpBackend, resolveBackend, resolvePermissions, resolvePermissionsWithMcp, scanInstances, supportsMode, toAgentTemplate, updateInstanceMeta, validateBackendConfig, validateDomainContextConfig, validatePermissionsConfig, validateProviderConfig, validateScheduleConfig, validateTemplate, writeInstanceMeta };