acpx 0.17.0 → 0.17.1
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/{agent-registry-DU6mhZBL.js → agent-registry-evUoJINz.js} +5 -1
- package/dist/agent-registry-evUoJINz.js.map +1 -0
- package/dist/agent-registry.d.ts.map +1 -1
- package/dist/agent-registry.js +1 -1
- package/dist/{cli-CiyfEC7L.js → cli-B2ycKzaO.js} +5 -5
- package/dist/{cli-CiyfEC7L.js.map → cli-B2ycKzaO.js.map} +1 -1
- package/dist/cli.js +9 -9
- package/dist/{client-C6NUFqr-.d.ts → client-CkbBoSGd.d.ts} +6 -2
- package/dist/client-CkbBoSGd.d.ts.map +1 -0
- package/dist/{flows-CTOdIk-m.js → flows-xGyhmoHO.js} +5 -5
- package/dist/{flows-CTOdIk-m.js.map → flows-xGyhmoHO.js.map} +1 -1
- package/dist/flows.d.ts +1 -1
- package/dist/flows.js +1 -1
- package/dist/{invocation-options-DbCcOAzM.js → invocation-options-eZEBh4vd.js} +5 -5
- package/dist/{invocation-options-DbCcOAzM.js.map → invocation-options-eZEBh4vd.js.map} +1 -1
- package/dist/{ipc-D3akHMEq.js → ipc-D2rstexT.js} +4 -4
- package/dist/ipc-D2rstexT.js.map +1 -0
- package/dist/{output-BPPjvJTI.js → output-D2xL6wdp.js} +3 -3
- package/dist/{output-BPPjvJTI.js.map → output-D2xL6wdp.js.map} +1 -1
- package/dist/{queue-owner-runtime--IbbndGz.js → queue-owner-runtime-Dgv3e2Tp.js} +64 -38
- package/dist/queue-owner-runtime-Dgv3e2Tp.js.map +1 -0
- package/dist/runtime.d.ts +91 -37
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +113 -29
- package/dist/runtime.js.map +1 -1
- package/dist/{session-watch--UX5dh00.js → session-watch-CTe9Bnbc.js} +4 -4
- package/dist/{session-watch--UX5dh00.js.map → session-watch-CTe9Bnbc.js.map} +1 -1
- package/dist/{watch-BbBxO-kb.js → watch-DxuXEc8n.js} +2 -2
- package/dist/{watch-BbBxO-kb.js.map → watch-DxuXEc8n.js.map} +1 -1
- package/package.json +3 -3
- package/skills/acpx/SKILL.md +1 -0
- package/dist/agent-registry-DU6mhZBL.js.map +0 -1
- package/dist/client-C6NUFqr-.d.ts.map +0 -1
- package/dist/ipc-D3akHMEq.js.map +0 -1
- package/dist/queue-owner-runtime--IbbndGz.js.map +0 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AcpAgentInspection, AcpAgentInspectionOptions, AcpAgentRegistry, AcpInspectableAgentRegistry, DEFAULT_AGENT_NAME, createAgentRegistry } from "./agent-registry.js";
|
|
2
|
-
import { C as PermissionPolicy, S as PermissionMode, T as SessionRecord, _ as AcpProcessSpawnFailure, a as AcpElicitationHandler, b as McpServer$1, c as AcpElicitationResponse, d as AcpPermissionHandler, f as AcpPermissionRequest, g as AcpProcessLifecycle, h as AcpProcessLaunchScope, i as AcpElicitationContext, l as AcpJsonRpcMessage, m as AcpProcessLaunch, n as SystemPromptOption, o as AcpElicitationMode, p as AcpProcessExit, s as AcpElicitationRequest, t as SessionAgentOptions, u as AcpPermissionDecision, v as AcpProcessStarted, x as NonInteractivePermissionPolicy, y as AuthPolicy } from "./session-options-Dp6mzNSy.js";
|
|
3
|
-
import { a as RequestedModelUnsupportedErrorCode, c as AcpControlAuthority, i as RequestedModelUnsupportedError, n as REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, o as RequestedModelUnsupportedReason, r as REQUESTED_MODEL_UNSUPPORTED_REASONS, s as isRequestedModelUnsupportedError, t as AcpClient } from "./client-
|
|
2
|
+
import { C as PermissionPolicy, E as PromptInput, S as PermissionMode, T as SessionRecord, _ as AcpProcessSpawnFailure, a as AcpElicitationHandler, b as McpServer$1, c as AcpElicitationResponse, d as AcpPermissionHandler, f as AcpPermissionRequest, g as AcpProcessLifecycle, h as AcpProcessLaunchScope, i as AcpElicitationContext, l as AcpJsonRpcMessage, m as AcpProcessLaunch, n as SystemPromptOption, o as AcpElicitationMode, p as AcpProcessExit, s as AcpElicitationRequest, t as SessionAgentOptions, u as AcpPermissionDecision, v as AcpProcessStarted, x as NonInteractivePermissionPolicy, y as AuthPolicy } from "./session-options-Dp6mzNSy.js";
|
|
3
|
+
import { a as RequestedModelUnsupportedErrorCode, c as AcpControlAuthority, i as RequestedModelUnsupportedError, n as REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, o as RequestedModelUnsupportedReason, r as REQUESTED_MODEL_UNSUPPORTED_REASONS, s as isRequestedModelUnsupportedError, t as AcpClient } from "./client-CkbBoSGd.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { SetSessionConfigOptionResponse, ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk";
|
|
6
6
|
//#region src/session/journal.d.ts
|
|
@@ -70,15 +70,22 @@ type AcpRuntimeTurnAttachment = {
|
|
|
70
70
|
mediaType: string;
|
|
71
71
|
data: string;
|
|
72
72
|
};
|
|
73
|
-
|
|
73
|
+
/**
|
|
74
|
+
* In-process turns check synchronous host authority before prompt dispatch.
|
|
75
|
+
* A throwing assertActive rejects admission without aborting the signal.
|
|
76
|
+
*/
|
|
77
|
+
type AcpRuntimeTurnInput = AcpControlAuthority & {
|
|
74
78
|
handle: AcpRuntimeHandle;
|
|
75
79
|
text: string;
|
|
76
80
|
attachments?: AcpRuntimeTurnAttachment[];
|
|
77
81
|
mode: AcpRuntimePromptMode;
|
|
78
82
|
requestId: string;
|
|
79
83
|
timeoutMs?: number;
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Overrides the client's default callback for this prompt turn. Throwing or
|
|
86
|
+
* returning undefined falls through to configured permission policy, not the
|
|
87
|
+
* default callback.
|
|
88
|
+
*/
|
|
82
89
|
onPermissionRequest?: AcpPermissionHandler;
|
|
83
90
|
/** Handles ACP elicitation requests owned by this prompt turn. */
|
|
84
91
|
onElicitation?: AcpElicitationHandler;
|
|
@@ -368,6 +375,13 @@ interface AcpSessionStore {
|
|
|
368
375
|
load(sessionId: string): Promise<AcpSessionRecord | undefined>;
|
|
369
376
|
save(record: AcpSessionRecord): Promise<void>;
|
|
370
377
|
}
|
|
378
|
+
type AcpRuntimeSessionContext = {
|
|
379
|
+
sessionKey: string;
|
|
380
|
+
cwd: string;
|
|
381
|
+
agentCommand: string;
|
|
382
|
+
agentArgv?: string[];
|
|
383
|
+
};
|
|
384
|
+
type AcpRuntimeSessionPermissions = Partial<Pick<AcpRuntimeOptions, "permissionMode" | "nonInteractivePermissions" | "permissionPolicy" | "onPermissionRequest">>;
|
|
371
385
|
type AcpRuntimeOptions = {
|
|
372
386
|
cwd: string;
|
|
373
387
|
/** Trusted child-only environment, snapshotted at construction and never persisted. */
|
|
@@ -380,12 +394,14 @@ type AcpRuntimeOptions = {
|
|
|
380
394
|
* Retained connections keep their original servers. Initialization-only health
|
|
381
395
|
* probes do not call the resolver.
|
|
382
396
|
*/
|
|
383
|
-
mcpServers?: McpServer$1[] | ((session:
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
397
|
+
mcpServers?: McpServer$1[] | ((session: AcpRuntimeSessionContext) => McpServer$1[]);
|
|
398
|
+
/**
|
|
399
|
+
* Client permissions for new and reconnected sessions, resolved from stored
|
|
400
|
+
* identity. Unspecified fields inherit runtime defaults. Retained clients keep
|
|
401
|
+
* their original policy; health probes do not call this resolver. Neither the
|
|
402
|
+
* policy nor its callback is persisted.
|
|
403
|
+
*/
|
|
404
|
+
sessionPermissions?: (session: AcpRuntimeSessionContext) => AcpRuntimeSessionPermissions | undefined;
|
|
389
405
|
permissionMode: PermissionMode;
|
|
390
406
|
nonInteractivePermissions?: NonInteractivePermissionPolicy;
|
|
391
407
|
permissionPolicy?: PermissionPolicy;
|
|
@@ -408,11 +424,53 @@ type RuntimeHealthReport = {
|
|
|
408
424
|
message: string;
|
|
409
425
|
details?: string[];
|
|
410
426
|
};
|
|
427
|
+
type InspectAgentModelsOptions = {
|
|
428
|
+
agentCommand: string[];
|
|
429
|
+
cwd: string;
|
|
430
|
+
signal?: AbortSignal;
|
|
431
|
+
/** Positive startup/session discovery deadline; defaults to 120 seconds. Cleanup is awaited. */
|
|
432
|
+
timeoutMs?: number;
|
|
433
|
+
/** Trusted child-only environment overlay; never persisted. */
|
|
434
|
+
agentProcessEnv?: Record<string, string>;
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* Inspect session model metadata without a runtime store or prompt. The agent
|
|
438
|
+
* may create native session history; only its owned transport is closed.
|
|
439
|
+
*/
|
|
440
|
+
export declare function inspectAgentModels(options: InspectAgentModelsOptions): Promise<AcpRuntimeSessionModels | undefined>;
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/runtime/engine/turn.d.ts
|
|
443
|
+
type Deferred<T> = {
|
|
444
|
+
promise: Promise<T>;
|
|
445
|
+
resolve: (value: T) => void;
|
|
446
|
+
reject: (error: unknown) => void;
|
|
447
|
+
};
|
|
448
|
+
declare class AsyncEventQueue {
|
|
449
|
+
private readonly items;
|
|
450
|
+
private readonly waits;
|
|
451
|
+
private closed;
|
|
452
|
+
push(item: AcpRuntimeEvent): void;
|
|
453
|
+
close(): void;
|
|
454
|
+
clear(): void;
|
|
455
|
+
next(): Promise<AcpRuntimeEvent | null>;
|
|
456
|
+
iterate(): AsyncIterable<AcpRuntimeEvent>;
|
|
457
|
+
}
|
|
411
458
|
//#endregion
|
|
412
459
|
//#region src/runtime/engine/manager.d.ts
|
|
413
460
|
type AcpRuntimeManagerDeps = {
|
|
414
461
|
clientFactory?: (options: ConstructorParameters<typeof AcpClient>[0]) => AcpClient;
|
|
415
462
|
};
|
|
463
|
+
type ActiveSessionController = {
|
|
464
|
+
hasActivePrompt: () => boolean;
|
|
465
|
+
requestCancelActivePrompt: () => Promise<boolean>;
|
|
466
|
+
setSessionMode: (modeId: string, authority?: AcpControlAuthority) => Promise<void>;
|
|
467
|
+
setSessionModel: (modelId: string, authority?: AcpControlAuthority) => ReturnType<AcpClient["setSessionModel"]>;
|
|
468
|
+
setSessionConfigOption: (configId: string, value: string, authority?: AcpControlAuthority) => ReturnType<AcpClient["setSessionConfigOption"]>;
|
|
469
|
+
setResolvedSessionConfigOption: (configId: string, value: string, authority?: AcpControlAuthority) => Promise<{
|
|
470
|
+
configId: string;
|
|
471
|
+
response: Awaited<ReturnType<AcpClient["setSessionConfigOption"]>>;
|
|
472
|
+
}>;
|
|
473
|
+
};
|
|
416
474
|
type RuntimeEnsureInput = {
|
|
417
475
|
sessionKey: string;
|
|
418
476
|
agent: string;
|
|
@@ -421,6 +479,23 @@ type RuntimeEnsureInput = {
|
|
|
421
479
|
resumeSessionId?: string;
|
|
422
480
|
sessionOptions?: SessionAgentOptions;
|
|
423
481
|
};
|
|
482
|
+
type RuntimeTurnTaskState = {
|
|
483
|
+
pendingCancel: boolean;
|
|
484
|
+
turnActive: boolean;
|
|
485
|
+
activeController: ActiveSessionController | null;
|
|
486
|
+
};
|
|
487
|
+
type RuntimeTurnTask = {
|
|
488
|
+
input: AcpRuntimeTurnInput & {
|
|
489
|
+
sessionMode: "persistent" | "oneshot";
|
|
490
|
+
};
|
|
491
|
+
promptInput: PromptInput | string;
|
|
492
|
+
queue: AsyncEventQueue;
|
|
493
|
+
promptStarted: Deferred<void>;
|
|
494
|
+
sessionReady: Deferred<void>;
|
|
495
|
+
state: RuntimeTurnTaskState;
|
|
496
|
+
settleResult: (next: AcpRuntimeTurnResult) => void;
|
|
497
|
+
abortHandler: () => void;
|
|
498
|
+
};
|
|
424
499
|
declare class AcpRuntimeManager {
|
|
425
500
|
private readonly options;
|
|
426
501
|
private readonly deps;
|
|
@@ -461,6 +536,7 @@ declare class AcpRuntimeManager {
|
|
|
461
536
|
private retainPersistentSessionOwnerAfterTurn;
|
|
462
537
|
private canRetainPersistentSessionOwner;
|
|
463
538
|
private resolveMcpServers;
|
|
539
|
+
private resolveSessionPermissions;
|
|
464
540
|
private withRuntimeControlSession;
|
|
465
541
|
private refreshOwnedRecordLifecycle;
|
|
466
542
|
ensureSession(input: RuntimeEnsureInput): Promise<SessionRecord>;
|
|
@@ -475,18 +551,7 @@ declare class AcpRuntimeManager {
|
|
|
475
551
|
private createOwnedRuntimeSession;
|
|
476
552
|
private prepareInitialRuntimeRecord;
|
|
477
553
|
private retainInitializedSessionOwner;
|
|
478
|
-
startTurn(input:
|
|
479
|
-
handle: AcpRuntimeHandle;
|
|
480
|
-
text: string;
|
|
481
|
-
attachments?: AcpRuntimeTurnAttachment[];
|
|
482
|
-
mode: AcpRuntimePromptMode;
|
|
483
|
-
sessionMode: "persistent" | "oneshot";
|
|
484
|
-
requestId: string;
|
|
485
|
-
timeoutMs?: number;
|
|
486
|
-
signal?: AbortSignal;
|
|
487
|
-
onElicitation?: AcpElicitationHandler;
|
|
488
|
-
onPermissionRequest?: AcpPermissionHandler;
|
|
489
|
-
}): AcpRuntimeTurn;
|
|
554
|
+
startTurn(input: RuntimeTurnTask["input"]): AcpRuntimeTurn;
|
|
490
555
|
private closeRetainedOneShotHandle;
|
|
491
556
|
private runRuntimeTurnTask;
|
|
492
557
|
private runRuntimePrompt;
|
|
@@ -510,26 +575,15 @@ declare class AcpRuntimeManager {
|
|
|
510
575
|
private publishRuntimeTurnController;
|
|
511
576
|
private resolveRuntimeTurnReady;
|
|
512
577
|
private cancelRuntimeTurnBeforePrompt;
|
|
513
|
-
private applyPendingRuntimeTurnCancel;
|
|
514
578
|
private saveCompletedRuntimeTurn;
|
|
579
|
+
private handleRuntimeTurnFailure;
|
|
515
580
|
private failRuntimeTurn;
|
|
516
581
|
private finalizeRuntimeTurn;
|
|
517
582
|
private discardRetainedRuntimeTurnOwner;
|
|
518
583
|
private closeRuntimeTurnClient;
|
|
519
584
|
private cleanupRuntimeTurn;
|
|
520
585
|
private finalizeRuntimeTurnRecord;
|
|
521
|
-
runTurn(input:
|
|
522
|
-
handle: AcpRuntimeHandle;
|
|
523
|
-
text: string;
|
|
524
|
-
attachments?: AcpRuntimeTurnAttachment[];
|
|
525
|
-
mode: AcpRuntimePromptMode;
|
|
526
|
-
sessionMode: "persistent" | "oneshot";
|
|
527
|
-
requestId: string;
|
|
528
|
-
timeoutMs?: number;
|
|
529
|
-
signal?: AbortSignal;
|
|
530
|
-
onElicitation?: AcpElicitationHandler;
|
|
531
|
-
onPermissionRequest?: AcpPermissionHandler;
|
|
532
|
-
}): AsyncIterable<AcpRuntimeEvent>;
|
|
586
|
+
runTurn(input: RuntimeTurnTask["input"]): AsyncIterable<AcpRuntimeEvent>;
|
|
533
587
|
getStatus(handle: AcpRuntimeHandle): Promise<AcpRuntimeStatus>;
|
|
534
588
|
private readStatus;
|
|
535
589
|
setMode(handle: AcpRuntimeHandle, mode: string, sessionMode?: "persistent" | "oneshot", authority?: AcpControlAuthority): Promise<void>;
|
|
@@ -726,5 +780,5 @@ export declare function createRuntimeStore(options: {
|
|
|
726
780
|
stateDir: string;
|
|
727
781
|
}): AcpSessionStore;
|
|
728
782
|
//#endregion
|
|
729
|
-
export { type AcpAgentInspection, type AcpAgentInspectionOptions, type AcpAgentRegistry, type AcpElicitationContext, type AcpElicitationHandler, type AcpElicitationMode, type AcpElicitationRequest, type AcpElicitationResponse, type AcpFileSessionStoreOptions, type AcpInspectableAgentRegistry, type AcpPermissionDecision, type AcpPermissionHandler, type AcpPermissionRequest, type AcpProcessExit, type AcpProcessLaunch, type AcpProcessLaunchScope, type AcpProcessLifecycle, type AcpProcessSpawnFailure, type AcpProcessStarted, type AcpRuntime, type AcpRuntimeAvailableCommand, type AcpRuntimeCapabilities, type AcpRuntimeDoctorReport, type AcpRuntimeEnsureInput, type AcpRuntimeErrorCode, type AcpRuntimeEvent, type AcpRuntimeHandle, type AcpRuntimeOptions, type AcpRuntimePlanEntry, type AcpRuntimePromptMode, type AcpRuntimeSessionMode, type AcpRuntimeSessionModels, type AcpRuntimeSessionUsage, type AcpRuntimeStatus, type AcpRuntimeTurn, type AcpRuntimeTurnAttachment, type AcpRuntimeTurnInput, type AcpRuntimeTurnResult, type AcpRuntimeTurnResultError, type AcpRuntimeUsageBreakdown, type AcpRuntimeUsageCost, type AcpSessionRecord, type AcpSessionStore, type AcpSessionUpdateTag, type AcpTextDeltaOriginMeta, DEFAULT_AGENT_NAME, type PermissionPolicy, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, REQUESTED_MODEL_UNSUPPORTED_REASONS, RequestedModelUnsupportedError, type RequestedModelUnsupportedErrorCode, type RequestedModelUnsupportedReason, type SessionAgentOptions, type SessionWatchEvent, type SessionWatchResult, type SharedAcpRuntimeOptions, type SystemPromptOption, createAgentRegistry, isRequestedModelUnsupportedError };
|
|
783
|
+
export { type AcpAgentInspection, type AcpAgentInspectionOptions, type AcpAgentRegistry, type AcpElicitationContext, type AcpElicitationHandler, type AcpElicitationMode, type AcpElicitationRequest, type AcpElicitationResponse, type AcpFileSessionStoreOptions, type AcpInspectableAgentRegistry, type AcpPermissionDecision, type AcpPermissionHandler, type AcpPermissionRequest, type AcpProcessExit, type AcpProcessLaunch, type AcpProcessLaunchScope, type AcpProcessLifecycle, type AcpProcessSpawnFailure, type AcpProcessStarted, type AcpRuntime, type AcpRuntimeAvailableCommand, type AcpRuntimeCapabilities, type AcpRuntimeDoctorReport, type AcpRuntimeEnsureInput, type AcpRuntimeErrorCode, type AcpRuntimeEvent, type AcpRuntimeHandle, type AcpRuntimeOptions, type AcpRuntimePlanEntry, type AcpRuntimePromptMode, type AcpRuntimeSessionContext, type AcpRuntimeSessionMode, type AcpRuntimeSessionModels, type AcpRuntimeSessionPermissions, type AcpRuntimeSessionUsage, type AcpRuntimeStatus, type AcpRuntimeTurn, type AcpRuntimeTurnAttachment, type AcpRuntimeTurnInput, type AcpRuntimeTurnResult, type AcpRuntimeTurnResultError, type AcpRuntimeUsageBreakdown, type AcpRuntimeUsageCost, type AcpSessionRecord, type AcpSessionStore, type AcpSessionUpdateTag, type AcpTextDeltaOriginMeta, DEFAULT_AGENT_NAME, type InspectAgentModelsOptions, type PermissionPolicy, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, REQUESTED_MODEL_UNSUPPORTED_REASONS, RequestedModelUnsupportedError, type RequestedModelUnsupportedErrorCode, type RequestedModelUnsupportedReason, type SessionAgentOptions, type SessionWatchEvent, type SessionWatchResult, type SharedAcpRuntimeOptions, type SystemPromptOption, createAgentRegistry, isRequestedModelUnsupportedError };
|
|
730
784
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","names":[],"sources":["../src/session/journal.ts","../src/runtime/public/contract.ts","../src/runtime/public/probe.ts","../src/runtime/engine/manager.ts","../src/runtime/public/file-session-store.ts","../src/runtime/public/errors.ts","../src/runtime/public/shared.ts","../src/runtime/public/handle-state.ts","../src/runtime/shared.ts","../src/runtime.ts"],"mappings":";;;;;;KAYY;EAEN;EACA;EACA,QAAQ;;EAGR;EACA;IAAS;IAAiB;IAAe;IAAqB;;;KAGxD;EAAsB;;EAC5B;EAAiB;EAA0B,SAAS;;EACpD;EAAsB;;EACtB;EAAqB;EAAmB,QAAQ;;;;KCiB1C;KAEA;KAEA;KAaA;KAMA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,MAAM;EACN;EACA;;;;;;;;;EASA,iBAAiB;;KAGP;;;;;EAKV;EACA
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","names":[],"sources":["../src/session/journal.ts","../src/runtime/public/contract.ts","../src/runtime/public/probe.ts","../src/runtime/engine/turn.ts","../src/runtime/engine/manager.ts","../src/runtime/public/file-session-store.ts","../src/runtime/public/errors.ts","../src/runtime/public/shared.ts","../src/runtime/public/handle-state.ts","../src/runtime/shared.ts","../src/runtime.ts"],"mappings":";;;;;;KAYY;EAEN;EACA;EACA,QAAQ;;EAGR;EACA;IAAS;IAAiB;IAAe;IAAqB;;;KAGxD;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;;qBAGP,uBAAuB;mBAQf;mBACA;UARX;UACA;mBACS;UACT;UACA;EAGW,YAAA,SAAS,mBACT;IACf,kBAAkB,SAAS,sBAAsB;IACjD,eAAe,SAAS,sBAAsB;MAC5C;MACA;MACA;;;EASN;EAIM,qBAAqB;EAKrB,UAAU,QAAQ;UAWhB;EAaF,YAAY;IAChB;IACA;MACE,QAAQ;EAWN,cAAc,OAAO,wBAAwB,QAAQ;UAenD;EAyBR,UAAU,OAAO;;;;;;;IAgCM,OAAA;MAAE;QAAiB;IAGd,YAAA;MAAE;QAAiB;;EAMxC,QAAQ,OAAO,sBAAsB,cAAc;EAkBpD,gBAAgB;IAAU,SAAS;MAAqB,QAAQ;EAyBhE,UAAU;IACd,QAAQ;IACR,SAAS;MACP,QAAQ;EAMN,QACJ,OAAO;IAAwB,QAAQ;IAAkB;MACxD;EAMG,SACJ,OAAO;IAAwB,QAAQ;IAAkB;MACxD;EAMG,gBACJ,OAAO;IACL,QAAQ;IACR;IACA;MAED,QAAQ;EAML,OAAO;IAAS,QAAQ;IAAkB;MAAoB;EAM9D,oBAAoB;IAAS,QAAQ;MAAqB;EAM1D,MAAM;IACV,QAAQ;IACR;IACA;MACE;EAQJ,YAAY;UAeE;UAkBA;UAmBN;UAcA;;wBA+BM,iBAAiB,SAAS,oBAAoB;wBAI9C,mBAAmB;EAAW;IAAqB"}
|
package/dist/runtime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as textPrompt, D as findSession, F as resolveSessionRecord, L as assertPersistedKeyPolicy, P as readSessionRecord, R as parseSessionRecord, gt as extractAcpError, mt as writePrivateJsonFile, t as tryCancelOnRunningOwner, vt as isAcpResourceNotFoundError, z as serializeSessionRecordForDisk } from "./ipc-
|
|
2
|
-
import { A as setDesiredModeId, B as recordClientOperation, C as withConnectedSession, D as applyInitialModelSelection, E as applyConfigOptionsToRecord, F as createInitialSessionRecord, G as AcpClient, H as recordSessionUpdate, I as reconcileAgentSessionId, J as RequestedModelUnsupportedError, K as REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, L as cloneSessionAcpxState, M as sessionOptionsFromRecord, N as applyConversation, O as applyModelSelection, P as applyLifecycleSnapshotToRecord, R as cloneSessionConversation, T as applyConfigOptionSelection, U as trimConversationForRuntime, V as recordPromptSubmission, W as advertisedModelState, Y as isRequestedModelUnsupportedError, _ as cancelSessionPrompt, c as LiveSessionCheckpoint, ct as normalizeOutputError, h as ensureSession, it as assertControlAuthority, j as persistSessionOptions, k as applyRequestedModelIfAdvertised, l as runPromptTurn, ot as withTimeout, q as REQUESTED_MODEL_UNSUPPORTED_REASONS, r as sendSession, s as DISCARD_OUTPUT_FORMATTER, v as closeSession, w as connectAndLoadSession } from "./queue-owner-runtime
|
|
3
|
-
import { D as normalizeAgentCommandInput, a as createAgentRegistry, i as DEFAULT_AGENT_NAME } from "./agent-registry-
|
|
4
|
-
import { t as watchSession } from "./watch-
|
|
1
|
+
import { C as textPrompt, D as findSession, F as resolveSessionRecord, L as assertPersistedKeyPolicy, P as readSessionRecord, R as parseSessionRecord, gt as extractAcpError, mt as writePrivateJsonFile, t as tryCancelOnRunningOwner, vt as isAcpResourceNotFoundError, z as serializeSessionRecordForDisk } from "./ipc-D2rstexT.js";
|
|
2
|
+
import { A as setDesiredModeId, B as recordClientOperation, C as withConnectedSession, D as applyInitialModelSelection, E as applyConfigOptionsToRecord, F as createInitialSessionRecord, G as AcpClient, H as recordSessionUpdate, I as reconcileAgentSessionId, J as RequestedModelUnsupportedError, K as REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, L as cloneSessionAcpxState, M as sessionOptionsFromRecord, N as applyConversation, O as applyModelSelection, P as applyLifecycleSnapshotToRecord, R as cloneSessionConversation, T as applyConfigOptionSelection, U as trimConversationForRuntime, V as recordPromptSubmission, W as advertisedModelState, Y as isRequestedModelUnsupportedError, _ as cancelSessionPrompt, c as LiveSessionCheckpoint, ct as normalizeOutputError, h as ensureSession, it as assertControlAuthority, j as persistSessionOptions, k as applyRequestedModelIfAdvertised, l as runPromptTurn, ot as withTimeout, q as REQUESTED_MODEL_UNSUPPORTED_REASONS, r as sendSession, rt as TimeoutError, s as DISCARD_OUTPUT_FORMATTER, v as closeSession, w as connectAndLoadSession } from "./queue-owner-runtime-Dgv3e2Tp.js";
|
|
3
|
+
import { D as normalizeAgentCommandInput, a as createAgentRegistry, i as DEFAULT_AGENT_NAME } from "./agent-registry-evUoJINz.js";
|
|
4
|
+
import { t as watchSession } from "./watch-DxuXEc8n.js";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import fs from "node:fs/promises";
|
|
@@ -547,6 +547,61 @@ function updateStatusEvent(payload, tag) {
|
|
|
547
547
|
}
|
|
548
548
|
//#endregion
|
|
549
549
|
//#region src/runtime/public/probe.ts
|
|
550
|
+
/**
|
|
551
|
+
* Inspect session model metadata without a runtime store or prompt. The agent
|
|
552
|
+
* may create native session history; only its owned transport is closed.
|
|
553
|
+
*/
|
|
554
|
+
async function inspectAgentModels(options) {
|
|
555
|
+
options.signal?.throwIfAborted();
|
|
556
|
+
const timeoutMs = options.timeoutMs ?? 12e4;
|
|
557
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > 2147483647) throw new RangeError("Model inspection timeoutMs must be positive and at most 2147483647");
|
|
558
|
+
const deadline = new AbortController();
|
|
559
|
+
const signal = options.signal ? AbortSignal.any([options.signal, deadline.signal]) : deadline.signal;
|
|
560
|
+
const assertActive = () => signal.throwIfAborted();
|
|
561
|
+
const client = new AcpClient({
|
|
562
|
+
...normalizeAgentCommandInput(options.agentCommand),
|
|
563
|
+
cwd: options.cwd,
|
|
564
|
+
agentProcessEnv: options.agentProcessEnv,
|
|
565
|
+
permissionMode: "deny-all",
|
|
566
|
+
nonInteractivePermissions: "deny",
|
|
567
|
+
fs: false,
|
|
568
|
+
terminal: false,
|
|
569
|
+
processLifecycle: {
|
|
570
|
+
onBeforeSpawn: assertActive,
|
|
571
|
+
onSpawned: assertActive
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
const timer = setTimeout(() => deadline.abort(new TimeoutError(timeoutMs)), timeoutMs);
|
|
575
|
+
let onAbort;
|
|
576
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
577
|
+
onAbort = () => reject(signal.reason);
|
|
578
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
579
|
+
});
|
|
580
|
+
const inspection = (async () => {
|
|
581
|
+
assertActive();
|
|
582
|
+
await client.start();
|
|
583
|
+
assertActive();
|
|
584
|
+
const { models } = await client.createSession();
|
|
585
|
+
assertActive();
|
|
586
|
+
return models ? {
|
|
587
|
+
currentModelId: models.currentModelId,
|
|
588
|
+
availableModelIds: models.availableModels.map((model) => model.modelId),
|
|
589
|
+
availableModels: models.availableModels
|
|
590
|
+
} : void 0;
|
|
591
|
+
})();
|
|
592
|
+
try {
|
|
593
|
+
return await Promise.race([inspection, aborted]);
|
|
594
|
+
} finally {
|
|
595
|
+
clearTimeout(timer);
|
|
596
|
+
signal.removeEventListener("abort", onAbort);
|
|
597
|
+
try {
|
|
598
|
+
if (signal.aborted) await client.close();
|
|
599
|
+
} finally {
|
|
600
|
+
await inspection.catch(() => {});
|
|
601
|
+
await client.close();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
550
605
|
function isPrimitiveDetail(value) {
|
|
551
606
|
return value == null || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint" || typeof value === "symbol";
|
|
552
607
|
}
|
|
@@ -877,6 +932,14 @@ function resolveSupportedConfigOptionId(record, configId) {
|
|
|
877
932
|
const supportedText = supported.length > 0 ? supported.join(", ") : "none";
|
|
878
933
|
throw new AcpRuntimeError("ACP_BACKEND_UNSUPPORTED_CONTROL", `ACP session ${record.acpxRecordId} does not advertise config option '${configId}'. Supported config options: ${supportedText}.`);
|
|
879
934
|
}
|
|
935
|
+
async function startRuntimeClient(client, agent, timeoutMs) {
|
|
936
|
+
try {
|
|
937
|
+
await withTimeout(client.start(), timeoutMs);
|
|
938
|
+
} catch (error) {
|
|
939
|
+
if (!(error instanceof TimeoutError)) throw error;
|
|
940
|
+
throw new AcpRuntimeError("ACP_SESSION_INIT_FAILED", `ACP agent ${path.basename(agent.agentArgv?.[0] ?? agent.agentCommand.split(/\s+/)[0])} did not complete ACP initialization within ${timeoutMs}ms. Check that the configured command starts an ACP server.`, { cause: error });
|
|
941
|
+
}
|
|
942
|
+
}
|
|
880
943
|
async function createOrLoadRuntimeSession(client, resumeSessionId, cwd) {
|
|
881
944
|
if (resumeSessionId) {
|
|
882
945
|
if (client.supportsResumeSession()) {
|
|
@@ -1184,6 +1247,21 @@ var AcpRuntimeManager = class {
|
|
|
1184
1247
|
agentArgv: agentArgv ? [...agentArgv] : void 0
|
|
1185
1248
|
}) : servers ?? []];
|
|
1186
1249
|
}
|
|
1250
|
+
resolveSessionPermissions(session) {
|
|
1251
|
+
const { sessionKey, cwd, agentCommand, agentArgv } = session;
|
|
1252
|
+
const { permissionMode = this.options.permissionMode, nonInteractivePermissions = this.options.nonInteractivePermissions, permissionPolicy = this.options.permissionPolicy, onPermissionRequest = this.options.onPermissionRequest } = this.options.sessionPermissions?.({
|
|
1253
|
+
sessionKey,
|
|
1254
|
+
cwd,
|
|
1255
|
+
agentCommand,
|
|
1256
|
+
agentArgv: agentArgv ? [...agentArgv] : void 0
|
|
1257
|
+
}) ?? {};
|
|
1258
|
+
return {
|
|
1259
|
+
permissionMode,
|
|
1260
|
+
nonInteractivePermissions,
|
|
1261
|
+
permissionPolicy,
|
|
1262
|
+
onPermissionRequest
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1187
1265
|
async withRuntimeControlSession(record, sessionMode, run, replacingConfigOption, authority) {
|
|
1188
1266
|
await this.retrySessionCleanup(record.acpxRecordId);
|
|
1189
1267
|
assertControlAuthority(authority);
|
|
@@ -1224,10 +1302,10 @@ var AcpRuntimeManager = class {
|
|
|
1224
1302
|
...record,
|
|
1225
1303
|
sessionKey: record.name ?? record.acpxRecordId
|
|
1226
1304
|
}),
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1305
|
+
...this.resolveSessionPermissions({
|
|
1306
|
+
...record,
|
|
1307
|
+
sessionKey: record.name ?? record.acpxRecordId
|
|
1308
|
+
}),
|
|
1231
1309
|
elicitationModes: this.options.elicitationModes,
|
|
1232
1310
|
verbose: this.options.verbose,
|
|
1233
1311
|
timeoutMs: this.options.timeoutMs,
|
|
@@ -1341,10 +1419,10 @@ var AcpRuntimeManager = class {
|
|
|
1341
1419
|
...agent,
|
|
1342
1420
|
sessionKey: input.sessionKey
|
|
1343
1421
|
}),
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1422
|
+
...this.resolveSessionPermissions({
|
|
1423
|
+
...agent,
|
|
1424
|
+
sessionKey: input.sessionKey
|
|
1425
|
+
}),
|
|
1348
1426
|
elicitationModes: this.options.elicitationModes,
|
|
1349
1427
|
processLifecycle: this.options.processLifecycle,
|
|
1350
1428
|
processLaunchScope: {
|
|
@@ -1361,7 +1439,7 @@ var AcpRuntimeManager = class {
|
|
|
1361
1439
|
});
|
|
1362
1440
|
let retained = false;
|
|
1363
1441
|
try {
|
|
1364
|
-
await client.
|
|
1442
|
+
await startRuntimeClient(client, agent, this.options.timeoutMs);
|
|
1365
1443
|
this.assertOpen();
|
|
1366
1444
|
const session = await createOrLoadRuntimeSession(client, input.resumeSessionId, cwd);
|
|
1367
1445
|
const record = await this.prepareInitialRuntimeRecord({
|
|
@@ -1465,7 +1543,7 @@ var AcpRuntimeManager = class {
|
|
|
1465
1543
|
return true;
|
|
1466
1544
|
};
|
|
1467
1545
|
const abortHandler = () => {
|
|
1468
|
-
requestCancel();
|
|
1546
|
+
requestCancel().catch(() => {});
|
|
1469
1547
|
};
|
|
1470
1548
|
if (input.signal && !input.signal.aborted) input.signal.addEventListener("abort", abortHandler, { once: true });
|
|
1471
1549
|
this.queueSessionTask(input.handle.acpxRecordId ?? input.handle.sessionKey, async () => this.runRuntimeTurnTask({
|
|
@@ -1515,7 +1593,6 @@ var AcpRuntimeManager = class {
|
|
|
1515
1593
|
stopReason: "cancelled"
|
|
1516
1594
|
};
|
|
1517
1595
|
else {
|
|
1518
|
-
await this.applyPendingRuntimeTurnCancel(task, turn);
|
|
1519
1596
|
const response = await this.runRuntimePrompt(task, turn, sessionId);
|
|
1520
1597
|
await this.saveCompletedRuntimeTurn(turn);
|
|
1521
1598
|
terminalResult = {
|
|
@@ -1526,7 +1603,7 @@ var AcpRuntimeManager = class {
|
|
|
1526
1603
|
}
|
|
1527
1604
|
}
|
|
1528
1605
|
} catch (error) {
|
|
1529
|
-
terminalResult = this.
|
|
1606
|
+
terminalResult = this.handleRuntimeTurnFailure(task, error);
|
|
1530
1607
|
}
|
|
1531
1608
|
const finalization = await settleAttempt(async () => this.finalizeRuntimeTurn(task, turn));
|
|
1532
1609
|
if (!finalization.ok) {
|
|
@@ -1546,7 +1623,8 @@ var AcpRuntimeManager = class {
|
|
|
1546
1623
|
promptMessageId: turn.promptMessageId,
|
|
1547
1624
|
onPromptRequestWritten: () => task.promptStarted.resolve(),
|
|
1548
1625
|
onElicitation: task.input.onElicitation,
|
|
1549
|
-
onPermissionRequest: task.input.onPermissionRequest
|
|
1626
|
+
onPermissionRequest: task.input.onPermissionRequest,
|
|
1627
|
+
authority: task.input
|
|
1550
1628
|
});
|
|
1551
1629
|
} finally {
|
|
1552
1630
|
turn.client.endPromptElicitation?.(sessionId);
|
|
@@ -1668,10 +1746,10 @@ var AcpRuntimeManager = class {
|
|
|
1668
1746
|
...record,
|
|
1669
1747
|
sessionKey: record.name ?? record.acpxRecordId
|
|
1670
1748
|
}),
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1749
|
+
...this.resolveSessionPermissions({
|
|
1750
|
+
...record,
|
|
1751
|
+
sessionKey: record.name ?? record.acpxRecordId
|
|
1752
|
+
}),
|
|
1675
1753
|
elicitationModes: this.options.elicitationModes,
|
|
1676
1754
|
processLifecycle: this.options.processLifecycle,
|
|
1677
1755
|
processLaunchScope: {
|
|
@@ -1790,12 +1868,6 @@ var AcpRuntimeManager = class {
|
|
|
1790
1868
|
task.promptStarted.reject(/* @__PURE__ */ new Error("ACP turn cancelled before prompt submission."));
|
|
1791
1869
|
return true;
|
|
1792
1870
|
}
|
|
1793
|
-
async applyPendingRuntimeTurnCancel(task, turn) {
|
|
1794
|
-
if (!task.state.pendingCancel || !turn.client.hasActivePrompt()) return false;
|
|
1795
|
-
const cancelled = await turn.client.requestCancelActivePrompt();
|
|
1796
|
-
if (cancelled) task.state.pendingCancel = false;
|
|
1797
|
-
return cancelled;
|
|
1798
|
-
}
|
|
1799
1871
|
async saveCompletedRuntimeTurn(turn) {
|
|
1800
1872
|
turn.record.acpSessionId = turn.activeSessionId;
|
|
1801
1873
|
reconcileAgentSessionId(turn.record, turn.record.agentSessionId);
|
|
@@ -1806,6 +1878,15 @@ var AcpRuntimeManager = class {
|
|
|
1806
1878
|
applyLifecycleSnapshotToRecord(turn.record, turn.client.getAgentLifecycleSnapshot());
|
|
1807
1879
|
await this.options.sessionStore.save(turn.record);
|
|
1808
1880
|
}
|
|
1881
|
+
handleRuntimeTurnFailure(task, error) {
|
|
1882
|
+
if (!task.input.signal?.aborted || error !== task.input.signal.reason) return this.failRuntimeTurn(task, error);
|
|
1883
|
+
task.promptStarted.reject(error);
|
|
1884
|
+
task.sessionReady.reject(error);
|
|
1885
|
+
return {
|
|
1886
|
+
status: "cancelled",
|
|
1887
|
+
stopReason: "cancelled"
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1809
1890
|
failRuntimeTurn(task, error) {
|
|
1810
1891
|
task.promptStarted.reject(error);
|
|
1811
1892
|
task.sessionReady.reject(error);
|
|
@@ -2188,6 +2269,7 @@ var SharedAcpRuntime = class {
|
|
|
2188
2269
|
"sessionStore",
|
|
2189
2270
|
"agentProcessEnv",
|
|
2190
2271
|
"mcpServers",
|
|
2272
|
+
"sessionPermissions",
|
|
2191
2273
|
"processLifecycle",
|
|
2192
2274
|
"onPermissionRequest",
|
|
2193
2275
|
"elicitationModes"
|
|
@@ -2239,7 +2321,7 @@ var SharedAcpRuntime = class {
|
|
|
2239
2321
|
}
|
|
2240
2322
|
startTurn(input) {
|
|
2241
2323
|
this.assertOpen();
|
|
2242
|
-
if (input.mode !== "prompt" || input.onPermissionRequest || input.onElicitation) invalidOption("Shared turns support prompt mode and the client's static permission policy; in-process callbacks and steering are unsupported.");
|
|
2324
|
+
if (input.mode !== "prompt" || input.assertActive || input.onPermissionRequest || input.onElicitation) invalidOption("Shared turns support prompt mode and the client's static permission policy; in-process callbacks and steering are unsupported.");
|
|
2243
2325
|
if (!input.requestId.trim()) invalidOption("A shared turn requires a requestId.");
|
|
2244
2326
|
const sessionId = sharedRecordId(input.handle);
|
|
2245
2327
|
const prompt = toPromptInput(input.text, input.attachments);
|
|
@@ -2471,6 +2553,7 @@ var AcpxRuntime = class {
|
|
|
2471
2553
|
requestId: input.requestId,
|
|
2472
2554
|
timeoutMs: input.timeoutMs,
|
|
2473
2555
|
signal: input.signal,
|
|
2556
|
+
assertActive: input.assertActive,
|
|
2474
2557
|
onElicitation: input.onElicitation,
|
|
2475
2558
|
onPermissionRequest: input.onPermissionRequest
|
|
2476
2559
|
}));
|
|
@@ -2504,6 +2587,7 @@ var AcpxRuntime = class {
|
|
|
2504
2587
|
requestId: input.requestId,
|
|
2505
2588
|
timeoutMs: input.timeoutMs,
|
|
2506
2589
|
signal: input.signal,
|
|
2590
|
+
assertActive: input.assertActive,
|
|
2507
2591
|
onElicitation: input.onElicitation,
|
|
2508
2592
|
onPermissionRequest: input.onPermissionRequest
|
|
2509
2593
|
});
|
|
@@ -2616,6 +2700,6 @@ function createRuntimeStore(options) {
|
|
|
2616
2700
|
return createFileSessionStore(options);
|
|
2617
2701
|
}
|
|
2618
2702
|
//#endregion
|
|
2619
|
-
export { ACPX_BACKEND_ID, AcpRuntimeError, AcpxRuntime, DEFAULT_AGENT_NAME, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, REQUESTED_MODEL_UNSUPPORTED_REASONS, RequestedModelUnsupportedError, SharedAcpRuntime, createAcpRuntime, createAgentRegistry, createFileSessionStore, createRuntimeStore, createSharedAcpRuntime, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, isAcpRuntimeError, isRequestedModelUnsupportedError };
|
|
2703
|
+
export { ACPX_BACKEND_ID, AcpRuntimeError, AcpxRuntime, DEFAULT_AGENT_NAME, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, REQUESTED_MODEL_UNSUPPORTED_REASONS, RequestedModelUnsupportedError, SharedAcpRuntime, createAcpRuntime, createAgentRegistry, createFileSessionStore, createRuntimeStore, createSharedAcpRuntime, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, inspectAgentModels, isAcpRuntimeError, isRequestedModelUnsupportedError };
|
|
2620
2704
|
|
|
2621
2705
|
//# sourceMappingURL=runtime.js.map
|