@herbertgao/pi-extensions 2026.10.10 → 2026.10.11

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 (108) hide show
  1. package/README.md +10 -8
  2. package/THIRD_PARTY_NOTICES.md +2 -2
  3. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +3 -0
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.md +3 -0
  5. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +1 -1
  6. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +3 -3
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +126 -42
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +24 -6
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +69 -16
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts +1 -1
  11. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  12. package/node_modules/@herbertgao/sol-pi/README.md +7 -1
  13. package/node_modules/@herbertgao/sol-pi/docs/compatibility.md +28 -4
  14. package/node_modules/@herbertgao/sol-pi/docs/configuration.md +17 -4
  15. package/node_modules/@herbertgao/sol-pi/package.json +1 -1
  16. package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/action-fusion/index.ts +35 -25
  17. package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/action-fusion/then-run.ts +95 -26
  18. package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/evidence-preserving-reducer/candidate.ts +39 -2
  19. package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/evidence-preserving-reducer/index.ts +24 -0
  20. package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/observation-pack/index.ts +12 -7
  21. package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/extension.ts +138 -130
  22. package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/projection.ts +88 -14
  23. package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/tools.ts +9 -0
  24. package/node_modules/@herbertgao/sol-pi/src/sol-pi/index.ts +14 -5
  25. package/node_modules/@herbertgao/sol-pi/src/sol-pi/shell-options.ts +22 -0
  26. package/node_modules/@herbertgao/sol-pi/src/sol-pi/tui.ts +11 -0
  27. package/node_modules/@juicesharp/rpiv-ask-user-question/answer-channel.ts +109 -0
  28. package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +117 -71
  29. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +2 -0
  30. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +3 -1
  31. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/startup-performance.md +83 -0
  32. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/tool-schema.md +74 -5
  33. package/node_modules/@juicesharp/rpiv-ask-user-question/events.ts +84 -0
  34. package/node_modules/@juicesharp/rpiv-ask-user-question/index.ts +10 -4
  35. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +4 -2
  36. package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +1 -1
  37. package/node_modules/@juicesharp/rpiv-ask-user-question/reconcile.ts +1 -1
  38. package/node_modules/@juicesharp/rpiv-ask-user-question/rpc-fallback.ts +5 -4
  39. package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +19 -19
  40. package/node_modules/@juicesharp/rpiv-ask-user-question/state/i18n-bridge.ts +1 -1
  41. package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +7 -4
  42. package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +10 -10
  43. package/node_modules/@juicesharp/rpiv-ask-user-question/state/row-intent.ts +2 -2
  44. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/contract.ts +6 -6
  45. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/derivations.ts +2 -2
  46. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/focus.ts +1 -1
  47. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/projections.ts +9 -9
  48. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +5 -5
  49. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +2 -2
  50. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/external-answer.ts +125 -0
  51. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/format-answer.ts +1 -1
  52. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/normalize-params.ts +1 -1
  53. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/response-envelope.ts +2 -2
  54. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/types.ts +1 -1
  55. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/validate-questionnaire.ts +1 -1
  56. package/node_modules/@juicesharp/rpiv-ask-user-question/view/component-binding.ts +4 -4
  57. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/multi-select-view.ts +4 -4
  58. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/option-list-view.ts +2 -2
  59. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/markdown-content-cache.ts +3 -3
  60. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +5 -5
  61. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-layout-decider.ts +3 -3
  62. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-pane.ts +10 -10
  63. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/submit-picker.ts +2 -2
  64. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/tab-bar.ts +1 -1
  65. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/wrapping-select.ts +1 -1
  66. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +9 -9
  67. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +1 -1
  68. package/node_modules/@juicesharp/rpiv-ask-user-question/view/props-adapter.ts +8 -8
  69. package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-components.ts +4 -4
  70. package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +10 -10
  71. package/node_modules/@narumitw/pi-btw/dist/index.ts +3 -0
  72. package/node_modules/@narumitw/pi-btw/dist/index.ts.map +2 -2
  73. package/node_modules/@narumitw/pi-btw/package.json +4 -4
  74. package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +6 -0
  75. package/node_modules/@narumitw/pi-btw/src/keybindings.ts +1 -1
  76. package/node_modules/@narumitw/pi-caffeinate/dist/index.ts +1 -0
  77. package/node_modules/@narumitw/pi-caffeinate/dist/index.ts.map +2 -2
  78. package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
  79. package/node_modules/@narumitw/pi-caffeinate/src/inhibitor-process.ts +1 -0
  80. package/node_modules/pi-antigravity/README.md +6 -2
  81. package/node_modules/pi-antigravity/package.json +2 -2
  82. package/node_modules/pi-antigravity/src/client/client.ts +44 -52
  83. package/node_modules/pi-antigravity/src/index.ts +13 -0
  84. package/node_modules/pi-antigravity/src/models/discovery.ts +25 -2
  85. package/node_modules/pi-antigravity/src/models/grouping.ts +107 -68
  86. package/node_modules/pi-antigravity/src/models/models.ts +10 -0
  87. package/node_modules/pi-antigravity/src/search/search.ts +581 -43
  88. package/node_modules/pi-antigravity/src/stream/stream.ts +53 -13
  89. package/node_modules/pi-antigravity/src/types/types.ts +13 -0
  90. package/node_modules/pi-antigravity/src/usage/usage.ts +11 -3
  91. package/node_modules/pi-web-access/CHANGELOG.md +21 -0
  92. package/node_modules/pi-web-access/README.md +22 -7
  93. package/node_modules/pi-web-access/credential-source.ts +54 -4
  94. package/node_modules/pi-web-access/curator-page.ts +3 -1
  95. package/node_modules/pi-web-access/curator-server.ts +1 -0
  96. package/node_modules/pi-web-access/deepseek.ts +204 -0
  97. package/node_modules/pi-web-access/dist/index.js +927 -642
  98. package/node_modules/pi-web-access/dist/mcp-cli.js +877 -615
  99. package/node_modules/pi-web-access/gemini-adc.ts +48 -1
  100. package/node_modules/pi-web-access/gemini-search.ts +8 -4
  101. package/node_modules/pi-web-access/index.ts +16 -1
  102. package/node_modules/pi-web-access/package.json +1 -1
  103. package/node_modules/pi-web-access/page-query.ts +12 -6
  104. package/node_modules/pi-web-access/query-rewrite.ts +16 -13
  105. package/node_modules/pi-web-access/summary-review.ts +16 -6
  106. package/node_modules/pi-web-access/utils.ts +3 -0
  107. package/node_modules/pi-web-access/web-tool-core.ts +2 -0
  108. package/package.json +9 -9
