@oh-my-pi/pi-coding-agent 15.10.12 → 15.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/CHANGELOG.md +90 -4
  2. package/dist/cli.js +869 -825
  3. package/dist/types/async/index.d.ts +0 -1
  4. package/dist/types/capability/mcp.d.ts +1 -0
  5. package/dist/types/cli/gallery-fixtures/types.d.ts +5 -0
  6. package/dist/types/config/keybindings.d.ts +6 -1
  7. package/dist/types/config/settings-schema.d.ts +66 -34
  8. package/dist/types/export/html/template.generated.d.ts +1 -1
  9. package/dist/types/extensibility/custom-tools/types.d.ts +2 -2
  10. package/dist/types/extensibility/shared-events.d.ts +2 -2
  11. package/dist/types/internal-urls/history-protocol.d.ts +14 -0
  12. package/dist/types/internal-urls/index.d.ts +1 -0
  13. package/dist/types/internal-urls/types.d.ts +1 -1
  14. package/dist/types/irc/bus.d.ts +66 -0
  15. package/dist/types/mcp/oauth-discovery.d.ts +2 -0
  16. package/dist/types/mcp/oauth-flow.d.ts +6 -1
  17. package/dist/types/mcp/transports/stdio.d.ts +1 -0
  18. package/dist/types/mcp/types.d.ts +2 -0
  19. package/dist/types/modes/components/agent-hub.d.ts +30 -0
  20. package/dist/types/modes/components/assistant-message.d.ts +1 -0
  21. package/dist/types/modes/components/compaction-summary-message.d.ts +10 -4
  22. package/dist/types/modes/components/custom-editor.d.ts +2 -0
  23. package/dist/types/modes/components/mcp-add-wizard.d.ts +2 -1
  24. package/dist/types/modes/components/settings-selector.d.ts +1 -0
  25. package/dist/types/modes/components/status-line/types.d.ts +3 -0
  26. package/dist/types/modes/components/tool-execution.d.ts +8 -0
  27. package/dist/types/modes/components/transcript-container.d.ts +3 -2
  28. package/dist/types/modes/components/ttsr-notification.d.ts +5 -1
  29. package/dist/types/modes/components/welcome.d.ts +3 -9
  30. package/dist/types/modes/controllers/selector-controller.d.ts +1 -1
  31. package/dist/types/modes/controllers/tool-args-reveal.d.ts +43 -0
  32. package/dist/types/modes/interactive-mode.d.ts +3 -2
  33. package/dist/types/modes/theme/theme.d.ts +3 -1
  34. package/dist/types/modes/types.d.ts +3 -2
  35. package/dist/types/modes/utils/ui-helpers.d.ts +1 -1
  36. package/dist/types/registry/agent-lifecycle.d.ts +51 -0
  37. package/dist/types/registry/agent-registry.d.ts +16 -5
  38. package/dist/types/session/agent-session.d.ts +35 -30
  39. package/dist/types/session/messages.d.ts +2 -4
  40. package/dist/types/session/session-history-format.d.ts +12 -0
  41. package/dist/types/session/session-manager.d.ts +21 -3
  42. package/dist/types/session/streaming-output.d.ts +23 -0
  43. package/dist/types/task/executor.d.ts +11 -2
  44. package/dist/types/task/index.d.ts +11 -4
  45. package/dist/types/task/output-manager.d.ts +0 -7
  46. package/dist/types/task/repair-args.d.ts +8 -7
  47. package/dist/types/task/types.d.ts +55 -51
  48. package/dist/types/tools/browser/tab-worker.d.ts +3 -1
  49. package/dist/types/tools/find.d.ts +0 -11
  50. package/dist/types/tools/grouped-file-output.d.ts +0 -49
  51. package/dist/types/tools/index.d.ts +1 -3
  52. package/dist/types/tools/irc.d.ts +76 -38
  53. package/dist/types/tools/job.d.ts +7 -1
  54. package/dist/types/tools/render-utils.d.ts +22 -0
  55. package/examples/extensions/with-deps/package.json +1 -0
  56. package/package.json +11 -10
  57. package/scripts/bundle-dist.ts +28 -19
  58. package/src/async/index.ts +0 -1
  59. package/src/capability/mcp.ts +1 -0
  60. package/src/cli/gallery-cli.ts +6 -5
  61. package/src/cli/gallery-fixtures/agentic.ts +230 -115
  62. package/src/cli/gallery-fixtures/types.ts +5 -0
  63. package/src/cli.ts +20 -6
  64. package/src/commit/agentic/tools/analyze-file.ts +38 -19
  65. package/src/config/keybindings.ts +6 -1
  66. package/src/config/mcp-schema.json +4 -0
  67. package/src/config/settings-schema.ts +68 -41
  68. package/src/config/settings.ts +7 -0
  69. package/src/edit/renderer.ts +96 -46
  70. package/src/eval/__tests__/agent-bridge.test.ts +5 -3
  71. package/src/eval/agent-bridge.ts +3 -16
  72. package/src/eval/js/shared/prelude.txt +1 -1
  73. package/src/eval/py/prelude.py +5 -6
  74. package/src/export/html/template.generated.ts +1 -1
  75. package/src/export/html/template.js +44 -14
  76. package/src/extensibility/custom-tools/types.ts +2 -2
  77. package/src/extensibility/shared-events.ts +2 -2
  78. package/src/internal-urls/docs-index.generated.ts +9 -9
  79. package/src/internal-urls/history-protocol.ts +113 -0
  80. package/src/internal-urls/index.ts +1 -0
  81. package/src/internal-urls/router.ts +3 -1
  82. package/src/internal-urls/types.ts +1 -1
  83. package/src/irc/bus.ts +292 -0
  84. package/src/main.ts +8 -60
  85. package/src/mcp/manager.ts +3 -0
  86. package/src/mcp/oauth-discovery.ts +27 -2
  87. package/src/mcp/oauth-flow.ts +47 -1
  88. package/src/mcp/transports/stdio.ts +3 -0
  89. package/src/mcp/types.ts +2 -0
  90. package/src/modes/components/{session-observer-overlay.ts → agent-hub.ts} +586 -367
  91. package/src/modes/components/assistant-message.ts +15 -0
  92. package/src/modes/components/btw-panel.ts +5 -1
  93. package/src/modes/components/compaction-summary-message.ts +68 -32
  94. package/src/modes/components/custom-editor.ts +10 -0
  95. package/src/modes/components/mcp-add-wizard.ts +13 -0
  96. package/src/modes/components/settings-selector.ts +2 -0
  97. package/src/modes/components/status-line/component.ts +22 -12
  98. package/src/modes/components/status-line/types.ts +3 -0
  99. package/src/modes/components/tool-execution.ts +31 -1
  100. package/src/modes/components/transcript-container.ts +99 -18
  101. package/src/modes/components/tree-selector.ts +6 -1
  102. package/src/modes/components/ttsr-notification.ts +72 -30
  103. package/src/modes/components/welcome.ts +9 -33
  104. package/src/modes/controllers/event-controller.ts +93 -4
  105. package/src/modes/controllers/extension-ui-controller.ts +8 -8
  106. package/src/modes/controllers/input-controller.ts +18 -2
  107. package/src/modes/controllers/mcp-command-controller.ts +34 -2
  108. package/src/modes/controllers/selector-controller.ts +25 -17
  109. package/src/modes/controllers/tool-args-reveal.ts +174 -0
  110. package/src/modes/interactive-mode.ts +17 -15
  111. package/src/modes/theme/theme.ts +24 -5
  112. package/src/modes/types.ts +3 -5
  113. package/src/modes/utils/hotkeys-markdown.ts +1 -0
  114. package/src/modes/utils/ui-helpers.ts +51 -49
  115. package/src/prompts/system/irc-incoming.md +3 -4
  116. package/src/prompts/system/orchestrate-notice.md +2 -2
  117. package/src/prompts/system/subagent-system-prompt.md +0 -5
  118. package/src/prompts/system/system-prompt.md +1 -0
  119. package/src/prompts/system/workflow-notice.md +2 -2
  120. package/src/prompts/tools/eval.md +3 -3
  121. package/src/prompts/tools/irc.md +29 -19
  122. package/src/prompts/tools/read.md +2 -2
  123. package/src/prompts/tools/task-summary.md +5 -16
  124. package/src/prompts/tools/task.md +43 -29
  125. package/src/registry/agent-lifecycle.ts +218 -0
  126. package/src/registry/agent-registry.ts +16 -5
  127. package/src/sdk.ts +29 -9
  128. package/src/session/agent-session.ts +268 -241
  129. package/src/session/messages.ts +11 -78
  130. package/src/session/session-history-format.ts +246 -0
  131. package/src/session/session-manager.ts +59 -5
  132. package/src/session/streaming-output.ts +60 -0
  133. package/src/task/executor.ts +855 -466
  134. package/src/task/index.ts +723 -794
  135. package/src/task/output-manager.ts +0 -11
  136. package/src/task/render.ts +142 -66
  137. package/src/task/repair-args.ts +21 -9
  138. package/src/task/types.ts +73 -66
  139. package/src/tools/ask.ts +4 -2
  140. package/src/tools/bash.ts +15 -5
  141. package/src/tools/browser/tab-worker.ts +26 -7
  142. package/src/tools/browser.ts +28 -1
  143. package/src/tools/find.ts +2 -27
  144. package/src/tools/grouped-file-output.ts +1 -118
  145. package/src/tools/index.ts +4 -12
  146. package/src/tools/irc.ts +596 -171
  147. package/src/tools/job.ts +41 -7
  148. package/src/tools/read.ts +57 -1
  149. package/src/tools/render-utils.ts +56 -0
  150. package/src/tools/renderers.ts +2 -0
  151. package/src/tools/resolve.ts +4 -1
  152. package/src/tools/write.ts +65 -47
  153. package/src/web/search/providers/anthropic.ts +29 -4
  154. package/dist/types/async/support.d.ts +0 -2
  155. package/dist/types/modes/components/session-observer-overlay.d.ts +0 -11
  156. package/dist/types/task/simple-mode.d.ts +0 -8
  157. package/src/async/support.ts +0 -5
  158. package/src/task/simple-mode.ts +0 -27
