@moxt-ai/mobius 0.0.340 → 0.0.342
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/adapter/claude/agent-connection.js +1 -1
- package/dist/acp/adapter/claude/agent-connection.js.map +1 -1
- package/dist/acp/adapter/codex/agent-connection.js +1 -1
- package/dist/acp/adapter/codex/agent-connection.js.map +1 -1
- package/dist/acp/adapter/codex/tool-event.js +2 -2
- package/dist/acp/adapter/codex/tool-event.js.map +1 -1
- package/dist/acp/adapter/pi/agent-connection.js +1 -1
- package/dist/acp/adapter/pi/agent-connection.js.map +1 -1
- package/dist/acp/adapter/session-events.d.ts +2 -1
- package/dist/acp/adapter/session-events.d.ts.map +1 -1
- package/dist/acp/adapter/session-events.js +66 -89
- package/dist/acp/adapter/session-events.js.map +1 -1
- package/dist/acp/agent/in-process-endpoint.d.ts +3 -1
- package/dist/acp/agent/in-process-endpoint.d.ts.map +1 -1
- package/dist/acp/connection/agent-connection.d.ts +2 -2
- package/dist/acp/connection/agent-connection.d.ts.map +1 -1
- package/dist/acp/content/content-externalizer.d.ts.map +1 -1
- package/dist/acp/content/content-externalizer.js +26 -0
- package/dist/acp/content/content-externalizer.js.map +1 -1
- package/dist/acp/harness/claude/endpoint.js +1 -1
- package/dist/acp/harness/claude/endpoint.js.map +1 -1
- package/dist/acp/harness/codex/agent.js +3 -3
- package/dist/acp/harness/codex/agent.js.map +1 -1
- package/dist/acp/harness/codex/owned-agent.d.ts +2 -2
- package/dist/acp/harness/codex/owned-agent.d.ts.map +1 -1
- package/dist/acp/harness/codex/owned-agent.js +3 -3
- package/dist/acp/harness/codex/owned-agent.js.map +1 -1
- package/dist/acp/native-history/preview-contract.d.ts +3 -4
- package/dist/acp/native-history/preview-contract.d.ts.map +1 -1
- package/dist/cli.js +277 -637
- package/dist/cli.js.map +4 -4
- package/dist/daemon/upgrades/data.js +5 -5
- package/dist/daemon/upgrades/data.js.map +1 -1
- package/dist/daemon/upgrades/package.js +5 -5
- package/dist/daemon/upgrades/package.js.map +1 -1
- package/dist/daemon/upgrades/upgrade.js +4 -7
- package/dist/daemon/upgrades/upgrade.js.map +1 -1
- package/dist/runtime.js +245 -142
- package/dist/runtime.js.map +4 -4
- package/dist/session/api/session-api.d.ts +3 -2
- package/dist/session/api/session-api.d.ts.map +1 -1
- package/dist/session/api/session-api.js +1 -1
- package/dist/session/api/session-api.js.map +1 -1
- package/dist/session/api/session-layer.d.ts +3 -2
- package/dist/session/api/session-layer.d.ts.map +1 -1
- package/dist/session/api/session-layer.js +4 -4
- package/dist/session/api/session-layer.js.map +1 -1
- package/dist/session/history/session-event-history-projection.d.ts.map +1 -1
- package/dist/session/history/session-event-history-projection.js +7 -0
- package/dist/session/history/session-event-history-projection.js.map +1 -1
- package/dist/session/live/agent-session.js +1 -1
- package/dist/session/live/agent-session.js.map +1 -1
- package/dist/session/turn/runtime-turn-activity.d.ts +5 -2
- package/dist/session/turn/runtime-turn-activity.d.ts.map +1 -1
- package/dist/session/turn/runtime-turn-activity.js +15 -10
- package/dist/session/turn/runtime-turn-activity.js.map +1 -1
- package/dist/storage/daemon/version-data.js +2 -2
- package/dist/storage/daemon/version-data.js.map +1 -1
- package/package.json +2 -2
package/dist/runtime.js
CHANGED
|
@@ -21307,6 +21307,7 @@ var boundedJsonSchema = external_exports.unknown().superRefine((value, context)
|
|
|
21307
21307
|
context.addIssue({ code: "custom", message: issue2 });
|
|
21308
21308
|
}
|
|
21309
21309
|
});
|
|
21310
|
+
var isBoundedJson = (value) => boundedJsonIssue(value) === null;
|
|
21310
21311
|
var toolCallLocationSchema = external_exports.object({
|
|
21311
21312
|
line: external_exports.number().int().nonnegative().safe().nullable().optional(),
|
|
21312
21313
|
path: boundedString
|
|
@@ -23273,29 +23274,11 @@ var AgentUpdateStream = class {
|
|
|
23273
23274
|
};
|
|
23274
23275
|
|
|
23275
23276
|
// src/acp/adapter/session-events.ts
|
|
23276
|
-
var MAXIMUM_REASONING_UPDATE_CHARACTERS = 1e6;
|
|
23277
|
-
function* reasoningWireUpdates(update) {
|
|
23278
|
-
if (update.sessionUpdate !== "agent_thought_chunk" || update.content.type !== "text" || update.content.text.length <= MAXIMUM_REASONING_UPDATE_CHARACTERS) {
|
|
23279
|
-
yield update;
|
|
23280
|
-
return;
|
|
23281
|
-
}
|
|
23282
|
-
const text2 = update.content.text;
|
|
23283
|
-
for (let start = 0; start < text2.length; ) {
|
|
23284
|
-
let end = Math.min(start + MAXIMUM_REASONING_UPDATE_CHARACTERS, text2.length);
|
|
23285
|
-
const last = text2.charCodeAt(end - 1);
|
|
23286
|
-
const next = text2.charCodeAt(end);
|
|
23287
|
-
if (last >= 55296 && last <= 56319 && next >= 56320 && next <= 57343) {
|
|
23288
|
-
end -= 1;
|
|
23289
|
-
}
|
|
23290
|
-
yield { ...update, content: { ...update.content, text: text2.slice(start, end) } };
|
|
23291
|
-
start = end;
|
|
23292
|
-
}
|
|
23293
|
-
}
|
|
23294
23277
|
var AdapterSessionConnection = class {
|
|
23295
23278
|
#connection;
|
|
23296
23279
|
#onBackgroundActivity;
|
|
23297
|
-
#backgroundActivity =
|
|
23298
|
-
hasBackgroundActivity = () => this.#backgroundActivity;
|
|
23280
|
+
#backgroundActivity = "none";
|
|
23281
|
+
hasBackgroundActivity = () => this.#backgroundActivity !== "none";
|
|
23299
23282
|
#updates;
|
|
23300
23283
|
#lifetime = new AbortController();
|
|
23301
23284
|
#onClosed;
|
|
@@ -23311,68 +23294,66 @@ var AdapterSessionConnection = class {
|
|
|
23311
23294
|
throw new AcpExecutionError("ACP agent referenced an unknown session", {}, "invalid_agent_session");
|
|
23312
23295
|
}
|
|
23313
23296
|
const signal = AbortSignal.any([this.#lifetime.signal, AbortSignal.timeout(3e4)]);
|
|
23314
|
-
|
|
23315
|
-
|
|
23316
|
-
|
|
23317
|
-
|
|
23318
|
-
|
|
23319
|
-
|
|
23320
|
-
|
|
23321
|
-
|
|
23322
|
-
|
|
23323
|
-
(update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") && backgroundTask !== void 0 && typeof eventUpdate === "object" && eventUpdate !== null ? { ...eventUpdate, backgroundTask } : eventUpdate
|
|
23324
|
-
)
|
|
23297
|
+
const externalized = await externalizer.update(options.sessionId(), notification.update, signal);
|
|
23298
|
+
signal.throwIfAborted();
|
|
23299
|
+
const update = externalized.agent;
|
|
23300
|
+
const eventUpdate = externalized.event;
|
|
23301
|
+
const backgroundTask = update._meta?.["mobius.backgroundTask"];
|
|
23302
|
+
const payload = decodeAcpSessionUpdate(
|
|
23303
|
+
JSON.stringify(
|
|
23304
|
+
normalizeEvent(
|
|
23305
|
+
(update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") && backgroundTask !== void 0 && typeof eventUpdate === "object" && eventUpdate !== null ? { ...eventUpdate, backgroundTask } : eventUpdate
|
|
23325
23306
|
)
|
|
23326
|
-
)
|
|
23327
|
-
|
|
23328
|
-
|
|
23329
|
-
|
|
23330
|
-
|
|
23331
|
-
|
|
23332
|
-
|
|
23333
|
-
|
|
23334
|
-
|
|
23335
|
-
|
|
23336
|
-
|
|
23337
|
-
|
|
23338
|
-
}
|
|
23339
|
-
|
|
23340
|
-
|
|
23341
|
-
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
|
|
23345
|
-
|
|
23346
|
-
|
|
23347
|
-
|
|
23348
|
-
|
|
23349
|
-
|
|
23350
|
-
|
|
23351
|
-
|
|
23352
|
-
|
|
23353
|
-
|
|
23354
|
-
}
|
|
23355
|
-
if (Object.hasOwn(update, "updatedAt")) {
|
|
23356
|
-
changes.push({ kind: "updated-at", value: truncate(update.updatedAt ?? "", 128) });
|
|
23357
|
-
}
|
|
23358
|
-
event = { kind: "info", payload, changes };
|
|
23359
|
-
break;
|
|
23307
|
+
)
|
|
23308
|
+
);
|
|
23309
|
+
let event;
|
|
23310
|
+
switch (update.sessionUpdate) {
|
|
23311
|
+
case "available_commands_update":
|
|
23312
|
+
event = {
|
|
23313
|
+
kind: "commands",
|
|
23314
|
+
payload,
|
|
23315
|
+
commands: update.availableCommands.slice(0, 500).map((command) => ({
|
|
23316
|
+
description: truncate(command.description, 500),
|
|
23317
|
+
inputHint: truncate(command.input?.hint ?? "", 255),
|
|
23318
|
+
name: truncate(command.name, 128)
|
|
23319
|
+
})).filter((command) => command.name.length > 0)
|
|
23320
|
+
};
|
|
23321
|
+
break;
|
|
23322
|
+
case "config_option_update":
|
|
23323
|
+
event = {
|
|
23324
|
+
kind: "configuration",
|
|
23325
|
+
payload,
|
|
23326
|
+
configOptions: protocol.normalizeUpdate(options.configOptions(), update.configOptions)
|
|
23327
|
+
};
|
|
23328
|
+
break;
|
|
23329
|
+
case "current_mode_update":
|
|
23330
|
+
event = { kind: "mode", payload, modeId: update.currentModeId };
|
|
23331
|
+
break;
|
|
23332
|
+
case "session_info_update": {
|
|
23333
|
+
const changes = [];
|
|
23334
|
+
if (Object.hasOwn(update, "title")) {
|
|
23335
|
+
changes.push({ kind: "title", value: truncate(update.title ?? "", 500) });
|
|
23360
23336
|
}
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
case "plan":
|
|
23367
|
-
case "plan_update":
|
|
23368
|
-
case "plan_removed":
|
|
23369
|
-
event = { kind: "content", payload };
|
|
23370
|
-
break;
|
|
23371
|
-
default:
|
|
23372
|
-
event = { kind: "other", payload };
|
|
23337
|
+
if (Object.hasOwn(update, "updatedAt")) {
|
|
23338
|
+
changes.push({ kind: "updated-at", value: truncate(update.updatedAt ?? "", 128) });
|
|
23339
|
+
}
|
|
23340
|
+
event = { kind: "info", payload, changes };
|
|
23341
|
+
break;
|
|
23373
23342
|
}
|
|
23374
|
-
|
|
23343
|
+
case "user_message_chunk":
|
|
23344
|
+
case "agent_message_chunk":
|
|
23345
|
+
case "agent_thought_chunk":
|
|
23346
|
+
case "tool_call":
|
|
23347
|
+
case "tool_call_update":
|
|
23348
|
+
case "plan":
|
|
23349
|
+
case "plan_update":
|
|
23350
|
+
case "plan_removed":
|
|
23351
|
+
event = { kind: "content", payload };
|
|
23352
|
+
break;
|
|
23353
|
+
default:
|
|
23354
|
+
event = { kind: "other", payload };
|
|
23375
23355
|
}
|
|
23356
|
+
await options.onEvent(event);
|
|
23376
23357
|
});
|
|
23377
23358
|
this.events = this.#updates;
|
|
23378
23359
|
const client2 = {
|
|
@@ -23401,12 +23382,12 @@ var AdapterSessionConnection = class {
|
|
|
23401
23382
|
this.#connection = options.agent.createConnection({
|
|
23402
23383
|
cwd: options.cwd,
|
|
23403
23384
|
client: client2,
|
|
23404
|
-
onBackgroundActivity: (
|
|
23385
|
+
onBackgroundActivity: (activity) => {
|
|
23405
23386
|
if (this.#lifetime.signal.aborted) {
|
|
23406
23387
|
return;
|
|
23407
23388
|
}
|
|
23408
|
-
this.#backgroundActivity =
|
|
23409
|
-
this.#onBackgroundActivity(
|
|
23389
|
+
this.#backgroundActivity = activity;
|
|
23390
|
+
this.#onBackgroundActivity(activity);
|
|
23410
23391
|
}
|
|
23411
23392
|
});
|
|
23412
23393
|
}
|
|
@@ -23425,8 +23406,8 @@ var AdapterSessionConnection = class {
|
|
|
23425
23406
|
await this.#updates.drained().catch(() => void 0);
|
|
23426
23407
|
} finally {
|
|
23427
23408
|
this.#onClosed();
|
|
23428
|
-
this.#backgroundActivity =
|
|
23429
|
-
this.#onBackgroundActivity(
|
|
23409
|
+
this.#backgroundActivity = "none";
|
|
23410
|
+
this.#onBackgroundActivity("none");
|
|
23430
23411
|
}
|
|
23431
23412
|
}
|
|
23432
23413
|
};
|
|
@@ -23780,6 +23761,7 @@ import { randomUUID } from "node:crypto";
|
|
|
23780
23761
|
|
|
23781
23762
|
// src/session/history/session-event-history-projection.ts
|
|
23782
23763
|
var MAXIMUM_PROJECTED_REASONING_BYTES = 24 * 1024;
|
|
23764
|
+
var MAXIMUM_PROJECTED_MESSAGE_CHARACTERS = 1e6;
|
|
23783
23765
|
function boundReasoning(payload) {
|
|
23784
23766
|
if (payload.content.type !== "text" || Buffer.byteLength(payload.content.text, "utf8") <= MAXIMUM_PROJECTED_REASONING_BYTES) {
|
|
23785
23767
|
return payload;
|
|
@@ -23848,6 +23830,9 @@ function mergeTextChunk(previous, incoming) {
|
|
|
23848
23830
|
if (previous.sessionUpdate !== "agent_message_chunk" && previous.sessionUpdate !== "agent_thought_chunk" && previous.sessionUpdate !== "user_message_chunk" || incoming.sessionUpdate !== previous.sessionUpdate || previous.messageId !== incoming.messageId || previous.content.type !== "text" || incoming.content.type !== "text") {
|
|
23849
23831
|
return null;
|
|
23850
23832
|
}
|
|
23833
|
+
if (previous.sessionUpdate !== "agent_thought_chunk" && previous.content.text.length + incoming.content.text.length > MAXIMUM_PROJECTED_MESSAGE_CHARACTERS) {
|
|
23834
|
+
return null;
|
|
23835
|
+
}
|
|
23851
23836
|
const content = { text: `${previous.content.text}${incoming.content.text}`, type: "text" };
|
|
23852
23837
|
if (previous.sessionUpdate === "agent_thought_chunk" && incoming.sessionUpdate === "agent_thought_chunk") {
|
|
23853
23838
|
return boundReasoning({
|
|
@@ -26351,7 +26336,7 @@ var CodexOwnedAcpAgent = class {
|
|
|
26351
26336
|
await this.#enqueue(async () => {
|
|
26352
26337
|
if (item.type === "commandExecution" && method === "item/started") {
|
|
26353
26338
|
this.#runningCommands.set(item.id, "foreground");
|
|
26354
|
-
this.#context.onBackgroundActivity?.(
|
|
26339
|
+
this.#context.onBackgroundActivity?.("running");
|
|
26355
26340
|
}
|
|
26356
26341
|
if (method === "item/started") {
|
|
26357
26342
|
await this.#context.emit({ ...update, sessionUpdate: "tool_call" });
|
|
@@ -26372,7 +26357,7 @@ var CodexOwnedAcpAgent = class {
|
|
|
26372
26357
|
}
|
|
26373
26358
|
if (item.type === "commandExecution" && method === "item/completed") {
|
|
26374
26359
|
this.#runningCommands.delete(item.id);
|
|
26375
|
-
this.#context.onBackgroundActivity?.(this.#runningCommands.size > 0);
|
|
26360
|
+
this.#context.onBackgroundActivity?.(this.#runningCommands.size > 0 ? "running" : "none");
|
|
26376
26361
|
}
|
|
26377
26362
|
});
|
|
26378
26363
|
}
|
|
@@ -32007,7 +31992,7 @@ function prepareCodexToolUpdate(update) {
|
|
|
32007
31992
|
};
|
|
32008
31993
|
}
|
|
32009
31994
|
function fitPayload(value) {
|
|
32010
|
-
if (value === void 0 ||
|
|
31995
|
+
if (value === void 0 || isBoundedJson(value)) {
|
|
32011
31996
|
return value;
|
|
32012
31997
|
}
|
|
32013
31998
|
return { truncated: true, text: payloadText(value) };
|
|
@@ -32181,6 +32166,29 @@ var harnessAdapters = (agent, dependencies) => {
|
|
|
32181
32166
|
|
|
32182
32167
|
// src/acp/content/content-externalizer.ts
|
|
32183
32168
|
var MAXIMUM_ENCODED_CONTENT_CHARACTERS = 4e6;
|
|
32169
|
+
var MAXIMUM_TEXT_CHARACTERS = 1e6;
|
|
32170
|
+
function boundedText2(text2) {
|
|
32171
|
+
if (text2.length <= MAXIMUM_TEXT_CHARACTERS) {
|
|
32172
|
+
return text2;
|
|
32173
|
+
}
|
|
32174
|
+
const marker = (start2) => `... [omit ${text2.length - start2} characters since ${start2}]`;
|
|
32175
|
+
let start = 0;
|
|
32176
|
+
let upper = MAXIMUM_TEXT_CHARACTERS;
|
|
32177
|
+
while (start < upper) {
|
|
32178
|
+
const candidate = Math.ceil((start + upper) / 2);
|
|
32179
|
+
if (candidate + marker(candidate).length <= MAXIMUM_TEXT_CHARACTERS) {
|
|
32180
|
+
start = candidate;
|
|
32181
|
+
} else {
|
|
32182
|
+
upper = candidate - 1;
|
|
32183
|
+
}
|
|
32184
|
+
}
|
|
32185
|
+
const last = text2.charCodeAt(start - 1);
|
|
32186
|
+
const next = text2.charCodeAt(start);
|
|
32187
|
+
if (last >= 55296 && last <= 56319 && next >= 56320 && next <= 57343) {
|
|
32188
|
+
start -= 1;
|
|
32189
|
+
}
|
|
32190
|
+
return text2.slice(0, start) + marker(start);
|
|
32191
|
+
}
|
|
32184
32192
|
function decodeBase64(data) {
|
|
32185
32193
|
if (data.length > MAXIMUM_ENCODED_CONTENT_CHARACTERS || data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(data)) {
|
|
32186
32194
|
throw new Error("The ACP embedded content is not valid bounded base64");
|
|
@@ -32225,6 +32233,7 @@ var AcpContentExternalizer = class {
|
|
|
32225
32233
|
async #content(sessionId, content, signal) {
|
|
32226
32234
|
switch (content.type) {
|
|
32227
32235
|
case "text":
|
|
32236
|
+
return { agent: content, event: { ...content, text: boundedText2(content.text) } };
|
|
32228
32237
|
case "resource_link":
|
|
32229
32238
|
return { agent: content, event: content };
|
|
32230
32239
|
case "image": {
|
|
@@ -32438,7 +32447,7 @@ import { fetch as fetch3 } from "undici";
|
|
|
32438
32447
|
// package.json
|
|
32439
32448
|
var package_default = {
|
|
32440
32449
|
name: "@moxt-ai/mobius",
|
|
32441
|
-
version: "0.0.
|
|
32450
|
+
version: "0.0.342",
|
|
32442
32451
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
32443
32452
|
type: "module",
|
|
32444
32453
|
bin: {
|
|
@@ -69064,6 +69073,108 @@ function backgroundTaskId(result) {
|
|
|
69064
69073
|
return typeof result === "object" && result !== null && "backgroundTaskId" in result && typeof result.backgroundTaskId === "string" && result.backgroundTaskId.length > 0 ? result.backgroundTaskId : void 0;
|
|
69065
69074
|
}
|
|
69066
69075
|
|
|
69076
|
+
// src/acp/harness/claude/upstream/dist/context-resources.js
|
|
69077
|
+
import { extname as extname2 } from "node:path";
|
|
69078
|
+
function formatUriAsLink(uri) {
|
|
69079
|
+
if (uri.startsWith("file://")) {
|
|
69080
|
+
const path7 = uri.slice(7);
|
|
69081
|
+
return `[@${path7.split("/").pop() || path7}](${uri})`;
|
|
69082
|
+
}
|
|
69083
|
+
if (uri.startsWith("zed://")) {
|
|
69084
|
+
return `[@${uri.split("/").pop() || uri}](${uri})`;
|
|
69085
|
+
}
|
|
69086
|
+
return uri;
|
|
69087
|
+
}
|
|
69088
|
+
var formatContextBlock = (uri, text2) => `
|
|
69089
|
+
<context ref="${uri}">
|
|
69090
|
+
${text2}
|
|
69091
|
+
</context>`;
|
|
69092
|
+
function parseContextBlock(block) {
|
|
69093
|
+
if (block.type !== "text" || typeof block.text !== "string") {
|
|
69094
|
+
return null;
|
|
69095
|
+
}
|
|
69096
|
+
const match = /^\n<context ref="([^"\r\n]+)">\n([\s\S]*)\n<\/context>$/u.exec(block.text);
|
|
69097
|
+
const uri = match?.[1];
|
|
69098
|
+
const text2 = match?.[2];
|
|
69099
|
+
if (uri === void 0 || text2 === void 0 || formatContextBlock(uri, text2) !== block.text) {
|
|
69100
|
+
return null;
|
|
69101
|
+
}
|
|
69102
|
+
return { uri, text: text2 };
|
|
69103
|
+
}
|
|
69104
|
+
function contextMimeType(uri) {
|
|
69105
|
+
let pathname = uri;
|
|
69106
|
+
try {
|
|
69107
|
+
pathname = new URL(uri).pathname;
|
|
69108
|
+
} catch {
|
|
69109
|
+
}
|
|
69110
|
+
switch (extname2(pathname).toLowerCase()) {
|
|
69111
|
+
case ".html":
|
|
69112
|
+
case ".htm":
|
|
69113
|
+
return "text/html";
|
|
69114
|
+
case ".js":
|
|
69115
|
+
case ".mjs":
|
|
69116
|
+
case ".cjs":
|
|
69117
|
+
return "text/javascript";
|
|
69118
|
+
case ".css":
|
|
69119
|
+
return "text/css";
|
|
69120
|
+
case ".json":
|
|
69121
|
+
return "application/json";
|
|
69122
|
+
case ".md":
|
|
69123
|
+
case ".markdown":
|
|
69124
|
+
return "text/markdown";
|
|
69125
|
+
case ".xml":
|
|
69126
|
+
return "application/xml";
|
|
69127
|
+
case ".svg":
|
|
69128
|
+
return "image/svg+xml";
|
|
69129
|
+
case ".csv":
|
|
69130
|
+
return "text/csv";
|
|
69131
|
+
default:
|
|
69132
|
+
return "text/plain";
|
|
69133
|
+
}
|
|
69134
|
+
}
|
|
69135
|
+
function replayContextResources(content) {
|
|
69136
|
+
const contexts = [];
|
|
69137
|
+
let contextStart = content.length;
|
|
69138
|
+
for (let index2 = content.length - 1; index2 >= 0; index2 -= 1) {
|
|
69139
|
+
const block = content[index2];
|
|
69140
|
+
const parsed = block === void 0 ? null : parseContextBlock(block);
|
|
69141
|
+
if (parsed === null) {
|
|
69142
|
+
break;
|
|
69143
|
+
}
|
|
69144
|
+
contexts.push(parsed);
|
|
69145
|
+
contextStart = index2;
|
|
69146
|
+
}
|
|
69147
|
+
if (contexts.length === 0) {
|
|
69148
|
+
return null;
|
|
69149
|
+
}
|
|
69150
|
+
contexts.reverse();
|
|
69151
|
+
const links = new Set(contexts.map(({ uri }) => formatUriAsLink(uri)));
|
|
69152
|
+
const resources = /* @__PURE__ */ new Map();
|
|
69153
|
+
let nextContext = 0;
|
|
69154
|
+
for (let index2 = 0; index2 < contextStart; index2 += 1) {
|
|
69155
|
+
const block = content[index2];
|
|
69156
|
+
if (block?.type !== "text" || typeof block.text !== "string") {
|
|
69157
|
+
continue;
|
|
69158
|
+
}
|
|
69159
|
+
if (block.text.startsWith('\n<context ref="')) {
|
|
69160
|
+
return null;
|
|
69161
|
+
}
|
|
69162
|
+
if (!links.has(block.text)) {
|
|
69163
|
+
continue;
|
|
69164
|
+
}
|
|
69165
|
+
const context = contexts[nextContext];
|
|
69166
|
+
if (context === void 0 || block.text !== formatUriAsLink(context.uri)) {
|
|
69167
|
+
return null;
|
|
69168
|
+
}
|
|
69169
|
+
resources.set(index2, {
|
|
69170
|
+
type: "resource",
|
|
69171
|
+
resource: { ...context, mimeType: contextMimeType(context.uri) }
|
|
69172
|
+
});
|
|
69173
|
+
nextContext += 1;
|
|
69174
|
+
}
|
|
69175
|
+
return nextContext === contexts.length ? { contextStart, resources } : null;
|
|
69176
|
+
}
|
|
69177
|
+
|
|
69067
69178
|
// src/acp/harness/claude/upstream/dist/elicitation.js
|
|
69068
69179
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
69069
69180
|
import { CreateElicitationResponse } from "@agentclientprotocol/sdk";
|
|
@@ -72403,14 +72514,15 @@ var ClaudeAcpAgent = class {
|
|
|
72403
72514
|
providerUpdate = null;
|
|
72404
72515
|
exitPlan;
|
|
72405
72516
|
environment;
|
|
72406
|
-
backgroundSessions = /* @__PURE__ */ new
|
|
72407
|
-
reportBackgroundActivity(session,
|
|
72408
|
-
if (
|
|
72409
|
-
this.backgroundSessions.add(session);
|
|
72410
|
-
} else {
|
|
72517
|
+
backgroundSessions = /* @__PURE__ */ new Map();
|
|
72518
|
+
reportBackgroundActivity(session, activity) {
|
|
72519
|
+
if (activity === "none") {
|
|
72411
72520
|
this.backgroundSessions.delete(session);
|
|
72521
|
+
} else {
|
|
72522
|
+
this.backgroundSessions.set(session, activity);
|
|
72412
72523
|
}
|
|
72413
|
-
|
|
72524
|
+
const activities = new Set(this.backgroundSessions.values());
|
|
72525
|
+
this.onBackgroundActivity?.(activities.has("running") ? "running" : activities.has("awaiting-results") ? "awaiting-results" : "none");
|
|
72414
72526
|
}
|
|
72415
72527
|
/** Grace period before a `session/cancel` forces a wedged prompt loop to
|
|
72416
72528
|
* return "cancelled". See {@link DEFAULT_FORCE_CANCEL_GRACE_MS}. Mutable so
|
|
@@ -73035,7 +73147,7 @@ var ClaudeAcpAgent = class {
|
|
|
73035
73147
|
const awaitingBackgroundResults = /* @__PURE__ */ new Set();
|
|
73036
73148
|
let processingBackgroundResults = /* @__PURE__ */ new Set();
|
|
73037
73149
|
let hasBackgroundLevel = false;
|
|
73038
|
-
const reportBackgroundActivity = () => this.reportBackgroundActivity(session, backgroundTasks.size > 0
|
|
73150
|
+
const reportBackgroundActivity = () => this.reportBackgroundActivity(session, backgroundTasks.size > 0 ? "running" : awaitingBackgroundResults.size > 0 ? "awaiting-results" : "none");
|
|
73039
73151
|
let lastAssistantTotalUsage = null;
|
|
73040
73152
|
let lastAssistantUsage = null;
|
|
73041
73153
|
let lastAssistantModel = null;
|
|
@@ -74372,7 +74484,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
74372
74484
|
session.settingsManager.dispose();
|
|
74373
74485
|
session.input.end();
|
|
74374
74486
|
session.query.close();
|
|
74375
|
-
this.reportBackgroundActivity(session,
|
|
74487
|
+
this.reportBackgroundActivity(session, "none");
|
|
74376
74488
|
}
|
|
74377
74489
|
/** Cleanly tear down a session: cancel in-flight work, release stream
|
|
74378
74490
|
* resources, and remove it from the session map. */
|
|
@@ -75982,22 +76094,6 @@ function getAvailableSlashCommands(commands, terminalCommands) {
|
|
|
75982
76094
|
};
|
|
75983
76095
|
}).filter((command) => !UNSUPPORTED_COMMANDS.includes(command.name));
|
|
75984
76096
|
}
|
|
75985
|
-
function formatUriAsLink(uri) {
|
|
75986
|
-
try {
|
|
75987
|
-
if (uri.startsWith("file://")) {
|
|
75988
|
-
const path7 = uri.slice(7);
|
|
75989
|
-
const name2 = path7.split("/").pop() || path7;
|
|
75990
|
-
return `[@${name2}](${uri})`;
|
|
75991
|
-
} else if (uri.startsWith("zed://")) {
|
|
75992
|
-
const parts = uri.split("/");
|
|
75993
|
-
const name2 = parts[parts.length - 1] || uri;
|
|
75994
|
-
return `[@${name2}](${uri})`;
|
|
75995
|
-
}
|
|
75996
|
-
return uri;
|
|
75997
|
-
} catch {
|
|
75998
|
-
return uri;
|
|
75999
|
-
}
|
|
76000
|
-
}
|
|
76001
76097
|
function promptToClaude(prompt) {
|
|
76002
76098
|
const content = [];
|
|
76003
76099
|
const context = [];
|
|
@@ -76030,10 +76126,7 @@ function promptToClaude(prompt) {
|
|
|
76030
76126
|
});
|
|
76031
76127
|
context.push({
|
|
76032
76128
|
type: "text",
|
|
76033
|
-
text:
|
|
76034
|
-
<context ref="${chunk.resource.uri}">
|
|
76035
|
-
${chunk.resource.text}
|
|
76036
|
-
</context>`
|
|
76129
|
+
text: formatContextBlock(chunk.resource.uri, chunk.resource.text)
|
|
76037
76130
|
});
|
|
76038
76131
|
}
|
|
76039
76132
|
break;
|
|
@@ -76203,8 +76296,13 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, client2, log
|
|
|
76203
76296
|
const toolUseResult = options?.toolUseResult !== void 0 && content.filter((c) => typeof c === "object" && c !== null && c.type === "tool_result").length === 1 ? options.toolUseResult : void 0;
|
|
76204
76297
|
const toolResultMeta = parseToolResultMeta(options?.toolResultMeta);
|
|
76205
76298
|
const output2 = [];
|
|
76206
|
-
|
|
76299
|
+
const replayedResources = role === "user" && options.historical === true ? replayContextResources(content) : null;
|
|
76300
|
+
for (const [index2, chunk] of content.entries()) {
|
|
76301
|
+
if (replayedResources !== null && index2 >= replayedResources.contextStart) {
|
|
76302
|
+
break;
|
|
76303
|
+
}
|
|
76207
76304
|
let update = null;
|
|
76305
|
+
const resource = replayedResources?.resources.get(index2);
|
|
76208
76306
|
switch (chunk.type) {
|
|
76209
76307
|
case "text":
|
|
76210
76308
|
case "text_delta": {
|
|
@@ -76213,7 +76311,7 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, client2, log
|
|
|
76213
76311
|
update = {
|
|
76214
76312
|
sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
|
|
76215
76313
|
messageId,
|
|
76216
|
-
content: {
|
|
76314
|
+
content: resource ?? {
|
|
76217
76315
|
type: "text",
|
|
76218
76316
|
text: chunk.text
|
|
76219
76317
|
}
|
|
@@ -76714,7 +76812,7 @@ var ClaudeAcpEndpoint = class {
|
|
|
76714
76812
|
CLAUDE_CODE_EXECUTABLE: options.command
|
|
76715
76813
|
}),
|
|
76716
76814
|
onSessionUpdate: options.onSessionUpdate,
|
|
76717
|
-
onBackgroundActivity: (
|
|
76815
|
+
onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity),
|
|
76718
76816
|
onConnect: (connection) => {
|
|
76719
76817
|
this.#connection = connection;
|
|
76720
76818
|
}
|
|
@@ -76751,7 +76849,7 @@ var ClaudeAgentConnection = class extends EndpointAgentConnection {
|
|
|
76751
76849
|
onSessionUpdate: async (notification) => {
|
|
76752
76850
|
await options.client.onUpdate(notification);
|
|
76753
76851
|
},
|
|
76754
|
-
onBackgroundActivity: (
|
|
76852
|
+
onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity)
|
|
76755
76853
|
});
|
|
76756
76854
|
super(endpoint, options.client);
|
|
76757
76855
|
}
|
|
@@ -77816,9 +77914,9 @@ var CodexAcpAgent = class {
|
|
|
77816
77914
|
threadId: () => this.#nativeSessionId,
|
|
77817
77915
|
connection: () => this.#connection,
|
|
77818
77916
|
emit: this.#emit,
|
|
77819
|
-
onBackgroundActivity: (
|
|
77917
|
+
onBackgroundActivity: (activity) => {
|
|
77820
77918
|
if (this.#closePromise === null) {
|
|
77821
|
-
this.#onBackgroundActivity?.(
|
|
77919
|
+
this.#onBackgroundActivity?.(activity);
|
|
77822
77920
|
}
|
|
77823
77921
|
},
|
|
77824
77922
|
close: this.close
|
|
@@ -77966,7 +78064,7 @@ var CodexAcpAgent = class {
|
|
|
77966
78064
|
await stopProcessTree(child, captured);
|
|
77967
78065
|
} finally {
|
|
77968
78066
|
this.#connection?.close();
|
|
77969
|
-
this.#onBackgroundActivity?.(
|
|
78067
|
+
this.#onBackgroundActivity?.("none");
|
|
77970
78068
|
}
|
|
77971
78069
|
})();
|
|
77972
78070
|
}
|
|
@@ -78063,7 +78161,7 @@ var CodexAgentConnection = class extends EndpointAgentConnection {
|
|
|
78063
78161
|
cwd: options.cwd,
|
|
78064
78162
|
environment: options.environment,
|
|
78065
78163
|
onSessionUpdate: options.client.onUpdate,
|
|
78066
|
-
onBackgroundActivity: (
|
|
78164
|
+
onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity)
|
|
78067
78165
|
});
|
|
78068
78166
|
super(endpoint, options.client);
|
|
78069
78167
|
}
|
|
@@ -82021,7 +82119,7 @@ var PiAgentConnection = class extends EndpointAgentConnection {
|
|
|
82021
82119
|
await options.client.onUpdate({ ...notification, update });
|
|
82022
82120
|
}
|
|
82023
82121
|
},
|
|
82024
|
-
onBackgroundActivity: (
|
|
82122
|
+
onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity)
|
|
82025
82123
|
});
|
|
82026
82124
|
super(endpoint, options.client);
|
|
82027
82125
|
}
|
|
@@ -84052,7 +84150,7 @@ function conversationTitleFromText(text2) {
|
|
|
84052
84150
|
|
|
84053
84151
|
// src/session/api/session-api.ts
|
|
84054
84152
|
var NullSessionObserver = class {
|
|
84055
|
-
onBackgroundActivity = (_source,
|
|
84153
|
+
onBackgroundActivity = (_source, _activity) => {
|
|
84056
84154
|
};
|
|
84057
84155
|
onSessionEvent = (_event) => Promise.resolve();
|
|
84058
84156
|
onCommands = () => Promise.resolve();
|
|
@@ -85165,7 +85263,7 @@ var AgentSession = class _AgentSession {
|
|
|
85165
85263
|
...scope,
|
|
85166
85264
|
additionalDirectories: this.#additionalDirectories,
|
|
85167
85265
|
capabilities: () => this.#capabilities,
|
|
85168
|
-
onBackgroundActivity: (
|
|
85266
|
+
onBackgroundActivity: (activity) => this.#getObserver().onBackgroundActivity?.(this, activity),
|
|
85169
85267
|
interactions: {
|
|
85170
85268
|
onPermission: this.#interactions.onPermission,
|
|
85171
85269
|
onElicitation: this.#interactions.onElicitation,
|
|
@@ -87341,25 +87439,30 @@ var ExecutionReceipts = class {
|
|
|
87341
87439
|
// src/session/turn/runtime-turn-activity.ts
|
|
87342
87440
|
var RuntimeTurnActivity = class {
|
|
87343
87441
|
#turns = /* @__PURE__ */ new Set();
|
|
87344
|
-
#backgroundSources = /* @__PURE__ */ new
|
|
87442
|
+
#backgroundSources = /* @__PURE__ */ new Map();
|
|
87345
87443
|
#idleWaiters = /* @__PURE__ */ new Set();
|
|
87346
87444
|
// When work last started or stopped; the quiet period is measured from here.
|
|
87347
87445
|
#changedAt = Date.now();
|
|
87348
87446
|
#reserved = false;
|
|
87349
87447
|
acceptsPrompts = () => !this.#reserved;
|
|
87350
87448
|
count = () => this.#turns.size + this.#backgroundSources.size;
|
|
87351
|
-
|
|
87352
|
-
|
|
87353
|
-
|
|
87354
|
-
|
|
87355
|
-
|
|
87356
|
-
|
|
87449
|
+
/** Why admission is held: prompts running or queued, native tasks running, results not yet handled. */
|
|
87450
|
+
describe = () => {
|
|
87451
|
+
const activities = [...this.#backgroundSources.values()];
|
|
87452
|
+
return {
|
|
87453
|
+
turns: this.#turns.size,
|
|
87454
|
+
backgroundRunning: activities.filter((activity) => activity === "running").length,
|
|
87455
|
+
backgroundAwaitingResults: activities.filter((activity) => activity === "awaiting-results").length
|
|
87456
|
+
};
|
|
87457
|
+
};
|
|
87458
|
+
setBackgroundActivity = (source, activity) => {
|
|
87459
|
+
if (activity === (this.#backgroundSources.get(source) ?? "none")) {
|
|
87357
87460
|
return;
|
|
87358
87461
|
}
|
|
87359
|
-
if (
|
|
87360
|
-
this.#backgroundSources.add(source);
|
|
87361
|
-
} else {
|
|
87462
|
+
if (activity === "none") {
|
|
87362
87463
|
this.#backgroundSources.delete(source);
|
|
87464
|
+
} else {
|
|
87465
|
+
this.#backgroundSources.set(source, activity);
|
|
87363
87466
|
}
|
|
87364
87467
|
this.#changed();
|
|
87365
87468
|
};
|
|
@@ -87882,8 +87985,8 @@ var SessionLayerObserver = class extends NullSessionObserver {
|
|
|
87882
87985
|
this.#publishInfo = publishInfo;
|
|
87883
87986
|
this.#record = record2;
|
|
87884
87987
|
}
|
|
87885
|
-
onBackgroundActivity = (source,
|
|
87886
|
-
this.#backgroundActivity(source,
|
|
87988
|
+
onBackgroundActivity = (source, activity) => {
|
|
87989
|
+
this.#backgroundActivity(source, activity);
|
|
87887
87990
|
};
|
|
87888
87991
|
onSessionEvent = (event) => {
|
|
87889
87992
|
this.#record(event);
|
|
@@ -87920,8 +88023,8 @@ function buildSessionLayer(options) {
|
|
|
87920
88023
|
eventProjection.record(event);
|
|
87921
88024
|
},
|
|
87922
88025
|
sink.publishInfo,
|
|
87923
|
-
(source,
|
|
87924
|
-
options.turnActivity?.setBackgroundActivity(source,
|
|
88026
|
+
(source, activity) => {
|
|
88027
|
+
options.turnActivity?.setBackgroundActivity(source, activity);
|
|
87925
88028
|
options.processes.notifyChanged();
|
|
87926
88029
|
}
|
|
87927
88030
|
),
|
|
@@ -89579,7 +89682,7 @@ function createContentWriteCommands(context) {
|
|
|
89579
89682
|
import { WebSocket as WebSocket5 } from "undici";
|
|
89580
89683
|
|
|
89581
89684
|
// src/session/content/session-files.ts
|
|
89582
|
-
import { basename as basename8, extname as
|
|
89685
|
+
import { basename as basename8, extname as extname3, isAbsolute as isAbsolute16, join as join33, normalize as normalize3, resolve as resolve17 } from "node:path";
|
|
89583
89686
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
89584
89687
|
function requestedPath(value) {
|
|
89585
89688
|
if (value.includes("\0")) {
|
|
@@ -89635,7 +89738,7 @@ async function streamLocalFile(command, send2, sendChunk, signal, workingDirecto
|
|
|
89635
89738
|
send2({
|
|
89636
89739
|
byteLength: before.size,
|
|
89637
89740
|
kind: FILE_BEGIN_KIND,
|
|
89638
|
-
mediaType: external?.mediaType ?? raster?.mimeType ?? (
|
|
89741
|
+
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname3(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
89639
89742
|
modifiedAt: before.modifiedAt.toISOString(),
|
|
89640
89743
|
name: external?.name ?? (basename8(target) || "file"),
|
|
89641
89744
|
requestId: command.requestId,
|