@quantiya/codevibe-claude-plugin 2.0.69 → 2.0.71
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/.claude-plugin/plugin.json +1 -1
- package/node_modules/@quantiya/codevibe-core/dist/appsync/appsync-client.d.ts +1 -1
- package/node_modules/@quantiya/codevibe-core/dist/index.js +519 -519
- package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/cli.js +662 -6
- 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
|
@@ -11572,6 +11572,8 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11572
11572
|
throw [
|
|
11573
11573
|
mutations.createEvent,
|
|
11574
11574
|
mutations.updateEventStatus,
|
|
11575
|
+
mutations.createEventV2,
|
|
11576
|
+
mutations.updateEventV2,
|
|
11575
11577
|
mutations.recordWorkspaceOutcomeV2,
|
|
11576
11578
|
mutations.reportSecurityPostureV2,
|
|
11577
11579
|
queries.listEvents,
|
|
@@ -11724,7 +11726,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11724
11726
|
return !this.authenticated || this.currentUserId !== userId || this.tokens?.userId !== userId || value?.userId !== userId || value.state.environment !== this.environment || !Number.isSafeInteger(now) || value.state.observedAtEpochMs > now + SYNC_STATE_CLOCK_SKEW_MS || now >= value.state.validUntilEpochMs ? null : value.state;
|
|
11725
11727
|
}
|
|
11726
11728
|
/** Existing socket maintenance recovers idle status after its cloud cache
|
|
11727
|
-
* expires.
|
|
11729
|
+
* expires. Cached observations never grant cloud mutation authority. */
|
|
11728
11730
|
async refreshCompanionSyncDisplayOnMaintenance(userId, signal) {
|
|
11729
11731
|
this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal), !this.companionSyncStatusSnapshot(userId) && (await this.getCompanionSyncState(signal), this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal));
|
|
11730
11732
|
}
|
|
@@ -11918,7 +11920,8 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
11918
11920
|
send: (action, input, signal) => (this.assertSyncAccount(userId), this.mutateDesktopSyncEvent(action, input, signal)),
|
|
11919
11921
|
isQuotaDenial: (error) => error instanceof AppSyncGraphQLError && error.errorType === "SYNC_QUOTA_EXHAUSTED",
|
|
11920
11922
|
omitNewPayload: async (signal) => {
|
|
11921
|
-
|
|
11923
|
+
this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal);
|
|
11924
|
+
let observed = this.companionSyncStatusSnapshot(userId), state = observed?.mode === "SHADOW" ? observed : await this.getCompanionSyncState(signal);
|
|
11922
11925
|
if (this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal), state.protocol !== "SYNC_V2") throw new SyncEventClientError("SYNC_PRODUCER_FROZEN");
|
|
11923
11926
|
return state.usage?.syncState === "PAUSED";
|
|
11924
11927
|
}
|
|
@@ -76689,7 +76692,7 @@ async function runLocalDecomposer(deps, brief, availableAgents, repoContext) {
|
|
|
76689
76692
|
timeoutMs: null,
|
|
76690
76693
|
stdinTty: !0,
|
|
76691
76694
|
stdinPayload: prompt
|
|
76692
|
-
}), exit = await handle.done, text2 = await readImplementorFinalMessage(plan, handle, agent, exit.exitCode, deps.workingDir),
|
|
76695
|
+
}), 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;
|
|
76693
76696
|
return { text: text2, providerError };
|
|
76694
76697
|
};
|
|
76695
76698
|
try {
|
|
@@ -76705,7 +76708,10 @@ async function runLocalDecomposer(deps, brief, availableAgents, repoContext) {
|
|
|
76705
76708
|
agent,
|
|
76706
76709
|
attempt: 2,
|
|
76707
76710
|
...describeDecomposerReply(second.text, second)
|
|
76708
|
-
}), {
|
|
76711
|
+
}), {
|
|
76712
|
+
decompose: !1,
|
|
76713
|
+
reason: second.providerError ? "decomposer provider error" : "decomposer output could not be parsed"
|
|
76714
|
+
});
|
|
76709
76715
|
} catch (err) {
|
|
76710
76716
|
return logger.warn("[team-decompose] decomposer spawn failed \u2014 single-task fallback", {
|
|
76711
76717
|
agent,
|
|
@@ -86635,7 +86641,17 @@ var ANTHROPIC_VERSION = "2023-06-01", ANTHROPIC_BETA_ALLOWLIST = /* @__PURE__ */
|
|
|
86635
86641
|
// Note: advisor-tool-2026-03-01 is deliberately EXCLUDED (unneeded and prevents account-billed advisor tool invocation).
|
|
86636
86642
|
"thinking-token-count-2026-05-13",
|
|
86637
86643
|
"per-turn-control-2026-07-01",
|
|
86638
|
-
"mid-conversation-tool-changes-2026-07-01"
|
|
86644
|
+
"mid-conversation-tool-changes-2026-07-01",
|
|
86645
|
+
// Reviewed 2026-10-14 (CP-7 decomposer dogfood): Empirically captured from live
|
|
86646
|
+
// Claude Code CLI 2.1.299 requests on /v1/messages (`model: "claude-opus-5-5"`).
|
|
86647
|
+
// Claude Code 2.1.299 sends `safeguards: [{ type: "dangerous_tool_use", ... }]` in the
|
|
86648
|
+
// request body; dropping `dangerous-tool-use-2026-09-03` causes upstream Anthropic to
|
|
86649
|
+
// return HTTP 400 (`invalid_request_error`: `"safeguards: Extra inputs are not permitted"`).
|
|
86650
|
+
// `buildCanonicalRequest` in `canonical.ts` validates `$.safeguards` fail-closed against
|
|
86651
|
+
// the 24-key Claude Code 2.1.299 `z1s`/`W3n`/`rmt`/`q1s`/`K1s`/`hmt`/`qOr` schema (and runs
|
|
86652
|
+
// before `scanRequestForBrokerCredentials` and `scrubRequestPayload`).
|
|
86653
|
+
// Note: `afk-mode-2026-01-31` is deliberately EXCLUDED (empirically verified unnecessary).
|
|
86654
|
+
"dangerous-tool-use-2026-09-03"
|
|
86639
86655
|
]), PROVIDER_CONFIGS = {
|
|
86640
86656
|
anthropic: {
|
|
86641
86657
|
upstreamBaseUrl: "https://api.anthropic.com",
|
|
@@ -86811,6 +86827,642 @@ function hasOwn(obj, key) {
|
|
|
86811
86827
|
function requestSha256(body) {
|
|
86812
86828
|
return (0, import_node_crypto35.createHash)("sha256").update(JSON.stringify(body)).digest("hex");
|
|
86813
86829
|
}
|
|
86830
|
+
var SAFE_SAFEGUARD_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
86831
|
+
"type",
|
|
86832
|
+
"classifier_context"
|
|
86833
|
+
]), SAFE_CLASSIFIER_CONTEXT_KEYS = /* @__PURE__ */ new Set([
|
|
86834
|
+
// Exact 16 base keys emitted by Claude Code 2.1.299 `mts` + `qOr` (`dangerous_tool_use` classifier_context):
|
|
86835
|
+
"v",
|
|
86836
|
+
"permission_mode",
|
|
86837
|
+
"platform",
|
|
86838
|
+
"live_cwd",
|
|
86839
|
+
"home_dir",
|
|
86840
|
+
"rule_roots",
|
|
86841
|
+
"trusted_directories",
|
|
86842
|
+
"rules",
|
|
86843
|
+
"auto_mode",
|
|
86844
|
+
"artifact_consent_holdback",
|
|
86845
|
+
"case_insensitive_paths",
|
|
86846
|
+
"restricted",
|
|
86847
|
+
"is_remote_mode",
|
|
86848
|
+
"classify_all_shell",
|
|
86849
|
+
"user_identity",
|
|
86850
|
+
"git_state",
|
|
86851
|
+
// Exact 8 conditional keys emitted by Claude Code 2.1.299 `mts` (offset 202112500) and `qOr` (offset 205163100)
|
|
86852
|
+
// on multi-turn / tool-result / reminder / artifact / byte-budget turns:
|
|
86853
|
+
"dropped",
|
|
86854
|
+
"truncated",
|
|
86855
|
+
"chrome_navigation",
|
|
86856
|
+
"prior_turn_context",
|
|
86857
|
+
"system_reminders",
|
|
86858
|
+
"artifacts",
|
|
86859
|
+
"shed",
|
|
86860
|
+
"tool_host_attached"
|
|
86861
|
+
]), CLASSIFIER_STRING_KEYS = [
|
|
86862
|
+
"permission_mode",
|
|
86863
|
+
"platform",
|
|
86864
|
+
"live_cwd",
|
|
86865
|
+
"home_dir"
|
|
86866
|
+
], CLASSIFIER_BOOLEAN_KEYS = [
|
|
86867
|
+
"artifact_consent_holdback",
|
|
86868
|
+
"case_insensitive_paths",
|
|
86869
|
+
"restricted",
|
|
86870
|
+
"is_remote_mode",
|
|
86871
|
+
"classify_all_shell",
|
|
86872
|
+
"truncated",
|
|
86873
|
+
"tool_host_attached"
|
|
86874
|
+
], SAFE_RULE_ROOT_KEYS = /* @__PURE__ */ new Set([
|
|
86875
|
+
"userSettings",
|
|
86876
|
+
"projectSettings",
|
|
86877
|
+
"localSettings",
|
|
86878
|
+
"flagSettings",
|
|
86879
|
+
"policySettings",
|
|
86880
|
+
"cliArg",
|
|
86881
|
+
"command",
|
|
86882
|
+
"session",
|
|
86883
|
+
"toolsNarrowing",
|
|
86884
|
+
"mcpServerPolicy",
|
|
86885
|
+
"hostCredential"
|
|
86886
|
+
]), SAFE_TRUSTED_DIRECTORIES_KEYS = /* @__PURE__ */ new Set([
|
|
86887
|
+
"primary",
|
|
86888
|
+
"additional",
|
|
86889
|
+
"network",
|
|
86890
|
+
"block_reads_outside_working_directories"
|
|
86891
|
+
]), SAFE_TRUSTED_DIRECTORY_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
86892
|
+
"path",
|
|
86893
|
+
"resolved",
|
|
86894
|
+
"source"
|
|
86895
|
+
]), SAFE_RULES_KEYS = /* @__PURE__ */ new Set([
|
|
86896
|
+
"allow",
|
|
86897
|
+
"deny",
|
|
86898
|
+
"ask"
|
|
86899
|
+
]), SAFE_DROPPED_KEYS = /* @__PURE__ */ new Set([
|
|
86900
|
+
"allow",
|
|
86901
|
+
"deny",
|
|
86902
|
+
"ask",
|
|
86903
|
+
"auto_mode_allow",
|
|
86904
|
+
"auto_mode_soft_deny",
|
|
86905
|
+
"auto_mode_hard_deny",
|
|
86906
|
+
"auto_mode_environment"
|
|
86907
|
+
]), SAFE_RULE_ITEM_KEYS = /* @__PURE__ */ new Set([
|
|
86908
|
+
"rule",
|
|
86909
|
+
"canonical",
|
|
86910
|
+
"source",
|
|
86911
|
+
"root",
|
|
86912
|
+
"pattern"
|
|
86913
|
+
]), SAFE_AUTO_MODE_KEYS = /* @__PURE__ */ new Set([
|
|
86914
|
+
"allow",
|
|
86915
|
+
"soft_deny",
|
|
86916
|
+
"hard_deny",
|
|
86917
|
+
"environment"
|
|
86918
|
+
]), SAFE_GIT_STATE_KEYS = /* @__PURE__ */ new Set([
|
|
86919
|
+
"cwd",
|
|
86920
|
+
"root",
|
|
86921
|
+
"branch",
|
|
86922
|
+
"default_branch",
|
|
86923
|
+
"status",
|
|
86924
|
+
"visibility",
|
|
86925
|
+
"error",
|
|
86926
|
+
"truncated"
|
|
86927
|
+
]), SAFE_GIT_ERROR_VALUES = /* @__PURE__ */ new Set([
|
|
86928
|
+
"timeout",
|
|
86929
|
+
"not_a_repo",
|
|
86930
|
+
"error",
|
|
86931
|
+
"pending"
|
|
86932
|
+
]), SAFE_GIT_STATUS_KEYS = /* @__PURE__ */ new Set([
|
|
86933
|
+
"clean",
|
|
86934
|
+
"counts",
|
|
86935
|
+
"porcelain",
|
|
86936
|
+
"truncated"
|
|
86937
|
+
]), SAFE_GIT_COUNTS_KEYS = /* @__PURE__ */ new Set([
|
|
86938
|
+
"staged",
|
|
86939
|
+
"modified",
|
|
86940
|
+
"untracked",
|
|
86941
|
+
"untracked_normal"
|
|
86942
|
+
]), SAFE_GIT_VISIBILITY_KEYS = /* @__PURE__ */ new Set([
|
|
86943
|
+
"origin",
|
|
86944
|
+
"push_remote",
|
|
86945
|
+
"remotes",
|
|
86946
|
+
"visibility_cache"
|
|
86947
|
+
]), SAFE_GIT_REPO_VISIBILITY_VALUES = /* @__PURE__ */ new Set([
|
|
86948
|
+
"public",
|
|
86949
|
+
"private",
|
|
86950
|
+
"unknown"
|
|
86951
|
+
]), SAFE_GIT_ORIGIN_KEYS = /* @__PURE__ */ new Set([
|
|
86952
|
+
"host",
|
|
86953
|
+
"remote",
|
|
86954
|
+
"visibility"
|
|
86955
|
+
]), SAFE_GIT_REMOTE_KEYS = /* @__PURE__ */ new Set([
|
|
86956
|
+
"name",
|
|
86957
|
+
"host",
|
|
86958
|
+
"remote",
|
|
86959
|
+
"visibility"
|
|
86960
|
+
]), SAFE_CHROME_NAVIGATION_KEYS = /* @__PURE__ */ new Set([
|
|
86961
|
+
"enabled",
|
|
86962
|
+
"baselines",
|
|
86963
|
+
"tabs"
|
|
86964
|
+
]), SAFE_PRIOR_TURN_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
86965
|
+
"tool_use_ids",
|
|
86966
|
+
"context"
|
|
86967
|
+
]), SAFE_PRIOR_TURN_INNER_CONTEXT_KEYS = /* @__PURE__ */ new Set([
|
|
86968
|
+
"git_state",
|
|
86969
|
+
"chrome_navigation",
|
|
86970
|
+
"live_cwd",
|
|
86971
|
+
"platform"
|
|
86972
|
+
]), SAFE_SYSTEM_REMINDER_KEYS = /* @__PURE__ */ new Set([
|
|
86973
|
+
"id",
|
|
86974
|
+
"provenance",
|
|
86975
|
+
"author",
|
|
86976
|
+
"written"
|
|
86977
|
+
]), SAFE_ARTIFACTS_KEYS = /* @__PURE__ */ new Set([
|
|
86978
|
+
"by_slug",
|
|
86979
|
+
"by_path",
|
|
86980
|
+
"live_docs",
|
|
86981
|
+
"room_armed",
|
|
86982
|
+
"type_reads",
|
|
86983
|
+
"last_publish",
|
|
86984
|
+
"session",
|
|
86985
|
+
"truncated"
|
|
86986
|
+
]), SAFE_ARTIFACT_ENV_VALUES = /* @__PURE__ */ new Set([
|
|
86987
|
+
"prod",
|
|
86988
|
+
"staging"
|
|
86989
|
+
]), SAFE_ARTIFACT_WATCH_RAIL_VALUES = /* @__PURE__ */ new Set([
|
|
86990
|
+
"live",
|
|
86991
|
+
"durable",
|
|
86992
|
+
"none"
|
|
86993
|
+
]), SAFE_ARTIFACT_SLUG_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
86994
|
+
"share",
|
|
86995
|
+
"attested",
|
|
86996
|
+
"notice_pending",
|
|
86997
|
+
"published_env",
|
|
86998
|
+
"watch"
|
|
86999
|
+
]), SAFE_ARTIFACT_WATCH_KEYS = /* @__PURE__ */ new Set([
|
|
87000
|
+
"stopped",
|
|
87001
|
+
"auto_reply_stopped",
|
|
87002
|
+
"auto_reply_swept",
|
|
87003
|
+
"replies_declined"
|
|
87004
|
+
]), SAFE_ARTIFACT_SHARE_KEYS = /* @__PURE__ */ new Set([
|
|
87005
|
+
"mode",
|
|
87006
|
+
"is_shared_live",
|
|
87007
|
+
"role",
|
|
87008
|
+
"probe_failed",
|
|
87009
|
+
"probed",
|
|
87010
|
+
"probe_current_account",
|
|
87011
|
+
"cowritten",
|
|
87012
|
+
"outside_writer",
|
|
87013
|
+
"artifact_kind",
|
|
87014
|
+
"type_locked",
|
|
87015
|
+
"type_lock",
|
|
87016
|
+
"type_first_party",
|
|
87017
|
+
"caps_read_not_found",
|
|
87018
|
+
"live_paths",
|
|
87019
|
+
"capabilities",
|
|
87020
|
+
"capabilities_unknown",
|
|
87021
|
+
"capabilities_cut",
|
|
87022
|
+
"grant_observed"
|
|
87023
|
+
]), SAFE_ARTIFACT_SHARE_TRUE_LITERAL_KEYS = [
|
|
87024
|
+
"probe_failed",
|
|
87025
|
+
"cowritten",
|
|
87026
|
+
"outside_writer",
|
|
87027
|
+
"type_locked",
|
|
87028
|
+
"type_first_party",
|
|
87029
|
+
"caps_read_not_found",
|
|
87030
|
+
"capabilities_unknown",
|
|
87031
|
+
"capabilities_cut"
|
|
87032
|
+
], SAFE_ARTIFACT_PATH_ENTRY_KEYS = /* @__PURE__ */ new Set([
|
|
87033
|
+
"slug",
|
|
87034
|
+
"thumbnail_named"
|
|
87035
|
+
]), SAFE_ARTIFACT_LIVE_DOC_KEYS = /* @__PURE__ */ new Set([
|
|
87036
|
+
"slug",
|
|
87037
|
+
"live_path",
|
|
87038
|
+
"working_copy"
|
|
87039
|
+
]), SAFE_ARTIFACT_TYPE_READ_KEYS = /* @__PURE__ */ new Set([
|
|
87040
|
+
"declares_room"
|
|
87041
|
+
]), SAFE_ARTIFACT_LAST_PUBLISH_KEYS = /* @__PURE__ */ new Set([
|
|
87042
|
+
"slug",
|
|
87043
|
+
"env"
|
|
87044
|
+
]), SAFE_ARTIFACT_SESSION_KEYS = /* @__PURE__ */ new Set([
|
|
87045
|
+
"frame_env",
|
|
87046
|
+
"viewer_origin",
|
|
87047
|
+
"dev_viewer_origin",
|
|
87048
|
+
"toolset",
|
|
87049
|
+
"short_links",
|
|
87050
|
+
"ant_build",
|
|
87051
|
+
"live_edit",
|
|
87052
|
+
"live_doc_stream",
|
|
87053
|
+
"live_paths_schema",
|
|
87054
|
+
"copy_from",
|
|
87055
|
+
"types_on",
|
|
87056
|
+
"five_class_asks",
|
|
87057
|
+
"inherited_type_grant",
|
|
87058
|
+
"watch_rail",
|
|
87059
|
+
"auto_react",
|
|
87060
|
+
"comments_in_schema",
|
|
87061
|
+
"db_str_replace",
|
|
87062
|
+
"handlers",
|
|
87063
|
+
"room_client",
|
|
87064
|
+
"eval_stub",
|
|
87065
|
+
"scratchpad_dir",
|
|
87066
|
+
"tool_results_dir"
|
|
87067
|
+
]), SAFE_ARTIFACT_SESSION_REQUIRED_BOOLEAN_KEYS = [
|
|
87068
|
+
"ant_build",
|
|
87069
|
+
"comments_in_schema",
|
|
87070
|
+
"handlers",
|
|
87071
|
+
"room_client",
|
|
87072
|
+
"eval_stub"
|
|
87073
|
+
], SAFE_ARTIFACT_SESSION_OPTIONAL_BOOLEAN_KEYS = [
|
|
87074
|
+
"toolset",
|
|
87075
|
+
"short_links",
|
|
87076
|
+
"live_edit",
|
|
87077
|
+
"live_doc_stream",
|
|
87078
|
+
"live_paths_schema",
|
|
87079
|
+
"copy_from",
|
|
87080
|
+
"types_on",
|
|
87081
|
+
"five_class_asks",
|
|
87082
|
+
"auto_react",
|
|
87083
|
+
"db_str_replace"
|
|
87084
|
+
], MAX_SAFEGUARDS_ENTRIES = 16;
|
|
87085
|
+
function isPlainObject(val) {
|
|
87086
|
+
return val !== null && typeof val == "object" && !Array.isArray(val);
|
|
87087
|
+
}
|
|
87088
|
+
function isFiniteNumber(val) {
|
|
87089
|
+
return typeof val == "number" && Number.isFinite(val);
|
|
87090
|
+
}
|
|
87091
|
+
function isStringArray(val) {
|
|
87092
|
+
return Array.isArray(val) && val.every((item2) => typeof item2 == "string");
|
|
87093
|
+
}
|
|
87094
|
+
function isStringRecord(val) {
|
|
87095
|
+
if (!isPlainObject(val)) return !1;
|
|
87096
|
+
for (let k of Object.keys(val))
|
|
87097
|
+
if (typeof val[k] != "string") return !1;
|
|
87098
|
+
return !0;
|
|
87099
|
+
}
|
|
87100
|
+
function isValidTrustedDirEntry(val) {
|
|
87101
|
+
if (!isPlainObject(val)) return !1;
|
|
87102
|
+
let keys = Object.keys(val);
|
|
87103
|
+
for (let k of keys)
|
|
87104
|
+
if (!SAFE_TRUSTED_DIRECTORY_ENTRY_KEYS.has(k)) return !1;
|
|
87105
|
+
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");
|
|
87106
|
+
}
|
|
87107
|
+
function isValidGitOriginOrCacheEntry(val) {
|
|
87108
|
+
if (!isPlainObject(val)) return !1;
|
|
87109
|
+
for (let k of Object.keys(val))
|
|
87110
|
+
if (!SAFE_GIT_ORIGIN_KEYS.has(k)) return !1;
|
|
87111
|
+
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));
|
|
87112
|
+
}
|
|
87113
|
+
function isValidGitRemoteEntry(val) {
|
|
87114
|
+
if (!isPlainObject(val)) return !1;
|
|
87115
|
+
for (let k of Object.keys(val))
|
|
87116
|
+
if (!SAFE_GIT_REMOTE_KEYS.has(k)) return !1;
|
|
87117
|
+
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));
|
|
87118
|
+
}
|
|
87119
|
+
function isValidGitState(val) {
|
|
87120
|
+
if (!isPlainObject(val)) return !1;
|
|
87121
|
+
for (let gk of Object.keys(val)) {
|
|
87122
|
+
if (!SAFE_GIT_STATE_KEYS.has(gk)) return !1;
|
|
87123
|
+
let gv = val[gk];
|
|
87124
|
+
if (gk === "cwd" || gk === "root" || gk === "branch" || gk === "default_branch") {
|
|
87125
|
+
if (gv != null && typeof gv != "string") return !1;
|
|
87126
|
+
} else if (gk === "error") {
|
|
87127
|
+
if (gv != null && (typeof gv != "string" || !SAFE_GIT_ERROR_VALUES.has(gv)))
|
|
87128
|
+
return !1;
|
|
87129
|
+
} else if (gk === "truncated") {
|
|
87130
|
+
if (gv !== void 0 && typeof gv != "boolean") return !1;
|
|
87131
|
+
} else if (gk === "status") {
|
|
87132
|
+
if (gv != null) {
|
|
87133
|
+
if (!isPlainObject(gv)) return !1;
|
|
87134
|
+
for (let sk of Object.keys(gv))
|
|
87135
|
+
if (!SAFE_GIT_STATUS_KEYS.has(sk)) return !1;
|
|
87136
|
+
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;
|
|
87137
|
+
if (gv.counts !== null) {
|
|
87138
|
+
if (!isPlainObject(gv.counts)) return !1;
|
|
87139
|
+
for (let ck of Object.keys(gv.counts))
|
|
87140
|
+
if (!SAFE_GIT_COUNTS_KEYS.has(ck)) return !1;
|
|
87141
|
+
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))
|
|
87142
|
+
return !1;
|
|
87143
|
+
}
|
|
87144
|
+
}
|
|
87145
|
+
} else if (gk === "visibility" && gv != null) {
|
|
87146
|
+
if (!isPlainObject(gv)) return !1;
|
|
87147
|
+
for (let vk of Object.keys(gv))
|
|
87148
|
+
if (!SAFE_GIT_VISIBILITY_KEYS.has(vk)) return !1;
|
|
87149
|
+
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))
|
|
87150
|
+
return !1;
|
|
87151
|
+
}
|
|
87152
|
+
}
|
|
87153
|
+
return !0;
|
|
87154
|
+
}
|
|
87155
|
+
function isValidChromeNavigation(val) {
|
|
87156
|
+
if (!isPlainObject(val)) return !1;
|
|
87157
|
+
for (let ck of Object.keys(val))
|
|
87158
|
+
if (!SAFE_CHROME_NAVIGATION_KEYS.has(ck)) return !1;
|
|
87159
|
+
if (!hasOwn(val, "enabled") || typeof val.enabled != "boolean" || !hasOwn(val, "baselines") || !isStringRecord(val.baselines)) return !1;
|
|
87160
|
+
if (hasOwn(val, "tabs") && val.tabs !== void 0) {
|
|
87161
|
+
if (!isPlainObject(val.tabs)) return !1;
|
|
87162
|
+
for (let tk of Object.keys(val.tabs))
|
|
87163
|
+
if (!isStringRecord(val.tabs[tk])) return !1;
|
|
87164
|
+
}
|
|
87165
|
+
return !0;
|
|
87166
|
+
}
|
|
87167
|
+
var SAFE_ARTIFACT_RULE_CAPABILITY_KEYS = /* @__PURE__ */ new Set([
|
|
87168
|
+
"artifact",
|
|
87169
|
+
"self",
|
|
87170
|
+
"downloads",
|
|
87171
|
+
"comments",
|
|
87172
|
+
"room",
|
|
87173
|
+
"db",
|
|
87174
|
+
"assets"
|
|
87175
|
+
]), SAFE_ARTIFACT_CAPABILITY_KEYS = /* @__PURE__ */ new Set([
|
|
87176
|
+
...SAFE_ARTIFACT_RULE_CAPABILITY_KEYS,
|
|
87177
|
+
"user",
|
|
87178
|
+
"mcp",
|
|
87179
|
+
"flags"
|
|
87180
|
+
]), 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([
|
|
87181
|
+
"view",
|
|
87182
|
+
"interact",
|
|
87183
|
+
"admin",
|
|
87184
|
+
"owner"
|
|
87185
|
+
]), SAFE_ARTIFACT_USER_CAP_KEYS = /* @__PURE__ */ new Set(["scopes"]), SAFE_ARTIFACT_USER_SCOPE_RE = /^[a-z][a-z0-9_-]{0,31}$/;
|
|
87186
|
+
function isValidArtifactCapabilityRules(val) {
|
|
87187
|
+
if (!Array.isArray(val)) return !1;
|
|
87188
|
+
for (let rule of val) {
|
|
87189
|
+
if (!isPlainObject(rule)) return !1;
|
|
87190
|
+
for (let rk of Object.keys(rule))
|
|
87191
|
+
if (!SAFE_ARTIFACT_RULE_ENTRY_KEYS.has(rk)) return !1;
|
|
87192
|
+
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)))
|
|
87193
|
+
return !1;
|
|
87194
|
+
}
|
|
87195
|
+
return !0;
|
|
87196
|
+
}
|
|
87197
|
+
function isValidArtifactCapabilityEntry(capKey, capVal) {
|
|
87198
|
+
if (!SAFE_ARTIFACT_CAPABILITY_KEYS.has(capKey) || !isPlainObject(capVal)) return !1;
|
|
87199
|
+
if (capKey === "mcp") {
|
|
87200
|
+
for (let mk of Object.keys(capVal))
|
|
87201
|
+
if (!SAFE_ARTIFACT_MCP_CAP_KEYS.has(mk)) return !1;
|
|
87202
|
+
if (hasOwn(capVal, "dynamic") && capVal.dynamic !== void 0 && typeof capVal.dynamic != "boolean")
|
|
87203
|
+
return !1;
|
|
87204
|
+
if (hasOwn(capVal, "servers") && capVal.servers !== void 0) {
|
|
87205
|
+
if (!Array.isArray(capVal.servers) || capVal.servers.length > MAX_ARTIFACT_MCP_SERVERS || capVal.servers.length === 0 && capVal.dynamic !== !0)
|
|
87206
|
+
return !1;
|
|
87207
|
+
for (let srv of capVal.servers) {
|
|
87208
|
+
if (!isPlainObject(srv)) return !1;
|
|
87209
|
+
for (let sk of Object.keys(srv))
|
|
87210
|
+
if (!SAFE_ARTIFACT_MCP_SERVER_KEYS.has(sk)) return !1;
|
|
87211
|
+
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)))
|
|
87212
|
+
return !1;
|
|
87213
|
+
}
|
|
87214
|
+
}
|
|
87215
|
+
return !0;
|
|
87216
|
+
}
|
|
87217
|
+
if (capKey === "user") {
|
|
87218
|
+
for (let uk of Object.keys(capVal))
|
|
87219
|
+
if (!SAFE_ARTIFACT_USER_CAP_KEYS.has(uk)) return !1;
|
|
87220
|
+
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))));
|
|
87221
|
+
}
|
|
87222
|
+
if (SAFE_ARTIFACT_RULE_CAPABILITY_KEYS.has(capKey)) {
|
|
87223
|
+
for (let dk of Object.keys(capVal))
|
|
87224
|
+
if (!SAFE_ARTIFACT_RULE_OBJECT_KEYS.has(dk)) return !1;
|
|
87225
|
+
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))));
|
|
87226
|
+
}
|
|
87227
|
+
for (let fk of Object.keys(capVal)) {
|
|
87228
|
+
if (!SAFE_ARTIFACT_USER_SCOPE_RE.test(fk)) return !1;
|
|
87229
|
+
let fv = capVal[fk];
|
|
87230
|
+
if (fv !== null && typeof fv != "string" && typeof fv != "boolean" && !isFiniteNumber(fv))
|
|
87231
|
+
return !1;
|
|
87232
|
+
}
|
|
87233
|
+
return !0;
|
|
87234
|
+
}
|
|
87235
|
+
function isValidArtifactShare(val) {
|
|
87236
|
+
if (!isPlainObject(val)) return !1;
|
|
87237
|
+
for (let k of Object.keys(val))
|
|
87238
|
+
if (!SAFE_ARTIFACT_SHARE_KEYS.has(k)) return !1;
|
|
87239
|
+
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")
|
|
87240
|
+
return !1;
|
|
87241
|
+
for (let tk of SAFE_ARTIFACT_SHARE_TRUE_LITERAL_KEYS)
|
|
87242
|
+
if (hasOwn(val, tk) && val[tk] !== void 0 && val[tk] !== !0) return !1;
|
|
87243
|
+
if (hasOwn(val, "live_paths") && val.live_paths !== void 0 && !isStringArray(val.live_paths))
|
|
87244
|
+
return !1;
|
|
87245
|
+
if (hasOwn(val, "capabilities") && val.capabilities !== void 0) {
|
|
87246
|
+
if (!isPlainObject(val.capabilities) || Buffer.byteLength(JSON.stringify(val.capabilities), "utf8") > MAX_ARTIFACT_CAPABILITIES_BYTES)
|
|
87247
|
+
return !1;
|
|
87248
|
+
for (let capKey of Object.keys(val.capabilities))
|
|
87249
|
+
if (!isValidArtifactCapabilityEntry(capKey, val.capabilities[capKey]))
|
|
87250
|
+
return !1;
|
|
87251
|
+
}
|
|
87252
|
+
return !0;
|
|
87253
|
+
}
|
|
87254
|
+
function isValidArtifacts(val) {
|
|
87255
|
+
if (!isPlainObject(val)) return !1;
|
|
87256
|
+
for (let artk of Object.keys(val))
|
|
87257
|
+
if (!SAFE_ARTIFACTS_KEYS.has(artk)) return !1;
|
|
87258
|
+
if (!hasOwn(val, "by_slug") || !isPlainObject(val.by_slug)) return !1;
|
|
87259
|
+
for (let slugKey of Object.keys(val.by_slug)) {
|
|
87260
|
+
let slugEntry = val.by_slug[slugKey];
|
|
87261
|
+
if (!isPlainObject(slugEntry)) return !1;
|
|
87262
|
+
for (let sek of Object.keys(slugEntry))
|
|
87263
|
+
if (!SAFE_ARTIFACT_SLUG_ENTRY_KEYS.has(sek)) return !1;
|
|
87264
|
+
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)))
|
|
87265
|
+
return !1;
|
|
87266
|
+
if (hasOwn(slugEntry, "watch") && slugEntry.watch !== void 0) {
|
|
87267
|
+
if (!isPlainObject(slugEntry.watch)) return !1;
|
|
87268
|
+
for (let wk of Object.keys(slugEntry.watch))
|
|
87269
|
+
if (!SAFE_ARTIFACT_WATCH_KEYS.has(wk) || slugEntry.watch[wk] !== void 0 && slugEntry.watch[wk] !== !0) return !1;
|
|
87270
|
+
}
|
|
87271
|
+
}
|
|
87272
|
+
if (!hasOwn(val, "by_path") || !isPlainObject(val.by_path)) return !1;
|
|
87273
|
+
for (let pathKey of Object.keys(val.by_path)) {
|
|
87274
|
+
let pathEntry = val.by_path[pathKey];
|
|
87275
|
+
if (!isPlainObject(pathEntry)) return !1;
|
|
87276
|
+
for (let pek of Object.keys(pathEntry))
|
|
87277
|
+
if (!SAFE_ARTIFACT_PATH_ENTRY_KEYS.has(pek)) return !1;
|
|
87278
|
+
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))
|
|
87279
|
+
return !1;
|
|
87280
|
+
}
|
|
87281
|
+
if (!hasOwn(val, "live_docs") || !Array.isArray(val.live_docs)) return !1;
|
|
87282
|
+
for (let doc of val.live_docs) {
|
|
87283
|
+
if (!isPlainObject(doc)) return !1;
|
|
87284
|
+
for (let dk of Object.keys(doc))
|
|
87285
|
+
if (!SAFE_ARTIFACT_LIVE_DOC_KEYS.has(dk)) return !1;
|
|
87286
|
+
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")
|
|
87287
|
+
return !1;
|
|
87288
|
+
}
|
|
87289
|
+
if (!hasOwn(val, "room_armed") || !isStringArray(val.room_armed) || !hasOwn(val, "type_reads") || !isPlainObject(val.type_reads)) return !1;
|
|
87290
|
+
for (let trKey of Object.keys(val.type_reads)) {
|
|
87291
|
+
let trEntry = val.type_reads[trKey];
|
|
87292
|
+
if (!isPlainObject(trEntry)) return !1;
|
|
87293
|
+
for (let trk of Object.keys(trEntry))
|
|
87294
|
+
if (!SAFE_ARTIFACT_TYPE_READ_KEYS.has(trk)) return !1;
|
|
87295
|
+
if (!hasOwn(trEntry, "declares_room") || typeof trEntry.declares_room != "boolean")
|
|
87296
|
+
return !1;
|
|
87297
|
+
}
|
|
87298
|
+
if (hasOwn(val, "last_publish") && val.last_publish !== void 0) {
|
|
87299
|
+
let lp = val.last_publish;
|
|
87300
|
+
if (!isPlainObject(lp)) return !1;
|
|
87301
|
+
for (let lpk of Object.keys(lp))
|
|
87302
|
+
if (!SAFE_ARTIFACT_LAST_PUBLISH_KEYS.has(lpk)) return !1;
|
|
87303
|
+
if (!hasOwn(lp, "slug") || typeof lp.slug != "string" || !hasOwn(lp, "env") || typeof lp.env != "string" || !SAFE_ARTIFACT_ENV_VALUES.has(lp.env))
|
|
87304
|
+
return !1;
|
|
87305
|
+
}
|
|
87306
|
+
if (!hasOwn(val, "session") || !isPlainObject(val.session)) return !1;
|
|
87307
|
+
let sess = val.session;
|
|
87308
|
+
for (let sk of Object.keys(sess))
|
|
87309
|
+
if (!SAFE_ARTIFACT_SESSION_KEYS.has(sk)) return !1;
|
|
87310
|
+
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")
|
|
87311
|
+
return !1;
|
|
87312
|
+
for (let reqBool of SAFE_ARTIFACT_SESSION_REQUIRED_BOOLEAN_KEYS)
|
|
87313
|
+
if (!hasOwn(sess, reqBool) || typeof sess[reqBool] != "boolean") return !1;
|
|
87314
|
+
for (let optBool of SAFE_ARTIFACT_SESSION_OPTIONAL_BOOLEAN_KEYS)
|
|
87315
|
+
if (hasOwn(sess, optBool) && sess[optBool] !== void 0 && typeof sess[optBool] != "boolean")
|
|
87316
|
+
return !1;
|
|
87317
|
+
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");
|
|
87318
|
+
}
|
|
87319
|
+
function validateCanonicalSafeguards(safeguards) {
|
|
87320
|
+
if (!Array.isArray(safeguards) || safeguards.length > MAX_SAFEGUARDS_ENTRIES)
|
|
87321
|
+
throw new CanonicalRejectError("safeguards is not a canonical dangerous_tool_use array");
|
|
87322
|
+
for (let entry5 of safeguards) {
|
|
87323
|
+
if (!isPlainObject(entry5))
|
|
87324
|
+
throw new CanonicalRejectError("safeguards entry is not a plain object");
|
|
87325
|
+
for (let k of Object.keys(entry5))
|
|
87326
|
+
if (!SAFE_SAFEGUARD_ENTRY_KEYS.has(k))
|
|
87327
|
+
throw new CanonicalRejectError("safeguards entry contains unsupported key");
|
|
87328
|
+
if (!hasOwn(entry5, "type") || entry5.type !== "dangerous_tool_use")
|
|
87329
|
+
throw new CanonicalRejectError("safeguards entry type is not dangerous_tool_use");
|
|
87330
|
+
if (hasOwn(entry5, "classifier_context") && entry5.classifier_context !== void 0) {
|
|
87331
|
+
let ctx = entry5.classifier_context;
|
|
87332
|
+
if (!isPlainObject(ctx))
|
|
87333
|
+
throw new CanonicalRejectError("safeguards classifier_context is not a plain object");
|
|
87334
|
+
for (let ck of Object.keys(ctx))
|
|
87335
|
+
if (!SAFE_CLASSIFIER_CONTEXT_KEYS.has(ck))
|
|
87336
|
+
throw new CanonicalRejectError("safeguards classifier_context contains unsupported key");
|
|
87337
|
+
if (hasOwn(ctx, "v") && ctx.v !== void 0 && !isFiniteNumber(ctx.v))
|
|
87338
|
+
throw new CanonicalRejectError("safeguards classifier_context.v is not a finite number");
|
|
87339
|
+
for (let sk of CLASSIFIER_STRING_KEYS)
|
|
87340
|
+
if (hasOwn(ctx, sk) && ctx[sk] !== void 0 && typeof ctx[sk] != "string")
|
|
87341
|
+
throw new CanonicalRejectError("safeguards classifier_context string field is invalid");
|
|
87342
|
+
for (let bk of CLASSIFIER_BOOLEAN_KEYS)
|
|
87343
|
+
if (hasOwn(ctx, bk) && ctx[bk] !== void 0 && typeof ctx[bk] != "boolean")
|
|
87344
|
+
throw new CanonicalRejectError("safeguards classifier_context boolean field is invalid");
|
|
87345
|
+
if (hasOwn(ctx, "user_identity") && ctx.user_identity !== void 0 && ctx.user_identity !== null && typeof ctx.user_identity != "string")
|
|
87346
|
+
throw new CanonicalRejectError("safeguards classifier_context.user_identity is invalid");
|
|
87347
|
+
if (hasOwn(ctx, "rule_roots") && ctx.rule_roots !== void 0) {
|
|
87348
|
+
if (!isPlainObject(ctx.rule_roots))
|
|
87349
|
+
throw new CanonicalRejectError("safeguards classifier_context.rule_roots is invalid");
|
|
87350
|
+
for (let rk of Object.keys(ctx.rule_roots)) {
|
|
87351
|
+
let rv = ctx.rule_roots[rk];
|
|
87352
|
+
if (!SAFE_RULE_ROOT_KEYS.has(rk) || rv !== null && typeof rv != "string")
|
|
87353
|
+
throw new CanonicalRejectError("safeguards classifier_context.rule_roots is invalid");
|
|
87354
|
+
}
|
|
87355
|
+
}
|
|
87356
|
+
if (hasOwn(ctx, "trusted_directories") && ctx.trusted_directories !== void 0) {
|
|
87357
|
+
if (!isPlainObject(ctx.trusted_directories))
|
|
87358
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87359
|
+
let td = ctx.trusted_directories;
|
|
87360
|
+
for (let tk of Object.keys(td))
|
|
87361
|
+
if (!SAFE_TRUSTED_DIRECTORIES_KEYS.has(tk))
|
|
87362
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87363
|
+
if (hasOwn(td, "primary") && td.primary !== void 0 && td.primary !== null && !isValidTrustedDirEntry(td.primary))
|
|
87364
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87365
|
+
if (hasOwn(td, "additional") && td.additional !== void 0 && (!Array.isArray(td.additional) || !td.additional.every((item2) => typeof item2 == "string" || isValidTrustedDirEntry(item2))))
|
|
87366
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87367
|
+
if (hasOwn(td, "network") && td.network !== void 0 && !isStringArray(td.network))
|
|
87368
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87369
|
+
if (hasOwn(td, "block_reads_outside_working_directories") && td.block_reads_outside_working_directories !== void 0 && typeof td.block_reads_outside_working_directories != "boolean")
|
|
87370
|
+
throw new CanonicalRejectError("safeguards classifier_context.trusted_directories is invalid");
|
|
87371
|
+
}
|
|
87372
|
+
if (hasOwn(ctx, "rules") && ctx.rules !== void 0) {
|
|
87373
|
+
if (!isPlainObject(ctx.rules))
|
|
87374
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87375
|
+
for (let rlk of Object.keys(ctx.rules)) {
|
|
87376
|
+
let rlv = ctx.rules[rlk];
|
|
87377
|
+
if (!SAFE_RULES_KEYS.has(rlk) || !Array.isArray(rlv))
|
|
87378
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87379
|
+
for (let item2 of rlv) {
|
|
87380
|
+
if (!isPlainObject(item2))
|
|
87381
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87382
|
+
for (let ik of Object.keys(item2))
|
|
87383
|
+
if (!SAFE_RULE_ITEM_KEYS.has(ik))
|
|
87384
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87385
|
+
if (!hasOwn(item2, "rule") || typeof item2.rule != "string" || !hasOwn(item2, "source") || typeof item2.source != "string")
|
|
87386
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87387
|
+
if (hasOwn(item2, "canonical") && item2.canonical !== void 0 && typeof item2.canonical != "string")
|
|
87388
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87389
|
+
if (hasOwn(item2, "root") && item2.root !== void 0 && item2.root !== null && typeof item2.root != "string")
|
|
87390
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87391
|
+
if (hasOwn(item2, "pattern") && item2.pattern !== void 0 && typeof item2.pattern != "string")
|
|
87392
|
+
throw new CanonicalRejectError("safeguards classifier_context.rules is invalid");
|
|
87393
|
+
}
|
|
87394
|
+
}
|
|
87395
|
+
}
|
|
87396
|
+
if (hasOwn(ctx, "dropped") && ctx.dropped !== void 0) {
|
|
87397
|
+
if (!isPlainObject(ctx.dropped))
|
|
87398
|
+
throw new CanonicalRejectError("safeguards classifier_context.dropped is invalid");
|
|
87399
|
+
for (let dk of Object.keys(ctx.dropped)) {
|
|
87400
|
+
let dv = ctx.dropped[dk];
|
|
87401
|
+
if (!SAFE_DROPPED_KEYS.has(dk) || !isFiniteNumber(dv))
|
|
87402
|
+
throw new CanonicalRejectError("safeguards classifier_context.dropped is invalid");
|
|
87403
|
+
}
|
|
87404
|
+
}
|
|
87405
|
+
if (hasOwn(ctx, "auto_mode") && ctx.auto_mode !== void 0) {
|
|
87406
|
+
if (!isPlainObject(ctx.auto_mode))
|
|
87407
|
+
throw new CanonicalRejectError("safeguards classifier_context.auto_mode is invalid");
|
|
87408
|
+
for (let ak of Object.keys(ctx.auto_mode))
|
|
87409
|
+
if (!SAFE_AUTO_MODE_KEYS.has(ak) || !isStringArray(ctx.auto_mode[ak]))
|
|
87410
|
+
throw new CanonicalRejectError("safeguards classifier_context.auto_mode is invalid");
|
|
87411
|
+
}
|
|
87412
|
+
if (hasOwn(ctx, "git_state") && ctx.git_state !== void 0 && ctx.git_state !== null && !isValidGitState(ctx.git_state))
|
|
87413
|
+
throw new CanonicalRejectError("safeguards classifier_context.git_state is invalid");
|
|
87414
|
+
if (hasOwn(ctx, "chrome_navigation") && ctx.chrome_navigation !== void 0 && !isValidChromeNavigation(ctx.chrome_navigation))
|
|
87415
|
+
throw new CanonicalRejectError("safeguards classifier_context.chrome_navigation is invalid");
|
|
87416
|
+
if (hasOwn(ctx, "prior_turn_context") && ctx.prior_turn_context !== void 0) {
|
|
87417
|
+
if (!Array.isArray(ctx.prior_turn_context))
|
|
87418
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87419
|
+
for (let pt of ctx.prior_turn_context) {
|
|
87420
|
+
if (!isPlainObject(pt))
|
|
87421
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87422
|
+
for (let ptk of Object.keys(pt))
|
|
87423
|
+
if (!SAFE_PRIOR_TURN_ENTRY_KEYS.has(ptk))
|
|
87424
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87425
|
+
if (!hasOwn(pt, "tool_use_ids") || !isStringArray(pt.tool_use_ids))
|
|
87426
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87427
|
+
if (!hasOwn(pt, "context") || !isPlainObject(pt.context))
|
|
87428
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87429
|
+
for (let icKey of Object.keys(pt.context))
|
|
87430
|
+
if (!SAFE_PRIOR_TURN_INNER_CONTEXT_KEYS.has(icKey))
|
|
87431
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87432
|
+
if (hasOwn(pt.context, "git_state") && pt.context.git_state !== void 0 && pt.context.git_state !== null && !isValidGitState(pt.context.git_state))
|
|
87433
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87434
|
+
if (hasOwn(pt.context, "chrome_navigation") && pt.context.chrome_navigation !== void 0 && !isValidChromeNavigation(pt.context.chrome_navigation))
|
|
87435
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87436
|
+
if (hasOwn(pt.context, "live_cwd") && pt.context.live_cwd !== void 0 && typeof pt.context.live_cwd != "string")
|
|
87437
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87438
|
+
if (hasOwn(pt.context, "platform") && pt.context.platform !== void 0 && typeof pt.context.platform != "string")
|
|
87439
|
+
throw new CanonicalRejectError("safeguards classifier_context.prior_turn_context is invalid");
|
|
87440
|
+
}
|
|
87441
|
+
}
|
|
87442
|
+
if (hasOwn(ctx, "system_reminders") && ctx.system_reminders !== void 0) {
|
|
87443
|
+
if (!Array.isArray(ctx.system_reminders))
|
|
87444
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87445
|
+
for (let sr of ctx.system_reminders) {
|
|
87446
|
+
if (!isPlainObject(sr))
|
|
87447
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87448
|
+
for (let srk of Object.keys(sr))
|
|
87449
|
+
if (!SAFE_SYSTEM_REMINDER_KEYS.has(srk))
|
|
87450
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87451
|
+
if (!hasOwn(sr, "id") || typeof sr.id != "string" || !hasOwn(sr, "provenance") || typeof sr.provenance != "string")
|
|
87452
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87453
|
+
if (hasOwn(sr, "author") && sr.author !== void 0 && typeof sr.author != "string")
|
|
87454
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87455
|
+
if (hasOwn(sr, "written") && sr.written !== void 0 && typeof sr.written != "string")
|
|
87456
|
+
throw new CanonicalRejectError("safeguards classifier_context.system_reminders is invalid");
|
|
87457
|
+
}
|
|
87458
|
+
}
|
|
87459
|
+
if (hasOwn(ctx, "artifacts") && ctx.artifacts !== void 0 && !isValidArtifacts(ctx.artifacts))
|
|
87460
|
+
throw new CanonicalRejectError("safeguards classifier_context.artifacts is invalid");
|
|
87461
|
+
if (hasOwn(ctx, "shed") && ctx.shed !== void 0 && !isStringArray(ctx.shed))
|
|
87462
|
+
throw new CanonicalRejectError("safeguards classifier_context.shed is invalid");
|
|
87463
|
+
}
|
|
87464
|
+
}
|
|
87465
|
+
}
|
|
86814
87466
|
function canonicalBetaHeader(provider, agentHeaders) {
|
|
86815
87467
|
let cfg = getProviderConfig(provider);
|
|
86816
87468
|
if (!cfg.betaHeaderName) return {};
|
|
@@ -86831,6 +87483,7 @@ function buildCanonicalRequest(input) {
|
|
|
86831
87483
|
if (typeof model != "string" || !CANONICAL_MODEL_ID.test(model))
|
|
86832
87484
|
throw new CanonicalRejectError("model is not a canonical model id");
|
|
86833
87485
|
}
|
|
87486
|
+
provider === "anthropic" && hasOwn(body, "safeguards") && validateCanonicalSafeguards(body.safeguards);
|
|
86834
87487
|
let modelCallId = (0, import_node_crypto35.randomUUID)(), sha = requestSha256(body), headers = {
|
|
86835
87488
|
...cfg.synthesizedHeaders,
|
|
86836
87489
|
...canonicalBetaHeader(provider, input.agentHeaders)
|
|
@@ -87354,7 +88007,10 @@ var LocalModelGatewayBroker = class {
|
|
|
87354
88007
|
});
|
|
87355
88008
|
} catch (err) {
|
|
87356
88009
|
if (err instanceof CanonicalRejectError)
|
|
87357
|
-
return
|
|
88010
|
+
return logger.warn("[broker] rejected non-canonical model request", {
|
|
88011
|
+
provider,
|
|
88012
|
+
reason: err.reason
|
|
88013
|
+
}), { status: 400, body: { error: err.reason } };
|
|
87358
88014
|
throw err;
|
|
87359
88015
|
}
|
|
87360
88016
|
let { modelCallId, requestSha256: reqSha } = canonical, selfSecrets = [
|