@@ -11,6 +11,7 @@ export interface OAuthEndpoints {
11
11
  tokenUrl: string;
12
12
  clientId?: string;
13
13
  scopes?: string;
14
+ resource?: string;
14
15
  }
15
16
 
16
17
  export interface AuthDetectionResult {
@@ -94,7 +95,12 @@ export function extractOAuthEndpoints(error: Error): OAuthEndpoints | null {
94
95
  (obj.default_client_id as string | undefined) ||
95
96
  (obj.public_client_id as string | undefined);
96
97
 
97
- return { authorizationUrl, tokenUrl, clientId, scopes };
98
+ const resource =
99
+ (obj.resource as string | undefined) ||
100
+ (obj.resource_uri as string | undefined) ||
101
+ (obj.resourceUri as string | undefined);
102
+
103
+ return { authorizationUrl, tokenUrl, clientId, scopes, resource };
98
104
  };
99
105
 
100
106
  const clientIdFromAuthUrl = (authorizationUrl: string): string | undefined => {
@@ -161,6 +167,7 @@ export function extractOAuthEndpoints(error: Error): OAuthEndpoints | null {
161
167
  challengeValues.get("realm");
162
168
  const tokenUrl =
163
169
  challengeValues.get("token_url") || challengeValues.get("token_uri") || challengeValues.get("token_endpoint");
170
+ const resource = challengeValues.get("resource") || challengeValues.get("resource_uri");
164
171
 
165
172
  if (authorizationUrl && tokenUrl) {
166
173
  return {
@@ -168,6 +175,7 @@ export function extractOAuthEndpoints(error: Error): OAuthEndpoints | null {
168
175
  tokenUrl,
169
176
  clientId: challengeValues.get("client_id") || clientIdFromAuthUrl(authorizationUrl),
170
177
  scopes: challengeValues.get("scope") || challengeValues.get("scopes") || scopeFromAuthUrl(authorizationUrl),
178
+ resource,
171
179
  };
172
180
  }
173
181
  }
@@ -250,7 +258,7 @@ export async function discoverOAuthEndpoints(
250
258
  serverUrl: string,
251
259
  authServerUrl?: string,
252
260
  resourceMetadataUrl?: string,
253
- opts?: { fetch?: FetchImpl },
261
+ opts?: { fetch?: FetchImpl; protectedResource?: string },
254
262
  ): Promise<OAuthEndpoints | null> {
255
263
  const fetchImpl: FetchImpl = opts?.fetch ?? fetch;
256
264
  const wellKnownPaths = [
@@ -264,6 +272,8 @@ export async function discoverOAuthEndpoints(
264
272
  const urlsToQuery: string[] = [];
265
273
  const visitedAuthServers = new Set<string>();
266
274
 
275
+ let protectedResource = opts?.protectedResource;
276
+
267
277
  // Step 1: If a resource_metadata URL was provided, fetch it to discover auth servers.
268
278
  // This follows the RFC 9728 chain: resource_metadata → authorization_servers.
269
279
  if (resourceMetadataUrl && !visitedAuthServers.has(resourceMetadataUrl)) {
@@ -276,6 +286,9 @@ export async function discoverOAuthEndpoints(
276
286
  });
277
287
  if (metaResp.ok) {
278
288
  const meta = (await metaResp.json()) as Record<string, unknown>;
289
+ if (typeof meta.resource === "string" && meta.resource.trim() !== "") {
290
+ protectedResource = meta.resource;
291
+ }
279
292
  const authServers = Array.isArray(meta.authorization_servers)
280
293
  ? meta.authorization_servers.filter((entry): entry is string => typeof entry === "string")
281
294
  : [];
@@ -304,6 +317,8 @@ export async function discoverOAuthEndpoints(
304
317
  const scopesSupported = Array.isArray(metadata.scopes_supported)
305
318
  ? metadata.scopes_supported.filter((scope): scope is string => typeof scope === "string").join(" ")
306
319
  : undefined;
320
+ const resource = typeof metadata.resource === "string" ? metadata.resource : protectedResource;
321
+
307
322
  return {
308
323
  authorizationUrl: String(metadata.authorization_endpoint),
309
324
  tokenUrl: String(metadata.token_endpoint),
@@ -324,12 +339,15 @@ export async function discoverOAuthEndpoints(
324
339
  : typeof metadata.scope === "string"
325
340
  ? metadata.scope
326
341
  : undefined),
342
+ resource,
327
343
  };
328
344
  }
329
345
 
330
346
  if (metadata.oauth || metadata.authorization || metadata.auth) {
331
347
  const oauthData = (metadata.oauth || metadata.authorization || metadata.auth) as Record<string, unknown>;
332
348
  if (typeof oauthData.authorization_url === "string" && typeof oauthData.token_url === "string") {
349
+ const resource = typeof oauthData.resource === "string" ? oauthData.resource : protectedResource;
350
+
333
351
  return {
334
352
  authorizationUrl: oauthData.authorization_url || String(oauthData.authorizationUrl),
335
353
  tokenUrl: oauthData.token_url || String(oauthData.tokenUrl),
@@ -349,6 +367,7 @@ export async function discoverOAuthEndpoints(
349
367
  : typeof oauthData.scope === "string"
350
368
  ? oauthData.scope
351
369
  : undefined,
370
+ resource,
352
371
  };
353
372
  }
354
373
  }
@@ -378,12 +397,18 @@ export async function discoverOAuthEndpoints(
378
397
  ? metadata.authorization_servers.filter((entry): entry is string => typeof entry === "string")
379
398
  : [];
380
399
 
400
+ const discoveredProtectedResource =
401
+ typeof metadata.resource === "string" && metadata.resource.trim() !== ""
402
+ ? metadata.resource
403
+ : protectedResource;
404
+
381
405
  for (const discoveredAuthServer of authServers) {
382
406
  if (visitedAuthServers.has(discoveredAuthServer)) {
383
407
  continue;
384
408
  }
385
409
  const discovered = await discoverOAuthEndpoints(serverUrl, discoveredAuthServer, undefined, {
386
410
  fetch: fetchImpl,
411
+ protectedResource: discoveredProtectedResource,
387
412
  });
388
413
  if (discovered) return discovered;
389
414
  }
@@ -98,6 +98,23 @@ function resolveCallbackOptions(config: MCPOAuthConfig): OAuthCallbackFlowOption
98
98
  };
99
99
  }
100
100
 
101
+ function resolveResourceUri(resource: string | undefined): string | undefined {
102
+ const trimmed = resource?.trim();
103
+ if (!trimmed) return undefined;
104
+ if (trimmed !== resource) {
105
+ throw new Error("OAuth resource URI must not include surrounding whitespace");
106
+ }
107
+
108
+ const parsed = new URL(trimmed);
109
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
110
+ throw new Error("OAuth resource URI must use http or https");
111
+ }
112
+ if (parsed.hash) {
113
+ throw new Error("OAuth resource URI must not include a fragment");
114
+ }
115
+ return trimmed;
116
+ }
117
+
101
118
  export interface MCPOAuthConfig {
102
119
  /** Authorization endpoint URL */
103
120
  authorizationUrl: string;
@@ -115,6 +132,8 @@ export interface MCPOAuthConfig {
115
132
  callbackPort?: number;
116
133
  /** Custom callback path (default: /callback or redirectUri pathname) */
117
134
  callbackPath?: string;
135
+ /** MCP resource URI for RFC 8707 resource indicators */
136
+ resource?: string;
118
137
  /** Fetch implementation for token exchange and discovery requests. */
119
138
  fetch?: FetchImpl;
120
139
  }
@@ -128,6 +147,7 @@ export class MCPOAuthFlow extends OAuthCallbackFlow {
128
147
  #registeredClientSecret?: string;
129
148
  #codeVerifier?: string;
130
149
  #fetch: FetchImpl;
150
+ #resource?: string;
131
151
 
132
152
  constructor(
133
153
  private config: MCPOAuthConfig,
@@ -136,6 +156,9 @@ export class MCPOAuthFlow extends OAuthCallbackFlow {
136
156
  super(ctrl, resolveCallbackOptions(config));
137
157
  this.#resolvedClientId = this.#resolveClientId(config);
138
158
  this.#fetch = config.fetch ?? ctrl.fetch ?? fetch;
159
+ this.#resource = resolveResourceUri(
160
+ config.resource ?? this.#resourceFromAuthorizationUrl(config.authorizationUrl),
161
+ );
139
162
  }
140
163
 
141
164
  /**
@@ -157,6 +180,9 @@ export class MCPOAuthFlow extends OAuthCallbackFlow {
157
180
  get registeredClientSecret(): string | undefined {
158
181
  return this.#registeredClientSecret;
159
182
  }
183
+ get resource(): string | undefined {
184
+ return this.#resource;
185
+ }
160
186
 
161
187
  async generateAuthUrl(state: string, redirectUri: string): Promise<{ url: string; instructions?: string }> {
162
188
  if (!this.#resolvedClientId) {
@@ -176,6 +202,12 @@ export class MCPOAuthFlow extends OAuthCallbackFlow {
176
202
  if (this.config.scopes && !params.get("scope")) {
177
203
  params.set("scope", this.config.scopes);
178
204
  }
205
+ const existingResource = params.get("resource")?.trim();
206
+ if (existingResource) {
207
+ this.#resource = resolveResourceUri(existingResource);
208
+ } else if (this.#resource) {
209
+ params.set("resource", this.#resource);
210
+ }
179
211
  params.set("redirect_uri", redirectUri);
180
212
  params.set("state", state);
181
213
 
@@ -212,6 +244,9 @@ export class MCPOAuthFlow extends OAuthCallbackFlow {
212
244
  this.#codeVerifier = undefined;
213
245
 
214
246
  // Add client secret if provided
247
+ if (this.#resource) {
248
+ params.set("resource", this.#resource);
249
+ }
215
250
  const clientSecret = this.config.clientSecret ?? this.#registeredClientSecret;
216
251
  if (clientSecret) {
217
252
  params.set("client_secret", clientSecret);
@@ -285,6 +320,13 @@ export class MCPOAuthFlow extends OAuthCallbackFlow {
285
320
  return undefined;
286
321
  }
287
322
  }
323
+ #resourceFromAuthorizationUrl(authorizationUrl: string): string | undefined {
324
+ try {
325
+ return new URL(authorizationUrl).searchParams.get("resource") ?? undefined;
326
+ } catch {
327
+ return undefined;
328
+ }
329
+ }
288
330
 
289
331
  /**
290
332
  * Try OAuth dynamic client registration when provider requires a client_id.
@@ -407,14 +449,18 @@ export async function refreshMCPOAuthToken(
407
449
  refreshToken: string,
408
450
  clientId?: string,
409
451
  clientSecret?: string,
452
+ resourceOrOpts?: string | { fetch?: FetchImpl },
410
453
  opts?: { fetch?: FetchImpl },
411
454
  ): Promise<OAuthCredentials> {
412
- const fetchImpl: FetchImpl = opts?.fetch ?? fetch;
455
+ const fetchImpl: FetchImpl = (typeof resourceOrOpts === "string" ? opts?.fetch : resourceOrOpts?.fetch) ?? fetch;
456
+ const resource = typeof resourceOrOpts === "string" ? resourceOrOpts : undefined;
413
457
  const params = new URLSearchParams({
414
458
  grant_type: "refresh_token",
415
459
  refresh_token: refreshToken,
416
460
  });
417
461
  if (clientId) params.set("client_id", clientId);
462
+ const resolvedResource = resolveResourceUri(resource);
463
+ if (resolvedResource) params.set("resource", resolvedResource);
418
464
  if (clientSecret) params.set("client_secret", clientSecret);
419
465
 
420
466
  const response = await fetchImpl(tokenUrl, {
@@ -25,6 +25,7 @@ import { isMCPTimeoutEnabled, resolveMCPTimeoutMs } from "../timeout";
25
25
  /** Subprocess argv for launching an MCP stdio server. */
26
26
  export interface StdioSpawnCommand {
27
27
  cmd: string[];
28
+ windowsHide?: boolean;
28
29
  }
29
30
 
30
31
  /** Inputs used to resolve platform-specific stdio spawn behavior. */
@@ -153,6 +154,7 @@ export async function resolveStdioSpawnCommand(
153
154
 
154
155
  return {
155
156
  cmd: [resolveComSpec(options.env), "/d", "/s", "/c", buildCmdExeCommand(resolvedCommand, args)],
157
+ windowsHide: true,
156
158
  };
157
159
  }
158
160
 
@@ -255,6 +257,7 @@ export class StdioTransport implements MCPTransport {
255
257
  stdin: "pipe",
256
258
  stdout: "pipe",
257
259
  stderr: "pipe",
260
+ windowsHide: spawnCommand.windowsHide,
258
261
  });
259
262
 
260
263
  this.#connected = true;
package/src/mcp/types.ts CHANGED
@@ -55,6 +55,8 @@ export interface MCPAuthConfig {
55
55
  clientId?: string;
56
56
  /** Client secret — persisted for token refresh */
57
57
  clientSecret?: string;
58
+ /** MCP resource URI — persisted for OAuth resource indicators during refresh */
59
+ resource?: string;
58
60
  }
59
61
 
60
62
  /** Base server config with shared options */