@actant/core 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
@@ -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, PermissionsConfig, SourceConfig, PackageManifest, PresetDefinition, GitHubSourceConfig, LocalSourceConfig, SourceEntry } from '@actant/shared';
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 } 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';
@@ -531,8 +531,10 @@ declare const DomainContextSchema: z.ZodObject<{
531
531
  declare const AgentBackendSchema: z.ZodObject<{
532
532
  type: z.ZodEnum<{
533
533
  cursor: "cursor";
534
+ "cursor-agent": "cursor-agent";
534
535
  "claude-code": "claude-code";
535
536
  custom: "custom";
537
+ pi: "pi";
536
538
  }>;
537
539
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
538
540
  }, z.core.$strip>;
@@ -541,7 +543,14 @@ declare const ModelProviderSchema: z.ZodObject<{
541
543
  custom: "custom";
542
544
  anthropic: "anthropic";
543
545
  openai: "openai";
546
+ "openai-compatible": "openai-compatible";
544
547
  }>;
548
+ protocol: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
549
+ http: "http";
550
+ websocket: "websocket";
551
+ grpc: "grpc";
552
+ }>>>;
553
+ baseUrl: z.ZodOptional<z.ZodString>;
545
554
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
546
555
  }, z.core.$strip>;
547
556
  declare const InitializerStepSchema: z.ZodObject<{
@@ -640,8 +649,10 @@ declare const AgentTemplateSchema: z.ZodObject<{
640
649
  backend: z.ZodObject<{
641
650
  type: z.ZodEnum<{
642
651
  cursor: "cursor";
652
+ "cursor-agent": "cursor-agent";
643
653
  "claude-code": "claude-code";
644
654
  custom: "custom";
655
+ pi: "pi";
645
656
  }>;
646
657
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
647
658
  }, z.core.$strip>;
@@ -650,7 +661,14 @@ declare const AgentTemplateSchema: z.ZodObject<{
650
661
  custom: "custom";
651
662
  anthropic: "anthropic";
652
663
  openai: "openai";
664
+ "openai-compatible": "openai-compatible";
653
665
  }>;
666
+ protocol: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
667
+ http: "http";
668
+ websocket: "websocket";
669
+ grpc: "grpc";
670
+ }>>>;
671
+ baseUrl: z.ZodOptional<z.ZodString>;
654
672
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
655
673
  }, z.core.$strip>;
