@moxt-ai/mobius 0.0.44 → 0.0.46
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/markdown-images.d.ts +2 -3
- package/dist/acp/markdown-images.d.ts.map +1 -1
- package/dist/acp/markdown-images.js +15 -7
- package/dist/acp/markdown-images.js.map +1 -1
- package/dist/acp/session-manager.d.ts +3 -2
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +29 -10
- package/dist/acp/session-manager.js.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.d.ts.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.js +1 -0
- package/dist/agent-catalog/publish-agent-catalog.js.map +1 -1
- package/dist/artifacts/runtime-artifact-uploader.d.ts.map +1 -1
- package/dist/artifacts/runtime-artifact-uploader.js +10 -17
- package/dist/artifacts/runtime-artifact-uploader.js.map +1 -1
- package/dist/authorization/local-raster.d.ts +1 -1
- package/dist/authorization/local-raster.d.ts.map +1 -1
- package/dist/authorization/local-raster.js +2 -21
- package/dist/authorization/local-raster.js.map +1 -1
- package/dist/cli.js +262 -105
- package/dist/cli.js.map +3 -3
- package/dist/index.js +268 -111
- package/dist/index.js.map +3 -3
- package/dist/native-sessions/codex-history.js +1 -1
- package/dist/native-sessions/codex-history.js.map +1 -1
- package/dist/native-sessions/history-images.d.ts +1 -1
- package/dist/native-sessions/history-images.d.ts.map +1 -1
- package/dist/native-sessions/history-images.js +5 -5
- package/dist/native-sessions/history-images.js.map +1 -1
- package/dist/pairing/pair-local-machine.d.ts.map +1 -1
- package/dist/pairing/pair-local-machine.js +1 -0
- package/dist/pairing/pair-local-machine.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +152 -27
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +261 -104
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -21071,6 +21071,7 @@ function decodeMessageKind(encoded) {
|
|
|
21071
21071
|
}
|
|
21072
21072
|
function decodeSessionPromptCommand(encoded) {
|
|
21073
21073
|
const value = parseJson2(encoded);
|
|
21074
|
+
const hasSessionConfigurations = Object.hasOwn(value, "sessionConfigurations");
|
|
21074
21075
|
assertExactKeys(value, [
|
|
21075
21076
|
"additionalDirectoryIds",
|
|
21076
21077
|
"agentId",
|
|
@@ -21082,6 +21083,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21082
21083
|
"kind",
|
|
21083
21084
|
"prompt",
|
|
21084
21085
|
"resources",
|
|
21086
|
+
...hasSessionConfigurations ? ["sessionConfigurations"] : [],
|
|
21085
21087
|
"sessionId",
|
|
21086
21088
|
"targetCommandId"
|
|
21087
21089
|
]);
|
|
@@ -21102,6 +21104,10 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21102
21104
|
if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !IDENTIFIER_PATTERN2.test(targetCommandId)) {
|
|
21103
21105
|
throw new ProtocolMessageError("Prompt disposition has an invalid target command");
|
|
21104
21106
|
}
|
|
21107
|
+
const sessionConfigurations = hasSessionConfigurations ? decodeSessionConfigurationSelections(value["sessionConfigurations"]) : [];
|
|
21108
|
+
if (new Set(sessionConfigurations.map((selection) => selection.configId)).size !== sessionConfigurations.length) {
|
|
21109
|
+
throw new ProtocolMessageError("Session configuration identifiers must be unique");
|
|
21110
|
+
}
|
|
21105
21111
|
return {
|
|
21106
21112
|
additionalDirectoryIds: readDirectoryIdentifiers(value, "additionalDirectoryIds", 16),
|
|
21107
21113
|
agentId: readIdentifier(value, "agentId"),
|
|
@@ -21113,6 +21119,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21113
21119
|
kind: SESSION_PROMPT_KIND,
|
|
21114
21120
|
prompt,
|
|
21115
21121
|
resources,
|
|
21122
|
+
...hasSessionConfigurations ? { sessionConfigurations } : {},
|
|
21116
21123
|
sessionId: readIdentifier(value, "sessionId"),
|
|
21117
21124
|
targetCommandId
|
|
21118
21125
|
};
|
|
@@ -24355,7 +24362,7 @@ import {
|
|
|
24355
24362
|
|
|
24356
24363
|
// src/authorization/local-raster.ts
|
|
24357
24364
|
import { readFile as readFile2, realpath as realpath6, stat as stat5 } from "node:fs/promises";
|
|
24358
|
-
import { basename, isAbsolute as isAbsolute8, normalize as normalize2
|
|
24365
|
+
import { basename, isAbsolute as isAbsolute8, normalize as normalize2 } from "node:path";
|
|
24359
24366
|
import { fileURLToPath } from "node:url";
|
|
24360
24367
|
var MAX_LOCAL_RASTER_BYTES = 3e6;
|
|
24361
24368
|
var PNG_SIGNATURE = Uint8Array.of(137, 80, 78, 71);
|
|
@@ -24413,10 +24420,6 @@ function readInlineRaster(data, name = "Image") {
|
|
|
24413
24420
|
}
|
|
24414
24421
|
return new LocalRasterImage(basename(name) || "Image", mimeType, bytes);
|
|
24415
24422
|
}
|
|
24416
|
-
function isInsideRoot(root, target) {
|
|
24417
|
-
const relation = relative4(root, target);
|
|
24418
|
-
return relation !== ".." && !relation.startsWith(`..${sep4}`) && !isAbsolute8(relation);
|
|
24419
|
-
}
|
|
24420
24423
|
async function resolveCanonicalPath(requested, signal) {
|
|
24421
24424
|
signal.throwIfAborted();
|
|
24422
24425
|
if (!isAbsolute8(requested) || requested.includes("\0") || normalize2(requested) !== requested) {
|
|
@@ -24461,7 +24464,7 @@ function parseLocalImageUri(uri) {
|
|
|
24461
24464
|
}
|
|
24462
24465
|
return trimmed;
|
|
24463
24466
|
}
|
|
24464
|
-
async function
|
|
24467
|
+
async function readLocalRaster(uri, signal) {
|
|
24465
24468
|
signal.throwIfAborted();
|
|
24466
24469
|
const requested = parseLocalImageUri(uri);
|
|
24467
24470
|
if (requested === null) {
|
|
@@ -24476,21 +24479,6 @@ async function readAuthorizedRaster(uri, roots, signal) {
|
|
|
24476
24479
|
if (!targetMetadata.isFile() || targetMetadata.size < 1 || targetMetadata.size > MAX_LOCAL_RASTER_BYTES) {
|
|
24477
24480
|
return null;
|
|
24478
24481
|
}
|
|
24479
|
-
const authorizedRoots = [];
|
|
24480
|
-
for (const root of roots) {
|
|
24481
|
-
const directory = await resolveCanonicalPath(root, signal);
|
|
24482
|
-
if (directory === null) {
|
|
24483
|
-
continue;
|
|
24484
|
-
}
|
|
24485
|
-
const metadata = await stat5(directory);
|
|
24486
|
-
signal.throwIfAborted();
|
|
24487
|
-
if (metadata.isDirectory()) {
|
|
24488
|
-
authorizedRoots.push(directory);
|
|
24489
|
-
}
|
|
24490
|
-
}
|
|
24491
|
-
if (!authorizedRoots.some((root) => isInsideRoot(root, target))) {
|
|
24492
|
-
return null;
|
|
24493
|
-
}
|
|
24494
24482
|
const bytes = new Uint8Array(await readFile2(target));
|
|
24495
24483
|
signal.throwIfAborted();
|
|
24496
24484
|
if (bytes.byteLength < 1 || bytes.byteLength > MAX_LOCAL_RASTER_BYTES) {
|
|
@@ -24589,7 +24577,7 @@ var unmeasuredOperationMetrics = Object.freeze({
|
|
|
24589
24577
|
|
|
24590
24578
|
// src/native-sessions/history-images.ts
|
|
24591
24579
|
var IMAGE_MARKER = /\[@image\]\(([^)\r\n]*)(?:\)|$)/g;
|
|
24592
|
-
async function embedLocalHistoryImages(history,
|
|
24580
|
+
async function embedLocalHistoryImages(history, signal) {
|
|
24593
24581
|
if (history.status !== "available") {
|
|
24594
24582
|
return history;
|
|
24595
24583
|
}
|
|
@@ -24597,7 +24585,7 @@ async function embedLocalHistoryImages(history, roots, signal) {
|
|
|
24597
24585
|
let imageCharacters = 0;
|
|
24598
24586
|
for (const message of history.messages) {
|
|
24599
24587
|
signal.throwIfAborted();
|
|
24600
|
-
const resolved = await resolveMessageImages(message,
|
|
24588
|
+
const resolved = await resolveMessageImages(message, imageCharacters, signal);
|
|
24601
24589
|
imageCharacters += (resolved.images ?? []).reduce((size, image) => size + image.data.length, 0);
|
|
24602
24590
|
messages.push(resolved);
|
|
24603
24591
|
}
|
|
@@ -24606,7 +24594,7 @@ async function embedLocalHistoryImages(history, roots, signal) {
|
|
|
24606
24594
|
messages
|
|
24607
24595
|
};
|
|
24608
24596
|
}
|
|
24609
|
-
async function resolveMessageImages(message,
|
|
24597
|
+
async function resolveMessageImages(message, usedCharacters, signal) {
|
|
24610
24598
|
const images = [...message.images ?? []];
|
|
24611
24599
|
let imageCharacters = images.reduce((size, image) => size + image.data.length, 0);
|
|
24612
24600
|
const text3 = await replaceImageMarkers(message.text, async (uri) => {
|
|
@@ -24622,7 +24610,7 @@ async function resolveMessageImages(message, roots, usedCharacters, signal) {
|
|
|
24622
24610
|
imageCharacters += embedded.data.length;
|
|
24623
24611
|
return "";
|
|
24624
24612
|
}
|
|
24625
|
-
const local = await
|
|
24613
|
+
const local = await readLocalRaster(uri, signal);
|
|
24626
24614
|
if (local === null) {
|
|
24627
24615
|
return "[Image unavailable]";
|
|
24628
24616
|
}
|
|
@@ -32354,16 +32342,24 @@ function parseMarkdownImages(markdown) {
|
|
|
32354
32342
|
});
|
|
32355
32343
|
return images.sort((left, right) => left.start - right.start);
|
|
32356
32344
|
}
|
|
32357
|
-
async function
|
|
32345
|
+
async function emitMarkdownChunksWithLocalImages(options) {
|
|
32346
|
+
const markdown = options.chunks.join("");
|
|
32347
|
+
const images = parseMarkdownImages(markdown);
|
|
32348
|
+
if (images.length === 0) {
|
|
32349
|
+
for (const chunk of options.chunks) {
|
|
32350
|
+
await options.onText(chunk);
|
|
32351
|
+
}
|
|
32352
|
+
return;
|
|
32353
|
+
}
|
|
32358
32354
|
let cursor = 0;
|
|
32359
|
-
for (const image of
|
|
32355
|
+
for (const image of images) {
|
|
32360
32356
|
if (image.start < cursor) {
|
|
32361
32357
|
continue;
|
|
32362
32358
|
}
|
|
32363
32359
|
if (image.start > cursor) {
|
|
32364
|
-
await options.onText(
|
|
32360
|
+
await options.onText(markdown.slice(cursor, image.start));
|
|
32365
32361
|
}
|
|
32366
|
-
const raster = await
|
|
32362
|
+
const raster = await readLocalRaster(image.uri, options.signal);
|
|
32367
32363
|
if (raster === null) {
|
|
32368
32364
|
await options.onText("[Image unavailable]");
|
|
32369
32365
|
} else {
|
|
@@ -32371,8 +32367,8 @@ async function emitMarkdownWithLocalImages(options) {
|
|
|
32371
32367
|
}
|
|
32372
32368
|
cursor = image.end;
|
|
32373
32369
|
}
|
|
32374
|
-
if (cursor <
|
|
32375
|
-
await options.onText(
|
|
32370
|
+
if (cursor < markdown.length) {
|
|
32371
|
+
await options.onText(markdown.slice(cursor));
|
|
32376
32372
|
}
|
|
32377
32373
|
}
|
|
32378
32374
|
|
|
@@ -33714,6 +33710,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33714
33710
|
#preSessionUpdateBytes = 0;
|
|
33715
33711
|
#agentName = "";
|
|
33716
33712
|
#agentVersion = "";
|
|
33713
|
+
#bufferedAgentText = null;
|
|
33717
33714
|
#capabilities = {
|
|
33718
33715
|
additionalDirectories: false,
|
|
33719
33716
|
audioPrompt: false,
|
|
@@ -33887,26 +33884,37 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33887
33884
|
);
|
|
33888
33885
|
await this.#updateTail;
|
|
33889
33886
|
signal.throwIfAborted();
|
|
33890
|
-
return await embedLocalHistoryImages(
|
|
33891
|
-
history.snapshot(),
|
|
33892
|
-
[this.#cwd, ...this.#additionalDirectories],
|
|
33893
|
-
signal
|
|
33894
|
-
);
|
|
33887
|
+
return await embedLocalHistoryImages(history.snapshot(), signal);
|
|
33895
33888
|
} finally {
|
|
33896
33889
|
this.#replay = { kind: "idle" };
|
|
33897
33890
|
}
|
|
33898
33891
|
};
|
|
33899
|
-
|
|
33900
|
-
emitAgentText = async (text3, messageId) => {
|
|
33892
|
+
emitAgentMessage = async (chunks, messageId) => {
|
|
33901
33893
|
const signal = AbortSignal.timeout(2e4);
|
|
33902
|
-
await
|
|
33903
|
-
|
|
33894
|
+
await emitMarkdownChunksWithLocalImages({
|
|
33895
|
+
chunks,
|
|
33904
33896
|
onImage: async (image) => await this.emitRaster(image, messageId, signal),
|
|
33905
33897
|
onText: async (content3) => await this.#turn.onText(content3, messageId),
|
|
33906
|
-
roots: this.imageRoots(),
|
|
33907
33898
|
signal
|
|
33908
33899
|
});
|
|
33909
33900
|
};
|
|
33901
|
+
bufferAgentText = async (text3, messageId) => {
|
|
33902
|
+
if (this.#bufferedAgentText !== null && this.#bufferedAgentText.messageId !== messageId) {
|
|
33903
|
+
await this.emitAgentMessage(this.#bufferedAgentText.chunks, this.#bufferedAgentText.messageId);
|
|
33904
|
+
this.#bufferedAgentText = null;
|
|
33905
|
+
}
|
|
33906
|
+
this.#bufferedAgentText = {
|
|
33907
|
+
chunks: [...this.#bufferedAgentText?.chunks ?? [], text3],
|
|
33908
|
+
messageId
|
|
33909
|
+
};
|
|
33910
|
+
};
|
|
33911
|
+
flushAgentText = async () => {
|
|
33912
|
+
const buffered = this.#bufferedAgentText;
|
|
33913
|
+
this.#bufferedAgentText = null;
|
|
33914
|
+
if (buffered !== null) {
|
|
33915
|
+
await this.emitAgentMessage(buffered.chunks, buffered.messageId);
|
|
33916
|
+
}
|
|
33917
|
+
};
|
|
33910
33918
|
prepareAgentContent = async (content3) => {
|
|
33911
33919
|
if (content3.type === "image" && content3.data.length > 0) {
|
|
33912
33920
|
const raster = readInlineRaster(content3.data, content3.name);
|
|
@@ -33916,7 +33924,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33916
33924
|
}
|
|
33917
33925
|
if (content3.type === "image" && content3.data.length === 0 && content3.uri.length > 0) {
|
|
33918
33926
|
const signal = AbortSignal.timeout(2e4);
|
|
33919
|
-
const raster = await
|
|
33927
|
+
const raster = await readLocalRaster(content3.uri, signal);
|
|
33920
33928
|
if (raster !== null) {
|
|
33921
33929
|
return await this.importRaster(raster, signal);
|
|
33922
33930
|
}
|
|
@@ -34386,6 +34394,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
34386
34394
|
options.signal
|
|
34387
34395
|
);
|
|
34388
34396
|
await this.#updateTail;
|
|
34397
|
+
await this.flushAgentText();
|
|
34389
34398
|
await running.activities.finish();
|
|
34390
34399
|
let result;
|
|
34391
34400
|
try {
|
|
@@ -34417,6 +34426,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
34417
34426
|
cause: error62
|
|
34418
34427
|
});
|
|
34419
34428
|
} finally {
|
|
34429
|
+
this.#bufferedAgentText = null;
|
|
34420
34430
|
this.#turn = new IdleAcpTurn();
|
|
34421
34431
|
}
|
|
34422
34432
|
};
|
|
@@ -34708,10 +34718,11 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
34708
34718
|
);
|
|
34709
34719
|
} else {
|
|
34710
34720
|
await this.#turn.activities.finishNarrative();
|
|
34711
|
-
await this.
|
|
34721
|
+
await this.bufferAgentText(update.content.text, truncate3(update.messageId ?? "", 255));
|
|
34712
34722
|
}
|
|
34713
34723
|
} else {
|
|
34714
34724
|
await this.#turn.activities.finishNarrative();
|
|
34725
|
+
await this.flushAgentText();
|
|
34715
34726
|
await this.emitAgentContent(
|
|
34716
34727
|
normalizeContentBlock(update.content),
|
|
34717
34728
|
truncate3(update.messageId ?? "", 255)
|
|
@@ -36026,7 +36037,8 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
36026
36037
|
botSessionConfiguration: true,
|
|
36027
36038
|
capabilities: agent.capabilities,
|
|
36028
36039
|
id: agent.id,
|
|
36029
|
-
label: agent.label
|
|
36040
|
+
label: agent.label,
|
|
36041
|
+
sessionTurnConfiguration: true
|
|
36030
36042
|
})),
|
|
36031
36043
|
installableAgents: catalog.installableAgents
|
|
36032
36044
|
}),
|
|
@@ -36752,13 +36764,6 @@ var UploadedRuntimeArtifact = class {
|
|
|
36752
36764
|
this.sha256 = sha256;
|
|
36753
36765
|
}
|
|
36754
36766
|
};
|
|
36755
|
-
function daemonToken(config2) {
|
|
36756
|
-
const token = config2.relayUrl.searchParams.get("token");
|
|
36757
|
-
if (token === null || token.length < 32) {
|
|
36758
|
-
throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay daemon token is missing");
|
|
36759
|
-
}
|
|
36760
|
-
return token;
|
|
36761
|
-
}
|
|
36762
36767
|
function channelOrigin(config2) {
|
|
36763
36768
|
const url2 = new URL(config2.relayUrl);
|
|
36764
36769
|
url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
|
|
@@ -36803,24 +36808,23 @@ async function readAuthorization(response) {
|
|
|
36803
36808
|
translateSdkError(cause);
|
|
36804
36809
|
}
|
|
36805
36810
|
}
|
|
36806
|
-
function sessionArtifactUrl(origin, sessionId, resourcePath
|
|
36807
|
-
|
|
36808
|
-
url2.searchParams.set("token", token);
|
|
36809
|
-
return url2;
|
|
36811
|
+
function sessionArtifactUrl(origin, sessionId, resourcePath) {
|
|
36812
|
+
return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
|
|
36810
36813
|
}
|
|
36811
|
-
async function postLease(url2, request, signal) {
|
|
36814
|
+
async function postLease(url2, headers, request, signal) {
|
|
36812
36815
|
return await fetch3(url2, {
|
|
36813
36816
|
dispatcher: environmentProxyDispatcher,
|
|
36814
|
-
headers: { "content-type": "application/json" },
|
|
36817
|
+
headers: { ...headers, "content-type": "application/json" },
|
|
36815
36818
|
method: "POST",
|
|
36816
36819
|
body: JSON.stringify(request),
|
|
36817
36820
|
signal
|
|
36818
36821
|
});
|
|
36819
36822
|
}
|
|
36820
|
-
async function putContent(url2, authorization, bytes, signal) {
|
|
36823
|
+
async function putContent(url2, headers, authorization, bytes, signal) {
|
|
36821
36824
|
return await fetch3(url2, {
|
|
36822
36825
|
dispatcher: environmentProxyDispatcher,
|
|
36823
36826
|
headers: {
|
|
36827
|
+
...headers,
|
|
36824
36828
|
"content-type": authorization.mediaType,
|
|
36825
36829
|
"x-mobius-upload-token": authorization.uploadToken
|
|
36826
36830
|
},
|
|
@@ -36845,11 +36849,12 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
36845
36849
|
const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
|
|
36846
36850
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
36847
36851
|
const origin = channelOrigin(config2);
|
|
36848
|
-
const
|
|
36852
|
+
const headers = runtimeAuthorization(config2.relayUrl);
|
|
36849
36853
|
let created;
|
|
36850
36854
|
try {
|
|
36851
36855
|
created = await postLease(
|
|
36852
|
-
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"
|
|
36856
|
+
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
|
|
36857
|
+
headers,
|
|
36853
36858
|
request,
|
|
36854
36859
|
requestSignal
|
|
36855
36860
|
);
|
|
@@ -36869,12 +36874,8 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
36869
36874
|
let uploaded;
|
|
36870
36875
|
try {
|
|
36871
36876
|
uploaded = await putContent(
|
|
36872
|
-
sessionArtifactUrl(
|
|
36873
|
-
|
|
36874
|
-
sessionId,
|
|
36875
|
-
`artifacts/${encodeURIComponent(authorization.artifactId)}/content`,
|
|
36876
|
-
token
|
|
36877
|
-
),
|
|
36877
|
+
sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
|
|
36878
|
+
headers,
|
|
36878
36879
|
authorization,
|
|
36879
36880
|
artifact.bytes,
|
|
36880
36881
|
requestSignal
|
|
@@ -36917,7 +36918,7 @@ var LocalAuthorizationError = class extends Error {
|
|
|
36917
36918
|
// src/authorization/workspace-directory.ts
|
|
36918
36919
|
import { readdir as readdir2, realpath as realpath7, stat as stat6 } from "node:fs/promises";
|
|
36919
36920
|
import { homedir as homedir2 } from "node:os";
|
|
36920
|
-
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute9, join as join15, normalize as normalize3, relative as
|
|
36921
|
+
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute9, join as join15, normalize as normalize3, relative as relative4 } from "node:path";
|
|
36921
36922
|
var WorkspaceDirectoryListing = class {
|
|
36922
36923
|
directoryId;
|
|
36923
36924
|
directoryLabel;
|
|
@@ -37000,7 +37001,7 @@ var WorkspaceDirectoryService = class {
|
|
|
37000
37001
|
}
|
|
37001
37002
|
};
|
|
37002
37003
|
label = (path2) => {
|
|
37003
|
-
const suffix =
|
|
37004
|
+
const suffix = relative4(homedir2(), path2);
|
|
37004
37005
|
return suffix === "" ? "~" : !isAbsolute9(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
|
|
37005
37006
|
};
|
|
37006
37007
|
identify = async (bindingId, requestedPath, signal) => {
|
|
@@ -37328,7 +37329,7 @@ function relayEndpoint(relayUrl, context, target) {
|
|
|
37328
37329
|
endpoint.pathname = `${MOBIUS_API_PREFIX}/v1/bot-executions/${execution}/delivery-targets/${encodeURIComponent(deliveryTargetId)}/messages`;
|
|
37329
37330
|
return endpoint;
|
|
37330
37331
|
}
|
|
37331
|
-
function
|
|
37332
|
+
function daemonToken(relayUrl) {
|
|
37332
37333
|
const token = relayUrl.searchParams.get("token") ?? "";
|
|
37333
37334
|
if (!/^[a-zA-Z0-9_-]{32,256}$/.test(token)) {
|
|
37334
37335
|
throw new LocalBotAuthorizationError("bot_service_unavailable", "The Runtime credential is unavailable");
|
|
@@ -37483,7 +37484,7 @@ var BotOutboundIpcServer = class {
|
|
|
37483
37484
|
response = await fetch4(relayEndpoint(this.#relayUrl, context, request.target), {
|
|
37484
37485
|
body: JSON.stringify({ idempotencyKey: request.idempotencyKey, text: request.text }),
|
|
37485
37486
|
headers: {
|
|
37486
|
-
authorization: `Bearer ${
|
|
37487
|
+
authorization: `Bearer ${daemonToken(this.#relayUrl)}`,
|
|
37487
37488
|
"content-type": "application/json",
|
|
37488
37489
|
"x-mobius-bot-execution-capability": context.command.executionCapabilitySecret
|
|
37489
37490
|
},
|
|
@@ -37738,7 +37739,7 @@ async function readCodexHistory(agent, cwd, nativeSessionId, signal) {
|
|
|
37738
37739
|
const snapshot = await response.promise;
|
|
37739
37740
|
return {
|
|
37740
37741
|
...snapshot,
|
|
37741
|
-
history: await embedLocalHistoryImages(snapshot.history,
|
|
37742
|
+
history: await embedLocalHistoryImages(snapshot.history, signal)
|
|
37742
37743
|
};
|
|
37743
37744
|
} finally {
|
|
37744
37745
|
clearTimeout(timeout);
|
|
@@ -39335,17 +39336,7 @@ var DaemonAcpObserver = class {
|
|
|
39335
39336
|
this.#config = config2;
|
|
39336
39337
|
this.#record = record4;
|
|
39337
39338
|
}
|
|
39338
|
-
importLocalArtifact = async (sessionId, artifact, signal) =>
|
|
39339
|
-
try {
|
|
39340
|
-
return (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
39341
|
-
} catch (cause) {
|
|
39342
|
-
signal.throwIfAborted();
|
|
39343
|
-
if (cause instanceof Error && cause.name === "AbortError") {
|
|
39344
|
-
throw cause;
|
|
39345
|
-
}
|
|
39346
|
-
return "";
|
|
39347
|
-
}
|
|
39348
|
-
};
|
|
39339
|
+
importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
39349
39340
|
onCommands = (event) => {
|
|
39350
39341
|
this.#record(event.sessionId, encodeSessionCommandsUpdatedEvent(event));
|
|
39351
39342
|
return Promise.resolve();
|
|
@@ -40118,6 +40109,36 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40118
40109
|
signal
|
|
40119
40110
|
);
|
|
40120
40111
|
const agent = config2.catalog.find(command.agentId);
|
|
40112
|
+
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40113
|
+
throw new AcpExecutionError(
|
|
40114
|
+
"The queued prompt target is unavailable",
|
|
40115
|
+
{},
|
|
40116
|
+
"prompt_queue_target_unavailable"
|
|
40117
|
+
);
|
|
40118
|
+
}
|
|
40119
|
+
if (command.sessionConfigurations !== void 0) {
|
|
40120
|
+
const prepared = await sessions.prepareExecutionSession({
|
|
40121
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
40122
|
+
agent,
|
|
40123
|
+
cwd: resolved.cwd,
|
|
40124
|
+
sessionId: command.sessionId,
|
|
40125
|
+
signal
|
|
40126
|
+
});
|
|
40127
|
+
if (command.disposition === SessionPromptDisposition.Steer) {
|
|
40128
|
+
assertCompleteSessionConfiguration(prepared.configOptions, command.sessionConfigurations);
|
|
40129
|
+
} else {
|
|
40130
|
+
await applyCompleteSessionConfiguration(
|
|
40131
|
+
sessions,
|
|
40132
|
+
prepared.configOptions,
|
|
40133
|
+
command.sessionConfigurations,
|
|
40134
|
+
agent,
|
|
40135
|
+
resolved.cwd,
|
|
40136
|
+
resolved.additionalDirectories,
|
|
40137
|
+
command.sessionId,
|
|
40138
|
+
signal
|
|
40139
|
+
);
|
|
40140
|
+
}
|
|
40141
|
+
}
|
|
40121
40142
|
audit.record({
|
|
40122
40143
|
commandId: command.commandId,
|
|
40123
40144
|
event: "session_authorized",
|
|
@@ -40152,13 +40173,6 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40152
40173
|
});
|
|
40153
40174
|
stopReason = "steered";
|
|
40154
40175
|
} else {
|
|
40155
|
-
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40156
|
-
throw new AcpExecutionError(
|
|
40157
|
-
"The queued prompt target is unavailable",
|
|
40158
|
-
{},
|
|
40159
|
-
"prompt_queue_target_unavailable"
|
|
40160
|
-
);
|
|
40161
|
-
}
|
|
40162
40176
|
const result = await sessions.runPrompt({
|
|
40163
40177
|
additionalDirectories: resolved.additionalDirectories,
|
|
40164
40178
|
agent,
|
|
@@ -40225,6 +40239,113 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40225
40239
|
console.error("Mobius daemon command failed", error62);
|
|
40226
40240
|
}
|
|
40227
40241
|
}
|
|
40242
|
+
function invalidSessionConfiguration(message) {
|
|
40243
|
+
return new AcpExecutionError(message, {}, "invalid_session_configuration");
|
|
40244
|
+
}
|
|
40245
|
+
function validateSessionConfigurationSelection(option, selection) {
|
|
40246
|
+
if (option.type !== selection.valueType) {
|
|
40247
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} changed type`);
|
|
40248
|
+
}
|
|
40249
|
+
if (option.type === "boolean") {
|
|
40250
|
+
if (selection.value.length > 0) {
|
|
40251
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40252
|
+
}
|
|
40253
|
+
return;
|
|
40254
|
+
}
|
|
40255
|
+
if (selection.booleanValue) {
|
|
40256
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40257
|
+
}
|
|
40258
|
+
if (!option.values.some((value) => value.value === selection.value)) {
|
|
40259
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an unavailable value`);
|
|
40260
|
+
}
|
|
40261
|
+
}
|
|
40262
|
+
function assertSessionConfigurationSchema(options, selections) {
|
|
40263
|
+
if (options.length !== selections.length) {
|
|
40264
|
+
throw invalidSessionConfiguration("The Turn configuration does not match the Agent settings schema");
|
|
40265
|
+
}
|
|
40266
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40267
|
+
if (selectionsById.size !== selections.length) {
|
|
40268
|
+
throw invalidSessionConfiguration("The Turn configuration contains duplicate Agent settings");
|
|
40269
|
+
}
|
|
40270
|
+
for (const option of options) {
|
|
40271
|
+
const selection = selectionsById.get(option.id);
|
|
40272
|
+
if (selection === void 0 || selection.valueType !== option.type || option.type === "boolean" && selection.value.length > 0 || option.type === "select" && selection.booleanValue) {
|
|
40273
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option.id}`);
|
|
40274
|
+
}
|
|
40275
|
+
}
|
|
40276
|
+
}
|
|
40277
|
+
function sessionConfigurationMatches(option, selection) {
|
|
40278
|
+
validateSessionConfigurationSelection(option, selection);
|
|
40279
|
+
return option.type === "boolean" ? option.booleanValue === selection.booleanValue : option.currentValue === selection.value;
|
|
40280
|
+
}
|
|
40281
|
+
function sessionConfigurationPriority(selection, options) {
|
|
40282
|
+
if (selection.configId === "permission_mode") {
|
|
40283
|
+
return 0;
|
|
40284
|
+
}
|
|
40285
|
+
const option = options.find((candidate) => candidate.id === selection.configId);
|
|
40286
|
+
if (selection.configId === "model" || option?.category === "model") {
|
|
40287
|
+
return 1;
|
|
40288
|
+
}
|
|
40289
|
+
if (selection.configId === "reasoning_effort" || option?.category === "thought_level") {
|
|
40290
|
+
return 2;
|
|
40291
|
+
}
|
|
40292
|
+
if (option?.category === "model_config") {
|
|
40293
|
+
return 3;
|
|
40294
|
+
}
|
|
40295
|
+
return 4;
|
|
40296
|
+
}
|
|
40297
|
+
function assertCompleteSessionConfiguration(options, selections) {
|
|
40298
|
+
assertSessionConfigurationSchema(options, selections);
|
|
40299
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40300
|
+
for (const option of options) {
|
|
40301
|
+
const selection = selectionsById.get(option.id);
|
|
40302
|
+
if (selection === void 0 || !sessionConfigurationMatches(option, selection)) {
|
|
40303
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option.id}`);
|
|
40304
|
+
}
|
|
40305
|
+
}
|
|
40306
|
+
}
|
|
40307
|
+
async function applySessionConfigurationSelection(sessions, options, selection, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40308
|
+
const option = options.find((candidate) => candidate.id === selection.configId);
|
|
40309
|
+
if (option === void 0) {
|
|
40310
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} is unavailable`);
|
|
40311
|
+
}
|
|
40312
|
+
if (sessionConfigurationMatches(option, selection)) {
|
|
40313
|
+
return options;
|
|
40314
|
+
}
|
|
40315
|
+
return await sessions.configureSession({
|
|
40316
|
+
additionalDirectories,
|
|
40317
|
+
agent,
|
|
40318
|
+
booleanValue: selection.booleanValue,
|
|
40319
|
+
configId: selection.configId,
|
|
40320
|
+
cwd,
|
|
40321
|
+
requestId: `cfg_${randomUUID3()}`,
|
|
40322
|
+
sessionId,
|
|
40323
|
+
signal,
|
|
40324
|
+
value: selection.value,
|
|
40325
|
+
valueType: selection.valueType
|
|
40326
|
+
});
|
|
40327
|
+
}
|
|
40328
|
+
async function applyCompleteSessionConfiguration(sessions, initialOptions, selections, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40329
|
+
assertSessionConfigurationSchema(initialOptions, selections);
|
|
40330
|
+
let options = initialOptions;
|
|
40331
|
+
const orderedSelections = selections.toSorted((left, right) => {
|
|
40332
|
+
const priority = sessionConfigurationPriority(left, initialOptions) - sessionConfigurationPriority(right, initialOptions);
|
|
40333
|
+
return priority === 0 ? left.configId.localeCompare(right.configId) : priority;
|
|
40334
|
+
});
|
|
40335
|
+
for (const selection of orderedSelections) {
|
|
40336
|
+
options = await applySessionConfigurationSelection(
|
|
40337
|
+
sessions,
|
|
40338
|
+
options,
|
|
40339
|
+
selection,
|
|
40340
|
+
agent,
|
|
40341
|
+
cwd,
|
|
40342
|
+
additionalDirectories,
|
|
40343
|
+
sessionId,
|
|
40344
|
+
signal
|
|
40345
|
+
);
|
|
40346
|
+
}
|
|
40347
|
+
assertCompleteSessionConfiguration(options, selections);
|
|
40348
|
+
}
|
|
40228
40349
|
function botExecutionAgent(agent, contextHandle, socketPath) {
|
|
40229
40350
|
return new LocalAgentDefinition(
|
|
40230
40351
|
agent.id,
|
|
@@ -40257,24 +40378,55 @@ function assertPreparedPermission(configOptions, permissionMode) {
|
|
|
40257
40378
|
);
|
|
40258
40379
|
}
|
|
40259
40380
|
}
|
|
40260
|
-
|
|
40381
|
+
function warnIgnoredExecutionSetting(audit, commandId, sessionId, agentId, selection, category, reason) {
|
|
40382
|
+
const details = {
|
|
40383
|
+
agentId,
|
|
40384
|
+
category,
|
|
40385
|
+
configId: selection.configId,
|
|
40386
|
+
reason,
|
|
40387
|
+
requestedValue: selection.value
|
|
40388
|
+
};
|
|
40389
|
+
const event = "bot_execution_setting_ignored";
|
|
40390
|
+
audit.record({ commandId, details, event, sessionId });
|
|
40391
|
+
process.stderr.write(`Mobius daemon warning ${JSON.stringify({ commandId, event, sessionId, ...details })}
|
|
40392
|
+
`);
|
|
40393
|
+
}
|
|
40394
|
+
async function applySupportedExecutionSelection(sessions, audit, configOptions, selection, category, agent, cwd, additionalDirectories, commandId, sessionId, signal) {
|
|
40395
|
+
if (selection.value === AGENT_DEFAULT_EXECUTION_SETTING) {
|
|
40396
|
+
return configOptions;
|
|
40397
|
+
}
|
|
40261
40398
|
const option = configOptions.find((candidate) => candidate.id === selection.configId);
|
|
40262
|
-
if (option === void 0
|
|
40263
|
-
|
|
40264
|
-
|
|
40265
|
-
|
|
40266
|
-
|
|
40399
|
+
if (option === void 0) {
|
|
40400
|
+
warnIgnoredExecutionSetting(audit, commandId, sessionId, agent.id, selection, category, "setting_unavailable");
|
|
40401
|
+
return configOptions;
|
|
40402
|
+
}
|
|
40403
|
+
if (option.type !== "select" || option.category !== category) {
|
|
40404
|
+
warnIgnoredExecutionSetting(
|
|
40405
|
+
audit,
|
|
40406
|
+
commandId,
|
|
40407
|
+
sessionId,
|
|
40408
|
+
agent.id,
|
|
40409
|
+
selection,
|
|
40410
|
+
category,
|
|
40411
|
+
"setting_schema_mismatch"
|
|
40267
40412
|
);
|
|
40413
|
+
return configOptions;
|
|
40268
40414
|
}
|
|
40269
|
-
if (selection.
|
|
40415
|
+
if (selection.valueType !== "select" || selection.booleanValue) {
|
|
40416
|
+
warnIgnoredExecutionSetting(
|
|
40417
|
+
audit,
|
|
40418
|
+
commandId,
|
|
40419
|
+
sessionId,
|
|
40420
|
+
agent.id,
|
|
40421
|
+
selection,
|
|
40422
|
+
category,
|
|
40423
|
+
"selection_schema_mismatch"
|
|
40424
|
+
);
|
|
40270
40425
|
return configOptions;
|
|
40271
40426
|
}
|
|
40272
40427
|
if (!option.values.some((value) => value.value === selection.value)) {
|
|
40273
|
-
|
|
40274
|
-
|
|
40275
|
-
{},
|
|
40276
|
-
"invalid_session_configuration"
|
|
40277
|
-
);
|
|
40428
|
+
warnIgnoredExecutionSetting(audit, commandId, sessionId, agent.id, selection, category, "value_unavailable");
|
|
40429
|
+
return configOptions;
|
|
40278
40430
|
}
|
|
40279
40431
|
if (option.currentValue === selection.value) {
|
|
40280
40432
|
return configOptions;
|
|
@@ -40373,25 +40525,29 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
40373
40525
|
signal: executionSignal
|
|
40374
40526
|
});
|
|
40375
40527
|
assertPreparedPermission(prepared.configOptions, execution.executionConfiguration.permissionMode);
|
|
40376
|
-
let configOptions = await
|
|
40528
|
+
let configOptions = await applySupportedExecutionSelection(
|
|
40377
40529
|
sessions,
|
|
40530
|
+
audit,
|
|
40378
40531
|
prepared.configOptions,
|
|
40379
40532
|
execution.executionConfiguration.model,
|
|
40380
40533
|
"model",
|
|
40381
40534
|
agent,
|
|
40382
40535
|
resolved.cwd,
|
|
40383
40536
|
resolved.additionalDirectories,
|
|
40537
|
+
command.commandId,
|
|
40384
40538
|
command.sessionId,
|
|
40385
40539
|
executionSignal
|
|
40386
40540
|
);
|
|
40387
|
-
configOptions = await
|
|
40541
|
+
configOptions = await applySupportedExecutionSelection(
|
|
40388
40542
|
sessions,
|
|
40543
|
+
audit,
|
|
40389
40544
|
configOptions,
|
|
40390
40545
|
execution.executionConfiguration.reasoningEffort,
|
|
40391
40546
|
"thought_level",
|
|
40392
40547
|
agent,
|
|
40393
40548
|
resolved.cwd,
|
|
40394
40549
|
resolved.additionalDirectories,
|
|
40550
|
+
command.commandId,
|
|
40395
40551
|
command.sessionId,
|
|
40396
40552
|
executionSignal
|
|
40397
40553
|
);
|
|
@@ -41703,7 +41859,8 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
41703
41859
|
botSessionConfiguration: true,
|
|
41704
41860
|
capabilities: agent.capabilities,
|
|
41705
41861
|
id: agent.id,
|
|
41706
|
-
label: agent.label
|
|
41862
|
+
label: agent.label,
|
|
41863
|
+
sessionTurnConfiguration: true
|
|
41707
41864
|
}));
|
|
41708
41865
|
const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
|
|
41709
41866
|
let response;
|