memeloop 0.2.4 → 0.2.5
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/browser.d.cts +26 -21
- package/dist/browser.d.ts +26 -21
- package/dist/chunk-4OITUYFC.js +37 -0
- package/dist/chunk-4OITUYFC.js.map +1 -0
- package/dist/{chunk-HY3U3GLE.js → chunk-5EUJNLVW.js} +1 -1
- package/dist/chunk-5EUJNLVW.js.map +1 -0
- package/dist/{chunk-KXVZQLJL.js → chunk-645GZGNM.js} +3 -2
- package/dist/chunk-645GZGNM.js.map +1 -0
- package/dist/{chunk-EPHRIRAL.js → chunk-6OLAL5CW.js} +16 -1
- package/dist/chunk-6OLAL5CW.js.map +1 -0
- package/dist/{chunk-LGUGYRR4.js → chunk-HVLCOJWI.js} +11 -6
- package/dist/{chunk-LGUGYRR4.js.map → chunk-HVLCOJWI.js.map} +1 -1
- package/dist/{chunk-5VYZV33O.js → chunk-KTZDDC7M.js} +64 -79
- package/dist/chunk-KTZDDC7M.js.map +1 -0
- package/dist/{chunk-K5KZJNDP.js → chunk-ROPAEJIM.js} +2 -2
- package/dist/{chunk-XNSJRDCW.js → chunk-UB77WKAU.js} +202 -344
- package/dist/chunk-UB77WKAU.js.map +1 -0
- package/dist/{chunk-KV6TC5UJ.js → chunk-XIEXGFPY.js} +3 -3
- package/dist/conversation.d.cts +4 -3
- package/dist/conversation.d.ts +4 -3
- package/dist/device-network-portable.cjs +2 -1
- package/dist/device-network-portable.cjs.map +1 -1
- package/dist/device-network-portable.d.cts +9 -7
- package/dist/device-network-portable.d.ts +9 -7
- package/dist/device-network-portable.js +1 -1
- package/dist/device-network.cjs +17 -1
- package/dist/device-network.cjs.map +1 -1
- package/dist/device-network.d.cts +6 -5
- package/dist/device-network.d.ts +6 -5
- package/dist/device-network.js +2 -2
- package/dist/{fetchProvider-B_vva3b3.d.ts → fetchProvider-Do8Hf1BN.d.ts} +1 -1
- package/dist/{fetchProvider-Bz4CE3_R.d.cts → fetchProvider-tMo6gc6N.d.cts} +1 -1
- package/dist/index.cjs +336 -438
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -26
- package/dist/index.d.ts +20 -26
- package/dist/index.js +29 -46
- package/dist/index.js.map +1 -1
- package/dist/{interface-3C3eG8Hn.d.cts → interface-C54gkLA3.d.ts} +3 -110
- package/dist/{interface-3C3eG8Hn.d.ts → interface-CECFnbzR.d.cts} +3 -110
- package/dist/llm-providers.cjs.map +1 -1
- package/dist/llm-providers.d.cts +3 -2
- package/dist/llm-providers.d.ts +3 -2
- package/dist/llm-providers.js +1 -1
- package/dist/llm-providers.js.map +1 -1
- package/dist/loop-api.cjs +81 -82
- package/dist/loop-api.cjs.map +1 -1
- package/dist/loop-api.d.cts +8 -7
- package/dist/loop-api.d.ts +8 -7
- package/dist/loop-api.js +5 -5
- package/dist/mobile.cjs +10 -5
- package/dist/mobile.cjs.map +1 -1
- package/dist/mobile.d.cts +6 -5
- package/dist/mobile.d.ts +6 -5
- package/dist/mobile.js +3 -3
- package/dist/{orchestration-portable-DUoAjtD1.d.ts → orchestration-portable-CQRrnoEw.d.ts} +5 -4
- package/dist/{orchestration-portable-xJ7z-ctw.d.cts → orchestration-portable-D4KBEYQb.d.cts} +5 -4
- package/dist/orchestration-portable.cjs +201 -343
- package/dist/orchestration-portable.cjs.map +1 -1
- package/dist/orchestration-portable.d.cts +6 -5
- package/dist/orchestration-portable.d.ts +6 -5
- package/dist/orchestration-portable.js +1 -1
- package/dist/{pairingInvite-C12n-7Ak.d.cts → pairingInvite-BmCQ-bHt.d.cts} +3 -3
- package/dist/{pairingInvite-CPQkuhLQ.d.ts → pairingInvite-CsfsexXC.d.ts} +3 -3
- package/dist/{promptConcat-VLe5SEN4.d.cts → promptConcat-BqImJtVh.d.cts} +7 -4
- package/dist/{promptConcat-CUEIA_3T.d.ts → promptConcat-C5SEgESi.d.ts} +7 -4
- package/dist/{providerRegistry-CaFK_aUd.d.ts → providerRegistry-BGrwd7Zl.d.cts} +2 -2
- package/dist/{providerRegistry-BDGGs5gz.d.cts → providerRegistry-Bs2lJpj9.d.ts} +2 -2
- package/dist/{registry-DNSEVYug.d.cts → registry-CelnriUR.d.cts} +3 -3
- package/dist/{registry-yGnYHWhq.d.ts → registry-DVv_RVPZ.d.ts} +3 -3
- package/dist/{remoteClient-DwBCoHpc.d.ts → remoteClient-D1gPizds.d.ts} +1 -1
- package/dist/{remoteClient-DFIyCZEv.d.cts → remoteClient-DxCHC4_Z.d.cts} +1 -1
- package/dist/{runtime-6EELHWVB.js → runtime-SASMRN4I.js} +3 -3
- package/dist/{scriptDeploymentPipeline-B1q-UhrO.d.ts → scriptDeploymentPipeline-CdDLEDMS.d.cts} +10 -1
- package/dist/{scriptDeploymentPipeline-XJzQyYys.d.cts → scriptDeploymentPipeline-DU6sor6Y.d.ts} +10 -1
- package/dist/{syncCloudDevices-C8fCUhnX.d.ts → syncCloudDevices-3RmB41sA.d.cts} +6 -2
- package/dist/{syncCloudDevices-BFw_c1g5.d.cts → syncCloudDevices-CSLbMESm.d.ts} +6 -2
- package/dist/tools.cjs +63 -0
- package/dist/tools.cjs.map +1 -0
- package/dist/tools.d.cts +12 -0
- package/dist/tools.d.ts +12 -0
- package/dist/tools.js +7 -0
- package/dist/tools.js.map +1 -0
- package/dist/{types-CcFFIk8W.d.ts → types-C29NBZ2w.d.ts} +1 -1
- package/dist/types-CcoJ_fdH.d.cts +110 -0
- package/dist/types-CcoJ_fdH.d.ts +110 -0
- package/dist/{types-C8gnhG9M.d.cts → types-D1rAJy9l.d.cts} +1 -1
- package/package.json +6 -1
- package/dist/chunk-5VYZV33O.js.map +0 -1
- package/dist/chunk-EPHRIRAL.js.map +0 -1
- package/dist/chunk-HY3U3GLE.js.map +0 -1
- package/dist/chunk-KXVZQLJL.js.map +0 -1
- package/dist/chunk-XNSJRDCW.js.map +0 -1
- /package/dist/{chunk-K5KZJNDP.js.map → chunk-ROPAEJIM.js.map} +0 -0
- /package/dist/{chunk-KV6TC5UJ.js.map → chunk-XIEXGFPY.js.map} +0 -0
- /package/dist/{runtime-6EELHWVB.js.map → runtime-SASMRN4I.js.map} +0 -0
|
@@ -1222,6 +1222,74 @@ function createArtifactManagementConformanceSuite(options) {
|
|
|
1222
1222
|
};
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
1225
|
+
// src/orchestration/drivers/driverState.ts
|
|
1226
|
+
function assertFencedDriverRequestEnvelope(request, options) {
|
|
1227
|
+
assertDriverRequestEnvelope(request, {
|
|
1228
|
+
now: options.now,
|
|
1229
|
+
requireRun: options.requireRun,
|
|
1230
|
+
requireFencing: true,
|
|
1231
|
+
requireCapability: true,
|
|
1232
|
+
expectedMethod: options.expectedMethod
|
|
1233
|
+
});
|
|
1234
|
+
if (options.actorKinds && !options.actorKinds.includes(request.actor.kind)) {
|
|
1235
|
+
throw new OrchestrationError({
|
|
1236
|
+
code: "FORBIDDEN",
|
|
1237
|
+
message: options.forbiddenMessage?.(request.actor.kind) ?? `actor kind '${request.actor.kind}' cannot call ${options.expectedMethod}`,
|
|
1238
|
+
retryable: false
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
const epoch = request.fencingEpoch;
|
|
1242
|
+
const current = options.fences.get(request.resource.uid) ?? 0;
|
|
1243
|
+
if (epoch < current) {
|
|
1244
|
+
throw new OrchestrationError({
|
|
1245
|
+
code: "STALE_EPOCH",
|
|
1246
|
+
message: `stale ${options.fenceName} fencing epoch ${epoch}; current epoch is ${current}`,
|
|
1247
|
+
retryable: false
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
options.fences.set(request.resource.uid, epoch);
|
|
1251
|
+
return epoch;
|
|
1252
|
+
}
|
|
1253
|
+
function driverOperationKey(request, operation) {
|
|
1254
|
+
return `${request.resource.uid}:${operation}:${request.idempotencyKey}`;
|
|
1255
|
+
}
|
|
1256
|
+
function findIdempotentDriverHandle(state, request, operation, driverName) {
|
|
1257
|
+
const key = driverOperationKey(request, operation);
|
|
1258
|
+
const handle = state.idempotency.get(key);
|
|
1259
|
+
if (handle === void 0) return void 0;
|
|
1260
|
+
if (state.idempotencyFingerprints.get(key) !== canonicalDriverValue(request.payload)) {
|
|
1261
|
+
throw new OrchestrationError({
|
|
1262
|
+
code: "CONFLICT",
|
|
1263
|
+
message: `${driverName} ${operation} idempotency key was reused with different input`,
|
|
1264
|
+
retryable: false
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
return handle;
|
|
1268
|
+
}
|
|
1269
|
+
function rememberIdempotentDriverHandle(state, request, operation, handle) {
|
|
1270
|
+
const key = driverOperationKey(request, operation);
|
|
1271
|
+
state.idempotency.set(key, handle);
|
|
1272
|
+
state.idempotencyFingerprints.set(key, canonicalDriverValue(request.payload));
|
|
1273
|
+
}
|
|
1274
|
+
function getOwnedDriverValue(collection, handle, resourceUid, kind) {
|
|
1275
|
+
const value = collection.get(handle);
|
|
1276
|
+
if (!value) {
|
|
1277
|
+
throw new OrchestrationError({
|
|
1278
|
+
code: "NOT_FOUND",
|
|
1279
|
+
message: `${kind} handle '${handle}' was not found`,
|
|
1280
|
+
retryable: false
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
if (value.resourceUid !== resourceUid) {
|
|
1284
|
+
throw new OrchestrationError({
|
|
1285
|
+
code: "FORBIDDEN",
|
|
1286
|
+
message: `${kind} handle '${handle}' belongs to another resource`,
|
|
1287
|
+
retryable: false
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
return value;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1225
1293
|
// src/orchestration/drivers/auditTelemetryManagement.ts
|
|
1226
1294
|
function createFakeAuditTelemetryState() {
|
|
1227
1295
|
return {
|
|
@@ -1237,16 +1305,8 @@ var FORBIDDEN_ATTRIBUTE = /(?:secret|token|password|credential|authorization|coo
|
|
|
1237
1305
|
function invalid3(message) {
|
|
1238
1306
|
throw new OrchestrationError({ code: "INVALID", message, retryable: false });
|
|
1239
1307
|
}
|
|
1240
|
-
function stable(value) {
|
|
1241
|
-
if (value === void 0) return "undefined";
|
|
1242
|
-
if (Array.isArray(value)) return `[${value.map(stable).join(",")}]`;
|
|
1243
|
-
if (value !== null && typeof value === "object") {
|
|
1244
|
-
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stable(item)}`).join(",")}}`;
|
|
1245
|
-
}
|
|
1246
|
-
return JSON.stringify(value) ?? typeof value;
|
|
1247
|
-
}
|
|
1248
1308
|
async function digest(value) {
|
|
1249
|
-
const bytes = new TextEncoder().encode(
|
|
1309
|
+
const bytes = new TextEncoder().encode(canonicalDriverValue(value));
|
|
1250
1310
|
const result = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
1251
1311
|
return `sha256:${[...new Uint8Array(result)].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
1252
1312
|
}
|
|
@@ -1264,29 +1324,13 @@ function createFakeAuditTelemetryManagementDriver(options = {}) {
|
|
|
1264
1324
|
const maxRecordsPerResource = options.maxRecordsPerResource ?? 1e4;
|
|
1265
1325
|
const maxAttributes = options.maxAttributes ?? 16;
|
|
1266
1326
|
function validate(request, expectedMethod, actorKinds) {
|
|
1267
|
-
|
|
1327
|
+
assertFencedDriverRequestEnvelope(request, {
|
|
1268
1328
|
now,
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1329
|
+
fences: state.fences,
|
|
1330
|
+
expectedMethod,
|
|
1331
|
+
fenceName: "audit",
|
|
1332
|
+
actorKinds
|
|
1272
1333
|
});
|
|
1273
|
-
if (!actorKinds.includes(request.actor.kind)) {
|
|
1274
|
-
throw new OrchestrationError({
|
|
1275
|
-
code: "FORBIDDEN",
|
|
1276
|
-
message: `actor kind '${request.actor.kind}' cannot call ${expectedMethod}`,
|
|
1277
|
-
retryable: false
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1280
|
-
const epoch = request.fencingEpoch;
|
|
1281
|
-
const current = state.fences.get(request.resource.uid) ?? 0;
|
|
1282
|
-
if (epoch < current) {
|
|
1283
|
-
throw new OrchestrationError({
|
|
1284
|
-
code: "STALE_EPOCH",
|
|
1285
|
-
message: `stale audit fencing epoch ${epoch}; current epoch is ${current}`,
|
|
1286
|
-
retryable: false
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
state.fences.set(request.resource.uid, epoch);
|
|
1290
1334
|
}
|
|
1291
1335
|
function common(request) {
|
|
1292
1336
|
const policyDigest = requiredString2(request.payload, "policyDigest", 80);
|
|
@@ -1316,7 +1360,7 @@ function createFakeAuditTelemetryManagementDriver(options = {}) {
|
|
|
1316
1360
|
}
|
|
1317
1361
|
async function append(request, kind, data) {
|
|
1318
1362
|
const idempotencyKey = `${request.resource.uid}:${request.method}:${request.idempotencyKey}`;
|
|
1319
|
-
const fingerprint =
|
|
1363
|
+
const fingerprint = canonicalDriverValue(request.payload);
|
|
1320
1364
|
let release;
|
|
1321
1365
|
const previousAppend = state.appendTail;
|
|
1322
1366
|
state.appendTail = new Promise((resolve) => {
|
|
@@ -2437,24 +2481,6 @@ function requiredString4(payload, field) {
|
|
|
2437
2481
|
if (payload === null || typeof payload !== "object" || typeof payload[field] !== "string" || !payload[field]) invalid5(`identity payload '${field}' is required`);
|
|
2438
2482
|
return payload[field];
|
|
2439
2483
|
}
|
|
2440
|
-
function owned(collection, handle, resourceUid, kind) {
|
|
2441
|
-
const value = collection.get(handle);
|
|
2442
|
-
if (!value) {
|
|
2443
|
-
throw new OrchestrationError({
|
|
2444
|
-
code: "NOT_FOUND",
|
|
2445
|
-
message: `${kind} handle '${handle}' was not found`,
|
|
2446
|
-
retryable: false
|
|
2447
|
-
});
|
|
2448
|
-
}
|
|
2449
|
-
if (value.resourceUid !== resourceUid) {
|
|
2450
|
-
throw new OrchestrationError({
|
|
2451
|
-
code: "FORBIDDEN",
|
|
2452
|
-
message: `${kind} handle '${handle}' belongs to another resource`,
|
|
2453
|
-
retryable: false
|
|
2454
|
-
});
|
|
2455
|
-
}
|
|
2456
|
-
return value;
|
|
2457
|
-
}
|
|
2458
2484
|
function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
2459
2485
|
const state = options.state ?? createFakeIdentityAttestationState();
|
|
2460
2486
|
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
@@ -2471,29 +2497,13 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2471
2497
|
`sha256:${"a".repeat(64)}`
|
|
2472
2498
|
];
|
|
2473
2499
|
function validate(request, expectedMethod, actorKinds) {
|
|
2474
|
-
|
|
2500
|
+
assertFencedDriverRequestEnvelope(request, {
|
|
2475
2501
|
now,
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2502
|
+
fences: state.fences,
|
|
2503
|
+
expectedMethod,
|
|
2504
|
+
fenceName: "identity",
|
|
2505
|
+
actorKinds
|
|
2479
2506
|
});
|
|
2480
|
-
if (!actorKinds.includes(request.actor.kind)) {
|
|
2481
|
-
throw new OrchestrationError({
|
|
2482
|
-
code: "FORBIDDEN",
|
|
2483
|
-
message: `actor kind '${request.actor.kind}' cannot call ${expectedMethod}`,
|
|
2484
|
-
retryable: false
|
|
2485
|
-
});
|
|
2486
|
-
}
|
|
2487
|
-
const fence = request.fencingEpoch;
|
|
2488
|
-
const current = state.fences.get(request.resource.uid) ?? 0;
|
|
2489
|
-
if (fence < current) {
|
|
2490
|
-
throw new OrchestrationError({
|
|
2491
|
-
code: "STALE_EPOCH",
|
|
2492
|
-
message: `stale identity fencing epoch ${fence}; current epoch is ${current}`,
|
|
2493
|
-
retryable: false
|
|
2494
|
-
});
|
|
2495
|
-
}
|
|
2496
|
-
state.fences.set(request.resource.uid, fence);
|
|
2497
2507
|
}
|
|
2498
2508
|
function ttl(payload, field, maximum) {
|
|
2499
2509
|
if (payload === null || typeof payload !== "object") {
|
|
@@ -2508,34 +2518,11 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2508
2518
|
state.nextHandle += 1;
|
|
2509
2519
|
return handle;
|
|
2510
2520
|
}
|
|
2511
|
-
function key(request, operation) {
|
|
2512
|
-
return `${request.resource.uid}:${operation}:${request.idempotencyKey}`;
|
|
2513
|
-
}
|
|
2514
|
-
function stable6(value) {
|
|
2515
|
-
if (value === void 0) return "undefined";
|
|
2516
|
-
if (Array.isArray(value)) return `[${value.map(stable6).join(",")}]`;
|
|
2517
|
-
if (value !== null && typeof value === "object") {
|
|
2518
|
-
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([name, item]) => `${JSON.stringify(name)}:${stable6(item)}`).join(",")}}`;
|
|
2519
|
-
}
|
|
2520
|
-
return JSON.stringify(value) ?? typeof value;
|
|
2521
|
-
}
|
|
2522
2521
|
function previous(request, operation) {
|
|
2523
|
-
|
|
2524
|
-
const handle = state.idempotency.get(idempotency);
|
|
2525
|
-
if (!handle) return void 0;
|
|
2526
|
-
if (state.idempotencyFingerprints.get(idempotency) !== stable6(request.payload)) {
|
|
2527
|
-
throw new OrchestrationError({
|
|
2528
|
-
code: "CONFLICT",
|
|
2529
|
-
message: `identity ${operation} idempotency key was reused with different input`,
|
|
2530
|
-
retryable: false
|
|
2531
|
-
});
|
|
2532
|
-
}
|
|
2533
|
-
return handle;
|
|
2522
|
+
return findIdempotentDriverHandle(state, request, operation, "identity");
|
|
2534
2523
|
}
|
|
2535
2524
|
function remember(request, operation, handle) {
|
|
2536
|
-
|
|
2537
|
-
state.idempotency.set(idempotency, handle);
|
|
2538
|
-
state.idempotencyFingerprints.set(idempotency, stable6(request.payload));
|
|
2525
|
+
rememberIdempotentDriverHandle(state, request, operation, handle);
|
|
2539
2526
|
}
|
|
2540
2527
|
function assertActiveIdentity(identity) {
|
|
2541
2528
|
if (identity.revoked) {
|
|
@@ -2579,7 +2566,7 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2579
2566
|
const ttlMs = ttl(request.payload, "ttlMs", maxSessionTtlMs);
|
|
2580
2567
|
const existing = previous(request, "enroll");
|
|
2581
2568
|
if (existing) {
|
|
2582
|
-
return structuredClone(
|
|
2569
|
+
return structuredClone(getOwnedDriverValue(
|
|
2583
2570
|
state.enrollments,
|
|
2584
2571
|
existing,
|
|
2585
2572
|
request.resource.uid,
|
|
@@ -2603,7 +2590,7 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2603
2590
|
},
|
|
2604
2591
|
async challenge(request) {
|
|
2605
2592
|
validate(request, "identity.challenge", ["controller", "admin"]);
|
|
2606
|
-
const enrollment =
|
|
2593
|
+
const enrollment = getOwnedDriverValue(
|
|
2607
2594
|
state.enrollments,
|
|
2608
2595
|
requiredString4(request.payload, "enrollmentHandle"),
|
|
2609
2596
|
request.resource.uid,
|
|
@@ -2616,7 +2603,7 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2616
2603
|
const ttlMs = ttl(request.payload, "ttlMs", maxChallengeTtlMs);
|
|
2617
2604
|
const existing = previous(request, "challenge");
|
|
2618
2605
|
if (existing) {
|
|
2619
|
-
return structuredClone(
|
|
2606
|
+
return structuredClone(getOwnedDriverValue(
|
|
2620
2607
|
state.challenges,
|
|
2621
2608
|
existing,
|
|
2622
2609
|
request.resource.uid,
|
|
@@ -2646,13 +2633,13 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2646
2633
|
},
|
|
2647
2634
|
async attest(request) {
|
|
2648
2635
|
validate(request, "identity.attest", ["controller", "verifier"]);
|
|
2649
|
-
const challenge =
|
|
2636
|
+
const challenge = getOwnedDriverValue(
|
|
2650
2637
|
state.challenges,
|
|
2651
2638
|
requiredString4(request.payload, "challengeHandle"),
|
|
2652
2639
|
request.resource.uid,
|
|
2653
2640
|
"challenge"
|
|
2654
2641
|
);
|
|
2655
|
-
const enrollment =
|
|
2642
|
+
const enrollment = getOwnedDriverValue(
|
|
2656
2643
|
state.enrollments,
|
|
2657
2644
|
challenge.enrollmentHandle,
|
|
2658
2645
|
request.resource.uid,
|
|
@@ -2688,7 +2675,7 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2688
2675
|
}
|
|
2689
2676
|
const existing = previous(request, "attest");
|
|
2690
2677
|
if (existing) {
|
|
2691
|
-
return structuredClone(
|
|
2678
|
+
return structuredClone(getOwnedDriverValue(
|
|
2692
2679
|
state.identities,
|
|
2693
2680
|
existing,
|
|
2694
2681
|
request.resource.uid,
|
|
@@ -2723,7 +2710,7 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2723
2710
|
},
|
|
2724
2711
|
async issueSession(request) {
|
|
2725
2712
|
validate(request, "identity.issue-session", ["controller", "admin"]);
|
|
2726
|
-
const identity =
|
|
2713
|
+
const identity = getOwnedDriverValue(
|
|
2727
2714
|
state.identities,
|
|
2728
2715
|
requiredString4(request.payload, "identityHandle"),
|
|
2729
2716
|
request.resource.uid,
|
|
@@ -2752,7 +2739,7 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2752
2739
|
const ttlMs = ttl(request.payload, "ttlMs", maxSessionTtlMs);
|
|
2753
2740
|
const existing = previous(request, "issue-session");
|
|
2754
2741
|
if (existing) {
|
|
2755
|
-
return structuredClone(
|
|
2742
|
+
return structuredClone(getOwnedDriverValue(
|
|
2756
2743
|
state.sessions,
|
|
2757
2744
|
existing,
|
|
2758
2745
|
request.resource.uid,
|
|
@@ -2776,7 +2763,7 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2776
2763
|
},
|
|
2777
2764
|
async rotate(request) {
|
|
2778
2765
|
validate(request, "identity.rotate", ["controller", "admin"]);
|
|
2779
|
-
const identity =
|
|
2766
|
+
const identity = getOwnedDriverValue(
|
|
2780
2767
|
state.identities,
|
|
2781
2768
|
requiredString4(request.payload, "identityHandle"),
|
|
2782
2769
|
request.resource.uid,
|
|
@@ -2793,7 +2780,7 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2793
2780
|
);
|
|
2794
2781
|
const existing = previous(request, "rotate");
|
|
2795
2782
|
if (existing) {
|
|
2796
|
-
return structuredClone(
|
|
2783
|
+
return structuredClone(getOwnedDriverValue(
|
|
2797
2784
|
state.identities,
|
|
2798
2785
|
existing,
|
|
2799
2786
|
request.resource.uid,
|
|
@@ -2821,7 +2808,7 @@ function createFakeIdentityAttestationManagementDriver(options = {}) {
|
|
|
2821
2808
|
},
|
|
2822
2809
|
async revoke(request) {
|
|
2823
2810
|
validate(request, "identity.revoke", ["controller", "admin"]);
|
|
2824
|
-
const identity =
|
|
2811
|
+
const identity = getOwnedDriverValue(
|
|
2825
2812
|
state.identities,
|
|
2826
2813
|
requiredString4(request.payload, "identityHandle"),
|
|
2827
2814
|
request.resource.uid,
|
|
@@ -4100,12 +4087,12 @@ function createManagedCredentialBrokerAdapter(broker, options) {
|
|
|
4100
4087
|
retryable: false
|
|
4101
4088
|
});
|
|
4102
4089
|
}
|
|
4103
|
-
const
|
|
4104
|
-
if (!
|
|
4090
|
+
const stable = options.stableHandleFor?.(request) ?? stableHandle();
|
|
4091
|
+
if (!stable || stable.length > 2048) {
|
|
4105
4092
|
invalid6("credential stable handle is empty or too long");
|
|
4106
4093
|
}
|
|
4107
4094
|
if (options.handleStore) {
|
|
4108
|
-
const adopted = await options.handleStore.get(
|
|
4095
|
+
const adopted = await options.handleStore.get(stable);
|
|
4109
4096
|
if (adopted) {
|
|
4110
4097
|
const inspection = await broker.inspect(adopted.token);
|
|
4111
4098
|
const exact = inspection.grantId === request.resource.uid && canonicalDriverValue(inspection.scope) === canonicalDriverValue({
|
|
@@ -4125,13 +4112,13 @@ function createManagedCredentialBrokerAdapter(broker, options) {
|
|
|
4125
4112
|
});
|
|
4126
4113
|
}
|
|
4127
4114
|
const adoptedRecord = {
|
|
4128
|
-
stableHandle:
|
|
4115
|
+
stableHandle: stable,
|
|
4129
4116
|
token: adopted.token,
|
|
4130
4117
|
resourceUid: request.resource.uid,
|
|
4131
4118
|
targetDriver: request.payload.targetDriver
|
|
4132
4119
|
};
|
|
4133
|
-
records.set(
|
|
4134
|
-
await rememberIdempotency(key, request,
|
|
4120
|
+
records.set(stable, adoptedRecord);
|
|
4121
|
+
await rememberIdempotency(key, request, stable);
|
|
4135
4122
|
return managed(adoptedRecord, inspection);
|
|
4136
4123
|
}
|
|
4137
4124
|
}
|
|
@@ -4147,7 +4134,7 @@ function createManagedCredentialBrokerAdapter(broker, options) {
|
|
|
4147
4134
|
grantId: request.resource.uid
|
|
4148
4135
|
});
|
|
4149
4136
|
const record2 = {
|
|
4150
|
-
stableHandle:
|
|
4137
|
+
stableHandle: stable,
|
|
4151
4138
|
token: issued.token,
|
|
4152
4139
|
resourceUid: request.resource.uid,
|
|
4153
4140
|
targetDriver: request.payload.targetDriver
|
|
@@ -5286,13 +5273,6 @@ function createFakeNetworkManagementState() {
|
|
|
5286
5273
|
nextHandle: 1
|
|
5287
5274
|
};
|
|
5288
5275
|
}
|
|
5289
|
-
function stable2(value) {
|
|
5290
|
-
if (Array.isArray(value)) return `[${value.map(stable2).join(",")}]`;
|
|
5291
|
-
if (value !== null && typeof value === "object") {
|
|
5292
|
-
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stable2(item)}`).join(",")}}`;
|
|
5293
|
-
}
|
|
5294
|
-
return JSON.stringify(value) ?? typeof value;
|
|
5295
|
-
}
|
|
5296
5276
|
function invalid7(message) {
|
|
5297
5277
|
throw new OrchestrationError({ code: "INVALID", message, retryable: false });
|
|
5298
5278
|
}
|
|
@@ -5493,31 +5473,15 @@ function createFakeNetworkManagementDriver(options = {}) {
|
|
|
5493
5473
|
...options.capabilities
|
|
5494
5474
|
};
|
|
5495
5475
|
function validate(request, method) {
|
|
5496
|
-
|
|
5476
|
+
return assertFencedDriverRequestEnvelope(request, {
|
|
5497
5477
|
now,
|
|
5478
|
+
fences: state.fences,
|
|
5498
5479
|
requireRun: true,
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5480
|
+
expectedMethod: method,
|
|
5481
|
+
fenceName: "network",
|
|
5482
|
+
actorKinds: ["controller", "admin"],
|
|
5483
|
+
forbiddenMessage: () => "network lifecycle requires a controller or admin actor"
|
|
5502
5484
|
});
|
|
5503
|
-
if (request.actor.kind !== "controller" && request.actor.kind !== "admin") {
|
|
5504
|
-
throw new OrchestrationError({
|
|
5505
|
-
code: "FORBIDDEN",
|
|
5506
|
-
message: "network lifecycle requires a controller or admin actor",
|
|
5507
|
-
retryable: false
|
|
5508
|
-
});
|
|
5509
|
-
}
|
|
5510
|
-
const fence = request.fencingEpoch;
|
|
5511
|
-
const current = state.fences.get(request.resource.uid) ?? 0;
|
|
5512
|
-
if (fence < current) {
|
|
5513
|
-
throw new OrchestrationError({
|
|
5514
|
-
code: "STALE_EPOCH",
|
|
5515
|
-
message: `stale network fencing epoch ${fence}; current epoch is ${current}`,
|
|
5516
|
-
retryable: false
|
|
5517
|
-
});
|
|
5518
|
-
}
|
|
5519
|
-
state.fences.set(request.resource.uid, fence);
|
|
5520
|
-
return fence;
|
|
5521
5485
|
}
|
|
5522
5486
|
function nextHandle(prefix) {
|
|
5523
5487
|
const handle = `${prefix}:${state.nextHandle}`;
|
|
@@ -5581,7 +5545,7 @@ function createFakeNetworkManagementDriver(options = {}) {
|
|
|
5581
5545
|
}
|
|
5582
5546
|
function idempotent(request, operation) {
|
|
5583
5547
|
const key = `${request.resource.uid}:${operation}:${request.idempotencyKey}`;
|
|
5584
|
-
const fingerprint =
|
|
5548
|
+
const fingerprint = canonicalDriverValue(request.payload);
|
|
5585
5549
|
const existing = state.idempotency.get(key);
|
|
5586
5550
|
if (existing) {
|
|
5587
5551
|
if (existing.fingerprint !== fingerprint) {
|
|
@@ -5598,7 +5562,7 @@ function createFakeNetworkManagementDriver(options = {}) {
|
|
|
5598
5562
|
function remember(request, operation, resultHandle) {
|
|
5599
5563
|
state.idempotency.set(
|
|
5600
5564
|
`${request.resource.uid}:${operation}:${request.idempotencyKey}`,
|
|
5601
|
-
{ fingerprint:
|
|
5565
|
+
{ fingerprint: canonicalDriverValue(request.payload), resultHandle }
|
|
5602
5566
|
);
|
|
5603
5567
|
}
|
|
5604
5568
|
return {
|
|
@@ -6163,18 +6127,10 @@ function requiredString6(value, field, maximum = 256) {
|
|
|
6163
6127
|
if (!result || result.length > maximum) invalid8(`tool payload '${field}' is invalid`);
|
|
6164
6128
|
return result;
|
|
6165
6129
|
}
|
|
6166
|
-
function stable3(value) {
|
|
6167
|
-
if (value === void 0) return "undefined";
|
|
6168
|
-
if (Array.isArray(value)) return `[${value.map(stable3).join(",")}]`;
|
|
6169
|
-
if (value !== null && typeof value === "object") {
|
|
6170
|
-
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stable3(item)}`).join(",")}}`;
|
|
6171
|
-
}
|
|
6172
|
-
return JSON.stringify(value) ?? typeof value;
|
|
6173
|
-
}
|
|
6174
6130
|
async function digest2(value) {
|
|
6175
6131
|
const result = await globalThis.crypto.subtle.digest(
|
|
6176
6132
|
"SHA-256",
|
|
6177
|
-
new TextEncoder().encode(
|
|
6133
|
+
new TextEncoder().encode(canonicalDriverValue(value))
|
|
6178
6134
|
);
|
|
6179
6135
|
return `sha256:${[...new Uint8Array(result)].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
6180
6136
|
}
|
|
@@ -6257,37 +6213,21 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6257
6213
|
if (!SHA2565.test(descriptor.schemaDigest) || descriptor.schemaDigest !== actualSchemaDigest || !descriptor.name || !descriptor.version || !descriptor.targets.length) invalid8(`tool catalog descriptor '${descriptor.name}' is invalid`);
|
|
6258
6214
|
}
|
|
6259
6215
|
return digest2(
|
|
6260
|
-
tools.map(descriptorInput).sort((left, right) =>
|
|
6216
|
+
tools.map(descriptorInput).sort((left, right) => canonicalDriverValue(left).localeCompare(canonicalDriverValue(right)))
|
|
6261
6217
|
);
|
|
6262
6218
|
})();
|
|
6263
6219
|
return catalogDigestPromise;
|
|
6264
6220
|
}
|
|
6265
6221
|
function validate(request, expectedMethod, actorKinds = ["controller"]) {
|
|
6266
|
-
|
|
6222
|
+
assertFencedDriverRequestEnvelope(request, {
|
|
6267
6223
|
now,
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6224
|
+
fences: state.fences,
|
|
6225
|
+
expectedMethod,
|
|
6226
|
+
fenceName: "tool",
|
|
6227
|
+
actorKinds
|
|
6271
6228
|
});
|
|
6272
|
-
if (!actorKinds.includes(request.actor.kind)) {
|
|
6273
|
-
throw new OrchestrationError({
|
|
6274
|
-
code: "FORBIDDEN",
|
|
6275
|
-
message: `actor kind '${request.actor.kind}' cannot call ${expectedMethod}`,
|
|
6276
|
-
retryable: false
|
|
6277
|
-
});
|
|
6278
|
-
}
|
|
6279
|
-
const epoch = request.fencingEpoch;
|
|
6280
|
-
const current = state.fences.get(request.resource.uid) ?? 0;
|
|
6281
|
-
if (epoch < current) {
|
|
6282
|
-
throw new OrchestrationError({
|
|
6283
|
-
code: "STALE_EPOCH",
|
|
6284
|
-
message: `stale tool fencing epoch ${epoch}; current epoch is ${current}`,
|
|
6285
|
-
retryable: false
|
|
6286
|
-
});
|
|
6287
|
-
}
|
|
6288
|
-
state.fences.set(request.resource.uid, epoch);
|
|
6289
6229
|
}
|
|
6290
|
-
function
|
|
6230
|
+
function owned(collection, handle, resourceUid, kind) {
|
|
6291
6231
|
const value = collection.get(handle);
|
|
6292
6232
|
if (!value) {
|
|
6293
6233
|
throw new OrchestrationError({
|
|
@@ -6312,21 +6252,10 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6312
6252
|
return `${prefix}:${state.nextHandle++}`;
|
|
6313
6253
|
}
|
|
6314
6254
|
function idempotency(request, operation) {
|
|
6315
|
-
|
|
6316
|
-
const previous = state.idempotency.get(key);
|
|
6317
|
-
if (previous && state.idempotencyFingerprints.get(key) !== stable3(request.payload)) {
|
|
6318
|
-
throw new OrchestrationError({
|
|
6319
|
-
code: "CONFLICT",
|
|
6320
|
-
message: `tool ${operation} idempotency key was reused with different input`,
|
|
6321
|
-
retryable: false
|
|
6322
|
-
});
|
|
6323
|
-
}
|
|
6324
|
-
return previous;
|
|
6255
|
+
return findIdempotentDriverHandle(state, request, operation, "tool");
|
|
6325
6256
|
}
|
|
6326
6257
|
function remember(request, operation, handle) {
|
|
6327
|
-
|
|
6328
|
-
state.idempotency.set(key, handle);
|
|
6329
|
-
state.idempotencyFingerprints.set(key, stable3(request.payload));
|
|
6258
|
+
rememberIdempotentDriverHandle(state, request, operation, handle);
|
|
6330
6259
|
}
|
|
6331
6260
|
async function* defaultExecutor(descriptor, target, arguments_) {
|
|
6332
6261
|
yield JSON.stringify({ tool: descriptor.name, target, arguments: arguments_ });
|
|
@@ -6409,7 +6338,7 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6409
6338
|
if (request.payload.operationIdempotencyKey && !descriptor.supportsIdempotency) invalid8("tool does not support operation idempotency");
|
|
6410
6339
|
const previous = idempotency(request, "prepare");
|
|
6411
6340
|
if (previous) {
|
|
6412
|
-
return structuredClone(
|
|
6341
|
+
return structuredClone(owned(
|
|
6413
6342
|
state.preparations,
|
|
6414
6343
|
previous,
|
|
6415
6344
|
request.resource.uid,
|
|
@@ -6434,7 +6363,7 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6434
6363
|
},
|
|
6435
6364
|
async authorize(request) {
|
|
6436
6365
|
validate(request, "tool.authorize", ["controller", "admin"]);
|
|
6437
|
-
const preparation =
|
|
6366
|
+
const preparation = owned(
|
|
6438
6367
|
state.preparations,
|
|
6439
6368
|
requiredString6(request.payload, "preparationHandle"),
|
|
6440
6369
|
request.resource.uid,
|
|
@@ -6465,7 +6394,7 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6465
6394
|
}
|
|
6466
6395
|
const previous = idempotency(request, "authorize");
|
|
6467
6396
|
if (previous) {
|
|
6468
|
-
return structuredClone(
|
|
6397
|
+
return structuredClone(owned(
|
|
6469
6398
|
state.authorizations,
|
|
6470
6399
|
previous,
|
|
6471
6400
|
request.resource.uid,
|
|
@@ -6487,13 +6416,13 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6487
6416
|
},
|
|
6488
6417
|
async *invoke(request, invokeOptions = {}) {
|
|
6489
6418
|
validate(request, "tool.invoke");
|
|
6490
|
-
const preparation =
|
|
6419
|
+
const preparation = owned(
|
|
6491
6420
|
state.preparations,
|
|
6492
6421
|
requiredString6(request.payload, "preparationHandle"),
|
|
6493
6422
|
request.resource.uid,
|
|
6494
6423
|
"tool preparation"
|
|
6495
6424
|
);
|
|
6496
|
-
const authorization =
|
|
6425
|
+
const authorization = owned(
|
|
6497
6426
|
state.authorizations,
|
|
6498
6427
|
requiredString6(request.payload, "authorizationHandle"),
|
|
6499
6428
|
request.resource.uid,
|
|
@@ -6513,7 +6442,7 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6513
6442
|
}
|
|
6514
6443
|
const previous = idempotency(request, "invoke");
|
|
6515
6444
|
if (previous) {
|
|
6516
|
-
const execution2 =
|
|
6445
|
+
const execution2 = owned(
|
|
6517
6446
|
state.executions,
|
|
6518
6447
|
previous,
|
|
6519
6448
|
request.resource.uid,
|
|
@@ -6618,14 +6547,14 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6618
6547
|
},
|
|
6619
6548
|
async reconcileUnknownEffect(request) {
|
|
6620
6549
|
validate(request, "tool.reconcile-unknown", ["controller", "verifier", "admin"]);
|
|
6621
|
-
const execution =
|
|
6550
|
+
const execution = owned(
|
|
6622
6551
|
state.executions,
|
|
6623
6552
|
requiredString6(request.payload, "executionHandle"),
|
|
6624
6553
|
request.resource.uid,
|
|
6625
6554
|
"tool execution"
|
|
6626
6555
|
);
|
|
6627
6556
|
if (execution.phase !== "Unknown") return structuredClone(execution);
|
|
6628
|
-
const preparation =
|
|
6557
|
+
const preparation = owned(
|
|
6629
6558
|
state.preparations,
|
|
6630
6559
|
execution.preparationHandle,
|
|
6631
6560
|
request.resource.uid,
|
|
@@ -6651,14 +6580,14 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6651
6580
|
},
|
|
6652
6581
|
async collectEvidence(request) {
|
|
6653
6582
|
validate(request, "tool.collect-evidence", ["controller", "verifier", "admin"]);
|
|
6654
|
-
const execution =
|
|
6583
|
+
const execution = owned(
|
|
6655
6584
|
state.executions,
|
|
6656
6585
|
requiredString6(request.payload, "executionHandle"),
|
|
6657
6586
|
request.resource.uid,
|
|
6658
6587
|
"tool execution"
|
|
6659
6588
|
);
|
|
6660
6589
|
const descriptor = tool(
|
|
6661
|
-
|
|
6590
|
+
owned(
|
|
6662
6591
|
state.preparations,
|
|
6663
6592
|
execution.preparationHandle,
|
|
6664
6593
|
request.resource.uid,
|
|
@@ -6668,7 +6597,7 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6668
6597
|
if (!descriptor?.supportsEvidence) invalid8("tool does not support evidence");
|
|
6669
6598
|
const previous = idempotency(request, "evidence");
|
|
6670
6599
|
if (previous) {
|
|
6671
|
-
return structuredClone(
|
|
6600
|
+
return structuredClone(owned(
|
|
6672
6601
|
state.evidence,
|
|
6673
6602
|
previous,
|
|
6674
6603
|
request.resource.uid,
|
|
@@ -6689,14 +6618,14 @@ function createFakeToolManagementDriver(options = {}) {
|
|
|
6689
6618
|
},
|
|
6690
6619
|
async cleanup(request) {
|
|
6691
6620
|
validate(request, "tool.cleanup");
|
|
6692
|
-
const preparation =
|
|
6621
|
+
const preparation = owned(
|
|
6693
6622
|
state.preparations,
|
|
6694
6623
|
requiredString6(request.payload, "preparationHandle"),
|
|
6695
6624
|
request.resource.uid,
|
|
6696
6625
|
"tool preparation"
|
|
6697
6626
|
);
|
|
6698
6627
|
if (request.payload.executionHandle) {
|
|
6699
|
-
const execution =
|
|
6628
|
+
const execution = owned(
|
|
6700
6629
|
state.executions,
|
|
6701
6630
|
request.payload.executionHandle,
|
|
6702
6631
|
request.resource.uid,
|
|
@@ -6855,7 +6784,7 @@ function createToolManagementConformanceSuite(options) {
|
|
|
6855
6784
|
{ executionHandle: first[0].executionHandle },
|
|
6856
6785
|
"inspect-invoke"
|
|
6857
6786
|
));
|
|
6858
|
-
if (!first.at(-1)?.final ||
|
|
6787
|
+
if (!first.at(-1)?.final || canonicalDriverValue(first) !== canonicalDriverValue(replay) || execution?.phase !== "Completed") throw new Error("tool streaming or retry did not converge");
|
|
6859
6788
|
}
|
|
6860
6789
|
},
|
|
6861
6790
|
{
|
|
@@ -7029,14 +6958,6 @@ function createFakeModelManagementState() {
|
|
|
7029
6958
|
nextHandle: 1
|
|
7030
6959
|
};
|
|
7031
6960
|
}
|
|
7032
|
-
function stable4(value) {
|
|
7033
|
-
if (value === void 0) return "undefined";
|
|
7034
|
-
if (Array.isArray(value)) return `[${value.map(stable4).join(",")}]`;
|
|
7035
|
-
if (value !== null && typeof value === "object") {
|
|
7036
|
-
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stable4(item)}`).join(",")}}`;
|
|
7037
|
-
}
|
|
7038
|
-
return JSON.stringify(value) ?? typeof value;
|
|
7039
|
-
}
|
|
7040
6961
|
function invalid9(message) {
|
|
7041
6962
|
throw new OrchestrationError({ code: "INVALID", message, retryable: false });
|
|
7042
6963
|
}
|
|
@@ -7095,31 +7016,15 @@ function createFakeModelManagementDriver(options = {}) {
|
|
|
7095
7016
|
};
|
|
7096
7017
|
const active = /* @__PURE__ */ new Map();
|
|
7097
7018
|
function validate(request, method) {
|
|
7098
|
-
|
|
7019
|
+
return assertFencedDriverRequestEnvelope(request, {
|
|
7099
7020
|
now,
|
|
7021
|
+
fences: state.fences,
|
|
7100
7022
|
requireRun: true,
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7023
|
+
expectedMethod: method,
|
|
7024
|
+
fenceName: "model",
|
|
7025
|
+
actorKinds: ["controller", "admin"],
|
|
7026
|
+
forbiddenMessage: () => "model provider access requires a controller or admin actor"
|
|
7104
7027
|
});
|
|
7105
|
-
if (request.actor.kind !== "controller" && request.actor.kind !== "admin") {
|
|
7106
|
-
throw new OrchestrationError({
|
|
7107
|
-
code: "FORBIDDEN",
|
|
7108
|
-
message: "model provider access requires a controller or admin actor",
|
|
7109
|
-
retryable: false
|
|
7110
|
-
});
|
|
7111
|
-
}
|
|
7112
|
-
const fence = request.fencingEpoch;
|
|
7113
|
-
const current = state.fences.get(request.resource.uid) ?? 0;
|
|
7114
|
-
if (fence < current) {
|
|
7115
|
-
throw new OrchestrationError({
|
|
7116
|
-
code: "STALE_EPOCH",
|
|
7117
|
-
message: `stale model fencing epoch ${fence}; current epoch is ${current}`,
|
|
7118
|
-
retryable: false
|
|
7119
|
-
});
|
|
7120
|
-
}
|
|
7121
|
-
state.fences.set(request.resource.uid, fence);
|
|
7122
|
-
return fence;
|
|
7123
7028
|
}
|
|
7124
7029
|
function modelFor(payload) {
|
|
7125
7030
|
assertOnlyFields2(
|
|
@@ -7246,7 +7151,7 @@ function createFakeModelManagementDriver(options = {}) {
|
|
|
7246
7151
|
const fence = validate(request, "model.generate");
|
|
7247
7152
|
const model = modelFor(request.payload);
|
|
7248
7153
|
await authorize(request, model);
|
|
7249
|
-
const inputFingerprint =
|
|
7154
|
+
const inputFingerprint = canonicalDriverValue({
|
|
7250
7155
|
payload: request.payload,
|
|
7251
7156
|
run: request.run,
|
|
7252
7157
|
session: request.session,
|
|
@@ -7485,7 +7390,9 @@ function createModelManagementConformanceSuite(options) {
|
|
|
7485
7390
|
);
|
|
7486
7391
|
const first = await collect(driver, request);
|
|
7487
7392
|
const second = await collect(driver, request);
|
|
7488
|
-
if (
|
|
7393
|
+
if (canonicalDriverValue(first) !== canonicalDriverValue(second)) {
|
|
7394
|
+
throw new Error("model generation did not replay");
|
|
7395
|
+
}
|
|
7489
7396
|
if (first.at(-1)?.type !== "done") throw new Error("model stream did not complete");
|
|
7490
7397
|
let driftRejected = false;
|
|
7491
7398
|
try {
|
|
@@ -7619,16 +7526,8 @@ function requiredString7(value, field) {
|
|
|
7619
7526
|
if (value === null || typeof value !== "object" || typeof value[field] !== "string" || !value[field]) invalid10(`policy payload '${field}' is required`);
|
|
7620
7527
|
return value[field];
|
|
7621
7528
|
}
|
|
7622
|
-
function stable5(value) {
|
|
7623
|
-
if (value === void 0) return "undefined";
|
|
7624
|
-
if (Array.isArray(value)) return `[${value.map(stable5).join(",")}]`;
|
|
7625
|
-
if (value !== null && typeof value === "object") {
|
|
7626
|
-
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stable5(item)}`).join(",")}}`;
|
|
7627
|
-
}
|
|
7628
|
-
return JSON.stringify(value) ?? typeof value;
|
|
7629
|
-
}
|
|
7630
7529
|
async function digest3(value) {
|
|
7631
|
-
const bytes = new TextEncoder().encode(
|
|
7530
|
+
const bytes = new TextEncoder().encode(canonicalDriverValue(value));
|
|
7632
7531
|
const result = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
7633
7532
|
return `sha256:${[...new Uint8Array(result)].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
7634
7533
|
}
|
|
@@ -7649,34 +7548,18 @@ function createFakePolicyApprovalManagementDriver(options = {}) {
|
|
|
7649
7548
|
]
|
|
7650
7549
|
);
|
|
7651
7550
|
function validate(request, expectedMethod, actorKinds) {
|
|
7652
|
-
|
|
7551
|
+
assertFencedDriverRequestEnvelope(request, {
|
|
7653
7552
|
now,
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7553
|
+
fences: state.fences,
|
|
7554
|
+
expectedMethod,
|
|
7555
|
+
fenceName: "policy",
|
|
7556
|
+
actorKinds
|
|
7657
7557
|
});
|
|
7658
|
-
if (!actorKinds.includes(request.actor.kind)) {
|
|
7659
|
-
throw new OrchestrationError({
|
|
7660
|
-
code: "FORBIDDEN",
|
|
7661
|
-
message: `actor kind '${request.actor.kind}' cannot call ${expectedMethod}`,
|
|
7662
|
-
retryable: false
|
|
7663
|
-
});
|
|
7664
|
-
}
|
|
7665
|
-
const epoch = request.fencingEpoch;
|
|
7666
|
-
const current = state.fences.get(request.resource.uid) ?? 0;
|
|
7667
|
-
if (epoch < current) {
|
|
7668
|
-
throw new OrchestrationError({
|
|
7669
|
-
code: "STALE_EPOCH",
|
|
7670
|
-
message: `stale policy fencing epoch ${epoch}; current epoch is ${current}`,
|
|
7671
|
-
retryable: false
|
|
7672
|
-
});
|
|
7673
|
-
}
|
|
7674
|
-
state.fences.set(request.resource.uid, epoch);
|
|
7675
7558
|
}
|
|
7676
7559
|
function assertPolicyDigest(value) {
|
|
7677
7560
|
if (!SHA2567.test(value)) invalid10("policyDigest must be a canonical sha256 digest");
|
|
7678
7561
|
}
|
|
7679
|
-
function
|
|
7562
|
+
function owned(handle, resourceUid) {
|
|
7680
7563
|
const decision = state.decisions.get(handle);
|
|
7681
7564
|
if (!decision) {
|
|
7682
7565
|
throw new OrchestrationError({
|
|
@@ -7696,18 +7579,14 @@ function createFakePolicyApprovalManagementDriver(options = {}) {
|
|
|
7696
7579
|
}
|
|
7697
7580
|
async function decide(request, operation, kind, outcome, policyDigest, reasons, obligations = [], approval) {
|
|
7698
7581
|
assertPolicyDigest(policyDigest);
|
|
7699
|
-
const
|
|
7700
|
-
|
|
7701
|
-
|
|
7582
|
+
const previousHandle = findIdempotentDriverHandle(
|
|
7583
|
+
state,
|
|
7584
|
+
request,
|
|
7585
|
+
operation,
|
|
7586
|
+
"policy"
|
|
7587
|
+
);
|
|
7702
7588
|
if (previousHandle) {
|
|
7703
|
-
|
|
7704
|
-
throw new OrchestrationError({
|
|
7705
|
-
code: "CONFLICT",
|
|
7706
|
-
message: `policy ${operation} idempotency key was reused with different input`,
|
|
7707
|
-
retryable: false
|
|
7708
|
-
});
|
|
7709
|
-
}
|
|
7710
|
-
return structuredClone(owned2(previousHandle, request.resource.uid));
|
|
7589
|
+
return structuredClone(owned(previousHandle, request.resource.uid));
|
|
7711
7590
|
}
|
|
7712
7591
|
const decision = {
|
|
7713
7592
|
decisionHandle: `policy-decision:${state.nextHandle++}`,
|
|
@@ -7723,8 +7602,12 @@ function createFakePolicyApprovalManagementDriver(options = {}) {
|
|
|
7723
7602
|
approval
|
|
7724
7603
|
};
|
|
7725
7604
|
state.decisions.set(decision.decisionHandle, decision);
|
|
7726
|
-
|
|
7727
|
-
|
|
7605
|
+
rememberIdempotentDriverHandle(
|
|
7606
|
+
state,
|
|
7607
|
+
request,
|
|
7608
|
+
operation,
|
|
7609
|
+
decision.decisionHandle
|
|
7610
|
+
);
|
|
7728
7611
|
return structuredClone(decision);
|
|
7729
7612
|
}
|
|
7730
7613
|
return {
|
|
@@ -7797,7 +7680,7 @@ function createFakePolicyApprovalManagementDriver(options = {}) {
|
|
|
7797
7680
|
}
|
|
7798
7681
|
let approval;
|
|
7799
7682
|
if (request.payload.approvalDecisionHandle) {
|
|
7800
|
-
approval =
|
|
7683
|
+
approval = owned(request.payload.approvalDecisionHandle, request.resource.uid);
|
|
7801
7684
|
}
|
|
7802
7685
|
const needsApproval = effect !== "read";
|
|
7803
7686
|
const approvalValid = !needsApproval || approval?.kind === "approval" && approval.outcome === "allow" && approval.policyDigest === policyDigest && approval.approval?.subjectDigest === operationDigest && Date.parse(approval.approval.expiresAt) > now().getTime();
|
|
@@ -7845,7 +7728,7 @@ function createFakePolicyApprovalManagementDriver(options = {}) {
|
|
|
7845
7728
|
if (!["allow", "deny"].includes(request.payload.outcome)) {
|
|
7846
7729
|
invalid10("approval outcome must be allow or deny");
|
|
7847
7730
|
}
|
|
7848
|
-
const decision =
|
|
7731
|
+
const decision = owned(handle, request.resource.uid);
|
|
7849
7732
|
if (decision.kind !== "approval") invalid10("decision is not an approval");
|
|
7850
7733
|
if (decision.approval && Date.parse(decision.approval.expiresAt) <= now().getTime()) {
|
|
7851
7734
|
decision.outcome = "deny";
|
|
@@ -7908,7 +7791,7 @@ function createFakePolicyApprovalManagementDriver(options = {}) {
|
|
|
7908
7791
|
"verifier",
|
|
7909
7792
|
"admin"
|
|
7910
7793
|
]);
|
|
7911
|
-
const decision =
|
|
7794
|
+
const decision = owned(
|
|
7912
7795
|
requiredString7(request.payload, "decisionHandle"),
|
|
7913
7796
|
request.resource.uid
|
|
7914
7797
|
);
|
|
@@ -8145,6 +8028,7 @@ function createFakeStorageManagementState() {
|
|
|
8145
8028
|
stages: /* @__PURE__ */ new Map(),
|
|
8146
8029
|
publications: /* @__PURE__ */ new Map(),
|
|
8147
8030
|
idempotency: /* @__PURE__ */ new Map(),
|
|
8031
|
+
idempotencyFingerprints: /* @__PURE__ */ new Map(),
|
|
8148
8032
|
fences: /* @__PURE__ */ new Map(),
|
|
8149
8033
|
nextHandle: 1
|
|
8150
8034
|
};
|
|
@@ -8172,32 +8056,18 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8172
8056
|
const state = options.state ?? createFakeStorageManagementState();
|
|
8173
8057
|
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
8174
8058
|
function validate(request, expectedMethod) {
|
|
8175
|
-
|
|
8059
|
+
return assertFencedDriverRequestEnvelope(request, {
|
|
8176
8060
|
now,
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8061
|
+
fences: state.fences,
|
|
8062
|
+
expectedMethod,
|
|
8063
|
+
fenceName: "storage"
|
|
8180
8064
|
});
|
|
8181
|
-
const fence = request.fencingEpoch;
|
|
8182
|
-
const current = state.fences.get(request.resource.uid) ?? 0;
|
|
8183
|
-
if (fence < current) {
|
|
8184
|
-
throw new OrchestrationError({
|
|
8185
|
-
code: "STALE_EPOCH",
|
|
8186
|
-
message: `stale storage fencing epoch ${fence}; current epoch is ${current}`,
|
|
8187
|
-
retryable: false
|
|
8188
|
-
});
|
|
8189
|
-
}
|
|
8190
|
-
state.fences.set(request.resource.uid, fence);
|
|
8191
|
-
return fence;
|
|
8192
8065
|
}
|
|
8193
8066
|
function nextHandle(prefix) {
|
|
8194
8067
|
const handle = `${prefix}:${state.nextHandle}`;
|
|
8195
8068
|
state.nextHandle += 1;
|
|
8196
8069
|
return handle;
|
|
8197
8070
|
}
|
|
8198
|
-
function operationKey(request, operation) {
|
|
8199
|
-
return `${request.resource.uid}:${operation}:${request.idempotencyKey}`;
|
|
8200
|
-
}
|
|
8201
8071
|
function getVolume(handle, resourceUid) {
|
|
8202
8072
|
const record2 = state.volumes.get(handle);
|
|
8203
8073
|
if (!record2 || record2.volume.phase === "Deleted") {
|
|
@@ -8216,27 +8086,8 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8216
8086
|
}
|
|
8217
8087
|
return record2;
|
|
8218
8088
|
}
|
|
8219
|
-
function owned2(collection, handle, resourceUid, kind) {
|
|
8220
|
-
const value = collection.get(handle);
|
|
8221
|
-
if (!value) {
|
|
8222
|
-
throw new OrchestrationError({
|
|
8223
|
-
code: "NOT_FOUND",
|
|
8224
|
-
message: `${kind} handle '${handle}' was not found`,
|
|
8225
|
-
retryable: false
|
|
8226
|
-
});
|
|
8227
|
-
}
|
|
8228
|
-
if (value.resourceUid !== resourceUid) {
|
|
8229
|
-
throw new OrchestrationError({
|
|
8230
|
-
code: "FORBIDDEN",
|
|
8231
|
-
message: `${kind} handle '${handle}' belongs to another resource`,
|
|
8232
|
-
retryable: false
|
|
8233
|
-
});
|
|
8234
|
-
}
|
|
8235
|
-
return value;
|
|
8236
|
-
}
|
|
8237
8089
|
function createVolume(request, capacityBytes, accessMode, replicaCount, operation) {
|
|
8238
|
-
const
|
|
8239
|
-
const existing = state.idempotency.get(key);
|
|
8090
|
+
const existing = findIdempotentDriverHandle(state, request, operation, "storage");
|
|
8240
8091
|
if (existing) return getVolume(existing, request.resource.uid).volume;
|
|
8241
8092
|
const volume = {
|
|
8242
8093
|
volumeHandle: nextHandle("volume"),
|
|
@@ -8247,7 +8098,7 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8247
8098
|
phase: "Available"
|
|
8248
8099
|
};
|
|
8249
8100
|
state.volumes.set(volume.volumeHandle, { volume, desiredReplicas: replicaCount });
|
|
8250
|
-
state
|
|
8101
|
+
rememberIdempotentDriverHandle(state, request, operation, volume.volumeHandle);
|
|
8251
8102
|
return volume;
|
|
8252
8103
|
}
|
|
8253
8104
|
return {
|
|
@@ -8303,9 +8154,10 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8303
8154
|
validate(request, "storage.snapshot");
|
|
8304
8155
|
const volumeHandle = requiredString8(request.payload, "volumeHandle");
|
|
8305
8156
|
getVolume(volumeHandle, request.resource.uid);
|
|
8306
|
-
const
|
|
8307
|
-
|
|
8308
|
-
|
|
8157
|
+
const existing = findIdempotentDriverHandle(state, request, "snapshot", "storage");
|
|
8158
|
+
if (existing) {
|
|
8159
|
+
return getOwnedDriverValue(state.snapshots, existing, request.resource.uid, "snapshot");
|
|
8160
|
+
}
|
|
8309
8161
|
const snapshot = {
|
|
8310
8162
|
snapshotHandle: nextHandle("snapshot"),
|
|
8311
8163
|
volumeHandle,
|
|
@@ -8313,12 +8165,12 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8313
8165
|
createdAt: now().toISOString()
|
|
8314
8166
|
};
|
|
8315
8167
|
state.snapshots.set(snapshot.snapshotHandle, snapshot);
|
|
8316
|
-
state
|
|
8168
|
+
rememberIdempotentDriverHandle(state, request, "snapshot", snapshot.snapshotHandle);
|
|
8317
8169
|
return snapshot;
|
|
8318
8170
|
},
|
|
8319
8171
|
async restoreSnapshot(request) {
|
|
8320
8172
|
validate(request, "storage.restore");
|
|
8321
|
-
const snapshot =
|
|
8173
|
+
const snapshot = getOwnedDriverValue(
|
|
8322
8174
|
state.snapshots,
|
|
8323
8175
|
requiredString8(request.payload, "snapshotHandle"),
|
|
8324
8176
|
request.resource.uid,
|
|
@@ -8381,9 +8233,10 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8381
8233
|
validate(request, "storage.backup");
|
|
8382
8234
|
const volumeHandle = requiredString8(request.payload, "volumeHandle");
|
|
8383
8235
|
getVolume(volumeHandle, request.resource.uid);
|
|
8384
|
-
const
|
|
8385
|
-
|
|
8386
|
-
|
|
8236
|
+
const existing = findIdempotentDriverHandle(state, request, "backup", "storage");
|
|
8237
|
+
if (existing) {
|
|
8238
|
+
return getOwnedDriverValue(state.backups, existing, request.resource.uid, "backup");
|
|
8239
|
+
}
|
|
8387
8240
|
const backup = {
|
|
8388
8241
|
backupHandle: nextHandle("backup"),
|
|
8389
8242
|
volumeHandle,
|
|
@@ -8391,7 +8244,7 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8391
8244
|
createdAt: now().toISOString()
|
|
8392
8245
|
};
|
|
8393
8246
|
state.backups.set(backup.backupHandle, backup);
|
|
8394
|
-
state
|
|
8247
|
+
rememberIdempotentDriverHandle(state, request, "backup", backup.backupHandle);
|
|
8395
8248
|
return backup;
|
|
8396
8249
|
},
|
|
8397
8250
|
async stage(request) {
|
|
@@ -8399,9 +8252,10 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8399
8252
|
const volumeHandle = requiredString8(request.payload, "volumeHandle");
|
|
8400
8253
|
getVolume(volumeHandle, request.resource.uid);
|
|
8401
8254
|
const nodeId = requiredString8(request.payload, "nodeId");
|
|
8402
|
-
const
|
|
8403
|
-
|
|
8404
|
-
|
|
8255
|
+
const existing = findIdempotentDriverHandle(state, request, "stage", "storage");
|
|
8256
|
+
if (existing) {
|
|
8257
|
+
return getOwnedDriverValue(state.stages, existing, request.resource.uid, "stage");
|
|
8258
|
+
}
|
|
8405
8259
|
const stage = {
|
|
8406
8260
|
stageHandle: nextHandle("stage"),
|
|
8407
8261
|
volumeHandle,
|
|
@@ -8409,12 +8263,12 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8409
8263
|
nodeId
|
|
8410
8264
|
};
|
|
8411
8265
|
state.stages.set(stage.stageHandle, stage);
|
|
8412
|
-
state
|
|
8266
|
+
rememberIdempotentDriverHandle(state, request, "stage", stage.stageHandle);
|
|
8413
8267
|
return stage;
|
|
8414
8268
|
},
|
|
8415
8269
|
async publish(request) {
|
|
8416
8270
|
validate(request, "storage.publish");
|
|
8417
|
-
const stage =
|
|
8271
|
+
const stage = getOwnedDriverValue(
|
|
8418
8272
|
state.stages,
|
|
8419
8273
|
requiredString8(request.payload, "stageHandle"),
|
|
8420
8274
|
request.resource.uid,
|
|
@@ -8423,10 +8277,14 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8423
8277
|
getVolume(stage.volumeHandle, request.resource.uid);
|
|
8424
8278
|
const workloadUid = requiredString8(request.payload, "workloadUid");
|
|
8425
8279
|
if (typeof request.payload.readOnly !== "boolean") invalid11("publish readOnly is required");
|
|
8426
|
-
const
|
|
8427
|
-
const existing = state.idempotency.get(key);
|
|
8280
|
+
const existing = findIdempotentDriverHandle(state, request, "publish", "storage");
|
|
8428
8281
|
if (existing) {
|
|
8429
|
-
return
|
|
8282
|
+
return getOwnedDriverValue(
|
|
8283
|
+
state.publications,
|
|
8284
|
+
existing,
|
|
8285
|
+
request.resource.uid,
|
|
8286
|
+
"publication"
|
|
8287
|
+
);
|
|
8430
8288
|
}
|
|
8431
8289
|
const publication = {
|
|
8432
8290
|
publishHandle: nextHandle("publication"),
|
|
@@ -8436,7 +8294,7 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8436
8294
|
readOnly: request.payload.readOnly
|
|
8437
8295
|
};
|
|
8438
8296
|
state.publications.set(publication.publishHandle, publication);
|
|
8439
|
-
state
|
|
8297
|
+
rememberIdempotentDriverHandle(state, request, "publish", publication.publishHandle);
|
|
8440
8298
|
return publication;
|
|
8441
8299
|
},
|
|
8442
8300
|
async unpublish(request) {
|
|
@@ -8444,7 +8302,7 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8444
8302
|
const handle = requiredString8(request.payload, "publishHandle");
|
|
8445
8303
|
const publication = state.publications.get(handle);
|
|
8446
8304
|
if (!publication) return;
|
|
8447
|
-
|
|
8305
|
+
getOwnedDriverValue(state.publications, handle, request.resource.uid, "publication");
|
|
8448
8306
|
state.publications.delete(handle);
|
|
8449
8307
|
},
|
|
8450
8308
|
async unstage(request) {
|
|
@@ -8452,7 +8310,7 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8452
8310
|
const handle = requiredString8(request.payload, "stageHandle");
|
|
8453
8311
|
const stage = state.stages.get(handle);
|
|
8454
8312
|
if (!stage) return;
|
|
8455
|
-
|
|
8313
|
+
getOwnedDriverValue(state.stages, handle, request.resource.uid, "stage");
|
|
8456
8314
|
if ([...state.publications.values()].some(
|
|
8457
8315
|
(publication) => publication.stageHandle === handle
|
|
8458
8316
|
)) {
|
|
@@ -8466,13 +8324,13 @@ function createFakeStorageManagementDriver(options = {}) {
|
|
|
8466
8324
|
},
|
|
8467
8325
|
async getStats(request) {
|
|
8468
8326
|
validate(request, "storage.stats");
|
|
8469
|
-
const publication =
|
|
8327
|
+
const publication = getOwnedDriverValue(
|
|
8470
8328
|
state.publications,
|
|
8471
8329
|
requiredString8(request.payload, "publishHandle"),
|
|
8472
8330
|
request.resource.uid,
|
|
8473
8331
|
"publication"
|
|
8474
8332
|
);
|
|
8475
|
-
const stage =
|
|
8333
|
+
const stage = getOwnedDriverValue(
|
|
8476
8334
|
state.stages,
|
|
8477
8335
|
publication.stageHandle,
|
|
8478
8336
|
request.resource.uid,
|
|
@@ -8741,4 +8599,4 @@ export {
|
|
|
8741
8599
|
createFakeStorageManagementDriver,
|
|
8742
8600
|
createStorageManagementConformanceSuite
|
|
8743
8601
|
};
|
|
8744
|
-
//# sourceMappingURL=chunk-
|
|
8602
|
+
//# sourceMappingURL=chunk-UB77WKAU.js.map
|