@moxt-ai/mobius 0.0.169 → 0.0.172
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/agent-session.d.ts.map +1 -1
- package/dist/acp/agent-session.js +141 -42
- package/dist/acp/agent-session.js.map +1 -1
- package/dist/acp/codex/agent.d.ts.map +1 -1
- package/dist/acp/codex/agent.js +56 -31
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/acp/codex/items.d.ts +0 -9
- package/dist/acp/codex/items.d.ts.map +1 -1
- package/dist/acp/codex/items.js +0 -11
- package/dist/acp/codex/items.js.map +1 -1
- package/dist/acp/run-prompt.d.ts.map +1 -1
- package/dist/acp/run-prompt.js +7 -1
- package/dist/acp/run-prompt.js.map +1 -1
- package/dist/acp/session-contracts.d.ts +9 -4
- package/dist/acp/session-contracts.d.ts.map +1 -1
- package/dist/acp/session-contracts.js +1 -1
- package/dist/acp/session-contracts.js.map +1 -1
- package/dist/acp/session-history.d.ts +6 -3
- package/dist/acp/session-history.d.ts.map +1 -1
- package/dist/acp/session-history.js +41 -17
- package/dist/acp/session-history.js.map +1 -1
- package/dist/acp/session-interactions.d.ts +2 -0
- package/dist/acp/session-interactions.d.ts.map +1 -1
- package/dist/acp/session-interactions.js +36 -8
- package/dist/acp/session-interactions.js.map +1 -1
- package/dist/acp/session-store.d.ts +0 -13
- package/dist/acp/session-store.d.ts.map +1 -1
- package/dist/acp/session-store.js +3 -65
- package/dist/acp/session-store.js.map +1 -1
- package/dist/cli.js +350 -511
- package/dist/cli.js.map +4 -4
- package/dist/daemon-command-handler.d.ts.map +1 -1
- package/dist/daemon-command-handler.js +3 -8
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-history-commands.d.ts +3 -3
- package/dist/daemon-history-commands.d.ts.map +1 -1
- package/dist/daemon-history-commands.js +10 -66
- package/dist/daemon-history-commands.js.map +1 -1
- package/dist/daemon-observers.d.ts +3 -3
- package/dist/daemon-observers.d.ts.map +1 -1
- package/dist/daemon-observers.js +2 -18
- package/dist/daemon-observers.js.map +1 -1
- package/dist/daemon-prompt-executor.d.ts.map +1 -1
- package/dist/daemon-prompt-executor.js +3 -1
- package/dist/daemon-prompt-executor.js.map +1 -1
- package/dist/index.js +356 -511
- package/dist/index.js.map +4 -4
- package/dist/native-sessions/codex-history.js +3 -3
- package/dist/native-sessions/codex-history.js.map +1 -1
- package/dist/native-sessions/live-history-page.d.ts +0 -1
- package/dist/native-sessions/live-history-page.d.ts.map +1 -1
- package/dist/native-sessions/live-history-page.js +0 -14
- package/dist/native-sessions/live-history-page.js.map +1 -1
- package/dist/relay-connection/session-event-publisher.d.ts +1 -6
- package/dist/relay-connection/session-event-publisher.d.ts.map +1 -1
- package/dist/relay-connection/session-event-publisher.js +2 -7
- package/dist/relay-connection/session-event-publisher.js.map +1 -1
- package/dist/run-daemon.js +2 -2
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +353 -514
- package/dist/runtime.js.map +4 -4
- package/dist/session-event-log-v2.d.ts +18 -9
- package/dist/session-event-log-v2.d.ts.map +1 -1
- package/dist/session-event-log-v2.js +39 -156
- package/dist/session-event-log-v2.js.map +1 -1
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -21494,10 +21494,7 @@ var lifecycleMetadataV2Schema = external_exports.discriminatedUnion("kind", [
|
|
|
21494
21494
|
external_exports.object({ kind: external_exports.literal("session.queue.changed") }).readonly(),
|
|
21495
21495
|
external_exports.object({ event: sessionPermissionRequestedEventSchema, kind: external_exports.literal("session.permission.requested") }).readonly(),
|
|
21496
21496
|
external_exports.object({ event: sessionPermissionResolvedEventSchema, kind: external_exports.literal("session.permission.resolved") }).readonly(),
|
|
21497
|
-
external_exports.object({
|
|
21498
|
-
event: sessionElicitationRequestedEventSchema,
|
|
21499
|
-
kind: external_exports.literal("session.elicitation.requested")
|
|
21500
|
-
}).readonly(),
|
|
21497
|
+
external_exports.object({ event: sessionElicitationRequestedEventSchema, kind: external_exports.literal("session.elicitation.requested") }).readonly(),
|
|
21501
21498
|
external_exports.object({ event: sessionElicitationResolvedEventSchema, kind: external_exports.literal("session.elicitation.resolved") }).readonly(),
|
|
21502
21499
|
external_exports.object({
|
|
21503
21500
|
...lifecycleBase,
|
|
@@ -21599,6 +21596,7 @@ var mobiusSessionExportV2Schema = external_exports.object({
|
|
|
21599
21596
|
}).readonly();
|
|
21600
21597
|
var sessionEventEnvelopeV2Schema = external_exports.object({ event: sessionEventV2Schema, kind: external_exports.literal(SESSION_EVENT_V2_KIND) }).readonly();
|
|
21601
21598
|
var sessionEventLogPageV2Schema = external_exports.object({
|
|
21599
|
+
daemonGenerationId: identifierStringSchema,
|
|
21602
21600
|
events: external_exports.array(sessionEventV2Schema).max(MAX_EVENT_COUNT).readonly(),
|
|
21603
21601
|
nextCursor: external_exports.string().min(1).max(512).nullable(),
|
|
21604
21602
|
tailCursor: external_exports.string().max(512),
|
|
@@ -21606,17 +21604,13 @@ var sessionEventLogPageV2Schema = external_exports.object({
|
|
|
21606
21604
|
version: external_exports.literal(2)
|
|
21607
21605
|
}).readonly();
|
|
21608
21606
|
var nativeEventPageRequestV2Schema = external_exports.object({ cursor: external_exports.string().min(1).max(512).nullable(), eventLimit: external_exports.number().int().min(1).max(1e4) }).readonly();
|
|
21609
|
-
var
|
|
21610
|
-
attemptId: identifierStringSchema,
|
|
21607
|
+
var queuedPromptRequestEventLogV2Schema = external_exports.object({
|
|
21611
21608
|
commandId: identifierStringSchema,
|
|
21612
|
-
|
|
21613
|
-
events: external_exports.array(sessionEventV2Schema).max(MAX_EVENT_COUNT).readonly(),
|
|
21614
|
-
tailCursor: external_exports.string().max(512),
|
|
21615
|
-
truncated: external_exports.boolean()
|
|
21609
|
+
content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly()
|
|
21616
21610
|
}).readonly();
|
|
21617
21611
|
var nativeSessionEventsV2Schema = external_exports.object({
|
|
21618
|
-
|
|
21619
|
-
|
|
21612
|
+
events: sessionEventLogPageV2Schema,
|
|
21613
|
+
queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogV2Schema).max(MAX_COLLECTION_SIZE).readonly()
|
|
21620
21614
|
}).readonly();
|
|
21621
21615
|
function inputValue(value) {
|
|
21622
21616
|
if (typeof value !== "string") {
|
|
@@ -21640,7 +21634,6 @@ function decode5(value, schema) {
|
|
|
21640
21634
|
function encode4(value, schema) {
|
|
21641
21635
|
return JSON.stringify(decode5(value, schema));
|
|
21642
21636
|
}
|
|
21643
|
-
var decodeSessionEventV2 = (value) => decode5(value, sessionEventV2Schema);
|
|
21644
21637
|
var decodeSessionEventEnvelopeV2 = (value) => decode5(value, sessionEventEnvelopeV2Schema);
|
|
21645
21638
|
var encodeSessionEventEnvelopeV2 = (value) => encode4(value, sessionEventEnvelopeV2Schema);
|
|
21646
21639
|
var decodeAcpSessionUpdateV2 = (value) => decode5(value, acpSessionUpdateV2Schema);
|
|
@@ -21734,28 +21727,11 @@ function decodeRecordedSessionEvent(encoded) {
|
|
|
21734
21727
|
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
21735
21728
|
|
|
21736
21729
|
// ../protocol/src/session-live-history.ts
|
|
21737
|
-
var SESSION_LIVE_HISTORY_LOAD_KIND = "session.live-history.load";
|
|
21738
|
-
var SESSION_LIVE_HISTORY_LOADED_KIND = "session.live-history.loaded";
|
|
21739
21730
|
var SESSION_LIVE_HISTORY_PAGE_LOAD_KIND = "session.live-history.page.load";
|
|
21740
21731
|
var SESSION_LIVE_HISTORY_PAGE_LOADED_KIND = "session.live-history.page.loaded";
|
|
21741
21732
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
21742
21733
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
21743
21734
|
var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
|
|
21744
|
-
var sessionLiveHistoryLoadSchema = external_exports.object({
|
|
21745
|
-
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21746
|
-
agentId: identifierStringSchema,
|
|
21747
|
-
bindingId: identifierStringSchema,
|
|
21748
|
-
directoryId: directoryIdentifier,
|
|
21749
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_LOAD_KIND),
|
|
21750
|
-
requestId: identifierStringSchema,
|
|
21751
|
-
sessionId: identifierStringSchema
|
|
21752
|
-
}).readonly();
|
|
21753
|
-
var sessionLiveHistoryLoadedSchema = external_exports.object({
|
|
21754
|
-
history: sessionHistorySchema,
|
|
21755
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_LOADED_KIND),
|
|
21756
|
-
requestId: identifierStringSchema,
|
|
21757
|
-
sessionId: identifierStringSchema
|
|
21758
|
-
}).readonly();
|
|
21759
21735
|
var sessionLiveHistoryPageLoadSchema = external_exports.object({
|
|
21760
21736
|
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21761
21737
|
agentId: identifierStringSchema,
|
|
@@ -21798,10 +21774,6 @@ function decode7(schema, encoded) {
|
|
|
21798
21774
|
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
21799
21775
|
}
|
|
21800
21776
|
}
|
|
21801
|
-
var decodeSessionLiveHistoryLoad = (encoded) => decode7(sessionLiveHistoryLoadSchema, encoded);
|
|
21802
|
-
var decodeSessionLiveHistoryLoaded = (encoded) => decode7(sessionLiveHistoryLoadedSchema, encoded);
|
|
21803
|
-
var encodeSessionLiveHistoryLoad = (value) => JSON.stringify(sessionLiveHistoryLoadSchema.parse(value));
|
|
21804
|
-
var encodeSessionLiveHistoryLoaded = (value) => JSON.stringify(sessionLiveHistoryLoadedSchema.parse(value));
|
|
21805
21777
|
var decodeSessionLiveHistoryPageLoad = (encoded) => decode7(sessionLiveHistoryPageLoadSchema, encoded);
|
|
21806
21778
|
var decodeSessionLiveHistoryPageLoaded = (encoded) => decode7(sessionLiveHistoryPageLoadedSchema, encoded);
|
|
21807
21779
|
var encodeSessionLiveHistoryPageLoad = (value) => JSON.stringify(sessionLiveHistoryPageLoadSchema.parse(value));
|
|
@@ -21884,11 +21856,6 @@ var serviceToDaemonSignatures = {
|
|
|
21884
21856
|
encodeSessionElicitationRespondCommand,
|
|
21885
21857
|
decodeSessionElicitationRespondCommand
|
|
21886
21858
|
),
|
|
21887
|
-
[SESSION_LIVE_HISTORY_LOAD_KIND]: defineMessageSignature(
|
|
21888
|
-
SESSION_LIVE_HISTORY_LOAD_KIND,
|
|
21889
|
-
encodeSessionLiveHistoryLoad,
|
|
21890
|
-
decodeSessionLiveHistoryLoad
|
|
21891
|
-
),
|
|
21892
21859
|
[SESSION_LIVE_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
21893
21860
|
SESSION_LIVE_HISTORY_PAGE_LOAD_KIND,
|
|
21894
21861
|
encodeSessionLiveHistoryPageLoad,
|
|
@@ -22029,11 +21996,6 @@ var daemonToServiceSignatures = {
|
|
|
22029
21996
|
encodeSessionOperationFailedEvent,
|
|
22030
21997
|
decodeSessionOperationFailedEvent
|
|
22031
21998
|
),
|
|
22032
|
-
[SESSION_LIVE_HISTORY_LOADED_KIND]: defineMessageSignature(
|
|
22033
|
-
SESSION_LIVE_HISTORY_LOADED_KIND,
|
|
22034
|
-
encodeSessionLiveHistoryLoaded,
|
|
22035
|
-
decodeSessionLiveHistoryLoaded
|
|
22036
|
-
),
|
|
22037
21999
|
[SESSION_LIVE_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
22038
22000
|
SESSION_LIVE_HISTORY_PAGE_LOADED_KIND,
|
|
22039
22001
|
encodeSessionLiveHistoryPageLoaded,
|
|
@@ -23982,7 +23944,6 @@ var CodexAppServerClient = class {
|
|
|
23982
23944
|
// src/acp/codex/items.ts
|
|
23983
23945
|
var TOOL_OUTPUT_CHARACTER_LIMIT = 32768;
|
|
23984
23946
|
var TITLE_CHARACTER_LIMIT = 500;
|
|
23985
|
-
var CODEX_META_KEY = "codex";
|
|
23986
23947
|
function truncate2(value, limit) {
|
|
23987
23948
|
return value.length <= limit ? value : value.slice(0, limit);
|
|
23988
23949
|
}
|
|
@@ -24121,12 +24082,6 @@ function reasoningText(item) {
|
|
|
24121
24082
|
}
|
|
24122
24083
|
return boundedParagraphs(item.summary.length > 0 ? item.summary : item.content, TOOL_OUTPUT_CHARACTER_LIMIT);
|
|
24123
24084
|
}
|
|
24124
|
-
function agentMessageMeta(phase) {
|
|
24125
|
-
if (phase == null) {
|
|
24126
|
-
return null;
|
|
24127
|
-
}
|
|
24128
|
-
return { [CODEX_META_KEY]: { phase } };
|
|
24129
|
-
}
|
|
24130
24085
|
|
|
24131
24086
|
// src/acp/codex/settings.ts
|
|
24132
24087
|
var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
|
|
@@ -24571,8 +24526,8 @@ function promptInput(prompt) {
|
|
|
24571
24526
|
function isCompactPrompt(prompt) {
|
|
24572
24527
|
return prompt.length === 1 && prompt[0]?.type === "text" && prompt[0].text.trim() === "/compact";
|
|
24573
24528
|
}
|
|
24574
|
-
function
|
|
24575
|
-
const
|
|
24529
|
+
function steeringPrompt(prompt) {
|
|
24530
|
+
const blocks = [];
|
|
24576
24531
|
for (const block of prompt) {
|
|
24577
24532
|
if (typeof block !== "object" || block === null) {
|
|
24578
24533
|
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
@@ -24583,7 +24538,7 @@ function steeringPromptInput(prompt) {
|
|
|
24583
24538
|
if (typeof text2 !== "string") {
|
|
24584
24539
|
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
24585
24540
|
}
|
|
24586
|
-
|
|
24541
|
+
blocks.push({ content: { text: text2, type: "text" }, input: { text: text2, text_elements: [], type: "text" } });
|
|
24587
24542
|
continue;
|
|
24588
24543
|
}
|
|
24589
24544
|
if (type === "image") {
|
|
@@ -24592,7 +24547,10 @@ function steeringPromptInput(prompt) {
|
|
|
24592
24547
|
if (typeof data !== "string" || typeof mimeType !== "string") {
|
|
24593
24548
|
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
24594
24549
|
}
|
|
24595
|
-
|
|
24550
|
+
blocks.push({
|
|
24551
|
+
content: { data, mimeType, type: "image" },
|
|
24552
|
+
input: { type: "image", url: `data:${mimeType};base64,${data}` }
|
|
24553
|
+
});
|
|
24596
24554
|
continue;
|
|
24597
24555
|
}
|
|
24598
24556
|
if (type === "resource") {
|
|
@@ -24600,24 +24558,40 @@ function steeringPromptInput(prompt) {
|
|
|
24600
24558
|
if (typeof resource !== "object" || resource === null) {
|
|
24601
24559
|
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
24602
24560
|
}
|
|
24561
|
+
const uri = Reflect.get(resource, "uri");
|
|
24603
24562
|
const text2 = Reflect.get(resource, "text");
|
|
24604
|
-
|
|
24563
|
+
const blob2 = Reflect.get(resource, "blob");
|
|
24564
|
+
if (typeof uri !== "string" || typeof text2 !== "string" && typeof blob2 !== "string" || text2 !== void 0 && typeof text2 !== "string" || blob2 !== void 0 && typeof blob2 !== "string") {
|
|
24605
24565
|
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
24606
24566
|
}
|
|
24607
|
-
|
|
24567
|
+
blocks.push({
|
|
24568
|
+
content: typeof text2 === "string" ? { resource: { text: text2, uri }, type: "resource" } : { resource: { blob: blob2, uri }, type: "resource" },
|
|
24569
|
+
input: { text: text2 ?? "", text_elements: [], type: "text" }
|
|
24570
|
+
});
|
|
24608
24571
|
continue;
|
|
24609
24572
|
}
|
|
24610
24573
|
if (type === "resource_link") {
|
|
24574
|
+
const name2 = Reflect.get(block, "name");
|
|
24611
24575
|
const uri = Reflect.get(block, "uri");
|
|
24612
|
-
if (typeof uri !== "string") {
|
|
24576
|
+
if (typeof name2 !== "string" || typeof uri !== "string") {
|
|
24613
24577
|
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
24614
24578
|
}
|
|
24615
|
-
|
|
24579
|
+
blocks.push({
|
|
24580
|
+
content: { name: name2, type: "resource_link", uri },
|
|
24581
|
+
input: { text: `Resource: ${uri}`, text_elements: [], type: "text" }
|
|
24582
|
+
});
|
|
24616
24583
|
continue;
|
|
24617
24584
|
}
|
|
24618
24585
|
throw new AcpExecutionError("Codex received an unsupported steering prompt", {}, "invalid_request");
|
|
24619
24586
|
}
|
|
24620
|
-
return
|
|
24587
|
+
return blocks;
|
|
24588
|
+
}
|
|
24589
|
+
function agentMessageUpdate(messageId, text2, phase) {
|
|
24590
|
+
return {
|
|
24591
|
+
content: { text: text2, type: "text" },
|
|
24592
|
+
messageId,
|
|
24593
|
+
sessionUpdate: phase === "commentary" ? "agent_thought_chunk" : "agent_message_chunk"
|
|
24594
|
+
};
|
|
24621
24595
|
}
|
|
24622
24596
|
function userInputSchema(questions) {
|
|
24623
24597
|
const properties = {};
|
|
@@ -24757,6 +24731,14 @@ var CodexAcpAgent = class {
|
|
|
24757
24731
|
if (isCompactPrompt(context.params.prompt)) {
|
|
24758
24732
|
return await this.#compact(context.signal);
|
|
24759
24733
|
}
|
|
24734
|
+
const messageId = crypto.randomUUID();
|
|
24735
|
+
for (const content of context.params.prompt) {
|
|
24736
|
+
await this.#emit({
|
|
24737
|
+
content,
|
|
24738
|
+
messageId,
|
|
24739
|
+
sessionUpdate: "user_message_chunk"
|
|
24740
|
+
});
|
|
24741
|
+
}
|
|
24760
24742
|
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
24761
24743
|
}).onRequest(
|
|
24762
24744
|
"_session/steering",
|
|
@@ -24844,12 +24826,7 @@ var CodexAcpAgent = class {
|
|
|
24844
24826
|
continue;
|
|
24845
24827
|
}
|
|
24846
24828
|
if (item.type === "agentMessage") {
|
|
24847
|
-
await this.#emit(
|
|
24848
|
-
_meta: agentMessageMeta(item.phase),
|
|
24849
|
-
content: { text: item.text, type: "text" },
|
|
24850
|
-
messageId: item.id,
|
|
24851
|
-
sessionUpdate: "agent_message_chunk"
|
|
24852
|
-
});
|
|
24829
|
+
await this.#emit(agentMessageUpdate(item.id, item.text, item.phase));
|
|
24853
24830
|
continue;
|
|
24854
24831
|
}
|
|
24855
24832
|
const update = toolCallUpdate(item, "snapshot");
|
|
@@ -24986,12 +24963,7 @@ var CodexAcpAgent = class {
|
|
|
24986
24963
|
const phase = this.#agentMessages.get(decoded.data.itemId)?.phase;
|
|
24987
24964
|
this.#agentMessages.set(decoded.data.itemId, { phase, kind: "streaming" });
|
|
24988
24965
|
await this.#enqueue(async () => {
|
|
24989
|
-
await this.#emit(
|
|
24990
|
-
_meta: agentMessageMeta(phase),
|
|
24991
|
-
content: { text: decoded.data.delta, type: "text" },
|
|
24992
|
-
messageId: decoded.data.itemId,
|
|
24993
|
-
sessionUpdate: "agent_message_chunk"
|
|
24994
|
-
});
|
|
24966
|
+
await this.#emit(agentMessageUpdate(decoded.data.itemId, decoded.data.delta, phase));
|
|
24995
24967
|
});
|
|
24996
24968
|
}
|
|
24997
24969
|
return;
|
|
@@ -25014,12 +24986,7 @@ var CodexAcpAgent = class {
|
|
|
25014
24986
|
return;
|
|
25015
24987
|
}
|
|
25016
24988
|
await this.#enqueue(async () => {
|
|
25017
|
-
await this.#emit(
|
|
25018
|
-
_meta: agentMessageMeta(item.phase),
|
|
25019
|
-
content: { text: item.text, type: "text" },
|
|
25020
|
-
messageId: item.id,
|
|
25021
|
-
sessionUpdate: "agent_message_chunk"
|
|
25022
|
-
});
|
|
24989
|
+
await this.#emit(agentMessageUpdate(item.id, item.text, item.phase));
|
|
25023
24990
|
});
|
|
25024
24991
|
return;
|
|
25025
24992
|
}
|
|
@@ -25253,14 +25220,22 @@ var CodexAcpAgent = class {
|
|
|
25253
25220
|
if (sessionId !== this.#nativeSessionId || active === null || active.turn.id.length === 0) {
|
|
25254
25221
|
return { outcome: "promptRequired", reason: "noRunningTurn" };
|
|
25255
25222
|
}
|
|
25256
|
-
const
|
|
25257
|
-
if (
|
|
25223
|
+
const steering = steeringPrompt(prompt);
|
|
25224
|
+
if (steering.length === 0) {
|
|
25258
25225
|
throw new AcpExecutionError("Codex received an empty steering request", {}, "invalid_request");
|
|
25259
25226
|
}
|
|
25227
|
+
const messageId = crypto.randomUUID();
|
|
25228
|
+
for (const block of steering) {
|
|
25229
|
+
await this.#emit({ content: block.content, messageId, sessionUpdate: "user_message_chunk" });
|
|
25230
|
+
}
|
|
25260
25231
|
const response = turnSteerResponseSchema.parse(
|
|
25261
25232
|
await this.#appServer.request(
|
|
25262
25233
|
"turn/steer",
|
|
25263
|
-
{
|
|
25234
|
+
{
|
|
25235
|
+
expectedTurnId: active.turn.id,
|
|
25236
|
+
input: steering.map((block) => block.input),
|
|
25237
|
+
threadId: this.#nativeSessionId
|
|
25238
|
+
},
|
|
25264
25239
|
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
25265
25240
|
)
|
|
25266
25241
|
);
|
|
@@ -27211,7 +27186,7 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
27211
27186
|
}
|
|
27212
27187
|
|
|
27213
27188
|
// src/run-daemon.ts
|
|
27214
|
-
import { createHash as createHash7, randomUUID as
|
|
27189
|
+
import { createHash as createHash7, randomUUID as randomUUID8 } from "node:crypto";
|
|
27215
27190
|
import { join as join18 } from "node:path";
|
|
27216
27191
|
import { styleText } from "node:util";
|
|
27217
27192
|
|
|
@@ -28760,7 +28735,7 @@ function sessionConfigProtocolForAgent(_agentId) {
|
|
|
28760
28735
|
|
|
28761
28736
|
// src/acp/session-contracts.ts
|
|
28762
28737
|
var NullAcpSessionObserver = class {
|
|
28763
|
-
|
|
28738
|
+
onSessionEventV2 = (_sessionId, _event, _position) => Promise.resolve();
|
|
28764
28739
|
onCommands = () => Promise.resolve();
|
|
28765
28740
|
onConfig = () => Promise.resolve();
|
|
28766
28741
|
onContent = () => Promise.resolve();
|
|
@@ -28828,7 +28803,8 @@ function historyContentCharacters(messages) {
|
|
|
28828
28803
|
var AcpHistoryReplay = class {
|
|
28829
28804
|
#activities = /* @__PURE__ */ new Map();
|
|
28830
28805
|
#messages = [];
|
|
28831
|
-
#
|
|
28806
|
+
#events = [];
|
|
28807
|
+
#records = [];
|
|
28832
28808
|
#turnActivityIds = /* @__PURE__ */ new Set();
|
|
28833
28809
|
#activityTracker = new AcpActivityTracker(
|
|
28834
28810
|
async (activity2) => {
|
|
@@ -28850,8 +28826,10 @@ var AcpHistoryReplay = class {
|
|
|
28850
28826
|
#firstMessageIndex = 0;
|
|
28851
28827
|
#characters = 0;
|
|
28852
28828
|
#truncated = false;
|
|
28853
|
-
record = async (update, rawUpdate) => {
|
|
28854
|
-
this.#
|
|
28829
|
+
record = async (update, rawUpdate, onRecorded = () => Promise.resolve()) => {
|
|
28830
|
+
this.#records.push({ kind: "acp", rawUpdate, update });
|
|
28831
|
+
this.#events.push({ payload: rawUpdate, type: "acp" });
|
|
28832
|
+
await onRecorded(this.#events.length);
|
|
28855
28833
|
if (update.sessionUpdate === "agent_thought_chunk") {
|
|
28856
28834
|
if (update.content.type === "text") {
|
|
28857
28835
|
await this.#activityTracker.recordNarrative(
|
|
@@ -28860,30 +28838,30 @@ var AcpHistoryReplay = class {
|
|
|
28860
28838
|
update.content.text
|
|
28861
28839
|
);
|
|
28862
28840
|
}
|
|
28863
|
-
return;
|
|
28841
|
+
return this.#events.length;
|
|
28864
28842
|
}
|
|
28865
28843
|
if (update.sessionUpdate === "tool_call") {
|
|
28866
28844
|
await this.#activityTracker.recordToolCall(update);
|
|
28867
|
-
return;
|
|
28845
|
+
return this.#events.length;
|
|
28868
28846
|
}
|
|
28869
28847
|
if (update.sessionUpdate === "tool_call_update") {
|
|
28870
28848
|
await this.#activityTracker.recordToolCallUpdate(update);
|
|
28871
|
-
return;
|
|
28849
|
+
return this.#events.length;
|
|
28872
28850
|
}
|
|
28873
28851
|
if (update.sessionUpdate === "plan") {
|
|
28874
28852
|
await this.#activityTracker.recordPlan(update);
|
|
28875
|
-
return;
|
|
28853
|
+
return this.#events.length;
|
|
28876
28854
|
}
|
|
28877
28855
|
if (update.sessionUpdate === "plan_update") {
|
|
28878
28856
|
await this.#activityTracker.recordPlanUpdate(update);
|
|
28879
|
-
return;
|
|
28857
|
+
return this.#events.length;
|
|
28880
28858
|
}
|
|
28881
28859
|
if (update.sessionUpdate === "plan_removed") {
|
|
28882
28860
|
await this.#activityTracker.removePlan(update);
|
|
28883
|
-
return;
|
|
28861
|
+
return this.#events.length;
|
|
28884
28862
|
}
|
|
28885
28863
|
if (update.sessionUpdate !== "user_message_chunk" && update.sessionUpdate !== "agent_message_chunk") {
|
|
28886
|
-
return;
|
|
28864
|
+
return this.#events.length;
|
|
28887
28865
|
}
|
|
28888
28866
|
if (update.sessionUpdate === "agent_message_chunk" && isProgressMessage(update)) {
|
|
28889
28867
|
if (update.content.type === "text") {
|
|
@@ -28893,18 +28871,18 @@ var AcpHistoryReplay = class {
|
|
|
28893
28871
|
update.content.text
|
|
28894
28872
|
);
|
|
28895
28873
|
}
|
|
28896
|
-
return;
|
|
28874
|
+
return this.#events.length;
|
|
28897
28875
|
}
|
|
28898
28876
|
const role = update.sessionUpdate === "user_message_chunk" ? "user" : "assistant";
|
|
28899
28877
|
const content = update.content;
|
|
28900
28878
|
if (role === "assistant" && content.type !== "text") {
|
|
28901
28879
|
await this.#activityTracker.finishNarrative();
|
|
28902
28880
|
this.recordAssistantContent(update.messageId ?? null, normalizeContentBlock(content));
|
|
28903
|
-
return;
|
|
28881
|
+
return this.#events.length;
|
|
28904
28882
|
}
|
|
28905
28883
|
const text2 = content.type === "text" ? content.text : content.type === "image" ? content.data.length > 0 ? `[@image](data:${content.mimeType};base64,${content.data})` : content.uri != null && content.uri.length > 0 ? `[@image](${content.uri})` : "[image attachment]" : `[${content.type} attachment]`;
|
|
28906
28884
|
if (text2.length === 0) {
|
|
28907
|
-
return;
|
|
28885
|
+
return this.#events.length;
|
|
28908
28886
|
}
|
|
28909
28887
|
const previous = this.#messages.at(-1);
|
|
28910
28888
|
const id = update.messageId ?? null;
|
|
@@ -28931,10 +28909,30 @@ var AcpHistoryReplay = class {
|
|
|
28931
28909
|
this.#characters += bounded2.length;
|
|
28932
28910
|
this.#lastMessageId = id;
|
|
28933
28911
|
this.trimMessages();
|
|
28912
|
+
return this.#events.length;
|
|
28913
|
+
};
|
|
28914
|
+
recordLifecycle = (event) => {
|
|
28915
|
+
if (event.type !== "lifecycle-metadata") {
|
|
28916
|
+
throw new Error("Lifecycle history only accepts lifecycle metadata");
|
|
28917
|
+
}
|
|
28918
|
+
this.#records.push({ event, kind: "lifecycle" });
|
|
28919
|
+
this.#events.push(event);
|
|
28920
|
+
return this.#events.length;
|
|
28921
|
+
};
|
|
28922
|
+
eventCount = () => this.#events.length;
|
|
28923
|
+
append = async (replay) => {
|
|
28924
|
+
for (const record2 of replay.#records) {
|
|
28925
|
+
if (record2.kind === "acp") {
|
|
28926
|
+
await this.record(record2.update, record2.rawUpdate);
|
|
28927
|
+
} else {
|
|
28928
|
+
this.recordLifecycle(record2.event);
|
|
28929
|
+
}
|
|
28930
|
+
}
|
|
28934
28931
|
};
|
|
28935
|
-
eventPage = (eventLimit, cursor) => {
|
|
28936
|
-
const
|
|
28937
|
-
|
|
28932
|
+
eventPage = (eventLimit, cursor, appended = null) => {
|
|
28933
|
+
const events = appended === null ? this.#events : [...this.#events, ...appended.#events];
|
|
28934
|
+
const parsedCursor = cursor === null ? events.length : Number(cursor);
|
|
28935
|
+
if (!Number.isSafeInteger(parsedCursor) || parsedCursor < 0 || parsedCursor > events.length) {
|
|
28938
28936
|
throw new Error("The native event cursor is invalid");
|
|
28939
28937
|
}
|
|
28940
28938
|
const endUpdate = parsedCursor;
|
|
@@ -28943,7 +28941,7 @@ var AcpHistoryReplay = class {
|
|
|
28943
28941
|
nextCursor: startUpdate === 0 ? null : startUpdate.toString(),
|
|
28944
28942
|
startPosition: startUpdate + 1,
|
|
28945
28943
|
truncated: startUpdate > 0,
|
|
28946
|
-
|
|
28944
|
+
events: events.slice(startUpdate, endUpdate)
|
|
28947
28945
|
};
|
|
28948
28946
|
};
|
|
28949
28947
|
snapshot = async () => {
|
|
@@ -29330,6 +29328,34 @@ var AcpSessionInteractions = class {
|
|
|
29330
29328
|
constructor(context) {
|
|
29331
29329
|
this.#context = context;
|
|
29332
29330
|
}
|
|
29331
|
+
#notifyPermissionRequested = async (event) => {
|
|
29332
|
+
await this.#context.recordSessionEventV2({
|
|
29333
|
+
payload: { event, kind: "session.permission.requested" },
|
|
29334
|
+
type: "lifecycle-metadata"
|
|
29335
|
+
});
|
|
29336
|
+
await this.#context.observer().onPermission(event);
|
|
29337
|
+
};
|
|
29338
|
+
#notifyPermissionResolved = async (event) => {
|
|
29339
|
+
await this.#context.recordSessionEventV2({
|
|
29340
|
+
payload: { event, kind: "session.permission.resolved" },
|
|
29341
|
+
type: "lifecycle-metadata"
|
|
29342
|
+
});
|
|
29343
|
+
await this.#context.observer().onPermissionResolved(event);
|
|
29344
|
+
};
|
|
29345
|
+
#notifyElicitationRequested = async (event) => {
|
|
29346
|
+
await this.#context.recordSessionEventV2({
|
|
29347
|
+
payload: { event, kind: "session.elicitation.requested" },
|
|
29348
|
+
type: "lifecycle-metadata"
|
|
29349
|
+
});
|
|
29350
|
+
await this.#context.observer().onElicitation(event);
|
|
29351
|
+
};
|
|
29352
|
+
#notifyElicitationResolved = async (event) => {
|
|
29353
|
+
await this.#context.recordSessionEventV2({
|
|
29354
|
+
payload: { event, kind: "session.elicitation.resolved" },
|
|
29355
|
+
type: "lifecycle-metadata"
|
|
29356
|
+
});
|
|
29357
|
+
await this.#context.observer().onElicitationResolved(event);
|
|
29358
|
+
};
|
|
29333
29359
|
respondPermission = async (options) => {
|
|
29334
29360
|
const pending = this.#pendingPermissions.get(options.interactionId);
|
|
29335
29361
|
if (pending === void 0) {
|
|
@@ -29355,7 +29381,7 @@ var AcpSessionInteractions = class {
|
|
|
29355
29381
|
);
|
|
29356
29382
|
}
|
|
29357
29383
|
this.#pendingPermissions.delete(options.interactionId);
|
|
29358
|
-
await this.#
|
|
29384
|
+
await this.#notifyPermissionResolved({
|
|
29359
29385
|
interactionId: options.interactionId,
|
|
29360
29386
|
kind: SESSION_PERMISSION_RESOLVED_KIND,
|
|
29361
29387
|
optionId: options.outcome === "selected" ? options.optionId : "",
|
|
@@ -29395,7 +29421,7 @@ var AcpSessionInteractions = class {
|
|
|
29395
29421
|
);
|
|
29396
29422
|
}
|
|
29397
29423
|
this.#pendingElicitations.delete(options.interactionId);
|
|
29398
|
-
await this.#
|
|
29424
|
+
await this.#notifyElicitationResolved({
|
|
29399
29425
|
action: options.action,
|
|
29400
29426
|
interactionId: options.interactionId,
|
|
29401
29427
|
kind: SESSION_ELICITATION_RESOLVED_KIND,
|
|
@@ -29424,7 +29450,7 @@ var AcpSessionInteractions = class {
|
|
|
29424
29450
|
};
|
|
29425
29451
|
signal.addEventListener("abort", abort, { once: true });
|
|
29426
29452
|
try {
|
|
29427
|
-
await this.#
|
|
29453
|
+
await this.#notifyPermissionRequested({
|
|
29428
29454
|
commandId: this.#context.commandId(),
|
|
29429
29455
|
interactionId,
|
|
29430
29456
|
kind: SESSION_PERMISSION_REQUESTED_KIND,
|
|
@@ -29469,7 +29495,7 @@ var AcpSessionInteractions = class {
|
|
|
29469
29495
|
};
|
|
29470
29496
|
signal.addEventListener("abort", abort, { once: true });
|
|
29471
29497
|
try {
|
|
29472
|
-
await this.#
|
|
29498
|
+
await this.#notifyElicitationRequested({
|
|
29473
29499
|
accepted: false,
|
|
29474
29500
|
commandId: this.#context.commandId(),
|
|
29475
29501
|
elicitationId,
|
|
@@ -29493,7 +29519,7 @@ var AcpSessionInteractions = class {
|
|
|
29493
29519
|
return;
|
|
29494
29520
|
}
|
|
29495
29521
|
this.#acceptedUrlElicitations.delete(notification.elicitationId);
|
|
29496
|
-
await this.#
|
|
29522
|
+
await this.#notifyElicitationResolved({
|
|
29497
29523
|
action: "complete",
|
|
29498
29524
|
interactionId,
|
|
29499
29525
|
kind: SESSION_ELICITATION_RESOLVED_KIND,
|
|
@@ -29506,7 +29532,7 @@ var AcpSessionInteractions = class {
|
|
|
29506
29532
|
return;
|
|
29507
29533
|
}
|
|
29508
29534
|
this.#pendingPermissions.delete(interactionId);
|
|
29509
|
-
await this.#
|
|
29535
|
+
await this.#notifyPermissionResolved({
|
|
29510
29536
|
interactionId,
|
|
29511
29537
|
kind: SESSION_PERMISSION_RESOLVED_KIND,
|
|
29512
29538
|
optionId: "",
|
|
@@ -29520,7 +29546,7 @@ var AcpSessionInteractions = class {
|
|
|
29520
29546
|
return;
|
|
29521
29547
|
}
|
|
29522
29548
|
this.#pendingElicitations.delete(interactionId);
|
|
29523
|
-
await this.#
|
|
29549
|
+
await this.#notifyElicitationResolved({
|
|
29524
29550
|
action: "cancel",
|
|
29525
29551
|
interactionId,
|
|
29526
29552
|
kind: SESSION_ELICITATION_RESOLVED_KIND,
|
|
@@ -29539,7 +29565,7 @@ var AcpSessionInteractions = class {
|
|
|
29539
29565
|
await this.cancelElicitation(interactionId);
|
|
29540
29566
|
}
|
|
29541
29567
|
for (const interactionId of acceptedElicitationIds) {
|
|
29542
|
-
await this.#
|
|
29568
|
+
await this.#notifyElicitationResolved({
|
|
29543
29569
|
action: "cancel",
|
|
29544
29570
|
interactionId,
|
|
29545
29571
|
kind: SESSION_ELICITATION_RESOLVED_KIND,
|
|
@@ -34474,21 +34500,9 @@ var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
|
34474
34500
|
var MemoryAcpSessionStore = class {
|
|
34475
34501
|
#sessions = /* @__PURE__ */ new Map();
|
|
34476
34502
|
#deleted = /* @__PURE__ */ new Set();
|
|
34477
|
-
#eventsV2 = /* @__PURE__ */ new Map();
|
|
34478
|
-
appendExecutingPromptEventV2 = (event) => {
|
|
34479
|
-
const events = this.#eventsV2.get(event.sessionId);
|
|
34480
|
-
if (events === void 0) {
|
|
34481
|
-
throw new Error("The executing prompt event log has not started");
|
|
34482
|
-
}
|
|
34483
|
-
events.push(event);
|
|
34484
|
-
};
|
|
34485
|
-
clearExecutingPromptEventsV2 = (sessionId) => {
|
|
34486
|
-
this.#eventsV2.delete(sessionId);
|
|
34487
|
-
};
|
|
34488
34503
|
close = () => {
|
|
34489
34504
|
this.#sessions.clear();
|
|
34490
34505
|
this.#deleted.clear();
|
|
34491
|
-
this.#eventsV2.clear();
|
|
34492
34506
|
};
|
|
34493
34507
|
findNative = (agentId, nativeSessionId) => [...this.#sessions.values()].filter(
|
|
34494
34508
|
(session) => session.agentId === agentId && session.nativeSessionId === nativeSessionId
|
|
@@ -34499,7 +34513,6 @@ var MemoryAcpSessionStore = class {
|
|
|
34499
34513
|
for (const id of ids) {
|
|
34500
34514
|
this.#sessions.delete(id);
|
|
34501
34515
|
this.#deleted.add(id);
|
|
34502
|
-
this.#eventsV2.delete(id);
|
|
34503
34516
|
}
|
|
34504
34517
|
return ids;
|
|
34505
34518
|
};
|
|
@@ -34512,13 +34525,6 @@ var MemoryAcpSessionStore = class {
|
|
|
34512
34525
|
};
|
|
34513
34526
|
remove = (sessionId) => {
|
|
34514
34527
|
this.#sessions.delete(sessionId);
|
|
34515
|
-
this.#eventsV2.delete(sessionId);
|
|
34516
|
-
};
|
|
34517
|
-
readExecutingPromptEventsV2 = (sessionId) => [
|
|
34518
|
-
...this.#eventsV2.get(sessionId) ?? []
|
|
34519
|
-
];
|
|
34520
|
-
startExecutingPromptEventsV2 = (sessionId, events) => {
|
|
34521
|
-
this.#eventsV2.set(sessionId, [...events]);
|
|
34522
34528
|
};
|
|
34523
34529
|
write = (session) => {
|
|
34524
34530
|
this.#sessions.set(session.sessionId, session);
|
|
@@ -34597,30 +34603,6 @@ var SqliteAcpSessionStore = class {
|
|
|
34597
34603
|
close = () => {
|
|
34598
34604
|
this.#sqliteDatabase.close();
|
|
34599
34605
|
};
|
|
34600
|
-
appendExecutingPromptEventV2 = (event) => {
|
|
34601
|
-
this.#database.insert(sessionEventV2).values({
|
|
34602
|
-
eventId: event.eventId,
|
|
34603
|
-
eventJson: JSON.stringify(event),
|
|
34604
|
-
position: Number(event.position),
|
|
34605
|
-
sessionId: event.sessionId
|
|
34606
|
-
}).run();
|
|
34607
|
-
};
|
|
34608
|
-
clearExecutingPromptEventsV2 = (sessionId) => {
|
|
34609
|
-
this.#database.delete(sessionEventV2).where(eq(sessionEventV2.sessionId, sessionId)).run();
|
|
34610
|
-
};
|
|
34611
|
-
startExecutingPromptEventsV2 = (sessionId, events) => {
|
|
34612
|
-
this.#transaction(() => {
|
|
34613
|
-
this.#database.delete(sessionEventV2).where(eq(sessionEventV2.sessionId, sessionId)).run();
|
|
34614
|
-
for (const event of events) {
|
|
34615
|
-
this.#database.insert(sessionEventV2).values({
|
|
34616
|
-
eventId: event.eventId,
|
|
34617
|
-
eventJson: JSON.stringify(event),
|
|
34618
|
-
position: Number(event.position),
|
|
34619
|
-
sessionId: event.sessionId
|
|
34620
|
-
}).run();
|
|
34621
|
-
}
|
|
34622
|
-
});
|
|
34623
|
-
};
|
|
34624
34606
|
findNative = (agentId, nativeSessionId) => this.#database.select().from(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).all().map(decodeStoredSession);
|
|
34625
34607
|
list = () => this.#database.select().from(acpSession).orderBy(desc(acpSession.updatedAt)).all().map(decodeStoredSession);
|
|
34626
34608
|
markDeleted = (agentId, nativeSessionId) => {
|
|
@@ -34629,7 +34611,6 @@ var SqliteAcpSessionStore = class {
|
|
|
34629
34611
|
this.#database.delete(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).run();
|
|
34630
34612
|
for (const id of ids) {
|
|
34631
34613
|
this.#database.insert(deletedAcpSession).values({ sessionId: id }).onConflictDoNothing().run();
|
|
34632
|
-
this.#database.delete(sessionEventV2).where(eq(sessionEventV2.sessionId, id)).run();
|
|
34633
34614
|
}
|
|
34634
34615
|
});
|
|
34635
34616
|
return ids;
|
|
@@ -34643,12 +34624,8 @@ var SqliteAcpSessionStore = class {
|
|
|
34643
34624
|
const row = this.#database.select().from(acpSession).where(eq(acpSession.sessionId, sessionId)).get();
|
|
34644
34625
|
return row === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(decodeStoredSession(row));
|
|
34645
34626
|
};
|
|
34646
|
-
readExecutingPromptEventsV2 = (sessionId) => this.#database.select({ eventJson: sessionEventV2.eventJson }).from(sessionEventV2).where(eq(sessionEventV2.sessionId, sessionId)).orderBy(asc(sessionEventV2.position)).all().map((row) => decodeSessionEventV2(row.eventJson));
|
|
34647
34627
|
remove = (sessionId) => {
|
|
34648
|
-
this.#
|
|
34649
|
-
this.#database.delete(acpSession).where(eq(acpSession.sessionId, sessionId)).run();
|
|
34650
|
-
this.#database.delete(sessionEventV2).where(eq(sessionEventV2.sessionId, sessionId)).run();
|
|
34651
|
-
});
|
|
34628
|
+
this.#database.delete(acpSession).where(eq(acpSession.sessionId, sessionId)).run();
|
|
34652
34629
|
};
|
|
34653
34630
|
write = (session) => {
|
|
34654
34631
|
const value = {
|
|
@@ -34718,6 +34695,7 @@ var AgentSession = class _AgentSession {
|
|
|
34718
34695
|
#sessionTitle = null;
|
|
34719
34696
|
#sessionUpdatedAt = "";
|
|
34720
34697
|
#turn = new IdleAcpTurn();
|
|
34698
|
+
#turnHistory = null;
|
|
34721
34699
|
constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store, metrics, contentExternalizer) {
|
|
34722
34700
|
this.#updates = new AgentUpdateStream((notification) => this.#processUpdate(notification));
|
|
34723
34701
|
this.#additionalDirectories = [...additionalDirectories];
|
|
@@ -34735,7 +34713,8 @@ var AgentSession = class _AgentSession {
|
|
|
34735
34713
|
sessionId: () => this.#mobiusSessionId,
|
|
34736
34714
|
commandId: () => this.#turn.commandId,
|
|
34737
34715
|
assertNativeSession: (sessionId) => this.assertNativeSession(sessionId),
|
|
34738
|
-
observer: getObserver
|
|
34716
|
+
observer: getObserver,
|
|
34717
|
+
recordSessionEventV2: this.#recordLifecycleEventV2
|
|
34739
34718
|
});
|
|
34740
34719
|
this.#connection = new AgentConnection(agent, cwd, this);
|
|
34741
34720
|
this.#contentExternalizer = contentExternalizer;
|
|
@@ -34831,13 +34810,10 @@ var AgentSession = class _AgentSession {
|
|
|
34831
34810
|
}
|
|
34832
34811
|
};
|
|
34833
34812
|
}
|
|
34834
|
-
const
|
|
34835
|
-
return await embedLocalHistoryImages(await
|
|
34813
|
+
const history = await this.#completedHistory(signal, "ACP agent exited while loading history");
|
|
34814
|
+
return await embedLocalHistoryImages(await history.snapshot(), signal);
|
|
34836
34815
|
};
|
|
34837
34816
|
loadHistoryEventsV2 = async (eventLimit, cursor, signal) => {
|
|
34838
|
-
if (!this.#prompted && this.#nativeHistoryOwnership.kind === "fresh-session") {
|
|
34839
|
-
return new AcpHistoryReplay().eventPage(eventLimit, cursor);
|
|
34840
|
-
}
|
|
34841
34817
|
if (!this.#capabilities.loadSession) {
|
|
34842
34818
|
throw new AcpExecutionError(
|
|
34843
34819
|
"This Agent restores context but does not provide message history.",
|
|
@@ -34845,9 +34821,20 @@ var AgentSession = class _AgentSession {
|
|
|
34845
34821
|
"native_history_unsupported"
|
|
34846
34822
|
);
|
|
34847
34823
|
}
|
|
34848
|
-
const
|
|
34849
|
-
return
|
|
34824
|
+
const history = await this.#completedHistory(signal, "ACP agent exited while loading history");
|
|
34825
|
+
return history.eventPage(eventLimit, cursor, this.#turnHistory);
|
|
34850
34826
|
};
|
|
34827
|
+
async #completedHistory(signal, exitMessage) {
|
|
34828
|
+
if (!this.#prompted && this.#nativeHistoryOwnership.kind === "fresh-session") {
|
|
34829
|
+
if (this.#sessionLoad.kind === "not-requested") {
|
|
34830
|
+
this.#sessionLoad = { history: new AcpHistoryReplay(), kind: "loaded", response: {} };
|
|
34831
|
+
}
|
|
34832
|
+
if (this.#sessionLoad.kind === "loaded") {
|
|
34833
|
+
return this.#sessionLoad.history;
|
|
34834
|
+
}
|
|
34835
|
+
}
|
|
34836
|
+
return (await this.#loadSession(signal, exitMessage)).history;
|
|
34837
|
+
}
|
|
34851
34838
|
async #loadSession(signal, exitMessage) {
|
|
34852
34839
|
if (this.#sessionLoad.kind === "loaded") {
|
|
34853
34840
|
return this.#sessionLoad;
|
|
@@ -35331,19 +35318,7 @@ var AgentSession = class _AgentSession {
|
|
|
35331
35318
|
if (this.#turn.running) {
|
|
35332
35319
|
throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
|
|
35333
35320
|
}
|
|
35334
|
-
|
|
35335
|
-
case "not-requested":
|
|
35336
|
-
break;
|
|
35337
|
-
case "loaded":
|
|
35338
|
-
this.#sessionLoad = { kind: "not-requested" };
|
|
35339
|
-
break;
|
|
35340
|
-
case "capturing":
|
|
35341
|
-
throw new AcpExecutionError("Session history is still loading", {}, "session_busy");
|
|
35342
|
-
default: {
|
|
35343
|
-
const unexpected = this.#sessionLoad;
|
|
35344
|
-
throw new Error(`Unexpected Session load state: ${JSON.stringify(unexpected)}`);
|
|
35345
|
-
}
|
|
35346
|
-
}
|
|
35321
|
+
const completedHistory = this.#capabilities.loadSession ? await this.#completedHistory(options.signal, "ACP agent exited while loading history before a prompt") : null;
|
|
35347
35322
|
const prompt = this.buildPrompt(options);
|
|
35348
35323
|
if (this.#sessionTitle === null || this.#sessionTitle.length === 0) {
|
|
35349
35324
|
this.#sessionTitle = truncate(options.prompt, 500);
|
|
@@ -35370,6 +35345,23 @@ var AgentSession = class _AgentSession {
|
|
|
35370
35345
|
this.prepareAgentContent
|
|
35371
35346
|
);
|
|
35372
35347
|
this.#turn = running;
|
|
35348
|
+
this.#turnHistory = completedHistory === null ? null : new AcpHistoryReplay();
|
|
35349
|
+
const lifecycleV2 = options.lifecycleV2;
|
|
35350
|
+
if (lifecycleV2 !== void 0) {
|
|
35351
|
+
await this.#recordLifecycleEventV2({
|
|
35352
|
+
payload: { commandId: options.commandId, content: lifecycleV2.content, kind: "prompt.requested" },
|
|
35353
|
+
type: "lifecycle-metadata"
|
|
35354
|
+
});
|
|
35355
|
+
await this.#recordLifecycleEventV2({
|
|
35356
|
+
payload: {
|
|
35357
|
+
attemptId: lifecycleV2.attemptId,
|
|
35358
|
+
commandId: options.commandId,
|
|
35359
|
+
epoch: lifecycleV2.epoch,
|
|
35360
|
+
kind: "prompt.started"
|
|
35361
|
+
},
|
|
35362
|
+
type: "lifecycle-metadata"
|
|
35363
|
+
});
|
|
35364
|
+
}
|
|
35373
35365
|
this.#nativePrompt = {
|
|
35374
35366
|
commandId: options.commandId,
|
|
35375
35367
|
previousTurnId: this.#connection.inProcessAgent?.nativeTurnId?.() ?? null
|
|
@@ -35424,16 +35416,37 @@ var AgentSession = class _AgentSession {
|
|
|
35424
35416
|
this.#lastTerminalCommandId
|
|
35425
35417
|
)
|
|
35426
35418
|
);
|
|
35419
|
+
if (lifecycleV2 !== void 0) {
|
|
35420
|
+
await this.#recordLifecycleEventV2({
|
|
35421
|
+
payload: { commandId: options.commandId, kind: "prompt.completed", stopReason: result.stopReason },
|
|
35422
|
+
type: "lifecycle-metadata"
|
|
35423
|
+
});
|
|
35424
|
+
}
|
|
35427
35425
|
return result;
|
|
35428
35426
|
} catch (error62) {
|
|
35429
35427
|
await running.activities.finish();
|
|
35428
|
+
const failure2 = error62 instanceof AcpExecutionError ? error62 : new AcpExecutionError("ACP agent execution failed", { cause: error62 });
|
|
35429
|
+
if (lifecycleV2 !== void 0) {
|
|
35430
|
+
await this.#recordLifecycleEventV2({
|
|
35431
|
+
payload: {
|
|
35432
|
+
attemptId: lifecycleV2.attemptId,
|
|
35433
|
+
code: failure2.code,
|
|
35434
|
+
commandId: options.commandId,
|
|
35435
|
+
kind: "prompt.failed",
|
|
35436
|
+
message: truncate(failure2.message, 500)
|
|
35437
|
+
},
|
|
35438
|
+
type: "lifecycle-metadata"
|
|
35439
|
+
});
|
|
35440
|
+
}
|
|
35430
35441
|
if (error62 instanceof AcpExecutionError) {
|
|
35431
35442
|
throw error62;
|
|
35432
35443
|
}
|
|
35433
|
-
throw
|
|
35434
|
-
cause: error62
|
|
35435
|
-
});
|
|
35444
|
+
throw failure2;
|
|
35436
35445
|
} finally {
|
|
35446
|
+
if (completedHistory !== null && this.#turnHistory !== null) {
|
|
35447
|
+
await completedHistory.append(this.#turnHistory);
|
|
35448
|
+
}
|
|
35449
|
+
this.#turnHistory = null;
|
|
35437
35450
|
this.#turn = new IdleAcpTurn();
|
|
35438
35451
|
}
|
|
35439
35452
|
};
|
|
@@ -35449,41 +35462,80 @@ var AgentSession = class _AgentSession {
|
|
|
35449
35462
|
throw new AcpExecutionError("The target turn is no longer active", {}, "steering_target_unavailable");
|
|
35450
35463
|
}
|
|
35451
35464
|
const prompt = this.buildPrompt(options);
|
|
35452
|
-
const
|
|
35453
|
-
|
|
35454
|
-
|
|
35455
|
-
prompt,
|
|
35456
|
-
|
|
35457
|
-
})
|
|
35458
|
-
|
|
35459
|
-
|
|
35460
|
-
|
|
35461
|
-
|
|
35465
|
+
const lifecycleV2 = options.lifecycleV2;
|
|
35466
|
+
if (lifecycleV2 !== void 0) {
|
|
35467
|
+
await this.#recordLifecycleEventV2({
|
|
35468
|
+
payload: { commandId: options.commandId, content: lifecycleV2.content, kind: "prompt.requested" },
|
|
35469
|
+
type: "lifecycle-metadata"
|
|
35470
|
+
});
|
|
35471
|
+
await this.#recordLifecycleEventV2({
|
|
35472
|
+
payload: {
|
|
35473
|
+
attemptId: lifecycleV2.attemptId,
|
|
35474
|
+
commandId: options.commandId,
|
|
35475
|
+
epoch: lifecycleV2.epoch,
|
|
35476
|
+
kind: "prompt.started"
|
|
35477
|
+
},
|
|
35478
|
+
type: "lifecycle-metadata"
|
|
35479
|
+
});
|
|
35480
|
+
}
|
|
35481
|
+
try {
|
|
35482
|
+
const response = await this.race(
|
|
35483
|
+
this.#connection.connection.agent.request("_session/steering", {
|
|
35484
|
+
_meta: { steering: { idleBehavior: "promptRequired" } },
|
|
35485
|
+
prompt,
|
|
35486
|
+
sessionId: this.#updates.sessionId()
|
|
35487
|
+
}),
|
|
35488
|
+
"ACP agent exited during steering",
|
|
35489
|
+
options.signal
|
|
35490
|
+
);
|
|
35491
|
+
if (!isRecord4(response)) {
|
|
35492
|
+
throw new AcpExecutionError(
|
|
35493
|
+
"ACP agent returned an invalid steering response",
|
|
35494
|
+
{},
|
|
35495
|
+
"acp_invalid_steering_response"
|
|
35496
|
+
);
|
|
35497
|
+
}
|
|
35498
|
+
const outcome = response["outcome"];
|
|
35499
|
+
if (outcome === "injected" || outcome === "startedNewTurn") {
|
|
35500
|
+
if (lifecycleV2 !== void 0) {
|
|
35501
|
+
await this.#recordLifecycleEventV2({
|
|
35502
|
+
payload: { commandId: options.commandId, kind: "prompt.completed", stopReason: "steered" },
|
|
35503
|
+
type: "lifecycle-metadata"
|
|
35504
|
+
});
|
|
35505
|
+
}
|
|
35506
|
+
return outcome;
|
|
35507
|
+
}
|
|
35508
|
+
if (outcome === "promptRequired") {
|
|
35509
|
+
throw new AcpExecutionError(
|
|
35510
|
+
"The target turn finished before steering could be injected",
|
|
35511
|
+
{},
|
|
35512
|
+
"steering_target_unavailable"
|
|
35513
|
+
);
|
|
35514
|
+
}
|
|
35515
|
+
if (outcome === "failed") {
|
|
35516
|
+
throw new AcpExecutionError("The Agent could not inject steering", {}, "steering_failed");
|
|
35517
|
+
}
|
|
35462
35518
|
throw new AcpExecutionError(
|
|
35463
35519
|
"ACP agent returned an invalid steering response",
|
|
35464
35520
|
{},
|
|
35465
35521
|
"acp_invalid_steering_response"
|
|
35466
35522
|
);
|
|
35523
|
+
} catch (error62) {
|
|
35524
|
+
const failure2 = error62 instanceof AcpExecutionError ? error62 : new AcpExecutionError("ACP agent execution failed", { cause: error62 });
|
|
35525
|
+
if (lifecycleV2 !== void 0) {
|
|
35526
|
+
await this.#recordLifecycleEventV2({
|
|
35527
|
+
payload: {
|
|
35528
|
+
attemptId: lifecycleV2.attemptId,
|
|
35529
|
+
code: failure2.code,
|
|
35530
|
+
commandId: options.commandId,
|
|
35531
|
+
kind: "prompt.failed",
|
|
35532
|
+
message: truncate(failure2.message, 500)
|
|
35533
|
+
},
|
|
35534
|
+
type: "lifecycle-metadata"
|
|
35535
|
+
});
|
|
35536
|
+
}
|
|
35537
|
+
throw failure2;
|
|
35467
35538
|
}
|
|
35468
|
-
const outcome = response["outcome"];
|
|
35469
|
-
if (outcome === "injected" || outcome === "startedNewTurn") {
|
|
35470
|
-
return outcome;
|
|
35471
|
-
}
|
|
35472
|
-
if (outcome === "promptRequired") {
|
|
35473
|
-
throw new AcpExecutionError(
|
|
35474
|
-
"The target turn finished before steering could be injected",
|
|
35475
|
-
{},
|
|
35476
|
-
"steering_target_unavailable"
|
|
35477
|
-
);
|
|
35478
|
-
}
|
|
35479
|
-
if (outcome === "failed") {
|
|
35480
|
-
throw new AcpExecutionError("The Agent could not inject steering", {}, "steering_failed");
|
|
35481
|
-
}
|
|
35482
|
-
throw new AcpExecutionError(
|
|
35483
|
-
"ACP agent returned an invalid steering response",
|
|
35484
|
-
{},
|
|
35485
|
-
"acp_invalid_steering_response"
|
|
35486
|
-
);
|
|
35487
35539
|
};
|
|
35488
35540
|
cancel = async () => {
|
|
35489
35541
|
const capturedProcesses = await this.#connection.captureProcessTree();
|
|
@@ -35504,6 +35556,13 @@ var AgentSession = class _AgentSession {
|
|
|
35504
35556
|
onElicitation = (request, signal) => this.#interactions.onElicitation(request, signal);
|
|
35505
35557
|
onElicitationComplete = (notification) => this.#interactions.onElicitationComplete(notification);
|
|
35506
35558
|
onUpdate = (notification) => this.#updates.receive(notification);
|
|
35559
|
+
#recordLifecycleEventV2 = async (event) => {
|
|
35560
|
+
if (event.type !== "lifecycle-metadata" || this.#sessionLoad.kind !== "loaded") {
|
|
35561
|
+
return;
|
|
35562
|
+
}
|
|
35563
|
+
const position = this.#turnHistory === null ? this.#sessionLoad.history.recordLifecycle(event) : this.#sessionLoad.history.eventCount() + this.#turnHistory.recordLifecycle(event);
|
|
35564
|
+
await this.#getObserver().onSessionEventV2?.(this.#mobiusSessionId, event, position);
|
|
35565
|
+
};
|
|
35507
35566
|
selectNativeSession = (sessionId) => {
|
|
35508
35567
|
this.#updates.select(sessionId);
|
|
35509
35568
|
this.#nativeHistoryOwnership = { kind: "agent-owned" };
|
|
@@ -35520,9 +35579,20 @@ var AgentSession = class _AgentSession {
|
|
|
35520
35579
|
if (this.#sessionLoad.kind === "capturing") {
|
|
35521
35580
|
await this.#sessionLoad.history.record(update, rawUpdate);
|
|
35522
35581
|
} else {
|
|
35523
|
-
const
|
|
35524
|
-
if (
|
|
35525
|
-
|
|
35582
|
+
const onSessionEventV2 = this.#getObserver().onSessionEventV2;
|
|
35583
|
+
if (this.#turnHistory !== null) {
|
|
35584
|
+
const completedEventCount = this.#sessionLoad.kind === "loaded" ? this.#sessionLoad.history.eventCount() : 0;
|
|
35585
|
+
await this.#turnHistory.record(update, rawUpdate, async (turnPosition) => {
|
|
35586
|
+
await onSessionEventV2?.(
|
|
35587
|
+
this.#mobiusSessionId,
|
|
35588
|
+
{ payload: rawUpdate, type: "acp" },
|
|
35589
|
+
completedEventCount + turnPosition
|
|
35590
|
+
);
|
|
35591
|
+
});
|
|
35592
|
+
} else if (this.#sessionLoad.kind === "loaded") {
|
|
35593
|
+
await this.#sessionLoad.history.record(update, rawUpdate, async (position) => {
|
|
35594
|
+
await onSessionEventV2?.(this.#mobiusSessionId, { payload: rawUpdate, type: "acp" }, position);
|
|
35595
|
+
});
|
|
35526
35596
|
}
|
|
35527
35597
|
}
|
|
35528
35598
|
if (this.#sessionLoad.kind === "capturing" && (update.sessionUpdate === "user_message_chunk" || update.sessionUpdate === "agent_message_chunk" || update.sessionUpdate === "agent_thought_chunk" || update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update" || update.sessionUpdate === "plan" || update.sessionUpdate === "plan_update" || update.sessionUpdate === "plan_removed")) {
|
|
@@ -38301,8 +38371,8 @@ var DaemonAcpObserver = class {
|
|
|
38301
38371
|
this.#record = record2;
|
|
38302
38372
|
this.#recordV2 = recordV2;
|
|
38303
38373
|
}
|
|
38304
|
-
|
|
38305
|
-
this.#recordV2(sessionId,
|
|
38374
|
+
onSessionEventV2 = (sessionId, event, position) => {
|
|
38375
|
+
this.#recordV2(sessionId, event, position);
|
|
38306
38376
|
return Promise.resolve();
|
|
38307
38377
|
};
|
|
38308
38378
|
onCommands = (event) => {
|
|
@@ -38319,18 +38389,10 @@ var DaemonAcpObserver = class {
|
|
|
38319
38389
|
};
|
|
38320
38390
|
onElicitation = (event) => {
|
|
38321
38391
|
this.#record(event.sessionId, event);
|
|
38322
|
-
this.#recordV2(event.sessionId, {
|
|
38323
|
-
payload: { event, kind: "session.elicitation.requested" },
|
|
38324
|
-
type: "lifecycle-metadata"
|
|
38325
|
-
});
|
|
38326
38392
|
return Promise.resolve();
|
|
38327
38393
|
};
|
|
38328
38394
|
onElicitationResolved = (event) => {
|
|
38329
38395
|
this.#record(event.sessionId, event);
|
|
38330
|
-
this.#recordV2(event.sessionId, {
|
|
38331
|
-
payload: { event, kind: "session.elicitation.resolved" },
|
|
38332
|
-
type: "lifecycle-metadata"
|
|
38333
|
-
});
|
|
38334
38396
|
return Promise.resolve();
|
|
38335
38397
|
};
|
|
38336
38398
|
onInfo = (event) => {
|
|
@@ -38339,18 +38401,10 @@ var DaemonAcpObserver = class {
|
|
|
38339
38401
|
};
|
|
38340
38402
|
onPermission = (event) => {
|
|
38341
38403
|
this.#record(event.sessionId, event);
|
|
38342
|
-
this.#recordV2(event.sessionId, {
|
|
38343
|
-
payload: { event, kind: "session.permission.requested" },
|
|
38344
|
-
type: "lifecycle-metadata"
|
|
38345
|
-
});
|
|
38346
38404
|
return Promise.resolve();
|
|
38347
38405
|
};
|
|
38348
38406
|
onPermissionResolved = (event) => {
|
|
38349
38407
|
this.#record(event.sessionId, event);
|
|
38350
|
-
this.#recordV2(event.sessionId, {
|
|
38351
|
-
payload: { event, kind: "session.permission.resolved" },
|
|
38352
|
-
type: "lifecycle-metadata"
|
|
38353
|
-
});
|
|
38354
38408
|
return Promise.resolve();
|
|
38355
38409
|
};
|
|
38356
38410
|
onUsage = (event) => {
|
|
@@ -39185,14 +39239,14 @@ function decodeHistory(thread, value, options) {
|
|
|
39185
39239
|
if (options.detail === "rich" && historyItem.text.length > 0) {
|
|
39186
39240
|
append({
|
|
39187
39241
|
activities: [
|
|
39188
|
-
activity(historyItem.id ?? `
|
|
39242
|
+
activity(historyItem.id ?? `reasoning-${sequence.toString()}`, "reasoning", sequence, {
|
|
39189
39243
|
input: "",
|
|
39190
39244
|
locations: [],
|
|
39191
39245
|
name: "",
|
|
39192
39246
|
output: historyItem.text,
|
|
39193
39247
|
status: "completed",
|
|
39194
|
-
title: "
|
|
39195
|
-
toolKind: ""
|
|
39248
|
+
title: "Reasoning",
|
|
39249
|
+
toolKind: "think"
|
|
39196
39250
|
})
|
|
39197
39251
|
],
|
|
39198
39252
|
content: [],
|
|
@@ -41210,9 +41264,6 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
41210
41264
|
});
|
|
41211
41265
|
}
|
|
41212
41266
|
|
|
41213
|
-
// src/daemon-history-commands.ts
|
|
41214
|
-
import { createHash as createHash6 } from "node:crypto";
|
|
41215
|
-
|
|
41216
41267
|
// src/authorization/resolve-session-directories.ts
|
|
41217
41268
|
import { basename as basename6 } from "node:path";
|
|
41218
41269
|
var ResolvedSessionDirectories = class {
|
|
@@ -41480,72 +41531,8 @@ function paginateLiveSessionHistory(history, activeTurn, sessionId, encodedCurso
|
|
|
41480
41531
|
}
|
|
41481
41532
|
return paginateActiveTurn(historical, activeTurn, sessionId, cursor?.endIndex ?? activeTurn.messages.length, limit);
|
|
41482
41533
|
}
|
|
41483
|
-
function mergeLiveSessionHistory(history, activeTurn, sessionId) {
|
|
41484
|
-
const page = paginateLiveSessionHistory(history, activeTurn, sessionId, null, 1e3);
|
|
41485
|
-
if (page.status === "unavailable") {
|
|
41486
|
-
return { cause: page.cause, status: "unavailable" };
|
|
41487
|
-
}
|
|
41488
|
-
return {
|
|
41489
|
-
coveredCommandIds: page.coveredCommandIds,
|
|
41490
|
-
...page.streamPosition === void 0 ? {} : { streamPosition: page.streamPosition },
|
|
41491
|
-
coveredMessageIds: page.coveredMessageIds,
|
|
41492
|
-
messages: page.messages,
|
|
41493
|
-
status: "available",
|
|
41494
|
-
truncated: page.truncated || page.nextCursor !== null
|
|
41495
|
-
};
|
|
41496
|
-
}
|
|
41497
41534
|
|
|
41498
41535
|
// src/daemon-history-commands.ts
|
|
41499
|
-
async function executeSessionLiveHistoryLoad(socket, command, config2, directories, audit, sessions, activeTurn, signal) {
|
|
41500
|
-
try {
|
|
41501
|
-
const resolved = await resolveSessionDirectories(
|
|
41502
|
-
directories,
|
|
41503
|
-
config2.bindingId,
|
|
41504
|
-
command.directoryId,
|
|
41505
|
-
command.additionalDirectoryIds,
|
|
41506
|
-
signal
|
|
41507
|
-
);
|
|
41508
|
-
const history = await sessions.loadSessionHistory({
|
|
41509
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
41510
|
-
agent: config2.catalog.find(command.agentId),
|
|
41511
|
-
cwd: resolved.cwd,
|
|
41512
|
-
sessionId: command.sessionId,
|
|
41513
|
-
signal
|
|
41514
|
-
});
|
|
41515
|
-
signal.throwIfAborted();
|
|
41516
|
-
const mergedHistory = mergeLiveSessionHistory(history, activeTurn(command.sessionId), command.sessionId);
|
|
41517
|
-
audit.record({
|
|
41518
|
-
commandId: command.requestId,
|
|
41519
|
-
event: "session_history_loaded",
|
|
41520
|
-
sessionId: command.sessionId
|
|
41521
|
-
});
|
|
41522
|
-
send(socket, {
|
|
41523
|
-
history: mergedHistory,
|
|
41524
|
-
kind: "session.live-history.loaded",
|
|
41525
|
-
requestId: command.requestId,
|
|
41526
|
-
sessionId: command.sessionId
|
|
41527
|
-
});
|
|
41528
|
-
} catch (error62) {
|
|
41529
|
-
if (signal.aborted) {
|
|
41530
|
-
return;
|
|
41531
|
-
}
|
|
41532
|
-
audit.record({
|
|
41533
|
-
commandId: command.requestId,
|
|
41534
|
-
details: { code: operationErrorCode(error62) },
|
|
41535
|
-
event: "session_history_unavailable",
|
|
41536
|
-
sessionId: command.sessionId
|
|
41537
|
-
});
|
|
41538
|
-
send(socket, {
|
|
41539
|
-
history: {
|
|
41540
|
-
status: "unavailable",
|
|
41541
|
-
cause: { code: operationErrorCode(error62), message: operationErrorMessage(error62) }
|
|
41542
|
-
},
|
|
41543
|
-
kind: "session.live-history.loaded",
|
|
41544
|
-
requestId: command.requestId,
|
|
41545
|
-
sessionId: command.sessionId
|
|
41546
|
-
});
|
|
41547
|
-
}
|
|
41548
|
-
}
|
|
41549
41536
|
async function executeSessionLiveHistoryPageLoad(socket, command, config2, directories, audit, sessions, activeTurn, signal) {
|
|
41550
41537
|
try {
|
|
41551
41538
|
const resolved = await resolveSessionDirectories(
|
|
@@ -41603,20 +41590,7 @@ async function executeSessionLiveHistoryPageLoad(socket, command, config2, direc
|
|
|
41603
41590
|
});
|
|
41604
41591
|
}
|
|
41605
41592
|
}
|
|
41606
|
-
function
|
|
41607
|
-
const encoded = JSON.stringify(update);
|
|
41608
|
-
const eventId = `native-${createHash6("sha256").update(sessionId).update(":").update(position.toString()).update(":").update(encoded).digest("hex")}`;
|
|
41609
|
-
return {
|
|
41610
|
-
eventId,
|
|
41611
|
-
payload: update,
|
|
41612
|
-
position: position.toString(),
|
|
41613
|
-
provenance: { kind: "original" },
|
|
41614
|
-
recordedAt: "1970-01-01T00:00:00.000Z",
|
|
41615
|
-
sessionId,
|
|
41616
|
-
type: "acp"
|
|
41617
|
-
};
|
|
41618
|
-
}
|
|
41619
|
-
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, executingPromptRequest, signal) {
|
|
41593
|
+
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
|
|
41620
41594
|
try {
|
|
41621
41595
|
const resolved = await resolveSessionDirectories(
|
|
41622
41596
|
directories,
|
|
@@ -41625,20 +41599,18 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
41625
41599
|
command.additionalDirectoryIds,
|
|
41626
41600
|
signal
|
|
41627
41601
|
);
|
|
41628
|
-
const
|
|
41629
|
-
|
|
41630
|
-
|
|
41631
|
-
|
|
41632
|
-
|
|
41633
|
-
|
|
41634
|
-
|
|
41635
|
-
|
|
41636
|
-
|
|
41637
|
-
command.cursor
|
|
41638
|
-
);
|
|
41602
|
+
const loadOptions = {
|
|
41603
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
41604
|
+
agent: config2.catalog.find(command.agentId),
|
|
41605
|
+
cwd: resolved.cwd,
|
|
41606
|
+
sessionId: command.sessionId,
|
|
41607
|
+
signal
|
|
41608
|
+
};
|
|
41609
|
+
const recovery = eventLogV2.promptRequestRecovery(command.sessionId);
|
|
41610
|
+
const replay = await sessions.loadSessionEventsV2(loadOptions, command.eventLimit, command.cursor);
|
|
41639
41611
|
signal.throwIfAborted();
|
|
41640
|
-
const events = replay.
|
|
41641
|
-
(
|
|
41612
|
+
const events = replay.events.map(
|
|
41613
|
+
(event, index2) => eventLogV2.event(command.sessionId, replay.startPosition + index2, event, "1970-01-01T00:00:00.000Z")
|
|
41642
41614
|
);
|
|
41643
41615
|
const tailCursor = events.at(-1)?.eventId ?? "";
|
|
41644
41616
|
audit.record({
|
|
@@ -41648,14 +41620,15 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
41648
41620
|
});
|
|
41649
41621
|
send(socket, {
|
|
41650
41622
|
events: {
|
|
41651
|
-
|
|
41652
|
-
|
|
41623
|
+
events: {
|
|
41624
|
+
daemonGenerationId: eventLogV2.daemonGenerationId,
|
|
41653
41625
|
events,
|
|
41654
41626
|
nextCursor: replay.nextCursor,
|
|
41655
41627
|
tailCursor,
|
|
41656
41628
|
truncated: replay.truncated,
|
|
41657
41629
|
version: 2
|
|
41658
|
-
}
|
|
41630
|
+
},
|
|
41631
|
+
queuedPromptRequests: recovery.queuedPromptRequests
|
|
41659
41632
|
},
|
|
41660
41633
|
kind: "session.live-history.v2.page.loaded",
|
|
41661
41634
|
requestId: command.requestId,
|
|
@@ -42105,7 +42078,7 @@ async function executePrompt({
|
|
|
42105
42078
|
}
|
|
42106
42079
|
}
|
|
42107
42080
|
const stream = activateAttempt();
|
|
42108
|
-
eventLogV2.started(command.sessionId, command.commandId, attemptId, stream.epoch);
|
|
42081
|
+
const lifecycleV2 = eventLogV2.started(command.sessionId, command.commandId, attemptId, stream.epoch);
|
|
42109
42082
|
if (!prepared.prompted) {
|
|
42110
42083
|
const listing = await directories.list(config2.bindingId, command.directoryId, signal);
|
|
42111
42084
|
publisher.publish(command.sessionId, {
|
|
@@ -42142,6 +42115,7 @@ async function executePrompt({
|
|
|
42142
42115
|
commandId: command.commandId,
|
|
42143
42116
|
cwd: resolved.cwd,
|
|
42144
42117
|
images: attachments.images,
|
|
42118
|
+
lifecycleV2,
|
|
42145
42119
|
prompt: command.prompt,
|
|
42146
42120
|
resources: attachments.resources,
|
|
42147
42121
|
sessionId: command.sessionId,
|
|
@@ -42157,6 +42131,7 @@ async function executePrompt({
|
|
|
42157
42131
|
cwd: resolved.cwd,
|
|
42158
42132
|
disposition: availability.disposition,
|
|
42159
42133
|
images: attachments.images,
|
|
42134
|
+
lifecycleV2,
|
|
42160
42135
|
onActivity: events.recordActivity,
|
|
42161
42136
|
onNarration: events.recordNarration,
|
|
42162
42137
|
onText: events.recordText,
|
|
@@ -42548,20 +42523,6 @@ function createDaemonCommandHandler({
|
|
|
42548
42523
|
return {
|
|
42549
42524
|
handle: (message) => {
|
|
42550
42525
|
const kind = message.kind;
|
|
42551
|
-
if (kind === SESSION_LIVE_HISTORY_LOAD_KIND) {
|
|
42552
|
-
const command2 = message;
|
|
42553
|
-
void executeSessionLiveHistoryLoad(
|
|
42554
|
-
socket,
|
|
42555
|
-
command2,
|
|
42556
|
-
config2,
|
|
42557
|
-
directories,
|
|
42558
|
-
audit,
|
|
42559
|
-
sessions,
|
|
42560
|
-
activeTurnRecovery,
|
|
42561
|
-
signal
|
|
42562
|
-
);
|
|
42563
|
-
return;
|
|
42564
|
-
}
|
|
42565
42526
|
if (kind === SESSION_LIVE_HISTORY_PAGE_LOAD_KIND) {
|
|
42566
42527
|
const command2 = message;
|
|
42567
42528
|
void executeSessionLiveHistoryPageLoad(
|
|
@@ -42585,7 +42546,7 @@ function createDaemonCommandHandler({
|
|
|
42585
42546
|
audit,
|
|
42586
42547
|
diagnostics,
|
|
42587
42548
|
sessions,
|
|
42588
|
-
eventLogV2
|
|
42549
|
+
eventLogV2,
|
|
42589
42550
|
signal
|
|
42590
42551
|
);
|
|
42591
42552
|
return;
|
|
@@ -43258,10 +43219,6 @@ import { WebSocket as WebSocket9 } from "undici";
|
|
|
43258
43219
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
43259
43220
|
var DaemonSessionEventPublisher = class {
|
|
43260
43221
|
#socket = null;
|
|
43261
|
-
#store;
|
|
43262
|
-
constructor(store) {
|
|
43263
|
-
this.#store = store;
|
|
43264
|
-
}
|
|
43265
43222
|
connect = (socket) => {
|
|
43266
43223
|
this.#socket = socket;
|
|
43267
43224
|
};
|
|
@@ -43313,7 +43270,6 @@ var DaemonSessionEventPublisher = class {
|
|
|
43313
43270
|
}
|
|
43314
43271
|
};
|
|
43315
43272
|
publishV2 = (event) => {
|
|
43316
|
-
this.#store.appendExecutingPromptEventV2(event);
|
|
43317
43273
|
const socket = this.#socket;
|
|
43318
43274
|
if (socket === null || socket.readyState !== WebSocket9.OPEN) {
|
|
43319
43275
|
return;
|
|
@@ -43340,7 +43296,7 @@ var SystemDaemonTimer = class {
|
|
|
43340
43296
|
var systemDaemonTimer = new SystemDaemonTimer();
|
|
43341
43297
|
|
|
43342
43298
|
// src/session-event-log-v2.ts
|
|
43343
|
-
|
|
43299
|
+
import { createHash as createHash6, randomUUID as randomUUID7 } from "node:crypto";
|
|
43344
43300
|
function promptContent(command) {
|
|
43345
43301
|
const content = [];
|
|
43346
43302
|
if (command.prompt.length > 0) {
|
|
@@ -43364,176 +43320,59 @@ function promptContent(command) {
|
|
|
43364
43320
|
}
|
|
43365
43321
|
return content;
|
|
43366
43322
|
}
|
|
43323
|
+
function sessionEventV22(daemonGenerationId, sessionId, position, event, recordedAt) {
|
|
43324
|
+
const sessionPrefix = createHash6("sha256").update(sessionId).digest("hex").slice(0, 16);
|
|
43325
|
+
return {
|
|
43326
|
+
eventId: `event-${daemonGenerationId}-${sessionPrefix}-${position.toString().padStart(16, "0")}`,
|
|
43327
|
+
...event,
|
|
43328
|
+
position: position.toString(),
|
|
43329
|
+
provenance: { kind: "original" },
|
|
43330
|
+
recordedAt,
|
|
43331
|
+
sessionId
|
|
43332
|
+
};
|
|
43333
|
+
}
|
|
43367
43334
|
var DaemonSessionEventLogV2 = class {
|
|
43368
|
-
|
|
43369
|
-
#requests = /* @__PURE__ */ new Map();
|
|
43370
|
-
#loadedRequestSessions = /* @__PURE__ */ new Set();
|
|
43335
|
+
daemonGenerationId = randomUUID7();
|
|
43371
43336
|
#publisher;
|
|
43372
|
-
#
|
|
43373
|
-
constructor(publisher
|
|
43337
|
+
#queued = /* @__PURE__ */ new Map();
|
|
43338
|
+
constructor(publisher) {
|
|
43374
43339
|
this.#publisher = publisher;
|
|
43375
|
-
this.#store = store;
|
|
43376
43340
|
}
|
|
43377
|
-
#loadStoredEvents = (sessionId) => {
|
|
43378
|
-
const stored = this.#store.readExecutingPromptEventsV2(sessionId);
|
|
43379
|
-
const lastPosition = stored.at(-1)?.position;
|
|
43380
|
-
if (lastPosition !== void 0) {
|
|
43381
|
-
this.#positions.set(sessionId, Number(lastPosition));
|
|
43382
|
-
}
|
|
43383
|
-
return stored;
|
|
43384
|
-
};
|
|
43385
|
-
#loadRequests = (sessionId) => {
|
|
43386
|
-
if (this.#loadedRequestSessions.has(sessionId)) {
|
|
43387
|
-
return;
|
|
43388
|
-
}
|
|
43389
|
-
for (const event of this.#loadStoredEvents(sessionId)) {
|
|
43390
|
-
if (event.type === "acp") {
|
|
43391
|
-
continue;
|
|
43392
|
-
}
|
|
43393
|
-
const payload = event.payload;
|
|
43394
|
-
if (payload.kind === "prompt.requested") {
|
|
43395
|
-
this.#requests.set(payload.commandId, {
|
|
43396
|
-
commandId: payload.commandId,
|
|
43397
|
-
kind: "requested",
|
|
43398
|
-
sessionId
|
|
43399
|
-
});
|
|
43400
|
-
continue;
|
|
43401
|
-
}
|
|
43402
|
-
if ("event" in payload) {
|
|
43403
|
-
continue;
|
|
43404
|
-
}
|
|
43405
|
-
if (!("commandId" in payload)) {
|
|
43406
|
-
continue;
|
|
43407
|
-
}
|
|
43408
|
-
const state = this.#requests.get(payload.commandId);
|
|
43409
|
-
if (state === void 0) {
|
|
43410
|
-
continue;
|
|
43411
|
-
}
|
|
43412
|
-
if (payload.kind === "prompt.started") {
|
|
43413
|
-
this.#requests.set(payload.commandId, {
|
|
43414
|
-
attemptId: payload.attemptId,
|
|
43415
|
-
commandId: payload.commandId,
|
|
43416
|
-
epoch: payload.epoch,
|
|
43417
|
-
kind: "executing",
|
|
43418
|
-
sessionId
|
|
43419
|
-
});
|
|
43420
|
-
} else if (payload.kind === "prompt.completed" || payload.kind === "prompt.failed" || payload.kind === "prompt.failed-before-start") {
|
|
43421
|
-
this.#requests.delete(payload.commandId);
|
|
43422
|
-
}
|
|
43423
|
-
}
|
|
43424
|
-
this.#loadedRequestSessions.add(sessionId);
|
|
43425
|
-
};
|
|
43426
|
-
#append = (sessionId, payload) => {
|
|
43427
|
-
this.#loadRequests(sessionId);
|
|
43428
|
-
const position = (this.#positions.get(sessionId) ?? 0) + 1;
|
|
43429
|
-
const event = {
|
|
43430
|
-
eventId: `event-${crypto.randomUUID()}`,
|
|
43431
|
-
...payload,
|
|
43432
|
-
position: position.toString(),
|
|
43433
|
-
provenance: { kind: "original" },
|
|
43434
|
-
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
43435
|
-
sessionId
|
|
43436
|
-
};
|
|
43437
|
-
this.#publisher.publishV2(event);
|
|
43438
|
-
this.#positions.set(sessionId, position);
|
|
43439
|
-
return event;
|
|
43440
|
-
};
|
|
43441
43341
|
requested = (command) => {
|
|
43442
|
-
|
|
43443
|
-
this.#append(command.sessionId, {
|
|
43444
|
-
payload: { commandId: command.commandId, content, kind: "prompt.requested" },
|
|
43445
|
-
type: "lifecycle-metadata"
|
|
43446
|
-
});
|
|
43447
|
-
this.#requests.set(command.commandId, {
|
|
43342
|
+
this.#queued.set(command.commandId, {
|
|
43448
43343
|
commandId: command.commandId,
|
|
43449
|
-
|
|
43344
|
+
content: promptContent(command),
|
|
43450
43345
|
sessionId: command.sessionId
|
|
43451
43346
|
});
|
|
43452
43347
|
};
|
|
43453
43348
|
started = (sessionId, commandId, attemptId, epoch) => {
|
|
43454
|
-
this.#
|
|
43455
|
-
|
|
43456
|
-
|
|
43457
|
-
return;
|
|
43349
|
+
const request = this.#queued.get(commandId);
|
|
43350
|
+
if (request?.sessionId === sessionId) {
|
|
43351
|
+
this.#queued.delete(commandId);
|
|
43352
|
+
return { attemptId, content: request.content, epoch };
|
|
43458
43353
|
}
|
|
43459
|
-
|
|
43460
|
-
payload: { attemptId, commandId, epoch, kind: "prompt.started" },
|
|
43461
|
-
type: "lifecycle-metadata"
|
|
43462
|
-
});
|
|
43463
|
-
this.#requests.set(commandId, {
|
|
43464
|
-
attemptId,
|
|
43465
|
-
commandId,
|
|
43466
|
-
epoch,
|
|
43467
|
-
kind: "executing",
|
|
43468
|
-
sessionId
|
|
43469
|
-
});
|
|
43354
|
+
throw new Error("The executing prompt was not registered in the V2 queue");
|
|
43470
43355
|
};
|
|
43471
|
-
record = (sessionId,
|
|
43472
|
-
this.#
|
|
43473
|
-
this.#append(sessionId, payload);
|
|
43356
|
+
record = (sessionId, event, position) => {
|
|
43357
|
+
this.#publisher.publishV2(this.event(sessionId, position, event, (/* @__PURE__ */ new Date()).toISOString()));
|
|
43474
43358
|
};
|
|
43475
|
-
|
|
43476
|
-
|
|
43477
|
-
|
|
43359
|
+
event = (sessionId, position, event, recordedAt) => sessionEventV22(this.daemonGenerationId, sessionId, position, event, recordedAt);
|
|
43360
|
+
queueChanged = (_sessionId) => void 0;
|
|
43361
|
+
completed = (sessionId, commandId, _stopReason) => {
|
|
43362
|
+
const request = this.#queued.get(commandId);
|
|
43363
|
+
if (request?.sessionId === sessionId) {
|
|
43364
|
+
this.#queued.delete(commandId);
|
|
43478
43365
|
}
|
|
43479
43366
|
};
|
|
43480
|
-
|
|
43481
|
-
this.#
|
|
43482
|
-
|
|
43483
|
-
|
|
43484
|
-
});
|
|
43485
|
-
};
|
|
43486
|
-
completed = (sessionId, commandId, stopReason) => {
|
|
43487
|
-
this.#loadRequests(sessionId);
|
|
43488
|
-
this.#append(sessionId, {
|
|
43489
|
-
payload: { commandId, kind: "prompt.completed", stopReason },
|
|
43490
|
-
type: "lifecycle-metadata"
|
|
43491
|
-
});
|
|
43492
|
-
this.#requests.delete(commandId);
|
|
43493
|
-
this.#clearCompletedSession(sessionId);
|
|
43494
|
-
};
|
|
43495
|
-
failed = (sessionId, commandId, code, message) => {
|
|
43496
|
-
this.#loadRequests(sessionId);
|
|
43497
|
-
const request = this.#requests.get(commandId);
|
|
43498
|
-
if (request?.kind === "executing" && request.commandId === commandId) {
|
|
43499
|
-
this.#append(sessionId, {
|
|
43500
|
-
payload: {
|
|
43501
|
-
attemptId: request.attemptId,
|
|
43502
|
-
code,
|
|
43503
|
-
commandId,
|
|
43504
|
-
kind: "prompt.failed",
|
|
43505
|
-
message
|
|
43506
|
-
},
|
|
43507
|
-
type: "lifecycle-metadata"
|
|
43508
|
-
});
|
|
43509
|
-
} else {
|
|
43510
|
-
this.#append(sessionId, {
|
|
43511
|
-
payload: { code, commandId, kind: "prompt.failed-before-start", message },
|
|
43512
|
-
type: "lifecycle-metadata"
|
|
43513
|
-
});
|
|
43514
|
-
}
|
|
43515
|
-
this.#requests.delete(commandId);
|
|
43516
|
-
this.#clearCompletedSession(sessionId);
|
|
43517
|
-
};
|
|
43518
|
-
executingPromptRequest = (sessionId) => {
|
|
43519
|
-
this.#loadRequests(sessionId);
|
|
43520
|
-
const request = [...this.#requests.values()].find(
|
|
43521
|
-
(candidate) => candidate.sessionId === sessionId && candidate.kind === "executing"
|
|
43522
|
-
);
|
|
43523
|
-
if (request?.kind !== "executing") {
|
|
43524
|
-
return null;
|
|
43367
|
+
failed = (sessionId, commandId, _code, _message) => {
|
|
43368
|
+
const request = this.#queued.get(commandId);
|
|
43369
|
+
if (request?.sessionId === sessionId) {
|
|
43370
|
+
this.#queued.delete(commandId);
|
|
43525
43371
|
}
|
|
43526
|
-
const requestEvents = this.#store.readExecutingPromptEventsV2(sessionId);
|
|
43527
|
-
const events = requestEvents.slice(-EXECUTING_PROMPT_EVENT_LIMIT);
|
|
43528
|
-
return {
|
|
43529
|
-
attemptId: request.attemptId,
|
|
43530
|
-
commandId: request.commandId,
|
|
43531
|
-
epoch: request.epoch,
|
|
43532
|
-
events,
|
|
43533
|
-
tailCursor: events.at(-1)?.eventId ?? "",
|
|
43534
|
-
truncated: events.length < requestEvents.length
|
|
43535
|
-
};
|
|
43536
43372
|
};
|
|
43373
|
+
promptRequestRecovery = (sessionId) => ({
|
|
43374
|
+
queuedPromptRequests: [...this.#queued.values()].filter((request) => request.sessionId === sessionId).map(({ commandId, content }) => ({ commandId, content }))
|
|
43375
|
+
});
|
|
43537
43376
|
};
|
|
43538
43377
|
|
|
43539
43378
|
// src/run-daemon.ts
|
|
@@ -43584,7 +43423,7 @@ async function installDetectedAgentIntegrations(config2, installations, signal)
|
|
|
43584
43423
|
{
|
|
43585
43424
|
agentId: agent.id,
|
|
43586
43425
|
kind: AGENT_INSTALL_REQUEST_KIND,
|
|
43587
|
-
requestId: `automatic-integration-${
|
|
43426
|
+
requestId: `automatic-integration-${randomUUID8()}`
|
|
43588
43427
|
},
|
|
43589
43428
|
signal
|
|
43590
43429
|
);
|
|
@@ -43607,8 +43446,8 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43607
43446
|
);
|
|
43608
43447
|
await using externalContent = new LocalExternalContentStore(stateDirectory);
|
|
43609
43448
|
const operations = new DaemonOperationState();
|
|
43610
|
-
const publisher = new DaemonSessionEventPublisher(
|
|
43611
|
-
const eventLogV2 = new DaemonSessionEventLogV2(publisher
|
|
43449
|
+
const publisher = new DaemonSessionEventPublisher();
|
|
43450
|
+
const eventLogV2 = new DaemonSessionEventLogV2(publisher);
|
|
43612
43451
|
const activeTurns = new DaemonTurnRegistry(operations);
|
|
43613
43452
|
const recordSessionEvent = (sessionId, event) => {
|
|
43614
43453
|
publisher.publish(sessionId, activeTurns.recordEvent(event));
|
|
@@ -43804,7 +43643,7 @@ import { basename as basename7, resolve as resolve7 } from "node:path";
|
|
|
43804
43643
|
import { fetch as fetch4 } from "undici";
|
|
43805
43644
|
|
|
43806
43645
|
// src/storage/runtime-installation-store.ts
|
|
43807
|
-
import { createHash as createHash8, randomUUID as
|
|
43646
|
+
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
43808
43647
|
import { mkdir as mkdir5, open as open5, readdir as readdir4, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
43809
43648
|
import { dirname as dirname6, join as join19, resolve as resolve6 } from "node:path";
|
|
43810
43649
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
@@ -43934,10 +43773,10 @@ function parseRelayOrigin(value) {
|
|
|
43934
43773
|
return origin;
|
|
43935
43774
|
}
|
|
43936
43775
|
function connectionId() {
|
|
43937
|
-
return `mcn_${
|
|
43776
|
+
return `mcn_${randomUUID9().replaceAll("-", "")}`;
|
|
43938
43777
|
}
|
|
43939
43778
|
function installationId() {
|
|
43940
|
-
return `min_${
|
|
43779
|
+
return `min_${randomUUID9().replaceAll("-", "")}`;
|
|
43941
43780
|
}
|
|
43942
43781
|
function channelIndexFileName(channelId) {
|
|
43943
43782
|
return `mci_${createHash8("sha256").update(channelId).digest("hex")}.json`;
|
|
@@ -44049,7 +43888,7 @@ async function readJsonFile(path2, signal, missingCode) {
|
|
|
44049
43888
|
async function writeJsonAtomically(path2, value, signal) {
|
|
44050
43889
|
signal.throwIfAborted();
|
|
44051
43890
|
const directory = dirname6(path2);
|
|
44052
|
-
const temporaryPath = join19(directory, `.${
|
|
43891
|
+
const temporaryPath = join19(directory, `.${randomUUID9()}.tmp`);
|
|
44053
43892
|
try {
|
|
44054
43893
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
44055
43894
|
signal.throwIfAborted();
|