@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/runtime.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all2) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/runtime.ts
|
|
8
|
-
import { mkdir as
|
|
8
|
+
import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
9
9
|
import { dirname as dirname8, join as join17, resolve as resolve7 } from "node:path";
|
|
10
10
|
|
|
11
11
|
// src/agent-catalog/local-agent.ts
|
|
@@ -1368,21 +1368,21 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1368
1368
|
};
|
|
1369
1369
|
|
|
1370
1370
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
1371
|
-
import { realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
1371
|
+
import { mkdir as mkdir2, realpath as realpath3, stat as stat3, writeFile } from "node:fs/promises";
|
|
1372
1372
|
import { isAbsolute as isAbsolute3, join as join6, normalize } from "node:path";
|
|
1373
1373
|
|
|
1374
1374
|
// src/agent-installation/deepseek-managed-package.ts
|
|
1375
1375
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
1376
|
-
dependencyResolutionArguments = Object.freeze(["--before=2026-09-
|
|
1376
|
+
dependencyResolutionArguments = Object.freeze(["--before=2026-09-18T00:00:00.000Z"]);
|
|
1377
1377
|
includeOptionalDependencies = true;
|
|
1378
1378
|
verifyDependencyClosure = true;
|
|
1379
1379
|
};
|
|
1380
1380
|
var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
1381
1381
|
"@deepseek-ai/dsh",
|
|
1382
|
-
"0.1.
|
|
1382
|
+
"0.1.5-rc.2",
|
|
1383
1383
|
"dsh",
|
|
1384
|
-
"sha512-
|
|
1385
|
-
"https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.
|
|
1384
|
+
"sha512-8Xc8hCQHcIWRmTCVU/xZdp6/qMsWMeAd2ObChKDEsfhUPJFXx6H0lgeb1DxUMD86HZrrVN+1bCvn1ppjZ/fOxw==",
|
|
1385
|
+
"https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.5-rc.2.tgz"
|
|
1386
1386
|
);
|
|
1387
1387
|
|
|
1388
1388
|
// src/storage/state-directory.ts
|
|
@@ -1397,16 +1397,30 @@ function readStateDirectory(environment = process.env) {
|
|
|
1397
1397
|
}
|
|
1398
1398
|
|
|
1399
1399
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
1400
|
-
|
|
1400
|
+
var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP bridge to an image-capable route.
|
|
1401
|
+
- id: acp
|
|
1402
|
+
config:
|
|
1403
|
+
provider: deepseek-official
|
|
1404
|
+
model: deepseek-v4-flash-vision-exp
|
|
1405
|
+
`;
|
|
1406
|
+
async function prepareAgentHome(path2, imagePrompts) {
|
|
1401
1407
|
if (!isAbsolute3(path2) || normalize(path2) !== path2) {
|
|
1402
1408
|
throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
|
|
1403
1409
|
}
|
|
1404
1410
|
try {
|
|
1411
|
+
if (imagePrompts) {
|
|
1412
|
+
await mkdir2(path2, { mode: 448, recursive: true });
|
|
1413
|
+
}
|
|
1405
1414
|
const resolved = await realpath3(path2);
|
|
1406
1415
|
const metadata = await stat3(resolved);
|
|
1407
1416
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
1408
1417
|
throw new Error("Agent home is not a user-owned directory");
|
|
1409
1418
|
}
|
|
1419
|
+
if (imagePrompts) {
|
|
1420
|
+
await writeFile(join6(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
1421
|
+
mode: 384
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1410
1424
|
return resolved;
|
|
1411
1425
|
} catch (error62) {
|
|
1412
1426
|
if (error62 instanceof AgentProbeError) {
|
|
@@ -1441,6 +1455,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1441
1455
|
}
|
|
1442
1456
|
createLaunchEnvironment = async (agent, context) => {
|
|
1443
1457
|
let selectedHome = context.environment["DSH_HOME"];
|
|
1458
|
+
let managedHome = false;
|
|
1444
1459
|
try {
|
|
1445
1460
|
const managed = await this.resolveManagedAgent(
|
|
1446
1461
|
readStateDirectory(context.environment),
|
|
@@ -1449,6 +1464,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1449
1464
|
);
|
|
1450
1465
|
if (managed.path === agent.path) {
|
|
1451
1466
|
selectedHome = join6(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
1467
|
+
managedHome = true;
|
|
1452
1468
|
}
|
|
1453
1469
|
} catch {
|
|
1454
1470
|
context.signal.throwIfAborted();
|
|
@@ -1457,7 +1473,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1457
1473
|
return Object.freeze({});
|
|
1458
1474
|
}
|
|
1459
1475
|
return Object.freeze({
|
|
1460
|
-
DSH_HOME: await
|
|
1476
|
+
DSH_HOME: await prepareAgentHome(selectedHome, managedHome)
|
|
1461
1477
|
});
|
|
1462
1478
|
};
|
|
1463
1479
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
@@ -1472,8 +1488,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
1472
1488
|
verifyAcp = (_connection, initialized, _defaultWorkspace, _signal) => {
|
|
1473
1489
|
const capabilities = initialized.agentCapabilities ?? {};
|
|
1474
1490
|
const session = capabilities.sessionCapabilities;
|
|
1475
|
-
|
|
1476
|
-
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) {
|
|
1491
|
+
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) {
|
|
1477
1492
|
throw new AgentProbeError(
|
|
1478
1493
|
"acp_incompatible",
|
|
1479
1494
|
"DeepSeek Harness reported an unsupported ACP capability set"
|
|
@@ -1684,7 +1699,7 @@ import { join as join9 } from "node:path";
|
|
|
1684
1699
|
// src/agent-installation/managed-agent-archive.ts
|
|
1685
1700
|
import { createHash } from "node:crypto";
|
|
1686
1701
|
import { createReadStream } from "node:fs";
|
|
1687
|
-
import { chmod, copyFile, mkdir as
|
|
1702
|
+
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";
|
|
1688
1703
|
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute5, join as join8, relative as relative3, sep as sep3 } from "node:path";
|
|
1689
1704
|
|
|
1690
1705
|
// src/agent-installation/verified-download.ts
|
|
@@ -2773,7 +2788,7 @@ var AuditStore = class {
|
|
|
2773
2788
|
this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
|
|
2774
2789
|
}
|
|
2775
2790
|
}
|
|
2776
|
-
record(
|
|
2791
|
+
record(record2) {
|
|
2777
2792
|
this.database.prepare(
|
|
2778
2793
|
`
|
|
2779
2794
|
INSERT INTO audit_events (
|
|
@@ -2786,10 +2801,10 @@ var AuditStore = class {
|
|
|
2786
2801
|
`
|
|
2787
2802
|
).run(
|
|
2788
2803
|
(/* @__PURE__ */ new Date()).toISOString(),
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
JSON.stringify(
|
|
2804
|
+
record2.event,
|
|
2805
|
+
record2.commandId,
|
|
2806
|
+
record2.sessionId,
|
|
2807
|
+
JSON.stringify(record2.details ?? {})
|
|
2793
2808
|
);
|
|
2794
2809
|
}
|
|
2795
2810
|
close() {
|
|
@@ -19393,8 +19408,8 @@ function rewriteKeyNames(ctx) {
|
|
|
19393
19408
|
bySchema.set(entry.schema, entry);
|
|
19394
19409
|
}
|
|
19395
19410
|
const rewrites = /* @__PURE__ */ new Map();
|
|
19396
|
-
for (const
|
|
19397
|
-
const seen = ctx.seen.get(
|
|
19411
|
+
for (const record2 of pendingRecords.get(ctx) ?? []) {
|
|
19412
|
+
const seen = ctx.seen.get(record2);
|
|
19398
19413
|
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
19399
19414
|
if (!names || names === true || rewrites.has(names))
|
|
19400
19415
|
continue;
|
|
@@ -23103,39 +23118,65 @@ var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.
|
|
|
23103
23118
|
var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
|
|
23104
23119
|
var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
|
|
23105
23120
|
var decodeAgentSettingsDiscoverCommand = (encoded) => decode3(encoded, agentSettingsDiscoverCommandSchema);
|
|
23121
|
+
var encodeAgentSettingsDiscoverCommand = (message) => encode3(message, agentSettingsDiscoverCommandSchema);
|
|
23122
|
+
var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSettingsDiscoveredEventSchema);
|
|
23106
23123
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
23124
|
+
var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
|
|
23107
23125
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
23108
23126
|
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
23127
|
+
var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
|
|
23128
|
+
var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
|
|
23109
23129
|
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
23130
|
+
var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
|
|
23110
23131
|
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
23111
23132
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
23133
|
+
var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
|
|
23134
|
+
var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
|
|
23112
23135
|
var encodeFileBeginEvent = (message) => encode3(message, fileBeginEventSchema);
|
|
23136
|
+
var decodeFileChunkEvent = (encoded) => decode3(encoded, fileChunkEventSchema);
|
|
23113
23137
|
var encodeFileChunkEvent = (message) => encode3(message, fileChunkEventSchema);
|
|
23138
|
+
var decodeFileEndEvent = (encoded) => decode3(encoded, fileEndEventSchema);
|
|
23114
23139
|
var encodeFileEndEvent = (message) => encode3(message, fileEndEventSchema);
|
|
23140
|
+
var decodeFileFailedEvent = (encoded) => decode3(encoded, fileFailedEventSchema);
|
|
23115
23141
|
var encodeFileFailedEvent = (message) => encode3(message, fileFailedEventSchema);
|
|
23116
23142
|
var decodeWorkspaceListCommand = (encoded) => decode3(encoded, workspaceListCommandSchema);
|
|
23143
|
+
var encodeWorkspaceListCommand = (message) => encode3(message, workspaceListCommandSchema);
|
|
23144
|
+
var decodeWorkspaceEntriesEvent = (encoded) => decode3(encoded, workspaceEntriesEventSchema);
|
|
23117
23145
|
var encodeWorkspaceEntriesEvent = (message) => encode3(message, workspaceEntriesEventSchema);
|
|
23118
23146
|
var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
|
|
23147
|
+
var encodeSessionPrepareCommand = (message) => encode3(message, sessionPrepareCommandSchema);
|
|
23148
|
+
var decodeSessionReadyEvent = (encoded) => decode3(encoded, sessionReadyEventSchema);
|
|
23119
23149
|
var encodeSessionReadyEvent = (message) => encode3(message, sessionReadyEventSchema);
|
|
23120
23150
|
var decodeSessionConfigureCommand = (encoded) => decode3(encoded, sessionConfigureCommandSchema);
|
|
23121
|
-
var
|
|
23122
|
-
var
|
|
23123
|
-
var
|
|
23124
|
-
var
|
|
23125
|
-
var
|
|
23151
|
+
var encodeSessionConfigureCommand = (message) => encode3(message, sessionConfigureCommandSchema);
|
|
23152
|
+
var decodeSessionConfigUpdatedEvent = (encoded) => decode3(encoded, sessionConfigUpdatedEventSchema);
|
|
23153
|
+
var decodeSessionUsageUpdatedEvent = (encoded) => decode3(encoded, sessionUsageUpdatedEventSchema);
|
|
23154
|
+
var decodeSessionCommandsUpdatedEvent = (encoded) => decode3(encoded, sessionCommandsUpdatedEventSchema);
|
|
23155
|
+
var decodeSessionInfoUpdatedEvent = (encoded) => decode3(encoded, sessionInfoUpdatedEventSchema);
|
|
23156
|
+
var decodeSessionPermissionRequestedEvent = (encoded) => decode3(encoded, sessionPermissionRequestedEventSchema);
|
|
23126
23157
|
var decodeSessionPermissionRespondCommand = (encoded) => decode3(encoded, sessionPermissionRespondCommandSchema);
|
|
23127
|
-
var
|
|
23128
|
-
var
|
|
23158
|
+
var encodeSessionPermissionRespondCommand = (message) => encode3(message, sessionPermissionRespondCommandSchema);
|
|
23159
|
+
var decodeSessionPermissionResolvedEvent = (encoded) => decode3(encoded, sessionPermissionResolvedEventSchema);
|
|
23160
|
+
var decodeSessionElicitationRequestedEvent = (encoded) => decode3(encoded, sessionElicitationRequestedEventSchema);
|
|
23129
23161
|
var decodeSessionElicitationRespondCommand = (encoded) => decode3(encoded, sessionElicitationRespondCommandSchema);
|
|
23130
|
-
var
|
|
23162
|
+
var encodeSessionElicitationRespondCommand = (message) => encode3(message, sessionElicitationRespondCommandSchema);
|
|
23163
|
+
var decodeSessionElicitationResolvedEvent = (encoded) => decode3(encoded, sessionElicitationResolvedEventSchema);
|
|
23164
|
+
var decodeSessionOperationFailedEvent = (encoded) => decode3(encoded, sessionOperationFailedEventSchema);
|
|
23131
23165
|
var encodeSessionOperationFailedEvent = (message) => encode3(message, sessionOperationFailedEventSchema);
|
|
23132
|
-
var
|
|
23166
|
+
var decodeAgentContentEvent = (encoded) => decode3(encoded, agentContentEventSchema);
|
|
23133
23167
|
var decodeAgentInstallRequestCommand = (encoded) => decode3(encoded, agentInstallRequestCommandSchema);
|
|
23168
|
+
var encodeAgentInstallRequestCommand = (message) => encode3(message, agentInstallRequestCommandSchema);
|
|
23134
23169
|
var decodeAgentInstallCancelCommand = (encoded) => decode3(encoded, agentInstallCancelCommandSchema);
|
|
23170
|
+
var encodeAgentInstallCancelCommand = (message) => encode3(message, agentInstallCancelCommandSchema);
|
|
23171
|
+
var decodeAgentInstallStartedEvent = (encoded) => decode3(encoded, agentInstallStartedEventSchema);
|
|
23135
23172
|
var encodeAgentInstallStartedEvent = (message) => encode3(message, agentInstallStartedEventSchema);
|
|
23173
|
+
var decodeAgentInstallProgressEvent = (encoded) => decode3(encoded, agentInstallProgressEventSchema);
|
|
23136
23174
|
var encodeAgentInstallProgressEvent = (message) => encode3(message, agentInstallProgressEventSchema);
|
|
23175
|
+
var decodeAgentInstallCompletedEvent = (encoded) => decode3(encoded, agentInstallCompletedEventSchema);
|
|
23137
23176
|
var encodeAgentInstallCompletedEvent = (message) => encode3(message, agentInstallCompletedEventSchema);
|
|
23177
|
+
var decodeAgentInstallFailedEvent = (encoded) => decode3(encoded, agentInstallFailedEventSchema);
|
|
23138
23178
|
var encodeAgentInstallFailedEvent = (message) => encode3(message, agentInstallFailedEventSchema);
|
|
23179
|
+
var decodeAgentInstallCancelledEvent = (encoded) => decode3(encoded, agentInstallCancelledEventSchema);
|
|
23139
23180
|
var encodeAgentInstallCancelledEvent = (message) => encode3(message, agentInstallCancelledEventSchema);
|
|
23140
23181
|
|
|
23141
23182
|
// ../protocol/src/messages.ts
|
|
@@ -23570,49 +23611,29 @@ function decodeSessionFailedEvent(encoded) {
|
|
|
23570
23611
|
sessionId: readIdentifier(value, "sessionId")
|
|
23571
23612
|
};
|
|
23572
23613
|
}
|
|
23573
|
-
function
|
|
23574
|
-
return JSON.stringify(
|
|
23614
|
+
function encodeSessionPromptCommand(message) {
|
|
23615
|
+
return JSON.stringify(decodeSessionPromptCommand(JSON.stringify(message)));
|
|
23575
23616
|
}
|
|
23576
|
-
function
|
|
23577
|
-
return JSON.stringify(
|
|
23617
|
+
function encodeSessionCancelCommand(message) {
|
|
23618
|
+
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
23578
23619
|
}
|
|
23579
|
-
function
|
|
23580
|
-
return JSON.stringify(
|
|
23620
|
+
function encodeRuntimeLivenessReadyEvent(message) {
|
|
23621
|
+
return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
|
|
23581
23622
|
}
|
|
23582
|
-
function
|
|
23583
|
-
return JSON.stringify(
|
|
23584
|
-
}
|
|
23585
|
-
function encodeAgentActivityEvent(message) {
|
|
23586
|
-
return JSON.stringify(decodeAgentActivityEvent(JSON.stringify(message)));
|
|
23623
|
+
function encodeRuntimeHeartbeatEvent(message) {
|
|
23624
|
+
return JSON.stringify(decodeRuntimeHeartbeatEvent(JSON.stringify(message)));
|
|
23587
23625
|
}
|
|
23588
|
-
function
|
|
23589
|
-
return JSON.stringify(
|
|
23626
|
+
function encodeRuntimeHeartbeatAckEvent(message) {
|
|
23627
|
+
return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
|
|
23590
23628
|
}
|
|
23591
|
-
function
|
|
23592
|
-
return JSON.stringify(
|
|
23629
|
+
function encodeRuntimeDelivery(message) {
|
|
23630
|
+
return JSON.stringify(decodeRuntimeDelivery(JSON.stringify(message)));
|
|
23593
23631
|
}
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
var MOBIUS_API_PREFIX = "/mobius/api";
|
|
23597
|
-
var API_PREFIX_PATTERN = /^\/[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*$/;
|
|
23598
|
-
var MobiusApiConfigurationError = class extends Error {
|
|
23599
|
-
code = "invalid_api_prefix";
|
|
23600
|
-
constructor() {
|
|
23601
|
-
super("The Mobius API prefix must be an absolute path without parameters");
|
|
23602
|
-
this.name = "MobiusApiConfigurationError";
|
|
23603
|
-
}
|
|
23604
|
-
};
|
|
23605
|
-
function parseMobiusApiPrefix(value) {
|
|
23606
|
-
if (typeof value !== "string" || !API_PREFIX_PATTERN.test(value)) {
|
|
23607
|
-
throw new MobiusApiConfigurationError();
|
|
23608
|
-
}
|
|
23609
|
-
return value;
|
|
23610
|
-
}
|
|
23611
|
-
function mobiusApiPath(resourcePath, apiPrefix = MOBIUS_API_PREFIX) {
|
|
23612
|
-
return `${parseMobiusApiPrefix(apiPrefix)}${resourcePath}`;
|
|
23632
|
+
function encodeRuntimeDeliveryReceived(message) {
|
|
23633
|
+
return JSON.stringify(decodeRuntimeDeliveryReceived(JSON.stringify(message)));
|
|
23613
23634
|
}
|
|
23614
|
-
function
|
|
23615
|
-
return
|
|
23635
|
+
function encodeRuntimeDeliveryCommitted(message) {
|
|
23636
|
+
return JSON.stringify(decodeRuntimeDeliveryCommitted(JSON.stringify(message)));
|
|
23616
23637
|
}
|
|
23617
23638
|
|
|
23618
23639
|
// ../protocol/src/session-history.ts
|
|
@@ -23789,9 +23810,13 @@ function decode4(schema, encoded) {
|
|
|
23789
23810
|
}
|
|
23790
23811
|
}
|
|
23791
23812
|
var decodeNativeSessionCommand = (encoded) => decode4(nativeSessionCommandSchema, encoded);
|
|
23813
|
+
var encodeNativeSessionCommand = (value) => JSON.stringify(nativeSessionCommandSchema.parse(value));
|
|
23814
|
+
var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema, encoded);
|
|
23792
23815
|
var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
|
|
23793
23816
|
var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
|
|
23817
|
+
var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
|
|
23794
23818
|
var decodeNativeSessionTurnForkCommand = (encoded) => decode4(nativeSessionTurnForkCommandSchema, encoded);
|
|
23819
|
+
var encodeNativeSessionTurnForkCommand = (value) => JSON.stringify(nativeSessionTurnForkCommandSchema.parse(value));
|
|
23795
23820
|
|
|
23796
23821
|
// ../protocol/src/session-events.ts
|
|
23797
23822
|
var SESSION_EVENT_KIND = "session.event";
|
|
@@ -23883,8 +23908,285 @@ var encode4 = (message, schema) => {
|
|
|
23883
23908
|
var decodeSessionEventEnvelope = (encoded) => decode5(encoded, eventEnvelopeSchema);
|
|
23884
23909
|
var encodeSessionEventEnvelope = (message) => encode4(message, eventEnvelopeSchema);
|
|
23885
23910
|
var decodeSessionEventAcknowledgement = (encoded) => decode5(encoded, eventAcknowledgementSchema);
|
|
23911
|
+
var encodeSessionEventAcknowledgement = (message) => encode4(message, eventAcknowledgementSchema);
|
|
23886
23912
|
var decodeSessionEventDeferred = (encoded) => decode5(encoded, eventDeferredSchema);
|
|
23913
|
+
var encodeSessionEventDeferred = (message) => encode4(message, eventDeferredSchema);
|
|
23887
23914
|
var decodeSessionEventRejection = (encoded) => decode5(encoded, eventRejectionSchema);
|
|
23915
|
+
var encodeSessionEventRejection = (message) => encode4(message, eventRejectionSchema);
|
|
23916
|
+
function decodeRecordedSessionEvent(encoded) {
|
|
23917
|
+
const kind = decodeMessageKind(encoded);
|
|
23918
|
+
switch (kind) {
|
|
23919
|
+
case AGENT_ACTIVITY_KIND:
|
|
23920
|
+
return decodeAgentActivityEvent(encoded);
|
|
23921
|
+
case AGENT_CONTENT_KIND:
|
|
23922
|
+
return decodeAgentContentEvent(encoded);
|
|
23923
|
+
case AGENT_MESSAGE_DELTA_KIND:
|
|
23924
|
+
return decodeAgentMessageDeltaEvent(encoded);
|
|
23925
|
+
case SESSION_COMMANDS_UPDATED_KIND:
|
|
23926
|
+
return decodeSessionCommandsUpdatedEvent(encoded);
|
|
23927
|
+
case SESSION_COMPLETED_KIND:
|
|
23928
|
+
return decodeSessionCompletedEvent(encoded);
|
|
23929
|
+
case SESSION_CONFIG_UPDATED_KIND:
|
|
23930
|
+
return decodeSessionConfigUpdatedEvent(encoded);
|
|
23931
|
+
case SESSION_ELICITATION_REQUESTED_KIND:
|
|
23932
|
+
return decodeSessionElicitationRequestedEvent(encoded);
|
|
23933
|
+
case SESSION_ELICITATION_RESOLVED_KIND:
|
|
23934
|
+
return decodeSessionElicitationResolvedEvent(encoded);
|
|
23935
|
+
case SESSION_FAILED_KIND:
|
|
23936
|
+
return decodeSessionFailedEvent(encoded);
|
|
23937
|
+
case SESSION_INFO_UPDATED_KIND:
|
|
23938
|
+
return decodeSessionInfoUpdatedEvent(encoded);
|
|
23939
|
+
case SESSION_PERMISSION_REQUESTED_KIND:
|
|
23940
|
+
return decodeSessionPermissionRequestedEvent(encoded);
|
|
23941
|
+
case SESSION_PERMISSION_RESOLVED_KIND:
|
|
23942
|
+
return decodeSessionPermissionResolvedEvent(encoded);
|
|
23943
|
+
case SESSION_READY_KIND:
|
|
23944
|
+
return decodeSessionReadyEvent(encoded);
|
|
23945
|
+
case SESSION_STARTED_KIND:
|
|
23946
|
+
return decodeSessionStartedEvent(encoded);
|
|
23947
|
+
case SESSION_USAGE_UPDATED_KIND:
|
|
23948
|
+
return decodeSessionUsageUpdatedEvent(encoded);
|
|
23949
|
+
default:
|
|
23950
|
+
throw new ProtocolMessageError("Unsupported recorded session event");
|
|
23951
|
+
}
|
|
23952
|
+
}
|
|
23953
|
+
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
23954
|
+
|
|
23955
|
+
// ../protocol/src/daemon-transport.ts
|
|
23956
|
+
function defineMessageSignature(kind, encoder, decoder) {
|
|
23957
|
+
const schema = (message) => decoder(JSON.stringify(message));
|
|
23958
|
+
return {
|
|
23959
|
+
decoder,
|
|
23960
|
+
encoder: (message) => encoder(schema(message)),
|
|
23961
|
+
kind,
|
|
23962
|
+
schema
|
|
23963
|
+
};
|
|
23964
|
+
}
|
|
23965
|
+
var serviceToDaemonSignatures = {
|
|
23966
|
+
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
23967
|
+
AGENT_CATALOG_REFRESH_KIND,
|
|
23968
|
+
encodeAgentCatalogRefreshCommand,
|
|
23969
|
+
decodeAgentCatalogRefreshCommand
|
|
23970
|
+
),
|
|
23971
|
+
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
23972
|
+
AGENT_INSTALL_CANCEL_KIND,
|
|
23973
|
+
encodeAgentInstallCancelCommand,
|
|
23974
|
+
decodeAgentInstallCancelCommand
|
|
23975
|
+
),
|
|
23976
|
+
[AGENT_INSTALL_REQUEST_KIND]: defineMessageSignature(
|
|
23977
|
+
AGENT_INSTALL_REQUEST_KIND,
|
|
23978
|
+
encodeAgentInstallRequestCommand,
|
|
23979
|
+
decodeAgentInstallRequestCommand
|
|
23980
|
+
),
|
|
23981
|
+
[AGENT_SETTINGS_DISCOVER_KIND]: defineMessageSignature(
|
|
23982
|
+
AGENT_SETTINGS_DISCOVER_KIND,
|
|
23983
|
+
encodeAgentSettingsDiscoverCommand,
|
|
23984
|
+
decodeAgentSettingsDiscoverCommand
|
|
23985
|
+
),
|
|
23986
|
+
[FILE_READ_KIND]: defineMessageSignature(FILE_READ_KIND, encodeFileReadCommand, decodeFileReadCommand),
|
|
23987
|
+
[NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
23988
|
+
NATIVE_SESSION_CANCEL_KIND,
|
|
23989
|
+
encodeNativeSessionCancel,
|
|
23990
|
+
decodeNativeSessionCancel
|
|
23991
|
+
),
|
|
23992
|
+
[NATIVE_SESSION_REQUEST_KIND]: defineMessageSignature(
|
|
23993
|
+
NATIVE_SESSION_REQUEST_KIND,
|
|
23994
|
+
encodeNativeSessionCommand,
|
|
23995
|
+
decodeNativeSessionCommand
|
|
23996
|
+
),
|
|
23997
|
+
[NATIVE_SESSION_TURN_FORK_KIND]: defineMessageSignature(
|
|
23998
|
+
NATIVE_SESSION_TURN_FORK_KIND,
|
|
23999
|
+
encodeNativeSessionTurnForkCommand,
|
|
24000
|
+
decodeNativeSessionTurnForkCommand
|
|
24001
|
+
),
|
|
24002
|
+
[RUNTIME_DELIVERY_KIND]: defineMessageSignature(
|
|
24003
|
+
RUNTIME_DELIVERY_KIND,
|
|
24004
|
+
encodeRuntimeDelivery,
|
|
24005
|
+
decodeRuntimeDelivery
|
|
24006
|
+
),
|
|
24007
|
+
[RUNTIME_DELIVERY_COMMITTED_KIND]: defineMessageSignature(
|
|
24008
|
+
RUNTIME_DELIVERY_COMMITTED_KIND,
|
|
24009
|
+
encodeRuntimeDeliveryCommitted,
|
|
24010
|
+
decodeRuntimeDeliveryCommitted
|
|
24011
|
+
),
|
|
24012
|
+
[RUNTIME_HEARTBEAT_ACK_KIND]: defineMessageSignature(
|
|
24013
|
+
RUNTIME_HEARTBEAT_ACK_KIND,
|
|
24014
|
+
encodeRuntimeHeartbeatAckEvent,
|
|
24015
|
+
decodeRuntimeHeartbeatAckEvent
|
|
24016
|
+
),
|
|
24017
|
+
[RUNTIME_LIVENESS_READY_KIND]: defineMessageSignature(
|
|
24018
|
+
RUNTIME_LIVENESS_READY_KIND,
|
|
24019
|
+
encodeRuntimeLivenessReadyEvent,
|
|
24020
|
+
decodeRuntimeLivenessReadyEvent
|
|
24021
|
+
),
|
|
24022
|
+
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
24023
|
+
SESSION_CANCEL_KIND,
|
|
24024
|
+
encodeSessionCancelCommand,
|
|
24025
|
+
decodeSessionCancelCommand
|
|
24026
|
+
),
|
|
24027
|
+
[SESSION_CONFIGURE_KIND]: defineMessageSignature(
|
|
24028
|
+
SESSION_CONFIGURE_KIND,
|
|
24029
|
+
encodeSessionConfigureCommand,
|
|
24030
|
+
decodeSessionConfigureCommand
|
|
24031
|
+
),
|
|
24032
|
+
[SESSION_ELICITATION_RESPOND_KIND]: defineMessageSignature(
|
|
24033
|
+
SESSION_ELICITATION_RESPOND_KIND,
|
|
24034
|
+
encodeSessionElicitationRespondCommand,
|
|
24035
|
+
decodeSessionElicitationRespondCommand
|
|
24036
|
+
),
|
|
24037
|
+
[SESSION_EVENT_ACK_KIND]: defineMessageSignature(
|
|
24038
|
+
SESSION_EVENT_ACK_KIND,
|
|
24039
|
+
encodeSessionEventAcknowledgement,
|
|
24040
|
+
decodeSessionEventAcknowledgement
|
|
24041
|
+
),
|
|
24042
|
+
[SESSION_EVENT_DEFERRED_KIND]: defineMessageSignature(
|
|
24043
|
+
SESSION_EVENT_DEFERRED_KIND,
|
|
24044
|
+
encodeSessionEventDeferred,
|
|
24045
|
+
decodeSessionEventDeferred
|
|
24046
|
+
),
|
|
24047
|
+
[SESSION_EVENT_REJECTED_KIND]: defineMessageSignature(
|
|
24048
|
+
SESSION_EVENT_REJECTED_KIND,
|
|
24049
|
+
encodeSessionEventRejection,
|
|
24050
|
+
decodeSessionEventRejection
|
|
24051
|
+
),
|
|
24052
|
+
[SESSION_PERMISSION_RESPOND_KIND]: defineMessageSignature(
|
|
24053
|
+
SESSION_PERMISSION_RESPOND_KIND,
|
|
24054
|
+
encodeSessionPermissionRespondCommand,
|
|
24055
|
+
decodeSessionPermissionRespondCommand
|
|
24056
|
+
),
|
|
24057
|
+
[SESSION_PREPARE_KIND]: defineMessageSignature(
|
|
24058
|
+
SESSION_PREPARE_KIND,
|
|
24059
|
+
encodeSessionPrepareCommand,
|
|
24060
|
+
decodeSessionPrepareCommand
|
|
24061
|
+
),
|
|
24062
|
+
[SESSION_PROMPT_KIND]: defineMessageSignature(
|
|
24063
|
+
SESSION_PROMPT_KIND,
|
|
24064
|
+
encodeSessionPromptCommand,
|
|
24065
|
+
decodeSessionPromptCommand
|
|
24066
|
+
),
|
|
24067
|
+
[WORKSPACE_LIST_KIND]: defineMessageSignature(
|
|
24068
|
+
WORKSPACE_LIST_KIND,
|
|
24069
|
+
encodeWorkspaceListCommand,
|
|
24070
|
+
decodeWorkspaceListCommand
|
|
24071
|
+
)
|
|
24072
|
+
};
|
|
24073
|
+
var serviceToDaemonRegistry = serviceToDaemonSignatures;
|
|
24074
|
+
function decodeServiceToDaemonMessage(encoded) {
|
|
24075
|
+
const kind = decodeMessageKind(encoded);
|
|
24076
|
+
const signature = serviceToDaemonRegistry[kind];
|
|
24077
|
+
if (signature === void 0) {
|
|
24078
|
+
throw new ProtocolMessageError(`Unsupported service-to-daemon message kind: ${kind}`);
|
|
24079
|
+
}
|
|
24080
|
+
return signature.decoder(encoded);
|
|
24081
|
+
}
|
|
24082
|
+
var daemonToServiceSignatures = {
|
|
24083
|
+
[AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
|
|
24084
|
+
AGENT_CATALOG_REFRESHED_KIND,
|
|
24085
|
+
encodeAgentCatalogRefreshedEvent,
|
|
24086
|
+
decodeAgentCatalogRefreshedEvent
|
|
24087
|
+
),
|
|
24088
|
+
[AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
|
|
24089
|
+
AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
24090
|
+
encodeAgentCatalogRefreshFailedEvent,
|
|
24091
|
+
decodeAgentCatalogRefreshFailedEvent
|
|
24092
|
+
),
|
|
24093
|
+
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
24094
|
+
AGENT_INSTALL_CANCELLED_KIND,
|
|
24095
|
+
encodeAgentInstallCancelledEvent,
|
|
24096
|
+
decodeAgentInstallCancelledEvent
|
|
24097
|
+
),
|
|
24098
|
+
[AGENT_INSTALL_COMPLETED_KIND]: defineMessageSignature(
|
|
24099
|
+
AGENT_INSTALL_COMPLETED_KIND,
|
|
24100
|
+
encodeAgentInstallCompletedEvent,
|
|
24101
|
+
decodeAgentInstallCompletedEvent
|
|
24102
|
+
),
|
|
24103
|
+
[AGENT_INSTALL_FAILED_KIND]: defineMessageSignature(
|
|
24104
|
+
AGENT_INSTALL_FAILED_KIND,
|
|
24105
|
+
encodeAgentInstallFailedEvent,
|
|
24106
|
+
decodeAgentInstallFailedEvent
|
|
24107
|
+
),
|
|
24108
|
+
[AGENT_INSTALL_PROGRESS_KIND]: defineMessageSignature(
|
|
24109
|
+
AGENT_INSTALL_PROGRESS_KIND,
|
|
24110
|
+
encodeAgentInstallProgressEvent,
|
|
24111
|
+
decodeAgentInstallProgressEvent
|
|
24112
|
+
),
|
|
24113
|
+
[AGENT_INSTALL_STARTED_KIND]: defineMessageSignature(
|
|
24114
|
+
AGENT_INSTALL_STARTED_KIND,
|
|
24115
|
+
encodeAgentInstallStartedEvent,
|
|
24116
|
+
decodeAgentInstallStartedEvent
|
|
24117
|
+
),
|
|
24118
|
+
[AGENT_SETTINGS_DISCOVERED_KIND]: defineMessageSignature(
|
|
24119
|
+
AGENT_SETTINGS_DISCOVERED_KIND,
|
|
24120
|
+
encodeAgentSettingsDiscoveredEvent,
|
|
24121
|
+
decodeAgentSettingsDiscoveredEvent
|
|
24122
|
+
),
|
|
24123
|
+
[AGENT_SETTINGS_DISCOVERY_FAILED_KIND]: defineMessageSignature(
|
|
24124
|
+
AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
24125
|
+
encodeAgentSettingsDiscoveryFailedEvent,
|
|
24126
|
+
decodeAgentSettingsDiscoveryFailedEvent
|
|
24127
|
+
),
|
|
24128
|
+
[FILE_BEGIN_KIND]: defineMessageSignature(FILE_BEGIN_KIND, encodeFileBeginEvent, decodeFileBeginEvent),
|
|
24129
|
+
[FILE_CHUNK_KIND]: defineMessageSignature(FILE_CHUNK_KIND, encodeFileChunkEvent, decodeFileChunkEvent),
|
|
24130
|
+
[FILE_END_KIND]: defineMessageSignature(FILE_END_KIND, encodeFileEndEvent, decodeFileEndEvent),
|
|
24131
|
+
[FILE_FAILED_KIND]: defineMessageSignature(FILE_FAILED_KIND, encodeFileFailedEvent, decodeFileFailedEvent),
|
|
24132
|
+
[NATIVE_SESSION_RESULT_KIND]: defineMessageSignature(
|
|
24133
|
+
NATIVE_SESSION_RESULT_KIND,
|
|
24134
|
+
encodeNativeSessionResult,
|
|
24135
|
+
decodeNativeSessionResult
|
|
24136
|
+
),
|
|
24137
|
+
[RUNTIME_DELIVERY_RECEIVED_KIND]: defineMessageSignature(
|
|
24138
|
+
RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
24139
|
+
encodeRuntimeDeliveryReceived,
|
|
24140
|
+
decodeRuntimeDeliveryReceived
|
|
24141
|
+
),
|
|
24142
|
+
[RUNTIME_HEARTBEAT_KIND]: defineMessageSignature(
|
|
24143
|
+
RUNTIME_HEARTBEAT_KIND,
|
|
24144
|
+
encodeRuntimeHeartbeatEvent,
|
|
24145
|
+
decodeRuntimeHeartbeatEvent
|
|
24146
|
+
),
|
|
24147
|
+
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
24148
|
+
SESSION_EVENT_KIND,
|
|
24149
|
+
encodeSessionEventEnvelope,
|
|
24150
|
+
decodeSessionEventEnvelope
|
|
24151
|
+
),
|
|
24152
|
+
[SESSION_OPERATION_FAILED_KIND]: defineMessageSignature(
|
|
24153
|
+
SESSION_OPERATION_FAILED_KIND,
|
|
24154
|
+
encodeSessionOperationFailedEvent,
|
|
24155
|
+
decodeSessionOperationFailedEvent
|
|
24156
|
+
),
|
|
24157
|
+
[SESSION_READY_KIND]: defineMessageSignature(SESSION_READY_KIND, encodeSessionReadyEvent, decodeSessionReadyEvent),
|
|
24158
|
+
[WORKSPACE_ENTRIES_KIND]: defineMessageSignature(
|
|
24159
|
+
WORKSPACE_ENTRIES_KIND,
|
|
24160
|
+
encodeWorkspaceEntriesEvent,
|
|
24161
|
+
decodeWorkspaceEntriesEvent
|
|
24162
|
+
)
|
|
24163
|
+
};
|
|
24164
|
+
function encodeDaemonToServiceMessage(message) {
|
|
24165
|
+
return daemonToServiceSignatures[message.kind].encoder(message);
|
|
24166
|
+
}
|
|
24167
|
+
|
|
24168
|
+
// ../protocol/src/mobius-api.ts
|
|
24169
|
+
var MOBIUS_API_PREFIX = "/mobius/api";
|
|
24170
|
+
var API_PREFIX_PATTERN = /^\/[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*$/;
|
|
24171
|
+
var MobiusApiConfigurationError = class extends Error {
|
|
24172
|
+
code = "invalid_api_prefix";
|
|
24173
|
+
constructor() {
|
|
24174
|
+
super("The Mobius API prefix must be an absolute path without parameters");
|
|
24175
|
+
this.name = "MobiusApiConfigurationError";
|
|
24176
|
+
}
|
|
24177
|
+
};
|
|
24178
|
+
function parseMobiusApiPrefix(value) {
|
|
24179
|
+
if (typeof value !== "string" || !API_PREFIX_PATTERN.test(value)) {
|
|
24180
|
+
throw new MobiusApiConfigurationError();
|
|
24181
|
+
}
|
|
24182
|
+
return value;
|
|
24183
|
+
}
|
|
24184
|
+
function mobiusApiPath(resourcePath, apiPrefix = MOBIUS_API_PREFIX) {
|
|
24185
|
+
return `${parseMobiusApiPrefix(apiPrefix)}${resourcePath}`;
|
|
24186
|
+
}
|
|
24187
|
+
function mobiusApiUrl(origin, resourcePath, apiPrefix = MOBIUS_API_PREFIX) {
|
|
24188
|
+
return new URL(mobiusApiPath(resourcePath, apiPrefix), origin);
|
|
24189
|
+
}
|
|
23888
24190
|
|
|
23889
24191
|
// src/config.ts
|
|
23890
24192
|
function loadDefaultWorkspace(environment = process.env) {
|
|
@@ -23945,10 +24247,10 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
23945
24247
|
}
|
|
23946
24248
|
|
|
23947
24249
|
// src/run-daemon.ts
|
|
23948
|
-
import { createHash as
|
|
24250
|
+
import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
|
|
23949
24251
|
import { basename as basename6 } from "node:path";
|
|
23950
24252
|
import { styleText } from "node:util";
|
|
23951
|
-
import { fetch as
|
|
24253
|
+
import { fetch as fetch4, WebSocket as WebSocket2 } from "undici";
|
|
23952
24254
|
|
|
23953
24255
|
// src/acp/session-manager.ts
|
|
23954
24256
|
import { spawn as spawn3 } from "node:child_process";
|
|
@@ -32652,10 +32954,6 @@ var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
|
|
|
32652
32954
|
var SESSION_CONTROL_COMMAND_ID = "session-control";
|
|
32653
32955
|
var SESSION_CONTROL_TIMEOUT_MILLISECONDS = 3e4;
|
|
32654
32956
|
var NullAcpSessionObserver = class {
|
|
32655
|
-
importLocalArtifact = (_sessionId, _artifact, signal) => {
|
|
32656
|
-
signal.throwIfAborted();
|
|
32657
|
-
return Promise.resolve("");
|
|
32658
|
-
};
|
|
32659
32957
|
onCommands = () => Promise.resolve();
|
|
32660
32958
|
onConfig = () => Promise.resolve();
|
|
32661
32959
|
onContent = () => Promise.resolve();
|
|
@@ -33215,20 +33513,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33215
33513
|
#agentName = "";
|
|
33216
33514
|
#agentVersion = "";
|
|
33217
33515
|
#bufferedAgentText = [];
|
|
33218
|
-
#capabilities =
|
|
33219
|
-
additionalDirectories: false,
|
|
33220
|
-
audioPrompt: false,
|
|
33221
|
-
closeSession: false,
|
|
33222
|
-
deleteSession: false,
|
|
33223
|
-
embeddedContextPrompt: false,
|
|
33224
|
-
imagePrompt: false,
|
|
33225
|
-
listSessions: false,
|
|
33226
|
-
loadSession: false,
|
|
33227
|
-
promptQueueing: false,
|
|
33228
|
-
resumeSession: false,
|
|
33229
|
-
steering: false,
|
|
33230
|
-
unstableForkSession: false
|
|
33231
|
-
};
|
|
33516
|
+
#capabilities = unsupportedSessionCapabilities();
|
|
33232
33517
|
#commands = [];
|
|
33233
33518
|
#configRevision = 0;
|
|
33234
33519
|
#configOptions = [];
|
|
@@ -33448,7 +33733,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33448
33733
|
if (video === null) {
|
|
33449
33734
|
return { ...content3, data: "" };
|
|
33450
33735
|
}
|
|
33451
|
-
return
|
|
33736
|
+
return this.importVideo(video);
|
|
33452
33737
|
}
|
|
33453
33738
|
return content3;
|
|
33454
33739
|
};
|
|
@@ -33499,22 +33784,19 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33499
33784
|
}
|
|
33500
33785
|
return imageDisplayContent(raster.mimeType, raster.name, await raster.base64(), "");
|
|
33501
33786
|
};
|
|
33502
|
-
importVideo =
|
|
33503
|
-
|
|
33504
|
-
|
|
33505
|
-
|
|
33506
|
-
|
|
33507
|
-
|
|
33508
|
-
|
|
33509
|
-
|
|
33510
|
-
|
|
33511
|
-
|
|
33512
|
-
|
|
33513
|
-
|
|
33514
|
-
|
|
33515
|
-
uri: ""
|
|
33516
|
-
};
|
|
33517
|
-
};
|
|
33787
|
+
importVideo = (video) => ({
|
|
33788
|
+
artifactId: "",
|
|
33789
|
+
data: video.base64(),
|
|
33790
|
+
mimeType: video.mimeType,
|
|
33791
|
+
name: video.name,
|
|
33792
|
+
newText: "",
|
|
33793
|
+
oldText: "",
|
|
33794
|
+
path: "",
|
|
33795
|
+
terminalId: "",
|
|
33796
|
+
text: "",
|
|
33797
|
+
type: "video",
|
|
33798
|
+
uri: ""
|
|
33799
|
+
});
|
|
33518
33800
|
async #initializeAgent(signal) {
|
|
33519
33801
|
await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
|
|
33520
33802
|
}
|
|
@@ -35707,11 +35989,42 @@ function relayHttpEndpoint(relayUrl) {
|
|
|
35707
35989
|
var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
|
|
35708
35990
|
var AgentCatalogPublishError = class extends Error {
|
|
35709
35991
|
code = "agent_catalog_update_failed";
|
|
35710
|
-
|
|
35992
|
+
diagnosticDetails;
|
|
35993
|
+
constructor(message, options = {}, diagnosticDetails = {}) {
|
|
35711
35994
|
super(message, options);
|
|
35995
|
+
this.diagnosticDetails = diagnosticDetails;
|
|
35712
35996
|
this.name = "AgentCatalogPublishError";
|
|
35713
35997
|
}
|
|
35714
35998
|
};
|
|
35999
|
+
function isRecord8(value) {
|
|
36000
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36001
|
+
}
|
|
36002
|
+
function isSafeRelayErrorMessage(value) {
|
|
36003
|
+
return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
|
|
36004
|
+
}
|
|
36005
|
+
async function rejectedCatalogError(response) {
|
|
36006
|
+
let value;
|
|
36007
|
+
try {
|
|
36008
|
+
value = await response.json();
|
|
36009
|
+
} catch {
|
|
36010
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
36011
|
+
}
|
|
36012
|
+
if (!isRecord8(value) || !isRecord8(value["error"])) {
|
|
36013
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
36014
|
+
}
|
|
36015
|
+
const code = value["error"]["code"];
|
|
36016
|
+
const message = value["error"]["message"];
|
|
36017
|
+
if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
|
|
36018
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
36019
|
+
}
|
|
36020
|
+
return new AgentCatalogPublishError(
|
|
36021
|
+
`The Relay rejected the Agent catalog update (${code}): ${message}`,
|
|
36022
|
+
{},
|
|
36023
|
+
{
|
|
36024
|
+
relayErrorCode: code
|
|
36025
|
+
}
|
|
36026
|
+
);
|
|
36027
|
+
}
|
|
35715
36028
|
function catalogEndpoint(config2) {
|
|
35716
36029
|
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
35717
36030
|
if (endpoint.pathname.endsWith("/daemon")) {
|
|
@@ -35759,10 +36072,10 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
35759
36072
|
{ cause: error62 }
|
|
35760
36073
|
);
|
|
35761
36074
|
}
|
|
35762
|
-
await response.body?.cancel();
|
|
35763
36075
|
if (!response.ok) {
|
|
35764
|
-
throw
|
|
36076
|
+
throw await rejectedCatalogError(response);
|
|
35765
36077
|
}
|
|
36078
|
+
await response.body?.cancel();
|
|
35766
36079
|
}
|
|
35767
36080
|
|
|
35768
36081
|
// src/agent-installation/agent-installation-manager.ts
|
|
@@ -36271,30 +36584,26 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
36271
36584
|
throw new Error("The local file is too large to read");
|
|
36272
36585
|
}
|
|
36273
36586
|
const raster = await readLocalRaster(target, signal);
|
|
36274
|
-
send2(
|
|
36275
|
-
|
|
36276
|
-
|
|
36277
|
-
|
|
36278
|
-
|
|
36279
|
-
|
|
36280
|
-
|
|
36281
|
-
|
|
36282
|
-
|
|
36283
|
-
})
|
|
36284
|
-
);
|
|
36587
|
+
send2({
|
|
36588
|
+
byteLength: before.size,
|
|
36589
|
+
kind: FILE_BEGIN_KIND,
|
|
36590
|
+
mediaType: raster?.mimeType ?? "application/octet-stream",
|
|
36591
|
+
modifiedAt: before.mtime.toISOString(),
|
|
36592
|
+
name: basename3(target) || "file",
|
|
36593
|
+
requestId: command.requestId,
|
|
36594
|
+
sessionId: command.sessionId
|
|
36595
|
+
});
|
|
36285
36596
|
let sequence = 0;
|
|
36286
36597
|
const stream = createReadStream2(target, { highWaterMark: CHUNK_BYTES, signal });
|
|
36287
36598
|
for await (const value of stream) {
|
|
36288
36599
|
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
36289
|
-
send2(
|
|
36290
|
-
|
|
36291
|
-
|
|
36292
|
-
|
|
36293
|
-
|
|
36294
|
-
|
|
36295
|
-
|
|
36296
|
-
})
|
|
36297
|
-
);
|
|
36600
|
+
send2({
|
|
36601
|
+
data: Buffer.from(bytes).toString("base64"),
|
|
36602
|
+
kind: FILE_CHUNK_KIND,
|
|
36603
|
+
requestId: command.requestId,
|
|
36604
|
+
sequence,
|
|
36605
|
+
sessionId: command.sessionId
|
|
36606
|
+
});
|
|
36298
36607
|
sequence += 1;
|
|
36299
36608
|
}
|
|
36300
36609
|
const after = await stat6(target);
|
|
@@ -36302,399 +36611,12 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
36302
36611
|
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
|
|
36303
36612
|
throw new Error("The local file changed during transfer");
|
|
36304
36613
|
}
|
|
36305
|
-
send2(
|
|
36306
|
-
|
|
36307
|
-
|
|
36308
|
-
|
|
36309
|
-
sessionId: command.sessionId
|
|
36310
|
-
})
|
|
36311
|
-
);
|
|
36312
|
-
}
|
|
36313
|
-
|
|
36314
|
-
// src/artifacts/runtime-artifact-uploader.ts
|
|
36315
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
36316
|
-
|
|
36317
|
-
// ../mobius-sdk/src/errors.ts
|
|
36318
|
-
var MobiusError = class extends Error {
|
|
36319
|
-
code;
|
|
36320
|
-
constructor(code, message, options = {}) {
|
|
36321
|
-
super(message, options);
|
|
36322
|
-
this.code = code;
|
|
36323
|
-
this.name = "MobiusError";
|
|
36324
|
-
}
|
|
36325
|
-
};
|
|
36326
|
-
var MobiusProtocolError = class extends MobiusError {
|
|
36327
|
-
constructor(message, options = {}) {
|
|
36328
|
-
super("invalid_service_response", message, options);
|
|
36329
|
-
this.name = "MobiusProtocolError";
|
|
36330
|
-
}
|
|
36331
|
-
};
|
|
36332
|
-
var MobiusValidationError = class extends MobiusError {
|
|
36333
|
-
constructor(message, options = {}) {
|
|
36334
|
-
super("invalid_request", message, options);
|
|
36335
|
-
this.name = "MobiusValidationError";
|
|
36336
|
-
}
|
|
36337
|
-
};
|
|
36338
|
-
|
|
36339
|
-
// ../mobius-sdk/src/resources.ts
|
|
36340
|
-
var IDENTIFIER_PATTERN4 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
36341
|
-
function invalidResponse(message) {
|
|
36342
|
-
return new MobiusProtocolError(message);
|
|
36343
|
-
}
|
|
36344
|
-
function isRecord8(value) {
|
|
36345
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36346
|
-
}
|
|
36347
|
-
function record2(value, name) {
|
|
36348
|
-
if (!isRecord8(value)) {
|
|
36349
|
-
throw invalidResponse(`The service returned an invalid ${name}`);
|
|
36350
|
-
}
|
|
36351
|
-
return value;
|
|
36352
|
-
}
|
|
36353
|
-
function stringField(value, field, maximumLength = 85e5) {
|
|
36354
|
-
const candidate = value[field];
|
|
36355
|
-
if (typeof candidate !== "string" || candidate.length > maximumLength) {
|
|
36356
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
36357
|
-
}
|
|
36358
|
-
return candidate;
|
|
36359
|
-
}
|
|
36360
|
-
function identifierField(value, field) {
|
|
36361
|
-
const candidate = stringField(value, field, 128);
|
|
36362
|
-
if (!IDENTIFIER_PATTERN4.test(candidate)) {
|
|
36363
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
36364
|
-
}
|
|
36365
|
-
return candidate;
|
|
36366
|
-
}
|
|
36367
|
-
function integerField(value, field) {
|
|
36368
|
-
const candidate = value[field];
|
|
36369
|
-
if (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0) {
|
|
36370
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
36371
|
-
}
|
|
36372
|
-
return candidate;
|
|
36373
|
-
}
|
|
36374
|
-
function validateTimestamp(value, field) {
|
|
36375
|
-
if (Number.isNaN(Date.parse(value))) {
|
|
36376
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
36377
|
-
}
|
|
36378
|
-
return value;
|
|
36379
|
-
}
|
|
36380
|
-
var MobiusArtifactUploadRequest = class {
|
|
36381
|
-
byteLength;
|
|
36382
|
-
mediaType;
|
|
36383
|
-
name;
|
|
36384
|
-
sha256;
|
|
36385
|
-
constructor(name, mediaType, byteLength, sha256) {
|
|
36386
|
-
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)) {
|
|
36387
|
-
throw new MobiusValidationError("The artifact upload request is invalid");
|
|
36388
|
-
}
|
|
36389
|
-
this.byteLength = byteLength;
|
|
36390
|
-
this.mediaType = mediaType;
|
|
36391
|
-
this.name = name;
|
|
36392
|
-
this.sha256 = sha256;
|
|
36393
|
-
}
|
|
36394
|
-
};
|
|
36395
|
-
var MobiusArtifact = class {
|
|
36396
|
-
artifactId;
|
|
36397
|
-
byteLength;
|
|
36398
|
-
createdAt;
|
|
36399
|
-
mediaType;
|
|
36400
|
-
name;
|
|
36401
|
-
sessionId;
|
|
36402
|
-
sha256;
|
|
36403
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt) {
|
|
36404
|
-
this.artifactId = artifactId;
|
|
36405
|
-
this.byteLength = byteLength;
|
|
36406
|
-
this.createdAt = createdAt;
|
|
36407
|
-
this.mediaType = mediaType;
|
|
36408
|
-
this.name = name;
|
|
36409
|
-
this.sessionId = sessionId;
|
|
36410
|
-
this.sha256 = sha256;
|
|
36411
|
-
}
|
|
36412
|
-
};
|
|
36413
|
-
var MobiusUploadingArtifact = class extends MobiusArtifact {
|
|
36414
|
-
expiresAt;
|
|
36415
|
-
state = "uploading";
|
|
36416
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiresAt) {
|
|
36417
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
36418
|
-
this.expiresAt = expiresAt;
|
|
36419
|
-
}
|
|
36420
|
-
};
|
|
36421
|
-
var MobiusArtifactUpload = class extends MobiusUploadingArtifact {
|
|
36422
|
-
uploadToken;
|
|
36423
|
-
constructor(artifact, uploadToken) {
|
|
36424
|
-
super(
|
|
36425
|
-
artifact.sessionId,
|
|
36426
|
-
artifact.artifactId,
|
|
36427
|
-
artifact.name,
|
|
36428
|
-
artifact.mediaType,
|
|
36429
|
-
artifact.byteLength,
|
|
36430
|
-
artifact.sha256,
|
|
36431
|
-
artifact.createdAt,
|
|
36432
|
-
artifact.expiresAt
|
|
36433
|
-
);
|
|
36434
|
-
this.uploadToken = uploadToken;
|
|
36435
|
-
}
|
|
36436
|
-
};
|
|
36437
|
-
var MobiusAvailableArtifact = class extends MobiusArtifact {
|
|
36438
|
-
availableAt;
|
|
36439
|
-
state = "available";
|
|
36440
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, availableAt) {
|
|
36441
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
36442
|
-
this.availableAt = availableAt;
|
|
36443
|
-
}
|
|
36444
|
-
};
|
|
36445
|
-
var MobiusExpiredArtifact = class extends MobiusArtifact {
|
|
36446
|
-
expiredAt;
|
|
36447
|
-
state = "expired";
|
|
36448
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiredAt) {
|
|
36449
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
36450
|
-
this.expiredAt = expiredAt;
|
|
36451
|
-
}
|
|
36452
|
-
};
|
|
36453
|
-
function artifactFields(value) {
|
|
36454
|
-
const sha256 = stringField(value, "sha256", 64);
|
|
36455
|
-
if (!/^[a-f0-9]{64}$/.test(sha256)) {
|
|
36456
|
-
throw invalidResponse("The service returned an invalid artifact digest");
|
|
36457
|
-
}
|
|
36458
|
-
return {
|
|
36459
|
-
artifactId: identifierField(value, "artifactId"),
|
|
36460
|
-
byteLength: integerField(value, "byteLength"),
|
|
36461
|
-
createdAt: validateTimestamp(stringField(value, "createdAt", 128), "createdAt"),
|
|
36462
|
-
mediaType: stringField(value, "mediaType", 255),
|
|
36463
|
-
name: stringField(value, "name", 500),
|
|
36464
|
-
sessionId: identifierField(value, "sessionId"),
|
|
36465
|
-
sha256
|
|
36466
|
-
};
|
|
36467
|
-
}
|
|
36468
|
-
function uploadingArtifact(value) {
|
|
36469
|
-
const fields = artifactFields(value);
|
|
36470
|
-
return new MobiusUploadingArtifact(
|
|
36471
|
-
fields.sessionId,
|
|
36472
|
-
fields.artifactId,
|
|
36473
|
-
fields.name,
|
|
36474
|
-
fields.mediaType,
|
|
36475
|
-
fields.byteLength,
|
|
36476
|
-
fields.sha256,
|
|
36477
|
-
fields.createdAt,
|
|
36478
|
-
validateTimestamp(stringField(value, "expiresAt", 128), "expiresAt")
|
|
36479
|
-
);
|
|
36480
|
-
}
|
|
36481
|
-
function decodeMobiusArtifactUpload(value) {
|
|
36482
|
-
const artifact = record2(value, "artifact upload authorization");
|
|
36483
|
-
return new MobiusArtifactUpload(uploadingArtifact(artifact), stringField(artifact, "uploadToken", 256));
|
|
36484
|
-
}
|
|
36485
|
-
function decodeMobiusArtifact(value) {
|
|
36486
|
-
const artifact = record2(value, "artifact");
|
|
36487
|
-
const state = stringField(artifact, "state", 32);
|
|
36488
|
-
if (state === "uploading") {
|
|
36489
|
-
return uploadingArtifact(artifact);
|
|
36490
|
-
}
|
|
36491
|
-
const fields = artifactFields(artifact);
|
|
36492
|
-
if (state === "available") {
|
|
36493
|
-
return new MobiusAvailableArtifact(
|
|
36494
|
-
fields.sessionId,
|
|
36495
|
-
fields.artifactId,
|
|
36496
|
-
fields.name,
|
|
36497
|
-
fields.mediaType,
|
|
36498
|
-
fields.byteLength,
|
|
36499
|
-
fields.sha256,
|
|
36500
|
-
fields.createdAt,
|
|
36501
|
-
validateTimestamp(stringField(artifact, "availableAt", 128), "availableAt")
|
|
36502
|
-
);
|
|
36503
|
-
}
|
|
36504
|
-
if (state === "expired") {
|
|
36505
|
-
return new MobiusExpiredArtifact(
|
|
36506
|
-
fields.sessionId,
|
|
36507
|
-
fields.artifactId,
|
|
36508
|
-
fields.name,
|
|
36509
|
-
fields.mediaType,
|
|
36510
|
-
fields.byteLength,
|
|
36511
|
-
fields.sha256,
|
|
36512
|
-
fields.createdAt,
|
|
36513
|
-
validateTimestamp(stringField(artifact, "expiredAt", 128), "expiredAt")
|
|
36514
|
-
);
|
|
36515
|
-
}
|
|
36516
|
-
throw invalidResponse("The service returned an invalid artifact state");
|
|
36517
|
-
}
|
|
36518
|
-
function decodeMobiusAvailableArtifact(value) {
|
|
36519
|
-
const artifact = decodeMobiusArtifact(value);
|
|
36520
|
-
if (!(artifact instanceof MobiusAvailableArtifact)) {
|
|
36521
|
-
throw invalidResponse("The service did not make the artifact available");
|
|
36522
|
-
}
|
|
36523
|
-
return artifact;
|
|
36524
|
-
}
|
|
36525
|
-
var MobiusRuntimePairingLifecycle = Object.freeze({
|
|
36526
|
-
Expired: "expired",
|
|
36527
|
-
Paired: "paired",
|
|
36528
|
-
Pending: "pending",
|
|
36529
|
-
Revoked: "revoked"
|
|
36530
|
-
});
|
|
36531
|
-
|
|
36532
|
-
// src/artifacts/runtime-artifact-uploader.ts
|
|
36533
|
-
import { fetch as fetch3 } from "undici";
|
|
36534
|
-
var UPLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
36535
|
-
var RuntimeArtifactUploadError = class extends Error {
|
|
36536
|
-
code;
|
|
36537
|
-
constructor(code, message, options = {}) {
|
|
36538
|
-
super(message, options);
|
|
36539
|
-
this.code = code;
|
|
36540
|
-
this.name = "RuntimeArtifactUploadError";
|
|
36541
|
-
}
|
|
36542
|
-
};
|
|
36543
|
-
var UploadedRuntimeArtifact = class {
|
|
36544
|
-
artifactId;
|
|
36545
|
-
byteLength;
|
|
36546
|
-
mimeType;
|
|
36547
|
-
name;
|
|
36548
|
-
sha256;
|
|
36549
|
-
constructor(artifactId, name, mimeType, byteLength, sha256) {
|
|
36550
|
-
this.artifactId = artifactId;
|
|
36551
|
-
this.byteLength = byteLength;
|
|
36552
|
-
this.mimeType = mimeType;
|
|
36553
|
-
this.name = name;
|
|
36554
|
-
this.sha256 = sha256;
|
|
36555
|
-
}
|
|
36556
|
-
};
|
|
36557
|
-
function channelOrigin(config2) {
|
|
36558
|
-
const url2 = new URL(config2.relayUrl);
|
|
36559
|
-
url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
|
|
36560
|
-
let channelPath = "";
|
|
36561
|
-
if (url2.pathname.endsWith("/daemon")) {
|
|
36562
|
-
channelPath = url2.pathname.slice(0, -"/daemon".length);
|
|
36563
|
-
} else {
|
|
36564
|
-
const runtimePath = `${MOBIUS_API_PREFIX}/v1/runtimes/connect`;
|
|
36565
|
-
if (!url2.pathname.endsWith("/v1/runtimes/connect") && !url2.pathname.endsWith(runtimePath)) {
|
|
36566
|
-
throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay artifact endpoint is invalid");
|
|
36567
|
-
}
|
|
36568
|
-
channelPath = `${url2.pathname.replace(/\/v1\/runtimes\/connect$/, "")}/channels/${encodeURIComponent(config2.channelId)}`;
|
|
36569
|
-
}
|
|
36570
|
-
url2.pathname = channelPath;
|
|
36571
|
-
url2.search = "";
|
|
36572
|
-
url2.hash = "";
|
|
36573
|
-
return url2;
|
|
36574
|
-
}
|
|
36575
|
-
function uploadError(code, message, cause) {
|
|
36576
|
-
return new RuntimeArtifactUploadError(code, message, cause === void 0 ? {} : { cause });
|
|
36577
|
-
}
|
|
36578
|
-
function translateSdkError(cause) {
|
|
36579
|
-
if (cause instanceof MobiusValidationError) {
|
|
36580
|
-
throw uploadError("artifact_upload_failed", cause.message, cause);
|
|
36581
|
-
}
|
|
36582
|
-
if (cause instanceof MobiusProtocolError) {
|
|
36583
|
-
throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
|
|
36584
|
-
}
|
|
36585
|
-
throw cause;
|
|
36586
|
-
}
|
|
36587
|
-
async function readJson(response) {
|
|
36588
|
-
try {
|
|
36589
|
-
return await response.json();
|
|
36590
|
-
} catch (cause) {
|
|
36591
|
-
throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
|
|
36592
|
-
}
|
|
36593
|
-
}
|
|
36594
|
-
async function readAuthorization(response) {
|
|
36595
|
-
try {
|
|
36596
|
-
return decodeMobiusArtifactUpload(await readJson(response));
|
|
36597
|
-
} catch (cause) {
|
|
36598
|
-
translateSdkError(cause);
|
|
36599
|
-
}
|
|
36600
|
-
}
|
|
36601
|
-
function sessionArtifactUrl(origin, sessionId, resourcePath) {
|
|
36602
|
-
return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
|
|
36603
|
-
}
|
|
36604
|
-
async function postLease(url2, headers, request, signal) {
|
|
36605
|
-
return await fetch3(url2, {
|
|
36606
|
-
dispatcher: environmentProxyDispatcher,
|
|
36607
|
-
headers: { ...headers, "content-type": "application/json" },
|
|
36608
|
-
method: "POST",
|
|
36609
|
-
body: JSON.stringify(request),
|
|
36610
|
-
signal
|
|
36611
|
-
});
|
|
36612
|
-
}
|
|
36613
|
-
async function putContent(url2, headers, authorization, bytes, signal) {
|
|
36614
|
-
return await fetch3(url2, {
|
|
36615
|
-
dispatcher: environmentProxyDispatcher,
|
|
36616
|
-
headers: {
|
|
36617
|
-
...headers,
|
|
36618
|
-
"content-type": authorization.mediaType,
|
|
36619
|
-
"x-mobius-upload-token": authorization.uploadToken
|
|
36620
|
-
},
|
|
36621
|
-
method: "PUT",
|
|
36622
|
-
body: bytes,
|
|
36623
|
-
signal
|
|
36614
|
+
send2({
|
|
36615
|
+
kind: FILE_END_KIND,
|
|
36616
|
+
requestId: command.requestId,
|
|
36617
|
+
sessionId: command.sessionId
|
|
36624
36618
|
});
|
|
36625
36619
|
}
|
|
36626
|
-
async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
36627
|
-
signal.throwIfAborted();
|
|
36628
|
-
let request;
|
|
36629
|
-
try {
|
|
36630
|
-
request = new MobiusArtifactUploadRequest(
|
|
36631
|
-
artifact.name,
|
|
36632
|
-
artifact.mimeType,
|
|
36633
|
-
artifact.bytes.byteLength,
|
|
36634
|
-
createHash2("sha256").update(artifact.bytes).digest("hex")
|
|
36635
|
-
);
|
|
36636
|
-
} catch (cause) {
|
|
36637
|
-
translateSdkError(cause);
|
|
36638
|
-
}
|
|
36639
|
-
const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
|
|
36640
|
-
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
36641
|
-
const origin = channelOrigin(config2);
|
|
36642
|
-
const headers = runtimeAuthorization(config2.relayUrl);
|
|
36643
|
-
let created;
|
|
36644
|
-
try {
|
|
36645
|
-
created = await postLease(
|
|
36646
|
-
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
|
|
36647
|
-
headers,
|
|
36648
|
-
request,
|
|
36649
|
-
requestSignal
|
|
36650
|
-
);
|
|
36651
|
-
} catch (cause) {
|
|
36652
|
-
signal.throwIfAborted();
|
|
36653
|
-
throw uploadError(
|
|
36654
|
-
timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
|
|
36655
|
-
timeoutSignal.aborted ? "The artifact upload authorization timed out" : "The artifact upload could not start",
|
|
36656
|
-
cause
|
|
36657
|
-
);
|
|
36658
|
-
}
|
|
36659
|
-
if (!created.ok) {
|
|
36660
|
-
await created.body?.cancel();
|
|
36661
|
-
throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact upload");
|
|
36662
|
-
}
|
|
36663
|
-
const authorization = await readAuthorization(created);
|
|
36664
|
-
let uploaded;
|
|
36665
|
-
try {
|
|
36666
|
-
uploaded = await putContent(
|
|
36667
|
-
sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
|
|
36668
|
-
headers,
|
|
36669
|
-
authorization,
|
|
36670
|
-
artifact.bytes,
|
|
36671
|
-
requestSignal
|
|
36672
|
-
);
|
|
36673
|
-
} catch (cause) {
|
|
36674
|
-
signal.throwIfAborted();
|
|
36675
|
-
throw uploadError(
|
|
36676
|
-
timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
|
|
36677
|
-
timeoutSignal.aborted ? "The artifact upload timed out" : "The artifact content could not be uploaded",
|
|
36678
|
-
cause
|
|
36679
|
-
);
|
|
36680
|
-
}
|
|
36681
|
-
if (!uploaded.ok) {
|
|
36682
|
-
await uploaded.body?.cancel();
|
|
36683
|
-
throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact content");
|
|
36684
|
-
}
|
|
36685
|
-
try {
|
|
36686
|
-
const available = decodeMobiusAvailableArtifact(await readJson(uploaded));
|
|
36687
|
-
return new UploadedRuntimeArtifact(
|
|
36688
|
-
available.artifactId,
|
|
36689
|
-
available.name,
|
|
36690
|
-
available.mediaType,
|
|
36691
|
-
available.byteLength,
|
|
36692
|
-
available.sha256
|
|
36693
|
-
);
|
|
36694
|
-
} catch (cause) {
|
|
36695
|
-
translateSdkError(cause);
|
|
36696
|
-
}
|
|
36697
|
-
}
|
|
36698
36620
|
|
|
36699
36621
|
// src/authorization/local-authorization-error.ts
|
|
36700
36622
|
var LocalAuthorizationError = class extends Error {
|
|
@@ -37524,13 +37446,13 @@ var NativeSessionService = class {
|
|
|
37524
37446
|
};
|
|
37525
37447
|
|
|
37526
37448
|
// src/prompt-artifact-resolver.ts
|
|
37527
|
-
import { createHash as
|
|
37528
|
-
import { fetch as
|
|
37449
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
37450
|
+
import { fetch as fetch3 } from "undici";
|
|
37529
37451
|
var ARTIFACT_SCHEME = "mobius-artifact:";
|
|
37530
37452
|
var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
37531
37453
|
var MAX_AGENT_IMAGE_BASE64_LENGTH = 4e6;
|
|
37532
37454
|
var MAX_AGENT_RESOURCE_BYTE_LENGTH = 1e6;
|
|
37533
|
-
var
|
|
37455
|
+
var IDENTIFIER_PATTERN4 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
37534
37456
|
var PromptArtifactError = class extends Error {
|
|
37535
37457
|
code;
|
|
37536
37458
|
constructor(code, message, options = {}) {
|
|
@@ -37573,7 +37495,7 @@ function parseReference(resource) {
|
|
|
37573
37495
|
const encodedByteLength2 = url2.searchParams.get("byteLength") ?? "";
|
|
37574
37496
|
const sha256 = url2.searchParams.get("sha256") ?? "";
|
|
37575
37497
|
const byteLength = Number(encodedByteLength2);
|
|
37576
|
-
if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !
|
|
37498
|
+
if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !IDENTIFIER_PATTERN4.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)) {
|
|
37577
37499
|
throw new PromptArtifactError("artifact_reference_invalid", "The prompt artifact reference is invalid");
|
|
37578
37500
|
}
|
|
37579
37501
|
return new PromptArtifactReference(artifactId, byteLength, sha256, resource);
|
|
@@ -37639,7 +37561,7 @@ async function download(config2, command, reference, signal) {
|
|
|
37639
37561
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37640
37562
|
let response;
|
|
37641
37563
|
try {
|
|
37642
|
-
response = await
|
|
37564
|
+
response = await fetch3(downloadUrl(config2, command, reference), {
|
|
37643
37565
|
dispatcher: environmentProxyDispatcher,
|
|
37644
37566
|
headers: {
|
|
37645
37567
|
accept: reference.resource.mimeType,
|
|
@@ -37663,7 +37585,7 @@ async function download(config2, command, reference, signal) {
|
|
|
37663
37585
|
);
|
|
37664
37586
|
}
|
|
37665
37587
|
const bytes = await responseBytes(response, reference.byteLength, requestSignal);
|
|
37666
|
-
if (
|
|
37588
|
+
if (createHash2("sha256").update(bytes).digest("hex") !== reference.sha256) {
|
|
37667
37589
|
throw new PromptArtifactError(
|
|
37668
37590
|
"artifact_integrity_failed",
|
|
37669
37591
|
"The prompt artifact failed integrity validation"
|
|
@@ -38153,12 +38075,10 @@ var RelayConnectionLiveness = class {
|
|
|
38153
38075
|
heartbeatId,
|
|
38154
38076
|
this.#timer.schedule(this.#handleTimeout, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS)
|
|
38155
38077
|
);
|
|
38156
|
-
const sent = this.#transport.send(
|
|
38157
|
-
|
|
38158
|
-
|
|
38159
|
-
|
|
38160
|
-
})
|
|
38161
|
-
);
|
|
38078
|
+
const sent = this.#transport.send({
|
|
38079
|
+
heartbeatId,
|
|
38080
|
+
kind: RUNTIME_HEARTBEAT_KIND
|
|
38081
|
+
});
|
|
38162
38082
|
if (!sent && this.#state instanceof AwaitingHeartbeatAckState && this.#state.heartbeatId === heartbeatId) {
|
|
38163
38083
|
this.#state.timeout.cancel();
|
|
38164
38084
|
this.#state = new FinishedRelayLivenessState();
|
|
@@ -38770,47 +38690,44 @@ var AGENT_TEXT_MAXIMUM_LENGTH = 1e5;
|
|
|
38770
38690
|
var ACTIVE_TURN_RECONCILIATION_TIMEOUT_MILLISECONDS = 2e4;
|
|
38771
38691
|
var ACTIVE_TURN_RECONCILIATION_CLOSE_CODE = 4009;
|
|
38772
38692
|
var DaemonAcpObserver = class {
|
|
38773
|
-
#config;
|
|
38774
38693
|
#record;
|
|
38775
|
-
constructor(
|
|
38776
|
-
this.#
|
|
38777
|
-
this.#record = record3;
|
|
38694
|
+
constructor(record2) {
|
|
38695
|
+
this.#record = record2;
|
|
38778
38696
|
}
|
|
38779
|
-
importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
38780
38697
|
onCommands = (event) => {
|
|
38781
|
-
this.#record(event.sessionId,
|
|
38698
|
+
this.#record(event.sessionId, event);
|
|
38782
38699
|
return Promise.resolve();
|
|
38783
38700
|
};
|
|
38784
38701
|
onConfig = (event) => {
|
|
38785
|
-
this.#record(event.sessionId,
|
|
38702
|
+
this.#record(event.sessionId, event);
|
|
38786
38703
|
return Promise.resolve();
|
|
38787
38704
|
};
|
|
38788
38705
|
onContent = (event) => {
|
|
38789
|
-
this.#record(event.sessionId,
|
|
38706
|
+
this.#record(event.sessionId, event);
|
|
38790
38707
|
return Promise.resolve();
|
|
38791
38708
|
};
|
|
38792
38709
|
onElicitation = (event) => {
|
|
38793
|
-
this.#record(event.sessionId,
|
|
38710
|
+
this.#record(event.sessionId, event);
|
|
38794
38711
|
return Promise.resolve();
|
|
38795
38712
|
};
|
|
38796
38713
|
onElicitationResolved = (event) => {
|
|
38797
|
-
this.#record(event.sessionId,
|
|
38714
|
+
this.#record(event.sessionId, event);
|
|
38798
38715
|
return Promise.resolve();
|
|
38799
38716
|
};
|
|
38800
38717
|
onInfo = (event) => {
|
|
38801
|
-
this.#record(event.sessionId,
|
|
38718
|
+
this.#record(event.sessionId, event);
|
|
38802
38719
|
return Promise.resolve();
|
|
38803
38720
|
};
|
|
38804
38721
|
onPermission = (event) => {
|
|
38805
|
-
this.#record(event.sessionId,
|
|
38722
|
+
this.#record(event.sessionId, event);
|
|
38806
38723
|
return Promise.resolve();
|
|
38807
38724
|
};
|
|
38808
38725
|
onPermissionResolved = (event) => {
|
|
38809
|
-
this.#record(event.sessionId,
|
|
38726
|
+
this.#record(event.sessionId, event);
|
|
38810
38727
|
return Promise.resolve();
|
|
38811
38728
|
};
|
|
38812
38729
|
onUsage = (event) => {
|
|
38813
|
-
this.#record(event.sessionId,
|
|
38730
|
+
this.#record(event.sessionId, event);
|
|
38814
38731
|
return Promise.resolve();
|
|
38815
38732
|
};
|
|
38816
38733
|
};
|
|
@@ -38859,60 +38776,45 @@ var DaemonInstallationObserver = class {
|
|
|
38859
38776
|
if (state instanceof RunningInstallation) {
|
|
38860
38777
|
if (!this.#started.has(state.requestId)) {
|
|
38861
38778
|
this.#started.add(state.requestId);
|
|
38862
|
-
this.#send(
|
|
38863
|
-
socket,
|
|
38864
|
-
encodeAgentInstallStartedEvent({
|
|
38865
|
-
agentId: state.agentId,
|
|
38866
|
-
kind: AGENT_INSTALL_STARTED_KIND,
|
|
38867
|
-
requestId: state.requestId
|
|
38868
|
-
})
|
|
38869
|
-
);
|
|
38870
|
-
}
|
|
38871
|
-
this.#send(
|
|
38872
|
-
socket,
|
|
38873
|
-
encodeAgentInstallProgressEvent({
|
|
38779
|
+
this.#send(socket, {
|
|
38874
38780
|
agentId: state.agentId,
|
|
38875
|
-
kind:
|
|
38876
|
-
requestId: state.requestId
|
|
38877
|
-
|
|
38878
|
-
|
|
38879
|
-
|
|
38781
|
+
kind: AGENT_INSTALL_STARTED_KIND,
|
|
38782
|
+
requestId: state.requestId
|
|
38783
|
+
});
|
|
38784
|
+
}
|
|
38785
|
+
this.#send(socket, {
|
|
38786
|
+
agentId: state.agentId,
|
|
38787
|
+
kind: AGENT_INSTALL_PROGRESS_KIND,
|
|
38788
|
+
requestId: state.requestId,
|
|
38789
|
+
stage: state.stage
|
|
38790
|
+
});
|
|
38880
38791
|
return Promise.resolve();
|
|
38881
38792
|
}
|
|
38882
38793
|
if (state instanceof SucceededInstallation) {
|
|
38883
|
-
this.#send(
|
|
38884
|
-
|
|
38885
|
-
|
|
38886
|
-
|
|
38887
|
-
|
|
38888
|
-
|
|
38889
|
-
requestId: state.requestId
|
|
38890
|
-
})
|
|
38891
|
-
);
|
|
38794
|
+
this.#send(socket, {
|
|
38795
|
+
agentId: state.agentId,
|
|
38796
|
+
authenticationMayBeRequired: state.authenticationMayBeRequired,
|
|
38797
|
+
kind: AGENT_INSTALL_COMPLETED_KIND,
|
|
38798
|
+
requestId: state.requestId
|
|
38799
|
+
});
|
|
38892
38800
|
return Promise.resolve();
|
|
38893
38801
|
}
|
|
38894
38802
|
if (state instanceof FailedInstallation) {
|
|
38895
|
-
this.#send(
|
|
38896
|
-
|
|
38897
|
-
|
|
38898
|
-
|
|
38899
|
-
|
|
38900
|
-
|
|
38901
|
-
|
|
38902
|
-
requestId: state.requestId
|
|
38903
|
-
})
|
|
38904
|
-
);
|
|
38803
|
+
this.#send(socket, {
|
|
38804
|
+
agentId: state.agentId,
|
|
38805
|
+
code: state.code,
|
|
38806
|
+
kind: AGENT_INSTALL_FAILED_KIND,
|
|
38807
|
+
message: state.message,
|
|
38808
|
+
requestId: state.requestId
|
|
38809
|
+
});
|
|
38905
38810
|
return Promise.resolve();
|
|
38906
38811
|
}
|
|
38907
38812
|
if (state instanceof CancelledInstallation) {
|
|
38908
|
-
this.#send(
|
|
38909
|
-
|
|
38910
|
-
|
|
38911
|
-
|
|
38912
|
-
|
|
38913
|
-
requestId: state.requestId
|
|
38914
|
-
})
|
|
38915
|
-
);
|
|
38813
|
+
this.#send(socket, {
|
|
38814
|
+
agentId: state.agentId,
|
|
38815
|
+
kind: AGENT_INSTALL_CANCELLED_KIND,
|
|
38816
|
+
requestId: state.requestId
|
|
38817
|
+
});
|
|
38916
38818
|
return Promise.resolve();
|
|
38917
38819
|
}
|
|
38918
38820
|
throw new Error("Unsupported Agent integration installation state");
|
|
@@ -39009,7 +38911,7 @@ async function reconcileActiveTurn(config2, turn, signal) {
|
|
|
39009
38911
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
39010
38912
|
let response;
|
|
39011
38913
|
try {
|
|
39012
|
-
response = await
|
|
38914
|
+
response = await fetch4(activeTurnReconciliationEndpoint(config2, turn), {
|
|
39013
38915
|
body: JSON.stringify({ outcome: { kind: "running" } }),
|
|
39014
38916
|
dispatcher: environmentProxyDispatcher,
|
|
39015
38917
|
headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
|
|
@@ -39042,7 +38944,7 @@ function send(socket, message) {
|
|
|
39042
38944
|
if (socket.readyState !== WebSocket2.OPEN) {
|
|
39043
38945
|
throw new Error("Relay connection is not open");
|
|
39044
38946
|
}
|
|
39045
|
-
socket.send(message);
|
|
38947
|
+
socket.send(encodeDaemonToServiceMessage(message));
|
|
39046
38948
|
}
|
|
39047
38949
|
function closeRelaySocket(socket, code, reason) {
|
|
39048
38950
|
try {
|
|
@@ -39076,7 +38978,7 @@ var ConnectedDaemonSessionEventState = class extends DaemonSessionEventConnectio
|
|
|
39076
38978
|
return false;
|
|
39077
38979
|
}
|
|
39078
38980
|
try {
|
|
39079
|
-
this.#socket.send(message);
|
|
38981
|
+
this.#socket.send(encodeDaemonToServiceMessage(message));
|
|
39080
38982
|
return true;
|
|
39081
38983
|
} catch {
|
|
39082
38984
|
return false;
|
|
@@ -39120,17 +39022,17 @@ var DaemonSessionEventPublisher = class {
|
|
|
39120
39022
|
this.#connection = this.#connection.disconnect(socket);
|
|
39121
39023
|
this.#clearInFlight();
|
|
39122
39024
|
};
|
|
39123
|
-
recordAttempt = (sessionId,
|
|
39124
|
-
const
|
|
39125
|
-
if (kind === SESSION_COMPLETED_KIND || kind === SESSION_FAILED_KIND) {
|
|
39126
|
-
this.#outbox.enqueueCritical(sessionId,
|
|
39025
|
+
recordAttempt = (sessionId, event, attemptId) => {
|
|
39026
|
+
const encoded = encodeRecordedSessionEvent(event);
|
|
39027
|
+
if (event.kind === SESSION_COMPLETED_KIND || event.kind === SESSION_FAILED_KIND) {
|
|
39028
|
+
this.#outbox.enqueueCritical(sessionId, encoded, attemptId);
|
|
39127
39029
|
} else {
|
|
39128
|
-
this.#outbox.enqueue(sessionId,
|
|
39030
|
+
this.#outbox.enqueue(sessionId, encoded, attemptId);
|
|
39129
39031
|
}
|
|
39130
39032
|
this.#publishNextBatch();
|
|
39131
39033
|
};
|
|
39132
|
-
recordRuntime = (sessionId,
|
|
39133
|
-
this.#outbox.enqueue(sessionId,
|
|
39034
|
+
recordRuntime = (sessionId, event) => {
|
|
39035
|
+
this.#outbox.enqueue(sessionId, encodeRecordedSessionEvent(event));
|
|
39134
39036
|
this.#publishNextBatch();
|
|
39135
39037
|
};
|
|
39136
39038
|
acknowledge = (acknowledgement) => {
|
|
@@ -39197,7 +39099,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
39197
39099
|
if (this.#inFlightBytes + byteLength > SESSION_EVENT_REPLAY_BYTE_LIMIT) {
|
|
39198
39100
|
continue;
|
|
39199
39101
|
}
|
|
39200
|
-
if (!this.#connection.send(
|
|
39102
|
+
if (!this.#connection.send(envelope2)) {
|
|
39201
39103
|
this.#clearInFlight();
|
|
39202
39104
|
return;
|
|
39203
39105
|
}
|
|
@@ -39291,8 +39193,8 @@ var CoalescingDaemonActivityPublisher = class {
|
|
|
39291
39193
|
}
|
|
39292
39194
|
};
|
|
39293
39195
|
};
|
|
39294
|
-
function
|
|
39295
|
-
return
|
|
39196
|
+
function daemonActivity(command, activity) {
|
|
39197
|
+
return {
|
|
39296
39198
|
activityId: activity.activityId,
|
|
39297
39199
|
activityType: activity.activityType,
|
|
39298
39200
|
commandId: command.commandId,
|
|
@@ -39308,18 +39210,18 @@ function encodeDaemonActivity(command, activity) {
|
|
|
39308
39210
|
status: activity.status,
|
|
39309
39211
|
title: activity.title,
|
|
39310
39212
|
toolKind: activity.toolKind
|
|
39311
|
-
}
|
|
39213
|
+
};
|
|
39312
39214
|
}
|
|
39313
39215
|
function reportFailure(publisher, command, code, message, attemptId) {
|
|
39314
39216
|
publisher.recordAttempt(
|
|
39315
39217
|
command.sessionId,
|
|
39316
|
-
|
|
39218
|
+
{
|
|
39317
39219
|
code,
|
|
39318
39220
|
commandId: command.commandId,
|
|
39319
39221
|
kind: SESSION_FAILED_KIND,
|
|
39320
39222
|
message,
|
|
39321
39223
|
sessionId: command.sessionId
|
|
39322
|
-
}
|
|
39224
|
+
},
|
|
39323
39225
|
attemptId
|
|
39324
39226
|
);
|
|
39325
39227
|
}
|
|
@@ -39339,17 +39241,14 @@ function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTi
|
|
|
39339
39241
|
if (socket.readyState !== WebSocket2.OPEN) {
|
|
39340
39242
|
return;
|
|
39341
39243
|
}
|
|
39342
|
-
send(
|
|
39343
|
-
|
|
39344
|
-
|
|
39345
|
-
|
|
39346
|
-
|
|
39347
|
-
|
|
39348
|
-
|
|
39349
|
-
|
|
39350
|
-
sessionId
|
|
39351
|
-
})
|
|
39352
|
-
);
|
|
39244
|
+
send(socket, {
|
|
39245
|
+
code: operationErrorCode(error62),
|
|
39246
|
+
kind: "session.operation.failed",
|
|
39247
|
+
message: operationErrorMessage(error62),
|
|
39248
|
+
requestId,
|
|
39249
|
+
...runtimeTimings.length === 0 ? {} : { runtimeTimings },
|
|
39250
|
+
sessionId
|
|
39251
|
+
});
|
|
39353
39252
|
}
|
|
39354
39253
|
async function resolveSessionDirectories(directories, bindingId, directoryId2, additionalDirectoryIds, signal) {
|
|
39355
39254
|
const cwd = await directories.resolve(bindingId, directoryId2, signal);
|
|
@@ -39522,7 +39421,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
39522
39421
|
resolution: modelEffort.resolution,
|
|
39523
39422
|
valuesByModel: {}
|
|
39524
39423
|
};
|
|
39525
|
-
return
|
|
39424
|
+
return createHash3("sha256").update(
|
|
39526
39425
|
JSON.stringify({
|
|
39527
39426
|
adapterVersion: agent.adapterVersion,
|
|
39528
39427
|
agentId: agent.id,
|
|
@@ -39541,18 +39440,15 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
|
|
|
39541
39440
|
event: "workspace_list_authorized",
|
|
39542
39441
|
sessionId: "workspace-browser"
|
|
39543
39442
|
});
|
|
39544
|
-
send(
|
|
39545
|
-
|
|
39546
|
-
|
|
39547
|
-
|
|
39548
|
-
|
|
39549
|
-
|
|
39550
|
-
|
|
39551
|
-
|
|
39552
|
-
|
|
39553
|
-
requestId: command.requestId
|
|
39554
|
-
})
|
|
39555
|
-
);
|
|
39443
|
+
send(socket, {
|
|
39444
|
+
bindingId: command.bindingId,
|
|
39445
|
+
directoryId: listing.directoryId,
|
|
39446
|
+
directoryLabel: listing.directoryLabel,
|
|
39447
|
+
entries: listing.entries,
|
|
39448
|
+
kind: "workspace.entries",
|
|
39449
|
+
parentDirectoryId: listing.parentDirectoryId,
|
|
39450
|
+
requestId: command.requestId
|
|
39451
|
+
});
|
|
39556
39452
|
} catch (error62) {
|
|
39557
39453
|
reportOperationFailure(socket, command.requestId, "", error62);
|
|
39558
39454
|
}
|
|
@@ -39607,15 +39503,12 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
39607
39503
|
event: "session_configured",
|
|
39608
39504
|
sessionId: command.sessionId
|
|
39609
39505
|
});
|
|
39610
|
-
publisher.recordRuntime(
|
|
39611
|
-
|
|
39612
|
-
|
|
39613
|
-
|
|
39614
|
-
|
|
39615
|
-
|
|
39616
|
-
sessionId: command.sessionId
|
|
39617
|
-
})
|
|
39618
|
-
);
|
|
39506
|
+
publisher.recordRuntime(command.sessionId, {
|
|
39507
|
+
configOptions,
|
|
39508
|
+
kind: "session.config.updated",
|
|
39509
|
+
requestId: command.requestId,
|
|
39510
|
+
sessionId: command.sessionId
|
|
39511
|
+
});
|
|
39619
39512
|
}
|
|
39620
39513
|
const event = {
|
|
39621
39514
|
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
@@ -39634,17 +39527,14 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
39634
39527
|
runtimeTimings: metrics.snapshot()
|
|
39635
39528
|
};
|
|
39636
39529
|
metrics.measureSync("readiness-commit", () => {
|
|
39637
|
-
publisher.recordRuntime(command.sessionId,
|
|
39530
|
+
publisher.recordRuntime(command.sessionId, event);
|
|
39638
39531
|
});
|
|
39639
39532
|
return event;
|
|
39640
39533
|
});
|
|
39641
|
-
send(
|
|
39642
|
-
|
|
39643
|
-
|
|
39644
|
-
|
|
39645
|
-
runtimeTimings: metrics.snapshot()
|
|
39646
|
-
})
|
|
39647
|
-
);
|
|
39534
|
+
send(socket, {
|
|
39535
|
+
...readyEvent,
|
|
39536
|
+
runtimeTimings: metrics.snapshot()
|
|
39537
|
+
});
|
|
39648
39538
|
} catch (error62) {
|
|
39649
39539
|
audit.record({
|
|
39650
39540
|
commandId: command.requestId,
|
|
@@ -39684,15 +39574,12 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
39684
39574
|
event: "session_configured",
|
|
39685
39575
|
sessionId: command.sessionId
|
|
39686
39576
|
});
|
|
39687
|
-
publisher.recordRuntime(
|
|
39688
|
-
|
|
39689
|
-
|
|
39690
|
-
|
|
39691
|
-
|
|
39692
|
-
|
|
39693
|
-
sessionId: command.sessionId
|
|
39694
|
-
})
|
|
39695
|
-
);
|
|
39577
|
+
publisher.recordRuntime(command.sessionId, {
|
|
39578
|
+
configOptions,
|
|
39579
|
+
kind: "session.config.updated",
|
|
39580
|
+
requestId: command.requestId,
|
|
39581
|
+
sessionId: command.sessionId
|
|
39582
|
+
});
|
|
39696
39583
|
} catch (error62) {
|
|
39697
39584
|
if (signal.aborted) {
|
|
39698
39585
|
signal.throwIfAborted();
|
|
@@ -39702,20 +39589,20 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
39702
39589
|
}
|
|
39703
39590
|
async function executePrompt(outbox, publisher, command, config2, directories, audit, sessions, attemptId, activateAttempt, timer, signal) {
|
|
39704
39591
|
const activities = new CoalescingDaemonActivityPublisher(timer, (activity) => {
|
|
39705
|
-
publisher.recordAttempt(command.sessionId,
|
|
39592
|
+
publisher.recordAttempt(command.sessionId, daemonActivity(command, activity), attemptId);
|
|
39706
39593
|
});
|
|
39707
39594
|
const text3 = new CoalescingTextPublisher(
|
|
39708
39595
|
timer,
|
|
39709
39596
|
(messageId, delta) => {
|
|
39710
39597
|
publisher.recordAttempt(
|
|
39711
39598
|
command.sessionId,
|
|
39712
|
-
|
|
39599
|
+
{
|
|
39713
39600
|
commandId: command.commandId,
|
|
39714
39601
|
kind: AGENT_MESSAGE_DELTA_KIND,
|
|
39715
39602
|
messageId,
|
|
39716
39603
|
sessionId: command.sessionId,
|
|
39717
39604
|
text: delta
|
|
39718
|
-
}
|
|
39605
|
+
},
|
|
39719
39606
|
attemptId
|
|
39720
39607
|
);
|
|
39721
39608
|
},
|
|
@@ -39774,12 +39661,12 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
39774
39661
|
outbox.transitionExecution(command.commandId, "running");
|
|
39775
39662
|
publisher.recordAttempt(
|
|
39776
39663
|
command.sessionId,
|
|
39777
|
-
|
|
39664
|
+
{
|
|
39778
39665
|
commandId: command.commandId,
|
|
39779
39666
|
kind: SESSION_STARTED_KIND,
|
|
39780
39667
|
attemptId,
|
|
39781
39668
|
sessionId: command.sessionId
|
|
39782
|
-
}
|
|
39669
|
+
},
|
|
39783
39670
|
attemptId
|
|
39784
39671
|
);
|
|
39785
39672
|
activateAttempt();
|
|
@@ -39824,12 +39711,12 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
39824
39711
|
activities.flush();
|
|
39825
39712
|
publisher.recordAttempt(
|
|
39826
39713
|
command.sessionId,
|
|
39827
|
-
|
|
39714
|
+
{
|
|
39828
39715
|
commandId: command.commandId,
|
|
39829
39716
|
kind: SESSION_COMPLETED_KIND,
|
|
39830
39717
|
sessionId: command.sessionId,
|
|
39831
39718
|
stopReason
|
|
39832
|
-
}
|
|
39719
|
+
},
|
|
39833
39720
|
attemptId
|
|
39834
39721
|
);
|
|
39835
39722
|
outbox.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
@@ -40253,9 +40140,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40253
40140
|
}
|
|
40254
40141
|
};
|
|
40255
40142
|
const processDeliveredPayload = async (delivery) => {
|
|
40256
|
-
const
|
|
40143
|
+
const message = decodeServiceToDaemonMessage(delivery.payload);
|
|
40144
|
+
const kind = message.kind;
|
|
40257
40145
|
if (kind === SESSION_CANCEL_KIND) {
|
|
40258
|
-
const cancellation =
|
|
40146
|
+
const cancellation = message;
|
|
40259
40147
|
if (cancellation.sessionId !== delivery.sessionId) {
|
|
40260
40148
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40261
40149
|
}
|
|
@@ -40272,7 +40160,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40272
40160
|
return;
|
|
40273
40161
|
}
|
|
40274
40162
|
if (kind === SESSION_CONFIGURE_KIND) {
|
|
40275
|
-
const command =
|
|
40163
|
+
const command = message;
|
|
40276
40164
|
if (command.sessionId !== delivery.sessionId) {
|
|
40277
40165
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40278
40166
|
}
|
|
@@ -40289,7 +40177,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40289
40177
|
return;
|
|
40290
40178
|
}
|
|
40291
40179
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
40292
|
-
const command =
|
|
40180
|
+
const command = message;
|
|
40293
40181
|
if (command.sessionId !== delivery.sessionId) {
|
|
40294
40182
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40295
40183
|
}
|
|
@@ -40306,7 +40194,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40306
40194
|
return;
|
|
40307
40195
|
}
|
|
40308
40196
|
if (kind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
40309
|
-
const command =
|
|
40197
|
+
const command = message;
|
|
40310
40198
|
if (command.sessionId !== delivery.sessionId) {
|
|
40311
40199
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40312
40200
|
}
|
|
@@ -40323,7 +40211,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40323
40211
|
return;
|
|
40324
40212
|
}
|
|
40325
40213
|
if (kind === SESSION_PROMPT_KIND) {
|
|
40326
|
-
const command =
|
|
40214
|
+
const command = message;
|
|
40327
40215
|
await processDeliveredPrompt(
|
|
40328
40216
|
delivery,
|
|
40329
40217
|
command,
|
|
@@ -40367,18 +40255,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40367
40255
|
}).finally(() => processingDeliveryIds.delete(delivery.deliveryId));
|
|
40368
40256
|
};
|
|
40369
40257
|
const receiveRuntimeDelivery = (delivery) => {
|
|
40370
|
-
const
|
|
40258
|
+
const payload = decodeServiceToDaemonMessage(delivery.payload);
|
|
40259
|
+
const payloadKind = payload.kind;
|
|
40371
40260
|
let payloadSessionId = "";
|
|
40372
40261
|
if (payloadKind === SESSION_CANCEL_KIND) {
|
|
40373
|
-
payloadSessionId =
|
|
40262
|
+
payloadSessionId = payload.sessionId;
|
|
40374
40263
|
} else if (payloadKind === SESSION_CONFIGURE_KIND) {
|
|
40375
|
-
payloadSessionId =
|
|
40264
|
+
payloadSessionId = payload.sessionId;
|
|
40376
40265
|
} else if (payloadKind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
40377
|
-
payloadSessionId =
|
|
40266
|
+
payloadSessionId = payload.sessionId;
|
|
40378
40267
|
} else if (payloadKind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
40379
|
-
payloadSessionId =
|
|
40268
|
+
payloadSessionId = payload.sessionId;
|
|
40380
40269
|
} else if (payloadKind === SESSION_PROMPT_KIND) {
|
|
40381
|
-
payloadSessionId =
|
|
40270
|
+
payloadSessionId = payload.sessionId;
|
|
40382
40271
|
} else {
|
|
40383
40272
|
throw new Error("Runtime delivery contains an unsupported protocol message");
|
|
40384
40273
|
}
|
|
@@ -40386,14 +40275,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40386
40275
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40387
40276
|
}
|
|
40388
40277
|
const stored = outbox.claimRuntimeDelivery(delivery);
|
|
40389
|
-
send(
|
|
40390
|
-
|
|
40391
|
-
|
|
40392
|
-
|
|
40393
|
-
|
|
40394
|
-
sessionId: delivery.sessionId
|
|
40395
|
-
})
|
|
40396
|
-
);
|
|
40278
|
+
send(socket, {
|
|
40279
|
+
deliveryId: delivery.deliveryId,
|
|
40280
|
+
kind: RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
40281
|
+
sessionId: delivery.sessionId
|
|
40282
|
+
});
|
|
40397
40283
|
processRuntimeDelivery(delivery, stored.state);
|
|
40398
40284
|
};
|
|
40399
40285
|
const resumeRuntimeDeliveries = () => {
|
|
@@ -40405,14 +40291,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40405
40291
|
sessionId: stored.sessionId
|
|
40406
40292
|
};
|
|
40407
40293
|
if (stored.state !== "relay_committed") {
|
|
40408
|
-
send(
|
|
40409
|
-
|
|
40410
|
-
|
|
40411
|
-
|
|
40412
|
-
|
|
40413
|
-
sessionId: stored.sessionId
|
|
40414
|
-
})
|
|
40415
|
-
);
|
|
40294
|
+
send(socket, {
|
|
40295
|
+
deliveryId: stored.deliveryId,
|
|
40296
|
+
kind: RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
40297
|
+
sessionId: stored.sessionId
|
|
40298
|
+
});
|
|
40416
40299
|
}
|
|
40417
40300
|
processRuntimeDelivery(delivery, stored.state);
|
|
40418
40301
|
}
|
|
@@ -40471,28 +40354,29 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40471
40354
|
return;
|
|
40472
40355
|
}
|
|
40473
40356
|
try {
|
|
40474
|
-
const
|
|
40357
|
+
const message = decodeServiceToDaemonMessage(encoded);
|
|
40358
|
+
const kind = message.kind;
|
|
40475
40359
|
if (kind === RUNTIME_DELIVERY_COMMITTED_KIND) {
|
|
40476
|
-
const committed =
|
|
40360
|
+
const committed = message;
|
|
40477
40361
|
if (!outbox.markRuntimeDeliveryCommitted(committed.deliveryId, committed.sessionId)) {
|
|
40478
40362
|
console.warn("Mobius daemon ignored confirmation for an unknown Runtime delivery");
|
|
40479
40363
|
}
|
|
40480
40364
|
return;
|
|
40481
40365
|
}
|
|
40482
40366
|
if (kind === RUNTIME_DELIVERY_KIND) {
|
|
40483
|
-
receiveRuntimeDelivery(
|
|
40367
|
+
receiveRuntimeDelivery(message);
|
|
40484
40368
|
return;
|
|
40485
40369
|
}
|
|
40486
40370
|
if (kind === SESSION_EVENT_ACK_KIND) {
|
|
40487
|
-
publisher.acknowledge(
|
|
40371
|
+
publisher.acknowledge(message);
|
|
40488
40372
|
return;
|
|
40489
40373
|
}
|
|
40490
40374
|
if (kind === SESSION_EVENT_DEFERRED_KIND) {
|
|
40491
|
-
publisher.defer(
|
|
40375
|
+
publisher.defer(message);
|
|
40492
40376
|
return;
|
|
40493
40377
|
}
|
|
40494
40378
|
if (kind === SESSION_EVENT_REJECTED_KIND) {
|
|
40495
|
-
const rejection =
|
|
40379
|
+
const rejection = message;
|
|
40496
40380
|
if (publisher.quarantine(rejection)) {
|
|
40497
40381
|
audit.record({
|
|
40498
40382
|
commandId: rejection.eventId,
|
|
@@ -40506,7 +40390,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40506
40390
|
return;
|
|
40507
40391
|
}
|
|
40508
40392
|
if (kind === NATIVE_SESSION_CANCEL_KIND) {
|
|
40509
|
-
const command2 =
|
|
40393
|
+
const command2 = message;
|
|
40510
40394
|
const pending = nativeRequests.get(command2.requestId);
|
|
40511
40395
|
if (pending?.sessionId === command2.sessionId) {
|
|
40512
40396
|
pending.controller.abort(
|
|
@@ -40520,35 +40404,29 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40520
40404
|
return;
|
|
40521
40405
|
}
|
|
40522
40406
|
if (kind === AGENT_SETTINGS_DISCOVER_KIND) {
|
|
40523
|
-
const command2 =
|
|
40407
|
+
const command2 = message;
|
|
40524
40408
|
const existing = [...agentSettingsDiscoveries.values()].find(
|
|
40525
40409
|
(request) => request.agentId === command2.agentId && !request.controller.signal.aborted
|
|
40526
40410
|
);
|
|
40527
40411
|
if (agentSettingsDiscoveries.has(command2.requestId) || existing !== void 0) {
|
|
40528
40412
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40529
|
-
send(
|
|
40530
|
-
|
|
40531
|
-
|
|
40532
|
-
|
|
40533
|
-
|
|
40534
|
-
|
|
40535
|
-
requestId: command2.requestId
|
|
40536
|
-
})
|
|
40537
|
-
);
|
|
40413
|
+
send(socket, {
|
|
40414
|
+
code: "agent_settings_discovery_busy",
|
|
40415
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
40416
|
+
message: "Another settings discovery is already running for this Agent",
|
|
40417
|
+
requestId: command2.requestId
|
|
40418
|
+
});
|
|
40538
40419
|
}
|
|
40539
40420
|
return;
|
|
40540
40421
|
}
|
|
40541
40422
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
40542
40423
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40543
|
-
send(
|
|
40544
|
-
|
|
40545
|
-
|
|
40546
|
-
|
|
40547
|
-
|
|
40548
|
-
|
|
40549
|
-
requestId: command2.requestId
|
|
40550
|
-
})
|
|
40551
|
-
);
|
|
40424
|
+
send(socket, {
|
|
40425
|
+
code: "agent_settings_discovery_busy",
|
|
40426
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
40427
|
+
message: "Too many Agent settings discoveries are running",
|
|
40428
|
+
requestId: command2.requestId
|
|
40429
|
+
});
|
|
40552
40430
|
}
|
|
40553
40431
|
return;
|
|
40554
40432
|
}
|
|
@@ -40580,7 +40458,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40580
40458
|
sessionId: `agent-settings:${command2.agentId}`
|
|
40581
40459
|
});
|
|
40582
40460
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40583
|
-
send(socket,
|
|
40461
|
+
send(socket, result);
|
|
40584
40462
|
}
|
|
40585
40463
|
} catch (error62) {
|
|
40586
40464
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -40595,15 +40473,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40595
40473
|
sessionId: `agent-settings:${command2.agentId}`
|
|
40596
40474
|
});
|
|
40597
40475
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40598
|
-
send(
|
|
40599
|
-
|
|
40600
|
-
|
|
40601
|
-
|
|
40602
|
-
|
|
40603
|
-
|
|
40604
|
-
requestId: command2.requestId
|
|
40605
|
-
})
|
|
40606
|
-
);
|
|
40476
|
+
send(socket, {
|
|
40477
|
+
code: operationErrorCode(failure2),
|
|
40478
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
40479
|
+
message: operationErrorMessage(failure2),
|
|
40480
|
+
requestId: command2.requestId
|
|
40481
|
+
});
|
|
40607
40482
|
}
|
|
40608
40483
|
} finally {
|
|
40609
40484
|
timeout.cancel();
|
|
@@ -40618,18 +40493,15 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40618
40493
|
return;
|
|
40619
40494
|
}
|
|
40620
40495
|
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
40621
|
-
const command2 =
|
|
40496
|
+
const command2 = message;
|
|
40622
40497
|
if (agentCatalogRefreshes.has(command2.requestId) || agentCatalogRefreshes.size > 0) {
|
|
40623
40498
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40624
|
-
send(
|
|
40625
|
-
|
|
40626
|
-
|
|
40627
|
-
|
|
40628
|
-
|
|
40629
|
-
|
|
40630
|
-
requestId: command2.requestId
|
|
40631
|
-
})
|
|
40632
|
-
);
|
|
40499
|
+
send(socket, {
|
|
40500
|
+
code: "agent_catalog_refresh_busy",
|
|
40501
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
40502
|
+
message: "Another local Agent catalog refresh is already running",
|
|
40503
|
+
requestId: command2.requestId
|
|
40504
|
+
});
|
|
40633
40505
|
}
|
|
40634
40506
|
return;
|
|
40635
40507
|
}
|
|
@@ -40654,13 +40526,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40654
40526
|
sessionId: "agent-catalog"
|
|
40655
40527
|
});
|
|
40656
40528
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40657
|
-
send(
|
|
40658
|
-
|
|
40659
|
-
|
|
40660
|
-
|
|
40661
|
-
requestId: command2.requestId
|
|
40662
|
-
})
|
|
40663
|
-
);
|
|
40529
|
+
send(socket, {
|
|
40530
|
+
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
40531
|
+
requestId: command2.requestId
|
|
40532
|
+
});
|
|
40664
40533
|
}
|
|
40665
40534
|
} catch (error62) {
|
|
40666
40535
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -40675,15 +40544,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40675
40544
|
sessionId: "agent-catalog"
|
|
40676
40545
|
});
|
|
40677
40546
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40678
|
-
send(
|
|
40679
|
-
|
|
40680
|
-
|
|
40681
|
-
|
|
40682
|
-
|
|
40683
|
-
|
|
40684
|
-
requestId: command2.requestId
|
|
40685
|
-
})
|
|
40686
|
-
);
|
|
40547
|
+
send(socket, {
|
|
40548
|
+
code: operationErrorCode(failure2),
|
|
40549
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
40550
|
+
message: operationErrorMessage(failure2),
|
|
40551
|
+
requestId: command2.requestId
|
|
40552
|
+
});
|
|
40687
40553
|
}
|
|
40688
40554
|
} finally {
|
|
40689
40555
|
timeout.cancel();
|
|
@@ -40694,7 +40560,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40694
40560
|
return;
|
|
40695
40561
|
}
|
|
40696
40562
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
40697
|
-
const command2 =
|
|
40563
|
+
const command2 = message;
|
|
40698
40564
|
const previous2 = [...nativeRequests.values()].filter(
|
|
40699
40565
|
(request) => request.agentId === command2.agentId
|
|
40700
40566
|
);
|
|
@@ -40747,7 +40613,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40747
40613
|
operationSignal.throwIfAborted();
|
|
40748
40614
|
const result = await nativeSessions.execute(command2, operationSignal);
|
|
40749
40615
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40750
|
-
send(socket,
|
|
40616
|
+
send(socket, result);
|
|
40751
40617
|
}
|
|
40752
40618
|
} catch (error62) {
|
|
40753
40619
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -40776,7 +40642,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40776
40642
|
return;
|
|
40777
40643
|
}
|
|
40778
40644
|
if (kind === NATIVE_SESSION_TURN_FORK_KIND) {
|
|
40779
|
-
const command2 =
|
|
40645
|
+
const command2 = message;
|
|
40780
40646
|
const previous2 = [...nativeRequests.values()].filter(
|
|
40781
40647
|
(request) => request.agentId === command2.agentId
|
|
40782
40648
|
);
|
|
@@ -40827,7 +40693,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40827
40693
|
operationSignal.throwIfAborted();
|
|
40828
40694
|
const result = await nativeSessions.executeTurnFork(command2, operationSignal);
|
|
40829
40695
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40830
|
-
send(socket,
|
|
40696
|
+
send(socket, result);
|
|
40831
40697
|
}
|
|
40832
40698
|
} catch (error62) {
|
|
40833
40699
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -40856,39 +40722,35 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40856
40722
|
return;
|
|
40857
40723
|
}
|
|
40858
40724
|
if (kind === RUNTIME_LIVENESS_READY_KIND) {
|
|
40859
|
-
decodeRuntimeLivenessReadyEvent(encoded);
|
|
40860
40725
|
connectionLiveness.start();
|
|
40861
40726
|
return;
|
|
40862
40727
|
}
|
|
40863
40728
|
if (kind === RUNTIME_HEARTBEAT_ACK_KIND) {
|
|
40864
|
-
connectionLiveness.acknowledge(
|
|
40729
|
+
connectionLiveness.acknowledge(message);
|
|
40865
40730
|
return;
|
|
40866
40731
|
}
|
|
40867
40732
|
if (kind === FILE_READ_KIND) {
|
|
40868
|
-
const command2 =
|
|
40733
|
+
const command2 = message;
|
|
40869
40734
|
void streamLocalFile(
|
|
40870
40735
|
command2,
|
|
40871
|
-
(
|
|
40736
|
+
(message2) => send(socket, message2),
|
|
40872
40737
|
connectionController.signal
|
|
40873
40738
|
).catch((error62) => {
|
|
40874
40739
|
if (socket.readyState !== WebSocket2.OPEN || connectionController.signal.aborted) {
|
|
40875
40740
|
return;
|
|
40876
40741
|
}
|
|
40877
|
-
send(
|
|
40878
|
-
|
|
40879
|
-
|
|
40880
|
-
|
|
40881
|
-
|
|
40882
|
-
|
|
40883
|
-
|
|
40884
|
-
sessionId: command2.sessionId
|
|
40885
|
-
})
|
|
40886
|
-
);
|
|
40742
|
+
send(socket, {
|
|
40743
|
+
code: "file_unavailable",
|
|
40744
|
+
kind: FILE_FAILED_KIND,
|
|
40745
|
+
message: error62 instanceof Error ? error62.message : "The local file is unavailable",
|
|
40746
|
+
requestId: command2.requestId,
|
|
40747
|
+
sessionId: command2.sessionId
|
|
40748
|
+
});
|
|
40887
40749
|
});
|
|
40888
40750
|
return;
|
|
40889
40751
|
}
|
|
40890
40752
|
if (kind === SESSION_CANCEL_KIND) {
|
|
40891
|
-
const cancellation =
|
|
40753
|
+
const cancellation = message;
|
|
40892
40754
|
const turn2 = activeTurns.get(cancellation.commandId);
|
|
40893
40755
|
if (turn2 === void 0 || !turn2.matches(cancellation)) {
|
|
40894
40756
|
console.warn("Mobius daemon ignored cancellation for an inactive turn");
|
|
@@ -40908,12 +40770,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40908
40770
|
return;
|
|
40909
40771
|
}
|
|
40910
40772
|
if (kind === WORKSPACE_LIST_KIND) {
|
|
40911
|
-
const command2 =
|
|
40773
|
+
const command2 = message;
|
|
40912
40774
|
void executeWorkspaceList(socket, command2, directories, audit, connectionController.signal);
|
|
40913
40775
|
return;
|
|
40914
40776
|
}
|
|
40915
40777
|
if (kind === SESSION_PREPARE_KIND) {
|
|
40916
|
-
const command2 =
|
|
40778
|
+
const command2 = message;
|
|
40917
40779
|
void executeSessionPrepare(
|
|
40918
40780
|
publisher,
|
|
40919
40781
|
socket,
|
|
@@ -40927,7 +40789,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40927
40789
|
return;
|
|
40928
40790
|
}
|
|
40929
40791
|
if (kind === SESSION_CONFIGURE_KIND) {
|
|
40930
|
-
const command2 =
|
|
40792
|
+
const command2 = message;
|
|
40931
40793
|
void executeSessionConfigure(
|
|
40932
40794
|
publisher,
|
|
40933
40795
|
socket,
|
|
@@ -40941,7 +40803,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40941
40803
|
return;
|
|
40942
40804
|
}
|
|
40943
40805
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
40944
|
-
const command2 =
|
|
40806
|
+
const command2 = message;
|
|
40945
40807
|
void sessions.respondPermission(command2).then(() => {
|
|
40946
40808
|
audit.record({
|
|
40947
40809
|
commandId: command2.interactionId,
|
|
@@ -40954,7 +40816,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40954
40816
|
return;
|
|
40955
40817
|
}
|
|
40956
40818
|
if (kind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
40957
|
-
const command2 =
|
|
40819
|
+
const command2 = message;
|
|
40958
40820
|
void sessions.respondElicitation(command2).then(() => {
|
|
40959
40821
|
audit.record({
|
|
40960
40822
|
commandId: command2.interactionId,
|
|
@@ -40967,14 +40829,14 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40967
40829
|
return;
|
|
40968
40830
|
}
|
|
40969
40831
|
if (kind === AGENT_INSTALL_REQUEST_KIND) {
|
|
40970
|
-
const command2 =
|
|
40832
|
+
const command2 = message;
|
|
40971
40833
|
void installations.request(command2, signal).catch((error62) => {
|
|
40972
40834
|
console.error("Mobius Agent integration installation failed", error62);
|
|
40973
40835
|
});
|
|
40974
40836
|
return;
|
|
40975
40837
|
}
|
|
40976
40838
|
if (kind === AGENT_INSTALL_CANCEL_KIND) {
|
|
40977
|
-
const command2 =
|
|
40839
|
+
const command2 = message;
|
|
40978
40840
|
void installations.cancel(command2.requestId).catch((error62) => {
|
|
40979
40841
|
reportOperationFailure(socket, command2.requestId, "", error62);
|
|
40980
40842
|
});
|
|
@@ -40983,7 +40845,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40983
40845
|
if (kind !== SESSION_PROMPT_KIND) {
|
|
40984
40846
|
throw new Error("Unsupported protocol message");
|
|
40985
40847
|
}
|
|
40986
|
-
const command =
|
|
40848
|
+
const command = message;
|
|
40987
40849
|
if (activeTurns.has(command.commandId)) {
|
|
40988
40850
|
return;
|
|
40989
40851
|
}
|
|
@@ -41104,15 +40966,15 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
41104
40966
|
const publisher = new DaemonSessionEventPublisher(outbox, timer);
|
|
41105
40967
|
const activeTurns = /* @__PURE__ */ new Map();
|
|
41106
40968
|
const activeAttemptIds = /* @__PURE__ */ new Map();
|
|
41107
|
-
const recordSessionEvent = (sessionId,
|
|
40969
|
+
const recordSessionEvent = (sessionId, event) => {
|
|
41108
40970
|
const attemptId = activeAttemptIds.get(sessionId);
|
|
41109
40971
|
if (attemptId === void 0) {
|
|
41110
|
-
publisher.recordRuntime(sessionId,
|
|
40972
|
+
publisher.recordRuntime(sessionId, event);
|
|
41111
40973
|
return;
|
|
41112
40974
|
}
|
|
41113
|
-
publisher.recordAttempt(sessionId,
|
|
40975
|
+
publisher.recordAttempt(sessionId, event, attemptId);
|
|
41114
40976
|
};
|
|
41115
|
-
const sessions = new AcpSessionManager(new DaemonAcpObserver(
|
|
40977
|
+
const sessions = new AcpSessionManager(new DaemonAcpObserver(recordSessionEvent), sessionStore);
|
|
41116
40978
|
const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
|
|
41117
40979
|
const installationObserver = new DaemonInstallationObserver();
|
|
41118
40980
|
const diagnostics = new RelayConnectionDiagnostics(audit, config2.channelId, config2.relayUrl);
|
|
@@ -41247,19 +41109,19 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
41247
41109
|
}
|
|
41248
41110
|
|
|
41249
41111
|
// src/pairing/pair-local-machine.ts
|
|
41250
|
-
import { mkdir as
|
|
41112
|
+
import { mkdir as mkdir5, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
41251
41113
|
import { hostname as hostname3 } from "node:os";
|
|
41252
41114
|
import { basename as basename7, resolve as resolve6 } from "node:path";
|
|
41253
|
-
import { fetch as
|
|
41115
|
+
import { fetch as fetch5 } from "undici";
|
|
41254
41116
|
|
|
41255
41117
|
// src/storage/runtime-installation-store.ts
|
|
41256
|
-
import { createHash as
|
|
41257
|
-
import { mkdir as
|
|
41118
|
+
import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
|
|
41119
|
+
import { mkdir as mkdir4, open as open5, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
|
|
41258
41120
|
import { dirname as dirname7, join as join16, resolve as resolve5 } from "node:path";
|
|
41259
41121
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
41260
41122
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
41261
41123
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
41262
|
-
var
|
|
41124
|
+
var IDENTIFIER_PATTERN5 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
41263
41125
|
var RUNTIME_CREDENTIAL_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
41264
41126
|
var MAX_FILE_LENGTH = 16 * 1024;
|
|
41265
41127
|
var INSTALLATION_POINTER_KEYS = ["installationId", "version"];
|
|
@@ -41369,7 +41231,7 @@ function validateInstallationId(value) {
|
|
|
41369
41231
|
return value;
|
|
41370
41232
|
}
|
|
41371
41233
|
function validateIdentifier(value, code) {
|
|
41372
|
-
if (!
|
|
41234
|
+
if (!IDENTIFIER_PATTERN5.test(value)) {
|
|
41373
41235
|
throw new RuntimeInstallationStoreError(code, "The saved Runtime connection is invalid");
|
|
41374
41236
|
}
|
|
41375
41237
|
return value;
|
|
@@ -41404,7 +41266,7 @@ function installationId() {
|
|
|
41404
41266
|
return `min_${randomUUID4().replaceAll("-", "")}`;
|
|
41405
41267
|
}
|
|
41406
41268
|
function channelIndexFileName(channelId) {
|
|
41407
|
-
return `mci_${
|
|
41269
|
+
return `mci_${createHash4("sha256").update(channelId).digest("hex")}.json`;
|
|
41408
41270
|
}
|
|
41409
41271
|
function decodeInstallationPointer(value) {
|
|
41410
41272
|
if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
|
|
@@ -41557,9 +41419,9 @@ async function writeJsonAtomically(path2, value, signal) {
|
|
|
41557
41419
|
const directory = dirname7(path2);
|
|
41558
41420
|
const temporaryPath = join16(directory, `.${randomUUID4()}.tmp`);
|
|
41559
41421
|
try {
|
|
41560
|
-
await
|
|
41422
|
+
await mkdir4(directory, { mode: 448, recursive: true });
|
|
41561
41423
|
signal.throwIfAborted();
|
|
41562
|
-
await
|
|
41424
|
+
await writeFile3(temporaryPath, `${JSON.stringify(value, null, 2)}
|
|
41563
41425
|
`, { flag: "wx", mode: 384 });
|
|
41564
41426
|
signal.throwIfAborted();
|
|
41565
41427
|
await rename3(temporaryPath, path2);
|
|
@@ -41590,7 +41452,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
41590
41452
|
const rootDirectory = resolve5(options.stateDirectory);
|
|
41591
41453
|
const applicationDirectory = join16(rootDirectory, "installations", applicationId);
|
|
41592
41454
|
try {
|
|
41593
|
-
await
|
|
41455
|
+
await mkdir4(applicationDirectory, { mode: 448, recursive: true });
|
|
41594
41456
|
} catch (cause) {
|
|
41595
41457
|
throw new RuntimeInstallationStoreError(
|
|
41596
41458
|
"installation_unavailable",
|
|
@@ -41603,7 +41465,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
41603
41465
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
41604
41466
|
const stateDirectory = join16(applicationDirectory, storedInstallationId);
|
|
41605
41467
|
try {
|
|
41606
|
-
await
|
|
41468
|
+
await mkdir4(stateDirectory, { mode: 448, recursive: true });
|
|
41607
41469
|
} catch (cause) {
|
|
41608
41470
|
throw new RuntimeInstallationStoreError(
|
|
41609
41471
|
"installation_unavailable",
|
|
@@ -41759,7 +41621,7 @@ async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
|
41759
41621
|
}
|
|
41760
41622
|
const candidate = installationId();
|
|
41761
41623
|
try {
|
|
41762
|
-
await
|
|
41624
|
+
await writeFile3(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
|
|
41763
41625
|
`, {
|
|
41764
41626
|
flag: "wx",
|
|
41765
41627
|
mode: 384
|
|
@@ -41785,7 +41647,7 @@ async function openRuntimeInstallationStore(options, signal) {
|
|
|
41785
41647
|
// src/pairing/pair-local-machine.ts
|
|
41786
41648
|
var PAIRING_TIMEOUT_MILLISECONDS = 2e4;
|
|
41787
41649
|
var PAIRING_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{4}(?:-[A-HJ-NP-Z2-9]{4}){4}$/;
|
|
41788
|
-
var
|
|
41650
|
+
var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
41789
41651
|
var TOKEN_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
41790
41652
|
var CLAIM_RESPONSE_KEYS = ["channelId", "daemonToken", "runtimeId"];
|
|
41791
41653
|
var REDEEM_RESPONSE_KEYS = ["channelId", "runtimeCredential", "runtimeId"];
|
|
@@ -41836,7 +41698,7 @@ function parsePairingCode(value) {
|
|
|
41836
41698
|
return code;
|
|
41837
41699
|
}
|
|
41838
41700
|
function validatePairingId(value) {
|
|
41839
|
-
if (!
|
|
41701
|
+
if (!IDENTIFIER_PATTERN6.test(value)) {
|
|
41840
41702
|
throw new PairingClientError("invalid_pairing_id", "The Runtime pairing ID is invalid");
|
|
41841
41703
|
}
|
|
41842
41704
|
return value;
|
|
@@ -41844,7 +41706,7 @@ function validatePairingId(value) {
|
|
|
41844
41706
|
async function resolveDefaultWorkspace2(path2) {
|
|
41845
41707
|
const requestedWorkspace = resolve6(path2);
|
|
41846
41708
|
try {
|
|
41847
|
-
await
|
|
41709
|
+
await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
|
|
41848
41710
|
const defaultWorkspace = await realpath9(requestedWorkspace);
|
|
41849
41711
|
const metadata = await stat8(defaultWorkspace);
|
|
41850
41712
|
if (!metadata.isDirectory()) {
|
|
@@ -41894,7 +41756,7 @@ function decodePairingResponse(value, credentialField, expectedKeys) {
|
|
|
41894
41756
|
const channelId = value["channelId"];
|
|
41895
41757
|
const runtimeCredential2 = value[credentialField];
|
|
41896
41758
|
const runtimeId = value["runtimeId"];
|
|
41897
|
-
if (typeof channelId !== "string" || !
|
|
41759
|
+
if (typeof channelId !== "string" || !IDENTIFIER_PATTERN6.test(channelId) || typeof runtimeCredential2 !== "string" || !TOKEN_PATTERN.test(runtimeCredential2) || typeof runtimeId !== "string" || !IDENTIFIER_PATTERN6.test(runtimeId)) {
|
|
41898
41760
|
throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
|
|
41899
41761
|
}
|
|
41900
41762
|
return { channelId, runtimeCredential: runtimeCredential2, runtimeId };
|
|
@@ -41912,7 +41774,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
41912
41774
|
const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
|
|
41913
41775
|
let response;
|
|
41914
41776
|
try {
|
|
41915
|
-
response = await
|
|
41777
|
+
response = await fetch5(endpoint, {
|
|
41916
41778
|
body: JSON.stringify({
|
|
41917
41779
|
agents,
|
|
41918
41780
|
installableAgents,
|
|
@@ -42014,7 +41876,7 @@ async function resumeMobiusRuntime(installation, connectionId2, signal, environm
|
|
|
42014
41876
|
}
|
|
42015
41877
|
|
|
42016
41878
|
// src/runtime.ts
|
|
42017
|
-
var
|
|
41879
|
+
var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
42018
41880
|
var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
42019
41881
|
var MobiusRuntimeConfigurationError = class extends Error {
|
|
42020
41882
|
code = "runtime_configuration_invalid";
|
|
@@ -42066,7 +41928,7 @@ function relayUrlFromConnection(connection) {
|
|
|
42066
41928
|
}
|
|
42067
41929
|
function loadMobiusRuntimeConnection(environment = process.env) {
|
|
42068
41930
|
const channelId = requiredEnvironmentValue(environment, "MOBIUS_CHANNEL_ID");
|
|
42069
|
-
if (!
|
|
41931
|
+
if (!IDENTIFIER_PATTERN7.test(channelId)) {
|
|
42070
41932
|
throw new MobiusRuntimeConfigurationError("MOBIUS_CHANNEL_ID is invalid");
|
|
42071
41933
|
}
|
|
42072
41934
|
return Object.freeze({
|
|
@@ -42080,7 +41942,7 @@ function loadMobiusRuntimeConnection(environment = process.env) {
|
|
|
42080
41942
|
async function resolveWorkspace(path2) {
|
|
42081
41943
|
const requested = resolve7(path2);
|
|
42082
41944
|
try {
|
|
42083
|
-
await
|
|
41945
|
+
await mkdir6(requested, { recursive: true, mode: 448 });
|
|
42084
41946
|
const resolved = await realpath10(requested);
|
|
42085
41947
|
const metadata = await stat9(resolved);
|
|
42086
41948
|
if (!metadata.isDirectory()) {
|
|
@@ -42100,7 +41962,7 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
42100
41962
|
const relayUrl = relayUrlFromConnection(connection);
|
|
42101
41963
|
const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
|
|
42102
41964
|
const auditDatabasePath = resolve7(connection.auditDatabasePath);
|
|
42103
|
-
await
|
|
41965
|
+
await mkdir6(dirname8(auditDatabasePath), { recursive: true, mode: 448 });
|
|
42104
41966
|
const inventory = await discoverLocalAgentInventory({
|
|
42105
41967
|
defaultWorkspace,
|
|
42106
41968
|
environment: localContext.environment,
|