@herbertgao/pi-extensions 2026.11.17 → 2026.11.19

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.
Files changed (159) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +3 -3
  3. package/THIRD_PARTY_NOTICES.md +2 -23
  4. package/node_modules/@estebanforge/pi-antigravity-bridge/CHANGELOG.md +956 -0
  5. package/node_modules/{pi-antigravity → @estebanforge/pi-antigravity-bridge}/LICENSE +1 -1
  6. package/node_modules/@estebanforge/pi-antigravity-bridge/README.md +240 -0
  7. package/node_modules/@estebanforge/pi-antigravity-bridge/extensions/index.ts +2117 -0
  8. package/node_modules/@estebanforge/pi-antigravity-bridge/package.json +61 -0
  9. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/connection.ts +644 -0
  10. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/driver.ts +1043 -0
  11. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/events.ts +323 -0
  12. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/home.ts +145 -0
  13. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/jsonrpc.ts +243 -0
  14. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/setup.ts +107 -0
  15. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/usage-estimate.ts +61 -0
  16. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agents.ts +64 -0
  17. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-install.ts +93 -0
  18. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-paths.ts +30 -0
  19. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-setup.ts +81 -0
  20. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-version.ts +289 -0
  21. package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-detect.ts +161 -0
  22. package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-gate.ts +233 -0
  23. package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-hook.ts +325 -0
  24. package/node_modules/@estebanforge/pi-antigravity-bridge/src/artifacts-ui.ts +88 -0
  25. package/node_modules/@estebanforge/pi-antigravity-bridge/src/artifacts.ts +144 -0
  26. package/node_modules/@estebanforge/pi-antigravity-bridge/src/ask-tool.ts +1221 -0
  27. package/node_modules/@estebanforge/pi-antigravity-bridge/src/background-watch.ts +225 -0
  28. package/node_modules/@estebanforge/pi-antigravity-bridge/src/bridge-catalog.ts +197 -0
  29. package/node_modules/@estebanforge/pi-antigravity-bridge/src/config.ts +523 -0
  30. package/node_modules/@estebanforge/pi-antigravity-bridge/src/daily-log.ts +196 -0
  31. package/node_modules/@estebanforge/pi-antigravity-bridge/src/dialog-lock.ts +48 -0
  32. package/node_modules/@estebanforge/pi-antigravity-bridge/src/diff-render.ts +207 -0
  33. package/node_modules/@estebanforge/pi-antigravity-bridge/src/driver-types.ts +168 -0
  34. package/node_modules/@estebanforge/pi-antigravity-bridge/src/driver.ts +907 -0
  35. package/node_modules/@estebanforge/pi-antigravity-bridge/src/engine-picker.ts +160 -0
  36. package/node_modules/@estebanforge/pi-antigravity-bridge/src/frame-guard.ts +38 -0
  37. package/node_modules/@estebanforge/pi-antigravity-bridge/src/handoff-toast.ts +21 -0
  38. package/node_modules/@estebanforge/pi-antigravity-bridge/src/mcp-registration.ts +376 -0
  39. package/node_modules/@estebanforge/pi-antigravity-bridge/src/mcp-server.ts +618 -0
  40. package/node_modules/@estebanforge/pi-antigravity-bridge/src/models.ts +404 -0
  41. package/node_modules/@estebanforge/pi-antigravity-bridge/src/native-tools.ts +104 -0
  42. package/node_modules/@estebanforge/pi-antigravity-bridge/src/parked-turn.ts +125 -0
  43. package/node_modules/@estebanforge/pi-antigravity-bridge/src/patch-cleanup.ts +523 -0
  44. package/node_modules/@estebanforge/pi-antigravity-bridge/src/poll-fold.ts +55 -0
  45. package/node_modules/@estebanforge/pi-antigravity-bridge/src/prompt-images.ts +92 -0
  46. package/node_modules/@estebanforge/pi-antigravity-bridge/src/provider.ts +2214 -0
  47. package/node_modules/@estebanforge/pi-antigravity-bridge/src/queued-messages.ts +152 -0
  48. package/node_modules/@estebanforge/pi-antigravity-bridge/src/quota-notice.ts +40 -0
  49. package/node_modules/@estebanforge/pi-antigravity-bridge/src/redact.ts +27 -0
  50. package/node_modules/@estebanforge/pi-antigravity-bridge/src/sessions.ts +197 -0
  51. package/node_modules/@estebanforge/pi-antigravity-bridge/src/skills.ts +207 -0
  52. package/node_modules/@estebanforge/pi-antigravity-bridge/src/stream-events.ts +161 -0
  53. package/node_modules/@estebanforge/pi-antigravity-bridge/src/stream-sanitizer.ts +180 -0
  54. package/node_modules/@estebanforge/pi-antigravity-bridge/src/subagent-roster.ts +245 -0
  55. package/node_modules/@estebanforge/pi-antigravity-bridge/src/sysprompt-agent.ts +130 -0
  56. package/node_modules/@estebanforge/pi-antigravity-bridge/src/tasks-ui.ts +90 -0
  57. package/node_modules/@estebanforge/pi-antigravity-bridge/src/tasks.ts +174 -0
  58. package/node_modules/@estebanforge/pi-antigravity-bridge/src/usage.ts +174 -0
  59. package/node_modules/@estebanforge/pi-antigravity-bridge/src/web-tools.ts +320 -0
  60. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +12 -0
  61. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +1 -1
  62. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +3 -1
  63. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +7 -0
  64. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/agent-badge.ts +244 -0
  65. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +1 -1
  66. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +10 -3
  67. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +18 -0
  68. package/node_modules/@herbertgao/pi-cc-extensions/package.json +1 -1
  69. package/node_modules/@herbertgao/pi-inline-skill-commands/README.md +18 -0
  70. package/node_modules/@herbertgao/pi-inline-skill-commands/package.json +1 -1
  71. package/node_modules/@herbertgao/pi-inline-skill-commands/src/index.ts +80 -0
  72. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +320 -102
  73. package/node_modules/@herbertgao/pi-subagents/SECURITY.md +2 -2
  74. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +240 -30
  75. package/node_modules/@herbertgao/pi-subagents/docs/translations.md +63 -0
  76. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +1 -1
  77. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  78. package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +2 -0
  79. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +89 -6
  80. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +6 -2
  81. package/node_modules/@herbertgao/pi-subagents/src/agent-types.ts +27 -13
  82. package/node_modules/@herbertgao/pi-subagents/src/cache-retention.ts +39 -0
  83. package/node_modules/@herbertgao/pi-subagents/src/completion-outbox.ts +5 -0
  84. package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +217 -41
  85. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +7 -0
  86. package/node_modules/@herbertgao/pi-subagents/src/group-join.ts +9 -0
  87. package/node_modules/@herbertgao/pi-subagents/src/index.ts +126 -93
  88. package/node_modules/@herbertgao/pi-subagents/src/mention-clone.ts +3 -2
  89. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +21 -0
  90. package/node_modules/@herbertgao/pi-subagents/src/subagent-info.ts +115 -0
  91. package/node_modules/@herbertgao/pi-subagents/src/types.ts +11 -7
  92. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +2 -3
  93. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +1 -1
  94. package/node_modules/@herbertgao/pi-subagents/src/workflow/meta.ts +2 -2
  95. package/node_modules/@herbertgao/pi-subagents/src/workflow-info.ts +184 -0
  96. package/node_modules/pi-commandcode-provider/CHANGELOG.md +10 -0
  97. package/node_modules/pi-commandcode-provider/README.md +3 -2
  98. package/node_modules/pi-commandcode-provider/index.ts +120 -13
  99. package/node_modules/pi-commandcode-provider/package.json +4 -3
  100. package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +11 -2
  101. package/node_modules/pi-commandcode-provider/src/pricing.ts +17 -1
  102. package/node_modules/pi-commandcode-provider/src/quota-command.ts +3 -2
  103. package/node_modules/pi-commandcode-provider/src/zdr.ts +163 -0
  104. package/package.json +12 -15
  105. package/node_modules/pi-antigravity/README.md +0 -298
  106. package/node_modules/pi-antigravity/docs/reader-guarantees.md +0 -35
  107. package/node_modules/pi-antigravity/package.json +0 -87
  108. package/node_modules/pi-antigravity/src/auth/accounts.ts +0 -327
  109. package/node_modules/pi-antigravity/src/auth/index.ts +0 -23
  110. package/node_modules/pi-antigravity/src/auth/oauth.ts +0 -445
  111. package/node_modules/pi-antigravity/src/client/client.ts +0 -602
  112. package/node_modules/pi-antigravity/src/client/enterprise.ts +0 -150
  113. package/node_modules/pi-antigravity/src/client/index.ts +0 -2
  114. package/node_modules/pi-antigravity/src/diagnostics/diagnostics.ts +0 -104
  115. package/node_modules/pi-antigravity/src/diagnostics/index.ts +0 -1
  116. package/node_modules/pi-antigravity/src/features/generate-image.ts +0 -132
  117. package/node_modules/pi-antigravity/src/features/google-search.ts +0 -72
  118. package/node_modules/pi-antigravity/src/features/read-url-content.ts +0 -124
  119. package/node_modules/pi-antigravity/src/image/image.ts +0 -427
  120. package/node_modules/pi-antigravity/src/image/index.ts +0 -1
  121. package/node_modules/pi-antigravity/src/image/native.ts +0 -69
  122. package/node_modules/pi-antigravity/src/index.ts +0 -547
  123. package/node_modules/pi-antigravity/src/models/discovery.ts +0 -176
  124. package/node_modules/pi-antigravity/src/models/grouping.ts +0 -487
  125. package/node_modules/pi-antigravity/src/models/index.ts +0 -3
  126. package/node_modules/pi-antigravity/src/models/models.ts +0 -647
  127. package/node_modules/pi-antigravity/src/search/index.ts +0 -1
  128. package/node_modules/pi-antigravity/src/search/search.ts +0 -967
  129. package/node_modules/pi-antigravity/src/stream/index.ts +0 -1
  130. package/node_modules/pi-antigravity/src/stream/stream.ts +0 -1961
  131. package/node_modules/pi-antigravity/src/types/enums.ts +0 -52
  132. package/node_modules/pi-antigravity/src/types/index.ts +0 -2
  133. package/node_modules/pi-antigravity/src/types/types.ts +0 -329
  134. package/node_modules/pi-antigravity/src/usage/index.ts +0 -1
  135. package/node_modules/pi-antigravity/src/usage/usage.ts +0 -437
  136. package/node_modules/pi-antigravity/src/utils/address.ts +0 -180
  137. package/node_modules/pi-antigravity/src/utils/credits.ts +0 -149
  138. package/node_modules/pi-antigravity/src/utils/html.ts +0 -31
  139. package/node_modules/pi-antigravity/src/utils/http.ts +0 -96
  140. package/node_modules/pi-antigravity/src/utils/index.ts +0 -5
  141. package/node_modules/pi-antigravity/src/utils/security.ts +0 -278
  142. package/node_modules/pi-antigravity/src/utils/text.ts +0 -66
  143. package/node_modules/pi-antigravity/src/utils/util.ts +0 -217
  144. package/node_modules/pi-antigravity/src/web-fetch/document.ts +0 -83
  145. package/node_modules/pi-antigravity/src/web-fetch/fences.ts +0 -24
  146. package/node_modules/pi-antigravity/src/web-fetch/header.ts +0 -97
  147. package/node_modules/pi-antigravity/src/web-fetch/index.ts +0 -3
  148. package/node_modules/pi-antigravity/src/web-fetch/inspect.ts +0 -328
  149. package/node_modules/pi-antigravity/src/web-fetch/limits.ts +0 -4
  150. package/node_modules/pi-antigravity/src/web-fetch/markdown.ts +0 -744
  151. package/node_modules/pi-antigravity/src/web-fetch/mdn.ts +0 -164
  152. package/node_modules/pi-antigravity/src/web-fetch/media.ts +0 -11
  153. package/node_modules/pi-antigravity/src/web-fetch/metadata.ts +0 -9
  154. package/node_modules/pi-antigravity/src/web-fetch/representation.ts +0 -93
  155. package/node_modules/pi-antigravity/src/web-fetch/save.ts +0 -71
  156. package/node_modules/pi-antigravity/src/web-fetch/sites.ts +0 -138
  157. package/node_modules/pi-antigravity/src/web-fetch/vendor.d.ts +0 -9
  158. package/node_modules/pi-antigravity/src/web-fetch/web-fetch.ts +0 -957
  159. package/node_modules/pi-antigravity/tsconfig.json +0 -21
