@oh-my-pi/pi-coding-agent 15.11.0 → 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.
- package/CHANGELOG.md +30 -1
- package/dist/cli.js +73 -67
- package/dist/types/capability/mcp.d.ts +1 -0
- package/dist/types/config/settings-schema.d.ts +13 -4
- package/dist/types/export/html/template.generated.d.ts +1 -1
- package/dist/types/mcp/oauth-discovery.d.ts +2 -0
- package/dist/types/mcp/oauth-flow.d.ts +6 -1
- package/dist/types/mcp/transports/stdio.d.ts +1 -0
- package/dist/types/mcp/types.d.ts +2 -0
- package/dist/types/modes/components/assistant-message.d.ts +1 -0
- package/dist/types/modes/components/mcp-add-wizard.d.ts +2 -1
- package/dist/types/modes/components/settings-selector.d.ts +1 -0
- package/dist/types/modes/components/status-line/types.d.ts +3 -0
- package/dist/types/modes/components/transcript-container.d.ts +3 -2
- package/dist/types/modes/controllers/tool-args-reveal.d.ts +43 -0
- package/dist/types/modes/theme/theme.d.ts +2 -1
- package/dist/types/task/index.d.ts +3 -3
- package/dist/types/tools/render-utils.d.ts +22 -0
- package/package.json +11 -11
- package/src/capability/mcp.ts +1 -0
- package/src/cli/gallery-cli.ts +5 -4
- package/src/config/mcp-schema.json +4 -0
- package/src/config/settings-schema.ts +15 -4
- package/src/edit/renderer.ts +96 -46
- package/src/export/html/template.generated.ts +1 -1
- package/src/export/html/template.js +6 -1
- package/src/internal-urls/docs-index.generated.ts +4 -4
- package/src/mcp/manager.ts +3 -0
- package/src/mcp/oauth-discovery.ts +27 -2
- package/src/mcp/oauth-flow.ts +47 -1
- package/src/mcp/transports/stdio.ts +3 -0
- package/src/mcp/types.ts +2 -0
- package/src/modes/components/assistant-message.ts +15 -0
- package/src/modes/components/btw-panel.ts +5 -1
- package/src/modes/components/mcp-add-wizard.ts +13 -0
- package/src/modes/components/settings-selector.ts +2 -0
- package/src/modes/components/status-line/component.ts +22 -12
- package/src/modes/components/status-line/types.ts +3 -0
- package/src/modes/components/transcript-container.ts +99 -18
- package/src/modes/components/tree-selector.ts +6 -1
- package/src/modes/controllers/event-controller.ts +28 -4
- package/src/modes/controllers/mcp-command-controller.ts +34 -2
- package/src/modes/controllers/selector-controller.ts +4 -0
- package/src/modes/controllers/tool-args-reveal.ts +174 -0
- package/src/modes/interactive-mode.ts +9 -2
- package/src/modes/theme/theme.ts +6 -0
- package/src/prompts/tools/task.md +7 -2
- package/src/session/agent-session.ts +25 -4
- package/src/task/index.ts +15 -10
- package/src/task/render.ts +10 -4
- package/src/tools/render-utils.ts +56 -0
- package/src/tools/write.ts +65 -47
- package/src/web/search/providers/anthropic.ts +29 -4
package/src/mcp/manager.ts
CHANGED
|
@@ -1174,12 +1174,15 @@ export class MCPManager {
|
|
|
1174
1174
|
const shouldRefresh =
|
|
1175
1175
|
forceRefresh || (credential.expires && Date.now() >= credential.expires - REFRESH_BUFFER_MS);
|
|
1176
1176
|
if (shouldRefresh && credential.refresh && auth.tokenUrl) {
|
|
1177
|
+
const resource =
|
|
1178
|
+
auth.resource ?? (config.type === "http" || config.type === "sse" ? config.url : undefined);
|
|
1177
1179
|
try {
|
|
1178
1180
|
const refreshed = await refreshMCPOAuthToken(
|
|
1179
1181
|
auth.tokenUrl,
|
|
1180
1182
|
credential.refresh,
|
|
1181
1183
|
auth.clientId,
|
|
1182
1184
|
auth.clientSecret,
|
|
1185
|
+
resource,
|
|
1183
1186
|
);
|
|
1184
1187
|
const refreshedCredential = { type: "oauth" as const, ...refreshed };
|
|
1185
1188
|
await this.#authStorage.set(credentialId, refreshedCredential);
|
|
@@ -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
|
-
|
|
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
|
}
|
package/src/mcp/oauth-flow.ts
CHANGED
|
@@ -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 */
|
|
@@ -36,6 +36,16 @@ export class AssistantMessageComponent extends Container {
|
|
|
36
36
|
* transcript keeps the error in history.
|
|
37
37
|
*/
|
|
38
38
|
#errorPinned = false;
|
|
39
|
+
/**
|
|
40
|
+
* Monotonic content version reported to the transcript container via
|
|
41
|
+
* {@link getTranscriptBlockVersion}. Bumped by {@link updateContent} — the
|
|
42
|
+
* choke point every mutator funnels through, including the post-finalize
|
|
43
|
+
* ones: `setErrorPinned(false)` restoring the inline error at the next
|
|
44
|
+
* turn's `agent_start`, late tool-result images, async Kitty conversions,
|
|
45
|
+
* and `setUsageInfo`. Without it, the container's committed-scrollback
|
|
46
|
+
* bypass would replay this block's pre-mutation bytes forever.
|
|
47
|
+
*/
|
|
48
|
+
#blockVersion = 0;
|
|
39
49
|
/** Whether the last updateContent carried an in-flight streaming partial; such
|
|
40
50
|
* renders bypass the markdown module LRU (see Markdown.transientRenderCache). */
|
|
41
51
|
#lastUpdateTransient = false;
|
|
@@ -86,6 +96,10 @@ export class AssistantMessageComponent extends Container {
|
|
|
86
96
|
return this.#transcriptBlockFinalized;
|
|
87
97
|
}
|
|
88
98
|
|
|
99
|
+
getTranscriptBlockVersion(): number {
|
|
100
|
+
return this.#blockVersion;
|
|
101
|
+
}
|
|
102
|
+
|
|
89
103
|
markTranscriptBlockFinalized(): void {
|
|
90
104
|
this.#transcriptBlockFinalized = true;
|
|
91
105
|
}
|
|
@@ -215,6 +229,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
215
229
|
}
|
|
216
230
|
|
|
217
231
|
updateContent(message: AssistantMessage, opts?: { transient?: boolean }): void {
|
|
232
|
+
this.#blockVersion++;
|
|
218
233
|
this.#lastMessage = message;
|
|
219
234
|
this.#lastUpdateTransient = opts?.transient === true;
|
|
220
235
|
|
|
@@ -73,7 +73,11 @@ export class BtwPanelComponent extends Container {
|
|
|
73
73
|
this.addChild(new Text(this.#footerLine(), 1, 0));
|
|
74
74
|
this.addChild(new Spacer(1));
|
|
75
75
|
this.addChild(new DynamicBorder(str => theme.fg("dim", str)));
|
|
76
|
-
this
|
|
76
|
+
// Component-scoped: a rebuild replaces only this panel's own children
|
|
77
|
+
// (streaming deltas arrive per token, and a full compose would re-walk
|
|
78
|
+
// the whole transcript each time). Before the panel is mounted the TUI
|
|
79
|
+
// cannot resolve it and falls back to a full compose on its own.
|
|
80
|
+
this.#tui.requestComponentRender(this);
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
#footerLine(): string {
|
|
@@ -57,6 +57,7 @@ export interface MCPAddWizardOAuthResult {
|
|
|
57
57
|
credentialId: string;
|
|
58
58
|
clientId?: string;
|
|
59
59
|
clientSecret?: string;
|
|
60
|
+
resource?: string;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
interface WizardState {
|
|
@@ -71,6 +72,7 @@ interface WizardState {
|
|
|
71
72
|
oauthClientId: string;
|
|
72
73
|
oauthClientSecret: string;
|
|
73
74
|
oauthScopes: string;
|
|
75
|
+
oauthResource: string;
|
|
74
76
|
oauthCredentialId: string | null;
|
|
75
77
|
apiKey: string;
|
|
76
78
|
authLocation: AuthLocation | null;
|
|
@@ -101,6 +103,7 @@ export class MCPAddWizard extends Container {
|
|
|
101
103
|
oauthClientId: "",
|
|
102
104
|
oauthClientSecret: "",
|
|
103
105
|
oauthScopes: "",
|
|
106
|
+
oauthResource: "",
|
|
104
107
|
oauthCredentialId: null,
|
|
105
108
|
apiKey: "",
|
|
106
109
|
authLocation: null,
|
|
@@ -122,6 +125,7 @@ export class MCPAddWizard extends Container {
|
|
|
122
125
|
clientId: string,
|
|
123
126
|
clientSecret: string,
|
|
124
127
|
scopes: string,
|
|
128
|
+
resource?: string,
|
|
125
129
|
) => Promise<MCPAddWizardOAuthResult>)
|
|
126
130
|
| null = null;
|
|
127
131
|
#onTestConnectionCallback: ((config: MCPServerConfig) => Promise<void>) | null = null;
|
|
@@ -136,6 +140,7 @@ export class MCPAddWizard extends Container {
|
|
|
136
140
|
clientId: string,
|
|
137
141
|
clientSecret: string,
|
|
138
142
|
scopes: string,
|
|
143
|
+
resource?: string,
|
|
139
144
|
) => Promise<MCPAddWizardOAuthResult>,
|
|
140
145
|
onTestConnection?: (config: MCPServerConfig) => Promise<void>,
|
|
141
146
|
onRender?: () => void,
|
|
@@ -987,6 +992,7 @@ export class MCPAddWizard extends Container {
|
|
|
987
992
|
this.#state.oauthTokenUrl = oauth.tokenUrl;
|
|
988
993
|
this.#state.oauthClientId = oauth.clientId || "";
|
|
989
994
|
this.#state.oauthScopes = oauth.scopes || "";
|
|
995
|
+
this.#state.oauthResource = oauth.resource || (this.#state.transport === "stdio" ? "" : this.#state.url);
|
|
990
996
|
this.#state.authMethod = "oauth";
|
|
991
997
|
|
|
992
998
|
this.#contentContainer.clear();
|
|
@@ -1054,6 +1060,7 @@ export class MCPAddWizard extends Container {
|
|
|
1054
1060
|
type: "oauth",
|
|
1055
1061
|
credentialId: this.#state.oauthCredentialId,
|
|
1056
1062
|
tokenUrl: this.#state.oauthTokenUrl || undefined,
|
|
1063
|
+
resource: this.#state.oauthResource || undefined,
|
|
1057
1064
|
clientId: this.#state.oauthClientId || undefined,
|
|
1058
1065
|
clientSecret: this.#state.oauthClientSecret || undefined,
|
|
1059
1066
|
};
|
|
@@ -1081,6 +1088,7 @@ export class MCPAddWizard extends Container {
|
|
|
1081
1088
|
type: "oauth",
|
|
1082
1089
|
credentialId: this.#state.oauthCredentialId,
|
|
1083
1090
|
tokenUrl: this.#state.oauthTokenUrl || undefined,
|
|
1091
|
+
resource: this.#state.oauthResource || undefined,
|
|
1084
1092
|
clientId: this.#state.oauthClientId || undefined,
|
|
1085
1093
|
clientSecret: this.#state.oauthClientSecret || undefined,
|
|
1086
1094
|
};
|
|
@@ -1142,12 +1150,14 @@ export class MCPAddWizard extends Container {
|
|
|
1142
1150
|
|
|
1143
1151
|
try {
|
|
1144
1152
|
// Call OAuth handler
|
|
1153
|
+
const oauthResource = this.#state.oauthResource || (this.#state.transport === "stdio" ? "" : this.#state.url);
|
|
1145
1154
|
const oauthResult = await this.#onOAuthCallback(
|
|
1146
1155
|
this.#state.oauthAuthUrl,
|
|
1147
1156
|
this.#state.oauthTokenUrl,
|
|
1148
1157
|
this.#state.oauthClientId,
|
|
1149
1158
|
this.#state.oauthClientSecret,
|
|
1150
1159
|
this.#state.oauthScopes,
|
|
1160
|
+
oauthResource || undefined,
|
|
1151
1161
|
);
|
|
1152
1162
|
|
|
1153
1163
|
// Store credential ID + any dynamically-registered client credentials,
|
|
@@ -1155,6 +1165,7 @@ export class MCPAddWizard extends Container {
|
|
|
1155
1165
|
this.#state.oauthCredentialId = oauthResult.credentialId;
|
|
1156
1166
|
if (oauthResult.clientId) this.#state.oauthClientId = oauthResult.clientId;
|
|
1157
1167
|
if (oauthResult.clientSecret) this.#state.oauthClientSecret = oauthResult.clientSecret;
|
|
1168
|
+
this.#state.oauthResource = oauthResult.resource ?? oauthResource;
|
|
1158
1169
|
|
|
1159
1170
|
// Show success message
|
|
1160
1171
|
this.#contentContainer.clear();
|
|
@@ -1284,6 +1295,7 @@ export class MCPAddWizard extends Container {
|
|
|
1284
1295
|
type: "oauth",
|
|
1285
1296
|
credentialId: this.#state.oauthCredentialId,
|
|
1286
1297
|
tokenUrl: this.#state.oauthTokenUrl || undefined,
|
|
1298
|
+
resource: this.#state.oauthResource || undefined,
|
|
1287
1299
|
clientId: this.#state.oauthClientId || undefined,
|
|
1288
1300
|
clientSecret: this.#state.oauthClientSecret || undefined,
|
|
1289
1301
|
};
|
|
@@ -1312,6 +1324,7 @@ export class MCPAddWizard extends Container {
|
|
|
1312
1324
|
type: "oauth",
|
|
1313
1325
|
credentialId: this.#state.oauthCredentialId,
|
|
1314
1326
|
tokenUrl: this.#state.oauthTokenUrl || undefined,
|
|
1327
|
+
resource: this.#state.oauthResource || undefined,
|
|
1315
1328
|
clientId: this.#state.oauthClientId || undefined,
|
|
1316
1329
|
clientSecret: this.#state.oauthClientSecret || undefined,
|
|
1317
1330
|
};
|
|
@@ -196,6 +196,7 @@ export interface StatusLinePreviewSettings {
|
|
|
196
196
|
rightSegments?: StatusLineSegmentId[];
|
|
197
197
|
separator?: StatusLineSeparatorStyle;
|
|
198
198
|
sessionAccent?: boolean;
|
|
199
|
+
transparent?: boolean;
|
|
199
200
|
}
|
|
200
201
|
|
|
201
202
|
export interface SettingsCallbacks {
|
|
@@ -590,6 +591,7 @@ export class SettingsSelectorComponent extends Container {
|
|
|
590
591
|
rightSegments: settings.get("statusLine.rightSegments"),
|
|
591
592
|
separator: settings.get("statusLine.separator"),
|
|
592
593
|
sessionAccent: settings.get("statusLine.sessionAccent"),
|
|
594
|
+
transparent: settings.get("statusLine.transparent"),
|
|
593
595
|
};
|
|
594
596
|
this.callbacks.onStatusLinePreview?.(statusLineSettings);
|
|
595
597
|
this.#updateStatusPreview();
|
|
@@ -3,7 +3,7 @@ import * as path from "node:path";
|
|
|
3
3
|
import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
|
|
4
4
|
import { estimateTokens } from "@oh-my-pi/pi-agent-core/compaction";
|
|
5
5
|
import { type Component, truncateToWidth, visibleWidth } from "@oh-my-pi/pi-tui";
|
|
6
|
-
import {
|
|
6
|
+
import { getProjectDir } from "@oh-my-pi/pi-utils";
|
|
7
7
|
import { $ } from "bun";
|
|
8
8
|
import { settings } from "../../../config/settings";
|
|
9
9
|
import type { AgentSession } from "../../../session/agent-session";
|
|
@@ -196,6 +196,7 @@ export class StatusLineComponent implements Component {
|
|
|
196
196
|
showHookStatus: settings.get("statusLine.showHookStatus"),
|
|
197
197
|
segmentOptions: settings.getGroup("statusLine").segmentOptions,
|
|
198
198
|
sessionAccent: settings.get("statusLine.sessionAccent"),
|
|
199
|
+
transparent: settings.get("statusLine.transparent"),
|
|
199
200
|
};
|
|
200
201
|
}
|
|
201
202
|
|
|
@@ -713,7 +714,15 @@ export class StatusLineComponent implements Component {
|
|
|
713
714
|
const ctx = this.#buildSegmentContext(width, effectiveSettings.segmentOptions, includeContext);
|
|
714
715
|
const separatorDef = getSeparator(effectiveSettings.separator ?? "powerline-thin", theme);
|
|
715
716
|
|
|
716
|
-
|
|
717
|
+
// `transparent` reuses the empty-string sentinel (`\x1b[49m`) so the bar
|
|
718
|
+
// inherits the terminal's default background, matching custom themes that
|
|
719
|
+
// set `statusLineBg: ""`. Powerline end caps need a contrasting fill to
|
|
720
|
+
// bridge the bar into the surrounding terminal; without one they read as
|
|
721
|
+
// stray glyphs, so the cap renderer drops them when the fill is empty.
|
|
722
|
+
const TRANSPARENT_BG_ANSI = "\x1b[49m";
|
|
723
|
+
const themeBgAnsi = theme.getBgAnsi("statusLineBg");
|
|
724
|
+
const bgAnsi = effectiveSettings.transparent ? TRANSPARENT_BG_ANSI : themeBgAnsi;
|
|
725
|
+
const transparentBg = bgAnsi === TRANSPARENT_BG_ANSI;
|
|
717
726
|
const fgAnsi = theme.getFgAnsi("text");
|
|
718
727
|
const sepAnsi = theme.getFgAnsi("statusLineSep");
|
|
719
728
|
|
|
@@ -738,9 +747,7 @@ export class StatusLineComponent implements Component {
|
|
|
738
747
|
|
|
739
748
|
const runningBackgroundJobs = this.session.getAsyncJobSnapshot()?.running.length ?? 0;
|
|
740
749
|
if (runningBackgroundJobs > 0) {
|
|
741
|
-
|
|
742
|
-
const label = `${formatCount("job", runningBackgroundJobs)} running`;
|
|
743
|
-
rightParts.push(theme.fg("statusLineSubagents", `${icon}${label}`));
|
|
750
|
+
rightParts.unshift(theme.fg("statusLineSubagents", `${theme.icon.job} ${runningBackgroundJobs}`));
|
|
744
751
|
}
|
|
745
752
|
const topFillWidth = Math.max(0, width);
|
|
746
753
|
const left = [...leftParts];
|
|
@@ -748,8 +755,10 @@ export class StatusLineComponent implements Component {
|
|
|
748
755
|
|
|
749
756
|
const leftSepWidth = visibleWidth(separatorDef.left);
|
|
750
757
|
const rightSepWidth = visibleWidth(separatorDef.right);
|
|
751
|
-
|
|
752
|
-
|
|
758
|
+
// Transparent mode drops powerline caps (they need a bg fill to bridge),
|
|
759
|
+
// so the width budget excludes them too.
|
|
760
|
+
const leftCapWidth = separatorDef.endCaps && !transparentBg ? visibleWidth(separatorDef.endCaps.right) : 0;
|
|
761
|
+
const rightCapWidth = separatorDef.endCaps && !transparentBg ? visibleWidth(separatorDef.endCaps.left) : 0;
|
|
753
762
|
|
|
754
763
|
const groupWidth = (parts: string[], capWidth: number, sepWidth: number): number => {
|
|
755
764
|
if (parts.length === 0) return 0;
|
|
@@ -810,11 +819,12 @@ export class StatusLineComponent implements Component {
|
|
|
810
819
|
const renderGroup = (parts: string[], direction: "left" | "right"): string => {
|
|
811
820
|
if (parts.length === 0) return "";
|
|
812
821
|
const sep = direction === "left" ? separatorDef.left : separatorDef.right;
|
|
813
|
-
const cap =
|
|
814
|
-
|
|
815
|
-
?
|
|
816
|
-
|
|
817
|
-
|
|
822
|
+
const cap =
|
|
823
|
+
separatorDef.endCaps && !transparentBg
|
|
824
|
+
? direction === "left"
|
|
825
|
+
? separatorDef.endCaps.right
|
|
826
|
+
: separatorDef.endCaps.left
|
|
827
|
+
: "";
|
|
818
828
|
const capPrefix = separatorDef.endCaps?.useBgAsFg ? bgAnsi.replace("\x1b[48;", "\x1b[38;") : bgAnsi + sepAnsi;
|
|
819
829
|
const capText = cap ? `${capPrefix}${cap}\x1b[0m` : "";
|
|
820
830
|
|
|
@@ -18,6 +18,9 @@ export interface StatusLineSettings {
|
|
|
18
18
|
segmentOptions?: StatusLineSegmentOptions;
|
|
19
19
|
showHookStatus?: boolean;
|
|
20
20
|
sessionAccent?: boolean;
|
|
21
|
+
/** Drop the theme's `statusLineBg` fill and powerline caps so the bar
|
|
22
|
+
* inherits the terminal's default background. */
|
|
23
|
+
transparent?: boolean;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export type EffectiveStatusLineSettings = Required<
|