@moxt-ai/mobius 0.0.107 → 0.0.110
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/acp/process-session.d.ts +1 -8
- package/dist/acp/process-session.d.ts.map +1 -1
- package/dist/acp/process-session.js +1 -27
- package/dist/acp/process-session.js.map +1 -1
- package/dist/acp/session-manager.d.ts +3 -76
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +4 -103
- package/dist/acp/session-manager.js.map +1 -1
- package/dist/cli.js +29 -332
- package/dist/cli.js.map +3 -3
- package/dist/index.js +28 -331
- package/dist/index.js.map +3 -3
- package/dist/native-sessions/acp-adapter.d.ts.map +1 -1
- package/dist/native-sessions/acp-adapter.js +0 -1
- package/dist/native-sessions/acp-adapter.js.map +1 -1
- package/dist/native-sessions/agent-adapter.d.ts +0 -1
- package/dist/native-sessions/agent-adapter.d.ts.map +1 -1
- package/dist/native-sessions/agent-adapter.js +0 -3
- package/dist/native-sessions/agent-adapter.js.map +1 -1
- package/dist/native-sessions/codex-adapter.d.ts.map +1 -1
- package/dist/native-sessions/codex-adapter.js +0 -1
- package/dist/native-sessions/codex-adapter.js.map +1 -1
- package/dist/native-sessions/handle-native-requests.d.ts +2 -3
- package/dist/native-sessions/handle-native-requests.d.ts.map +1 -1
- package/dist/native-sessions/handle-native-requests.js +5 -11
- package/dist/native-sessions/handle-native-requests.js.map +1 -1
- package/dist/native-sessions/service.d.ts +1 -2
- package/dist/native-sessions/service.d.ts.map +1 -1
- package/dist/native-sessions/service.js +2 -105
- package/dist/native-sessions/service.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +18 -2
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +30 -333
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -25616,8 +25616,6 @@ var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
|
|
|
25616
25616
|
var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
25617
25617
|
var NATIVE_SESSION_RESULT_KIND = "native.session.result";
|
|
25618
25618
|
var NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
|
|
25619
|
-
var NATIVE_SESSION_TURN_FORK_REQUEST_KIND = "native.session.turn-fork.request";
|
|
25620
|
-
var NATIVE_SESSION_TURN_FORK_KIND = "native.session.turn-fork";
|
|
25621
25619
|
var ACTIVE_TURN_TEXT_LIMIT = 1e6;
|
|
25622
25620
|
var identifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/);
|
|
25623
25621
|
var directoryId = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
|
|
@@ -25633,31 +25631,8 @@ var identity = {
|
|
|
25633
25631
|
bindingId: identifier,
|
|
25634
25632
|
directoryId
|
|
25635
25633
|
};
|
|
25636
|
-
var turnForkIdentity = {
|
|
25637
|
-
additionalDirectoryIds: external_exports.array(directoryId).max(16).readonly(),
|
|
25638
|
-
agentId: identifier,
|
|
25639
|
-
bindingId: identifier,
|
|
25640
|
-
directoryId,
|
|
25641
|
-
requestId: identifier,
|
|
25642
|
-
sessionId: identifier,
|
|
25643
|
-
sourceCommandId: identifier,
|
|
25644
|
-
targetSessionId: identifier
|
|
25645
|
-
};
|
|
25646
|
-
var nativeSessionTurnForkRequestSchema = external_exports.strictObject({
|
|
25647
|
-
...turnForkIdentity,
|
|
25648
|
-
kind: external_exports.literal(NATIVE_SESSION_TURN_FORK_REQUEST_KIND)
|
|
25649
|
-
}).readonly();
|
|
25650
|
-
var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
|
|
25651
|
-
...turnForkIdentity,
|
|
25652
|
-
kind: external_exports.literal(NATIVE_SESSION_TURN_FORK_KIND),
|
|
25653
|
-
messageFingerprint: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
25654
|
-
messageId: external_exports.string().min(1).max(255),
|
|
25655
|
-
messageOccurrence: external_exports.number().int().positive(),
|
|
25656
|
-
title: external_exports.string().max(500)
|
|
25657
|
-
}).readonly();
|
|
25658
25634
|
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
25659
25635
|
external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
25660
|
-
external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
|
|
25661
25636
|
external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifier }).readonly(),
|
|
25662
25637
|
external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
|
|
25663
25638
|
external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
|
|
@@ -25681,7 +25656,6 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
25681
25656
|
]);
|
|
25682
25657
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
25683
25658
|
external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
25684
|
-
external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
|
|
25685
25659
|
external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifier }).readonly(),
|
|
25686
25660
|
external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
|
|
25687
25661
|
external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
|
|
@@ -25697,12 +25671,6 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
|
25697
25671
|
entryId: identifier,
|
|
25698
25672
|
targetSessionId: identifier
|
|
25699
25673
|
}).readonly(),
|
|
25700
|
-
external_exports.strictObject({
|
|
25701
|
-
...identity,
|
|
25702
|
-
action: external_exports.enum(["import-only", "fork-only"]),
|
|
25703
|
-
entryId: identifier,
|
|
25704
|
-
targetSessionId: identifier
|
|
25705
|
-
}).readonly(),
|
|
25706
25674
|
external_exports.strictObject({
|
|
25707
25675
|
...identity,
|
|
25708
25676
|
action: external_exports.literal("delete"),
|
|
@@ -25725,12 +25693,6 @@ var resultEnvelope = {
|
|
|
25725
25693
|
};
|
|
25726
25694
|
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
25727
25695
|
external_exports.strictObject({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifier }).readonly(),
|
|
25728
|
-
external_exports.strictObject({
|
|
25729
|
-
...resultEnvelope,
|
|
25730
|
-
action: external_exports.literal("linked-history"),
|
|
25731
|
-
targetSessionId: identifier,
|
|
25732
|
-
history: sessionHistorySchema
|
|
25733
|
-
}).readonly(),
|
|
25734
25696
|
external_exports.strictObject({
|
|
25735
25697
|
...resultEnvelope,
|
|
25736
25698
|
action: external_exports.literal("active-turn"),
|
|
@@ -25749,11 +25711,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
25749
25711
|
state: external_exports.literal("running")
|
|
25750
25712
|
}).readonly().nullable()
|
|
25751
25713
|
}).readonly(),
|
|
25752
|
-
external_exports.strictObject({
|
|
25753
|
-
...resultEnvelope,
|
|
25754
|
-
action: external_exports.literal("unlinked-history"),
|
|
25755
|
-
targetSessionId: identifier
|
|
25756
|
-
}).readonly(),
|
|
25757
25714
|
external_exports.strictObject({
|
|
25758
25715
|
...resultEnvelope,
|
|
25759
25716
|
action: external_exports.literal("find"),
|
|
@@ -25771,7 +25728,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
25771
25728
|
action: external_exports.enum(["import", "fork"]),
|
|
25772
25729
|
targetSessionId: identifier,
|
|
25773
25730
|
ready: sessionReadyEventSchema,
|
|
25774
|
-
history: sessionHistorySchema,
|
|
25775
25731
|
title: external_exports.string().max(500)
|
|
25776
25732
|
}).readonly(),
|
|
25777
25733
|
external_exports.strictObject({
|
|
@@ -25812,8 +25768,6 @@ var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema,
|
|
|
25812
25768
|
var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
|
|
25813
25769
|
var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
|
|
25814
25770
|
var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
|
|
25815
|
-
var decodeNativeSessionTurnForkCommand = (encoded) => decode4(nativeSessionTurnForkCommandSchema, encoded);
|
|
25816
|
-
var encodeNativeSessionTurnForkCommand = (value) => JSON.stringify(nativeSessionTurnForkCommandSchema.parse(value));
|
|
25817
25771
|
|
|
25818
25772
|
// ../protocol/src/session-events.ts
|
|
25819
25773
|
var SESSION_EVENT_KIND = "session.event";
|
|
@@ -26000,11 +25954,6 @@ var serviceToDaemonSignatures = {
|
|
|
26000
25954
|
encodeNativeSessionCommand,
|
|
26001
25955
|
decodeNativeSessionCommand
|
|
26002
25956
|
),
|
|
26003
|
-
[NATIVE_SESSION_TURN_FORK_KIND]: defineMessageSignature(
|
|
26004
|
-
NATIVE_SESSION_TURN_FORK_KIND,
|
|
26005
|
-
encodeNativeSessionTurnForkCommand,
|
|
26006
|
-
decodeNativeSessionTurnForkCommand
|
|
26007
|
-
),
|
|
26008
25957
|
[RUNTIME_HEARTBEAT_ACK_KIND]: defineMessageSignature(
|
|
26009
25958
|
RUNTIME_HEARTBEAT_ACK_KIND,
|
|
26010
25959
|
encodeRuntimeHeartbeatAckEvent,
|
|
@@ -28068,15 +28017,6 @@ var PendingElicitation = class {
|
|
|
28068
28017
|
var PROCESS_STOP_TIMEOUT_MILLISECONDS = 1e3;
|
|
28069
28018
|
var MAX_PRE_SESSION_UPDATES = 100;
|
|
28070
28019
|
var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
|
|
28071
|
-
function nativeHistoryNotRetained() {
|
|
28072
|
-
return {
|
|
28073
|
-
cause: {
|
|
28074
|
-
code: "native_history_not_retained",
|
|
28075
|
-
message: "Native message history is not retained in the cloud for this Session."
|
|
28076
|
-
},
|
|
28077
|
-
status: "unavailable"
|
|
28078
|
-
};
|
|
28079
|
-
}
|
|
28080
28020
|
var NullAcpSessionObserver = class {
|
|
28081
28021
|
onCommands = () => Promise.resolve();
|
|
28082
28022
|
onConfig = () => Promise.resolve();
|
|
@@ -28363,17 +28303,6 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
28363
28303
|
async (runtime) => await runtime.#initializeAgent(options.signal),
|
|
28364
28304
|
unmeasuredOperationMetrics
|
|
28365
28305
|
);
|
|
28366
|
-
static startSessionForkAtTurn = async (options, sourceNativeSessionId, forkPoint, getObserver, store) => await _AcpProcessSession.#start(
|
|
28367
|
-
options,
|
|
28368
|
-
getObserver,
|
|
28369
|
-
store,
|
|
28370
|
-
async (runtime) => await runtime.initialize(
|
|
28371
|
-
options.signal,
|
|
28372
|
-
{ kind: "fork", nativeSessionId: sourceNativeSessionId },
|
|
28373
|
-
forkPoint
|
|
28374
|
-
),
|
|
28375
|
-
unmeasuredOperationMetrics
|
|
28376
|
-
);
|
|
28377
28306
|
belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
|
|
28378
28307
|
usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
|
|
28379
28308
|
canRebind = () => !this.#prompted && !this.#turn.running;
|
|
@@ -28556,7 +28485,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
28556
28485
|
128
|
|
28557
28486
|
);
|
|
28558
28487
|
}
|
|
28559
|
-
initialize = async (signal, origin
|
|
28488
|
+
initialize = async (signal, origin) => {
|
|
28560
28489
|
await this.#initializeAgent(signal);
|
|
28561
28490
|
let stored = this.#metrics.measureSync(
|
|
28562
28491
|
"session-state-read",
|
|
@@ -28608,21 +28537,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
28608
28537
|
sessionId: nativeSessionIdSchema.parse(origin.nativeSessionId),
|
|
28609
28538
|
cwd: this.#cwd,
|
|
28610
28539
|
additionalDirectories: [...this.#additionalDirectories],
|
|
28611
|
-
mcpServers: []
|
|
28612
|
-
...forkPoint === void 0 ? {} : {
|
|
28613
|
-
_meta: {
|
|
28614
|
-
jetbrains: {
|
|
28615
|
-
air: {
|
|
28616
|
-
fork: {
|
|
28617
|
-
version: 1,
|
|
28618
|
-
messageFingerprint: forkPoint.messageFingerprint,
|
|
28619
|
-
messageId: forkPoint.messageId,
|
|
28620
|
-
messageOccurrence: forkPoint.messageOccurrence
|
|
28621
|
-
}
|
|
28622
|
-
}
|
|
28623
|
-
}
|
|
28624
|
-
}
|
|
28625
|
-
}
|
|
28540
|
+
mcpServers: []
|
|
28626
28541
|
},
|
|
28627
28542
|
{ cancellationSignal: signal }
|
|
28628
28543
|
),
|
|
@@ -29848,7 +29763,7 @@ var AcpSessionManager = class {
|
|
|
29848
29763
|
return await this.#startRetainedSessionProcess(
|
|
29849
29764
|
options,
|
|
29850
29765
|
async () => await AcpProcessSession.start(
|
|
29851
|
-
this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
|
|
29766
|
+
options.origin === void 0 && this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
|
|
29852
29767
|
() => this.#observer,
|
|
29853
29768
|
this.#store,
|
|
29854
29769
|
metrics
|
|
@@ -29862,27 +29777,6 @@ var AcpSessionManager = class {
|
|
|
29862
29777
|
this.#preparing.set(options.sessionId, operation);
|
|
29863
29778
|
return await operation;
|
|
29864
29779
|
}
|
|
29865
|
-
async #startSessionForkAtTurnPreparation(options, sourceNativeSessionId, forkPoint) {
|
|
29866
|
-
const operation = (async () => {
|
|
29867
|
-
try {
|
|
29868
|
-
return await this.#startRetainedSessionProcess(
|
|
29869
|
-
options,
|
|
29870
|
-
async () => await AcpProcessSession.startSessionForkAtTurn(
|
|
29871
|
-
options,
|
|
29872
|
-
sourceNativeSessionId,
|
|
29873
|
-
forkPoint,
|
|
29874
|
-
() => this.#observer,
|
|
29875
|
-
this.#store
|
|
29876
|
-
)
|
|
29877
|
-
);
|
|
29878
|
-
} finally {
|
|
29879
|
-
this.#preparing.delete(options.sessionId);
|
|
29880
|
-
this.#notifyProcessCapacityChanged();
|
|
29881
|
-
}
|
|
29882
|
-
})();
|
|
29883
|
-
this.#preparing.set(options.sessionId, operation);
|
|
29884
|
-
return await operation;
|
|
29885
|
-
}
|
|
29886
29780
|
async #replacePreparation(existing, options, metrics) {
|
|
29887
29781
|
const operation = (async () => {
|
|
29888
29782
|
try {
|
|
@@ -30412,26 +30306,7 @@ var AcpSessionManager = class {
|
|
|
30412
30306
|
this.#endSessionUse(options.sessionId);
|
|
30413
30307
|
}
|
|
30414
30308
|
};
|
|
30415
|
-
|
|
30416
|
-
options.signal.throwIfAborted();
|
|
30417
|
-
const stored = this.#store.read(options.sessionId);
|
|
30418
|
-
if (!(stored instanceof FoundAcpStoredSession) || !stored.session.prompted) {
|
|
30419
|
-
return null;
|
|
30420
|
-
}
|
|
30421
|
-
const linked = stored.session;
|
|
30422
|
-
if (linked.agentId !== options.agent.id || linked.cwd !== options.cwd || linked.additionalDirectories.length !== options.additionalDirectories.length || linked.additionalDirectories.some((directory, index) => directory !== options.additionalDirectories[index])) {
|
|
30423
|
-
throw new AcpExecutionError(
|
|
30424
|
-
"The session belongs to another Agent or workspace",
|
|
30425
|
-
{},
|
|
30426
|
-
"session_identity_mismatch"
|
|
30427
|
-
);
|
|
30428
|
-
}
|
|
30429
|
-
if (this.#nativeHistoryReader === null) {
|
|
30430
|
-
return await this.loadSessionHistory(options);
|
|
30431
|
-
}
|
|
30432
|
-
return await this.#nativeHistoryReader.read(options, linked.nativeSessionId) ?? await this.loadSessionHistory(options);
|
|
30433
|
-
};
|
|
30434
|
-
openNativeSession = async (options, origin, loadHistory) => {
|
|
30309
|
+
openNativeSession = async (options, origin) => {
|
|
30435
30310
|
const key = `${options.agent.id}:${origin.nativeSessionId}`;
|
|
30436
30311
|
if (this.#nativeOperations.has(key)) {
|
|
30437
30312
|
throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
|
|
@@ -30461,19 +30336,10 @@ var AcpSessionManager = class {
|
|
|
30461
30336
|
}
|
|
30462
30337
|
this.#nativeOperations.add(key);
|
|
30463
30338
|
try {
|
|
30464
|
-
const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
|
|
30465
30339
|
return {
|
|
30466
30340
|
prepared: runtime.prepared(),
|
|
30467
|
-
sessionId: existing.sessionId
|
|
30468
|
-
history
|
|
30341
|
+
sessionId: existing.sessionId
|
|
30469
30342
|
};
|
|
30470
|
-
} catch (error62) {
|
|
30471
|
-
await this.#retireSessionProcess(
|
|
30472
|
-
existing.sessionId,
|
|
30473
|
-
runtime,
|
|
30474
|
-
async () => await runtime.closeProcess()
|
|
30475
|
-
);
|
|
30476
|
-
throw error62;
|
|
30477
30343
|
} finally {
|
|
30478
30344
|
this.#nativeOperations.delete(key);
|
|
30479
30345
|
this.#notifyProcessCapacityChanged();
|
|
@@ -30492,16 +30358,10 @@ var AcpSessionManager = class {
|
|
|
30492
30358
|
const openedKey = `${options.agent.id}:${runtime.nativeSessionId()}`;
|
|
30493
30359
|
this.#nativeOperations.add(openedKey);
|
|
30494
30360
|
try {
|
|
30495
|
-
const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
|
|
30496
30361
|
return {
|
|
30497
30362
|
sessionId: options.sessionId,
|
|
30498
|
-
prepared: runtime.prepared()
|
|
30499
|
-
history
|
|
30363
|
+
prepared: runtime.prepared()
|
|
30500
30364
|
};
|
|
30501
|
-
} catch (error62) {
|
|
30502
|
-
this.#store.remove(options.sessionId);
|
|
30503
|
-
await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.closeProcess());
|
|
30504
|
-
throw error62;
|
|
30505
30365
|
} finally {
|
|
30506
30366
|
this.#nativeOperations.delete(openedKey);
|
|
30507
30367
|
this.#notifyProcessCapacityChanged();
|
|
@@ -30518,70 +30378,6 @@ var AcpSessionManager = class {
|
|
|
30518
30378
|
this.#endSessionUse(options.sessionId);
|
|
30519
30379
|
}
|
|
30520
30380
|
};
|
|
30521
|
-
forkSessionAtTurn = async (options, sourceSessionId, forkPoint) => {
|
|
30522
|
-
if (sourceSessionId === options.sessionId) {
|
|
30523
|
-
throw new AcpExecutionError(
|
|
30524
|
-
"The fork destination must be a new conversation",
|
|
30525
|
-
{},
|
|
30526
|
-
"session_identity_mismatch"
|
|
30527
|
-
);
|
|
30528
|
-
}
|
|
30529
|
-
const source = this.#store.read(sourceSessionId);
|
|
30530
|
-
if (!(source instanceof FoundAcpStoredSession) || !source.session.prompted) {
|
|
30531
|
-
throw new AcpExecutionError(
|
|
30532
|
-
"The source conversation has no resumable native Agent session",
|
|
30533
|
-
{},
|
|
30534
|
-
"native_session_not_found"
|
|
30535
|
-
);
|
|
30536
|
-
}
|
|
30537
|
-
if (source.session.agentId !== options.agent.id || source.session.cwd !== options.cwd || !arraysEqual(source.session.additionalDirectories, options.additionalDirectories)) {
|
|
30538
|
-
throw new AcpExecutionError(
|
|
30539
|
-
"The source conversation execution target does not match the fork request",
|
|
30540
|
-
{},
|
|
30541
|
-
"native_session_target_changed"
|
|
30542
|
-
);
|
|
30543
|
-
}
|
|
30544
|
-
const key = `${options.agent.id}:${source.session.nativeSessionId}`;
|
|
30545
|
-
const linked = this.#store.findNative(options.agent.id, source.session.nativeSessionId);
|
|
30546
|
-
if (this.#nativeOperations.has(key) || linked.some((entry) => this.#activeSessionIds.has(entry.sessionId) || this.#preparing.has(entry.sessionId))) {
|
|
30547
|
-
throw new AcpExecutionError(
|
|
30548
|
-
"Wait for the source conversation's running operation to finish",
|
|
30549
|
-
{},
|
|
30550
|
-
"session_busy"
|
|
30551
|
-
);
|
|
30552
|
-
}
|
|
30553
|
-
if (this.#sessions.has(options.sessionId) || this.#preparing.has(options.sessionId) || this.#store.read(options.sessionId) instanceof FoundAcpStoredSession || this.#store.read(options.sessionId) instanceof DeletedAcpStoredSession) {
|
|
30554
|
-
throw new AcpExecutionError("The destination conversation already exists", {}, "session_identity_mismatch");
|
|
30555
|
-
}
|
|
30556
|
-
this.#beginSessionUse(options.sessionId);
|
|
30557
|
-
this.#nativeOperations.add(key);
|
|
30558
|
-
try {
|
|
30559
|
-
const runtime = await this.#startSessionForkAtTurnPreparation(
|
|
30560
|
-
options,
|
|
30561
|
-
source.session.nativeSessionId,
|
|
30562
|
-
forkPoint
|
|
30563
|
-
);
|
|
30564
|
-
const openedKey = `${options.agent.id}:${runtime.nativeSessionId()}`;
|
|
30565
|
-
this.#nativeOperations.add(openedKey);
|
|
30566
|
-
try {
|
|
30567
|
-
return {
|
|
30568
|
-
history: await runtime.loadHistory(options.signal),
|
|
30569
|
-
prepared: runtime.prepared(),
|
|
30570
|
-
sessionId: options.sessionId
|
|
30571
|
-
};
|
|
30572
|
-
} catch (error62) {
|
|
30573
|
-
this.#store.remove(options.sessionId);
|
|
30574
|
-
await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.closeProcess());
|
|
30575
|
-
throw error62;
|
|
30576
|
-
} finally {
|
|
30577
|
-
this.#nativeOperations.delete(openedKey);
|
|
30578
|
-
this.#notifyProcessCapacityChanged();
|
|
30579
|
-
}
|
|
30580
|
-
} finally {
|
|
30581
|
-
this.#nativeOperations.delete(key);
|
|
30582
|
-
this.#endSessionUse(options.sessionId);
|
|
30583
|
-
}
|
|
30584
|
-
};
|
|
30585
30381
|
deleteNativeSession = async (options, nativeSessionId) => {
|
|
30586
30382
|
this.#beginNativeBrowserUse(options.sessionId);
|
|
30587
30383
|
try {
|
|
@@ -34162,7 +33958,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
34162
33958
|
};
|
|
34163
33959
|
const handle = (command) => {
|
|
34164
33960
|
const previous = [...pending.values()].filter((request) => request.agentId === command.agentId);
|
|
34165
|
-
const parallelRead = command.
|
|
33961
|
+
const parallelRead = command.action === "active-turn";
|
|
34166
33962
|
if (pending.has(command.requestId) || pending.size >= 4 || !parallelRead && previous.some((request) => !request.controller.signal.aborted)) {
|
|
34167
33963
|
reportOperationFailure(
|
|
34168
33964
|
socket,
|
|
@@ -34183,7 +33979,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
34183
33979
|
const completion = (async () => {
|
|
34184
33980
|
try {
|
|
34185
33981
|
operationSignal.throwIfAborted();
|
|
34186
|
-
const skipPrevious = command.
|
|
33982
|
+
const skipPrevious = command.action === "active-turn";
|
|
34187
33983
|
if (previous.length > 0 && !skipPrevious) {
|
|
34188
33984
|
await new Promise((resolve8, reject) => {
|
|
34189
33985
|
const onAbort = () => reject(operationSignal.reason);
|
|
@@ -34201,13 +33997,13 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
34201
33997
|
});
|
|
34202
33998
|
}
|
|
34203
33999
|
operationSignal.throwIfAborted();
|
|
34204
|
-
const result =
|
|
34000
|
+
const result = await nativeSessions.execute(command, operationSignal);
|
|
34205
34001
|
if (socket.readyState === WebSocket5.OPEN) {
|
|
34206
34002
|
send(socket, result);
|
|
34207
34003
|
}
|
|
34208
34004
|
} catch (error62) {
|
|
34209
34005
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError("Native session operation cancelled", {}, "native_session_cancelled") : error62;
|
|
34210
|
-
const event =
|
|
34006
|
+
const event = "native_session_operation_failed";
|
|
34211
34007
|
audit.record({
|
|
34212
34008
|
commandId: command.requestId,
|
|
34213
34009
|
sessionId: command.sessionId,
|
|
@@ -34218,7 +34014,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
34218
34014
|
event,
|
|
34219
34015
|
command.requestId,
|
|
34220
34016
|
{
|
|
34221
|
-
|
|
34017
|
+
action: command.action,
|
|
34222
34018
|
agentId: command.agentId,
|
|
34223
34019
|
code: operationErrorCode(failure2),
|
|
34224
34020
|
sessionId: command.sessionId
|
|
@@ -34246,7 +34042,6 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
34246
34042
|
|
|
34247
34043
|
// src/native-sessions/service.ts
|
|
34248
34044
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
34249
|
-
import { basename as basename6 } from "node:path";
|
|
34250
34045
|
|
|
34251
34046
|
// src/native-sessions/acp-history.ts
|
|
34252
34047
|
async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
|
|
@@ -34282,7 +34077,6 @@ async function readAcpHistory(sessions, directories, bindingId, options, nativeS
|
|
|
34282
34077
|
|
|
34283
34078
|
// src/native-sessions/acp-adapter.ts
|
|
34284
34079
|
var acpSessionAdapter = {
|
|
34285
|
-
linkedHistory: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
|
|
34286
34080
|
history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
|
|
34287
34081
|
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
34288
34082
|
};
|
|
@@ -34302,7 +34096,6 @@ async function verifiedHistory(context, full) {
|
|
|
34302
34096
|
return snapshot.history;
|
|
34303
34097
|
}
|
|
34304
34098
|
var codexSessionAdapter = {
|
|
34305
|
-
linkedHistory: async (context) => await verifiedHistory(context, true),
|
|
34306
34099
|
history: async (context) => await verifiedHistory(context, true),
|
|
34307
34100
|
// Codex enforces an exclusive writer per thread. Its read-only app-server
|
|
34308
34101
|
// history path keeps externally owned conversations previewable.
|
|
@@ -34311,9 +34104,6 @@ var codexSessionAdapter = {
|
|
|
34311
34104
|
|
|
34312
34105
|
// src/native-sessions/agent-adapter.ts
|
|
34313
34106
|
var genericSessionAdapter = {
|
|
34314
|
-
linkedHistory: async () => {
|
|
34315
|
-
throw new AcpExecutionError("This Agent does not support Chat history", {}, "native_session_unsupported");
|
|
34316
|
-
},
|
|
34317
34107
|
history: async () => {
|
|
34318
34108
|
throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
|
|
34319
34109
|
},
|
|
@@ -34373,42 +34163,6 @@ var NativeSessionService = class {
|
|
|
34373
34163
|
turn: this.#activeTurn(command)
|
|
34374
34164
|
};
|
|
34375
34165
|
}
|
|
34376
|
-
if (command.action === "linked-history") {
|
|
34377
|
-
const nativeSessionId = nativeSessionIdSchema.parse(command.targetSessionId);
|
|
34378
|
-
if (this.#sessions.hasPreparedSession(nativeSessionId, options.agent.id, cwd, additionalDirectories) && await this.#sessions.loadLinkedSessionHistory({ ...options, sessionId: nativeSessionId }) === null) {
|
|
34379
|
-
this.record(command, "native_session_history_read");
|
|
34380
|
-
return {
|
|
34381
|
-
action: "linked-history",
|
|
34382
|
-
history: {
|
|
34383
|
-
status: "available",
|
|
34384
|
-
messages: [],
|
|
34385
|
-
truncated: false,
|
|
34386
|
-
coveredCommandIds: [],
|
|
34387
|
-
coveredMessageIds: []
|
|
34388
|
-
},
|
|
34389
|
-
kind: "native.session.result",
|
|
34390
|
-
requestId: command.requestId,
|
|
34391
|
-
sessionId: command.sessionId,
|
|
34392
|
-
targetSessionId: command.targetSessionId
|
|
34393
|
-
};
|
|
34394
|
-
}
|
|
34395
|
-
const history = await nativeSessionAdapter(options.agent.id).linkedHistory({
|
|
34396
|
-
sessions: this.#sessions,
|
|
34397
|
-
directories: this.#directories,
|
|
34398
|
-
bindingId: command.bindingId,
|
|
34399
|
-
options,
|
|
34400
|
-
nativeSessionId
|
|
34401
|
-
});
|
|
34402
|
-
this.record(command, "native_session_history_read");
|
|
34403
|
-
return {
|
|
34404
|
-
action: "linked-history",
|
|
34405
|
-
history,
|
|
34406
|
-
kind: "native.session.result",
|
|
34407
|
-
requestId: command.requestId,
|
|
34408
|
-
sessionId: command.sessionId,
|
|
34409
|
-
targetSessionId: command.targetSessionId
|
|
34410
|
-
};
|
|
34411
|
-
}
|
|
34412
34166
|
if (command.action === "create") {
|
|
34413
34167
|
if (!supportsNativeChat(options.agent.id)) {
|
|
34414
34168
|
throw new AcpExecutionError(
|
|
@@ -34619,7 +34373,7 @@ var NativeSessionService = class {
|
|
|
34619
34373
|
deletedSessionIds
|
|
34620
34374
|
};
|
|
34621
34375
|
}
|
|
34622
|
-
const action = command.action
|
|
34376
|
+
const action = command.action;
|
|
34623
34377
|
if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
|
|
34624
34378
|
throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
|
|
34625
34379
|
}
|
|
@@ -34644,8 +34398,7 @@ var NativeSessionService = class {
|
|
|
34644
34398
|
sessionId: command.targetSessionId,
|
|
34645
34399
|
additionalDirectories: target.additionalDirectories
|
|
34646
34400
|
},
|
|
34647
|
-
{ kind: action, nativeSessionId: target.info.sessionId }
|
|
34648
|
-
command.action !== "import-only" && command.action !== "fork-only"
|
|
34401
|
+
{ kind: action, nativeSessionId: target.info.sessionId }
|
|
34649
34402
|
);
|
|
34650
34403
|
signal.throwIfAborted();
|
|
34651
34404
|
const ready = {
|
|
@@ -34669,8 +34422,7 @@ var NativeSessionService = class {
|
|
|
34669
34422
|
action,
|
|
34670
34423
|
ready,
|
|
34671
34424
|
targetSessionId: command.targetSessionId,
|
|
34672
|
-
title: target.info.title ?? "Untitled session"
|
|
34673
|
-
history: opened.history
|
|
34425
|
+
title: target.info.title ?? "Untitled session"
|
|
34674
34426
|
};
|
|
34675
34427
|
};
|
|
34676
34428
|
querySessions = async (sessionIds, signal) => {
|
|
@@ -34696,74 +34448,6 @@ var NativeSessionService = class {
|
|
|
34696
34448
|
}
|
|
34697
34449
|
return entries;
|
|
34698
34450
|
};
|
|
34699
|
-
executeTurnFork = async (command, signal) => {
|
|
34700
|
-
signal.throwIfAborted();
|
|
34701
|
-
const cwd = await this.#directories.resolve(this.#config.bindingId, command.directoryId, signal);
|
|
34702
|
-
const additionalDirectories = [];
|
|
34703
|
-
const additionalEntries = [];
|
|
34704
|
-
const resolvedPaths = /* @__PURE__ */ new Set([cwd]);
|
|
34705
|
-
for (const directoryId2 of command.additionalDirectoryIds) {
|
|
34706
|
-
const path2 = await this.#directories.resolve(this.#config.bindingId, directoryId2, signal);
|
|
34707
|
-
if (resolvedPaths.has(path2)) {
|
|
34708
|
-
throw new LocalAuthorizationError("Workspace directories must resolve to distinct locations");
|
|
34709
|
-
}
|
|
34710
|
-
resolvedPaths.add(path2);
|
|
34711
|
-
additionalDirectories.push(path2);
|
|
34712
|
-
additionalEntries.push({ directoryId: directoryId2, name: basename6(path2) });
|
|
34713
|
-
}
|
|
34714
|
-
const listing = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
|
|
34715
|
-
const opened = await this.#sessions.forkSessionAtTurn(
|
|
34716
|
-
{
|
|
34717
|
-
additionalDirectories,
|
|
34718
|
-
agent: this.#config.catalog.find(command.agentId),
|
|
34719
|
-
cwd,
|
|
34720
|
-
sessionId: command.targetSessionId,
|
|
34721
|
-
signal
|
|
34722
|
-
},
|
|
34723
|
-
command.sessionId,
|
|
34724
|
-
{
|
|
34725
|
-
messageFingerprint: command.messageFingerprint,
|
|
34726
|
-
messageId: command.messageId,
|
|
34727
|
-
messageOccurrence: command.messageOccurrence
|
|
34728
|
-
}
|
|
34729
|
-
);
|
|
34730
|
-
signal.throwIfAborted();
|
|
34731
|
-
const ready = {
|
|
34732
|
-
additionalDirectories: additionalEntries,
|
|
34733
|
-
agentId: command.agentId,
|
|
34734
|
-
agentName: opened.prepared.agentName,
|
|
34735
|
-
agentVersion: opened.prepared.agentVersion,
|
|
34736
|
-
capabilities: opened.prepared.capabilities,
|
|
34737
|
-
commands: opened.prepared.commands,
|
|
34738
|
-
configOptions: opened.prepared.configOptions,
|
|
34739
|
-
directoryId: command.directoryId,
|
|
34740
|
-
directoryLabel: listing.directoryLabel,
|
|
34741
|
-
kind: "session.ready",
|
|
34742
|
-
requestId: command.requestId,
|
|
34743
|
-
restored: true,
|
|
34744
|
-
sessionId: opened.sessionId
|
|
34745
|
-
};
|
|
34746
|
-
this.#audit.record({
|
|
34747
|
-
commandId: command.requestId,
|
|
34748
|
-
details: {
|
|
34749
|
-
agentId: command.agentId,
|
|
34750
|
-
messageId: command.messageId,
|
|
34751
|
-
sourceCommandId: command.sourceCommandId
|
|
34752
|
-
},
|
|
34753
|
-
event: "native_session_turn_forked",
|
|
34754
|
-
sessionId: command.sessionId
|
|
34755
|
-
});
|
|
34756
|
-
return {
|
|
34757
|
-
action: "fork",
|
|
34758
|
-
history: opened.history,
|
|
34759
|
-
kind: "native.session.result",
|
|
34760
|
-
ready,
|
|
34761
|
-
requestId: command.requestId,
|
|
34762
|
-
sessionId: command.sessionId,
|
|
34763
|
-
targetSessionId: command.targetSessionId,
|
|
34764
|
-
title: command.title
|
|
34765
|
-
};
|
|
34766
|
-
};
|
|
34767
34451
|
authorizeEntry = async (command, options, info) => {
|
|
34768
34452
|
try {
|
|
34769
34453
|
const primary = await this.#directories.identify(command.bindingId, info.cwd, options.signal);
|
|
@@ -35656,7 +35340,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
35656
35340
|
handleCatalogRefresh.handle(message);
|
|
35657
35341
|
return;
|
|
35658
35342
|
}
|
|
35659
|
-
if (kind === NATIVE_SESSION_REQUEST_KIND
|
|
35343
|
+
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
35660
35344
|
nativeRequestHandler.handle(message);
|
|
35661
35345
|
return;
|
|
35662
35346
|
}
|
|
@@ -35745,6 +35429,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
35745
35429
|
);
|
|
35746
35430
|
return;
|
|
35747
35431
|
}
|
|
35432
|
+
if (kind === SESSION_QUERY_KIND) {
|
|
35433
|
+
const command2 = message;
|
|
35434
|
+
void nativeSessions.querySessions(command2.sessionIds, connectionController.signal).then((entries) => {
|
|
35435
|
+
send(socket, {
|
|
35436
|
+
entries,
|
|
35437
|
+
kind: SESSION_QUERIED_KIND,
|
|
35438
|
+
requestId: command2.requestId
|
|
35439
|
+
});
|
|
35440
|
+
}).catch((error62) => {
|
|
35441
|
+
reportOperationFailure(socket, command2.requestId, "", error62);
|
|
35442
|
+
});
|
|
35443
|
+
return;
|
|
35444
|
+
}
|
|
35748
35445
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
35749
35446
|
const command2 = message;
|
|
35750
35447
|
void sessions.respondPermission(command2).then(() => {
|
|
@@ -36067,7 +35764,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
36067
35764
|
// src/pairing/pair-local-machine.ts
|
|
36068
35765
|
import { mkdir as mkdir5, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
36069
35766
|
import { hostname as hostname3 } from "node:os";
|
|
36070
|
-
import { basename as
|
|
35767
|
+
import { basename as basename6, resolve as resolve6 } from "node:path";
|
|
36071
35768
|
import { fetch as fetch5 } from "undici";
|
|
36072
35769
|
|
|
36073
35770
|
// src/storage/runtime-installation-store.ts
|
|
@@ -36711,7 +36408,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
36711
36408
|
installableAgents,
|
|
36712
36409
|
machineName: hostname3(),
|
|
36713
36410
|
pairingCode: options.code,
|
|
36714
|
-
workspaceName:
|
|
36411
|
+
workspaceName: basename6(defaultWorkspace) || "Local workspace"
|
|
36715
36412
|
}),
|
|
36716
36413
|
dispatcher: environmentProxyDispatcher,
|
|
36717
36414
|
headers: { "content-type": "application/json" },
|