@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/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ import { mkdir as mkdir5 } from "node:fs/promises";
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "@moxt-ai/mobius",
|
|
14
|
-
version: "0.0.
|
|
14
|
+
version: "0.0.46",
|
|
15
15
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
16
16
|
type: "module",
|
|
17
17
|
bin: {
|
|
@@ -21138,6 +21138,7 @@ function decodeMessageKind(encoded) {
|
|
|
21138
21138
|
}
|
|
21139
21139
|
function decodeSessionPromptCommand(encoded) {
|
|
21140
21140
|
const value = parseJson2(encoded);
|
|
21141
|
+
const hasSessionConfigurations = Object.hasOwn(value, "sessionConfigurations");
|
|
21141
21142
|
assertExactKeys(value, [
|
|
21142
21143
|
"additionalDirectoryIds",
|
|
21143
21144
|
"agentId",
|
|
@@ -21149,6 +21150,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21149
21150
|
"kind",
|
|
21150
21151
|
"prompt",
|
|
21151
21152
|
"resources",
|
|
21153
|
+
...hasSessionConfigurations ? ["sessionConfigurations"] : [],
|
|
21152
21154
|
"sessionId",
|
|
21153
21155
|
"targetCommandId"
|
|
21154
21156
|
]);
|
|
@@ -21169,6 +21171,10 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21169
21171
|
if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !IDENTIFIER_PATTERN2.test(targetCommandId)) {
|
|
21170
21172
|
throw new ProtocolMessageError("Prompt disposition has an invalid target command");
|
|
21171
21173
|
}
|
|
21174
|
+
const sessionConfigurations = hasSessionConfigurations ? decodeSessionConfigurationSelections(value["sessionConfigurations"]) : [];
|
|
21175
|
+
if (new Set(sessionConfigurations.map((selection) => selection.configId)).size !== sessionConfigurations.length) {
|
|
21176
|
+
throw new ProtocolMessageError("Session configuration identifiers must be unique");
|
|
21177
|
+
}
|
|
21172
21178
|
return {
|
|
21173
21179
|
additionalDirectoryIds: readDirectoryIdentifiers(value, "additionalDirectoryIds", 16),
|
|
21174
21180
|
agentId: readIdentifier(value, "agentId"),
|
|
@@ -21180,6 +21186,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21180
21186
|
kind: SESSION_PROMPT_KIND,
|
|
21181
21187
|
prompt,
|
|
21182
21188
|
resources,
|
|
21189
|
+
...hasSessionConfigurations ? { sessionConfigurations } : {},
|
|
21183
21190
|
sessionId: readIdentifier(value, "sessionId"),
|
|
21184
21191
|
targetCommandId
|
|
21185
21192
|
};
|
|
@@ -24758,7 +24765,8 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
24758
24765
|
botSessionConfiguration: true,
|
|
24759
24766
|
capabilities: agent.capabilities,
|
|
24760
24767
|
id: agent.id,
|
|
24761
|
-
label: agent.label
|
|
24768
|
+
label: agent.label,
|
|
24769
|
+
sessionTurnConfiguration: true
|
|
24762
24770
|
}));
|
|
24763
24771
|
const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
|
|
24764
24772
|
let response;
|
|
@@ -24991,7 +24999,7 @@ import {
|
|
|
24991
24999
|
|
|
24992
25000
|
// src/authorization/local-raster.ts
|
|
24993
25001
|
import { readFile as readFile2, realpath as realpath7, stat as stat6 } from "node:fs/promises";
|
|
24994
|
-
import { basename as basename2, isAbsolute as isAbsolute8, normalize as normalize2
|
|
25002
|
+
import { basename as basename2, isAbsolute as isAbsolute8, normalize as normalize2 } from "node:path";
|
|
24995
25003
|
import { fileURLToPath } from "node:url";
|
|
24996
25004
|
var MAX_LOCAL_RASTER_BYTES = 3e6;
|
|
24997
25005
|
var PNG_SIGNATURE = Uint8Array.of(137, 80, 78, 71);
|
|
@@ -25049,10 +25057,6 @@ function readInlineRaster(data, name = "Image") {
|
|
|
25049
25057
|
}
|
|
25050
25058
|
return new LocalRasterImage(basename2(name) || "Image", mimeType, bytes);
|
|
25051
25059
|
}
|
|
25052
|
-
function isInsideRoot(root, target) {
|
|
25053
|
-
const relation = relative4(root, target);
|
|
25054
|
-
return relation !== ".." && !relation.startsWith(`..${sep4}`) && !isAbsolute8(relation);
|
|
25055
|
-
}
|
|
25056
25060
|
async function resolveCanonicalPath(requested, signal) {
|
|
25057
25061
|
signal.throwIfAborted();
|
|
25058
25062
|
if (!isAbsolute8(requested) || requested.includes("\0") || normalize2(requested) !== requested) {
|
|
@@ -25097,7 +25101,7 @@ function parseLocalImageUri(uri) {
|
|
|
25097
25101
|
}
|
|
25098
25102
|
return trimmed;
|
|
25099
25103
|
}
|
|
25100
|
-
async function
|
|
25104
|
+
async function readLocalRaster(uri, signal) {
|
|
25101
25105
|
signal.throwIfAborted();
|
|
25102
25106
|
const requested = parseLocalImageUri(uri);
|
|
25103
25107
|
if (requested === null) {
|
|
@@ -25112,21 +25116,6 @@ async function readAuthorizedRaster(uri, roots, signal) {
|
|
|
25112
25116
|
if (!targetMetadata.isFile() || targetMetadata.size < 1 || targetMetadata.size > MAX_LOCAL_RASTER_BYTES) {
|
|
25113
25117
|
return null;
|
|
25114
25118
|
}
|
|
25115
|
-
const authorizedRoots = [];
|
|
25116
|
-
for (const root of roots) {
|
|
25117
|
-
const directory = await resolveCanonicalPath(root, signal);
|
|
25118
|
-
if (directory === null) {
|
|
25119
|
-
continue;
|
|
25120
|
-
}
|
|
25121
|
-
const metadata = await stat6(directory);
|
|
25122
|
-
signal.throwIfAborted();
|
|
25123
|
-
if (metadata.isDirectory()) {
|
|
25124
|
-
authorizedRoots.push(directory);
|
|
25125
|
-
}
|
|
25126
|
-
}
|
|
25127
|
-
if (!authorizedRoots.some((root) => isInsideRoot(root, target))) {
|
|
25128
|
-
return null;
|
|
25129
|
-
}
|
|
25130
25119
|
const bytes = new Uint8Array(await readFile2(target));
|
|
25131
25120
|
signal.throwIfAborted();
|
|
25132
25121
|
if (bytes.byteLength < 1 || bytes.byteLength > MAX_LOCAL_RASTER_BYTES) {
|
|
@@ -25225,7 +25214,7 @@ var unmeasuredOperationMetrics = Object.freeze({
|
|
|
25225
25214
|
|
|
25226
25215
|
// src/native-sessions/history-images.ts
|
|
25227
25216
|
var IMAGE_MARKER = /\[@image\]\(([^)\r\n]*)(?:\)|$)/g;
|
|
25228
|
-
async function embedLocalHistoryImages(history,
|
|
25217
|
+
async function embedLocalHistoryImages(history, signal) {
|
|
25229
25218
|
if (history.status !== "available") {
|
|
25230
25219
|
return history;
|
|
25231
25220
|
}
|
|
@@ -25233,7 +25222,7 @@ async function embedLocalHistoryImages(history, roots, signal) {
|
|
|
25233
25222
|
let imageCharacters = 0;
|
|
25234
25223
|
for (const message of history.messages) {
|
|
25235
25224
|
signal.throwIfAborted();
|
|
25236
|
-
const resolved = await resolveMessageImages(message,
|
|
25225
|
+
const resolved = await resolveMessageImages(message, imageCharacters, signal);
|
|
25237
25226
|
imageCharacters += (resolved.images ?? []).reduce((size, image) => size + image.data.length, 0);
|
|
25238
25227
|
messages.push(resolved);
|
|
25239
25228
|
}
|
|
@@ -25242,7 +25231,7 @@ async function embedLocalHistoryImages(history, roots, signal) {
|
|
|
25242
25231
|
messages
|
|
25243
25232
|
};
|
|
25244
25233
|
}
|
|
25245
|
-
async function resolveMessageImages(message,
|
|
25234
|
+
async function resolveMessageImages(message, usedCharacters, signal) {
|
|
25246
25235
|
const images = [...message.images ?? []];
|
|
25247
25236
|
let imageCharacters = images.reduce((size, image) => size + image.data.length, 0);
|
|
25248
25237
|
const text3 = await replaceImageMarkers(message.text, async (uri) => {
|
|
@@ -25258,7 +25247,7 @@ async function resolveMessageImages(message, roots, usedCharacters, signal) {
|
|
|
25258
25247
|
imageCharacters += embedded.data.length;
|
|
25259
25248
|
return "";
|
|
25260
25249
|
}
|
|
25261
|
-
const local = await
|
|
25250
|
+
const local = await readLocalRaster(uri, signal);
|
|
25262
25251
|
if (local === null) {
|
|
25263
25252
|
return "[Image unavailable]";
|
|
25264
25253
|
}
|
|
@@ -32990,16 +32979,24 @@ function parseMarkdownImages(markdown) {
|
|
|
32990
32979
|
});
|
|
32991
32980
|
return images.sort((left, right) => left.start - right.start);
|
|
32992
32981
|
}
|
|
32993
|
-
async function
|
|
32982
|
+
async function emitMarkdownChunksWithLocalImages(options) {
|
|
32983
|
+
const markdown = options.chunks.join("");
|
|
32984
|
+
const images = parseMarkdownImages(markdown);
|
|
32985
|
+
if (images.length === 0) {
|
|
32986
|
+
for (const chunk of options.chunks) {
|
|
32987
|
+
await options.onText(chunk);
|
|
32988
|
+
}
|
|
32989
|
+
return;
|
|
32990
|
+
}
|
|
32994
32991
|
let cursor = 0;
|
|
32995
|
-
for (const image of
|
|
32992
|
+
for (const image of images) {
|
|
32996
32993
|
if (image.start < cursor) {
|
|
32997
32994
|
continue;
|
|
32998
32995
|
}
|
|
32999
32996
|
if (image.start > cursor) {
|
|
33000
|
-
await options.onText(
|
|
32997
|
+
await options.onText(markdown.slice(cursor, image.start));
|
|
33001
32998
|
}
|
|
33002
|
-
const raster = await
|
|
32999
|
+
const raster = await readLocalRaster(image.uri, options.signal);
|
|
33003
33000
|
if (raster === null) {
|
|
33004
33001
|
await options.onText("[Image unavailable]");
|
|
33005
33002
|
} else {
|
|
@@ -33007,8 +33004,8 @@ async function emitMarkdownWithLocalImages(options) {
|
|
|
33007
33004
|
}
|
|
33008
33005
|
cursor = image.end;
|
|
33009
33006
|
}
|
|
33010
|
-
if (cursor <
|
|
33011
|
-
await options.onText(
|
|
33007
|
+
if (cursor < markdown.length) {
|
|
33008
|
+
await options.onText(markdown.slice(cursor));
|
|
33012
33009
|
}
|
|
33013
33010
|
}
|
|
33014
33011
|
|
|
@@ -34350,6 +34347,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
34350
34347
|
#preSessionUpdateBytes = 0;
|
|
34351
34348
|
#agentName = "";
|
|
34352
34349
|
#agentVersion = "";
|
|
34350
|
+
#bufferedAgentText = null;
|
|
34353
34351
|
#capabilities = {
|
|
34354
34352
|
additionalDirectories: false,
|
|
34355
34353
|
audioPrompt: false,
|
|
@@ -34523,26 +34521,37 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
34523
34521
|
);
|
|
34524
34522
|
await this.#updateTail;
|
|
34525
34523
|
signal.throwIfAborted();
|
|
34526
|
-
return await embedLocalHistoryImages(
|
|
34527
|
-
history.snapshot(),
|
|
34528
|
-
[this.#cwd, ...this.#additionalDirectories],
|
|
34529
|
-
signal
|
|
34530
|
-
);
|
|
34524
|
+
return await embedLocalHistoryImages(history.snapshot(), signal);
|
|
34531
34525
|
} finally {
|
|
34532
34526
|
this.#replay = { kind: "idle" };
|
|
34533
34527
|
}
|
|
34534
34528
|
};
|
|
34535
|
-
|
|
34536
|
-
emitAgentText = async (text3, messageId) => {
|
|
34529
|
+
emitAgentMessage = async (chunks, messageId) => {
|
|
34537
34530
|
const signal = AbortSignal.timeout(2e4);
|
|
34538
|
-
await
|
|
34539
|
-
|
|
34531
|
+
await emitMarkdownChunksWithLocalImages({
|
|
34532
|
+
chunks,
|
|
34540
34533
|
onImage: async (image) => await this.emitRaster(image, messageId, signal),
|
|
34541
34534
|
onText: async (content3) => await this.#turn.onText(content3, messageId),
|
|
34542
|
-
roots: this.imageRoots(),
|
|
34543
34535
|
signal
|
|
34544
34536
|
});
|
|
34545
34537
|
};
|
|
34538
|
+
bufferAgentText = async (text3, messageId) => {
|
|
34539
|
+
if (this.#bufferedAgentText !== null && this.#bufferedAgentText.messageId !== messageId) {
|
|
34540
|
+
await this.emitAgentMessage(this.#bufferedAgentText.chunks, this.#bufferedAgentText.messageId);
|
|
34541
|
+
this.#bufferedAgentText = null;
|
|
34542
|
+
}
|
|
34543
|
+
this.#bufferedAgentText = {
|
|
34544
|
+
chunks: [...this.#bufferedAgentText?.chunks ?? [], text3],
|
|
34545
|
+
messageId
|
|
34546
|
+
};
|
|
34547
|
+
};
|
|
34548
|
+
flushAgentText = async () => {
|
|
34549
|
+
const buffered = this.#bufferedAgentText;
|
|
34550
|
+
this.#bufferedAgentText = null;
|
|
34551
|
+
if (buffered !== null) {
|
|
34552
|
+
await this.emitAgentMessage(buffered.chunks, buffered.messageId);
|
|
34553
|
+
}
|
|
34554
|
+
};
|
|
34546
34555
|
prepareAgentContent = async (content3) => {
|
|
34547
34556
|
if (content3.type === "image" && content3.data.length > 0) {
|
|
34548
34557
|
const raster = readInlineRaster(content3.data, content3.name);
|
|
@@ -34552,7 +34561,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
34552
34561
|
}
|
|
34553
34562
|
if (content3.type === "image" && content3.data.length === 0 && content3.uri.length > 0) {
|
|
34554
34563
|
const signal = AbortSignal.timeout(2e4);
|
|
34555
|
-
const raster = await
|
|
34564
|
+
const raster = await readLocalRaster(content3.uri, signal);
|
|
34556
34565
|
if (raster !== null) {
|
|
34557
34566
|
return await this.importRaster(raster, signal);
|
|
34558
34567
|
}
|
|
@@ -35022,6 +35031,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
35022
35031
|
options.signal
|
|
35023
35032
|
);
|
|
35024
35033
|
await this.#updateTail;
|
|
35034
|
+
await this.flushAgentText();
|
|
35025
35035
|
await running.activities.finish();
|
|
35026
35036
|
let result;
|
|
35027
35037
|
try {
|
|
@@ -35053,6 +35063,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
35053
35063
|
cause: error62
|
|
35054
35064
|
});
|
|
35055
35065
|
} finally {
|
|
35066
|
+
this.#bufferedAgentText = null;
|
|
35056
35067
|
this.#turn = new IdleAcpTurn();
|
|
35057
35068
|
}
|
|
35058
35069
|
};
|
|
@@ -35344,10 +35355,11 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
35344
35355
|
);
|
|
35345
35356
|
} else {
|
|
35346
35357
|
await this.#turn.activities.finishNarrative();
|
|
35347
|
-
await this.
|
|
35358
|
+
await this.bufferAgentText(update.content.text, truncate3(update.messageId ?? "", 255));
|
|
35348
35359
|
}
|
|
35349
35360
|
} else {
|
|
35350
35361
|
await this.#turn.activities.finishNarrative();
|
|
35362
|
+
await this.flushAgentText();
|
|
35351
35363
|
await this.emitAgentContent(
|
|
35352
35364
|
normalizeContentBlock(update.content),
|
|
35353
35365
|
truncate3(update.messageId ?? "", 255)
|
|
@@ -36662,7 +36674,8 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
36662
36674
|
botSessionConfiguration: true,
|
|
36663
36675
|
capabilities: agent.capabilities,
|
|
36664
36676
|
id: agent.id,
|
|
36665
|
-
label: agent.label
|
|
36677
|
+
label: agent.label,
|
|
36678
|
+
sessionTurnConfiguration: true
|
|
36666
36679
|
})),
|
|
36667
36680
|
installableAgents: catalog.installableAgents
|
|
36668
36681
|
}),
|
|
@@ -37388,13 +37401,6 @@ var UploadedRuntimeArtifact = class {
|
|
|
37388
37401
|
this.sha256 = sha256;
|
|
37389
37402
|
}
|
|
37390
37403
|
};
|
|
37391
|
-
function daemonToken(config2) {
|
|
37392
|
-
const token = config2.relayUrl.searchParams.get("token");
|
|
37393
|
-
if (token === null || token.length < 32) {
|
|
37394
|
-
throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay daemon token is missing");
|
|
37395
|
-
}
|
|
37396
|
-
return token;
|
|
37397
|
-
}
|
|
37398
37404
|
function channelOrigin(config2) {
|
|
37399
37405
|
const url2 = new URL(config2.relayUrl);
|
|
37400
37406
|
url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
|
|
@@ -37439,24 +37445,23 @@ async function readAuthorization(response) {
|
|
|
37439
37445
|
translateSdkError(cause);
|
|
37440
37446
|
}
|
|
37441
37447
|
}
|
|
37442
|
-
function sessionArtifactUrl(origin, sessionId, resourcePath
|
|
37443
|
-
|
|
37444
|
-
url2.searchParams.set("token", token);
|
|
37445
|
-
return url2;
|
|
37448
|
+
function sessionArtifactUrl(origin, sessionId, resourcePath) {
|
|
37449
|
+
return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
|
|
37446
37450
|
}
|
|
37447
|
-
async function postLease(url2, request, signal) {
|
|
37451
|
+
async function postLease(url2, headers, request, signal) {
|
|
37448
37452
|
return await fetch4(url2, {
|
|
37449
37453
|
dispatcher: environmentProxyDispatcher,
|
|
37450
|
-
headers: { "content-type": "application/json" },
|
|
37454
|
+
headers: { ...headers, "content-type": "application/json" },
|
|
37451
37455
|
method: "POST",
|
|
37452
37456
|
body: JSON.stringify(request),
|
|
37453
37457
|
signal
|
|
37454
37458
|
});
|
|
37455
37459
|
}
|
|
37456
|
-
async function putContent(url2, authorization, bytes, signal) {
|
|
37460
|
+
async function putContent(url2, headers, authorization, bytes, signal) {
|
|
37457
37461
|
return await fetch4(url2, {
|
|
37458
37462
|
dispatcher: environmentProxyDispatcher,
|
|
37459
37463
|
headers: {
|
|
37464
|
+
...headers,
|
|
37460
37465
|
"content-type": authorization.mediaType,
|
|
37461
37466
|
"x-mobius-upload-token": authorization.uploadToken
|
|
37462
37467
|
},
|
|
@@ -37481,11 +37486,12 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
37481
37486
|
const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
|
|
37482
37487
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37483
37488
|
const origin = channelOrigin(config2);
|
|
37484
|
-
const
|
|
37489
|
+
const headers = runtimeAuthorization(config2.relayUrl);
|
|
37485
37490
|
let created;
|
|
37486
37491
|
try {
|
|
37487
37492
|
created = await postLease(
|
|
37488
|
-
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"
|
|
37493
|
+
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
|
|
37494
|
+
headers,
|
|
37489
37495
|
request,
|
|
37490
37496
|
requestSignal
|
|
37491
37497
|
);
|
|
@@ -37505,12 +37511,8 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
37505
37511
|
let uploaded;
|
|
37506
37512
|
try {
|
|
37507
37513
|
uploaded = await putContent(
|
|
37508
|
-
sessionArtifactUrl(
|
|
37509
|
-
|
|
37510
|
-
sessionId,
|
|
37511
|
-
`artifacts/${encodeURIComponent(authorization.artifactId)}/content`,
|
|
37512
|
-
token
|
|
37513
|
-
),
|
|
37514
|
+
sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
|
|
37515
|
+
headers,
|
|
37514
37516
|
authorization,
|
|
37515
37517
|
artifact.bytes,
|
|
37516
37518
|
requestSignal
|
|
@@ -37553,7 +37555,7 @@ var LocalAuthorizationError = class extends Error {
|
|
|
37553
37555
|
// src/authorization/workspace-directory.ts
|
|
37554
37556
|
import { readdir as readdir2, realpath as realpath8, stat as stat7 } from "node:fs/promises";
|
|
37555
37557
|
import { homedir as homedir2 } from "node:os";
|
|
37556
|
-
import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute9, join as join16, normalize as normalize3, relative as
|
|
37558
|
+
import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute9, join as join16, normalize as normalize3, relative as relative4 } from "node:path";
|
|
37557
37559
|
var WorkspaceDirectoryListing = class {
|
|
37558
37560
|
directoryId;
|
|
37559
37561
|
directoryLabel;
|
|
@@ -37636,7 +37638,7 @@ var WorkspaceDirectoryService = class {
|
|
|
37636
37638
|
}
|
|
37637
37639
|
};
|
|
37638
37640
|
label = (path2) => {
|
|
37639
|
-
const suffix =
|
|
37641
|
+
const suffix = relative4(homedir2(), path2);
|
|
37640
37642
|
return suffix === "" ? "~" : !isAbsolute9(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
|
|
37641
37643
|
};
|
|
37642
37644
|
identify = async (bindingId, requestedPath, signal) => {
|
|
@@ -37964,7 +37966,7 @@ function relayEndpoint(relayUrl, context, target) {
|
|
|
37964
37966
|
endpoint.pathname = `${MOBIUS_API_PREFIX}/v1/bot-executions/${execution}/delivery-targets/${encodeURIComponent(deliveryTargetId)}/messages`;
|
|
37965
37967
|
return endpoint;
|
|
37966
37968
|
}
|
|
37967
|
-
function
|
|
37969
|
+
function daemonToken(relayUrl) {
|
|
37968
37970
|
const token = relayUrl.searchParams.get("token") ?? "";
|
|
37969
37971
|
if (!/^[a-zA-Z0-9_-]{32,256}$/.test(token)) {
|
|
37970
37972
|
throw new LocalBotAuthorizationError("bot_service_unavailable", "The Runtime credential is unavailable");
|
|
@@ -38119,7 +38121,7 @@ var BotOutboundIpcServer = class {
|
|
|
38119
38121
|
response = await fetch5(relayEndpoint(this.#relayUrl, context, request.target), {
|
|
38120
38122
|
body: JSON.stringify({ idempotencyKey: request.idempotencyKey, text: request.text }),
|
|
38121
38123
|
headers: {
|
|
38122
|
-
authorization: `Bearer ${
|
|
38124
|
+
authorization: `Bearer ${daemonToken(this.#relayUrl)}`,
|
|
38123
38125
|
"content-type": "application/json",
|
|
38124
38126
|
"x-mobius-bot-execution-capability": context.command.executionCapabilitySecret
|
|
38125
38127
|
},
|
|
@@ -38374,7 +38376,7 @@ async function readCodexHistory(agent, cwd, nativeSessionId, signal) {
|
|
|
38374
38376
|
const snapshot = await response.promise;
|
|
38375
38377
|
return {
|
|
38376
38378
|
...snapshot,
|
|
38377
|
-
history: await embedLocalHistoryImages(snapshot.history,
|
|
38379
|
+
history: await embedLocalHistoryImages(snapshot.history, signal)
|
|
38378
38380
|
};
|
|
38379
38381
|
} finally {
|
|
38380
38382
|
clearTimeout(timeout);
|
|
@@ -39971,17 +39973,7 @@ var DaemonAcpObserver = class {
|
|
|
39971
39973
|
this.#config = config2;
|
|
39972
39974
|
this.#record = record4;
|
|
39973
39975
|
}
|
|
39974
|
-
importLocalArtifact = async (sessionId, artifact, signal) =>
|
|
39975
|
-
try {
|
|
39976
|
-
return (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
39977
|
-
} catch (cause) {
|
|
39978
|
-
signal.throwIfAborted();
|
|
39979
|
-
if (cause instanceof Error && cause.name === "AbortError") {
|
|
39980
|
-
throw cause;
|
|
39981
|
-
}
|
|
39982
|
-
return "";
|
|
39983
|
-
}
|
|
39984
|
-
};
|
|
39976
|
+
importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
39985
39977
|
onCommands = (event) => {
|
|
39986
39978
|
this.#record(event.sessionId, encodeSessionCommandsUpdatedEvent(event));
|
|
39987
39979
|
return Promise.resolve();
|
|
@@ -40754,6 +40746,36 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40754
40746
|
signal
|
|
40755
40747
|
);
|
|
40756
40748
|
const agent = config2.catalog.find(command.agentId);
|
|
40749
|
+
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40750
|
+
throw new AcpExecutionError(
|
|
40751
|
+
"The queued prompt target is unavailable",
|
|
40752
|
+
{},
|
|
40753
|
+
"prompt_queue_target_unavailable"
|
|
40754
|
+
);
|
|
40755
|
+
}
|
|
40756
|
+
if (command.sessionConfigurations !== void 0) {
|
|
40757
|
+
const prepared = await sessions.prepareExecutionSession({
|
|
40758
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
40759
|
+
agent,
|
|
40760
|
+
cwd: resolved.cwd,
|
|
40761
|
+
sessionId: command.sessionId,
|
|
40762
|
+
signal
|
|
40763
|
+
});
|
|
40764
|
+
if (command.disposition === SessionPromptDisposition.Steer) {
|
|
40765
|
+
assertCompleteSessionConfiguration(prepared.configOptions, command.sessionConfigurations);
|
|
40766
|
+
} else {
|
|
40767
|
+
await applyCompleteSessionConfiguration(
|
|
40768
|
+
sessions,
|
|
40769
|
+
prepared.configOptions,
|
|
40770
|
+
command.sessionConfigurations,
|
|
40771
|
+
agent,
|
|
40772
|
+
resolved.cwd,
|
|
40773
|
+
resolved.additionalDirectories,
|
|
40774
|
+
command.sessionId,
|
|
40775
|
+
signal
|
|
40776
|
+
);
|
|
40777
|
+
}
|
|
40778
|
+
}
|
|
40757
40779
|
audit.record({
|
|
40758
40780
|
commandId: command.commandId,
|
|
40759
40781
|
event: "session_authorized",
|
|
@@ -40788,13 +40810,6 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40788
40810
|
});
|
|
40789
40811
|
stopReason = "steered";
|
|
40790
40812
|
} else {
|
|
40791
|
-
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40792
|
-
throw new AcpExecutionError(
|
|
40793
|
-
"The queued prompt target is unavailable",
|
|
40794
|
-
{},
|
|
40795
|
-
"prompt_queue_target_unavailable"
|
|
40796
|
-
);
|
|
40797
|
-
}
|
|
40798
40813
|
const result = await sessions.runPrompt({
|
|
40799
40814
|
additionalDirectories: resolved.additionalDirectories,
|
|
40800
40815
|
agent,
|
|
@@ -40861,6 +40876,113 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40861
40876
|
console.error("Mobius daemon command failed", error62);
|
|
40862
40877
|
}
|
|
40863
40878
|
}
|
|
40879
|
+
function invalidSessionConfiguration(message) {
|
|
40880
|
+
return new AcpExecutionError(message, {}, "invalid_session_configuration");
|
|
40881
|
+
}
|
|
40882
|
+
function validateSessionConfigurationSelection(option2, selection) {
|
|
40883
|
+
if (option2.type !== selection.valueType) {
|
|
40884
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} changed type`);
|
|
40885
|
+
}
|
|
40886
|
+
if (option2.type === "boolean") {
|
|
40887
|
+
if (selection.value.length > 0) {
|
|
40888
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40889
|
+
}
|
|
40890
|
+
return;
|
|
40891
|
+
}
|
|
40892
|
+
if (selection.booleanValue) {
|
|
40893
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40894
|
+
}
|
|
40895
|
+
if (!option2.values.some((value) => value.value === selection.value)) {
|
|
40896
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an unavailable value`);
|
|
40897
|
+
}
|
|
40898
|
+
}
|
|
40899
|
+
function assertSessionConfigurationSchema(options, selections) {
|
|
40900
|
+
if (options.length !== selections.length) {
|
|
40901
|
+
throw invalidSessionConfiguration("The Turn configuration does not match the Agent settings schema");
|
|
40902
|
+
}
|
|
40903
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40904
|
+
if (selectionsById.size !== selections.length) {
|
|
40905
|
+
throw invalidSessionConfiguration("The Turn configuration contains duplicate Agent settings");
|
|
40906
|
+
}
|
|
40907
|
+
for (const option2 of options) {
|
|
40908
|
+
const selection = selectionsById.get(option2.id);
|
|
40909
|
+
if (selection === void 0 || selection.valueType !== option2.type || option2.type === "boolean" && selection.value.length > 0 || option2.type === "select" && selection.booleanValue) {
|
|
40910
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option2.id}`);
|
|
40911
|
+
}
|
|
40912
|
+
}
|
|
40913
|
+
}
|
|
40914
|
+
function sessionConfigurationMatches(option2, selection) {
|
|
40915
|
+
validateSessionConfigurationSelection(option2, selection);
|
|
40916
|
+
return option2.type === "boolean" ? option2.booleanValue === selection.booleanValue : option2.currentValue === selection.value;
|
|
40917
|
+
}
|
|
40918
|
+
function sessionConfigurationPriority(selection, options) {
|
|
40919
|
+
if (selection.configId === "permission_mode") {
|
|
40920
|
+
return 0;
|
|
40921
|
+
}
|
|
40922
|
+
const option2 = options.find((candidate) => candidate.id === selection.configId);
|
|
40923
|
+
if (selection.configId === "model" || option2?.category === "model") {
|
|
40924
|
+
return 1;
|
|
40925
|
+
}
|
|
40926
|
+
if (selection.configId === "reasoning_effort" || option2?.category === "thought_level") {
|
|
40927
|
+
return 2;
|
|
40928
|
+
}
|
|
40929
|
+
if (option2?.category === "model_config") {
|
|
40930
|
+
return 3;
|
|
40931
|
+
}
|
|
40932
|
+
return 4;
|
|
40933
|
+
}
|
|
40934
|
+
function assertCompleteSessionConfiguration(options, selections) {
|
|
40935
|
+
assertSessionConfigurationSchema(options, selections);
|
|
40936
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40937
|
+
for (const option2 of options) {
|
|
40938
|
+
const selection = selectionsById.get(option2.id);
|
|
40939
|
+
if (selection === void 0 || !sessionConfigurationMatches(option2, selection)) {
|
|
40940
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option2.id}`);
|
|
40941
|
+
}
|
|
40942
|
+
}
|
|
40943
|
+
}
|
|
40944
|
+
async function applySessionConfigurationSelection(sessions, options, selection, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40945
|
+
const option2 = options.find((candidate) => candidate.id === selection.configId);
|
|
40946
|
+
if (option2 === void 0) {
|
|
40947
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} is unavailable`);
|
|
40948
|
+
}
|
|
40949
|
+
if (sessionConfigurationMatches(option2, selection)) {
|
|
40950
|
+
return options;
|
|
40951
|
+
}
|
|
40952
|
+
return await sessions.configureSession({
|
|
40953
|
+
additionalDirectories,
|
|
40954
|
+
agent,
|
|
40955
|
+
booleanValue: selection.booleanValue,
|
|
40956
|
+
configId: selection.configId,
|
|
40957
|
+
cwd,
|
|
40958
|
+
requestId: `cfg_${randomUUID5()}`,
|
|
40959
|
+
sessionId,
|
|
40960
|
+
signal,
|
|
40961
|
+
value: selection.value,
|
|
40962
|
+
valueType: selection.valueType
|
|
40963
|
+
});
|
|
40964
|
+
}
|
|
40965
|
+
async function applyCompleteSessionConfiguration(sessions, initialOptions, selections, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40966
|
+
assertSessionConfigurationSchema(initialOptions, selections);
|
|
40967
|
+
let options = initialOptions;
|
|
40968
|
+
const orderedSelections = selections.toSorted((left, right) => {
|
|
40969
|
+
const priority = sessionConfigurationPriority(left, initialOptions) - sessionConfigurationPriority(right, initialOptions);
|
|
40970
|
+
return priority === 0 ? left.configId.localeCompare(right.configId) : priority;
|
|
40971
|
+
});
|
|
40972
|
+
for (const selection of orderedSelections) {
|
|
40973
|
+
options = await applySessionConfigurationSelection(
|
|
40974
|
+
sessions,
|
|
40975
|
+
options,
|
|
40976
|
+
selection,
|
|
40977
|
+
agent,
|
|
40978
|
+
cwd,
|
|
40979
|
+
additionalDirectories,
|
|
40980
|
+
sessionId,
|
|
40981
|
+
signal
|
|
40982
|
+
);
|
|
40983
|
+
}
|
|
40984
|
+
assertCompleteSessionConfiguration(options, selections);
|
|
40985
|
+
}
|
|
40864
40986
|
function botExecutionAgent(agent, contextHandle, socketPath) {
|
|
40865
40987
|
return new LocalAgentDefinition(
|
|
40866
40988
|
agent.id,
|
|
@@ -40893,24 +41015,55 @@ function assertPreparedPermission(configOptions, permissionMode) {
|
|
|
40893
41015
|
);
|
|
40894
41016
|
}
|
|
40895
41017
|
}
|
|
40896
|
-
|
|
41018
|
+
function warnIgnoredExecutionSetting(audit, commandId, sessionId, agentId, selection, category, reason) {
|
|
41019
|
+
const details = {
|
|
41020
|
+
agentId,
|
|
41021
|
+
category,
|
|
41022
|
+
configId: selection.configId,
|
|
41023
|
+
reason,
|
|
41024
|
+
requestedValue: selection.value
|
|
41025
|
+
};
|
|
41026
|
+
const event = "bot_execution_setting_ignored";
|
|
41027
|
+
audit.record({ commandId, details, event, sessionId });
|
|
41028
|
+
process.stderr.write(`Mobius daemon warning ${JSON.stringify({ commandId, event, sessionId, ...details })}
|
|
41029
|
+
`);
|
|
41030
|
+
}
|
|
41031
|
+
async function applySupportedExecutionSelection(sessions, audit, configOptions, selection, category, agent, cwd, additionalDirectories, commandId, sessionId, signal) {
|
|
41032
|
+
if (selection.value === AGENT_DEFAULT_EXECUTION_SETTING) {
|
|
41033
|
+
return configOptions;
|
|
41034
|
+
}
|
|
40897
41035
|
const option2 = configOptions.find((candidate) => candidate.id === selection.configId);
|
|
40898
|
-
if (option2 === void 0
|
|
40899
|
-
|
|
40900
|
-
|
|
40901
|
-
|
|
40902
|
-
|
|
41036
|
+
if (option2 === void 0) {
|
|
41037
|
+
warnIgnoredExecutionSetting(audit, commandId, sessionId, agent.id, selection, category, "setting_unavailable");
|
|
41038
|
+
return configOptions;
|
|
41039
|
+
}
|
|
41040
|
+
if (option2.type !== "select" || option2.category !== category) {
|
|
41041
|
+
warnIgnoredExecutionSetting(
|
|
41042
|
+
audit,
|
|
41043
|
+
commandId,
|
|
41044
|
+
sessionId,
|
|
41045
|
+
agent.id,
|
|
41046
|
+
selection,
|
|
41047
|
+
category,
|
|
41048
|
+
"setting_schema_mismatch"
|
|
40903
41049
|
);
|
|
41050
|
+
return configOptions;
|
|
40904
41051
|
}
|
|
40905
|
-
if (selection.
|
|
41052
|
+
if (selection.valueType !== "select" || selection.booleanValue) {
|
|
41053
|
+
warnIgnoredExecutionSetting(
|
|
41054
|
+
audit,
|
|
41055
|
+
commandId,
|
|
41056
|
+
sessionId,
|
|
41057
|
+
agent.id,
|
|
41058
|
+
selection,
|
|
41059
|
+
category,
|
|
41060
|
+
"selection_schema_mismatch"
|
|
41061
|
+
);
|
|
40906
41062
|
return configOptions;
|
|
40907
41063
|
}
|
|
40908
41064
|
if (!option2.values.some((value) => value.value === selection.value)) {
|
|
40909
|
-
|
|
40910
|
-
|
|
40911
|
-
{},
|
|
40912
|
-
"invalid_session_configuration"
|
|
40913
|
-
);
|
|
41065
|
+
warnIgnoredExecutionSetting(audit, commandId, sessionId, agent.id, selection, category, "value_unavailable");
|
|
41066
|
+
return configOptions;
|
|
40914
41067
|
}
|
|
40915
41068
|
if (option2.currentValue === selection.value) {
|
|
40916
41069
|
return configOptions;
|
|
@@ -41009,25 +41162,29 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41009
41162
|
signal: executionSignal
|
|
41010
41163
|
});
|
|
41011
41164
|
assertPreparedPermission(prepared.configOptions, execution.executionConfiguration.permissionMode);
|
|
41012
|
-
let configOptions = await
|
|
41165
|
+
let configOptions = await applySupportedExecutionSelection(
|
|
41013
41166
|
sessions,
|
|
41167
|
+
audit,
|
|
41014
41168
|
prepared.configOptions,
|
|
41015
41169
|
execution.executionConfiguration.model,
|
|
41016
41170
|
"model",
|
|
41017
41171
|
agent,
|
|
41018
41172
|
resolved.cwd,
|
|
41019
41173
|
resolved.additionalDirectories,
|
|
41174
|
+
command.commandId,
|
|
41020
41175
|
command.sessionId,
|
|
41021
41176
|
executionSignal
|
|
41022
41177
|
);
|
|
41023
|
-
configOptions = await
|
|
41178
|
+
configOptions = await applySupportedExecutionSelection(
|
|
41024
41179
|
sessions,
|
|
41180
|
+
audit,
|
|
41025
41181
|
configOptions,
|
|
41026
41182
|
execution.executionConfiguration.reasoningEffort,
|
|
41027
41183
|
"thought_level",
|
|
41028
41184
|
agent,
|
|
41029
41185
|
resolved.cwd,
|
|
41030
41186
|
resolved.additionalDirectories,
|
|
41187
|
+
command.commandId,
|
|
41031
41188
|
command.sessionId,
|
|
41032
41189
|
executionSignal
|
|
41033
41190
|
);
|