@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/runtime.js
CHANGED
|
@@ -19765,6 +19765,8 @@ var SESSION_LIST_KIND = "session.list";
|
|
|
19765
19765
|
var SESSION_LISTED_KIND = "session.listed";
|
|
19766
19766
|
var SESSION_QUERY_KIND = "session.query";
|
|
19767
19767
|
var SESSION_QUERIED_KIND = "session.queried";
|
|
19768
|
+
var SESSION_RESTORE_KIND = "session.restore";
|
|
19769
|
+
var SESSION_RESTORED_KIND = "session.restored";
|
|
19768
19770
|
var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
|
|
19769
19771
|
var SESSION_CONFIGURE_KIND = "session.configure";
|
|
19770
19772
|
var SESSION_CONFIG_UPDATED_KIND = "session.config.updated";
|
|
@@ -19845,6 +19847,11 @@ var sessionsQueriedEventSchema = external_exports.object({
|
|
|
19845
19847
|
kind: external_exports.literal(SESSION_QUERIED_KIND),
|
|
19846
19848
|
requestId: identifierStringSchema
|
|
19847
19849
|
}).readonly();
|
|
19850
|
+
var sessionRestoreCommandSchema = external_exports.object({
|
|
19851
|
+
kind: external_exports.literal(SESSION_RESTORE_KIND),
|
|
19852
|
+
requestId: identifierStringSchema,
|
|
19853
|
+
sessionId: identifierStringSchema
|
|
19854
|
+
}).readonly();
|
|
19848
19855
|
var fileReadCommandSchema = external_exports.object({
|
|
19849
19856
|
kind: external_exports.literal(FILE_READ_KIND),
|
|
19850
19857
|
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
@@ -20159,6 +20166,12 @@ var sessionReadyEventSchema = external_exports.object({
|
|
|
20159
20166
|
runtimeTimings: runtimeTimingsSchema.optional(),
|
|
20160
20167
|
sessionId: identifierStringSchema
|
|
20161
20168
|
}).readonly();
|
|
20169
|
+
var sessionRestoredEventSchema = external_exports.object({
|
|
20170
|
+
entry: sessionMetadataSchema,
|
|
20171
|
+
kind: external_exports.literal(SESSION_RESTORED_KIND),
|
|
20172
|
+
ready: sessionReadyEventSchema,
|
|
20173
|
+
requestId: identifierStringSchema
|
|
20174
|
+
}).readonly();
|
|
20162
20175
|
var sessionConfigureCommandSchema = external_exports.object({
|
|
20163
20176
|
...sessionIdentityFields,
|
|
20164
20177
|
booleanValue: external_exports.boolean(),
|
|
@@ -20374,6 +20387,10 @@ var decodeSessionQueryCommand = (encoded) => decode3(encoded, sessionQueryComman
|
|
|
20374
20387
|
var encodeSessionQueryCommand = (message) => encode3(message, sessionQueryCommandSchema);
|
|
20375
20388
|
var decodeSessionsQueriedEvent = (encoded) => decode3(encoded, sessionsQueriedEventSchema);
|
|
20376
20389
|
var encodeSessionsQueriedEvent = (message) => encode3(message, sessionsQueriedEventSchema);
|
|
20390
|
+
var decodeSessionRestoreCommand = (encoded) => decode3(encoded, sessionRestoreCommandSchema);
|
|
20391
|
+
var encodeSessionRestoreCommand = (message) => encode3(message, sessionRestoreCommandSchema);
|
|
20392
|
+
var decodeSessionRestoredEvent = (encoded) => decode3(encoded, sessionRestoredEventSchema);
|
|
20393
|
+
var encodeSessionRestoredEvent = (message) => encode3(message, sessionRestoredEventSchema);
|
|
20377
20394
|
var decodeSessionStatusChangedEvent = (encoded) => decode3(encoded, sessionStatusChangedEventSchema);
|
|
20378
20395
|
var encodeSessionStatusChangedEvent = (message) => encode3(message, sessionStatusChangedEventSchema);
|
|
20379
20396
|
var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
|
|
@@ -21456,6 +21473,11 @@ var serviceToDaemonSignatures = {
|
|
|
21456
21473
|
encodeSessionQueryCommand,
|
|
21457
21474
|
decodeSessionQueryCommand
|
|
21458
21475
|
),
|
|
21476
|
+
[SESSION_RESTORE_KIND]: defineMessageSignature(
|
|
21477
|
+
SESSION_RESTORE_KIND,
|
|
21478
|
+
encodeSessionRestoreCommand,
|
|
21479
|
+
decodeSessionRestoreCommand
|
|
21480
|
+
),
|
|
21459
21481
|
[NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
21460
21482
|
NATIVE_SESSION_CANCEL_KIND,
|
|
21461
21483
|
encodeNativeSessionCancel,
|
|
@@ -21587,6 +21609,11 @@ var daemonToServiceSignatures = {
|
|
|
21587
21609
|
encodeSessionsQueriedEvent,
|
|
21588
21610
|
decodeSessionsQueriedEvent
|
|
21589
21611
|
),
|
|
21612
|
+
[SESSION_RESTORED_KIND]: defineMessageSignature(
|
|
21613
|
+
SESSION_RESTORED_KIND,
|
|
21614
|
+
encodeSessionRestoredEvent,
|
|
21615
|
+
decodeSessionRestoredEvent
|
|
21616
|
+
),
|
|
21590
21617
|
[SESSION_STATUS_CHANGED_KIND]: defineMessageSignature(
|
|
21591
21618
|
SESSION_STATUS_CHANGED_KIND,
|
|
21592
21619
|
encodeSessionStatusChangedEvent,
|
|
@@ -23079,6 +23106,7 @@ function sessionFailureMeta(failure2) {
|
|
|
23079
23106
|
import { spawn as spawn2 } from "node:child_process";
|
|
23080
23107
|
|
|
23081
23108
|
// src/acp/codex/app-server-protocol.ts
|
|
23109
|
+
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
23082
23110
|
var boundedText = (maximum) => external_exports.string().max(maximum);
|
|
23083
23111
|
var jsonValue = external_exports.lazy(() => external_exports.unknown());
|
|
23084
23112
|
var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
|
|
@@ -23149,6 +23177,7 @@ var imageGenerationItemSchema = external_exports.object({
|
|
|
23149
23177
|
});
|
|
23150
23178
|
var threadItemSchema = external_exports.discriminatedUnion("type", [
|
|
23151
23179
|
imageGenerationItemSchema,
|
|
23180
|
+
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute2) }),
|
|
23152
23181
|
external_exports.object({
|
|
23153
23182
|
id: boundedText(256),
|
|
23154
23183
|
text: boundedText(1e6),
|
|
@@ -23573,6 +23602,7 @@ var CodexAppServerClient = class {
|
|
|
23573
23602
|
};
|
|
23574
23603
|
|
|
23575
23604
|
// src/acp/codex/items.ts
|
|
23605
|
+
import { pathToFileURL } from "node:url";
|
|
23576
23606
|
var TOOL_OUTPUT_CHARACTER_LIMIT = 32768;
|
|
23577
23607
|
var TITLE_CHARACTER_LIMIT = 500;
|
|
23578
23608
|
function truncate2(value, limit) {
|
|
@@ -23594,6 +23624,14 @@ function textContent(text2) {
|
|
|
23594
23624
|
const block = { text: truncate2(text2, TOOL_OUTPUT_CHARACTER_LIMIT), type: "text" };
|
|
23595
23625
|
return { content: block, type: "content" };
|
|
23596
23626
|
}
|
|
23627
|
+
function structuredToolText(value) {
|
|
23628
|
+
const result = external_exports.object({ content: external_exports.array(external_exports.unknown()) }).safeParse(value);
|
|
23629
|
+
const items = Array.isArray(value) ? value : result.success ? result.data.content : [];
|
|
23630
|
+
return items.flatMap((item) => {
|
|
23631
|
+
const text2 = external_exports.object({ type: external_exports.enum(["text", "inputText"]), text: external_exports.string() }).safeParse(item);
|
|
23632
|
+
return text2.success ? [textContent(text2.data.text)] : [];
|
|
23633
|
+
});
|
|
23634
|
+
}
|
|
23597
23635
|
function firstLine(value) {
|
|
23598
23636
|
const line = value.split("\n", 1)[0] ?? "";
|
|
23599
23637
|
return line.trim().length > 0 ? line.trim() : value.trim();
|
|
@@ -23614,6 +23652,22 @@ function mcpStatus(status) {
|
|
|
23614
23652
|
return status === "inProgress" ? "in_progress" : status === "completed" ? "completed" : "failed";
|
|
23615
23653
|
}
|
|
23616
23654
|
function presentToolItem(item) {
|
|
23655
|
+
if (item.type === "imageView") {
|
|
23656
|
+
return {
|
|
23657
|
+
content: [
|
|
23658
|
+
{
|
|
23659
|
+
type: "content",
|
|
23660
|
+
content: { type: "image", data: "", mimeType: "", uri: pathToFileURL(item.path).href }
|
|
23661
|
+
}
|
|
23662
|
+
],
|
|
23663
|
+
kind: "read",
|
|
23664
|
+
locations: [{ path: item.path }],
|
|
23665
|
+
rawInput: { path: item.path },
|
|
23666
|
+
rawOutput: null,
|
|
23667
|
+
status: "completed",
|
|
23668
|
+
title: "View image"
|
|
23669
|
+
};
|
|
23670
|
+
}
|
|
23617
23671
|
if (item.type === "imageGeneration") {
|
|
23618
23672
|
const failed = item.failure != null || item.status === "failed";
|
|
23619
23673
|
const content = [];
|
|
@@ -23678,13 +23732,7 @@ function presentToolItem(item) {
|
|
|
23678
23732
|
}
|
|
23679
23733
|
if (item.type === "mcpToolCall") {
|
|
23680
23734
|
const label = `${item.server}/${item.tool}`;
|
|
23681
|
-
const content =
|
|
23682
|
-
if (item.result != null) {
|
|
23683
|
-
content.push(textContent(JSON.stringify(item.result)));
|
|
23684
|
-
}
|
|
23685
|
-
if (item.error != null) {
|
|
23686
|
-
content.push(textContent(JSON.stringify(item.error)));
|
|
23687
|
-
}
|
|
23735
|
+
const content = structuredToolText(item.error ?? item.result);
|
|
23688
23736
|
return {
|
|
23689
23737
|
content,
|
|
23690
23738
|
kind: "other",
|
|
@@ -23697,13 +23745,13 @@ function presentToolItem(item) {
|
|
|
23697
23745
|
}
|
|
23698
23746
|
if (item.type === "dynamicToolCall") {
|
|
23699
23747
|
const label = item.namespace == null ? item.tool : `${item.namespace}/${item.tool}`;
|
|
23700
|
-
const content = (item.contentItems
|
|
23748
|
+
const content = structuredToolText(item.contentItems);
|
|
23701
23749
|
return {
|
|
23702
23750
|
content,
|
|
23703
23751
|
kind: "other",
|
|
23704
23752
|
locations: [],
|
|
23705
23753
|
rawInput: item.arguments ?? null,
|
|
23706
|
-
rawOutput: item.
|
|
23754
|
+
rawOutput: item.contentItems ?? null,
|
|
23707
23755
|
status: mcpStatus(item.status),
|
|
23708
23756
|
title: truncate2(label, TITLE_CHARACTER_LIMIT)
|
|
23709
23757
|
};
|
|
@@ -23716,12 +23764,12 @@ function toolCallUpdate(item, lifecycle) {
|
|
|
23716
23764
|
return null;
|
|
23717
23765
|
}
|
|
23718
23766
|
return {
|
|
23719
|
-
content: [...presentation.content],
|
|
23767
|
+
content: item.type === "imageView" && lifecycle === "started" ? [] : [...presentation.content],
|
|
23720
23768
|
kind: presentation.kind,
|
|
23721
23769
|
locations: [...presentation.locations],
|
|
23722
23770
|
rawInput: presentation.rawInput,
|
|
23723
23771
|
rawOutput: presentation.rawOutput,
|
|
23724
|
-
status: lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
|
|
23772
|
+
status: item.type === "imageView" && lifecycle === "started" ? "in_progress" : lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
|
|
23725
23773
|
title: presentation.title,
|
|
23726
23774
|
toolCallId: item.id
|
|
23727
23775
|
};
|
|
@@ -24945,12 +24993,12 @@ var AgentProbeError = class extends Error {
|
|
|
24945
24993
|
};
|
|
24946
24994
|
|
|
24947
24995
|
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
24948
|
-
import { isAbsolute as
|
|
24996
|
+
import { isAbsolute as isAbsolute3, join as join4 } from "node:path";
|
|
24949
24997
|
async function resolveUserLocalExecutable(executableName, context) {
|
|
24950
24998
|
context.signal.throwIfAborted();
|
|
24951
24999
|
const platform = context.platform ?? process.platform;
|
|
24952
25000
|
const homeDirectory = context.environment["HOME"];
|
|
24953
|
-
if (platform === "win32" || homeDirectory === void 0 || !
|
|
25001
|
+
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute3(homeDirectory)) {
|
|
24954
25002
|
return [];
|
|
24955
25003
|
}
|
|
24956
25004
|
const executable = await resolveExecutablePath(join4(homeDirectory, ".local", "bin", executableName), platform);
|
|
@@ -25043,7 +25091,7 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25043
25091
|
|
|
25044
25092
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
25045
25093
|
import { mkdir as mkdir2, realpath as realpath3, stat as stat3, writeFile } from "node:fs/promises";
|
|
25046
|
-
import { isAbsolute as
|
|
25094
|
+
import { isAbsolute as isAbsolute4, join as join6, normalize } from "node:path";
|
|
25047
25095
|
|
|
25048
25096
|
// src/agent-installation/deepseek-managed-package.ts
|
|
25049
25097
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -25078,7 +25126,7 @@ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP brid
|
|
|
25078
25126
|
model: deepseek-v4-flash-vision-exp
|
|
25079
25127
|
`;
|
|
25080
25128
|
async function prepareAgentHome(path2, imagePrompts) {
|
|
25081
|
-
if (!
|
|
25129
|
+
if (!isAbsolute4(path2) || normalize(path2) !== path2) {
|
|
25082
25130
|
throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
|
|
25083
25131
|
}
|
|
25084
25132
|
try {
|
|
@@ -25210,7 +25258,7 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25210
25258
|
|
|
25211
25259
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
25212
25260
|
import { realpath as realpath4 } from "node:fs/promises";
|
|
25213
|
-
import { isAbsolute as
|
|
25261
|
+
import { isAbsolute as isAbsolute5, join as join7, relative as relative2, sep as sep2 } from "node:path";
|
|
25214
25262
|
import {
|
|
25215
25263
|
RequestError
|
|
25216
25264
|
} from "@agentclientprotocol/sdk";
|
|
@@ -25276,7 +25324,7 @@ function grokBuildManagedPackage(platform, architecture) {
|
|
|
25276
25324
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
25277
25325
|
function isContainedPath2(root, candidate) {
|
|
25278
25326
|
const difference = relative2(root, candidate);
|
|
25279
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !
|
|
25327
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute5(difference);
|
|
25280
25328
|
}
|
|
25281
25329
|
var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
25282
25330
|
adapterVersion = GROK_BUILD_MANAGED_VERSION;
|
|
@@ -25425,7 +25473,7 @@ import { join as join9 } from "node:path";
|
|
|
25425
25473
|
import { createHash } from "node:crypto";
|
|
25426
25474
|
import { createReadStream } from "node:fs";
|
|
25427
25475
|
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";
|
|
25428
|
-
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as
|
|
25476
|
+
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute6, join as join8, relative as relative3, sep as sep3 } from "node:path";
|
|
25429
25477
|
|
|
25430
25478
|
// src/agent-installation/verified-download.ts
|
|
25431
25479
|
import { fetch } from "undici";
|
|
@@ -25531,7 +25579,7 @@ function isRecord5(value) {
|
|
|
25531
25579
|
}
|
|
25532
25580
|
function isContainedPath3(root, candidate) {
|
|
25533
25581
|
const difference = relative3(root, candidate);
|
|
25534
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !
|
|
25582
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute6(difference);
|
|
25535
25583
|
}
|
|
25536
25584
|
async function hashFile(path2, signal) {
|
|
25537
25585
|
signal.throwIfAborted();
|
|
@@ -25921,7 +25969,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
25921
25969
|
};
|
|
25922
25970
|
|
|
25923
25971
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
25924
|
-
import { isAbsolute as
|
|
25972
|
+
import { isAbsolute as isAbsolute7, join as join11 } from "node:path";
|
|
25925
25973
|
|
|
25926
25974
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
25927
25975
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -25989,7 +26037,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25989
26037
|
}
|
|
25990
26038
|
const requestedPaths = [join11("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
25991
26039
|
const homeDirectory = context.environment["HOME"];
|
|
25992
|
-
if (homeDirectory !== void 0 &&
|
|
26040
|
+
if (homeDirectory !== void 0 && isAbsolute7(homeDirectory)) {
|
|
25993
26041
|
requestedPaths.unshift(join11(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
25994
26042
|
}
|
|
25995
26043
|
const executables = [];
|
|
@@ -26354,7 +26402,7 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
26354
26402
|
}
|
|
26355
26403
|
|
|
26356
26404
|
// src/agent-catalog/executable-discovery.ts
|
|
26357
|
-
import { isAbsolute as
|
|
26405
|
+
import { isAbsolute as isAbsolute8, join as join13 } from "node:path";
|
|
26358
26406
|
|
|
26359
26407
|
// src/agent-installation/managed-adapter-installer.ts
|
|
26360
26408
|
import { join as join12 } from "node:path";
|
|
@@ -26459,7 +26507,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
26459
26507
|
async function resolveSpecificationExecutables(executableName, overrideVariable, resolveInstalled, resolveManaged, context) {
|
|
26460
26508
|
const override = context.environment[overrideVariable];
|
|
26461
26509
|
if (override !== void 0) {
|
|
26462
|
-
if (override.length === 0 || !
|
|
26510
|
+
if (override.length === 0 || !isAbsolute8(override)) {
|
|
26463
26511
|
return [];
|
|
26464
26512
|
}
|
|
26465
26513
|
const executable = await resolveExecutablePath(override, context.platform);
|
|
@@ -26921,7 +26969,7 @@ import {
|
|
|
26921
26969
|
|
|
26922
26970
|
// src/authorization/local-raster.ts
|
|
26923
26971
|
import { open as open4, readFile as readFile2, realpath as realpath6, stat as stat5 } from "node:fs/promises";
|
|
26924
|
-
import { basename, isAbsolute as
|
|
26972
|
+
import { basename, isAbsolute as isAbsolute9, normalize as normalize2 } from "node:path";
|
|
26925
26973
|
import { fileURLToPath } from "node:url";
|
|
26926
26974
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
26927
26975
|
var MAX_INLINE_RASTER_BYTES = 3e6;
|
|
@@ -26987,13 +27035,13 @@ function readInlineRaster(data, name2 = "Image") {
|
|
|
26987
27035
|
}
|
|
26988
27036
|
async function resolveCanonicalPath(requested, signal) {
|
|
26989
27037
|
signal.throwIfAborted();
|
|
26990
|
-
if (!
|
|
27038
|
+
if (!isAbsolute9(requested) || requested.includes("\0") || normalize2(requested) !== requested) {
|
|
26991
27039
|
return null;
|
|
26992
27040
|
}
|
|
26993
27041
|
try {
|
|
26994
27042
|
const target = await realpath6(requested);
|
|
26995
27043
|
signal.throwIfAborted();
|
|
26996
|
-
if (!
|
|
27044
|
+
if (!isAbsolute9(target) || normalize2(target) !== target) {
|
|
26997
27045
|
return null;
|
|
26998
27046
|
}
|
|
26999
27047
|
return target;
|
|
@@ -35721,6 +35769,24 @@ var embeddedImageSchema = external_exports.looseObject({
|
|
|
35721
35769
|
data: external_exports.string(),
|
|
35722
35770
|
mimeType: external_exports.string()
|
|
35723
35771
|
});
|
|
35772
|
+
var inlineImageUrlSchema = external_exports.string().regex(/^data:image\/(?:png|jpeg|gif|webp);base64,/u).transform((url2) => ({
|
|
35773
|
+
type: "image",
|
|
35774
|
+
data: url2.slice(url2.indexOf(",") + 1),
|
|
35775
|
+
mimeType: url2.slice(5, url2.indexOf(";"))
|
|
35776
|
+
}));
|
|
35777
|
+
var toolImageSchema = external_exports.union([
|
|
35778
|
+
embeddedImageSchema,
|
|
35779
|
+
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),
|
|
35780
|
+
external_exports.object({ type: external_exports.literal("inputImage"), imageUrl: inlineImageUrlSchema }).transform(({ imageUrl }) => imageUrl),
|
|
35781
|
+
external_exports.object({
|
|
35782
|
+
type: external_exports.literal("image"),
|
|
35783
|
+
source: external_exports.object({ type: external_exports.literal("base64"), data: external_exports.string(), media_type: external_exports.string() })
|
|
35784
|
+
}).transform(({ source }) => ({ type: "image", data: source.data, mimeType: source.media_type })),
|
|
35785
|
+
external_exports.object({
|
|
35786
|
+
type: external_exports.literal("image"),
|
|
35787
|
+
file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
|
|
35788
|
+
}).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
|
|
35789
|
+
]);
|
|
35724
35790
|
function isRecord8(value) {
|
|
35725
35791
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
35726
35792
|
}
|
|
@@ -35840,7 +35906,7 @@ var AcpContentExternalizer = class {
|
|
|
35840
35906
|
if (!isRecord8(value)) {
|
|
35841
35907
|
return value;
|
|
35842
35908
|
}
|
|
35843
|
-
const image =
|
|
35909
|
+
const image = toolImageSchema.safeParse(value);
|
|
35844
35910
|
if (image.success && image.data.data.length > 0) {
|
|
35845
35911
|
const prepared = await this.#content(sessionId, image.data, signal);
|
|
35846
35912
|
if (isRecord8(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
@@ -35859,6 +35925,7 @@ var AcpContentExternalizer = class {
|
|
|
35859
35925
|
async #toolUpdate(sessionId, update, signal) {
|
|
35860
35926
|
const images = /* @__PURE__ */ new Map();
|
|
35861
35927
|
const rawOutput = update.rawOutput === void 0 ? void 0 : await this.#rawOutput(sessionId, update.rawOutput, images, signal);
|
|
35928
|
+
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));
|
|
35862
35929
|
const originalJson = images.size === 0 ? void 0 : JSON.stringify(update.rawOutput);
|
|
35863
35930
|
const rewrittenJson = images.size === 0 ? void 0 : JSON.stringify(rawOutput);
|
|
35864
35931
|
const agentContent = [];
|
|
@@ -35882,10 +35949,11 @@ var AcpContentExternalizer = class {
|
|
|
35882
35949
|
eventContent.push({ type: "content", content: prepared.event });
|
|
35883
35950
|
}
|
|
35884
35951
|
const output2 = update.rawOutput === void 0 ? {} : { rawOutput };
|
|
35952
|
+
const meta3 = metadata === void 0 ? {} : { _meta: metadata };
|
|
35885
35953
|
const hasContent = update.content !== void 0 && update.content !== null || agentContent.length > 0;
|
|
35886
35954
|
return {
|
|
35887
|
-
agent: { ...update, ...output2, ...hasContent ? { content: agentContent } : {} },
|
|
35888
|
-
event: { ...update, ...output2, ...hasContent ? { content: eventContent } : {} }
|
|
35955
|
+
agent: { ...update, ...meta3, ...output2, ...hasContent ? { content: agentContent } : {} },
|
|
35956
|
+
event: { ...update, ...meta3, ...output2, ...hasContent ? { content: eventContent } : {} }
|
|
35889
35957
|
};
|
|
35890
35958
|
}
|
|
35891
35959
|
update = async (sessionId, update, signal) => {
|
|
@@ -37516,7 +37584,7 @@ var FixedInstallationExecutor = class {
|
|
|
37516
37584
|
// src/authorization/workspace-directory.ts
|
|
37517
37585
|
import { readdir as readdir3, realpath as realpath8, stat as stat7 } from "node:fs/promises";
|
|
37518
37586
|
import { homedir as homedir2 } from "node:os";
|
|
37519
|
-
import { basename as basename3, dirname as dirname4, isAbsolute as
|
|
37587
|
+
import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute10, join as join16, normalize as normalize3, relative as relative4 } from "node:path";
|
|
37520
37588
|
|
|
37521
37589
|
// src/authorization/local-authorization-error.ts
|
|
37522
37590
|
var LocalAuthorizationError = class extends Error {
|
|
@@ -37583,7 +37651,7 @@ var WorkspaceDirectoryService = class {
|
|
|
37583
37651
|
}
|
|
37584
37652
|
if (id.startsWith("path-")) {
|
|
37585
37653
|
const path2 = expandCurrentUserHome(decodePath(id, "path-"));
|
|
37586
|
-
if (
|
|
37654
|
+
if (isAbsolute10(path2)) {
|
|
37587
37655
|
return path2;
|
|
37588
37656
|
}
|
|
37589
37657
|
}
|
|
@@ -37591,7 +37659,7 @@ var WorkspaceDirectoryService = class {
|
|
|
37591
37659
|
};
|
|
37592
37660
|
resolvePath = async (requested, signal) => {
|
|
37593
37661
|
signal.throwIfAborted();
|
|
37594
|
-
if (!
|
|
37662
|
+
if (!isAbsolute10(requested) || requested.includes("\0") || normalize3(requested) !== requested) {
|
|
37595
37663
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
37596
37664
|
}
|
|
37597
37665
|
try {
|
|
@@ -37599,7 +37667,7 @@ var WorkspaceDirectoryService = class {
|
|
|
37599
37667
|
signal.throwIfAborted();
|
|
37600
37668
|
const metadata = await stat7(target);
|
|
37601
37669
|
signal.throwIfAborted();
|
|
37602
|
-
if (!
|
|
37670
|
+
if (!isAbsolute10(target) || normalize3(target) !== target || !metadata.isDirectory()) {
|
|
37603
37671
|
throw new LocalAuthorizationError("The selected location is not a directory");
|
|
37604
37672
|
}
|
|
37605
37673
|
return target;
|
|
@@ -37615,7 +37683,7 @@ var WorkspaceDirectoryService = class {
|
|
|
37615
37683
|
};
|
|
37616
37684
|
label = (path2) => {
|
|
37617
37685
|
const suffix = relative4(homedir2(), path2);
|
|
37618
|
-
return suffix === "" ? "~" : !
|
|
37686
|
+
return suffix === "" ? "~" : !isAbsolute10(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
|
|
37619
37687
|
};
|
|
37620
37688
|
identify = async (bindingId, requestedPath2, signal) => {
|
|
37621
37689
|
this.authorizeMachine(bindingId);
|
|
@@ -40693,7 +40761,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
40693
40761
|
// src/artifacts/local-file-streamer.ts
|
|
40694
40762
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
40695
40763
|
import { realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
40696
|
-
import { basename as basename4, isAbsolute as
|
|
40764
|
+
import { basename as basename4, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve5 } from "node:path";
|
|
40697
40765
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
40698
40766
|
var CHUNK_BYTES = 192 * 1024;
|
|
40699
40767
|
function requestedPath(value) {
|
|
@@ -40712,17 +40780,17 @@ function requestedPath(value) {
|
|
|
40712
40780
|
}
|
|
40713
40781
|
async function resolveFile(value, workingDirectory, signal) {
|
|
40714
40782
|
const path2 = requestedPath(value);
|
|
40715
|
-
if (path2 === null || !
|
|
40783
|
+
if (path2 === null || !isAbsolute11(path2) && workingDirectory === null) {
|
|
40716
40784
|
return null;
|
|
40717
40785
|
}
|
|
40718
40786
|
const requested = workingDirectory === null ? path2 : resolve5(workingDirectory, path2);
|
|
40719
|
-
if (!
|
|
40787
|
+
if (!isAbsolute11(requested) || isAbsolute11(path2) && normalize4(path2) !== path2) {
|
|
40720
40788
|
return null;
|
|
40721
40789
|
}
|
|
40722
40790
|
try {
|
|
40723
40791
|
const target = await realpath9(requested);
|
|
40724
40792
|
signal.throwIfAborted();
|
|
40725
|
-
return
|
|
40793
|
+
return isAbsolute11(target) && normalize4(target) === target ? target : null;
|
|
40726
40794
|
} catch {
|
|
40727
40795
|
signal.throwIfAborted();
|
|
40728
40796
|
return null;
|
|
@@ -41251,6 +41319,72 @@ async function executePrompt({
|
|
|
41251
41319
|
}
|
|
41252
41320
|
|
|
41253
41321
|
// src/daemon-session-commands.ts
|
|
41322
|
+
async function prepareSession(command, config2, directories, audit, sessions, metrics, signal) {
|
|
41323
|
+
return await metrics.measure("prepare-total", async () => {
|
|
41324
|
+
const resolved = await metrics.measure(
|
|
41325
|
+
"workspace-resolve",
|
|
41326
|
+
async () => await resolveSessionDirectories(
|
|
41327
|
+
directories,
|
|
41328
|
+
config2.bindingId,
|
|
41329
|
+
command.directoryId,
|
|
41330
|
+
command.additionalDirectoryIds,
|
|
41331
|
+
signal
|
|
41332
|
+
)
|
|
41333
|
+
);
|
|
41334
|
+
const agent = config2.catalog.find(command.agentId);
|
|
41335
|
+
const preparation = {
|
|
41336
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
41337
|
+
agent,
|
|
41338
|
+
cwd: resolved.cwd,
|
|
41339
|
+
sessionId: command.sessionId,
|
|
41340
|
+
signal
|
|
41341
|
+
};
|
|
41342
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
41343
|
+
const configuration = command.configuration;
|
|
41344
|
+
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
41345
|
+
"configuration",
|
|
41346
|
+
async () => await sessions.configureSession({
|
|
41347
|
+
...preparation,
|
|
41348
|
+
booleanValue: configuration.booleanValue,
|
|
41349
|
+
configId: configuration.configId,
|
|
41350
|
+
requestId: command.requestId,
|
|
41351
|
+
value: configuration.value,
|
|
41352
|
+
valueType: configuration.valueType
|
|
41353
|
+
})
|
|
41354
|
+
);
|
|
41355
|
+
const listing = await metrics.measure(
|
|
41356
|
+
"workspace-list",
|
|
41357
|
+
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
41358
|
+
);
|
|
41359
|
+
audit.record({
|
|
41360
|
+
commandId: command.requestId,
|
|
41361
|
+
event: "session_prepared",
|
|
41362
|
+
sessionId: command.sessionId
|
|
41363
|
+
});
|
|
41364
|
+
if (command.configuration !== void 0) {
|
|
41365
|
+
audit.record({
|
|
41366
|
+
commandId: command.requestId,
|
|
41367
|
+
event: "session_configured",
|
|
41368
|
+
sessionId: command.sessionId
|
|
41369
|
+
});
|
|
41370
|
+
}
|
|
41371
|
+
return {
|
|
41372
|
+
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
41373
|
+
agentId: command.agentId,
|
|
41374
|
+
agentName: prepared.agentName,
|
|
41375
|
+
agentVersion: prepared.agentVersion,
|
|
41376
|
+
capabilities: prepared.capabilities,
|
|
41377
|
+
commands: prepared.commands,
|
|
41378
|
+
configOptions,
|
|
41379
|
+
directoryId: command.directoryId,
|
|
41380
|
+
directoryLabel: listing.directoryLabel,
|
|
41381
|
+
kind: "session.ready",
|
|
41382
|
+
requestId: command.requestId,
|
|
41383
|
+
restored: prepared.restored,
|
|
41384
|
+
sessionId: command.sessionId
|
|
41385
|
+
};
|
|
41386
|
+
});
|
|
41387
|
+
}
|
|
41254
41388
|
async function executeWorkspaceList(socket, command, directories, audit, signal) {
|
|
41255
41389
|
try {
|
|
41256
41390
|
const listing = await directories.list(command.bindingId, command.directoryId, signal);
|
|
@@ -41275,72 +41409,7 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
|
|
|
41275
41409
|
async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
|
|
41276
41410
|
const metrics = new AccumulatingOperationMetrics();
|
|
41277
41411
|
try {
|
|
41278
|
-
const readyEvent = await
|
|
41279
|
-
const resolved = await metrics.measure(
|
|
41280
|
-
"workspace-resolve",
|
|
41281
|
-
async () => await resolveSessionDirectories(
|
|
41282
|
-
directories,
|
|
41283
|
-
config2.bindingId,
|
|
41284
|
-
command.directoryId,
|
|
41285
|
-
command.additionalDirectoryIds,
|
|
41286
|
-
signal
|
|
41287
|
-
)
|
|
41288
|
-
);
|
|
41289
|
-
const agent = config2.catalog.find(command.agentId);
|
|
41290
|
-
const preparation = {
|
|
41291
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
41292
|
-
agent,
|
|
41293
|
-
cwd: resolved.cwd,
|
|
41294
|
-
sessionId: command.sessionId,
|
|
41295
|
-
signal
|
|
41296
|
-
};
|
|
41297
|
-
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
41298
|
-
const configuration = command.configuration;
|
|
41299
|
-
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
41300
|
-
"configuration",
|
|
41301
|
-
async () => await sessions.configureSession({
|
|
41302
|
-
...preparation,
|
|
41303
|
-
booleanValue: configuration.booleanValue,
|
|
41304
|
-
configId: configuration.configId,
|
|
41305
|
-
requestId: command.requestId,
|
|
41306
|
-
value: configuration.value,
|
|
41307
|
-
valueType: configuration.valueType
|
|
41308
|
-
})
|
|
41309
|
-
);
|
|
41310
|
-
const listing = await metrics.measure(
|
|
41311
|
-
"workspace-list",
|
|
41312
|
-
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
41313
|
-
);
|
|
41314
|
-
audit.record({
|
|
41315
|
-
commandId: command.requestId,
|
|
41316
|
-
event: "session_prepared",
|
|
41317
|
-
sessionId: command.sessionId
|
|
41318
|
-
});
|
|
41319
|
-
if (command.configuration !== void 0) {
|
|
41320
|
-
audit.record({
|
|
41321
|
-
commandId: command.requestId,
|
|
41322
|
-
event: "session_configured",
|
|
41323
|
-
sessionId: command.sessionId
|
|
41324
|
-
});
|
|
41325
|
-
}
|
|
41326
|
-
const event = {
|
|
41327
|
-
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
41328
|
-
agentId: command.agentId,
|
|
41329
|
-
agentName: prepared.agentName,
|
|
41330
|
-
agentVersion: prepared.agentVersion,
|
|
41331
|
-
capabilities: prepared.capabilities,
|
|
41332
|
-
commands: prepared.commands,
|
|
41333
|
-
configOptions,
|
|
41334
|
-
directoryId: command.directoryId,
|
|
41335
|
-
directoryLabel: listing.directoryLabel,
|
|
41336
|
-
kind: "session.ready",
|
|
41337
|
-
requestId: command.requestId,
|
|
41338
|
-
restored: prepared.restored,
|
|
41339
|
-
sessionId: command.sessionId,
|
|
41340
|
-
runtimeTimings: metrics.snapshot()
|
|
41341
|
-
};
|
|
41342
|
-
return event;
|
|
41343
|
-
});
|
|
41412
|
+
const readyEvent = await prepareSession(command, config2, directories, audit, sessions, metrics, signal);
|
|
41344
41413
|
send(socket, {
|
|
41345
41414
|
...readyEvent,
|
|
41346
41415
|
runtimeTimings: metrics.snapshot()
|
|
@@ -41368,6 +41437,59 @@ async function executeSessionPrepare(socket, command, config2, directories, audi
|
|
|
41368
41437
|
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
41369
41438
|
}
|
|
41370
41439
|
}
|
|
41440
|
+
async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
|
|
41441
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
41442
|
+
try {
|
|
41443
|
+
const entry = await metrics.measure("session-lookup", async () => {
|
|
41444
|
+
const [found] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
41445
|
+
if (found === void 0) {
|
|
41446
|
+
throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
|
|
41447
|
+
}
|
|
41448
|
+
return found;
|
|
41449
|
+
});
|
|
41450
|
+
const ready = await prepareSession(
|
|
41451
|
+
{
|
|
41452
|
+
additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
|
|
41453
|
+
agentId: entry.agentId,
|
|
41454
|
+
bindingId: config2.bindingId,
|
|
41455
|
+
directoryId: entry.directoryId,
|
|
41456
|
+
kind: "session.prepare",
|
|
41457
|
+
requestId: command.requestId,
|
|
41458
|
+
sessionId: command.sessionId,
|
|
41459
|
+
sessionState: "provisioned"
|
|
41460
|
+
},
|
|
41461
|
+
config2,
|
|
41462
|
+
directories,
|
|
41463
|
+
audit,
|
|
41464
|
+
sessions,
|
|
41465
|
+
metrics,
|
|
41466
|
+
signal
|
|
41467
|
+
);
|
|
41468
|
+
send(socket, {
|
|
41469
|
+
entry,
|
|
41470
|
+
kind: "session.restored",
|
|
41471
|
+
ready: { ...ready, runtimeTimings: metrics.snapshot() },
|
|
41472
|
+
requestId: command.requestId
|
|
41473
|
+
});
|
|
41474
|
+
} catch (error62) {
|
|
41475
|
+
diagnostics.daemonDiagnostic(
|
|
41476
|
+
"session_restore_failed",
|
|
41477
|
+
command.requestId,
|
|
41478
|
+
{
|
|
41479
|
+
code: operationErrorCode(error62),
|
|
41480
|
+
sessionId: command.sessionId
|
|
41481
|
+
},
|
|
41482
|
+
error62
|
|
41483
|
+
);
|
|
41484
|
+
audit.record({
|
|
41485
|
+
commandId: command.requestId,
|
|
41486
|
+
details: { code: operationErrorCode(error62) },
|
|
41487
|
+
event: "session_restore_failed",
|
|
41488
|
+
sessionId: command.sessionId
|
|
41489
|
+
});
|
|
41490
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
41491
|
+
}
|
|
41492
|
+
}
|
|
41371
41493
|
async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
|
|
41372
41494
|
try {
|
|
41373
41495
|
const resolved = await resolveSessionDirectories(
|
|
@@ -41681,6 +41803,21 @@ function createDaemonCommandHandler({
|
|
|
41681
41803
|
});
|
|
41682
41804
|
return;
|
|
41683
41805
|
}
|
|
41806
|
+
if (kind === SESSION_RESTORE_KIND) {
|
|
41807
|
+
const command2 = message;
|
|
41808
|
+
void executeSessionRestore(
|
|
41809
|
+
socket,
|
|
41810
|
+
command2,
|
|
41811
|
+
config2,
|
|
41812
|
+
directories,
|
|
41813
|
+
audit,
|
|
41814
|
+
sessions,
|
|
41815
|
+
nativeSessions,
|
|
41816
|
+
diagnostics,
|
|
41817
|
+
signal
|
|
41818
|
+
);
|
|
41819
|
+
return;
|
|
41820
|
+
}
|
|
41684
41821
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
41685
41822
|
const command2 = message;
|
|
41686
41823
|
void sessions.respondPermission(command2).then(() => {
|