@habitat-ai/cli 0.7.0 → 0.8.1

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.
@@ -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$2, () => "Expected a canonical safe repository-relative path");
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$2(value) {
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$10(previous, current) >= 0) return false;
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$10(left, right) {
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$9(left.ruleId, right.ruleId) || compareText$9(instanceId(left) ?? "", instanceId(right) ?? "") || compareText$9(left.ownerProject, right.ownerProject);
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$9(left, right) {
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$8);
1732
+ for (const children of directChildren.values()) children.sort(compareText$11);
1733
1733
  return {
1734
- paths: [...allPaths].sort(compareText$8),
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$8),
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$8);
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$8(left, right) {
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,981 @@ 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 CLAUDE_HOOKS_PATH = "hooks/hooks.json";
4821
+ const HOOK_PROJECTION_METADATA = /* @__PURE__ */ new Set([
4822
+ ".claude-plugin/plugin.json",
4823
+ ".codex-plugin/plugin.json",
4824
+ ".mcp.json",
4825
+ "AGENTS.md",
4826
+ CLAUDE_HOOKS_PATH
4827
+ ]);
4828
+ const CLAUDE_BUN_HOOK_COMMAND = /^bun "\$\{CLAUDE_PLUGIN_ROOT\}\/(hooks\/[A-Za-z0-9_-]+\.ts)"$/u;
4829
+ const DEFAULT_OMITTED_ANTIGRAVITY_TOOLS = [
4830
+ "read_file",
4831
+ "edit_file",
4832
+ "write_file",
4833
+ "run_command",
4834
+ "manage_task",
4835
+ "search_web",
4836
+ "grep_search",
4837
+ "find_by_name",
4838
+ "list_dir",
4839
+ "read_url_content"
4840
+ ];
4841
+ const NATIVE_ANTIGRAVITY_TOOLS = /* @__PURE__ */ new Set([
4842
+ "read_file",
4843
+ "view_file",
4844
+ "edit_file",
4845
+ "write_file",
4846
+ "run_command",
4847
+ "manage_task",
4848
+ "search_web",
4849
+ "read_url_content",
4850
+ "grep_search",
4851
+ "find_by_name",
4852
+ "list_dir",
4853
+ "code_search",
4854
+ "invoke_subagent",
4855
+ "manage_subagents",
4856
+ "send_message",
4857
+ "ask_question",
4858
+ "update_focus",
4859
+ "update_steps",
4860
+ "generate_image",
4861
+ "browser_subagent",
4862
+ "open_browser_url",
4863
+ "call_mcp_tool",
4864
+ "list_resources",
4865
+ "read_resource"
4866
+ ]);
4867
+ const CLAUDE_TO_ANTIGRAVITY_TOOLS = {
4868
+ Read: ["read_file"],
4869
+ NotebookRead: ["read_file"],
4870
+ Glob: ["find_by_name", "list_dir"],
4871
+ LS: ["list_dir"],
4872
+ Grep: ["grep_search"],
4873
+ Edit: ["edit_file"],
4874
+ MultiEdit: ["edit_file"],
4875
+ NotebookEdit: ["edit_file"],
4876
+ Write: ["write_file"],
4877
+ Bash: ["run_command", "manage_task"],
4878
+ BashOutput: ["manage_task"],
4879
+ KillShell: ["manage_task"],
4880
+ KillBash: ["manage_task"],
4881
+ WebSearch: ["search_web"],
4882
+ WebFetch: ["read_url_content"],
4883
+ Task: ["invoke_subagent"],
4884
+ Agent: ["invoke_subagent"],
4885
+ AskUserQuestion: ["ask_question"],
4886
+ TodoWrite: ["update_steps"]
4887
+ };
4888
+ const DENIED_CLAUDE_TO_ANTIGRAVITY_TOOLS = {
4889
+ Read: ["read_file", "view_file"],
4890
+ NotebookRead: ["read_file", "view_file"],
4891
+ Glob: ["find_by_name", "list_dir"],
4892
+ LS: ["list_dir"],
4893
+ Grep: ["grep_search"],
4894
+ Edit: [
4895
+ "edit_file",
4896
+ "replace_file_content",
4897
+ "multi_replace_file_content"
4898
+ ],
4899
+ MultiEdit: [
4900
+ "edit_file",
4901
+ "replace_file_content",
4902
+ "multi_replace_file_content"
4903
+ ],
4904
+ NotebookEdit: [
4905
+ "edit_file",
4906
+ "replace_file_content",
4907
+ "multi_replace_file_content"
4908
+ ],
4909
+ Write: ["write_file", "write_to_file"],
4910
+ Bash: ["run_command", "manage_task"],
4911
+ BashOutput: ["manage_task"],
4912
+ KillShell: ["manage_task"],
4913
+ KillBash: ["manage_task"],
4914
+ WebSearch: ["search_web", "read_url_content"],
4915
+ WebFetch: ["search_web", "read_url_content"],
4916
+ Task: ["invoke_subagent"],
4917
+ Agent: ["invoke_subagent"],
4918
+ AskUserQuestion: ["ask_question"],
4919
+ TodoWrite: ["update_steps"]
4920
+ };
4921
+ const MAX_MCP_SERVER_NAME_CODE_UNITS = 256;
4922
+ const HTTP_HEADER_TOKEN_PATTERN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u;
4923
+ /**
4924
+ * Bounds an omitted MCP server key to at most 256 well-formed UTF-16 code units without
4925
+ * splitting surrogate pairs, preserving `""` when the source `.mcp.json` key was empty.
4926
+ */
4927
+ function boundOmittedMcpServerName(rawKey) {
4928
+ let end = Math.min(rawKey.length, MAX_MCP_SERVER_NAME_CODE_UNITS);
4929
+ if (end < rawKey.length) {
4930
+ const lastCode = rawKey.charCodeAt(end - 1);
4931
+ if (lastCode >= 55296 && lastCode <= 56319) end -= 1;
4932
+ }
4933
+ const sliced = rawKey.slice(0, end);
4934
+ let out = "";
4935
+ for (let index = 0; index < sliced.length; index += 1) {
4936
+ const code = sliced.charCodeAt(index);
4937
+ if (code >= 55296 && code <= 56319) {
4938
+ const next = index + 1 < sliced.length ? sliced.charCodeAt(index + 1) : 0;
4939
+ if (next >= 56320 && next <= 57343) {
4940
+ out += sliced.slice(index, index + 2);
4941
+ index += 1;
4942
+ } else out += "�";
4943
+ } else if (code >= 56320 && code <= 57343) out += "�";
4944
+ else out += sliced[index];
4945
+ }
4946
+ return out;
4947
+ }
4948
+ /**
4949
+ * Deterministically projects a multi-provider plugin payload into an Antigravity-native bundle.
4950
+ *
4951
+ * @remarks
4952
+ * Both the Antigravity native provider's `addMarketplace` staging and the lifecycle service's
4953
+ * desired-content construction invoke this pure function with identical inputs so staged,
4954
+ * installed, and verified bytes agree bit-for-bit without sidecars inside installed plugins.
4955
+ */
4956
+ function projectAntigravityPluginBundle(input) {
4957
+ const byPath = /* @__PURE__ */ new Map();
4958
+ for (const entry of input.entries) {
4959
+ if (!isCanonicalRelativePath$2(entry.path)) return invalid$2(`Plugin payload contains a non-canonical relative path: ${entry.path}`);
4960
+ if (entry.mode !== 420 && entry.mode !== 493) return invalid$2(`Plugin payload entry has an unsupported file mode: ${entry.path}`);
4961
+ if (byPath.has(entry.path)) return invalid$2(`Plugin payload contains duplicate relative path: ${entry.path}`);
4962
+ byPath.set(entry.path, entry);
4963
+ }
4964
+ const claudeManifestEntry = byPath.get(".claude-plugin/plugin.json");
4965
+ const codexManifestEntry = byPath.get(".codex-plugin/plugin.json");
4966
+ if (claudeManifestEntry === void 0 && codexManifestEntry === void 0) return invalid$2("Plugin payload must contain .claude-plugin/plugin.json or .codex-plugin/plugin.json");
4967
+ const claudeManifest = claudeManifestEntry === void 0 ? null : parseJsonRecord(claudeManifestEntry.bytes, ".claude-plugin/plugin.json");
4968
+ if (claudeManifest !== null && !claudeManifest.ok) return claudeManifest;
4969
+ const codexManifest = codexManifestEntry === void 0 ? null : parseJsonRecord(codexManifestEntry.bytes, ".codex-plugin/plugin.json");
4970
+ if (codexManifest !== null && !codexManifest.ok) return codexManifest;
4971
+ const claude = claudeManifest?.record ?? {};
4972
+ const codex = codexManifest?.record ?? {};
4973
+ const projectedAssets = /* @__PURE__ */ new Set();
4974
+ for (const path of byPath.keys()) if (path.startsWith("assets/")) projectedAssets.add(path);
4975
+ const manifestResult = buildPluginManifestJson(claude, codex, input.repositoryUrl, projectedAssets);
4976
+ if (!manifestResult.ok) return manifestResult;
4977
+ const output = /* @__PURE__ */ new Map();
4978
+ output.set("plugin.json", Object.freeze({
4979
+ path: "plugin.json",
4980
+ mode: 420,
4981
+ bytes: manifestResult.bytes
4982
+ }));
4983
+ let omittedMcpServers = Object.freeze([]);
4984
+ const mcpEntry = byPath.get(".mcp.json");
4985
+ if (mcpEntry !== void 0) {
4986
+ const mcpResult = buildMcpConfigJson(mcpEntry.bytes);
4987
+ if (!mcpResult.ok) return mcpResult;
4988
+ omittedMcpServers = mcpResult.omittedMcpServers;
4989
+ if (mcpResult.bytes !== null) output.set("mcp_config.json", Object.freeze({
4990
+ path: "mcp_config.json",
4991
+ mode: 420,
4992
+ bytes: mcpResult.bytes
4993
+ }));
4994
+ }
4995
+ const claudeHooks = byPath.get(CLAUDE_HOOKS_PATH);
4996
+ const rootHooks = byPath.get("hooks.json");
4997
+ const parsedRootHooks = rootHooks === void 0 ? null : parseJsonRecord(rootHooks.bytes, "hooks.json", { requireUniqueMemberNames: true });
4998
+ if (parsedRootHooks?.ok === false) return parsedRootHooks;
4999
+ const rootHookGroups = parsedRootHooks?.ok ? parsedRootHooks.record : null;
5000
+ const disabledNativeHook = rootHookGroups !== null && hasDisabledNativeHook(rootHookGroups);
5001
+ const keepNativeHooks = claudeHooks === void 0 && rootHooks !== void 0 && rootHookGroups !== null && shouldKeepNativeAntigravityHooks(rootHookGroups, byPath);
5002
+ const keepDisabledHook = claudeHooks !== void 0 || disabledNativeHook;
5003
+ if (claudeHooks !== void 0) {
5004
+ if (rootHooks !== void 0 || "hooks" in claude || "hooks" in codex) return invalid$2("Antigravity cannot project the Claude hook in hooks/hooks.json with another hook declaration.");
5005
+ const disabledHook = buildDisabledClaudeHook(claudeHooks, byPath, manifestResult.pluginName);
5006
+ if (!disabledHook.ok) return disabledHook;
5007
+ output.set("hooks.json", disabledHook.entry);
5008
+ } else if (keepNativeHooks) output.set("hooks.json", Object.freeze({
5009
+ path: "hooks.json",
5010
+ mode: 420,
5011
+ bytes: new Uint8Array(rootHooks.bytes)
5012
+ }));
5013
+ else if (disabledNativeHook) return invalid$2("Antigravity cannot preserve the explicitly disabled native hook in hooks.json.");
5014
+ for (const [path, entry] of byPath.entries()) {
5015
+ const isWorkflowSource = path.startsWith("workflows/");
5016
+ if (keepDisabledHook && isWorkflowSource && !path.endsWith(".md")) return invalid$2(`Antigravity cannot relocate a possible disabled-hook support file: ${path}`);
5017
+ if (isWorkflowSource || path === "LICENSE.txt" || keepDisabledHook && path === "package.json" || path.startsWith("skills/") || path.startsWith("scripts/") || path.startsWith("assets/") || path.startsWith("rules/") || (keepNativeHooks || claudeHooks !== void 0) && path.startsWith("hooks/") && path !== CLAUDE_HOOKS_PATH) {
5018
+ const retainedPath = isWorkflowSource ? `workflow-sources/${path.slice(10)}` : path;
5019
+ if (isWorkflowSource && byPath.has(retainedPath)) return invalid$2(`Antigravity workflow retention conflicts with source path: ${retainedPath}`);
5020
+ output.set(retainedPath, Object.freeze({
5021
+ path: retainedPath,
5022
+ mode: entry.mode,
5023
+ bytes: new Uint8Array(entry.bytes)
5024
+ }));
5025
+ continue;
5026
+ }
5027
+ if (path.startsWith("agents/") && path.endsWith(".md") && path.indexOf("/", 7) === -1) {
5028
+ const decoded = decodeUtf8(entry.bytes, path);
5029
+ if (!decoded.ok) return decoded;
5030
+ const translated = translateAgentMarkdown(decoded.text);
5031
+ output.set(path, Object.freeze({
5032
+ path,
5033
+ mode: 420,
5034
+ bytes: utf8Encoder.encode(translated)
5035
+ }));
5036
+ continue;
5037
+ }
5038
+ if (keepDisabledHook && !HOOK_PROJECTION_METADATA.has(path) && path !== "hooks.json") return invalid$2(`Antigravity cannot retain a possible disabled-hook support file: ${path}`);
5039
+ }
5040
+ const entries = Object.freeze([...output.values()].sort((left, right) => compareText$10(left.path, right.path)));
5041
+ return Object.freeze({
5042
+ ok: true,
5043
+ pluginName: manifestResult.pluginName,
5044
+ entries,
5045
+ omittedMcpServers
5046
+ });
5047
+ }
5048
+ function buildPluginManifestJson(claude, codex, repositoryUrl, projectedAssets) {
5049
+ const claudeName = nonEmptyString(claude.name);
5050
+ const codexName = nonEmptyString(codex.name);
5051
+ if (claudeName !== null && codexName !== null && claudeName !== codexName) return invalid$2(`Claude and Codex plugin manifests disagree on plugin name (${claudeName} vs ${codexName})`);
5052
+ const name = claudeName ?? codexName;
5053
+ 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");
5054
+ const codexInterface = asRecord(codex.interface);
5055
+ const displayName = (codexInterface === null ? null : nonEmptyString(codexInterface.displayName)) ?? nonEmptyString(claude.displayName) ?? nonEmptyString(codex.displayName);
5056
+ const description = nonEmptyString(claude.description) ?? nonEmptyString(codex.description) ?? (codexInterface === null ? null : nonEmptyString(codexInterface.shortDescription));
5057
+ const version = nonEmptyString(claude.version) ?? nonEmptyString(codex.version);
5058
+ const author = normalizeAuthor(claude.author) ?? normalizeAuthor(codex.author);
5059
+ const homepage = httpsUrlString(claude.homepage) ?? httpsUrlString(codex.homepage);
5060
+ const repository = (repositoryUrl !== null ? httpsUrlString(repositoryUrl) : null) ?? normalizeRepository(claude.repository) ?? normalizeRepository(codex.repository);
5061
+ const rawLogo = nonEmptyString(claude.logo) ?? nonEmptyString(codex.logo) ?? (codexInterface === null ? null : nonEmptyString(codexInterface.logo));
5062
+ const logo = rawLogo !== null && isValidLogoPath(rawLogo, projectedAssets) ? rawLogo : null;
5063
+ const suggestedPrompts = normalizeSuggestedPrompts(claude.suggestedPrompts) ?? normalizeSuggestedPrompts(codex.suggestedPrompts);
5064
+ const disabled = typeof claude.disabled === "boolean" ? claude.disabled : typeof codex.disabled === "boolean" ? codex.disabled : null;
5065
+ const manifest = { name };
5066
+ if (displayName !== null) manifest.displayName = displayName;
5067
+ if (description !== null) manifest.description = description;
5068
+ if (version !== null) manifest.version = version;
5069
+ if (author !== null) manifest.author = author;
5070
+ if (homepage !== null) manifest.homepage = homepage;
5071
+ if (repository !== null) manifest.repository = repository;
5072
+ if (logo !== null) manifest.logo = logo;
5073
+ if (suggestedPrompts !== null) manifest.suggestedPrompts = suggestedPrompts;
5074
+ if (disabled !== null) manifest.disabled = disabled;
5075
+ return Object.freeze({
5076
+ ok: true,
5077
+ pluginName: name,
5078
+ bytes: utf8Encoder.encode(`${JSON.stringify(manifest, null, 2)}\n`)
5079
+ });
5080
+ }
5081
+ /**
5082
+ * Projects remote HTTPS HTTP-transport MCP servers that can install and enable headlessly in Antigravity,
5083
+ * recording canonically ordered omission reasons for skipped entries.
5084
+ */
5085
+ function buildMcpConfigJson(bytes) {
5086
+ const parsed = parseJsonRecord(bytes, ".mcp.json");
5087
+ if (!parsed.ok) return parsed;
5088
+ const rawServers = parsed.record.mcpServers;
5089
+ if (rawServers === void 0) return Object.freeze({
5090
+ ok: true,
5091
+ bytes: null,
5092
+ omittedMcpServers: Object.freeze([])
5093
+ });
5094
+ const serversRecord = asRecord(rawServers);
5095
+ if (serversRecord === null) return invalid$2(".mcp.json mcpServers field must be a JSON object");
5096
+ const remoteServers = Object.create(null);
5097
+ const omitted = [];
5098
+ for (const key of Object.keys(serversRecord).sort(compareText$10)) {
5099
+ const boundedName = boundOmittedMcpServerName(key);
5100
+ if (key.length === 0 || key.length > MAX_MCP_SERVER_NAME_CODE_UNITS || key === "__proto__") {
5101
+ omitted.push(Object.freeze({
5102
+ name: boundedName,
5103
+ reason: "invalid-config"
5104
+ }));
5105
+ continue;
5106
+ }
5107
+ const config = asRecord(serversRecord[key]);
5108
+ if (config === null) {
5109
+ omitted.push(Object.freeze({
5110
+ name: boundedName,
5111
+ reason: "invalid-config"
5112
+ }));
5113
+ continue;
5114
+ }
5115
+ let headersRecord = null;
5116
+ if (config.headers !== void 0) {
5117
+ headersRecord = asRecord(config.headers);
5118
+ if (headersRecord === null) {
5119
+ omitted.push(Object.freeze({
5120
+ name: boundedName,
5121
+ reason: "invalid-config"
5122
+ }));
5123
+ continue;
5124
+ }
5125
+ let hasInvalidHeader = false;
5126
+ for (const headerName of Object.keys(headersRecord)) {
5127
+ const rawHeaderValue = headersRecord[headerName];
5128
+ 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)) {
5129
+ hasInvalidHeader = true;
5130
+ break;
5131
+ }
5132
+ }
5133
+ if (hasInvalidHeader) {
5134
+ omitted.push(Object.freeze({
5135
+ name: boundedName,
5136
+ reason: "invalid-config"
5137
+ }));
5138
+ continue;
5139
+ }
5140
+ }
5141
+ if (config.type !== void 0 && config.type !== "http") {
5142
+ omitted.push(Object.freeze({
5143
+ name: boundedName,
5144
+ reason: "unsupported-transport"
5145
+ }));
5146
+ continue;
5147
+ }
5148
+ if (config.url === void 0 && config.serverUrl === void 0) {
5149
+ omitted.push(Object.freeze({
5150
+ name: boundedName,
5151
+ reason: "unsupported-transport"
5152
+ }));
5153
+ continue;
5154
+ }
5155
+ const rawUrlCandidate = config.url !== void 0 ? config.url : config.serverUrl;
5156
+ if (typeof rawUrlCandidate !== "string" || rawUrlCandidate.length === 0) {
5157
+ omitted.push(Object.freeze({
5158
+ name: boundedName,
5159
+ reason: "invalid-config"
5160
+ }));
5161
+ continue;
5162
+ }
5163
+ const expandedUrl = expandClaudeDefaultPlaceholders(rawUrlCandidate);
5164
+ if (hasUnresolvedMcpPlaceholder(expandedUrl)) {
5165
+ omitted.push(Object.freeze({
5166
+ name: boundedName,
5167
+ reason: "requires-variables"
5168
+ }));
5169
+ continue;
5170
+ }
5171
+ if (!isRemoteHttpsUrl(expandedUrl)) {
5172
+ omitted.push(Object.freeze({
5173
+ name: boundedName,
5174
+ reason: "non-remote-https-url"
5175
+ }));
5176
+ continue;
5177
+ }
5178
+ let normalizedHeaders;
5179
+ let hasUnresolvedHeader = false;
5180
+ let hasInvalidExpandedHeader = false;
5181
+ if (headersRecord !== null) {
5182
+ const collectedHeaders = Object.create(null);
5183
+ for (const headerName of Object.keys(headersRecord).sort(compareText$10)) {
5184
+ const expandedHeader = expandClaudeDefaultPlaceholders(headersRecord[headerName].trim());
5185
+ if (/[\r\n\u0000]/u.test(expandedHeader)) {
5186
+ hasInvalidExpandedHeader = true;
5187
+ break;
5188
+ }
5189
+ if (hasUnresolvedMcpPlaceholder(expandedHeader)) {
5190
+ hasUnresolvedHeader = true;
5191
+ break;
5192
+ }
5193
+ collectedHeaders[headerName] = expandedHeader;
5194
+ }
5195
+ if (hasInvalidExpandedHeader) {
5196
+ omitted.push(Object.freeze({
5197
+ name: boundedName,
5198
+ reason: "invalid-config"
5199
+ }));
5200
+ continue;
5201
+ }
5202
+ if (hasUnresolvedHeader) {
5203
+ omitted.push(Object.freeze({
5204
+ name: boundedName,
5205
+ reason: "requires-variables"
5206
+ }));
5207
+ continue;
5208
+ }
5209
+ if (Object.keys(collectedHeaders).length > 0) normalizedHeaders = collectedHeaders;
5210
+ }
5211
+ const serverEntry = Object.create(null);
5212
+ serverEntry.url = expandedUrl;
5213
+ if (normalizedHeaders !== void 0) serverEntry.headers = normalizedHeaders;
5214
+ remoteServers[key] = serverEntry;
5215
+ }
5216
+ omitted.sort((left, right) => compareText$10(left.name, right.name) || compareText$10(left.reason, right.reason));
5217
+ const omittedMcpServers = Object.freeze(omitted);
5218
+ if (Object.keys(remoteServers).length === 0) return Object.freeze({
5219
+ ok: true,
5220
+ bytes: null,
5221
+ omittedMcpServers
5222
+ });
5223
+ return Object.freeze({
5224
+ ok: true,
5225
+ bytes: utf8Encoder.encode(`${JSON.stringify({ mcpServers: remoteServers }, null, 2)}\n`),
5226
+ omittedMcpServers
5227
+ });
5228
+ }
5229
+ function expandClaudeDefaultPlaceholders(value) {
5230
+ return value.replace(/\$\{(?:env:)?[A-Za-z_][A-Za-z0-9_]*:-([^}]+)\}/gu, "$1");
5231
+ }
5232
+ function hasUnresolvedMcpPlaceholder(value) {
5233
+ return /\$\{[^}]*\}/u.test(value);
5234
+ }
5235
+ function buildDisabledClaudeHook(source, byPath, pluginName) {
5236
+ const parsed = parseJsonRecord(source.bytes, CLAUDE_HOOKS_PATH, { requireUniqueMemberNames: true });
5237
+ if (!parsed.ok) return parsed;
5238
+ const group = singleHookRecord(hookRecord(hookRecord(parsed.record, ["hooks"])?.hooks, ["PreToolUse"])?.PreToolUse, ["matcher", "hooks"]);
5239
+ const handler = singleHookRecord(group?.hooks, ["type", "command"]);
5240
+ const script = typeof handler?.command === "string" ? CLAUDE_BUN_HOOK_COMMAND.exec(handler.command)?.[1] : void 0;
5241
+ if (group?.matcher !== "^Bash$" || handler?.type !== "command" || script === void 0) return invalid$2("Antigravity cannot project the Claude hook in hooks/hooks.json: expected one PreToolUse ^Bash$ group with one plugin-local Bun TypeScript command.");
5242
+ if (!byPath.has(script)) return invalid$2("Antigravity cannot project the Claude hook in hooks/hooks.json: the command's supporting file is missing: " + script);
5243
+ const nativeHooks = { [pluginName]: {
5244
+ enabled: false,
5245
+ PreToolUse: [{
5246
+ matcher: "run_command",
5247
+ hooks: [{
5248
+ type: "command",
5249
+ command: "bun \"./" + script + "\"",
5250
+ timeout: 60
5251
+ }]
5252
+ }]
5253
+ } };
5254
+ const entry = Object.freeze({
5255
+ path: "hooks.json",
5256
+ mode: 420,
5257
+ bytes: utf8Encoder.encode(JSON.stringify(nativeHooks, null, 2) + "\n")
5258
+ });
5259
+ return Object.freeze({
5260
+ ok: true,
5261
+ entry
5262
+ });
5263
+ }
5264
+ function hookRecord(value, keys) {
5265
+ const record = asRecord(value);
5266
+ return record !== null && Object.keys(record).length === keys.length && keys.every((key) => Object.hasOwn(record, key)) ? record : null;
5267
+ }
5268
+ function singleHookRecord(value, keys) {
5269
+ return Array.isArray(value) && value.length === 1 ? hookRecord(value[0], keys) : null;
5270
+ }
5271
+ function hasDuplicateJsonMemberName(text) {
5272
+ const objects = [];
5273
+ for (const [token, key, separator] of text.matchAll(/("(?:[^"\\]|\\.)*")(\s*:)?|[{}]/gu)) if (token === "{") objects.push(/* @__PURE__ */ new Set());
5274
+ else if (token === "}") objects.pop();
5275
+ else if (key !== void 0 && separator !== void 0) {
5276
+ const members = objects.at(-1);
5277
+ const name = JSON.parse(key);
5278
+ if (members.has(name)) return true;
5279
+ members.add(name);
5280
+ }
5281
+ return false;
5282
+ }
5283
+ function hasDisabledNativeHook(groups) {
5284
+ return groups.enabled === false || Object.values(groups).some((group) => asRecord(group)?.enabled === false);
5285
+ }
5286
+ function shouldKeepNativeAntigravityHooks(rootHooks, byPath) {
5287
+ if ("hooks" in rootHooks || containsAsyncRewake(rootHooks)) return false;
5288
+ if (JSON.stringify(rootHooks).includes("CLAUDE_PLUGIN_ROOT")) return false;
5289
+ const hookEntries = Object.entries(rootHooks);
5290
+ if (hookEntries.length === 0) return false;
5291
+ for (const [, spec] of hookEntries) {
5292
+ const specRecord = asRecord(spec);
5293
+ if (specRecord === null) return false;
5294
+ const keys = Object.keys(specRecord);
5295
+ if (keys.length === 0) return false;
5296
+ if (keys.some((key) => key !== "enabled" && !ANTIGRAVITY_HOOK_EVENTS.has(key))) return false;
5297
+ if (specRecord.enabled === false && !Object.entries(specRecord).some(([event, handlers]) => ANTIGRAVITY_HOOK_EVENTS.has(event) && Array.isArray(handlers) && handlers.some((handler) => {
5298
+ const item = asRecord(handler);
5299
+ return typeof item?.type === "string" || Array.isArray(item?.hooks) && item.hooks.some((hook) => typeof asRecord(hook)?.type === "string");
5300
+ }))) return false;
5301
+ }
5302
+ for (const [path, entry] of byPath.entries()) {
5303
+ if (!path.startsWith("hooks/")) continue;
5304
+ const decoded = decodeUtf8(entry.bytes, path);
5305
+ if (!decoded.ok) continue;
5306
+ if (decoded.text.includes("CLAUDE_PLUGIN_ROOT") || decoded.text.includes("session_id") && !decoded.text.includes("conversationId")) return false;
5307
+ }
5308
+ return true;
5309
+ }
5310
+ function containsAsyncRewake(value) {
5311
+ if (Array.isArray(value)) return value.some(containsAsyncRewake);
5312
+ const record = asRecord(value);
5313
+ if (record === null) return false;
5314
+ if (record.asyncRewake === true) return true;
5315
+ return Object.values(record).some(containsAsyncRewake);
5316
+ }
5317
+ /**
5318
+ * Translates one Claude/Codex agent markdown file into Antigravity's subagent schema,
5319
+ * subtracting `disallowedTools` fail-closed from the declared or default tool set.
5320
+ */
5321
+ function translateAgentMarkdown(markdown) {
5322
+ const allLines = (markdown.startsWith("") ? markdown.slice(1) : markdown).replace(/\r\n/gu, "\n").split("\n");
5323
+ const firstLine = allLines[0];
5324
+ if (firstLine === void 0 || !/^---[ \t]*$/u.test(firstLine)) return markdown.replace(/\r\n/gu, "\n");
5325
+ let closingLineIndex = -1;
5326
+ for (let lineIndex = 1; lineIndex < allLines.length; lineIndex += 1) if (/^---[ \t]*$/u.test(allLines[lineIndex])) {
5327
+ closingLineIndex = lineIndex;
5328
+ break;
5329
+ }
5330
+ if (closingLineIndex === -1) return markdown.replace(/\r\n/gu, "\n");
5331
+ const lines = allLines.slice(1, closingLineIndex);
5332
+ const remainingLines = allLines.slice(closingLineIndex + 1);
5333
+ const afterClosing = remainingLines.length === 0 ? "" : `\n${remainingLines.join("\n")}`;
5334
+ const outLines = [];
5335
+ let hasSubagent = false;
5336
+ let hasMainAgent = false;
5337
+ let hasTools = false;
5338
+ let toolsInsertPosition = null;
5339
+ const declaredToolTokens = [];
5340
+ const disallowedToolTokens = [];
5341
+ let index = 0;
5342
+ while (index < lines.length) {
5343
+ const line = lines[index];
5344
+ const keyMatch = /^([A-Za-z_][A-Za-z0-9_-]*):(?:\s*(.*))?$/u.exec(line);
5345
+ if (keyMatch === null) {
5346
+ outLines.push(line);
5347
+ index += 1;
5348
+ continue;
5349
+ }
5350
+ const key = keyMatch[1];
5351
+ const commentStrippedValue = stripUnquotedYamlComment((keyMatch[2] ?? "").trim());
5352
+ if (key === "subagent") {
5353
+ hasSubagent = true;
5354
+ outLines.push(`subagent: ${stripYamlQuotes(commentStrippedValue)}`);
5355
+ index += 1;
5356
+ continue;
5357
+ }
5358
+ if (key === "mainAgent") {
5359
+ hasMainAgent = true;
5360
+ outLines.push(`mainAgent: ${stripYamlQuotes(commentStrippedValue)}`);
5361
+ index += 1;
5362
+ continue;
5363
+ }
5364
+ if (key === "model") {
5365
+ const unquoted = stripYamlQuotes(commentStrippedValue);
5366
+ outLines.push(`model: ${mapAntigravityModel(unquoted)}`);
5367
+ index += 1;
5368
+ continue;
5369
+ }
5370
+ if (key === "tools") {
5371
+ hasTools = true;
5372
+ if (toolsInsertPosition === null) toolsInsertPosition = outLines.length;
5373
+ const parsedTools = parseYamlToolsField(lines, index, commentStrippedValue);
5374
+ declaredToolTokens.push(...parsedTools.items);
5375
+ index = parsedTools.nextIndex;
5376
+ continue;
5377
+ }
5378
+ if (key === "disallowedTools" || key === "disallowed-tools") {
5379
+ const parsedDenied = parseYamlToolsField(lines, index, commentStrippedValue);
5380
+ disallowedToolTokens.push(...parsedDenied.items);
5381
+ index = parsedDenied.nextIndex;
5382
+ continue;
5383
+ }
5384
+ outLines.push(line);
5385
+ index += 1;
5386
+ }
5387
+ const baseTools = hasTools ? mapClaudeToolsToAntigravity(declaredToolTokens) : DEFAULT_OMITTED_ANTIGRAVITY_TOOLS;
5388
+ const deniedTools = mapDeniedToolsToAntigravity(disallowedToolTokens);
5389
+ const effectiveTools = deniedTools.size === 0 ? baseTools : baseTools.filter((tool) => !deniedTools.has(tool));
5390
+ const renderedToolsLines = [];
5391
+ emitToolsYaml(renderedToolsLines, effectiveTools);
5392
+ if (toolsInsertPosition !== null) outLines.splice(toolsInsertPosition, 0, ...renderedToolsLines);
5393
+ else outLines.push(...renderedToolsLines);
5394
+ if (!hasSubagent) outLines.push("subagent: true");
5395
+ if (!hasMainAgent) outLines.push("mainAgent: false");
5396
+ return `---\n${outLines.join("\n")}\n---${afterClosing}`;
5397
+ }
5398
+ function parseYamlToolsField(lines, startIndex, commentStrippedValue) {
5399
+ if (commentStrippedValue === "") {
5400
+ const rawItems = [];
5401
+ let cursor = startIndex + 1;
5402
+ while (cursor < lines.length) {
5403
+ const candidate = lines[cursor];
5404
+ if (/^\s*(?:#.*)?$/u.test(candidate)) {
5405
+ let lookahead = cursor + 1;
5406
+ while (lookahead < lines.length && /^\s*(?:#.*)?$/u.test(lines[lookahead])) lookahead += 1;
5407
+ const nextLine = lookahead < lines.length ? lines[lookahead] : null;
5408
+ if (nextLine !== null && (/^[ \t]+/u.test(nextLine) || /^-(?:$|[ \t])/u.test(nextLine))) {
5409
+ cursor = lookahead;
5410
+ continue;
5411
+ }
5412
+ break;
5413
+ }
5414
+ if (!/^[ \t]/u.test(candidate) && !/^-(?:$|[ \t])/u.test(candidate)) break;
5415
+ const strippedCandidate = stripUnquotedYamlComment(candidate);
5416
+ if (strippedCandidate.length > 0 && strippedCandidate !== "-") {
5417
+ const itemMatch = /^-(?:[ \t]+(.*))?$/u.exec(strippedCandidate);
5418
+ const payload = itemMatch !== null ? (itemMatch[1] ?? "").trim() : strippedCandidate;
5419
+ if (payload.length > 0) rawItems.push(payload);
5420
+ }
5421
+ cursor += 1;
5422
+ }
5423
+ return Object.freeze({
5424
+ items: expandRawToolTokens(rawItems),
5425
+ nextIndex: cursor
5426
+ });
5427
+ }
5428
+ if (commentStrippedValue.startsWith("[")) return collectFlowSequenceItems(lines, startIndex, commentStrippedValue);
5429
+ if (/^[|>][+-]?\d*$/u.test(commentStrippedValue)) return collectBlockScalarItems(lines, startIndex);
5430
+ return collectPlainScalarItems(lines, startIndex, commentStrippedValue);
5431
+ }
5432
+ function collectFlowSequenceItems(lines, startIndex, initialValue) {
5433
+ const firstSegment = initialValue.slice(1);
5434
+ const firstClose = findUnquotedClosingBracket(firstSegment);
5435
+ if (firstClose !== -1) {
5436
+ const inner = firstSegment.slice(0, firstClose).trim();
5437
+ return Object.freeze({
5438
+ items: parseFlowInnerItems(inner),
5439
+ nextIndex: startIndex + 1
5440
+ });
5441
+ }
5442
+ const segments = [firstSegment];
5443
+ let cursor = startIndex + 1;
5444
+ while (cursor < lines.length) {
5445
+ const candidate = lines[cursor];
5446
+ if (/^[A-Za-z_][A-Za-z0-9_-]*:/u.test(candidate)) break;
5447
+ const stripped = stripUnquotedYamlComment(candidate);
5448
+ const closeIndex = findUnquotedClosingBracket(stripped);
5449
+ if (closeIndex !== -1) {
5450
+ segments.push(stripped.slice(0, closeIndex));
5451
+ return Object.freeze({
5452
+ items: parseFlowInnerItems(segments.join(" ").trim()),
5453
+ nextIndex: cursor + 1
5454
+ });
5455
+ }
5456
+ segments.push(stripped);
5457
+ cursor += 1;
5458
+ }
5459
+ return Object.freeze({
5460
+ items: parseFlowInnerItems(segments.join(" ").trim()),
5461
+ nextIndex: cursor
5462
+ });
5463
+ }
5464
+ function collectBlockScalarItems(lines, startIndex) {
5465
+ const rawSegments = [];
5466
+ let cursor = startIndex + 1;
5467
+ while (cursor < lines.length) {
5468
+ const candidate = lines[cursor];
5469
+ if (candidate.trim().length > 0 && !/^[ \t]/u.test(candidate)) break;
5470
+ const stripped = stripUnquotedYamlComment(candidate);
5471
+ if (stripped.length > 0) rawSegments.push(stripped.replace(/^-\s+/u, ""));
5472
+ cursor += 1;
5473
+ }
5474
+ return Object.freeze({
5475
+ items: expandRawToolTokens(rawSegments),
5476
+ nextIndex: cursor
5477
+ });
5478
+ }
5479
+ function collectPlainScalarItems(lines, startIndex, firstValue) {
5480
+ const segments = [firstValue];
5481
+ let cursor = startIndex + 1;
5482
+ while (cursor < lines.length) {
5483
+ const candidate = lines[cursor];
5484
+ if (candidate.trim().length > 0 && !/^[ \t]/u.test(candidate)) break;
5485
+ const stripped = stripUnquotedYamlComment(candidate);
5486
+ if (stripped.length > 0) segments.push(stripped);
5487
+ cursor += 1;
5488
+ }
5489
+ return Object.freeze({
5490
+ items: expandRawToolTokens([segments.join(" ")]),
5491
+ nextIndex: cursor
5492
+ });
5493
+ }
5494
+ function parseFlowInnerItems(inner) {
5495
+ if (inner === "") return Object.freeze([]);
5496
+ return expandRawToolTokens([inner]);
5497
+ }
5498
+ function expandRawToolTokens(segments) {
5499
+ const items = [];
5500
+ for (const segment of segments) for (const quotedOrBare of splitCommaRespectingQuotes(segment)) {
5501
+ const unquoted = stripYamlQuotes(quotedOrBare);
5502
+ if (unquoted.length === 0) continue;
5503
+ for (const atom of splitCommasOutsideParens(unquoted)) {
5504
+ const cleaned = stripYamlQuotes(atom);
5505
+ if (cleaned.length > 0) items.push(cleaned);
5506
+ }
5507
+ }
5508
+ return Object.freeze(items);
5509
+ }
5510
+ function findUnquotedClosingBracket(input) {
5511
+ let quote = null;
5512
+ for (let index = 0; index < input.length; index += 1) {
5513
+ const ch = input[index];
5514
+ if (quote !== null) {
5515
+ if (ch === quote && input[index - 1] !== "\\") quote = null;
5516
+ continue;
5517
+ }
5518
+ if (ch === "\"" || ch === "'") {
5519
+ quote = ch;
5520
+ continue;
5521
+ }
5522
+ if (ch === "]") return index;
5523
+ }
5524
+ return -1;
5525
+ }
5526
+ function stripUnquotedYamlComment(input) {
5527
+ let quote = null;
5528
+ for (let index = 0; index < input.length; index += 1) {
5529
+ const ch = input[index];
5530
+ if (quote !== null) {
5531
+ if (ch === quote && input[index - 1] !== "\\") quote = null;
5532
+ continue;
5533
+ }
5534
+ if (ch === "\"" || ch === "'") {
5535
+ quote = ch;
5536
+ continue;
5537
+ }
5538
+ if (ch === "#" && (index === 0 || input[index - 1] === " " || input[index - 1] === " ")) return input.slice(0, index).trim();
5539
+ }
5540
+ return input.trim();
5541
+ }
5542
+ function mapClaudeToolsToAntigravity(rawItems) {
5543
+ if (rawItems.length === 0) return Object.freeze([]);
5544
+ const mapped = [];
5545
+ const seen = /* @__PURE__ */ new Set();
5546
+ const addTool = (tool) => {
5547
+ if (!seen.has(tool)) {
5548
+ seen.add(tool);
5549
+ mapped.push(tool);
5550
+ }
5551
+ };
5552
+ for (const rawItem of rawItems) {
5553
+ const trimmed = rawItem.trim();
5554
+ if (trimmed.length === 0) continue;
5555
+ if (NATIVE_ANTIGRAVITY_TOOLS.has(trimmed)) {
5556
+ addTool(trimmed);
5557
+ continue;
5558
+ }
5559
+ const targets = CLAUDE_TO_ANTIGRAVITY_TOOLS[trimmed];
5560
+ if (targets !== void 0) {
5561
+ for (const target of targets) addTool(target);
5562
+ continue;
5563
+ }
5564
+ if (/^Bash\(.+\)$/u.test(trimmed)) {
5565
+ addTool("run_command");
5566
+ addTool("manage_task");
5567
+ }
5568
+ }
5569
+ return Object.freeze(mapped);
5570
+ }
5571
+ function mapDeniedToolsToAntigravity(rawItems) {
5572
+ if (rawItems.length === 0) return /* @__PURE__ */ new Set();
5573
+ const denied = /* @__PURE__ */ new Set();
5574
+ for (const rawItem of rawItems) {
5575
+ const trimmed = rawItem.trim();
5576
+ if (trimmed.length === 0) continue;
5577
+ const scopedMatch = /^([A-Za-z_][A-Za-z0-9_-]*)\(.*\)$/su.exec(trimmed);
5578
+ const baseName = scopedMatch !== null ? scopedMatch[1] : trimmed;
5579
+ if (NATIVE_ANTIGRAVITY_TOOLS.has(trimmed)) denied.add(trimmed);
5580
+ if (NATIVE_ANTIGRAVITY_TOOLS.has(baseName)) denied.add(baseName);
5581
+ const targets = DENIED_CLAUDE_TO_ANTIGRAVITY_TOOLS[baseName];
5582
+ if (targets !== void 0) for (const target of targets) denied.add(target);
5583
+ }
5584
+ return denied;
5585
+ }
5586
+ function emitToolsYaml(outLines, items) {
5587
+ if (items.length === 0) {
5588
+ outLines.push("tools: []");
5589
+ return;
5590
+ }
5591
+ outLines.push("tools:");
5592
+ for (const item of items) outLines.push(` - ${formatYamlScalar(item)}`);
5593
+ }
5594
+ function formatYamlScalar(value) {
5595
+ return /^[A-Za-z0-9_./:-]+$/u.test(value) ? value : JSON.stringify(value);
5596
+ }
5597
+ function mapAntigravityModel(raw) {
5598
+ const normalized = raw.trim().toLowerCase();
5599
+ if (normalized === "inherit" || normalized === "pro" || normalized === "flash" || normalized === "flash_lite") return normalized;
5600
+ if (normalized === "opus" || normalized.includes("opus")) return "pro";
5601
+ if (normalized === "sonnet" || normalized.includes("sonnet")) return "inherit";
5602
+ if (normalized === "haiku" || normalized.includes("haiku")) return "flash";
5603
+ return normalized.length === 0 ? "inherit" : raw.trim();
5604
+ }
5605
+ function splitCommaRespectingQuotes(input) {
5606
+ const parts = [];
5607
+ let current = "";
5608
+ let quote = null;
5609
+ let parenDepth = 0;
5610
+ for (let index = 0; index < input.length; index += 1) {
5611
+ const ch = input[index];
5612
+ if (quote !== null) {
5613
+ current += ch;
5614
+ if (ch === quote && input[index - 1] !== "\\") quote = null;
5615
+ continue;
5616
+ }
5617
+ if (ch === "\"" || ch === "'") {
5618
+ quote = ch;
5619
+ current += ch;
5620
+ continue;
5621
+ }
5622
+ if (ch === "(") {
5623
+ parenDepth += 1;
5624
+ current += ch;
5625
+ continue;
5626
+ }
5627
+ if (ch === ")" && parenDepth > 0) {
5628
+ parenDepth -= 1;
5629
+ current += ch;
5630
+ continue;
5631
+ }
5632
+ if (ch === "," && parenDepth === 0) {
5633
+ parts.push(current.trim());
5634
+ current = "";
5635
+ continue;
5636
+ }
5637
+ current += ch;
5638
+ }
5639
+ parts.push(current.trim());
5640
+ return parts;
5641
+ }
5642
+ function splitCommasOutsideParens(input) {
5643
+ const parts = [];
5644
+ let current = "";
5645
+ let parenDepth = 0;
5646
+ for (let index = 0; index < input.length; index += 1) {
5647
+ const ch = input[index];
5648
+ if (ch === "(") {
5649
+ parenDepth += 1;
5650
+ current += ch;
5651
+ continue;
5652
+ }
5653
+ if (ch === ")" && parenDepth > 0) {
5654
+ parenDepth -= 1;
5655
+ current += ch;
5656
+ continue;
5657
+ }
5658
+ if (ch === "," && parenDepth === 0) {
5659
+ parts.push(current.trim());
5660
+ current = "";
5661
+ continue;
5662
+ }
5663
+ current += ch;
5664
+ }
5665
+ parts.push(current.trim());
5666
+ return parts;
5667
+ }
5668
+ function stripYamlQuotes(input) {
5669
+ const trimmed = input.trim();
5670
+ if (trimmed.length >= 2 && (trimmed.startsWith("\"") && trimmed.endsWith("\"") || trimmed.startsWith("'") && trimmed.endsWith("'"))) return trimmed.slice(1, -1).trim();
5671
+ return trimmed;
5672
+ }
5673
+ function normalizeAuthor(value) {
5674
+ const text = nonEmptyString(value);
5675
+ if (text !== null) return text;
5676
+ const record = asRecord(value);
5677
+ if (record === null) return null;
5678
+ const name = nonEmptyString(record.name);
5679
+ if (name === null) return null;
5680
+ const url = httpsUrlString(record.url);
5681
+ return url === null ? Object.freeze({ name }) : Object.freeze({
5682
+ name,
5683
+ url
5684
+ });
5685
+ }
5686
+ function normalizeRepository(value) {
5687
+ const url = httpsUrlString(value);
5688
+ if (url !== null) return url;
5689
+ const record = asRecord(value);
5690
+ if (record === null) return null;
5691
+ const recordUrl = httpsUrlString(record.url);
5692
+ if (recordUrl === null) return null;
5693
+ return record.type === "git" ? Object.freeze({
5694
+ type: "git",
5695
+ url: recordUrl
5696
+ }) : recordUrl;
5697
+ }
5698
+ function normalizeSuggestedPrompts(value) {
5699
+ if (!Array.isArray(value)) return null;
5700
+ const prompts = value.map(nonEmptyString).filter((entry) => entry !== null).slice(0, 3);
5701
+ return prompts.length === 0 ? null : Object.freeze(prompts);
5702
+ }
5703
+ function isValidLogoPath(candidate, projectedAssets) {
5704
+ if (!isCanonicalRelativePath$2(candidate)) return false;
5705
+ const lower = candidate.toLowerCase();
5706
+ if (!ANTIGRAVITY_LOGO_EXTENSIONS.some((ext) => lower.endsWith(ext))) return false;
5707
+ return projectedAssets.has(candidate);
5708
+ }
5709
+ function httpsUrlString(value) {
5710
+ if (typeof value !== "string" || value.length === 0) return null;
5711
+ if (/[\s\\]/u.test(value) || !/^https:\/\/[^/\\?#\s]/u.test(value)) return null;
5712
+ try {
5713
+ const parsed = new URL(value);
5714
+ return parsed.protocol === "https:" && parsed.href === value ? value : null;
5715
+ } catch {
5716
+ return null;
5717
+ }
5718
+ }
5719
+ function isRemoteHttpsUrl(candidate) {
5720
+ if (httpsUrlString(candidate) === null) return false;
5721
+ let parsed;
5722
+ try {
5723
+ parsed = new URL(candidate);
5724
+ } catch {
5725
+ return false;
5726
+ }
5727
+ const host = parsed.hostname.toLowerCase().replace(/\.+$/u, "");
5728
+ 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;
5729
+ return true;
5730
+ }
5731
+ function parseJsonRecord(bytes, label, options = {}) {
5732
+ const decoded = decodeUtf8(bytes, label);
5733
+ if (!decoded.ok) return decoded;
5734
+ let parsed;
5735
+ try {
5736
+ parsed = JSON.parse(decoded.text);
5737
+ } catch {
5738
+ return invalid$2(`${label} is not valid JSON`);
5739
+ }
5740
+ const record = asRecord(parsed);
5741
+ if (record === null) return invalid$2(`${label} must contain a JSON object`);
5742
+ if (options.requireUniqueMemberNames && hasDuplicateJsonMemberName(decoded.text)) return invalid$2(label + " contains duplicate JSON member names");
5743
+ return Object.freeze({
5744
+ ok: true,
5745
+ record
5746
+ });
5747
+ }
5748
+ function decodeUtf8(bytes, label) {
5749
+ try {
5750
+ return Object.freeze({
5751
+ ok: true,
5752
+ text: utf8Decoder$1.decode(bytes)
5753
+ });
5754
+ } catch {
5755
+ return invalid$2(`${label} is not valid UTF-8`);
5756
+ }
5757
+ }
5758
+ function asRecord(value) {
5759
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
5760
+ }
5761
+ function nonEmptyString(value) {
5762
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
5763
+ }
5764
+ function isCanonicalRelativePath$2(value) {
5765
+ 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 !== "..");
5766
+ }
5767
+ function invalid$2(detail) {
5768
+ return Object.freeze({
5769
+ ok: false,
5770
+ detail
5771
+ });
5772
+ }
5773
+ function compareText$10(left, right) {
5774
+ return left < right ? -1 : left > right ? 1 : 0;
5775
+ }
5776
+ //#endregion
4794
5777
  //#region ../../resources/native-agent-provider/contract.ts
4795
5778
  const BoundedTextSchema = Type.String({
4796
5779
  minLength: 1,
@@ -4814,6 +5797,16 @@ const PluginSelectorSchema$1 = Type.String({
4814
5797
  pattern: "^[a-z0-9][a-z0-9._-]*@[a-z0-9][a-z0-9_-]*$",
4815
5798
  maxLength: 256
4816
5799
  });
5800
+ const ObservedPluginNameSchema = Type.String({
5801
+ pattern: "^[^\\u0000-\\u001f\\u007f@/\\\\]{1,256}$",
5802
+ minLength: 1,
5803
+ maxLength: 256
5804
+ });
5805
+ const ObservedPluginSelectorSchema = Type.String({
5806
+ pattern: "^[^\\u0000-\\u001f\\u007f@/\\\\]{1,256}@[a-z0-9][a-z0-9_-]*$",
5807
+ minLength: 3,
5808
+ maxLength: 385
5809
+ });
4817
5810
  const RevisionSchema = Type.String({
4818
5811
  pattern: "^[^\\s#]+$",
4819
5812
  minLength: 1,
@@ -4825,10 +5818,28 @@ const SparsePathSchema = Refine(Type.String({
4825
5818
  }), isCanonicalRelativePath$1, () => "Expected one canonical relative POSIX path");
4826
5819
  const SparsePathsSchema = Type.Unsafe(Refine(Type.Array(SparsePathSchema, { maxItems: 64 }), isCanonicalDistinctOrder$1, () => "Expected distinct code-unit-sorted sparse paths"));
4827
5820
  const NullablePathSchema = Type.Union([CanonicalProviderPathSchema, Type.Null()]);
4828
- const NullablePluginVersionSchema = Type.Union([Type.String({
5821
+ /** Admits a canonical provider-reported plugin version string. */
5822
+ const PluginVersionSchema = Type.String({
4829
5823
  pattern: "^[0-9A-Za-z][0-9A-Za-z.+_-]*$",
4830
5824
  maxLength: 256
4831
- }), Type.Null()]);
5825
+ });
5826
+ const NullablePluginVersionSchema = Type.Union([PluginVersionSchema, Type.Null()]);
5827
+ const McpServerIdentitySchema = Type.String({
5828
+ pattern: "^[a-z0-9][a-z0-9_-]*$",
5829
+ minLength: 1,
5830
+ maxLength: 128
5831
+ });
5832
+ const OwnerPluginIdSchema = Type.String({
5833
+ pattern: "^[a-z0-9][a-z0-9._-]*$",
5834
+ minLength: 1,
5835
+ maxLength: 512
5836
+ });
5837
+ /** Admits bounded MCP server names observed in live user-scope provider configuration. */
5838
+ const ObservedMcpServerNameSchema = Type.String({
5839
+ pattern: "^[^\\u0000-\\u001f\\u007f]+$",
5840
+ minLength: 1,
5841
+ maxLength: 256
5842
+ });
4832
5843
  /**
4833
5844
  * Admits credential-free HTTPS Git locators that native marketplace adapters can reproduce exactly.
4834
5845
  * The canonical form prevents provider-specific URL normalization from changing source identity.
@@ -4837,8 +5848,20 @@ const CanonicalGitRepositoryUrlSchema = Refine(Type.String({
4837
5848
  minLength: 14,
4838
5849
  maxLength: 2048
4839
5850
  }), isCanonicalHttpsGitUrl$1, () => "Expected a canonical HTTPS Git repository URL");
5851
+ /**
5852
+ * Admits credential-free loopback HTTP URLs with an explicit non-default port for host-scoped MCP
5853
+ * servers. Canonical formatting keeps native MCP observations comparable across provider homes.
5854
+ */
5855
+ const CanonicalLoopbackHttpUrlSchema = Refine(Type.String({
5856
+ minLength: 14,
5857
+ maxLength: 2048
5858
+ }), isCanonicalLoopbackHttpUrl, () => "Expected a canonical loopback HTTP URL with an explicit non-default port");
4840
5859
  /** Identifies one native agent provider supported by the closed resource catalog. */
4841
- const NativeAgentProviderIdSchema = Type.Union([Type.Literal("claude"), Type.Literal("codex")], { description: "Identity of one supported native agent provider." });
5860
+ const NativeAgentProviderIdSchema = Type.Union([
5861
+ Type.Literal("claude"),
5862
+ Type.Literal("codex"),
5863
+ Type.Literal("antigravity")
5864
+ ], { description: "Identity of one supported native agent provider." });
4842
5865
  /**
4843
5866
  * Defines the closed operation vocabulary carried through provider execution and diagnostics.
4844
5867
  * Provider kernels and lifecycle consumers use these identifiers to preserve operation ownership.
@@ -4852,7 +5875,9 @@ const NativeAgentProviderOperationSchema = Type.Union([
4852
5875
  Type.Literal("plugin-files-read"),
4853
5876
  Type.Literal("plugin-install"),
4854
5877
  Type.Literal("plugin-enable"),
4855
- Type.Literal("plugin-remove")
5878
+ Type.Literal("plugin-remove"),
5879
+ Type.Literal("mcp-add"),
5880
+ Type.Literal("mcp-remove")
4856
5881
  ]);
4857
5882
  /**
4858
5883
  * Records how far a native command progressed when an operation fails.
@@ -4892,8 +5917,28 @@ Type.Readonly(Type.Object({
4892
5917
  }, { additionalProperties: false }));
4893
5918
  /** Validates the explicit provider home supplied for one acquired native session. */
4894
5919
  const NativeProviderHomeSchema = CanonicalProviderPathSchema;
4895
- /** Admits the explicit home for one native-provider session. */
4896
- const NativeProviderSessionInputSchema = Type.Readonly(Type.Object({ home: NativeProviderHomeSchema }, { additionalProperties: false }));
5920
+ /** Admits the explicit home and optional disposable-root boundary for one native-provider session. */
5921
+ const NativeProviderSessionInputSchema = Type.Readonly(Type.Object({
5922
+ home: NativeProviderHomeSchema,
5923
+ disposableRoot: Type.Optional(CanonicalProviderPathSchema)
5924
+ }, { additionalProperties: false }));
5925
+ /** Caps marketplace inventory accepted from one native provider command. */
5926
+ const MAX_NATIVE_PROVIDER_MARKETPLACES = 1024;
5927
+ /** Caps plugin inventory accepted from one native provider command. */
5928
+ const MAX_NATIVE_PROVIDER_PLUGINS = 4096;
5929
+ /** Caps user-scope MCP server inventory accepted from one native provider observation. */
5930
+ const MAX_NATIVE_PROVIDER_MCP_SERVERS = 1024;
5931
+ /**
5932
+ * Admits optional observation controls for one native inventory read.
5933
+ * Callers may skip reading user-scope MCP configuration when neither desired content nor a
5934
+ * relevant managed MCP ledger owner requires MCP server observation. Codex can also report
5935
+ * user-config plugin selectors for one marketplace, including selectors its catalog omits.
5936
+ */
5937
+ const NativeProviderInventoryOptionsSchema = Type.Readonly(Type.Object({
5938
+ observeMcpServers: Type.Optional(Type.Boolean()),
5939
+ observePluginConfigForMarketplace: Type.Optional(MarketplaceIdentitySchema$2),
5940
+ relevantOwnerPluginIds: Type.Optional(Type.Readonly(Type.Array(OwnerPluginIdSchema, { maxItems: MAX_NATIVE_PROVIDER_PLUGINS })))
5941
+ }, { additionalProperties: false }));
4897
5942
  /**
4898
5943
  * Admits an explicit Git or local source for a native marketplace-add operation.
4899
5944
  * Provider adapters consume this neutral request and own its translation to vendor command
@@ -4922,7 +5967,10 @@ const NativeProviderCapabilitySchema = Type.Union([
4922
5967
  Type.Literal("plugin-enable"),
4923
5968
  Type.Literal("plugin-disable"),
4924
5969
  Type.Literal("plugin-remove"),
4925
- Type.Literal("plugin-update")
5970
+ Type.Literal("plugin-update"),
5971
+ Type.Literal("mcp-list"),
5972
+ Type.Literal("mcp-add"),
5973
+ Type.Literal("mcp-remove")
4926
5974
  ]);
4927
5975
  const CodexNativeProviderCapabilitySchema = Type.Union([
4928
5976
  Type.Literal("marketplace-list"),
@@ -4930,9 +5978,24 @@ const CodexNativeProviderCapabilitySchema = Type.Union([
4930
5978
  Type.Literal("marketplace-remove"),
4931
5979
  Type.Literal("plugin-list"),
4932
5980
  Type.Literal("plugin-install"),
4933
- Type.Literal("plugin-remove")
5981
+ Type.Literal("plugin-remove"),
5982
+ Type.Literal("mcp-list"),
5983
+ Type.Literal("mcp-add"),
5984
+ Type.Literal("mcp-remove")
4934
5985
  ]);
4935
5986
  const ClaudeNativeProviderCapabilitySchema = NativeProviderCapabilitySchema;
5987
+ const AntigravityNativeProviderCapabilitySchema = Type.Union([
5988
+ Type.Literal("marketplace-list"),
5989
+ Type.Literal("marketplace-add"),
5990
+ Type.Literal("marketplace-remove"),
5991
+ Type.Literal("plugin-list"),
5992
+ Type.Literal("plugin-install"),
5993
+ Type.Literal("plugin-enable"),
5994
+ Type.Literal("plugin-disable"),
5995
+ Type.Literal("plugin-remove"),
5996
+ Type.Literal("mcp-add"),
5997
+ Type.Literal("mcp-remove")
5998
+ ]);
4936
5999
  const nativeCapabilityProperties = {
4937
6000
  home: CanonicalProviderPathSchema,
4938
6001
  version: BoundedTextSchema
@@ -4942,15 +6005,23 @@ const nativeCapabilityProperties = {
4942
6005
  * Provider-specific constraints keep lifecycle orchestration from assuming operations an adapter
4943
6006
  * cannot implement.
4944
6007
  */
4945
- const NativeProviderCapabilitiesSchema = Type.Union([ReadonlyObject(Type.Object({
4946
- ...nativeCapabilityProperties,
4947
- provider: Type.Literal("codex"),
4948
- capabilities: Refine(Type.Array(CodexNativeProviderCapabilitySchema, { maxItems: 6 }), (capabilities) => new Set(capabilities).size === capabilities.length, () => "Codex capabilities must be distinct")
4949
- }), { additionalProperties: false }), ReadonlyObject(Type.Object({
4950
- ...nativeCapabilityProperties,
4951
- provider: Type.Literal("claude"),
4952
- capabilities: Refine(Type.Array(ClaudeNativeProviderCapabilitySchema, { maxItems: 10 }), (capabilities) => capabilities.includes("plugin-enable") && new Set(capabilities).size === capabilities.length, () => "Claude capabilities must include distinct plugin enablement")
4953
- }), { additionalProperties: false })]);
6008
+ const NativeProviderCapabilitiesSchema = Type.Union([
6009
+ ReadonlyObject(Type.Object({
6010
+ ...nativeCapabilityProperties,
6011
+ provider: Type.Literal("codex"),
6012
+ capabilities: Refine(Type.Array(CodexNativeProviderCapabilitySchema, { maxItems: 9 }), (capabilities) => new Set(capabilities).size === capabilities.length, () => "Codex capabilities must be distinct")
6013
+ }), { additionalProperties: false }),
6014
+ ReadonlyObject(Type.Object({
6015
+ ...nativeCapabilityProperties,
6016
+ provider: Type.Literal("claude"),
6017
+ 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")
6018
+ }), { additionalProperties: false }),
6019
+ ReadonlyObject(Type.Object({
6020
+ ...nativeCapabilityProperties,
6021
+ provider: Type.Literal("antigravity"),
6022
+ 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")
6023
+ }), { additionalProperties: false })
6024
+ ]);
4954
6025
  /**
4955
6026
  * Describes the source evidence a native provider actually reports for an installed marketplace.
4956
6027
  * Inventory consumers compare these observations with curated intent without treating them as
@@ -4979,27 +6050,54 @@ const NativeProviderMarketplaceObservationSchema = Type.Readonly(Type.Object({
4979
6050
  * decisions owned by the lifecycle service.
4980
6051
  */
4981
6052
  const NativeProviderPluginObservationSchema = Type.Readonly(Type.Object({
4982
- selector: PluginSelectorSchema$1,
6053
+ selector: ObservedPluginSelectorSchema,
4983
6054
  marketplaceIdentity: MarketplaceIdentitySchema$2,
4984
- name: Type.String({
4985
- pattern: "^[a-z0-9][a-z0-9._-]*$",
4986
- maxLength: 128
4987
- }),
6055
+ name: ObservedPluginNameSchema,
4988
6056
  installed: Type.Boolean(),
4989
6057
  enabled: Type.Union([Type.Boolean(), Type.Null()]),
4990
6058
  version: NullablePluginVersionSchema,
4991
6059
  root: NullablePathSchema
4992
6060
  }, { additionalProperties: false }));
4993
6061
  /**
6062
+ * Validates one user-scope MCP server entry from live native-provider inventory.
6063
+ * Transport, URL, and enablement feed collision safety and host-scoped HTTP MCP convergence
6064
+ * while preserving unmanaged foreign entries in the explicit home.
6065
+ */
6066
+ const NativeProviderMcpServerObservationSchema = Type.Readonly(Type.Object({
6067
+ name: ObservedMcpServerNameSchema,
6068
+ transport: Type.Union([Type.Literal("http"), Type.Literal("other")]),
6069
+ url: Type.Union([BoundedTextSchema, Type.Null()]),
6070
+ enabled: Type.Union([Type.Boolean(), Type.Null()])
6071
+ }, { additionalProperties: false }));
6072
+ /**
6073
+ * Validates one Habitat-managed host-scoped HTTP MCP ownership record persisted in
6074
+ * `<home>/.habitat-host-mcp-ledger.json` (or `<geminiRoot>/config/.habitat-host-mcp-ledger.json`
6075
+ * on Antigravity) outside installed plugin directories.
6076
+ */
6077
+ const NativeManagedMcpServerRecordSchema = Type.Readonly(Type.Object({
6078
+ name: McpServerIdentitySchema,
6079
+ url: CanonicalLoopbackHttpUrlSchema,
6080
+ ownerPluginId: OwnerPluginIdSchema
6081
+ }, { additionalProperties: false }));
6082
+ /**
4994
6083
  * Validates a complete, canonically ordered native-provider inventory snapshot.
4995
6084
  * Stable ordering and distinct identities make provider observations deterministic for lifecycle
4996
6085
  * comparison and diagnostics.
4997
6086
  */
4998
6087
  const NativeProviderInventorySchema = Refine(Type.Readonly(Type.Object({
4999
6088
  provider: NativeAgentProviderIdSchema,
5000
- marketplaces: Type.Readonly(Type.Array(NativeProviderMarketplaceObservationSchema, { maxItems: 1024 })),
5001
- plugins: Type.Readonly(Type.Array(NativeProviderPluginObservationSchema, { maxItems: 4096 }))
5002
- }, { additionalProperties: false })), (inventory) => isCanonicalDistinctOrder$1(inventory.marketplaces.map((marketplace) => marketplace.identity)) && isCanonicalDistinctOrder$1(inventory.plugins.map((plugin) => plugin.selector)), () => "Expected canonical distinct marketplace identities and plugin selectors");
6089
+ marketplaces: Type.Readonly(Type.Array(NativeProviderMarketplaceObservationSchema, { maxItems: MAX_NATIVE_PROVIDER_MARKETPLACES })),
6090
+ plugins: Type.Readonly(Type.Array(NativeProviderPluginObservationSchema, { maxItems: MAX_NATIVE_PROVIDER_PLUGINS })),
6091
+ pluginConfig: Type.Optional(Type.Readonly(Type.Object({
6092
+ marketplaceIdentity: MarketplaceIdentitySchema$2,
6093
+ selectors: Type.Readonly(Type.Array(ObservedPluginSelectorSchema, { maxItems: MAX_NATIVE_PROVIDER_PLUGINS }))
6094
+ }, { additionalProperties: false }))),
6095
+ mcpServers: Type.Readonly(Type.Array(NativeProviderMcpServerObservationSchema, { maxItems: MAX_NATIVE_PROVIDER_MCP_SERVERS })),
6096
+ managedMcpServers: Type.Readonly(Type.Array(NativeManagedMcpServerRecordSchema, { maxItems: MAX_NATIVE_PROVIDER_MCP_SERVERS }))
6097
+ }, { additionalProperties: false })), (inventory) => {
6098
+ const { pluginConfig } = inventory;
6099
+ return isCanonicalDistinctOrder$1(inventory.marketplaces.map((marketplace) => marketplace.identity)) && isCanonicalDistinctOrder$1(inventory.plugins.map((plugin) => plugin.selector)) && (pluginConfig === void 0 || isCanonicalDistinctOrder$1(pluginConfig.selectors) && pluginConfig.selectors.every((selector) => selector.slice(selector.indexOf("@") + 1) === pluginConfig.marketplaceIdentity)) && isCanonicalDistinctOrder$1(inventory.mcpServers.map((server) => server.name)) && isCanonicalDistinctOrder$1(inventory.managedMcpServers.map((server) => server.name));
6100
+ }, () => "Expected canonical distinct marketplace identities, scoped plugin selectors, MCP server names, and managed MCP server names");
5003
6101
  /**
5004
6102
  * Admits the marketplace identity for one explicit native removal.
5005
6103
  * The narrow request prevents mutation adapters from receiving unrelated lifecycle state.
@@ -5010,6 +6108,22 @@ const NativeProviderMarketplaceIdentityInputSchema = Type.Readonly(Type.Object({
5010
6108
  * Provider adapters translate this shared selector into their vendor-specific commands.
5011
6109
  */
5012
6110
  const NativeProviderPluginSelectorInputSchema = Type.Readonly(Type.Object({ selector: PluginSelectorSchema$1 }, { additionalProperties: false }));
6111
+ /**
6112
+ * Admits the canonical server name, loopback HTTP URL, and owning plugin identity for one native
6113
+ * MCP add operation. Provider adapters record ownership in `<home>/.habitat-host-mcp-ledger.json`
6114
+ * (or `<geminiRoot>/config/.habitat-host-mcp-ledger.json` on Antigravity) before running their
6115
+ * user-scoped HTTP MCP command.
6116
+ */
6117
+ const NativeProviderMcpServerAddInputSchema = Type.Readonly(Type.Object({
6118
+ name: McpServerIdentitySchema,
6119
+ url: CanonicalLoopbackHttpUrlSchema,
6120
+ ownerPluginId: OwnerPluginIdSchema
6121
+ }, { additionalProperties: false }));
6122
+ /**
6123
+ * Admits the canonical server name for one explicit native MCP removal operation.
6124
+ * The narrow request prevents adapters from receiving unrelated lifecycle state.
6125
+ */
6126
+ const NativeProviderMcpServerRemoveInputSchema = Type.Readonly(Type.Object({ name: McpServerIdentitySchema }, { additionalProperties: false }));
5013
6127
  /** Caps the number of installed plugin files observed in one provider request. */
5014
6128
  const MAX_NATIVE_PROVIDER_PLUGIN_FILES = 16384;
5015
6129
  /** Caps the bytes admitted for any single installed plugin file. */
@@ -5108,6 +6222,16 @@ function isCanonicalHttpsGitUrl$1(value) {
5108
6222
  }
5109
6223
  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
6224
  }
6225
+ function isCanonicalLoopbackHttpUrl(value) {
6226
+ let parsed;
6227
+ try {
6228
+ parsed = new URL(value);
6229
+ } catch {
6230
+ return false;
6231
+ }
6232
+ const port = parsed.port === "" ? NaN : Number(parsed.port);
6233
+ 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;
6234
+ }
5111
6235
  function isCanonicalRelativePath$1(value) {
5112
6236
  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
6237
  }
@@ -5119,12 +6243,141 @@ function hasBoundedDistinctFileRequests(input) {
5119
6243
  return isCanonicalDistinctOrder$1(input.files.map((file) => file.relativePath)) && input.files.reduce((total, file) => total + file.maxBytes, 0) <= 67108864;
5120
6244
  }
5121
6245
  //#endregion
6246
+ //#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/model/dto/selected-content.ts
6247
+ const MAX_SELECTED_ISSUES = 256;
6248
+ const MAX_SELECTED_ISSUE_DETAIL = 4096;
6249
+ /** Maximum host-scoped HTTP MCP servers admitted across one selected release set. */
6250
+ const MAX_HOST_MCP_SERVERS = 1024;
6251
+ const MarketplaceIdentitySchema$1 = Type.String({
6252
+ minLength: 1,
6253
+ maxLength: 128,
6254
+ pattern: "^[a-z0-9][a-z0-9_-]*$"
6255
+ });
6256
+ const AntigravityBundleOmittedMcpServerReasonSchema = Type.Union([
6257
+ Type.Literal("unsupported-transport"),
6258
+ Type.Literal("non-remote-https-url"),
6259
+ Type.Literal("requires-variables"),
6260
+ Type.Literal("invalid-config")
6261
+ ]);
6262
+ /** Validates a canonical host-scoped HTTP MCP server identifier. */
6263
+ const HostMcpServerNameSchema = Type.String({
6264
+ minLength: 1,
6265
+ maxLength: 128,
6266
+ pattern: "^[a-z0-9][a-z0-9_-]*$"
6267
+ });
6268
+ /** Validates the wire structure of a canonical loopback HTTP MCP endpoint URL. */
6269
+ const HostMcpServerUrlSchema = Type.String({
6270
+ minLength: 14,
6271
+ maxLength: 2048,
6272
+ pattern: "^http://(?:127\\.0\\.0\\.1|localhost|\\[::1\\]):(?!80/)[1-9][0-9]{0,4}/[^\\s#?]*$"
6273
+ });
6274
+ /** Describes one host-scoped loopback HTTP MCP server derived from a selected plugin payload. */
6275
+ const SelectedHostMcpServerSchema = ReadonlyObject(Type.Object({
6276
+ name: HostMcpServerNameSchema,
6277
+ url: HostMcpServerUrlSchema,
6278
+ ownerPluginId: PluginIdSchema
6279
+ }), { additionalProperties: false });
6280
+ /** Describes one payload file whose exact bytes a provider operation must verify. */
6281
+ const SelectedContentFileSchema = PayloadManifestEntrySchema;
6282
+ /** Identifies one `.mcp.json` server omitted from Antigravity's projected `mcp_config.json`. */
6283
+ const AntigravityOmittedMcpServerSchema = ReadonlyObject(Type.Object({
6284
+ name: Type.String({ maxLength: 256 }),
6285
+ reason: AntigravityBundleOmittedMcpServerReasonSchema
6286
+ }), { additionalProperties: false });
6287
+ /**
6288
+ * Describes one selected plugin and the immutable ownership and payload facts used during
6289
+ * provider convergence.
6290
+ */
6291
+ const SelectedContentMemberSchema = ReadonlyObject(Type.Object({
6292
+ pluginId: PluginIdSchema,
6293
+ aliases: ReadonlyObject(Type.Array(OwnershipIdentitySchema), {
6294
+ maxItems: MAX_OWNERSHIP_CLAIMS,
6295
+ uniqueItems: true
6296
+ }),
6297
+ payloadDigest: PayloadDigestSchema,
6298
+ releaseDigest: ReleaseDigestSchema,
6299
+ manifest: ReadonlyObject(Type.Array(SelectedContentFileSchema), {
6300
+ minItems: 1,
6301
+ maxItems: MAX_PAYLOAD_ENTRIES_PER_MEMBER,
6302
+ uniqueItems: true
6303
+ }),
6304
+ antigravityManifest: Type.Union([ReadonlyObject(Type.Array(SelectedContentFileSchema), {
6305
+ minItems: 1,
6306
+ maxItems: MAX_PAYLOAD_ENTRIES_PER_MEMBER,
6307
+ uniqueItems: true
6308
+ }), Type.Null()]),
6309
+ antigravityProjectionError: Type.Optional(Type.String({
6310
+ minLength: 1,
6311
+ maxLength: MAX_SELECTED_ISSUE_DETAIL,
6312
+ description: "Why the selected payload cannot be projected for Antigravity."
6313
+ })),
6314
+ antigravityOmittedMcpServers: ReadonlyObject(Type.Array(AntigravityOmittedMcpServerSchema), {
6315
+ maxItems: MAX_PAYLOAD_ENTRIES_PER_MEMBER,
6316
+ uniqueItems: true
6317
+ })
6318
+ }), { additionalProperties: false });
6319
+ const selectedContentProperties = {
6320
+ contentAuthority: ContentAuthoritySchema,
6321
+ repositoryIdentity: RepositoryIdentitySchema$1,
6322
+ sourceCommit: GitCommitIdSchema,
6323
+ sourceTree: GitTreeIdSchema,
6324
+ releaseInputDigest: ReleaseInputDigestSchema,
6325
+ marketplace: ReadonlyObject(Type.Object({
6326
+ identity: MarketplaceIdentitySchema$1,
6327
+ source: NativeMarketplaceSourceSchema
6328
+ }), { additionalProperties: false }),
6329
+ members: ReadonlyObject(Type.Array(SelectedContentMemberSchema), {
6330
+ minItems: 1,
6331
+ maxItems: MAX_RELEASE_MEMBERS,
6332
+ uniqueItems: true
6333
+ }),
6334
+ hostMcpServers: BoundedReadonlyArray(SelectedHostMcpServerSchema, { maxItems: MAX_HOST_MCP_SERVERS })
6335
+ };
6336
+ /**
6337
+ * Defines the complete provider-owned selection that status, test, and sync inspect or
6338
+ * converge without becoming a new source authority.
6339
+ */
6340
+ const SelectedContentSchema = Type.Union([ReadonlyObject(Type.Object({
6341
+ ...selectedContentProperties,
6342
+ selectionKind: Type.Literal("targeted"),
6343
+ releaseSetDigest: Type.Null()
6344
+ }), { additionalProperties: false }), ReadonlyObject(Type.Object({
6345
+ ...selectedContentProperties,
6346
+ selectionKind: Type.Literal("complete-set"),
6347
+ releaseSetDigest: ReleaseSetDigestSchema
6348
+ }), { additionalProperties: false })]);
6349
+ /** Classifies provider-selection failures without leaking resource implementation details. */
6350
+ const SelectedContentIssueCodeSchema = Type.Union([
6351
+ Type.Literal("SourceIneligible"),
6352
+ Type.Literal("SourceReadFailed"),
6353
+ Type.Literal("ReleaseConstructionFailed"),
6354
+ Type.Literal("SelectionMismatch"),
6355
+ Type.Literal("DesiredContentInvalid")
6356
+ ]);
6357
+ /** Carries one bounded provider-selection failure to the owning provider operation. */
6358
+ const SelectedContentIssueSchema = ReadonlyObject(Type.Object({
6359
+ code: SelectedContentIssueCodeSchema,
6360
+ detail: Type.String({
6361
+ minLength: 1,
6362
+ maxLength: MAX_SELECTED_ISSUE_DETAIL
6363
+ }),
6364
+ pluginId: Type.Optional(PluginIdSchema)
6365
+ }), { additionalProperties: false });
6366
+ Type.Union([ReadonlyObject(Type.Object({
6367
+ kind: Type.Literal("Selected"),
6368
+ content: SelectedContentSchema
6369
+ }), { additionalProperties: false }), ReadonlyObject(Type.Object({
6370
+ kind: Type.Literal("Rejected"),
6371
+ issues: NonEmptyReadonlyArray(SelectedContentIssueSchema, { maxItems: MAX_SELECTED_ISSUES })
6372
+ }), { additionalProperties: false })]);
6373
+ //#endregion
5122
6374
  //#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/model/dto/provider-lifecycle.ts
5123
6375
  const MAX_TARGETS = 16;
5124
- const MAX_CONFIRMED_NATIVE_OPERATIONS = 7170;
6376
+ const MAX_CONFIRMED_NATIVE_OPERATIONS = 10242;
5125
6377
  /** Maximum public verification facts returned for one Provider target. */
5126
6378
  const MAX_PROVIDER_FACTS = 4096;
5127
6379
  const MAX_DETAIL_LENGTH = 4096;
6380
+ const ProviderIdSchema = NativeAgentProviderIdSchema;
5128
6381
  /** Publishes the structural wire shape of an explicit native-provider home. */
5129
6382
  const ProviderHomeSchema = Type.String({
5130
6383
  minLength: 2,
@@ -5133,7 +6386,7 @@ const ProviderHomeSchema = Type.String({
5133
6386
  description: "Projectable non-root absolute path structure; native-provider policy owns canonical admission."
5134
6387
  });
5135
6388
  const ProviderTargetSchema = ReadonlyObject(Type.Object({
5136
- provider: NativeAgentProviderIdSchema,
6389
+ provider: ProviderIdSchema,
5137
6390
  home: ProviderHomeSchema
5138
6391
  }), { additionalProperties: false });
5139
6392
  /**
@@ -5181,12 +6434,17 @@ const ProviderIssueCodeSchema = Type.Union([
5181
6434
  Type.Literal("CapabilityMissing"),
5182
6435
  Type.Literal("MarketplaceCollision"),
5183
6436
  Type.Literal("PluginCollision"),
6437
+ Type.Literal("McpServerCollision"),
5184
6438
  Type.Literal("MarketplaceDrift"),
5185
6439
  Type.Literal("PluginMissing"),
5186
6440
  Type.Literal("PluginDisabled"),
5187
6441
  Type.Literal("OmittedPluginPresent"),
5188
6442
  Type.Literal("PluginFileMissing"),
5189
6443
  Type.Literal("PluginFileMismatch"),
6444
+ Type.Literal("McpServerMissing"),
6445
+ Type.Literal("McpServerDrift"),
6446
+ Type.Literal("McpServerDisabled"),
6447
+ Type.Literal("OmittedMcpServerPresent"),
5190
6448
  Type.Literal("NativeObservationFailed"),
5191
6449
  Type.Literal("NativeCommandFailed"),
5192
6450
  Type.Literal("VerificationFailed"),
@@ -5200,7 +6458,7 @@ const ProviderIssueSchema = ReadonlyObject(Type.Object({
5200
6458
  }),
5201
6459
  pluginId: Type.Optional(PluginIdSchema)
5202
6460
  }), { additionalProperties: false });
5203
- const MarketplaceIdentitySchema$1 = Type.String({
6461
+ const MarketplaceIdentitySchema = Type.String({
5204
6462
  minLength: 1,
5205
6463
  maxLength: 128,
5206
6464
  pattern: "^[a-z0-9][a-z0-9_-]*$"
@@ -5213,11 +6471,11 @@ const PluginSelectorSchema = Type.String({
5213
6471
  const ConfirmedNativeOperationSchema = Type.Union([
5214
6472
  ReadonlyObject(Type.Object({
5215
6473
  kind: Type.Literal("marketplace-added"),
5216
- identity: MarketplaceIdentitySchema$1
6474
+ identity: MarketplaceIdentitySchema
5217
6475
  }), { additionalProperties: false }),
5218
6476
  ReadonlyObject(Type.Object({
5219
6477
  kind: Type.Literal("marketplace-removed"),
5220
- identity: MarketplaceIdentitySchema$1
6478
+ identity: MarketplaceIdentitySchema
5221
6479
  }), { additionalProperties: false }),
5222
6480
  ReadonlyObject(Type.Object({
5223
6481
  kind: Type.Literal("plugin-installed"),
@@ -5230,21 +6488,39 @@ const ConfirmedNativeOperationSchema = Type.Union([
5230
6488
  ReadonlyObject(Type.Object({
5231
6489
  kind: Type.Literal("plugin-removed"),
5232
6490
  selector: PluginSelectorSchema
6491
+ }), { additionalProperties: false }),
6492
+ ReadonlyObject(Type.Object({
6493
+ kind: Type.Literal("mcp-added"),
6494
+ name: HostMcpServerNameSchema,
6495
+ url: HostMcpServerUrlSchema
6496
+ }), { additionalProperties: false }),
6497
+ ReadonlyObject(Type.Object({
6498
+ kind: Type.Literal("mcp-removed"),
6499
+ name: HostMcpServerNameSchema
5233
6500
  }), { additionalProperties: false })
5234
6501
  ]);
5235
6502
  const NativeOperationAttemptSchema = ReadonlyObject(Type.Object({
5236
6503
  operation: ConfirmedNativeOperationSchema,
5237
6504
  commandPhase: Type.Union([Type.Literal("started"), Type.Literal("command-returned")])
5238
6505
  }), { additionalProperties: false });
6506
+ /** Identifies why a `.mcp.json` server entry was omitted from Antigravity's bundle projection. */
6507
+ const AntigravityOmittedMcpServerReasonSchema = Type.Union([
6508
+ Type.Literal("unsupported-transport"),
6509
+ Type.Literal("non-remote-https-url"),
6510
+ Type.Literal("requires-variables"),
6511
+ Type.Literal("invalid-config")
6512
+ ]);
5239
6513
  const targetObservationProperties = {
5240
6514
  target: ProviderTargetSchema,
5241
- facts: BoundedReadonlyArray(ReadonlyObject(Type.Object({
6515
+ facts: BoundedReadonlyArray(Type.Union([ReadonlyObject(Type.Object({
5242
6516
  kind: Type.Union([
5243
6517
  Type.Literal("marketplace-source"),
5244
6518
  Type.Literal("plugin-installed"),
5245
6519
  Type.Literal("plugin-enabled"),
5246
6520
  Type.Literal("plugin-file"),
5247
- Type.Literal("plugin-absent")
6521
+ Type.Literal("plugin-absent"),
6522
+ Type.Literal("mcp-configured"),
6523
+ Type.Literal("mcp-absent")
5248
6524
  ]),
5249
6525
  subject: Type.String({
5250
6526
  minLength: 1,
@@ -5254,7 +6530,20 @@ const targetObservationProperties = {
5254
6530
  minLength: 1,
5255
6531
  maxLength: MAX_DETAIL_LENGTH
5256
6532
  })
5257
- }), { additionalProperties: false }), { maxItems: MAX_PROVIDER_FACTS }),
6533
+ }), { additionalProperties: false }), ReadonlyObject(Type.Object({
6534
+ kind: Type.Literal("mcp-omitted"),
6535
+ pluginId: PluginIdSchema,
6536
+ name: Type.String({ maxLength: 256 }),
6537
+ reason: AntigravityOmittedMcpServerReasonSchema,
6538
+ subject: Type.String({
6539
+ minLength: 1,
6540
+ maxLength: 2048
6541
+ }),
6542
+ detail: Type.String({
6543
+ minLength: 1,
6544
+ maxLength: MAX_DETAIL_LENGTH
6545
+ })
6546
+ }), { additionalProperties: false })]), { maxItems: MAX_PROVIDER_FACTS }),
5258
6547
  issues: BoundedReadonlyArray(ProviderIssueSchema, { maxItems: 256 })
5259
6548
  };
5260
6549
  const boundedNativeOperations = () => BoundedReadonlyArray(ConfirmedNativeOperationSchema, { maxItems: MAX_CONFIRMED_NATIVE_OPERATIONS });
@@ -7642,7 +8931,7 @@ function sameInspection(left, right) {
7642
8931
  function exactRepositoryIdentity(remoteUrls, expected) {
7643
8932
  const observed = remoteUrls.map((remoteUrl) => repositoryIdentityFromRemote(remoteUrl) ?? remoteUrl);
7644
8933
  if (observed.includes(expected)) return expected;
7645
- const unique = [...new Set(observed)].sort(compareText$7);
8934
+ const unique = [...new Set(observed)].sort(compareText$9);
7646
8935
  return unique.length === 1 ? unique[0] : "unresolved:multiple-or-missing-remotes";
7647
8936
  }
7648
8937
  function repositoryIdentityFromRemote(remoteUrl) {
@@ -7705,7 +8994,7 @@ function requireRelativePath(value, path) {
7705
8994
  if (!parsed.ok) throw new Error(`Compiled ${path} is invalid`);
7706
8995
  return parsed.value;
7707
8996
  }
7708
- function compareText$7(left, right) {
8997
+ function compareText$9(left, right) {
7709
8998
  return left < right ? -1 : left > right ? 1 : 0;
7710
8999
  }
7711
9000
  //#endregion
@@ -9580,127 +10869,48 @@ const router$8 = { package: service$1.packaging.use(async ({ context, next }) =>
9580
10869
  }) };
9581
10870
  //#endregion
9582
10871
  //#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 })]);
10872
+ /** Reserved direct child that keeps one native marketplace reachable for a disposable root. */
10873
+ const DISPOSABLE_MARKETPLACE_DIRECTORY = ".rawr-agent-plugin-marketplace";
10874
+ /** Confirms every provider target carries the native resource's canonical home shape. */
10875
+ function hasCanonicalProviderHomes(targets) {
10876
+ return targets.every((target) => isCanonicalProviderHome(target.home));
10877
+ }
10878
+ /** Admits one canonical non-root native-provider home. */
10879
+ function isCanonicalProviderHome(value) {
10880
+ return Value.Check(NativeProviderHomeSchema, value);
10881
+ }
10882
+ /** Confirms every provider home is owned by the explicit disposable parent. */
10883
+ function hasStrictDescendantHomes(disposableRoot, targets) {
10884
+ const descendantPrefix = `${disposableRoot}/`;
10885
+ return targets.every((target) => target.home.startsWith(descendantPrefix));
10886
+ }
10887
+ /** Confirms no two provider homes are equal or contain one another. */
10888
+ function hasPairwiseDisjointProviderHomes(targets) {
10889
+ for (let leftIndex = 0; leftIndex < targets.length; leftIndex += 1) {
10890
+ const left = targets[leftIndex].home;
10891
+ for (let rightIndex = leftIndex + 1; rightIndex < targets.length; rightIndex += 1) {
10892
+ const right = targets[rightIndex].home;
10893
+ if (left === right || left.startsWith(`${right}/`) || right.startsWith(`${left}/`)) return false;
10894
+ }
10895
+ }
10896
+ return true;
10897
+ }
10898
+ /** Prevents two canonical absolute paths from containing one another. */
10899
+ function areDisjointPaths(left, right) {
10900
+ return left !== right && !left.startsWith(`${right}/`) && !right.startsWith(`${left}/`);
10901
+ }
10902
+ /** Returns the one stable marketplace root owned by a disposable test parent. */
10903
+ function disposableMarketplaceRoot(disposableRoot) {
10904
+ return `${disposableRoot}/${DISPOSABLE_MARKETPLACE_DIRECTORY}`;
10905
+ }
10906
+ /** Prevents the stable marketplace and any provider home from containing one another. */
10907
+ function hasDisjointMarketplaceRoot(disposableRoot, targets) {
10908
+ const marketplaceRoot = disposableMarketplaceRoot(disposableRoot);
10909
+ return targets.every((target) => areDisjointPaths(marketplaceRoot, target.home));
10910
+ }
9702
10911
  //#endregion
9703
10912
  //#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/model/policy/selected-content.ts
10913
+ const utf8Decoder = new TextDecoder("utf-8", { fatal: true });
9704
10914
  /**
9705
10915
  * Projects service-owned release derivation into Provider-selected content.
9706
10916
  *
@@ -9714,16 +10924,37 @@ function constructSelectedContent(input) {
9714
10924
  if (firstRelease === void 0) return selectedContentRejected("ReleaseConstructionFailed", "Release derivation did not produce a selected member.");
9715
10925
  const releaseSet = input.derivation.releaseSet;
9716
10926
  if (input.selectionKind === "targeted" && releaseSet !== void 0) return selectedContentRejected("ReleaseConstructionFailed", "Release derivation does not match the Provider selection kind.");
9717
- const members = input.derivation.releases.map((release) => {
10927
+ const repositoryUrl = input.marketplace.source.kind === "git" ? input.marketplace.source.repositoryUrl : null;
10928
+ const members = [];
10929
+ const hostMcpServers = [];
10930
+ for (const release of input.derivation.releases) {
9718
10931
  const body = release.body;
9719
- return Object.freeze({
10932
+ const antigravity = deriveAntigravityBundleFacts(release.payload.entries, repositoryUrl);
10933
+ const packageEntry = release.payload.entries.find((entry) => entry.path === "package.json");
10934
+ const claudeEntry = release.payload.entries.find((entry) => entry.path === ".claude-plugin/plugin.json");
10935
+ const codexEntry = release.payload.entries.find((entry) => entry.path === ".codex-plugin/plugin.json");
10936
+ const mcpEntry = release.payload.entries.find((entry) => entry.path === ".mcp.json");
10937
+ const extracted = extractPluginHostMcpServers({
10938
+ pluginId: body.pluginId,
10939
+ packageJsonBytes: packageEntry === void 0 ? void 0 : payloadEntryBytes(packageEntry),
10940
+ claudeManifestBytes: claudeEntry === void 0 ? void 0 : payloadEntryBytes(claudeEntry),
10941
+ codexManifestBytes: codexEntry === void 0 ? void 0 : payloadEntryBytes(codexEntry),
10942
+ mcpConfigBytes: mcpEntry === void 0 ? void 0 : payloadEntryBytes(mcpEntry)
10943
+ });
10944
+ if (!extracted.ok) return selectedContentRejected("DesiredContentInvalid", extracted.detail, body.pluginId);
10945
+ hostMcpServers.push(...extracted.servers);
10946
+ members.push(Object.freeze({
9720
10947
  pluginId: body.pluginId,
9721
10948
  aliases: [...body.aliases],
9722
10949
  payloadDigest: body.payloadDigest,
9723
10950
  releaseDigest: release.releaseDigest,
9724
- manifest: body.payloadManifest.map((entry) => Object.freeze({ ...entry }))
9725
- });
9726
- });
10951
+ manifest: body.payloadManifest.map((entry) => Object.freeze({ ...entry })),
10952
+ antigravityManifest: antigravity.manifest,
10953
+ ...antigravity.projectionError === void 0 ? {} : { antigravityProjectionError: antigravity.projectionError },
10954
+ antigravityOmittedMcpServers: antigravity.omittedMcpServers
10955
+ }));
10956
+ }
10957
+ hostMcpServers.sort((left, right) => compareText$8(left.name, right.name) || compareText$8(left.ownerPluginId, right.ownerPluginId));
9727
10958
  const releaseBody = firstRelease.body;
9728
10959
  const common = Object.freeze({
9729
10960
  contentAuthority: releaseBody.contentAuthority,
@@ -9732,7 +10963,8 @@ function constructSelectedContent(input) {
9732
10963
  sourceTree: releaseBody.sourceTree,
9733
10964
  releaseInputDigest: releaseBody.releaseInputDigest,
9734
10965
  marketplace: input.marketplace,
9735
- members
10966
+ members: Object.freeze(members),
10967
+ hostMcpServers: Object.freeze(hostMcpServers)
9736
10968
  });
9737
10969
  if (input.selectionKind === "targeted") return Object.freeze({
9738
10970
  kind: "Selected",
@@ -9769,7 +11001,7 @@ function selectedContentFromSourceIssues(issues) {
9769
11001
  function providerSelectionResolution(resolved) {
9770
11002
  if (resolved.kind === "Rejected") return {
9771
11003
  kind: "Rejected",
9772
- issues: Object.freeze(resolved.issues.map((issue) => providerIssue("SelectionRejected", `${issue.code}: ${issue.detail}`)))
11004
+ 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
11005
  };
9774
11006
  const issues = validateSelectedContent(resolved.content);
9775
11007
  return issues.length === 0 ? {
@@ -9781,10 +11013,11 @@ function providerSelectionResolution(resolved) {
9781
11013
  };
9782
11014
  }
9783
11015
  /** Constructs one bounded selected-content refusal. */
9784
- function selectedContentRejected(code, detail) {
11016
+ function selectedContentRejected(code, detail, pluginId) {
9785
11017
  const issues = [Object.freeze({
9786
11018
  code,
9787
- detail: boundedDetail(detail)
11019
+ detail: boundedDetail(detail),
11020
+ ...pluginId === void 0 ? {} : { pluginId }
9788
11021
  })];
9789
11022
  return Object.freeze({
9790
11023
  kind: "Rejected",
@@ -9809,9 +11042,25 @@ function validateSelectedContent(content) {
9809
11042
  if (!isCanonicalDistinctOrder(member.aliases)) issues.push(providerIssue("DesiredContentInvalid", "Selected aliases must be distinct and canonically ordered.", member.pluginId));
9810
11043
  if (!isCanonicalDistinctOrder(member.manifest.map((file) => file.path))) issues.push(providerIssue("DesiredContentInvalid", "Selected manifest paths must be distinct and canonically ordered.", member.pluginId));
9811
11044
  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));
11045
+ if (member.antigravityManifest !== null) {
11046
+ if (!isCanonicalDistinctOrder(member.antigravityManifest.map((file) => file.path))) issues.push(providerIssue("DesiredContentInvalid", "Selected Antigravity manifest paths must be distinct and canonically ordered.", member.pluginId));
11047
+ 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));
11048
+ }
11049
+ 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
11050
  collectOwnedName(ownedNames, member.pluginId, member.pluginId, issues);
9813
11051
  for (const alias of member.aliases) collectOwnedName(ownedNames, alias, member.pluginId, issues);
9814
11052
  }
11053
+ const memberIds = new Set(content.members.map((member) => member.pluginId));
11054
+ if (content.hostMcpServers.length > 1024) issues.push(providerIssue("DesiredContentInvalid", "Selected host MCP servers exceed the aggregate protocol bound."));
11055
+ const mcpOwners = /* @__PURE__ */ new Map();
11056
+ for (const [index, server] of content.hostMcpServers.entries()) {
11057
+ 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));
11058
+ if (!memberIds.has(server.ownerPluginId)) issues.push(providerIssue("DesiredContentInvalid", `Host MCP server ${server.name} references undeclared owner plugin ${server.ownerPluginId}.`, server.ownerPluginId));
11059
+ if (parseCanonicalLoopbackHttpUrl(server.url) !== server.url) issues.push(providerIssue("DesiredContentInvalid", `Host MCP server ${server.name} must declare a canonical loopback HTTP URL.`, server.ownerPluginId));
11060
+ const existingOwner = mcpOwners.get(server.name);
11061
+ if (existingOwner !== void 0) issues.push(providerIssue("DesiredContentInvalid", `Host MCP server ${server.name} is declared by both ${existingOwner} and ${server.ownerPluginId}.`, server.ownerPluginId));
11062
+ else mcpOwners.set(server.name, server.ownerPluginId);
11063
+ }
9815
11064
  return Object.freeze(issues);
9816
11065
  }
9817
11066
  function selectedContentObservation(content) {
@@ -9828,7 +11077,152 @@ function selectedContentObservation(content) {
9828
11077
  });
9829
11078
  }
9830
11079
  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);
11080
+ 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);
11081
+ }
11082
+ /**
11083
+ * Canonicalizes a credential-free loopback HTTP URL (`127.0.0.1`, `localhost`, or `[::1]`) with an
11084
+ * explicit non-default port (`1`–`65535`, excluding port `80`), returning `undefined` when the
11085
+ * input is non-loopback, portless, or non-canonical.
11086
+ */
11087
+ function parseCanonicalLoopbackHttpUrl(value) {
11088
+ let parsed;
11089
+ try {
11090
+ parsed = new URL(value);
11091
+ } catch {
11092
+ return;
11093
+ }
11094
+ 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;
11095
+ const port = Number(parsed.port);
11096
+ if (!Number.isSafeInteger(port) || port < 1 || port > 65535) return void 0;
11097
+ const canonical = parsed.toString();
11098
+ if (value !== canonical && `${value}/` !== canonical) return void 0;
11099
+ return Value.Check(HostMcpServerUrlSchema, canonical) ? canonical : void 0;
11100
+ }
11101
+ /**
11102
+ * Extracts deterministic host-scoped loopback HTTP MCP server declarations from one plugin's
11103
+ * curated `package.json` (`rawr.pluginContent.hostMcpServers`), rejecting malformed entries or
11104
+ * colliding plugin-level MCP server declarations.
11105
+ */
11106
+ function extractPluginHostMcpServers(input) {
11107
+ if (input.packageJsonBytes === void 0) return Object.freeze({
11108
+ ok: true,
11109
+ servers: Object.freeze([])
11110
+ });
11111
+ const parsedPackage = parseUtf8JsonRecord(input.packageJsonBytes);
11112
+ if (parsedPackage === void 0) return Object.freeze({
11113
+ ok: false,
11114
+ detail: `Plugin ${input.pluginId} package.json must be a valid UTF-8 JSON object.`
11115
+ });
11116
+ if (!Object.hasOwn(parsedPackage, "rawr") || Reflect.get(parsedPackage, "rawr") === void 0) return Object.freeze({
11117
+ ok: true,
11118
+ servers: Object.freeze([])
11119
+ });
11120
+ const rawr = Reflect.get(parsedPackage, "rawr");
11121
+ if (!isPlainRecord(rawr)) return Object.freeze({
11122
+ ok: false,
11123
+ detail: `Plugin ${input.pluginId} package.json rawr field must be a JSON object.`
11124
+ });
11125
+ if (!Object.hasOwn(rawr, "pluginContent") || Reflect.get(rawr, "pluginContent") === void 0) return Object.freeze({
11126
+ ok: true,
11127
+ servers: Object.freeze([])
11128
+ });
11129
+ const pluginContent = Reflect.get(rawr, "pluginContent");
11130
+ if (!isPlainRecord(pluginContent)) return Object.freeze({
11131
+ ok: false,
11132
+ detail: `Plugin ${input.pluginId} package.json rawr.pluginContent must be a JSON object.`
11133
+ });
11134
+ if (!Object.hasOwn(pluginContent, "hostMcpServers") || Reflect.get(pluginContent, "hostMcpServers") === void 0) return Object.freeze({
11135
+ ok: true,
11136
+ servers: Object.freeze([])
11137
+ });
11138
+ const rawServers = Reflect.get(pluginContent, "hostMcpServers");
11139
+ if (!isPlainRecord(rawServers)) return Object.freeze({
11140
+ ok: false,
11141
+ detail: `Plugin ${input.pluginId} package.json rawr.pluginContent.hostMcpServers must be a JSON object.`
11142
+ });
11143
+ const entries = Object.entries(rawServers).sort(([left], [right]) => compareText$8(left, right));
11144
+ if (entries.length > 1024) return Object.freeze({
11145
+ ok: false,
11146
+ detail: `Plugin ${input.pluginId} package.json rawr.pluginContent.hostMcpServers exceeds the host MCP server limit.`
11147
+ });
11148
+ const servers = [];
11149
+ for (const [name, rawEntry] of entries) {
11150
+ if (!Value.Check(HostMcpServerNameSchema, name)) return Object.freeze({
11151
+ ok: false,
11152
+ detail: `Plugin ${input.pluginId} hostMcpServers key ${name} must match ^[a-z0-9][a-z0-9_-]*$.`
11153
+ });
11154
+ if (!isPlainRecord(rawEntry) || Object.keys(rawEntry).some((key) => key !== "type" && key !== "url")) return Object.freeze({
11155
+ ok: false,
11156
+ detail: `Plugin ${input.pluginId} hostMcpServers entry ${name} must be a JSON object with only type and url.`
11157
+ });
11158
+ if (Reflect.get(rawEntry, "type") !== "http") return Object.freeze({
11159
+ ok: false,
11160
+ detail: `Plugin ${input.pluginId} hostMcpServers entry ${name} must declare type "http".`
11161
+ });
11162
+ const rawUrl = Reflect.get(rawEntry, "url");
11163
+ if (typeof rawUrl !== "string") return Object.freeze({
11164
+ ok: false,
11165
+ detail: `Plugin ${input.pluginId} hostMcpServers entry ${name} must declare a string url.`
11166
+ });
11167
+ const canonicalUrl = parseCanonicalLoopbackHttpUrl(rawUrl);
11168
+ if (canonicalUrl === void 0) return Object.freeze({
11169
+ ok: false,
11170
+ detail: `Plugin ${input.pluginId} hostMcpServers entry ${name} requires a canonical loopback HTTP URL with an explicit non-default port.`
11171
+ });
11172
+ servers.push(Object.freeze({
11173
+ name,
11174
+ url: canonicalUrl,
11175
+ ownerPluginId: input.pluginId
11176
+ }));
11177
+ }
11178
+ if (servers.length > 0) {
11179
+ const conflict = findPluginManifestMcpConflict(input, new Set(servers.map((server) => server.name)));
11180
+ if (conflict !== void 0) return Object.freeze({
11181
+ ok: false,
11182
+ detail: conflict
11183
+ });
11184
+ }
11185
+ return Object.freeze({
11186
+ ok: true,
11187
+ servers: Object.freeze(servers)
11188
+ });
11189
+ }
11190
+ function findPluginManifestMcpConflict(input, declaredHostNames) {
11191
+ if (input.mcpConfigBytes !== void 0) {
11192
+ const parsedMcp = parseUtf8JsonRecord(input.mcpConfigBytes);
11193
+ if (parsedMcp === void 0) return `Plugin ${input.pluginId} .mcp.json must be a valid UTF-8 JSON object.`;
11194
+ if (Object.hasOwn(parsedMcp, "mcpServers")) {
11195
+ const mcpServers = Reflect.get(parsedMcp, "mcpServers");
11196
+ if (!isPlainRecord(mcpServers)) return `Plugin ${input.pluginId} .mcp.json mcpServers must be a JSON object.`;
11197
+ 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.`;
11198
+ }
11199
+ }
11200
+ for (const [label, bytes] of [[".claude-plugin/plugin.json", input.claudeManifestBytes], [".codex-plugin/plugin.json", input.codexManifestBytes]]) {
11201
+ if (bytes === void 0) continue;
11202
+ const parsed = parseUtf8JsonRecord(bytes);
11203
+ if (parsed === void 0) return `Plugin ${input.pluginId} ${label} must be a valid UTF-8 JSON object.`;
11204
+ if (!Object.hasOwn(parsed, "mcpServers")) continue;
11205
+ const rawMcpServers = Reflect.get(parsed, "mcpServers");
11206
+ if (rawMcpServers === void 0) continue;
11207
+ if (isPlainRecord(rawMcpServers)) {
11208
+ 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}.`;
11209
+ continue;
11210
+ }
11211
+ const paths = typeof rawMcpServers === "string" ? [rawMcpServers] : Array.isArray(rawMcpServers) && rawMcpServers.every((item) => typeof item === "string") ? rawMcpServers : null;
11212
+ 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.`;
11213
+ }
11214
+ }
11215
+ function parseUtf8JsonRecord(bytes) {
11216
+ let candidate;
11217
+ try {
11218
+ candidate = JSON.parse(utf8Decoder.decode(bytes));
11219
+ } catch {
11220
+ return;
11221
+ }
11222
+ return isPlainRecord(candidate) ? candidate : void 0;
11223
+ }
11224
+ function isPlainRecord(value) {
11225
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9832
11226
  }
9833
11227
  function collectOwnedName(owners, name, pluginId, issues) {
9834
11228
  const existing = owners.get(name);
@@ -9847,7 +11241,68 @@ function sameMarketplaceSource(left, right) {
9847
11241
  function sameMembers(left, right) {
9848
11242
  return left.length === right.length && left.every((member, index) => {
9849
11243
  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);
11244
+ 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)) && member.antigravityProjectionError === other.antigravityProjectionError && sameOmittedMcpServers(member.antigravityOmittedMcpServers, other.antigravityOmittedMcpServers);
11245
+ });
11246
+ }
11247
+ function deriveAntigravityBundleFacts(entries, repositoryUrl) {
11248
+ const projected = projectAntigravityPluginBundle({
11249
+ entries: entries.map((entry) => ({
11250
+ path: entry.path,
11251
+ mode: entry.mode,
11252
+ bytes: payloadEntryBytes(entry)
11253
+ })),
11254
+ repositoryUrl
11255
+ });
11256
+ if (!projected.ok) return Object.freeze({
11257
+ manifest: null,
11258
+ projectionError: boundedDetail(projected.detail),
11259
+ omittedMcpServers: Object.freeze([])
11260
+ });
11261
+ if (projected.entries.length === 0 || projected.entries.length > 16384) return Object.freeze({
11262
+ manifest: null,
11263
+ omittedMcpServers: Object.freeze([])
11264
+ });
11265
+ const files = [];
11266
+ for (const entry of projected.entries) {
11267
+ const parsedPath = parseReleaseRelativePath$1(entry.path);
11268
+ if (!parsedPath.ok) return Object.freeze({
11269
+ manifest: null,
11270
+ omittedMcpServers: Object.freeze([])
11271
+ });
11272
+ files.push(Object.freeze({
11273
+ path: parsedPath.value,
11274
+ mode: entry.mode,
11275
+ byteLength: entry.bytes.byteLength,
11276
+ contentDigest: contentDigest(entry.bytes)
11277
+ }));
11278
+ }
11279
+ files.sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
11280
+ if (!isCanonicalDistinctOrder(files.map((file) => file.path))) return Object.freeze({
11281
+ manifest: null,
11282
+ omittedMcpServers: Object.freeze([])
11283
+ });
11284
+ const normalizedOmitted = projected.omittedMcpServers.map((item) => Object.freeze({
11285
+ name: boundOmittedMcpServerName(item.name),
11286
+ reason: item.reason
11287
+ })).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
11288
+ const distinctOmitted = [];
11289
+ const seenOmittedNames = /* @__PURE__ */ new Set();
11290
+ for (const item of normalizedOmitted) {
11291
+ if (seenOmittedNames.has(item.name)) continue;
11292
+ seenOmittedNames.add(item.name);
11293
+ distinctOmitted.push(item);
11294
+ if (distinctOmitted.length >= 16384) break;
11295
+ }
11296
+ const omittedMcpServers = Object.freeze(distinctOmitted);
11297
+ return Object.freeze({
11298
+ manifest: Object.freeze(files),
11299
+ omittedMcpServers
11300
+ });
11301
+ }
11302
+ function sameOmittedMcpServers(left, right) {
11303
+ return left.length === right.length && left.every((entry, index) => {
11304
+ const other = right[index];
11305
+ return other !== void 0 && entry.name === other.name && entry.reason === other.reason;
9851
11306
  });
9852
11307
  }
9853
11308
  function sameSelectedContentManifest(left, right) {
@@ -9859,6 +11314,15 @@ function sameSelectedContentManifest(left, right) {
9859
11314
  function sameTextArray(left, right) {
9860
11315
  return left.length === right.length && left.every((value, index) => value === right[index]);
9861
11316
  }
11317
+ function sameHostMcpServers(left, right) {
11318
+ return left.length === right.length && left.every((server, index) => {
11319
+ const other = right[index];
11320
+ return other !== void 0 && server.name === other.name && server.url === other.url && server.ownerPluginId === other.ownerPluginId;
11321
+ });
11322
+ }
11323
+ function compareText$8(left, right) {
11324
+ return left < right ? -1 : left > right ? 1 : 0;
11325
+ }
9862
11326
  function isCanonicalDistinctOrder(values) {
9863
11327
  for (let index = 1; index < values.length; index += 1) if (values[index - 1] >= values[index]) return false;
9864
11328
  return true;
@@ -9891,10 +11355,14 @@ function marketplaceSourceIsRelated(observed, desired) {
9891
11355
  }
9892
11356
  /** Selects the bounded payload manifest required for native file verification. */
9893
11357
  function verificationFiles(member, provider) {
11358
+ if (provider === "antigravity") {
11359
+ if (member.antigravityManifest === null || member.antigravityManifest.length > MAX_PROVIDER_VERIFICATION_FILES) return null;
11360
+ return Object.freeze([...member.antigravityManifest].sort((left, right) => compareText$7(left.path, right.path)));
11361
+ }
9894
11362
  const manifestPath = provider === "codex" ? ".codex-plugin/plugin.json" : ".claude-plugin/plugin.json";
9895
11363
  if (!member.manifest.some((file) => file.path === manifestPath)) return null;
9896
11364
  if (member.manifest.length > MAX_PROVIDER_VERIFICATION_FILES) return null;
9897
- return Object.freeze([...member.manifest].sort((left, right) => compareText$6(left.path, right.path)));
11365
+ return Object.freeze([...member.manifest].sort((left, right) => compareText$7(left.path, right.path)));
9898
11366
  }
9899
11367
  /**
9900
11368
  * Plans the exact native file batches required to assess installed selected members.
@@ -10007,14 +11475,35 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
10007
11475
  } else pushFact(facts, "marketplace-source", identity, "Marketplace source matches the selection.");
10008
11476
  const desiredNames = new Set(content.members.flatMap((member) => [member.pluginId, ...member.aliases]));
10009
11477
  for (const live of inventory.plugins) {
10010
- if (live.marketplaceIdentity === identity || !desiredNames.has(live.name)) continue;
11478
+ const normalizedLiveName = target.provider === "antigravity" ? live.name.toLowerCase() : live.name;
11479
+ if (live.marketplaceIdentity === identity || !desiredNames.has(normalizedLiveName)) continue;
10011
11480
  collision = true;
10012
- issues.push(providerIssue("PluginCollision", `Plugin name ${live.name} is associated with marketplace ${live.marketplaceIdentity}.`, content.members.find((member) => member.pluginId === live.name || member.aliases.some((alias) => alias === live.name))?.pluginId));
11481
+ 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
11482
  }
10014
11483
  const members = [];
10015
11484
  for (const member of content.members) {
10016
11485
  const selector = providerPluginSelector(member, identity);
11486
+ if (target.provider === "antigravity") for (const omitted of member.antigravityOmittedMcpServers) pushRecordFact(facts, Object.freeze({
11487
+ kind: "mcp-omitted",
11488
+ pluginId: member.pluginId,
11489
+ name: omitted.name,
11490
+ reason: omitted.reason,
11491
+ subject: `${selector}:${omitted.name}`,
11492
+ detail: `Omitted MCP server ${omitted.name} from Antigravity projection (${omitted.reason}).`
11493
+ }));
10017
11494
  const live = inventory.plugins.find((plugin) => plugin.selector === selector && plugin.marketplaceIdentity === identity);
11495
+ if (target.provider === "antigravity" && member.antigravityProjectionError !== void 0) {
11496
+ failed = true;
11497
+ issues.push(providerIssue("DesiredContentInvalid", member.antigravityProjectionError, member.pluginId));
11498
+ members.push({
11499
+ member,
11500
+ selector,
11501
+ installed: live?.installed ?? false,
11502
+ enabled: live?.enabled ?? null,
11503
+ filesMatch: false
11504
+ });
11505
+ continue;
11506
+ }
10018
11507
  if (live === void 0 || !live.installed) {
10019
11508
  needsMutation = true;
10020
11509
  issues.push(providerIssue("PluginMissing", `Plugin ${selector} is not installed.`, member.pluginId));
@@ -10029,9 +11518,9 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
10029
11518
  }
10030
11519
  pushFact(facts, "plugin-installed", selector, "Plugin is installed from the selected marketplace.");
10031
11520
  const enabled = live.enabled;
10032
- if (enabled === false || target.provider === "claude" && enabled === null) {
11521
+ if (enabled === false || (target.provider === "claude" || target.provider === "antigravity") && enabled === null) {
10033
11522
  needsMutation = true;
10034
- issues.push(providerIssue("PluginDisabled", enabled === null ? `Claude did not report enabled state for ${selector}.` : `Plugin ${selector} is disabled.`, member.pluginId));
11523
+ 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
11524
  } else if (enabled === true) pushFact(facts, "plugin-enabled", selector, "Plugin is enabled for the provider.");
10036
11525
  if (verificationFiles(member, target.provider) === null) {
10037
11526
  failed = true;
@@ -10059,7 +11548,7 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
10059
11548
  });
10060
11549
  continue;
10061
11550
  }
10062
- for (const fact of verified.facts) pushFact(facts, fact.kind, fact.subject, fact.detail);
11551
+ for (const fact of verified.facts) pushRecordFact(facts, fact);
10063
11552
  if (verified.failed) failed = true;
10064
11553
  if (!verified.matches) {
10065
11554
  needsMutation = true;
@@ -10079,17 +11568,145 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
10079
11568
  issues.push(providerIssue("MarketplaceDrift", `Marketplace ${identity} must be refreshed before selected bytes can be repaired.`));
10080
11569
  }
10081
11570
  const candidateOmitted = candidateOmittedSelectors(content, inventory);
11571
+ const ownershipIssue = policy.retireOmitted ? codexOmittedPluginOwnershipIssue(content, inventory, candidateOmitted) : void 0;
11572
+ if (ownershipIssue !== void 0) {
11573
+ collision = true;
11574
+ issues.push(ownershipIssue);
11575
+ }
10082
11576
  const omittedSelectors = Object.freeze(marketplaceMatches.length === 1 && marketplaceExact ? candidateOmitted : []);
10083
- if (policy.retireOmitted && omittedSelectors.length > 0) {
11577
+ if (policy.retireOmitted && ownershipIssue === void 0 && omittedSelectors.length > 0) {
10084
11578
  needsMutation = true;
10085
11579
  for (const selector of omittedSelectors) issues.push(providerIssue("OmittedPluginPresent", `Managed plugin ${selector} is absent from the selected complete set.`));
10086
11580
  }
11581
+ const mcpServers = [];
11582
+ const selectedStaleNames = [];
11583
+ const omittedStaleNames = [];
11584
+ const ledgerByName = new Map(inventory.managedMcpServers.map((record) => [record.name, record]));
11585
+ for (const desired of content.hostMcpServers) {
11586
+ const liveMcp = inventory.mcpServers.find((entry) => entry.name === desired.name);
11587
+ const ledgerEntry = ledgerByName.get(desired.name);
11588
+ const isManaged = ledgerEntry !== void 0 && liveMcp !== void 0 && liveMcp.transport === "http" && liveMcp.url === ledgerEntry.url;
11589
+ if (liveMcp === void 0) {
11590
+ needsMutation = true;
11591
+ issues.push(providerIssue("McpServerMissing", `Host MCP server ${desired.name} is not configured.`, desired.ownerPluginId));
11592
+ mcpServers.push(Object.freeze({
11593
+ server: desired,
11594
+ present: false,
11595
+ exact: false,
11596
+ replace: false
11597
+ }));
11598
+ continue;
11599
+ }
11600
+ if (liveMcp.transport !== "http" || liveMcp.url === null || parseCanonicalLoopbackHttpUrl(liveMcp.url) === void 0) {
11601
+ collision = true;
11602
+ issues.push(providerIssue("McpServerCollision", `MCP server ${desired.name} uses a non-loopback or non-HTTP configuration.`, desired.ownerPluginId));
11603
+ mcpServers.push(Object.freeze({
11604
+ server: desired,
11605
+ present: true,
11606
+ exact: false,
11607
+ replace: false
11608
+ }));
11609
+ continue;
11610
+ }
11611
+ if (liveMcp.url !== desired.url) {
11612
+ if (!isManaged) {
11613
+ collision = true;
11614
+ issues.push(providerIssue("McpServerCollision", `MCP server ${desired.name} is configured with unmanaged URL ${liveMcp.url}.`, desired.ownerPluginId));
11615
+ mcpServers.push(Object.freeze({
11616
+ server: desired,
11617
+ present: true,
11618
+ exact: false,
11619
+ replace: false
11620
+ }));
11621
+ } else {
11622
+ needsMutation = true;
11623
+ issues.push(providerIssue("McpServerDrift", `Host MCP server ${desired.name} points to ${liveMcp.url} instead of ${desired.url}.`, desired.ownerPluginId));
11624
+ mcpServers.push(Object.freeze({
11625
+ server: desired,
11626
+ present: true,
11627
+ exact: false,
11628
+ replace: true
11629
+ }));
11630
+ }
11631
+ continue;
11632
+ }
11633
+ if (liveMcp.enabled === false) {
11634
+ if (!isManaged) {
11635
+ collision = true;
11636
+ issues.push(providerIssue("McpServerCollision", `MCP server ${desired.name} is disabled by unmanaged configuration.`, desired.ownerPluginId));
11637
+ mcpServers.push(Object.freeze({
11638
+ server: desired,
11639
+ present: true,
11640
+ exact: false,
11641
+ replace: false
11642
+ }));
11643
+ } else {
11644
+ needsMutation = true;
11645
+ issues.push(providerIssue("McpServerDisabled", `Host MCP server ${desired.name} is disabled.`, desired.ownerPluginId));
11646
+ mcpServers.push(Object.freeze({
11647
+ server: desired,
11648
+ present: true,
11649
+ exact: false,
11650
+ replace: true
11651
+ }));
11652
+ }
11653
+ continue;
11654
+ }
11655
+ if (isManaged && ledgerEntry.ownerPluginId !== desired.ownerPluginId) {
11656
+ needsMutation = true;
11657
+ issues.push(providerIssue("McpServerDrift", `Host MCP server ${desired.name} ownership moved from ${ledgerEntry.ownerPluginId} to ${desired.ownerPluginId}.`, desired.ownerPluginId));
11658
+ mcpServers.push(Object.freeze({
11659
+ server: desired,
11660
+ present: true,
11661
+ exact: false,
11662
+ replace: true
11663
+ }));
11664
+ continue;
11665
+ }
11666
+ pushFact(facts, "mcp-configured", desired.name, desired.url);
11667
+ mcpServers.push(Object.freeze({
11668
+ server: desired,
11669
+ present: true,
11670
+ exact: true,
11671
+ replace: false
11672
+ }));
11673
+ }
11674
+ const desiredMcpNames = new Set(content.hostMcpServers.map((server) => server.name));
11675
+ const selectedPluginIds = new Set(content.members.map((member) => member.pluginId));
11676
+ for (const record of inventory.managedMcpServers) {
11677
+ if (desiredMcpNames.has(record.name) || !selectedPluginIds.has(record.ownerPluginId)) continue;
11678
+ const ownerMember = content.members.find((member) => member.pluginId === record.ownerPluginId);
11679
+ const liveMcp = inventory.mcpServers.find((entry) => entry.name === record.name);
11680
+ if (liveMcp !== void 0 && (liveMcp.transport !== "http" || liveMcp.url !== record.url)) {
11681
+ collision = true;
11682
+ issues.push(providerIssue("McpServerCollision", `MCP server ${record.name} was modified outside Habitat and cannot be retired.`, ownerMember?.pluginId));
11683
+ continue;
11684
+ }
11685
+ needsMutation = true;
11686
+ selectedStaleNames.push(record.name);
11687
+ issues.push(providerIssue("OmittedMcpServerPresent", `Managed host MCP server ${record.name} is no longer declared by selected plugin ${record.ownerPluginId}.`, ownerMember?.pluginId));
11688
+ }
11689
+ if (policy.retireOmitted) for (const record of inventory.managedMcpServers) {
11690
+ if (desiredMcpNames.has(record.name) || selectedPluginIds.has(record.ownerPluginId)) continue;
11691
+ const liveMcp = inventory.mcpServers.find((entry) => entry.name === record.name);
11692
+ if (liveMcp !== void 0 && (liveMcp.transport !== "http" || liveMcp.url !== record.url)) {
11693
+ collision = true;
11694
+ issues.push(providerIssue("McpServerCollision", `MCP server ${record.name} was modified outside Habitat and cannot be retired.`));
11695
+ continue;
11696
+ }
11697
+ needsMutation = true;
11698
+ omittedStaleNames.push(record.name);
11699
+ issues.push(providerIssue("OmittedMcpServerPresent", `Managed host MCP server ${record.name} belongs to an omitted plugin.`));
11700
+ }
11701
+ const selectedStaleMcpServers = Object.freeze(selectedStaleNames.sort(compareText$7));
11702
+ const candidateOmittedMcpServers = Object.freeze(omittedStaleNames.sort(compareText$7));
11703
+ const staleMcpRemovals = [...selectedStaleMcpServers, ...candidateOmittedMcpServers];
10087
11704
  if (mutationIntent && !collision && !failed && needsMutation) {
10088
- if (maximumPlannedOperations(target, marketplace !== void 0, marketplaceRefreshRequired, members, policy.retireOmitted ? candidateOmitted : []) > MAX_OPERATIONS_PER_TARGET) {
11705
+ if (maximumPlannedOperations(target, marketplace !== void 0, marketplaceRefreshRequired, members, mcpServers, policy.retireOmitted ? candidateOmitted : [], staleMcpRemovals) > MAX_OPERATIONS_PER_TARGET) {
10089
11706
  failed = true;
10090
11707
  issues.push(providerIssue("DesiredContentInvalid", "Selected native changes exceed the per-target operation bound."));
10091
11708
  }
10092
- const missing = missingMutationCapabilities(target, capabilities, marketplace !== void 0, marketplaceRefreshRequired, members, policy.retireOmitted ? candidateOmitted : []);
11709
+ const missing = missingMutationCapabilities(target, capabilities, marketplace !== void 0, marketplaceRefreshRequired, members, mcpServers, policy.retireOmitted ? candidateOmitted : [], staleMcpRemovals);
10093
11710
  if (missing.length > 0) {
10094
11711
  failed = true;
10095
11712
  issues.push(providerIssue("CapabilityMissing", `Native provider lacks required commands: ${missing.join(", ")}.`));
@@ -10104,6 +11721,9 @@ function assessNativeTarget(content, target, capabilities, inventory, fileAssess
10104
11721
  marketplaceExact,
10105
11722
  marketplaceRefreshRequired,
10106
11723
  members: Object.freeze(members),
11724
+ mcpServers: Object.freeze(mcpServers),
11725
+ selectedStaleMcpServers,
11726
+ omittedMcpServers: candidateOmittedMcpServers,
10107
11727
  facts: Object.freeze(facts),
10108
11728
  issues: Object.freeze(issues.slice(0, 256)),
10109
11729
  collision,
@@ -10120,6 +11740,9 @@ function unavailableNativeTarget(target, detail) {
10120
11740
  marketplacePresent: false,
10121
11741
  marketplaceRefreshRequired: false,
10122
11742
  members: Object.freeze([]),
11743
+ mcpServers: Object.freeze([]),
11744
+ selectedStaleMcpServers: Object.freeze([]),
11745
+ omittedMcpServers: Object.freeze([]),
10123
11746
  facts: Object.freeze([]),
10124
11747
  issues: Object.freeze([providerIssue("TargetUnavailable", detail)]),
10125
11748
  collision: false,
@@ -10199,48 +11822,79 @@ function hasOneExactMarketplace(inventory, content) {
10199
11822
  const marketplace = matches.at(0);
10200
11823
  return matches.length === 1 && marketplace !== void 0 && marketplaceSourceMatches(marketplace, content.marketplace.source);
10201
11824
  }
11825
+ /** Requires Codex to have reported each omitted selector under the related marketplace before refresh. */
11826
+ function codexOmittedPluginOwnershipIssue(content, openingInventory, selectors) {
11827
+ if (openingInventory.provider !== "codex" || selectors.length === 0) return void 0;
11828
+ const identity = content.marketplace.identity;
11829
+ const marketplaces = openingInventory.marketplaces.filter((entry) => entry.identity === identity);
11830
+ const marketplace = marketplaces[0];
11831
+ const catalogSelectors = new Set(openingInventory.plugins.filter((entry) => entry.marketplaceIdentity === identity && entry.installed).map((entry) => entry.selector));
11832
+ const unproven = marketplaces.length !== 1 || marketplace === void 0 || !marketplaceSourceIsRelated(marketplace, content.marketplace.source) ? selectors[0] : selectors.find((selector) => !catalogSelectors.has(selector));
11833
+ return unproven === void 0 ? void 0 : providerIssue("PluginCollision", `Cannot verify that Codex plugin ${unproven} belongs to the managed marketplace before refresh.`);
11834
+ }
11835
+ /**
11836
+ * Requires the last observation before a Codex marketplace refresh to prove each
11837
+ * omitted selector seen either at preflight or at the refresh guard.
11838
+ */
11839
+ function codexMarketplaceRefreshOmittedPluginIssue(content, preflight, beforeRefresh) {
11840
+ if (beforeRefresh.provider !== "codex") return void 0;
11841
+ return codexOmittedPluginOwnershipIssue(content, beforeRefresh, [...candidateOmittedSelectors(content, preflight), ...candidateOmittedSelectors(content, beforeRefresh)]);
11842
+ }
10202
11843
  /** Selects omitted managed plugins only when marketplace provenance is exact. */
10203
11844
  function exactManagedOmittedSelectors(content, inventory) {
10204
11845
  return hasOneExactMarketplace(inventory, content) ? candidateOmittedSelectors(content, inventory) : null;
10205
11846
  }
10206
11847
  function candidateOmittedSelectors(content, inventory) {
10207
- 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$6));
11848
+ const identity = content.marketplace.identity;
11849
+ const desiredSelectors = new Set(content.members.map((member) => providerPluginSelector(member, identity)));
11850
+ const observedSelectors = inventory.plugins.filter((plugin) => plugin.marketplaceIdentity === identity).map((plugin) => plugin.selector);
11851
+ const configuredSelectors = inventory.pluginConfig?.marketplaceIdentity === identity ? inventory.pluginConfig.selectors : [];
11852
+ return Object.freeze([.../* @__PURE__ */ new Set([...observedSelectors, ...configuredSelectors])].filter((selector) => !desiredSelectors.has(selector)).sort(compareText$7));
10209
11853
  }
10210
11854
  function marketplaceRevisionIsUnobservable(observed, desired) {
10211
11855
  return desired.kind === "git" && observed?.source?.kind === "git" && observed.source.repositoryUrl === desired.repositoryUrl && observed.source.revision === null;
10212
11856
  }
10213
- function missingMutationCapabilities(target, capabilities, marketplacePresent, marketplaceRefreshRequired, members, omittedSelectors) {
11857
+ function missingMutationCapabilities(target, capabilities, marketplacePresent, marketplaceRefreshRequired, members, mcpServers, omittedSelectors, omittedMcpServers) {
10214
11858
  const required = /* @__PURE__ */ new Set();
10215
11859
  if (marketplaceRefreshRequired) required.add("marketplace-add");
10216
11860
  if (marketplacePresent && marketplaceRefreshRequired) required.add("marketplace-remove");
10217
11861
  for (const member of members) {
10218
11862
  if (!member.installed || !member.filesMatch || marketplaceRefreshRequired) required.add("plugin-install");
10219
11863
  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");
11864
+ if ((target.provider === "claude" || target.provider === "antigravity") && (member.enabled !== true || !member.installed) || target.provider === "codex" && member.enabled === false) required.add("plugin-enable");
11865
+ }
11866
+ for (const mcp of mcpServers) {
11867
+ if (!mcp.exact) required.add("mcp-add");
11868
+ if (mcp.replace) required.add("mcp-remove");
10221
11869
  }
10222
11870
  if (omittedSelectors.length > 0) required.add("plugin-remove");
11871
+ if (omittedMcpServers.length > 0) required.add("mcp-remove");
10223
11872
  const observed = new Set(capabilities.capabilities);
10224
- return Object.freeze([...required].filter((capability) => !observed.has(capability)).sort(compareText$6));
11873
+ return Object.freeze([...required].filter((capability) => !observed.has(capability)).sort(compareText$7));
10225
11874
  }
10226
- function maximumPlannedOperations(target, marketplacePresent, marketplaceRefreshRequired, members, omittedSelectors) {
11875
+ function maximumPlannedOperations(target, marketplacePresent, marketplaceRefreshRequired, members, mcpServers, omittedSelectors, omittedMcpServers) {
10227
11876
  let operations = marketplaceRefreshRequired ? marketplacePresent ? 2 : 1 : 0;
10228
11877
  for (const member of members) {
10229
11878
  if (!member.installed) operations += 1;
10230
11879
  else if (!member.filesMatch || marketplaceRefreshRequired) operations += 2;
10231
- if (target.provider === "claude" && (member.enabled !== true || !member.installed)) operations += 1;
11880
+ if ((target.provider === "claude" || target.provider === "antigravity") && (member.enabled !== true || !member.installed)) operations += 1;
10232
11881
  }
10233
- return operations + omittedSelectors.length;
11882
+ for (const mcp of mcpServers) if (mcp.replace) operations += 2;
11883
+ else if (!mcp.exact) operations += 1;
11884
+ return operations + omittedSelectors.length + omittedMcpServers.length;
10234
11885
  }
10235
11886
  function pushFact(facts, kind, subject, detail) {
10236
- if (facts.length >= 4096) return;
10237
- facts.push(Object.freeze({
11887
+ pushRecordFact(facts, Object.freeze({
10238
11888
  kind,
10239
11889
  subject,
10240
11890
  detail
10241
11891
  }));
10242
11892
  }
10243
- function compareText$6(left, right) {
11893
+ function pushRecordFact(facts, fact) {
11894
+ if (facts.length >= 4096) return;
11895
+ facts.push(fact);
11896
+ }
11897
+ function compareText$7(left, right) {
10244
11898
  return left < right ? -1 : left > right ? 1 : 0;
10245
11899
  }
10246
11900
  //#endregion
@@ -10309,14 +11963,14 @@ function canonicalProviderTargets(targets) {
10309
11963
  provider: target.provider,
10310
11964
  home: target.home
10311
11965
  })).sort((left, right) => {
10312
- const provider = compareText$5(left.provider, right.provider);
10313
- return provider === 0 ? compareText$5(left.home, right.home) : provider;
11966
+ const provider = compareText$6(left.provider, right.provider);
11967
+ return provider === 0 ? compareText$6(left.home, right.home) : provider;
10314
11968
  });
10315
11969
  const first = sorted[0];
10316
11970
  if (first === void 0) throw new Error("Provider targets must be nonempty");
10317
11971
  return Object.freeze([first, ...sorted.slice(1)]);
10318
11972
  }
10319
- function compareText$5(left, right) {
11973
+ function compareText$6(left, right) {
10320
11974
  return left < right ? -1 : left > right ? 1 : 0;
10321
11975
  }
10322
11976
  function hasPossibleConfirmedOperationHistory(result) {
@@ -10421,8 +12075,8 @@ function validateClaudeMembers(manifest, expectedMembers) {
10421
12075
  }
10422
12076
  function validateExactMembers(actualMembers, expectedMembers, provider) {
10423
12077
  if (new Set(actualMembers).size !== actualMembers.length) return invalid(`${provider} marketplace contains duplicate plugin identities.`);
10424
- const actual = [...actualMembers].sort(compareText$4);
10425
- const expected = [...expectedMembers].sort(compareText$4);
12078
+ const actual = [...actualMembers].sort(compareText$5);
12079
+ const expected = [...expectedMembers].sort(compareText$5);
10426
12080
  if (actual.length !== expected.length || actual.some((pluginId, index) => pluginId !== expected[index])) return invalid(`${provider} marketplace plugin set differs from the release input.`);
10427
12081
  return Object.freeze({ ok: true });
10428
12082
  }
@@ -10435,7 +12089,7 @@ function invalid(detail) {
10435
12089
  detail
10436
12090
  });
10437
12091
  }
10438
- function compareText$4(left, right) {
12092
+ function compareText$5(left, right) {
10439
12093
  return left < right ? -1 : left > right ? 1 : 0;
10440
12094
  }
10441
12095
  //#endregion
@@ -10790,16 +12444,20 @@ const status$1 = module$5.status.effect(function* ({ context, errors, input }) {
10790
12444
  * sequentially after TypeBox admits the provider observation.
10791
12445
  */
10792
12446
  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));
12447
+ 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
12448
  const acquisition = yield* Effect.result(acquire);
10795
12449
  if (Result.isFailure(acquisition)) return unavailableNativeTarget(target, `Native provider acquisition failed: ${acquisition.failure.detail}`);
10796
12450
  const session = acquisition.success;
10797
12451
  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 });
12452
+ const observation = Effect.all([session.probe(), session.inventory({
12453
+ observeMcpServers: content.hostMcpServers.length > 0,
12454
+ ...target.provider === "codex" ? { observePluginConfigForMarketplace: content.marketplace.identity } : {}
12455
+ })], { concurrency: 2 });
10799
12456
  const observed = yield* Effect.result(observation);
10800
12457
  if (Result.isFailure(observed)) return unavailableNativeTarget(target, `Native provider inspection failed: ${observed.failure.detail}`);
10801
12458
  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.");
12459
+ if (target.provider === "codex" && inventory?.pluginConfig?.marketplaceIdentity !== content.marketplace.identity) return unavailableNativeTarget(target, "Codex did not report user-config plugin selectors for the selected marketplace.");
12460
+ 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
12461
  const fileAssessments = [];
10804
12462
  for (const plan of planNativePluginFileReads(content, target, inventory)) {
10805
12463
  const attempt = yield* Effect.result(session.readPluginFiles({
@@ -11166,10 +12824,10 @@ function planNativeTargetMutation(content, assessment, policy) {
11166
12824
  kind: "plugin-installed",
11167
12825
  selector: member.selector
11168
12826
  }, "IfMissing"));
11169
- if (assessment.target.provider === "claude" && (member.enabled !== true || !member.installed || replace)) steps.push(commandPlan({
12827
+ if ((assessment.target.provider === "claude" || assessment.target.provider === "antigravity") && (member.enabled !== true || !member.installed || replace)) steps.push(commandPlan({
11170
12828
  kind: "plugin-enabled",
11171
12829
  selector: member.selector
11172
- }, "IfClaudeNotEnabled"));
12830
+ }, "IfPluginNotEnabled"));
11173
12831
  const files = verificationFiles(member.member, assessment.target.provider);
11174
12832
  if (files !== null) steps.push(Object.freeze({
11175
12833
  kind: "VerifyMember",
@@ -11180,16 +12838,44 @@ function planNativeTargetMutation(content, assessment, policy) {
11180
12838
  })
11181
12839
  }));
11182
12840
  }
12841
+ for (const mcp of assessment.mcpServers) {
12842
+ if (mcp.replace) steps.push(commandPlan({
12843
+ kind: "mcp-removed",
12844
+ name: mcp.server.name
12845
+ }, "IfMcpOrLedgerPresent"));
12846
+ if (!mcp.exact) steps.push(commandPlan({
12847
+ kind: "mcp-added",
12848
+ name: mcp.server.name,
12849
+ url: mcp.server.url
12850
+ }, "IfMcpNotExact"));
12851
+ }
12852
+ for (const staleName of assessment.selectedStaleMcpServers) steps.push(commandPlan({
12853
+ kind: "mcp-removed",
12854
+ name: staleName
12855
+ }, "IfMcpOrLedgerPresent"));
11183
12856
  if (policy.retireOmitted) steps.push(Object.freeze({ kind: "RetireOmitted" }));
11184
12857
  return Object.freeze(steps);
11185
12858
  }
11186
12859
  /** Determines whether the current inventory still requires one planned command. */
11187
- function nativeCommandIsRequired(plan, inventory) {
12860
+ function nativeCommandIsRequired(content, plan, inventory) {
12861
+ const { operation } = plan;
11188
12862
  switch (plan.condition) {
11189
12863
  case "Always": return true;
11190
- case "IfInstalled": return plan.operation.kind === "plugin-removed" && installedPlugin(inventory, plan.operation.selector) !== void 0;
11191
- case "IfMissing": return plan.operation.kind === "plugin-installed" && installedPlugin(inventory, plan.operation.selector) === void 0;
11192
- case "IfClaudeNotEnabled": return plan.operation.kind === "plugin-enabled" && installedPlugin(inventory, plan.operation.selector)?.enabled !== true;
12864
+ case "IfInstalled": return operation.kind === "plugin-removed" && installedPlugin(inventory, operation.selector) !== void 0;
12865
+ case "IfMissing": return operation.kind === "plugin-installed" && installedPlugin(inventory, operation.selector) === void 0;
12866
+ case "IfPluginNotEnabled": return operation.kind === "plugin-enabled" && installedPlugin(inventory, operation.selector)?.enabled !== true;
12867
+ case "IfMcpOrLedgerPresent": {
12868
+ if (operation.kind !== "mcp-removed") return false;
12869
+ const ledger = inventory.managedMcpServers.find((entry) => entry.name === operation.name);
12870
+ if (ledger === void 0) return false;
12871
+ const live = inventory.mcpServers.find((entry) => entry.name === operation.name);
12872
+ return live === void 0 || live.transport === "http" && live.url === ledger.url;
12873
+ }
12874
+ case "IfMcpNotExact": {
12875
+ if (operation.kind !== "mcp-added") return false;
12876
+ const desired = content.hostMcpServers.find((entry) => entry.name === operation.name);
12877
+ return desired !== void 0 && !hasExactManagedMcpServer(inventory, desired.name, desired.url, desired.ownerPluginId);
12878
+ }
11193
12879
  }
11194
12880
  }
11195
12881
  /** Admits removal only while the marketplace still belongs to the selected source family. */
@@ -11202,24 +12888,80 @@ function marketplaceRemovalIssue(content, inventory) {
11202
12888
  * Selects the latest exact-provenance omitted members before canonical retirement.
11203
12889
  *
11204
12890
  * @param content - Exact selected complete-set content.
12891
+ * @param openingInventory - TypeBox-admitted inventory before any marketplace mutation.
11205
12892
  * @param inventory - Latest TypeBox-admitted provider inventory.
11206
12893
  * @param confirmedOperationCount - Confirmed prefix already applied to this target.
11207
12894
  */
11208
- function planOmittedRetirement(content, inventory, confirmedOperationCount) {
12895
+ function planOmittedRetirement(content, openingInventory, inventory, confirmedOperationCount) {
11209
12896
  const selectors = exactManagedOmittedSelectors(content, inventory);
11210
12897
  if (selectors === null) return Object.freeze({
11211
12898
  ok: false,
11212
- issue: providerIssue("MarketplaceCollision", "Managed plugin retirement requires one exact observed marketplace source.")
12899
+ issue: retirementMarketplaceIssue()
12900
+ });
12901
+ const ownershipIssue = codexOmittedPluginOwnershipIssue(content, openingInventory, selectors);
12902
+ if (ownershipIssue !== void 0) return Object.freeze({
12903
+ ok: false,
12904
+ issue: ownershipIssue
11213
12905
  });
11214
- if (confirmedOperationCount + selectors.length > MAX_CONFIRMED_NATIVE_OPERATIONS) return Object.freeze({
12906
+ const desiredMcpNames = new Set(content.hostMcpServers.map((server) => server.name));
12907
+ const retiredMcpNames = [];
12908
+ for (const record of inventory.managedMcpServers) {
12909
+ if (desiredMcpNames.has(record.name)) continue;
12910
+ const live = inventory.mcpServers.find((entry) => entry.name === record.name);
12911
+ if (live !== void 0 && (live.transport !== "http" || live.url !== record.url)) return Object.freeze({
12912
+ ok: false,
12913
+ issue: providerIssue("McpServerCollision", `MCP server ${record.name} was modified outside Habitat and cannot be retired.`)
12914
+ });
12915
+ retiredMcpNames.push(record.name);
12916
+ }
12917
+ const mcpNames = Object.freeze([...new Set(retiredMcpNames)].sort(compareText$4));
12918
+ if (confirmedOperationCount + mcpNames.length + selectors.length > MAX_CONFIRMED_NATIVE_OPERATIONS) return Object.freeze({
11215
12919
  ok: false,
11216
12920
  issue: providerIssue("DesiredContentInvalid", "Selected native changes exceed the per-target operation bound.")
11217
12921
  });
11218
12922
  return Object.freeze({
11219
12923
  ok: true,
12924
+ mcpNames,
11220
12925
  selectors
11221
12926
  });
11222
12927
  }
12928
+ /** Identifies installed selectors whose configuration survives a confirmed marketplace removal. */
12929
+ function codexMarketplaceRefreshCandidates(beforeRemoval, afterRemoval) {
12930
+ const configuredBefore = new Set(beforeRemoval.pluginConfig?.selectors);
12931
+ const configuredAfter = new Set(afterRemoval.pluginConfig?.selectors);
12932
+ return new Set(beforeRemoval.plugins.filter((plugin) => plugin.installed && plugin.marketplaceIdentity === beforeRemoval.pluginConfig?.marketplaceIdentity && configuredBefore.has(plugin.selector) && configuredAfter.has(plugin.selector)).map((plugin) => plugin.selector));
12933
+ }
12934
+ /** Retains only selectors that remain configured and catalog-hidden after refresh. */
12935
+ function retainCodexRefreshProof(candidates, inventory) {
12936
+ if (candidates === void 0 || candidates.size === 0) return candidates;
12937
+ const catalog = new Set(inventory.plugins.map((plugin) => plugin.selector));
12938
+ return new Set(inventory.pluginConfig?.selectors.filter((selector) => candidates.has(selector) && !catalog.has(selector)));
12939
+ }
12940
+ /** Requires a current installed row or a proven config-only transition from this sync's refresh. */
12941
+ function revalidateCodexOmittedPluginRemoval(content, inventory, selector, refreshProof) {
12942
+ if (!hasOneExactMarketplace(inventory, content)) return Object.freeze({
12943
+ ok: false,
12944
+ issue: retirementMarketplaceIssue()
12945
+ });
12946
+ const plugin = observedPlugin(inventory, selector);
12947
+ const configured = inventory.pluginConfig?.selectors.includes(selector) === true;
12948
+ if (plugin === void 0 && !configured) return Object.freeze({
12949
+ ok: true,
12950
+ present: false
12951
+ });
12952
+ if (plugin?.installed === true && plugin.marketplaceIdentity === content.marketplace.identity || plugin === void 0 && configured && refreshProof?.has(selector)) return Object.freeze({
12953
+ ok: true,
12954
+ present: true
12955
+ });
12956
+ return Object.freeze({
12957
+ ok: false,
12958
+ issue: providerIssue("PluginCollision", `Cannot verify current ownership of omitted Codex plugin ${selector} before removal.`)
12959
+ });
12960
+ }
12961
+ /** Explains why a native marketplace cannot authorize a retirement. */
12962
+ function retirementMarketplaceIssue() {
12963
+ return providerIssue("MarketplaceCollision", "Managed plugin retirement requires one exact observed marketplace source.");
12964
+ }
11223
12965
  /**
11224
12966
  * Classifies one command and its immediate native re-observation.
11225
12967
  *
@@ -11347,6 +13089,18 @@ function notAttemptedAfterMutation(assessments) {
11347
13089
  function finalNativeAssessmentIssue(assessment) {
11348
13090
  return assessment.failed || assessment.collision || assessment.needsMutation ? providerIssue("VerificationFailed", "Final native provider verification did not converge.") : void 0;
11349
13091
  }
13092
+ /** Emits `mcp-absent` facts for stale host MCP servers retired and verified absent. */
13093
+ function retiredOmittedMcpFacts(content, operations, finalInventory) {
13094
+ const desiredNames = new Set(content.hostMcpServers.map((server) => server.name));
13095
+ const liveNames = new Set(finalInventory.mcpServers.map((server) => server.name));
13096
+ const managedNames = new Set(finalInventory.managedMcpServers.map((server) => server.name));
13097
+ 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);
13098
+ return Object.freeze(names.map((name) => Object.freeze({
13099
+ kind: "mcp-absent",
13100
+ subject: name,
13101
+ detail: "Host-scoped HTTP MCP server was retired."
13102
+ })));
13103
+ }
11350
13104
  function commandPlan(operation, condition) {
11351
13105
  return Object.freeze({
11352
13106
  kind: "Command",
@@ -11358,11 +13112,29 @@ function nativeOperationPostcondition(content, operation, inventory) {
11358
13112
  switch (operation.kind) {
11359
13113
  case "marketplace-removed": return !inventory.marketplaces.some((marketplace) => marketplace.identity === operation.identity);
11360
13114
  case "marketplace-added": return hasOneExactMarketplace(inventory, content);
11361
- case "plugin-removed": return observedPlugin(inventory, operation.selector) === void 0;
13115
+ case "plugin-removed": return !pluginSelectorIsPresent(inventory, operation.selector);
11362
13116
  case "plugin-installed": return installedPlugin(inventory, operation.selector) !== void 0;
11363
13117
  case "plugin-enabled": return installedPlugin(inventory, operation.selector)?.enabled === true;
13118
+ case "mcp-removed": return !inventory.mcpServers.some((server) => server.name === operation.name) && !inventory.managedMcpServers.some((server) => server.name === operation.name);
13119
+ case "mcp-added": {
13120
+ const desired = content.hostMcpServers.find((entry) => entry.name === operation.name);
13121
+ return desired === void 0 ? hasExactMcpServer(inventory, operation.name, operation.url) : hasExactManagedMcpServer(inventory, operation.name, operation.url, desired.ownerPluginId);
13122
+ }
11364
13123
  }
11365
13124
  }
13125
+ function pluginSelectorIsPresent(inventory, selector) {
13126
+ return observedPlugin(inventory, selector) !== void 0 || inventory.pluginConfig?.selectors.includes(selector) === true;
13127
+ }
13128
+ function hasExactMcpServer(inventory, name, url) {
13129
+ const live = inventory.mcpServers.find((entry) => entry.name === name);
13130
+ return live !== void 0 && live.transport === "http" && live.url === url && live.enabled !== false;
13131
+ }
13132
+ function hasExactManagedMcpServer(inventory, name, url, ownerPluginId) {
13133
+ return hasExactMcpServer(inventory, name, url) && inventory.managedMcpServers.some((record) => record.name === name && record.url === url && record.ownerPluginId === ownerPluginId);
13134
+ }
13135
+ function compareText$4(left, right) {
13136
+ return left < right ? -1 : left > right ? 1 : 0;
13137
+ }
11366
13138
  //#endregion
11367
13139
  //#region ../../services/agent-plugin-lifecycle/src/service/modules/providers/router/sync.ts
11368
13140
  /**
@@ -11377,6 +13149,20 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11377
13149
  if (!hasCanonicalProviderHomes(canonicalRequest.targets)) return yield* Effect.fail(errors.BAD_REQUEST({ message: "Expected a canonical non-root absolute path" }));
11378
13150
  const locator = decodeGitLocator(canonicalRequest.locator);
11379
13151
  const nativePolicy = Object.freeze({ retireOmitted: true });
13152
+ const observeInventory = (content, session, observeMcpServers = content.hostMcpServers.length > 0) => {
13153
+ const marketplaceIdentity = session.provider === "codex" ? content.marketplace.identity : void 0;
13154
+ return session.inventory({
13155
+ observeMcpServers,
13156
+ ...marketplaceIdentity === void 0 ? {} : { observePluginConfigForMarketplace: marketplaceIdentity }
13157
+ }).pipe(Effect.flatMap((inventory) => marketplaceIdentity === void 0 || inventory?.pluginConfig?.marketplaceIdentity === marketplaceIdentity ? Effect.succeed(inventory) : Effect.fail({
13158
+ _tag: "NativeAgentProviderFailure",
13159
+ provider: "codex",
13160
+ operation: "inventory",
13161
+ commandPhase: "not-started",
13162
+ reason: "ProtocolFailed",
13163
+ detail: "Codex did not report user-config plugin selectors for the selected marketplace."
13164
+ })));
13165
+ };
11380
13166
  /** Reads selected files and classifies one already-admitted native inventory. */
11381
13167
  const assessInventory = (content, target, session, capabilities, inventory, mutationIntent) => Effect.gen(function* () {
11382
13168
  const fileAssessments = [];
@@ -11399,7 +13185,7 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11399
13185
  * session is invocation-local and is reused only by the final mutation pass.
11400
13186
  */
11401
13187
  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));
13188
+ 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
13189
  const acquisition = yield* Effect.result(acquire);
11404
13190
  if (Result.isFailure(acquisition)) return Object.freeze({
11405
13191
  kind: "Unavailable",
@@ -11410,14 +13196,14 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11410
13196
  kind: "Unavailable",
11411
13197
  assessment: unavailableNativeTarget(target, "Native provider acquisition returned a session for a different target.")
11412
13198
  });
11413
- const observation = Effect.all([session.probe(), session.inventory()], { concurrency: 2 });
13199
+ const observation = Effect.all([session.probe(), observeInventory(content, session)], { concurrency: 2 });
11414
13200
  const observed = yield* Effect.result(observation);
11415
13201
  if (Result.isFailure(observed)) return Object.freeze({
11416
13202
  kind: "Unavailable",
11417
13203
  assessment: unavailableNativeTarget(target, `Native provider inspection failed: ${observed.failure.detail}`)
11418
13204
  });
11419
13205
  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({
13206
+ 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
13207
  kind: "Unavailable",
11422
13208
  assessment: unavailableNativeTarget(target, "Native provider inspection returned facts for a different target.")
11423
13209
  });
@@ -11430,7 +13216,7 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11430
13216
  /** Preflights every target sequentially before any target can mutate. */
11431
13217
  const observeTargets = (content, targets, mutationIntent) => Effect.forEach(targets, (target) => observeTarget(content, target, mutationIntent), { concurrency: 1 }).pipe(Effect.map((observations) => Object.freeze(observations)));
11432
13218
  /** Recovers best-effort terminal facts without turning evidence into authority. */
11433
- const observeTerminalFacts = (content, observation) => Effect.result(observation.session.inventory()).pipe(Effect.flatMap((attempt) => {
13219
+ const observeTerminalFacts = (content, observation) => Effect.result(observeInventory(content, observation.session)).pipe(Effect.flatMap((attempt) => {
11434
13220
  if (Result.isFailure(attempt) || !Value.Check(NativeProviderInventorySchema, attempt.success) || attempt.success.provider !== observation.assessment.target.provider) return Effect.succeed(Object.freeze([]));
11435
13221
  return assessInventory(content, observation.assessment.target, observation.session, observation.assessment.capabilities, attempt.success, false).pipe(Effect.map((assessment) => assessment.facts));
11436
13222
  }));
@@ -11453,13 +13239,31 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11453
13239
  kind: "Ready",
11454
13240
  effect: session.removePlugin({ selector: operation.selector })
11455
13241
  });
11456
- case "plugin-enabled": return session.provider === "claude" ? Object.freeze({
13242
+ case "plugin-enabled": return session.provider === "claude" || session.provider === "antigravity" ? Object.freeze({
11457
13243
  kind: "Ready",
11458
13244
  effect: session.enablePlugin({ selector: operation.selector })
11459
13245
  }) : Object.freeze({
11460
13246
  kind: "Refused",
11461
13247
  issue: providerIssue("CapabilityMissing", "Codex did not expose plugin enablement.")
11462
13248
  });
13249
+ case "mcp-added": {
13250
+ const desired = content.hostMcpServers.find((entry) => entry.name === operation.name);
13251
+ return desired === void 0 ? Object.freeze({
13252
+ kind: "Refused",
13253
+ issue: providerIssue("DesiredContentInvalid", `Host MCP server ${operation.name} has no selected owner plugin.`)
13254
+ }) : Object.freeze({
13255
+ kind: "Ready",
13256
+ effect: session.addMcpServer({
13257
+ name: operation.name,
13258
+ url: operation.url,
13259
+ ownerPluginId: desired.ownerPluginId
13260
+ })
13261
+ });
13262
+ }
13263
+ case "mcp-removed": return Object.freeze({
13264
+ kind: "Ready",
13265
+ effect: session.removeMcpServer({ name: operation.name })
13266
+ });
11463
13267
  }
11464
13268
  };
11465
13269
  /** Attempts one native command and immediately observes its postcondition. */
@@ -11475,7 +13279,7 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11475
13279
  commandPhase: commandAttempt.failure.commandPhase,
11476
13280
  detail: commandAttempt.failure.detail
11477
13281
  }) : Object.freeze({ kind: "Returned" });
11478
- const inventoryAttempt = yield* Effect.result(observation.session.inventory());
13282
+ const inventoryAttempt = yield* Effect.result(observeInventory(content, observation.session, content.hostMcpServers.length > 0 || operation.kind === "mcp-added" || operation.kind === "mcp-removed"));
11479
13283
  return classifyNativeMutationStep(content, operation, command, Result.isFailure(inventoryAttempt) ? Object.freeze({
11480
13284
  kind: "Failed",
11481
13285
  detail: inventoryAttempt.failure.detail
@@ -11491,8 +13295,13 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11491
13295
  const mutateTarget = (content, observation) => Effect.gen(function* () {
11492
13296
  const { assessment, session } = observation;
11493
13297
  let inventory = assessment.inventory;
13298
+ let beforeRefresh = assessment.inventory;
13299
+ let codexRefreshCandidates;
13300
+ let codexRefreshProof;
13301
+ let codexMarketplaceOwnershipLoss;
11494
13302
  const operations = [];
11495
13303
  const issues = [];
13304
+ const failGuard = (issue) => failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, issue]);
11496
13305
  const terminalResult = (step) => Effect.gen(function* () {
11497
13306
  if (step.kind === "Failed") return failedMutationTarget(assessment, operations, yield* observeTerminalFacts(content, observation), [...issues, step.issue]);
11498
13307
  if (step.kind === "Uncertain") return uncertainMutationTarget(assessment, operations, step.attempted, yield* observeTerminalFacts(content, observation), [...issues, step.issue]);
@@ -11501,15 +13310,23 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11501
13310
  if (step.kind !== "Confirmed" && step.kind !== "AlreadySatisfied") return;
11502
13311
  inventory = step.inventory;
11503
13312
  if (step.kind === "Confirmed") operations.push(operation);
13313
+ if (session.provider !== "codex") return;
13314
+ if (operation.kind === "marketplace-removed") {
13315
+ if (step.kind === "Confirmed") codexRefreshCandidates = codexMarketplaceRefreshCandidates(beforeRefresh, inventory);
13316
+ return;
13317
+ }
13318
+ if (!hasOneExactMarketplace(inventory, content)) codexMarketplaceOwnershipLoss ??= inventory;
13319
+ codexRefreshProof = retainCodexRefreshProof(operation.kind === "marketplace-added" && step.kind === "Confirmed" ? codexRefreshCandidates : codexRefreshProof, inventory);
11504
13320
  };
11505
13321
  for (const plan of planNativeTargetMutation(content, assessment, nativePolicy)) {
11506
13322
  if (plan.kind === "GuardMarketplaceRemoval") {
11507
- const guardAttempt = yield* Effect.result(session.inventory());
13323
+ const guardAttempt = yield* Effect.result(observeInventory(content, session));
11508
13324
  if (Result.isFailure(guardAttempt)) return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", `Marketplace could not be reobserved before removal: ${guardAttempt.failure.detail}`)]);
11509
13325
  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
13326
  inventory = guardAttempt.success;
11511
- const guardIssue = marketplaceRemovalIssue(content, inventory);
13327
+ const guardIssue = marketplaceRemovalIssue(content, inventory) ?? codexMarketplaceRefreshOmittedPluginIssue(content, assessment.inventory, inventory);
11512
13328
  if (guardIssue !== void 0) return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, guardIssue]);
13329
+ beforeRefresh = inventory;
11513
13330
  continue;
11514
13331
  }
11515
13332
  if (plan.kind === "VerifyMember") {
@@ -11525,9 +13342,30 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11525
13342
  continue;
11526
13343
  }
11527
13344
  if (plan.kind === "RetireOmitted") {
11528
- const retirement = planOmittedRetirement(content, inventory, operations.length);
13345
+ const retirement = planOmittedRetirement(content, beforeRefresh, inventory, operations.length);
11529
13346
  if (!retirement.ok) return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, retirement.issue]);
13347
+ for (const name of retirement.mcpNames) {
13348
+ const operation = Object.freeze({
13349
+ kind: "mcp-removed",
13350
+ name
13351
+ });
13352
+ const step = yield* mutateAndObserve(content, observation, operation);
13353
+ const terminal = yield* terminalResult(step);
13354
+ if (terminal !== void 0) return terminal;
13355
+ acceptCompletedStep(step, operation);
13356
+ }
11530
13357
  for (const selector of retirement.selectors) {
13358
+ if (session.provider === "codex") {
13359
+ if (!hasOneExactMarketplace(codexMarketplaceOwnershipLoss ?? inventory, content)) return failGuard(retirementMarketplaceIssue());
13360
+ const guardAttempt = yield* Effect.result(observeInventory(content, session));
13361
+ if (Result.isFailure(guardAttempt)) return failGuard(providerIssue("NativeObservationFailed", `Codex plugin ${selector} could not be reobserved before removal: ${guardAttempt.failure.detail}`));
13362
+ if (!Value.Check(NativeProviderInventorySchema, guardAttempt.success) || guardAttempt.success.provider !== session.provider) return failGuard(providerIssue("NativeObservationFailed", `Codex returned an invalid inventory before removing ${selector}.`));
13363
+ inventory = guardAttempt.success;
13364
+ codexRefreshProof = retainCodexRefreshProof(codexRefreshProof, inventory);
13365
+ const current = revalidateCodexOmittedPluginRemoval(content, inventory, selector, codexRefreshProof);
13366
+ if (!current.ok) return failGuard(current.issue);
13367
+ if (!current.present) continue;
13368
+ }
11531
13369
  const operation = Object.freeze({
11532
13370
  kind: "plugin-removed",
11533
13371
  selector
@@ -11539,13 +13377,15 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11539
13377
  }
11540
13378
  continue;
11541
13379
  }
11542
- if (!nativeCommandIsRequired(plan, inventory)) continue;
11543
- const step = yield* mutateAndObserve(content, observation, plan.operation);
13380
+ if (!nativeCommandIsRequired(content, plan, inventory)) continue;
13381
+ const { operation } = plan;
13382
+ if (session.provider === "codex" && "selector" in operation && !hasOneExactMarketplace(codexMarketplaceOwnershipLoss ?? inventory, content)) return failGuard(providerIssue("MarketplaceCollision", `Codex plugin ${operation.selector} requires one exact observed marketplace source before mutation.`));
13383
+ const step = yield* mutateAndObserve(content, observation, operation);
11544
13384
  const terminal = yield* terminalResult(step);
11545
13385
  if (terminal !== void 0) return terminal;
11546
- acceptCompletedStep(step, plan.operation);
13386
+ acceptCompletedStep(step, operation);
11547
13387
  }
11548
- const finalInventoryAttempt = yield* Effect.result(session.inventory());
13388
+ const finalInventoryAttempt = yield* Effect.result(observeInventory(content, session, content.hostMcpServers.length > 0 || operations.some((operation) => operation.kind === "mcp-added" || operation.kind === "mcp-removed")));
11549
13389
  if (Result.isFailure(finalInventoryAttempt)) return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", `Final provider state could not be observed: ${finalInventoryAttempt.failure.detail}`)]);
11550
13390
  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
13391
  const finalAssessment = yield* assessInventory(content, assessment.target, session, assessment.capabilities, finalInventoryAttempt.success, false);
@@ -11555,7 +13395,8 @@ const sync = module$5.sync.effect(function* ({ context, errors, input }) {
11555
13395
  ...finalAssessment.issues,
11556
13396
  finalIssue
11557
13397
  ]);
11558
- return completedMutationTarget(assessment, operations, finalAssessment.facts, issues);
13398
+ const retiredFacts = retiredOmittedMcpFacts(content, operations, finalInventoryAttempt.success);
13399
+ return completedMutationTarget(assessment, operations, [...finalAssessment.facts, ...retiredFacts], issues);
11559
13400
  });
11560
13401
  /**
11561
13402
  * Performs one complete current-main plus selected-content observation.
@@ -11984,7 +13825,16 @@ const router$7 = {
11984
13825
  };
11985
13826
  /** Acquires and admits one invocation-local native session without observing provider state. */
11986
13827
  const acquireTarget = (target) => Effect.gen(function* () {
11987
- 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));
13828
+ const acquire = target.provider === "codex" ? context.nativeProviders.codex.acquire({
13829
+ home: target.home,
13830
+ disposableRoot: canonicalRequest.disposableRoot
13831
+ }).pipe(Effect.map((session) => session)) : target.provider === "claude" ? context.nativeProviders.claude.acquire({
13832
+ home: target.home,
13833
+ disposableRoot: canonicalRequest.disposableRoot
13834
+ }).pipe(Effect.map((session) => session)) : context.nativeProviders.antigravity.acquire({
13835
+ home: target.home,
13836
+ disposableRoot: canonicalRequest.disposableRoot
13837
+ }).pipe(Effect.map((session) => session));
11988
13838
  const acquisition = yield* Effect.result(acquire);
11989
13839
  if (Result.isFailure(acquisition)) return Object.freeze({
11990
13840
  kind: "Unavailable",
@@ -12008,7 +13858,10 @@ const router$7 = {
12008
13858
  * Typed provider failures remain ordinary facts. Defects and interruption
12009
13859
  * continue through the Effect cause channel.
12010
13860
  */
12011
- const observeInventory = (session, target) => Effect.result(session.inventory()).pipe(Effect.map((attempt) => {
13861
+ const observeInventory = (content, session, target, observeMcpServers) => Effect.result(session.inventory({
13862
+ observeMcpServers,
13863
+ relevantOwnerPluginIds: content.members.map((member) => member.pluginId)
13864
+ })).pipe(Effect.map((attempt) => {
12012
13865
  if (Result.isFailure(attempt)) return Object.freeze({
12013
13866
  kind: "Failed",
12014
13867
  detail: attempt.failure.detail
@@ -12063,19 +13916,24 @@ const router$7 = {
12063
13916
  * @param inventory - TypeBox-admitted live provider inventory.
12064
13917
  * @param mutationIntent - Whether this observation must admit planned commands.
12065
13918
  */
12066
- const assessInventory = (content, target, session, capabilities, inventory, mutationIntent) => assessPluginFiles(content, target, session, inventory).pipe(Effect.map((fileAssessments) => assessNativeTarget(content, target, capabilities, inventory, fileAssessments, nativePolicy, mutationIntent)));
13919
+ const assessInventory = (content, target, session, capabilities, inventory, mutationIntent) => Effect.gen(function* () {
13920
+ return assessNativeTarget(content, target, capabilities, inventory, yield* assessPluginFiles(content, target, session, inventory), nativePolicy, mutationIntent);
13921
+ });
12067
13922
  /** Completely observes one admitted disposable provider target. */
12068
13923
  const observeTarget = (content, admission, mutationIntent) => Effect.gen(function* () {
12069
13924
  if (admission.kind === "Unavailable") return admission;
12070
13925
  const { session, target } = admission;
12071
- const inspection = Effect.all([session.probe(), session.inventory()], { concurrency: 2 });
13926
+ const inspection = Effect.all([session.probe(), session.inventory({
13927
+ observeMcpServers: content.hostMcpServers.length > 0,
13928
+ relevantOwnerPluginIds: content.members.map((member) => member.pluginId)
13929
+ })], { concurrency: 2 });
12072
13930
  const observed = yield* Effect.result(inspection);
12073
13931
  if (Result.isFailure(observed)) return Object.freeze({
12074
13932
  kind: "Unavailable",
12075
13933
  assessment: unavailableNativeTarget(target, `Native provider inspection failed: ${observed.failure.detail}`)
12076
13934
  });
12077
13935
  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({
13936
+ 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
13937
  kind: "Unavailable",
12080
13938
  assessment: unavailableNativeTarget(target, "Native provider inspection returned facts for a different target.")
12081
13939
  });
@@ -12090,7 +13948,7 @@ const router$7 = {
12090
13948
  const observeTargets = (content, admissions, mutationIntent) => Effect.forEach(admissions, (admission) => observeTarget(content, admission, mutationIntent), { concurrency: 1 }).pipe(Effect.map((observations) => Object.freeze(observations)));
12091
13949
  /** Best-effort terminal observation for public failure diagnostics. */
12092
13950
  const observeTerminalFacts = (content, observation) => Effect.gen(function* () {
12093
- const inventory = yield* observeInventory(observation.session, observation.assessment.target);
13951
+ const inventory = yield* observeInventory(content, observation.session, observation.assessment.target, content.hostMcpServers.length > 0);
12094
13952
  if (inventory.kind === "Failed") return Object.freeze([]);
12095
13953
  return (yield* assessInventory(content, observation.assessment.target, observation.session, observation.assessment.capabilities, inventory.inventory, false)).facts;
12096
13954
  });
@@ -12121,14 +13979,29 @@ const router$7 = {
12121
13979
  mutation = session.removePlugin({ selector: operation.selector });
12122
13980
  break;
12123
13981
  case "plugin-enabled":
12124
- if (session.provider !== "claude") return {
13982
+ if (session.provider !== "claude" && session.provider !== "antigravity") return {
12125
13983
  kind: "Failed",
12126
13984
  issue: providerIssue("CapabilityMissing", "Codex did not expose plugin enablement.")
12127
13985
  };
12128
13986
  mutation = session.enablePlugin({ selector: operation.selector });
13987
+ break;
13988
+ case "mcp-added": {
13989
+ const desired = content.hostMcpServers.find((entry) => entry.name === operation.name);
13990
+ if (desired === void 0) return {
13991
+ kind: "Failed",
13992
+ issue: providerIssue("DesiredContentInvalid", `Host MCP server ${operation.name} has no selected owner plugin.`)
13993
+ };
13994
+ mutation = session.addMcpServer({
13995
+ name: operation.name,
13996
+ url: operation.url,
13997
+ ownerPluginId: desired.ownerPluginId
13998
+ });
13999
+ break;
14000
+ }
14001
+ case "mcp-removed": mutation = session.removeMcpServer({ name: operation.name });
12129
14002
  }
12130
14003
  const command = yield* Effect.result(mutation);
12131
- const observed = yield* observeInventory(session, assessment.target);
14004
+ const observed = yield* observeInventory(content, session, assessment.target, content.hostMcpServers.length > 0 || operation.kind === "mcp-added" || operation.kind === "mcp-removed");
12132
14005
  return classifyNativeMutationStep(content, operation, Result.isFailure(command) ? {
12133
14006
  kind: "Failed",
12134
14007
  commandPhase: command.failure.commandPhase,
@@ -12137,7 +14010,7 @@ const router$7 = {
12137
14010
  });
12138
14011
  for (const plan of planNativeTargetMutation(content, assessment, nativePolicy)) switch (plan.kind) {
12139
14012
  case "GuardMarketplaceRemoval": {
12140
- const observed = yield* observeInventory(session, assessment.target);
14013
+ const observed = yield* observeInventory(content, session, assessment.target, content.hostMcpServers.length > 0);
12141
14014
  if (observed.kind === "Failed") return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", `Marketplace could not be reobserved before removal: ${observed.detail}`)]);
12142
14015
  inventory = observed.inventory;
12143
14016
  const ownershipIssue = marketplaceRemovalIssue(content, inventory);
@@ -12151,7 +14024,7 @@ const router$7 = {
12151
14024
  }
12152
14025
  case "RetireOmitted": return failedMutationTarget(assessment, operations, yield* observeTerminalFacts(content, observation), [...issues, providerIssue("DesiredContentInvalid", "Disposable provider testing cannot retire omitted plugins.")]);
12153
14026
  case "Command": {
12154
- if (!nativeCommandIsRequired(plan, inventory)) break;
14027
+ if (!nativeCommandIsRequired(content, plan, inventory)) break;
12155
14028
  const step = yield* executeCommand(plan.operation);
12156
14029
  if (step.kind === "Failed") return failedMutationTarget(assessment, operations, yield* observeTerminalFacts(content, observation), [...issues, step.issue]);
12157
14030
  if (step.kind === "Uncertain") return uncertainMutationTarget(assessment, operations, step.attempted, yield* observeTerminalFacts(content, observation), [...issues, step.issue]);
@@ -12160,11 +14033,12 @@ const router$7 = {
12160
14033
  break;
12161
14034
  }
12162
14035
  }
12163
- const finalInventory = yield* observeInventory(session, assessment.target);
14036
+ const finalInventory = yield* observeInventory(content, session, assessment.target, content.hostMcpServers.length > 0 || operations.some((operation) => operation.kind === "mcp-added" || operation.kind === "mcp-removed"));
12164
14037
  if (finalInventory.kind === "Failed") return failedMutationTarget(assessment, operations, Object.freeze([]), [...issues, providerIssue("NativeObservationFailed", `Final provider state could not be observed: ${finalInventory.detail}`)]);
12165
14038
  const finalAssessment = yield* assessInventory(content, assessment.target, session, assessment.capabilities, finalInventory.inventory, false);
12166
14039
  const finalIssue = finalNativeAssessmentIssue(finalAssessment);
12167
- return finalIssue === void 0 ? completedMutationTarget(assessment, operations, finalAssessment.facts, issues) : failedMutationTarget(assessment, operations, finalAssessment.facts, [
14040
+ const retiredFacts = retiredOmittedMcpFacts(content, operations, finalInventory.inventory);
14041
+ return finalIssue === void 0 ? completedMutationTarget(assessment, operations, [...finalAssessment.facts, ...retiredFacts], issues) : failedMutationTarget(assessment, operations, finalAssessment.facts, [
12168
14042
  ...issues,
12169
14043
  ...finalAssessment.issues,
12170
14044
  finalIssue
@@ -14600,6 +16474,7 @@ const definition$1 = defineService({
14600
16474
  packageOutput: resourceDep(AgentPluginPackageOutputRuntimeResource),
14601
16475
  codex: resourceDep(CodexNativeAgentProviderRuntimeResource),
14602
16476
  claude: resourceDep(ClaudeNativeAgentProviderRuntimeResource),
16477
+ antigravity: resourceDep(AntigravityNativeAgentProviderRuntimeResource),
14603
16478
  versionedContent: resourceDep(VersionedContentRuntimeResource)
14604
16479
  }
14605
16480
  });
@@ -14616,7 +16491,8 @@ const serviceRuntimeExport$1 = sealService(definition$1, {
14616
16491
  packageOutput: deps.packageOutput,
14617
16492
  nativeProviders: {
14618
16493
  codex: deps.codex,
14619
- claude: deps.claude
16494
+ claude: deps.claude,
16495
+ antigravity: deps.antigravity
14620
16496
  },
14621
16497
  versionedContent: deps.versionedContent
14622
16498
  },
@@ -14738,7 +16614,7 @@ const targetFlag = Flags.custom({
14738
16614
  const separator = value.indexOf("=");
14739
16615
  const provider = value.slice(0, separator);
14740
16616
  const home = value.slice(separator + 1);
14741
- if (separator < 1 || provider !== "codex" && provider !== "claude") throw new Error("Expected provider=absolute-home with codex or claude.");
16617
+ if (separator < 1 || provider !== "codex" && provider !== "claude" && provider !== "antigravity") throw new Error("Expected provider=absolute-home with codex, claude, or antigravity.");
14742
16618
  const parsedHome = absolutePath(home);
14743
16619
  if (parsedHome === void 0) throw new Error("Expected an absolute provider home.");
14744
16620
  return {
@@ -15022,10 +16898,24 @@ function formatOutcome$1(outcome) {
15022
16898
  result
15023
16899
  }, null, outcome.json ? void 0 : 2)}\n`;
15024
16900
  }
16901
+ function escapeTerminalText(value) {
16902
+ 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")}`);
16903
+ }
16904
+ /** Formats non-blocking Antigravity MCP omission notices for human CLI operators. */
16905
+ function formatOmittedMcpNotices(outcome) {
16906
+ if (outcome.operation !== "providers.status" && outcome.operation !== "providers.sync" && outcome.operation !== "providers.test") return "";
16907
+ const lines = [];
16908
+ 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})`);
16909
+ return lines.length === 0 ? "" : `${lines.join("\n")}\n`;
16910
+ }
15025
16911
  /** Awaits native stdout completion before applying the result's process exit classification. */
15026
16912
  async function present$1(outcome, command) {
15027
16913
  const output = formatOutcome$1(outcome);
15028
16914
  await new Promise((resolve, reject) => process.stdout.write(output, (error) => error ? reject(error) : resolve()));
16915
+ if (!outcome.json) {
16916
+ const notices = formatOmittedMcpNotices(outcome);
16917
+ if (notices.length > 0) await new Promise((resolve, reject) => process.stderr.write(notices, (error) => error ? reject(error) : resolve()));
16918
+ }
15029
16919
  const code = exitCode$1(outcome);
15030
16920
  if (code !== 0) command.exit(code);
15031
16921
  }
@@ -16614,4 +18504,4 @@ const habitatApp = defineApp({
16614
18504
  ]
16615
18505
  });
16616
18506
  //#endregion
16617
- export { FilesystemRuntimeResource as A, SourceInventoryPathSchema as C, RuleEvaluationRequestSchema as D, MAX_RULE_EVALUATION_FAILURE_DETAIL as E, SourceInventoryRuntimeResource as O, ObserveSourceInventoryInputSchema as S, contract$10 as T, CodexNativeAgentProviderRuntimeResource as _, MaterializeRemoteInputSchema as a, MAX_SOURCE_INVENTORY_FAILURE_DETAIL as b, CanonicalGitRepositoryUrlSchema as c, NativeProviderMarketplaceIdentityInputSchema as d, NativeProviderPluginFilesReadInputSchema as f, ClaudeNativeAgentProviderRuntimeResource as g, VersionedContentRuntimeResource as h, MAX_VERSIONED_CONTENT_FAILURE_DETAIL as i, RuleEvaluationRuntimeResource as k, NativeMarketplaceSourceSchema as l, NativeProviderSessionInputSchema as m, ChildProcessRuntimeResource as n, ObserveRemoteInputSchema as o, NativeProviderPluginSelectorInputSchema as p, AncestryInputSchema as r, VersionedContentTreeEntrySchema as s, habitatApp as t, NativeProviderInventorySchema as u, ContentWorkspaceRuntimeResource as v, SourceInventoryResultSchema as w, MAX_SOURCE_INVENTORY_ROOT_LENGTH as x, AgentPluginPackageOutputRuntimeResource as y };
18507
+ export { ContentWorkspaceRuntimeResource as A, SourceInventoryRuntimeResource as B, ObservedMcpServerNameSchema as C, AntigravityNativeAgentProviderRuntimeResource as D, VersionedContentRuntimeResource as E, SourceInventoryPathSchema as F, FilesystemRuntimeResource as H, SourceInventoryResultSchema as I, contract$10 as L, MAX_SOURCE_INVENTORY_FAILURE_DETAIL as M, MAX_SOURCE_INVENTORY_ROOT_LENGTH as N, ClaudeNativeAgentProviderRuntimeResource as O, ObserveSourceInventoryInputSchema as P, MAX_RULE_EVALUATION_FAILURE_DETAIL as R, NativeProviderSessionInputSchema as S, projectAntigravityPluginBundle as T, RuleEvaluationRuntimeResource as V, NativeProviderMarketplaceIdentityInputSchema as _, MaterializeRemoteInputSchema as a, NativeProviderPluginFilesReadInputSchema as b, CanonicalGitRepositoryUrlSchema as c, MAX_NATIVE_PROVIDER_PLUGIN_FILES as d, MAX_NATIVE_PROVIDER_PLUGIN_FILE_BYTES as f, NativeProviderInventorySchema as g, NativeProviderInventoryOptionsSchema as h, MAX_VERSIONED_CONTENT_FAILURE_DETAIL as i, AgentPluginPackageOutputRuntimeResource as j, CodexNativeAgentProviderRuntimeResource as k, MAX_NATIVE_PROVIDER_MCP_SERVERS as l, NativeMarketplaceSourceSchema as m, ChildProcessRuntimeResource as n, ObserveRemoteInputSchema as o, NativeManagedMcpServerRecordSchema as p, AncestryInputSchema as r, VersionedContentTreeEntrySchema as s, habitatApp as t, MAX_NATIVE_PROVIDER_PLUGINS as u, NativeProviderMcpServerAddInputSchema as v, PluginVersionSchema as w, NativeProviderPluginSelectorInputSchema as x, NativeProviderMcpServerRemoveInputSchema as y, RuleEvaluationRequestSchema as z };