@@ -1,150 +0,0 @@
1
- /**
2
- * Gemini Enterprise routing.
3
- *
4
- * Consumer prompts stay on cloudcode-pa. A regional enterprise license (error
5
- * #3501) must not fall back there: Google documents separate Business AI Code
6
- * hosts, and a consumer URL both fails the license check and leaves the
7
- * configured region. Inference is sent only to the host for the selected
8
- * location, using the enterprise generate path:
9
- * /v1beta/projects/{project}/locations/{location}:streamGenerateContent
10
- * The body keeps the Gemini request fields and names the license tier. Unknown
11
- * consumer envelope fields are dropped because the enterprise API rejects them.
12
- */
13
- import { existsSync, readFileSync } from "node:fs";
14
- import { homedir } from "node:os";
15
- import { join } from "node:path";
16
- import type { AntigravityGenerateRequest } from "../types/types.js";
17
- import { antigravityEnv, isRecord } from "../utils/util.js";
18
-
19
- const LOCATIONS = ["global", "us", "eu"] as const;
20
- export type EnterpriseLocation = (typeof LOCATIONS)[number];
21
-
22
- const PROJECT_ID = /^[a-z][a-z0-9-]{4,28}[a-z0-9]$/;
23
- const USER_TIER = /^[a-z0-9][a-z0-9._-]{0,80}$/;
24
-
25
- export type EnterpriseTarget = {
26
- location: EnterpriseLocation;
27
- projectId: string;
28
- userTier: string;
29
- host: string;
30
- };
31
-
32
- export function enterpriseHost(location: EnterpriseLocation): string {
33
- if (location === "global") return "https://businessaicode.googleapis.com";
34
- return `https://businessaicode.${location}.rep.googleapis.com`;
35
- }
36
-
37
- export function enterpriseStreamUrl(target: EnterpriseTarget): string {
38
- const project = encodeURIComponent(target.projectId);
39
- return `${target.host}/v1beta/projects/${project}/locations/${target.location}:streamGenerateContent?alt=sse`;
40
- }
41
-
42
- function truthy(value: string | undefined): boolean {
43
- return !!value && ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
44
- }
45
-
46
- function stringField(record: Record<string, unknown> | undefined, key: string): string {
47
- const value = record?.[key];
48
- return typeof value === "string" ? value.trim() : "";
49
- }
50
-
51
- function readCliSettings(): Record<string, unknown> | undefined {
52
- const path = join(homedir(), ".gemini", "antigravity-cli", "settings.json");
53
- if (!existsSync(path)) return undefined;
54
- try {
55
- const parsed = JSON.parse(readFileSync(path, "utf8")) as unknown;
56
- return isRecord(parsed) ? parsed : undefined;
57
- } catch {
58
- return undefined;
59
- }
60
- }
61
-
62
- function licenseRecord(
63
- settings: Record<string, unknown> | undefined,
64
- ): Record<string, unknown> | undefined {
65
- const license = settings?.selectedLicense ?? settings?.license;
66
- return isRecord(license) ? license : undefined;
67
- }
68
-
69
- /**
70
- * Resolve an explicit enterprise target, or undefined for the consumer path.
71
- * `eu` / `us` (and `ANTIGRAVITY_ENTERPRISE=1`) never silently use cloudcode-pa.
72
- */
73
- export function resolveEnterpriseTarget(): EnterpriseTarget | undefined {
74
- const settings = readCliSettings();
75
- const license = licenseRecord(settings);
76
- const forced = truthy(antigravityEnv("ENTERPRISE"));
77
- const locationRaw = (
78
- antigravityEnv("LOCATION") ||
79
- stringField(settings, "location") ||
80
- stringField(license, "location") ||
81
- (forced ? process.env.GOOGLE_CLOUD_LOCATION || "global" : "")
82
- )
83
- .trim()
84
- .toLowerCase();
85
-
86
- if (locationRaw && !LOCATIONS.includes(locationRaw as EnterpriseLocation)) {
87
- throw new Error("ANTIGRAVITY_LOCATION must be global, us, or eu. The prompt was not sent.");
88
- }
89
-
90
- const regional = locationRaw === "eu" || locationRaw === "us";
91
- if (!regional && !forced) return undefined;
92
-
93
- const location = (locationRaw || "global") as EnterpriseLocation;
94
- const projectId =
95
- antigravityEnv("ENTERPRISE_PROJECT")?.trim() ||
96
- stringField(settings, "project") ||
97
- stringField(settings, "projectId") ||
98
- stringField(settings, "licenseProject") ||
99
- stringField(license, "project") ||
100
- stringField(license, "projectId");
101
- const userTier =
102
- antigravityEnv("USER_TIER")?.trim() ||
103
- stringField(settings, "userTier") ||
104
- stringField(settings, "entitlementTier") ||
105
- stringField(license, "userTier") ||
106
- stringField(license, "tier");
107
-
108
- if (!PROJECT_ID.test(projectId)) {
109
- throw new Error(
110
- "Gemini Enterprise routing needs ANTIGRAVITY_ENTERPRISE_PROJECT set to the license's Google Cloud project id. Refusing to send this prompt to the consumer endpoint.",
111
- );
112
- }
113
- if (!USER_TIER.test(userTier)) {
114
- throw new Error(
115
- "Gemini Enterprise routing needs ANTIGRAVITY_USER_TIER from the selected license (for example the tier id shown by agy). Refusing to send this prompt to the consumer endpoint.",
116
- );
117
- }
118
-
119
- return { location, projectId, userTier, host: enterpriseHost(location) };
120
- }
121
-
122
- export function describeEnterpriseRouting(): string {
123
- try {
124
- const target = resolveEnterpriseTarget();
125
- if (!target) return "consumer";
126
- return `enterprise location=${target.location} host=${target.host} project=${target.projectId}`;
127
- } catch (error) {
128
- const message = error instanceof Error ? error.message : "invalid enterprise configuration";
129
- return `enterprise misconfigured (${message})`;
130
- }
131
- }
132
-
133
- /** Allowlisted enterprise generate body. Drops the consumer envelope. */
134
- export function toEnterpriseGenerateBody(
135
- payload: AntigravityGenerateRequest,
136
- target: EnterpriseTarget,
137
- ): Record<string, unknown> {
138
- const request = payload.request;
139
- const body: Record<string, unknown> = {
140
- contents: request.contents,
141
- aicode: { experience: payload.model },
142
- entitlement: { userTier: target.userTier },
143
- };
144
- if (request.systemInstruction) body.systemInstruction = request.systemInstruction;
145
- if (request.tools) body.tools = request.tools;
146
- if (request.toolConfig) body.toolConfig = request.toolConfig;
147
- if (request.generationConfig) body.generationConfig = request.generationConfig;
148
- if (request.labels) body.labels = request.labels;
149
- return body;
150
- }
@@ -1,2 +0,0 @@
1
- export * from "./client.js";
2
- export * from "./enterprise.js";
@@ -1,104 +0,0 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- import { redactSecrets, stripValidationUrls } from "../utils/security.js";
3
- import { cleanText } from "../utils/text.js";
4
-
5
- export type DiagnosticsSnapshot = {
6
- status?: number;
7
- endpoint?: string;
8
- error?: string;
9
- projectId?: string;
10
- resolvedRuntimeModel?: string;
11
- availableModels?: string;
12
- matchedModelDebug?: string;
13
- latencyMs?: number;
14
- maskedEmail?: string;
15
- tokenExpiry?: string;
16
- toolSchemaWarnings?: string;
17
- fetchTrace?: string;
18
- };
19
-
20
- const storage = new AsyncLocalStorage<DiagnosticsSnapshot>();
21
-
22
- /** Last completed request snapshot for `/antigravity.doctor`. */
23
- let lastSnapshot: DiagnosticsSnapshot = {};
24
-
25
- function currentBag(): DiagnosticsSnapshot {
26
- return storage.getStore() ?? lastSnapshot;
27
- }
28
-
29
- /** Run work with an isolated diagnostics bag; commits it to `lastSnapshot` when done. */
30
- export async function runWithDiagnostics<T>(fn: () => Promise<T>): Promise<T> {
31
- const bag: DiagnosticsSnapshot = {};
32
- return storage.run(bag, async () => {
33
- try {
34
- return await fn();
35
- } finally {
36
- lastSnapshot = { ...bag };
37
- }
38
- });
39
- }
40
-
41
- export function getLastDiagnostics(): Readonly<DiagnosticsSnapshot> {
42
- return lastSnapshot;
43
- }
44
-
45
- /** Read endpoint from the active request bag (or last snapshot outside a request). */
46
- export function getCurrentEndpoint(): string | undefined {
47
- return currentBag().endpoint;
48
- }
49
-
50
- export function getCurrentMatchedModelDebug(): string | undefined {
51
- return currentBag().matchedModelDebug;
52
- }
53
-
54
- export function getCurrentAvailableModels(): string | undefined {
55
- return currentBag().availableModels;
56
- }
57
-
58
- /** The bounded fetch history survives a small model-facing details budget. */
59
- export function setLastFetchTrace(trace: string): void {
60
- currentBag().fetchTrace = cleanText(stripValidationUrls(redactSecrets(trace)), 6_000);
61
- }
62
-
63
- export function setLastStatus(status: number | undefined): void {
64
- currentBag().status = status;
65
- }
66
- export function setLastEndpoint(endpoint: string | undefined): void {
67
- currentBag().endpoint = endpoint;
68
- }
69
- export function setLastError(error: string | undefined): void {
70
- currentBag().error =
71
- error === undefined ? undefined : stripValidationUrls(redactSecrets(error)).slice(0, 800);
72
- }
73
- export function setLastProjectId(projectId: string | undefined): void {
74
- currentBag().projectId = projectId;
75
- }
76
- export function setLastResolvedRuntimeModel(model: string | undefined): void {
77
- currentBag().resolvedRuntimeModel = model;
78
- }
79
- export function setLastAvailableModels(models: string | undefined): void {
80
- currentBag().availableModels = models;
81
- }
82
- export function setLastMatchedModelDebug(debug: string | undefined): void {
83
- currentBag().matchedModelDebug =
84
- debug === undefined ? undefined : redactSecrets(debug).slice(0, 1200);
85
- }
86
- export function setLastLatencyMs(ms: number | undefined): void {
87
- currentBag().latencyMs = ms;
88
- }
89
- export function setLastMaskedEmail(email: string | undefined): void {
90
- currentBag().maskedEmail = email;
91
- }
92
- export function setLastTokenExpiry(expiry: string | undefined): void {
93
- currentBag().tokenExpiry = expiry;
94
- }
95
- /** Store sanitized tool-schema omissions for the next doctor report. */
96
- export function setLastToolSchemaWarnings(warnings: string[] | undefined): void {
97
- currentBag().toolSchemaWarnings =
98
- warnings === undefined ? undefined : redactSecrets(warnings.join(" | ")).slice(0, 1200);
99
- }
100
-
101
- /** Test helper: reset last snapshot between cases. */
102
- export function resetDiagnosticsForTests(): void {
103
- lastSnapshot = {};
104
- }
@@ -1 +0,0 @@
1
- export * from "./diagnostics.js";
@@ -1,132 +0,0 @@
1
- /**
2
- * Optional model-facing image tool.
3
- * Disable this extension resource in `pi config` to keep the Antigravity provider
4
- * and `/antigravity.image` without registering `generate_image`.
5
- */
6
- import { readFile, realpath } from "node:fs/promises";
7
- import { isAbsolute, relative, resolve, sep } from "node:path";
8
- import {
9
- detectSupportedImageMimeTypeFromFile,
10
- type ExtensionAPI,
11
- } from "@earendil-works/pi-coding-agent";
12
- import { Type } from "typebox";
13
- import {
14
- DEFAULT_IMAGE_MODEL,
15
- generateAntigravityImage,
16
- IMAGE_ASPECT_RATIOS,
17
- } from "../image/index.js";
18
- import { extraToolExposure, isExtraToolEnabled } from "../utils/index.js";
19
-
20
- export default function (pi: ExtensionAPI): void {
21
- if (!isExtraToolEnabled("IMAGE")) return;
22
- pi.registerTool({
23
- ...extraToolExposure(),
24
- name: "generate_image",
25
- label: "Generate image",
26
- description:
27
- "Generate an image via Antigravity using the signed-in Google account, optionally guided by local reference images. Saves under .pi/generated-images/ unless path is set.",
28
- promptSnippet: "Generate images via Antigravity OAuth (Gemini image models)",
29
- promptGuidelines: [
30
- "Use generate_image when the user asks to create, draw, or generate an image.",
31
- ],
32
- parameters: Type.Object({
33
- prompt: Type.String({ description: "Image description." }),
34
- aspectRatio: Type.Optional(
35
- Type.Unsafe<(typeof IMAGE_ASPECT_RATIOS)[number]>({
36
- type: "string",
37
- enum: [...IMAGE_ASPECT_RATIOS],
38
- }),
39
- ),
40
- model: Type.Optional(
41
- Type.String({
42
- description: `Image model id. Default: ${DEFAULT_IMAGE_MODEL}.`,
43
- }),
44
- ),
45
- referenceImages: Type.Optional(
46
- Type.Array(
47
- Type.String({
48
- description: "Project-relative reference image path (PNG, JPEG, WebP, or GIF).",
49
- }),
50
- { description: "Reference images to send alongside the prompt." },
51
- ),
52
- ),
53
- path: Type.Optional(
54
- Type.String({
55
- description: "Project-relative file or directory to save the image.",
56
- }),
57
- ),
58
- }),
59
- async execute(_toolCallId, params, signal, onUpdate, ctx) {
60
- const apiKey = await ctx.modelRegistry.getApiKeyForProvider("antigravity");
61
- if (!apiKey) {
62
- throw new Error("No Antigravity credentials. Run /login antigravity first.");
63
- }
64
- const inputImages = [];
65
- const MAX_REFERENCE_IMAGES = 4;
66
- const MAX_REFERENCE_BYTES = 10 * 1024 * 1024;
67
- if (params.referenceImages && params.referenceImages.length > MAX_REFERENCE_IMAGES) {
68
- throw new Error(`At most ${MAX_REFERENCE_IMAGES} reference images are allowed.`);
69
- }
70
- if (params.referenceImages?.length) {
71
- const root = await realpath(ctx.cwd);
72
- for (const imagePath of params.referenceImages) {
73
- const target = await realpath(resolve(root, imagePath));
74
- const rel = relative(root, target);
75
- if (
76
- isAbsolute(imagePath) ||
77
- !rel ||
78
- rel === ".." ||
79
- rel.startsWith(`..${sep}`) ||
80
- isAbsolute(rel)
81
- ) {
82
- throw new Error(
83
- "Reference image paths must be project-relative and inside the working directory.",
84
- );
85
- }
86
- const mimeType = await detectSupportedImageMimeTypeFromFile(target);
87
- if (
88
- !mimeType ||
89
- !["image/png", "image/jpeg", "image/webp", "image/gif"].includes(mimeType)
90
- ) {
91
- throw new Error(
92
- `Unsupported reference image: ${imagePath}. Use PNG, JPEG, WebP, or GIF.`,
93
- );
94
- }
95
- const data = await readFile(target, { signal });
96
- if (data.byteLength > MAX_REFERENCE_BYTES) {
97
- throw new Error(
98
- `Reference image is too large: ${imagePath}. Each reference must be at most 10 MB.`,
99
- );
100
- }
101
- inputImages.push({ data: data.toString("base64"), mimeType });
102
- }
103
- }
104
- onUpdate?.({ content: [{ type: "text", text: "Generating image…" }], details: {} });
105
- const result = await generateAntigravityImage({
106
- apiKey,
107
- cwd: ctx.cwd,
108
- prompt: params.prompt,
109
- aspectRatio: params.aspectRatio,
110
- model: params.model,
111
- path: params.path,
112
- inputImages,
113
- signal,
114
- });
115
- const notes = result.text.join(" ").trim();
116
- return {
117
- content: [
118
- {
119
- type: "text" as const,
120
- text: `Saved image to ${result.savedPaths.join(", ")}${notes ? `. ${notes}` : ""}`,
121
- },
122
- ...result.images.map((image) => ({
123
- type: "image" as const,
124
- data: image.data,
125
- mimeType: image.mimeType,
126
- })),
127
- ],
128
- details: { model: result.model, savedPaths: result.savedPaths },
129
- };
130
- },
131
- });
132
- }
@@ -1,72 +0,0 @@
1
- /**
2
- * Optional model-facing search tool.
3
- * Disable this extension resource in `pi config` to keep the Antigravity provider
4
- * and `/antigravity.search` without registering `google_search`.
5
- */
6
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
7
- import { Type } from "typebox";
8
- import { executeAntigravitySearch } from "../search/index.js";
9
- import { extraToolExposure, isExtraToolEnabled, redactSecrets } from "../utils/index.js";
10
-
11
- export default function (pi: ExtensionAPI): void {
12
- if (!isExtraToolEnabled("SEARCH")) return;
13
- pi.registerTool({
14
- ...extraToolExposure(),
15
- name: "google_search",
16
- label: "Google Search",
17
- description:
18
- "Search the web using Google Search via Antigravity Grounding. Returns a compact evidence brief with source citations. Use this whenever current, real-time information or web research is needed.",
19
- promptSnippet: "Real-time Google Search grounding via Antigravity",
20
- promptGuidelines: [
21
- "Use google_search when you need real-time, up-to-date web information, latest news, documentation, or fact checking.",
22
- "Pass specific URLs into the urls array if you want the search engine to fetch and analyze specific pages.",
23
- "Set instruction to provide special research directives from the lead agent (e.g. focus on issues, compare benchmarks, restrict time range).",
24
- ],
25
- parameters: Type.Object({
26
- query: Type.String({ description: "Search query or question." }),
27
- instruction: Type.Optional(
28
- Type.String({
29
- description:
30
- "Specific directive or focus from the lead agent (e.g., '重点关注英文社区近七天的讨论', 'focus on GitHub issues and benchmarks', 'ignore marketing announcements').",
31
- }),
32
- ),
33
- urls: Type.Optional(
34
- Type.Array(Type.String(), {
35
- description: "Optional specific URLs to fetch and analyze alongside the search.",
36
- }),
37
- ),
38
- thinking: Type.Optional(
39
- Type.Boolean({
40
- description: "Enable deeper thinking for complex analysis (default: false).",
41
- }),
42
- ),
43
- }),
44
- async execute(_toolCallId, params, signal, onUpdate, ctx) {
45
- const apiKey = await ctx.modelRegistry.getApiKeyForProvider("antigravity");
46
- if (!apiKey) {
47
- throw new Error("No Antigravity credentials. Run /login antigravity first.");
48
- }
49
- onUpdate?.({
50
- content: [{ type: "text", text: `Searching Google for: "${params.query}"…` }],
51
- details: {},
52
- });
53
- try {
54
- const result = await executeAntigravitySearch({
55
- apiKey,
56
- query: params.query,
57
- instruction: params.instruction,
58
- urls: params.urls,
59
- thinking: params.thinking,
60
- signal,
61
- });
62
- return {
63
- content: [{ type: "text", text: result }],
64
- details: {},
65
- };
66
- } catch (error) {
67
- const msg = error instanceof Error ? error.message : String(error);
68
- throw new Error(redactSecrets(msg), { cause: error });
69
- }
70
- },
71
- });
72
- }
@@ -1,124 +0,0 @@
1
- /**
2
- * Optional model-facing web fetch tool.
3
- * Disable this extension resource in `pi config` to keep the Antigravity provider
4
- * and `/antigravity.fetch` without registering `read_url_content`.
5
- */
6
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
7
- import { Type } from "typebox";
8
- import { isExtraToolEnabled, redactSecrets } from "../utils/index.js";
9
- import {
10
- executeAntigravityWebFetch,
11
- formatWebFetchHeader,
12
- formatWebFetchResult,
13
- resolveMaxChars,
14
- discardSavedPage,
15
- savePage,
16
- savedPageNote,
17
- type SavedPage,
18
- validateFetchTarget,
19
- withSavedCopy,
20
- } from "../web-fetch/index.js";
21
-
22
- export default function (pi: Pick<ExtensionAPI, "registerTool">): void {
23
- if (!isExtraToolEnabled("FETCH")) return;
24
- pi.registerTool({
25
- name: "read_url_content",
26
- label: "Read URL Content",
27
- description:
28
- "Read a public web page through Google's Antigravity crawler and return it as markdown. Use it for documentation, articles, changelogs, and standards pages when search snippets are not enough. The crawl runs on Google's side: no JavaScript execution, no cookies, and no pages behind a login — for those, ask the user to open the page in their browser.",
29
- promptSnippet: "Read a public web page as markdown via the Antigravity crawler",
30
- promptGuidelines: [
31
- "Use read_url_content when you have a specific URL whose contents you need, instead of guessing from a search result summary.",
32
- "One URL per call, and prefer the page that holds the answer over a site root or a category index.",
33
- "Long pages return their beginning and save the full page to a local file; read or search that file instead of fetching the URL again.",
34
- "It cannot log in, run JavaScript, or read local and private addresses, so do not use it for those.",
35
- ],
36
- parameters: Type.Object({
37
- url: Type.String({ description: "Public http(s) URL to fetch." }),
38
- }),
39
- async execute(_toolCallId, params, signal, onUpdate, ctx) {
40
- if (signal?.aborted) throw new Error("Web fetch aborted");
41
- const maxChars = resolveMaxChars();
42
- try {
43
- const url = validateFetchTarget(params.url);
44
- const apiKey = await ctx.modelRegistry.getApiKeyForProvider("antigravity");
45
- if (!apiKey) throw new Error("No Antigravity credentials. Run /login antigravity first.");
46
- if (signal?.aborted) throw new Error("Web fetch aborted");
47
- onUpdate?.({
48
- content: [{ type: "text", text: `Reading ${redactSecrets(url)}…` }],
49
- details: {},
50
- });
51
- const result = await executeAntigravityWebFetch({ apiKey, url, signal });
52
- if (signal?.aborted) throw new Error("Web fetch aborted");
53
- const attempts: Array<{
54
- source: string;
55
- outcome: string;
56
- url?: string;
57
- stage?: string;
58
- endpoint?: string;
59
- }> = [...(result.attempts ?? [])];
60
- const details = {
61
- source: result.source,
62
- bytes: result.bytes,
63
- truncated: false,
64
- partial: result.partial,
65
- assessment: result.assessment,
66
- representationUrl: result.representationUrl
67
- ? redactSecrets(result.representationUrl)
68
- : undefined,
69
- attempts,
70
- omittedAttempts: 0,
71
- fullOutputPath: undefined as string | undefined,
72
- };
73
- const detailsBudget = Math.floor(maxChars * 0.4);
74
- const size = () => JSON.stringify(details).length;
75
- while (size() > detailsBudget && details.attempts.length > 1) {
76
- details.attempts.shift();
77
- details.omittedAttempts += 1;
78
- }
79
- if (size() > detailsBudget && details.attempts.length === 1) {
80
- const last = details.attempts[0];
81
- details.attempts = [{ source: last.source, stage: last.stage, outcome: last.outcome }];
82
- }
83
- if (size() > detailsBudget) details.representationUrl = undefined;
84
- if (size() > detailsBudget && details.attempts.length) {
85
- details.attempts = [];
86
- details.omittedAttempts += 1;
87
- }
88
- const full = result.content;
89
- const captured = { ...result, maxChars: maxChars - size() };
90
- let footer = "";
91
- let saved: SavedPage | undefined;
92
- if (formatWebFetchHeader(captured).length + full.length > captured.maxChars) {
93
- // Pi's convention for long tool output: show the start, keep the whole on disk.
94
- saved = await savePage(formatWebFetchHeader(result) + full, "md");
95
- footer = savedPageNote(saved, full.length);
96
- if (saved.ok) details.fullOutputPath = saved.path;
97
- details.truncated = true;
98
- // The path is part of details too, so charge it before formatting.
99
- captured.maxChars = maxChars - size();
100
- }
101
- let text: string;
102
- try {
103
- if (signal?.aborted) throw new Error("Web fetch aborted");
104
- text = formatWebFetchResult(captured, footer);
105
- } catch (error) {
106
- // No answer will name the file, so leave none behind.
107
- if (saved) await discardSavedPage(saved);
108
- throw error;
109
- }
110
- return {
111
- content: [{ type: "text", text }],
112
- details,
113
- };
114
- } catch (caught) {
115
- const error = await withSavedCopy(caught);
116
- const msg = error instanceof Error ? error.message : String(error);
117
- // Error causes can retain request objects and response text; keep only a redacted message.
118
- const safe = redactSecrets(msg);
119
- // eslint-disable-next-line preserve-caught-error -- the raw cause can retain request/response bodies
120
- throw new Error(safe, { cause: new Error(safe) });
121
- }
122
- },
123
- });
124
- }