@moxt-ai/mobius 0.0.181 → 0.0.183
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/codex/app-server-protocol.d.ts +4 -0
- package/dist/acp/codex/app-server-protocol.d.ts.map +1 -1
- package/dist/acp/codex/app-server-protocol.js +2 -0
- package/dist/acp/codex/app-server-protocol.js.map +1 -1
- package/dist/acp/codex/items.d.ts.map +1 -1
- package/dist/acp/codex/items.js +35 -11
- package/dist/acp/codex/items.js.map +1 -1
- package/dist/cli.js +244 -105
- package/dist/cli.js.map +4 -4
- package/dist/daemon-command-handler.d.ts.map +1 -1
- package/dist/daemon-command-handler.js +7 -2
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-session-commands.d.ts +3 -1
- package/dist/daemon-session-commands.d.ts.map +1 -1
- package/dist/daemon-session-commands.js +98 -55
- package/dist/daemon-session-commands.js.map +1 -1
- package/dist/external-content/acp-content-externalizer.d.ts.map +1 -1
- package/dist/external-content/acp-content-externalizer.js +37 -3
- package/dist/external-content/acp-content-externalizer.js.map +1 -1
- package/dist/index.js +238 -101
- package/dist/index.js.map +3 -3
- package/dist/runtime.js +241 -104
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.183",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -4975,6 +4975,9 @@ function sessionFailureMeta(failure2) {
|
|
|
4975
4975
|
// src/acp/codex/app-server-client.ts
|
|
4976
4976
|
import { spawn as spawn2 } from "node:child_process";
|
|
4977
4977
|
|
|
4978
|
+
// src/acp/codex/app-server-protocol.ts
|
|
4979
|
+
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
4980
|
+
|
|
4978
4981
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/external.js
|
|
4979
4982
|
var external_exports = {};
|
|
4980
4983
|
__export(external_exports, {
|
|
@@ -24714,6 +24717,7 @@ var imageGenerationItemSchema = external_exports.object({
|
|
|
24714
24717
|
});
|
|
24715
24718
|
var threadItemSchema = external_exports.discriminatedUnion("type", [
|
|
24716
24719
|
imageGenerationItemSchema,
|
|
24720
|
+
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute2) }),
|
|
24717
24721
|
external_exports.object({
|
|
24718
24722
|
id: boundedText(256),
|
|
24719
24723
|
text: boundedText(1e6),
|
|
@@ -25138,6 +25142,7 @@ var CodexAppServerClient = class {
|
|
|
25138
25142
|
};
|
|
25139
25143
|
|
|
25140
25144
|
// src/acp/codex/items.ts
|
|
25145
|
+
import { pathToFileURL } from "node:url";
|
|
25141
25146
|
var TOOL_OUTPUT_CHARACTER_LIMIT = 32768;
|
|
25142
25147
|
var TITLE_CHARACTER_LIMIT = 500;
|
|
25143
25148
|
function truncate2(value, limit) {
|
|
@@ -25159,6 +25164,14 @@ function textContent(text2) {
|
|
|
25159
25164
|
const block = { text: truncate2(text2, TOOL_OUTPUT_CHARACTER_LIMIT), type: "text" };
|
|
25160
25165
|
return { content: block, type: "content" };
|
|
25161
25166
|
}
|
|
25167
|
+
function structuredToolText(value) {
|
|
25168
|
+
const result = external_exports.object({ content: external_exports.array(external_exports.unknown()) }).safeParse(value);
|
|
25169
|
+
const items = Array.isArray(value) ? value : result.success ? result.data.content : [];
|
|
25170
|
+
return items.flatMap((item) => {
|
|
25171
|
+
const text2 = external_exports.object({ type: external_exports.enum(["text", "inputText"]), text: external_exports.string() }).safeParse(item);
|
|
25172
|
+
return text2.success ? [textContent(text2.data.text)] : [];
|
|
25173
|
+
});
|
|
25174
|
+
}
|
|
25162
25175
|
function firstLine(value) {
|
|
25163
25176
|
const line = value.split("\n", 1)[0] ?? "";
|
|
25164
25177
|
return line.trim().length > 0 ? line.trim() : value.trim();
|
|
@@ -25179,6 +25192,22 @@ function mcpStatus(status) {
|
|
|
25179
25192
|
return status === "inProgress" ? "in_progress" : status === "completed" ? "completed" : "failed";
|
|
25180
25193
|
}
|
|
25181
25194
|
function presentToolItem(item) {
|
|
25195
|
+
if (item.type === "imageView") {
|
|
25196
|
+
return {
|
|
25197
|
+
content: [
|
|
25198
|
+
{
|
|
25199
|
+
type: "content",
|
|
25200
|
+
content: { type: "image", data: "", mimeType: "", uri: pathToFileURL(item.path).href }
|
|
25201
|
+
}
|
|
25202
|
+
],
|
|
25203
|
+
kind: "read",
|
|
25204
|
+
locations: [{ path: item.path }],
|
|
25205
|
+
rawInput: { path: item.path },
|
|
25206
|
+
rawOutput: null,
|
|
25207
|
+
status: "completed",
|
|
25208
|
+
title: "View image"
|
|
25209
|
+
};
|
|
25210
|
+
}
|
|
25182
25211
|
if (item.type === "imageGeneration") {
|
|
25183
25212
|
const failed = item.failure != null || item.status === "failed";
|
|
25184
25213
|
const content = [];
|
|
@@ -25243,13 +25272,7 @@ function presentToolItem(item) {
|
|
|
25243
25272
|
}
|
|
25244
25273
|
if (item.type === "mcpToolCall") {
|
|
25245
25274
|
const label = `${item.server}/${item.tool}`;
|
|
25246
|
-
const content =
|
|
25247
|
-
if (item.result != null) {
|
|
25248
|
-
content.push(textContent(JSON.stringify(item.result)));
|
|
25249
|
-
}
|
|
25250
|
-
if (item.error != null) {
|
|
25251
|
-
content.push(textContent(JSON.stringify(item.error)));
|
|
25252
|
-
}
|
|
25275
|
+
const content = structuredToolText(item.error ?? item.result);
|
|
25253
25276
|
return {
|
|
25254
25277
|
content,
|
|
25255
25278
|
kind: "other",
|
|
@@ -25262,13 +25285,13 @@ function presentToolItem(item) {
|
|
|
25262
25285
|
}
|
|
25263
25286
|
if (item.type === "dynamicToolCall") {
|
|
25264
25287
|
const label = item.namespace == null ? item.tool : `${item.namespace}/${item.tool}`;
|
|
25265
|
-
const content = (item.contentItems
|
|
25288
|
+
const content = structuredToolText(item.contentItems);
|
|
25266
25289
|
return {
|
|
25267
25290
|
content,
|
|
25268
25291
|
kind: "other",
|
|
25269
25292
|
locations: [],
|
|
25270
25293
|
rawInput: item.arguments ?? null,
|
|
25271
|
-
rawOutput: item.
|
|
25294
|
+
rawOutput: item.contentItems ?? null,
|
|
25272
25295
|
status: mcpStatus(item.status),
|
|
25273
25296
|
title: truncate2(label, TITLE_CHARACTER_LIMIT)
|
|
25274
25297
|
};
|
|
@@ -25281,12 +25304,12 @@ function toolCallUpdate(item, lifecycle) {
|
|
|
25281
25304
|
return null;
|
|
25282
25305
|
}
|
|
25283
25306
|
return {
|
|
25284
|
-
content: [...presentation.content],
|
|
25307
|
+
content: item.type === "imageView" && lifecycle === "started" ? [] : [...presentation.content],
|
|
25285
25308
|
kind: presentation.kind,
|
|
25286
25309
|
locations: [...presentation.locations],
|
|
25287
25310
|
rawInput: presentation.rawInput,
|
|
25288
25311
|
rawOutput: presentation.rawOutput,
|
|
25289
|
-
status: lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
|
|
25312
|
+
status: item.type === "imageView" && lifecycle === "started" ? "in_progress" : lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
|
|
25290
25313
|
title: presentation.title,
|
|
25291
25314
|
toolCallId: item.id
|
|
25292
25315
|
};
|
|
@@ -26510,12 +26533,12 @@ var AgentProbeError = class extends Error {
|
|
|
26510
26533
|
};
|
|
26511
26534
|
|
|
26512
26535
|
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
26513
|
-
import { isAbsolute as
|
|
26536
|
+
import { isAbsolute as isAbsolute3, join as join4 } from "node:path";
|
|
26514
26537
|
async function resolveUserLocalExecutable(executableName, context) {
|
|
26515
26538
|
context.signal.throwIfAborted();
|
|
26516
26539
|
const platform = context.platform ?? process.platform;
|
|
26517
26540
|
const homeDirectory = context.environment["HOME"];
|
|
26518
|
-
if (platform === "win32" || homeDirectory === void 0 || !
|
|
26541
|
+
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute3(homeDirectory)) {
|
|
26519
26542
|
return [];
|
|
26520
26543
|
}
|
|
26521
26544
|
const executable = await resolveExecutablePath(join4(homeDirectory, ".local", "bin", executableName), platform);
|
|
@@ -26608,7 +26631,7 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26608
26631
|
|
|
26609
26632
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
26610
26633
|
import { mkdir as mkdir2, realpath as realpath3, stat as stat3, writeFile } from "node:fs/promises";
|
|
26611
|
-
import { isAbsolute as
|
|
26634
|
+
import { isAbsolute as isAbsolute4, join as join6, normalize } from "node:path";
|
|
26612
26635
|
|
|
26613
26636
|
// src/agent-installation/deepseek-managed-package.ts
|
|
26614
26637
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -26643,7 +26666,7 @@ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP brid
|
|
|
26643
26666
|
model: deepseek-v4-flash-vision-exp
|
|
26644
26667
|
`;
|
|
26645
26668
|
async function prepareAgentHome(path3, imagePrompts) {
|
|
26646
|
-
if (!
|
|
26669
|
+
if (!isAbsolute4(path3) || normalize(path3) !== path3) {
|
|
26647
26670
|
throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
|
|
26648
26671
|
}
|
|
26649
26672
|
try {
|
|
@@ -26775,7 +26798,7 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26775
26798
|
|
|
26776
26799
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
26777
26800
|
import { realpath as realpath4 } from "node:fs/promises";
|
|
26778
|
-
import { isAbsolute as
|
|
26801
|
+
import { isAbsolute as isAbsolute5, join as join7, relative as relative2, sep as sep2 } from "node:path";
|
|
26779
26802
|
import {
|
|
26780
26803
|
RequestError
|
|
26781
26804
|
} from "@agentclientprotocol/sdk";
|
|
@@ -26841,7 +26864,7 @@ function grokBuildManagedPackage(platform, architecture) {
|
|
|
26841
26864
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
26842
26865
|
function isContainedPath2(root, candidate) {
|
|
26843
26866
|
const difference = relative2(root, candidate);
|
|
26844
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !
|
|
26867
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute5(difference);
|
|
26845
26868
|
}
|
|
26846
26869
|
var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
26847
26870
|
adapterVersion = GROK_BUILD_MANAGED_VERSION;
|
|
@@ -26990,7 +27013,7 @@ import { join as join9 } from "node:path";
|
|
|
26990
27013
|
import { createHash } from "node:crypto";
|
|
26991
27014
|
import { createReadStream } from "node:fs";
|
|
26992
27015
|
import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as realpath5, rename as rename2, rm as rm2, stat as stat4, writeFile as writeFile2 } from "node:fs/promises";
|
|
26993
|
-
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as
|
|
27016
|
+
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute6, join as join8, relative as relative3, sep as sep3 } from "node:path";
|
|
26994
27017
|
|
|
26995
27018
|
// src/agent-installation/verified-download.ts
|
|
26996
27019
|
import { fetch } from "undici";
|
|
@@ -27096,7 +27119,7 @@ function isRecord4(value) {
|
|
|
27096
27119
|
}
|
|
27097
27120
|
function isContainedPath3(root, candidate) {
|
|
27098
27121
|
const difference = relative3(root, candidate);
|
|
27099
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !
|
|
27122
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute6(difference);
|
|
27100
27123
|
}
|
|
27101
27124
|
async function hashFile(path3, signal) {
|
|
27102
27125
|
signal.throwIfAborted();
|
|
@@ -27486,7 +27509,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
27486
27509
|
};
|
|
27487
27510
|
|
|
27488
27511
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
27489
|
-
import { isAbsolute as
|
|
27512
|
+
import { isAbsolute as isAbsolute7, join as join11 } from "node:path";
|
|
27490
27513
|
|
|
27491
27514
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
27492
27515
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -27554,7 +27577,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
27554
27577
|
}
|
|
27555
27578
|
const requestedPaths = [join11("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
27556
27579
|
const homeDirectory = context.environment["HOME"];
|
|
27557
|
-
if (homeDirectory !== void 0 &&
|
|
27580
|
+
if (homeDirectory !== void 0 && isAbsolute7(homeDirectory)) {
|
|
27558
27581
|
requestedPaths.unshift(join11(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
27559
27582
|
}
|
|
27560
27583
|
const executables = [];
|
|
@@ -27919,7 +27942,7 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
27919
27942
|
}
|
|
27920
27943
|
|
|
27921
27944
|
// src/agent-catalog/executable-discovery.ts
|
|
27922
|
-
import { isAbsolute as
|
|
27945
|
+
import { isAbsolute as isAbsolute8, join as join13 } from "node:path";
|
|
27923
27946
|
|
|
27924
27947
|
// src/agent-installation/managed-adapter-installer.ts
|
|
27925
27948
|
import { join as join12 } from "node:path";
|
|
@@ -28024,7 +28047,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
28024
28047
|
async function resolveSpecificationExecutables(executableName, overrideVariable, resolveInstalled, resolveManaged, context) {
|
|
28025
28048
|
const override = context.environment[overrideVariable];
|
|
28026
28049
|
if (override !== void 0) {
|
|
28027
|
-
if (override.length === 0 || !
|
|
28050
|
+
if (override.length === 0 || !isAbsolute8(override)) {
|
|
28028
28051
|
return [];
|
|
28029
28052
|
}
|
|
28030
28053
|
const executable = await resolveExecutablePath(override, context.platform);
|
|
@@ -28418,6 +28441,8 @@ var SESSION_LIST_KIND = "session.list";
|
|
|
28418
28441
|
var SESSION_LISTED_KIND = "session.listed";
|
|
28419
28442
|
var SESSION_QUERY_KIND = "session.query";
|
|
28420
28443
|
var SESSION_QUERIED_KIND = "session.queried";
|
|
28444
|
+
var SESSION_RESTORE_KIND = "session.restore";
|
|
28445
|
+
var SESSION_RESTORED_KIND = "session.restored";
|
|
28421
28446
|
var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
|
|
28422
28447
|
var SESSION_CONFIGURE_KIND = "session.configure";
|
|
28423
28448
|
var SESSION_CONFIG_UPDATED_KIND = "session.config.updated";
|
|
@@ -28498,6 +28523,11 @@ var sessionsQueriedEventSchema = external_exports.object({
|
|
|
28498
28523
|
kind: external_exports.literal(SESSION_QUERIED_KIND),
|
|
28499
28524
|
requestId: identifierStringSchema
|
|
28500
28525
|
}).readonly();
|
|
28526
|
+
var sessionRestoreCommandSchema = external_exports.object({
|
|
28527
|
+
kind: external_exports.literal(SESSION_RESTORE_KIND),
|
|
28528
|
+
requestId: identifierStringSchema,
|
|
28529
|
+
sessionId: identifierStringSchema
|
|
28530
|
+
}).readonly();
|
|
28501
28531
|
var fileReadCommandSchema = external_exports.object({
|
|
28502
28532
|
kind: external_exports.literal(FILE_READ_KIND),
|
|
28503
28533
|
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
@@ -28812,6 +28842,12 @@ var sessionReadyEventSchema = external_exports.object({
|
|
|
28812
28842
|
runtimeTimings: runtimeTimingsSchema.optional(),
|
|
28813
28843
|
sessionId: identifierStringSchema
|
|
28814
28844
|
}).readonly();
|
|
28845
|
+
var sessionRestoredEventSchema = external_exports.object({
|
|
28846
|
+
entry: sessionMetadataSchema,
|
|
28847
|
+
kind: external_exports.literal(SESSION_RESTORED_KIND),
|
|
28848
|
+
ready: sessionReadyEventSchema,
|
|
28849
|
+
requestId: identifierStringSchema
|
|
28850
|
+
}).readonly();
|
|
28815
28851
|
var sessionConfigureCommandSchema = external_exports.object({
|
|
28816
28852
|
...sessionIdentityFields,
|
|
28817
28853
|
booleanValue: external_exports.boolean(),
|
|
@@ -29027,6 +29063,10 @@ var decodeSessionQueryCommand = (encoded) => decode3(encoded, sessionQueryComman
|
|
|
29027
29063
|
var encodeSessionQueryCommand = (message) => encode3(message, sessionQueryCommandSchema);
|
|
29028
29064
|
var decodeSessionsQueriedEvent = (encoded) => decode3(encoded, sessionsQueriedEventSchema);
|
|
29029
29065
|
var encodeSessionsQueriedEvent = (message) => encode3(message, sessionsQueriedEventSchema);
|
|
29066
|
+
var decodeSessionRestoreCommand = (encoded) => decode3(encoded, sessionRestoreCommandSchema);
|
|
29067
|
+
var encodeSessionRestoreCommand = (message) => encode3(message, sessionRestoreCommandSchema);
|
|
29068
|
+
var decodeSessionRestoredEvent = (encoded) => decode3(encoded, sessionRestoredEventSchema);
|
|
29069
|
+
var encodeSessionRestoredEvent = (message) => encode3(message, sessionRestoredEventSchema);
|
|
29030
29070
|
var decodeSessionStatusChangedEvent = (encoded) => decode3(encoded, sessionStatusChangedEventSchema);
|
|
29031
29071
|
var encodeSessionStatusChangedEvent = (message) => encode3(message, sessionStatusChangedEventSchema);
|
|
29032
29072
|
var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
|
|
@@ -30109,6 +30149,11 @@ var serviceToDaemonSignatures = {
|
|
|
30109
30149
|
encodeSessionQueryCommand,
|
|
30110
30150
|
decodeSessionQueryCommand
|
|
30111
30151
|
),
|
|
30152
|
+
[SESSION_RESTORE_KIND]: defineMessageSignature(
|
|
30153
|
+
SESSION_RESTORE_KIND,
|
|
30154
|
+
encodeSessionRestoreCommand,
|
|
30155
|
+
decodeSessionRestoreCommand
|
|
30156
|
+
),
|
|
30112
30157
|
[NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
30113
30158
|
NATIVE_SESSION_CANCEL_KIND,
|
|
30114
30159
|
encodeNativeSessionCancel,
|
|
@@ -30240,6 +30285,11 @@ var daemonToServiceSignatures = {
|
|
|
30240
30285
|
encodeSessionsQueriedEvent,
|
|
30241
30286
|
decodeSessionsQueriedEvent
|
|
30242
30287
|
),
|
|
30288
|
+
[SESSION_RESTORED_KIND]: defineMessageSignature(
|
|
30289
|
+
SESSION_RESTORED_KIND,
|
|
30290
|
+
encodeSessionRestoredEvent,
|
|
30291
|
+
decodeSessionRestoredEvent
|
|
30292
|
+
),
|
|
30243
30293
|
[SESSION_STATUS_CHANGED_KIND]: defineMessageSignature(
|
|
30244
30294
|
SESSION_STATUS_CHANGED_KIND,
|
|
30245
30295
|
encodeSessionStatusChangedEvent,
|
|
@@ -31287,7 +31337,7 @@ import {
|
|
|
31287
31337
|
|
|
31288
31338
|
// src/authorization/local-raster.ts
|
|
31289
31339
|
import { open as open5, readFile as readFile2, realpath as realpath7, stat as stat6 } from "node:fs/promises";
|
|
31290
|
-
import { basename as basename2, isAbsolute as
|
|
31340
|
+
import { basename as basename2, isAbsolute as isAbsolute9, normalize as normalize2 } from "node:path";
|
|
31291
31341
|
import { fileURLToPath } from "node:url";
|
|
31292
31342
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
31293
31343
|
var MAX_INLINE_RASTER_BYTES = 3e6;
|
|
@@ -31353,13 +31403,13 @@ function readInlineRaster(data, name2 = "Image") {
|
|
|
31353
31403
|
}
|
|
31354
31404
|
async function resolveCanonicalPath(requested, signal) {
|
|
31355
31405
|
signal.throwIfAborted();
|
|
31356
|
-
if (!
|
|
31406
|
+
if (!isAbsolute9(requested) || requested.includes("\0") || normalize2(requested) !== requested) {
|
|
31357
31407
|
return null;
|
|
31358
31408
|
}
|
|
31359
31409
|
try {
|
|
31360
31410
|
const target = await realpath7(requested);
|
|
31361
31411
|
signal.throwIfAborted();
|
|
31362
|
-
if (!
|
|
31412
|
+
if (!isAbsolute9(target) || normalize2(target) !== target) {
|
|
31363
31413
|
return null;
|
|
31364
31414
|
}
|
|
31365
31415
|
return target;
|
|
@@ -40087,6 +40137,24 @@ var embeddedImageSchema = external_exports.looseObject({
|
|
|
40087
40137
|
data: external_exports.string(),
|
|
40088
40138
|
mimeType: external_exports.string()
|
|
40089
40139
|
});
|
|
40140
|
+
var inlineImageUrlSchema = external_exports.string().regex(/^data:image\/(?:png|jpeg|gif|webp);base64,/u).transform((url2) => ({
|
|
40141
|
+
type: "image",
|
|
40142
|
+
data: url2.slice(url2.indexOf(",") + 1),
|
|
40143
|
+
mimeType: url2.slice(5, url2.indexOf(";"))
|
|
40144
|
+
}));
|
|
40145
|
+
var toolImageSchema = external_exports.union([
|
|
40146
|
+
embeddedImageSchema,
|
|
40147
|
+
external_exports.object({ type: external_exports.literal("file"), mime: external_exports.string(), url: inlineImageUrlSchema }).refine(({ mime, url: url2 }) => mime === url2.mimeType).transform(({ url: url2 }) => url2),
|
|
40148
|
+
external_exports.object({ type: external_exports.literal("inputImage"), imageUrl: inlineImageUrlSchema }).transform(({ imageUrl }) => imageUrl),
|
|
40149
|
+
external_exports.object({
|
|
40150
|
+
type: external_exports.literal("image"),
|
|
40151
|
+
source: external_exports.object({ type: external_exports.literal("base64"), data: external_exports.string(), media_type: external_exports.string() })
|
|
40152
|
+
}).transform(({ source }) => ({ type: "image", data: source.data, mimeType: source.media_type })),
|
|
40153
|
+
external_exports.object({
|
|
40154
|
+
type: external_exports.literal("image"),
|
|
40155
|
+
file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
|
|
40156
|
+
}).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
|
|
40157
|
+
]);
|
|
40090
40158
|
function isRecord10(value) {
|
|
40091
40159
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
40092
40160
|
}
|
|
@@ -40206,7 +40274,7 @@ var AcpContentExternalizer = class {
|
|
|
40206
40274
|
if (!isRecord10(value)) {
|
|
40207
40275
|
return value;
|
|
40208
40276
|
}
|
|
40209
|
-
const image =
|
|
40277
|
+
const image = toolImageSchema.safeParse(value);
|
|
40210
40278
|
if (image.success && image.data.data.length > 0) {
|
|
40211
40279
|
const prepared = await this.#content(sessionId, image.data, signal);
|
|
40212
40280
|
if (isRecord10(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
@@ -40225,6 +40293,7 @@ var AcpContentExternalizer = class {
|
|
|
40225
40293
|
async #toolUpdate(sessionId, update, signal) {
|
|
40226
40294
|
const images = /* @__PURE__ */ new Map();
|
|
40227
40295
|
const rawOutput = update.rawOutput === void 0 ? void 0 : await this.#rawOutput(sessionId, update.rawOutput, images, signal);
|
|
40296
|
+
const metadata = update._meta === void 0 || update._meta === null ? update._meta : external_exports.record(external_exports.string(), external_exports.unknown()).parse(await this.#rawOutput(sessionId, update._meta, images, signal));
|
|
40228
40297
|
const originalJson = images.size === 0 ? void 0 : JSON.stringify(update.rawOutput);
|
|
40229
40298
|
const rewrittenJson = images.size === 0 ? void 0 : JSON.stringify(rawOutput);
|
|
40230
40299
|
const agentContent = [];
|
|
@@ -40248,10 +40317,11 @@ var AcpContentExternalizer = class {
|
|
|
40248
40317
|
eventContent.push({ type: "content", content: prepared.event });
|
|
40249
40318
|
}
|
|
40250
40319
|
const output2 = update.rawOutput === void 0 ? {} : { rawOutput };
|
|
40320
|
+
const meta3 = metadata === void 0 ? {} : { _meta: metadata };
|
|
40251
40321
|
const hasContent = update.content !== void 0 && update.content !== null || agentContent.length > 0;
|
|
40252
40322
|
return {
|
|
40253
|
-
agent: { ...update, ...output2, ...hasContent ? { content: agentContent } : {} },
|
|
40254
|
-
event: { ...update, ...output2, ...hasContent ? { content: eventContent } : {} }
|
|
40323
|
+
agent: { ...update, ...meta3, ...output2, ...hasContent ? { content: agentContent } : {} },
|
|
40324
|
+
event: { ...update, ...meta3, ...output2, ...hasContent ? { content: eventContent } : {} }
|
|
40255
40325
|
};
|
|
40256
40326
|
}
|
|
40257
40327
|
update = async (sessionId, update, signal) => {
|
|
@@ -41882,7 +41952,7 @@ var FixedInstallationExecutor = class {
|
|
|
41882
41952
|
// src/authorization/workspace-directory.ts
|
|
41883
41953
|
import { readdir as readdir4, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
41884
41954
|
import { homedir as homedir2 } from "node:os";
|
|
41885
|
-
import { basename as basename4, dirname as dirname5, isAbsolute as
|
|
41955
|
+
import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute10, join as join17, normalize as normalize3, relative as relative4 } from "node:path";
|
|
41886
41956
|
|
|
41887
41957
|
// src/authorization/local-authorization-error.ts
|
|
41888
41958
|
var LocalAuthorizationError = class extends Error {
|
|
@@ -41949,7 +42019,7 @@ var WorkspaceDirectoryService = class {
|
|
|
41949
42019
|
}
|
|
41950
42020
|
if (id.startsWith("path-")) {
|
|
41951
42021
|
const path3 = expandCurrentUserHome(decodePath(id, "path-"));
|
|
41952
|
-
if (
|
|
42022
|
+
if (isAbsolute10(path3)) {
|
|
41953
42023
|
return path3;
|
|
41954
42024
|
}
|
|
41955
42025
|
}
|
|
@@ -41957,7 +42027,7 @@ var WorkspaceDirectoryService = class {
|
|
|
41957
42027
|
};
|
|
41958
42028
|
resolvePath = async (requested, signal) => {
|
|
41959
42029
|
signal.throwIfAborted();
|
|
41960
|
-
if (!
|
|
42030
|
+
if (!isAbsolute10(requested) || requested.includes("\0") || normalize3(requested) !== requested) {
|
|
41961
42031
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
41962
42032
|
}
|
|
41963
42033
|
try {
|
|
@@ -41965,7 +42035,7 @@ var WorkspaceDirectoryService = class {
|
|
|
41965
42035
|
signal.throwIfAborted();
|
|
41966
42036
|
const metadata = await stat8(target);
|
|
41967
42037
|
signal.throwIfAborted();
|
|
41968
|
-
if (!
|
|
42038
|
+
if (!isAbsolute10(target) || normalize3(target) !== target || !metadata.isDirectory()) {
|
|
41969
42039
|
throw new LocalAuthorizationError("The selected location is not a directory");
|
|
41970
42040
|
}
|
|
41971
42041
|
return target;
|
|
@@ -41981,7 +42051,7 @@ var WorkspaceDirectoryService = class {
|
|
|
41981
42051
|
};
|
|
41982
42052
|
label = (path3) => {
|
|
41983
42053
|
const suffix = relative4(homedir2(), path3);
|
|
41984
|
-
return suffix === "" ? "~" : !
|
|
42054
|
+
return suffix === "" ? "~" : !isAbsolute10(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path3;
|
|
41985
42055
|
};
|
|
41986
42056
|
identify = async (bindingId, requestedPath2, signal) => {
|
|
41987
42057
|
this.authorizeMachine(bindingId);
|
|
@@ -45059,7 +45129,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45059
45129
|
// src/artifacts/local-file-streamer.ts
|
|
45060
45130
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
45061
45131
|
import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
45062
|
-
import { basename as basename5, isAbsolute as
|
|
45132
|
+
import { basename as basename5, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
|
|
45063
45133
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
45064
45134
|
var CHUNK_BYTES = 192 * 1024;
|
|
45065
45135
|
function requestedPath(value) {
|
|
@@ -45078,17 +45148,17 @@ function requestedPath(value) {
|
|
|
45078
45148
|
}
|
|
45079
45149
|
async function resolveFile(value, workingDirectory, signal) {
|
|
45080
45150
|
const path3 = requestedPath(value);
|
|
45081
|
-
if (path3 === null || !
|
|
45151
|
+
if (path3 === null || !isAbsolute11(path3) && workingDirectory === null) {
|
|
45082
45152
|
return null;
|
|
45083
45153
|
}
|
|
45084
45154
|
const requested = workingDirectory === null ? path3 : resolve7(workingDirectory, path3);
|
|
45085
|
-
if (!
|
|
45155
|
+
if (!isAbsolute11(requested) || isAbsolute11(path3) && normalize4(path3) !== path3) {
|
|
45086
45156
|
return null;
|
|
45087
45157
|
}
|
|
45088
45158
|
try {
|
|
45089
45159
|
const target = await realpath10(requested);
|
|
45090
45160
|
signal.throwIfAborted();
|
|
45091
|
-
return
|
|
45161
|
+
return isAbsolute11(target) && normalize4(target) === target ? target : null;
|
|
45092
45162
|
} catch {
|
|
45093
45163
|
signal.throwIfAborted();
|
|
45094
45164
|
return null;
|
|
@@ -45617,6 +45687,72 @@ async function executePrompt({
|
|
|
45617
45687
|
}
|
|
45618
45688
|
|
|
45619
45689
|
// src/daemon-session-commands.ts
|
|
45690
|
+
async function prepareSession(command, config2, directories, audit, sessions, metrics, signal) {
|
|
45691
|
+
return await metrics.measure("prepare-total", async () => {
|
|
45692
|
+
const resolved = await metrics.measure(
|
|
45693
|
+
"workspace-resolve",
|
|
45694
|
+
async () => await resolveSessionDirectories(
|
|
45695
|
+
directories,
|
|
45696
|
+
config2.bindingId,
|
|
45697
|
+
command.directoryId,
|
|
45698
|
+
command.additionalDirectoryIds,
|
|
45699
|
+
signal
|
|
45700
|
+
)
|
|
45701
|
+
);
|
|
45702
|
+
const agent = config2.catalog.find(command.agentId);
|
|
45703
|
+
const preparation = {
|
|
45704
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
45705
|
+
agent,
|
|
45706
|
+
cwd: resolved.cwd,
|
|
45707
|
+
sessionId: command.sessionId,
|
|
45708
|
+
signal
|
|
45709
|
+
};
|
|
45710
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
45711
|
+
const configuration = command.configuration;
|
|
45712
|
+
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
45713
|
+
"configuration",
|
|
45714
|
+
async () => await sessions.configureSession({
|
|
45715
|
+
...preparation,
|
|
45716
|
+
booleanValue: configuration.booleanValue,
|
|
45717
|
+
configId: configuration.configId,
|
|
45718
|
+
requestId: command.requestId,
|
|
45719
|
+
value: configuration.value,
|
|
45720
|
+
valueType: configuration.valueType
|
|
45721
|
+
})
|
|
45722
|
+
);
|
|
45723
|
+
const listing = await metrics.measure(
|
|
45724
|
+
"workspace-list",
|
|
45725
|
+
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
45726
|
+
);
|
|
45727
|
+
audit.record({
|
|
45728
|
+
commandId: command.requestId,
|
|
45729
|
+
event: "session_prepared",
|
|
45730
|
+
sessionId: command.sessionId
|
|
45731
|
+
});
|
|
45732
|
+
if (command.configuration !== void 0) {
|
|
45733
|
+
audit.record({
|
|
45734
|
+
commandId: command.requestId,
|
|
45735
|
+
event: "session_configured",
|
|
45736
|
+
sessionId: command.sessionId
|
|
45737
|
+
});
|
|
45738
|
+
}
|
|
45739
|
+
return {
|
|
45740
|
+
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
45741
|
+
agentId: command.agentId,
|
|
45742
|
+
agentName: prepared.agentName,
|
|
45743
|
+
agentVersion: prepared.agentVersion,
|
|
45744
|
+
capabilities: prepared.capabilities,
|
|
45745
|
+
commands: prepared.commands,
|
|
45746
|
+
configOptions,
|
|
45747
|
+
directoryId: command.directoryId,
|
|
45748
|
+
directoryLabel: listing.directoryLabel,
|
|
45749
|
+
kind: "session.ready",
|
|
45750
|
+
requestId: command.requestId,
|
|
45751
|
+
restored: prepared.restored,
|
|
45752
|
+
sessionId: command.sessionId
|
|
45753
|
+
};
|
|
45754
|
+
});
|
|
45755
|
+
}
|
|
45620
45756
|
async function executeWorkspaceList(socket, command, directories, audit, signal) {
|
|
45621
45757
|
try {
|
|
45622
45758
|
const listing = await directories.list(command.bindingId, command.directoryId, signal);
|
|
@@ -45641,72 +45777,7 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
|
|
|
45641
45777
|
async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
|
|
45642
45778
|
const metrics = new AccumulatingOperationMetrics();
|
|
45643
45779
|
try {
|
|
45644
|
-
const readyEvent = await
|
|
45645
|
-
const resolved = await metrics.measure(
|
|
45646
|
-
"workspace-resolve",
|
|
45647
|
-
async () => await resolveSessionDirectories(
|
|
45648
|
-
directories,
|
|
45649
|
-
config2.bindingId,
|
|
45650
|
-
command.directoryId,
|
|
45651
|
-
command.additionalDirectoryIds,
|
|
45652
|
-
signal
|
|
45653
|
-
)
|
|
45654
|
-
);
|
|
45655
|
-
const agent = config2.catalog.find(command.agentId);
|
|
45656
|
-
const preparation = {
|
|
45657
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
45658
|
-
agent,
|
|
45659
|
-
cwd: resolved.cwd,
|
|
45660
|
-
sessionId: command.sessionId,
|
|
45661
|
-
signal
|
|
45662
|
-
};
|
|
45663
|
-
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
45664
|
-
const configuration = command.configuration;
|
|
45665
|
-
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
45666
|
-
"configuration",
|
|
45667
|
-
async () => await sessions.configureSession({
|
|
45668
|
-
...preparation,
|
|
45669
|
-
booleanValue: configuration.booleanValue,
|
|
45670
|
-
configId: configuration.configId,
|
|
45671
|
-
requestId: command.requestId,
|
|
45672
|
-
value: configuration.value,
|
|
45673
|
-
valueType: configuration.valueType
|
|
45674
|
-
})
|
|
45675
|
-
);
|
|
45676
|
-
const listing = await metrics.measure(
|
|
45677
|
-
"workspace-list",
|
|
45678
|
-
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
45679
|
-
);
|
|
45680
|
-
audit.record({
|
|
45681
|
-
commandId: command.requestId,
|
|
45682
|
-
event: "session_prepared",
|
|
45683
|
-
sessionId: command.sessionId
|
|
45684
|
-
});
|
|
45685
|
-
if (command.configuration !== void 0) {
|
|
45686
|
-
audit.record({
|
|
45687
|
-
commandId: command.requestId,
|
|
45688
|
-
event: "session_configured",
|
|
45689
|
-
sessionId: command.sessionId
|
|
45690
|
-
});
|
|
45691
|
-
}
|
|
45692
|
-
const event = {
|
|
45693
|
-
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
45694
|
-
agentId: command.agentId,
|
|
45695
|
-
agentName: prepared.agentName,
|
|
45696
|
-
agentVersion: prepared.agentVersion,
|
|
45697
|
-
capabilities: prepared.capabilities,
|
|
45698
|
-
commands: prepared.commands,
|
|
45699
|
-
configOptions,
|
|
45700
|
-
directoryId: command.directoryId,
|
|
45701
|
-
directoryLabel: listing.directoryLabel,
|
|
45702
|
-
kind: "session.ready",
|
|
45703
|
-
requestId: command.requestId,
|
|
45704
|
-
restored: prepared.restored,
|
|
45705
|
-
sessionId: command.sessionId,
|
|
45706
|
-
runtimeTimings: metrics.snapshot()
|
|
45707
|
-
};
|
|
45708
|
-
return event;
|
|
45709
|
-
});
|
|
45780
|
+
const readyEvent = await prepareSession(command, config2, directories, audit, sessions, metrics, signal);
|
|
45710
45781
|
send(socket, {
|
|
45711
45782
|
...readyEvent,
|
|
45712
45783
|
runtimeTimings: metrics.snapshot()
|
|
@@ -45734,6 +45805,59 @@ async function executeSessionPrepare(socket, command, config2, directories, audi
|
|
|
45734
45805
|
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
45735
45806
|
}
|
|
45736
45807
|
}
|
|
45808
|
+
async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
|
|
45809
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
45810
|
+
try {
|
|
45811
|
+
const entry = await metrics.measure("session-lookup", async () => {
|
|
45812
|
+
const [found] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
45813
|
+
if (found === void 0) {
|
|
45814
|
+
throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
|
|
45815
|
+
}
|
|
45816
|
+
return found;
|
|
45817
|
+
});
|
|
45818
|
+
const ready = await prepareSession(
|
|
45819
|
+
{
|
|
45820
|
+
additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
|
|
45821
|
+
agentId: entry.agentId,
|
|
45822
|
+
bindingId: config2.bindingId,
|
|
45823
|
+
directoryId: entry.directoryId,
|
|
45824
|
+
kind: "session.prepare",
|
|
45825
|
+
requestId: command.requestId,
|
|
45826
|
+
sessionId: command.sessionId,
|
|
45827
|
+
sessionState: "provisioned"
|
|
45828
|
+
},
|
|
45829
|
+
config2,
|
|
45830
|
+
directories,
|
|
45831
|
+
audit,
|
|
45832
|
+
sessions,
|
|
45833
|
+
metrics,
|
|
45834
|
+
signal
|
|
45835
|
+
);
|
|
45836
|
+
send(socket, {
|
|
45837
|
+
entry,
|
|
45838
|
+
kind: "session.restored",
|
|
45839
|
+
ready: { ...ready, runtimeTimings: metrics.snapshot() },
|
|
45840
|
+
requestId: command.requestId
|
|
45841
|
+
});
|
|
45842
|
+
} catch (error62) {
|
|
45843
|
+
diagnostics.daemonDiagnostic(
|
|
45844
|
+
"session_restore_failed",
|
|
45845
|
+
command.requestId,
|
|
45846
|
+
{
|
|
45847
|
+
code: operationErrorCode(error62),
|
|
45848
|
+
sessionId: command.sessionId
|
|
45849
|
+
},
|
|
45850
|
+
error62
|
|
45851
|
+
);
|
|
45852
|
+
audit.record({
|
|
45853
|
+
commandId: command.requestId,
|
|
45854
|
+
details: { code: operationErrorCode(error62) },
|
|
45855
|
+
event: "session_restore_failed",
|
|
45856
|
+
sessionId: command.sessionId
|
|
45857
|
+
});
|
|
45858
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
45859
|
+
}
|
|
45860
|
+
}
|
|
45737
45861
|
async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
|
|
45738
45862
|
try {
|
|
45739
45863
|
const resolved = await resolveSessionDirectories(
|
|
@@ -46047,6 +46171,21 @@ function createDaemonCommandHandler({
|
|
|
46047
46171
|
});
|
|
46048
46172
|
return;
|
|
46049
46173
|
}
|
|
46174
|
+
if (kind === SESSION_RESTORE_KIND) {
|
|
46175
|
+
const command2 = message;
|
|
46176
|
+
void executeSessionRestore(
|
|
46177
|
+
socket,
|
|
46178
|
+
command2,
|
|
46179
|
+
config2,
|
|
46180
|
+
directories,
|
|
46181
|
+
audit,
|
|
46182
|
+
sessions,
|
|
46183
|
+
nativeSessions,
|
|
46184
|
+
diagnostics,
|
|
46185
|
+
signal
|
|
46186
|
+
);
|
|
46187
|
+
return;
|
|
46188
|
+
}
|
|
46050
46189
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
46051
46190
|
const command2 = message;
|
|
46052
46191
|
void sessions.respondPermission(command2).then(() => {
|