@habitat-ai/cli 0.6.0 → 0.8.0

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