@@ -0,0 +1,204 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { activityMonitor } from "./activity.ts";
3
+ import { normalizeDomain } from "./domain-filter-normalization.ts";
4
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
5
+ import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
6
+ import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
7
+ import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
8
+ import { fetchWithCredentialRedirects, getWebSearchConfigPath } from "./utils.ts";
9
+
10
+ const DEEPSEEK_SEARCH_URL = "https://api.deepseek.com/v1/tools/search";
11
+ const CONFIG_PATH = getWebSearchConfigPath();
12
+ const SEARCH_TIMEOUT_MS = 30_000;
13
+ // The API rejects queries over 128 Unicode characters, operators included.
14
+ const MAX_QUERY_CHARS = 128;
15
+ // `summary` is documented as 600-800 characters and written for models; keep it whole.
16
+ const MAX_SNIPPET_CHARS = 800;
17
+ const RECENCY_DAYS: Record<NonNullable<SearchOptions["recencyFilter"]>, number> = {
18
+ day: 1,
19
+ week: 7,
20
+ month: 30,
21
+ year: 365,
22
+ };
23
+
24
+ interface WebSearchConfig {
25
+ deepseekApiKey?: unknown;
26
+ }
27
+
28
+ interface DeepSeekResult {
29
+ title?: unknown;
30
+ url?: unknown;
31
+ snippet?: unknown;
32
+ summary?: unknown;
33
+ }
34
+
35
+ let cachedConfig: WebSearchConfig | null = null;
36
+
37
+ function loadConfig(): WebSearchConfig {
38
+ if (cachedConfig) return cachedConfig;
39
+ if (!existsSync(CONFIG_PATH)) {
40
+ cachedConfig = {};
41
+ return cachedConfig;
42
+ }
43
+ const raw = readFileSync(CONFIG_PATH, "utf-8");
44
+ let parsed: unknown;
45
+ try {
46
+ parsed = JSON.parse(raw);
47
+ } catch (err) {
48
+ const message = err instanceof Error ? err.message : String(err);
49
+ throw new Error(`Failed to parse ${CONFIG_PATH}: ${message}`);
50
+ }
51
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
52
+ throw new Error(`Invalid config in ${CONFIG_PATH}: expected a JSON object`);
53
+ }
54
+ cachedConfig = parsed as WebSearchConfig;
55
+ return cachedConfig;
56
+ }
57
+
58
+ async function requireApiKey(signal?: AbortSignal): Promise<string> {
59
+ const apiKey = await resolveCredential({
60
+ provider: "DeepSeek",
61
+ configuredValue: loadConfig().deepseekApiKey,
62
+ environmentValue: process.env.DEEPSEEK_API_KEY,
63
+ signal,
64
+ });
65
+ if (!apiKey) {
66
+ throw new Error(
67
+ "DeepSeek API key not found. Either:\n" +
68
+ ` 1. Create ${CONFIG_PATH} with { "deepseekApiKey": "your-key" }\n` +
69
+ " 2. Set DEEPSEEK_API_KEY environment variable\n" +
70
+ "Get a key at https://platform.deepseek.com/api_keys",
71
+ );
72
+ }
73
+ return apiKey;
74
+ }
75
+
76
+ // DeepSeek documents `site:` joined with OR, `-site:`, and `after:<date>` as query operators.
77
+ function buildQuery(query: string, options: SearchOptions): string {
78
+ const include: string[] = [];
79
+ const exclude: string[] = [];
80
+ for (const raw of options.domainFilter ?? []) {
81
+ const domain = normalizeDomain(raw);
82
+ if (!domain) continue;
83
+ const target = raw.trim().startsWith("-") ? exclude : include;
84
+ if (!target.includes(domain)) target.push(domain);
85
+ }
86
+ const parts = [query.trim()];
87
+ if (include.length > 0) parts.push(include.map(domain => `site:${domain}`).join(" OR "));
88
+ for (const domain of exclude) parts.push(`-site:${domain}`);
89
+ if (options.recencyFilter) {
90
+ const after = new Date(Date.now() - RECENCY_DAYS[options.recencyFilter] * 86_400_000).toISOString().slice(0, 10);
91
+ parts.push(`after:${after}`);
92
+ }
93
+ const built = parts.join(" ");
94
+ const length = [...built].length;
95
+ if (length > MAX_QUERY_CHARS) {
96
+ throw new Error(`DeepSeek invalid request: the query is ${length} characters with domain and date filters; DeepSeek accepts at most ${MAX_QUERY_CHARS}`);
97
+ }
98
+ return built;
99
+ }
100
+
101
+ function text(value: unknown): string {
102
+ return typeof value === "string" ? value.replace(/\s+/g, " ").trim() : "";
103
+ }
104
+
105
+ function errorMessage(err: unknown): string {
106
+ return err instanceof Error ? err.message : String(err);
107
+ }
108
+
109
+ function parseResponse(value: unknown): DeepSeekResult[] {
110
+ const results = value && typeof value === "object" && !Array.isArray(value) ? (value as Record<string, unknown>).results : undefined;
111
+ if (!Array.isArray(results)) throw new Error("DeepSeek returned invalid response: expected a results array");
112
+ return results as DeepSeekResult[];
113
+ }
114
+
115
+ // Errors use the OpenAI shape `{ error: { message, type, param, code } }`.
116
+ function describeError(body: string): string {
117
+ try {
118
+ const error = (JSON.parse(body) as { error?: { message?: unknown } }).error;
119
+ const message = text(error?.message);
120
+ if (message) return message;
121
+ } catch {}
122
+ return body;
123
+ }
124
+
125
+ export function isDeepSeekAvailable(): boolean {
126
+ return hasCredentialSource({ provider: "DeepSeek", configuredValue: loadConfig().deepseekApiKey, environmentValue: process.env.DEEPSEEK_API_KEY });
127
+ }
128
+
129
+ export async function searchWithDeepSeek(query: string, options: SearchOptions = {}): Promise<SearchResponse> {
130
+ const builtQuery = buildQuery(query, options);
131
+ const apiKey = await requireApiKey(options.signal);
132
+ const numResults = normalizeSearchResultCount(options.numResults);
133
+ const activityId = activityMonitor.logStart({ type: "api", query });
134
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS);
135
+ let response: Response;
136
+ let entries: DeepSeekResult[];
137
+ try {
138
+ response = await fetchWithCredentialRedirects(DEEPSEEK_SEARCH_URL, {
139
+ method: "POST",
140
+ headers: {
141
+ Accept: "application/json",
142
+ "Content-Type": "application/json",
143
+ Authorization: `Bearer ${apiKey}`,
144
+ },
145
+ body: JSON.stringify({ query: builtQuery, count: numResults }),
146
+ signal: options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal,
147
+ }, ["Authorization"]);
148
+ if (!response.ok) {
149
+ const errorText = redactCredential(describeError(await response.text()), apiKey).slice(0, 300);
150
+ throw new Error(`DeepSeek error ${response.status}: ${errorText}`);
151
+ }
152
+ let rawData: unknown;
153
+ try {
154
+ rawData = await response.json();
155
+ } catch (err) {
156
+ if (err instanceof Error && err.name === "TimeoutError") throw err;
157
+ throw new Error(`DeepSeek returned invalid JSON: ${errorMessage(err)}`);
158
+ }
159
+ entries = parseResponse(rawData);
160
+ } catch (err) {
161
+ if (options.signal?.aborted) {
162
+ activityMonitor.logComplete(activityId, 0);
163
+ throw new Error("Aborted");
164
+ }
165
+ const message = errorMessage(err);
166
+ const providerTimeout = timeoutSignal.aborted || (err instanceof Error && err.name === "TimeoutError");
167
+ const outgoing = providerTimeout
168
+ ? new Error(`DeepSeek request timed out after ${Math.round(SEARCH_TIMEOUT_MS / 1000)}s`)
169
+ : (() => {
170
+ const redactedMessage = redactCredential(message, apiKey);
171
+ if (redactedMessage === message && err instanceof Error) return err;
172
+ const redactedError = new Error(redactedMessage);
173
+ if (err instanceof Error) redactedError.name = err.name;
174
+ return redactedError;
175
+ })();
176
+ activityMonitor.logError(activityId, redactCredential(errorMessage(outgoing), apiKey));
177
+ throw outgoing;
178
+ }
179
+ activityMonitor.logComplete(activityId, response.status);
180
+ const results: SearchResponse["results"] = [];
181
+ const seen = new Set<string>();
182
+ for (const entry of entries) {
183
+ if (!entry || typeof entry !== "object") continue;
184
+ if (typeof entry.url !== "string" || !entry.url) continue;
185
+ let resultUrl: URL;
186
+ try {
187
+ resultUrl = new URL(entry.url);
188
+ } catch {
189
+ continue;
190
+ }
191
+ if (resultUrl.protocol !== "http:" && resultUrl.protocol !== "https:") continue;
192
+ if (seen.has(resultUrl.href)) continue;
193
+ seen.add(resultUrl.href);
194
+ results.push({
195
+ title: text(entry.title) || `Source ${results.length + 1}`,
196
+ url: resultUrl.href,
197
+ snippet: (text(entry.summary) || text(entry.snippet)).slice(0, MAX_SNIPPET_CHARS),
198
+ });
199
+ if (results.length >= numResults) break;
200
+ }
201
+ // A non-empty page with no usable entry is a broken response, not "no results", so routing can fall back.
202
+ if (entries.length > 0 && results.length === 0) throw new Error("DeepSeek returned invalid response: no result had an http(s) URL");
203
+ return { answer: formatSearchResultsAsAnswer(results), results };
204
+ }