@habitat-ai/cli 0.7.0 → 0.8.0
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/README.md +10 -2
- package/dist/{application-Idvdhc9h.js → application-fyrwZzvC.js} +3 -3
- package/dist/application.js +1 -1
- package/dist/{cli-DxjKzwlV.js → cli-B3N248Jk.js} +2408 -339
- package/dist/cli.js +1 -1
- package/dist/{habitat.app-CgdXa2f2.js → habitat.app-B8eGl9YJ.js} +1983 -314
- package/dist/habitat.app.js +1 -1
- package/dist/index.js +1 -1
- package/dist/nx-plugin.js +1 -1
- package/dist/{oclif-DBwcAyVK.js → oclif-fzwqfE6X.js} +1 -1
- package/dist/oclif.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
|
@@ -1151,7 +1151,7 @@ const SourceInventoryPathSchema = Refine(Type.String({
|
|
|
1151
1151
|
minLength: 1,
|
|
1152
1152
|
maxLength: MAX_SOURCE_INVENTORY_PATH_LENGTH,
|
|
1153
1153
|
description: "Canonical repository-relative visible entry path"
|
|
1154
|
-
}), isCanonicalRelativePath$
|
|
1154
|
+
}), isCanonicalRelativePath$3, () => "Expected a canonical safe repository-relative path");
|
|
1155
1155
|
const MaxEntriesSchema$1 = Type.Integer({
|
|
1156
1156
|
minimum: 1,
|
|
1157
1157
|
maximum: MAX_SOURCE_INVENTORY_ENTRIES,
|
|
@@ -1202,7 +1202,7 @@ const SourceInventoryFailureSchema = ReadonlyObject(Type.Object({
|
|
|
1202
1202
|
})
|
|
1203
1203
|
}), { additionalProperties: false });
|
|
1204
1204
|
new Validator({}, SourceInventoryFailureSchema);
|
|
1205
|
-
function isCanonicalRelativePath$
|
|
1205
|
+
function isCanonicalRelativePath$3(value) {
|
|
1206
1206
|
return !value.startsWith("/") && !value.endsWith("/") && !value.includes("\\") && !/^[A-Za-z]:\//u.test(value) && !/[\u0000-\u001f\u007f]/u.test(value) && value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
1207
1207
|
}
|
|
1208
1208
|
function isCanonicalInventory(value) {
|
|
@@ -1214,11 +1214,11 @@ function isStrictlySorted(paths) {
|
|
|
1214
1214
|
for (let index = 1; index < paths.length; index += 1) {
|
|
1215
1215
|
const previous = paths[index - 1];
|
|
1216
1216
|
const current = paths[index];
|
|
1217
|
-
if (previous === void 0 || current === void 0 || compareText$
|
|
1217
|
+
if (previous === void 0 || current === void 0 || compareText$13(previous, current) >= 0) return false;
|
|
1218
1218
|
}
|
|
1219
1219
|
return true;
|
|
1220
1220
|
}
|
|
1221
|
-
function compareText$
|
|
1221
|
+
function compareText$13(left, right) {
|
|
1222
1222
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
1223
1223
|
}
|
|
1224
1224
|
//#endregion
|
|
@@ -1417,9 +1417,9 @@ function isExecutableCheckApplication(application) {
|
|
|
1417
1417
|
return application.runner.name === "habitat" || isGritCheckApplication(application);
|
|
1418
1418
|
}
|
|
1419
1419
|
function compareApplications(left, right) {
|
|
1420
|
-
return compareText$
|
|
1420
|
+
return compareText$12(left.ruleId, right.ruleId) || compareText$12(instanceId(left) ?? "", instanceId(right) ?? "") || compareText$12(left.ownerProject, right.ownerProject);
|
|
1421
1421
|
}
|
|
1422
|
-
function compareText$
|
|
1422
|
+
function compareText$12(left, right) {
|
|
1423
1423
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
1424
1424
|
}
|
|
1425
1425
|
function refused$1(issues) {
|
|
@@ -1729,9 +1729,9 @@ function makeStructureUniverse(inventory) {
|
|
|
1729
1729
|
children.push(baseName(candidate));
|
|
1730
1730
|
directChildren.set(parent, children);
|
|
1731
1731
|
}
|
|
1732
|
-
for (const children of directChildren.values()) children.sort(compareText$
|
|
1732
|
+
for (const children of directChildren.values()) children.sort(compareText$11);
|
|
1733
1733
|
return {
|
|
1734
|
-
paths: [...allPaths].sort(compareText$
|
|
1734
|
+
paths: [...allPaths].sort(compareText$11),
|
|
1735
1735
|
trackedNonFilePaths,
|
|
1736
1736
|
directChildren
|
|
1737
1737
|
};
|
|
@@ -1757,7 +1757,7 @@ function planStructureEvaluation(admitted, universe) {
|
|
|
1757
1757
|
return {
|
|
1758
1758
|
application: admitted.application,
|
|
1759
1759
|
scopes,
|
|
1760
|
-
rootObservationPaths: [...rootObservationPaths].sort(compareText$
|
|
1760
|
+
rootObservationPaths: [...rootObservationPaths].sort(compareText$11),
|
|
1761
1761
|
universe
|
|
1762
1762
|
};
|
|
1763
1763
|
}
|
|
@@ -1771,7 +1771,7 @@ function structureChildObservationPaths(plan, observedKinds) {
|
|
|
1771
1771
|
for (const child of plan.universe.directChildren.get(root.path) ?? []) paths.add(appendPath(root.path, child));
|
|
1772
1772
|
}
|
|
1773
1773
|
}
|
|
1774
|
-
return [...paths].sort(compareText$
|
|
1774
|
+
return [...paths].sort(compareText$11);
|
|
1775
1775
|
}
|
|
1776
1776
|
/** Applies native structure semantics to a prepared source universe and observed root kinds. */
|
|
1777
1777
|
function evaluateStructurePlan(plan, observedKinds) {
|
|
@@ -1887,7 +1887,7 @@ function baseName(candidate) {
|
|
|
1887
1887
|
function displayPath(candidate) {
|
|
1888
1888
|
return candidate === "" ? "." : candidate;
|
|
1889
1889
|
}
|
|
1890
|
-
function compareText$
|
|
1890
|
+
function compareText$11(left, right) {
|
|
1891
1891
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
1892
1892
|
}
|
|
1893
1893
|
//#endregion
|
|
@@ -3877,6 +3877,14 @@ const ClaudeNativeAgentProviderRuntimeResource = defineRuntimeResource({
|
|
|
3877
3877
|
defaultLifetime: "process",
|
|
3878
3878
|
allowedLifetimes: ["process"]
|
|
3879
3879
|
});
|
|
3880
|
+
/** A cold process-lifetime capability; operations retain their own native scopes. */
|
|
3881
|
+
const AntigravityNativeAgentProviderRuntimeResource = defineRuntimeResource({
|
|
3882
|
+
id: "native-agent-provider.antigravity",
|
|
3883
|
+
title: "Antigravity native agent provider",
|
|
3884
|
+
purpose: "Explicit-home Antigravity plugin operations",
|
|
3885
|
+
defaultLifetime: "process",
|
|
3886
|
+
allowedLifetimes: ["process"]
|
|
3887
|
+
});
|
|
3880
3888
|
//#endregion
|
|
3881
3889
|
//#region ../../resources/versioned-content/dist/runtime.js
|
|
3882
3890
|
/** A cold process-lifetime capability; operations retain their own native scopes. */
|
|
@@ -4791,6 +4799,908 @@ const contract$8 = { package: oc.meta(procedureMetadata({
|
|
|
4791
4799
|
entity: "packaging"
|
|
4792
4800
|
})).input(standard(PackageAgentPluginRequestSchema)).output(standard(PackageAgentPluginResultSchema)).errors({ BAD_REQUEST: { message: "Package request is invalid" } }) };
|
|
4793
4801
|
//#endregion
|
|
4802
|
+
//#region ../../resources/native-agent-provider/antigravity-projection.ts
|
|
4803
|
+
const utf8Decoder$1 = new TextDecoder("utf-8", { fatal: true });
|
|
4804
|
+
const utf8Encoder = new TextEncoder();
|
|
4805
|
+
const ANTIGRAVITY_LOGO_EXTENSIONS = [
|
|
4806
|
+
".png",
|
|
4807
|
+
".svg",
|
|
4808
|
+
".jpg",
|
|
4809
|
+
".jpeg",
|
|
4810
|
+
".webp"
|
|
4811
|
+
];
|
|
4812
|
+
const ANTIGRAVITY_HOOK_EVENTS = /* @__PURE__ */ new Set([
|
|
4813
|
+
"SessionStart",
|
|
4814
|
+
"PreToolUse",
|
|
4815
|
+
"PostToolUse",
|
|
4816
|
+
"PreInvocation",
|
|
4817
|
+
"PostInvocation",
|
|
4818
|
+
"Stop"
|
|
4819
|
+
]);
|
|
4820
|
+
const DEFAULT_OMITTED_ANTIGRAVITY_TOOLS = [
|
|
4821
|
+
"read_file",
|
|
4822
|
+
"edit_file",
|
|
4823
|
+
"write_file",
|
|
4824
|
+
"run_command",
|
|
4825
|
+
"manage_task",
|
|
4826
|
+
"search_web",
|
|
4827
|
+
"grep_search",
|
|
4828
|
+
"find_by_name",
|
|
4829
|
+
"list_dir",
|
|
4830
|
+
"read_url_content"
|
|
4831
|
+
];
|
|
4832
|
+
const NATIVE_ANTIGRAVITY_TOOLS = /* @__PURE__ */ new Set([
|
|
4833
|
+
"read_file",
|
|
4834
|
+
"view_file",
|
|
4835
|
+
"edit_file",
|
|
4836
|
+
"write_file",
|
|
4837
|
+
"run_command",
|
|
4838
|
+
"manage_task",
|
|
4839
|
+
"search_web",
|
|
4840
|
+
"read_url_content",
|
|
4841
|
+
"grep_search",
|
|
4842
|
+
"find_by_name",
|
|
4843
|
+
"list_dir",
|
|
4844
|
+
"code_search",
|
|
4845
|
+
"invoke_subagent",
|
|
4846
|
+
"manage_subagents",
|
|
4847
|
+
"send_message",
|
|
4848
|
+
"ask_question",
|
|
4849
|
+
"update_focus",
|
|
4850
|
+
"update_steps",
|
|
4851
|
+
"generate_image",
|
|
4852
|
+
"browser_subagent",
|
|
4853
|
+
"open_browser_url",
|
|
4854
|
+
"call_mcp_tool",
|
|
4855
|
+
"list_resources",
|
|
4856
|
+
"read_resource"
|
|
4857
|
+
]);
|
|
4858
|
+
const CLAUDE_TO_ANTIGRAVITY_TOOLS = {
|
|
4859
|
+
Read: ["read_file"],
|
|
4860
|
+
NotebookRead: ["read_file"],
|
|
4861
|
+
Glob: ["find_by_name", "list_dir"],
|
|
4862
|
+
LS: ["list_dir"],
|
|
4863
|
+
Grep: ["grep_search"],
|
|
4864
|
+
Edit: ["edit_file"],
|
|
4865
|
+
MultiEdit: ["edit_file"],
|
|
4866
|
+
NotebookEdit: ["edit_file"],
|
|
4867
|
+
Write: ["write_file"],
|
|
4868
|
+
Bash: ["run_command", "manage_task"],
|
|
4869
|
+
BashOutput: ["manage_task"],
|
|
4870
|
+
KillShell: ["manage_task"],
|
|
4871
|
+
KillBash: ["manage_task"],
|
|
4872
|
+
WebSearch: ["search_web"],
|
|
4873
|
+
WebFetch: ["read_url_content"],
|
|
4874
|
+
Task: ["invoke_subagent"],
|
|
4875
|
+
Agent: ["invoke_subagent"],
|
|
4876
|
+
AskUserQuestion: ["ask_question"],
|
|
4877
|
+
TodoWrite: ["update_steps"]
|
|
4878
|
+
};
|
|
4879
|
+
const DENIED_CLAUDE_TO_ANTIGRAVITY_TOOLS = {
|
|
4880
|
+
Read: ["read_file", "view_file"],
|
|
4881
|
+
NotebookRead: ["read_file", "view_file"],
|
|
4882
|
+
Glob: ["find_by_name", "list_dir"],
|
|
4883
|
+
LS: ["list_dir"],
|
|
4884
|
+
Grep: ["grep_search"],
|
|
4885
|
+
Edit: [
|
|
4886
|
+
"edit_file",
|
|
4887
|
+
"replace_file_content",
|
|
4888
|
+
"multi_replace_file_content"
|
|
4889
|
+
],
|
|
4890
|
+
MultiEdit: [
|
|
4891
|
+
"edit_file",
|
|
4892
|
+
"replace_file_content",
|
|
4893
|
+
"multi_replace_file_content"
|
|
4894
|
+
],
|
|
4895
|
+
NotebookEdit: [
|
|
4896
|
+
"edit_file",
|
|
4897
|
+
"replace_file_content",
|
|
4898
|
+
"multi_replace_file_content"
|
|
4899
|
+
],
|
|
4900
|
+
Write: ["write_file", "write_to_file"],
|
|
4901
|
+
Bash: ["run_command", "manage_task"],
|
|
4902
|
+
BashOutput: ["manage_task"],
|
|
4903
|
+
KillShell: ["manage_task"],
|
|
4904
|
+
KillBash: ["manage_task"],
|
|
4905
|
+
WebSearch: ["search_web", "read_url_content"],
|
|
4906
|
+
WebFetch: ["search_web", "read_url_content"],
|
|
4907
|
+
Task: ["invoke_subagent"],
|
|
4908
|
+
Agent: ["invoke_subagent"],
|
|
4909
|
+
AskUserQuestion: ["ask_question"],
|
|
4910
|
+
TodoWrite: ["update_steps"]
|
|
4911
|
+
};
|
|
4912
|
+
const MAX_MCP_SERVER_NAME_CODE_UNITS = 256;
|
|
4913
|
+
const HTTP_HEADER_TOKEN_PATTERN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u;
|
|
4914
|
+
/**
|
|
4915
|
+
* Bounds an omitted MCP server key to at most 256 well-formed UTF-16 code units without
|
|
4916
|
+
* splitting surrogate pairs, preserving `""` when the source `.mcp.json` key was empty.
|
|
4917
|
+
*/
|
|
4918
|
+
function boundOmittedMcpServerName(rawKey) {
|
|
4919
|
+
let end = Math.min(rawKey.length, MAX_MCP_SERVER_NAME_CODE_UNITS);
|
|
4920
|
+
if (end < rawKey.length) {
|
|
4921
|
+
const lastCode = rawKey.charCodeAt(end - 1);
|
|
4922
|
+
if (lastCode >= 55296 && lastCode <= 56319) end -= 1;
|
|
4923
|
+
}
|
|
4924
|
+
const sliced = rawKey.slice(0, end);
|
|
4925
|
+
let out = "";
|
|
4926
|
+
for (let index = 0; index < sliced.length; index += 1) {
|
|
4927
|
+
const code = sliced.charCodeAt(index);
|
|
4928
|
+
if (code >= 55296 && code <= 56319) {
|
|
4929
|
+
const next = index + 1 < sliced.length ? sliced.charCodeAt(index + 1) : 0;
|
|
4930
|
+
if (next >= 56320 && next <= 57343) {
|
|
4931
|
+
out += sliced.slice(index, index + 2);
|
|
4932
|
+
index += 1;
|
|
4933
|
+
} else out += "�";
|
|
4934
|
+
} else if (code >= 56320 && code <= 57343) out += "�";
|
|
4935
|
+
else out += sliced[index];
|
|
4936
|
+
}
|
|
4937
|
+
return out;
|
|
4938
|
+
}
|
|
4939
|
+
/**
|
|
4940
|
+
* Deterministically projects a multi-provider plugin payload into an Antigravity-native bundle.
|
|
4941
|
+
*
|
|
4942
|
+
* @remarks
|
|
4943
|
+
* Both the Antigravity native provider's `addMarketplace` staging and the lifecycle service's
|
|
4944
|
+
* desired-content construction invoke this pure function with identical inputs so staged,
|
|
4945
|
+
* installed, and verified bytes agree bit-for-bit without sidecars inside installed plugins.
|
|
4946
|
+
*/
|
|
4947
|
+
function projectAntigravityPluginBundle(input) {
|
|
4948
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
4949
|
+
for (const entry of input.entries) {
|
|
4950
|
+
if (!isCanonicalRelativePath$2(entry.path)) return invalid$2(`Plugin payload contains a non-canonical relative path: ${entry.path}`);
|
|
4951
|
+
if (entry.mode !== 420 && entry.mode !== 493) return invalid$2(`Plugin payload entry has an unsupported file mode: ${entry.path}`);
|
|
4952
|
+
if (byPath.has(entry.path)) return invalid$2(`Plugin payload contains duplicate relative path: ${entry.path}`);
|
|
4953
|
+
byPath.set(entry.path, entry);
|
|
4954
|
+
}
|
|
4955
|
+
const claudeManifestEntry = byPath.get(".claude-plugin/plugin.json");
|
|
4956
|
+
const codexManifestEntry = byPath.get(".codex-plugin/plugin.json");
|
|
4957
|
+
if (claudeManifestEntry === void 0 && codexManifestEntry === void 0) return invalid$2("Plugin payload must contain .claude-plugin/plugin.json or .codex-plugin/plugin.json");
|
|
4958
|
+
const claudeManifest = claudeManifestEntry === void 0 ? null : parseJsonRecord(claudeManifestEntry.bytes, ".claude-plugin/plugin.json");
|
|
4959
|
+
if (claudeManifest !== null && !claudeManifest.ok) return claudeManifest;
|
|
4960
|
+
const codexManifest = codexManifestEntry === void 0 ? null : parseJsonRecord(codexManifestEntry.bytes, ".codex-plugin/plugin.json");
|
|
4961
|
+
if (codexManifest !== null && !codexManifest.ok) return codexManifest;
|
|
4962
|
+
const claude = claudeManifest?.record ?? {};
|
|
4963
|
+
const codex = codexManifest?.record ?? {};
|
|
4964
|
+
const projectedAssets = /* @__PURE__ */ new Set();
|
|
4965
|
+
for (const path of byPath.keys()) if (path.startsWith("assets/")) projectedAssets.add(path);
|
|
4966
|
+
const manifestResult = buildPluginManifestJson(claude, codex, input.repositoryUrl, projectedAssets);
|
|
4967
|
+
if (!manifestResult.ok) return manifestResult;
|
|
4968
|
+
const output = /* @__PURE__ */ new Map();
|
|
4969
|
+
output.set("plugin.json", Object.freeze({
|
|
4970
|
+
path: "plugin.json",
|
|
4971
|
+
mode: 420,
|
|
4972
|
+
bytes: manifestResult.bytes
|
|
4973
|
+
}));
|
|
4974
|
+
let omittedMcpServers = Object.freeze([]);
|
|
4975
|
+
const mcpEntry = byPath.get(".mcp.json");
|
|
4976
|
+
if (mcpEntry !== void 0) {
|
|
4977
|
+
const mcpResult = buildMcpConfigJson(mcpEntry.bytes);
|
|
4978
|
+
if (!mcpResult.ok) return mcpResult;
|
|
4979
|
+
omittedMcpServers = mcpResult.omittedMcpServers;
|
|
4980
|
+
if (mcpResult.bytes !== null) output.set("mcp_config.json", Object.freeze({
|
|
4981
|
+
path: "mcp_config.json",
|
|
4982
|
+
mode: 420,
|
|
4983
|
+
bytes: mcpResult.bytes
|
|
4984
|
+
}));
|
|
4985
|
+
}
|
|
4986
|
+
const keepNativeHooks = shouldKeepNativeAntigravityHooks(byPath);
|
|
4987
|
+
if (keepNativeHooks) {
|
|
4988
|
+
const rootHooks = byPath.get("hooks.json");
|
|
4989
|
+
if (rootHooks !== void 0) output.set("hooks.json", Object.freeze({
|
|
4990
|
+
path: "hooks.json",
|
|
4991
|
+
mode: 420,
|
|
4992
|
+
bytes: new Uint8Array(rootHooks.bytes)
|
|
4993
|
+
}));
|
|
4994
|
+
}
|
|
4995
|
+
for (const [path, entry] of byPath.entries()) {
|
|
4996
|
+
if (path.startsWith("skills/") || path.startsWith("scripts/") || path.startsWith("assets/") || path.startsWith("rules/") || keepNativeHooks && path.startsWith("hooks/")) {
|
|
4997
|
+
output.set(path, Object.freeze({
|
|
4998
|
+
path,
|
|
4999
|
+
mode: entry.mode,
|
|
5000
|
+
bytes: new Uint8Array(entry.bytes)
|
|
5001
|
+
}));
|
|
5002
|
+
continue;
|
|
5003
|
+
}
|
|
5004
|
+
if (path.startsWith("agents/") && path.endsWith(".md") && path.indexOf("/", 7) === -1) {
|
|
5005
|
+
const decoded = decodeUtf8(entry.bytes, path);
|
|
5006
|
+
if (!decoded.ok) return decoded;
|
|
5007
|
+
const translated = translateAgentMarkdown(decoded.text);
|
|
5008
|
+
output.set(path, Object.freeze({
|
|
5009
|
+
path,
|
|
5010
|
+
mode: 420,
|
|
5011
|
+
bytes: utf8Encoder.encode(translated)
|
|
5012
|
+
}));
|
|
5013
|
+
}
|
|
5014
|
+
}
|
|
5015
|
+
const entries = Object.freeze([...output.values()].sort((left, right) => compareText$10(left.path, right.path)));
|
|
5016
|
+
return Object.freeze({
|
|
5017
|
+
ok: true,
|
|
5018
|
+
pluginName: manifestResult.pluginName,
|
|
5019
|
+
entries,
|
|
5020
|
+
omittedMcpServers
|
|
5021
|
+
});
|
|
5022
|
+
}
|
|
5023
|
+
function buildPluginManifestJson(claude, codex, repositoryUrl, projectedAssets) {
|
|
5024
|
+
const claudeName = nonEmptyString(claude.name);
|
|
5025
|
+
const codexName = nonEmptyString(codex.name);
|
|
5026
|
+
if (claudeName !== null && codexName !== null && claudeName !== codexName) return invalid$2(`Claude and Codex plugin manifests disagree on plugin name (${claudeName} vs ${codexName})`);
|
|
5027
|
+
const name = claudeName ?? codexName;
|
|
5028
|
+
if (name === null || !/^[a-z0-9][a-z0-9._-]*$/u.test(name) || name.length > 128) return invalid$2("Plugin manifest must declare a canonical lowercase plugin name");
|
|
5029
|
+
const codexInterface = asRecord(codex.interface);
|
|
5030
|
+
const displayName = (codexInterface === null ? null : nonEmptyString(codexInterface.displayName)) ?? nonEmptyString(claude.displayName) ?? nonEmptyString(codex.displayName);
|
|
5031
|
+
const description = nonEmptyString(claude.description) ?? nonEmptyString(codex.description) ?? (codexInterface === null ? null : nonEmptyString(codexInterface.shortDescription));
|
|
5032
|
+
const version = nonEmptyString(claude.version) ?? nonEmptyString(codex.version);
|
|
5033
|
+
const author = normalizeAuthor(claude.author) ?? normalizeAuthor(codex.author);
|
|
5034
|
+
const homepage = httpsUrlString(claude.homepage) ?? httpsUrlString(codex.homepage);
|
|
5035
|
+
const repository = (repositoryUrl !== null ? httpsUrlString(repositoryUrl) : null) ?? normalizeRepository(claude.repository) ?? normalizeRepository(codex.repository);
|
|
5036
|
+
const rawLogo = nonEmptyString(claude.logo) ?? nonEmptyString(codex.logo) ?? (codexInterface === null ? null : nonEmptyString(codexInterface.logo));
|
|
5037
|
+
const logo = rawLogo !== null && isValidLogoPath(rawLogo, projectedAssets) ? rawLogo : null;
|
|
5038
|
+
const suggestedPrompts = normalizeSuggestedPrompts(claude.suggestedPrompts) ?? normalizeSuggestedPrompts(codex.suggestedPrompts);
|
|
5039
|
+
const disabled = typeof claude.disabled === "boolean" ? claude.disabled : typeof codex.disabled === "boolean" ? codex.disabled : null;
|
|
5040
|
+
const manifest = { name };
|
|
5041
|
+
if (displayName !== null) manifest.displayName = displayName;
|
|
5042
|
+
if (description !== null) manifest.description = description;
|
|
5043
|
+
if (version !== null) manifest.version = version;
|
|
5044
|
+
if (author !== null) manifest.author = author;
|
|
5045
|
+
if (homepage !== null) manifest.homepage = homepage;
|
|
5046
|
+
if (repository !== null) manifest.repository = repository;
|
|
5047
|
+
if (logo !== null) manifest.logo = logo;
|
|
5048
|
+
if (suggestedPrompts !== null) manifest.suggestedPrompts = suggestedPrompts;
|
|
5049
|
+
if (disabled !== null) manifest.disabled = disabled;
|
|
5050
|
+
return Object.freeze({
|
|
5051
|
+
ok: true,
|
|
5052
|
+
pluginName: name,
|
|
5053
|
+
bytes: utf8Encoder.encode(`${JSON.stringify(manifest, null, 2)}\n`)
|
|
5054
|
+
});
|
|
5055
|
+
}
|
|
5056
|
+
/**
|
|
5057
|
+
* Projects remote HTTPS HTTP-transport MCP servers that can install and enable headlessly in Antigravity,
|
|
5058
|
+
* recording canonically ordered omission reasons for skipped entries.
|
|
5059
|
+
*/
|
|
5060
|
+
function buildMcpConfigJson(bytes) {
|
|
5061
|
+
const parsed = parseJsonRecord(bytes, ".mcp.json");
|
|
5062
|
+
if (!parsed.ok) return parsed;
|
|
5063
|
+
const rawServers = parsed.record.mcpServers;
|
|
5064
|
+
if (rawServers === void 0) return Object.freeze({
|
|
5065
|
+
ok: true,
|
|
5066
|
+
bytes: null,
|
|
5067
|
+
omittedMcpServers: Object.freeze([])
|
|
5068
|
+
});
|
|
5069
|
+
const serversRecord = asRecord(rawServers);
|
|
5070
|
+
if (serversRecord === null) return invalid$2(".mcp.json mcpServers field must be a JSON object");
|
|
5071
|
+
const remoteServers = Object.create(null);
|
|
5072
|
+
const omitted = [];
|
|
5073
|
+
for (const key of Object.keys(serversRecord).sort(compareText$10)) {
|
|
5074
|
+
const boundedName = boundOmittedMcpServerName(key);
|
|
5075
|
+
if (key.length === 0 || key.length > MAX_MCP_SERVER_NAME_CODE_UNITS || key === "__proto__") {
|
|
5076
|
+
omitted.push(Object.freeze({
|
|
5077
|
+
name: boundedName,
|
|
5078
|
+
reason: "invalid-config"
|
|
5079
|
+
}));
|
|
5080
|
+
continue;
|
|
5081
|
+
}
|
|
5082
|
+
const config = asRecord(serversRecord[key]);
|
|
5083
|
+
if (config === null) {
|
|
5084
|
+
omitted.push(Object.freeze({
|
|
5085
|
+
name: boundedName,
|
|
5086
|
+
reason: "invalid-config"
|
|
5087
|
+
}));
|
|
5088
|
+
continue;
|
|
5089
|
+
}
|
|
5090
|
+
let headersRecord = null;
|
|
5091
|
+
if (config.headers !== void 0) {
|
|
5092
|
+
headersRecord = asRecord(config.headers);
|
|
5093
|
+
if (headersRecord === null) {
|
|
5094
|
+
omitted.push(Object.freeze({
|
|
5095
|
+
name: boundedName,
|
|
5096
|
+
reason: "invalid-config"
|
|
5097
|
+
}));
|
|
5098
|
+
continue;
|
|
5099
|
+
}
|
|
5100
|
+
let hasInvalidHeader = false;
|
|
5101
|
+
for (const headerName of Object.keys(headersRecord)) {
|
|
5102
|
+
const rawHeaderValue = headersRecord[headerName];
|
|
5103
|
+
if (headerName.length === 0 || headerName === "__proto__" || !HTTP_HEADER_TOKEN_PATTERN.test(headerName) || typeof rawHeaderValue !== "string" || rawHeaderValue.trim().length === 0 || /[\r\n\u0000]/u.test(rawHeaderValue)) {
|
|
5104
|
+
hasInvalidHeader = true;
|
|
5105
|
+
break;
|
|
5106
|
+
}
|
|
5107
|
+
}
|
|
5108
|
+
if (hasInvalidHeader) {
|
|
5109
|
+
omitted.push(Object.freeze({
|
|
5110
|
+
name: boundedName,
|
|
5111
|
+
reason: "invalid-config"
|
|
5112
|
+
}));
|
|
5113
|
+
continue;
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
if (config.type !== void 0 && config.type !== "http") {
|
|
5117
|
+
omitted.push(Object.freeze({
|
|
5118
|
+
name: boundedName,
|
|
5119
|
+
reason: "unsupported-transport"
|
|
5120
|
+
}));
|
|
5121
|
+
continue;
|
|
5122
|
+
}
|
|
5123
|
+
if (config.url === void 0 && config.serverUrl === void 0) {
|
|
5124
|
+
omitted.push(Object.freeze({
|
|
5125
|
+
name: boundedName,
|
|
5126
|
+
reason: "unsupported-transport"
|
|
5127
|
+
}));
|
|
5128
|
+
continue;
|
|
5129
|
+
}
|
|
5130
|
+
const rawUrlCandidate = config.url !== void 0 ? config.url : config.serverUrl;
|
|
5131
|
+
if (typeof rawUrlCandidate !== "string" || rawUrlCandidate.length === 0) {
|
|
5132
|
+
omitted.push(Object.freeze({
|
|
5133
|
+
name: boundedName,
|
|
5134
|
+
reason: "invalid-config"
|
|
5135
|
+
}));
|
|
5136
|
+
continue;
|
|
5137
|
+
}
|
|
5138
|
+
const expandedUrl = expandClaudeDefaultPlaceholders(rawUrlCandidate);
|
|
5139
|
+
if (hasUnresolvedMcpPlaceholder(expandedUrl)) {
|
|
5140
|
+
omitted.push(Object.freeze({
|
|
5141
|
+
name: boundedName,
|
|
5142
|
+
reason: "requires-variables"
|
|
5143
|
+
}));
|
|
5144
|
+
continue;
|
|
5145
|
+
}
|
|
5146
|
+
if (!isRemoteHttpsUrl(expandedUrl)) {
|
|
5147
|
+
omitted.push(Object.freeze({
|
|
5148
|
+
name: boundedName,
|
|
5149
|
+
reason: "non-remote-https-url"
|
|
5150
|
+
}));
|
|
5151
|
+
continue;
|
|
5152
|
+
}
|
|
5153
|
+
let normalizedHeaders;
|
|
5154
|
+
let hasUnresolvedHeader = false;
|
|
5155
|
+
let hasInvalidExpandedHeader = false;
|
|
5156
|
+
if (headersRecord !== null) {
|
|
5157
|
+
const collectedHeaders = Object.create(null);
|
|
5158
|
+
for (const headerName of Object.keys(headersRecord).sort(compareText$10)) {
|
|
5159
|
+
const expandedHeader = expandClaudeDefaultPlaceholders(headersRecord[headerName].trim());
|
|
5160
|
+
if (/[\r\n\u0000]/u.test(expandedHeader)) {
|
|
5161
|
+
hasInvalidExpandedHeader = true;
|
|
5162
|
+
break;
|
|
5163
|
+
}
|
|
5164
|
+
if (hasUnresolvedMcpPlaceholder(expandedHeader)) {
|
|
5165
|
+
hasUnresolvedHeader = true;
|
|
5166
|
+
break;
|
|
5167
|
+
}
|
|
5168
|
+
collectedHeaders[headerName] = expandedHeader;
|
|
5169
|
+
}
|
|
5170
|
+
if (hasInvalidExpandedHeader) {
|
|
5171
|
+
omitted.push(Object.freeze({
|
|
5172
|
+
name: boundedName,
|
|
5173
|
+
reason: "invalid-config"
|
|
5174
|
+
}));
|
|
5175
|
+
continue;
|
|
5176
|
+
}
|
|
5177
|
+
if (hasUnresolvedHeader) {
|
|
5178
|
+
omitted.push(Object.freeze({
|
|
5179
|
+
name: boundedName,
|
|
5180
|
+
reason: "requires-variables"
|
|
5181
|
+
}));
|
|
5182
|
+
continue;
|
|
5183
|
+
}
|
|
5184
|
+
if (Object.keys(collectedHeaders).length > 0) normalizedHeaders = collectedHeaders;
|
|
5185
|
+
}
|
|
5186
|
+
const serverEntry = Object.create(null);
|
|
5187
|
+
serverEntry.url = expandedUrl;
|
|
5188
|
+
if (normalizedHeaders !== void 0) serverEntry.headers = normalizedHeaders;
|
|
5189
|
+
remoteServers[key] = serverEntry;
|
|
5190
|
+
}
|
|
5191
|
+
omitted.sort((left, right) => compareText$10(left.name, right.name) || compareText$10(left.reason, right.reason));
|
|
5192
|
+
const omittedMcpServers = Object.freeze(omitted);
|
|
5193
|
+
if (Object.keys(remoteServers).length === 0) return Object.freeze({
|
|
5194
|
+
ok: true,
|
|
5195
|
+
bytes: null,
|
|
5196
|
+
omittedMcpServers
|
|
5197
|
+
});
|
|
5198
|
+
return Object.freeze({
|
|
5199
|
+
ok: true,
|
|
5200
|
+
bytes: utf8Encoder.encode(`${JSON.stringify({ mcpServers: remoteServers }, null, 2)}\n`),
|
|
5201
|
+
omittedMcpServers
|
|
5202
|
+
});
|
|
5203
|
+
}
|
|
5204
|
+
function expandClaudeDefaultPlaceholders(value) {
|
|
5205
|
+
return value.replace(/\$\{(?:env:)?[A-Za-z_][A-Za-z0-9_]*:-([^}]+)\}/gu, "$1");
|
|
5206
|
+
}
|
|
5207
|
+
function hasUnresolvedMcpPlaceholder(value) {
|
|
5208
|
+
return /\$\{[^}]*\}/u.test(value);
|
|
5209
|
+
}
|
|
5210
|
+
function shouldKeepNativeAntigravityHooks(byPath) {
|
|
5211
|
+
if (byPath.has("hooks/hooks.json")) return false;
|
|
5212
|
+
const rootHooksEntry = byPath.get("hooks.json");
|
|
5213
|
+
if (rootHooksEntry === void 0) return false;
|
|
5214
|
+
const decodedHooks = decodeUtf8(rootHooksEntry.bytes, "hooks.json");
|
|
5215
|
+
if (!decodedHooks.ok) return false;
|
|
5216
|
+
if (decodedHooks.text.includes("CLAUDE_PLUGIN_ROOT")) return false;
|
|
5217
|
+
const parsedHooks = parseJsonRecord(rootHooksEntry.bytes, "hooks.json");
|
|
5218
|
+
if (!parsedHooks.ok) return false;
|
|
5219
|
+
if ("hooks" in parsedHooks.record) return false;
|
|
5220
|
+
if (containsAsyncRewake(parsedHooks.record)) return false;
|
|
5221
|
+
const hookEntries = Object.entries(parsedHooks.record);
|
|
5222
|
+
if (hookEntries.length === 0) return false;
|
|
5223
|
+
for (const [, spec] of hookEntries) {
|
|
5224
|
+
const specRecord = asRecord(spec);
|
|
5225
|
+
if (specRecord === null) return false;
|
|
5226
|
+
const keys = Object.keys(specRecord);
|
|
5227
|
+
if (keys.length === 0) return false;
|
|
5228
|
+
if (keys.some((key) => key !== "enabled" && !ANTIGRAVITY_HOOK_EVENTS.has(key))) return false;
|
|
5229
|
+
}
|
|
5230
|
+
for (const [path, entry] of byPath.entries()) {
|
|
5231
|
+
if (!path.startsWith("hooks/")) continue;
|
|
5232
|
+
const decoded = decodeUtf8(entry.bytes, path);
|
|
5233
|
+
if (!decoded.ok) continue;
|
|
5234
|
+
if (decoded.text.includes("CLAUDE_PLUGIN_ROOT") || decoded.text.includes("session_id") && !decoded.text.includes("conversationId")) return false;
|
|
5235
|
+
}
|
|
5236
|
+
return true;
|
|
5237
|
+
}
|
|
5238
|
+
function containsAsyncRewake(value) {
|
|
5239
|
+
if (Array.isArray(value)) return value.some(containsAsyncRewake);
|
|
5240
|
+
const record = asRecord(value);
|
|
5241
|
+
if (record === null) return false;
|
|
5242
|
+
if (record.asyncRewake === true) return true;
|
|
5243
|
+
return Object.values(record).some(containsAsyncRewake);
|
|
5244
|
+
}
|
|
5245
|
+
/**
|
|
5246
|
+
* Translates one Claude/Codex agent markdown file into Antigravity's subagent schema,
|
|
5247
|
+
* subtracting `disallowedTools` fail-closed from the declared or default tool set.
|
|
5248
|
+
*/
|
|
5249
|
+
function translateAgentMarkdown(markdown) {
|
|
5250
|
+
const allLines = (markdown.startsWith("") ? markdown.slice(1) : markdown).replace(/\r\n/gu, "\n").split("\n");
|
|
5251
|
+
const firstLine = allLines[0];
|
|
5252
|
+
if (firstLine === void 0 || !/^---[ \t]*$/u.test(firstLine)) return markdown.replace(/\r\n/gu, "\n");
|
|
5253
|
+
let closingLineIndex = -1;
|
|
5254
|
+
for (let lineIndex = 1; lineIndex < allLines.length; lineIndex += 1) if (/^---[ \t]*$/u.test(allLines[lineIndex])) {
|
|
5255
|
+
closingLineIndex = lineIndex;
|
|
5256
|
+
break;
|
|
5257
|
+
}
|
|
5258
|
+
if (closingLineIndex === -1) return markdown.replace(/\r\n/gu, "\n");
|
|
5259
|
+
const lines = allLines.slice(1, closingLineIndex);
|
|
5260
|
+
const remainingLines = allLines.slice(closingLineIndex + 1);
|
|
5261
|
+
const afterClosing = remainingLines.length === 0 ? "" : `\n${remainingLines.join("\n")}`;
|
|
5262
|
+
const outLines = [];
|
|
5263
|
+
let hasSubagent = false;
|
|
5264
|
+
let hasMainAgent = false;
|
|
5265
|
+
let hasTools = false;
|
|
5266
|
+
let toolsInsertPosition = null;
|
|
5267
|
+
const declaredToolTokens = [];
|
|
5268
|
+
const disallowedToolTokens = [];
|
|
5269
|
+
let index = 0;
|
|
5270
|
+
while (index < lines.length) {
|
|
5271
|
+
const line = lines[index];
|
|
5272
|
+
const keyMatch = /^([A-Za-z_][A-Za-z0-9_-]*):(?:\s*(.*))?$/u.exec(line);
|
|
5273
|
+
if (keyMatch === null) {
|
|
5274
|
+
outLines.push(line);
|
|
5275
|
+
index += 1;
|
|
5276
|
+
continue;
|
|
5277
|
+
}
|
|
5278
|
+
const key = keyMatch[1];
|
|
5279
|
+
const commentStrippedValue = stripUnquotedYamlComment((keyMatch[2] ?? "").trim());
|
|
5280
|
+
if (key === "subagent") {
|
|
5281
|
+
hasSubagent = true;
|
|
5282
|
+
outLines.push(`subagent: ${stripYamlQuotes(commentStrippedValue)}`);
|
|
5283
|
+
index += 1;
|
|
5284
|
+
continue;
|
|
5285
|
+
}
|
|
5286
|
+
if (key === "mainAgent") {
|
|
5287
|
+
hasMainAgent = true;
|
|
5288
|
+
outLines.push(`mainAgent: ${stripYamlQuotes(commentStrippedValue)}`);
|
|
5289
|
+
index += 1;
|
|
5290
|
+
continue;
|
|
5291
|
+
}
|
|
5292
|
+
if (key === "model") {
|
|
5293
|
+
const unquoted = stripYamlQuotes(commentStrippedValue);
|
|
5294
|
+
outLines.push(`model: ${mapAntigravityModel(unquoted)}`);
|
|
5295
|
+
index += 1;
|
|
5296
|
+
continue;
|
|
5297
|
+
}
|
|
5298
|
+
if (key === "tools") {
|
|
5299
|
+
hasTools = true;
|
|
5300
|
+
if (toolsInsertPosition === null) toolsInsertPosition = outLines.length;
|
|
5301
|
+
const parsedTools = parseYamlToolsField(lines, index, commentStrippedValue);
|
|
5302
|
+
declaredToolTokens.push(...parsedTools.items);
|
|
5303
|
+
index = parsedTools.nextIndex;
|
|
5304
|
+
continue;
|
|
5305
|
+
}
|
|
5306
|
+
if (key === "disallowedTools" || key === "disallowed-tools") {
|
|
5307
|
+
const parsedDenied = parseYamlToolsField(lines, index, commentStrippedValue);
|
|
5308
|
+
disallowedToolTokens.push(...parsedDenied.items);
|
|
5309
|
+
index = parsedDenied.nextIndex;
|
|
5310
|
+
continue;
|
|
5311
|
+
}
|
|
5312
|
+
outLines.push(line);
|
|
5313
|
+
index += 1;
|
|
5314
|
+
}
|
|
5315
|
+
const baseTools = hasTools ? mapClaudeToolsToAntigravity(declaredToolTokens) : DEFAULT_OMITTED_ANTIGRAVITY_TOOLS;
|
|
5316
|
+
const deniedTools = mapDeniedToolsToAntigravity(disallowedToolTokens);
|
|
5317
|
+
const effectiveTools = deniedTools.size === 0 ? baseTools : baseTools.filter((tool) => !deniedTools.has(tool));
|
|
5318
|
+
const renderedToolsLines = [];
|
|
5319
|
+
emitToolsYaml(renderedToolsLines, effectiveTools);
|
|
5320
|
+
if (toolsInsertPosition !== null) outLines.splice(toolsInsertPosition, 0, ...renderedToolsLines);
|
|
5321
|
+
else outLines.push(...renderedToolsLines);
|
|
5322
|
+
if (!hasSubagent) outLines.push("subagent: true");
|
|
5323
|
+
if (!hasMainAgent) outLines.push("mainAgent: false");
|
|
5324
|
+
return `---\n${outLines.join("\n")}\n---${afterClosing}`;
|
|
5325
|
+
}
|
|
5326
|
+
function parseYamlToolsField(lines, startIndex, commentStrippedValue) {
|
|
5327
|
+
if (commentStrippedValue === "") {
|
|
5328
|
+
const rawItems = [];
|
|
5329
|
+
let cursor = startIndex + 1;
|
|
5330
|
+
while (cursor < lines.length) {
|
|
5331
|
+
const candidate = lines[cursor];
|
|
5332
|
+
if (/^\s*(?:#.*)?$/u.test(candidate)) {
|
|
5333
|
+
let lookahead = cursor + 1;
|
|
5334
|
+
while (lookahead < lines.length && /^\s*(?:#.*)?$/u.test(lines[lookahead])) lookahead += 1;
|
|
5335
|
+
const nextLine = lookahead < lines.length ? lines[lookahead] : null;
|
|
5336
|
+
if (nextLine !== null && (/^[ \t]+/u.test(nextLine) || /^-(?:$|[ \t])/u.test(nextLine))) {
|
|
5337
|
+
cursor = lookahead;
|
|
5338
|
+
continue;
|
|
5339
|
+
}
|
|
5340
|
+
break;
|
|
5341
|
+
}
|
|
5342
|
+
if (!/^[ \t]/u.test(candidate) && !/^-(?:$|[ \t])/u.test(candidate)) break;
|
|
5343
|
+
const strippedCandidate = stripUnquotedYamlComment(candidate);
|
|
5344
|
+
if (strippedCandidate.length > 0 && strippedCandidate !== "-") {
|
|
5345
|
+
const itemMatch = /^-(?:[ \t]+(.*))?$/u.exec(strippedCandidate);
|
|
5346
|
+
const payload = itemMatch !== null ? (itemMatch[1] ?? "").trim() : strippedCandidate;
|
|
5347
|
+
if (payload.length > 0) rawItems.push(payload);
|
|
5348
|
+
}
|
|
5349
|
+
cursor += 1;
|
|
5350
|
+
}
|
|
5351
|
+
return Object.freeze({
|
|
5352
|
+
items: expandRawToolTokens(rawItems),
|
|
5353
|
+
nextIndex: cursor
|
|
5354
|
+
});
|
|
5355
|
+
}
|
|
5356
|
+
if (commentStrippedValue.startsWith("[")) return collectFlowSequenceItems(lines, startIndex, commentStrippedValue);
|
|
5357
|
+
if (/^[|>][+-]?\d*$/u.test(commentStrippedValue)) return collectBlockScalarItems(lines, startIndex);
|
|
5358
|
+
return collectPlainScalarItems(lines, startIndex, commentStrippedValue);
|
|
5359
|
+
}
|
|
5360
|
+
function collectFlowSequenceItems(lines, startIndex, initialValue) {
|
|
5361
|
+
const firstSegment = initialValue.slice(1);
|
|
5362
|
+
const firstClose = findUnquotedClosingBracket(firstSegment);
|
|
5363
|
+
if (firstClose !== -1) {
|
|
5364
|
+
const inner = firstSegment.slice(0, firstClose).trim();
|
|
5365
|
+
return Object.freeze({
|
|
5366
|
+
items: parseFlowInnerItems(inner),
|
|
5367
|
+
nextIndex: startIndex + 1
|
|
5368
|
+
});
|
|
5369
|
+
}
|
|
5370
|
+
const segments = [firstSegment];
|
|
5371
|
+
let cursor = startIndex + 1;
|
|
5372
|
+
while (cursor < lines.length) {
|
|
5373
|
+
const candidate = lines[cursor];
|
|
5374
|
+
if (/^[A-Za-z_][A-Za-z0-9_-]*:/u.test(candidate)) break;
|
|
5375
|
+
const stripped = stripUnquotedYamlComment(candidate);
|
|
5376
|
+
const closeIndex = findUnquotedClosingBracket(stripped);
|
|
5377
|
+
if (closeIndex !== -1) {
|
|
5378
|
+
segments.push(stripped.slice(0, closeIndex));
|
|
5379
|
+
return Object.freeze({
|
|
5380
|
+
items: parseFlowInnerItems(segments.join(" ").trim()),
|
|
5381
|
+
nextIndex: cursor + 1
|
|
5382
|
+
});
|
|
5383
|
+
}
|
|
5384
|
+
segments.push(stripped);
|
|
5385
|
+
cursor += 1;
|
|
5386
|
+
}
|
|
5387
|
+
return Object.freeze({
|
|
5388
|
+
items: parseFlowInnerItems(segments.join(" ").trim()),
|
|
5389
|
+
nextIndex: cursor
|
|
5390
|
+
});
|
|
5391
|
+
}
|
|
5392
|
+
function collectBlockScalarItems(lines, startIndex) {
|
|
5393
|
+
const rawSegments = [];
|
|
5394
|
+
let cursor = startIndex + 1;
|
|
5395
|
+
while (cursor < lines.length) {
|
|
5396
|
+
const candidate = lines[cursor];
|
|
5397
|
+
if (candidate.trim().length > 0 && !/^[ \t]/u.test(candidate)) break;
|
|
5398
|
+
const stripped = stripUnquotedYamlComment(candidate);
|
|
5399
|
+
if (stripped.length > 0) rawSegments.push(stripped.replace(/^-\s+/u, ""));
|
|
5400
|
+
cursor += 1;
|
|
5401
|
+
}
|
|
5402
|
+
return Object.freeze({
|
|
5403
|
+
items: expandRawToolTokens(rawSegments),
|
|
5404
|
+
nextIndex: cursor
|
|
5405
|
+
});
|
|
5406
|
+
}
|
|
5407
|
+
function collectPlainScalarItems(lines, startIndex, firstValue) {
|
|
5408
|
+
const segments = [firstValue];
|
|
5409
|
+
let cursor = startIndex + 1;
|
|
5410
|
+
while (cursor < lines.length) {
|
|
5411
|
+
const candidate = lines[cursor];
|
|
5412
|
+
if (candidate.trim().length > 0 && !/^[ \t]/u.test(candidate)) break;
|
|
5413
|
+
const stripped = stripUnquotedYamlComment(candidate);
|
|
5414
|
+
if (stripped.length > 0) segments.push(stripped);
|
|
5415
|
+
cursor += 1;
|
|
5416
|
+
}
|
|
5417
|
+
return Object.freeze({
|
|
5418
|
+
items: expandRawToolTokens([segments.join(" ")]),
|
|
5419
|
+
nextIndex: cursor
|
|
5420
|
+
});
|
|
5421
|
+
}
|
|
5422
|
+
function parseFlowInnerItems(inner) {
|
|
5423
|
+
if (inner === "") return Object.freeze([]);
|
|
5424
|
+
return expandRawToolTokens([inner]);
|
|
5425
|
+
}
|
|
5426
|
+
function expandRawToolTokens(segments) {
|
|
5427
|
+
const items = [];
|
|
5428
|
+
for (const segment of segments) for (const quotedOrBare of splitCommaRespectingQuotes(segment)) {
|
|
5429
|
+
const unquoted = stripYamlQuotes(quotedOrBare);
|
|
5430
|
+
if (unquoted.length === 0) continue;
|
|
5431
|
+
for (const atom of splitCommasOutsideParens(unquoted)) {
|
|
5432
|
+
const cleaned = stripYamlQuotes(atom);
|
|
5433
|
+
if (cleaned.length > 0) items.push(cleaned);
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
return Object.freeze(items);
|
|
5437
|
+
}
|
|
5438
|
+
function findUnquotedClosingBracket(input) {
|
|
5439
|
+
let quote = null;
|
|
5440
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
5441
|
+
const ch = input[index];
|
|
5442
|
+
if (quote !== null) {
|
|
5443
|
+
if (ch === quote && input[index - 1] !== "\\") quote = null;
|
|
5444
|
+
continue;
|
|
5445
|
+
}
|
|
5446
|
+
if (ch === "\"" || ch === "'") {
|
|
5447
|
+
quote = ch;
|
|
5448
|
+
continue;
|
|
5449
|
+
}
|
|
5450
|
+
if (ch === "]") return index;
|
|
5451
|
+
}
|
|
5452
|
+
return -1;
|
|
5453
|
+
}
|
|
5454
|
+
function stripUnquotedYamlComment(input) {
|
|
5455
|
+
let quote = null;
|
|
5456
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
5457
|
+
const ch = input[index];
|
|
5458
|
+
if (quote !== null) {
|
|
5459
|
+
if (ch === quote && input[index - 1] !== "\\") quote = null;
|
|
5460
|
+
continue;
|
|
5461
|
+
}
|
|
5462
|
+
if (ch === "\"" || ch === "'") {
|
|
5463
|
+
quote = ch;
|
|
5464
|
+
continue;
|
|
5465
|
+
}
|
|
5466
|
+
if (ch === "#" && (index === 0 || input[index - 1] === " " || input[index - 1] === " ")) return input.slice(0, index).trim();
|
|
5467
|
+
}
|
|
5468
|
+
return input.trim();
|
|
5469
|
+
}
|
|
5470
|
+
function mapClaudeToolsToAntigravity(rawItems) {
|
|
5471
|
+
if (rawItems.length === 0) return Object.freeze([]);
|
|
5472
|
+
const mapped = [];
|
|
5473
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5474
|
+
const addTool = (tool) => {
|
|
5475
|
+
if (!seen.has(tool)) {
|
|
5476
|
+
seen.add(tool);
|
|
5477
|
+
mapped.push(tool);
|
|
5478
|
+
}
|
|
5479
|
+
};
|
|
5480
|
+
for (const rawItem of rawItems) {
|
|
5481
|
+
const trimmed = rawItem.trim();
|
|
5482
|
+
if (trimmed.length === 0) continue;
|
|
5483
|
+
if (NATIVE_ANTIGRAVITY_TOOLS.has(trimmed)) {
|
|
5484
|
+
addTool(trimmed);
|
|
5485
|
+
continue;
|
|
5486
|
+
}
|
|
5487
|
+
const targets = CLAUDE_TO_ANTIGRAVITY_TOOLS[trimmed];
|
|
5488
|
+
if (targets !== void 0) {
|
|
5489
|
+
for (const target of targets) addTool(target);
|
|
5490
|
+
continue;
|
|
5491
|
+
}
|
|
5492
|
+
if (/^Bash\(.+\)$/u.test(trimmed)) {
|
|
5493
|
+
addTool("run_command");
|
|
5494
|
+
addTool("manage_task");
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
return Object.freeze(mapped);
|
|
5498
|
+
}
|
|
5499
|
+
function mapDeniedToolsToAntigravity(rawItems) {
|
|
5500
|
+
if (rawItems.length === 0) return /* @__PURE__ */ new Set();
|
|
5501
|
+
const denied = /* @__PURE__ */ new Set();
|
|
5502
|
+
for (const rawItem of rawItems) {
|
|
5503
|
+
const trimmed = rawItem.trim();
|
|
5504
|
+
if (trimmed.length === 0) continue;
|
|
5505
|
+
const scopedMatch = /^([A-Za-z_][A-Za-z0-9_-]*)\(.*\)$/su.exec(trimmed);
|
|
5506
|
+
const baseName = scopedMatch !== null ? scopedMatch[1] : trimmed;
|
|
5507
|
+
if (NATIVE_ANTIGRAVITY_TOOLS.has(trimmed)) denied.add(trimmed);
|
|
5508
|
+
if (NATIVE_ANTIGRAVITY_TOOLS.has(baseName)) denied.add(baseName);
|
|
5509
|
+
const targets = DENIED_CLAUDE_TO_ANTIGRAVITY_TOOLS[baseName];
|
|
5510
|
+
if (targets !== void 0) for (const target of targets) denied.add(target);
|
|
5511
|
+
}
|
|
5512
|
+
return denied;
|
|
5513
|
+
}
|
|
5514
|
+
function emitToolsYaml(outLines, items) {
|
|
5515
|
+
if (items.length === 0) {
|
|
5516
|
+
outLines.push("tools: []");
|
|
5517
|
+
return;
|
|
5518
|
+
}
|
|
5519
|
+
outLines.push("tools:");
|
|
5520
|
+
for (const item of items) outLines.push(` - ${formatYamlScalar(item)}`);
|
|
5521
|
+
}
|
|
5522
|
+
function formatYamlScalar(value) {
|
|
5523
|
+
return /^[A-Za-z0-9_./:-]+$/u.test(value) ? value : JSON.stringify(value);
|
|
5524
|
+
}
|
|
5525
|
+
function mapAntigravityModel(raw) {
|
|
5526
|
+
const normalized = raw.trim().toLowerCase();
|
|
5527
|
+
if (normalized === "inherit" || normalized === "pro" || normalized === "flash" || normalized === "flash_lite") return normalized;
|
|
5528
|
+
if (normalized === "opus" || normalized.includes("opus")) return "pro";
|
|
5529
|
+
if (normalized === "sonnet" || normalized.includes("sonnet")) return "inherit";
|
|
5530
|
+
if (normalized === "haiku" || normalized.includes("haiku")) return "flash";
|
|
5531
|
+
return normalized.length === 0 ? "inherit" : raw.trim();
|
|
5532
|
+
}
|
|
5533
|
+
function splitCommaRespectingQuotes(input) {
|
|
5534
|
+
const parts = [];
|
|
5535
|
+
let current = "";
|
|
5536
|
+
let quote = null;
|
|
5537
|
+
let parenDepth = 0;
|
|
5538
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
5539
|
+
const ch = input[index];
|
|
5540
|
+
if (quote !== null) {
|
|
5541
|
+
current += ch;
|
|
5542
|
+
if (ch === quote && input[index - 1] !== "\\") quote = null;
|
|
5543
|
+
continue;
|
|
5544
|
+
}
|
|
5545
|
+
if (ch === "\"" || ch === "'") {
|
|
5546
|
+
quote = ch;
|
|
5547
|
+
current += ch;
|
|
5548
|
+
continue;
|
|
5549
|
+
}
|
|
5550
|
+
if (ch === "(") {
|
|
5551
|
+
parenDepth += 1;
|
|
5552
|
+
current += ch;
|
|
5553
|
+
continue;
|
|
5554
|
+
}
|
|
5555
|
+
if (ch === ")" && parenDepth > 0) {
|
|
5556
|
+
parenDepth -= 1;
|
|
5557
|
+
current += ch;
|
|
5558
|
+
continue;
|
|
5559
|
+
}
|
|
5560
|
+
if (ch === "," && parenDepth === 0) {
|
|
5561
|
+
parts.push(current.trim());
|
|
5562
|
+
current = "";
|
|
5563
|
+
continue;
|
|
5564
|
+
}
|
|
5565
|
+
current += ch;
|
|
5566
|
+
}
|
|
5567
|
+
parts.push(current.trim());
|
|
5568
|
+
return parts;
|
|
5569
|
+
}
|
|
5570
|
+
function splitCommasOutsideParens(input) {
|
|
5571
|
+
const parts = [];
|
|
5572
|
+
let current = "";
|
|
5573
|
+
let parenDepth = 0;
|
|
5574
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
5575
|
+
const ch = input[index];
|
|
5576
|
+
if (ch === "(") {
|
|
5577
|
+
parenDepth += 1;
|
|
5578
|
+
current += ch;
|
|
5579
|
+
continue;
|
|
5580
|
+
}
|
|
5581
|
+
if (ch === ")" && parenDepth > 0) {
|
|
5582
|
+
parenDepth -= 1;
|
|
5583
|
+
current += ch;
|
|
5584
|
+
continue;
|
|
5585
|
+
}
|
|
5586
|
+
if (ch === "," && parenDepth === 0) {
|
|
5587
|
+
parts.push(current.trim());
|
|
5588
|
+
current = "";
|
|
5589
|
+
continue;
|
|
5590
|
+
}
|
|
5591
|
+
current += ch;
|
|
5592
|
+
}
|
|
5593
|
+
parts.push(current.trim());
|
|
5594
|
+
return parts;
|
|
5595
|
+
}
|
|
5596
|
+
function stripYamlQuotes(input) {
|
|
5597
|
+
const trimmed = input.trim();
|
|
5598
|
+
if (trimmed.length >= 2 && (trimmed.startsWith("\"") && trimmed.endsWith("\"") || trimmed.startsWith("'") && trimmed.endsWith("'"))) return trimmed.slice(1, -1).trim();
|
|
5599
|
+
return trimmed;
|
|
5600
|
+
}
|
|
5601
|
+
function normalizeAuthor(value) {
|
|
5602
|
+
const text = nonEmptyString(value);
|
|
5603
|
+
if (text !== null) return text;
|
|
5604
|
+
const record = asRecord(value);
|
|
5605
|
+
if (record === null) return null;
|
|
5606
|
+
const name = nonEmptyString(record.name);
|
|
5607
|
+
if (name === null) return null;
|
|
5608
|
+
const url = httpsUrlString(record.url);
|
|
5609
|
+
return url === null ? Object.freeze({ name }) : Object.freeze({
|
|
5610
|
+
name,
|
|
5611
|
+
url
|
|
5612
|
+
});
|
|
5613
|
+
}
|
|
5614
|
+
function normalizeRepository(value) {
|
|
5615
|
+
const url = httpsUrlString(value);
|
|
5616
|
+
if (url !== null) return url;
|
|
5617
|
+
const record = asRecord(value);
|
|
5618
|
+
if (record === null) return null;
|
|
5619
|
+
const recordUrl = httpsUrlString(record.url);
|
|
5620
|
+
if (recordUrl === null) return null;
|
|
5621
|
+
return record.type === "git" ? Object.freeze({
|
|
5622
|
+
type: "git",
|
|
5623
|
+
url: recordUrl
|
|
5624
|
+
}) : recordUrl;
|
|
5625
|
+
}
|
|
5626
|
+
function normalizeSuggestedPrompts(value) {
|
|
5627
|
+
if (!Array.isArray(value)) return null;
|
|
5628
|
+
const prompts = value.map(nonEmptyString).filter((entry) => entry !== null).slice(0, 3);
|
|
5629
|
+
return prompts.length === 0 ? null : Object.freeze(prompts);
|
|
5630
|
+
}
|
|
5631
|
+
function isValidLogoPath(candidate, projectedAssets) {
|
|
5632
|
+
if (!isCanonicalRelativePath$2(candidate)) return false;
|
|
5633
|
+
const lower = candidate.toLowerCase();
|
|
5634
|
+
if (!ANTIGRAVITY_LOGO_EXTENSIONS.some((ext) => lower.endsWith(ext))) return false;
|
|
5635
|
+
return projectedAssets.has(candidate);
|
|
5636
|
+
}
|
|
5637
|
+
function httpsUrlString(value) {
|
|
5638
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
5639
|
+
if (/[\s\\]/u.test(value) || !/^https:\/\/[^/\\?#\s]/u.test(value)) return null;
|
|
5640
|
+
try {
|
|
5641
|
+
const parsed = new URL(value);
|
|
5642
|
+
return parsed.protocol === "https:" && parsed.href === value ? value : null;
|
|
5643
|
+
} catch {
|
|
5644
|
+
return null;
|
|
5645
|
+
}
|
|
5646
|
+
}
|
|
5647
|
+
function isRemoteHttpsUrl(candidate) {
|
|
5648
|
+
if (httpsUrlString(candidate) === null) return false;
|
|
5649
|
+
let parsed;
|
|
5650
|
+
try {
|
|
5651
|
+
parsed = new URL(candidate);
|
|
5652
|
+
} catch {
|
|
5653
|
+
return false;
|
|
5654
|
+
}
|
|
5655
|
+
const host = parsed.hostname.toLowerCase().replace(/\.+$/u, "");
|
|
5656
|
+
if (host === "" || host === "localhost" || host.endsWith(".localhost") || host === "::1" || host === "[::1]" || host === "[::]" || host === "[::ffff:0:0]" || /^\[::ffff:7f[0-9a-f]{2}:[0-9a-f]{1,4}\]$/u.test(host) || host === "0.0.0.0" || /^127(?:\.\d{1,3}){3}$/u.test(host)) return false;
|
|
5657
|
+
return true;
|
|
5658
|
+
}
|
|
5659
|
+
function parseJsonRecord(bytes, label) {
|
|
5660
|
+
const decoded = decodeUtf8(bytes, label);
|
|
5661
|
+
if (!decoded.ok) return decoded;
|
|
5662
|
+
let parsed;
|
|
5663
|
+
try {
|
|
5664
|
+
parsed = JSON.parse(decoded.text);
|
|
5665
|
+
} catch {
|
|
5666
|
+
return invalid$2(`${label} is not valid JSON`);
|
|
5667
|
+
}
|
|
5668
|
+
const record = asRecord(parsed);
|
|
5669
|
+
if (record === null) return invalid$2(`${label} must contain a JSON object`);
|
|
5670
|
+
return Object.freeze({
|
|
5671
|
+
ok: true,
|
|
5672
|
+
record
|
|
5673
|
+
});
|
|
5674
|
+
}
|
|
5675
|
+
function decodeUtf8(bytes, label) {
|
|
5676
|
+
try {
|
|
5677
|
+
return Object.freeze({
|
|
5678
|
+
ok: true,
|
|
5679
|
+
text: utf8Decoder$1.decode(bytes)
|
|
5680
|
+
});
|
|
5681
|
+
} catch {
|
|
5682
|
+
return invalid$2(`${label} is not valid UTF-8`);
|
|
5683
|
+
}
|
|
5684
|
+
}
|
|
5685
|
+
function asRecord(value) {
|
|
5686
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
5687
|
+
}
|
|
5688
|
+
function nonEmptyString(value) {
|
|
5689
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
5690
|
+
}
|
|
5691
|
+
function isCanonicalRelativePath$2(value) {
|
|
5692
|
+
return value.length > 0 && value.length <= 1024 && !value.startsWith("/") && !value.endsWith("/") && !value.includes("\\") && !/[\u0000-\u001f\u007f]/u.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
5693
|
+
}
|
|
5694
|
+
function invalid$2(detail) {
|
|
5695
|
+
return Object.freeze({
|
|
5696
|
+
ok: false,
|
|
5697
|
+
detail
|
|
5698
|
+
});
|
|
5699
|
+
}
|
|
5700
|
+
function compareText$10(left, right) {
|
|
5701
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
5702
|
+
}
|
|
5703
|
+
//#endregion
|
|
4794
5704
|
//#region ../../resources/native-agent-provider/contract.ts
|
|
4795
5705
|
const BoundedTextSchema = Type.String({
|
|
4796
5706
|
minLength: 1,
|
|
@@ -4814,6 +5724,16 @@ const PluginSelectorSchema$1 = Type.String({
|
|
|
4814
5724
|
pattern: "^[a-z0-9][a-z0-9._-]*@[a-z0-9][a-z0-9_-]*$",
|
|
4815
5725
|
maxLength: 256
|
|
4816
5726
|
});
|
|
5727
|
+
const ObservedPluginNameSchema = Type.String({
|
|
5728
|
+
pattern: "^[^\\u0000-\\u001f\\u007f@/\\\\]{1,256}$",
|
|
5729
|
+
minLength: 1,
|
|
5730
|
+
maxLength: 256
|
|
5731
|
+
});
|
|
5732
|
+
const ObservedPluginSelectorSchema = Type.String({
|
|
5733
|
+
pattern: "^[^\\u0000-\\u001f\\u007f@/\\\\]{1,256}@[a-z0-9][a-z0-9_-]*$",
|
|
5734
|
+
minLength: 3,
|
|
5735
|
+
maxLength: 385
|
|
5736
|
+
});
|
|
4817
5737
|
const RevisionSchema = Type.String({
|
|
4818
5738
|
pattern: "^[^\\s#]+$",
|
|
4819
5739
|
minLength: 1,
|
|
@@ -4825,10 +5745,28 @@ const SparsePathSchema = Refine(Type.String({
|
|
|
4825
5745
|
}), isCanonicalRelativePath$1, () => "Expected one canonical relative POSIX path");
|
|
4826
5746
|
const SparsePathsSchema = Type.Unsafe(Refine(Type.Array(SparsePathSchema, { maxItems: 64 }), isCanonicalDistinctOrder$1, () => "Expected distinct code-unit-sorted sparse paths"));
|
|
4827
5747
|
const NullablePathSchema = Type.Union([CanonicalProviderPathSchema, Type.Null()]);
|
|
4828
|
-
|
|
5748
|
+
/** Admits a canonical provider-reported plugin version string. */
|
|
5749
|
+
const PluginVersionSchema = Type.String({
|
|
4829
5750
|
pattern: "^[0-9A-Za-z][0-9A-Za-z.+_-]*$",
|
|
4830
5751
|
maxLength: 256
|
|
4831
|
-
})
|
|
5752
|
+
});
|
|
5753
|
+
const NullablePluginVersionSchema = Type.Union([PluginVersionSchema, Type.Null()]);
|
|
5754
|
+
const McpServerIdentitySchema = Type.String({
|
|
5755
|
+
pattern: "^[a-z0-9][a-z0-9_-]*$",
|
|
5756
|
+
minLength: 1,
|
|
5757
|
+
maxLength: 128
|
|
5758
|
+
});
|
|
5759
|
+
const OwnerPluginIdSchema = Type.String({
|
|
5760
|
+
pattern: "^[a-z0-9][a-z0-9._-]*$",
|
|
5761
|
+
minLength: 1,
|
|
5762
|
+
maxLength: 512
|
|
5763
|
+
});
|
|
5764
|
+
/** Admits bounded MCP server names observed in live user-scope provider configuration. */
|
|
5765
|
+
const ObservedMcpServerNameSchema = Type.String({
|
|
5766
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$",
|
|
5767
|
+
minLength: 1,
|
|
5768
|
+
maxLength: 256
|
|
5769
|
+
});
|
|
4832
5770
|
/**
|
|
4833
5771
|
* Admits credential-free HTTPS Git locators that native marketplace adapters can reproduce exactly.
|
|
4834
5772
|
* The canonical form prevents provider-specific URL normalization from changing source identity.
|
|
@@ -4837,8 +5775,20 @@ const CanonicalGitRepositoryUrlSchema = Refine(Type.String({
|
|
|
4837
5775
|
minLength: 14,
|
|
4838
5776
|
maxLength: 2048
|
|
4839
5777
|
}), isCanonicalHttpsGitUrl$1, () => "Expected a canonical HTTPS Git repository URL");
|
|
5778
|
+
/**
|
|
5779
|
+
* Admits credential-free loopback HTTP URLs with an explicit non-default port for host-scoped MCP
|
|
5780
|
+
* servers. Canonical formatting keeps native MCP observations comparable across provider homes.
|
|
5781
|
+
*/
|
|
5782
|
+
const CanonicalLoopbackHttpUrlSchema = Refine(Type.String({
|
|
5783
|
+
minLength: 14,
|
|
5784
|
+
maxLength: 2048
|
|
5785
|
+
}), isCanonicalLoopbackHttpUrl, () => "Expected a canonical loopback HTTP URL with an explicit non-default port");
|
|
4840
5786
|
/** Identifies one native agent provider supported by the closed resource catalog. */
|
|
4841
|
-
const NativeAgentProviderIdSchema = Type.Union([
|
|
5787
|
+
const NativeAgentProviderIdSchema = Type.Union([
|
|
5788
|
+
Type.Literal("claude"),
|
|
5789
|
+
Type.Literal("codex"),
|
|
5790
|
+
Type.Literal("antigravity")
|
|
5791
|
+
], { description: "Identity of one supported native agent provider." });
|
|
4842
5792
|
/**
|
|
4843
5793
|
* Defines the closed operation vocabulary carried through provider execution and diagnostics.
|
|
4844
5794
|
* Provider kernels and lifecycle consumers use these identifiers to preserve operation ownership.
|
|
@@ -4852,7 +5802,9 @@ const NativeAgentProviderOperationSchema = Type.Union([
|
|
|
4852
5802
|
Type.Literal("plugin-files-read"),
|
|
4853
5803
|
Type.Literal("plugin-install"),
|
|
4854
5804
|
Type.Literal("plugin-enable"),
|
|
4855
|
-
Type.Literal("plugin-remove")
|
|
5805
|
+
Type.Literal("plugin-remove"),
|
|
5806
|
+
Type.Literal("mcp-add"),
|
|
5807
|
+
Type.Literal("mcp-remove")
|
|
4856
5808
|
]);
|
|
4857
5809
|
/**
|
|
4858
5810
|
* Records how far a native command progressed when an operation fails.
|
|
@@ -4892,8 +5844,26 @@ Type.Readonly(Type.Object({
|
|
|
4892
5844
|
}, { additionalProperties: false }));
|
|
4893
5845
|
/** Validates the explicit provider home supplied for one acquired native session. */
|
|
4894
5846
|
const NativeProviderHomeSchema = CanonicalProviderPathSchema;
|
|
4895
|
-
/** Admits the explicit home for one native-provider session. */
|
|
4896
|
-
const NativeProviderSessionInputSchema = Type.Readonly(Type.Object({
|
|
5847
|
+
/** Admits the explicit home and optional disposable-root boundary for one native-provider session. */
|
|
5848
|
+
const NativeProviderSessionInputSchema = Type.Readonly(Type.Object({
|
|
5849
|
+
home: NativeProviderHomeSchema,
|
|
5850
|
+
disposableRoot: Type.Optional(CanonicalProviderPathSchema)
|
|
5851
|
+
}, { additionalProperties: false }));
|
|
5852
|
+
/** Caps marketplace inventory accepted from one native provider command. */
|
|
5853
|
+
const MAX_NATIVE_PROVIDER_MARKETPLACES = 1024;
|
|
5854
|
+
/** Caps plugin inventory accepted from one native provider command. */
|
|
5855
|
+
const MAX_NATIVE_PROVIDER_PLUGINS = 4096;
|
|
5856
|
+
/** Caps user-scope MCP server inventory accepted from one native provider observation. */
|
|
5857
|
+
const MAX_NATIVE_PROVIDER_MCP_SERVERS = 1024;
|
|
5858
|
+
/**
|
|
5859
|
+
* Admits optional observation controls for one native inventory read.
|
|
5860
|
+
* Callers may skip reading user-scope MCP configuration when neither desired content nor a
|
|
5861
|
+
* relevant managed MCP ledger owner requires MCP server observation.
|
|
5862
|
+
*/
|
|
5863
|
+
const NativeProviderInventoryOptionsSchema = Type.Readonly(Type.Object({
|
|
5864
|
+
observeMcpServers: Type.Optional(Type.Boolean()),
|
|
5865
|
+
relevantOwnerPluginIds: Type.Optional(Type.Readonly(Type.Array(OwnerPluginIdSchema, { maxItems: MAX_NATIVE_PROVIDER_PLUGINS })))
|
|
5866
|
+
}, { additionalProperties: false }));
|
|
4897
5867
|
/**
|
|
4898
5868
|
* Admits an explicit Git or local source for a native marketplace-add operation.
|
|
4899
5869
|
* Provider adapters consume this neutral request and own its translation to vendor command
|
|
@@ -4922,7 +5892,10 @@ const NativeProviderCapabilitySchema = Type.Union([
|
|
|
4922
5892
|
Type.Literal("plugin-enable"),
|
|
4923
5893
|
Type.Literal("plugin-disable"),
|
|
4924
5894
|
Type.Literal("plugin-remove"),
|
|
4925
|
-
Type.Literal("plugin-update")
|
|
5895
|
+
Type.Literal("plugin-update"),
|
|
5896
|
+
Type.Literal("mcp-list"),
|
|
5897
|
+
Type.Literal("mcp-add"),
|
|
5898
|
+
Type.Literal("mcp-remove")
|
|
4926
5899
|
]);
|
|
4927
5900
|
const CodexNativeProviderCapabilitySchema = Type.Union([
|
|
4928
5901
|
Type.Literal("marketplace-list"),
|
|
@@ -4930,9 +5903,24 @@ const CodexNativeProviderCapabilitySchema = Type.Union([
|
|
|
4930
5903
|
Type.Literal("marketplace-remove"),
|
|
4931
5904
|
Type.Literal("plugin-list"),
|
|
4932
5905
|
Type.Literal("plugin-install"),
|
|
4933
|
-
Type.Literal("plugin-remove")
|
|
5906
|
+
Type.Literal("plugin-remove"),
|
|
5907
|
+
Type.Literal("mcp-list"),
|
|
5908
|
+
Type.Literal("mcp-add"),
|
|
5909
|
+
Type.Literal("mcp-remove")
|
|
4934
5910
|
]);
|
|
4935
5911
|
const ClaudeNativeProviderCapabilitySchema = NativeProviderCapabilitySchema;
|
|
5912
|
+
const AntigravityNativeProviderCapabilitySchema = Type.Union([
|
|
5913
|
+
Type.Literal("marketplace-list"),
|
|
5914
|
+
Type.Literal("marketplace-add"),
|
|
5915
|
+
Type.Literal("marketplace-remove"),
|
|
5916
|
+
Type.Literal("plugin-list"),
|
|
5917
|
+
Type.Literal("plugin-install"),
|
|
5918
|
+
Type.Literal("plugin-enable"),
|
|
5919
|
+
Type.Literal("plugin-disable"),
|
|
5920
|
+
Type.Literal("plugin-remove"),
|
|
5921
|
+
Type.Literal("mcp-add"),
|
|
5922
|
+
Type.Literal("mcp-remove")
|
|
5923
|
+
]);
|
|
4936
5924
|
const nativeCapabilityProperties = {
|
|
4937
5925
|
home: CanonicalProviderPathSchema,
|
|
4938
5926
|
version: BoundedTextSchema
|
|
@@ -4942,15 +5930,23 @@ const nativeCapabilityProperties = {
|
|
|
4942
5930
|
* Provider-specific constraints keep lifecycle orchestration from assuming operations an adapter
|
|
4943
5931
|
* cannot implement.
|
|
4944
5932
|
*/
|
|
4945
|
-
const NativeProviderCapabilitiesSchema = Type.Union([
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
5933
|
+
const NativeProviderCapabilitiesSchema = Type.Union([
|
|
5934
|
+
ReadonlyObject(Type.Object({
|
|
5935
|
+
...nativeCapabilityProperties,
|
|
5936
|
+
provider: Type.Literal("codex"),
|
|
5937
|
+
capabilities: Refine(Type.Array(CodexNativeProviderCapabilitySchema, { maxItems: 9 }), (capabilities) => new Set(capabilities).size === capabilities.length, () => "Codex capabilities must be distinct")
|
|
5938
|
+
}), { additionalProperties: false }),
|
|
5939
|
+
ReadonlyObject(Type.Object({
|
|
5940
|
+
...nativeCapabilityProperties,
|
|
5941
|
+
provider: Type.Literal("claude"),
|
|
5942
|
+
capabilities: Refine(Type.Array(ClaudeNativeProviderCapabilitySchema, { maxItems: 13 }), (capabilities) => capabilities.includes("plugin-enable") && new Set(capabilities).size === capabilities.length, () => "Claude capabilities must include distinct plugin enablement")
|
|
5943
|
+
}), { additionalProperties: false }),
|
|
5944
|
+
ReadonlyObject(Type.Object({
|
|
5945
|
+
...nativeCapabilityProperties,
|
|
5946
|
+
provider: Type.Literal("antigravity"),
|
|
5947
|
+
capabilities: Refine(Type.Array(AntigravityNativeProviderCapabilitySchema, { maxItems: 10 }), (capabilities) => capabilities.includes("plugin-enable") && new Set(capabilities).size === capabilities.length, () => "Antigravity capabilities must include distinct plugin enablement")
|
|
5948
|
+
}), { additionalProperties: false })
|
|
5949
|
+
]);
|
|
4954
5950
|
/**
|
|
4955
5951
|
* Describes the source evidence a native provider actually reports for an installed marketplace.
|
|
4956
5952
|
* Inventory consumers compare these observations with curated intent without treating them as
|
|
@@ -4979,27 +5975,47 @@ const NativeProviderMarketplaceObservationSchema = Type.Readonly(Type.Object({
|
|
|
4979
5975
|
* decisions owned by the lifecycle service.
|
|
4980
5976
|
*/
|
|
4981
5977
|
const NativeProviderPluginObservationSchema = Type.Readonly(Type.Object({
|
|
4982
|
-
selector:
|
|
5978
|
+
selector: ObservedPluginSelectorSchema,
|
|
4983
5979
|
marketplaceIdentity: MarketplaceIdentitySchema$2,
|
|
4984
|
-
name:
|
|
4985
|
-
pattern: "^[a-z0-9][a-z0-9._-]*$",
|
|
4986
|
-
maxLength: 128
|
|
4987
|
-
}),
|
|
5980
|
+
name: ObservedPluginNameSchema,
|
|
4988
5981
|
installed: Type.Boolean(),
|
|
4989
5982
|
enabled: Type.Union([Type.Boolean(), Type.Null()]),
|
|
4990
5983
|
version: NullablePluginVersionSchema,
|
|
4991
5984
|
root: NullablePathSchema
|
|
4992
5985
|
}, { additionalProperties: false }));
|
|
4993
5986
|
/**
|
|
5987
|
+
* Validates one user-scope MCP server entry from live native-provider inventory.
|
|
5988
|
+
* Transport, URL, and enablement feed collision safety and host-scoped HTTP MCP convergence
|
|
5989
|
+
* while preserving unmanaged foreign entries in the explicit home.
|
|
5990
|
+
*/
|
|
5991
|
+
const NativeProviderMcpServerObservationSchema = Type.Readonly(Type.Object({
|
|
5992
|
+
name: ObservedMcpServerNameSchema,
|
|
5993
|
+
transport: Type.Union([Type.Literal("http"), Type.Literal("other")]),
|
|
5994
|
+
url: Type.Union([BoundedTextSchema, Type.Null()]),
|
|
5995
|
+
enabled: Type.Union([Type.Boolean(), Type.Null()])
|
|
5996
|
+
}, { additionalProperties: false }));
|
|
5997
|
+
/**
|
|
5998
|
+
* Validates one Habitat-managed host-scoped HTTP MCP ownership record persisted in
|
|
5999
|
+
* `<home>/.habitat-host-mcp-ledger.json` (or `<geminiRoot>/config/.habitat-host-mcp-ledger.json`
|
|
6000
|
+
* on Antigravity) outside installed plugin directories.
|
|
6001
|
+
*/
|
|
6002
|
+
const NativeManagedMcpServerRecordSchema = Type.Readonly(Type.Object({
|
|
6003
|
+
name: McpServerIdentitySchema,
|
|
6004
|
+
url: CanonicalLoopbackHttpUrlSchema,
|
|
6005
|
+
ownerPluginId: OwnerPluginIdSchema
|
|
6006
|
+
}, { additionalProperties: false }));
|
|
6007
|
+
/**
|
|
4994
6008
|
* Validates a complete, canonically ordered native-provider inventory snapshot.
|
|
4995
6009
|
* Stable ordering and distinct identities make provider observations deterministic for lifecycle
|
|
4996
6010
|
* comparison and diagnostics.
|
|
4997
6011
|
*/
|
|
4998
6012
|
const NativeProviderInventorySchema = Refine(Type.Readonly(Type.Object({
|
|
4999
6013
|
provider: NativeAgentProviderIdSchema,
|
|
5000
|
-
marketplaces: Type.Readonly(Type.Array(NativeProviderMarketplaceObservationSchema, { maxItems:
|
|
5001
|
-
plugins: Type.Readonly(Type.Array(NativeProviderPluginObservationSchema, { maxItems:
|
|
5002
|
-
|
|
6014
|
+
marketplaces: Type.Readonly(Type.Array(NativeProviderMarketplaceObservationSchema, { maxItems: MAX_NATIVE_PROVIDER_MARKETPLACES })),
|
|
6015
|
+
plugins: Type.Readonly(Type.Array(NativeProviderPluginObservationSchema, { maxItems: MAX_NATIVE_PROVIDER_PLUGINS })),
|
|
6016
|
+
mcpServers: Type.Readonly(Type.Array(NativeProviderMcpServerObservationSchema, { maxItems: MAX_NATIVE_PROVIDER_MCP_SERVERS })),
|
|
6017
|
+
managedMcpServers: Type.Readonly(Type.Array(NativeManagedMcpServerRecordSchema, { maxItems: MAX_NATIVE_PROVIDER_MCP_SERVERS }))
|
|
6018
|
+
}, { additionalProperties: false })), (inventory) => isCanonicalDistinctOrder$1(inventory.marketplaces.map((marketplace) => marketplace.identity)) && isCanonicalDistinctOrder$1(inventory.plugins.map((plugin) => plugin.selector)) && isCanonicalDistinctOrder$1(inventory.mcpServers.map((server) => server.name)) && isCanonicalDistinctOrder$1(inventory.managedMcpServers.map((server) => server.name)), () => "Expected canonical distinct marketplace identities, plugin selectors, MCP server names, and managed MCP server names");
|
|
5003
6019
|
/**
|
|
5004
6020
|
* Admits the marketplace identity for one explicit native removal.
|
|
5005
6021
|
* The narrow request prevents mutation adapters from receiving unrelated lifecycle state.
|
|
@@ -5010,6 +6026,22 @@ const NativeProviderMarketplaceIdentityInputSchema = Type.Readonly(Type.Object({
|
|
|
5010
6026
|
* Provider adapters translate this shared selector into their vendor-specific commands.
|
|
5011
6027
|
*/
|
|
5012
6028
|
const NativeProviderPluginSelectorInputSchema = Type.Readonly(Type.Object({ selector: PluginSelectorSchema$1 }, { additionalProperties: false }));
|
|
6029
|
+
/**
|
|
6030
|
+
* Admits the canonical server name, loopback HTTP URL, and owning plugin identity for one native
|
|
6031
|
+
* MCP add operation. Provider adapters record ownership in `<home>/.habitat-host-mcp-ledger.json`
|
|
6032
|
+
* (or `<geminiRoot>/config/.habitat-host-mcp-ledger.json` on Antigravity) before running their
|
|
6033
|
+
* user-scoped HTTP MCP command.
|
|
6034
|
+
*/
|
|
6035
|
+
const NativeProviderMcpServerAddInputSchema = Type.Readonly(Type.Object({
|
|
6036
|
+
name: McpServerIdentitySchema,
|
|
6037
|
+
url: CanonicalLoopbackHttpUrlSchema,
|
|
6038
|
+
ownerPluginId: OwnerPluginIdSchema
|
|
6039
|
+
}, { additionalProperties: false }));
|
|
6040
|
+
/**
|
|
6041
|
+
* Admits the canonical server name for one explicit native MCP removal operation.
|
|
6042
|
+
* The narrow request prevents adapters from receiving unrelated lifecycle state.
|
|
6043
|
+
*/
|
|
6044
|
+
const NativeProviderMcpServerRemoveInputSchema = Type.Readonly(Type.Object({ name: McpServerIdentitySchema }, { additionalProperties: false }));
|
|
5013
6045
|
/** Caps the number of installed plugin files observed in one provider request. */
|
|
5014
6046
|
const MAX_NATIVE_PROVIDER_PLUGIN_FILES = 16384;
|
|
5015
6047
|
/** Caps the bytes admitted for any single installed plugin file. */
|
|
@@ -5072,59 +6104,193 @@ const NativeProviderPluginFileTooLargeSchema = Type.Readonly(Type.Object({
|
|
|
5072
6104
|
relativePath: SparsePathSchema
|
|
5073
6105
|
}, { additionalProperties: false }));
|
|
5074
6106
|
/**
|
|
5075
|
-
* Unifies read, missing, and bounded-too-large outcomes for one requested plugin file.
|
|
5076
|
-
* Native sessions return this closed result set to lifecycle verification.
|
|
6107
|
+
* Unifies read, missing, and bounded-too-large outcomes for one requested plugin file.
|
|
6108
|
+
* Native sessions return this closed result set to lifecycle verification.
|
|
6109
|
+
*/
|
|
6110
|
+
const NativeProviderPluginFileObservationSchema = Type.Union([
|
|
6111
|
+
NativeProviderPluginFileReadSchema,
|
|
6112
|
+
NativeProviderPluginFileMissingSchema,
|
|
6113
|
+
NativeProviderPluginFileTooLargeSchema
|
|
6114
|
+
]);
|
|
6115
|
+
/**
|
|
6116
|
+
* Validates a bounded, canonically ordered set of distinct file observations for one plugin.
|
|
6117
|
+
* Service policy separately correlates the observations with the requested paths.
|
|
6118
|
+
*/
|
|
6119
|
+
const NativeProviderPluginFilesSchema = Refine(Type.Readonly(Type.Object({
|
|
6120
|
+
selector: PluginSelectorSchema$1,
|
|
6121
|
+
files: Type.Unsafe(Type.Array(NativeProviderPluginFileObservationSchema, {
|
|
6122
|
+
minItems: 1,
|
|
6123
|
+
maxItems: MAX_NATIVE_PROVIDER_PLUGIN_FILES
|
|
6124
|
+
}))
|
|
6125
|
+
}, { additionalProperties: false })), (input) => isCanonicalDistinctOrder$1(input.files.map((file) => file.relativePath)), () => "Expected one canonical observation per plugin file");
|
|
6126
|
+
Type.Readonly(Type.Object({
|
|
6127
|
+
provider: NativeAgentProviderIdSchema,
|
|
6128
|
+
operation: NativeAgentProviderOperationSchema,
|
|
6129
|
+
commandPhase: Type.Literal("command-returned")
|
|
6130
|
+
}, { additionalProperties: false }));
|
|
6131
|
+
function isCanonicalAbsolutePath$1(value) {
|
|
6132
|
+
return value.startsWith("/") && value !== "/" && !value.endsWith("/") && !value.includes("//") && !value.includes("\\") && !/[\u0000-\u001f\u007f]/u.test(value) && value.split("/").slice(1).every((part) => part !== "" && part !== "." && part !== "..");
|
|
6133
|
+
}
|
|
6134
|
+
function isCanonicalHttpsGitUrl$1(value) {
|
|
6135
|
+
let parsed;
|
|
6136
|
+
try {
|
|
6137
|
+
parsed = new URL(value);
|
|
6138
|
+
} catch {
|
|
6139
|
+
return false;
|
|
6140
|
+
}
|
|
6141
|
+
return parsed.protocol === "https:" && parsed.username === "" && parsed.password === "" && parsed.port === "" && parsed.search === "" && parsed.hash === "" && parsed.hostname === parsed.hostname.toLowerCase() && parsed.pathname.startsWith("/") && parsed.pathname.endsWith(".git") && parsed.toString() === value;
|
|
6142
|
+
}
|
|
6143
|
+
function isCanonicalLoopbackHttpUrl(value) {
|
|
6144
|
+
let parsed;
|
|
6145
|
+
try {
|
|
6146
|
+
parsed = new URL(value);
|
|
6147
|
+
} catch {
|
|
6148
|
+
return false;
|
|
6149
|
+
}
|
|
6150
|
+
const port = parsed.port === "" ? NaN : Number(parsed.port);
|
|
6151
|
+
return parsed.protocol === "http:" && (parsed.hostname === "127.0.0.1" || parsed.hostname === "localhost" || parsed.hostname === "[::1]") && parsed.port !== "" && Number.isSafeInteger(port) && port >= 1 && port <= 65535 && port !== 80 && parsed.username === "" && parsed.password === "" && parsed.search === "" && parsed.hash === "" && parsed.pathname.startsWith("/") && parsed.toString() === value;
|
|
6152
|
+
}
|
|
6153
|
+
function isCanonicalRelativePath$1(value) {
|
|
6154
|
+
return value.length > 0 && value.length <= 1024 && !value.startsWith("/") && !value.endsWith("/") && !value.includes("\\") && !/[\u0000-\u001f\u007f]/u.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
6155
|
+
}
|
|
6156
|
+
function isCanonicalDistinctOrder$1(values) {
|
|
6157
|
+
for (let index = 1; index < values.length; index += 1) if (values[index - 1] >= values[index]) return false;
|
|
6158
|
+
return true;
|
|
6159
|
+
}
|
|
6160
|
+
function hasBoundedDistinctFileRequests(input) {
|
|
6161
|
+
return isCanonicalDistinctOrder$1(input.files.map((file) => file.relativePath)) && input.files.reduce((total, file) => total + file.maxBytes, 0) <= 67108864;
|
|
6162
|
+
}
|
|
6163
|
+
//#endregion
|
|
6164
|
+
//#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/model/dto/selected-content.ts
|
|
6165
|
+
const MAX_SELECTED_ISSUES = 256;
|
|
6166
|
+
const MAX_SELECTED_ISSUE_DETAIL = 4096;
|
|
6167
|
+
/** Maximum host-scoped HTTP MCP servers admitted across one selected release set. */
|
|
6168
|
+
const MAX_HOST_MCP_SERVERS = 1024;
|
|
6169
|
+
const MarketplaceIdentitySchema$1 = Type.String({
|
|
6170
|
+
minLength: 1,
|
|
6171
|
+
maxLength: 128,
|
|
6172
|
+
pattern: "^[a-z0-9][a-z0-9_-]*$"
|
|
6173
|
+
});
|
|
6174
|
+
const AntigravityBundleOmittedMcpServerReasonSchema = Type.Union([
|
|
6175
|
+
Type.Literal("unsupported-transport"),
|
|
6176
|
+
Type.Literal("non-remote-https-url"),
|
|
6177
|
+
Type.Literal("requires-variables"),
|
|
6178
|
+
Type.Literal("invalid-config")
|
|
6179
|
+
]);
|
|
6180
|
+
/** Validates a canonical host-scoped HTTP MCP server identifier. */
|
|
6181
|
+
const HostMcpServerNameSchema = Type.String({
|
|
6182
|
+
minLength: 1,
|
|
6183
|
+
maxLength: 128,
|
|
6184
|
+
pattern: "^[a-z0-9][a-z0-9_-]*$"
|
|
6185
|
+
});
|
|
6186
|
+
/** Validates the wire structure of a canonical loopback HTTP MCP endpoint URL. */
|
|
6187
|
+
const HostMcpServerUrlSchema = Type.String({
|
|
6188
|
+
minLength: 14,
|
|
6189
|
+
maxLength: 2048,
|
|
6190
|
+
pattern: "^http://(?:127\\.0\\.0\\.1|localhost|\\[::1\\]):(?!80/)[1-9][0-9]{0,4}/[^\\s#?]*$"
|
|
6191
|
+
});
|
|
6192
|
+
/** Describes one host-scoped loopback HTTP MCP server derived from a selected plugin payload. */
|
|
6193
|
+
const SelectedHostMcpServerSchema = ReadonlyObject(Type.Object({
|
|
6194
|
+
name: HostMcpServerNameSchema,
|
|
6195
|
+
url: HostMcpServerUrlSchema,
|
|
6196
|
+
ownerPluginId: PluginIdSchema
|
|
6197
|
+
}), { additionalProperties: false });
|
|
6198
|
+
/** Describes one payload file whose exact bytes a provider operation must verify. */
|
|
6199
|
+
const SelectedContentFileSchema = PayloadManifestEntrySchema;
|
|
6200
|
+
/** Identifies one `.mcp.json` server omitted from Antigravity's projected `mcp_config.json`. */
|
|
6201
|
+
const AntigravityOmittedMcpServerSchema = ReadonlyObject(Type.Object({
|
|
6202
|
+
name: Type.String({ maxLength: 256 }),
|
|
6203
|
+
reason: AntigravityBundleOmittedMcpServerReasonSchema
|
|
6204
|
+
}), { additionalProperties: false });
|
|
6205
|
+
/**
|
|
6206
|
+
* Describes one selected plugin and the immutable ownership and payload facts used during
|
|
6207
|
+
* provider convergence.
|
|
6208
|
+
*/
|
|
6209
|
+
const SelectedContentMemberSchema = ReadonlyObject(Type.Object({
|
|
6210
|
+
pluginId: PluginIdSchema,
|
|
6211
|
+
aliases: ReadonlyObject(Type.Array(OwnershipIdentitySchema), {
|
|
6212
|
+
maxItems: MAX_OWNERSHIP_CLAIMS,
|
|
6213
|
+
uniqueItems: true
|
|
6214
|
+
}),
|
|
6215
|
+
payloadDigest: PayloadDigestSchema,
|
|
6216
|
+
releaseDigest: ReleaseDigestSchema,
|
|
6217
|
+
manifest: ReadonlyObject(Type.Array(SelectedContentFileSchema), {
|
|
6218
|
+
minItems: 1,
|
|
6219
|
+
maxItems: MAX_PAYLOAD_ENTRIES_PER_MEMBER,
|
|
6220
|
+
uniqueItems: true
|
|
6221
|
+
}),
|
|
6222
|
+
antigravityManifest: Type.Union([ReadonlyObject(Type.Array(SelectedContentFileSchema), {
|
|
6223
|
+
minItems: 1,
|
|
6224
|
+
maxItems: MAX_PAYLOAD_ENTRIES_PER_MEMBER,
|
|
6225
|
+
uniqueItems: true
|
|
6226
|
+
}), Type.Null()]),
|
|
6227
|
+
antigravityOmittedMcpServers: ReadonlyObject(Type.Array(AntigravityOmittedMcpServerSchema), {
|
|
6228
|
+
maxItems: MAX_PAYLOAD_ENTRIES_PER_MEMBER,
|
|
6229
|
+
uniqueItems: true
|
|
6230
|
+
})
|
|
6231
|
+
}), { additionalProperties: false });
|
|
6232
|
+
const selectedContentProperties = {
|
|
6233
|
+
contentAuthority: ContentAuthoritySchema,
|
|
6234
|
+
repositoryIdentity: RepositoryIdentitySchema$1,
|
|
6235
|
+
sourceCommit: GitCommitIdSchema,
|
|
6236
|
+
sourceTree: GitTreeIdSchema,
|
|
6237
|
+
releaseInputDigest: ReleaseInputDigestSchema,
|
|
6238
|
+
marketplace: ReadonlyObject(Type.Object({
|
|
6239
|
+
identity: MarketplaceIdentitySchema$1,
|
|
6240
|
+
source: NativeMarketplaceSourceSchema
|
|
6241
|
+
}), { additionalProperties: false }),
|
|
6242
|
+
members: ReadonlyObject(Type.Array(SelectedContentMemberSchema), {
|
|
6243
|
+
minItems: 1,
|
|
6244
|
+
maxItems: MAX_RELEASE_MEMBERS,
|
|
6245
|
+
uniqueItems: true
|
|
6246
|
+
}),
|
|
6247
|
+
hostMcpServers: BoundedReadonlyArray(SelectedHostMcpServerSchema, { maxItems: MAX_HOST_MCP_SERVERS })
|
|
6248
|
+
};
|
|
6249
|
+
/**
|
|
6250
|
+
* Defines the complete provider-owned selection that status, test, and sync inspect or
|
|
6251
|
+
* converge without becoming a new source authority.
|
|
5077
6252
|
*/
|
|
5078
|
-
const
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
6253
|
+
const SelectedContentSchema = Type.Union([ReadonlyObject(Type.Object({
|
|
6254
|
+
...selectedContentProperties,
|
|
6255
|
+
selectionKind: Type.Literal("targeted"),
|
|
6256
|
+
releaseSetDigest: Type.Null()
|
|
6257
|
+
}), { additionalProperties: false }), ReadonlyObject(Type.Object({
|
|
6258
|
+
...selectedContentProperties,
|
|
6259
|
+
selectionKind: Type.Literal("complete-set"),
|
|
6260
|
+
releaseSetDigest: ReleaseSetDigestSchema
|
|
6261
|
+
}), { additionalProperties: false })]);
|
|
6262
|
+
/** Classifies provider-selection failures without leaking resource implementation details. */
|
|
6263
|
+
const SelectedContentIssueCodeSchema = Type.Union([
|
|
6264
|
+
Type.Literal("SourceIneligible"),
|
|
6265
|
+
Type.Literal("SourceReadFailed"),
|
|
6266
|
+
Type.Literal("ReleaseConstructionFailed"),
|
|
6267
|
+
Type.Literal("SelectionMismatch"),
|
|
6268
|
+
Type.Literal("DesiredContentInvalid")
|
|
5082
6269
|
]);
|
|
5083
|
-
/**
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
}, { additionalProperties: false }));
|
|
5099
|
-
function isCanonicalAbsolutePath$1(value) {
|
|
5100
|
-
return value.startsWith("/") && value !== "/" && !value.endsWith("/") && !value.includes("//") && !value.includes("\\") && !/[\u0000-\u001f\u007f]/u.test(value) && value.split("/").slice(1).every((part) => part !== "" && part !== "." && part !== "..");
|
|
5101
|
-
}
|
|
5102
|
-
function isCanonicalHttpsGitUrl$1(value) {
|
|
5103
|
-
let parsed;
|
|
5104
|
-
try {
|
|
5105
|
-
parsed = new URL(value);
|
|
5106
|
-
} catch {
|
|
5107
|
-
return false;
|
|
5108
|
-
}
|
|
5109
|
-
return parsed.protocol === "https:" && parsed.username === "" && parsed.password === "" && parsed.port === "" && parsed.search === "" && parsed.hash === "" && parsed.hostname === parsed.hostname.toLowerCase() && parsed.pathname.startsWith("/") && parsed.pathname.endsWith(".git") && parsed.toString() === value;
|
|
5110
|
-
}
|
|
5111
|
-
function isCanonicalRelativePath$1(value) {
|
|
5112
|
-
return value.length > 0 && value.length <= 1024 && !value.startsWith("/") && !value.endsWith("/") && !value.includes("\\") && !/[\u0000-\u001f\u007f]/u.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
5113
|
-
}
|
|
5114
|
-
function isCanonicalDistinctOrder$1(values) {
|
|
5115
|
-
for (let index = 1; index < values.length; index += 1) if (values[index - 1] >= values[index]) return false;
|
|
5116
|
-
return true;
|
|
5117
|
-
}
|
|
5118
|
-
function hasBoundedDistinctFileRequests(input) {
|
|
5119
|
-
return isCanonicalDistinctOrder$1(input.files.map((file) => file.relativePath)) && input.files.reduce((total, file) => total + file.maxBytes, 0) <= 67108864;
|
|
5120
|
-
}
|
|
6270
|
+
/** Carries one bounded provider-selection failure to the owning provider operation. */
|
|
6271
|
+
const SelectedContentIssueSchema = ReadonlyObject(Type.Object({
|
|
6272
|
+
code: SelectedContentIssueCodeSchema,
|
|
6273
|
+
detail: Type.String({
|
|
6274
|
+
minLength: 1,
|
|
6275
|
+
maxLength: MAX_SELECTED_ISSUE_DETAIL
|
|
6276
|
+
}),
|
|
6277
|
+
pluginId: Type.Optional(PluginIdSchema)
|
|
6278
|
+
}), { additionalProperties: false });
|
|
6279
|
+
Type.Union([ReadonlyObject(Type.Object({
|
|
6280
|
+
kind: Type.Literal("Selected"),
|
|
6281
|
+
content: SelectedContentSchema
|
|
6282
|
+
}), { additionalProperties: false }), ReadonlyObject(Type.Object({
|
|
6283
|
+
kind: Type.Literal("Rejected"),
|
|
6284
|
+
issues: NonEmptyReadonlyArray(SelectedContentIssueSchema, { maxItems: MAX_SELECTED_ISSUES })
|
|
6285
|
+
}), { additionalProperties: false })]);
|
|
5121
6286
|
//#endregion
|
|
5122
6287
|
//#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/model/dto/provider-lifecycle.ts
|
|
5123
6288
|
const MAX_TARGETS = 16;
|
|
5124
|
-
const MAX_CONFIRMED_NATIVE_OPERATIONS =
|
|
6289
|
+
const MAX_CONFIRMED_NATIVE_OPERATIONS = 10242;
|
|
5125
6290
|
/** Maximum public verification facts returned for one Provider target. */
|
|
5126
6291
|
const MAX_PROVIDER_FACTS = 4096;
|
|
5127
6292
|
const MAX_DETAIL_LENGTH = 4096;
|
|
6293
|
+
const ProviderIdSchema = NativeAgentProviderIdSchema;
|
|
5128
6294
|
/** Publishes the structural wire shape of an explicit native-provider home. */
|
|
5129
6295
|
const ProviderHomeSchema = Type.String({
|
|
5130
6296
|
minLength: 2,
|
|
@@ -5133,7 +6299,7 @@ const ProviderHomeSchema = Type.String({
|
|
|
5133
6299
|
description: "Projectable non-root absolute path structure; native-provider policy owns canonical admission."
|
|
5134
6300
|
});
|
|
5135
6301
|
const ProviderTargetSchema = ReadonlyObject(Type.Object({
|
|
5136
|
-
provider:
|
|
6302
|
+
provider: ProviderIdSchema,
|
|
5137
6303
|
home: ProviderHomeSchema
|
|
5138
6304
|
}), { additionalProperties: false });
|
|
5139
6305
|
/**
|
|
@@ -5181,12 +6347,17 @@ const ProviderIssueCodeSchema = Type.Union([
|
|
|
5181
6347
|
Type.Literal("CapabilityMissing"),
|
|
5182
6348
|
Type.Literal("MarketplaceCollision"),
|
|
5183
6349
|
Type.Literal("PluginCollision"),
|
|
6350
|
+
Type.Literal("McpServerCollision"),
|
|
5184
6351
|
Type.Literal("MarketplaceDrift"),
|
|
5185
6352
|
Type.Literal("PluginMissing"),
|
|
5186
6353
|
Type.Literal("PluginDisabled"),
|
|
5187
6354
|
Type.Literal("OmittedPluginPresent"),
|
|
5188
6355
|
Type.Literal("PluginFileMissing"),
|
|
5189
6356
|
Type.Literal("PluginFileMismatch"),
|
|
6357
|
+
Type.Literal("McpServerMissing"),
|
|
6358
|
+
Type.Literal("McpServerDrift"),
|
|
6359
|
+
Type.Literal("McpServerDisabled"),
|
|
6360
|
+
Type.Literal("OmittedMcpServerPresent"),
|
|
5190
6361
|
Type.Literal("NativeObservationFailed"),
|
|
5191
6362
|
Type.Literal("NativeCommandFailed"),
|
|
5192
6363
|
Type.Literal("VerificationFailed"),
|
|
@@ -5200,7 +6371,7 @@ const ProviderIssueSchema = ReadonlyObject(Type.Object({
|
|
|
5200
6371
|
}),
|
|
5201
6372
|
pluginId: Type.Optional(PluginIdSchema)
|
|
5202
6373
|
}), { additionalProperties: false });
|
|
5203
|
-
const MarketplaceIdentitySchema
|
|
6374
|
+
const MarketplaceIdentitySchema = Type.String({
|
|
5204
6375
|
minLength: 1,
|
|
5205
6376
|
maxLength: 128,
|
|
5206
6377
|
pattern: "^[a-z0-9][a-z0-9_-]*$"
|
|
@@ -5213,11 +6384,11 @@ const PluginSelectorSchema = Type.String({
|
|
|
5213
6384
|
const ConfirmedNativeOperationSchema = Type.Union([
|
|
5214
6385
|
ReadonlyObject(Type.Object({
|
|
5215
6386
|
kind: Type.Literal("marketplace-added"),
|
|
5216
|
-
identity: MarketplaceIdentitySchema
|
|
6387
|
+
identity: MarketplaceIdentitySchema
|
|
5217
6388
|
}), { additionalProperties: false }),
|
|
5218
6389
|
ReadonlyObject(Type.Object({
|
|
5219
6390
|
kind: Type.Literal("marketplace-removed"),
|
|
5220
|
-
identity: MarketplaceIdentitySchema
|
|
6391
|
+
identity: MarketplaceIdentitySchema
|
|
5221
6392
|
}), { additionalProperties: false }),
|
|
5222
6393
|
ReadonlyObject(Type.Object({
|
|
5223
6394
|
kind: Type.Literal("plugin-installed"),
|
|
@@ -5230,21 +6401,39 @@ const ConfirmedNativeOperationSchema = Type.Union([
|
|
|
5230
6401
|
ReadonlyObject(Type.Object({
|
|
5231
6402
|
kind: Type.Literal("plugin-removed"),
|
|
5232
6403
|
selector: PluginSelectorSchema
|
|
6404
|
+
}), { additionalProperties: false }),
|
|
6405
|
+
ReadonlyObject(Type.Object({
|
|
6406
|
+
kind: Type.Literal("mcp-added"),
|
|
6407
|
+
name: HostMcpServerNameSchema,
|
|
6408
|
+
url: HostMcpServerUrlSchema
|
|
6409
|
+
}), { additionalProperties: false }),
|
|
6410
|
+
ReadonlyObject(Type.Object({
|
|
6411
|
+
kind: Type.Literal("mcp-removed"),
|
|
6412
|
+
name: HostMcpServerNameSchema
|
|
5233
6413
|
}), { additionalProperties: false })
|
|
5234
6414
|
]);
|
|
5235
6415
|
const NativeOperationAttemptSchema = ReadonlyObject(Type.Object({
|
|
5236
6416
|
operation: ConfirmedNativeOperationSchema,
|
|
5237
6417
|
commandPhase: Type.Union([Type.Literal("started"), Type.Literal("command-returned")])
|
|
5238
6418
|
}), { additionalProperties: false });
|
|
6419
|
+
/** Identifies why a `.mcp.json` server entry was omitted from Antigravity's bundle projection. */
|
|
6420
|
+
const AntigravityOmittedMcpServerReasonSchema = Type.Union([
|
|
6421
|
+
Type.Literal("unsupported-transport"),
|
|
6422
|
+
Type.Literal("non-remote-https-url"),
|
|
6423
|
+
Type.Literal("requires-variables"),
|
|
6424
|
+
Type.Literal("invalid-config")
|
|
6425
|
+
]);
|
|
5239
6426
|
const targetObservationProperties = {
|
|
5240
6427
|
target: ProviderTargetSchema,
|
|
5241
|
-
facts: BoundedReadonlyArray(ReadonlyObject(Type.Object({
|
|
6428
|
+
facts: BoundedReadonlyArray(Type.Union([ReadonlyObject(Type.Object({
|
|
5242
6429
|
kind: Type.Union([
|
|
5243
6430
|
Type.Literal("marketplace-source"),
|
|
5244
6431
|
Type.Literal("plugin-installed"),
|
|
5245
6432
|
Type.Literal("plugin-enabled"),
|
|
5246
6433
|
Type.Literal("plugin-file"),
|
|
5247
|
-
Type.Literal("plugin-absent")
|
|
6434
|
+
Type.Literal("plugin-absent"),
|
|
6435
|
+
Type.Literal("mcp-configured"),
|
|
6436
|
+
Type.Literal("mcp-absent")
|
|
5248
6437
|
]),
|
|
5249
6438
|
subject: Type.String({
|
|
5250
6439
|
minLength: 1,
|
|
@@ -5254,7 +6443,20 @@ const targetObservationProperties = {
|
|
|
5254
6443
|
minLength: 1,
|
|
5255
6444
|
maxLength: MAX_DETAIL_LENGTH
|
|
5256
6445
|
})
|
|
5257
|
-
}), { additionalProperties: false }), {
|
|
6446
|
+
}), { additionalProperties: false }), ReadonlyObject(Type.Object({
|
|
6447
|
+
kind: Type.Literal("mcp-omitted"),
|
|
6448
|
+
pluginId: PluginIdSchema,
|
|
6449
|
+
name: Type.String({ maxLength: 256 }),
|
|
6450
|
+
reason: AntigravityOmittedMcpServerReasonSchema,
|
|
6451
|
+
subject: Type.String({
|
|
6452
|
+
minLength: 1,
|
|
6453
|
+
maxLength: 2048
|
|
6454
|
+
}),
|
|
6455
|
+
detail: Type.String({
|
|
6456
|
+
minLength: 1,
|
|
6457
|
+
maxLength: MAX_DETAIL_LENGTH
|
|
6458
|
+
})
|
|
6459
|
+
}), { additionalProperties: false })]), { maxItems: MAX_PROVIDER_FACTS }),
|
|
5258
6460
|
issues: BoundedReadonlyArray(ProviderIssueSchema, { maxItems: 256 })
|
|
5259
6461
|
};
|
|
5260
6462
|
const boundedNativeOperations = () => BoundedReadonlyArray(ConfirmedNativeOperationSchema, { maxItems: MAX_CONFIRMED_NATIVE_OPERATIONS });
|
|
@@ -7642,7 +8844,7 @@ function sameInspection(left, right) {
|
|
|
7642
8844
|
function exactRepositoryIdentity(remoteUrls, expected) {
|
|
7643
8845
|
const observed = remoteUrls.map((remoteUrl) => repositoryIdentityFromRemote(remoteUrl) ?? remoteUrl);
|
|
7644
8846
|
if (observed.includes(expected)) return expected;
|
|
7645
|
-
const unique = [...new Set(observed)].sort(compareText$
|
|
8847
|
+
const unique = [...new Set(observed)].sort(compareText$9);
|
|
7646
8848
|
return unique.length === 1 ? unique[0] : "unresolved:multiple-or-missing-remotes";
|
|
7647
8849
|
}
|
|
7648
8850
|
function repositoryIdentityFromRemote(remoteUrl) {
|
|
@@ -7705,7 +8907,7 @@ function requireRelativePath(value, path) {
|
|
|
7705
8907
|
if (!parsed.ok) throw new Error(`Compiled ${path} is invalid`);
|
|
7706
8908
|
return parsed.value;
|
|
7707
8909
|
}
|
|
7708
|
-
function compareText$
|
|
8910
|
+
function compareText$9(left, right) {
|
|
7709
8911
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
7710
8912
|
}
|
|
7711
8913
|
//#endregion
|
|
@@ -9545,162 +10747,83 @@ const router$8 = { package: service$1.packaging.use(async ({ context, next }) =>
|
|
|
9545
10747
|
packageDigest
|
|
9546
10748
|
};
|
|
9547
10749
|
const outputAttempt = yield* Effect.result(Effect.uninterruptible(context.packageOutput.publish({
|
|
9548
|
-
outputPath,
|
|
9549
|
-
bytes: new Uint8Array(bytes),
|
|
9550
|
-
maxPriorOutputBytes: priorOutputObservationLimit(bytes.byteLength)
|
|
9551
|
-
})));
|
|
9552
|
-
if (outputAttempt._tag === "Failure") return {
|
|
9553
|
-
kind: "OutputUnsettled",
|
|
9554
|
-
primaryFailure: unsettledPackageOutputFailure(outputAttempt.failure),
|
|
9555
|
-
...identity
|
|
9556
|
-
};
|
|
9557
|
-
const output = outputAttempt.success;
|
|
9558
|
-
switch (output.kind) {
|
|
9559
|
-
case "RejectedBeforeOutputMutation": return {
|
|
9560
|
-
kind: output.kind,
|
|
9561
|
-
primaryFailure: mapPackageOutputFailure(output.primaryFailure),
|
|
9562
|
-
...output.cleanupFailure === void 0 ? {} : { cleanupFailure: mapPackageOutputFailure(output.cleanupFailure, true) }
|
|
9563
|
-
};
|
|
9564
|
-
case "ReadOnlyConverged": return {
|
|
9565
|
-
kind: output.kind,
|
|
9566
|
-
...identity
|
|
9567
|
-
};
|
|
9568
|
-
case "OutputReplacedVerified": return {
|
|
9569
|
-
kind: output.kind,
|
|
9570
|
-
priorOutput: output.priorOutput,
|
|
9571
|
-
...identity
|
|
9572
|
-
};
|
|
9573
|
-
case "OutputUnsettled": return {
|
|
9574
|
-
kind: output.kind,
|
|
9575
|
-
primaryFailure: mapPackageOutputFailure(output.primaryFailure),
|
|
9576
|
-
...output.cleanupFailure === void 0 ? {} : { cleanupFailure: mapPackageOutputFailure(output.cleanupFailure, true) },
|
|
9577
|
-
...identity
|
|
9578
|
-
};
|
|
9579
|
-
}
|
|
9580
|
-
}) };
|
|
9581
|
-
//#endregion
|
|
9582
|
-
//#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/model/policy/disposable-root.ts
|
|
9583
|
-
/** Reserved direct child that keeps one native marketplace reachable for a disposable root. */
|
|
9584
|
-
const DISPOSABLE_MARKETPLACE_DIRECTORY = ".rawr-agent-plugin-marketplace";
|
|
9585
|
-
/** Confirms every provider target carries the native resource's canonical home shape. */
|
|
9586
|
-
function hasCanonicalProviderHomes(targets) {
|
|
9587
|
-
return targets.every((target) => isCanonicalProviderHome(target.home));
|
|
9588
|
-
}
|
|
9589
|
-
/** Admits one canonical non-root native-provider home. */
|
|
9590
|
-
function isCanonicalProviderHome(value) {
|
|
9591
|
-
return Value.Check(NativeProviderHomeSchema, value);
|
|
9592
|
-
}
|
|
9593
|
-
/** Confirms every provider home is owned by the explicit disposable parent. */
|
|
9594
|
-
function hasStrictDescendantHomes(disposableRoot, targets) {
|
|
9595
|
-
const descendantPrefix = `${disposableRoot}/`;
|
|
9596
|
-
return targets.every((target) => target.home.startsWith(descendantPrefix));
|
|
9597
|
-
}
|
|
9598
|
-
/** Confirms no two provider homes are equal or contain one another. */
|
|
9599
|
-
function hasPairwiseDisjointProviderHomes(targets) {
|
|
9600
|
-
for (let leftIndex = 0; leftIndex < targets.length; leftIndex += 1) {
|
|
9601
|
-
const left = targets[leftIndex].home;
|
|
9602
|
-
for (let rightIndex = leftIndex + 1; rightIndex < targets.length; rightIndex += 1) {
|
|
9603
|
-
const right = targets[rightIndex].home;
|
|
9604
|
-
if (left === right || left.startsWith(`${right}/`) || right.startsWith(`${left}/`)) return false;
|
|
9605
|
-
}
|
|
9606
|
-
}
|
|
9607
|
-
return true;
|
|
9608
|
-
}
|
|
9609
|
-
/** Prevents two canonical absolute paths from containing one another. */
|
|
9610
|
-
function areDisjointPaths(left, right) {
|
|
9611
|
-
return left !== right && !left.startsWith(`${right}/`) && !right.startsWith(`${left}/`);
|
|
9612
|
-
}
|
|
9613
|
-
/** Returns the one stable marketplace root owned by a disposable test parent. */
|
|
9614
|
-
function disposableMarketplaceRoot(disposableRoot) {
|
|
9615
|
-
return `${disposableRoot}/${DISPOSABLE_MARKETPLACE_DIRECTORY}`;
|
|
9616
|
-
}
|
|
9617
|
-
/** Prevents the stable marketplace and any provider home from containing one another. */
|
|
9618
|
-
function hasDisjointMarketplaceRoot(disposableRoot, targets) {
|
|
9619
|
-
const marketplaceRoot = disposableMarketplaceRoot(disposableRoot);
|
|
9620
|
-
return targets.every((target) => areDisjointPaths(marketplaceRoot, target.home));
|
|
9621
|
-
}
|
|
9622
|
-
//#endregion
|
|
9623
|
-
//#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/model/dto/selected-content.ts
|
|
9624
|
-
const MAX_SELECTED_ISSUES = 256;
|
|
9625
|
-
const MAX_SELECTED_ISSUE_DETAIL = 4096;
|
|
9626
|
-
const MarketplaceIdentitySchema = Type.String({
|
|
9627
|
-
minLength: 1,
|
|
9628
|
-
maxLength: 128,
|
|
9629
|
-
pattern: "^[a-z0-9][a-z0-9_-]*$"
|
|
9630
|
-
});
|
|
9631
|
-
/** Describes one payload file whose exact bytes a provider operation must verify. */
|
|
9632
|
-
const SelectedContentFileSchema = PayloadManifestEntrySchema;
|
|
9633
|
-
/**
|
|
9634
|
-
* Describes one selected plugin and the immutable ownership and payload facts used during
|
|
9635
|
-
* provider convergence.
|
|
9636
|
-
*/
|
|
9637
|
-
const SelectedContentMemberSchema = ReadonlyObject(Type.Object({
|
|
9638
|
-
pluginId: PluginIdSchema,
|
|
9639
|
-
aliases: ReadonlyObject(Type.Array(OwnershipIdentitySchema), {
|
|
9640
|
-
maxItems: MAX_OWNERSHIP_CLAIMS,
|
|
9641
|
-
uniqueItems: true
|
|
9642
|
-
}),
|
|
9643
|
-
payloadDigest: PayloadDigestSchema,
|
|
9644
|
-
releaseDigest: ReleaseDigestSchema,
|
|
9645
|
-
manifest: ReadonlyObject(Type.Array(SelectedContentFileSchema), {
|
|
9646
|
-
minItems: 1,
|
|
9647
|
-
maxItems: MAX_PAYLOAD_ENTRIES_PER_MEMBER,
|
|
9648
|
-
uniqueItems: true
|
|
9649
|
-
})
|
|
9650
|
-
}), { additionalProperties: false });
|
|
9651
|
-
const selectedContentProperties = {
|
|
9652
|
-
contentAuthority: ContentAuthoritySchema,
|
|
9653
|
-
repositoryIdentity: RepositoryIdentitySchema$1,
|
|
9654
|
-
sourceCommit: GitCommitIdSchema,
|
|
9655
|
-
sourceTree: GitTreeIdSchema,
|
|
9656
|
-
releaseInputDigest: ReleaseInputDigestSchema,
|
|
9657
|
-
marketplace: ReadonlyObject(Type.Object({
|
|
9658
|
-
identity: MarketplaceIdentitySchema,
|
|
9659
|
-
source: NativeMarketplaceSourceSchema
|
|
9660
|
-
}), { additionalProperties: false }),
|
|
9661
|
-
members: ReadonlyObject(Type.Array(SelectedContentMemberSchema), {
|
|
9662
|
-
minItems: 1,
|
|
9663
|
-
maxItems: MAX_RELEASE_MEMBERS,
|
|
9664
|
-
uniqueItems: true
|
|
9665
|
-
})
|
|
9666
|
-
};
|
|
9667
|
-
/**
|
|
9668
|
-
* Defines the complete provider-owned selection that status, test, and sync inspect or
|
|
9669
|
-
* converge without becoming a new source authority.
|
|
9670
|
-
*/
|
|
9671
|
-
const SelectedContentSchema = Type.Union([ReadonlyObject(Type.Object({
|
|
9672
|
-
...selectedContentProperties,
|
|
9673
|
-
selectionKind: Type.Literal("targeted"),
|
|
9674
|
-
releaseSetDigest: Type.Null()
|
|
9675
|
-
}), { additionalProperties: false }), ReadonlyObject(Type.Object({
|
|
9676
|
-
...selectedContentProperties,
|
|
9677
|
-
selectionKind: Type.Literal("complete-set"),
|
|
9678
|
-
releaseSetDigest: ReleaseSetDigestSchema
|
|
9679
|
-
}), { additionalProperties: false })]);
|
|
9680
|
-
/** Classifies provider-selection failures without leaking resource implementation details. */
|
|
9681
|
-
const SelectedContentIssueCodeSchema = Type.Union([
|
|
9682
|
-
Type.Literal("SourceIneligible"),
|
|
9683
|
-
Type.Literal("SourceReadFailed"),
|
|
9684
|
-
Type.Literal("ReleaseConstructionFailed"),
|
|
9685
|
-
Type.Literal("SelectionMismatch")
|
|
9686
|
-
]);
|
|
9687
|
-
/** Carries one bounded provider-selection failure to the owning provider operation. */
|
|
9688
|
-
const SelectedContentIssueSchema = ReadonlyObject(Type.Object({
|
|
9689
|
-
code: SelectedContentIssueCodeSchema,
|
|
9690
|
-
detail: Type.String({
|
|
9691
|
-
minLength: 1,
|
|
9692
|
-
maxLength: MAX_SELECTED_ISSUE_DETAIL
|
|
9693
|
-
})
|
|
9694
|
-
}), { additionalProperties: false });
|
|
9695
|
-
Type.Union([ReadonlyObject(Type.Object({
|
|
9696
|
-
kind: Type.Literal("Selected"),
|
|
9697
|
-
content: SelectedContentSchema
|
|
9698
|
-
}), { additionalProperties: false }), ReadonlyObject(Type.Object({
|
|
9699
|
-
kind: Type.Literal("Rejected"),
|
|
9700
|
-
issues: NonEmptyReadonlyArray(SelectedContentIssueSchema, { maxItems: MAX_SELECTED_ISSUES })
|
|
9701
|
-
}), { additionalProperties: false })]);
|
|
10750
|
+
outputPath,
|
|
10751
|
+
bytes: new Uint8Array(bytes),
|
|
10752
|
+
maxPriorOutputBytes: priorOutputObservationLimit(bytes.byteLength)
|
|
10753
|
+
})));
|
|
10754
|
+
if (outputAttempt._tag === "Failure") return {
|
|
10755
|
+
kind: "OutputUnsettled",
|
|
10756
|
+
primaryFailure: unsettledPackageOutputFailure(outputAttempt.failure),
|
|
10757
|
+
...identity
|
|
10758
|
+
};
|
|
10759
|
+
const output = outputAttempt.success;
|
|
10760
|
+
switch (output.kind) {
|
|
10761
|
+
case "RejectedBeforeOutputMutation": return {
|
|
10762
|
+
kind: output.kind,
|
|
10763
|
+
primaryFailure: mapPackageOutputFailure(output.primaryFailure),
|
|
10764
|
+
...output.cleanupFailure === void 0 ? {} : { cleanupFailure: mapPackageOutputFailure(output.cleanupFailure, true) }
|
|
10765
|
+
};
|
|
10766
|
+
case "ReadOnlyConverged": return {
|
|
10767
|
+
kind: output.kind,
|
|
10768
|
+
...identity
|
|
10769
|
+
};
|
|
10770
|
+
case "OutputReplacedVerified": return {
|
|
10771
|
+
kind: output.kind,
|
|
10772
|
+
priorOutput: output.priorOutput,
|
|
10773
|
+
...identity
|
|
10774
|
+
};
|
|
10775
|
+
case "OutputUnsettled": return {
|
|
10776
|
+
kind: output.kind,
|
|
10777
|
+
primaryFailure: mapPackageOutputFailure(output.primaryFailure),
|
|
10778
|
+
...output.cleanupFailure === void 0 ? {} : { cleanupFailure: mapPackageOutputFailure(output.cleanupFailure, true) },
|
|
10779
|
+
...identity
|
|
10780
|
+
};
|
|
10781
|
+
}
|
|
10782
|
+
}) };
|
|
10783
|
+
//#endregion
|
|
10784
|
+
//#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/model/policy/disposable-root.ts
|
|
10785
|
+
/** Reserved direct child that keeps one native marketplace reachable for a disposable root. */
|
|
10786
|
+
const DISPOSABLE_MARKETPLACE_DIRECTORY = ".rawr-agent-plugin-marketplace";
|
|
10787
|
+
/** Confirms every provider target carries the native resource's canonical home shape. */
|
|
10788
|
+
function hasCanonicalProviderHomes(targets) {
|
|
10789
|
+
return targets.every((target) => isCanonicalProviderHome(target.home));
|
|
10790
|
+
}
|
|
10791
|
+
/** Admits one canonical non-root native-provider home. */
|
|
10792
|
+
function isCanonicalProviderHome(value) {
|
|
10793
|
+
return Value.Check(NativeProviderHomeSchema, value);
|
|
10794
|
+
}
|
|
10795
|
+
/** Confirms every provider home is owned by the explicit disposable parent. */
|
|
10796
|
+
function hasStrictDescendantHomes(disposableRoot, targets) {
|
|
10797
|
+
const descendantPrefix = `${disposableRoot}/`;
|
|
10798
|
+
return targets.every((target) => target.home.startsWith(descendantPrefix));
|
|
10799
|
+
}
|
|
10800
|
+
/** Confirms no two provider homes are equal or contain one another. */
|
|
10801
|
+
function hasPairwiseDisjointProviderHomes(targets) {
|
|
10802
|
+
for (let leftIndex = 0; leftIndex < targets.length; leftIndex += 1) {
|
|
10803
|
+
const left = targets[leftIndex].home;
|
|
10804
|
+
for (let rightIndex = leftIndex + 1; rightIndex < targets.length; rightIndex += 1) {
|
|
10805
|
+
const right = targets[rightIndex].home;
|
|
10806
|
+
if (left === right || left.startsWith(`${right}/`) || right.startsWith(`${left}/`)) return false;
|
|
10807
|
+
}
|
|
10808
|
+
}
|
|
10809
|
+
return true;
|
|
10810
|
+
}
|
|
10811
|
+
/** Prevents two canonical absolute paths from containing one another. */
|
|
10812
|
+
function areDisjointPaths(left, right) {
|
|
10813
|
+
return left !== right && !left.startsWith(`${right}/`) && !right.startsWith(`${left}/`);
|
|
10814
|
+
}
|
|
10815
|
+
/** Returns the one stable marketplace root owned by a disposable test parent. */
|
|
10816
|
+
function disposableMarketplaceRoot(disposableRoot) {
|
|
10817
|
+
return `${disposableRoot}/${DISPOSABLE_MARKETPLACE_DIRECTORY}`;
|
|
10818
|
+
}
|
|
10819
|
+
/** Prevents the stable marketplace and any provider home from containing one another. */
|
|
10820
|
+
function hasDisjointMarketplaceRoot(disposableRoot, targets) {
|
|
10821
|
+
const marketplaceRoot = disposableMarketplaceRoot(disposableRoot);
|
|
10822
|
+
return targets.every((target) => areDisjointPaths(marketplaceRoot, target.home));
|
|
10823
|
+
}
|
|
9702
10824
|
//#endregion
|
|
9703
10825
|
//#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/model/policy/selected-content.ts
|
|
10826
|
+
const utf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
9704
10827
|
/**
|
|
9705
10828
|
* Projects service-owned release derivation into Provider-selected content.
|
|
9706
10829
|
*
|
|
@@ -9714,16 +10837,36 @@ function constructSelectedContent(input) {
|
|
|
9714
10837
|
if (firstRelease === void 0) return selectedContentRejected("ReleaseConstructionFailed", "Release derivation did not produce a selected member.");
|
|
9715
10838
|
const releaseSet = input.derivation.releaseSet;
|
|
9716
10839
|
if (input.selectionKind === "targeted" && releaseSet !== void 0) return selectedContentRejected("ReleaseConstructionFailed", "Release derivation does not match the Provider selection kind.");
|
|
9717
|
-
const
|
|
10840
|
+
const repositoryUrl = input.marketplace.source.kind === "git" ? input.marketplace.source.repositoryUrl : null;
|
|
10841
|
+
const members = [];
|
|
10842
|
+
const hostMcpServers = [];
|
|
10843
|
+
for (const release of input.derivation.releases) {
|
|
9718
10844
|
const body = release.body;
|
|
9719
|
-
|
|
10845
|
+
const antigravity = deriveAntigravityBundleFacts(release.payload.entries, repositoryUrl);
|
|
10846
|
+
const packageEntry = release.payload.entries.find((entry) => entry.path === "package.json");
|
|
10847
|
+
const claudeEntry = release.payload.entries.find((entry) => entry.path === ".claude-plugin/plugin.json");
|
|
10848
|
+
const codexEntry = release.payload.entries.find((entry) => entry.path === ".codex-plugin/plugin.json");
|
|
10849
|
+
const mcpEntry = release.payload.entries.find((entry) => entry.path === ".mcp.json");
|
|
10850
|
+
const extracted = extractPluginHostMcpServers({
|
|
10851
|
+
pluginId: body.pluginId,
|
|
10852
|
+
packageJsonBytes: packageEntry === void 0 ? void 0 : payloadEntryBytes(packageEntry),
|
|
10853
|
+
claudeManifestBytes: claudeEntry === void 0 ? void 0 : payloadEntryBytes(claudeEntry),
|
|
10854
|
+
codexManifestBytes: codexEntry === void 0 ? void 0 : payloadEntryBytes(codexEntry),
|
|
10855
|
+
mcpConfigBytes: mcpEntry === void 0 ? void 0 : payloadEntryBytes(mcpEntry)
|
|
10856
|
+
});
|
|
10857
|
+
if (!extracted.ok) return selectedContentRejected("DesiredContentInvalid", extracted.detail, body.pluginId);
|
|
10858
|
+
hostMcpServers.push(...extracted.servers);
|
|
10859
|
+
members.push(Object.freeze({
|
|
9720
10860
|
pluginId: body.pluginId,
|
|
9721
10861
|
aliases: [...body.aliases],
|
|
9722
10862
|
payloadDigest: body.payloadDigest,
|
|
9723
10863
|
releaseDigest: release.releaseDigest,
|
|
9724
|
-
manifest: body.payloadManifest.map((entry) => Object.freeze({ ...entry }))
|
|
9725
|
-
|
|
9726
|
-
|
|
10864
|
+
manifest: body.payloadManifest.map((entry) => Object.freeze({ ...entry })),
|
|
10865
|
+
antigravityManifest: antigravity.manifest,
|
|
10866
|
+
antigravityOmittedMcpServers: antigravity.omittedMcpServers
|
|
10867
|
+
}));
|
|
10868
|
+
}
|
|
10869
|
+
hostMcpServers.sort((left, right) => compareText$8(left.name, right.name) || compareText$8(left.ownerPluginId, right.ownerPluginId));
|
|
9727
10870
|
const releaseBody = firstRelease.body;
|
|
9728
10871
|
const common = Object.freeze({
|
|
9729
10872
|
contentAuthority: releaseBody.contentAuthority,
|
|
@@ -9732,7 +10875,8 @@ function constructSelectedContent(input) {
|
|
|
9732
10875
|
sourceTree: releaseBody.sourceTree,
|
|
9733
10876
|
releaseInputDigest: releaseBody.releaseInputDigest,
|
|
9734
10877
|
marketplace: input.marketplace,
|
|
9735
|
-
members
|
|
10878
|
+
members: Object.freeze(members),
|
|
10879
|
+
hostMcpServers: Object.freeze(hostMcpServers)
|
|
9736
10880
|
});
|
|
9737
10881
|
if (input.selectionKind === "targeted") return Object.freeze({
|
|
9738
10882
|
kind: "Selected",
|
|
@@ -9769,7 +10913,7 @@ function selectedContentFromSourceIssues(issues) {
|
|
|
9769
10913
|
function providerSelectionResolution(resolved) {
|
|
9770
10914
|
if (resolved.kind === "Rejected") return {
|
|
9771
10915
|
kind: "Rejected",
|
|
9772
|
-
issues: Object.freeze(resolved.issues.map((issue) => providerIssue("SelectionRejected", `${issue.code}: ${issue.detail}
|
|
10916
|
+
issues: Object.freeze(resolved.issues.map((issue) => issue.code === "DesiredContentInvalid" ? providerIssue("DesiredContentInvalid", issue.detail, issue.pluginId) : providerIssue("SelectionRejected", `${issue.code}: ${issue.detail}`, issue.pluginId)))
|
|
9773
10917
|
};
|
|
9774
10918
|
const issues = validateSelectedContent(resolved.content);
|
|
9775
10919
|
return issues.length === 0 ? {
|
|
@@ -9781,10 +10925,11 @@ function providerSelectionResolution(resolved) {
|
|
|
9781
10925
|
};
|
|
9782
10926
|
}
|
|
9783
10927
|
/** Constructs one bounded selected-content refusal. */
|
|
9784
|
-
function selectedContentRejected(code, detail) {
|
|
10928
|
+
function selectedContentRejected(code, detail, pluginId) {
|
|
9785
10929
|
const issues = [Object.freeze({
|
|
9786
10930
|
code,
|
|
9787
|
-
detail: boundedDetail(detail)
|
|
10931
|
+
detail: boundedDetail(detail),
|
|
10932
|
+
...pluginId === void 0 ? {} : { pluginId }
|
|
9788
10933
|
})];
|
|
9789
10934
|
return Object.freeze({
|
|
9790
10935
|
kind: "Rejected",
|
|
@@ -9809,9 +10954,25 @@ function validateSelectedContent(content) {
|
|
|
9809
10954
|
if (!isCanonicalDistinctOrder(member.aliases)) issues.push(providerIssue("DesiredContentInvalid", "Selected aliases must be distinct and canonically ordered.", member.pluginId));
|
|
9810
10955
|
if (!isCanonicalDistinctOrder(member.manifest.map((file) => file.path))) issues.push(providerIssue("DesiredContentInvalid", "Selected manifest paths must be distinct and canonically ordered.", member.pluginId));
|
|
9811
10956
|
if (member.manifest.some((file) => !parseReleaseRelativePath$1(file.path).ok)) issues.push(providerIssue("DesiredContentInvalid", "Selected manifest paths must be canonical release-relative paths.", member.pluginId));
|
|
10957
|
+
if (member.antigravityManifest !== null) {
|
|
10958
|
+
if (!isCanonicalDistinctOrder(member.antigravityManifest.map((file) => file.path))) issues.push(providerIssue("DesiredContentInvalid", "Selected Antigravity manifest paths must be distinct and canonically ordered.", member.pluginId));
|
|
10959
|
+
if (member.antigravityManifest.some((file) => !parseReleaseRelativePath$1(file.path).ok)) issues.push(providerIssue("DesiredContentInvalid", "Selected Antigravity manifest paths must be canonical release-relative paths.", member.pluginId));
|
|
10960
|
+
}
|
|
10961
|
+
if (!isCanonicalDistinctOrder(member.antigravityOmittedMcpServers.map((entry) => entry.name))) issues.push(providerIssue("DesiredContentInvalid", "Selected Antigravity omitted MCP server names must be distinct and canonically ordered.", member.pluginId));
|
|
9812
10962
|
collectOwnedName(ownedNames, member.pluginId, member.pluginId, issues);
|
|
9813
10963
|
for (const alias of member.aliases) collectOwnedName(ownedNames, alias, member.pluginId, issues);
|
|
9814
10964
|
}
|
|
10965
|
+
const memberIds = new Set(content.members.map((member) => member.pluginId));
|
|
10966
|
+
if (content.hostMcpServers.length > 1024) issues.push(providerIssue("DesiredContentInvalid", "Selected host MCP servers exceed the aggregate protocol bound."));
|
|
10967
|
+
const mcpOwners = /* @__PURE__ */ new Map();
|
|
10968
|
+
for (const [index, server] of content.hostMcpServers.entries()) {
|
|
10969
|
+
if (index > 0 && compareText$8(content.hostMcpServers[index - 1].name, server.name) > 0) issues.push(providerIssue("DesiredContentInvalid", "Selected host MCP servers must be canonically ordered.", server.ownerPluginId));
|
|
10970
|
+
if (!memberIds.has(server.ownerPluginId)) issues.push(providerIssue("DesiredContentInvalid", `Host MCP server ${server.name} references undeclared owner plugin ${server.ownerPluginId}.`, server.ownerPluginId));
|
|
10971
|
+
if (parseCanonicalLoopbackHttpUrl(server.url) !== server.url) issues.push(providerIssue("DesiredContentInvalid", `Host MCP server ${server.name} must declare a canonical loopback HTTP URL.`, server.ownerPluginId));
|
|
10972
|
+
const existingOwner = mcpOwners.get(server.name);
|
|
10973
|
+
if (existingOwner !== void 0) issues.push(providerIssue("DesiredContentInvalid", `Host MCP server ${server.name} is declared by both ${existingOwner} and ${server.ownerPluginId}.`, server.ownerPluginId));
|
|
10974
|
+
else mcpOwners.set(server.name, server.ownerPluginId);
|
|
10975
|
+
}
|
|
9815
10976
|
return Object.freeze(issues);
|
|
9816
10977
|
}
|
|
9817
10978
|
function selectedContentObservation(content) {
|
|
@@ -9828,7 +10989,152 @@ function selectedContentObservation(content) {
|
|
|
9828
10989
|
});
|
|
9829
10990
|
}
|
|
9830
10991
|
function sameSelectedContent(left, right) {
|
|
9831
|
-
return left.selectionKind === right.selectionKind && left.contentAuthority === right.contentAuthority && left.repositoryIdentity === right.repositoryIdentity && left.sourceCommit === right.sourceCommit && left.sourceTree === right.sourceTree && left.releaseInputDigest === right.releaseInputDigest && left.releaseSetDigest === right.releaseSetDigest && sameMarketplaceSource(left.marketplace.source, right.marketplace.source) && left.marketplace.identity === right.marketplace.identity && sameMembers(left.members, right.members);
|
|
10992
|
+
return left.selectionKind === right.selectionKind && left.contentAuthority === right.contentAuthority && left.repositoryIdentity === right.repositoryIdentity && left.sourceCommit === right.sourceCommit && left.sourceTree === right.sourceTree && left.releaseInputDigest === right.releaseInputDigest && left.releaseSetDigest === right.releaseSetDigest && sameMarketplaceSource(left.marketplace.source, right.marketplace.source) && left.marketplace.identity === right.marketplace.identity && sameMembers(left.members, right.members) && sameHostMcpServers(left.hostMcpServers, right.hostMcpServers);
|
|
10993
|
+
}
|
|
10994
|
+
/**
|
|
10995
|
+
* Canonicalizes a credential-free loopback HTTP URL (`127.0.0.1`, `localhost`, or `[::1]`) with an
|
|
10996
|
+
* explicit non-default port (`1`–`65535`, excluding port `80`), returning `undefined` when the
|
|
10997
|
+
* input is non-loopback, portless, or non-canonical.
|
|
10998
|
+
*/
|
|
10999
|
+
function parseCanonicalLoopbackHttpUrl(value) {
|
|
11000
|
+
let parsed;
|
|
11001
|
+
try {
|
|
11002
|
+
parsed = new URL(value);
|
|
11003
|
+
} catch {
|
|
11004
|
+
return;
|
|
11005
|
+
}
|
|
11006
|
+
if (parsed.protocol !== "http:" || parsed.hostname !== "127.0.0.1" && parsed.hostname !== "localhost" && parsed.hostname !== "[::1]" || parsed.port === "" || parsed.username !== "" || parsed.password !== "" || parsed.search !== "" || parsed.hash !== "" || !parsed.pathname.startsWith("/")) return;
|
|
11007
|
+
const port = Number(parsed.port);
|
|
11008
|
+
if (!Number.isSafeInteger(port) || port < 1 || port > 65535) return void 0;
|
|
11009
|
+
const canonical = parsed.toString();
|
|
11010
|
+
if (value !== canonical && `${value}/` !== canonical) return void 0;
|
|
11011
|
+
return Value.Check(HostMcpServerUrlSchema, canonical) ? canonical : void 0;
|
|
11012
|
+
}
|
|
11013
|
+
/**
|
|
11014
|
+
* Extracts deterministic host-scoped loopback HTTP MCP server declarations from one plugin's
|
|
11015
|
+
* curated `package.json` (`rawr.pluginContent.hostMcpServers`), rejecting malformed entries or
|
|
11016
|
+
* colliding plugin-level MCP server declarations.
|
|
11017
|
+
*/
|
|
11018
|
+
function extractPluginHostMcpServers(input) {
|
|
11019
|
+
if (input.packageJsonBytes === void 0) return Object.freeze({
|
|
11020
|
+
ok: true,
|
|
11021
|
+
servers: Object.freeze([])
|
|
11022
|
+
});
|
|
11023
|
+
const parsedPackage = parseUtf8JsonRecord(input.packageJsonBytes);
|
|
11024
|
+
if (parsedPackage === void 0) return Object.freeze({
|
|
11025
|
+
ok: false,
|
|
11026
|
+
detail: `Plugin ${input.pluginId} package.json must be a valid UTF-8 JSON object.`
|
|
11027
|
+
});
|
|
11028
|
+
if (!Object.hasOwn(parsedPackage, "rawr") || Reflect.get(parsedPackage, "rawr") === void 0) return Object.freeze({
|
|
11029
|
+
ok: true,
|
|
11030
|
+
servers: Object.freeze([])
|
|
11031
|
+
});
|
|
11032
|
+
const rawr = Reflect.get(parsedPackage, "rawr");
|
|
11033
|
+
if (!isPlainRecord(rawr)) return Object.freeze({
|
|
11034
|
+
ok: false,
|
|
11035
|
+
detail: `Plugin ${input.pluginId} package.json rawr field must be a JSON object.`
|
|
11036
|
+
});
|
|
11037
|
+
if (!Object.hasOwn(rawr, "pluginContent") || Reflect.get(rawr, "pluginContent") === void 0) return Object.freeze({
|
|
11038
|
+
ok: true,
|
|
11039
|
+
servers: Object.freeze([])
|
|
11040
|
+
});
|
|
11041
|
+
const pluginContent = Reflect.get(rawr, "pluginContent");
|
|
11042
|
+
if (!isPlainRecord(pluginContent)) return Object.freeze({
|
|
11043
|
+
ok: false,
|
|
11044
|
+
detail: `Plugin ${input.pluginId} package.json rawr.pluginContent must be a JSON object.`
|
|
11045
|
+
});
|
|
11046
|
+
if (!Object.hasOwn(pluginContent, "hostMcpServers") || Reflect.get(pluginContent, "hostMcpServers") === void 0) return Object.freeze({
|
|
11047
|
+
ok: true,
|
|
11048
|
+
servers: Object.freeze([])
|
|
11049
|
+
});
|
|
11050
|
+
const rawServers = Reflect.get(pluginContent, "hostMcpServers");
|
|
11051
|
+
if (!isPlainRecord(rawServers)) return Object.freeze({
|
|
11052
|
+
ok: false,
|
|
11053
|
+
detail: `Plugin ${input.pluginId} package.json rawr.pluginContent.hostMcpServers must be a JSON object.`
|
|
11054
|
+
});
|
|
11055
|
+
const entries = Object.entries(rawServers).sort(([left], [right]) => compareText$8(left, right));
|
|
11056
|
+
if (entries.length > 1024) return Object.freeze({
|
|
11057
|
+
ok: false,
|
|
11058
|
+
detail: `Plugin ${input.pluginId} package.json rawr.pluginContent.hostMcpServers exceeds the host MCP server limit.`
|
|
11059
|
+
});
|
|
11060
|
+
const servers = [];
|
|
11061
|
+
for (const [name, rawEntry] of entries) {
|
|
11062
|
+
if (!Value.Check(HostMcpServerNameSchema, name)) return Object.freeze({
|
|
11063
|
+
ok: false,
|
|
11064
|
+
detail: `Plugin ${input.pluginId} hostMcpServers key ${name} must match ^[a-z0-9][a-z0-9_-]*$.`
|
|
11065
|
+
});
|
|
11066
|
+
if (!isPlainRecord(rawEntry) || Object.keys(rawEntry).some((key) => key !== "type" && key !== "url")) return Object.freeze({
|
|
11067
|
+
ok: false,
|
|
11068
|
+
detail: `Plugin ${input.pluginId} hostMcpServers entry ${name} must be a JSON object with only type and url.`
|
|
11069
|
+
});
|
|
11070
|
+
if (Reflect.get(rawEntry, "type") !== "http") return Object.freeze({
|
|
11071
|
+
ok: false,
|
|
11072
|
+
detail: `Plugin ${input.pluginId} hostMcpServers entry ${name} must declare type "http".`
|
|
11073
|
+
});
|
|
11074
|
+
const rawUrl = Reflect.get(rawEntry, "url");
|
|
11075
|
+
if (typeof rawUrl !== "string") return Object.freeze({
|
|
11076
|
+
ok: false,
|
|
11077
|
+
detail: `Plugin ${input.pluginId} hostMcpServers entry ${name} must declare a string url.`
|
|
11078
|
+
});
|
|
11079
|
+
const canonicalUrl = parseCanonicalLoopbackHttpUrl(rawUrl);
|
|
11080
|
+
if (canonicalUrl === void 0) return Object.freeze({
|
|
11081
|
+
ok: false,
|
|
11082
|
+
detail: `Plugin ${input.pluginId} hostMcpServers entry ${name} requires a canonical loopback HTTP URL with an explicit non-default port.`
|
|
11083
|
+
});
|
|
11084
|
+
servers.push(Object.freeze({
|
|
11085
|
+
name,
|
|
11086
|
+
url: canonicalUrl,
|
|
11087
|
+
ownerPluginId: input.pluginId
|
|
11088
|
+
}));
|
|
11089
|
+
}
|
|
11090
|
+
if (servers.length > 0) {
|
|
11091
|
+
const conflict = findPluginManifestMcpConflict(input, new Set(servers.map((server) => server.name)));
|
|
11092
|
+
if (conflict !== void 0) return Object.freeze({
|
|
11093
|
+
ok: false,
|
|
11094
|
+
detail: conflict
|
|
11095
|
+
});
|
|
11096
|
+
}
|
|
11097
|
+
return Object.freeze({
|
|
11098
|
+
ok: true,
|
|
11099
|
+
servers: Object.freeze(servers)
|
|
11100
|
+
});
|
|
11101
|
+
}
|
|
11102
|
+
function findPluginManifestMcpConflict(input, declaredHostNames) {
|
|
11103
|
+
if (input.mcpConfigBytes !== void 0) {
|
|
11104
|
+
const parsedMcp = parseUtf8JsonRecord(input.mcpConfigBytes);
|
|
11105
|
+
if (parsedMcp === void 0) return `Plugin ${input.pluginId} .mcp.json must be a valid UTF-8 JSON object.`;
|
|
11106
|
+
if (Object.hasOwn(parsedMcp, "mcpServers")) {
|
|
11107
|
+
const mcpServers = Reflect.get(parsedMcp, "mcpServers");
|
|
11108
|
+
if (!isPlainRecord(mcpServers)) return `Plugin ${input.pluginId} .mcp.json mcpServers must be a JSON object.`;
|
|
11109
|
+
for (const name of Object.keys(mcpServers)) if (declaredHostNames.has(name)) return `Plugin ${input.pluginId} declares MCP server ${name} in both package.json rawr.pluginContent.hostMcpServers and .mcp.json.`;
|
|
11110
|
+
}
|
|
11111
|
+
}
|
|
11112
|
+
for (const [label, bytes] of [[".claude-plugin/plugin.json", input.claudeManifestBytes], [".codex-plugin/plugin.json", input.codexManifestBytes]]) {
|
|
11113
|
+
if (bytes === void 0) continue;
|
|
11114
|
+
const parsed = parseUtf8JsonRecord(bytes);
|
|
11115
|
+
if (parsed === void 0) return `Plugin ${input.pluginId} ${label} must be a valid UTF-8 JSON object.`;
|
|
11116
|
+
if (!Object.hasOwn(parsed, "mcpServers")) continue;
|
|
11117
|
+
const rawMcpServers = Reflect.get(parsed, "mcpServers");
|
|
11118
|
+
if (rawMcpServers === void 0) continue;
|
|
11119
|
+
if (isPlainRecord(rawMcpServers)) {
|
|
11120
|
+
for (const name of Object.keys(rawMcpServers)) if (declaredHostNames.has(name)) return `Plugin ${input.pluginId} declares MCP server ${name} in both package.json rawr.pluginContent.hostMcpServers and ${label}.`;
|
|
11121
|
+
continue;
|
|
11122
|
+
}
|
|
11123
|
+
const paths = typeof rawMcpServers === "string" ? [rawMcpServers] : Array.isArray(rawMcpServers) && rawMcpServers.every((item) => typeof item === "string") ? rawMcpServers : null;
|
|
11124
|
+
if (paths === null || paths.some((entry) => entry !== "./.mcp.json" && entry !== ".mcp.json")) return `Plugin ${input.pluginId} ${label} declares non-inline mcpServers alongside package.json rawr.pluginContent.hostMcpServers.`;
|
|
11125
|
+
}
|
|
11126
|
+
}
|
|
11127
|
+
function parseUtf8JsonRecord(bytes) {
|
|
11128
|
+
let candidate;
|
|
11129
|
+
try {
|
|
11130
|
+
candidate = JSON.parse(utf8Decoder.decode(bytes));
|
|
11131
|
+
} catch {
|
|
11132
|
+
return;
|
|
11133
|
+
}
|
|
11134
|
+
return isPlainRecord(candidate) ? candidate : void 0;
|
|
11135
|
+
}
|
|
11136
|
+
function isPlainRecord(value) {
|
|
11137
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9832
11138
|
}
|
|
9833
11139
|
function collectOwnedName(owners, name, pluginId, issues) {
|
|
9834
11140
|
const existing = owners.get(name);
|
|
@@ -9847,7 +11153,63 @@ function sameMarketplaceSource(left, right) {
|
|
|
9847
11153
|
function sameMembers(left, right) {
|
|
9848
11154
|
return left.length === right.length && left.every((member, index) => {
|
|
9849
11155
|
const other = right[index];
|
|
9850
|
-
return other !== void 0 && member.pluginId === other.pluginId && member.payloadDigest === other.payloadDigest && member.releaseDigest === other.releaseDigest && sameTextArray(member.aliases, other.aliases) && sameSelectedContentManifest(member.manifest, other.manifest);
|
|
11156
|
+
return other !== void 0 && member.pluginId === other.pluginId && member.payloadDigest === other.payloadDigest && member.releaseDigest === other.releaseDigest && sameTextArray(member.aliases, other.aliases) && sameSelectedContentManifest(member.manifest, other.manifest) && (member.antigravityManifest === null && other.antigravityManifest === null || member.antigravityManifest !== null && other.antigravityManifest !== null && sameSelectedContentManifest(member.antigravityManifest, other.antigravityManifest)) && sameOmittedMcpServers(member.antigravityOmittedMcpServers, other.antigravityOmittedMcpServers);
|
|
11157
|
+
});
|
|
11158
|
+
}
|
|
11159
|
+
function deriveAntigravityBundleFacts(entries, repositoryUrl) {
|
|
11160
|
+
const projected = projectAntigravityPluginBundle({
|
|
11161
|
+
entries: entries.map((entry) => ({
|
|
11162
|
+
path: entry.path,
|
|
11163
|
+
mode: entry.mode,
|
|
11164
|
+
bytes: payloadEntryBytes(entry)
|
|
11165
|
+
})),
|
|
11166
|
+
repositoryUrl
|
|
11167
|
+
});
|
|
11168
|
+
if (!projected.ok || projected.entries.length === 0 || projected.entries.length > 16384) return Object.freeze({
|
|
11169
|
+
manifest: null,
|
|
11170
|
+
omittedMcpServers: Object.freeze([])
|
|
11171
|
+
});
|
|
11172
|
+
const files = [];
|
|
11173
|
+
for (const entry of projected.entries) {
|
|
11174
|
+
const parsedPath = parseReleaseRelativePath$1(entry.path);
|
|
11175
|
+
if (!parsedPath.ok) return Object.freeze({
|
|
11176
|
+
manifest: null,
|
|
11177
|
+
omittedMcpServers: Object.freeze([])
|
|
11178
|
+
});
|
|
11179
|
+
files.push(Object.freeze({
|
|
11180
|
+
path: parsedPath.value,
|
|
11181
|
+
mode: entry.mode,
|
|
11182
|
+
byteLength: entry.bytes.byteLength,
|
|
11183
|
+
contentDigest: contentDigest(entry.bytes)
|
|
11184
|
+
}));
|
|
11185
|
+
}
|
|
11186
|
+
files.sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
|
|
11187
|
+
if (!isCanonicalDistinctOrder(files.map((file) => file.path))) return Object.freeze({
|
|
11188
|
+
manifest: null,
|
|
11189
|
+
omittedMcpServers: Object.freeze([])
|
|
11190
|
+
});
|
|
11191
|
+
const normalizedOmitted = projected.omittedMcpServers.map((item) => Object.freeze({
|
|
11192
|
+
name: boundOmittedMcpServerName(item.name),
|
|
11193
|
+
reason: item.reason
|
|
11194
|
+
})).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
|
|
11195
|
+
const distinctOmitted = [];
|
|
11196
|
+
const seenOmittedNames = /* @__PURE__ */ new Set();
|
|
11197
|
+
for (const item of normalizedOmitted) {
|
|
11198
|
+
if (seenOmittedNames.has(item.name)) continue;
|
|
11199
|
+
seenOmittedNames.add(item.name);
|
|
11200
|
+
distinctOmitted.push(item);
|
|
11201
|
+
if (distinctOmitted.length >= 16384) break;
|
|
11202
|
+
}
|
|
11203
|
+
const omittedMcpServers = Object.freeze(distinctOmitted);
|
|
11204
|
+
return Object.freeze({
|
|
11205
|
+
manifest: Object.freeze(files),
|
|
11206
|
+
omittedMcpServers
|
|
11207
|
+
});
|
|
11208
|
+
}
|
|
11209
|
+
function sameOmittedMcpServers(left, right) {
|
|
11210
|
+
return left.length === right.length && left.every((entry, index) => {
|
|
11211
|
+
const other = right[index];
|
|
11212
|
+
return other !== void 0 && entry.name === other.name && entry.reason === other.reason;
|
|
9851
11213
|
});
|
|
9852
11214
|
}
|
|
9853
11215
|
function sameSelectedContentManifest(left, right) {
|
|
@@ -9859,6 +11221,15 @@ function sameSelectedContentManifest(left, right) {
|
|
|
9859
11221
|
function sameTextArray(left, right) {
|
|
9860
11222
|
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
9861
11223
|
}
|
|
11224
|
+
function sameHostMcpServers(left, right) {
|
|
11225
|
+
return left.length === right.length && left.every((server, index) => {
|
|
11226
|
+
const other = right[index];
|
|
11227
|
+
return other !== void 0 && server.name === other.name && server.url === other.url && server.ownerPluginId === other.ownerPluginId;
|
|
11228
|
+
});
|
|
11229
|
+
}
|
|
11230
|
+
function compareText$8(left, right) {
|
|
11231
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
11232
|
+
}
|
|
9862
11233
|
function isCanonicalDistinctOrder(values) {
|
|
9863
11234
|
for (let index = 1; index < values.length; index += 1) if (values[index - 1] >= values[index]) return false;
|
|
9864
11235
|
return true;
|
|
@@ -9891,10 +11262,14 @@ function marketplaceSourceIsRelated(observed, desired) {
|
|
|
9891
11262
|
}
|
|
9892
11263
|
/** Selects the bounded payload manifest required for native file verification. */
|
|
9893
11264
|
function verificationFiles(member, provider) {
|
|
11265
|
+
if (provider === "antigravity") {
|
|
11266
|
+
if (member.antigravityManifest === null || member.antigravityManifest.length > MAX_PROVIDER_VERIFICATION_FILES) return null;
|
|
11267
|
+
return Object.freeze([...member.antigravityManifest].sort((left, right) => compareText$7(left.path, right.path)));
|
|
11268
|
+
}
|
|
9894
11269
|
const manifestPath = provider === "codex" ? ".codex-plugin/plugin.json" : ".claude-plugin/plugin.json";
|
|
9895
11270
|
if (!member.manifest.some((file) => file.path === manifestPath)) return null;
|
|
9896
11271
|
if (member.manifest.length > MAX_PROVIDER_VERIFICATION_FILES) return null;
|
|
9897
|
-
return Object.freeze([...member.manifest].sort((left, right) => compareText$
|
|
11272
|
+
return Object.freeze([...member.manifest].sort((left, right) => compareText$7(left.path, right.path)));
|
|
9898
11273
|
}
|
|
9899
11274
|
/**
|
|
9900
11275
|
* Plans the exact native file batches required to assess installed selected members.
|
|
@@ -10007,13 +11382,22 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
|
|
|
10007
11382
|
} else pushFact(facts, "marketplace-source", identity, "Marketplace source matches the selection.");
|
|
10008
11383
|
const desiredNames = new Set(content.members.flatMap((member) => [member.pluginId, ...member.aliases]));
|
|
10009
11384
|
for (const live of inventory.plugins) {
|
|
10010
|
-
|
|
11385
|
+
const normalizedLiveName = target.provider === "antigravity" ? live.name.toLowerCase() : live.name;
|
|
11386
|
+
if (live.marketplaceIdentity === identity || !desiredNames.has(normalizedLiveName)) continue;
|
|
10011
11387
|
collision = true;
|
|
10012
|
-
issues.push(providerIssue("PluginCollision", `Plugin name ${live.name} is associated with marketplace ${live.marketplaceIdentity}.`, content.members.find((member) => member.pluginId ===
|
|
11388
|
+
issues.push(providerIssue("PluginCollision", `Plugin name ${live.name} is associated with marketplace ${live.marketplaceIdentity}.`, content.members.find((member) => member.pluginId === normalizedLiveName || member.aliases.some((alias) => alias === normalizedLiveName))?.pluginId));
|
|
10013
11389
|
}
|
|
10014
11390
|
const members = [];
|
|
10015
11391
|
for (const member of content.members) {
|
|
10016
11392
|
const selector = providerPluginSelector(member, identity);
|
|
11393
|
+
if (target.provider === "antigravity") for (const omitted of member.antigravityOmittedMcpServers) pushRecordFact(facts, Object.freeze({
|
|
11394
|
+
kind: "mcp-omitted",
|
|
11395
|
+
pluginId: member.pluginId,
|
|
11396
|
+
name: omitted.name,
|
|
11397
|
+
reason: omitted.reason,
|
|
11398
|
+
subject: `${selector}:${omitted.name}`,
|
|
11399
|
+
detail: `Omitted MCP server ${omitted.name} from Antigravity projection (${omitted.reason}).`
|
|
11400
|
+
}));
|
|
10017
11401
|
const live = inventory.plugins.find((plugin) => plugin.selector === selector && plugin.marketplaceIdentity === identity);
|
|
10018
11402
|
if (live === void 0 || !live.installed) {
|
|
10019
11403
|
needsMutation = true;
|
|
@@ -10029,9 +11413,9 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
|
|
|
10029
11413
|
}
|
|
10030
11414
|
pushFact(facts, "plugin-installed", selector, "Plugin is installed from the selected marketplace.");
|
|
10031
11415
|
const enabled = live.enabled;
|
|
10032
|
-
if (enabled === false || target.provider === "claude" && enabled === null) {
|
|
11416
|
+
if (enabled === false || (target.provider === "claude" || target.provider === "antigravity") && enabled === null) {
|
|
10033
11417
|
needsMutation = true;
|
|
10034
|
-
issues.push(providerIssue("PluginDisabled", enabled === null ?
|
|
11418
|
+
issues.push(providerIssue("PluginDisabled", enabled === null ? `${target.provider === "claude" ? "Claude" : "Antigravity"} did not report enabled state for ${selector}.` : `Plugin ${selector} is disabled.`, member.pluginId));
|
|
10035
11419
|
} else if (enabled === true) pushFact(facts, "plugin-enabled", selector, "Plugin is enabled for the provider.");
|
|
10036
11420
|
if (verificationFiles(member, target.provider) === null) {
|
|
10037
11421
|
failed = true;
|
|
@@ -10059,7 +11443,7 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
|
|
|
10059
11443
|
});
|
|
10060
11444
|
continue;
|
|
10061
11445
|
}
|
|
10062
|
-
for (const fact of verified.facts)
|
|
11446
|
+
for (const fact of verified.facts) pushRecordFact(facts, fact);
|
|
10063
11447
|
if (verified.failed) failed = true;
|
|
10064
11448
|
if (!verified.matches) {
|
|
10065
11449
|
needsMutation = true;
|
|
@@ -10084,12 +11468,135 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
|
|
|
10084
11468
|
needsMutation = true;
|
|
10085
11469
|
for (const selector of omittedSelectors) issues.push(providerIssue("OmittedPluginPresent", `Managed plugin ${selector} is absent from the selected complete set.`));
|
|
10086
11470
|
}
|
|
11471
|
+
const mcpServers = [];
|
|
11472
|
+
const selectedStaleNames = [];
|
|
11473
|
+
const omittedStaleNames = [];
|
|
11474
|
+
const ledgerByName = new Map(inventory.managedMcpServers.map((record) => [record.name, record]));
|
|
11475
|
+
for (const desired of content.hostMcpServers) {
|
|
11476
|
+
const liveMcp = inventory.mcpServers.find((entry) => entry.name === desired.name);
|
|
11477
|
+
const ledgerEntry = ledgerByName.get(desired.name);
|
|
11478
|
+
const isManaged = ledgerEntry !== void 0 && liveMcp !== void 0 && liveMcp.transport === "http" && liveMcp.url === ledgerEntry.url;
|
|
11479
|
+
if (liveMcp === void 0) {
|
|
11480
|
+
needsMutation = true;
|
|
11481
|
+
issues.push(providerIssue("McpServerMissing", `Host MCP server ${desired.name} is not configured.`, desired.ownerPluginId));
|
|
11482
|
+
mcpServers.push(Object.freeze({
|
|
11483
|
+
server: desired,
|
|
11484
|
+
present: false,
|
|
11485
|
+
exact: false,
|
|
11486
|
+
replace: false
|
|
11487
|
+
}));
|
|
11488
|
+
continue;
|
|
11489
|
+
}
|
|
11490
|
+
if (liveMcp.transport !== "http" || liveMcp.url === null || parseCanonicalLoopbackHttpUrl(liveMcp.url) === void 0) {
|
|
11491
|
+
collision = true;
|
|
11492
|
+
issues.push(providerIssue("McpServerCollision", `MCP server ${desired.name} uses a non-loopback or non-HTTP configuration.`, desired.ownerPluginId));
|
|
11493
|
+
mcpServers.push(Object.freeze({
|
|
11494
|
+
server: desired,
|
|
11495
|
+
present: true,
|
|
11496
|
+
exact: false,
|
|
11497
|
+
replace: false
|
|
11498
|
+
}));
|
|
11499
|
+
continue;
|
|
11500
|
+
}
|
|
11501
|
+
if (liveMcp.url !== desired.url) {
|
|
11502
|
+
if (!isManaged) {
|
|
11503
|
+
collision = true;
|
|
11504
|
+
issues.push(providerIssue("McpServerCollision", `MCP server ${desired.name} is configured with unmanaged URL ${liveMcp.url}.`, desired.ownerPluginId));
|
|
11505
|
+
mcpServers.push(Object.freeze({
|
|
11506
|
+
server: desired,
|
|
11507
|
+
present: true,
|
|
11508
|
+
exact: false,
|
|
11509
|
+
replace: false
|
|
11510
|
+
}));
|
|
11511
|
+
} else {
|
|
11512
|
+
needsMutation = true;
|
|
11513
|
+
issues.push(providerIssue("McpServerDrift", `Host MCP server ${desired.name} points to ${liveMcp.url} instead of ${desired.url}.`, desired.ownerPluginId));
|
|
11514
|
+
mcpServers.push(Object.freeze({
|
|
11515
|
+
server: desired,
|
|
11516
|
+
present: true,
|
|
11517
|
+
exact: false,
|
|
11518
|
+
replace: true
|
|
11519
|
+
}));
|
|
11520
|
+
}
|
|
11521
|
+
continue;
|
|
11522
|
+
}
|
|
11523
|
+
if (liveMcp.enabled === false) {
|
|
11524
|
+
if (!isManaged) {
|
|
11525
|
+
collision = true;
|
|
11526
|
+
issues.push(providerIssue("McpServerCollision", `MCP server ${desired.name} is disabled by unmanaged configuration.`, desired.ownerPluginId));
|
|
11527
|
+
mcpServers.push(Object.freeze({
|
|
11528
|
+
server: desired,
|
|
11529
|
+
present: true,
|
|
11530
|
+
exact: false,
|
|
11531
|
+
replace: false
|
|
11532
|
+
}));
|
|
11533
|
+
} else {
|
|
11534
|
+
needsMutation = true;
|
|
11535
|
+
issues.push(providerIssue("McpServerDisabled", `Host MCP server ${desired.name} is disabled.`, desired.ownerPluginId));
|
|
11536
|
+
mcpServers.push(Object.freeze({
|
|
11537
|
+
server: desired,
|
|
11538
|
+
present: true,
|
|
11539
|
+
exact: false,
|
|
11540
|
+
replace: true
|
|
11541
|
+
}));
|
|
11542
|
+
}
|
|
11543
|
+
continue;
|
|
11544
|
+
}
|
|
11545
|
+
if (isManaged && ledgerEntry.ownerPluginId !== desired.ownerPluginId) {
|
|
11546
|
+
needsMutation = true;
|
|
11547
|
+
issues.push(providerIssue("McpServerDrift", `Host MCP server ${desired.name} ownership moved from ${ledgerEntry.ownerPluginId} to ${desired.ownerPluginId}.`, desired.ownerPluginId));
|
|
11548
|
+
mcpServers.push(Object.freeze({
|
|
11549
|
+
server: desired,
|
|
11550
|
+
present: true,
|
|
11551
|
+
exact: false,
|
|
11552
|
+
replace: true
|
|
11553
|
+
}));
|
|
11554
|
+
continue;
|
|
11555
|
+
}
|
|
11556
|
+
pushFact(facts, "mcp-configured", desired.name, desired.url);
|
|
11557
|
+
mcpServers.push(Object.freeze({
|
|
11558
|
+
server: desired,
|
|
11559
|
+
present: true,
|
|
11560
|
+
exact: true,
|
|
11561
|
+
replace: false
|
|
11562
|
+
}));
|
|
11563
|
+
}
|
|
11564
|
+
const desiredMcpNames = new Set(content.hostMcpServers.map((server) => server.name));
|
|
11565
|
+
const selectedPluginIds = new Set(content.members.map((member) => member.pluginId));
|
|
11566
|
+
for (const record of inventory.managedMcpServers) {
|
|
11567
|
+
if (desiredMcpNames.has(record.name) || !selectedPluginIds.has(record.ownerPluginId)) continue;
|
|
11568
|
+
const ownerMember = content.members.find((member) => member.pluginId === record.ownerPluginId);
|
|
11569
|
+
const liveMcp = inventory.mcpServers.find((entry) => entry.name === record.name);
|
|
11570
|
+
if (liveMcp !== void 0 && (liveMcp.transport !== "http" || liveMcp.url !== record.url)) {
|
|
11571
|
+
collision = true;
|
|
11572
|
+
issues.push(providerIssue("McpServerCollision", `MCP server ${record.name} was modified outside Habitat and cannot be retired.`, ownerMember?.pluginId));
|
|
11573
|
+
continue;
|
|
11574
|
+
}
|
|
11575
|
+
needsMutation = true;
|
|
11576
|
+
selectedStaleNames.push(record.name);
|
|
11577
|
+
issues.push(providerIssue("OmittedMcpServerPresent", `Managed host MCP server ${record.name} is no longer declared by selected plugin ${record.ownerPluginId}.`, ownerMember?.pluginId));
|
|
11578
|
+
}
|
|
11579
|
+
if (policy.retireOmitted) for (const record of inventory.managedMcpServers) {
|
|
11580
|
+
if (desiredMcpNames.has(record.name) || selectedPluginIds.has(record.ownerPluginId)) continue;
|
|
11581
|
+
const liveMcp = inventory.mcpServers.find((entry) => entry.name === record.name);
|
|
11582
|
+
if (liveMcp !== void 0 && (liveMcp.transport !== "http" || liveMcp.url !== record.url)) {
|
|
11583
|
+
collision = true;
|
|
11584
|
+
issues.push(providerIssue("McpServerCollision", `MCP server ${record.name} was modified outside Habitat and cannot be retired.`));
|
|
11585
|
+
continue;
|
|
11586
|
+
}
|
|
11587
|
+
needsMutation = true;
|
|
11588
|
+
omittedStaleNames.push(record.name);
|
|
11589
|
+
issues.push(providerIssue("OmittedMcpServerPresent", `Managed host MCP server ${record.name} belongs to an omitted plugin.`));
|
|
11590
|
+
}
|
|
11591
|
+
const selectedStaleMcpServers = Object.freeze(selectedStaleNames.sort(compareText$7));
|
|
11592
|
+
const candidateOmittedMcpServers = Object.freeze(omittedStaleNames.sort(compareText$7));
|
|
11593
|
+
const staleMcpRemovals = [...selectedStaleMcpServers, ...candidateOmittedMcpServers];
|
|
10087
11594
|
if (mutationIntent && !collision && !failed && needsMutation) {
|
|
10088
|
-
if (maximumPlannedOperations(target, marketplace !== void 0, marketplaceRefreshRequired, members, policy.retireOmitted ? candidateOmitted : []) > MAX_OPERATIONS_PER_TARGET) {
|
|
11595
|
+
if (maximumPlannedOperations(target, marketplace !== void 0, marketplaceRefreshRequired, members, mcpServers, policy.retireOmitted ? candidateOmitted : [], staleMcpRemovals) > MAX_OPERATIONS_PER_TARGET) {
|
|
10089
11596
|
failed = true;
|
|
10090
11597
|
issues.push(providerIssue("DesiredContentInvalid", "Selected native changes exceed the per-target operation bound."));
|
|
10091
11598
|
}
|
|
10092
|
-
const missing = missingMutationCapabilities(target, capabilities, marketplace !== void 0, marketplaceRefreshRequired, members, policy.retireOmitted ? candidateOmitted : []);
|
|
11599
|
+
const missing = missingMutationCapabilities(target, capabilities, marketplace !== void 0, marketplaceRefreshRequired, members, mcpServers, policy.retireOmitted ? candidateOmitted : [], staleMcpRemovals);
|
|
10093
11600
|
if (missing.length > 0) {
|
|
10094
11601
|
failed = true;
|
|
10095
11602
|
issues.push(providerIssue("CapabilityMissing", `Native provider lacks required commands: ${missing.join(", ")}.`));
|
|
@@ -10104,6 +11611,9 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
|
|
|
10104
11611
|
marketplaceExact,
|
|
10105
11612
|
marketplaceRefreshRequired,
|
|
10106
11613
|
members: Object.freeze(members),
|
|
11614
|
+
mcpServers: Object.freeze(mcpServers),
|
|
11615
|
+
selectedStaleMcpServers,
|
|
11616
|
+
omittedMcpServers: candidateOmittedMcpServers,
|
|
10107
11617
|
facts: Object.freeze(facts),
|
|
10108
11618
|
issues: Object.freeze(issues.slice(0, 256)),
|
|
10109
11619
|
collision,
|
|
@@ -10120,6 +11630,9 @@ function unavailableNativeTarget(target, detail) {
|
|
|
10120
11630
|
marketplacePresent: false,
|
|
10121
11631
|
marketplaceRefreshRequired: false,
|
|
10122
11632
|
members: Object.freeze([]),
|
|
11633
|
+
mcpServers: Object.freeze([]),
|
|
11634
|
+
selectedStaleMcpServers: Object.freeze([]),
|
|
11635
|
+
omittedMcpServers: Object.freeze([]),
|
|
10123
11636
|
facts: Object.freeze([]),
|
|
10124
11637
|
issues: Object.freeze([providerIssue("TargetUnavailable", detail)]),
|
|
10125
11638
|
collision: false,
|
|
@@ -10205,42 +11718,52 @@ function exactManagedOmittedSelectors(content, inventory) {
|
|
|
10205
11718
|
}
|
|
10206
11719
|
function candidateOmittedSelectors(content, inventory) {
|
|
10207
11720
|
const desiredNames = new Set(content.members.map((member) => member.pluginId));
|
|
10208
|
-
return Object.freeze([...new Set(inventory.plugins.filter((plugin) => plugin.marketplaceIdentity === content.marketplace.identity && !desiredNames.has(plugin.name)).map((plugin) => plugin.selector))].sort(compareText$
|
|
11721
|
+
return Object.freeze([...new Set(inventory.plugins.filter((plugin) => plugin.marketplaceIdentity === content.marketplace.identity && !desiredNames.has(plugin.name)).map((plugin) => plugin.selector))].sort(compareText$7));
|
|
10209
11722
|
}
|
|
10210
11723
|
function marketplaceRevisionIsUnobservable(observed, desired) {
|
|
10211
11724
|
return desired.kind === "git" && observed?.source?.kind === "git" && observed.source.repositoryUrl === desired.repositoryUrl && observed.source.revision === null;
|
|
10212
11725
|
}
|
|
10213
|
-
function missingMutationCapabilities(target, capabilities, marketplacePresent, marketplaceRefreshRequired, members, omittedSelectors) {
|
|
11726
|
+
function missingMutationCapabilities(target, capabilities, marketplacePresent, marketplaceRefreshRequired, members, mcpServers, omittedSelectors, omittedMcpServers) {
|
|
10214
11727
|
const required = /* @__PURE__ */ new Set();
|
|
10215
11728
|
if (marketplaceRefreshRequired) required.add("marketplace-add");
|
|
10216
11729
|
if (marketplacePresent && marketplaceRefreshRequired) required.add("marketplace-remove");
|
|
10217
11730
|
for (const member of members) {
|
|
10218
11731
|
if (!member.installed || !member.filesMatch || marketplaceRefreshRequired) required.add("plugin-install");
|
|
10219
11732
|
if (member.installed && (!member.filesMatch || marketplaceRefreshRequired)) required.add("plugin-remove");
|
|
10220
|
-
if (target.provider === "claude" && (member.enabled !== true || !member.installed) || target.provider === "codex" && member.enabled === false) required.add("plugin-enable");
|
|
11733
|
+
if ((target.provider === "claude" || target.provider === "antigravity") && (member.enabled !== true || !member.installed) || target.provider === "codex" && member.enabled === false) required.add("plugin-enable");
|
|
11734
|
+
}
|
|
11735
|
+
for (const mcp of mcpServers) {
|
|
11736
|
+
if (!mcp.exact) required.add("mcp-add");
|
|
11737
|
+
if (mcp.replace) required.add("mcp-remove");
|
|
10221
11738
|
}
|
|
10222
11739
|
if (omittedSelectors.length > 0) required.add("plugin-remove");
|
|
11740
|
+
if (omittedMcpServers.length > 0) required.add("mcp-remove");
|
|
10223
11741
|
const observed = new Set(capabilities.capabilities);
|
|
10224
|
-
return Object.freeze([...required].filter((capability) => !observed.has(capability)).sort(compareText$
|
|
11742
|
+
return Object.freeze([...required].filter((capability) => !observed.has(capability)).sort(compareText$7));
|
|
10225
11743
|
}
|
|
10226
|
-
function maximumPlannedOperations(target, marketplacePresent, marketplaceRefreshRequired, members, omittedSelectors) {
|
|
11744
|
+
function maximumPlannedOperations(target, marketplacePresent, marketplaceRefreshRequired, members, mcpServers, omittedSelectors, omittedMcpServers) {
|
|
10227
11745
|
let operations = marketplaceRefreshRequired ? marketplacePresent ? 2 : 1 : 0;
|
|
10228
11746
|
for (const member of members) {
|
|
10229
11747
|
if (!member.installed) operations += 1;
|
|
10230
11748
|
else if (!member.filesMatch || marketplaceRefreshRequired) operations += 2;
|
|
10231
|
-
if (target.provider === "claude" && (member.enabled !== true || !member.installed)) operations += 1;
|
|
11749
|
+
if ((target.provider === "claude" || target.provider === "antigravity") && (member.enabled !== true || !member.installed)) operations += 1;
|
|
10232
11750
|
}
|
|
10233
|
-
|
|
11751
|
+
for (const mcp of mcpServers) if (mcp.replace) operations += 2;
|
|
11752
|
+
else if (!mcp.exact) operations += 1;
|
|
11753
|
+
return operations + omittedSelectors.length + omittedMcpServers.length;
|
|
10234
11754
|
}
|
|
10235
11755
|
function pushFact(facts, kind, subject, detail) {
|
|
10236
|
-
|
|
10237
|
-
facts.push(Object.freeze({
|
|
11756
|
+
pushRecordFact(facts, Object.freeze({
|
|
10238
11757
|
kind,
|
|
10239
11758
|
subject,
|
|
10240
11759
|
detail
|
|
10241
11760
|
}));
|
|
10242
11761
|
}
|
|
10243
|
-
function
|
|
11762
|
+
function pushRecordFact(facts, fact) {
|
|
11763
|
+
if (facts.length >= 4096) return;
|
|
11764
|
+
facts.push(fact);
|
|
11765
|
+
}
|
|
11766
|
+
function compareText$7(left, right) {
|
|
10244
11767
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
10245
11768
|
}
|
|
10246
11769
|
//#endregion
|
|
@@ -10309,14 +11832,14 @@ function canonicalProviderTargets(targets) {
|
|
|
10309
11832
|
provider: target.provider,
|
|
10310
11833
|
home: target.home
|
|
10311
11834
|
})).sort((left, right) => {
|
|
10312
|
-
const provider = compareText$
|
|
10313
|
-
return provider === 0 ? compareText$
|
|
11835
|
+
const provider = compareText$6(left.provider, right.provider);
|
|
11836
|
+
return provider === 0 ? compareText$6(left.home, right.home) : provider;
|
|
10314
11837
|
});
|
|
10315
11838
|
const first = sorted[0];
|
|
10316
11839
|
if (first === void 0) throw new Error("Provider targets must be nonempty");
|
|
10317
11840
|
return Object.freeze([first, ...sorted.slice(1)]);
|
|
10318
11841
|
}
|
|
10319
|
-
function compareText$
|
|
11842
|
+
function compareText$6(left, right) {
|
|
10320
11843
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
10321
11844
|
}
|
|
10322
11845
|
function hasPossibleConfirmedOperationHistory(result) {
|
|
@@ -10421,8 +11944,8 @@ function validateClaudeMembers(manifest, expectedMembers) {
|
|
|
10421
11944
|
}
|
|
10422
11945
|
function validateExactMembers(actualMembers, expectedMembers, provider) {
|
|
10423
11946
|
if (new Set(actualMembers).size !== actualMembers.length) return invalid(`${provider} marketplace contains duplicate plugin identities.`);
|
|
10424
|
-
const actual = [...actualMembers].sort(compareText$
|
|
10425
|
-
const expected = [...expectedMembers].sort(compareText$
|
|
11947
|
+
const actual = [...actualMembers].sort(compareText$5);
|
|
11948
|
+
const expected = [...expectedMembers].sort(compareText$5);
|
|
10426
11949
|
if (actual.length !== expected.length || actual.some((pluginId, index) => pluginId !== expected[index])) return invalid(`${provider} marketplace plugin set differs from the release input.`);
|
|
10427
11950
|
return Object.freeze({ ok: true });
|
|
10428
11951
|
}
|
|
@@ -10435,7 +11958,7 @@ function invalid(detail) {
|
|
|
10435
11958
|
detail
|
|
10436
11959
|
});
|
|
10437
11960
|
}
|
|
10438
|
-
function compareText$
|
|
11961
|
+
function compareText$5(left, right) {
|
|
10439
11962
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
10440
11963
|
}
|
|
10441
11964
|
//#endregion
|
|
@@ -10790,16 +12313,16 @@ const status$1 = module$5.status.effect(function* ({ context, errors, input }) {
|
|
|
10790
12313
|
* sequentially after TypeBox admits the provider observation.
|
|
10791
12314
|
*/
|
|
10792
12315
|
const observeTarget = (content, target, mutationIntent) => Effect.gen(function* () {
|
|
10793
|
-
const acquire = target.provider === "codex" ? context.nativeProviders.codex.acquire({ home: target.home }).pipe(Effect.map((session) => session)) : context.nativeProviders.claude.acquire({ home: target.home }).pipe(Effect.map((session) => session));
|
|
12316
|
+
const acquire = target.provider === "codex" ? context.nativeProviders.codex.acquire({ home: target.home }).pipe(Effect.map((session) => session)) : target.provider === "claude" ? context.nativeProviders.claude.acquire({ home: target.home }).pipe(Effect.map((session) => session)) : context.nativeProviders.antigravity.acquire({ home: target.home }).pipe(Effect.map((session) => session));
|
|
10794
12317
|
const acquisition = yield* Effect.result(acquire);
|
|
10795
12318
|
if (Result.isFailure(acquisition)) return unavailableNativeTarget(target, `Native provider acquisition failed: ${acquisition.failure.detail}`);
|
|
10796
12319
|
const session = acquisition.success;
|
|
10797
12320
|
if (session.provider !== target.provider || session.home !== target.home) return unavailableNativeTarget(target, "Native provider acquisition returned a session for a different target.");
|
|
10798
|
-
const observation = Effect.all([session.probe(), session.inventory()], { concurrency: 2 });
|
|
12321
|
+
const observation = Effect.all([session.probe(), session.inventory({ observeMcpServers: content.hostMcpServers.length > 0 })], { concurrency: 2 });
|
|
10799
12322
|
const observed = yield* Effect.result(observation);
|
|
10800
12323
|
if (Result.isFailure(observed)) return unavailableNativeTarget(target, `Native provider inspection failed: ${observed.failure.detail}`);
|
|
10801
12324
|
const [capabilities, inventory] = observed.success;
|
|
10802
|
-
if (!Value.Check(NativeProviderCapabilitiesSchema, capabilities) || !Value.Check(NativeProviderInventorySchema, inventory) || capabilities.provider !== target.provider || inventory.provider !== target.provider || capabilities.home !== target.home || session.provider === "claude" && (typeof session.enablePlugin !== "function" || !new Set(capabilities.capabilities).has("plugin-enable"))) return unavailableNativeTarget(target, "Native provider inspection returned facts for a different target.");
|
|
12325
|
+
if (!Value.Check(NativeProviderCapabilitiesSchema, capabilities) || !Value.Check(NativeProviderInventorySchema, inventory) || capabilities.provider !== target.provider || inventory.provider !== target.provider || capabilities.home !== target.home || (session.provider === "claude" || session.provider === "antigravity") && (typeof session.enablePlugin !== "function" || !new Set(capabilities.capabilities).has("plugin-enable"))) return unavailableNativeTarget(target, "Native provider inspection returned facts for a different target.");
|
|
10803
12326
|
const fileAssessments = [];
|
|
10804
12327
|
for (const plan of planNativePluginFileReads(content, target, inventory)) {
|
|
10805
12328
|
const attempt = yield* Effect.result(session.readPluginFiles({
|
|
@@ -11166,10 +12689,10 @@ function planNativeTargetMutation(content, assessment, policy) {
|
|
|
11166
12689
|
kind: "plugin-installed",
|
|
11167
12690
|
selector: member.selector
|
|
11168
12691
|
}, "IfMissing"));
|
|
11169
|
-
if (assessment.target.provider === "claude" && (member.enabled !== true || !member.installed || replace)) steps.push(commandPlan({
|
|
12692
|
+
if ((assessment.target.provider === "claude" || assessment.target.provider === "antigravity") && (member.enabled !== true || !member.installed || replace)) steps.push(commandPlan({
|
|
11170
12693
|
kind: "plugin-enabled",
|
|
11171
12694
|
selector: member.selector
|
|
11172
|
-
}, "
|
|
12695
|
+
}, "IfPluginNotEnabled"));
|
|
11173
12696
|
const files = verificationFiles(member.member, assessment.target.provider);
|
|
11174
12697
|
if (files !== null) steps.push(Object.freeze({
|
|
11175
12698
|
kind: "VerifyMember",
|
|
@@ -11180,16 +12703,44 @@ function planNativeTargetMutation(content, assessment, policy) {
|
|
|
11180
12703
|
})
|
|
11181
12704
|
}));
|
|
11182
12705
|
}
|
|
12706
|
+
for (const mcp of assessment.mcpServers) {
|
|
12707
|
+
if (mcp.replace) steps.push(commandPlan({
|
|
12708
|
+
kind: "mcp-removed",
|
|
12709
|
+
name: mcp.server.name
|
|
12710
|
+
}, "IfMcpOrLedgerPresent"));
|
|
12711
|
+
if (!mcp.exact) steps.push(commandPlan({
|
|
12712
|
+
kind: "mcp-added",
|
|
12713
|
+
name: mcp.server.name,
|
|
12714
|
+
url: mcp.server.url
|
|
12715
|
+
}, "IfMcpNotExact"));
|
|
12716
|
+
}
|
|
12717
|
+
for (const staleName of assessment.selectedStaleMcpServers) steps.push(commandPlan({
|
|
12718
|
+
kind: "mcp-removed",
|
|
12719
|
+
name: staleName
|
|
12720
|
+
}, "IfMcpOrLedgerPresent"));
|
|
11183
12721
|
if (policy.retireOmitted) steps.push(Object.freeze({ kind: "RetireOmitted" }));
|
|
11184
12722
|
return Object.freeze(steps);
|
|
11185
12723
|
}
|
|
11186
12724
|
/** Determines whether the current inventory still requires one planned command. */
|
|
11187
|
-
function nativeCommandIsRequired(plan, inventory) {
|
|
12725
|
+
function nativeCommandIsRequired(content, plan, inventory) {
|
|
12726
|
+
const { operation } = plan;
|
|
11188
12727
|
switch (plan.condition) {
|
|
11189
12728
|
case "Always": return true;
|
|
11190
|
-
case "IfInstalled": return
|
|
11191
|
-
case "IfMissing": return
|
|
11192
|
-
case "
|
|
12729
|
+
case "IfInstalled": return operation.kind === "plugin-removed" && installedPlugin(inventory, operation.selector) !== void 0;
|
|
12730
|
+
case "IfMissing": return operation.kind === "plugin-installed" && installedPlugin(inventory, operation.selector) === void 0;
|
|
12731
|
+
case "IfPluginNotEnabled": return operation.kind === "plugin-enabled" && installedPlugin(inventory, operation.selector)?.enabled !== true;
|
|
12732
|
+
case "IfMcpOrLedgerPresent": {
|
|
12733
|
+
if (operation.kind !== "mcp-removed") return false;
|
|
12734
|
+
const ledger = inventory.managedMcpServers.find((entry) => entry.name === operation.name);
|
|
12735
|
+
if (ledger === void 0) return false;
|
|
12736
|
+
const live = inventory.mcpServers.find((entry) => entry.name === operation.name);
|
|
12737
|
+
return live === void 0 || live.transport === "http" && live.url === ledger.url;
|
|
12738
|
+
}
|
|
12739
|
+
case "IfMcpNotExact": {
|
|
12740
|
+
if (operation.kind !== "mcp-added") return false;
|
|
12741
|
+
const desired = content.hostMcpServers.find((entry) => entry.name === operation.name);
|
|
12742
|
+
return desired !== void 0 && !hasExactManagedMcpServer(inventory, desired.name, desired.url, desired.ownerPluginId);
|
|
12743
|
+
}
|
|
11193
12744
|
}
|
|
11194
12745
|
}
|
|
11195
12746
|
/** Admits removal only while the marketplace still belongs to the selected source family. */
|
|
@@ -11211,12 +12762,25 @@ function planOmittedRetirement(content, inventory, confirmedOperationCount) {
|
|
|
11211
12762
|
ok: false,
|
|
11212
12763
|
issue: providerIssue("MarketplaceCollision", "Managed plugin retirement requires one exact observed marketplace source.")
|
|
11213
12764
|
});
|
|
11214
|
-
|
|
12765
|
+
const desiredMcpNames = new Set(content.hostMcpServers.map((server) => server.name));
|
|
12766
|
+
const retiredMcpNames = [];
|
|
12767
|
+
for (const record of inventory.managedMcpServers) {
|
|
12768
|
+
if (desiredMcpNames.has(record.name)) continue;
|
|
12769
|
+
const live = inventory.mcpServers.find((entry) => entry.name === record.name);
|
|
12770
|
+
if (live !== void 0 && (live.transport !== "http" || live.url !== record.url)) return Object.freeze({
|
|
12771
|
+
ok: false,
|
|
12772
|
+
issue: providerIssue("McpServerCollision", `MCP server ${record.name} was modified outside Habitat and cannot be retired.`)
|
|
12773
|
+
});
|
|
12774
|
+
retiredMcpNames.push(record.name);
|
|
12775
|
+
}
|
|
12776
|
+
const mcpNames = Object.freeze([...new Set(retiredMcpNames)].sort(compareText$4));
|
|
12777
|
+
if (confirmedOperationCount + mcpNames.length + selectors.length > MAX_CONFIRMED_NATIVE_OPERATIONS) return Object.freeze({
|
|
11215
12778
|
ok: false,
|
|
11216
12779
|
issue: providerIssue("DesiredContentInvalid", "Selected native changes exceed the per-target operation bound.")
|
|
11217
12780
|
});
|
|
11218
12781
|
return Object.freeze({
|
|
11219
12782
|
ok: true,
|
|
12783
|
+
mcpNames,
|
|
11220
12784
|
selectors
|
|
11221
12785
|
});
|
|
11222
12786
|
}
|
|
@@ -11347,6 +12911,18 @@ function notAttemptedAfterMutation(assessments) {
|
|
|
11347
12911
|
function finalNativeAssessmentIssue(assessment) {
|
|
11348
12912
|
return assessment.failed || assessment.collision || assessment.needsMutation ? providerIssue("VerificationFailed", "Final native provider verification did not converge.") : void 0;
|
|
11349
12913
|
}
|
|
12914
|
+
/** Emits `mcp-absent` facts for stale host MCP servers retired and verified absent. */
|
|
12915
|
+
function retiredOmittedMcpFacts(content, operations, finalInventory) {
|
|
12916
|
+
const desiredNames = new Set(content.hostMcpServers.map((server) => server.name));
|
|
12917
|
+
const liveNames = new Set(finalInventory.mcpServers.map((server) => server.name));
|
|
12918
|
+
const managedNames = new Set(finalInventory.managedMcpServers.map((server) => server.name));
|
|
12919
|
+
const names = [...new Set(operations.filter((operation) => operation.kind === "mcp-removed" && !desiredNames.has(operation.name) && !liveNames.has(operation.name) && !managedNames.has(operation.name)).map((operation) => operation.name))].sort(compareText$4);
|
|
12920
|
+
return Object.freeze(names.map((name) => Object.freeze({
|
|
12921
|
+
kind: "mcp-absent",
|
|
12922
|
+
subject: name,
|
|
12923
|
+
detail: "Host-scoped HTTP MCP server was retired."
|
|
12924
|
+
})));
|
|
12925
|
+
}
|
|
11350
12926
|
function commandPlan(operation, condition) {
|
|
11351
12927
|
return Object.freeze({
|
|
11352
12928
|
kind: "Command",
|
|
@@ -11361,8 +12937,23 @@ function nativeOperationPostcondition(content, operation, inventory) {
|
|
|
11361
12937
|
case "plugin-removed": return observedPlugin(inventory, operation.selector) === void 0;
|
|
11362
12938
|
case "plugin-installed": return installedPlugin(inventory, operation.selector) !== void 0;
|
|
11363
12939
|
case "plugin-enabled": return installedPlugin(inventory, operation.selector)?.enabled === true;
|
|
12940
|
+
case "mcp-removed": return !inventory.mcpServers.some((server) => server.name === operation.name) && !inventory.managedMcpServers.some((server) => server.name === operation.name);
|
|
12941
|
+
case "mcp-added": {
|
|
12942
|
+
const desired = content.hostMcpServers.find((entry) => entry.name === operation.name);
|
|
12943
|
+
return desired === void 0 ? hasExactMcpServer(inventory, operation.name, operation.url) : hasExactManagedMcpServer(inventory, operation.name, operation.url, desired.ownerPluginId);
|
|
12944
|
+
}
|
|
11364
12945
|
}
|
|
11365
12946
|
}
|
|
12947
|
+
function hasExactMcpServer(inventory, name, url) {
|
|
12948
|
+
const live = inventory.mcpServers.find((entry) => entry.name === name);
|
|
12949
|
+
return live !== void 0 && live.transport === "http" && live.url === url && live.enabled !== false;
|
|
12950
|
+
}
|
|
12951
|
+
function hasExactManagedMcpServer(inventory, name, url, ownerPluginId) {
|
|
12952
|
+
return hasExactMcpServer(inventory, name, url) && inventory.managedMcpServers.some((record) => record.name === name && record.url === url && record.ownerPluginId === ownerPluginId);
|
|
12953
|
+
}
|
|
12954
|
+
function compareText$4(left, right) {
|
|
12955
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
12956
|
+
}
|
|
11366
12957
|
//#endregion
|
|
11367
12958
|
//#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/router/sync.ts
|
|
11368
12959
|
/**
|
|
@@ -11399,7 +12990,7 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
|
|
|
11399
12990
|
* session is invocation-local and is reused only by the final mutation pass.
|
|
11400
12991
|
*/
|
|
11401
12992
|
const observeTarget = (content, target, mutationIntent) => Effect.gen(function* () {
|
|
11402
|
-
const acquire = target.provider === "codex" ? context.nativeProviders.codex.acquire({ home: target.home }).pipe(Effect.map((session) => session)) : context.nativeProviders.claude.acquire({ home: target.home }).pipe(Effect.map((session) => session));
|
|
12993
|
+
const acquire = target.provider === "codex" ? context.nativeProviders.codex.acquire({ home: target.home }).pipe(Effect.map((session) => session)) : target.provider === "claude" ? context.nativeProviders.claude.acquire({ home: target.home }).pipe(Effect.map((session) => session)) : context.nativeProviders.antigravity.acquire({ home: target.home }).pipe(Effect.map((session) => session));
|
|
11403
12994
|
const acquisition = yield* Effect.result(acquire);
|
|
11404
12995
|
if (Result.isFailure(acquisition)) return Object.freeze({
|
|
11405
12996
|
kind: "Unavailable",
|
|
@@ -11410,14 +13001,14 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
|
|
|
11410
13001
|
kind: "Unavailable",
|
|
11411
13002
|
assessment: unavailableNativeTarget(target, "Native provider acquisition returned a session for a different target.")
|
|
11412
13003
|
});
|
|
11413
|
-
const observation = Effect.all([session.probe(), session.inventory()], { concurrency: 2 });
|
|
13004
|
+
const observation = Effect.all([session.probe(), session.inventory({ observeMcpServers: content.hostMcpServers.length > 0 })], { concurrency: 2 });
|
|
11414
13005
|
const observed = yield* Effect.result(observation);
|
|
11415
13006
|
if (Result.isFailure(observed)) return Object.freeze({
|
|
11416
13007
|
kind: "Unavailable",
|
|
11417
13008
|
assessment: unavailableNativeTarget(target, `Native provider inspection failed: ${observed.failure.detail}`)
|
|
11418
13009
|
});
|
|
11419
13010
|
const [capabilities, inventory] = observed.success;
|
|
11420
|
-
if (!Value.Check(NativeProviderCapabilitiesSchema, capabilities) || !Value.Check(NativeProviderInventorySchema, inventory) || capabilities.provider !== target.provider || inventory.provider !== target.provider || capabilities.home !== target.home || session.provider === "claude" && (typeof session.enablePlugin !== "function" || !new Set(capabilities.capabilities).has("plugin-enable"))) return Object.freeze({
|
|
13011
|
+
if (!Value.Check(NativeProviderCapabilitiesSchema, capabilities) || !Value.Check(NativeProviderInventorySchema, inventory) || capabilities.provider !== target.provider || inventory.provider !== target.provider || capabilities.home !== target.home || (session.provider === "claude" || session.provider === "antigravity") && (typeof session.enablePlugin !== "function" || !new Set(capabilities.capabilities).has("plugin-enable"))) return Object.freeze({
|
|
11421
13012
|
kind: "Unavailable",
|
|
11422
13013
|
assessment: unavailableNativeTarget(target, "Native provider inspection returned facts for a different target.")
|
|
11423
13014
|
});
|
|
@@ -11430,7 +13021,7 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
|
|
|
11430
13021
|
/** Preflights every target sequentially before any target can mutate. */
|
|
11431
13022
|
const observeTargets = (content, targets, mutationIntent) => Effect.forEach(targets, (target) => observeTarget(content, target, mutationIntent), { concurrency: 1 }).pipe(Effect.map((observations) => Object.freeze(observations)));
|
|
11432
13023
|
/** Recovers best-effort terminal facts without turning evidence into authority. */
|
|
11433
|
-
const observeTerminalFacts = (content, observation) => Effect.result(observation.session.inventory()).pipe(Effect.flatMap((attempt) => {
|
|
13024
|
+
const observeTerminalFacts = (content, observation) => Effect.result(observation.session.inventory({ observeMcpServers: content.hostMcpServers.length > 0 })).pipe(Effect.flatMap((attempt) => {
|
|
11434
13025
|
if (Result.isFailure(attempt) || !Value.Check(NativeProviderInventorySchema, attempt.success) || attempt.success.provider !== observation.assessment.target.provider) return Effect.succeed(Object.freeze([]));
|
|
11435
13026
|
return assessInventory(content, observation.assessment.target, observation.session, observation.assessment.capabilities, attempt.success, false).pipe(Effect.map((assessment) => assessment.facts));
|
|
11436
13027
|
}));
|
|
@@ -11453,13 +13044,31 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
|
|
|
11453
13044
|
kind: "Ready",
|
|
11454
13045
|
effect: session.removePlugin({ selector: operation.selector })
|
|
11455
13046
|
});
|
|
11456
|
-
case "plugin-enabled": return session.provider === "claude" ? Object.freeze({
|
|
13047
|
+
case "plugin-enabled": return session.provider === "claude" || session.provider === "antigravity" ? Object.freeze({
|
|
11457
13048
|
kind: "Ready",
|
|
11458
13049
|
effect: session.enablePlugin({ selector: operation.selector })
|
|
11459
13050
|
}) : Object.freeze({
|
|
11460
13051
|
kind: "Refused",
|
|
11461
13052
|
issue: providerIssue("CapabilityMissing", "Codex did not expose plugin enablement.")
|
|
11462
13053
|
});
|
|
13054
|
+
case "mcp-added": {
|
|
13055
|
+
const desired = content.hostMcpServers.find((entry) => entry.name === operation.name);
|
|
13056
|
+
return desired === void 0 ? Object.freeze({
|
|
13057
|
+
kind: "Refused",
|
|
13058
|
+
issue: providerIssue("DesiredContentInvalid", `Host MCP server ${operation.name} has no selected owner plugin.`)
|
|
13059
|
+
}) : Object.freeze({
|
|
13060
|
+
kind: "Ready",
|
|
13061
|
+
effect: session.addMcpServer({
|
|
13062
|
+
name: operation.name,
|
|
13063
|
+
url: operation.url,
|
|
13064
|
+
ownerPluginId: desired.ownerPluginId
|
|
13065
|
+
})
|
|
13066
|
+
});
|
|
13067
|
+
}
|
|
13068
|
+
case "mcp-removed": return Object.freeze({
|
|
13069
|
+
kind: "Ready",
|
|
13070
|
+
effect: session.removeMcpServer({ name: operation.name })
|
|
13071
|
+
});
|
|
11463
13072
|
}
|
|
11464
13073
|
};
|
|
11465
13074
|
/** Attempts one native command and immediately observes its postcondition. */
|
|
@@ -11475,7 +13084,7 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
|
|
|
11475
13084
|
commandPhase: commandAttempt.failure.commandPhase,
|
|
11476
13085
|
detail: commandAttempt.failure.detail
|
|
11477
13086
|
}) : Object.freeze({ kind: "Returned" });
|
|
11478
|
-
const inventoryAttempt = yield* Effect.result(observation.session.inventory());
|
|
13087
|
+
const inventoryAttempt = yield* Effect.result(observation.session.inventory({ observeMcpServers: content.hostMcpServers.length > 0 || operation.kind === "mcp-added" || operation.kind === "mcp-removed" }));
|
|
11479
13088
|
return classifyNativeMutationStep(content, operation, command, Result.isFailure(inventoryAttempt) ? Object.freeze({
|
|
11480
13089
|
kind: "Failed",
|
|
11481
13090
|
detail: inventoryAttempt.failure.detail
|
|
@@ -11504,7 +13113,7 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
|
|
|
11504
13113
|
};
|
|
11505
13114
|
for (const plan of planNativeTargetMutation(content, assessment, nativePolicy)) {
|
|
11506
13115
|
if (plan.kind === "GuardMarketplaceRemoval") {
|
|
11507
|
-
const guardAttempt = yield* Effect.result(session.inventory());
|
|
13116
|
+
const guardAttempt = yield* Effect.result(session.inventory({ observeMcpServers: content.hostMcpServers.length > 0 }));
|
|
11508
13117
|
if (Result.isFailure(guardAttempt)) return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", `Marketplace could not be reobserved before removal: ${guardAttempt.failure.detail}`)]);
|
|
11509
13118
|
if (!Value.Check(NativeProviderInventorySchema, guardAttempt.success) || guardAttempt.success.provider !== assessment.target.provider) return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", "Marketplace could not be admitted before removal.")]);
|
|
11510
13119
|
inventory = guardAttempt.success;
|
|
@@ -11527,6 +13136,16 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
|
|
|
11527
13136
|
if (plan.kind === "RetireOmitted") {
|
|
11528
13137
|
const retirement = planOmittedRetirement(content, inventory, operations.length);
|
|
11529
13138
|
if (!retirement.ok) return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, retirement.issue]);
|
|
13139
|
+
for (const name of retirement.mcpNames) {
|
|
13140
|
+
const operation = Object.freeze({
|
|
13141
|
+
kind: "mcp-removed",
|
|
13142
|
+
name
|
|
13143
|
+
});
|
|
13144
|
+
const step = yield* mutateAndObserve(content, observation, operation);
|
|
13145
|
+
const terminal = yield* terminalResult(step);
|
|
13146
|
+
if (terminal !== void 0) return terminal;
|
|
13147
|
+
acceptCompletedStep(step, operation);
|
|
13148
|
+
}
|
|
11530
13149
|
for (const selector of retirement.selectors) {
|
|
11531
13150
|
const operation = Object.freeze({
|
|
11532
13151
|
kind: "plugin-removed",
|
|
@@ -11539,13 +13158,13 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
|
|
|
11539
13158
|
}
|
|
11540
13159
|
continue;
|
|
11541
13160
|
}
|
|
11542
|
-
if (!nativeCommandIsRequired(plan, inventory)) continue;
|
|
13161
|
+
if (!nativeCommandIsRequired(content, plan, inventory)) continue;
|
|
11543
13162
|
const step = yield* mutateAndObserve(content, observation, plan.operation);
|
|
11544
13163
|
const terminal = yield* terminalResult(step);
|
|
11545
13164
|
if (terminal !== void 0) return terminal;
|
|
11546
13165
|
acceptCompletedStep(step, plan.operation);
|
|
11547
13166
|
}
|
|
11548
|
-
const finalInventoryAttempt = yield* Effect.result(session.inventory());
|
|
13167
|
+
const finalInventoryAttempt = yield* Effect.result(session.inventory({ observeMcpServers: content.hostMcpServers.length > 0 || operations.some((operation) => operation.kind === "mcp-added" || operation.kind === "mcp-removed") }));
|
|
11549
13168
|
if (Result.isFailure(finalInventoryAttempt)) return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", `Final provider state could not be observed: ${finalInventoryAttempt.failure.detail}`)]);
|
|
11550
13169
|
if (!Value.Check(NativeProviderInventorySchema, finalInventoryAttempt.success) || finalInventoryAttempt.success.provider !== assessment.target.provider) return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", "Final provider state returned an invalid inventory.")]);
|
|
11551
13170
|
const finalAssessment = yield* assessInventory(content, assessment.target, session, assessment.capabilities, finalInventoryAttempt.success, false);
|
|
@@ -11555,7 +13174,8 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
|
|
|
11555
13174
|
...finalAssessment.issues,
|
|
11556
13175
|
finalIssue
|
|
11557
13176
|
]);
|
|
11558
|
-
|
|
13177
|
+
const retiredFacts = retiredOmittedMcpFacts(content, operations, finalInventoryAttempt.success);
|
|
13178
|
+
return completedMutationTarget(assessment, operations, [...finalAssessment.facts, ...retiredFacts], issues);
|
|
11559
13179
|
});
|
|
11560
13180
|
/**
|
|
11561
13181
|
* Performs one complete current-main plus selected-content observation.
|
|
@@ -11984,7 +13604,16 @@ const router$7 = {
|
|
|
11984
13604
|
};
|
|
11985
13605
|
/** Acquires and admits one invocation-local native session without observing provider state. */
|
|
11986
13606
|
const acquireTarget = (target) => Effect.gen(function* () {
|
|
11987
|
-
const acquire = target.provider === "codex" ? context.nativeProviders.codex.acquire({
|
|
13607
|
+
const acquire = target.provider === "codex" ? context.nativeProviders.codex.acquire({
|
|
13608
|
+
home: target.home,
|
|
13609
|
+
disposableRoot: canonicalRequest.disposableRoot
|
|
13610
|
+
}).pipe(Effect.map((session) => session)) : target.provider === "claude" ? context.nativeProviders.claude.acquire({
|
|
13611
|
+
home: target.home,
|
|
13612
|
+
disposableRoot: canonicalRequest.disposableRoot
|
|
13613
|
+
}).pipe(Effect.map((session) => session)) : context.nativeProviders.antigravity.acquire({
|
|
13614
|
+
home: target.home,
|
|
13615
|
+
disposableRoot: canonicalRequest.disposableRoot
|
|
13616
|
+
}).pipe(Effect.map((session) => session));
|
|
11988
13617
|
const acquisition = yield* Effect.result(acquire);
|
|
11989
13618
|
if (Result.isFailure(acquisition)) return Object.freeze({
|
|
11990
13619
|
kind: "Unavailable",
|
|
@@ -12008,7 +13637,10 @@ const router$7 = {
|
|
|
12008
13637
|
* Typed provider failures remain ordinary facts. Defects and interruption
|
|
12009
13638
|
* continue through the Effect cause channel.
|
|
12010
13639
|
*/
|
|
12011
|
-
const observeInventory = (session, target) => Effect.result(session.inventory(
|
|
13640
|
+
const observeInventory = (content, session, target, observeMcpServers) => Effect.result(session.inventory({
|
|
13641
|
+
observeMcpServers,
|
|
13642
|
+
relevantOwnerPluginIds: content.members.map((member) => member.pluginId)
|
|
13643
|
+
})).pipe(Effect.map((attempt) => {
|
|
12012
13644
|
if (Result.isFailure(attempt)) return Object.freeze({
|
|
12013
13645
|
kind: "Failed",
|
|
12014
13646
|
detail: attempt.failure.detail
|
|
@@ -12063,19 +13695,24 @@ const router$7 = {
|
|
|
12063
13695
|
* @param inventory - TypeBox-admitted live provider inventory.
|
|
12064
13696
|
* @param mutationIntent - Whether this observation must admit planned commands.
|
|
12065
13697
|
*/
|
|
12066
|
-
const assessInventory = (content, target, session, capabilities, inventory, mutationIntent) =>
|
|
13698
|
+
const assessInventory = (content, target, session, capabilities, inventory, mutationIntent) => Effect.gen(function* () {
|
|
13699
|
+
return assessNativeTarget(content, target, capabilities, inventory, yield* assessPluginFiles(content, target, session, inventory), nativePolicy, mutationIntent);
|
|
13700
|
+
});
|
|
12067
13701
|
/** Completely observes one admitted disposable provider target. */
|
|
12068
13702
|
const observeTarget = (content, admission, mutationIntent) => Effect.gen(function* () {
|
|
12069
13703
|
if (admission.kind === "Unavailable") return admission;
|
|
12070
13704
|
const { session, target } = admission;
|
|
12071
|
-
const inspection = Effect.all([session.probe(), session.inventory(
|
|
13705
|
+
const inspection = Effect.all([session.probe(), session.inventory({
|
|
13706
|
+
observeMcpServers: content.hostMcpServers.length > 0,
|
|
13707
|
+
relevantOwnerPluginIds: content.members.map((member) => member.pluginId)
|
|
13708
|
+
})], { concurrency: 2 });
|
|
12072
13709
|
const observed = yield* Effect.result(inspection);
|
|
12073
13710
|
if (Result.isFailure(observed)) return Object.freeze({
|
|
12074
13711
|
kind: "Unavailable",
|
|
12075
13712
|
assessment: unavailableNativeTarget(target, `Native provider inspection failed: ${observed.failure.detail}`)
|
|
12076
13713
|
});
|
|
12077
13714
|
const [capabilities, inventory] = observed.success;
|
|
12078
|
-
if (!Value.Check(NativeProviderCapabilitiesSchema, capabilities) || !Value.Check(NativeProviderInventorySchema, inventory) || capabilities.provider !== target.provider || inventory.provider !== target.provider || capabilities.home !== target.home || session.provider === "claude" && (typeof session.enablePlugin !== "function" || !new Set(capabilities.capabilities).has("plugin-enable"))) return Object.freeze({
|
|
13715
|
+
if (!Value.Check(NativeProviderCapabilitiesSchema, capabilities) || !Value.Check(NativeProviderInventorySchema, inventory) || capabilities.provider !== target.provider || inventory.provider !== target.provider || capabilities.home !== target.home || (session.provider === "claude" || session.provider === "antigravity") && (typeof session.enablePlugin !== "function" || !new Set(capabilities.capabilities).has("plugin-enable"))) return Object.freeze({
|
|
12079
13716
|
kind: "Unavailable",
|
|
12080
13717
|
assessment: unavailableNativeTarget(target, "Native provider inspection returned facts for a different target.")
|
|
12081
13718
|
});
|
|
@@ -12090,7 +13727,7 @@ const router$7 = {
|
|
|
12090
13727
|
const observeTargets = (content, admissions, mutationIntent) => Effect.forEach(admissions, (admission) => observeTarget(content, admission, mutationIntent), { concurrency: 1 }).pipe(Effect.map((observations) => Object.freeze(observations)));
|
|
12091
13728
|
/** Best-effort terminal observation for public failure diagnostics. */
|
|
12092
13729
|
const observeTerminalFacts = (content, observation) => Effect.gen(function* () {
|
|
12093
|
-
const inventory = yield* observeInventory(observation.session, observation.assessment.target);
|
|
13730
|
+
const inventory = yield* observeInventory(content, observation.session, observation.assessment.target, content.hostMcpServers.length > 0);
|
|
12094
13731
|
if (inventory.kind === "Failed") return Object.freeze([]);
|
|
12095
13732
|
return (yield* assessInventory(content, observation.assessment.target, observation.session, observation.assessment.capabilities, inventory.inventory, false)).facts;
|
|
12096
13733
|
});
|
|
@@ -12121,14 +13758,29 @@ const router$7 = {
|
|
|
12121
13758
|
mutation = session.removePlugin({ selector: operation.selector });
|
|
12122
13759
|
break;
|
|
12123
13760
|
case "plugin-enabled":
|
|
12124
|
-
if (session.provider !== "claude") return {
|
|
13761
|
+
if (session.provider !== "claude" && session.provider !== "antigravity") return {
|
|
12125
13762
|
kind: "Failed",
|
|
12126
13763
|
issue: providerIssue("CapabilityMissing", "Codex did not expose plugin enablement.")
|
|
12127
13764
|
};
|
|
12128
13765
|
mutation = session.enablePlugin({ selector: operation.selector });
|
|
13766
|
+
break;
|
|
13767
|
+
case "mcp-added": {
|
|
13768
|
+
const desired = content.hostMcpServers.find((entry) => entry.name === operation.name);
|
|
13769
|
+
if (desired === void 0) return {
|
|
13770
|
+
kind: "Failed",
|
|
13771
|
+
issue: providerIssue("DesiredContentInvalid", `Host MCP server ${operation.name} has no selected owner plugin.`)
|
|
13772
|
+
};
|
|
13773
|
+
mutation = session.addMcpServer({
|
|
13774
|
+
name: operation.name,
|
|
13775
|
+
url: operation.url,
|
|
13776
|
+
ownerPluginId: desired.ownerPluginId
|
|
13777
|
+
});
|
|
13778
|
+
break;
|
|
13779
|
+
}
|
|
13780
|
+
case "mcp-removed": mutation = session.removeMcpServer({ name: operation.name });
|
|
12129
13781
|
}
|
|
12130
13782
|
const command = yield* Effect.result(mutation);
|
|
12131
|
-
const observed = yield* observeInventory(session, assessment.target);
|
|
13783
|
+
const observed = yield* observeInventory(content, session, assessment.target, content.hostMcpServers.length > 0 || operation.kind === "mcp-added" || operation.kind === "mcp-removed");
|
|
12132
13784
|
return classifyNativeMutationStep(content, operation, Result.isFailure(command) ? {
|
|
12133
13785
|
kind: "Failed",
|
|
12134
13786
|
commandPhase: command.failure.commandPhase,
|
|
@@ -12137,7 +13789,7 @@ const router$7 = {
|
|
|
12137
13789
|
});
|
|
12138
13790
|
for (const plan of planNativeTargetMutation(content, assessment, nativePolicy)) switch (plan.kind) {
|
|
12139
13791
|
case "GuardMarketplaceRemoval": {
|
|
12140
|
-
const observed = yield* observeInventory(session, assessment.target);
|
|
13792
|
+
const observed = yield* observeInventory(content, session, assessment.target, content.hostMcpServers.length > 0);
|
|
12141
13793
|
if (observed.kind === "Failed") return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", `Marketplace could not be reobserved before removal: ${observed.detail}`)]);
|
|
12142
13794
|
inventory = observed.inventory;
|
|
12143
13795
|
const ownershipIssue = marketplaceRemovalIssue(content, inventory);
|
|
@@ -12151,7 +13803,7 @@ const router$7 = {
|
|
|
12151
13803
|
}
|
|
12152
13804
|
case "RetireOmitted": return failedMutationTarget(assessment, operations, yield* observeTerminalFacts(content, observation), [...issues, providerIssue("DesiredContentInvalid", "Disposable provider testing cannot retire omitted plugins.")]);
|
|
12153
13805
|
case "Command": {
|
|
12154
|
-
if (!nativeCommandIsRequired(plan, inventory)) break;
|
|
13806
|
+
if (!nativeCommandIsRequired(content, plan, inventory)) break;
|
|
12155
13807
|
const step = yield* executeCommand(plan.operation);
|
|
12156
13808
|
if (step.kind === "Failed") return failedMutationTarget(assessment, operations, yield* observeTerminalFacts(content, observation), [...issues, step.issue]);
|
|
12157
13809
|
if (step.kind === "Uncertain") return uncertainMutationTarget(assessment, operations, step.attempted, yield* observeTerminalFacts(content, observation), [...issues, step.issue]);
|
|
@@ -12160,11 +13812,12 @@ const router$7 = {
|
|
|
12160
13812
|
break;
|
|
12161
13813
|
}
|
|
12162
13814
|
}
|
|
12163
|
-
const finalInventory = yield* observeInventory(session, assessment.target);
|
|
13815
|
+
const finalInventory = yield* observeInventory(content, session, assessment.target, content.hostMcpServers.length > 0 || operations.some((operation) => operation.kind === "mcp-added" || operation.kind === "mcp-removed"));
|
|
12164
13816
|
if (finalInventory.kind === "Failed") return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", `Final provider state could not be observed: ${finalInventory.detail}`)]);
|
|
12165
13817
|
const finalAssessment = yield* assessInventory(content, assessment.target, session, assessment.capabilities, finalInventory.inventory, false);
|
|
12166
13818
|
const finalIssue = finalNativeAssessmentIssue(finalAssessment);
|
|
12167
|
-
|
|
13819
|
+
const retiredFacts = retiredOmittedMcpFacts(content, operations, finalInventory.inventory);
|
|
13820
|
+
return finalIssue === void 0 ? completedMutationTarget(assessment, operations, [...finalAssessment.facts, ...retiredFacts], issues) : failedMutationTarget(assessment, operations, finalAssessment.facts, [
|
|
12168
13821
|
...issues,
|
|
12169
13822
|
...finalAssessment.issues,
|
|
12170
13823
|
finalIssue
|
|
@@ -14600,6 +16253,7 @@ const definition$1 = defineService({
|
|
|
14600
16253
|
packageOutput: resourceDep(AgentPluginPackageOutputRuntimeResource),
|
|
14601
16254
|
codex: resourceDep(CodexNativeAgentProviderRuntimeResource),
|
|
14602
16255
|
claude: resourceDep(ClaudeNativeAgentProviderRuntimeResource),
|
|
16256
|
+
antigravity: resourceDep(AntigravityNativeAgentProviderRuntimeResource),
|
|
14603
16257
|
versionedContent: resourceDep(VersionedContentRuntimeResource)
|
|
14604
16258
|
}
|
|
14605
16259
|
});
|
|
@@ -14616,7 +16270,8 @@ const serviceRuntimeExport$1 = sealService(definition$1, {
|
|
|
14616
16270
|
packageOutput: deps.packageOutput,
|
|
14617
16271
|
nativeProviders: {
|
|
14618
16272
|
codex: deps.codex,
|
|
14619
|
-
claude: deps.claude
|
|
16273
|
+
claude: deps.claude,
|
|
16274
|
+
antigravity: deps.antigravity
|
|
14620
16275
|
},
|
|
14621
16276
|
versionedContent: deps.versionedContent
|
|
14622
16277
|
},
|
|
@@ -14738,7 +16393,7 @@ const targetFlag = Flags.custom({
|
|
|
14738
16393
|
const separator = value.indexOf("=");
|
|
14739
16394
|
const provider = value.slice(0, separator);
|
|
14740
16395
|
const home = value.slice(separator + 1);
|
|
14741
|
-
if (separator < 1 || provider !== "codex" && provider !== "claude") throw new Error("Expected provider=absolute-home with codex or
|
|
16396
|
+
if (separator < 1 || provider !== "codex" && provider !== "claude" && provider !== "antigravity") throw new Error("Expected provider=absolute-home with codex, claude, or antigravity.");
|
|
14742
16397
|
const parsedHome = absolutePath(home);
|
|
14743
16398
|
if (parsedHome === void 0) throw new Error("Expected an absolute provider home.");
|
|
14744
16399
|
return {
|
|
@@ -15022,10 +16677,24 @@ function formatOutcome$1(outcome) {
|
|
|
15022
16677
|
result
|
|
15023
16678
|
}, null, outcome.json ? void 0 : 2)}\n`;
|
|
15024
16679
|
}
|
|
16680
|
+
function escapeTerminalText(value) {
|
|
16681
|
+
return JSON.stringify(value).replace(/[\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069\ufeff]/gu, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
16682
|
+
}
|
|
16683
|
+
/** Formats non-blocking Antigravity MCP omission notices for human CLI operators. */
|
|
16684
|
+
function formatOmittedMcpNotices(outcome) {
|
|
16685
|
+
if (outcome.operation !== "providers.status" && outcome.operation !== "providers.sync" && outcome.operation !== "providers.test") return "";
|
|
16686
|
+
const lines = [];
|
|
16687
|
+
for (const target of outcome.result.targets) for (const fact of target.facts) if (fact.kind === "mcp-omitted") lines.push(`note [${target.target.provider}=${escapeTerminalText(target.target.home)}]: omitted MCP server ${escapeTerminalText(fact.name)} in plugin ${escapeTerminalText(fact.pluginId)} (${fact.reason})`);
|
|
16688
|
+
return lines.length === 0 ? "" : `${lines.join("\n")}\n`;
|
|
16689
|
+
}
|
|
15025
16690
|
/** Awaits native stdout completion before applying the result's process exit classification. */
|
|
15026
16691
|
async function present$1(outcome, command) {
|
|
15027
16692
|
const output = formatOutcome$1(outcome);
|
|
15028
16693
|
await new Promise((resolve, reject) => process.stdout.write(output, (error) => error ? reject(error) : resolve()));
|
|
16694
|
+
if (!outcome.json) {
|
|
16695
|
+
const notices = formatOmittedMcpNotices(outcome);
|
|
16696
|
+
if (notices.length > 0) await new Promise((resolve, reject) => process.stderr.write(notices, (error) => error ? reject(error) : resolve()));
|
|
16697
|
+
}
|
|
15029
16698
|
const code = exitCode$1(outcome);
|
|
15030
16699
|
if (code !== 0) command.exit(code);
|
|
15031
16700
|
}
|
|
@@ -16614,4 +18283,4 @@ const habitatApp = defineApp({
|
|
|
16614
18283
|
]
|
|
16615
18284
|
});
|
|
16616
18285
|
//#endregion
|
|
16617
|
-
export {
|
|
18286
|
+
export { AgentPluginPackageOutputRuntimeResource as A, RuleEvaluationRuntimeResource as B, PluginVersionSchema as C, ClaudeNativeAgentProviderRuntimeResource as D, AntigravityNativeAgentProviderRuntimeResource as E, SourceInventoryResultSchema as F, contract$10 as I, MAX_RULE_EVALUATION_FAILURE_DETAIL as L, MAX_SOURCE_INVENTORY_ROOT_LENGTH as M, ObserveSourceInventoryInputSchema as N, CodexNativeAgentProviderRuntimeResource as O, SourceInventoryPathSchema as P, RuleEvaluationRequestSchema as R, ObservedMcpServerNameSchema as S, VersionedContentRuntimeResource as T, FilesystemRuntimeResource as V, NativeProviderMcpServerAddInputSchema as _, MaterializeRemoteInputSchema as a, NativeProviderPluginSelectorInputSchema as b, CanonicalGitRepositoryUrlSchema as c, MAX_NATIVE_PROVIDER_PLUGIN_FILE_BYTES as d, NativeManagedMcpServerRecordSchema as f, NativeProviderMarketplaceIdentityInputSchema as g, NativeProviderInventorySchema as h, MAX_VERSIONED_CONTENT_FAILURE_DETAIL as i, MAX_SOURCE_INVENTORY_FAILURE_DETAIL as j, ContentWorkspaceRuntimeResource as k, MAX_NATIVE_PROVIDER_MCP_SERVERS as l, NativeProviderInventoryOptionsSchema as m, ChildProcessRuntimeResource as n, ObserveRemoteInputSchema as o, NativeMarketplaceSourceSchema as p, AncestryInputSchema as r, VersionedContentTreeEntrySchema as s, habitatApp as t, MAX_NATIVE_PROVIDER_PLUGIN_FILES as u, NativeProviderMcpServerRemoveInputSchema as v, projectAntigravityPluginBundle as w, NativeProviderSessionInputSchema as x, NativeProviderPluginFilesReadInputSchema as y, SourceInventoryRuntimeResource as z };
|