@moxt-ai/mobius 0.0.356 → 0.0.357
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/dist/cli.js +179 -106
- package/dist/cli.js.map +3 -3
- package/dist/engine/acp/adapter/codex/adapter.d.ts.map +1 -1
- package/dist/engine/acp/adapter/codex/adapter.js +6 -4
- package/dist/engine/acp/adapter/codex/adapter.js.map +1 -1
- package/dist/engine/acp/adapter/session-events.d.ts.map +1 -1
- package/dist/engine/acp/adapter/session-events.js +57 -56
- package/dist/engine/acp/adapter/session-events.js.map +1 -1
- package/dist/engine/acp/content/content-externalizer.d.ts +8 -2
- package/dist/engine/acp/content/content-externalizer.d.ts.map +1 -1
- package/dist/engine/acp/content/content-externalizer.js +23 -6
- package/dist/engine/acp/content/content-externalizer.js.map +1 -1
- package/dist/engine/acp/harness/codex/history.d.ts.map +1 -1
- package/dist/engine/acp/harness/codex/history.js +25 -23
- package/dist/engine/acp/harness/codex/history.js.map +1 -1
- package/dist/engine/agent/runtime-agents.d.ts +1 -1
- package/dist/engine/agent/runtime-agents.d.ts.map +1 -1
- package/dist/engine/agent/runtime-agents.js +2 -2
- package/dist/engine/agent/runtime-agents.js.map +1 -1
- package/dist/engine/runtime/run.d.ts.map +1 -1
- package/dist/engine/runtime/run.js +1 -1
- package/dist/engine/runtime/run.js.map +1 -1
- package/dist/engine/session/content/external-content-store.d.ts +4 -0
- package/dist/engine/session/content/external-content-store.d.ts.map +1 -1
- package/dist/engine/session/content/external-content-store.js +31 -1
- package/dist/engine/session/content/external-content-store.js.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.js +6 -1
- package/dist/engine/session/prompt/prompt-lifecycle.js.map +1 -1
- package/dist/engine/session/turn/execution-receipts.d.ts.map +1 -1
- package/dist/engine/session/turn/execution-receipts.js +14 -4
- package/dist/engine/session/turn/execution-receipts.js.map +1 -1
- package/dist/engine.js +176 -106
- package/dist/engine.js.map +3 -3
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -2086,7 +2086,7 @@ var init_package = __esm({
|
|
|
2086
2086
|
"package.json"() {
|
|
2087
2087
|
package_default = {
|
|
2088
2088
|
name: "@moxt-ai/mobius",
|
|
2089
|
-
version: "0.0.
|
|
2089
|
+
version: "0.0.357",
|
|
2090
2090
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
2091
2091
|
type: "module",
|
|
2092
2092
|
bin: {
|
|
@@ -2161,8 +2161,8 @@ var init_package = __esm({
|
|
|
2161
2161
|
ws: "^8.21.3"
|
|
2162
2162
|
},
|
|
2163
2163
|
keywords: [],
|
|
2164
|
-
author: "",
|
|
2165
|
-
license: "
|
|
2164
|
+
author: "Moxt",
|
|
2165
|
+
license: "Apache-2.0",
|
|
2166
2166
|
bugs: {
|
|
2167
2167
|
url: "https://github.com/moxt-ai/mobius/issues"
|
|
2168
2168
|
},
|
|
@@ -27237,6 +27237,7 @@ var init_events = __esm({
|
|
|
27237
27237
|
external_exports.object({
|
|
27238
27238
|
...lifecycleBase,
|
|
27239
27239
|
kind: external_exports.literal("prompt.completed"),
|
|
27240
|
+
execution: external_exports.literal("not-started").optional(),
|
|
27240
27241
|
stopReason: shortString
|
|
27241
27242
|
}).readonly(),
|
|
27242
27243
|
external_exports.object({
|
|
@@ -76925,40 +76926,42 @@ async function replayCodexHistory(client2, threadId, emit, signal) {
|
|
|
76925
76926
|
continue;
|
|
76926
76927
|
}
|
|
76927
76928
|
if (item.type === "userMessage") {
|
|
76928
|
-
const
|
|
76929
|
+
const contents = item.content.flatMap((content) => {
|
|
76929
76930
|
if (typeof content !== "object" || content === null) {
|
|
76930
76931
|
return [];
|
|
76931
76932
|
}
|
|
76932
76933
|
const type = Reflect.get(content, "type");
|
|
76933
|
-
const
|
|
76934
|
+
const text2 = Reflect.get(content, "text");
|
|
76934
76935
|
const url2 = Reflect.get(content, "url");
|
|
76935
76936
|
if (type === "image" && typeof url2 === "string") {
|
|
76936
76937
|
return [`[@image](${url2})`];
|
|
76937
76938
|
}
|
|
76938
|
-
return type === "text" && typeof
|
|
76939
|
-
})
|
|
76940
|
-
const
|
|
76941
|
-
|
|
76942
|
-
|
|
76943
|
-
|
|
76944
|
-
|
|
76945
|
-
|
|
76946
|
-
|
|
76947
|
-
|
|
76948
|
-
|
|
76949
|
-
|
|
76950
|
-
|
|
76951
|
-
|
|
76952
|
-
|
|
76953
|
-
|
|
76954
|
-
|
|
76955
|
-
|
|
76956
|
-
|
|
76957
|
-
|
|
76958
|
-
|
|
76959
|
-
|
|
76960
|
-
|
|
76961
|
-
|
|
76939
|
+
return type === "text" && typeof text2 === "string" ? [text2] : [];
|
|
76940
|
+
});
|
|
76941
|
+
for (const text2 of contents) {
|
|
76942
|
+
const history = await embedLocalHistoryImages(
|
|
76943
|
+
{ status: "available", truncated: false, messages: [{ role: "user", text: text2 }] },
|
|
76944
|
+
deadline
|
|
76945
|
+
);
|
|
76946
|
+
if (history.status !== "available") {
|
|
76947
|
+
continue;
|
|
76948
|
+
}
|
|
76949
|
+
const message = history.messages[0];
|
|
76950
|
+
for (const image of message?.images ?? []) {
|
|
76951
|
+
await emit({
|
|
76952
|
+
content: { type: "image", data: image.data, mimeType: image.mimeType },
|
|
76953
|
+
messageId: item.id,
|
|
76954
|
+
sessionUpdate: "user_message_chunk"
|
|
76955
|
+
});
|
|
76956
|
+
}
|
|
76957
|
+
const restoredText = message?.text ?? "";
|
|
76958
|
+
if (restoredText.length > 0) {
|
|
76959
|
+
await emit({
|
|
76960
|
+
content: { text: restoredText, type: "text" },
|
|
76961
|
+
messageId: item.id,
|
|
76962
|
+
sessionUpdate: "user_message_chunk"
|
|
76963
|
+
});
|
|
76964
|
+
}
|
|
76962
76965
|
}
|
|
76963
76966
|
} else if (item.type === "agentMessage") {
|
|
76964
76967
|
await emit(agentMessageUpdate(item.id, item.text));
|
|
@@ -80153,14 +80156,17 @@ var init_session = __esm({
|
|
|
80153
80156
|
});
|
|
80154
80157
|
|
|
80155
80158
|
// src/engine/acp/harness/pi/upstream/dist/acp/translate/pi-messages.js
|
|
80156
|
-
function
|
|
80159
|
+
function piUserMessageContent(content) {
|
|
80157
80160
|
if (typeof content === "string") {
|
|
80158
|
-
return content;
|
|
80161
|
+
return content.length === 0 ? [] : [{ type: "text", text: content }];
|
|
80159
80162
|
}
|
|
80160
80163
|
if (!Array.isArray(content)) {
|
|
80161
|
-
return
|
|
80164
|
+
return [];
|
|
80162
80165
|
}
|
|
80163
|
-
return content.
|
|
80166
|
+
return content.flatMap((value) => {
|
|
80167
|
+
const parsed = userContentSchema.safeParse(value);
|
|
80168
|
+
return parsed.success ? [parsed.data] : [];
|
|
80169
|
+
});
|
|
80164
80170
|
}
|
|
80165
80171
|
function normalizePiAssistantText(content) {
|
|
80166
80172
|
if (!Array.isArray(content)) {
|
|
@@ -80168,9 +80174,15 @@ function normalizePiAssistantText(content) {
|
|
|
80168
80174
|
}
|
|
80169
80175
|
return content.map((c) => c?.type === "text" && typeof c.text === "string" ? c.text : "").filter(Boolean).join("");
|
|
80170
80176
|
}
|
|
80177
|
+
var userContentSchema;
|
|
80171
80178
|
var init_pi_messages = __esm({
|
|
80172
80179
|
"src/engine/acp/harness/pi/upstream/dist/acp/translate/pi-messages.js"() {
|
|
80173
80180
|
"use strict";
|
|
80181
|
+
init_zod();
|
|
80182
|
+
userContentSchema = external_exports.discriminatedUnion("type", [
|
|
80183
|
+
external_exports.object({ type: external_exports.literal("text"), text: external_exports.string() }),
|
|
80184
|
+
external_exports.object({ type: external_exports.literal("image"), data: external_exports.string(), mimeType: external_exports.string() })
|
|
80185
|
+
]);
|
|
80174
80186
|
}
|
|
80175
80187
|
});
|
|
80176
80188
|
|
|
@@ -81612,13 +81624,13 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
81612
81624
|
const m = entry.message;
|
|
81613
81625
|
const role = String(m?.role ?? "");
|
|
81614
81626
|
if (role === "user") {
|
|
81615
|
-
|
|
81616
|
-
|
|
81627
|
+
this.conn.startUserMessage();
|
|
81628
|
+
for (const content of piUserMessageContent(m.content)) {
|
|
81617
81629
|
await this.conn.sessionUpdate({
|
|
81618
81630
|
sessionId: session.sessionId,
|
|
81619
81631
|
update: {
|
|
81620
81632
|
sessionUpdate: "user_message_chunk",
|
|
81621
|
-
content
|
|
81633
|
+
content
|
|
81622
81634
|
}
|
|
81623
81635
|
});
|
|
81624
81636
|
}
|
|
@@ -83304,63 +83316,64 @@ var init_session_events = __esm({
|
|
|
83304
83316
|
const externalized = await externalizer.update(options.sessionId(), notification.update, signal);
|
|
83305
83317
|
signal.throwIfAborted();
|
|
83306
83318
|
const update = externalized.agent;
|
|
83307
|
-
const eventUpdate
|
|
83308
|
-
|
|
83309
|
-
|
|
83310
|
-
|
|
83311
|
-
|
|
83312
|
-
|
|
83319
|
+
for (const eventUpdate of externalized.events) {
|
|
83320
|
+
const backgroundTask = update._meta?.["mobius.backgroundTask"];
|
|
83321
|
+
const payload = decodeAcpSessionUpdate(
|
|
83322
|
+
JSON.stringify(
|
|
83323
|
+
normalizeEvent(
|
|
83324
|
+
(update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") && backgroundTask !== void 0 && typeof eventUpdate === "object" && eventUpdate !== null ? { ...eventUpdate, backgroundTask } : eventUpdate
|
|
83325
|
+
)
|
|
83313
83326
|
)
|
|
83314
|
-
)
|
|
83315
|
-
|
|
83316
|
-
|
|
83317
|
-
|
|
83318
|
-
|
|
83319
|
-
|
|
83320
|
-
|
|
83321
|
-
|
|
83322
|
-
|
|
83323
|
-
|
|
83324
|
-
|
|
83325
|
-
|
|
83326
|
-
}
|
|
83327
|
-
|
|
83328
|
-
|
|
83329
|
-
|
|
83330
|
-
|
|
83331
|
-
|
|
83332
|
-
|
|
83333
|
-
|
|
83334
|
-
|
|
83335
|
-
|
|
83336
|
-
|
|
83337
|
-
|
|
83338
|
-
|
|
83339
|
-
|
|
83340
|
-
|
|
83341
|
-
|
|
83342
|
-
|
|
83343
|
-
|
|
83344
|
-
|
|
83345
|
-
|
|
83327
|
+
);
|
|
83328
|
+
let event;
|
|
83329
|
+
switch (update.sessionUpdate) {
|
|
83330
|
+
case "available_commands_update":
|
|
83331
|
+
event = {
|
|
83332
|
+
kind: "commands",
|
|
83333
|
+
payload,
|
|
83334
|
+
commands: update.availableCommands.slice(0, 500).map((command) => ({
|
|
83335
|
+
description: truncate(command.description, 500),
|
|
83336
|
+
inputHint: truncate(command.input?.hint ?? "", 255),
|
|
83337
|
+
name: truncate(command.name, 128)
|
|
83338
|
+
})).filter((command) => command.name.length > 0)
|
|
83339
|
+
};
|
|
83340
|
+
break;
|
|
83341
|
+
case "config_option_update":
|
|
83342
|
+
event = {
|
|
83343
|
+
kind: "configuration",
|
|
83344
|
+
payload,
|
|
83345
|
+
configOptions: protocol.normalizeUpdate(options.configOptions(), update.configOptions)
|
|
83346
|
+
};
|
|
83347
|
+
break;
|
|
83348
|
+
case "current_mode_update":
|
|
83349
|
+
event = { kind: "mode", payload, modeId: update.currentModeId };
|
|
83350
|
+
break;
|
|
83351
|
+
case "session_info_update": {
|
|
83352
|
+
const changes = [];
|
|
83353
|
+
if (Object.hasOwn(update, "title")) {
|
|
83354
|
+
changes.push({ kind: "title", value: truncate(update.title ?? "", 500) });
|
|
83355
|
+
}
|
|
83356
|
+
if (Object.hasOwn(update, "updatedAt")) {
|
|
83357
|
+
changes.push({ kind: "updated-at", value: truncate(update.updatedAt ?? "", 128) });
|
|
83358
|
+
}
|
|
83359
|
+
event = { kind: "info", payload, changes };
|
|
83360
|
+
break;
|
|
83346
83361
|
}
|
|
83347
|
-
|
|
83348
|
-
|
|
83362
|
+
case "user_message_chunk":
|
|
83363
|
+
case "agent_message_chunk":
|
|
83364
|
+
case "agent_thought_chunk":
|
|
83365
|
+
case "tool_call":
|
|
83366
|
+
case "tool_call_update":
|
|
83367
|
+
case "plan":
|
|
83368
|
+
case "plan_update":
|
|
83369
|
+
case "plan_removed":
|
|
83370
|
+
event = { kind: "content", payload };
|
|
83371
|
+
break;
|
|
83372
|
+
default:
|
|
83373
|
+
event = { kind: "other", payload };
|
|
83349
83374
|
}
|
|
83350
|
-
|
|
83351
|
-
case "agent_message_chunk":
|
|
83352
|
-
case "agent_thought_chunk":
|
|
83353
|
-
case "tool_call":
|
|
83354
|
-
case "tool_call_update":
|
|
83355
|
-
case "plan":
|
|
83356
|
-
case "plan_update":
|
|
83357
|
-
case "plan_removed":
|
|
83358
|
-
event = { kind: "content", payload };
|
|
83359
|
-
break;
|
|
83360
|
-
default:
|
|
83361
|
-
event = { kind: "other", payload };
|
|
83375
|
+
await options.onEvent(event);
|
|
83362
83376
|
}
|
|
83363
|
-
await options.onEvent(event);
|
|
83364
83377
|
});
|
|
83365
83378
|
this.events = this.#updates;
|
|
83366
83379
|
const client2 = {
|
|
@@ -90848,10 +90861,12 @@ var init_adapter2 = __esm({
|
|
|
90848
90861
|
request.nativeSessionId,
|
|
90849
90862
|
async (update) => {
|
|
90850
90863
|
const externalized = await this.#contentExternalizer.update(sessionId, update, signal);
|
|
90851
|
-
events
|
|
90852
|
-
|
|
90853
|
-
|
|
90854
|
-
|
|
90864
|
+
for (const event of externalized.events) {
|
|
90865
|
+
events.push({
|
|
90866
|
+
type: "acp",
|
|
90867
|
+
payload: decodeAcpSessionUpdate(JSON.stringify(fitCodexToolEvent(event)))
|
|
90868
|
+
});
|
|
90869
|
+
}
|
|
90855
90870
|
},
|
|
90856
90871
|
signal
|
|
90857
90872
|
);
|
|
@@ -91001,8 +91016,18 @@ var init_content_externalizer = __esm({
|
|
|
91001
91016
|
]);
|
|
91002
91017
|
AcpContentExternalizer = class {
|
|
91003
91018
|
#store;
|
|
91004
|
-
|
|
91019
|
+
#linkedResources;
|
|
91020
|
+
constructor(store, linkedResources = () => []) {
|
|
91005
91021
|
this.#store = store;
|
|
91022
|
+
this.#linkedResources = linkedResources;
|
|
91023
|
+
}
|
|
91024
|
+
#resourceLinks(text2) {
|
|
91025
|
+
return this.#linkedResources(text2).map((resource) => ({
|
|
91026
|
+
type: "resource_link",
|
|
91027
|
+
uri: resource.uri,
|
|
91028
|
+
name: resource.name,
|
|
91029
|
+
mimeType: resource.mediaType
|
|
91030
|
+
}));
|
|
91006
91031
|
}
|
|
91007
91032
|
async #content(sessionId, content, signal) {
|
|
91008
91033
|
switch (content.type) {
|
|
@@ -91154,7 +91179,7 @@ var init_content_externalizer = __esm({
|
|
|
91154
91179
|
const hasContent = update.content !== void 0 && update.content !== null || agentContent.length > 0;
|
|
91155
91180
|
return {
|
|
91156
91181
|
agent: { ...update, ...meta3, ...output2, ...hasContent ? { content: agentContent } : {} },
|
|
91157
|
-
|
|
91182
|
+
events: [{ ...update, ...meta3, ...output2, ...hasContent ? { content: eventContent } : {} }]
|
|
91158
91183
|
};
|
|
91159
91184
|
}
|
|
91160
91185
|
update = async (sessionId, update, signal) => {
|
|
@@ -91166,7 +91191,12 @@ var init_content_externalizer = __esm({
|
|
|
91166
91191
|
const content = await this.#content(sessionId, update.content, signal);
|
|
91167
91192
|
return {
|
|
91168
91193
|
agent: { ...update, content: content.agent },
|
|
91169
|
-
|
|
91194
|
+
events: [
|
|
91195
|
+
{ ...update, content: content.event },
|
|
91196
|
+
// Keep native text intact. Only add cards for exact file URLs whose
|
|
91197
|
+
// original upload metadata is still known; arbitrary context stays text.
|
|
91198
|
+
...update.sessionUpdate === "user_message_chunk" && update.content.type === "text" ? this.#resourceLinks(update.content.text).map((content2) => ({ ...update, content: content2 })) : []
|
|
91199
|
+
]
|
|
91170
91200
|
};
|
|
91171
91201
|
}
|
|
91172
91202
|
case "tool_call":
|
|
@@ -91174,14 +91204,14 @@ var init_content_externalizer = __esm({
|
|
|
91174
91204
|
return await this.#toolUpdate(sessionId, update, signal);
|
|
91175
91205
|
case "compaction_update": {
|
|
91176
91206
|
if (update.summary === void 0 || update.summary === null) {
|
|
91177
|
-
return { agent: update,
|
|
91207
|
+
return { agent: update, events: [update] };
|
|
91178
91208
|
}
|
|
91179
91209
|
const content = await Promise.all(
|
|
91180
91210
|
update.summary.map(async (item) => await this.#content(sessionId, item, signal))
|
|
91181
91211
|
);
|
|
91182
91212
|
return {
|
|
91183
91213
|
agent: { ...update, summary: content.map((item) => item.agent) },
|
|
91184
|
-
|
|
91214
|
+
events: [{ ...update, summary: content.map((item) => item.event) }]
|
|
91185
91215
|
};
|
|
91186
91216
|
}
|
|
91187
91217
|
case "plan":
|
|
@@ -91192,7 +91222,7 @@ var init_content_externalizer = __esm({
|
|
|
91192
91222
|
case "config_option_update":
|
|
91193
91223
|
case "session_info_update":
|
|
91194
91224
|
case "usage_update":
|
|
91195
|
-
return { agent: update,
|
|
91225
|
+
return { agent: update, events: [update] };
|
|
91196
91226
|
}
|
|
91197
91227
|
};
|
|
91198
91228
|
};
|
|
@@ -91200,10 +91230,10 @@ var init_content_externalizer = __esm({
|
|
|
91200
91230
|
});
|
|
91201
91231
|
|
|
91202
91232
|
// src/engine/agent/runtime-agents.ts
|
|
91203
|
-
function createRuntimeAdapterRegistry(adapters, processes, externalize) {
|
|
91233
|
+
function createRuntimeAdapterRegistry(adapters, processes, externalize, linkedResources) {
|
|
91204
91234
|
return new AdapterRegistry(adapters, {
|
|
91205
91235
|
processes,
|
|
91206
|
-
contentExternalizer: new AcpContentExternalizer(externalize)
|
|
91236
|
+
contentExternalizer: new AcpContentExternalizer(externalize, linkedResources)
|
|
91207
91237
|
});
|
|
91208
91238
|
}
|
|
91209
91239
|
var RuntimeAgentDependencies;
|
|
@@ -95905,7 +95935,12 @@ var init_prompt_lifecycle = __esm({
|
|
|
95905
95935
|
}
|
|
95906
95936
|
const recorded = await this.#recordLifecycle(sessionId, {
|
|
95907
95937
|
type: "lifecycle-metadata",
|
|
95908
|
-
payload: {
|
|
95938
|
+
payload: {
|
|
95939
|
+
kind: "prompt.completed",
|
|
95940
|
+
commandId,
|
|
95941
|
+
stopReason,
|
|
95942
|
+
...request.phase === "queued" ? { execution: "not-started" } : {}
|
|
95943
|
+
}
|
|
95909
95944
|
});
|
|
95910
95945
|
if (!recorded) {
|
|
95911
95946
|
this.#sink.publishOperationFailure(
|
|
@@ -96061,7 +96096,7 @@ var init_execution_receipts = __esm({
|
|
|
96061
96096
|
/** Started identities remain authoritative after their detailed receipt is evicted. */
|
|
96062
96097
|
hasStarted = (commandId, sessionId) => {
|
|
96063
96098
|
const receipt = this.#executions.get(commandId);
|
|
96064
|
-
return receipt ===
|
|
96099
|
+
return receipt?.sessionId === sessionId && receipt.started || this.#table.identity(commandId)?.sessionId === sessionId;
|
|
96065
96100
|
};
|
|
96066
96101
|
/** Reserves an unseen command for cancellation before a delayed prompt can claim its identity. */
|
|
96067
96102
|
recordCancellationBeforeAdmission = (commandId, sessionId) => {
|
|
@@ -96069,9 +96104,16 @@ var init_execution_receipts = __esm({
|
|
|
96069
96104
|
if (existing !== void 0) {
|
|
96070
96105
|
return existing.sessionId === sessionId ? this.outcome(commandId) : void 0;
|
|
96071
96106
|
}
|
|
96107
|
+
const identity2 = this.#table.identity(commandId);
|
|
96108
|
+
if (identity2 !== void 0) {
|
|
96109
|
+
return identity2.sessionId === sessionId ? {
|
|
96110
|
+
type: "lifecycle-metadata",
|
|
96111
|
+
payload: { kind: "prompt.completed", commandId, stopReason: "cancelled" }
|
|
96112
|
+
} : void 0;
|
|
96113
|
+
}
|
|
96072
96114
|
const outcome = {
|
|
96073
96115
|
type: "lifecycle-metadata",
|
|
96074
|
-
payload: { kind: "prompt.completed", commandId, stopReason: "cancelled" }
|
|
96116
|
+
payload: { kind: "prompt.completed", commandId, stopReason: "cancelled", execution: "not-started" }
|
|
96075
96117
|
};
|
|
96076
96118
|
const commandHash = createHash7("sha256").update(
|
|
96077
96119
|
encodeSessionCancelBeforeStartCommand({
|
|
@@ -97008,6 +97050,7 @@ var init_scratch_directory = __esm({
|
|
|
97008
97050
|
// src/engine/session/content/external-content-store.ts
|
|
97009
97051
|
import { createHash as createHash8 } from "node:crypto";
|
|
97010
97052
|
import { extname as extname2, join as join31 } from "node:path";
|
|
97053
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
97011
97054
|
function contentFileName(key, name2) {
|
|
97012
97055
|
const extension = extname2(name2).toLowerCase();
|
|
97013
97056
|
return /^\.[a-z0-9]{1,16}$/u.test(extension) ? `${key}${extension}` : key;
|
|
@@ -97017,6 +97060,7 @@ var init_external_content_store = __esm({
|
|
|
97017
97060
|
"src/engine/session/content/external-content-store.ts"() {
|
|
97018
97061
|
"use strict";
|
|
97019
97062
|
init_zod();
|
|
97063
|
+
init_operation_error();
|
|
97020
97064
|
init_scratch_directory();
|
|
97021
97065
|
contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
|
|
97022
97066
|
CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
|
|
@@ -97080,8 +97124,12 @@ var init_external_content_store = __esm({
|
|
|
97080
97124
|
}
|
|
97081
97125
|
await this.#expire();
|
|
97082
97126
|
active.throwIfAborted();
|
|
97083
|
-
const
|
|
97127
|
+
const writtenPath = await this.#scratch.write(kind, contentFileName(key, metadata.name), bytes, active);
|
|
97128
|
+
const path8 = await this.#scratch.resolveFile(writtenPath);
|
|
97084
97129
|
active.throwIfAborted();
|
|
97130
|
+
if (path8 === null) {
|
|
97131
|
+
throw new OperationError("content_unavailable", "The cached content file is unavailable");
|
|
97132
|
+
}
|
|
97085
97133
|
const retained = this.#entries.get(request);
|
|
97086
97134
|
this.#entries.set(request, {
|
|
97087
97135
|
byteLength: bytes.byteLength,
|
|
@@ -97122,6 +97170,30 @@ var init_external_content_store = __esm({
|
|
|
97122
97170
|
const bytes = await this.#scratch.read(resolved.path, active);
|
|
97123
97171
|
return bytes === null ? null : { ...resolved, bytes };
|
|
97124
97172
|
});
|
|
97173
|
+
/** Metadata for exact, still-cached file URLs. This does not grant content access. */
|
|
97174
|
+
linkedResources = (text2) => {
|
|
97175
|
+
if (!text2.includes("file:///")) {
|
|
97176
|
+
return [];
|
|
97177
|
+
}
|
|
97178
|
+
const resources = [];
|
|
97179
|
+
for (const [request, entry] of this.#entries) {
|
|
97180
|
+
if (!request.startsWith("mobius-content:resource:") || entry.expiresAt <= Date.now()) {
|
|
97181
|
+
continue;
|
|
97182
|
+
}
|
|
97183
|
+
const uri = pathToFileURL3(entry.path).href;
|
|
97184
|
+
for (let index2 = text2.indexOf(uri); index2 >= 0; index2 = text2.indexOf(uri, index2 + uri.length)) {
|
|
97185
|
+
const following = text2[index2 + uri.length];
|
|
97186
|
+
if (following === void 0 || /[\s<>"')\]]/u.test(following)) {
|
|
97187
|
+
resources.push({
|
|
97188
|
+
index: index2,
|
|
97189
|
+
resource: { uri, mediaType: entry.mediaType, name: entry.name, path: entry.path }
|
|
97190
|
+
});
|
|
97191
|
+
break;
|
|
97192
|
+
}
|
|
97193
|
+
}
|
|
97194
|
+
}
|
|
97195
|
+
return resources.sort((left, right) => left.index - right.index).map(({ resource }) => resource);
|
|
97196
|
+
};
|
|
97125
97197
|
[Symbol.asyncDispose] = async () => {
|
|
97126
97198
|
clearInterval(this.#expirationTimer);
|
|
97127
97199
|
this.#lifetime.abort();
|
|
@@ -100820,7 +100892,8 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
|
|
|
100820
100892
|
const adapters = createRuntimeAdapterRegistry(
|
|
100821
100893
|
config2.adapters,
|
|
100822
100894
|
processes,
|
|
100823
|
-
(sessionId, content, contentSignal) => externalContent.put({ ...content, sessionId, signal: contentSignal })
|
|
100895
|
+
(sessionId, content, contentSignal) => externalContent.put({ ...content, sessionId, signal: contentSignal }),
|
|
100896
|
+
externalContent.linkedResources
|
|
100824
100897
|
);
|
|
100825
100898
|
const resolveAgent = async (agentId, resolveSignal, sessionId) => {
|
|
100826
100899
|
const catalogAgent = await resolveCatalogAgent(config2, agentId, resolveSignal);
|