@a5c-ai/agent-comm-mux 5.0.1-staging.04ca6ab00d21
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/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/adapter-registry.d.ts +51 -0
- package/dist/adapter-registry.d.ts.map +1 -0
- package/dist/adapter-registry.js +208 -0
- package/dist/adapter-registry.js.map +1 -0
- package/dist/adapter-types.d.ts +164 -0
- package/dist/adapter-types.d.ts.map +1 -0
- package/dist/adapter-types.js +27 -0
- package/dist/adapter-types.js.map +1 -0
- package/dist/adapter.d.ts +248 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +18 -0
- package/dist/adapter.js.map +1 -0
- package/dist/atomic-fs.d.ts +33 -0
- package/dist/atomic-fs.d.ts.map +1 -0
- package/dist/atomic-fs.js +190 -0
- package/dist/atomic-fs.js.map +1 -0
- package/dist/auth-manager.d.ts +37 -0
- package/dist/auth-manager.d.ts.map +1 -0
- package/dist/auth-manager.js +94 -0
- package/dist/auth-manager.js.map +1 -0
- package/dist/auth-types.d.ts +83 -0
- package/dist/auth-types.d.ts.map +1 -0
- package/dist/auth-types.js +10 -0
- package/dist/auth-types.js.map +1 -0
- package/dist/automation.d.ts +104 -0
- package/dist/automation.d.ts.map +1 -0
- package/dist/automation.js +2 -0
- package/dist/automation.js.map +1 -0
- package/dist/browser.d.ts +5 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -0
- package/dist/builtin-hooks.d.ts +24 -0
- package/dist/builtin-hooks.d.ts.map +1 -0
- package/dist/builtin-hooks.js +80 -0
- package/dist/builtin-hooks.js.map +1 -0
- package/dist/capabilities.d.ts +251 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +7 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/client.d.ts +118 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +316 -0
- package/dist/client.js.map +1 -0
- package/dist/config-manager.d.ts +85 -0
- package/dist/config-manager.d.ts.map +1 -0
- package/dist/config-manager.js +202 -0
- package/dist/config-manager.js.map +1 -0
- package/dist/config-types.d.ts +134 -0
- package/dist/config-types.d.ts.map +1 -0
- package/dist/config-types.js +10 -0
- package/dist/config-types.js.map +1 -0
- package/dist/cost-utils.d.ts +31 -0
- package/dist/cost-utils.d.ts.map +1 -0
- package/dist/cost-utils.js +69 -0
- package/dist/cost-utils.js.map +1 -0
- package/dist/errors.d.ts +50 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +85 -0
- package/dist/errors.js.map +1 -0
- package/dist/events-control.d.ts +91 -0
- package/dist/events-control.d.ts.map +1 -0
- package/dist/events-control.js +8 -0
- package/dist/events-control.js.map +1 -0
- package/dist/events.d.ts +285 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +8 -0
- package/dist/events.js.map +1 -0
- package/dist/hook-catalog.d.ts +20 -0
- package/dist/hook-catalog.d.ts.map +1 -0
- package/dist/hook-catalog.js +63 -0
- package/dist/hook-catalog.js.map +1 -0
- package/dist/hook-dispatcher.d.ts +24 -0
- package/dist/hook-dispatcher.d.ts.map +1 -0
- package/dist/hook-dispatcher.js +91 -0
- package/dist/hook-dispatcher.js.map +1 -0
- package/dist/hook-payload.d.ts +24 -0
- package/dist/hook-payload.d.ts.map +1 -0
- package/dist/hook-payload.js +62 -0
- package/dist/hook-payload.js.map +1 -0
- package/dist/hooks.d.ts +59 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +118 -0
- package/dist/hooks.js.map +1 -0
- package/dist/host-detection.d.ts +67 -0
- package/dist/host-detection.d.ts.map +1 -0
- package/dist/host-detection.js +147 -0
- package/dist/host-detection.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction-channel-impl.d.ts +56 -0
- package/dist/interaction-channel-impl.d.ts.map +1 -0
- package/dist/interaction-channel-impl.js +159 -0
- package/dist/interaction-channel-impl.js.map +1 -0
- package/dist/interaction.d.ts +93 -0
- package/dist/interaction.d.ts.map +1 -0
- package/dist/interaction.js +8 -0
- package/dist/interaction.js.map +1 -0
- package/dist/invocation.d.ts +100 -0
- package/dist/invocation.d.ts.map +1 -0
- package/dist/invocation.js +17 -0
- package/dist/invocation.js.map +1 -0
- package/dist/kanban.d.ts +894 -0
- package/dist/kanban.d.ts.map +1 -0
- package/dist/kanban.js +1155 -0
- package/dist/kanban.js.map +1 -0
- package/dist/merge.d.ts +37 -0
- package/dist/merge.d.ts.map +1 -0
- package/dist/merge.js +102 -0
- package/dist/merge.js.map +1 -0
- package/dist/model-registry.d.ts +61 -0
- package/dist/model-registry.d.ts.map +1 -0
- package/dist/model-registry.js +198 -0
- package/dist/model-registry.js.map +1 -0
- package/dist/plugin-manager-impl.d.ts +48 -0
- package/dist/plugin-manager-impl.d.ts.map +1 -0
- package/dist/plugin-manager-impl.js +343 -0
- package/dist/plugin-manager-impl.js.map +1 -0
- package/dist/plugin-manager.d.ts +81 -0
- package/dist/plugin-manager.d.ts.map +1 -0
- package/dist/plugin-manager.js +7 -0
- package/dist/plugin-manager.js.map +1 -0
- package/dist/plugin-types.d.ts +114 -0
- package/dist/plugin-types.d.ts.map +1 -0
- package/dist/plugin-types.js +7 -0
- package/dist/plugin-types.js.map +1 -0
- package/dist/process-tracker.d.ts +20 -0
- package/dist/process-tracker.d.ts.map +1 -0
- package/dist/process-tracker.js +96 -0
- package/dist/process-tracker.js.map +1 -0
- package/dist/profiles.d.ts +99 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +231 -0
- package/dist/profiles.js.map +1 -0
- package/dist/programmatic-runner.d.ts +4 -0
- package/dist/programmatic-runner.d.ts.map +1 -0
- package/dist/programmatic-runner.js +110 -0
- package/dist/programmatic-runner.js.map +1 -0
- package/dist/provider-config.d.ts +40 -0
- package/dist/provider-config.d.ts.map +1 -0
- package/dist/provider-config.js +67 -0
- package/dist/provider-config.js.map +1 -0
- package/dist/provider-profiles.d.ts +47 -0
- package/dist/provider-profiles.d.ts.map +1 -0
- package/dist/provider-profiles.js +117 -0
- package/dist/provider-profiles.js.map +1 -0
- package/dist/provider-resolver.d.ts +15 -0
- package/dist/provider-resolver.d.ts.map +1 -0
- package/dist/provider-resolver.js +114 -0
- package/dist/provider-resolver.js.map +1 -0
- package/dist/provider-support-matrix.d.ts +12 -0
- package/dist/provider-support-matrix.d.ts.map +1 -0
- package/dist/provider-support-matrix.js +88 -0
- package/dist/provider-support-matrix.js.map +1 -0
- package/dist/remote-runner.d.ts +4 -0
- package/dist/remote-runner.d.ts.map +1 -0
- package/dist/remote-runner.js +114 -0
- package/dist/remote-runner.js.map +1 -0
- package/dist/retry.d.ts +13 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +17 -0
- package/dist/retry.js.map +1 -0
- package/dist/run-handle-cost.d.ts +36 -0
- package/dist/run-handle-cost.d.ts.map +1 -0
- package/dist/run-handle-cost.js +62 -0
- package/dist/run-handle-cost.js.map +1 -0
- package/dist/run-handle-impl.d.ts +144 -0
- package/dist/run-handle-impl.d.ts.map +1 -0
- package/dist/run-handle-impl.js +695 -0
- package/dist/run-handle-impl.js.map +1 -0
- package/dist/run-handle.d.ts +222 -0
- package/dist/run-handle.d.ts.map +1 -0
- package/dist/run-handle.js +9 -0
- package/dist/run-handle.js.map +1 -0
- package/dist/run-options-validation.d.ts +23 -0
- package/dist/run-options-validation.d.ts.map +1 -0
- package/dist/run-options-validation.js +234 -0
- package/dist/run-options-validation.js.map +1 -0
- package/dist/run-options.d.ts +128 -0
- package/dist/run-options.d.ts.map +1 -0
- package/dist/run-options.js +329 -0
- package/dist/run-options.js.map +1 -0
- package/dist/runtime-hook-dispatcher.d.ts +19 -0
- package/dist/runtime-hook-dispatcher.d.ts.map +1 -0
- package/dist/runtime-hook-dispatcher.js +50 -0
- package/dist/runtime-hook-dispatcher.js.map +1 -0
- package/dist/runtime-hooks.d.ts +47 -0
- package/dist/runtime-hooks.d.ts.map +1 -0
- package/dist/runtime-hooks.js +2 -0
- package/dist/runtime-hooks.js.map +1 -0
- package/dist/schema/__tests__/event-schema.test.d.ts +1 -0
- package/dist/schema/__tests__/event-schema.test.d.ts.map +1 -0
- package/dist/schema/__tests__/event-schema.test.js +480 -0
- package/dist/schema/__tests__/event-schema.test.js.map +1 -0
- package/dist/schema/event-schema.d.ts +120 -0
- package/dist/schema/event-schema.d.ts.map +1 -0
- package/dist/schema/event-schema.js +546 -0
- package/dist/schema/event-schema.js.map +1 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +49 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/session-manager-helpers.d.ts +33 -0
- package/dist/session-manager-helpers.d.ts.map +1 -0
- package/dist/session-manager-helpers.js +66 -0
- package/dist/session-manager-helpers.js.map +1 -0
- package/dist/session-manager.d.ts +70 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/session-manager.js +343 -0
- package/dist/session-manager.js.map +1 -0
- package/dist/session-types.d.ts +358 -0
- package/dist/session-types.d.ts.map +1 -0
- package/dist/session-types.js +10 -0
- package/dist/session-types.js.map +1 -0
- package/dist/spawn-invocation.d.ts +52 -0
- package/dist/spawn-invocation.d.ts.map +1 -0
- package/dist/spawn-invocation.js +218 -0
- package/dist/spawn-invocation.js.map +1 -0
- package/dist/spawn-runner-utils.d.ts +21 -0
- package/dist/spawn-runner-utils.d.ts.map +1 -0
- package/dist/spawn-runner-utils.js +102 -0
- package/dist/spawn-runner-utils.js.map +1 -0
- package/dist/spawn-runner.d.ts +21 -0
- package/dist/spawn-runner.d.ts.map +1 -0
- package/dist/spawn-runner.js +576 -0
- package/dist/spawn-runner.js.map +1 -0
- package/dist/spawn-runtime-hooks.d.ts +15 -0
- package/dist/spawn-runtime-hooks.d.ts.map +1 -0
- package/dist/spawn-runtime-hooks.js +136 -0
- package/dist/spawn-runtime-hooks.js.map +1 -0
- package/dist/state-machine.d.ts +33 -0
- package/dist/state-machine.d.ts.map +1 -0
- package/dist/state-machine.js +61 -0
- package/dist/state-machine.js.map +1 -0
- package/dist/storage.d.ts +47 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +90 -0
- package/dist/storage.js.map +1 -0
- package/dist/stream-assembler.d.ts +51 -0
- package/dist/stream-assembler.d.ts.map +1 -0
- package/dist/stream-assembler.js +86 -0
- package/dist/stream-assembler.js.map +1 -0
- package/dist/tools/classify.d.ts +9 -0
- package/dist/tools/classify.d.ts.map +1 -0
- package/dist/tools/classify.js +77 -0
- package/dist/tools/classify.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types.d.ts +288 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/workspaces.d.ts +142 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +515 -0
- package/dist/workspaces.js.map +1 -0
- package/package.json +107 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @a5c-ai/agent-comm-mux
|
|
3
|
+
*
|
|
4
|
+
* Core runtime, types, and utilities for agent-mux.
|
|
5
|
+
* Runtime deps: @a5c-ai/agent-catalog and @a5c-ai/agent-mux-observability.
|
|
6
|
+
*/
|
|
7
|
+
// Errors
|
|
8
|
+
export { AgentMuxError, CapabilityError, ValidationError, AuthError, } from './errors.js';
|
|
9
|
+
export { DEFAULT_RETRY_POLICY } from './retry.js';
|
|
10
|
+
export { resolveStoragePaths } from './storage.js';
|
|
11
|
+
export { WorkspaceService, resolveWorkspaceDefaultCwd } from './workspaces.js';
|
|
12
|
+
export { sumCost, sumCostAsync, filterEvents, filterEventsAsync, } from './cost-utils.js';
|
|
13
|
+
export { TERMINAL_STATES, VALID_TRANSITIONS, isTerminal, assertTransition, } from './state-machine.js';
|
|
14
|
+
// Interaction channel implementation
|
|
15
|
+
export { InteractionChannelImpl } from './interaction-channel-impl.js';
|
|
16
|
+
// RunHandle implementation
|
|
17
|
+
export { RunHandleImpl } from './run-handle-impl.js';
|
|
18
|
+
export { processTracker } from './process-tracker.js';
|
|
19
|
+
export { HARNESS_IMAGE_CATALOG, lookupHarnessImage } from './invocation.js';
|
|
20
|
+
export { buildInvocationCommand } from './spawn-runner.js';
|
|
21
|
+
export { validateRunOptions, PROHIBITED_PROFILE_FIELDS, validateProfileData, } from './run-options.js';
|
|
22
|
+
export { RuntimeHookDispatcher, RuntimeHookDispatcher as PerRunRuntimeHookDispatcher } from './runtime-hook-dispatcher.js';
|
|
23
|
+
export { classifyTool } from './tools/index.js';
|
|
24
|
+
// Merge
|
|
25
|
+
export { deepMerge, stripUndefined, resolveRunOptions } from './merge.js';
|
|
26
|
+
export { ProfileManagerImpl } from './profiles.js';
|
|
27
|
+
export { StreamAssembler } from './stream-assembler.js';
|
|
28
|
+
export { normalizeKanbanIssue, resolveKanbanWorkflowState, resolveKanbanSwimlane, resolveKanbanStatusForWorkflowState, summarizeKanbanReviewArtifact, evaluateKanbanIssueMove, computeKanbanProjectMetrics, buildKanbanBacklogSnapshot, buildKanbanProjectBoard, buildKanbanBoardSnapshot, upsertKanbanProjectRepository, updateKanbanProjectRepositorySettings, linkKanbanIssueRepository, createKanbanIssuePullRequest, } from './kanban.js';
|
|
29
|
+
export { AdapterRegistryImpl } from './adapter-registry.js';
|
|
30
|
+
export { ModelRegistryImpl } from './model-registry.js';
|
|
31
|
+
export { SessionManagerImpl } from './session-manager.js';
|
|
32
|
+
export { ConfigManagerImpl } from './config-manager.js';
|
|
33
|
+
export { AuthManagerImpl } from './auth-manager.js';
|
|
34
|
+
export { PluginManagerImpl } from './plugin-manager-impl.js';
|
|
35
|
+
export { detectHostHarness, DEFAULT_HOST_SIGNALS, DEFAULT_HOST_METADATA } from './host-detection.js';
|
|
36
|
+
export { AgentMuxClient, createClient } from './client.js';
|
|
37
|
+
export { HookConfigManager } from './hooks.js';
|
|
38
|
+
export { BuiltInHooksRegistry, builtInHooks } from './builtin-hooks.js';
|
|
39
|
+
export { HookDispatcher } from './hook-dispatcher.js';
|
|
40
|
+
export { HOOK_CATALOG, getHookCatalog, isKnownHookType } from './hook-catalog.js';
|
|
41
|
+
export { parseHookPayload, formatHookResult } from './hook-payload.js';
|
|
42
|
+
export { writeFileAtomic, writeJsonAtomic } from './atomic-fs.js';
|
|
43
|
+
export { PROVIDER_DEFAULTS, translateModelId, MODEL_TRANSLATION_TABLE } from './provider-config.js';
|
|
44
|
+
export { resolveProvider } from './provider-resolver.js';
|
|
45
|
+
export { resolveProvidersFilePath, loadProvidersFile, writeProvidersFile, upsertProviderProfile, updateProviderDefaults, loadProfile, loadProviderDefaults } from './provider-profiles.js';
|
|
46
|
+
// Provider support matrix
|
|
47
|
+
export { isNativelySupported, getNativeMechanism, getRequiredProxyTransport, getHarnessDefaultTransport, isTransportCompatible } from './provider-support-matrix.js';
|
|
48
|
+
// Event schemas (TypeBox JSON Schema definitions for all 67 event types)
|
|
49
|
+
export * as schema from './schema/index.js';
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH,SAAS;AACT,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,SAAS,GACV,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIlD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAkBnD,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AA+E/E,OAAO,EACL,OAAO,EACP,YAAY,EACZ,YAAY,E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pl — concrete implementation of InteractionChannel.
|
|
3
|
+
*
|
|
4
|
+
* Maintains a pending queue of interactions, fires onPending callbacks,
|
|
5
|
+
* and performs auto-resolution for 'yolo' and 'deny' approval modes.
|
|
6
|
+
*/
|
|
7
|
+
import type { InteractionChannel, PendingInteraction, InteractionResponse } from './interaction.js';
|
|
8
|
+
import type { ApprovalRequestEvent, InputRequiredEvent } from './events.js';
|
|
9
|
+
export declare class InteractionChannelImpl implements InteractionChannel {
|
|
10
|
+
/** Currently pending interactions, in arrival order. */
|
|
11
|
+
private _pending;
|
|
12
|
+
/** Registered onPending handlers. */
|
|
13
|
+
private _handlers;
|
|
14
|
+
/**
|
|
15
|
+
* Response dispatcher injected by RunHandleImpl.
|
|
16
|
+
* Called when the consumer responds to an interaction; the run handle
|
|
17
|
+
* is responsible for writing the response to the agent subprocess.
|
|
18
|
+
*/
|
|
19
|
+
private _dispatch;
|
|
20
|
+
/** Whether the run is still active. Set to false when the run terminates. */
|
|
21
|
+
private _active;
|
|
22
|
+
/** Approval mode for auto-resolution. */
|
|
23
|
+
private readonly _approvalMode;
|
|
24
|
+
constructor(approvalMode?: 'yolo' | 'prompt' | 'deny');
|
|
25
|
+
get pending(): PendingInteraction[];
|
|
26
|
+
onPending(handler: (interaction: PendingInteraction) => void): () => void;
|
|
27
|
+
respond(id: string, response: InteractionResponse): Promise<void>;
|
|
28
|
+
approveAll(): Promise<void>;
|
|
29
|
+
denyAll(reason?: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Inject the response dispatcher. Called by RunHandleImpl during construction.
|
|
32
|
+
*/
|
|
33
|
+
setDispatch(dispatch: (id: string, response: InteractionResponse) => Promise<void>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Mark the run as terminated. Clears pending interactions (they expire).
|
|
36
|
+
*/
|
|
37
|
+
terminate(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Handle an incoming approval_request event.
|
|
40
|
+
*
|
|
41
|
+
* If approvalMode is 'yolo', auto-approves without queuing.
|
|
42
|
+
* If approvalMode is 'deny', auto-denies without queuing.
|
|
43
|
+
* Otherwise, queues to pending and fires onPending handlers.
|
|
44
|
+
*
|
|
45
|
+
* @returns Whether the interaction was auto-resolved (true = handled internally).
|
|
46
|
+
*/
|
|
47
|
+
handleApprovalRequest(event: ApprovalRequestEvent): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Handle an incoming input_required event.
|
|
50
|
+
*
|
|
51
|
+
* Input interactions are always queued regardless of approvalMode.
|
|
52
|
+
* (approvalMode only affects approval-type interactions.)
|
|
53
|
+
*/
|
|
54
|
+
handleInputRequired(event: InputRequiredEvent): void;
|
|
55
|
+
private _addPending;
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction-channel-impl.d.ts","sourceRoot":"","sources":["../src/interaction-channel-impl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EAGpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAM5E,qBAAa,sBAAuB,YAAW,kBAAkB;IAC/D,wDAAwD;IACxD,OAAO,CAAC,QAAQ,CAA4B;IAE5C,qCAAqC;IACrC,OAAO,CAAC,SAAS,CAAqD;IAEtE;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAA+E;IAEhG,6EAA6E;IAC7E,OAAO,CAAC,OAAO,CAAQ;IAEvB,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;gBAE/C,YAAY,GAAE,MAAM,GAAG,QAAQ,GAAG,MAAiB;IAM/D,IAAI,OAAO,IAAI,kBAAkB,EAAE,CAElC;IAED,SAAS,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,kBAAkB,KAAK,IAAI,GAAG,MAAM,IAAI;IAQnE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBjE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3B,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7C;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAIzF;;OAEG;IACH,SAAS,IAAI,IAAI;IAKjB;;;;;;;;OAQG;IACH,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAoC3D;;;;;OAKG;IACH,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAoBpD,OAAO,CAAC,WAAW;CAUpB"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InteractionChannelImpl — concrete implementation of InteractionChannel.
|
|
3
|
+
*
|
|
4
|
+
* Maintains a pending queue of interactions, fires onPending callbacks,
|
|
5
|
+
* and performs auto-resolution for 'yolo' and 'deny' approval modes.
|
|
6
|
+
*/
|
|
7
|
+
import { AgentMuxError } from './errors.js';
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// InteractionChannelImpl
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
export class InteractionChannelImpl {
|
|
12
|
+
/** Currently pending interactions, in arrival order. */
|
|
13
|
+
_pending = [];
|
|
14
|
+
/** Registered onPending handlers. */
|
|
15
|
+
_handlers = [];
|
|
16
|
+
/**
|
|
17
|
+
* Response dispatcher injected by RunHandleImpl.
|
|
18
|
+
* Called when the consumer responds to an interaction; the run handle
|
|
19
|
+
* is responsible for writing the response to the agent subprocess.
|
|
20
|
+
*/
|
|
21
|
+
_dispatch = null;
|
|
22
|
+
/** Whether the run is still active. Set to false when the run terminates. */
|
|
23
|
+
_active = true;
|
|
24
|
+
/** Approval mode for auto-resolution. */
|
|
25
|
+
_approvalMode;
|
|
26
|
+
constructor(approvalMode = 'prompt') {
|
|
27
|
+
this._approvalMode = approvalMode;
|
|
28
|
+
}
|
|
29
|
+
// ── InteractionChannel interface ─────────────────────────────────────────
|
|
30
|
+
get pending() {
|
|
31
|
+
return [...this._pending];
|
|
32
|
+
}
|
|
33
|
+
onPending(handler) {
|
|
34
|
+
this._handlers.push(handler);
|
|
35
|
+
return () => {
|
|
36
|
+
const idx = this._handlers.indexOf(handler);
|
|
37
|
+
if (idx !== -1)
|
|
38
|
+
this._handlers.splice(idx, 1);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async respond(id, response) {
|
|
42
|
+
if (!this._active) {
|
|
43
|
+
throw new AgentMuxError('RUN_NOT_ACTIVE', 'Cannot respond to an interaction after the run has terminated', false);
|
|
44
|
+
}
|
|
45
|
+
const idx = this._pending.findIndex((p) => p.id === id);
|
|
46
|
+
if (idx === -1) {
|
|
47
|
+
throw new AgentMuxError('INTERACTION_NOT_FOUND', `No pending interaction with id '${id}'`, false);
|
|
48
|
+
}
|
|
49
|
+
// Remove from pending before dispatching (prevents double-response).
|
|
50
|
+
this._pending.splice(idx, 1);
|
|
51
|
+
if (this._dispatch) {
|
|
52
|
+
await this._dispatch(id, response);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async approveAll() {
|
|
56
|
+
const approvals = this._pending.filter((p) => p.type === 'approval');
|
|
57
|
+
for (const interaction of approvals) {
|
|
58
|
+
await this.respond(interaction.id, { type: 'approve' });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async denyAll(reason) {
|
|
62
|
+
const approvals = this._pending.filter((p) => p.type === 'approval');
|
|
63
|
+
for (const interaction of approvals) {
|
|
64
|
+
await this.respond(interaction.id, { type: 'deny', reason });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// ── Internal methods (called by RunHandleImpl) ────────────────────────────
|
|
68
|
+
/**
|
|
69
|
+
* Inject the response dispatcher. Called by RunHandleImpl during construction.
|
|
70
|
+
*/
|
|
71
|
+
setDispatch(dispatch) {
|
|
72
|
+
this._dispatch = dispatch;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Mark the run as terminated. Clears pending interactions (they expire).
|
|
76
|
+
*/
|
|
77
|
+
terminate() {
|
|
78
|
+
this._active = false;
|
|
79
|
+
this._pending = [];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Handle an incoming approval_request event.
|
|
83
|
+
*
|
|
84
|
+
* If approvalMode is 'yolo', auto-approves without queuing.
|
|
85
|
+
* If approvalMode is 'deny', auto-denies without queuing.
|
|
86
|
+
* Otherwise, queues to pending and fires onPending handlers.
|
|
87
|
+
*
|
|
88
|
+
* @returns Whether the interaction was auto-resolved (true = handled internally).
|
|
89
|
+
*/
|
|
90
|
+
handleApprovalRequest(event) {
|
|
91
|
+
if (this._approvalMode === 'yolo') {
|
|
92
|
+
// Auto-approve — do not queue, caller should emit approval_granted
|
|
93
|
+
if (this._dispatch) {
|
|
94
|
+
void this._dispatch(event.interactionId, { type: 'approve' });
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
if (this._approvalMode === 'deny') {
|
|
99
|
+
// Auto-deny — do not queue, caller should emit approval_denied
|
|
100
|
+
if (this._dispatch) {
|
|
101
|
+
void this._dispatch(event.interactionId, { type: 'deny' });
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
// 'prompt' mode — queue it
|
|
106
|
+
const detail = {
|
|
107
|
+
kind: 'approval',
|
|
108
|
+
action: event.action,
|
|
109
|
+
toolName: event.toolName,
|
|
110
|
+
riskLevel: event.riskLevel,
|
|
111
|
+
};
|
|
112
|
+
const interaction = {
|
|
113
|
+
id: event.interactionId,
|
|
114
|
+
type: 'approval',
|
|
115
|
+
runId: event.runId,
|
|
116
|
+
description: event.detail,
|
|
117
|
+
detail,
|
|
118
|
+
createdAt: event.timestamp,
|
|
119
|
+
};
|
|
120
|
+
this._addPending(interaction);
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Handle an incoming input_required event.
|
|
125
|
+
*
|
|
126
|
+
* Input interactions are always queued regardless of approvalMode.
|
|
127
|
+
* (approvalMode only affects approval-type interactions.)
|
|
128
|
+
*/
|
|
129
|
+
handleInputRequired(event) {
|
|
130
|
+
const detail = {
|
|
131
|
+
kind: 'input',
|
|
132
|
+
question: event.question,
|
|
133
|
+
context: event.context,
|
|
134
|
+
source: event.source,
|
|
135
|
+
};
|
|
136
|
+
const interaction = {
|
|
137
|
+
id: event.interactionId,
|
|
138
|
+
type: 'input',
|
|
139
|
+
runId: event.runId,
|
|
140
|
+
description: event.question,
|
|
141
|
+
detail,
|
|
142
|
+
createdAt: event.timestamp,
|
|
143
|
+
};
|
|
144
|
+
this._addPending(interaction);
|
|
145
|
+
}
|
|
146
|
+
// ── Private helpers ───────────────────────────────────────────────────────
|
|
147
|
+
_addPending(interaction) {
|
|
148
|
+
this._pending.push(interaction);
|
|
149
|
+
for (const handler of this._handlers) {
|
|
150
|
+
try {
|
|
151
|
+
handler(interaction);
|
|
152
|
+
}
|
|
153
|
+
catch (_err) {
|
|
154
|
+
// Swallow handler errors — they must not disrupt the interaction pipeline.
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=interaction-channel-impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction-channel-impl.js","sourceRoot":"","sources":["../src/interaction-channel-impl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAU5C,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E,MAAM,OAAO,sBAAsB;IACjC,wDAAwD;IAChD,QAAQ,GAAyB,EAAE,CAAC;IAE5C,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AC,QAAQ;YAC3B,MAAM;YACN,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC;IAED,6EAA6E;IAErE,WAAW,CAAC,WAA+B;QACjD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAChC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACrC,IAAI,CAAC;gBACH,OAAO,CAAC,WAAW,CAAC,CAAC;YACvB,CAAC;YAAC,OAAO,IAAI,EAAE,CAAC;gBACd,2EAA2E;YAC7E,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InteractionChannel types for @a5c-ai/agent-mux.
|
|
3
|
+
*
|
|
4
|
+
* Defines the queue-based interaction handler for pending agent requests
|
|
5
|
+
* (approval requests and input prompts), and associated response types.
|
|
6
|
+
*/
|
|
7
|
+
export interface ApprovalDetail {
|
|
8
|
+
readonly kind: 'approval';
|
|
9
|
+
readonly action: string;
|
|
10
|
+
readonly toolName: string | undefined;
|
|
11
|
+
readonly riskLevel: 'low' | 'medium' | 'high';
|
|
12
|
+
}
|
|
13
|
+
export interface InputDetail {
|
|
14
|
+
readonly kind: 'input';
|
|
15
|
+
readonly question: string;
|
|
16
|
+
readonly context: string | undefined;
|
|
17
|
+
readonly source: 'agent' | 'tool';
|
|
18
|
+
}
|
|
19
|
+
/** Discriminated union for the additional context carried by a PendingInteraction. */
|
|
20
|
+
export type InteractionDetail = ApprovalDetail | InputDetail;
|
|
21
|
+
/**
|
|
22
|
+
* A pending interaction awaiting a response from the consumer.
|
|
23
|
+
*
|
|
24
|
+
* Created when the agent emits an `approval_request` or `input_required`
|
|
25
|
+
* event and not yet resolved.
|
|
26
|
+
*/
|
|
27
|
+
export interface PendingInteraction {
|
|
28
|
+
/** Unique identifier for this interaction. Matches the `interactionId` on the source event. */
|
|
29
|
+
readonly id: string;
|
|
30
|
+
/** Discriminant for the interaction type. */
|
|
31
|
+
readonly type: 'approval' | 'input';
|
|
32
|
+
/** The `runId` of the run that generated this interaction. */
|
|
33
|
+
readonly runId: string;
|
|
34
|
+
/** Human-readable description of what the agent wants to do or needs. */
|
|
35
|
+
readonly description: string;
|
|
36
|
+
/** Additional context about the interaction. */
|
|
37
|
+
readonly detail: InteractionDetail;
|
|
38
|
+
/** Timestamp (ms since epoch) when the interaction was created. */
|
|
39
|
+
readonly createdAt: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ApproveResponse {
|
|
42
|
+
readonly type: 'approve';
|
|
43
|
+
readonly detail?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface DenyResponse {
|
|
46
|
+
readonly type: 'deny';
|
|
47
|
+
readonly reason?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface TextInputResponse {
|
|
50
|
+
readonly type: 'text';
|
|
51
|
+
readonly text: string;
|
|
52
|
+
}
|
|
53
|
+
/** A response to a pending interaction. */
|
|
54
|
+
export type InteractionResponse = ApproveResponse | DenyResponse | TextInputResponse;
|
|
55
|
+
/**
|
|
56
|
+
* Queue-based interaction handler for pending agent requests.
|
|
57
|
+
*
|
|
58
|
+
* Tracks all unresolved approval requests and input prompts, provides
|
|
59
|
+
* notification when new interactions arrive, and offers response methods
|
|
60
|
+
* for individual or batch resolution.
|
|
61
|
+
*/
|
|
62
|
+
export interface InteractionChannel {
|
|
63
|
+
/**
|
|
64
|
+
* Array of currently pending interactions, in arrival order.
|
|
65
|
+
* Read this each time you need the current state — it is not updated in place.
|
|
66
|
+
*/
|
|
67
|
+
readonly pending: PendingInteraction[];
|
|
68
|
+
/**
|
|
69
|
+
* Register a callback invoked whenever a new interaction becomes pending.
|
|
70
|
+
*
|
|
71
|
+
* @returns An unsubscribe function.
|
|
72
|
+
*/
|
|
73
|
+
onPending(handler: (interaction: PendingInteraction) => void): () => void;
|
|
74
|
+
/**
|
|
75
|
+
* Respond to a specific pending interaction by its ID.
|
|
76
|
+
*
|
|
77
|
+
* @throws {AgentMuxError} code `INTERACTION_NOT_FOUND` if no pending interaction matches.
|
|
78
|
+
* @throws {AgentMuxError} code `RUN_NOT_ACTIVE` if the run has terminated.
|
|
79
|
+
*/
|
|
80
|
+
respond(id: string, response: InteractionResponse): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Approve all currently pending approval interactions at once.
|
|
83
|
+
* Input interactions are skipped.
|
|
84
|
+
*/
|
|
85
|
+
approveAll(): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Deny all currently pending approval interactions.
|
|
88
|
+
* Input interactions are skipped.
|
|
89
|
+
*
|
|
90
|
+
* @param reason - Optional denial reason forwarded to the agent.
|
|
91
|
+
*/
|
|
92
|
+
denyAll(reason?: string): Promise<void>;
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../src/interaction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC/C;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CACnC;AAED,sFAAsF;AACtF,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG,WAAW,CAAC;AAM7D;;;;;GAKG;AACH,MAAM,W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,CAAC;IAE5B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InteractionChannel types for @a5c-ai/agent-mux.
|
|
3
|
+
*
|
|
4
|
+
* Defines the queue-based interaction handler for pending agent requests
|
|
5
|
+
* (approval requests and input prompts), and associated response types.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.js","sourceRoot":"","sources":["../src/interaction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invocation mode types for @a5c-ai/agent-mux.
|
|
3
|
+
*
|
|
4
|
+
* Defines how a harness process is spawned: locally, in Docker,
|
|
5
|
+
* on a remote machine via SSH, or on a remote k8s cluster.
|
|
6
|
+
*/
|
|
7
|
+
/** Local process invocation (default). Spawns directly on the host machine. */
|
|
8
|
+
export interface LocalInvocation {
|
|
9
|
+
readonly mode: 'local';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Docker invocation. Runs the harness inside a Docker container with
|
|
13
|
+
* the working directory mounted.
|
|
14
|
+
*/
|
|
15
|
+
export interface DockerInvocation {
|
|
16
|
+
readonly mode: 'docker';
|
|
17
|
+
/** Docker image to use. If omitted, uses the catalog default for the harness. */
|
|
18
|
+
readonly image?: string;
|
|
19
|
+
/** Additional volumes to mount (host:container format). */
|
|
20
|
+
readonly volumes?: string[];
|
|
21
|
+
/** Additional environment variables for the container. */
|
|
22
|
+
readonly env?: Record<string, string>;
|
|
23
|
+
/** Docker network to attach to. */
|
|
24
|
+
readonly network?: string;
|
|
25
|
+
/** Working directory inside the container. @default '/workspace' */
|
|
26
|
+
readonly workdir?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Remote SSH invocation. Connects to a remote machine, installs the
|
|
30
|
+
* harness if needed, transfers files, invokes the CLI, and copies
|
|
31
|
+
* modified files back.
|
|
32
|
+
*/
|
|
33
|
+
export interface SshInvocation {
|
|
34
|
+
readonly mode: 'ssh';
|
|
35
|
+
/** SSH host (user@host or just host). */
|
|
36
|
+
readonly host: string;
|
|
37
|
+
/** SSH port. @default 22 */
|
|
38
|
+
readonly port?: number;
|
|
39
|
+
/** Path to SSH identity file (private key). */
|
|
40
|
+
readonly identityFile?: string;
|
|
41
|
+
/** Remote working directory. Files are scp'd here before invocation. */
|
|
42
|
+
readonly remoteDir?: string;
|
|
43
|
+
/** Whether to install the harness on the remote machine if missing. @default true */
|
|
44
|
+
readonly autoInstall?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Remote Kubernetes invocation. Snapshots relevant data, transfers it
|
|
48
|
+
* to a pod, runs the harness in a container, and copies results back.
|
|
49
|
+
*/
|
|
50
|
+
export interface K8sInvocation {
|
|
51
|
+
readonly mode: 'k8s';
|
|
52
|
+
/** Kubernetes namespace. @default 'default' */
|
|
53
|
+
readonly namespace?: string;
|
|
54
|
+
/** Docker image for the pod. Uses the catalog default if omitted. */
|
|
55
|
+
readonly image?: string;
|
|
56
|
+
/** Resource requests/limits for the pod. */
|
|
57
|
+
readonly resources?: {
|
|
58
|
+
readonly cpu?: string;
|
|
59
|
+
readonly memory?: string;
|
|
60
|
+
};
|
|
61
|
+
/** Kubernetes context to use. */
|
|
62
|
+
readonly context?: string;
|
|
63
|
+
/** Service account for the pod. */
|
|
64
|
+
readonly serviceAccount?: string;
|
|
65
|
+
/** Timeout for pod startup in milliseconds. @default 120000 */
|
|
66
|
+
readonly podStartupTimeoutMs?: number;
|
|
67
|
+
/**
|
|
68
|
+
* If set, `kubectl exec` into this existing pod instead of creating a new
|
|
69
|
+
* one. Mutually exclusive with `ephemeral`.
|
|
70
|
+
*/
|
|
71
|
+
readonly pod?: string;
|
|
72
|
+
/**
|
|
73
|
+
* When true (default if `pod` is not provided), create a fresh ephemeral
|
|
74
|
+
* pod via `kubectl run --rm` and tear it down on exit. When false, expect
|
|
75
|
+
* `pod` to be set and `kubectl exec` into it.
|
|
76
|
+
*/
|
|
77
|
+
readonly ephemeral?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/** Discriminated union of all invocation modes. */
|
|
80
|
+
export type InvocationMode = LocalInvocation | DockerInvocation | SshInvocation | K8sInvocation;
|
|
81
|
+
/** All valid invocation mode discriminant strings. */
|
|
82
|
+
export type InvocationModeType = InvocationMode['mode'];
|
|
83
|
+
/** Entry in the harness Docker image catalog. */
|
|
84
|
+
export interface HarnessImageEntry {
|
|
85
|
+
/** Harness name (e.g., 'claude-code', 'codex'). */
|
|
86
|
+
readonly harness: string;
|
|
87
|
+
/** Default Docker image for this harness. */
|
|
88
|
+
readonly image: string;
|
|
89
|
+
/** Tag to use. @default 'latest' */
|
|
90
|
+
readonly tag?: string;
|
|
91
|
+
/** Whether the image includes the harness CLI pre-installed. */
|
|
92
|
+
readonly preinstalled: boolean;
|
|
93
|
+
}
|
|
94
|
+
/** Default image catalog for built-in harnesses. */
|
|
95
|
+
export declare const HARNESS_IMAGE_CATALOG: readonly HarnessImageEntry[];
|
|
96
|
+
/**
|
|
97
|
+
* Look up the default image for a harness.
|
|
98
|
+
* Returns undefined if no catalog entry exists.
|
|
99
|
+
*/
|
|
100
|
+
export declare function lookupHarnessImage(harness: string): HarnessImageEntry | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocation.d.ts","sourceRoot":"","sources":["../src/invocation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,+EAA+E;AAC/E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,QAAQ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;IACnC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,+DAA+D;IAC/D,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GACtB,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,aAAa,CAAC;AAElB,sDAAsD;AACtD,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAMxD,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,oDAAoD;AACpD,eAAO,MAAM,qBAAqB,EAAE,SAAS,iBAAiB,EAAuB,CAAC;AAEtF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEjF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invocation mode types for @a5c-ai/agent-mux.
|
|
3
|
+
*
|
|
4
|
+
* Defines how a harness process is spawned: locally, in Docker,
|
|
5
|
+
* on a remote machine via SSH, or on a remote k8s cluster.
|
|
6
|
+
*/
|
|
7
|
+
import { getHarnessImages, lookupHarnessImage as lookupCatalogHarnessImage, } from '@a5c-ai/agent-catalog';
|
|
8
|
+
/** Default image catalog for built-in harnesses. */
|
|
9
|
+
export const HARNESS_IMAGE_CATALOG = getHarnessImages();
|
|
10
|
+
/**
|
|
11
|
+
* Look up the default image for a harness.
|
|
12
|
+
* Returns undefined if no catalog entry exists.
|
|
13
|
+
*/
|
|
14
|
+
export function lookupHarnessImage(harness) {
|
|
15
|
+
return lookupCatalogHarnessImage(harness);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=invocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocation.js","sourceRoot":"","sources":["../src/invocation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,IAAI,yBAAyB,GAChD,MAAM,uBAAuB,CAAC;AA4G/B,oDAAoD;AACpD,MAAM,CAAC,MAAM,qBAAqB,GAAiC,gBAAgB,EAAE,CAAC;AAEtF;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC"}
|