@moxt-ai/mobius 0.0.59 → 0.0.61
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/session-manager.d.ts +0 -3
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +16 -36
- package/dist/acp/session-manager.js.map +1 -1
- package/dist/agent-catalog/agents/deepseek-harness-agent.d.ts.map +1 -1
- package/dist/agent-catalog/agents/deepseek-harness-agent.js +39 -8
- package/dist/agent-catalog/agents/deepseek-harness-agent.js.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.d.ts.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.js +36 -3
- package/dist/agent-catalog/publish-agent-catalog.js.map +1 -1
- package/dist/agent-installation/deepseek-managed-package.js +2 -2
- package/dist/artifacts/local-file-streamer.d.ts +2 -2
- package/dist/artifacts/local-file-streamer.d.ts.map +1 -1
- package/dist/artifacts/local-file-streamer.js +7 -7
- package/dist/artifacts/local-file-streamer.js.map +1 -1
- package/dist/authorization/local-video.d.ts +1 -2
- package/dist/authorization/local-video.d.ts.map +1 -1
- package/dist/authorization/local-video.js.map +1 -1
- package/dist/cli.js +650 -789
- package/dist/cli.js.map +4 -4
- package/dist/index.js +652 -790
- package/dist/index.js.map +4 -4
- package/dist/relay-connection/liveness.d.ts +2 -2
- package/dist/relay-connection/liveness.d.ts.map +1 -1
- package/dist/relay-connection/liveness.js +3 -3
- package/dist/relay-connection/liveness.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +116 -118
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +661 -799
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -2
- package/dist/artifacts/runtime-artifact-uploader.d.ts +0 -12
- package/dist/artifacts/runtime-artifact-uploader.d.ts.map +0 -1
- package/dist/artifacts/runtime-artifact-uploader.js +0 -150
- package/dist/artifacts/runtime-artifact-uploader.js.map +0 -1
- package/dist/authorization/local-artifact.d.ts +0 -6
- package/dist/authorization/local-artifact.d.ts.map +0 -1
- package/dist/authorization/local-artifact.js +0 -2
- package/dist/authorization/local-artifact.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -6,12 +6,12 @@ var __export = (target, all2) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
|
-
import { mkdir as
|
|
9
|
+
import { mkdir as mkdir6 } from "node:fs/promises";
|
|
10
10
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "@moxt-ai/mobius",
|
|
14
|
-
version: "0.0.
|
|
14
|
+
version: "0.0.61",
|
|
15
15
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
16
16
|
type: "module",
|
|
17
17
|
bin: {
|
|
@@ -57,7 +57,6 @@ var package_default = {
|
|
|
57
57
|
},
|
|
58
58
|
devDependencies: {
|
|
59
59
|
"@moxt-ai/mobius-protocol": "workspace:*",
|
|
60
|
-
"@moxt-ai/mobius-sdk": "workspace:*",
|
|
61
60
|
"@types/mdast": "4.0.4",
|
|
62
61
|
"@types/node": "^24.13.4",
|
|
63
62
|
esbuild: "0.28.2"
|
|
@@ -1500,21 +1499,21 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1500
1499
|
};
|
|
1501
1500
|
|
|
1502
1501
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
1503
|
-
import { realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
1502
|
+
import { mkdir as mkdir2, realpath as realpath3, stat as stat3, writeFile } from "node:fs/promises";
|
|
1504
1503
|
import { isAbsolute as isAbsolute3, join as join6, normalize } from "node:path";
|
|
1505
1504
|
|
|
1506
1505
|
// src/agent-installation/deepseek-managed-package.ts
|
|
1507
1506
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
1508
|
-
dependencyResolutionArguments = Object.freeze(["--before=2026-09-
|
|
1507
|
+
dependencyResolutionArguments = Object.freeze(["--before=2026-09-18T00:00:00.000Z"]);
|
|
1509
1508
|
includeOptionalDependencies = true;
|
|
1510
1509
|
verifyDependencyClosure = true;
|
|
1511
1510
|
};
|
|
1512
1511
|
var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
1513
1512
|
"@deepseek-ai/dsh",
|
|
1514
|
-
"0.1.
|
|
1513
|
+
"0.1.5-rc.2",
|
|
1515
1514
|
"dsh",
|
|
1516
|
-
"sha512-
|
|
1517
|
-
"https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.
|
|
1515
|
+
"sha512-8Xc8hCQHcIWRmTCVU/xZdp6/qMsWMeAd2ObChKDEsfhUPJFXx6H0lgeb1DxUMD86HZrrVN+1bCvn1ppjZ/fOxw==",
|
|
1516
|
+
"https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.5-rc.2.tgz"
|
|
1518
1517
|
);
|
|
1519
1518
|
|
|
1520
1519
|
// src/storage/state-directory.ts
|
|
@@ -1529,16 +1528,30 @@ function readStateDirectory(environment = process.env) {
|
|
|
1529
1528
|
}
|
|
1530
1529
|
|
|
1531
1530
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
1532
|
-
|
|
1531
|
+
var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP bridge to an image-capable route.
|
|
1532
|
+
- id: acp
|
|
1533
|
+
config:
|
|
1534
|
+
provider: deepseek-official
|
|
1535
|
+
model: deepseek-v4-flash-vision-exp
|
|
1536
|
+
`;
|
|
1537
|
+
async function prepareAgentHome(path2, imagePrompts) {
|
|
1533
1538
|
if (!isAbsolute3(path2) || normalize(path2) !== path2) {
|
|
1534
1539
|
throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
|
|
1535
1540
|
}
|
|
1536
1541
|
try {
|
|
1542
|
+
if (imagePrompts) {
|
|
1543
|
+
await mkdir2(path2, { mode: 448, recursive: true });
|
|
1544
|
+
}
|
|
1537
1545
|
const resolved = await realpath3(path2);
|
|
1538
1546
|
const metadata = await stat3(resolved);
|
|
1539
1547
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
1540
1548
|
throw new Error("Agent home is not a user-owned directory");
|
|
1541
1549
|
}
|
|
1550
|
+
if (imagePrompts) {
|
|
1551
|
+
await writeFile(join6(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
1552
|
+
mode: 384
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1542
1555
|
return resolved;
|
|
1543
1556
|
} catch (error62) {
|
|
1544
1557
|
if (error62 instanceof AgentProbeError) {
|
|
@@ -1573,6 +1586,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1573
1586
|
}
|
|
1574
1587
|
createLaunchEnvironment = async (agent, context) => {
|
|
1575
1588
|
let selectedHome = context.environment["DSH_HOME"];
|
|
1589
|
+
let managedHome = false;
|
|
1576
1590
|
try {
|
|
1577
1591
|
const managed = await this.resolveManagedAgent(
|
|
1578
1592
|
readStateDirectory(context.environment),
|
|
@@ -1581,6 +1595,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1581
1595
|
);
|
|
1582
1596
|
if (managed.path === agent.path) {
|
|
1583
1597
|
selectedHome = join6(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
1598
|
+
managedHome = true;
|
|
1584
1599
|
}
|
|
1585
1600
|
} catch {
|
|
1586
1601
|
context.signal.throwIfAborted();
|
|
@@ -1589,7 +1604,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1589
1604
|
return Object.freeze({});
|
|
1590
1605
|
}
|
|
1591
1606
|
return Object.freeze({
|
|
1592
|
-
DSH_HOME: await
|
|
1607
|
+
DSH_HOME: await prepareAgentHome(selectedHome, managedHome)
|
|
1593
1608
|
});
|
|
1594
1609
|
};
|
|
1595
1610
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
@@ -1604,8 +1619,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1604
1619
|
verifyAcp = (_connection, initialized, _defaultWorkspace, _signal) => {
|
|
1605
1620
|
const capabilities = initialized.agentCapabilities ?? {};
|
|
1606
1621
|
const session = capabilities.sessionCapabilities;
|
|
1607
|
-
|
|
1608
|
-
if ((initialized.authMethods ?? []).length !== 0 || capabilities.loadSession === true || capabilities.mcpCapabilities?.http !== true || session?.close == null || session.list == null || session.resume == null || session.additionalDirectories != null || session.delete != null || session.fork != null || prompt?.audio === true || prompt?.embeddedContext === true || prompt?.image === true) {
|
|
1622
|
+
if ((initialized.authMethods ?? []).length !== 0 || capabilities.loadSession === true || capabilities.mcpCapabilities?.http !== true || session?.close == null || session.list == null || session.resume == null || session.additionalDirectories != null || session.delete != null || session.fork != null) {
|
|
1609
1623
|
throw new AgentProbeError(
|
|
1610
1624
|
"acp_incompatible",
|
|
1611
1625
|
"DeepSeek Harness reported an unsupported ACP capability set"
|
|
@@ -1816,7 +1830,7 @@ import { join as join9 } from "node:path";
|
|
|
1816
1830
|
// src/agent-installation/managed-agent-archive.ts
|
|
1817
1831
|
import { createHash } from "node:crypto";
|
|
1818
1832
|
import { createReadStream } from "node:fs";
|
|
1819
|
-
import { chmod, copyFile, mkdir as
|
|
1833
|
+
import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open2, realpath as realpath5, rename as rename2, rm as rm2, stat as stat4, writeFile as writeFile2 } from "node:fs/promises";
|
|
1820
1834
|
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute5, join as join8, relative as relative3, sep as sep3 } from "node:path";
|
|
1821
1835
|
|
|
1822
1836
|
// src/agent-installation/verified-download.ts
|
|
@@ -19477,8 +19491,8 @@ function rewriteKeyNames(ctx) {
|
|
|
19477
19491
|
bySchema.set(entry.schema, entry);
|
|
19478
19492
|
}
|
|
19479
19493
|
const rewrites = /* @__PURE__ */ new Map();
|
|
19480
|
-
for (const
|
|
19481
|
-
const seen = ctx.seen.get(
|
|
19494
|
+
for (const record2 of pendingRecords.get(ctx) ?? []) {
|
|
19495
|
+
const seen = ctx.seen.get(record2);
|
|
19482
19496
|
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
19483
19497
|
if (!names || names === true || rewrites.has(names))
|
|
19484
19498
|
continue;
|
|
@@ -23187,39 +23201,65 @@ var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.
|
|
|
23187
23201
|
var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
|
|
23188
23202
|
var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
|
|
23189
23203
|
var decodeAgentSettingsDiscoverCommand = (encoded) => decode3(encoded, agentSettingsDiscoverCommandSchema);
|
|
23204
|
+
var encodeAgentSettingsDiscoverCommand = (message) => encode3(message, agentSettingsDiscoverCommandSchema);
|
|
23205
|
+
var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSettingsDiscoveredEventSchema);
|
|
23190
23206
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
23207
|
+
var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
|
|
23191
23208
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
23192
23209
|
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
23210
|
+
var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
|
|
23211
|
+
var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
|
|
23193
23212
|
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
23213
|
+
var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
|
|
23194
23214
|
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
23195
23215
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
23216
|
+
var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
|
|
23217
|
+
var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
|
|
23196
23218
|
var encodeFileBeginEvent = (message) => encode3(message, fileBeginEventSchema);
|
|
23219
|
+
var decodeFileChunkEvent = (encoded) => decode3(encoded, fileChunkEventSchema);
|
|
23197
23220
|
var encodeFileChunkEvent = (message) => encode3(message, fileChunkEventSchema);
|
|
23221
|
+
var decodeFileEndEvent = (encoded) => decode3(encoded, fileEndEventSchema);
|
|
23198
23222
|
var encodeFileEndEvent = (message) => encode3(message, fileEndEventSchema);
|
|
23223
|
+
var decodeFileFailedEvent = (encoded) => decode3(encoded, fileFailedEventSchema);
|
|
23199
23224
|
var encodeFileFailedEvent = (message) => encode3(message, fileFailedEventSchema);
|
|
23200
23225
|
var decodeWorkspaceListCommand = (encoded) => decode3(encoded, workspaceListCommandSchema);
|
|
23226
|
+
var encodeWorkspaceListCommand = (message) => encode3(message, workspaceListCommandSchema);
|
|
23227
|
+
var decodeWorkspaceEntriesEvent = (encoded) => decode3(encoded, workspaceEntriesEventSchema);
|
|
23201
23228
|
var encodeWorkspaceEntriesEvent = (message) => encode3(message, workspaceEntriesEventSchema);
|
|
23202
23229
|
var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
|
|
23230
|
+
var encodeSessionPrepareCommand = (message) => encode3(message, sessionPrepareCommandSchema);
|
|
23231
|
+
var decodeSessionReadyEvent = (encoded) => decode3(encoded, sessionReadyEventSchema);
|
|
23203
23232
|
var encodeSessionReadyEvent = (message) => encode3(message, sessionReadyEventSchema);
|
|
23204
23233
|
var decodeSessionConfigureCommand = (encoded) => decode3(encoded, sessionConfigureCommandSchema);
|
|
23205
|
-
var
|
|
23206
|
-
var
|
|
23207
|
-
var
|
|
23208
|
-
var
|
|
23209
|
-
var
|
|
23234
|
+
var encodeSessionConfigureCommand = (message) => encode3(message, sessionConfigureCommandSchema);
|
|
23235
|
+
var decodeSessionConfigUpdatedEvent = (encoded) => decode3(encoded, sessionConfigUpdatedEventSchema);
|
|
23236
|
+
var decodeSessionUsageUpdatedEvent = (encoded) => decode3(encoded, sessionUsageUpdatedEventSchema);
|
|
23237
|
+
var decodeSessionCommandsUpdatedEvent = (encoded) => decode3(encoded, sessionCommandsUpdatedEventSchema);
|
|
23238
|
+
var decodeSessionInfoUpdatedEvent = (encoded) => decode3(encoded, sessionInfoUpdatedEventSchema);
|
|
23239
|
+
var decodeSessionPermissionRequestedEvent = (encoded) => decode3(encoded, sessionPermissionRequestedEventSchema);
|
|
23210
23240
|
var decodeSessionPermissionRespondCommand = (encoded) => decode3(encoded, sessionPermissionRespondCommandSchema);
|
|
23211
|
-
var
|
|
23212
|
-
var
|
|
23241
|
+
var encodeSessionPermissionRespondCommand = (message) => encode3(message, sessionPermissionRespondCommandSchema);
|
|
23242
|
+
var decodeSessionPermissionResolvedEvent = (encoded) => decode3(encoded, sessionPermissionResolvedEventSchema);
|
|
23243
|
+
var decodeSessionElicitationRequestedEvent = (encoded) => decode3(encoded, sessionElicitationRequestedEventSchema);
|
|
23213
23244
|
var decodeSessionElicitationRespondCommand = (encoded) => decode3(encoded, sessionElicitationRespondCommandSchema);
|
|
23214
|
-
var
|
|
23245
|
+
var encodeSessionElicitationRespondCommand = (message) => encode3(message, sessionElicitationRespondCommandSchema);
|
|
23246
|
+
var decodeSessionElicitationResolvedEvent = (encoded) => decode3(encoded, sessionElicitationResolvedEventSchema);
|
|
23247
|
+
var decodeSessionOperationFailedEvent = (encoded) => decode3(encoded, sessionOperationFailedEventSchema);
|
|
23215
23248
|
var encodeSessionOperationFailedEvent = (message) => encode3(message, sessionOperationFailedEventSchema);
|
|
23216
|
-
var
|
|
23249
|
+
var decodeAgentContentEvent = (encoded) => decode3(encoded, agentContentEventSchema);
|
|
23217
23250
|
var decodeAgentInstallRequestCommand = (encoded) => decode3(encoded, agentInstallRequestCommandSchema);
|
|
23251
|
+
var encodeAgentInstallRequestCommand = (message) => encode3(message, agentInstallRequestCommandSchema);
|
|
23218
23252
|
var decodeAgentInstallCancelCommand = (encoded) => decode3(encoded, agentInstallCancelCommandSchema);
|
|
23253
|
+
var encodeAgentInstallCancelCommand = (message) => encode3(message, agentInstallCancelCommandSchema);
|
|
23254
|
+
var decodeAgentInstallStartedEvent = (encoded) => decode3(encoded, agentInstallStartedEventSchema);
|
|
23219
23255
|
var encodeAgentInstallStartedEvent = (message) => encode3(message, agentInstallStartedEventSchema);
|
|
23256
|
+
var decodeAgentInstallProgressEvent = (encoded) => decode3(encoded, agentInstallProgressEventSchema);
|
|
23220
23257
|
var encodeAgentInstallProgressEvent = (message) => encode3(message, agentInstallProgressEventSchema);
|
|
23258
|
+
var decodeAgentInstallCompletedEvent = (encoded) => decode3(encoded, agentInstallCompletedEventSchema);
|
|
23221
23259
|
var encodeAgentInstallCompletedEvent = (message) => encode3(message, agentInstallCompletedEventSchema);
|
|
23260
|
+
var decodeAgentInstallFailedEvent = (encoded) => decode3(encoded, agentInstallFailedEventSchema);
|
|
23222
23261
|
var encodeAgentInstallFailedEvent = (message) => encode3(message, agentInstallFailedEventSchema);
|
|
23262
|
+
var decodeAgentInstallCancelledEvent = (encoded) => decode3(encoded, agentInstallCancelledEventSchema);
|
|
23223
23263
|
var encodeAgentInstallCancelledEvent = (message) => encode3(message, agentInstallCancelledEventSchema);
|
|
23224
23264
|
|
|
23225
23265
|
// ../protocol/src/messages.ts
|
|
@@ -23654,49 +23694,29 @@ function decodeSessionFailedEvent(encoded) {
|
|
|
23654
23694
|
sessionId: readIdentifier(value, "sessionId")
|
|
23655
23695
|
};
|
|
23656
23696
|
}
|
|
23657
|
-
function
|
|
23658
|
-
return JSON.stringify(
|
|
23659
|
-
}
|
|
23660
|
-
function encodeRuntimeDeliveryReceived(message) {
|
|
23661
|
-
return JSON.stringify(decodeRuntimeDeliveryReceived(JSON.stringify(message)));
|
|
23662
|
-
}
|
|
23663
|
-
function encodeSessionStartedEvent(message) {
|
|
23664
|
-
return JSON.stringify(decodeSessionStartedEvent(JSON.stringify(message)));
|
|
23697
|
+
function encodeSessionPromptCommand(message) {
|
|
23698
|
+
return JSON.stringify(decodeSessionPromptCommand(JSON.stringify(message)));
|
|
23665
23699
|
}
|
|
23666
|
-
function
|
|
23667
|
-
return JSON.stringify(
|
|
23700
|
+
function encodeSessionCancelCommand(message) {
|
|
23701
|
+
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
23668
23702
|
}
|
|
23669
|
-
function
|
|
23670
|
-
return JSON.stringify(
|
|
23703
|
+
function encodeRuntimeLivenessReadyEvent(message) {
|
|
23704
|
+
return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
|
|
23671
23705
|
}
|
|
23672
|
-
function
|
|
23673
|
-
return JSON.stringify(
|
|
23706
|
+
function encodeRuntimeHeartbeatEvent(message) {
|
|
23707
|
+
return JSON.stringify(decodeRuntimeHeartbeatEvent(JSON.stringify(message)));
|
|
23674
23708
|
}
|
|
23675
|
-
function
|
|
23676
|
-
return JSON.stringify(
|
|
23709
|
+
function encodeRuntimeHeartbeatAckEvent(message) {
|
|
23710
|
+
return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
|
|
23677
23711
|
}
|
|
23678
|
-
|
|
23679
|
-
|
|
23680
|
-
var MOBIUS_API_PREFIX = "/mobius/api";
|
|
23681
|
-
var API_PREFIX_PATTERN = /^\/[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*$/;
|
|
23682
|
-
var MobiusApiConfigurationError = class extends Error {
|
|
23683
|
-
code = "invalid_api_prefix";
|
|
23684
|
-
constructor() {
|
|
23685
|
-
super("The Mobius API prefix must be an absolute path without parameters");
|
|
23686
|
-
this.name = "MobiusApiConfigurationError";
|
|
23687
|
-
}
|
|
23688
|
-
};
|
|
23689
|
-
function parseMobiusApiPrefix(value) {
|
|
23690
|
-
if (typeof value !== "string" || !API_PREFIX_PATTERN.test(value)) {
|
|
23691
|
-
throw new MobiusApiConfigurationError();
|
|
23692
|
-
}
|
|
23693
|
-
return value;
|
|
23712
|
+
function encodeRuntimeDelivery(message) {
|
|
23713
|
+
return JSON.stringify(decodeRuntimeDelivery(JSON.stringify(message)));
|
|
23694
23714
|
}
|
|
23695
|
-
function
|
|
23696
|
-
return
|
|
23715
|
+
function encodeRuntimeDeliveryReceived(message) {
|
|
23716
|
+
return JSON.stringify(decodeRuntimeDeliveryReceived(JSON.stringify(message)));
|
|
23697
23717
|
}
|
|
23698
|
-
function
|
|
23699
|
-
return
|
|
23718
|
+
function encodeRuntimeDeliveryCommitted(message) {
|
|
23719
|
+
return JSON.stringify(decodeRuntimeDeliveryCommitted(JSON.stringify(message)));
|
|
23700
23720
|
}
|
|
23701
23721
|
|
|
23702
23722
|
// ../protocol/src/session-history.ts
|
|
@@ -23873,9 +23893,13 @@ function decode4(schema, encoded) {
|
|
|
23873
23893
|
}
|
|
23874
23894
|
}
|
|
23875
23895
|
var decodeNativeSessionCommand = (encoded) => decode4(nativeSessionCommandSchema, encoded);
|
|
23896
|
+
var encodeNativeSessionCommand = (value) => JSON.stringify(nativeSessionCommandSchema.parse(value));
|
|
23897
|
+
var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema, encoded);
|
|
23876
23898
|
var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
|
|
23877
23899
|
var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
|
|
23900
|
+
var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
|
|
23878
23901
|
var decodeNativeSessionTurnForkCommand = (encoded) => decode4(nativeSessionTurnForkCommandSchema, encoded);
|
|
23902
|
+
var encodeNativeSessionTurnForkCommand = (value) => JSON.stringify(nativeSessionTurnForkCommandSchema.parse(value));
|
|
23879
23903
|
|
|
23880
23904
|
// ../protocol/src/session-events.ts
|
|
23881
23905
|
var SESSION_EVENT_KIND = "session.event";
|
|
@@ -23967,8 +23991,285 @@ var encode4 = (message, schema) => {
|
|
|
23967
23991
|
var decodeSessionEventEnvelope = (encoded) => decode5(encoded, eventEnvelopeSchema);
|
|
23968
23992
|
var encodeSessionEventEnvelope = (message) => encode4(message, eventEnvelopeSchema);
|
|
23969
23993
|
var decodeSessionEventAcknowledgement = (encoded) => decode5(encoded, eventAcknowledgementSchema);
|
|
23994
|
+
var encodeSessionEventAcknowledgement = (message) => encode4(message, eventAcknowledgementSchema);
|
|
23970
23995
|
var decodeSessionEventDeferred = (encoded) => decode5(encoded, eventDeferredSchema);
|
|
23996
|
+
var encodeSessionEventDeferred = (message) => encode4(message, eventDeferredSchema);
|
|
23971
23997
|
var decodeSessionEventRejection = (encoded) => decode5(encoded, eventRejectionSchema);
|
|
23998
|
+
var encodeSessionEventRejection = (message) => encode4(message, eventRejectionSchema);
|
|
23999
|
+
function decodeRecordedSessionEvent(encoded) {
|
|
24000
|
+
const kind = decodeMessageKind(encoded);
|
|
24001
|
+
switch (kind) {
|
|
24002
|
+
case AGENT_ACTIVITY_KIND:
|
|
24003
|
+
return decodeAgentActivityEvent(encoded);
|
|
24004
|
+
case AGENT_CONTENT_KIND:
|
|
24005
|
+
return decodeAgentContentEvent(encoded);
|
|
24006
|
+
case AGENT_MESSAGE_DELTA_KIND:
|
|
24007
|
+
return decodeAgentMessageDeltaEvent(encoded);
|
|
24008
|
+
case SESSION_COMMANDS_UPDATED_KIND:
|
|
24009
|
+
return decodeSessionCommandsUpdatedEvent(encoded);
|
|
24010
|
+
case SESSION_COMPLETED_KIND:
|
|
24011
|
+
return decodeSessionCompletedEvent(encoded);
|
|
24012
|
+
case SESSION_CONFIG_UPDATED_KIND:
|
|
24013
|
+
return decodeSessionConfigUpdatedEvent(encoded);
|
|
24014
|
+
case SESSION_ELICITATION_REQUESTED_KIND:
|
|
24015
|
+
return decodeSessionElicitationRequestedEvent(encoded);
|
|
24016
|
+
case SESSION_ELICITATION_RESOLVED_KIND:
|
|
24017
|
+
return decodeSessionElicitationResolvedEvent(encoded);
|
|
24018
|
+
case SESSION_FAILED_KIND:
|
|
24019
|
+
return decodeSessionFailedEvent(encoded);
|
|
24020
|
+
case SESSION_INFO_UPDATED_KIND:
|
|
24021
|
+
return decodeSessionInfoUpdatedEvent(encoded);
|
|
24022
|
+
case SESSION_PERMISSION_REQUESTED_KIND:
|
|
24023
|
+
return decodeSessionPermissionRequestedEvent(encoded);
|
|
24024
|
+
case SESSION_PERMISSION_RESOLVED_KIND:
|
|
24025
|
+
return decodeSessionPermissionResolvedEvent(encoded);
|
|
24026
|
+
case SESSION_READY_KIND:
|
|
24027
|
+
return decodeSessionReadyEvent(encoded);
|
|
24028
|
+
case SESSION_STARTED_KIND:
|
|
24029
|
+
return decodeSessionStartedEvent(encoded);
|
|
24030
|
+
case SESSION_USAGE_UPDATED_KIND:
|
|
24031
|
+
return decodeSessionUsageUpdatedEvent(encoded);
|
|
24032
|
+
default:
|
|
24033
|
+
throw new ProtocolMessageError("Unsupported recorded session event");
|
|
24034
|
+
}
|
|
24035
|
+
}
|
|
24036
|
+
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
24037
|
+
|
|
24038
|
+
// ../protocol/src/daemon-transport.ts
|
|
24039
|
+
function defineMessageSignature(kind, encoder, decoder) {
|
|
24040
|
+
const schema = (message) => decoder(JSON.stringify(message));
|
|
24041
|
+
return {
|
|
24042
|
+
decoder,
|
|
24043
|
+
encoder: (message) => encoder(schema(message)),
|
|
24044
|
+
kind,
|
|
24045
|
+
schema
|
|
24046
|
+
};
|
|
24047
|
+
}
|
|
24048
|
+
var serviceToDaemonSignatures = {
|
|
24049
|
+
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
24050
|
+
AGENT_CATALOG_REFRESH_KIND,
|
|
24051
|
+
encodeAgentCatalogRefreshCommand,
|
|
24052
|
+
decodeAgentCatalogRefreshCommand
|
|
24053
|
+
),
|
|
24054
|
+
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
24055
|
+
AGENT_INSTALL_CANCEL_KIND,
|
|
24056
|
+
encodeAgentInstallCancelCommand,
|
|
24057
|
+
decodeAgentInstallCancelCommand
|
|
24058
|
+
),
|
|
24059
|
+
[AGENT_INSTALL_REQUEST_KIND]: defineMessageSignature(
|
|
24060
|
+
AGENT_INSTALL_REQUEST_KIND,
|
|
24061
|
+
encodeAgentInstallRequestCommand,
|
|
24062
|
+
decodeAgentInstallRequestCommand
|
|
24063
|
+
),
|
|
24064
|
+
[AGENT_SETTINGS_DISCOVER_KIND]: defineMessageSignature(
|
|
24065
|
+
AGENT_SETTINGS_DISCOVER_KIND,
|
|
24066
|
+
encodeAgentSettingsDiscoverCommand,
|
|
24067
|
+
decodeAgentSettingsDiscoverCommand
|
|
24068
|
+
),
|
|
24069
|
+
[FILE_READ_KIND]: defineMessageSignature(FILE_READ_KIND, encodeFileReadCommand, decodeFileReadCommand),
|
|
24070
|
+
[NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
24071
|
+
NATIVE_SESSION_CANCEL_KIND,
|
|
24072
|
+
encodeNativeSessionCancel,
|
|
24073
|
+
decodeNativeSessionCancel
|
|
24074
|
+
),
|
|
24075
|
+
[NATIVE_SESSION_REQUEST_KIND]: defineMessageSignature(
|
|
24076
|
+
NATIVE_SESSION_REQUEST_KIND,
|
|
24077
|
+
encodeNativeSessionCommand,
|
|
24078
|
+
decodeNativeSessionCommand
|
|
24079
|
+
),
|
|
24080
|
+
[NATIVE_SESSION_TURN_FORK_KIND]: defineMessageSignature(
|
|
24081
|
+
NATIVE_SESSION_TURN_FORK_KIND,
|
|
24082
|
+
encodeNativeSessionTurnForkCommand,
|
|
24083
|
+
decodeNativeSessionTurnForkCommand
|
|
24084
|
+
),
|
|
24085
|
+
[RUNTIME_DELIVERY_KIND]: defineMessageSignature(
|
|
24086
|
+
RUNTIME_DELIVERY_KIND,
|
|
24087
|
+
encodeRuntimeDelivery,
|
|
24088
|
+
decodeRuntimeDelivery
|
|
24089
|
+
),
|
|
24090
|
+
[RUNTIME_DELIVERY_COMMITTED_KIND]: defineMessageSignature(
|
|
24091
|
+
RUNTIME_DELIVERY_COMMITTED_KIND,
|
|
24092
|
+
encodeRuntimeDeliveryCommitted,
|
|
24093
|
+
decodeRuntimeDeliveryCommitted
|
|
24094
|
+
),
|
|
24095
|
+
[RUNTIME_HEARTBEAT_ACK_KIND]: defineMessageSignature(
|
|
24096
|
+
RUNTIME_HEARTBEAT_ACK_KIND,
|
|
24097
|
+
encodeRuntimeHeartbeatAckEvent,
|
|
24098
|
+
decodeRuntimeHeartbeatAckEvent
|
|
24099
|
+
),
|
|
24100
|
+
[RUNTIME_LIVENESS_READY_KIND]: defineMessageSignature(
|
|
24101
|
+
RUNTIME_LIVENESS_READY_KIND,
|
|
24102
|
+
encodeRuntimeLivenessReadyEvent,
|
|
24103
|
+
decodeRuntimeLivenessReadyEvent
|
|
24104
|
+
),
|
|
24105
|
+
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
24106
|
+
SESSION_CANCEL_KIND,
|
|
24107
|
+
encodeSessionCancelCommand,
|
|
24108
|
+
decodeSessionCancelCommand
|
|
24109
|
+
),
|
|
24110
|
+
[SESSION_CONFIGURE_KIND]: defineMessageSignature(
|
|
24111
|
+
SESSION_CONFIGURE_KIND,
|
|
24112
|
+
encodeSessionConfigureCommand,
|
|
24113
|
+
decodeSessionConfigureCommand
|
|
24114
|
+
),
|
|
24115
|
+
[SESSION_ELICITATION_RESPOND_KIND]: defineMessageSignature(
|
|
24116
|
+
SESSION_ELICITATION_RESPOND_KIND,
|
|
24117
|
+
encodeSessionElicitationRespondCommand,
|
|
24118
|
+
decodeSessionElicitationRespondCommand
|
|
24119
|
+
),
|
|
24120
|
+
[SESSION_EVENT_ACK_KIND]: defineMessageSignature(
|
|
24121
|
+
SESSION_EVENT_ACK_KIND,
|
|
24122
|
+
encodeSessionEventAcknowledgement,
|
|
24123
|
+
decodeSessionEventAcknowledgement
|
|
24124
|
+
),
|
|
24125
|
+
[SESSION_EVENT_DEFERRED_KIND]: defineMessageSignature(
|
|
24126
|
+
SESSION_EVENT_DEFERRED_KIND,
|
|
24127
|
+
encodeSessionEventDeferred,
|
|
24128
|
+
decodeSessionEventDeferred
|
|
24129
|
+
),
|
|
24130
|
+
[SESSION_EVENT_REJECTED_KIND]: defineMessageSignature(
|
|
24131
|
+
SESSION_EVENT_REJECTED_KIND,
|
|
24132
|
+
encodeSessionEventRejection,
|
|
24133
|
+
decodeSessionEventRejection
|
|
24134
|
+
),
|
|
24135
|
+
[SESSION_PERMISSION_RESPOND_KIND]: defineMessageSignature(
|
|
24136
|
+
SESSION_PERMISSION_RESPOND_KIND,
|
|
24137
|
+
encodeSessionPermissionRespondCommand,
|
|
24138
|
+
decodeSessionPermissionRespondCommand
|
|
24139
|
+
),
|
|
24140
|
+
[SESSION_PREPARE_KIND]: defineMessageSignature(
|
|
24141
|
+
SESSION_PREPARE_KIND,
|
|
24142
|
+
encodeSessionPrepareCommand,
|
|
24143
|
+
decodeSessionPrepareCommand
|
|
24144
|
+
),
|
|
24145
|
+
[SESSION_PROMPT_KIND]: defineMessageSignature(
|
|
24146
|
+
SESSION_PROMPT_KIND,
|
|
24147
|
+
encodeSessionPromptCommand,
|
|
24148
|
+
decodeSessionPromptCommand
|
|
24149
|
+
),
|
|
24150
|
+
[WORKSPACE_LIST_KIND]: defineMessageSignature(
|
|
24151
|
+
WORKSPACE_LIST_KIND,
|
|
24152
|
+
encodeWorkspaceListCommand,
|
|
24153
|
+
decodeWorkspaceListCommand
|
|
24154
|
+
)
|
|
24155
|
+
};
|
|
24156
|
+
var serviceToDaemonRegistry = serviceToDaemonSignatures;
|
|
24157
|
+
function decodeServiceToDaemonMessage(encoded) {
|
|
24158
|
+
const kind = decodeMessageKind(encoded);
|
|
24159
|
+
const signature = serviceToDaemonRegistry[kind];
|
|
24160
|
+
if (signature === void 0) {
|
|
24161
|
+
throw new ProtocolMessageError(`Unsupported service-to-daemon message kind: ${kind}`);
|
|
24162
|
+
}
|
|
24163
|
+
return signature.decoder(encoded);
|
|
24164
|
+
}
|
|
24165
|
+
var daemonToServiceSignatures = {
|
|
24166
|
+
[AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
|
|
24167
|
+
AGENT_CATALOG_REFRESHED_KIND,
|
|
24168
|
+
encodeAgentCatalogRefreshedEvent,
|
|
24169
|
+
decodeAgentCatalogRefreshedEvent
|
|
24170
|
+
),
|
|
24171
|
+
[AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
|
|
24172
|
+
AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
24173
|
+
encodeAgentCatalogRefreshFailedEvent,
|
|
24174
|
+
decodeAgentCatalogRefreshFailedEvent
|
|
24175
|
+
),
|
|
24176
|
+
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
24177
|
+
AGENT_INSTALL_CANCELLED_KIND,
|
|
24178
|
+
encodeAgentInstallCancelledEvent,
|
|
24179
|
+
decodeAgentInstallCancelledEvent
|
|
24180
|
+
),
|
|
24181
|
+
[AGENT_INSTALL_COMPLETED_KIND]: defineMessageSignature(
|
|
24182
|
+
AGENT_INSTALL_COMPLETED_KIND,
|
|
24183
|
+
encodeAgentInstallCompletedEvent,
|
|
24184
|
+
decodeAgentInstallCompletedEvent
|
|
24185
|
+
),
|
|
24186
|
+
[AGENT_INSTALL_FAILED_KIND]: defineMessageSignature(
|
|
24187
|
+
AGENT_INSTALL_FAILED_KIND,
|
|
24188
|
+
encodeAgentInstallFailedEvent,
|
|
24189
|
+
decodeAgentInstallFailedEvent
|
|
24190
|
+
),
|
|
24191
|
+
[AGENT_INSTALL_PROGRESS_KIND]: defineMessageSignature(
|
|
24192
|
+
AGENT_INSTALL_PROGRESS_KIND,
|
|
24193
|
+
encodeAgentInstallProgressEvent,
|
|
24194
|
+
decodeAgentInstallProgressEvent
|
|
24195
|
+
),
|
|
24196
|
+
[AGENT_INSTALL_STARTED_KIND]: defineMessageSignature(
|
|
24197
|
+
AGENT_INSTALL_STARTED_KIND,
|
|
24198
|
+
encodeAgentInstallStartedEvent,
|
|
24199
|
+
decodeAgentInstallStartedEvent
|
|
24200
|
+
),
|
|
24201
|
+
[AGENT_SETTINGS_DISCOVERED_KIND]: defineMessageSignature(
|
|
24202
|
+
AGENT_SETTINGS_DISCOVERED_KIND,
|
|
24203
|
+
encodeAgentSettingsDiscoveredEvent,
|
|
24204
|
+
decodeAgentSettingsDiscoveredEvent
|
|
24205
|
+
),
|
|
24206
|
+
[AGENT_SETTINGS_DISCOVERY_FAILED_KIND]: defineMessageSignature(
|
|
24207
|
+
AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
24208
|
+
encodeAgentSettingsDiscoveryFailedEvent,
|
|
24209
|
+
decodeAgentSettingsDiscoveryFailedEvent
|
|
24210
|
+
),
|
|
24211
|
+
[FILE_BEGIN_KIND]: defineMessageSignature(FILE_BEGIN_KIND, encodeFileBeginEvent, decodeFileBeginEvent),
|
|
24212
|
+
[FILE_CHUNK_KIND]: defineMessageSignature(FILE_CHUNK_KIND, encodeFileChunkEvent, decodeFileChunkEvent),
|
|
24213
|
+
[FILE_END_KIND]: defineMessageSignature(FILE_END_KIND, encodeFileEndEvent, decodeFileEndEvent),
|
|
24214
|
+
[FILE_FAILED_KIND]: defineMessageSignature(FILE_FAILED_KIND, encodeFileFailedEvent, decodeFileFailedEvent),
|
|
24215
|
+
[NATIVE_SESSION_RESULT_KIND]: defineMessageSignature(
|
|
24216
|
+
NATIVE_SESSION_RESULT_KIND,
|
|
24217
|
+
encodeNativeSessionResult,
|
|
24218
|
+
decodeNativeSessionResult
|
|
24219
|
+
),
|
|
24220
|
+
[RUNTIME_DELIVERY_RECEIVED_KIND]: defineMessageSignature(
|
|
24221
|
+
RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
24222
|
+
encodeRuntimeDeliveryReceived,
|
|
24223
|
+
decodeRuntimeDeliveryReceived
|
|
24224
|
+
),
|
|
24225
|
+
[RUNTIME_HEARTBEAT_KIND]: defineMessageSignature(
|
|
24226
|
+
RUNTIME_HEARTBEAT_KIND,
|
|
24227
|
+
encodeRuntimeHeartbeatEvent,
|
|
24228
|
+
decodeRuntimeHeartbeatEvent
|
|
24229
|
+
),
|
|
24230
|
+
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
24231
|
+
SESSION_EVENT_KIND,
|
|
24232
|
+
encodeSessionEventEnvelope,
|
|
24233
|
+
decodeSessionEventEnvelope
|
|
24234
|
+
),
|
|
24235
|
+
[SESSION_OPERATION_FAILED_KIND]: defineMessageSignature(
|
|
24236
|
+
SESSION_OPERATION_FAILED_KIND,
|
|
24237
|
+
encodeSessionOperationFailedEvent,
|
|
24238
|
+
decodeSessionOperationFailedEvent
|
|
24239
|
+
),
|
|
24240
|
+
[SESSION_READY_KIND]: defineMessageSignature(SESSION_READY_KIND, encodeSessionReadyEvent, decodeSessionReadyEvent),
|
|
24241
|
+
[WORKSPACE_ENTRIES_KIND]: defineMessageSignature(
|
|
24242
|
+
WORKSPACE_ENTRIES_KIND,
|
|
24243
|
+
encodeWorkspaceEntriesEvent,
|
|
24244
|
+
decodeWorkspaceEntriesEvent
|
|
24245
|
+
)
|
|
24246
|
+
};
|
|
24247
|
+
function encodeDaemonToServiceMessage(message) {
|
|
24248
|
+
return daemonToServiceSignatures[message.kind].encoder(message);
|
|
24249
|
+
}
|
|
24250
|
+
|
|
24251
|
+
// ../protocol/src/mobius-api.ts
|
|
24252
|
+
var MOBIUS_API_PREFIX = "/mobius/api";
|
|
24253
|
+
var API_PREFIX_PATTERN = /^\/[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*$/;
|
|
24254
|
+
var MobiusApiConfigurationError = class extends Error {
|
|
24255
|
+
code = "invalid_api_prefix";
|
|
24256
|
+
constructor() {
|
|
24257
|
+
super("The Mobius API prefix must be an absolute path without parameters");
|
|
24258
|
+
this.name = "MobiusApiConfigurationError";
|
|
24259
|
+
}
|
|
24260
|
+
};
|
|
24261
|
+
function parseMobiusApiPrefix(value) {
|
|
24262
|
+
if (typeof value !== "string" || !API_PREFIX_PATTERN.test(value)) {
|
|
24263
|
+
throw new MobiusApiConfigurationError();
|
|
24264
|
+
}
|
|
24265
|
+
return value;
|
|
24266
|
+
}
|
|
24267
|
+
function mobiusApiPath(resourcePath, apiPrefix = MOBIUS_API_PREFIX) {
|
|
24268
|
+
return `${parseMobiusApiPrefix(apiPrefix)}${resourcePath}`;
|
|
24269
|
+
}
|
|
24270
|
+
function mobiusApiUrl(origin, resourcePath, apiPrefix = MOBIUS_API_PREFIX) {
|
|
24271
|
+
return new URL(mobiusApiPath(resourcePath, apiPrefix), origin);
|
|
24272
|
+
}
|
|
23972
24273
|
|
|
23973
24274
|
// src/config.ts
|
|
23974
24275
|
function loadDefaultWorkspace(environment = process.env) {
|
|
@@ -24029,14 +24330,14 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
24029
24330
|
}
|
|
24030
24331
|
|
|
24031
24332
|
// src/pairing/pair-local-machine.ts
|
|
24032
|
-
import { mkdir as
|
|
24333
|
+
import { mkdir as mkdir5, realpath as realpath6, stat as stat5 } from "node:fs/promises";
|
|
24033
24334
|
import { hostname as hostname3 } from "node:os";
|
|
24034
24335
|
import { basename, resolve as resolve5 } from "node:path";
|
|
24035
24336
|
import { fetch as fetch2 } from "undici";
|
|
24036
24337
|
|
|
24037
24338
|
// src/storage/runtime-installation-store.ts
|
|
24038
24339
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
24039
|
-
import { mkdir as
|
|
24340
|
+
import { mkdir as mkdir4, open as open4, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
|
|
24040
24341
|
import { dirname as dirname3, join as join15, resolve as resolve4 } from "node:path";
|
|
24041
24342
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
24042
24343
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
@@ -24339,9 +24640,9 @@ async function writeJsonAtomically(path2, value, signal) {
|
|
|
24339
24640
|
const directory = dirname3(path2);
|
|
24340
24641
|
const temporaryPath = join15(directory, `.${randomUUID()}.tmp`);
|
|
24341
24642
|
try {
|
|
24342
|
-
await
|
|
24643
|
+
await mkdir4(directory, { mode: 448, recursive: true });
|
|
24343
24644
|
signal.throwIfAborted();
|
|
24344
|
-
await
|
|
24645
|
+
await writeFile3(temporaryPath, `${JSON.stringify(value, null, 2)}
|
|
24345
24646
|
`, { flag: "wx", mode: 384 });
|
|
24346
24647
|
signal.throwIfAborted();
|
|
24347
24648
|
await rename3(temporaryPath, path2);
|
|
@@ -24372,7 +24673,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
24372
24673
|
const rootDirectory = resolve4(options.stateDirectory);
|
|
24373
24674
|
const applicationDirectory = join15(rootDirectory, "installations", applicationId);
|
|
24374
24675
|
try {
|
|
24375
|
-
await
|
|
24676
|
+
await mkdir4(applicationDirectory, { mode: 448, recursive: true });
|
|
24376
24677
|
} catch (cause) {
|
|
24377
24678
|
throw new RuntimeInstallationStoreError(
|
|
24378
24679
|
"installation_unavailable",
|
|
@@ -24385,7 +24686,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
24385
24686
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
24386
24687
|
const stateDirectory = join15(applicationDirectory, storedInstallationId);
|
|
24387
24688
|
try {
|
|
24388
|
-
await
|
|
24689
|
+
await mkdir4(stateDirectory, { mode: 448, recursive: true });
|
|
24389
24690
|
} catch (cause) {
|
|
24390
24691
|
throw new RuntimeInstallationStoreError(
|
|
24391
24692
|
"installation_unavailable",
|
|
@@ -24541,7 +24842,7 @@ async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
|
24541
24842
|
}
|
|
24542
24843
|
const candidate = installationId();
|
|
24543
24844
|
try {
|
|
24544
|
-
await
|
|
24845
|
+
await writeFile3(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
|
|
24545
24846
|
`, {
|
|
24546
24847
|
flag: "wx",
|
|
24547
24848
|
mode: 384
|
|
@@ -24705,7 +25006,7 @@ function parseResumeArgument(arguments_) {
|
|
|
24705
25006
|
async function resolveDefaultWorkspace(path2) {
|
|
24706
25007
|
const requestedWorkspace = resolve5(path2);
|
|
24707
25008
|
try {
|
|
24708
|
-
await
|
|
25009
|
+
await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
|
|
24709
25010
|
const defaultWorkspace = await realpath6(requestedWorkspace);
|
|
24710
25011
|
const metadata = await stat5(defaultWorkspace);
|
|
24711
25012
|
if (!metadata.isDirectory()) {
|
|
@@ -24919,7 +25220,7 @@ var AuditStore = class {
|
|
|
24919
25220
|
this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
|
|
24920
25221
|
}
|
|
24921
25222
|
}
|
|
24922
|
-
record(
|
|
25223
|
+
record(record2) {
|
|
24923
25224
|
this.database.prepare(
|
|
24924
25225
|
`
|
|
24925
25226
|
INSERT INTO audit_events (
|
|
@@ -24932,10 +25233,10 @@ var AuditStore = class {
|
|
|
24932
25233
|
`
|
|
24933
25234
|
).run(
|
|
24934
25235
|
(/* @__PURE__ */ new Date()).toISOString(),
|
|
24935
|
-
|
|
24936
|
-
|
|
24937
|
-
|
|
24938
|
-
JSON.stringify(
|
|
25236
|
+
record2.event,
|
|
25237
|
+
record2.commandId,
|
|
25238
|
+
record2.sessionId,
|
|
25239
|
+
JSON.stringify(record2.details ?? {})
|
|
24939
25240
|
);
|
|
24940
25241
|
}
|
|
24941
25242
|
close() {
|
|
@@ -24944,10 +25245,10 @@ var AuditStore = class {
|
|
|
24944
25245
|
};
|
|
24945
25246
|
|
|
24946
25247
|
// src/run-daemon.ts
|
|
24947
|
-
import { createHash as
|
|
25248
|
+
import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
|
|
24948
25249
|
import { basename as basename7 } from "node:path";
|
|
24949
25250
|
import { styleText } from "node:util";
|
|
24950
|
-
import { fetch as
|
|
25251
|
+
import { fetch as fetch5, WebSocket as WebSocket2 } from "undici";
|
|
24951
25252
|
|
|
24952
25253
|
// src/acp/session-manager.ts
|
|
24953
25254
|
import { spawn as spawn3 } from "node:child_process";
|
|
@@ -33651,10 +33952,6 @@ var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
|
|
|
33651
33952
|
var SESSION_CONTROL_COMMAND_ID = "session-control";
|
|
33652
33953
|
var SESSION_CONTROL_TIMEOUT_MILLISECONDS = 3e4;
|
|
33653
33954
|
var NullAcpSessionObserver = class {
|
|
33654
|
-
importLocalArtifact = (_sessionId, _artifact, signal) => {
|
|
33655
|
-
signal.throwIfAborted();
|
|
33656
|
-
return Promise.resolve("");
|
|
33657
|
-
};
|
|
33658
33955
|
onCommands = () => Promise.resolve();
|
|
33659
33956
|
onConfig = () => Promise.resolve();
|
|
33660
33957
|
onContent = () => Promise.resolve();
|
|
@@ -34214,20 +34511,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
34214
34511
|
#agentName = "";
|
|
34215
34512
|
#agentVersion = "";
|
|
34216
34513
|
#bufferedAgentText = [];
|
|
34217
|
-
#capabilities =
|
|
34218
|
-
additionalDirectories: false,
|
|
34219
|
-
audioPrompt: false,
|
|
34220
|
-
closeSession: false,
|
|
34221
|
-
deleteSession: false,
|
|
34222
|
-
embeddedContextPrompt: false,
|
|
34223
|
-
imagePrompt: false,
|
|
34224
|
-
listSessions: false,
|
|
34225
|
-
loadSession: false,
|
|
34226
|
-
promptQueueing: false,
|
|
34227
|
-
resumeSession: false,
|
|
34228
|
-
steering: false,
|
|
34229
|
-
unstableForkSession: false
|
|
34230
|
-
};
|
|
34514
|
+
#capabilities = unsupportedSessionCapabilities();
|
|
34231
34515
|
#commands = [];
|
|
34232
34516
|
#configRevision = 0;
|
|
34233
34517
|
#configOptions = [];
|
|
@@ -34447,7 +34731,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
34447
34731
|
if (video === null) {
|
|
34448
34732
|
return { ...content3, data: "" };
|
|
34449
34733
|
}
|
|
34450
|
-
return
|
|
34734
|
+
return this.importVideo(video);
|
|
34451
34735
|
}
|
|
34452
34736
|
return content3;
|
|
34453
34737
|
};
|
|
@@ -34498,22 +34782,19 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
34498
34782
|
}
|
|
34499
34783
|
return imageDisplayContent(raster.mimeType, raster.name, await raster.base64(), "");
|
|
34500
34784
|
};
|
|
34501
|
-
importVideo =
|
|
34502
|
-
|
|
34503
|
-
|
|
34504
|
-
|
|
34505
|
-
|
|
34506
|
-
|
|
34507
|
-
|
|
34508
|
-
|
|
34509
|
-
|
|
34510
|
-
|
|
34511
|
-
|
|
34512
|
-
|
|
34513
|
-
|
|
34514
|
-
uri: ""
|
|
34515
|
-
};
|
|
34516
|
-
};
|
|
34785
|
+
importVideo = (video) => ({
|
|
34786
|
+
artifactId: "",
|
|
34787
|
+
data: video.base64(),
|
|
34788
|
+
mimeType: video.mimeType,
|
|
34789
|
+
name: video.name,
|
|
34790
|
+
newText: "",
|
|
34791
|
+
oldText: "",
|
|
34792
|
+
path: "",
|
|
34793
|
+
terminalId: "",
|
|
34794
|
+
text: "",
|
|
34795
|
+
type: "video",
|
|
34796
|
+
uri: ""
|
|
34797
|
+
});
|
|
34517
34798
|
async #initializeAgent(signal) {
|
|
34518
34799
|
await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
|
|
34519
34800
|
}
|
|
@@ -36706,11 +36987,42 @@ function relayHttpEndpoint(relayUrl) {
|
|
|
36706
36987
|
var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
|
|
36707
36988
|
var AgentCatalogPublishError = class extends Error {
|
|
36708
36989
|
code = "agent_catalog_update_failed";
|
|
36709
|
-
|
|
36990
|
+
diagnosticDetails;
|
|
36991
|
+
constructor(message, options = {}, diagnosticDetails = {}) {
|
|
36710
36992
|
super(message, options);
|
|
36993
|
+
this.diagnosticDetails = diagnosticDetails;
|
|
36711
36994
|
this.name = "AgentCatalogPublishError";
|
|
36712
36995
|
}
|
|
36713
36996
|
};
|
|
36997
|
+
function isRecord10(value) {
|
|
36998
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36999
|
+
}
|
|
37000
|
+
function isSafeRelayErrorMessage(value) {
|
|
37001
|
+
return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
|
|
37002
|
+
}
|
|
37003
|
+
async function rejectedCatalogError(response) {
|
|
37004
|
+
let value;
|
|
37005
|
+
try {
|
|
37006
|
+
value = await response.json();
|
|
37007
|
+
} catch {
|
|
37008
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
37009
|
+
}
|
|
37010
|
+
if (!isRecord10(value) || !isRecord10(value["error"])) {
|
|
37011
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
37012
|
+
}
|
|
37013
|
+
const code = value["error"]["code"];
|
|
37014
|
+
const message = value["error"]["message"];
|
|
37015
|
+
if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
|
|
37016
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
37017
|
+
}
|
|
37018
|
+
return new AgentCatalogPublishError(
|
|
37019
|
+
`The Relay rejected the Agent catalog update (${code}): ${message}`,
|
|
37020
|
+
{},
|
|
37021
|
+
{
|
|
37022
|
+
relayErrorCode: code
|
|
37023
|
+
}
|
|
37024
|
+
);
|
|
37025
|
+
}
|
|
36714
37026
|
function catalogEndpoint(config2) {
|
|
36715
37027
|
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
36716
37028
|
if (endpoint.pathname.endsWith("/daemon")) {
|
|
@@ -36758,10 +37070,10 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
36758
37070
|
{ cause: error62 }
|
|
36759
37071
|
);
|
|
36760
37072
|
}
|
|
36761
|
-
await response.body?.cancel();
|
|
36762
37073
|
if (!response.ok) {
|
|
36763
|
-
throw
|
|
37074
|
+
throw await rejectedCatalogError(response);
|
|
36764
37075
|
}
|
|
37076
|
+
await response.body?.cancel();
|
|
36765
37077
|
}
|
|
36766
37078
|
|
|
36767
37079
|
// src/agent-installation/agent-installation-manager.ts
|
|
@@ -37270,30 +37582,26 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
37270
37582
|
throw new Error("The local file is too large to read");
|
|
37271
37583
|
}
|
|
37272
37584
|
const raster = await readLocalRaster(target, signal);
|
|
37273
|
-
send2(
|
|
37274
|
-
|
|
37275
|
-
|
|
37276
|
-
|
|
37277
|
-
|
|
37278
|
-
|
|
37279
|
-
|
|
37280
|
-
|
|
37281
|
-
|
|
37282
|
-
})
|
|
37283
|
-
);
|
|
37585
|
+
send2({
|
|
37586
|
+
byteLength: before.size,
|
|
37587
|
+
kind: FILE_BEGIN_KIND,
|
|
37588
|
+
mediaType: raster?.mimeType ?? "application/octet-stream",
|
|
37589
|
+
modifiedAt: before.mtime.toISOString(),
|
|
37590
|
+
name: basename4(target) || "file",
|
|
37591
|
+
requestId: command.requestId,
|
|
37592
|
+
sessionId: command.sessionId
|
|
37593
|
+
});
|
|
37284
37594
|
let sequence = 0;
|
|
37285
37595
|
const stream = createReadStream2(target, { highWaterMark: CHUNK_BYTES, signal });
|
|
37286
37596
|
for await (const value of stream) {
|
|
37287
37597
|
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
37288
|
-
send2(
|
|
37289
|
-
|
|
37290
|
-
|
|
37291
|
-
|
|
37292
|
-
|
|
37293
|
-
|
|
37294
|
-
|
|
37295
|
-
})
|
|
37296
|
-
);
|
|
37598
|
+
send2({
|
|
37599
|
+
data: Buffer.from(bytes).toString("base64"),
|
|
37600
|
+
kind: FILE_CHUNK_KIND,
|
|
37601
|
+
requestId: command.requestId,
|
|
37602
|
+
sequence,
|
|
37603
|
+
sessionId: command.sessionId
|
|
37604
|
+
});
|
|
37297
37605
|
sequence += 1;
|
|
37298
37606
|
}
|
|
37299
37607
|
const after = await stat7(target);
|
|
@@ -37301,399 +37609,12 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
37301
37609
|
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
|
|
37302
37610
|
throw new Error("The local file changed during transfer");
|
|
37303
37611
|
}
|
|
37304
|
-
send2(
|
|
37305
|
-
|
|
37306
|
-
|
|
37307
|
-
|
|
37308
|
-
sessionId: command.sessionId
|
|
37309
|
-
})
|
|
37310
|
-
);
|
|
37311
|
-
}
|
|
37312
|
-
|
|
37313
|
-
// src/artifacts/runtime-artifact-uploader.ts
|
|
37314
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
37315
|
-
|
|
37316
|
-
// ../mobius-sdk/src/errors.ts
|
|
37317
|
-
var MobiusError = class extends Error {
|
|
37318
|
-
code;
|
|
37319
|
-
constructor(code, message, options = {}) {
|
|
37320
|
-
super(message, options);
|
|
37321
|
-
this.code = code;
|
|
37322
|
-
this.name = "MobiusError";
|
|
37323
|
-
}
|
|
37324
|
-
};
|
|
37325
|
-
var MobiusProtocolError = class extends MobiusError {
|
|
37326
|
-
constructor(message, options = {}) {
|
|
37327
|
-
super("invalid_service_response", message, options);
|
|
37328
|
-
this.name = "MobiusProtocolError";
|
|
37329
|
-
}
|
|
37330
|
-
};
|
|
37331
|
-
var MobiusValidationError = class extends MobiusError {
|
|
37332
|
-
constructor(message, options = {}) {
|
|
37333
|
-
super("invalid_request", message, options);
|
|
37334
|
-
this.name = "MobiusValidationError";
|
|
37335
|
-
}
|
|
37336
|
-
};
|
|
37337
|
-
|
|
37338
|
-
// ../mobius-sdk/src/resources.ts
|
|
37339
|
-
var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
37340
|
-
function invalidResponse(message) {
|
|
37341
|
-
return new MobiusProtocolError(message);
|
|
37342
|
-
}
|
|
37343
|
-
function isRecord10(value) {
|
|
37344
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37345
|
-
}
|
|
37346
|
-
function record2(value, name) {
|
|
37347
|
-
if (!isRecord10(value)) {
|
|
37348
|
-
throw invalidResponse(`The service returned an invalid ${name}`);
|
|
37349
|
-
}
|
|
37350
|
-
return value;
|
|
37351
|
-
}
|
|
37352
|
-
function stringField(value, field, maximumLength = 85e5) {
|
|
37353
|
-
const candidate = value[field];
|
|
37354
|
-
if (typeof candidate !== "string" || candidate.length > maximumLength) {
|
|
37355
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
37356
|
-
}
|
|
37357
|
-
return candidate;
|
|
37358
|
-
}
|
|
37359
|
-
function identifierField(value, field) {
|
|
37360
|
-
const candidate = stringField(value, field, 128);
|
|
37361
|
-
if (!IDENTIFIER_PATTERN6.test(candidate)) {
|
|
37362
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
37363
|
-
}
|
|
37364
|
-
return candidate;
|
|
37365
|
-
}
|
|
37366
|
-
function integerField(value, field) {
|
|
37367
|
-
const candidate = value[field];
|
|
37368
|
-
if (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0) {
|
|
37369
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
37370
|
-
}
|
|
37371
|
-
return candidate;
|
|
37372
|
-
}
|
|
37373
|
-
function validateTimestamp(value, field) {
|
|
37374
|
-
if (Number.isNaN(Date.parse(value))) {
|
|
37375
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
37376
|
-
}
|
|
37377
|
-
return value;
|
|
37378
|
-
}
|
|
37379
|
-
var MobiusArtifactUploadRequest = class {
|
|
37380
|
-
byteLength;
|
|
37381
|
-
mediaType;
|
|
37382
|
-
name;
|
|
37383
|
-
sha256;
|
|
37384
|
-
constructor(name, mediaType, byteLength, sha256) {
|
|
37385
|
-
if (name.length < 1 || name.length > 500 || name.includes("\0") || mediaType.length < 1 || mediaType.length > 255 || mediaType.includes("\r") || mediaType.includes("\n") || !Number.isSafeInteger(byteLength) || byteLength < 1 || !/^[a-f0-9]{64}$/.test(sha256)) {
|
|
37386
|
-
throw new MobiusValidationError("The artifact upload request is invalid");
|
|
37387
|
-
}
|
|
37388
|
-
this.byteLength = byteLength;
|
|
37389
|
-
this.mediaType = mediaType;
|
|
37390
|
-
this.name = name;
|
|
37391
|
-
this.sha256 = sha256;
|
|
37392
|
-
}
|
|
37393
|
-
};
|
|
37394
|
-
var MobiusArtifact = class {
|
|
37395
|
-
artifactId;
|
|
37396
|
-
byteLength;
|
|
37397
|
-
createdAt;
|
|
37398
|
-
mediaType;
|
|
37399
|
-
name;
|
|
37400
|
-
sessionId;
|
|
37401
|
-
sha256;
|
|
37402
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt) {
|
|
37403
|
-
this.artifactId = artifactId;
|
|
37404
|
-
this.byteLength = byteLength;
|
|
37405
|
-
this.createdAt = createdAt;
|
|
37406
|
-
this.mediaType = mediaType;
|
|
37407
|
-
this.name = name;
|
|
37408
|
-
this.sessionId = sessionId;
|
|
37409
|
-
this.sha256 = sha256;
|
|
37410
|
-
}
|
|
37411
|
-
};
|
|
37412
|
-
var MobiusUploadingArtifact = class extends MobiusArtifact {
|
|
37413
|
-
expiresAt;
|
|
37414
|
-
state = "uploading";
|
|
37415
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiresAt) {
|
|
37416
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
37417
|
-
this.expiresAt = expiresAt;
|
|
37418
|
-
}
|
|
37419
|
-
};
|
|
37420
|
-
var MobiusArtifactUpload = class extends MobiusUploadingArtifact {
|
|
37421
|
-
uploadToken;
|
|
37422
|
-
constructor(artifact, uploadToken) {
|
|
37423
|
-
super(
|
|
37424
|
-
artifact.sessionId,
|
|
37425
|
-
artifact.artifactId,
|
|
37426
|
-
artifact.name,
|
|
37427
|
-
artifact.mediaType,
|
|
37428
|
-
artifact.byteLength,
|
|
37429
|
-
artifact.sha256,
|
|
37430
|
-
artifact.createdAt,
|
|
37431
|
-
artifact.expiresAt
|
|
37432
|
-
);
|
|
37433
|
-
this.uploadToken = uploadToken;
|
|
37434
|
-
}
|
|
37435
|
-
};
|
|
37436
|
-
var MobiusAvailableArtifact = class extends MobiusArtifact {
|
|
37437
|
-
availableAt;
|
|
37438
|
-
state = "available";
|
|
37439
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, availableAt) {
|
|
37440
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
37441
|
-
this.availableAt = availableAt;
|
|
37442
|
-
}
|
|
37443
|
-
};
|
|
37444
|
-
var MobiusExpiredArtifact = class extends MobiusArtifact {
|
|
37445
|
-
expiredAt;
|
|
37446
|
-
state = "expired";
|
|
37447
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiredAt) {
|
|
37448
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
37449
|
-
this.expiredAt = expiredAt;
|
|
37450
|
-
}
|
|
37451
|
-
};
|
|
37452
|
-
function artifactFields(value) {
|
|
37453
|
-
const sha256 = stringField(value, "sha256", 64);
|
|
37454
|
-
if (!/^[a-f0-9]{64}$/.test(sha256)) {
|
|
37455
|
-
throw invalidResponse("The service returned an invalid artifact digest");
|
|
37456
|
-
}
|
|
37457
|
-
return {
|
|
37458
|
-
artifactId: identifierField(value, "artifactId"),
|
|
37459
|
-
byteLength: integerField(value, "byteLength"),
|
|
37460
|
-
createdAt: validateTimestamp(stringField(value, "createdAt", 128), "createdAt"),
|
|
37461
|
-
mediaType: stringField(value, "mediaType", 255),
|
|
37462
|
-
name: stringField(value, "name", 500),
|
|
37463
|
-
sessionId: identifierField(value, "sessionId"),
|
|
37464
|
-
sha256
|
|
37465
|
-
};
|
|
37466
|
-
}
|
|
37467
|
-
function uploadingArtifact(value) {
|
|
37468
|
-
const fields = artifactFields(value);
|
|
37469
|
-
return new MobiusUploadingArtifact(
|
|
37470
|
-
fields.sessionId,
|
|
37471
|
-
fields.artifactId,
|
|
37472
|
-
fields.name,
|
|
37473
|
-
fields.mediaType,
|
|
37474
|
-
fields.byteLength,
|
|
37475
|
-
fields.sha256,
|
|
37476
|
-
fields.createdAt,
|
|
37477
|
-
validateTimestamp(stringField(value, "expiresAt", 128), "expiresAt")
|
|
37478
|
-
);
|
|
37479
|
-
}
|
|
37480
|
-
function decodeMobiusArtifactUpload(value) {
|
|
37481
|
-
const artifact = record2(value, "artifact upload authorization");
|
|
37482
|
-
return new MobiusArtifactUpload(uploadingArtifact(artifact), stringField(artifact, "uploadToken", 256));
|
|
37483
|
-
}
|
|
37484
|
-
function decodeMobiusArtifact(value) {
|
|
37485
|
-
const artifact = record2(value, "artifact");
|
|
37486
|
-
const state = stringField(artifact, "state", 32);
|
|
37487
|
-
if (state === "uploading") {
|
|
37488
|
-
return uploadingArtifact(artifact);
|
|
37489
|
-
}
|
|
37490
|
-
const fields = artifactFields(artifact);
|
|
37491
|
-
if (state === "available") {
|
|
37492
|
-
return new MobiusAvailableArtifact(
|
|
37493
|
-
fields.sessionId,
|
|
37494
|
-
fields.artifactId,
|
|
37495
|
-
fields.name,
|
|
37496
|
-
fields.mediaType,
|
|
37497
|
-
fields.byteLength,
|
|
37498
|
-
fields.sha256,
|
|
37499
|
-
fields.createdAt,
|
|
37500
|
-
validateTimestamp(stringField(artifact, "availableAt", 128), "availableAt")
|
|
37501
|
-
);
|
|
37502
|
-
}
|
|
37503
|
-
if (state === "expired") {
|
|
37504
|
-
return new MobiusExpiredArtifact(
|
|
37505
|
-
fields.sessionId,
|
|
37506
|
-
fields.artifactId,
|
|
37507
|
-
fields.name,
|
|
37508
|
-
fields.mediaType,
|
|
37509
|
-
fields.byteLength,
|
|
37510
|
-
fields.sha256,
|
|
37511
|
-
fields.createdAt,
|
|
37512
|
-
validateTimestamp(stringField(artifact, "expiredAt", 128), "expiredAt")
|
|
37513
|
-
);
|
|
37514
|
-
}
|
|
37515
|
-
throw invalidResponse("The service returned an invalid artifact state");
|
|
37516
|
-
}
|
|
37517
|
-
function decodeMobiusAvailableArtifact(value) {
|
|
37518
|
-
const artifact = decodeMobiusArtifact(value);
|
|
37519
|
-
if (!(artifact instanceof MobiusAvailableArtifact)) {
|
|
37520
|
-
throw invalidResponse("The service did not make the artifact available");
|
|
37521
|
-
}
|
|
37522
|
-
return artifact;
|
|
37523
|
-
}
|
|
37524
|
-
var MobiusRuntimePairingLifecycle = Object.freeze({
|
|
37525
|
-
Expired: "expired",
|
|
37526
|
-
Paired: "paired",
|
|
37527
|
-
Pending: "pending",
|
|
37528
|
-
Revoked: "revoked"
|
|
37529
|
-
});
|
|
37530
|
-
|
|
37531
|
-
// src/artifacts/runtime-artifact-uploader.ts
|
|
37532
|
-
import { fetch as fetch4 } from "undici";
|
|
37533
|
-
var UPLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
37534
|
-
var RuntimeArtifactUploadError = class extends Error {
|
|
37535
|
-
code;
|
|
37536
|
-
constructor(code, message, options = {}) {
|
|
37537
|
-
super(message, options);
|
|
37538
|
-
this.code = code;
|
|
37539
|
-
this.name = "RuntimeArtifactUploadError";
|
|
37540
|
-
}
|
|
37541
|
-
};
|
|
37542
|
-
var UploadedRuntimeArtifact = class {
|
|
37543
|
-
artifactId;
|
|
37544
|
-
byteLength;
|
|
37545
|
-
mimeType;
|
|
37546
|
-
name;
|
|
37547
|
-
sha256;
|
|
37548
|
-
constructor(artifactId, name, mimeType, byteLength, sha256) {
|
|
37549
|
-
this.artifactId = artifactId;
|
|
37550
|
-
this.byteLength = byteLength;
|
|
37551
|
-
this.mimeType = mimeType;
|
|
37552
|
-
this.name = name;
|
|
37553
|
-
this.sha256 = sha256;
|
|
37554
|
-
}
|
|
37555
|
-
};
|
|
37556
|
-
function channelOrigin(config2) {
|
|
37557
|
-
const url2 = new URL(config2.relayUrl);
|
|
37558
|
-
url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
|
|
37559
|
-
let channelPath = "";
|
|
37560
|
-
if (url2.pathname.endsWith("/daemon")) {
|
|
37561
|
-
channelPath = url2.pathname.slice(0, -"/daemon".length);
|
|
37562
|
-
} else {
|
|
37563
|
-
const runtimePath = `${MOBIUS_API_PREFIX}/v1/runtimes/connect`;
|
|
37564
|
-
if (!url2.pathname.endsWith("/v1/runtimes/connect") && !url2.pathname.endsWith(runtimePath)) {
|
|
37565
|
-
throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay artifact endpoint is invalid");
|
|
37566
|
-
}
|
|
37567
|
-
channelPath = `${url2.pathname.replace(/\/v1\/runtimes\/connect$/, "")}/channels/${encodeURIComponent(config2.channelId)}`;
|
|
37568
|
-
}
|
|
37569
|
-
url2.pathname = channelPath;
|
|
37570
|
-
url2.search = "";
|
|
37571
|
-
url2.hash = "";
|
|
37572
|
-
return url2;
|
|
37573
|
-
}
|
|
37574
|
-
function uploadError(code, message, cause) {
|
|
37575
|
-
return new RuntimeArtifactUploadError(code, message, cause === void 0 ? {} : { cause });
|
|
37576
|
-
}
|
|
37577
|
-
function translateSdkError(cause) {
|
|
37578
|
-
if (cause instanceof MobiusValidationError) {
|
|
37579
|
-
throw uploadError("artifact_upload_failed", cause.message, cause);
|
|
37580
|
-
}
|
|
37581
|
-
if (cause instanceof MobiusProtocolError) {
|
|
37582
|
-
throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
|
|
37583
|
-
}
|
|
37584
|
-
throw cause;
|
|
37585
|
-
}
|
|
37586
|
-
async function readJson(response) {
|
|
37587
|
-
try {
|
|
37588
|
-
return await response.json();
|
|
37589
|
-
} catch (cause) {
|
|
37590
|
-
throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
|
|
37591
|
-
}
|
|
37592
|
-
}
|
|
37593
|
-
async function readAuthorization(response) {
|
|
37594
|
-
try {
|
|
37595
|
-
return decodeMobiusArtifactUpload(await readJson(response));
|
|
37596
|
-
} catch (cause) {
|
|
37597
|
-
translateSdkError(cause);
|
|
37598
|
-
}
|
|
37599
|
-
}
|
|
37600
|
-
function sessionArtifactUrl(origin, sessionId, resourcePath) {
|
|
37601
|
-
return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
|
|
37602
|
-
}
|
|
37603
|
-
async function postLease(url2, headers, request, signal) {
|
|
37604
|
-
return await fetch4(url2, {
|
|
37605
|
-
dispatcher: environmentProxyDispatcher,
|
|
37606
|
-
headers: { ...headers, "content-type": "application/json" },
|
|
37607
|
-
method: "POST",
|
|
37608
|
-
body: JSON.stringify(request),
|
|
37609
|
-
signal
|
|
37610
|
-
});
|
|
37611
|
-
}
|
|
37612
|
-
async function putContent(url2, headers, authorization, bytes, signal) {
|
|
37613
|
-
return await fetch4(url2, {
|
|
37614
|
-
dispatcher: environmentProxyDispatcher,
|
|
37615
|
-
headers: {
|
|
37616
|
-
...headers,
|
|
37617
|
-
"content-type": authorization.mediaType,
|
|
37618
|
-
"x-mobius-upload-token": authorization.uploadToken
|
|
37619
|
-
},
|
|
37620
|
-
method: "PUT",
|
|
37621
|
-
body: bytes,
|
|
37622
|
-
signal
|
|
37612
|
+
send2({
|
|
37613
|
+
kind: FILE_END_KIND,
|
|
37614
|
+
requestId: command.requestId,
|
|
37615
|
+
sessionId: command.sessionId
|
|
37623
37616
|
});
|
|
37624
37617
|
}
|
|
37625
|
-
async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
37626
|
-
signal.throwIfAborted();
|
|
37627
|
-
let request;
|
|
37628
|
-
try {
|
|
37629
|
-
request = new MobiusArtifactUploadRequest(
|
|
37630
|
-
artifact.name,
|
|
37631
|
-
artifact.mimeType,
|
|
37632
|
-
artifact.bytes.byteLength,
|
|
37633
|
-
createHash3("sha256").update(artifact.bytes).digest("hex")
|
|
37634
|
-
);
|
|
37635
|
-
} catch (cause) {
|
|
37636
|
-
translateSdkError(cause);
|
|
37637
|
-
}
|
|
37638
|
-
const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
|
|
37639
|
-
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37640
|
-
const origin = channelOrigin(config2);
|
|
37641
|
-
const headers = runtimeAuthorization(config2.relayUrl);
|
|
37642
|
-
let created;
|
|
37643
|
-
try {
|
|
37644
|
-
created = await postLease(
|
|
37645
|
-
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
|
|
37646
|
-
headers,
|
|
37647
|
-
request,
|
|
37648
|
-
requestSignal
|
|
37649
|
-
);
|
|
37650
|
-
} catch (cause) {
|
|
37651
|
-
signal.throwIfAborted();
|
|
37652
|
-
throw uploadError(
|
|
37653
|
-
timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
|
|
37654
|
-
timeoutSignal.aborted ? "The artifact upload authorization timed out" : "The artifact upload could not start",
|
|
37655
|
-
cause
|
|
37656
|
-
);
|
|
37657
|
-
}
|
|
37658
|
-
if (!created.ok) {
|
|
37659
|
-
await created.body?.cancel();
|
|
37660
|
-
throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact upload");
|
|
37661
|
-
}
|
|
37662
|
-
const authorization = await readAuthorization(created);
|
|
37663
|
-
let uploaded;
|
|
37664
|
-
try {
|
|
37665
|
-
uploaded = await putContent(
|
|
37666
|
-
sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
|
|
37667
|
-
headers,
|
|
37668
|
-
authorization,
|
|
37669
|
-
artifact.bytes,
|
|
37670
|
-
requestSignal
|
|
37671
|
-
);
|
|
37672
|
-
} catch (cause) {
|
|
37673
|
-
signal.throwIfAborted();
|
|
37674
|
-
throw uploadError(
|
|
37675
|
-
timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
|
|
37676
|
-
timeoutSignal.aborted ? "The artifact upload timed out" : "The artifact content could not be uploaded",
|
|
37677
|
-
cause
|
|
37678
|
-
);
|
|
37679
|
-
}
|
|
37680
|
-
if (!uploaded.ok) {
|
|
37681
|
-
await uploaded.body?.cancel();
|
|
37682
|
-
throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact content");
|
|
37683
|
-
}
|
|
37684
|
-
try {
|
|
37685
|
-
const available = decodeMobiusAvailableArtifact(await readJson(uploaded));
|
|
37686
|
-
return new UploadedRuntimeArtifact(
|
|
37687
|
-
available.artifactId,
|
|
37688
|
-
available.name,
|
|
37689
|
-
available.mediaType,
|
|
37690
|
-
available.byteLength,
|
|
37691
|
-
available.sha256
|
|
37692
|
-
);
|
|
37693
|
-
} catch (cause) {
|
|
37694
|
-
translateSdkError(cause);
|
|
37695
|
-
}
|
|
37696
|
-
}
|
|
37697
37618
|
|
|
37698
37619
|
// src/authorization/local-authorization-error.ts
|
|
37699
37620
|
var LocalAuthorizationError = class extends Error {
|
|
@@ -38523,13 +38444,13 @@ var NativeSessionService = class {
|
|
|
38523
38444
|
};
|
|
38524
38445
|
|
|
38525
38446
|
// src/prompt-artifact-resolver.ts
|
|
38526
|
-
import { createHash as
|
|
38527
|
-
import { fetch as
|
|
38447
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
38448
|
+
import { fetch as fetch4 } from "undici";
|
|
38528
38449
|
var ARTIFACT_SCHEME = "mobius-artifact:";
|
|
38529
38450
|
var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
38530
38451
|
var MAX_AGENT_IMAGE_BASE64_LENGTH = 4e6;
|
|
38531
38452
|
var MAX_AGENT_RESOURCE_BYTE_LENGTH = 1e6;
|
|
38532
|
-
var
|
|
38453
|
+
var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
38533
38454
|
var PromptArtifactError = class extends Error {
|
|
38534
38455
|
code;
|
|
38535
38456
|
constructor(code, message, options = {}) {
|
|
@@ -38572,7 +38493,7 @@ function parseReference(resource) {
|
|
|
38572
38493
|
const encodedByteLength2 = url2.searchParams.get("byteLength") ?? "";
|
|
38573
38494
|
const sha256 = url2.searchParams.get("sha256") ?? "";
|
|
38574
38495
|
const byteLength = Number(encodedByteLength2);
|
|
38575
|
-
if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !
|
|
38496
|
+
if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !IDENTIFIER_PATTERN6.test(artifactId) || keys.length !== 2 || keys[0] !== "byteLength" || keys[1] !== "sha256" || !/^[1-9][0-9]*$/.test(encodedByteLength2) || !Number.isSafeInteger(byteLength) || !/^[a-f0-9]{64}$/.test(sha256)) {
|
|
38576
38497
|
throw new PromptArtifactError("artifact_reference_invalid", "The prompt artifact reference is invalid");
|
|
38577
38498
|
}
|
|
38578
38499
|
return new PromptArtifactReference(artifactId, byteLength, sha256, resource);
|
|
@@ -38638,7 +38559,7 @@ async function download(config2, command, reference, signal) {
|
|
|
38638
38559
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
38639
38560
|
let response;
|
|
38640
38561
|
try {
|
|
38641
|
-
response = await
|
|
38562
|
+
response = await fetch4(downloadUrl(config2, command, reference), {
|
|
38642
38563
|
dispatcher: environmentProxyDispatcher,
|
|
38643
38564
|
headers: {
|
|
38644
38565
|
accept: reference.resource.mimeType,
|
|
@@ -38662,7 +38583,7 @@ async function download(config2, command, reference, signal) {
|
|
|
38662
38583
|
);
|
|
38663
38584
|
}
|
|
38664
38585
|
const bytes = await responseBytes(response, reference.byteLength, requestSignal);
|
|
38665
|
-
if (
|
|
38586
|
+
if (createHash3("sha256").update(bytes).digest("hex") !== reference.sha256) {
|
|
38666
38587
|
throw new PromptArtifactError(
|
|
38667
38588
|
"artifact_integrity_failed",
|
|
38668
38589
|
"The prompt artifact failed integrity validation"
|
|
@@ -39152,12 +39073,10 @@ var RelayConnectionLiveness = class {
|
|
|
39152
39073
|
heartbeatId,
|
|
39153
39074
|
this.#timer.schedule(this.#handleTimeout, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS)
|
|
39154
39075
|
);
|
|
39155
|
-
const sent = this.#transport.send(
|
|
39156
|
-
|
|
39157
|
-
|
|
39158
|
-
|
|
39159
|
-
})
|
|
39160
|
-
);
|
|
39076
|
+
const sent = this.#transport.send({
|
|
39077
|
+
heartbeatId,
|
|
39078
|
+
kind: RUNTIME_HEARTBEAT_KIND
|
|
39079
|
+
});
|
|
39161
39080
|
if (!sent && this.#state instanceof AwaitingHeartbeatAckState && this.#state.heartbeatId === heartbeatId) {
|
|
39162
39081
|
this.#state.timeout.cancel();
|
|
39163
39082
|
this.#state = new FinishedRelayLivenessState();
|
|
@@ -39769,47 +39688,44 @@ var AGENT_TEXT_MAXIMUM_LENGTH = 1e5;
|
|
|
39769
39688
|
var ACTIVE_TURN_RECONCILIATION_TIMEOUT_MILLISECONDS = 2e4;
|
|
39770
39689
|
var ACTIVE_TURN_RECONCILIATION_CLOSE_CODE = 4009;
|
|
39771
39690
|
var DaemonAcpObserver = class {
|
|
39772
|
-
#config;
|
|
39773
39691
|
#record;
|
|
39774
|
-
constructor(
|
|
39775
|
-
this.#
|
|
39776
|
-
this.#record = record3;
|
|
39692
|
+
constructor(record2) {
|
|
39693
|
+
this.#record = record2;
|
|
39777
39694
|
}
|
|
39778
|
-
importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
39779
39695
|
onCommands = (event) => {
|
|
39780
|
-
this.#record(event.sessionId,
|
|
39696
|
+
this.#record(event.sessionId, event);
|
|
39781
39697
|
return Promise.resolve();
|
|
39782
39698
|
};
|
|
39783
39699
|
onConfig = (event) => {
|
|
39784
|
-
this.#record(event.sessionId,
|
|
39700
|
+
this.#record(event.sessionId, event);
|
|
39785
39701
|
return Promise.resolve();
|
|
39786
39702
|
};
|
|
39787
39703
|
onContent = (event) => {
|
|
39788
|
-
this.#record(event.sessionId,
|
|
39704
|
+
this.#record(event.sessionId, event);
|
|
39789
39705
|
return Promise.resolve();
|
|
39790
39706
|
};
|
|
39791
39707
|
onElicitation = (event) => {
|
|
39792
|
-
this.#record(event.sessionId,
|
|
39708
|
+
this.#record(event.sessionId, event);
|
|
39793
39709
|
return Promise.resolve();
|
|
39794
39710
|
};
|
|
39795
39711
|
onElicitationResolved = (event) => {
|
|
39796
|
-
this.#record(event.sessionId,
|
|
39712
|
+
this.#record(event.sessionId, event);
|
|
39797
39713
|
return Promise.resolve();
|
|
39798
39714
|
};
|
|
39799
39715
|
onInfo = (event) => {
|
|
39800
|
-
this.#record(event.sessionId,
|
|
39716
|
+
this.#record(event.sessionId, event);
|
|
39801
39717
|
return Promise.resolve();
|
|
39802
39718
|
};
|
|
39803
39719
|
onPermission = (event) => {
|
|
39804
|
-
this.#record(event.sessionId,
|
|
39720
|
+
this.#record(event.sessionId, event);
|
|
39805
39721
|
return Promise.resolve();
|
|
39806
39722
|
};
|
|
39807
39723
|
onPermissionResolved = (event) => {
|
|
39808
|
-
this.#record(event.sessionId,
|
|
39724
|
+
this.#record(event.sessionId, event);
|
|
39809
39725
|
return Promise.resolve();
|
|
39810
39726
|
};
|
|
39811
39727
|
onUsage = (event) => {
|
|
39812
|
-
this.#record(event.sessionId,
|
|
39728
|
+
this.#record(event.sessionId, event);
|
|
39813
39729
|
return Promise.resolve();
|
|
39814
39730
|
};
|
|
39815
39731
|
};
|
|
@@ -39858,60 +39774,45 @@ var DaemonInstallationObserver = class {
|
|
|
39858
39774
|
if (state instanceof RunningInstallation) {
|
|
39859
39775
|
if (!this.#started.has(state.requestId)) {
|
|
39860
39776
|
this.#started.add(state.requestId);
|
|
39861
|
-
this.#send(
|
|
39862
|
-
socket,
|
|
39863
|
-
encodeAgentInstallStartedEvent({
|
|
39864
|
-
agentId: state.agentId,
|
|
39865
|
-
kind: AGENT_INSTALL_STARTED_KIND,
|
|
39866
|
-
requestId: state.requestId
|
|
39867
|
-
})
|
|
39868
|
-
);
|
|
39869
|
-
}
|
|
39870
|
-
this.#send(
|
|
39871
|
-
socket,
|
|
39872
|
-
encodeAgentInstallProgressEvent({
|
|
39777
|
+
this.#send(socket, {
|
|
39873
39778
|
agentId: state.agentId,
|
|
39874
|
-
kind:
|
|
39875
|
-
requestId: state.requestId
|
|
39876
|
-
|
|
39877
|
-
|
|
39878
|
-
|
|
39779
|
+
kind: AGENT_INSTALL_STARTED_KIND,
|
|
39780
|
+
requestId: state.requestId
|
|
39781
|
+
});
|
|
39782
|
+
}
|
|
39783
|
+
this.#send(socket, {
|
|
39784
|
+
agentId: state.agentId,
|
|
39785
|
+
kind: AGENT_INSTALL_PROGRESS_KIND,
|
|
39786
|
+
requestId: state.requestId,
|
|
39787
|
+
stage: state.stage
|
|
39788
|
+
});
|
|
39879
39789
|
return Promise.resolve();
|
|
39880
39790
|
}
|
|
39881
39791
|
if (state instanceof SucceededInstallation) {
|
|
39882
|
-
this.#send(
|
|
39883
|
-
|
|
39884
|
-
|
|
39885
|
-
|
|
39886
|
-
|
|
39887
|
-
|
|
39888
|
-
requestId: state.requestId
|
|
39889
|
-
})
|
|
39890
|
-
);
|
|
39792
|
+
this.#send(socket, {
|
|
39793
|
+
agentId: state.agentId,
|
|
39794
|
+
authenticationMayBeRequired: state.authenticationMayBeRequired,
|
|
39795
|
+
kind: AGENT_INSTALL_COMPLETED_KIND,
|
|
39796
|
+
requestId: state.requestId
|
|
39797
|
+
});
|
|
39891
39798
|
return Promise.resolve();
|
|
39892
39799
|
}
|
|
39893
39800
|
if (state instanceof FailedInstallation) {
|
|
39894
|
-
this.#send(
|
|
39895
|
-
|
|
39896
|
-
|
|
39897
|
-
|
|
39898
|
-
|
|
39899
|
-
|
|
39900
|
-
|
|
39901
|
-
requestId: state.requestId
|
|
39902
|
-
})
|
|
39903
|
-
);
|
|
39801
|
+
this.#send(socket, {
|
|
39802
|
+
agentId: state.agentId,
|
|
39803
|
+
code: state.code,
|
|
39804
|
+
kind: AGENT_INSTALL_FAILED_KIND,
|
|
39805
|
+
message: state.message,
|
|
39806
|
+
requestId: state.requestId
|
|
39807
|
+
});
|
|
39904
39808
|
return Promise.resolve();
|
|
39905
39809
|
}
|
|
39906
39810
|
if (state instanceof CancelledInstallation) {
|
|
39907
|
-
this.#send(
|
|
39908
|
-
|
|
39909
|
-
|
|
39910
|
-
|
|
39911
|
-
|
|
39912
|
-
requestId: state.requestId
|
|
39913
|
-
})
|
|
39914
|
-
);
|
|
39811
|
+
this.#send(socket, {
|
|
39812
|
+
agentId: state.agentId,
|
|
39813
|
+
kind: AGENT_INSTALL_CANCELLED_KIND,
|
|
39814
|
+
requestId: state.requestId
|
|
39815
|
+
});
|
|
39915
39816
|
return Promise.resolve();
|
|
39916
39817
|
}
|
|
39917
39818
|
throw new Error("Unsupported Agent integration installation state");
|
|
@@ -40008,7 +39909,7 @@ async function reconcileActiveTurn(config2, turn, signal) {
|
|
|
40008
39909
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
40009
39910
|
let response;
|
|
40010
39911
|
try {
|
|
40011
|
-
response = await
|
|
39912
|
+
response = await fetch5(activeTurnReconciliationEndpoint(config2, turn), {
|
|
40012
39913
|
body: JSON.stringify({ outcome: { kind: "running" } }),
|
|
40013
39914
|
dispatcher: environmentProxyDispatcher,
|
|
40014
39915
|
headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
|
|
@@ -40041,7 +39942,7 @@ function send(socket, message) {
|
|
|
40041
39942
|
if (socket.readyState !== WebSocket2.OPEN) {
|
|
40042
39943
|
throw new Error("Relay connection is not open");
|
|
40043
39944
|
}
|
|
40044
|
-
socket.send(message);
|
|
39945
|
+
socket.send(encodeDaemonToServiceMessage(message));
|
|
40045
39946
|
}
|
|
40046
39947
|
function closeRelaySocket(socket, code, reason) {
|
|
40047
39948
|
try {
|
|
@@ -40075,7 +39976,7 @@ var ConnectedDaemonSessionEventState = class extends DaemonSessionEventConnectio
|
|
|
40075
39976
|
return false;
|
|
40076
39977
|
}
|
|
40077
39978
|
try {
|
|
40078
|
-
this.#socket.send(message);
|
|
39979
|
+
this.#socket.send(encodeDaemonToServiceMessage(message));
|
|
40079
39980
|
return true;
|
|
40080
39981
|
} catch {
|
|
40081
39982
|
return false;
|
|
@@ -40119,17 +40020,17 @@ var DaemonSessionEventPublisher = class {
|
|
|
40119
40020
|
this.#connection = this.#connection.disconnect(socket);
|
|
40120
40021
|
this.#clearInFlight();
|
|
40121
40022
|
};
|
|
40122
|
-
recordAttempt = (sessionId,
|
|
40123
|
-
const
|
|
40124
|
-
if (kind === SESSION_COMPLETED_KIND || kind === SESSION_FAILED_KIND) {
|
|
40125
|
-
this.#outbox.enqueueCritical(sessionId,
|
|
40023
|
+
recordAttempt = (sessionId, event, attemptId) => {
|
|
40024
|
+
const encoded = encodeRecordedSessionEvent(event);
|
|
40025
|
+
if (event.kind === SESSION_COMPLETED_KIND || event.kind === SESSION_FAILED_KIND) {
|
|
40026
|
+
this.#outbox.enqueueCritical(sessionId, encoded, attemptId);
|
|
40126
40027
|
} else {
|
|
40127
|
-
this.#outbox.enqueue(sessionId,
|
|
40028
|
+
this.#outbox.enqueue(sessionId, encoded, attemptId);
|
|
40128
40029
|
}
|
|
40129
40030
|
this.#publishNextBatch();
|
|
40130
40031
|
};
|
|
40131
|
-
recordRuntime = (sessionId,
|
|
40132
|
-
this.#outbox.enqueue(sessionId,
|
|
40032
|
+
recordRuntime = (sessionId, event) => {
|
|
40033
|
+
this.#outbox.enqueue(sessionId, encodeRecordedSessionEvent(event));
|
|
40133
40034
|
this.#publishNextBatch();
|
|
40134
40035
|
};
|
|
40135
40036
|
acknowledge = (acknowledgement) => {
|
|
@@ -40196,7 +40097,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
40196
40097
|
if (this.#inFlightBytes + byteLength > SESSION_EVENT_REPLAY_BYTE_LIMIT) {
|
|
40197
40098
|
continue;
|
|
40198
40099
|
}
|
|
40199
|
-
if (!this.#connection.send(
|
|
40100
|
+
if (!this.#connection.send(envelope2)) {
|
|
40200
40101
|
this.#clearInFlight();
|
|
40201
40102
|
return;
|
|
40202
40103
|
}
|
|
@@ -40290,8 +40191,8 @@ var CoalescingDaemonActivityPublisher = class {
|
|
|
40290
40191
|
}
|
|
40291
40192
|
};
|
|
40292
40193
|
};
|
|
40293
|
-
function
|
|
40294
|
-
return
|
|
40194
|
+
function daemonActivity(command, activity) {
|
|
40195
|
+
return {
|
|
40295
40196
|
activityId: activity.activityId,
|
|
40296
40197
|
activityType: activity.activityType,
|
|
40297
40198
|
commandId: command.commandId,
|
|
@@ -40307,18 +40208,18 @@ function encodeDaemonActivity(command, activity) {
|
|
|
40307
40208
|
status: activity.status,
|
|
40308
40209
|
title: activity.title,
|
|
40309
40210
|
toolKind: activity.toolKind
|
|
40310
|
-
}
|
|
40211
|
+
};
|
|
40311
40212
|
}
|
|
40312
40213
|
function reportFailure(publisher, command, code, message, attemptId) {
|
|
40313
40214
|
publisher.recordAttempt(
|
|
40314
40215
|
command.sessionId,
|
|
40315
|
-
|
|
40216
|
+
{
|
|
40316
40217
|
code,
|
|
40317
40218
|
commandId: command.commandId,
|
|
40318
40219
|
kind: SESSION_FAILED_KIND,
|
|
40319
40220
|
message,
|
|
40320
40221
|
sessionId: command.sessionId
|
|
40321
|
-
}
|
|
40222
|
+
},
|
|
40322
40223
|
attemptId
|
|
40323
40224
|
);
|
|
40324
40225
|
}
|
|
@@ -40338,17 +40239,14 @@ function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTi
|
|
|
40338
40239
|
if (socket.readyState !== WebSocket2.OPEN) {
|
|
40339
40240
|
return;
|
|
40340
40241
|
}
|
|
40341
|
-
send(
|
|
40342
|
-
|
|
40343
|
-
|
|
40344
|
-
|
|
40345
|
-
|
|
40346
|
-
|
|
40347
|
-
|
|
40348
|
-
|
|
40349
|
-
sessionId
|
|
40350
|
-
})
|
|
40351
|
-
);
|
|
40242
|
+
send(socket, {
|
|
40243
|
+
code: operationErrorCode(error62),
|
|
40244
|
+
kind: "session.operation.failed",
|
|
40245
|
+
message: operationErrorMessage(error62),
|
|
40246
|
+
requestId,
|
|
40247
|
+
...runtimeTimings.length === 0 ? {} : { runtimeTimings },
|
|
40248
|
+
sessionId
|
|
40249
|
+
});
|
|
40352
40250
|
}
|
|
40353
40251
|
async function resolveSessionDirectories(directories, bindingId, directoryId2, additionalDirectoryIds, signal) {
|
|
40354
40252
|
const cwd = await directories.resolve(bindingId, directoryId2, signal);
|
|
@@ -40521,7 +40419,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
40521
40419
|
resolution: modelEffort.resolution,
|
|
40522
40420
|
valuesByModel: {}
|
|
40523
40421
|
};
|
|
40524
|
-
return
|
|
40422
|
+
return createHash4("sha256").update(
|
|
40525
40423
|
JSON.stringify({
|
|
40526
40424
|
adapterVersion: agent.adapterVersion,
|
|
40527
40425
|
agentId: agent.id,
|
|
@@ -40540,18 +40438,15 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
|
|
|
40540
40438
|
event: "workspace_list_authorized",
|
|
40541
40439
|
sessionId: "workspace-browser"
|
|
40542
40440
|
});
|
|
40543
|
-
send(
|
|
40544
|
-
|
|
40545
|
-
|
|
40546
|
-
|
|
40547
|
-
|
|
40548
|
-
|
|
40549
|
-
|
|
40550
|
-
|
|
40551
|
-
|
|
40552
|
-
requestId: command.requestId
|
|
40553
|
-
})
|
|
40554
|
-
);
|
|
40441
|
+
send(socket, {
|
|
40442
|
+
bindingId: command.bindingId,
|
|
40443
|
+
directoryId: listing.directoryId,
|
|
40444
|
+
directoryLabel: listing.directoryLabel,
|
|
40445
|
+
entries: listing.entries,
|
|
40446
|
+
kind: "workspace.entries",
|
|
40447
|
+
parentDirectoryId: listing.parentDirectoryId,
|
|
40448
|
+
requestId: command.requestId
|
|
40449
|
+
});
|
|
40555
40450
|
} catch (error62) {
|
|
40556
40451
|
reportOperationFailure(socket, command.requestId, "", error62);
|
|
40557
40452
|
}
|
|
@@ -40606,15 +40501,12 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
40606
40501
|
event: "session_configured",
|
|
40607
40502
|
sessionId: command.sessionId
|
|
40608
40503
|
});
|
|
40609
|
-
publisher.recordRuntime(
|
|
40610
|
-
|
|
40611
|
-
|
|
40612
|
-
|
|
40613
|
-
|
|
40614
|
-
|
|
40615
|
-
sessionId: command.sessionId
|
|
40616
|
-
})
|
|
40617
|
-
);
|
|
40504
|
+
publisher.recordRuntime(command.sessionId, {
|
|
40505
|
+
configOptions,
|
|
40506
|
+
kind: "session.config.updated",
|
|
40507
|
+
requestId: command.requestId,
|
|
40508
|
+
sessionId: command.sessionId
|
|
40509
|
+
});
|
|
40618
40510
|
}
|
|
40619
40511
|
const event = {
|
|
40620
40512
|
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
@@ -40633,17 +40525,14 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
40633
40525
|
runtimeTimings: metrics.snapshot()
|
|
40634
40526
|
};
|
|
40635
40527
|
metrics.measureSync("readiness-commit", () => {
|
|
40636
|
-
publisher.recordRuntime(command.sessionId,
|
|
40528
|
+
publisher.recordRuntime(command.sessionId, event);
|
|
40637
40529
|
});
|
|
40638
40530
|
return event;
|
|
40639
40531
|
});
|
|
40640
|
-
send(
|
|
40641
|
-
|
|
40642
|
-
|
|
40643
|
-
|
|
40644
|
-
runtimeTimings: metrics.snapshot()
|
|
40645
|
-
})
|
|
40646
|
-
);
|
|
40532
|
+
send(socket, {
|
|
40533
|
+
...readyEvent,
|
|
40534
|
+
runtimeTimings: metrics.snapshot()
|
|
40535
|
+
});
|
|
40647
40536
|
} catch (error62) {
|
|
40648
40537
|
audit.record({
|
|
40649
40538
|
commandId: command.requestId,
|
|
@@ -40683,15 +40572,12 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
40683
40572
|
event: "session_configured",
|
|
40684
40573
|
sessionId: command.sessionId
|
|
40685
40574
|
});
|
|
40686
|
-
publisher.recordRuntime(
|
|
40687
|
-
|
|
40688
|
-
|
|
40689
|
-
|
|
40690
|
-
|
|
40691
|
-
|
|
40692
|
-
sessionId: command.sessionId
|
|
40693
|
-
})
|
|
40694
|
-
);
|
|
40575
|
+
publisher.recordRuntime(command.sessionId, {
|
|
40576
|
+
configOptions,
|
|
40577
|
+
kind: "session.config.updated",
|
|
40578
|
+
requestId: command.requestId,
|
|
40579
|
+
sessionId: command.sessionId
|
|
40580
|
+
});
|
|
40695
40581
|
} catch (error62) {
|
|
40696
40582
|
if (signal.aborted) {
|
|
40697
40583
|
signal.throwIfAborted();
|
|
@@ -40701,20 +40587,20 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
40701
40587
|
}
|
|
40702
40588
|
async function executePrompt(outbox, publisher, command, config2, directories, audit, sessions, attemptId, activateAttempt, timer, signal) {
|
|
40703
40589
|
const activities = new CoalescingDaemonActivityPublisher(timer, (activity) => {
|
|
40704
|
-
publisher.recordAttempt(command.sessionId,
|
|
40590
|
+
publisher.recordAttempt(command.sessionId, daemonActivity(command, activity), attemptId);
|
|
40705
40591
|
});
|
|
40706
40592
|
const text3 = new CoalescingTextPublisher(
|
|
40707
40593
|
timer,
|
|
40708
40594
|
(messageId, delta) => {
|
|
40709
40595
|
publisher.recordAttempt(
|
|
40710
40596
|
command.sessionId,
|
|
40711
|
-
|
|
40597
|
+
{
|
|
40712
40598
|
commandId: command.commandId,
|
|
40713
40599
|
kind: AGENT_MESSAGE_DELTA_KIND,
|
|
40714
40600
|
messageId,
|
|
40715
40601
|
sessionId: command.sessionId,
|
|
40716
40602
|
text: delta
|
|
40717
|
-
}
|
|
40603
|
+
},
|
|
40718
40604
|
attemptId
|
|
40719
40605
|
);
|
|
40720
40606
|
},
|
|
@@ -40773,12 +40659,12 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40773
40659
|
outbox.transitionExecution(command.commandId, "running");
|
|
40774
40660
|
publisher.recordAttempt(
|
|
40775
40661
|
command.sessionId,
|
|
40776
|
-
|
|
40662
|
+
{
|
|
40777
40663
|
commandId: command.commandId,
|
|
40778
40664
|
kind: SESSION_STARTED_KIND,
|
|
40779
40665
|
attemptId,
|
|
40780
40666
|
sessionId: command.sessionId
|
|
40781
|
-
}
|
|
40667
|
+
},
|
|
40782
40668
|
attemptId
|
|
40783
40669
|
);
|
|
40784
40670
|
activateAttempt();
|
|
@@ -40823,12 +40709,12 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40823
40709
|
activities.flush();
|
|
40824
40710
|
publisher.recordAttempt(
|
|
40825
40711
|
command.sessionId,
|
|
40826
|
-
|
|
40712
|
+
{
|
|
40827
40713
|
commandId: command.commandId,
|
|
40828
40714
|
kind: SESSION_COMPLETED_KIND,
|
|
40829
40715
|
sessionId: command.sessionId,
|
|
40830
40716
|
stopReason
|
|
40831
|
-
}
|
|
40717
|
+
},
|
|
40832
40718
|
attemptId
|
|
40833
40719
|
);
|
|
40834
40720
|
outbox.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
@@ -41252,9 +41138,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41252
41138
|
}
|
|
41253
41139
|
};
|
|
41254
41140
|
const processDeliveredPayload = async (delivery) => {
|
|
41255
|
-
const
|
|
41141
|
+
const message = decodeServiceToDaemonMessage(delivery.payload);
|
|
41142
|
+
const kind = message.kind;
|
|
41256
41143
|
if (kind === SESSION_CANCEL_KIND) {
|
|
41257
|
-
const cancellation =
|
|
41144
|
+
const cancellation = message;
|
|
41258
41145
|
if (cancellation.sessionId !== delivery.sessionId) {
|
|
41259
41146
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41260
41147
|
}
|
|
@@ -41271,7 +41158,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41271
41158
|
return;
|
|
41272
41159
|
}
|
|
41273
41160
|
if (kind === SESSION_CONFIGURE_KIND) {
|
|
41274
|
-
const command =
|
|
41161
|
+
const command = message;
|
|
41275
41162
|
if (command.sessionId !== delivery.sessionId) {
|
|
41276
41163
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41277
41164
|
}
|
|
@@ -41288,7 +41175,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41288
41175
|
return;
|
|
41289
41176
|
}
|
|
41290
41177
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
41291
|
-
const command =
|
|
41178
|
+
const command = message;
|
|
41292
41179
|
if (command.sessionId !== delivery.sessionId) {
|
|
41293
41180
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41294
41181
|
}
|
|
@@ -41305,7 +41192,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41305
41192
|
return;
|
|
41306
41193
|
}
|
|
41307
41194
|
if (kind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
41308
|
-
const command =
|
|
41195
|
+
const command = message;
|
|
41309
41196
|
if (command.sessionId !== delivery.sessionId) {
|
|
41310
41197
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41311
41198
|
}
|
|
@@ -41322,7 +41209,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41322
41209
|
return;
|
|
41323
41210
|
}
|
|
41324
41211
|
if (kind === SESSION_PROMPT_KIND) {
|
|
41325
|
-
const command =
|
|
41212
|
+
const command = message;
|
|
41326
41213
|
await processDeliveredPrompt(
|
|
41327
41214
|
delivery,
|
|
41328
41215
|
command,
|
|
@@ -41366,18 +41253,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41366
41253
|
}).finally(() => processingDeliveryIds.delete(delivery.deliveryId));
|
|
41367
41254
|
};
|
|
41368
41255
|
const receiveRuntimeDelivery = (delivery) => {
|
|
41369
|
-
const
|
|
41256
|
+
const payload = decodeServiceToDaemonMessage(delivery.payload);
|
|
41257
|
+
const payloadKind = payload.kind;
|
|
41370
41258
|
let payloadSessionId = "";
|
|
41371
41259
|
if (payloadKind === SESSION_CANCEL_KIND) {
|
|
41372
|
-
payloadSessionId =
|
|
41260
|
+
payloadSessionId = payload.sessionId;
|
|
41373
41261
|
} else if (payloadKind === SESSION_CONFIGURE_KIND) {
|
|
41374
|
-
payloadSessionId =
|
|
41262
|
+
payloadSessionId = payload.sessionId;
|
|
41375
41263
|
} else if (payloadKind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
41376
|
-
payloadSessionId =
|
|
41264
|
+
payloadSessionId = payload.sessionId;
|
|
41377
41265
|
} else if (payloadKind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
41378
|
-
payloadSessionId =
|
|
41266
|
+
payloadSessionId = payload.sessionId;
|
|
41379
41267
|
} else if (payloadKind === SESSION_PROMPT_KIND) {
|
|
41380
|
-
payloadSessionId =
|
|
41268
|
+
payloadSessionId = payload.sessionId;
|
|
41381
41269
|
} else {
|
|
41382
41270
|
throw new Error("Runtime delivery contains an unsupported protocol message");
|
|
41383
41271
|
}
|
|
@@ -41385,14 +41273,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41385
41273
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41386
41274
|
}
|
|
41387
41275
|
const stored = outbox.claimRuntimeDelivery(delivery);
|
|
41388
|
-
send(
|
|
41389
|
-
|
|
41390
|
-
|
|
41391
|
-
|
|
41392
|
-
|
|
41393
|
-
sessionId: delivery.sessionId
|
|
41394
|
-
})
|
|
41395
|
-
);
|
|
41276
|
+
send(socket, {
|
|
41277
|
+
deliveryId: delivery.deliveryId,
|
|
41278
|
+
kind: RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
41279
|
+
sessionId: delivery.sessionId
|
|
41280
|
+
});
|
|
41396
41281
|
processRuntimeDelivery(delivery, stored.state);
|
|
41397
41282
|
};
|
|
41398
41283
|
const resumeRuntimeDeliveries = () => {
|
|
@@ -41404,14 +41289,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41404
41289
|
sessionId: stored.sessionId
|
|
41405
41290
|
};
|
|
41406
41291
|
if (stored.state !== "relay_committed") {
|
|
41407
|
-
send(
|
|
41408
|
-
|
|
41409
|
-
|
|
41410
|
-
|
|
41411
|
-
|
|
41412
|
-
sessionId: stored.sessionId
|
|
41413
|
-
})
|
|
41414
|
-
);
|
|
41292
|
+
send(socket, {
|
|
41293
|
+
deliveryId: stored.deliveryId,
|
|
41294
|
+
kind: RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
41295
|
+
sessionId: stored.sessionId
|
|
41296
|
+
});
|
|
41415
41297
|
}
|
|
41416
41298
|
processRuntimeDelivery(delivery, stored.state);
|
|
41417
41299
|
}
|
|
@@ -41470,28 +41352,29 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41470
41352
|
return;
|
|
41471
41353
|
}
|
|
41472
41354
|
try {
|
|
41473
|
-
const
|
|
41355
|
+
const message = decodeServiceToDaemonMessage(encoded);
|
|
41356
|
+
const kind = message.kind;
|
|
41474
41357
|
if (kind === RUNTIME_DELIVERY_COMMITTED_KIND) {
|
|
41475
|
-
const committed =
|
|
41358
|
+
const committed = message;
|
|
41476
41359
|
if (!outbox.markRuntimeDeliveryCommitted(committed.deliveryId, committed.sessionId)) {
|
|
41477
41360
|
console.warn("Mobius daemon ignored confirmation for an unknown Runtime delivery");
|
|
41478
41361
|
}
|
|
41479
41362
|
return;
|
|
41480
41363
|
}
|
|
41481
41364
|
if (kind === RUNTIME_DELIVERY_KIND) {
|
|
41482
|
-
receiveRuntimeDelivery(
|
|
41365
|
+
receiveRuntimeDelivery(message);
|
|
41483
41366
|
return;
|
|
41484
41367
|
}
|
|
41485
41368
|
if (kind === SESSION_EVENT_ACK_KIND) {
|
|
41486
|
-
publisher.acknowledge(
|
|
41369
|
+
publisher.acknowledge(message);
|
|
41487
41370
|
return;
|
|
41488
41371
|
}
|
|
41489
41372
|
if (kind === SESSION_EVENT_DEFERRED_KIND) {
|
|
41490
|
-
publisher.defer(
|
|
41373
|
+
publisher.defer(message);
|
|
41491
41374
|
return;
|
|
41492
41375
|
}
|
|
41493
41376
|
if (kind === SESSION_EVENT_REJECTED_KIND) {
|
|
41494
|
-
const rejection =
|
|
41377
|
+
const rejection = message;
|
|
41495
41378
|
if (publisher.quarantine(rejection)) {
|
|
41496
41379
|
audit.record({
|
|
41497
41380
|
commandId: rejection.eventId,
|
|
@@ -41505,7 +41388,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41505
41388
|
return;
|
|
41506
41389
|
}
|
|
41507
41390
|
if (kind === NATIVE_SESSION_CANCEL_KIND) {
|
|
41508
|
-
const command2 =
|
|
41391
|
+
const command2 = message;
|
|
41509
41392
|
const pending = nativeRequests.get(command2.requestId);
|
|
41510
41393
|
if (pending?.sessionId === command2.sessionId) {
|
|
41511
41394
|
pending.controller.abort(
|
|
@@ -41519,35 +41402,29 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41519
41402
|
return;
|
|
41520
41403
|
}
|
|
41521
41404
|
if (kind === AGENT_SETTINGS_DISCOVER_KIND) {
|
|
41522
|
-
const command2 =
|
|
41405
|
+
const command2 = message;
|
|
41523
41406
|
const existing = [...agentSettingsDiscoveries.values()].find(
|
|
41524
41407
|
(request) => request.agentId === command2.agentId && !request.controller.signal.aborted
|
|
41525
41408
|
);
|
|
41526
41409
|
if (agentSettingsDiscoveries.has(command2.requestId) || existing !== void 0) {
|
|
41527
41410
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41528
|
-
send(
|
|
41529
|
-
|
|
41530
|
-
|
|
41531
|
-
|
|
41532
|
-
|
|
41533
|
-
|
|
41534
|
-
requestId: command2.requestId
|
|
41535
|
-
})
|
|
41536
|
-
);
|
|
41411
|
+
send(socket, {
|
|
41412
|
+
code: "agent_settings_discovery_busy",
|
|
41413
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
41414
|
+
message: "Another settings discovery is already running for this Agent",
|
|
41415
|
+
requestId: command2.requestId
|
|
41416
|
+
});
|
|
41537
41417
|
}
|
|
41538
41418
|
return;
|
|
41539
41419
|
}
|
|
41540
41420
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
41541
41421
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41542
|
-
send(
|
|
41543
|
-
|
|
41544
|
-
|
|
41545
|
-
|
|
41546
|
-
|
|
41547
|
-
|
|
41548
|
-
requestId: command2.requestId
|
|
41549
|
-
})
|
|
41550
|
-
);
|
|
41422
|
+
send(socket, {
|
|
41423
|
+
code: "agent_settings_discovery_busy",
|
|
41424
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
41425
|
+
message: "Too many Agent settings discoveries are running",
|
|
41426
|
+
requestId: command2.requestId
|
|
41427
|
+
});
|
|
41551
41428
|
}
|
|
41552
41429
|
return;
|
|
41553
41430
|
}
|
|
@@ -41579,7 +41456,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41579
41456
|
sessionId: `agent-settings:${command2.agentId}`
|
|
41580
41457
|
});
|
|
41581
41458
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41582
|
-
send(socket,
|
|
41459
|
+
send(socket, result);
|
|
41583
41460
|
}
|
|
41584
41461
|
} catch (error62) {
|
|
41585
41462
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -41594,15 +41471,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41594
41471
|
sessionId: `agent-settings:${command2.agentId}`
|
|
41595
41472
|
});
|
|
41596
41473
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41597
|
-
send(
|
|
41598
|
-
|
|
41599
|
-
|
|
41600
|
-
|
|
41601
|
-
|
|
41602
|
-
|
|
41603
|
-
requestId: command2.requestId
|
|
41604
|
-
})
|
|
41605
|
-
);
|
|
41474
|
+
send(socket, {
|
|
41475
|
+
code: operationErrorCode(failure2),
|
|
41476
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
41477
|
+
message: operationErrorMessage(failure2),
|
|
41478
|
+
requestId: command2.requestId
|
|
41479
|
+
});
|
|
41606
41480
|
}
|
|
41607
41481
|
} finally {
|
|
41608
41482
|
timeout.cancel();
|
|
@@ -41617,18 +41491,15 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41617
41491
|
return;
|
|
41618
41492
|
}
|
|
41619
41493
|
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
41620
|
-
const command2 =
|
|
41494
|
+
const command2 = message;
|
|
41621
41495
|
if (agentCatalogRefreshes.has(command2.requestId) || agentCatalogRefreshes.size > 0) {
|
|
41622
41496
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41623
|
-
send(
|
|
41624
|
-
|
|
41625
|
-
|
|
41626
|
-
|
|
41627
|
-
|
|
41628
|
-
|
|
41629
|
-
requestId: command2.requestId
|
|
41630
|
-
})
|
|
41631
|
-
);
|
|
41497
|
+
send(socket, {
|
|
41498
|
+
code: "agent_catalog_refresh_busy",
|
|
41499
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
41500
|
+
message: "Another local Agent catalog refresh is already running",
|
|
41501
|
+
requestId: command2.requestId
|
|
41502
|
+
});
|
|
41632
41503
|
}
|
|
41633
41504
|
return;
|
|
41634
41505
|
}
|
|
@@ -41653,13 +41524,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41653
41524
|
sessionId: "agent-catalog"
|
|
41654
41525
|
});
|
|
41655
41526
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41656
|
-
send(
|
|
41657
|
-
|
|
41658
|
-
|
|
41659
|
-
|
|
41660
|
-
requestId: command2.requestId
|
|
41661
|
-
})
|
|
41662
|
-
);
|
|
41527
|
+
send(socket, {
|
|
41528
|
+
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
41529
|
+
requestId: command2.requestId
|
|
41530
|
+
});
|
|
41663
41531
|
}
|
|
41664
41532
|
} catch (error62) {
|
|
41665
41533
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -41674,15 +41542,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41674
41542
|
sessionId: "agent-catalog"
|
|
41675
41543
|
});
|
|
41676
41544
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41677
|
-
send(
|
|
41678
|
-
|
|
41679
|
-
|
|
41680
|
-
|
|
41681
|
-
|
|
41682
|
-
|
|
41683
|
-
requestId: command2.requestId
|
|
41684
|
-
})
|
|
41685
|
-
);
|
|
41545
|
+
send(socket, {
|
|
41546
|
+
code: operationErrorCode(failure2),
|
|
41547
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
41548
|
+
message: operationErrorMessage(failure2),
|
|
41549
|
+
requestId: command2.requestId
|
|
41550
|
+
});
|
|
41686
41551
|
}
|
|
41687
41552
|
} finally {
|
|
41688
41553
|
timeout.cancel();
|
|
@@ -41693,7 +41558,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41693
41558
|
return;
|
|
41694
41559
|
}
|
|
41695
41560
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
41696
|
-
const command2 =
|
|
41561
|
+
const command2 = message;
|
|
41697
41562
|
const previous2 = [...nativeRequests.values()].filter(
|
|
41698
41563
|
(request) => request.agentId === command2.agentId
|
|
41699
41564
|
);
|
|
@@ -41746,7 +41611,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41746
41611
|
operationSignal.throwIfAborted();
|
|
41747
41612
|
const result = await nativeSessions.execute(command2, operationSignal);
|
|
41748
41613
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41749
|
-
send(socket,
|
|
41614
|
+
send(socket, result);
|
|
41750
41615
|
}
|
|
41751
41616
|
} catch (error62) {
|
|
41752
41617
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -41775,7 +41640,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41775
41640
|
return;
|
|
41776
41641
|
}
|
|
41777
41642
|
if (kind === NATIVE_SESSION_TURN_FORK_KIND) {
|
|
41778
|
-
const command2 =
|
|
41643
|
+
const command2 = message;
|
|
41779
41644
|
const previous2 = [...nativeRequests.values()].filter(
|
|
41780
41645
|
(request) => request.agentId === command2.agentId
|
|
41781
41646
|
);
|
|
@@ -41826,7 +41691,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41826
41691
|
operationSignal.throwIfAborted();
|
|
41827
41692
|
const result = await nativeSessions.executeTurnFork(command2, operationSignal);
|
|
41828
41693
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41829
|
-
send(socket,
|
|
41694
|
+
send(socket, result);
|
|
41830
41695
|
}
|
|
41831
41696
|
} catch (error62) {
|
|
41832
41697
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -41855,39 +41720,35 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41855
41720
|
return;
|
|
41856
41721
|
}
|
|
41857
41722
|
if (kind === RUNTIME_LIVENESS_READY_KIND) {
|
|
41858
|
-
decodeRuntimeLivenessReadyEvent(encoded);
|
|
41859
41723
|
connectionLiveness.start();
|
|
41860
41724
|
return;
|
|
41861
41725
|
}
|
|
41862
41726
|
if (kind === RUNTIME_HEARTBEAT_ACK_KIND) {
|
|
41863
|
-
connectionLiveness.acknowledge(
|
|
41727
|
+
connectionLiveness.acknowledge(message);
|
|
41864
41728
|
return;
|
|
41865
41729
|
}
|
|
41866
41730
|
if (kind === FILE_READ_KIND) {
|
|
41867
|
-
const command2 =
|
|
41731
|
+
const command2 = message;
|
|
41868
41732
|
void streamLocalFile(
|
|
41869
41733
|
command2,
|
|
41870
|
-
(
|
|
41734
|
+
(message2) => send(socket, message2),
|
|
41871
41735
|
connectionController.signal
|
|
41872
41736
|
).catch((error62) => {
|
|
41873
41737
|
if (socket.readyState !== WebSocket2.OPEN || connectionController.signal.aborted) {
|
|
41874
41738
|
return;
|
|
41875
41739
|
}
|
|
41876
|
-
send(
|
|
41877
|
-
|
|
41878
|
-
|
|
41879
|
-
|
|
41880
|
-
|
|
41881
|
-
|
|
41882
|
-
|
|
41883
|
-
sessionId: command2.sessionId
|
|
41884
|
-
})
|
|
41885
|
-
);
|
|
41740
|
+
send(socket, {
|
|
41741
|
+
code: "file_unavailable",
|
|
41742
|
+
kind: FILE_FAILED_KIND,
|
|
41743
|
+
message: error62 instanceof Error ? error62.message : "The local file is unavailable",
|
|
41744
|
+
requestId: command2.requestId,
|
|
41745
|
+
sessionId: command2.sessionId
|
|
41746
|
+
});
|
|
41886
41747
|
});
|
|
41887
41748
|
return;
|
|
41888
41749
|
}
|
|
41889
41750
|
if (kind === SESSION_CANCEL_KIND) {
|
|
41890
|
-
const cancellation =
|
|
41751
|
+
const cancellation = message;
|
|
41891
41752
|
const turn2 = activeTurns.get(cancellation.commandId);
|
|
41892
41753
|
if (turn2 === void 0 || !turn2.matches(cancellation)) {
|
|
41893
41754
|
console.warn("Mobius daemon ignored cancellation for an inactive turn");
|
|
@@ -41907,12 +41768,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41907
41768
|
return;
|
|
41908
41769
|
}
|
|
41909
41770
|
if (kind === WORKSPACE_LIST_KIND) {
|
|
41910
|
-
const command2 =
|
|
41771
|
+
const command2 = message;
|
|
41911
41772
|
void executeWorkspaceList(socket, command2, directories, audit, connectionController.signal);
|
|
41912
41773
|
return;
|
|
41913
41774
|
}
|
|
41914
41775
|
if (kind === SESSION_PREPARE_KIND) {
|
|
41915
|
-
const command2 =
|
|
41776
|
+
const command2 = message;
|
|
41916
41777
|
void executeSessionPrepare(
|
|
41917
41778
|
publisher,
|
|
41918
41779
|
socket,
|
|
@@ -41926,7 +41787,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41926
41787
|
return;
|
|
41927
41788
|
}
|
|
41928
41789
|
if (kind === SESSION_CONFIGURE_KIND) {
|
|
41929
|
-
const command2 =
|
|
41790
|
+
const command2 = message;
|
|
41930
41791
|
void executeSessionConfigure(
|
|
41931
41792
|
publisher,
|
|
41932
41793
|
socket,
|
|
@@ -41940,7 +41801,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41940
41801
|
return;
|
|
41941
41802
|
}
|
|
41942
41803
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
41943
|
-
const command2 =
|
|
41804
|
+
const command2 = message;
|
|
41944
41805
|
void sessions.respondPermission(command2).then(() => {
|
|
41945
41806
|
audit.record({
|
|
41946
41807
|
commandId: command2.interactionId,
|
|
@@ -41953,7 +41814,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41953
41814
|
return;
|
|
41954
41815
|
}
|
|
41955
41816
|
if (kind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
41956
|
-
const command2 =
|
|
41817
|
+
const command2 = message;
|
|
41957
41818
|
void sessions.respondElicitation(command2).then(() => {
|
|
41958
41819
|
audit.record({
|
|
41959
41820
|
commandId: command2.interactionId,
|
|
@@ -41966,14 +41827,14 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41966
41827
|
return;
|
|
41967
41828
|
}
|
|
41968
41829
|
if (kind === AGENT_INSTALL_REQUEST_KIND) {
|
|
41969
|
-
const command2 =
|
|
41830
|
+
const command2 = message;
|
|
41970
41831
|
void installations.request(command2, signal).catch((error62) => {
|
|
41971
41832
|
console.error("Mobius Agent integration installation failed", error62);
|
|
41972
41833
|
});
|
|
41973
41834
|
return;
|
|
41974
41835
|
}
|
|
41975
41836
|
if (kind === AGENT_INSTALL_CANCEL_KIND) {
|
|
41976
|
-
const command2 =
|
|
41837
|
+
const command2 = message;
|
|
41977
41838
|
void installations.cancel(command2.requestId).catch((error62) => {
|
|
41978
41839
|
reportOperationFailure(socket, command2.requestId, "", error62);
|
|
41979
41840
|
});
|
|
@@ -41982,7 +41843,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41982
41843
|
if (kind !== SESSION_PROMPT_KIND) {
|
|
41983
41844
|
throw new Error("Unsupported protocol message");
|
|
41984
41845
|
}
|
|
41985
|
-
const command =
|
|
41846
|
+
const command = message;
|
|
41986
41847
|
if (activeTurns.has(command.commandId)) {
|
|
41987
41848
|
return;
|
|
41988
41849
|
}
|
|
@@ -42103,15 +41964,15 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
42103
41964
|
const publisher = new DaemonSessionEventPublisher(outbox, timer);
|
|
42104
41965
|
const activeTurns = /* @__PURE__ */ new Map();
|
|
42105
41966
|
const activeAttemptIds = /* @__PURE__ */ new Map();
|
|
42106
|
-
const recordSessionEvent = (sessionId,
|
|
41967
|
+
const recordSessionEvent = (sessionId, event) => {
|
|
42107
41968
|
const attemptId = activeAttemptIds.get(sessionId);
|
|
42108
41969
|
if (attemptId === void 0) {
|
|
42109
|
-
publisher.recordRuntime(sessionId,
|
|
41970
|
+
publisher.recordRuntime(sessionId, event);
|
|
42110
41971
|
return;
|
|
42111
41972
|
}
|
|
42112
|
-
publisher.recordAttempt(sessionId,
|
|
41973
|
+
publisher.recordAttempt(sessionId, event, attemptId);
|
|
42113
41974
|
};
|
|
42114
|
-
const sessions = new AcpSessionManager(new DaemonAcpObserver(
|
|
41975
|
+
const sessions = new AcpSessionManager(new DaemonAcpObserver(recordSessionEvent), sessionStore);
|
|
42115
41976
|
const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
|
|
42116
41977
|
const installationObserver = new DaemonInstallationObserver();
|
|
42117
41978
|
const diagnostics = new RelayConnectionDiagnostics(audit, config2.channelId, config2.relayUrl);
|
|
@@ -42345,7 +42206,7 @@ async function main() {
|
|
|
42345
42206
|
const installation = await openMobiusCliInstallation(shutdown.signal, process.env);
|
|
42346
42207
|
const localContext = new DaemonLocalContext(installation.stateDirectory, process.env);
|
|
42347
42208
|
const defaultWorkspace = loadDefaultWorkspace(localContext.environment);
|
|
42348
|
-
await
|
|
42209
|
+
await mkdir6(defaultWorkspace, { recursive: true, mode: 448 });
|
|
42349
42210
|
const inventory = await discoverLocalAgentInventory({
|
|
42350
42211
|
defaultWorkspace,
|
|
42351
42212
|
environment: localContext.environment,
|