@moxt-ai/mobius 0.0.60 → 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-installation/deepseek-managed-package.js +2 -2
- 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 +71 -465
- package/dist/cli.js.map +4 -4
- package/dist/index.js +73 -466
- package/dist/index.js.map +4 -4
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +2 -6
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +91 -484
- 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;
|
|
@@ -24232,10 +24247,10 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
24232
24247
|
}
|
|
24233
24248
|
|
|
24234
24249
|
// src/run-daemon.ts
|
|
24235
|
-
import { createHash as
|
|
24250
|
+
import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
|
|
24236
24251
|
import { basename as basename6 } from "node:path";
|
|
24237
24252
|
import { styleText } from "node:util";
|
|
24238
|
-
import { fetch as
|
|
24253
|
+
import { fetch as fetch4, WebSocket as WebSocket2 } from "undici";
|
|
24239
24254
|
|
|
24240
24255
|
// src/acp/session-manager.ts
|
|
24241
24256
|
import { spawn as spawn3 } from "node:child_process";
|
|
@@ -32939,10 +32954,6 @@ var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
|
|
|
32939
32954
|
var SESSION_CONTROL_COMMAND_ID = "session-control";
|
|
32940
32955
|
var SESSION_CONTROL_TIMEOUT_MILLISECONDS = 3e4;
|
|
32941
32956
|
var NullAcpSessionObserver = class {
|
|
32942
|
-
importLocalArtifact = (_sessionId, _artifact, signal) => {
|
|
32943
|
-
signal.throwIfAborted();
|
|
32944
|
-
return Promise.resolve("");
|
|
32945
|
-
};
|
|
32946
32957
|
onCommands = () => Promise.resolve();
|
|
32947
32958
|
onConfig = () => Promise.resolve();
|
|
32948
32959
|
onContent = () => Promise.resolve();
|
|
@@ -33502,20 +33513,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33502
33513
|
#agentName = "";
|
|
33503
33514
|
#agentVersion = "";
|
|
33504
33515
|
#bufferedAgentText = [];
|
|
33505
|
-
#capabilities =
|
|
33506
|
-
additionalDirectories: false,
|
|
33507
|
-
audioPrompt: false,
|
|
33508
|
-
closeSession: false,
|
|
33509
|
-
deleteSession: false,
|
|
33510
|
-
embeddedContextPrompt: false,
|
|
33511
|
-
imagePrompt: false,
|
|
33512
|
-
listSessions: false,
|
|
33513
|
-
loadSession: false,
|
|
33514
|
-
promptQueueing: false,
|
|
33515
|
-
resumeSession: false,
|
|
33516
|
-
steering: false,
|
|
33517
|
-
unstableForkSession: false
|
|
33518
|
-
};
|
|
33516
|
+
#capabilities = unsupportedSessionCapabilities();
|
|
33519
33517
|
#commands = [];
|
|
33520
33518
|
#configRevision = 0;
|
|
33521
33519
|
#configOptions = [];
|
|
@@ -33735,7 +33733,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33735
33733
|
if (video === null) {
|
|
33736
33734
|
return { ...content3, data: "" };
|
|
33737
33735
|
}
|
|
33738
|
-
return
|
|
33736
|
+
return this.importVideo(video);
|
|
33739
33737
|
}
|
|
33740
33738
|
return content3;
|
|
33741
33739
|
};
|
|
@@ -33786,22 +33784,19 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
33786
33784
|
}
|
|
33787
33785
|
return imageDisplayContent(raster.mimeType, raster.name, await raster.base64(), "");
|
|
33788
33786
|
};
|
|
33789
|
-
importVideo =
|
|
33790
|
-
|
|
33791
|
-
|
|
33792
|
-
|
|
33793
|
-
|
|
33794
|
-
|
|
33795
|
-
|
|
33796
|
-
|
|
33797
|
-
|
|
33798
|
-
|
|
33799
|
-
|
|
33800
|
-
|
|
33801
|
-
|
|
33802
|
-
uri: ""
|
|
33803
|
-
};
|
|
33804
|
-
};
|
|
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
|
+
});
|
|
33805
33800
|
async #initializeAgent(signal) {
|
|
33806
33801
|
await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
|
|
33807
33802
|
}
|
|
@@ -36623,391 +36618,6 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
36623
36618
|
});
|
|
36624
36619
|
}
|
|
36625
36620
|
|
|
36626
|
-
// src/artifacts/runtime-artifact-uploader.ts
|
|
36627
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
36628
|
-
|
|
36629
|
-
// ../mobius-sdk/src/errors.ts
|
|
36630
|
-
var MobiusError = class extends Error {
|
|
36631
|
-
code;
|
|
36632
|
-
constructor(code, message, options = {}) {
|
|
36633
|
-
super(message, options);
|
|
36634
|
-
this.code = code;
|
|
36635
|
-
this.name = "MobiusError";
|
|
36636
|
-
}
|
|
36637
|
-
};
|
|
36638
|
-
var MobiusProtocolError = class extends MobiusError {
|
|
36639
|
-
constructor(message, options = {}) {
|
|
36640
|
-
super("invalid_service_response", message, options);
|
|
36641
|
-
this.name = "MobiusProtocolError";
|
|
36642
|
-
}
|
|
36643
|
-
};
|
|
36644
|
-
var MobiusValidationError = class extends MobiusError {
|
|
36645
|
-
constructor(message, options = {}) {
|
|
36646
|
-
super("invalid_request", message, options);
|
|
36647
|
-
this.name = "MobiusValidationError";
|
|
36648
|
-
}
|
|
36649
|
-
};
|
|
36650
|
-
|
|
36651
|
-
// ../mobius-sdk/src/resources.ts
|
|
36652
|
-
var IDENTIFIER_PATTERN4 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
36653
|
-
function invalidResponse(message) {
|
|
36654
|
-
return new MobiusProtocolError(message);
|
|
36655
|
-
}
|
|
36656
|
-
function isRecord9(value) {
|
|
36657
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36658
|
-
}
|
|
36659
|
-
function record2(value, name) {
|
|
36660
|
-
if (!isRecord9(value)) {
|
|
36661
|
-
throw invalidResponse(`The service returned an invalid ${name}`);
|
|
36662
|
-
}
|
|
36663
|
-
return value;
|
|
36664
|
-
}
|
|
36665
|
-
function stringField(value, field, maximumLength = 85e5) {
|
|
36666
|
-
const candidate = value[field];
|
|
36667
|
-
if (typeof candidate !== "string" || candidate.length > maximumLength) {
|
|
36668
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
36669
|
-
}
|
|
36670
|
-
return candidate;
|
|
36671
|
-
}
|
|
36672
|
-
function identifierField(value, field) {
|
|
36673
|
-
const candidate = stringField(value, field, 128);
|
|
36674
|
-
if (!IDENTIFIER_PATTERN4.test(candidate)) {
|
|
36675
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
36676
|
-
}
|
|
36677
|
-
return candidate;
|
|
36678
|
-
}
|
|
36679
|
-
function integerField(value, field) {
|
|
36680
|
-
const candidate = value[field];
|
|
36681
|
-
if (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0) {
|
|
36682
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
36683
|
-
}
|
|
36684
|
-
return candidate;
|
|
36685
|
-
}
|
|
36686
|
-
function validateTimestamp(value, field) {
|
|
36687
|
-
if (Number.isNaN(Date.parse(value))) {
|
|
36688
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
36689
|
-
}
|
|
36690
|
-
return value;
|
|
36691
|
-
}
|
|
36692
|
-
var MobiusArtifactUploadRequest = class {
|
|
36693
|
-
byteLength;
|
|
36694
|
-
mediaType;
|
|
36695
|
-
name;
|
|
36696
|
-
sha256;
|
|
36697
|
-
constructor(name, mediaType, byteLength, sha256) {
|
|
36698
|
-
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)) {
|
|
36699
|
-
throw new MobiusValidationError("The artifact upload request is invalid");
|
|
36700
|
-
}
|
|
36701
|
-
this.byteLength = byteLength;
|
|
36702
|
-
this.mediaType = mediaType;
|
|
36703
|
-
this.name = name;
|
|
36704
|
-
this.sha256 = sha256;
|
|
36705
|
-
}
|
|
36706
|
-
};
|
|
36707
|
-
var MobiusArtifact = class {
|
|
36708
|
-
artifactId;
|
|
36709
|
-
byteLength;
|
|
36710
|
-
createdAt;
|
|
36711
|
-
mediaType;
|
|
36712
|
-
name;
|
|
36713
|
-
sessionId;
|
|
36714
|
-
sha256;
|
|
36715
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt) {
|
|
36716
|
-
this.artifactId = artifactId;
|
|
36717
|
-
this.byteLength = byteLength;
|
|
36718
|
-
this.createdAt = createdAt;
|
|
36719
|
-
this.mediaType = mediaType;
|
|
36720
|
-
this.name = name;
|
|
36721
|
-
this.sessionId = sessionId;
|
|
36722
|
-
this.sha256 = sha256;
|
|
36723
|
-
}
|
|
36724
|
-
};
|
|
36725
|
-
var MobiusUploadingArtifact = class extends MobiusArtifact {
|
|
36726
|
-
expiresAt;
|
|
36727
|
-
state = "uploading";
|
|
36728
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiresAt) {
|
|
36729
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
36730
|
-
this.expiresAt = expiresAt;
|
|
36731
|
-
}
|
|
36732
|
-
};
|
|
36733
|
-
var MobiusArtifactUpload = class extends MobiusUploadingArtifact {
|
|
36734
|
-
uploadToken;
|
|
36735
|
-
constructor(artifact, uploadToken) {
|
|
36736
|
-
super(
|
|
36737
|
-
artifact.sessionId,
|
|
36738
|
-
artifact.artifactId,
|
|
36739
|
-
artifact.name,
|
|
36740
|
-
artifact.mediaType,
|
|
36741
|
-
artifact.byteLength,
|
|
36742
|
-
artifact.sha256,
|
|
36743
|
-
artifact.createdAt,
|
|
36744
|
-
artifact.expiresAt
|
|
36745
|
-
);
|
|
36746
|
-
this.uploadToken = uploadToken;
|
|
36747
|
-
}
|
|
36748
|
-
};
|
|
36749
|
-
var MobiusAvailableArtifact = class extends MobiusArtifact {
|
|
36750
|
-
availableAt;
|
|
36751
|
-
state = "available";
|
|
36752
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, availableAt) {
|
|
36753
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
36754
|
-
this.availableAt = availableAt;
|
|
36755
|
-
}
|
|
36756
|
-
};
|
|
36757
|
-
var MobiusExpiredArtifact = class extends MobiusArtifact {
|
|
36758
|
-
expiredAt;
|
|
36759
|
-
state = "expired";
|
|
36760
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiredAt) {
|
|
36761
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
36762
|
-
this.expiredAt = expiredAt;
|
|
36763
|
-
}
|
|
36764
|
-
};
|
|
36765
|
-
function artifactFields(value) {
|
|
36766
|
-
const sha256 = stringField(value, "sha256", 64);
|
|
36767
|
-
if (!/^[a-f0-9]{64}$/.test(sha256)) {
|
|
36768
|
-
throw invalidResponse("The service returned an invalid artifact digest");
|
|
36769
|
-
}
|
|
36770
|
-
return {
|
|
36771
|
-
artifactId: identifierField(value, "artifactId"),
|
|
36772
|
-
byteLength: integerField(value, "byteLength"),
|
|
36773
|
-
createdAt: validateTimestamp(stringField(value, "createdAt", 128), "createdAt"),
|
|
36774
|
-
mediaType: stringField(value, "mediaType", 255),
|
|
36775
|
-
name: stringField(value, "name", 500),
|
|
36776
|
-
sessionId: identifierField(value, "sessionId"),
|
|
36777
|
-
sha256
|
|
36778
|
-
};
|
|
36779
|
-
}
|
|
36780
|
-
function uploadingArtifact(value) {
|
|
36781
|
-
const fields = artifactFields(value);
|
|
36782
|
-
return new MobiusUploadingArtifact(
|
|
36783
|
-
fields.sessionId,
|
|
36784
|
-
fields.artifactId,
|
|
36785
|
-
fields.name,
|
|
36786
|
-
fields.mediaType,
|
|
36787
|
-
fields.byteLength,
|
|
36788
|
-
fields.sha256,
|
|
36789
|
-
fields.createdAt,
|
|
36790
|
-
validateTimestamp(stringField(value, "expiresAt", 128), "expiresAt")
|
|
36791
|
-
);
|
|
36792
|
-
}
|
|
36793
|
-
function decodeMobiusArtifactUpload(value) {
|
|
36794
|
-
const artifact = record2(value, "artifact upload authorization");
|
|
36795
|
-
return new MobiusArtifactUpload(uploadingArtifact(artifact), stringField(artifact, "uploadToken", 256));
|
|
36796
|
-
}
|
|
36797
|
-
function decodeMobiusArtifact(value) {
|
|
36798
|
-
const artifact = record2(value, "artifact");
|
|
36799
|
-
const state = stringField(artifact, "state", 32);
|
|
36800
|
-
if (state === "uploading") {
|
|
36801
|
-
return uploadingArtifact(artifact);
|
|
36802
|
-
}
|
|
36803
|
-
const fields = artifactFields(artifact);
|
|
36804
|
-
if (state === "available") {
|
|
36805
|
-
return new MobiusAvailableArtifact(
|
|
36806
|
-
fields.sessionId,
|
|
36807
|
-
fields.artifactId,
|
|
36808
|
-
fields.name,
|
|
36809
|
-
fields.mediaType,
|
|
36810
|
-
fields.byteLength,
|
|
36811
|
-
fields.sha256,
|
|
36812
|
-
fields.createdAt,
|
|
36813
|
-
validateTimestamp(stringField(artifact, "availableAt", 128), "availableAt")
|
|
36814
|
-
);
|
|
36815
|
-
}
|
|
36816
|
-
if (state === "expired") {
|
|
36817
|
-
return new MobiusExpiredArtifact(
|
|
36818
|
-
fields.sessionId,
|
|
36819
|
-
fields.artifactId,
|
|
36820
|
-
fields.name,
|
|
36821
|
-
fields.mediaType,
|
|
36822
|
-
fields.byteLength,
|
|
36823
|
-
fields.sha256,
|
|
36824
|
-
fields.createdAt,
|
|
36825
|
-
validateTimestamp(stringField(artifact, "expiredAt", 128), "expiredAt")
|
|
36826
|
-
);
|
|
36827
|
-
}
|
|
36828
|
-
throw invalidResponse("The service returned an invalid artifact state");
|
|
36829
|
-
}
|
|
36830
|
-
function decodeMobiusAvailableArtifact(value) {
|
|
36831
|
-
const artifact = decodeMobiusArtifact(value);
|
|
36832
|
-
if (!(artifact instanceof MobiusAvailableArtifact)) {
|
|
36833
|
-
throw invalidResponse("The service did not make the artifact available");
|
|
36834
|
-
}
|
|
36835
|
-
return artifact;
|
|
36836
|
-
}
|
|
36837
|
-
var MobiusRuntimePairingLifecycle = Object.freeze({
|
|
36838
|
-
Expired: "expired",
|
|
36839
|
-
Paired: "paired",
|
|
36840
|
-
Pending: "pending",
|
|
36841
|
-
Revoked: "revoked"
|
|
36842
|
-
});
|
|
36843
|
-
|
|
36844
|
-
// src/artifacts/runtime-artifact-uploader.ts
|
|
36845
|
-
import { fetch as fetch3 } from "undici";
|
|
36846
|
-
var UPLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
36847
|
-
var RuntimeArtifactUploadError = class extends Error {
|
|
36848
|
-
code;
|
|
36849
|
-
constructor(code, message, options = {}) {
|
|
36850
|
-
super(message, options);
|
|
36851
|
-
this.code = code;
|
|
36852
|
-
this.name = "RuntimeArtifactUploadError";
|
|
36853
|
-
}
|
|
36854
|
-
};
|
|
36855
|
-
var UploadedRuntimeArtifact = class {
|
|
36856
|
-
artifactId;
|
|
36857
|
-
byteLength;
|
|
36858
|
-
mimeType;
|
|
36859
|
-
name;
|
|
36860
|
-
sha256;
|
|
36861
|
-
constructor(artifactId, name, mimeType, byteLength, sha256) {
|
|
36862
|
-
this.artifactId = artifactId;
|
|
36863
|
-
this.byteLength = byteLength;
|
|
36864
|
-
this.mimeType = mimeType;
|
|
36865
|
-
this.name = name;
|
|
36866
|
-
this.sha256 = sha256;
|
|
36867
|
-
}
|
|
36868
|
-
};
|
|
36869
|
-
function channelOrigin(config2) {
|
|
36870
|
-
const url2 = new URL(config2.relayUrl);
|
|
36871
|
-
url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
|
|
36872
|
-
let channelPath = "";
|
|
36873
|
-
if (url2.pathname.endsWith("/daemon")) {
|
|
36874
|
-
channelPath = url2.pathname.slice(0, -"/daemon".length);
|
|
36875
|
-
} else {
|
|
36876
|
-
const runtimePath = `${MOBIUS_API_PREFIX}/v1/runtimes/connect`;
|
|
36877
|
-
if (!url2.pathname.endsWith("/v1/runtimes/connect") && !url2.pathname.endsWith(runtimePath)) {
|
|
36878
|
-
throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay artifact endpoint is invalid");
|
|
36879
|
-
}
|
|
36880
|
-
channelPath = `${url2.pathname.replace(/\/v1\/runtimes\/connect$/, "")}/channels/${encodeURIComponent(config2.channelId)}`;
|
|
36881
|
-
}
|
|
36882
|
-
url2.pathname = channelPath;
|
|
36883
|
-
url2.search = "";
|
|
36884
|
-
url2.hash = "";
|
|
36885
|
-
return url2;
|
|
36886
|
-
}
|
|
36887
|
-
function uploadError(code, message, cause) {
|
|
36888
|
-
return new RuntimeArtifactUploadError(code, message, cause === void 0 ? {} : { cause });
|
|
36889
|
-
}
|
|
36890
|
-
function translateSdkError(cause) {
|
|
36891
|
-
if (cause instanceof MobiusValidationError) {
|
|
36892
|
-
throw uploadError("artifact_upload_failed", cause.message, cause);
|
|
36893
|
-
}
|
|
36894
|
-
if (cause instanceof MobiusProtocolError) {
|
|
36895
|
-
throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
|
|
36896
|
-
}
|
|
36897
|
-
throw cause;
|
|
36898
|
-
}
|
|
36899
|
-
async function readJson(response) {
|
|
36900
|
-
try {
|
|
36901
|
-
return await response.json();
|
|
36902
|
-
} catch (cause) {
|
|
36903
|
-
throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
|
|
36904
|
-
}
|
|
36905
|
-
}
|
|
36906
|
-
async function readAuthorization(response) {
|
|
36907
|
-
try {
|
|
36908
|
-
return decodeMobiusArtifactUpload(await readJson(response));
|
|
36909
|
-
} catch (cause) {
|
|
36910
|
-
translateSdkError(cause);
|
|
36911
|
-
}
|
|
36912
|
-
}
|
|
36913
|
-
function sessionArtifactUrl(origin, sessionId, resourcePath) {
|
|
36914
|
-
return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
|
|
36915
|
-
}
|
|
36916
|
-
async function postLease(url2, headers, request, signal) {
|
|
36917
|
-
return await fetch3(url2, {
|
|
36918
|
-
dispatcher: environmentProxyDispatcher,
|
|
36919
|
-
headers: { ...headers, "content-type": "application/json" },
|
|
36920
|
-
method: "POST",
|
|
36921
|
-
body: JSON.stringify(request),
|
|
36922
|
-
signal
|
|
36923
|
-
});
|
|
36924
|
-
}
|
|
36925
|
-
async function putContent(url2, headers, authorization, bytes, signal) {
|
|
36926
|
-
return await fetch3(url2, {
|
|
36927
|
-
dispatcher: environmentProxyDispatcher,
|
|
36928
|
-
headers: {
|
|
36929
|
-
...headers,
|
|
36930
|
-
"content-type": authorization.mediaType,
|
|
36931
|
-
"x-mobius-upload-token": authorization.uploadToken
|
|
36932
|
-
},
|
|
36933
|
-
method: "PUT",
|
|
36934
|
-
body: bytes,
|
|
36935
|
-
signal
|
|
36936
|
-
});
|
|
36937
|
-
}
|
|
36938
|
-
async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
36939
|
-
signal.throwIfAborted();
|
|
36940
|
-
let request;
|
|
36941
|
-
try {
|
|
36942
|
-
request = new MobiusArtifactUploadRequest(
|
|
36943
|
-
artifact.name,
|
|
36944
|
-
artifact.mimeType,
|
|
36945
|
-
artifact.bytes.byteLength,
|
|
36946
|
-
createHash2("sha256").update(artifact.bytes).digest("hex")
|
|
36947
|
-
);
|
|
36948
|
-
} catch (cause) {
|
|
36949
|
-
translateSdkError(cause);
|
|
36950
|
-
}
|
|
36951
|
-
const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
|
|
36952
|
-
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
36953
|
-
const origin = channelOrigin(config2);
|
|
36954
|
-
const headers = runtimeAuthorization(config2.relayUrl);
|
|
36955
|
-
let created;
|
|
36956
|
-
try {
|
|
36957
|
-
created = await postLease(
|
|
36958
|
-
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
|
|
36959
|
-
headers,
|
|
36960
|
-
request,
|
|
36961
|
-
requestSignal
|
|
36962
|
-
);
|
|
36963
|
-
} catch (cause) {
|
|
36964
|
-
signal.throwIfAborted();
|
|
36965
|
-
throw uploadError(
|
|
36966
|
-
timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
|
|
36967
|
-
timeoutSignal.aborted ? "The artifact upload authorization timed out" : "The artifact upload could not start",
|
|
36968
|
-
cause
|
|
36969
|
-
);
|
|
36970
|
-
}
|
|
36971
|
-
if (!created.ok) {
|
|
36972
|
-
await created.body?.cancel();
|
|
36973
|
-
throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact upload");
|
|
36974
|
-
}
|
|
36975
|
-
const authorization = await readAuthorization(created);
|
|
36976
|
-
let uploaded;
|
|
36977
|
-
try {
|
|
36978
|
-
uploaded = await putContent(
|
|
36979
|
-
sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
|
|
36980
|
-
headers,
|
|
36981
|
-
authorization,
|
|
36982
|
-
artifact.bytes,
|
|
36983
|
-
requestSignal
|
|
36984
|
-
);
|
|
36985
|
-
} catch (cause) {
|
|
36986
|
-
signal.throwIfAborted();
|
|
36987
|
-
throw uploadError(
|
|
36988
|
-
timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
|
|
36989
|
-
timeoutSignal.aborted ? "The artifact upload timed out" : "The artifact content could not be uploaded",
|
|
36990
|
-
cause
|
|
36991
|
-
);
|
|
36992
|
-
}
|
|
36993
|
-
if (!uploaded.ok) {
|
|
36994
|
-
await uploaded.body?.cancel();
|
|
36995
|
-
throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact content");
|
|
36996
|
-
}
|
|
36997
|
-
try {
|
|
36998
|
-
const available = decodeMobiusAvailableArtifact(await readJson(uploaded));
|
|
36999
|
-
return new UploadedRuntimeArtifact(
|
|
37000
|
-
available.artifactId,
|
|
37001
|
-
available.name,
|
|
37002
|
-
available.mediaType,
|
|
37003
|
-
available.byteLength,
|
|
37004
|
-
available.sha256
|
|
37005
|
-
);
|
|
37006
|
-
} catch (cause) {
|
|
37007
|
-
translateSdkError(cause);
|
|
37008
|
-
}
|
|
37009
|
-
}
|
|
37010
|
-
|
|
37011
36621
|
// src/authorization/local-authorization-error.ts
|
|
37012
36622
|
var LocalAuthorizationError = class extends Error {
|
|
37013
36623
|
code = "local_authorization_failed";
|
|
@@ -37836,13 +37446,13 @@ var NativeSessionService = class {
|
|
|
37836
37446
|
};
|
|
37837
37447
|
|
|
37838
37448
|
// src/prompt-artifact-resolver.ts
|
|
37839
|
-
import { createHash as
|
|
37840
|
-
import { fetch as
|
|
37449
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
37450
|
+
import { fetch as fetch3 } from "undici";
|
|
37841
37451
|
var ARTIFACT_SCHEME = "mobius-artifact:";
|
|
37842
37452
|
var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
37843
37453
|
var MAX_AGENT_IMAGE_BASE64_LENGTH = 4e6;
|
|
37844
37454
|
var MAX_AGENT_RESOURCE_BYTE_LENGTH = 1e6;
|
|
37845
|
-
var
|
|
37455
|
+
var IDENTIFIER_PATTERN4 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
37846
37456
|
var PromptArtifactError = class extends Error {
|
|
37847
37457
|
code;
|
|
37848
37458
|
constructor(code, message, options = {}) {
|
|
@@ -37885,7 +37495,7 @@ function parseReference(resource) {
|
|
|
37885
37495
|
const encodedByteLength2 = url2.searchParams.get("byteLength") ?? "";
|
|
37886
37496
|
const sha256 = url2.searchParams.get("sha256") ?? "";
|
|
37887
37497
|
const byteLength = Number(encodedByteLength2);
|
|
37888
|
-
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)) {
|
|
37889
37499
|
throw new PromptArtifactError("artifact_reference_invalid", "The prompt artifact reference is invalid");
|
|
37890
37500
|
}
|
|
37891
37501
|
return new PromptArtifactReference(artifactId, byteLength, sha256, resource);
|
|
@@ -37951,7 +37561,7 @@ async function download(config2, command, reference, signal) {
|
|
|
37951
37561
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37952
37562
|
let response;
|
|
37953
37563
|
try {
|
|
37954
|
-
response = await
|
|
37564
|
+
response = await fetch3(downloadUrl(config2, command, reference), {
|
|
37955
37565
|
dispatcher: environmentProxyDispatcher,
|
|
37956
37566
|
headers: {
|
|
37957
37567
|
accept: reference.resource.mimeType,
|
|
@@ -37975,7 +37585,7 @@ async function download(config2, command, reference, signal) {
|
|
|
37975
37585
|
);
|
|
37976
37586
|
}
|
|
37977
37587
|
const bytes = await responseBytes(response, reference.byteLength, requestSignal);
|
|
37978
|
-
if (
|
|
37588
|
+
if (createHash2("sha256").update(bytes).digest("hex") !== reference.sha256) {
|
|
37979
37589
|
throw new PromptArtifactError(
|
|
37980
37590
|
"artifact_integrity_failed",
|
|
37981
37591
|
"The prompt artifact failed integrity validation"
|
|
@@ -39080,13 +38690,10 @@ var AGENT_TEXT_MAXIMUM_LENGTH = 1e5;
|
|
|
39080
38690
|
var ACTIVE_TURN_RECONCILIATION_TIMEOUT_MILLISECONDS = 2e4;
|
|
39081
38691
|
var ACTIVE_TURN_RECONCILIATION_CLOSE_CODE = 4009;
|
|
39082
38692
|
var DaemonAcpObserver = class {
|
|
39083
|
-
#config;
|
|
39084
38693
|
#record;
|
|
39085
|
-
constructor(
|
|
39086
|
-
this.#
|
|
39087
|
-
this.#record = record3;
|
|
38694
|
+
constructor(record2) {
|
|
38695
|
+
this.#record = record2;
|
|
39088
38696
|
}
|
|
39089
|
-
importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
39090
38697
|
onCommands = (event) => {
|
|
39091
38698
|
this.#record(event.sessionId, event);
|
|
39092
38699
|
return Promise.resolve();
|
|
@@ -39304,7 +38911,7 @@ async function reconcileActiveTurn(config2, turn, signal) {
|
|
|
39304
38911
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
39305
38912
|
let response;
|
|
39306
38913
|
try {
|
|
39307
|
-
response = await
|
|
38914
|
+
response = await fetch4(activeTurnReconciliationEndpoint(config2, turn), {
|
|
39308
38915
|
body: JSON.stringify({ outcome: { kind: "running" } }),
|
|
39309
38916
|
dispatcher: environmentProxyDispatcher,
|
|
39310
38917
|
headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
|
|
@@ -39814,7 +39421,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
39814
39421
|
resolution: modelEffort.resolution,
|
|
39815
39422
|
valuesByModel: {}
|
|
39816
39423
|
};
|
|
39817
|
-
return
|
|
39424
|
+
return createHash3("sha256").update(
|
|
39818
39425
|
JSON.stringify({
|
|
39819
39426
|
adapterVersion: agent.adapterVersion,
|
|
39820
39427
|
agentId: agent.id,
|
|
@@ -41367,7 +40974,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
41367
40974
|
}
|
|
41368
40975
|
publisher.recordAttempt(sessionId, event, attemptId);
|
|
41369
40976
|
};
|
|
41370
|
-
const sessions = new AcpSessionManager(new DaemonAcpObserver(
|
|
40977
|
+
const sessions = new AcpSessionManager(new DaemonAcpObserver(recordSessionEvent), sessionStore);
|
|
41371
40978
|
const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
|
|
41372
40979
|
const installationObserver = new DaemonInstallationObserver();
|
|
41373
40980
|
const diagnostics = new RelayConnectionDiagnostics(audit, config2.channelId, config2.relayUrl);
|
|
@@ -41502,19 +41109,19 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
41502
41109
|
}
|
|
41503
41110
|
|
|
41504
41111
|
// src/pairing/pair-local-machine.ts
|
|
41505
|
-
import { mkdir as
|
|
41112
|
+
import { mkdir as mkdir5, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
41506
41113
|
import { hostname as hostname3 } from "node:os";
|
|
41507
41114
|
import { basename as basename7, resolve as resolve6 } from "node:path";
|
|
41508
|
-
import { fetch as
|
|
41115
|
+
import { fetch as fetch5 } from "undici";
|
|
41509
41116
|
|
|
41510
41117
|
// src/storage/runtime-installation-store.ts
|
|
41511
|
-
import { createHash as
|
|
41512
|
-
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";
|
|
41513
41120
|
import { dirname as dirname7, join as join16, resolve as resolve5 } from "node:path";
|
|
41514
41121
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
41515
41122
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
41516
41123
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
41517
|
-
var
|
|
41124
|
+
var IDENTIFIER_PATTERN5 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
41518
41125
|
var RUNTIME_CREDENTIAL_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
41519
41126
|
var MAX_FILE_LENGTH = 16 * 1024;
|
|
41520
41127
|
var INSTALLATION_POINTER_KEYS = ["installationId", "version"];
|
|
@@ -41595,7 +41202,7 @@ var ImportedLegacyRuntimeConnection = class extends StoredRuntimeConnection {
|
|
|
41595
41202
|
super(applicationId, installationId2, connectionId2, channelId, defaultWorkspace, relayOrigin, runtimeCredential2);
|
|
41596
41203
|
}
|
|
41597
41204
|
};
|
|
41598
|
-
function
|
|
41205
|
+
function isRecord9(value) {
|
|
41599
41206
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41600
41207
|
}
|
|
41601
41208
|
function hasExactKeys(value, expectedKeys) {
|
|
@@ -41624,7 +41231,7 @@ function validateInstallationId(value) {
|
|
|
41624
41231
|
return value;
|
|
41625
41232
|
}
|
|
41626
41233
|
function validateIdentifier(value, code) {
|
|
41627
|
-
if (!
|
|
41234
|
+
if (!IDENTIFIER_PATTERN5.test(value)) {
|
|
41628
41235
|
throw new RuntimeInstallationStoreError(code, "The saved Runtime connection is invalid");
|
|
41629
41236
|
}
|
|
41630
41237
|
return value;
|
|
@@ -41659,10 +41266,10 @@ function installationId() {
|
|
|
41659
41266
|
return `min_${randomUUID4().replaceAll("-", "")}`;
|
|
41660
41267
|
}
|
|
41661
41268
|
function channelIndexFileName(channelId) {
|
|
41662
|
-
return `mci_${
|
|
41269
|
+
return `mci_${createHash4("sha256").update(channelId).digest("hex")}.json`;
|
|
41663
41270
|
}
|
|
41664
41271
|
function decodeInstallationPointer(value) {
|
|
41665
|
-
if (!
|
|
41272
|
+
if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
|
|
41666
41273
|
throw new RuntimeInstallationStoreError("invalid_installation", "The local installation record is invalid");
|
|
41667
41274
|
}
|
|
41668
41275
|
const storedInstallationId = value["installationId"];
|
|
@@ -41672,7 +41279,7 @@ function decodeInstallationPointer(value) {
|
|
|
41672
41279
|
return { installationId: validateInstallationId(storedInstallationId) };
|
|
41673
41280
|
}
|
|
41674
41281
|
function decodeChannelIndex(value) {
|
|
41675
|
-
if (!
|
|
41282
|
+
if (!isRecord9(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
|
|
41676
41283
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
41677
41284
|
}
|
|
41678
41285
|
const applicationId = value["applicationId"];
|
|
@@ -41740,7 +41347,7 @@ function decodeImportedLegacyConnection(value) {
|
|
|
41740
41347
|
);
|
|
41741
41348
|
}
|
|
41742
41349
|
function decodeConnection(value) {
|
|
41743
|
-
if (!
|
|
41350
|
+
if (!isRecord9(value)) {
|
|
41744
41351
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
41745
41352
|
}
|
|
41746
41353
|
if (value["kind"] === "verified") {
|
|
@@ -41752,7 +41359,7 @@ function decodeConnection(value) {
|
|
|
41752
41359
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
41753
41360
|
}
|
|
41754
41361
|
function decodeLegacyConnection(value, expectedChannelId) {
|
|
41755
|
-
if (!
|
|
41362
|
+
if (!isRecord9(value) || !hasExactKeys(value, CURRENT_CONNECTION_KEYS) && !hasExactKeys(value, LEGACY_CONNECTION_KEYS)) {
|
|
41756
41363
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
41757
41364
|
}
|
|
41758
41365
|
const channelId = value["channelId"];
|
|
@@ -41812,9 +41419,9 @@ async function writeJsonAtomically(path2, value, signal) {
|
|
|
41812
41419
|
const directory = dirname7(path2);
|
|
41813
41420
|
const temporaryPath = join16(directory, `.${randomUUID4()}.tmp`);
|
|
41814
41421
|
try {
|
|
41815
|
-
await
|
|
41422
|
+
await mkdir4(directory, { mode: 448, recursive: true });
|
|
41816
41423
|
signal.throwIfAborted();
|
|
41817
|
-
await
|
|
41424
|
+
await writeFile3(temporaryPath, `${JSON.stringify(value, null, 2)}
|
|
41818
41425
|
`, { flag: "wx", mode: 384 });
|
|
41819
41426
|
signal.throwIfAborted();
|
|
41820
41427
|
await rename3(temporaryPath, path2);
|
|
@@ -41845,7 +41452,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
41845
41452
|
const rootDirectory = resolve5(options.stateDirectory);
|
|
41846
41453
|
const applicationDirectory = join16(rootDirectory, "installations", applicationId);
|
|
41847
41454
|
try {
|
|
41848
|
-
await
|
|
41455
|
+
await mkdir4(applicationDirectory, { mode: 448, recursive: true });
|
|
41849
41456
|
} catch (cause) {
|
|
41850
41457
|
throw new RuntimeInstallationStoreError(
|
|
41851
41458
|
"installation_unavailable",
|
|
@@ -41858,7 +41465,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
41858
41465
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
41859
41466
|
const stateDirectory = join16(applicationDirectory, storedInstallationId);
|
|
41860
41467
|
try {
|
|
41861
|
-
await
|
|
41468
|
+
await mkdir4(stateDirectory, { mode: 448, recursive: true });
|
|
41862
41469
|
} catch (cause) {
|
|
41863
41470
|
throw new RuntimeInstallationStoreError(
|
|
41864
41471
|
"installation_unavailable",
|
|
@@ -42014,7 +41621,7 @@ async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
|
42014
41621
|
}
|
|
42015
41622
|
const candidate = installationId();
|
|
42016
41623
|
try {
|
|
42017
|
-
await
|
|
41624
|
+
await writeFile3(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
|
|
42018
41625
|
`, {
|
|
42019
41626
|
flag: "wx",
|
|
42020
41627
|
mode: 384
|
|
@@ -42040,7 +41647,7 @@ async function openRuntimeInstallationStore(options, signal) {
|
|
|
42040
41647
|
// src/pairing/pair-local-machine.ts
|
|
42041
41648
|
var PAIRING_TIMEOUT_MILLISECONDS = 2e4;
|
|
42042
41649
|
var PAIRING_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{4}(?:-[A-HJ-NP-Z2-9]{4}){4}$/;
|
|
42043
|
-
var
|
|
41650
|
+
var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
42044
41651
|
var TOKEN_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
42045
41652
|
var CLAIM_RESPONSE_KEYS = ["channelId", "daemonToken", "runtimeId"];
|
|
42046
41653
|
var REDEEM_RESPONSE_KEYS = ["channelId", "runtimeCredential", "runtimeId"];
|
|
@@ -42052,7 +41659,7 @@ var PairingClientError = class extends Error {
|
|
|
42052
41659
|
this.name = "PairingClientError";
|
|
42053
41660
|
}
|
|
42054
41661
|
};
|
|
42055
|
-
function
|
|
41662
|
+
function isRecord10(value) {
|
|
42056
41663
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
42057
41664
|
}
|
|
42058
41665
|
function hasExactKeys2(value, expectedKeys) {
|
|
@@ -42091,7 +41698,7 @@ function parsePairingCode(value) {
|
|
|
42091
41698
|
return code;
|
|
42092
41699
|
}
|
|
42093
41700
|
function validatePairingId(value) {
|
|
42094
|
-
if (!
|
|
41701
|
+
if (!IDENTIFIER_PATTERN6.test(value)) {
|
|
42095
41702
|
throw new PairingClientError("invalid_pairing_id", "The Runtime pairing ID is invalid");
|
|
42096
41703
|
}
|
|
42097
41704
|
return value;
|
|
@@ -42099,7 +41706,7 @@ function validatePairingId(value) {
|
|
|
42099
41706
|
async function resolveDefaultWorkspace2(path2) {
|
|
42100
41707
|
const requestedWorkspace = resolve6(path2);
|
|
42101
41708
|
try {
|
|
42102
|
-
await
|
|
41709
|
+
await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
|
|
42103
41710
|
const defaultWorkspace = await realpath9(requestedWorkspace);
|
|
42104
41711
|
const metadata = await stat8(defaultWorkspace);
|
|
42105
41712
|
if (!metadata.isDirectory()) {
|
|
@@ -42130,9 +41737,9 @@ async function readJsonResponse(response) {
|
|
|
42130
41737
|
}
|
|
42131
41738
|
}
|
|
42132
41739
|
function readRelayError(value) {
|
|
42133
|
-
if (
|
|
41740
|
+
if (isRecord10(value)) {
|
|
42134
41741
|
const error62 = value["error"];
|
|
42135
|
-
if (
|
|
41742
|
+
if (isRecord10(error62)) {
|
|
42136
41743
|
const code = error62["code"];
|
|
42137
41744
|
const message = error62["message"];
|
|
42138
41745
|
if (typeof code === "string" && typeof message === "string") {
|
|
@@ -42143,13 +41750,13 @@ function readRelayError(value) {
|
|
|
42143
41750
|
return new PairingClientError("pairing_failed", "The relay could not pair this machine");
|
|
42144
41751
|
}
|
|
42145
41752
|
function decodePairingResponse(value, credentialField, expectedKeys) {
|
|
42146
|
-
if (!
|
|
41753
|
+
if (!isRecord10(value) || !hasExactKeys2(value, expectedKeys)) {
|
|
42147
41754
|
throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
|
|
42148
41755
|
}
|
|
42149
41756
|
const channelId = value["channelId"];
|
|
42150
41757
|
const runtimeCredential2 = value[credentialField];
|
|
42151
41758
|
const runtimeId = value["runtimeId"];
|
|
42152
|
-
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)) {
|
|
42153
41760
|
throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
|
|
42154
41761
|
}
|
|
42155
41762
|
return { channelId, runtimeCredential: runtimeCredential2, runtimeId };
|
|
@@ -42167,7 +41774,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
42167
41774
|
const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
|
|
42168
41775
|
let response;
|
|
42169
41776
|
try {
|
|
42170
|
-
response = await
|
|
41777
|
+
response = await fetch5(endpoint, {
|
|
42171
41778
|
body: JSON.stringify({
|
|
42172
41779
|
agents,
|
|
42173
41780
|
installableAgents,
|
|
@@ -42269,7 +41876,7 @@ async function resumeMobiusRuntime(installation, connectionId2, signal, environm
|
|
|
42269
41876
|
}
|
|
42270
41877
|
|
|
42271
41878
|
// src/runtime.ts
|
|
42272
|
-
var
|
|
41879
|
+
var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
42273
41880
|
var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
42274
41881
|
var MobiusRuntimeConfigurationError = class extends Error {
|
|
42275
41882
|
code = "runtime_configuration_invalid";
|
|
@@ -42321,7 +41928,7 @@ function relayUrlFromConnection(connection) {
|
|
|
42321
41928
|
}
|
|
42322
41929
|
function loadMobiusRuntimeConnection(environment = process.env) {
|
|
42323
41930
|
const channelId = requiredEnvironmentValue(environment, "MOBIUS_CHANNEL_ID");
|
|
42324
|
-
if (!
|
|
41931
|
+
if (!IDENTIFIER_PATTERN7.test(channelId)) {
|
|
42325
41932
|
throw new MobiusRuntimeConfigurationError("MOBIUS_CHANNEL_ID is invalid");
|
|
42326
41933
|
}
|
|
42327
41934
|
return Object.freeze({
|
|
@@ -42335,7 +41942,7 @@ function loadMobiusRuntimeConnection(environment = process.env) {
|
|
|
42335
41942
|
async function resolveWorkspace(path2) {
|
|
42336
41943
|
const requested = resolve7(path2);
|
|
42337
41944
|
try {
|
|
42338
|
-
await
|
|
41945
|
+
await mkdir6(requested, { recursive: true, mode: 448 });
|
|
42339
41946
|
const resolved = await realpath10(requested);
|
|
42340
41947
|
const metadata = await stat9(resolved);
|
|
42341
41948
|
if (!metadata.isDirectory()) {
|
|
@@ -42355,7 +41962,7 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
42355
41962
|
const relayUrl = relayUrlFromConnection(connection);
|
|
42356
41963
|
const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
|
|
42357
41964
|
const auditDatabasePath = resolve7(connection.auditDatabasePath);
|
|
42358
|
-
await
|
|
41965
|
+
await mkdir6(dirname8(auditDatabasePath), { recursive: true, mode: 448 });
|
|
42359
41966
|
const inventory = await discoverLocalAgentInventory({
|
|
42360
41967
|
defaultWorkspace,
|
|
42361
41968
|
environment: localContext.environment,
|