@quantiya/codevibe-codex-plugin 2.0.72 → 2.0.74
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/node_modules/@quantiya/codevibe-core/dist/appsync/appsync-client.d.ts +19 -4
- package/node_modules/@quantiya/codevibe-core/dist/index.js +519 -519
- package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/cli.js +820 -33
- package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/team-decompose.d.ts +4 -4
- package/node_modules/@quantiya/codevibe-core/package.json +1 -1
- package/package.json +2 -2
|
@@ -6741,6 +6741,11 @@ function invalid3() {
|
|
|
6741
6741
|
function badResponse() {
|
|
6742
6742
|
throw new SyncReadClientError("INVALID_SYNC_READ_RESPONSE");
|
|
6743
6743
|
}
|
|
6744
|
+
function gatewayUnavailable(status, value) {
|
|
6745
|
+
if (!closed3(value, ["message"]) || typeof value.message != "string") return !1;
|
|
6746
|
+
let message = value.message.toLowerCase();
|
|
6747
|
+
return [500, 502, 503, 504].includes(status) && message === "internal server error" || status === 429 && message === "too many requests";
|
|
6748
|
+
}
|
|
6744
6749
|
function syncReadResponseError(value) {
|
|
6745
6750
|
return (!plain4(value) || value.ok !== !1 || typeof value.errorCode != "string" || Object.keys(value).some((k) => !["ok", "errorCode", "retryAfterMs"].includes(k)) || value.retryAfterMs !== void 0 && (!Number.isSafeInteger(value.retryAfterMs) || value.retryAfterMs < 0)) && badResponse(), new SyncReadClientError(
|
|
6746
6751
|
"SYNC_READ_UNAVAILABLE",
|
|
@@ -6770,7 +6775,7 @@ var DesktopSyncReadClient = class {
|
|
|
6770
6775
|
}
|
|
6771
6776
|
event(value) {
|
|
6772
6777
|
let mobileInput = plain4(value) && value.source === "MOBILE" && ["USER_PROMPT", "PROMPT_RESPONSE"].includes(value.type), legacyStatusRevision = plain4(value) && value.deliveryStatus === "SENT" ? "0" : plain4(value) && value.deliveryStatus === "DELIVERED" ? "1" : plain4(value) && value.deliveryStatus === "EXECUTED" ? "2" : void 0, legacyInput = mobileInput && value.syncLegacyProjection === 1 && value.syncLifecycleVersion === void 0 && value.syncVisibility === "VISIBLE_METERED" && value.syncEventRevision === legacyStatusRevision && value.syncOperationId === void 0 && value.syncImmutableIdentityDigest === void 0;
|
|
6773
|
-
return (!plain4(value) || typeof value.eventId != "string" || !ID2.test(value.eventId) || value.sessionId !== this.scope.sessionId || value.sessionGenerationId !== this.scope.sessionGenerationId || !timestamp2(value.timestamp) || typeof value.type != "string" || !/^[A-Z][A-Z0-9_]{0,63}$/.test(value.type) || !["DESKTOP", "MOBILE"].includes(value.source) || value.syncLegacyProjection !== void 0 && !legacyInput || mobileInput && value.syncLifecycleVersion !== 1 && !legacyInput || value.content !== void 0 && typeof value.content != "string" || value.metadata !== void 0 && typeof value.metadata != "string" || value.isEncrypted !== void 0 && typeof value.isEncrypted != "boolean" || value.isEncrypted === !0 && value.encryptionVersion !== 1 || Buffer.byteLength(JSON.stringify(value)) > 350 * 1024) && badResponse(), Object.freeze(value);
|
|
6778
|
+
return (!plain4(value) || typeof value.eventId != "string" || !ID2.test(value.eventId) || value.sessionId !== this.scope.sessionId || value.sessionGenerationId !== this.scope.sessionGenerationId || !timestamp2(value.timestamp) || typeof value.type != "string" || !/^[A-Z][A-Z0-9_]{0,63}$/.test(value.type) || !["DESKTOP", "MOBILE"].includes(value.source) || value.syncLegacyProjection !== void 0 && !legacyInput || mobileInput && value.syncLifecycleVersion !== 1 && !legacyInput || value.content !== void 0 && typeof value.content != "string" || value.metadata !== void 0 && typeof value.metadata != "string" || value.isEncrypted !== void 0 && typeof value.isEncrypted != "boolean" || value.isEncrypted === !0 && value.encryptionVersion !== 1 && !(legacyInput && value.encryptionVersion === void 0) || Buffer.byteLength(JSON.stringify(value)) > 350 * 1024) && badResponse(), Object.freeze(value);
|
|
6774
6779
|
}
|
|
6775
6780
|
async request(method, path83, body, proofPayload, action, bound, headers, signal) {
|
|
6776
6781
|
this.fence(signal);
|
|
@@ -6819,7 +6824,7 @@ var DesktopSyncReadClient = class {
|
|
|
6819
6824
|
return badResponse();
|
|
6820
6825
|
}
|
|
6821
6826
|
if (!response.ok)
|
|
6822
|
-
throw syncReadResponseError(value);
|
|
6827
|
+
throw gatewayUnavailable(response.status, value) ? new SyncReadClientError("SYNC_READ_UNAVAILABLE") : syncReadResponseError(value);
|
|
6823
6828
|
return { text: text2, value };
|
|
6824
6829
|
} finally {
|
|
6825
6830
|
controller.abort(), clearTimeout(timer), signal?.removeEventListener("abort", cancel);
|
|
@@ -10969,7 +10974,7 @@ function coerceAwsJsonObject(raw, op) {
|
|
|
10969
10974
|
}
|
|
10970
10975
|
var AppSyncGraphQLError = class extends Error {
|
|
10971
10976
|
constructor(opts) {
|
|
10972
|
-
super(`GraphQL error: ${opts.message}`), this.name = "AppSyncGraphQLError", this.responseMessage = opts.message, this.errorType = opts.errorType, this.
|
|
10977
|
+
super(`GraphQL error: ${opts.message}`), this.name = "AppSyncGraphQLError", this.responseMessage = opts.message, this.errorType = opts.errorType, this.extensions = opts.extensions, this.path = opts.path, this.data = opts.data, this.requestId = typeof opts.requestId == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(opts.requestId) ? opts.requestId : void 0;
|
|
10973
10978
|
}
|
|
10974
10979
|
}, AppSyncAuthenticationError = class extends Error {
|
|
10975
10980
|
constructor(kind) {
|
|
@@ -11032,6 +11037,8 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11032
11037
|
this.syncDisplayAppliedSequence = 0;
|
|
11033
11038
|
this.syncDisplay = null;
|
|
11034
11039
|
this.syncDisplayListeners = /* @__PURE__ */ new Set();
|
|
11040
|
+
this.syncStateRead = null;
|
|
11041
|
+
this.syncStateRetry = null;
|
|
11035
11042
|
/** Passive server-denial deadlines shared by existing source retry owners.
|
|
11036
11043
|
* Exactly two producer families; no timer, durable state or admission grant. */
|
|
11037
11044
|
this.syncProducerEpoch = 0;
|
|
@@ -11233,6 +11240,16 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11233
11240
|
static throwIfAborted(signal) {
|
|
11234
11241
|
if (signal?.aborted) throw _AppSyncClient.abortReason(signal);
|
|
11235
11242
|
}
|
|
11243
|
+
static async waitForSyncStateRetry(delayMs, signal) {
|
|
11244
|
+
_AppSyncClient.throwIfAborted(signal), await new Promise((resolve28, reject) => {
|
|
11245
|
+
let timer = setTimeout(() => {
|
|
11246
|
+
signal?.removeEventListener("abort", onAbort), resolve28();
|
|
11247
|
+
}, delayMs), onAbort = () => {
|
|
11248
|
+
clearTimeout(timer), signal?.removeEventListener("abort", onAbort), reject(_AppSyncClient.abortReason(signal));
|
|
11249
|
+
};
|
|
11250
|
+
signal?.addEventListener("abort", onAbort, { once: !0 }), signal?.aborted && onAbort();
|
|
11251
|
+
});
|
|
11252
|
+
}
|
|
11236
11253
|
/**
|
|
11237
11254
|
* Bound one stage by its owning operation's absolute deadline. Every stage
|
|
11238
11255
|
* receives the same `deadlineAtMs`; a storage-backed retry therefore consumes
|
|
@@ -11518,7 +11535,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11518
11535
|
*/
|
|
11519
11536
|
async graphqlRequest(query, variables, isRetry = !1, signal, expectedUserId, maxResponseBytes, beforeSend) {
|
|
11520
11537
|
_AppSyncClient.throwIfAborted(signal), expectedUserId !== void 0 && this.assertSyncAccount(expectedUserId);
|
|
11521
|
-
let config = getConfig();
|
|
11538
|
+
let syncUserId = this.currentUserId, syncEpoch = this.syncDisplayEpoch, config = getConfig();
|
|
11522
11539
|
if (!this.tokens?.idToken)
|
|
11523
11540
|
throw new Error('Not authenticated. Run "codevibe login" first.');
|
|
11524
11541
|
let headers = {
|
|
@@ -11552,12 +11569,22 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11552
11569
|
let result = maxResponseBytes === void 0 ? await response.json() : await this.boundedGraphQLJson(response, maxResponseBytes, signal);
|
|
11553
11570
|
if (expectedUserId !== void 0 && this.assertSyncAccount(expectedUserId), result.errors?.length) {
|
|
11554
11571
|
let first = result.errors[0];
|
|
11555
|
-
throw
|
|
11572
|
+
throw [
|
|
11573
|
+
mutations.createEvent,
|
|
11574
|
+
mutations.updateEventStatus,
|
|
11575
|
+
mutations.recordWorkspaceOutcomeV2,
|
|
11576
|
+
mutations.reportSecurityPostureV2,
|
|
11577
|
+
queries.listEvents,
|
|
11578
|
+
queries.listSupervisionEvents,
|
|
11579
|
+
queries.getGateResolution,
|
|
11580
|
+
queries.getGateResolutionV2
|
|
11581
|
+
].includes(query) && syncUserId === this.currentUserId && syncEpoch === this.syncDisplayEpoch && ["UPDATE_REQUIRED", "AUTHORITY_UNAVAILABLE", "SYNC_BLOCKED"].includes(first.errorType ?? "") && this.resetCompanionSyncDisplay(), new AppSyncGraphQLError({
|
|
11556
11582
|
message: first.message,
|
|
11557
11583
|
errorType: first.errorType,
|
|
11558
|
-
data: first.data,
|
|
11559
11584
|
extensions: first.extensions,
|
|
11560
|
-
path: first.path
|
|
11585
|
+
path: first.path,
|
|
11586
|
+
data: first.data,
|
|
11587
|
+
requestId: response.headers?.get("x-amzn-requestid")
|
|
11561
11588
|
});
|
|
11562
11589
|
}
|
|
11563
11590
|
return result;
|
|
@@ -11596,15 +11623,70 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11596
11623
|
if (!this.authenticated || this.currentUserId !== userId || this.tokens?.userId !== userId)
|
|
11597
11624
|
throw new SyncEventClientError("SYNC_ACCOUNT_CHANGED");
|
|
11598
11625
|
}
|
|
11599
|
-
/**
|
|
11626
|
+
/** Concurrent fresh reads share one account/epoch-bound request and retry
|
|
11627
|
+
* loop. Sequential status/quota reads remain fresh; one cancelled caller
|
|
11628
|
+
* cannot cancel another caller's read. No cached admission authority. */
|
|
11600
11629
|
async getCompanionSyncState(signal) {
|
|
11601
|
-
let userId = this.getCurrentUserId()
|
|
11630
|
+
let userId = this.getCurrentUserId(), epoch = this.syncDisplayEpoch, check = () => {
|
|
11631
|
+
if (this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal), epoch !== this.syncDisplayEpoch) throw new SyncEventClientError("INVALID_SYNC_STATE");
|
|
11632
|
+
};
|
|
11633
|
+
check();
|
|
11634
|
+
let flight = this.syncStateRead;
|
|
11635
|
+
if (!flight || flight.userId !== userId || flight.epoch !== epoch || flight.controller.signal.aborted) {
|
|
11636
|
+
let controller = new AbortController();
|
|
11637
|
+
flight = { userId, epoch, controller, promise: this.readCompanionSyncState(userId, epoch, controller.signal), waiters: 0, settled: !1 }, this.syncStateRead = flight;
|
|
11638
|
+
let owned2 = flight, settled = () => {
|
|
11639
|
+
owned2.settled = !0, this.syncStateRead === owned2 && (this.syncStateRead = null);
|
|
11640
|
+
};
|
|
11641
|
+
owned2.promise.then(settled, settled);
|
|
11642
|
+
}
|
|
11643
|
+
let owned = flight;
|
|
11644
|
+
return owned.waiters++, new Promise((resolve28, reject) => {
|
|
11645
|
+
let finished = !1, finish = (error) => {
|
|
11646
|
+
if (!finished) {
|
|
11647
|
+
finished = !0, signal?.removeEventListener("abort", onAbort), --owned.waiters === 0 && !owned.settled && (this.syncStateRead === owned && (this.syncStateRead = null), owned.controller.abort(new Error("Sync state read has no callers")));
|
|
11648
|
+
try {
|
|
11649
|
+
if (check(), error !== void 0) throw error;
|
|
11650
|
+
let state = this.companionSyncStatusSnapshot(userId);
|
|
11651
|
+
if (!state) throw new SyncEventClientError("INVALID_SYNC_STATE");
|
|
11652
|
+
resolve28(state);
|
|
11653
|
+
} catch (failure2) {
|
|
11654
|
+
reject(failure2);
|
|
11655
|
+
}
|
|
11656
|
+
}
|
|
11657
|
+
}, onAbort = () => finish(_AppSyncClient.abortReason(signal));
|
|
11658
|
+
signal?.addEventListener("abort", onAbort, { once: !0 }), owned.promise.then(() => finish(), (error) => finish(error)), signal?.aborted && onAbort();
|
|
11659
|
+
});
|
|
11660
|
+
}
|
|
11661
|
+
/** Only explicit HISTORY_RETRY_AFTER permits two retries / ten seconds of
|
|
11662
|
+
* added wait. Retain the server's earliest retry time after cancellation or
|
|
11663
|
+
* exhaustion so a later caller cannot restart I/O before that time. */
|
|
11664
|
+
async readCompanionSyncState(userId, epoch, signal) {
|
|
11602
11665
|
this.assertSyncAccount(userId);
|
|
11603
|
-
let
|
|
11666
|
+
let sequence = ++this.syncDisplaySequence;
|
|
11604
11667
|
try {
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11668
|
+
let response, retries = 0, waitedMs = 0;
|
|
11669
|
+
for (; ; ) {
|
|
11670
|
+
this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal);
|
|
11671
|
+
let cooldown = this.syncStateRetry;
|
|
11672
|
+
if (cooldown?.userId === userId && cooldown.epoch === epoch) {
|
|
11673
|
+
let delayMs = cooldown.retryAtMs - Date.now();
|
|
11674
|
+
if (delayMs > 1e4 - waitedMs) throw cooldown.error;
|
|
11675
|
+
delayMs > 0 && (waitedMs += delayMs, await _AppSyncClient.waitForSyncStateRetry(delayMs, signal), this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal));
|
|
11676
|
+
}
|
|
11677
|
+
try {
|
|
11678
|
+
response = await this.graphqlRequest(queries.getCompanionSyncState, {}, !1, signal, userId);
|
|
11679
|
+
break;
|
|
11680
|
+
} catch (error) {
|
|
11681
|
+
this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal);
|
|
11682
|
+
let data = error instanceof AppSyncGraphQLError ? error.data : void 0, retryAfterMs = data && typeof data == "object" && !Array.isArray(data) ? data.retryAfterMs : void 0;
|
|
11683
|
+
if (!(error instanceof AppSyncGraphQLError) || error.errorType !== "HISTORY_RETRY_AFTER" || typeof retryAfterMs != "number" || !Number.isSafeInteger(retryAfterMs) || retryAfterMs < 0) throw error;
|
|
11684
|
+
let retryAtMs = Date.now() + Math.max(1, retryAfterMs);
|
|
11685
|
+
if (!Number.isSafeInteger(retryAtMs) || (this.syncStateRetry = { userId, epoch, retryAtMs, error }, retries >= 2)) throw error;
|
|
11686
|
+
retries++;
|
|
11687
|
+
}
|
|
11688
|
+
}
|
|
11689
|
+
this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal), this.syncStateRetry?.userId === userId && this.syncStateRetry.epoch === epoch && (this.syncStateRetry = null);
|
|
11608
11690
|
let state = parseCompanionSyncState(response?.data?.getCompanionSyncState, this.environment), effective = this.publishCompanionSyncDisplay(userId, state, epoch, sequence), now = Date.now();
|
|
11609
11691
|
if (!effective || !Number.isSafeInteger(now) || effective.observedAtEpochMs > now + SYNC_STATE_CLOCK_SKEW_MS || effective.validUntilEpochMs <= now)
|
|
11610
11692
|
throw new SyncEventClientError("INVALID_SYNC_STATE");
|
|
@@ -11613,6 +11695,19 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11613
11695
|
throw this.publishCompanionSyncDisplay(userId, null, epoch, sequence), error;
|
|
11614
11696
|
}
|
|
11615
11697
|
}
|
|
11698
|
+
/** Reuse only the server-unexpired protocol selection, never its entitlement
|
|
11699
|
+
* or usage as admission authority. Every selected cloud operation still
|
|
11700
|
+
* authorizes itself. Explicit status/quota refreshes remain fresh reads. */
|
|
11701
|
+
async getCompanionSyncRoute(signal) {
|
|
11702
|
+
let userId = this.getCurrentUserId(), epoch = this.syncDisplayEpoch, check = () => {
|
|
11703
|
+
if (this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal), epoch !== this.syncDisplayEpoch) throw new SyncEventClientError("INVALID_SYNC_STATE");
|
|
11704
|
+
};
|
|
11705
|
+
check();
|
|
11706
|
+
let cached = this.companionSyncStatusSnapshot(userId);
|
|
11707
|
+
if (cached) return { protocol: cached.protocol };
|
|
11708
|
+
let state = await this.getCompanionSyncState(signal);
|
|
11709
|
+
return check(), { protocol: state.protocol };
|
|
11710
|
+
}
|
|
11616
11711
|
/** Subscribe to validated reads already performed by this client. No new
|
|
11617
11712
|
* request, persistent journal, producer grant or retry is created here. */
|
|
11618
11713
|
subscribeCompanionSyncState(userId, listener) {
|
|
@@ -11645,7 +11740,9 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11645
11740
|
this.syncProducerEpoch++, this.syncProducerRetry.clear();
|
|
11646
11741
|
}
|
|
11647
11742
|
resetCompanionSyncDisplay() {
|
|
11648
|
-
this.syncDisplayEpoch += 1
|
|
11743
|
+
this.syncDisplayEpoch += 1;
|
|
11744
|
+
let flight = this.syncStateRead;
|
|
11745
|
+
this.syncStateRead = null, this.syncStateRetry = null, flight?.controller.abort(new Error("Sync routing observation invalidated")), this.syncDisplay = null, this.syncDisplayAppliedSequence = this.syncDisplaySequence;
|
|
11649
11746
|
for (let entry5 of this.syncDisplayListeners) this.notifyCompanionSyncDisplay(entry5);
|
|
11650
11747
|
}
|
|
11651
11748
|
publishCompanionSyncDisplay(userId, state, epoch, sequence) {
|
|
@@ -11671,7 +11768,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11671
11768
|
posture
|
|
11672
11769
|
}, userId = this.getCurrentUserId();
|
|
11673
11770
|
this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal);
|
|
11674
|
-
let state = await this.
|
|
11771
|
+
let state = await this.getCompanionSyncRoute(signal);
|
|
11675
11772
|
if (this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal), state.protocol === "LEGACY") return null;
|
|
11676
11773
|
if (state.protocol !== "SYNC_V2") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
11677
11774
|
if (!scope.sessionGenerationId) throw new SyncEventClientError("SYNC_SESSION_GENERATION_CHANGED");
|
|
@@ -11699,7 +11796,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11699
11796
|
async desktopSyncReadClient(sessionScope, signal) {
|
|
11700
11797
|
let scope = { ...sessionScope }, userId = this.getCurrentUserId();
|
|
11701
11798
|
this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal);
|
|
11702
|
-
let state = await this.
|
|
11799
|
+
let state = await this.getCompanionSyncRoute(signal);
|
|
11703
11800
|
if (this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal), state.protocol !== "SYNC_V2") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
11704
11801
|
let config = getConfig();
|
|
11705
11802
|
if (config.environment !== this.environment || !config.aws.syncHttpUrl) throw new SyncEventClientError("SYNC_SESSION_UNAVAILABLE");
|
|
@@ -12006,13 +12103,13 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
12006
12103
|
getEncryptionContext: selected.getEncryptionContext
|
|
12007
12104
|
});
|
|
12008
12105
|
}
|
|
12009
|
-
/** Shared cloud-selected
|
|
12106
|
+
/** Shared cloud-selected routing for tools and ordinary native sources. */
|
|
12010
12107
|
async selectCompanionSourceTransport(options) {
|
|
12011
12108
|
let { sessionId, root } = options;
|
|
12012
12109
|
if (typeof sessionId != "string" || !/^[A-Za-z0-9_-]{1,256}$/.test(sessionId)) throw new SyncEventClientError("INVALID_SYNC_INPUT");
|
|
12013
12110
|
let userId = this.getCurrentUserId();
|
|
12014
12111
|
this.assertSyncAccount(userId);
|
|
12015
|
-
let state = await this.
|
|
12112
|
+
let state = await this.getCompanionSyncRoute();
|
|
12016
12113
|
if (this.assertSyncAccount(userId), state.protocol === "FROZEN") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
12017
12114
|
if (state.protocol === "LEGACY") return Object.freeze({ protocol: "LEGACY" });
|
|
12018
12115
|
let readSession = async () => {
|
|
@@ -12161,12 +12258,12 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
12161
12258
|
let resolutions = await writer.promptResolutions();
|
|
12162
12259
|
check();
|
|
12163
12260
|
let knownV2 = [...publications, ...resolutions].some((row3) => row3.sessionId === input.sessionId && row3.promptId === input.promptId), durable = (control, selected) => writer.runPromptResolution(control, async (saved, fence) => {
|
|
12164
|
-
let state2 = selected ?? await this.
|
|
12261
|
+
let state2 = selected ?? await this.getCompanionSyncRoute();
|
|
12165
12262
|
if (await fence(), state2.protocol !== "SYNC_V2") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
12166
12263
|
return this.finishPromptResolution(saved, options, fence);
|
|
12167
12264
|
});
|
|
12168
12265
|
if (knownV2) return durable(prepareV2());
|
|
12169
|
-
let state = await this.
|
|
12266
|
+
let state = await this.getCompanionSyncRoute();
|
|
12170
12267
|
if (check(), state.protocol === "LEGACY")
|
|
12171
12268
|
return this.resolvePromptPublication(input, async (hasV2Publication) => {
|
|
12172
12269
|
if (hasV2Publication || (await writer.promptResolutions()).some((row3) => row3.sessionId === input.sessionId && row3.promptId === input.promptId))
|
|
@@ -12197,7 +12294,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
12197
12294
|
check();
|
|
12198
12295
|
let records = (await writer.promptResolutions()).filter((row3) => row3.sessionId === sessionId);
|
|
12199
12296
|
if (check(), !records.length) return 0;
|
|
12200
|
-
let state = await this.
|
|
12297
|
+
let state = await this.getCompanionSyncRoute(signal);
|
|
12201
12298
|
if (check(), state.protocol !== "SYNC_V2") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
12202
12299
|
let completed = 0, firstFailure;
|
|
12203
12300
|
for (let input of records) {
|
|
@@ -12631,7 +12728,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
12631
12728
|
async submitWorkspaceOutcome(value, options = {}) {
|
|
12632
12729
|
let input = snapshotWorkspaceOutcomeInput(value), userId = this.getCurrentUserId();
|
|
12633
12730
|
this.assertSyncAccount(userId);
|
|
12634
|
-
let route = await this.
|
|
12731
|
+
let route = await this.getCompanionSyncRoute();
|
|
12635
12732
|
if (this.assertSyncAccount(userId), route.protocol === "FROZEN") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
12636
12733
|
if (route.protocol === "LEGACY") {
|
|
12637
12734
|
if (options.requiresV2) throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
@@ -12735,7 +12832,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
12735
12832
|
source: "MOBILE" /* MOBILE */,
|
|
12736
12833
|
type: expected.type
|
|
12737
12834
|
}), this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal));
|
|
12738
|
-
let route = await this.
|
|
12835
|
+
let route = await this.getCompanionSyncRoute(signal);
|
|
12739
12836
|
if (this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal), route.protocol === "FROZEN") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
12740
12837
|
if (requiredSessionGenerationId !== void 0 && route.protocol !== "SYNC_V2") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
12741
12838
|
if (route.protocol === "LEGACY") {
|
|
@@ -12763,7 +12860,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
12763
12860
|
* List events for a session
|
|
12764
12861
|
*/
|
|
12765
12862
|
async listEvents(sessionId, source2, limit) {
|
|
12766
|
-
let route = await this.
|
|
12863
|
+
let route = await this.getCompanionSyncRoute();
|
|
12767
12864
|
if (route.protocol === "FROZEN") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
12768
12865
|
if (route.protocol === "SYNC_V2") {
|
|
12769
12866
|
if (limit !== void 0 && (!Number.isSafeInteger(limit) || limit < 1 || limit > 100)) throw new SyncEventClientError("INVALID_SYNC_INPUT");
|
|
@@ -12777,7 +12874,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
12777
12874
|
* can merge each page through the same strict event classifier as live data.
|
|
12778
12875
|
*/
|
|
12779
12876
|
async listSupervisionEvents(input) {
|
|
12780
|
-
let route = await this.
|
|
12877
|
+
let route = await this.getCompanionSyncRoute();
|
|
12781
12878
|
if (route.protocol === "FROZEN") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
12782
12879
|
if (route.protocol === "SYNC_V2") {
|
|
12783
12880
|
if (input.limit !== void 0 && input.limit !== 100) throw new SyncEventClientError("INVALID_SYNC_INPUT");
|
|
@@ -13226,7 +13323,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
13226
13323
|
async getGateResolution(input) {
|
|
13227
13324
|
let expected = { ...input }, userId = this.getCurrentUserId(), epoch = this.syncReadEpoch;
|
|
13228
13325
|
this.assertSyncAccount(userId), this.assertSyncReadAdmission(expected.sessionId);
|
|
13229
|
-
let route = await this.
|
|
13326
|
+
let route = await this.getCompanionSyncRoute();
|
|
13230
13327
|
if (this.assertSyncAccount(userId), this.assertSyncReadAdmission(expected.sessionId), epoch !== this.syncReadEpoch) throw new SyncEventClientError("SYNC_SESSION_UNAVAILABLE");
|
|
13231
13328
|
if (route.protocol === "LEGACY") {
|
|
13232
13329
|
let response = await this.graphqlRequest(
|
|
@@ -14258,7 +14355,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14258
14355
|
createSubscription(state) {
|
|
14259
14356
|
let abort = state.setupAbort = new AbortController(), current = () => !state.destroyed && !abort.signal.aborted && this.activeSubscriptions.get(state.sessionId) === state, setup = (async () => {
|
|
14260
14357
|
if (await this.joinSyncSubscriptionClosures(state.sessionId), !current()) return;
|
|
14261
|
-
let userId = this.getCurrentUserId(), route = await this.
|
|
14358
|
+
let userId = this.getCurrentUserId(), route = await this.getCompanionSyncRoute(abort.signal);
|
|
14262
14359
|
if (!current()) return;
|
|
14263
14360
|
if (this.assertSyncAccount(userId), route.protocol === "FROZEN") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
14264
14361
|
if (route.protocol === "LEGACY") {
|
|
@@ -76592,7 +76689,7 @@ async function runLocalDecomposer(deps, brief, availableAgents, repoContext) {
|
|
|
76592
76689
|
timeoutMs: null,
|
|
76593
76690
|
stdinTty: !0,
|
|
76594
76691
|
stdinPayload: prompt
|
|
76595
|
-
}), exit = await handle.done, text2 = await readImplementorFinalMessage(plan, handle, agent, exit.exitCode, deps.workingDir),
|
|
76692
|
+
}), exit = await handle.done, text2 = await readImplementorFinalMessage(plan, handle, agent, exit.exitCode, deps.workingDir), providerError = (agent === "CLAUDE" && text2.length === 0 ? firstResultEnvelope(handle.stdout()) : null)?.is_error === !0;
|
|
76596
76693
|
return { text: text2, providerError };
|
|
76597
76694
|
};
|
|
76598
76695
|
try {
|
|
@@ -76608,7 +76705,10 @@ async function runLocalDecomposer(deps, brief, availableAgents, repoContext) {
|
|
|
76608
76705
|
agent,
|
|
76609
76706
|
attempt: 2,
|
|
76610
76707
|
...describeDecomposerReply(second.text, second)
|
|
76611
|
-
}), {
|
|
76708
|
+
}), {
|
|
76709
|
+
decompose: !1,
|
|
76710
|
+
reason: second.providerError ? "decomposer provider error" : "decomposer output could not be parsed"
|
|
76711
|
+
});
|
|
76612
76712
|
} catch (err) {
|
|
76613
76713
|
return logger.warn("[team-decompose] decomposer spawn failed \u2014 single-task fallback", {
|
|
76614
76714
|
agent,
|
|
@@ -77347,10 +77447,47 @@ var OrchestrationShellStartupError = class extends Error {
|
|
|
77347
77447
|
super(message), this.name = "OrchestrationShellStartupError", this.cause = cause;
|
|
77348
77448
|
}
|
|
77349
77449
|
}, STARTUP_SUBSCRIPTION_TIMEOUT_MS = 15e3;
|
|
77450
|
+
function logStartupFailure(boundary, errorValue, reason) {
|
|
77451
|
+
try {
|
|
77452
|
+
let error = errorValue, classes = [
|
|
77453
|
+
"AppSyncGraphQLError",
|
|
77454
|
+
"AppSyncAuthenticationError",
|
|
77455
|
+
"SyncEventClientError",
|
|
77456
|
+
"SyncReadClientError",
|
|
77457
|
+
"Error",
|
|
77458
|
+
"TypeError"
|
|
77459
|
+
], codes = [
|
|
77460
|
+
"HISTORY_RETRY_AFTER",
|
|
77461
|
+
"CONTROL_BREAKER_CONTENTION",
|
|
77462
|
+
"AUTHORITY_UNAVAILABLE",
|
|
77463
|
+
"INVALID_SYNC_STATE",
|
|
77464
|
+
"INVALID_SYNC_READ_RESPONSE",
|
|
77465
|
+
"SYNC_PRODUCER_FROZEN",
|
|
77466
|
+
"SYNC_ACCOUNT_CHANGED",
|
|
77467
|
+
"SYNC_SESSION_UNAVAILABLE",
|
|
77468
|
+
"EPERM",
|
|
77469
|
+
"EACCES",
|
|
77470
|
+
"ENOENT",
|
|
77471
|
+
"ENETUNREACH",
|
|
77472
|
+
"EAI_AGAIN",
|
|
77473
|
+
"ECONNREFUSED",
|
|
77474
|
+
"ECONNRESET",
|
|
77475
|
+
"ETIMEDOUT"
|
|
77476
|
+
], code = [error?.errorType, error?.code].find((value) => typeof value == "string" && codes.includes(value)), requestId = typeof error?.requestId == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(error.requestId) ? error.requestId : void 0, delay = error?.data?.retryAfterMs, retryAfterMs = code === "HISTORY_RETRY_AFTER" && typeof delay == "number" && Number.isSafeInteger(delay) && delay >= 0 ? delay : void 0;
|
|
77477
|
+
logger.warn(`[orchestration-shell] startup ${boundary} failed`, {
|
|
77478
|
+
...reason !== void 0 && { reason },
|
|
77479
|
+
errorClass: typeof error?.name == "string" && classes.includes(error.name) ? error.name : "UNKNOWN",
|
|
77480
|
+
errorCode: code ?? "UNKNOWN",
|
|
77481
|
+
...requestId && { requestId },
|
|
77482
|
+
...retryAfterMs !== void 0 && { retryAfterMs }
|
|
77483
|
+
});
|
|
77484
|
+
} catch {
|
|
77485
|
+
}
|
|
77486
|
+
}
|
|
77350
77487
|
function startupEventFailure(result) {
|
|
77351
77488
|
if (result.emitted)
|
|
77352
77489
|
return new OrchestrationShellStartupError("Unexpected successful startup event result");
|
|
77353
|
-
switch (result.reason) {
|
|
77490
|
+
switch (logStartupFailure("event", result.error, result.reason), result.reason) {
|
|
77354
77491
|
case "missing_session_key":
|
|
77355
77492
|
return new OrchestrationShellStartupError(
|
|
77356
77493
|
"CodeVibe could not access the orchestration session encryption key. Exit and launch CodeVibe again; if the problem persists, run `codevibe login`.",
|
|
@@ -77889,7 +78026,7 @@ async function runOrchestrationShell(args) {
|
|
|
77889
78026
|
// an event actually arrives (async) — never during this synchronous setup.
|
|
77890
78027
|
subscribedEventDispatcher,
|
|
77891
78028
|
(err) => {
|
|
77892
|
-
initialCatchUpStarted && rejectInitialSubscription(err), logger.warn("[orchestration-shell] subscribeToEvents error", {
|
|
78029
|
+
initialSubscriptionSettled || logStartupFailure("subscription", err), initialCatchUpStarted && rejectInitialSubscription(err), logger.warn("[orchestration-shell] subscribeToEvents error", {
|
|
77893
78030
|
error: err.message
|
|
77894
78031
|
});
|
|
77895
78032
|
},
|
|
@@ -86501,7 +86638,17 @@ var ANTHROPIC_VERSION = "2023-06-01", ANTHROPIC_BETA_ALLOWLIST = /* @__PURE__ */
|
|
|
86501
86638
|
// Note: advisor-tool-2026-03-01 is deliberately EXCLUDED (unneeded and prevents account-billed advisor tool invocation).
|
|
86502
86639
|
"thinking-token-count-2026-05-13",
|
|
86503
86640
|
"per-turn-control-2026-07-01",
|
|
86504
|
-
"mid-conversation-tool-changes-2026-07-01"
|
|
86641
|
+
"mid-conversation-tool-changes-2026-07-01",
|
|
86642
|
+
// Reviewed 2026-10-14 (CP-7 decomposer dogfood): Empirically captured from live
|
|
86643
|
+
// Claude Code CLI 2.1.299 requests on /v1/messages (`model: "claude-opus-5-5"`).
|
|
86644
|
+
// Claude Code 2.1.299 sends `safeguards: [{ type: "dangerous_tool_use", ... }]` in the
|
|
86645
|
+
// request body; dropping `dangerous-tool-use-2026-09-03` causes upstream Anthropic to
|
|
86646
|
+
// return HTTP 400 (`invalid_request_error`: `"safeguards: Extra inputs are not permitted"`).
|
|
86647
|
+
// `buildCanonicalRequest` in `canonical.ts` validates `$.safeguards` fail-closed against
|
|
86648
|
+
// the 24-key Claude Code 2.1.299 `z1s`/`W3n`/`rmt`/`q1s`/`K1s`/`hmt`/`qOr` schema (and runs
|
|
86649
|
+
// before `scanRequestForBrokerCredentials` and `scrubRequestPayload`).
|
|
86650
|
+
// Note: `afk-mode-2026-01-31` is deliberately EXCLUDED (empirically verified unnecessary).
|
|
86651
|
+
"dangerous-tool-use-2026-09-03"
|
|
86505
86652
|
]), PROVIDER_CONFIGS = {
|
|
86506
86653
|
anthropic: {
|
|
86507
86654
|
upstreamBaseUrl: "https://api.anthropic.com",
|
|
@@ -86677,6 +86824,642 @@ function hasOwn(obj, key) {
|
|
|
86677
86824
|
function requestSha256(body) {
|
|
86678
86825
|
return (0, import_node_crypto35.createHash)("sha256").update(JSON.stringify(body)).digest("hex");
|
|
86679
86826
|
}
|
|
86827
|
+
var SAFE_SAFEGUARD_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
86828
|
+
"type",
|
|
86829
|
+
"classifier_context"
|
|
86830
|
+
]), SAFE_CLASSIFIER_CONTEXT_KEYS = /* @__PURE__ */ new Set([
|
|
86831
|
+
// Exact 16 base keys emitted by Claude Code 2.1.299 `mts` + `qOr` (`dangerous_tool_use` classifier_context):
|
|
86832
|
+
"v",
|
|
86833
|
+
"permission_mode",
|
|
86834
|
+
"platform",
|
|
86835
|
+
"live_cwd",
|
|
86836
|
+
"home_dir",
|
|
86837
|
+
"rule_roots",
|
|
86838
|
+
"trusted_directories",
|
|
86839
|
+
"rules",
|
|
86840
|
+
"auto_mode",
|
|
86841
|
+
"artifact_consent_holdback",
|
|
86842
|
+
"case_insensitive_paths",
|
|
86843
|
+
"restricted",
|
|
86844
|
+
"is_remote_mode",
|
|
86845
|
+
"classify_all_shell",
|
|
86846
|
+
"user_identity",
|
|
86847
|
+
"git_state",
|
|
86848
|
+
// Exact 8 conditional keys emitted by Claude Code 2.1.299 `mts` (offset 202112500) and `qOr` (offset 205163100)
|
|
86849
|
+
// on multi-turn / tool-result / reminder / artifact / byte-budget turns:
|
|
86850
|
+
"dropped",
|
|
86851
|
+
"truncated",
|
|
86852
|
+
"chrome_navigation",
|
|
86853
|
+
"prior_turn_context",
|
|
86854
|
+
"system_reminders",
|
|
86855
|
+
"artifacts",
|
|
86856
|
+
"shed",
|
|
86857
|
+
"tool_host_attached"
|
|
86858
|
+
]), CLASSIFIER_STRING_KEYS = [
|
|
86859
|
+
"permission_mode",
|
|
86860
|
+
"platform",
|
|
86861
|
+
"live_cwd",
|
|
86862
|
+
"home_dir"
|
|
86863
|
+
], CLASSIFIER_BOOLEAN_KEYS = [
|
|
86864
|
+
"artifact_consent_holdback",
|
|
86865
|
+
"case_insensitive_paths",
|
|
86866
|
+
"restricted",
|
|
86867
|
+
"is_remote_mode",
|
|
86868
|
+
"classify_all_shell",
|
|
86869
|
+
"truncated",
|
|
86870
|
+
"tool_host_attached"
|
|
86871
|
+
], SAFE_RULE_ROOT_KEYS = /* @__PURE__ */ new Set([
|
|
86872
|
+
"userSettings",
|
|
86873
|
+
"projectSettings",
|
|
86874
|
+
"localSettings",
|
|
86875
|
+
"flagSettings",
|
|
86876
|
+
"policySettings",
|
|
86877
|
+
"cliArg",
|
|
86878
|
+
"command",
|
|
86879
|
+
"session",
|
|
86880
|
+
"toolsNarrowing",
|
|
86881
|
+
"mcpServerPolicy",
|
|
86882
|
+
"hostCredential"
|
|
86883
|
+
]), SAFE_TRUSTED_DIRECTORIES_KEYS = /* @__PURE__ */ new Set([
|
|
86884
|
+
"primary",
|
|
86885
|
+
"additional",
|
|
86886
|
+
"network",
|
|
86887
|
+
"block_reads_outside_working_directories"
|
|
86888
|
+
]), SAFE_TRUSTED_DIRECTORY_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
86889
|
+
"path",
|
|
86890
|
+
"resolved",
|
|
86891
|
+
"source"
|
|
86892
|
+
]), SAFE_RULES_KEYS = /* @__PURE__ */ new Set([
|
|
86893
|
+
"allow",
|
|
86894
|
+
"deny",
|
|
86895
|
+
"ask"
|
|
86896
|
+
]), SAFE_DROPPED_KEYS = /* @__PURE__ */ new Set([
|
|
86897
|
+
"allow",
|
|
86898
|
+
"deny",
|
|
86899
|
+
"ask",
|
|
86900
|
+
"auto_mode_allow",
|
|
86901
|
+
"auto_mode_soft_deny",
|
|
86902
|
+
"auto_mode_hard_deny",
|
|
86903
|
+
"auto_mode_environment"
|
|
86904
|
+
]), SAFE_RULE_ITEM_KEYS = /* @__PURE__ */ new Set([
|
|
86905
|
+
"rule",
|
|
86906
|
+
"canonical",
|
|
86907
|
+
"source",
|
|
86908
|
+
"root",
|
|
86909
|
+
"pattern"
|
|
86910
|
+
]), SAFE_AUTO_MODE_KEYS = /* @__PURE__ */ new Set([
|
|
86911
|
+
"allow",
|
|
86912
|
+
"soft_deny",
|
|
86913
|
+
"hard_deny",
|
|
86914
|
+
"environment"
|
|
86915
|
+
]), SAFE_GIT_STATE_KEYS = /* @__PURE__ */ new Set([
|
|
86916
|
+
"cwd",
|
|
86917
|
+
"root",
|
|
86918
|
+
"branch",
|
|
86919
|
+
"default_branch",
|
|
86920
|
+
"status",
|
|
86921
|
+
"visibility",
|
|
86922
|
+
"error",
|
|
86923
|
+
"truncated"
|
|
86924
|
+
]), SAFE_GIT_ERROR_VALUES = /* @__PURE__ */ new Set([
|
|
86925
|
+
"timeout",
|
|
86926
|
+
"not_a_repo",
|
|
86927
|
+
"error",
|
|
86928
|
+
"pending"
|
|
86929
|
+
]), SAFE_GIT_STATUS_KEYS = /* @__PURE__ */ new Set([
|
|
86930
|
+
"clean",
|
|
86931
|
+
"counts",
|
|
86932
|
+
"porcelain",
|
|
86933
|
+
"truncated"
|
|
86934
|
+
]), SAFE_GIT_COUNTS_KEYS = /* @__PURE__ */ new Set([
|
|
86935
|
+
"staged",
|
|
86936
|
+
"modified",
|
|
86937
|
+
"untracked",
|
|
86938
|
+
"untracked_normal"
|
|
86939
|
+
]), SAFE_GIT_VISIBILITY_KEYS = /* @__PURE__ */ new Set([
|
|
86940
|
+
"origin",
|
|
86941
|
+
"push_remote",
|
|
86942
|
+
"remotes",
|
|
86943
|
+
"visibility_cache"
|
|
86944
|
+
]), SAFE_GIT_REPO_VISIBILITY_VALUES = /* @__PURE__ */ new Set([
|
|
86945
|
+
"public",
|
|
86946
|
+
"private",
|
|
86947
|
+
"unknown"
|
|
86948
|
+
]), SAFE_GIT_ORIGIN_KEYS = /* @__PURE__ */ new Set([
|
|
86949
|
+
"host",
|
|
86950
|
+
"remote",
|
|
86951
|
+
"visibility"
|
|
86952
|
+
]), SAFE_GIT_REMOTE_KEYS = /* @__PURE__ */ new Set([
|
|
86953
|
+
"name",
|
|
86954
|
+
"host",
|
|
86955
|
+
"remote",
|
|
86956
|
+
"visibility"
|
|
86957
|
+
]), SAFE_CHROME_NAVIGATION_KEYS = /* @__PURE__ */ new Set([
|
|
86958
|
+
"enabled",
|
|
86959
|
+
"baselines",
|
|
86960
|
+
"tabs"
|
|
86961
|
+
]), SAFE_PRIOR_TURN_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
86962
|
+
"tool_use_ids",
|
|
86963
|
+
"context"
|
|
86964
|
+
]), SAFE_PRIOR_TURN_INNER_CONTEXT_KEYS = /* @__PURE__ */ new Set([
|
|
86965
|
+
"git_state",
|
|
86966
|
+
"chrome_navigation",
|
|
86967
|
+
"live_cwd",
|
|
86968
|
+
"platform"
|
|
86969
|
+
]), SAFE_SYSTEM_REMINDER_KEYS = /* @__PURE__ */ new Set([
|
|
86970
|
+
"id",
|
|
86971
|
+
"provenance",
|
|
86972
|
+
"author",
|
|
86973
|
+
"written"
|
|
86974
|
+
]), SAFE_ARTIFACTS_KEYS = /* @__PURE__ */ new Set([
|
|
86975
|
+
"by_slug",
|
|
86976
|
+
"by_path",
|
|
86977
|
+
"live_docs",
|
|
86978
|
+
"room_armed",
|
|
86979
|
+
"type_reads",
|
|
86980
|
+
"last_publish",
|
|
86981
|
+
"session",
|
|
86982
|
+
"truncated"
|
|
86983
|
+
]), SAFE_ARTIFACT_ENV_VALUES = /* @__PURE__ */ new Set([
|
|
86984
|
+
"prod",
|
|
86985
|
+
"staging"
|
|
86986
|
+
]), SAFE_ARTIFACT_WATCH_RAIL_VALUES = /* @__PURE__ */ new Set([
|
|
86987
|
+
"live",
|
|
86988
|
+
"durable",
|
|
86989
|
+
"none"
|
|
86990
|
+
]), SAFE_ARTIFACT_SLUG_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
86991
|
+
"share",
|
|
86992
|
+
"attested",
|
|
86993
|
+
"notice_pending",
|
|
86994
|
+
"published_env",
|
|
86995
|
+
"watch"
|
|
86996
|
+
]), SAFE_ARTIFACT_WATCH_KEYS = /* @__PURE__ */ new Set([
|
|
86997
|
+
"stopped",
|
|
86998
|
+
"auto_reply_stopped",
|
|
86999
|
+
"auto_reply_swept",
|
|
87000
|
+
"replies_declined"
|
|
87001
|
+
]), SAFE_ARTIFACT_SHARE_KEYS = /* @__PURE__ */ new Set([
|
|
87002
|
+
"mode",
|
|
87003
|
+
"is_shared_live",
|
|
87004
|
+
"role",
|
|
87005
|
+
"probe_failed",
|
|
87006
|
+
"probed",
|
|
87007
|
+
"probe_current_account",
|
|
87008
|
+
"cowritten",
|
|
87009
|
+
"outside_writer",
|
|
87010
|
+
"artifact_kind",
|
|
87011
|
+
"type_locked",
|
|
87012
|
+
"type_lock",
|
|
87013
|
+
"type_first_party",
|
|
87014
|
+
"caps_read_not_found",
|
|
87015
|
+
"live_paths",
|
|
87016
|
+
"capabilities",
|
|
87017
|
+
"capabilities_unknown",
|
|
87018
|
+
"capabilities_cut",
|
|
87019
|
+
"grant_observed"
|
|
87020
|
+
]), SAFE_ARTIFACT_SHARE_TRUE_LITERAL_KEYS = [
|
|
87021
|
+
"probe_failed",
|
|
87022
|
+
"cowritten",
|
|
87023
|
+
"outside_writer",
|
|
87024
|
+
"type_locked",
|
|
87025
|
+
"type_first_party",
|
|
87026
|
+
"caps_read_not_found",
|
|
87027
|
+
"capabilities_unknown",
|
|
87028
|
+
"capabilities_cut"
|
|
87029
|
+
], SAFE_ARTIFACT_PATH_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
87030
|
+
"slug",
|
|
87031
|
+
"thumbnail_named"
|
|
87032
|
+
]), SAFE_ARTIFACT_LIVE_DOC_KEYS = /* @__PURE__ */ new Set([
|
|
87033
|
+
"slug",
|
|
87034
|
+
"live_path",
|
|
87035
|
+
"working_copy"
|
|
87036
|
+
]), SAFE_ARTIFACT_TYPE_READ_KEYS = /* @__PURE__ */ new Set([
|
|
87037
|
+
"declares_room"
|
|
87038
|
+
]), SAFE_ARTIFACT_LAST_PUBLISH_KEYS = /* @__PURE__ */ new Set([
|
|
87039
|
+
"slug",
|
|
87040
|
+
"env"
|
|
87041
|
+
]), SAFE_ARTIFACT_SESSION_KEYS = /* @__PURE__ */ new Set([
|
|
87042
|
+
"frame_env",
|
|
87043
|
+
"viewer_origin",
|
|
87044
|
+
"dev_viewer_origin",
|
|
87045
|
+
"toolset",
|
|
87046
|
+
"short_links",
|
|
87047
|
+
"ant_build",
|
|
87048
|
+
"live_edit",
|
|
87049
|
+
"live_doc_stream",
|
|
87050
|
+
"live_paths_schema",
|
|
87051
|
+
"copy_from",
|
|
87052
|
+
"types_on",
|
|
87053
|
+
"five_class_asks",
|
|
87054
|
+
"inherited_type_grant",
|
|
87055
|
+
"watch_rail",
|
|
87056
|
+
"auto_react",
|
|
87057
|
+
"comments_in_schema",
|
|
87058
|
+
"db_str_replace",
|
|
87059
|
+
"handlers",
|
|
87060
|
+
"room_client",
|
|
87061
|
+
"eval_stub",
|
|
87062
|
+
"scratchpad_dir",
|
|
87063
|
+
"tool_results_dir"
|
|
87064
|
+
]), SAFE_ARTIFACT_SESSION_REQUIRED_BOOLEAN_KEYS = [
|
|
87065
|
+
"ant_build",
|
|
87066
|
+
"comments_in_schema",
|
|
87067
|
+
"handlers",
|
|
87068
|
+
"room_client",
|
|
87069
|
+
"eval_stub"
|
|
87070
|
+
], SAFE_ARTIFACT_SESSION_OPTIONAL_BOOLEAN_KEYS = [
|
|
87071
|
+
"toolset",
|
|
87072
|
+
"short_links",
|
|
87073
|
+
"live_edit",
|
|
87074
|
+
"live_doc_stream",
|
|
87075
|
+
"live_paths_schema",
|
|
87076
|
+
"copy_from",
|
|
87077
|
+
"types_on",
|
|
87078
|
+
"five_class_asks",
|
|
87079
|
+
"auto_react",
|
|
87080
|
+
"db_str_replace"
|
|
87081
|
+
], MAX_SAFEGUARDS_ENTRIES = 16;
|
|
87082
|
+
function isPlainObject(val) {
|
|
87083
|
+
return val !== null && typeof val == "object" && !Array.isArray(val);
|
|
87084
|
+
}
|
|
87085
|
+
function isFiniteNumber(val) {
|
|
87086
|
+
return typeof val == "number" && Number.isFinite(val);
|
|
87087
|
+
}
|
|
87088
|
+
function isStringArray(val) {
|
|
87089
|
+
return Array.isArray(val) && val.every((item2) => typeof item2 == "string");
|
|
87090
|
+
}
|
|
87091
|
+
function isStringRecord(val) {
|
|
87092
|
+
if (!isPlainObject(val)) return !1;
|
|
87093
|
+
for (let k of Object.keys(val))
|
|
87094
|
+
if (typeof val[k] != "string") return !1;
|
|
87095
|
+
return !0;
|
|
87096
|
+
}
|
|
87097
|
+
function isValidTrustedDirEntry(val) {
|
|
87098
|
+
if (!isPlainObject(val)) return !1;
|
|
87099
|
+
let keys = Object.keys(val);
|
|
87100
|
+
for (let k of keys)
|
|
87101
|
+
if (!SAFE_TRUSTED_DIRECTORY_ENTRY_KEYS.has(k)) return !1;
|
|
87102
|
+
return !(!hasOwn(val, "path") || typeof val.path != "string" || !hasOwn(val, "resolved") || !isStringArray(val.resolved) || hasOwn(val, "source") && val.source !== void 0 && typeof val.source != "string");
|
|
87103
|
+
}
|
|
87104
|
+
function isValidGitOriginOrCacheEntry(val) {
|
|
87105
|
+
if (!isPlainObject(val)) return !1;
|
|
87106
|
+
for (let k of Object.keys(val))
|
|
87107
|
+
if (!SAFE_GIT_ORIGIN_KEYS.has(k)) return !1;
|
|
87108
|
+
return !(!hasOwn(val, "host") || typeof val.host != "string" || !hasOwn(val, "remote") || typeof val.remote != "string" || !hasOwn(val, "visibility") || typeof val.visibility != "string" || !SAFE_GIT_REPO_VISIBILITY_VALUES.has(val.visibility));
|
|
87109
|
+
}
|
|
87110
|
+
function isValidGitRemoteEntry(val) {
|
|
87111
|
+
if (!isPlainObject(val)) return !1;
|
|
87112
|
+
for (let k of Object.keys(val))
|
|
87113
|
+
if (!SAFE_GIT_REMOTE_KEYS.has(k)) return !1;
|
|
87114
|
+
return !(!hasOwn(val, "name") || typeof val.name != "string" || !hasOwn(val, "host") || typeof val.host != "string" || !hasOwn(val, "remote") || typeof val.remote != "string" || !hasOwn(val, "visibility") || typeof val.visibility != "string" || !SAFE_GIT_REPO_VISIBILITY_VALUES.has(val.visibility));
|
|
87115
|
+
}
|
|
87116
|
+
function isValidGitState(val) {
|
|
87117
|
+
if (!isPlainObject(val)) return !1;
|
|
87118
|
+
for (let gk of Object.keys(val)) {
|
|
87119
|
+
if (!SAFE_GIT_STATE_KEYS.has(gk)) return !1;
|
|
87120
|
+
let gv = val[gk];
|
|
87121
|
+
if (gk === "cwd" || gk === "root" || gk === "branch" || gk === "default_branch") {
|
|
87122
|
+
if (gv != null && typeof gv != "string") return !1;
|
|
87123
|
+
} else if (gk === "error") {
|
|
87124
|
+
if (gv != null && (typeof gv != "string" || !SAFE_GIT_ERROR_VALUES.has(gv)))
|
|
87125
|
+
return !1;
|
|
87126
|
+
} else if (gk === "truncated") {
|
|
87127
|
+
if (gv !== void 0 && typeof gv != "boolean") return !1;
|
|
87128
|
+
} else if (gk === "status") {
|
|
87129
|
+
if (gv != null) {
|
|
87130
|
+
if (!isPlainObject(gv)) return !1;
|
|
87131
|
+
for (let sk of Object.keys(gv))
|
|
87132
|
+
if (!SAFE_GIT_STATUS_KEYS.has(sk)) return !1;
|
|
87133
|
+
if (!hasOwn(gv, "clean") || typeof gv.clean != "boolean" || !hasOwn(gv, "truncated") || typeof gv.truncated != "boolean" || !hasOwn(gv, "porcelain") || gv.porcelain !== null && typeof gv.porcelain != "string" || !hasOwn(gv, "counts")) return !1;
|
|
87134
|
+
if (gv.counts !== null) {
|
|
87135
|
+
if (!isPlainObject(gv.counts)) return !1;
|
|
87136
|
+
for (let ck of Object.keys(gv.counts))
|
|
87137
|
+
if (!SAFE_GIT_COUNTS_KEYS.has(ck)) return !1;
|
|
87138
|
+
if (!hasOwn(gv.counts, "staged") || !isFiniteNumber(gv.counts.staged) || !hasOwn(gv.counts, "modified") || !isFiniteNumber(gv.counts.modified) || !hasOwn(gv.counts, "untracked") || gv.counts.untracked !== null && !isFiniteNumber(gv.counts.untracked) || !hasOwn(gv.counts, "untracked_normal") || gv.counts.untracked_normal !== null && !isFiniteNumber(gv.counts.untracked_normal))
|
|
87139
|
+
return !1;
|
|
87140
|
+
}
|
|
87141
|
+
}
|
|
87142
|
+
} else if (gk === "visibility" && gv != null) {
|
|
87143
|
+
if (!isPlainObject(gv)) return !1;
|
|
87144
|
+
for (let vk of Object.keys(gv))
|
|
87145
|
+
if (!SAFE_GIT_VISIBILITY_KEYS.has(vk)) return !1;
|
|
87146
|
+
if (!hasOwn(gv, "origin") || gv.origin !== null && !isValidGitOriginOrCacheEntry(gv.origin) || !hasOwn(gv, "push_remote") || gv.push_remote !== null && typeof gv.push_remote != "string" || !hasOwn(gv, "remotes") || !Array.isArray(gv.remotes) || !gv.remotes.every(isValidGitRemoteEntry) || !hasOwn(gv, "visibility_cache") || !Array.isArray(gv.visibility_cache) || !gv.visibility_cache.every(isValidGitOriginOrCacheEntry))
|
|
87147
|
+
return !1;
|
|
87148
|
+
}
|
|
87149
|
+
}
|
|
87150
|
+
return !0;
|
|
87151
|
+
}
|
|
87152
|
+
function isValidChromeNavigation(val) {
|
|
87153
|
+
if (!isPlainObject(val)) return !1;
|
|
87154
|
+
for (let ck of Object.keys(val))
|
|
87155
|
+
if (!SAFE_CHROME_NAVIGATION_KEYS.has(ck)) return !1;
|
|
87156
|
+
if (!hasOwn(val, "enabled") || typeof val.enabled != "boolean" || !hasOwn(val, "baselines") || !isStringRecord(val.baselines)) return !1;
|
|
87157
|
+
if (hasOwn(val, "tabs") && val.tabs !== void 0) {
|
|
87158
|
+
if (!isPlainObject(val.tabs)) return !1;
|
|
87159
|
+
for (let tk of Object.keys(val.tabs))
|
|
87160
|
+
if (!isStringRecord(val.tabs[tk])) return !1;
|
|
87161
|
+
}
|
|
87162
|
+
return !0;
|
|
87163
|
+
}
|
|
87164
|
+
var SAFE_ARTIFACT_RULE_CAPABILITY_KEYS = /* @__PURE__ */ new Set([
|
|
87165
|
+
"artifact",
|
|
87166
|
+
"self",
|
|
87167
|
+
"downloads",
|
|
87168
|
+
"comments",
|
|
87169
|
+
"room",
|
|
87170
|
+
"db",
|
|
87171
|
+
"assets"
|
|
87172
|
+
]), SAFE_ARTIFACT_CAPABILITY_KEYS = /* @__PURE__ */ new Set([
|
|
87173
|
+
...SAFE_ARTIFACT_RULE_CAPABILITY_KEYS,
|
|
87174
|
+
"user",
|
|
87175
|
+
"mcp",
|
|
87176
|
+
"flags"
|
|
87177
|
+
]), MAX_ARTIFACT_CAPABILITIES_BYTES = 4e3, MAX_ARTIFACT_MCP_SERVERS = 32, MAX_ARTIFACT_MCP_TOOLS = 128, SAFE_ARTIFACT_MCP_TOOL_RE = /^[A-Za-z0-9_.-]{1,128}$/, SAFE_ARTIFACT_MCP_CAP_KEYS = /* @__PURE__ */ new Set(["servers", "dynamic"]), SAFE_ARTIFACT_MCP_SERVER_KEYS = /* @__PURE__ */ new Set(["server", "tools"]), SAFE_ARTIFACT_RULE_OBJECT_KEYS = /* @__PURE__ */ new Set(["rules", "wake"]), SAFE_ARTIFACT_RULE_ENTRY_KEYS = /* @__PURE__ */ new Set(["path", "read", "write"]), SAFE_ARTIFACT_RULE_PATH_RE = /^(?:[A-Za-z0-9_.~:@+-]+|\{self\})(?:\/(?:[A-Za-z0-9_.~:@+-]+|\{self\}))*$/, SAFE_ARTIFACT_RULE_PERMS = /* @__PURE__ */ new Set([
|
|
87178
|
+
"view",
|
|
87179
|
+
"interact",
|
|
87180
|
+
"admin",
|
|
87181
|
+
"owner"
|
|
87182
|
+
]), SAFE_ARTIFACT_USER_CAP_KEYS = /* @__PURE__ */ new Set(["scopes"]), SAFE_ARTIFACT_USER_SCOPE_RE = /^[a-z][a-z0-9_-]{0,31}$/;
|
|
87183
|
+
function isValidArtifactCapabilityRules(val) {
|
|
87184
|
+
if (!Array.isArray(val)) return !1;
|
|
87185
|
+
for (let rule of val) {
|
|
87186
|
+
if (!isPlainObject(rule)) return !1;
|
|
87187
|
+
for (let rk of Object.keys(rule))
|
|
87188
|
+
if (!SAFE_ARTIFACT_RULE_ENTRY_KEYS.has(rk)) return !1;
|
|
87189
|
+
if (!hasOwn(rule, "path") || typeof rule.path != "string" || rule.path !== "" && !SAFE_ARTIFACT_RULE_PATH_RE.test(rule.path) || hasOwn(rule, "read") && rule.read !== void 0 && (typeof rule.read != "string" || !SAFE_ARTIFACT_RULE_PERMS.has(rule.read)) || hasOwn(rule, "write") && rule.write !== void 0 && (typeof rule.write != "string" || !SAFE_ARTIFACT_RULE_PERMS.has(rule.write)))
|
|
87190
|
+
return !1;
|
|
87191
|
+
}
|
|
87192
|
+
return !0;
|
|
87193
|
+
}
|
|
87194
|
+
function isValidArtifactCapabilityEntry(capKey, capVal) {
|
|
87195
|
+
if (!SAFE_ARTIFACT_CAPABILITY_KEYS.has(capKey) || !isPlainObject(capVal)) return !1;
|
|
87196
|
+
if (capKey === "mcp") {
|
|
87197
|
+
for (let mk of Object.keys(capVal))
|
|
87198
|
+
if (!SAFE_ARTIFACT_MCP_CAP_KEYS.has(mk)) return !1;
|
|
87199
|
+
if (hasOwn(capVal, "dynamic") && capVal.dynamic !== void 0 && typeof capVal.dynamic != "boolean")
|
|
87200
|
+
return !1;
|
|
87201
|
+
if (hasOwn(capVal, "servers") && capVal.servers !== void 0) {
|
|
87202
|
+
if (!Array.isArray(capVal.servers) || capVal.servers.length > MAX_ARTIFACT_MCP_SERVERS || capVal.servers.length === 0 && capVal.dynamic !== !0)
|
|
87203
|
+
return !1;
|
|
87204
|
+
for (let srv of capVal.servers) {
|
|
87205
|
+
if (!isPlainObject(srv)) return !1;
|
|
87206
|
+
for (let sk of Object.keys(srv))
|
|
87207
|
+
if (!SAFE_ARTIFACT_MCP_SERVER_KEYS.has(sk)) return !1;
|
|
87208
|
+
if (!hasOwn(srv, "server") || typeof srv.server != "string" || srv.server.length === 0 || srv.server.length > 128 || !hasOwn(srv, "tools") || !Array.isArray(srv.tools) || srv.tools.length === 0 || srv.tools.length > MAX_ARTIFACT_MCP_TOOLS || !srv.tools.every((t) => typeof t == "string" && SAFE_ARTIFACT_MCP_TOOL_RE.test(t)))
|
|
87209
|
+
return !1;
|
|
87210
|
+
}
|
|
87211
|
+
}
|
|
87212
|
+
return !0;
|
|
87213
|
+
}
|
|
87214
|
+
if (capKey === "user") {
|
|
87215
|
+
for (let uk of Object.keys(capVal))
|
|
87216
|
+
if (!SAFE_ARTIFACT_USER_CAP_KEYS.has(uk)) return !1;
|
|
87217
|
+
return !(hasOwn(capVal, "scopes") && capVal.scopes !== void 0 && (!Array.isArray(capVal.scopes) || !capVal.scopes.every((s) => typeof s == "string" && SAFE_ARTIFACT_USER_SCOPE_RE.test(s))));
|
|
87218
|
+
}
|
|
87219
|
+
if (SAFE_ARTIFACT_RULE_CAPABILITY_KEYS.has(capKey)) {
|
|
87220
|
+
for (let dk of Object.keys(capVal))
|
|
87221
|
+
if (!SAFE_ARTIFACT_RULE_OBJECT_KEYS.has(dk)) return !1;
|
|
87222
|
+
return !(hasOwn(capVal, "rules") && capVal.rules !== void 0 && !isValidArtifactCapabilityRules(capVal.rules) || hasOwn(capVal, "wake") && capVal.wake !== void 0 && (!Array.isArray(capVal.wake) || !capVal.wake.every((w) => typeof w == "string" && SAFE_ARTIFACT_RULE_PATH_RE.test(w))));
|
|
87223
|
+
}
|
|
87224
|
+
for (let fk of Object.keys(capVal)) {
|
|
87225
|
+
if (!SAFE_ARTIFACT_USER_SCOPE_RE.test(fk)) return !1;
|
|
87226
|
+
let fv = capVal[fk];
|
|
87227
|
+
if (fv !== null && typeof fv != "string" && typeof fv != "boolean" && !isFiniteNumber(fv))
|
|
87228
|
+
return !1;
|
|
87229
|
+
}
|
|
87230
|
+
return !0;
|
|
87231
|
+
}
|
|
87232
|
+
function isValidArtifactShare(val) {
|
|
87233
|
+
if (!isPlainObject(val)) return !1;
|
|
87234
|
+
for (let k of Object.keys(val))
|
|
87235
|
+
if (!SAFE_ARTIFACT_SHARE_KEYS.has(k)) return !1;
|
|
87236
|
+
if (!hasOwn(val, "mode") || typeof val.mode != "string" || !hasOwn(val, "is_shared_live") || typeof val.is_shared_live != "boolean" || !hasOwn(val, "probed") || typeof val.probed != "boolean" || !hasOwn(val, "probe_current_account") || typeof val.probe_current_account != "boolean" || !hasOwn(val, "grant_observed") || typeof val.grant_observed != "boolean" || hasOwn(val, "role") && val.role !== void 0 && typeof val.role != "string" || hasOwn(val, "artifact_kind") && val.artifact_kind !== void 0 && typeof val.artifact_kind != "string" || hasOwn(val, "type_lock") && val.type_lock !== void 0 && typeof val.type_lock != "boolean")
|
|
87237
|
+
return !1;
|
|
87238
|
+
for (let tk of SAFE_ARTIFACT_SHARE_TRUE_LITERAL_KEYS)
|
|
87239
|
+
if (hasOwn(val, tk) && val[tk] !== void 0 && val[tk] !== !0) return !1;
|
|
87240
|
+
if (hasOwn(val, "live_paths") && val.live_paths !== void 0 && !isStringArray(val.live_paths))
|
|
87241
|
+
return !1;
|
|
87242
|
+
if (hasOwn(val, "capabilities") && val.capabilities !== void 0) {
|
|
87243
|
+
if (!isPlainObject(val.capabilities) || Buffer.byteLength(JSON.stringify(val.capabilities), "utf8") > MAX_ARTIFACT_CAPABILITIES_BYTES)
|
|
87244
|
+
return !1;
|
|
87245
|
+
for (let capKey of Object.keys(val.capabilities))
|
|
87246
|
+
if (!isValidArtifactCapabilityEntry(capKey, val.capabilities[capKey]))
|
|
87247
|
+
return !1;
|
|
87248
|
+
}
|
|
87249
|
+
return !0;
|
|
87250
|
+
}
|
|
87251
|
+
function isValidArtifacts(val) {
|
|
87252
|
+
if (!isPlainObject(val)) return !1;
|
|
87253
|
+
for (let artk of Object.keys(val))
|
|
87254
|
+
if (!SAFE_ARTIFACTS_KEYS.has(artk)) return !1;
|
|
87255
|
+
if (!hasOwn(val, "by_slug") || !isPlainObject(val.by_slug)) return !1;
|
|
87256
|
+
for (let slugKey of Object.keys(val.by_slug)) {
|
|
87257
|
+
let slugEntry = val.by_slug[slugKey];
|
|
87258
|
+
if (!isPlainObject(slugEntry)) return !1;
|
|
87259
|
+
for (let sek of Object.keys(slugEntry))
|
|
87260
|
+
if (!SAFE_ARTIFACT_SLUG_ENTRY_KEYS.has(sek)) return !1;
|
|
87261
|
+
if (hasOwn(slugEntry, "share") && slugEntry.share !== void 0 && !isValidArtifactShare(slugEntry.share) || hasOwn(slugEntry, "attested") && slugEntry.attested !== void 0 && typeof slugEntry.attested != "string" || hasOwn(slugEntry, "notice_pending") && slugEntry.notice_pending !== void 0 && slugEntry.notice_pending !== !0 || hasOwn(slugEntry, "published_env") && slugEntry.published_env !== void 0 && (typeof slugEntry.published_env != "string" || !SAFE_ARTIFACT_ENV_VALUES.has(slugEntry.published_env)))
|
|
87262
|
+
return !1;
|
|
87263
|
+
if (hasOwn(slugEntry, "watch") && slugEntry.watch !== void 0) {
|
|
87264
|
+
if (!isPlainObject(slugEntry.watch)) return !1;
|
|
87265
|
+
for (let wk of Object.keys(slugEntry.watch))
|
|
87266
|
+
if (!SAFE_ARTIFACT_WATCH_KEYS.has(wk) || slugEntry.watch[wk] !== void 0 && slugEntry.watch[wk] !== !0) return !1;
|
|
87267
|
+
}
|
|
87268
|
+
}
|
|
87269
|
+
if (!hasOwn(val, "by_path") || !isPlainObject(val.by_path)) return !1;
|
|
87270
|
+
for (let pathKey of Object.keys(val.by_path)) {
|
|
87271
|
+
let pathEntry = val.by_path[pathKey];
|
|
87272
|
+
if (!isPlainObject(pathEntry)) return !1;
|
|
87273
|
+
for (let pek of Object.keys(pathEntry))
|
|
87274
|
+
if (!SAFE_ARTIFACT_PATH_ENTRY_KEYS.has(pek)) return !1;
|
|
87275
|
+
if (hasOwn(pathEntry, "slug") && pathEntry.slug !== void 0 && typeof pathEntry.slug != "string" || hasOwn(pathEntry, "thumbnail_named") && pathEntry.thumbnail_named !== void 0 && !isStringArray(pathEntry.thumbnail_named))
|
|
87276
|
+
return !1;
|
|
87277
|
+
}
|
|
87278
|
+
if (!hasOwn(val, "live_docs") || !Array.isArray(val.live_docs)) return !1;
|
|
87279
|
+
for (let doc of val.live_docs) {
|
|
87280
|
+
if (!isPlainObject(doc)) return !1;
|
|
87281
|
+
for (let dk of Object.keys(doc))
|
|
87282
|
+
if (!SAFE_ARTIFACT_LIVE_DOC_KEYS.has(dk)) return !1;
|
|
87283
|
+
if (!hasOwn(doc, "slug") || typeof doc.slug != "string" || !hasOwn(doc, "live_path") || typeof doc.live_path != "string" || !hasOwn(doc, "working_copy") || typeof doc.working_copy != "string")
|
|
87284
|
+
return !1;
|
|
87285
|
+
}
|
|
87286
|
+
if (!hasOwn(val, "room_armed") || !isStringArray(val.room_armed) || !hasOwn(val, "type_reads") || !isPlainObject(val.type_reads)) return !1;
|
|
87287
|
+
for (let trKey of Object.keys(val.type_reads)) {
|
|
87288
|
+
let trEntry = val.type_reads[trKey];
|
|
87289
|
+
if (!isPlainObject(trEntry)) return !1;
|
|
87290
|
+
for (let trk of Object.keys(trEntry))
|
|
87291
|
+
if (!SAFE_ARTIFACT_TYPE_READ_KEYS.has(trk)) return !1;
|
|
87292
|
+
if (!hasOwn(trEntry, "declares_room") || typeof trEntry.declares_room != "boolean")
|
|
87293
|
+
return !1;
|
|
87294
|
+
}
|
|
87295
|
+
if (hasOwn(val, "last_publish") && val.last_publish !== void 0) {
|
|
87296
|
+
let lp = val.last_publish;
|
|
87297
|
+
if (!isPlainObject(lp)) return !1;
|
|
87298
|
+
for (let lpk of Object.keys(lp))
|
|
87299
|
+
if (!SAFE_ARTIFACT_LAST_PUBLISH_KEYS.has(lpk)) return !1;
|
|
87300
|
+
if (!hasOwn(lp, "slug") || typeof lp.slug != "string" || !hasOwn(lp, "env") || typeof lp.env != "string" || !SAFE_ARTIFACT_ENV_VALUES.has(lp.env))
|
|
87301
|
+
return !1;
|
|
87302
|
+
}
|
|
87303
|
+
if (!hasOwn(val, "session") || !isPlainObject(val.session)) return !1;
|
|
87304
|
+
let sess = val.session;
|
|
87305
|
+
for (let sk of Object.keys(sess))
|
|
87306
|
+
if (!SAFE_ARTIFACT_SESSION_KEYS.has(sk)) return !1;
|
|
87307
|
+
if (!hasOwn(sess, "frame_env") || typeof sess.frame_env != "string" || !SAFE_ARTIFACT_ENV_VALUES.has(sess.frame_env) || !hasOwn(sess, "viewer_origin") || typeof sess.viewer_origin != "string" || hasOwn(sess, "dev_viewer_origin") && sess.dev_viewer_origin !== void 0 && typeof sess.dev_viewer_origin != "string")
|
|
87308
|
+
return !1;
|
|
87309
|
+
for (let reqBool of SAFE_ARTIFACT_SESSION_REQUIRED_BOOLEAN_KEYS)
|
|
87310
|
+
if (!hasOwn(sess, reqBool) || typeof sess[reqBool] != "boolean") return !1;
|
|
87311
|
+
for (let optBool of SAFE_ARTIFACT_SESSION_OPTIONAL_BOOLEAN_KEYS)
|
|
87312
|
+
if (hasOwn(sess, optBool) && sess[optBool] !== void 0 && typeof sess[optBool] != "boolean")
|
|
87313
|
+
return !1;
|
|
87314
|
+
return !(hasOwn(sess, "inherited_type_grant") && sess.inherited_type_grant !== void 0 && sess.inherited_type_grant !== !0 || hasOwn(sess, "watch_rail") && sess.watch_rail !== void 0 && (typeof sess.watch_rail != "string" || !SAFE_ARTIFACT_WATCH_RAIL_VALUES.has(sess.watch_rail)) || !hasOwn(sess, "scratchpad_dir") || sess.scratchpad_dir !== null && typeof sess.scratchpad_dir != "string" || hasOwn(sess, "tool_results_dir") && sess.tool_results_dir !== void 0 && typeof sess.tool_results_dir != "string" || hasOwn(val, "truncated") && val.truncated !== void 0 && typeof val.truncated != "boolean");
|
|
87315
|
+
}
|
|
87316
|
+
function validateCanonicalSafeguards(safeguards) {
|
|
87317
|
+
if (!Array.isArray(safeguards) || safeguards.length > MAX_SAFEGUARDS_ENTRIES)
|
|
87318
|
+
throw new CanonicalRejectError("safeguards is not a canonical dangerous_tool_use array");
|
|
87319
|
+
for (let entry5 of safeguards) {
|
|
87320
|
+
if (!isPlainObject(entry5))
|
|
87321
|
+
throw new CanonicalRejectError("safeguards entry is not a plain object");
|
|
87322
|
+
for (let k of Object.keys(entry5))
|
|
87323
|
+
if (!SAFE_SAFEGUARD_ENTRY_KEYS.has(k))
|
|
87324
|
+
throw new CanonicalRejectError("safeguards entry contains unsupported key");
|
|
87325
|
+
if (!hasOwn(entry5, "type") || entry5.type !== "dangerous_tool_use")
|
|
87326
|
+
throw new CanonicalRejectError("safeguards entry type is not dangerous_tool_use");
|
|
87327
|
+
if (hasOwn(entry5, "classifier_context") && entry5.classifier_context !== void 0) {
|
|
87328
|
+
let ctx = entry5.classifier_context;
|
|
87329
|
+
if (!isPlainObject(ctx))
|
|
87330
|
+
throw new CanonicalRejectError("safeguards classifier_context is not a plain object");
|
|
87331
|
+
for (let ck of Object.keys(ctx))
|
|
87332
|
+
if (!SAFE_CLASSIFIER_CONTEXT_KEYS.has(ck))
|
|
87333
|
+
throw new CanonicalRejectError("safeguards classifier_context contains unsupported key");
|
|
87334
|
+
if (hasOwn(ctx, "v") && ctx.v !== void 0 && !isFiniteNumber(ctx.v))
|
|
87335
|
+
throw new CanonicalRejectError("safeguards classifier_context.v is not a finite number");
|
|
87336
|
+
for (let sk of CLASSIFIER_STRING_KEYS)
|
|
87337
|
+
if (hasOwn(ctx, sk) && ctx[sk] !== void 0 && typeof ctx[sk] != "string")
|
|
87338
|
+
throw new CanonicalRejectError("safeguards classifier_context string field is invalid");
|
|
87339
|
+
for (let bk of CLASSIFIER_BOOLEAN_KEYS)
|
|
87340
|
+
if (hasOwn(ctx, bk) && ctx[bk] !== void 0 && typeof ctx[bk] != "boolean")
|
|
87341
|
+
throw new CanonicalRejectError("safeguards classifier_context boolean field is invalid");
|
|
87342
|
+
if (hasOwn(ctx, "user_identity") && ctx.user_identity !== void 0 && ctx.user_identity !== null && typeof ctx.user_identity != "string")
|
|
87343
|
+
throw new CanonicalRejectError("safeguards classifier_context.user_identity is invalid");
|
|
87344
|
+
if (hasOwn(ctx, "rule_roots") && ctx.rule_roots !== void 0) {
|
|
87345
|
+
if (!isPlainObject(ctx.rule_roots))
|
|
87346
|
+
throw new CanonicalRejectError("safeguards classifier_context.rule_roots is invalid");
|
|
87347
|
+
for (let rk of Object.keys(ctx.rule_roots)) {
|
|
87348
|
+
let rv = ctx.rule_roots[rk];
|
|
87349
|
+
if (!SAFE_RULE_ROOT_KEYS.has(rk) || rv !== null && typeof rv != "string")
|
|
87350
|
+
throw new CanonicalRejectError("safeguards classifier_context.rule_roots is invalid");
|
|
87351
|
+
}
|
|
87352
|
+
}
|
|
87353
|
+
if (hasOwn(ctx, "trusted_directories") && ctx.trusted_directories !== void 0) {
|
|
87354
|
+
if (!isPlainObject(ctx.trusted_directories))
|
|
87355
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87356
|
+
let td = ctx.trusted_directories;
|
|
87357
|
+
for (let tk of Object.keys(td))
|
|
87358
|
+
if (!SAFE_TRUSTED_DIRECTORIES_KEYS.has(tk))
|
|
87359
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87360
|
+
if (hasOwn(td, "primary") && td.primary !== void 0 && td.primary !== null && !isValidTrustedDirEntry(td.primary))
|
|
87361
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87362
|
+
if (hasOwn(td, "additional") && td.additional !== void 0 && (!Array.isArray(td.additional) || !td.additional.every((item2) => typeof item2 == "string" || isValidTrustedDirEntry(item2))))
|
|
87363
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87364
|
+
if (hasOwn(td, "network") && td.network !== void 0 && !isStringArray(td.network))
|
|
87365
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87366
|
+
if (hasOwn(td, "block_reads_outside_working_directories") && td.block_reads_outside_working_directories !== void 0 && typeof td.block_reads_outside_working_directories != "boolean")
|
|
87367
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87368
|
+
}
|
|
87369
|
+
if (hasOwn(ctx, "rules") && ctx.rules !== void 0) {
|
|
87370
|
+
if (!isPlainObject(ctx.rules))
|
|
87371
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87372
|
+
for (let rlk of Object.keys(ctx.rules)) {
|
|
87373
|
+
let rlv = ctx.rules[rlk];
|
|
87374
|
+
if (!SAFE_RULES_KEYS.has(rlk) || !Array.isArray(rlv))
|
|
87375
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87376
|
+
for (let item2 of rlv) {
|
|
87377
|
+
if (!isPlainObject(item2))
|
|
87378
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87379
|
+
for (let ik of Object.keys(item2))
|
|
87380
|
+
if (!SAFE_RULE_ITEM_KEYS.has(ik))
|
|
87381
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87382
|
+
if (!hasOwn(item2, "rule") || typeof item2.rule != "string" || !hasOwn(item2, "source") || typeof item2.source != "string")
|
|
87383
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87384
|
+
if (hasOwn(item2, "canonical") && item2.canonical !== void 0 && typeof item2.canonical != "string")
|
|
87385
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87386
|
+
if (hasOwn(item2, "root") && item2.root !== void 0 && item2.root !== null && typeof item2.root != "string")
|
|
87387
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87388
|
+
if (hasOwn(item2, "pattern") && item2.pattern !== void 0 && typeof item2.pattern != "string")
|
|
87389
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87390
|
+
}
|
|
87391
|
+
}
|
|
87392
|
+
}
|
|
87393
|
+
if (hasOwn(ctx, "dropped") && ctx.dropped !== void 0) {
|
|
87394
|
+
if (!isPlainObject(ctx.dropped))
|
|
87395
|
+
throw new CanonicalRejectError("safeguards classifier_context.dropped is invalid");
|
|
87396
|
+
for (let dk of Object.keys(ctx.dropped)) {
|
|
87397
|
+
let dv = ctx.dropped[dk];
|
|
87398
|
+
if (!SAFE_DROPPED_KEYS.has(dk) || !isFiniteNumber(dv))
|
|
87399
|
+
throw new CanonicalRejectError("safeguards classifier_context.dropped is invalid");
|
|
87400
|
+
}
|
|
87401
|
+
}
|
|
87402
|
+
if (hasOwn(ctx, "auto_mode") && ctx.auto_mode !== void 0) {
|
|
87403
|
+
if (!isPlainObject(ctx.auto_mode))
|
|
87404
|
+
throw new CanonicalRejectError("safeguards classifier_context.auto_mode is invalid");
|
|
87405
|
+
for (let ak of Object.keys(ctx.auto_mode))
|
|
87406
|
+
if (!SAFE_AUTO_MODE_KEYS.has(ak) || !isStringArray(ctx.auto_mode[ak]))
|
|
87407
|
+
throw new CanonicalRejectError("safeguards classifier_context.auto_mode is invalid");
|
|
87408
|
+
}
|
|
87409
|
+
if (hasOwn(ctx, "git_state") && ctx.git_state !== void 0 && ctx.git_state !== null && !isValidGitState(ctx.git_state))
|
|
87410
|
+
throw new CanonicalRejectError("safeguards classifier_context.git_state is invalid");
|
|
87411
|
+
if (hasOwn(ctx, "chrome_navigation") && ctx.chrome_navigation !== void 0 && !isValidChromeNavigation(ctx.chrome_navigation))
|
|
87412
|
+
throw new CanonicalRejectError("safeguards classifier_context.chrome_navigation is invalid");
|
|
87413
|
+
if (hasOwn(ctx, "prior_turn_context") && ctx.prior_turn_context !== void 0) {
|
|
87414
|
+
if (!Array.isArray(ctx.prior_turn_context))
|
|
87415
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87416
|
+
for (let pt of ctx.prior_turn_context) {
|
|
87417
|
+
if (!isPlainObject(pt))
|
|
87418
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87419
|
+
for (let ptk of Object.keys(pt))
|
|
87420
|
+
if (!SAFE_PRIOR_TURN_ENTRY_KEYS.has(ptk))
|
|
87421
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87422
|
+
if (!hasOwn(pt, "tool_use_ids") || !isStringArray(pt.tool_use_ids))
|
|
87423
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87424
|
+
if (!hasOwn(pt, "context") || !isPlainObject(pt.context))
|
|
87425
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87426
|
+
for (let icKey of Object.keys(pt.context))
|
|
87427
|
+
if (!SAFE_PRIOR_TURN_INNER_CONTEXT_KEYS.has(icKey))
|
|
87428
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87429
|
+
if (hasOwn(pt.context, "git_state") && pt.context.git_state !== void 0 && pt.context.git_state !== null && !isValidGitState(pt.context.git_state))
|
|
87430
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87431
|
+
if (hasOwn(pt.context, "chrome_navigation") && pt.context.chrome_navigation !== void 0 && !isValidChromeNavigation(pt.context.chrome_navigation))
|
|
87432
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87433
|
+
if (hasOwn(pt.context, "live_cwd") && pt.context.live_cwd !== void 0 && typeof pt.context.live_cwd != "string")
|
|
87434
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87435
|
+
if (hasOwn(pt.context, "platform") && pt.context.platform !== void 0 && typeof pt.context.platform != "string")
|
|
87436
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87437
|
+
}
|
|
87438
|
+
}
|
|
87439
|
+
if (hasOwn(ctx, "system_reminders") && ctx.system_reminders !== void 0) {
|
|
87440
|
+
if (!Array.isArray(ctx.system_reminders))
|
|
87441
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87442
|
+
for (let sr of ctx.system_reminders) {
|
|
87443
|
+
if (!isPlainObject(sr))
|
|
87444
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87445
|
+
for (let srk of Object.keys(sr))
|
|
87446
|
+
if (!SAFE_SYSTEM_REMINDER_KEYS.has(srk))
|
|
87447
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87448
|
+
if (!hasOwn(sr, "id") || typeof sr.id != "string" || !hasOwn(sr, "provenance") || typeof sr.provenance != "string")
|
|
87449
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87450
|
+
if (hasOwn(sr, "author") && sr.author !== void 0 && typeof sr.author != "string")
|
|
87451
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87452
|
+
if (hasOwn(sr, "written") && sr.written !== void 0 && typeof sr.written != "string")
|
|
87453
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87454
|
+
}
|
|
87455
|
+
}
|
|
87456
|
+
if (hasOwn(ctx, "artifacts") && ctx.artifacts !== void 0 && !isValidArtifacts(ctx.artifacts))
|
|
87457
|
+
throw new CanonicalRejectError("safeguards classifier_context.artifacts is invalid");
|
|
87458
|
+
if (hasOwn(ctx, "shed") && ctx.shed !== void 0 && !isStringArray(ctx.shed))
|
|
87459
|
+
throw new CanonicalRejectError("safeguards classifier_context.shed is invalid");
|
|
87460
|
+
}
|
|
87461
|
+
}
|
|
87462
|
+
}
|
|
86680
87463
|
function canonicalBetaHeader(provider, agentHeaders) {
|
|
86681
87464
|
let cfg = getProviderConfig(provider);
|
|
86682
87465
|
if (!cfg.betaHeaderName) return {};
|
|
@@ -86697,6 +87480,7 @@ function buildCanonicalRequest(input) {
|
|
|
86697
87480
|
if (typeof model != "string" || !CANONICAL_MODEL_ID.test(model))
|
|
86698
87481
|
throw new CanonicalRejectError("model is not a canonical model id");
|
|
86699
87482
|
}
|
|
87483
|
+
provider === "anthropic" && hasOwn(body, "safeguards") && validateCanonicalSafeguards(body.safeguards);
|
|
86700
87484
|
let modelCallId = (0, import_node_crypto35.randomUUID)(), sha = requestSha256(body), headers = {
|
|
86701
87485
|
...cfg.synthesizedHeaders,
|
|
86702
87486
|
...canonicalBetaHeader(provider, input.agentHeaders)
|
|
@@ -87220,7 +88004,10 @@ var LocalModelGatewayBroker = class {
|
|
|
87220
88004
|
});
|
|
87221
88005
|
} catch (err) {
|
|
87222
88006
|
if (err instanceof CanonicalRejectError)
|
|
87223
|
-
return
|
|
88007
|
+
return logger.warn("[broker] rejected non-canonical model request", {
|
|
88008
|
+
provider,
|
|
88009
|
+
reason: err.reason
|
|
88010
|
+
}), { status: 400, body: { error: err.reason } };
|
|
87224
88011
|
throw err;
|
|
87225
88012
|
}
|
|
87226
88013
|
let { modelCallId, requestSha256: reqSha } = canonical, selfSecrets = [
|