@quantiya/codevibe-codex-plugin 2.0.73 → 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/index.js +519 -519
- package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/cli.js +657 -4
- 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
|
@@ -76689,7 +76689,7 @@ async function runLocalDecomposer(deps, brief, availableAgents, repoContext) {
|
|
|
76689
76689
|
timeoutMs: null,
|
|
76690
76690
|
stdinTty: !0,
|
|
76691
76691
|
stdinPayload: prompt
|
|
76692
|
-
}), 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;
|
|
76693
76693
|
return { text: text2, providerError };
|
|
76694
76694
|
};
|
|
76695
76695
|
try {
|
|
@@ -76705,7 +76705,10 @@ async function runLocalDecomposer(deps, brief, availableAgents, repoContext) {
|
|
|
76705
76705
|
agent,
|
|
76706
76706
|
attempt: 2,
|
|
76707
76707
|
...describeDecomposerReply(second.text, second)
|
|
76708
|
-
}), {
|
|
76708
|
+
}), {
|
|
76709
|
+
decompose: !1,
|
|
76710
|
+
reason: second.providerError ? "decomposer provider error" : "decomposer output could not be parsed"
|
|
76711
|
+
});
|
|
76709
76712
|
} catch (err) {
|
|
76710
76713
|
return logger.warn("[team-decompose] decomposer spawn failed \u2014 single-task fallback", {
|
|
76711
76714
|
agent,
|
|
@@ -86635,7 +86638,17 @@ var ANTHROPIC_VERSION = "2023-06-01", ANTHROPIC_BETA_ALLOWLIST = /* @__PURE__ */
|
|
|
86635
86638
|
// Note: advisor-tool-2026-03-01 is deliberately EXCLUDED (unneeded and prevents account-billed advisor tool invocation).
|
|
86636
86639
|
"thinking-token-count-2026-05-13",
|
|
86637
86640
|
"per-turn-control-2026-07-01",
|
|
86638
|
-
"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"
|
|
86639
86652
|
]), PROVIDER_CONFIGS = {
|
|
86640
86653
|
anthropic: {
|
|
86641
86654
|
upstreamBaseUrl: "https://api.anthropic.com",
|
|
@@ -86811,6 +86824,642 @@ function hasOwn(obj, key) {
|
|
|
86811
86824
|
function requestSha256(body) {
|
|
86812
86825
|
return (0, import_node_crypto35.createHash)("sha256").update(JSON.stringify(body)).digest("hex");
|
|
86813
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
|
+
}
|
|
86814
87463
|
function canonicalBetaHeader(provider, agentHeaders) {
|
|
86815
87464
|
let cfg = getProviderConfig(provider);
|
|
86816
87465
|
if (!cfg.betaHeaderName) return {};
|
|
@@ -86831,6 +87480,7 @@ function buildCanonicalRequest(input) {
|
|
|
86831
87480
|
if (typeof model != "string" || !CANONICAL_MODEL_ID.test(model))
|
|
86832
87481
|
throw new CanonicalRejectError("model is not a canonical model id");
|
|
86833
87482
|
}
|
|
87483
|
+
provider === "anthropic" && hasOwn(body, "safeguards") && validateCanonicalSafeguards(body.safeguards);
|
|
86834
87484
|
let modelCallId = (0, import_node_crypto35.randomUUID)(), sha = requestSha256(body), headers = {
|
|
86835
87485
|
...cfg.synthesizedHeaders,
|
|
86836
87486
|
...canonicalBetaHeader(provider, input.agentHeaders)
|
|
@@ -87354,7 +88004,10 @@ var LocalModelGatewayBroker = class {
|
|
|
87354
88004
|
});
|
|
87355
88005
|
} catch (err) {
|
|
87356
88006
|
if (err instanceof CanonicalRejectError)
|
|
87357
|
-
return
|
|
88007
|
+
return logger.warn("[broker] rejected non-canonical model request", {
|
|
88008
|
+
provider,
|
|
88009
|
+
reason: err.reason
|
|
88010
|
+
}), { status: 400, body: { error: err.reason } };
|
|
87358
88011
|
throw err;
|
|
87359
88012
|
}
|
|
87360
88013
|
let { modelCallId, requestSha256: reqSha } = canonical, selfSecrets = [
|