@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/index.js
CHANGED
|
@@ -20514,6 +20514,7 @@ function decodeMessageKind(encoded) {
|
|
|
20514
20514
|
}
|
|
20515
20515
|
function decodeSessionPromptCommand(encoded) {
|
|
20516
20516
|
const value = parseJson2(encoded);
|
|
20517
|
+
const hasSessionConfigurations = Object.hasOwn(value, "sessionConfigurations");
|
|
20517
20518
|
assertExactKeys(value, [
|
|
20518
20519
|
"additionalDirectoryIds",
|
|
20519
20520
|
"agentId",
|
|
@@ -20525,6 +20526,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
20525
20526
|
"kind",
|
|
20526
20527
|
"prompt",
|
|
20527
20528
|
"resources",
|
|
20529
|
+
...hasSessionConfigurations ? ["sessionConfigurations"] : [],
|
|
20528
20530
|
"sessionId",
|
|
20529
20531
|
"targetCommandId"
|
|
20530
20532
|
]);
|
|
@@ -20545,6 +20547,10 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
20545
20547
|
if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !IDENTIFIER_PATTERN2.test(targetCommandId)) {
|
|
20546
20548
|
throw new ProtocolMessageError("Prompt disposition has an invalid target command");
|
|
20547
20549
|
}
|
|
20550
|
+
const sessionConfigurations = hasSessionConfigurations ? decodeSessionConfigurationSelections(value["sessionConfigurations"]) : [];
|
|
20551
|
+
if (new Set(sessionConfigurations.map((selection) => selection.configId)).size !== sessionConfigurations.length) {
|
|
20552
|
+
throw new ProtocolMessageError("Session configuration identifiers must be unique");
|
|
20553
|
+
}
|
|
20548
20554
|
return {
|
|
20549
20555
|
additionalDirectoryIds: readDirectoryIdentifiers(value, "additionalDirectoryIds", 16),
|
|
20550
20556
|
agentId: readIdentifier(value, "agentId"),
|
|
@@ -20556,6 +20562,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
20556
20562
|
kind: SESSION_PROMPT_KIND,
|
|
20557
20563
|
prompt,
|
|
20558
20564
|
resources,
|
|
20565
|
+
...hasSessionConfigurations ? { sessionConfigurations } : {},
|
|
20559
20566
|
sessionId: readIdentifier(value, "sessionId"),
|
|
20560
20567
|
targetCommandId
|
|
20561
20568
|
};
|
|
@@ -22321,7 +22328,7 @@ import {
|
|
|
22321
22328
|
|
|
22322
22329
|
// src/authorization/local-raster.ts
|
|
22323
22330
|
import { readFile as readFile2, realpath as realpath2, stat as stat2 } from "node:fs/promises";
|
|
22324
|
-
import { basename, isAbsolute, normalize
|
|
22331
|
+
import { basename, isAbsolute, normalize } from "node:path";
|
|
22325
22332
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
22326
22333
|
var MAX_LOCAL_RASTER_BYTES = 3e6;
|
|
22327
22334
|
var PNG_SIGNATURE = Uint8Array.of(137, 80, 78, 71);
|
|
@@ -22379,10 +22386,6 @@ function readInlineRaster(data, name = "Image") {
|
|
|
22379
22386
|
}
|
|
22380
22387
|
return new LocalRasterImage(basename(name) || "Image", mimeType, bytes);
|
|
22381
22388
|
}
|
|
22382
|
-
function isInsideRoot(root, target) {
|
|
22383
|
-
const relation = relative(root, target);
|
|
22384
|
-
return relation !== ".." && !relation.startsWith(`..${sep}`) && !isAbsolute(relation);
|
|
22385
|
-
}
|
|
22386
22389
|
async function resolveCanonicalPath(requested, signal) {
|
|
22387
22390
|
signal.throwIfAborted();
|
|
22388
22391
|
if (!isAbsolute(requested) || requested.includes("\0") || normalize(requested) !== requested) {
|
|
@@ -22427,7 +22430,7 @@ function parseLocalImageUri(uri) {
|
|
|
22427
22430
|
}
|
|
22428
22431
|
return trimmed;
|
|
22429
22432
|
}
|
|
22430
|
-
async function
|
|
22433
|
+
async function readLocalRaster(uri, signal) {
|
|
22431
22434
|
signal.throwIfAborted();
|
|
22432
22435
|
const requested = parseLocalImageUri(uri);
|
|
22433
22436
|
if (requested === null) {
|
|
@@ -22442,21 +22445,6 @@ async function readAuthorizedRaster(uri, roots, signal) {
|
|
|
22442
22445
|
if (!targetMetadata.isFile() || targetMetadata.size < 1 || targetMetadata.size > MAX_LOCAL_RASTER_BYTES) {
|
|
22443
22446
|
return null;
|
|
22444
22447
|
}
|
|
22445
|
-
const authorizedRoots = [];
|
|
22446
|
-
for (const root of roots) {
|
|
22447
|
-
const directory = await resolveCanonicalPath(root, signal);
|
|
22448
|
-
if (directory === null) {
|
|
22449
|
-
continue;
|
|
22450
|
-
}
|
|
22451
|
-
const metadata = await stat2(directory);
|
|
22452
|
-
signal.throwIfAborted();
|
|
22453
|
-
if (metadata.isDirectory()) {
|
|
22454
|
-
authorizedRoots.push(directory);
|
|
22455
|
-
}
|
|
22456
|
-
}
|
|
22457
|
-
if (!authorizedRoots.some((root) => isInsideRoot(root, target))) {
|
|
22458
|
-
return null;
|
|
22459
|
-
}
|
|
22460
22448
|
const bytes = new Uint8Array(await readFile2(target));
|
|
22461
22449
|
signal.throwIfAborted();
|
|
22462
22450
|
if (bytes.byteLength < 1 || bytes.byteLength > MAX_LOCAL_RASTER_BYTES) {
|
|
@@ -22555,7 +22543,7 @@ var unmeasuredOperationMetrics = Object.freeze({
|
|
|
22555
22543
|
|
|
22556
22544
|
// src/native-sessions/history-images.ts
|
|
22557
22545
|
var IMAGE_MARKER = /\[@image\]\(([^)\r\n]*)(?:\)|$)/g;
|
|
22558
|
-
async function embedLocalHistoryImages(history,
|
|
22546
|
+
async function embedLocalHistoryImages(history, signal) {
|
|
22559
22547
|
if (history.status !== "available") {
|
|
22560
22548
|
return history;
|
|
22561
22549
|
}
|
|
@@ -22563,7 +22551,7 @@ async function embedLocalHistoryImages(history, roots, signal) {
|
|
|
22563
22551
|
let imageCharacters = 0;
|
|
22564
22552
|
for (const message of history.messages) {
|
|
22565
22553
|
signal.throwIfAborted();
|
|
22566
|
-
const resolved = await resolveMessageImages(message,
|
|
22554
|
+
const resolved = await resolveMessageImages(message, imageCharacters, signal);
|
|
22567
22555
|
imageCharacters += (resolved.images ?? []).reduce((size, image) => size + image.data.length, 0);
|
|
22568
22556
|
messages.push(resolved);
|
|
22569
22557
|
}
|
|
@@ -22572,7 +22560,7 @@ async function embedLocalHistoryImages(history, roots, signal) {
|
|
|
22572
22560
|
messages
|
|
22573
22561
|
};
|
|
22574
22562
|
}
|
|
22575
|
-
async function resolveMessageImages(message,
|
|
22563
|
+
async function resolveMessageImages(message, usedCharacters, signal) {
|
|
22576
22564
|
const images = [...message.images ?? []];
|
|
22577
22565
|
let imageCharacters = images.reduce((size, image) => size + image.data.length, 0);
|
|
22578
22566
|
const text3 = await replaceImageMarkers(message.text, async (uri) => {
|
|
@@ -22588,7 +22576,7 @@ async function resolveMessageImages(message, roots, usedCharacters, signal) {
|
|
|
22588
22576
|
imageCharacters += embedded.data.length;
|
|
22589
22577
|
return "";
|
|
22590
22578
|
}
|
|
22591
|
-
const local = await
|
|
22579
|
+
const local = await readLocalRaster(uri, signal);
|
|
22592
22580
|
if (local === null) {
|
|
22593
22581
|
return "[Image unavailable]";
|
|
22594
22582
|
}
|
|
@@ -30320,16 +30308,24 @@ function parseMarkdownImages(markdown) {
|
|
|
30320
30308
|
});
|
|
30321
30309
|
return images.sort((left, right) => left.start - right.start);
|
|
30322
30310
|
}
|
|
30323
|
-
async function
|
|
30311
|
+
async function emitMarkdownChunksWithLocalImages(options) {
|
|
30312
|
+
const markdown = options.chunks.join("");
|
|
30313
|
+
const images = parseMarkdownImages(markdown);
|
|
30314
|
+
if (images.length === 0) {
|
|
30315
|
+
for (const chunk of options.chunks) {
|
|
30316
|
+
await options.onText(chunk);
|
|
30317
|
+
}
|
|
30318
|
+
return;
|
|
30319
|
+
}
|
|
30324
30320
|
let cursor = 0;
|
|
30325
|
-
for (const image of
|
|
30321
|
+
for (const image of images) {
|
|
30326
30322
|
if (image.start < cursor) {
|
|
30327
30323
|
continue;
|
|
30328
30324
|
}
|
|
30329
30325
|
if (image.start > cursor) {
|
|
30330
|
-
await options.onText(
|
|
30326
|
+
await options.onText(markdown.slice(cursor, image.start));
|
|
30331
30327
|
}
|
|
30332
|
-
const raster = await
|
|
30328
|
+
const raster = await readLocalRaster(image.uri, options.signal);
|
|
30333
30329
|
if (raster === null) {
|
|
30334
30330
|
await options.onText("[Image unavailable]");
|
|
30335
30331
|
} else {
|
|
@@ -30337,8 +30333,8 @@ async function emitMarkdownWithLocalImages(options) {
|
|
|
30337
30333
|
}
|
|
30338
30334
|
cursor = image.end;
|
|
30339
30335
|
}
|
|
30340
|
-
if (cursor <
|
|
30341
|
-
await options.onText(
|
|
30336
|
+
if (cursor < markdown.length) {
|
|
30337
|
+
await options.onText(markdown.slice(cursor));
|
|
30342
30338
|
}
|
|
30343
30339
|
}
|
|
30344
30340
|
|
|
@@ -31680,6 +31676,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31680
31676
|
#preSessionUpdateBytes = 0;
|
|
31681
31677
|
#agentName = "";
|
|
31682
31678
|
#agentVersion = "";
|
|
31679
|
+
#bufferedAgentText = null;
|
|
31683
31680
|
#capabilities = {
|
|
31684
31681
|
additionalDirectories: false,
|
|
31685
31682
|
audioPrompt: false,
|
|
@@ -31853,26 +31850,37 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31853
31850
|
);
|
|
31854
31851
|
await this.#updateTail;
|
|
31855
31852
|
signal.throwIfAborted();
|
|
31856
|
-
return await embedLocalHistoryImages(
|
|
31857
|
-
history.snapshot(),
|
|
31858
|
-
[this.#cwd, ...this.#additionalDirectories],
|
|
31859
|
-
signal
|
|
31860
|
-
);
|
|
31853
|
+
return await embedLocalHistoryImages(history.snapshot(), signal);
|
|
31861
31854
|
} finally {
|
|
31862
31855
|
this.#replay = { kind: "idle" };
|
|
31863
31856
|
}
|
|
31864
31857
|
};
|
|
31865
|
-
|
|
31866
|
-
emitAgentText = async (text3, messageId) => {
|
|
31858
|
+
emitAgentMessage = async (chunks, messageId) => {
|
|
31867
31859
|
const signal = AbortSignal.timeout(2e4);
|
|
31868
|
-
await
|
|
31869
|
-
|
|
31860
|
+
await emitMarkdownChunksWithLocalImages({
|
|
31861
|
+
chunks,
|
|
31870
31862
|
onImage: async (image) => await this.emitRaster(image, messageId, signal),
|
|
31871
31863
|
onText: async (content3) => await this.#turn.onText(content3, messageId),
|
|
31872
|
-
roots: this.imageRoots(),
|
|
31873
31864
|
signal
|
|
31874
31865
|
});
|
|
31875
31866
|
};
|
|
31867
|
+
bufferAgentText = async (text3, messageId) => {
|
|
31868
|
+
if (this.#bufferedAgentText !== null && this.#bufferedAgentText.messageId !== messageId) {
|
|
31869
|
+
await this.emitAgentMessage(this.#bufferedAgentText.chunks, this.#bufferedAgentText.messageId);
|
|
31870
|
+
this.#bufferedAgentText = null;
|
|
31871
|
+
}
|
|
31872
|
+
this.#bufferedAgentText = {
|
|
31873
|
+
chunks: [...this.#bufferedAgentText?.chunks ?? [], text3],
|
|
31874
|
+
messageId
|
|
31875
|
+
};
|
|
31876
|
+
};
|
|
31877
|
+
flushAgentText = async () => {
|
|
31878
|
+
const buffered = this.#bufferedAgentText;
|
|
31879
|
+
this.#bufferedAgentText = null;
|
|
31880
|
+
if (buffered !== null) {
|
|
31881
|
+
await this.emitAgentMessage(buffered.chunks, buffered.messageId);
|
|
31882
|
+
}
|
|
31883
|
+
};
|
|
31876
31884
|
prepareAgentContent = async (content3) => {
|
|
31877
31885
|
if (content3.type === "image" && content3.data.length > 0) {
|
|
31878
31886
|
const raster = readInlineRaster(content3.data, content3.name);
|
|
@@ -31882,7 +31890,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31882
31890
|
}
|
|
31883
31891
|
if (content3.type === "image" && content3.data.length === 0 && content3.uri.length > 0) {
|
|
31884
31892
|
const signal = AbortSignal.timeout(2e4);
|
|
31885
|
-
const raster = await
|
|
31893
|
+
const raster = await readLocalRaster(content3.uri, signal);
|
|
31886
31894
|
if (raster !== null) {
|
|
31887
31895
|
return await this.importRaster(raster, signal);
|
|
31888
31896
|
}
|
|
@@ -32352,6 +32360,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
32352
32360
|
options.signal
|
|
32353
32361
|
);
|
|
32354
32362
|
await this.#updateTail;
|
|
32363
|
+
await this.flushAgentText();
|
|
32355
32364
|
await running.activities.finish();
|
|
32356
32365
|
let result;
|
|
32357
32366
|
try {
|
|
@@ -32383,6 +32392,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
32383
32392
|
cause: error62
|
|
32384
32393
|
});
|
|
32385
32394
|
} finally {
|
|
32395
|
+
this.#bufferedAgentText = null;
|
|
32386
32396
|
this.#turn = new IdleAcpTurn();
|
|
32387
32397
|
}
|
|
32388
32398
|
};
|
|
@@ -32674,10 +32684,11 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
32674
32684
|
);
|
|
32675
32685
|
} else {
|
|
32676
32686
|
await this.#turn.activities.finishNarrative();
|
|
32677
|
-
await this.
|
|
32687
|
+
await this.bufferAgentText(update.content.text, truncate3(update.messageId ?? "", 255));
|
|
32678
32688
|
}
|
|
32679
32689
|
} else {
|
|
32680
32690
|
await this.#turn.activities.finishNarrative();
|
|
32691
|
+
await this.flushAgentText();
|
|
32681
32692
|
await this.emitAgentContent(
|
|
32682
32693
|
normalizeContentBlock(update.content),
|
|
32683
32694
|
truncate3(update.messageId ?? "", 255)
|
|
@@ -34691,7 +34702,7 @@ var LocalAgentInventory = class {
|
|
|
34691
34702
|
|
|
34692
34703
|
// src/agent-installation/managed-npm-package.ts
|
|
34693
34704
|
import { mkdir as mkdir2, mkdtemp, open as open2, realpath as realpath3, rename, rm, stat as stat3 } from "node:fs/promises";
|
|
34694
|
-
import { delimiter, dirname as dirname4, isAbsolute as isAbsolute3, join as join4, relative
|
|
34705
|
+
import { delimiter, dirname as dirname4, isAbsolute as isAbsolute3, join as join4, relative, sep } from "node:path";
|
|
34695
34706
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
34696
34707
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
34697
34708
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -34745,8 +34756,8 @@ function packagePath(root, packageName) {
|
|
|
34745
34756
|
return join4(root, "node_modules", ...packageName.split("/"));
|
|
34746
34757
|
}
|
|
34747
34758
|
function isContainedPath(root, candidate) {
|
|
34748
|
-
const difference =
|
|
34749
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${
|
|
34759
|
+
const difference = relative(root, candidate);
|
|
34760
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep}`) && !isAbsolute3(difference);
|
|
34750
34761
|
}
|
|
34751
34762
|
async function readJsonRecord(path2, maximumBytes) {
|
|
34752
34763
|
try {
|
|
@@ -35372,7 +35383,7 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35372
35383
|
|
|
35373
35384
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
35374
35385
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
35375
|
-
import { isAbsolute as isAbsolute6, join as join8, relative as
|
|
35386
|
+
import { isAbsolute as isAbsolute6, join as join8, relative as relative2, sep as sep2 } from "node:path";
|
|
35376
35387
|
import {
|
|
35377
35388
|
RequestError as RequestError2
|
|
35378
35389
|
} from "@agentclientprotocol/sdk";
|
|
@@ -35437,8 +35448,8 @@ function grokBuildManagedPackage(platform, architecture) {
|
|
|
35437
35448
|
|
|
35438
35449
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
35439
35450
|
function isContainedPath2(root, candidate) {
|
|
35440
|
-
const difference =
|
|
35441
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${
|
|
35451
|
+
const difference = relative2(root, candidate);
|
|
35452
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute6(difference);
|
|
35442
35453
|
}
|
|
35443
35454
|
var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
35444
35455
|
adapterVersion = GROK_BUILD_MANAGED_VERSION;
|
|
@@ -35540,7 +35551,7 @@ import { join as join10 } from "node:path";
|
|
|
35540
35551
|
import { createHash } from "node:crypto";
|
|
35541
35552
|
import { createReadStream } from "node:fs";
|
|
35542
35553
|
import { chmod as chmod2, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5, writeFile } from "node:fs/promises";
|
|
35543
|
-
import { delimiter as delimiter2, dirname as dirname5, isAbsolute as isAbsolute7, join as join9, relative as
|
|
35554
|
+
import { delimiter as delimiter2, dirname as dirname5, isAbsolute as isAbsolute7, join as join9, relative as relative3, sep as sep3 } from "node:path";
|
|
35544
35555
|
|
|
35545
35556
|
// src/agent-installation/verified-download.ts
|
|
35546
35557
|
import { fetch as fetch2 } from "undici";
|
|
@@ -35645,8 +35656,8 @@ function isRecord10(value) {
|
|
|
35645
35656
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
35646
35657
|
}
|
|
35647
35658
|
function isContainedPath3(root, candidate) {
|
|
35648
|
-
const difference =
|
|
35649
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${
|
|
35659
|
+
const difference = relative3(root, candidate);
|
|
35660
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute7(difference);
|
|
35650
35661
|
}
|
|
35651
35662
|
async function hashFile(path2, signal) {
|
|
35652
35663
|
signal.throwIfAborted();
|
|
@@ -36752,7 +36763,8 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
36752
36763
|
botSessionConfiguration: true,
|
|
36753
36764
|
capabilities: agent.capabilities,
|
|
36754
36765
|
id: agent.id,
|
|
36755
|
-
label: agent.label
|
|
36766
|
+
label: agent.label,
|
|
36767
|
+
sessionTurnConfiguration: true
|
|
36756
36768
|
}));
|
|
36757
36769
|
const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
|
|
36758
36770
|
let response;
|
|
@@ -36994,7 +37006,8 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
36994
37006
|
botSessionConfiguration: true,
|
|
36995
37007
|
capabilities: agent.capabilities,
|
|
36996
37008
|
id: agent.id,
|
|
36997
|
-
label: agent.label
|
|
37009
|
+
label: agent.label,
|
|
37010
|
+
sessionTurnConfiguration: true
|
|
36998
37011
|
})),
|
|
36999
37012
|
installableAgents: catalog.installableAgents
|
|
37000
37013
|
}),
|
|
@@ -37720,13 +37733,6 @@ var UploadedRuntimeArtifact = class {
|
|
|
37720
37733
|
this.sha256 = sha256;
|
|
37721
37734
|
}
|
|
37722
37735
|
};
|
|
37723
|
-
function daemonToken2(config2) {
|
|
37724
|
-
const token = config2.relayUrl.searchParams.get("token");
|
|
37725
|
-
if (token === null || token.length < 32) {
|
|
37726
|
-
throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay daemon token is missing");
|
|
37727
|
-
}
|
|
37728
|
-
return token;
|
|
37729
|
-
}
|
|
37730
37736
|
function channelOrigin(config2) {
|
|
37731
37737
|
const url2 = new URL(config2.relayUrl);
|
|
37732
37738
|
url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
|
|
@@ -37771,24 +37777,23 @@ async function readAuthorization(response) {
|
|
|
37771
37777
|
translateSdkError(cause);
|
|
37772
37778
|
}
|
|
37773
37779
|
}
|
|
37774
|
-
function sessionArtifactUrl(origin, sessionId, resourcePath
|
|
37775
|
-
|
|
37776
|
-
url2.searchParams.set("token", token);
|
|
37777
|
-
return url2;
|
|
37780
|
+
function sessionArtifactUrl(origin, sessionId, resourcePath) {
|
|
37781
|
+
return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
|
|
37778
37782
|
}
|
|
37779
|
-
async function postLease(url2, request, signal) {
|
|
37783
|
+
async function postLease(url2, headers, request, signal) {
|
|
37780
37784
|
return await fetch5(url2, {
|
|
37781
37785
|
dispatcher: environmentProxyDispatcher,
|
|
37782
|
-
headers: { "content-type": "application/json" },
|
|
37786
|
+
headers: { ...headers, "content-type": "application/json" },
|
|
37783
37787
|
method: "POST",
|
|
37784
37788
|
body: JSON.stringify(request),
|
|
37785
37789
|
signal
|
|
37786
37790
|
});
|
|
37787
37791
|
}
|
|
37788
|
-
async function putContent(url2, authorization, bytes, signal) {
|
|
37792
|
+
async function putContent(url2, headers, authorization, bytes, signal) {
|
|
37789
37793
|
return await fetch5(url2, {
|
|
37790
37794
|
dispatcher: environmentProxyDispatcher,
|
|
37791
37795
|
headers: {
|
|
37796
|
+
...headers,
|
|
37792
37797
|
"content-type": authorization.mediaType,
|
|
37793
37798
|
"x-mobius-upload-token": authorization.uploadToken
|
|
37794
37799
|
},
|
|
@@ -37813,11 +37818,12 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
37813
37818
|
const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
|
|
37814
37819
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37815
37820
|
const origin = channelOrigin(config2);
|
|
37816
|
-
const
|
|
37821
|
+
const headers = runtimeAuthorization(config2.relayUrl);
|
|
37817
37822
|
let created;
|
|
37818
37823
|
try {
|
|
37819
37824
|
created = await postLease(
|
|
37820
|
-
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"
|
|
37825
|
+
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
|
|
37826
|
+
headers,
|
|
37821
37827
|
request,
|
|
37822
37828
|
requestSignal
|
|
37823
37829
|
);
|
|
@@ -37837,12 +37843,8 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
37837
37843
|
let uploaded;
|
|
37838
37844
|
try {
|
|
37839
37845
|
uploaded = await putContent(
|
|
37840
|
-
sessionArtifactUrl(
|
|
37841
|
-
|
|
37842
|
-
sessionId,
|
|
37843
|
-
`artifacts/${encodeURIComponent(authorization.artifactId)}/content`,
|
|
37844
|
-
token
|
|
37845
|
-
),
|
|
37846
|
+
sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
|
|
37847
|
+
headers,
|
|
37846
37848
|
authorization,
|
|
37847
37849
|
artifact.bytes,
|
|
37848
37850
|
requestSignal
|
|
@@ -37876,7 +37878,7 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
37876
37878
|
// src/authorization/workspace-directory.ts
|
|
37877
37879
|
import { readdir as readdir2, realpath as realpath8, stat as stat7 } from "node:fs/promises";
|
|
37878
37880
|
import { homedir as homedir2 } from "node:os";
|
|
37879
|
-
import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute10, join as join16, normalize as normalize3, relative as
|
|
37881
|
+
import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute10, join as join16, normalize as normalize3, relative as relative4 } from "node:path";
|
|
37880
37882
|
var WorkspaceDirectoryListing = class {
|
|
37881
37883
|
directoryId;
|
|
37882
37884
|
directoryLabel;
|
|
@@ -37959,7 +37961,7 @@ var WorkspaceDirectoryService = class {
|
|
|
37959
37961
|
}
|
|
37960
37962
|
};
|
|
37961
37963
|
label = (path2) => {
|
|
37962
|
-
const suffix =
|
|
37964
|
+
const suffix = relative4(homedir2(), path2);
|
|
37963
37965
|
return suffix === "" ? "~" : !isAbsolute10(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
|
|
37964
37966
|
};
|
|
37965
37967
|
identify = async (bindingId, requestedPath, signal) => {
|
|
@@ -38296,7 +38298,7 @@ async function readCodexHistory(agent, cwd, nativeSessionId, signal) {
|
|
|
38296
38298
|
const snapshot = await response.promise;
|
|
38297
38299
|
return {
|
|
38298
38300
|
...snapshot,
|
|
38299
|
-
history: await embedLocalHistoryImages(snapshot.history,
|
|
38301
|
+
history: await embedLocalHistoryImages(snapshot.history, signal)
|
|
38300
38302
|
};
|
|
38301
38303
|
} finally {
|
|
38302
38304
|
clearTimeout(timeout);
|
|
@@ -39893,17 +39895,7 @@ var DaemonAcpObserver = class {
|
|
|
39893
39895
|
this.#config = config2;
|
|
39894
39896
|
this.#record = record4;
|
|
39895
39897
|
}
|
|
39896
|
-
importLocalArtifact = async (sessionId, artifact, signal) =>
|
|
39897
|
-
try {
|
|
39898
|
-
return (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
39899
|
-
} catch (cause) {
|
|
39900
|
-
signal.throwIfAborted();
|
|
39901
|
-
if (cause instanceof Error && cause.name === "AbortError") {
|
|
39902
|
-
throw cause;
|
|
39903
|
-
}
|
|
39904
|
-
return "";
|
|
39905
|
-
}
|
|
39906
|
-
};
|
|
39898
|
+
importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
39907
39899
|
onCommands = (event) => {
|
|
39908
39900
|
this.#record(event.sessionId, encodeSessionCommandsUpdatedEvent(event));
|
|
39909
39901
|
return Promise.resolve();
|
|
@@ -40676,6 +40668,36 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40676
40668
|
signal
|
|
40677
40669
|
);
|
|
40678
40670
|
const agent = config2.catalog.find(command.agentId);
|
|
40671
|
+
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40672
|
+
throw new AcpExecutionError(
|
|
40673
|
+
"The queued prompt target is unavailable",
|
|
40674
|
+
{},
|
|
40675
|
+
"prompt_queue_target_unavailable"
|
|
40676
|
+
);
|
|
40677
|
+
}
|
|
40678
|
+
if (command.sessionConfigurations !== void 0) {
|
|
40679
|
+
const prepared = await sessions.prepareExecutionSession({
|
|
40680
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
40681
|
+
agent,
|
|
40682
|
+
cwd: resolved.cwd,
|
|
40683
|
+
sessionId: command.sessionId,
|
|
40684
|
+
signal
|
|
40685
|
+
});
|
|
40686
|
+
if (command.disposition === SessionPromptDisposition.Steer) {
|
|
40687
|
+
assertCompleteSessionConfiguration(prepared.configOptions, command.sessionConfigurations);
|
|
40688
|
+
} else {
|
|
40689
|
+
await applyCompleteSessionConfiguration(
|
|
40690
|
+
sessions,
|
|
40691
|
+
prepared.configOptions,
|
|
40692
|
+
command.sessionConfigurations,
|
|
40693
|
+
agent,
|
|
40694
|
+
resolved.cwd,
|
|
40695
|
+
resolved.additionalDirectories,
|
|
40696
|
+
command.sessionId,
|
|
40697
|
+
signal
|
|
40698
|
+
);
|
|
40699
|
+
}
|
|
40700
|
+
}
|
|
40679
40701
|
audit.record({
|
|
40680
40702
|
commandId: command.commandId,
|
|
40681
40703
|
event: "session_authorized",
|
|
@@ -40710,13 +40732,6 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40710
40732
|
});
|
|
40711
40733
|
stopReason = "steered";
|
|
40712
40734
|
} else {
|
|
40713
|
-
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40714
|
-
throw new AcpExecutionError(
|
|
40715
|
-
"The queued prompt target is unavailable",
|
|
40716
|
-
{},
|
|
40717
|
-
"prompt_queue_target_unavailable"
|
|
40718
|
-
);
|
|
40719
|
-
}
|
|
40720
40735
|
const result = await sessions.runPrompt({
|
|
40721
40736
|
additionalDirectories: resolved.additionalDirectories,
|
|
40722
40737
|
agent,
|
|
@@ -40783,6 +40798,113 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40783
40798
|
console.error("Mobius daemon command failed", error62);
|
|
40784
40799
|
}
|
|
40785
40800
|
}
|
|
40801
|
+
function invalidSessionConfiguration(message) {
|
|
40802
|
+
return new AcpExecutionError(message, {}, "invalid_session_configuration");
|
|
40803
|
+
}
|
|
40804
|
+
function validateSessionConfigurationSelection(option2, selection) {
|
|
40805
|
+
if (option2.type !== selection.valueType) {
|
|
40806
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} changed type`);
|
|
40807
|
+
}
|
|
40808
|
+
if (option2.type === "boolean") {
|
|
40809
|
+
if (selection.value.length > 0) {
|
|
40810
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40811
|
+
}
|
|
40812
|
+
return;
|
|
40813
|
+
}
|
|
40814
|
+
if (selection.booleanValue) {
|
|
40815
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40816
|
+
}
|
|
40817
|
+
if (!option2.values.some((value) => value.value === selection.value)) {
|
|
40818
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an unavailable value`);
|
|
40819
|
+
}
|
|
40820
|
+
}
|
|
40821
|
+
function assertSessionConfigurationSchema(options, selections) {
|
|
40822
|
+
if (options.length !== selections.length) {
|
|
40823
|
+
throw invalidSessionConfiguration("The Turn configuration does not match the Agent settings schema");
|
|
40824
|
+
}
|
|
40825
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40826
|
+
if (selectionsById.size !== selections.length) {
|
|
40827
|
+
throw invalidSessionConfiguration("The Turn configuration contains duplicate Agent settings");
|
|
40828
|
+
}
|
|
40829
|
+
for (const option2 of options) {
|
|
40830
|
+
const selection = selectionsById.get(option2.id);
|
|
40831
|
+
if (selection === void 0 || selection.valueType !== option2.type || option2.type === "boolean" && selection.value.length > 0 || option2.type === "select" && selection.booleanValue) {
|
|
40832
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option2.id}`);
|
|
40833
|
+
}
|
|
40834
|
+
}
|
|
40835
|
+
}
|
|
40836
|
+
function sessionConfigurationMatches(option2, selection) {
|
|
40837
|
+
validateSessionConfigurationSelection(option2, selection);
|
|
40838
|
+
return option2.type === "boolean" ? option2.booleanValue === selection.booleanValue : option2.currentValue === selection.value;
|
|
40839
|
+
}
|
|
40840
|
+
function sessionConfigurationPriority(selection, options) {
|
|
40841
|
+
if (selection.configId === "permission_mode") {
|
|
40842
|
+
return 0;
|
|
40843
|
+
}
|
|
40844
|
+
const option2 = options.find((candidate) => candidate.id === selection.configId);
|
|
40845
|
+
if (selection.configId === "model" || option2?.category === "model") {
|
|
40846
|
+
return 1;
|
|
40847
|
+
}
|
|
40848
|
+
if (selection.configId === "reasoning_effort" || option2?.category === "thought_level") {
|
|
40849
|
+
return 2;
|
|
40850
|
+
}
|
|
40851
|
+
if (option2?.category === "model_config") {
|
|
40852
|
+
return 3;
|
|
40853
|
+
}
|
|
40854
|
+
return 4;
|
|
40855
|
+
}
|
|
40856
|
+
function assertCompleteSessionConfiguration(options, selections) {
|
|
40857
|
+
assertSessionConfigurationSchema(options, selections);
|
|
40858
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40859
|
+
for (const option2 of options) {
|
|
40860
|
+
const selection = selectionsById.get(option2.id);
|
|
40861
|
+
if (selection === void 0 || !sessionConfigurationMatches(option2, selection)) {
|
|
40862
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option2.id}`);
|
|
40863
|
+
}
|
|
40864
|
+
}
|
|
40865
|
+
}
|
|
40866
|
+
async function applySessionConfigurationSelection(sessions, options, selection, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40867
|
+
const option2 = options.find((candidate) => candidate.id === selection.configId);
|
|
40868
|
+
if (option2 === void 0) {
|
|
40869
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} is unavailable`);
|
|
40870
|
+
}
|
|
40871
|
+
if (sessionConfigurationMatches(option2, selection)) {
|
|
40872
|
+
return options;
|
|
40873
|
+
}
|
|
40874
|
+
return await sessions.configureSession({
|
|
40875
|
+
additionalDirectories,
|
|
40876
|
+
agent,
|
|
40877
|
+
booleanValue: selection.booleanValue,
|
|
40878
|
+
configId: selection.configId,
|
|
40879
|
+
cwd,
|
|
40880
|
+
requestId: `cfg_${randomUUID5()}`,
|
|
40881
|
+
sessionId,
|
|
40882
|
+
signal,
|
|
40883
|
+
value: selection.value,
|
|
40884
|
+
valueType: selection.valueType
|
|
40885
|
+
});
|
|
40886
|
+
}
|
|
40887
|
+
async function applyCompleteSessionConfiguration(sessions, initialOptions, selections, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40888
|
+
assertSessionConfigurationSchema(initialOptions, selections);
|
|
40889
|
+
let options = initialOptions;
|
|
40890
|
+
const orderedSelections = selections.toSorted((left, right) => {
|
|
40891
|
+
const priority = sessionConfigurationPriority(left, initialOptions) - sessionConfigurationPriority(right, initialOptions);
|
|
40892
|
+
return priority === 0 ? left.configId.localeCompare(right.configId) : priority;
|
|
40893
|
+
});
|
|
40894
|
+
for (const selection of orderedSelections) {
|
|
40895
|
+
options = await applySessionConfigurationSelection(
|
|
40896
|
+
sessions,
|
|
40897
|
+
options,
|
|
40898
|
+
selection,
|
|
40899
|
+
agent,
|
|
40900
|
+
cwd,
|
|
40901
|
+
additionalDirectories,
|
|
40902
|
+
sessionId,
|
|
40903
|
+
signal
|
|
40904
|
+
);
|
|
40905
|
+
}
|
|
40906
|
+
assertCompleteSessionConfiguration(options, selections);
|
|
40907
|
+
}
|
|
40786
40908
|
function botExecutionAgent(agent, contextHandle, socketPath) {
|
|
40787
40909
|
return new LocalAgentDefinition(
|
|
40788
40910
|
agent.id,
|
|
@@ -40815,24 +40937,55 @@ function assertPreparedPermission(configOptions, permissionMode) {
|
|
|
40815
40937
|
);
|
|
40816
40938
|
}
|
|
40817
40939
|
}
|
|
40818
|
-
|
|
40940
|
+
function warnIgnoredExecutionSetting(audit, commandId, sessionId, agentId, selection, category, reason) {
|
|
40941
|
+
const details = {
|
|
40942
|
+
agentId,
|
|
40943
|
+
category,
|
|
40944
|
+
configId: selection.configId,
|
|
40945
|
+
reason,
|
|
40946
|
+
requestedValue: selection.value
|
|
40947
|
+
};
|
|
40948
|
+
const event = "bot_execution_setting_ignored";
|
|
40949
|
+
audit.record({ commandId, details, event, sessionId });
|
|
40950
|
+
process.stderr.write(`Mobius daemon warning ${JSON.stringify({ commandId, event, sessionId, ...details })}
|
|
40951
|
+
`);
|
|
40952
|
+
}
|
|
40953
|
+
async function applySupportedExecutionSelection(sessions, audit, configOptions, selection, category, agent, cwd, additionalDirectories, commandId, sessionId, signal) {
|
|
40954
|
+
if (selection.value === AGENT_DEFAULT_EXECUTION_SETTING) {
|
|
40955
|
+
return configOptions;
|
|
40956
|
+
}
|
|
40819
40957
|
const option2 = configOptions.find((candidate) => candidate.id === selection.configId);
|
|
40820
|
-
if (option2 === void 0
|
|
40821
|
-
|
|
40822
|
-
|
|
40823
|
-
|
|
40824
|
-
|
|
40958
|
+
if (option2 === void 0) {
|
|
40959
|
+
warnIgnoredExecutionSetting(audit, commandId, sessionId, agent.id, selection, category, "setting_unavailable");
|
|
40960
|
+
return configOptions;
|
|
40961
|
+
}
|
|
40962
|
+
if (option2.type !== "select" || option2.category !== category) {
|
|
40963
|
+
warnIgnoredExecutionSetting(
|
|
40964
|
+
audit,
|
|
40965
|
+
commandId,
|
|
40966
|
+
sessionId,
|
|
40967
|
+
agent.id,
|
|
40968
|
+
selection,
|
|
40969
|
+
category,
|
|
40970
|
+
"setting_schema_mismatch"
|
|
40825
40971
|
);
|
|
40972
|
+
return configOptions;
|
|
40826
40973
|
}
|
|
40827
|
-
if (selection.
|
|
40974
|
+
if (selection.valueType !== "select" || selection.booleanValue) {
|
|
40975
|
+
warnIgnoredExecutionSetting(
|
|
40976
|
+
audit,
|
|
40977
|
+
commandId,
|
|
40978
|
+
sessionId,
|
|
40979
|
+
agent.id,
|
|
40980
|
+
selection,
|
|
40981
|
+
category,
|
|
40982
|
+
"selection_schema_mismatch"
|
|
40983
|
+
);
|
|
40828
40984
|
return configOptions;
|
|
40829
40985
|
}
|
|
40830
40986
|
if (!option2.values.some((value) => value.value === selection.value)) {
|
|
40831
|
-
|
|
40832
|
-
|
|
40833
|
-
{},
|
|
40834
|
-
"invalid_session_configuration"
|
|
40835
|
-
);
|
|
40987
|
+
warnIgnoredExecutionSetting(audit, commandId, sessionId, agent.id, selection, category, "value_unavailable");
|
|
40988
|
+
return configOptions;
|
|
40836
40989
|
}
|
|
40837
40990
|
if (option2.currentValue === selection.value) {
|
|
40838
40991
|
return configOptions;
|
|
@@ -40931,25 +41084,29 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
40931
41084
|
signal: executionSignal
|
|
40932
41085
|
});
|
|
40933
41086
|
assertPreparedPermission(prepared.configOptions, execution.executionConfiguration.permissionMode);
|
|
40934
|
-
let configOptions = await
|
|
41087
|
+
let configOptions = await applySupportedExecutionSelection(
|
|
40935
41088
|
sessions,
|
|
41089
|
+
audit,
|
|
40936
41090
|
prepared.configOptions,
|
|
40937
41091
|
execution.executionConfiguration.model,
|
|
40938
41092
|
"model",
|
|
40939
41093
|
agent,
|
|
40940
41094
|
resolved.cwd,
|
|
40941
41095
|
resolved.additionalDirectories,
|
|
41096
|
+
command.commandId,
|
|
40942
41097
|
command.sessionId,
|
|
40943
41098
|
executionSignal
|
|
40944
41099
|
);
|
|
40945
|
-
configOptions = await
|
|
41100
|
+
configOptions = await applySupportedExecutionSelection(
|
|
40946
41101
|
sessions,
|
|
41102
|
+
audit,
|
|
40947
41103
|
configOptions,
|
|
40948
41104
|
execution.executionConfiguration.reasoningEffort,
|
|
40949
41105
|
"thought_level",
|
|
40950
41106
|
agent,
|
|
40951
41107
|
resolved.cwd,
|
|
40952
41108
|
resolved.additionalDirectories,
|
|
41109
|
+
command.commandId,
|
|
40953
41110
|
command.sessionId,
|
|
40954
41111
|
executionSignal
|
|
40955
41112
|
);
|