656
674
  domainContext: z.ZodObject<{
@@ -946,6 +964,7 @@ declare class AgentInitializer {
946
964
  private readonly builder;
947
965
  private readonly pipeline?;
948
966
  constructor(templateRegistry: TemplateRegistry, instancesBaseDir: string, options?: InitializerOptions | undefined);
967
+ get workspaceBuilder(): WorkspaceBuilder;
949
968
  /**
950
969
  * Create a new Agent Instance.
951
970
  * 1. Resolve template from registry
@@ -1125,8 +1144,10 @@ declare const AgentInstanceMetaSchema: z.ZodObject<{
1125
1144
  templateVersion: z.ZodString;
1126
1145
  backendType: z.ZodDefault<z.ZodEnum<{
1127
1146
  cursor: "cursor";
1147
+ "cursor-agent": "cursor-agent";
1128
1148
  "claude-code": "claude-code";
1129
1149
  custom: "custom";
1150
+ pi: "pi";
1130
1151
  }>>;
1131
1152
  backendConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1132
1153
  status: z.ZodEnum<{
@@ -1405,10 +1426,12 @@ declare class AgentManager {
1405
1426
  created: boolean;
1406
1427
  }>;
1407
1428
  /**
1408
- * Start an agent — launch the backend process.
1409
- * For ACP backends, also establishes ACP connection (initialize + session/new).
1429
+ * Start an agent — launch the backend process via ACP.
1430
+ * Requires the backend to support "acp" mode.
1431
+ * For acpOwnsProcess backends, ProcessLauncher is skipped.
1410
1432
  * @throws {AgentNotFoundError} if agent is not in cache
1411
1433
  * @throws {AgentAlreadyRunningError} if agent is already running
1434
+ * @throws {Error} if backend does not support "acp" mode
1412
1435
  */
1413
1436
  startAgent(name: string): Promise<void>;
1414
1437
  /**
@@ -1431,6 +1454,15 @@ declare class AgentManager {
1431
1454
  * If the agent doesn't exist but templateName is provided, auto-creates it.
1432
1455
  */
1433
1456
  resolveAgent(name: string, templateName?: string, overrides?: Partial<InstanceOverrides>): Promise<ResolveResult>;
1457
+ /**
1458
+ * Open an agent's native TUI/UI (e.g. `cursor <dir>`).
1459
+ * Requires the backend to support "open" mode.
1460
+ * @throws if backend does not support "open" mode
1461
+ */
1462
+ openAgent(name: string): Promise<{
1463
+ command: string;
1464
+ args: string[];
1465
+ }>;
1434
1466
  /**
1435
1467
  * Register an externally-spawned process with the manager.
1436
1468
  * Sets processOwnership to "external" and registers ProcessWatcher monitoring.
@@ -1454,9 +1486,10 @@ declare class AgentManager {
1454
1486
  runPrompt(name: string, prompt: string, options?: RunPromptOptions): Promise<PromptResult>;
1455
1487
  /**
1456
1488
  * Send a prompt to an agent and stream the response.
1457
- * Uses ACP connection if available, otherwise falls back to CLI pipe mode.
1489
+ * Uses ACP connection if available, otherwise falls back to communicator.
1458
1490
  */
1459
1491
  streamPrompt(name: string, prompt: string, options?: RunPromptOptions): AsyncIterable<StreamChunk>;
1492
+ private streamFromAcp;
1460
1493
  /**
1461
1494
  * Send a message to a running agent via its ACP session.
1462
1495
  * Unlike runPrompt, this requires the agent to be started with ACP.
@@ -1603,13 +1636,51 @@ interface ResolvedBackend {
1603
1636
  command: string;
1604
1637
  args: string[];
1605
1638
  }
1606
- /** Whether a backend type uses the ACP stdio protocol for communication. */
1639
+ /**
1640
+ * Whether a backend type supports the ACP protocol for Actant-managed control.
1641
+ * Replaces the old hardcoded `isAcpBackend()`.
1642
+ */
1607
1643
  declare function isAcpBackend(backendType: AgentBackendType): boolean;
1608
1644
  /**
1609
- * Resolve the executable command and arguments for a given backend type.
1610
- * Supports explicit override via `backendConfig.executablePath` and `backendConfig.args`.
1645
+ * Whether a backend's ACP connection owns the process lifecycle.
1646
+ * When true, ProcessLauncher.launch() is skipped only AcpConnectionManager spawns the process.
1647
+ */
1648
+ declare function isAcpOnlyBackend(backendType: AgentBackendType): boolean;
1649
+ /**
1650
+ * Resolve the executable command and arguments for spawning a backend (resolve mode).
1651
+ * @throws if the backend does not support "resolve" mode.
1611
1652
  */
1612
1653
  declare function resolveBackend(backendType: AgentBackendType, workspaceDir: string, backendConfig?: Record<string, unknown>): ResolvedBackend;
1654
+ /**
1655
+ * Resolve the open command for directly launching a backend's native TUI/UI.
1656
+ * @throws if the backend does not support "open" mode.
1657
+ */
1658
+ declare function openBackend(backendType: AgentBackendType, workspaceDir: string): ResolvedBackend;
1659
+ /**
1660
+ * Resolve the ACP spawn command for a backend.
1661
+ * For ACP backends, this returns the command used by AcpConnectionManager to spawn the agent process.
1662
+ * Checks acpCommand first, then falls back to resolveCommand.
1663
+ * @throws if the backend does not support "acp" mode.
1664
+ */
1665
+ declare function resolveAcpBackend(backendType: AgentBackendType, workspaceDir: string, backendConfig?: Record<string, unknown>): ResolvedBackend;
1666
+
1667
+ /**
1668
+ * Register a backend descriptor.
1669
+ * Call at startup for built-in backends and from external packages (e.g. @actant/pi).
1670
+ */
1671
+ declare function registerBackend(descriptor: BackendDescriptor): void;
1672
+ /**
1673
+ * Retrieve the descriptor for a backend type.
1674
+ * @throws if the type has not been registered.
1675
+ */
1676
+ declare function getBackendDescriptor(type: AgentBackendType): BackendDescriptor;
1677
+ /** Check whether a backend supports a specific open mode. */
1678
+ declare function supportsMode(type: AgentBackendType, mode: AgentOpenMode): boolean;
1679
+ /**
1680
+ * Assert that a backend supports a mode, throwing a descriptive error if not.
1681
+ * Used as a guard in manager methods before executing mode-specific logic.
1682
+ */
1683
+ declare function requireMode(type: AgentBackendType, mode: AgentOpenMode): void;
1613
1684
 
1614
1685
  /**
1615
1686
  * Check whether a process with the given PID is still alive.
@@ -1679,7 +1750,14 @@ declare class CursorCommunicator implements AgentCommunicator {
1679
1750
  streamPrompt(_workspaceDir: string, _prompt: string, _options?: RunPromptOptions): AsyncIterable<StreamChunk>;
1680
1751
  }
1681
1752
 
1682
- declare function createCommunicator(backendType: AgentBackendType): AgentCommunicator;
1753
+ /**
1754
+ * Register a communicator factory for a backend type.
1755
+ * External packages (e.g. @actant/pi) call this at startup.
1756
+ * The factory receives the template's `backend.config` so it can extract
1757
+ * provider-specific settings (provider, model, apiKey, etc.).
1758
+ */
1759
+ declare function registerCommunicator(backendType: AgentBackendType, factory: (backendConfig?: Record<string, unknown>) => AgentCommunicator): void;
1760
+ declare function createCommunicator(backendType: AgentBackendType, backendConfig?: Record<string, unknown>): AgentCommunicator;
1683
1761
 
1684
1762
  declare function resolvePermissions(input: PermissionsInput | undefined): PermissionsConfig;
1685
1763
  declare function resolvePermissionsWithMcp(input: PermissionsInput | undefined, mcpServerNames: string[]): PermissionsConfig;
@@ -1925,6 +2003,10 @@ interface SourceManagerDeps {
1925
2003
  * Manages component sources (GitHub repos, local dirs, etc.).
1926
2004
  * Syncs remote components into the domain managers with `package@name` namespacing.
1927
2005
  */
2006
+ interface SourceManagerOptions {
2007
+ /** Skip auto-registration of the default actant-hub source (useful for tests). */
2008
+ skipDefaultSource?: boolean;
2009
+ }
1928
2010
  declare class SourceManager {
1929
2011
  private readonly sources;
1930
2012
  private readonly presets;
@@ -1932,7 +2014,8 @@ declare class SourceManager {
1932
2014
  private readonly homeDir;
1933
2015
  private readonly sourcesFilePath;
1934
2016
  private readonly cacheDir;
1935
- constructor(homeDir: string, managers: SourceManagerDeps);
2017
+ private readonly skipDefaultSource;
2018
+ constructor(homeDir: string, managers: SourceManagerDeps, options?: SourceManagerOptions);
1936
2019
  addSource(name: string, config: SourceConfig): Promise<FetchResult>;
1937
2020
  syncSource(name: string): Promise<FetchResult>;
1938
2021
  syncSourceWithReport(name: string): Promise<{
@@ -1955,6 +2038,11 @@ declare class SourceManager {
1955
2038
  */
1956
2039
  applyPreset(qualifiedName: string, template: AgentTemplate): AgentTemplate;
1957
2040
  initialize(): Promise<void>;
2041
+ /**
2042
+ * Registers the official actant-hub as the default source if not already present.
2043
+ * Fails silently when offline or the repo is unreachable.
2044
+ */
2045
+ private ensureDefaultSource;
1958
2046
  private createSource;
1959
2047
  private injectComponents;
1960
2048
  private removeNamespacedComponents;
@@ -1965,4 +2053,4 @@ declare class SourceManager {
1965
2053
  private buildSyncReport;
1966
2054
  }
1967
2055
 
1968
- export { AgentBackendSchema, type AgentCommunicator, AgentInitializer, AgentInstanceMetaSchema, type AgentLauncher, AgentManager, type AgentProcess, AgentStatusSchema, type AgentTask, type AgentTemplateInput, type AgentTemplateOutput, AgentTemplateSchema, type AuditEntry, type BackendBuilder, BaseComponentManager, ClaudeCodeBuilder, ClaudeCodeCommunicator, type CommunicatorFactory, 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, 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 StepContext, StepRegistry, type StepResult, type StepValidationResult, type StreamChunk, type TaskCallback, TaskDispatcher, type TaskPriority, TaskQueue, type TaskStatus, TemplateFileWatcher, type TemplateFileWatcherOptions, TemplateLoader, TemplateRegistry, type ToolCallInfo, type VerifyResult, WorkflowManager, type WorkspaceBuildResult, WorkspaceBuilder, createCommunicator, createDefaultStepRegistry, createLauncher, getLaunchModeHandler, globMatch, isAcpBackend, isProcessAlive, metaFilePath, readInstanceMeta, resolveBackend, resolvePermissions, resolvePermissionsWithMcp, scanInstances, toAgentTemplate, updateInstanceMeta, validateBackendConfig, validateDomainContextConfig, validatePermissionsConfig, validateProviderConfig, validateScheduleConfig, validateTemplate, writeInstanceMeta };
2056
+ export { AgentBackendSchema, type AgentCommunicator, AgentInitializer, AgentInstanceMetaSchema, type AgentLauncher, AgentManager, type AgentProcess, AgentStatusSchema, type AgentTask, type AgentTemplateInput, type AgentTemplateOutput, AgentTemplateSchema, type AuditEntry, type BackendBuilder, BaseComponentManager, ClaudeCodeBuilder, ClaudeCodeCommunicator, type CommunicatorFactory, 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, 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 StepContext, StepRegistry, type StepResult, type StepValidationResult, type StreamChunk, type TaskCallback, TaskDispatcher, type TaskPriority, TaskQueue, type TaskStatus, TemplateFileWatcher, type TemplateFileWatcherOptions, TemplateLoader, TemplateRegistry, type ToolCallInfo, type VerifyResult, WorkflowManager, type WorkspaceBuildResult, WorkspaceBuilder, createCommunicator, createDefaultStepRegistry, createLauncher, getBackendDescriptor, getLaunchModeHandler, globMatch, isAcpBackend, isAcpOnlyBackend, isProcessAlive, metaFilePath, openBackend, readInstanceMeta, registerBackend, registerCommunicator, requireMode, resolveAcpBackend, resolveBackend, resolvePermissions, resolvePermissionsWithMcp, scanInstances, supportsMode, toAgentTemplate, updateInstanceMeta, validateBackendConfig, validateDomainContextConfig, validatePermissionsConfig, validateProviderConfig, validateScheduleConfig, validateTemplate, writeInstanceMeta };