@getpaseo/server 0.16.0 → 0.16.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 (29) hide show
  1. package/dist/server/builtin-plugins/package.json +1 -1
  2. package/dist/server/server/agent/agent-manager.js +7 -15
  3. package/dist/server/server/agent/providers/claude/agent.d.ts +1 -0
  4. package/dist/server/server/agent/providers/claude/agent.js +7 -5
  5. package/dist/server/server/agent/providers/claude/bypass-approval.d.ts +5 -0
  6. package/dist/server/server/agent/providers/claude/bypass-approval.js +37 -0
  7. package/dist/server/server/agent/providers/claude/model-discovery.d.ts +2 -0
  8. package/dist/server/server/agent/providers/claude/model-discovery.js +55 -11
  9. package/dist/server/server/agent/providers/codex-app-server-agent.js +3 -0
  10. package/dist/server/server/agent/providers/model-label.d.ts +5 -0
  11. package/dist/server/server/agent/providers/model-label.js +21 -0
  12. package/dist/server/server/agent/providers/omp/agent.d.ts +1 -2
  13. package/dist/server/server/agent/providers/omp/agent.js +1 -26
  14. package/dist/server/server/agent/providers/omp/map-omp-model.js +2 -1
  15. package/dist/server/server/agent/providers/opencode-agent.js +15 -10
  16. package/dist/server/server/agent/providers/pi/agent.d.ts +1 -2
  17. package/dist/server/server/agent/providers/pi/agent.js +4 -28
  18. package/dist/server/server/agent/timeline-projection.d.ts +6 -0
  19. package/dist/server/server/agent/timeline-projection.js +12 -8
  20. package/dist/server/utils/checkout-git.js +9 -1
  21. package/dist/server/web-ui/_expo/static/js/web/{index-c6834d1a59b83addc7491f02fc3b6494.js → index-6de36f49f1c767e50d1cf95ae05eb46a.js} +9 -9
  22. package/dist/server/web-ui/_expo/static/js/web/index-6de36f49f1c767e50d1cf95ae05eb46a.js.br +0 -0
  23. package/dist/server/web-ui/_expo/static/js/web/index-6de36f49f1c767e50d1cf95ae05eb46a.js.gz +0 -0
  24. package/dist/server/web-ui/index.html +1 -1
  25. package/dist/server/web-ui/index.html.br +0 -0
  26. package/dist/server/web-ui/index.html.gz +0 -0
  27. package/package.json +7 -7
  28. package/dist/server/web-ui/_expo/static/js/web/index-c6834d1a59b83addc7491f02fc3b6494.js.br +0 -0
  29. package/dist/server/web-ui/_expo/static/js/web/index-c6834d1a59b83addc7491f02fc3b6494.js.gz +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/builtin-plugins",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  import { ProviderOptionsValidationError } from "./provider-options.js";
2
2
  import { AgentNotFoundError, ensureAgentLoaded } from "./agent-loading.js";
3
- import { projectTimelineRows } from "./timeline-projection.js";
3
+ import { continuesAssistantMessage, projectTimelineRows } from "./timeline-projection.js";
4
4
  import { describeHookAgent, publishAgentStream } from "../plugins/lifecycle/index.js";
5
5
  import { applyRecordPatch } from "../record-patch.js";
6
6
  import { randomUUID } from "node:crypto";
@@ -2833,25 +2833,17 @@ export class AgentManager {
2833
2833
  null);
2834
2834
  }
2835
2835
  getLastAssistantMessageSegmentFromTimeline(timeline) {
2836
- // Collect the last contiguous assistant messages of one turn (Claude streams chunks).
2837
- // A turn the provider starts on its own has no user message before its reply.
2836
+ // Collect the chunks of the last assistant message (Claude streams chunks). A turn the
2837
+ // provider starts on its own has no user message before its reply.
2838
2838
  const chunks = [];
2839
- let replyTurnId;
2840
2839
  let startsAtBeginning = false;
2841
2840
  for (let i = timeline.length - 1; i >= 0; i--) {
2842
- const { item, turnId } = timeline[i];
2843
- if (item.type !== "assistant_message") {
2844
- if (chunks.length) {
2845
- break;
2846
- }
2847
- continue;
2848
- }
2849
- if (chunks.length === 0) {
2850
- replyTurnId = turnId;
2851
- }
2852
- else if (turnId !== replyTurnId) {
2841
+ const { item } = timeline[i];
2842
+ if (chunks.length > 0 && !continuesAssistantMessage(timeline[i], timeline[i + 1])) {
2853
2843
  break;
2854
2844
  }
2845
+ if (item.type !== "assistant_message")
2846
+ continue;
2855
2847
  chunks.push(item.text);
2856
2848
  startsAtBeginning = i === 0;
2857
2849
  }
@@ -50,6 +50,7 @@ export declare class ClaudeAgentClient implements AgentClient {
50
50
  resumeSession(handle: AgentPersistenceHandle, overrides?: Partial<AgentSessionConfig>, launchContext?: AgentLaunchContext): Promise<AgentSession>;
51
51
  getCatalogCacheKey(_options: FetchCatalogOptions): Promise<string>;
52
52
  fetchCatalog(_options: FetchCatalogOptions, context?: ProviderRefreshContext): Promise<ProviderCatalog>;
53
+ shutdown(): Promise<void>;
53
54
  resolveDefaultModeId({ env: launchEnv }: ResolveAgentDefaultModeInput): Promise<string>;
54
55
  private buildProviderEnv;
55
56
  listControls(config: AgentSessionConfig): Promise<AgentDraftControls>;
@@ -9,6 +9,7 @@ import path from "node:path";
9
9
  import { LRUCache } from "lru-cache";
10
10
  import stripAnsi from "strip-ansi";
11
11
  import { createImportDescriptorScheduler } from "./import-descriptor-scheduler.js";
12
+ import { bypassApprovesAsk } from "./bypass-approval.js";
12
13
  import { mapClaudeCanceledToolCall, mapClaudeCompletedToolCall, mapClaudeFailedToolCall, mapClaudeRunningToolCall, } from "./tool-call-mapper.js";
13
14
  import { mapTaskNotificationSystemRecordToToolCall, mapTaskNotificationUserContentToToolCall, readTaskNotificationToolUseIdFromHistoryRecord, readTaskNotificationFromHistoryRecord, } from "./task-notification-tool-call.js";
14
15
  import { isClaudeInterruptPlaceholderText } from "./interrupt-placeholder.js";
@@ -32,7 +33,7 @@ import { buildBinaryDiagnosticRows, buildCommandResolutionDiagnosticRows, format
32
33
  import { appendOrReplaceGrowingAssistantMessage, runProviderTurn } from "../provider-runner.js";
33
34
  import { applyClaudeToolPolicy, ClaudeProviderOptionsSchema, } from "./options.js";
34
35
  import { renderPromptAttachmentAsText } from "../../prompt-attachments.js";
35
- import { discoverClaudeModels } from "./model-discovery.js";
36
+ import { discoverClaudeModels, killExitingClaudeModelDiscoveries } from "./model-discovery.js";
36
37
  import { claudeQuery } from "./query.js";
37
38
  import { findSteeredMessageParent, realClaudeRewindSdk, revertClaudeConversation, revertClaudeFiles, } from "./rewind.js";
38
39
  import { normalizeProviderReplayTimestamp } from "../../provider-history-timestamps.js";
@@ -1229,6 +1230,9 @@ export class ClaudeAgentClient {
1229
1230
  ...modeCatalog,
1230
1231
  };
1231
1232
  }
1233
+ async shutdown() {
1234
+ await killExitingClaudeModelDiscoveries();
1235
+ }
1232
1236
  async resolveDefaultModeId({ env: launchEnv }) {
1233
1237
  return claudeModeCatalog(this.buildProviderEnv(launchEnv)).defaultModeId;
1234
1238
  }
@@ -1782,10 +1786,8 @@ class ClaudeAgentSession {
1782
1786
  this.closed = false;
1783
1787
  this.openOptionsPatch = {};
1784
1788
  this.handlePermissionRequest = async (toolName, input, options) => {
1785
- // Decide before publishing anything: bypassed tools never enter the permission UI.
1786
- // Claude also routes questions and plan review through this callback.
1787
- const needsUserAnswer = toolName === "AskUserQuestion" || toolName === "ExitPlanMode";
1788
- if (this.currentMode === "bypassPermissions" && !needsUserAnswer) {
1789
+ // Decide before publishing anything: bypassed asks never enter the permission UI.
1790
+ if (this.currentMode === "bypassPermissions" && bypassApprovesAsk(toolName, options)) {
1789
1791
  return { behavior: "allow", updatedInput: input, toolUseID: options.toolUseID };
1790
1792
  }
1791
1793
  const requestId = `permission-${randomUUID()}`;
@@ -0,0 +1,5 @@
1
+ import type { CanUseTool } from "@anthropic-ai/claude-agent-sdk";
2
+ type PermissionOptions = Parameters<CanUseTool>[2];
3
+ export declare function bypassApprovesAsk(toolName: string, options: PermissionOptions): boolean;
4
+ export {};
5
+ //# sourceMappingURL=bypass-approval.d.ts.map
@@ -0,0 +1,37 @@
1
+ // In bypassPermissions, Claude Code still forwards an ask when the user configured one
2
+ // (a permissions.ask rule, including managed policy, or a PreToolUse hook), when the tool
3
+ // needs an answer, or when one of its own checks fires. Bypass approves only Claude's own
4
+ // checks. A missing or unknown reason type stays with the user.
5
+ // `subcommandResults` is left out: a compound or piped command uses it as a container,
6
+ // including when a user's ask rule matched one of its parts. `sandboxOverride` is left
7
+ // out: in Bypass, Claude Code forwards it only when the user's read block or hook raised it.
8
+ const CLAUDE_OWN_CHECK_TYPES = new Set([
9
+ "safetyCheck",
10
+ "workingDir",
11
+ "mode",
12
+ "classifier",
13
+ "asyncAgent",
14
+ ]);
15
+ // Settings the user or organization chose, which Claude Code reports under its own types:
16
+ // permissions.blockReadsOutsideWorkingDirectories, and an organization's ask limit.
17
+ const CONFIGURED_ASK_CODES = new Set([
18
+ "outside_reads_blocked",
19
+ "org_ask_ceiling",
20
+ ]);
21
+ const QUESTION_TOOLS = new Set(["AskUserQuestion", "ExitPlanMode"]);
22
+ export function bypassApprovesAsk(toolName, options) {
23
+ if (QUESTION_TOOLS.has(toolName) || options.matchedAskRule) {
24
+ return false;
25
+ }
26
+ // The SDK forwards these from Claude Code without declaring them on CanUseTool.
27
+ if ("requiresUserInteraction" in options && options.requiresUserInteraction === true) {
28
+ return false;
29
+ }
30
+ const reasonCode = "decisionReasonCode" in options ? options.decisionReasonCode : undefined;
31
+ if (typeof reasonCode === "string" && CONFIGURED_ASK_CODES.has(reasonCode)) {
32
+ return false;
33
+ }
34
+ const reasonType = "decisionReasonType" in options ? options.decisionReasonType : undefined;
35
+ return typeof reasonType === "string" && CLAUDE_OWN_CHECK_TYPES.has(reasonType);
36
+ }
37
+ //# sourceMappingURL=bypass-approval.js.map
@@ -9,5 +9,7 @@ interface ClaudeModelDiscoveryOptions {
9
9
  }
10
10
  type OpenDiscoveryQuery = (input: ClaudeQueryInput, context: ClaudeQueryContext) => Pick<Query, "supportedModels" | "close">;
11
11
  export declare function discoverClaudeModels(options: ClaudeModelDiscoveryOptions, openQuery?: OpenDiscoveryQuery): Promise<ModelInfo[]>;
12
+ /** Kills discovery processes still exiting after their wait ended. Called on daemon shutdown. */
13
+ export declare function killExitingClaudeModelDiscoveries(): Promise<void>;
12
14
  export {};
13
15
  //# sourceMappingURL=model-discovery.d.ts.map
@@ -2,14 +2,19 @@ import os from "node:os";
2
2
  import { raceProviderRefreshAbort } from "../../provider-refresh-deadline.js";
3
3
  import { terminateWithTreeKill } from "../../../../utils/tree-kill.js";
4
4
  import { claudeQuery } from "./query.js";
5
+ const DISCOVERY_WAIT_MS = 5000;
6
+ // Long enough for the CLI to finish an OAuth token refresh it started before the wait ended.
7
+ const DISCOVERY_EXIT_GRACE_MS = 60000;
8
+ // Discovery processes left to exit on their own after their caller stopped waiting.
9
+ const exitingDiscoveries = new Map();
5
10
  // The curated catalog survives a failed or slow probe. This process never receives
6
11
  // a prompt and must not persist a session or launch user MCP servers/hooks.
7
12
  export async function discoverClaudeModels(options, openQuery = claudeQuery) {
8
- const controller = new AbortController();
13
+ const waitController = new AbortController();
9
14
  const signal = options.signal
10
- ? AbortSignal.any([options.signal, controller.signal])
11
- : controller.signal;
12
- const timer = setTimeout(() => controller.abort(new Error("Claude model discovery timed out")), 5000);
15
+ ? AbortSignal.any([options.signal, waitController.signal])
16
+ : waitController.signal;
17
+ const timer = setTimeout(() => waitController.abort(new Error("Claude model discovery timed out")), DISCOVERY_WAIT_MS);
13
18
  let endInput;
14
19
  const ended = new Promise((resolve) => {
15
20
  endInput = resolve;
@@ -41,7 +46,8 @@ export async function discoverClaudeModels(options, openQuery = claudeQuery) {
41
46
  strictMcpConfig: true,
42
47
  settingSources: ["user"],
43
48
  settings: { disableAllHooks: true },
44
- abortController: controller,
49
+ // No abortController: the SDK kills the process when it aborts, and the end of
50
+ // the wait must not.
45
51
  },
46
52
  }, {
47
53
  runtimeSettings: options.runtimeSettings,
@@ -54,14 +60,52 @@ export async function discoverClaudeModels(options, openQuery = claudeQuery) {
54
60
  finally {
55
61
  clearTimeout(timer);
56
62
  endInput();
57
- try {
58
- query?.close();
63
+ if (query && child && !hasExited(child)) {
64
+ // The CLI may be refreshing an expired OAuth token, even after it has answered.
65
+ // Claude Code rotates the refresh token before saving the new pair, so killing it now
66
+ // leaves a revoked token on disk and logs the user out (#9314). With its input ended
67
+ // it exits once that work is done; the grace period and daemon shutdown bound the wait.
68
+ letDiscoveryExit(query, child);
59
69
  }
60
- finally {
61
- if (child) {
62
- await terminateWithTreeKill(child, { gracefulTimeoutMs: 200, forceTimeoutMs: 200 });
63
- }
70
+ else {
71
+ await retireDiscovery(query, child);
64
72
  }
65
73
  }
66
74
  }
75
+ /** Kills discovery processes still exiting after their wait ended. Called on daemon shutdown. */
76
+ export async function killExitingClaudeModelDiscoveries() {
77
+ await Promise.all(Array.from(exitingDiscoveries.values(), (kill) => kill()));
78
+ }
79
+ function letDiscoveryExit(query, child) {
80
+ function forget() {
81
+ clearTimeout(graceTimer);
82
+ child.off("exit", onExit);
83
+ exitingDiscoveries.delete(child);
84
+ }
85
+ function onExit() {
86
+ forget();
87
+ query.close();
88
+ }
89
+ async function kill() {
90
+ forget();
91
+ await retireDiscovery(query, child);
92
+ }
93
+ const graceTimer = setTimeout(() => void kill(), DISCOVERY_EXIT_GRACE_MS);
94
+ graceTimer.unref();
95
+ child.once("exit", onExit);
96
+ exitingDiscoveries.set(child, kill);
97
+ }
98
+ async function retireDiscovery(query, child) {
99
+ try {
100
+ query?.close();
101
+ }
102
+ finally {
103
+ if (child) {
104
+ await terminateWithTreeKill(child, { gracefulTimeoutMs: 200, forceTimeoutMs: 200 });
105
+ }
106
+ }
107
+ }
108
+ function hasExited(child) {
109
+ return child.exitCode !== null || child.signalCode !== null;
110
+ }
67
111
  //# sourceMappingURL=model-discovery.js.map
@@ -4090,6 +4090,9 @@ export class CodexAppServerAgentSession {
4090
4090
  return this.background.stopItem(id);
4091
4091
  }
4092
4092
  async canStopRuntime() {
4093
+ // A history session released its app-server once it read the thread, so nothing runs.
4094
+ if (this.connectionState === "history-ready")
4095
+ return true;
4093
4096
  if (!this.client ||
4094
4097
  this.client.hasPendingRequests() ||
4095
4098
  !this.currentThreadId ||
@@ -0,0 +1,5 @@
1
+ export declare function modelDisplayLabel(model: {
2
+ id: string;
3
+ name?: string;
4
+ }): string;
5
+ //# sourceMappingURL=model-label.d.ts.map
@@ -0,0 +1,21 @@
1
+ // Drops an upstream "Vendor: " prefix ("OpenAI: GPT-5.5"). A colon inside parentheses or after a
2
+ // comma belongs to the model name ("DeepSeek V4 (ctx: 128k)"), so it is kept.
3
+ function stripVendorPrefix(label) {
4
+ const vendorSeparatorIndex = label.indexOf(": ");
5
+ if (vendorSeparatorIndex === -1 || /[(),]/.test(label.slice(0, vendorSeparatorIndex))) {
6
+ return label;
7
+ }
8
+ return label.slice(vendorSeparatorIndex + 2).trim();
9
+ }
10
+ // The label Pi and OMP show for a model from their catalogs. A model name is either a path
11
+ // ("google/gemini_2.5-flash", as OpenRouter reports it) or free text that can contain slashes
12
+ // and underscores ("IQ3_S ... 52/56"). Only paths are shortened.
13
+ export function modelDisplayLabel(model) {
14
+ const text = model.name?.trim().replace(/\s+/g, " ") || model.id.trim();
15
+ if (/\s/.test(text)) {
16
+ return stripVendorPrefix(text);
17
+ }
18
+ const lastSegment = text.split("/").findLast((segment) => segment.length > 0) ?? text;
19
+ return stripVendorPrefix(lastSegment.replace(/_+/g, " "));
20
+ }
21
+ //# sourceMappingURL=model-label.js.map
@@ -1,6 +1,6 @@
1
1
  import type { ProviderOptions } from "@getpaseo/protocol/agent-types";
2
2
  import type { Logger } from "pino";
3
- import { type AgentCapabilityFlags, type AgentClient, type AgentDraftControls, type AgentOptionControl, type AgentLaunchContext, type AgentMode, type AgentModelDefinition, type AgentPermissionRequest, type AgentPermissionResponse, type AgentProviderNotice, type AgentPersistenceHandle, type AgentPromptInput, type AgentProvider, type AgentResumeSessionOptions, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type FetchCatalogOptions, type ImportableProviderSession, type ImportProviderSessionContext, type ImportProviderSessionInput, type ListImportableSessionsOptions, type ProviderCatalog, type ProviderRefreshContext, type SteerActiveTurnOptions, type SteerResult } from "../../agent-sdk-types.js";
3
+ import { type AgentCapabilityFlags, type AgentClient, type AgentDraftControls, type AgentOptionControl, type AgentLaunchContext, type AgentMode, type AgentPermissionRequest, type AgentPermissionResponse, type AgentProviderNotice, type AgentPersistenceHandle, type AgentPromptInput, type AgentProvider, type AgentResumeSessionOptions, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type FetchCatalogOptions, type ImportableProviderSession, type ImportProviderSessionContext, type ImportProviderSessionInput, type ListImportableSessionsOptions, type ProviderCatalog, type ProviderRefreshContext, type SteerActiveTurnOptions, type SteerResult } from "../../agent-sdk-types.js";
4
4
  import { type ProviderRuntimeSettings } from "../../provider-launch-config.js";
5
5
  export { formatOmpVersionSupport, resolveOmpDiagnosticPaths } from "./provider-config.js";
6
6
  import type { OmpRuntime, OmpRuntimeSession } from "./runtime.js";
@@ -47,7 +47,6 @@ interface OmpAgentSessionOptions {
47
47
  */
48
48
  live?: boolean;
49
49
  }
50
- export declare function transformOmpModels(models: AgentModelDefinition[]): AgentModelDefinition[];
51
50
  export declare class OmpAgentSession implements AgentSession {
52
51
  readonly provider: AgentProvider;
53
52
  readonly capabilities: AgentCapabilityFlags;
@@ -75,31 +75,6 @@ function createOmpNoTurnScheduler() {
75
75
  },
76
76
  };
77
77
  }
78
- function normalizeOmpModelLabel(label) {
79
- const normalizedLabel = label.trim().replace(/[_\s]+/g, " ");
80
- const vendorSeparatorIndex = normalizedLabel.indexOf(": ");
81
- if (vendorSeparatorIndex === -1) {
82
- return normalizedLabel;
83
- }
84
- return normalizedLabel.slice(vendorSeparatorIndex + 2).trim();
85
- }
86
- export function transformOmpModels(models) {
87
- return models.map((model) => {
88
- if (!model.label.includes("/")) {
89
- return model;
90
- }
91
- const segments = model.label.split("/").filter((segment) => segment.length > 0);
92
- const rawLabel = segments.at(-1);
93
- if (!rawLabel) {
94
- return model;
95
- }
96
- return {
97
- ...model,
98
- label: normalizeOmpModelLabel(rawLabel),
99
- description: model.description ?? model.label,
100
- };
101
- });
102
- }
103
78
  function isOmpThinkingLevel(value) {
104
79
  return (value === "off" ||
105
80
  value === "minimal" ||
@@ -2051,7 +2026,7 @@ export class OmpAgentClient {
2051
2026
  if (!runtimeSession)
2052
2027
  throw new Error("OMP catalog runtime did not start");
2053
2028
  const catalogSession = runtimeSession;
2054
- const models = transformOmpModels((await runProviderRefreshActivity(context, "get_available_models", () => catalogSession.getAvailableModels(null))).map((model) => mapOmpModel(model, this.provider)));
2029
+ const models = (await runProviderRefreshActivity(context, "get_available_models", () => catalogSession.getAvailableModels(null))).map((model) => mapOmpModel(model, this.provider));
2055
2030
  return { models, modes: [...OMP_MODES] };
2056
2031
  }
2057
2032
  finally {
@@ -1,3 +1,4 @@
1
+ import { modelDisplayLabel } from "../model-label.js";
1
2
  export const DEFAULT_OMP_THINKING_LEVEL = "medium";
2
3
  export const OMP_THINKING_OPTIONS = [
3
4
  { id: "auto", label: "Auto", description: "OMP picks the effort each turn" },
@@ -25,7 +26,7 @@ export function mapOmpModel(model, provider) {
25
26
  return {
26
27
  provider,
27
28
  id: `${model.provider}/${model.id}`,
28
- label: `${model.provider}/${model.name ?? model.id}`,
29
+ label: modelDisplayLabel(model),
29
30
  description: `${model.provider}/${model.id}`,
30
31
  metadata: {
31
32
  provider: model.provider,
@@ -3787,19 +3787,24 @@ class OpenCodeAgentSession {
3787
3787
  answers,
3788
3788
  });
3789
3789
  }
3790
- this.pendingPermissions.delete(requestId);
3791
- this.pendingPermissionDirectories.delete(requestId);
3792
- return;
3793
3790
  }
3794
- const reply = resolveOpenCodePermissionReply(response);
3795
- await this.client.permission.reply({
3796
- requestID: requestId,
3797
- directory,
3798
- reply,
3799
- message: response.behavior === "deny" ? response.message : undefined,
3800
- });
3791
+ else {
3792
+ const reply = resolveOpenCodePermissionReply(response);
3793
+ await this.client.permission.reply({
3794
+ requestID: requestId,
3795
+ directory,
3796
+ reply,
3797
+ message: response.behavior === "deny" ? response.message : undefined,
3798
+ });
3799
+ }
3801
3800
  this.pendingPermissions.delete(requestId);
3802
3801
  this.pendingPermissionDirectories.delete(requestId);
3802
+ this.notifySubscribers({
3803
+ type: "permission_resolved",
3804
+ provider: "opencode",
3805
+ requestId,
3806
+ resolution: response,
3807
+ });
3803
3808
  }
3804
3809
  describePersistence() {
3805
3810
  return {
@@ -1,6 +1,6 @@
1
1
  import type { Logger } from "pino";
2
2
  import { z } from "zod";
3
- import { type AgentCapabilityFlags, type AgentClient, type AgentDraftControls, type AgentLaunchContext, type AgentMode, type AgentModelDefinition, type AgentPermissionRequest, type AgentPermissionResponse, type AgentProviderNotice, type AgentPersistenceHandle, type AgentPromptInput, type AgentProvider, type AgentResumeSessionOptions, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type FetchCatalogOptions, type SteerActiveTurnOptions, type SteerResult, type ImportableProviderSession, type ImportProviderSessionContext, type ImportProviderSessionInput, type ListImportableSessionsOptions, type ProviderCatalog, type ProviderRefreshContext } from "../../agent-sdk-types.js";
3
+ import { type AgentCapabilityFlags, type AgentClient, type AgentDraftControls, type AgentLaunchContext, type AgentMode, type AgentPermissionRequest, type AgentPermissionResponse, type AgentProviderNotice, type AgentPersistenceHandle, type AgentPromptInput, type AgentProvider, type AgentResumeSessionOptions, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type FetchCatalogOptions, type SteerActiveTurnOptions, type SteerResult, type ImportableProviderSession, type ImportProviderSessionContext, type ImportProviderSessionInput, type ListImportableSessionsOptions, type ProviderCatalog, type ProviderRefreshContext } from "../../agent-sdk-types.js";
4
4
  import { type ProviderRuntimeSettings } from "../../provider-launch-config.js";
5
5
  import type { PiRuntime, PiRuntimeSession } from "./runtime.js";
6
6
  import type { PiSessionState } from "./rpc-types.js";
@@ -32,7 +32,6 @@ interface PiRpcAgentSessionOptions {
32
32
  logger: Logger;
33
33
  usagePollScheduler?: PiUsagePollScheduler;
34
34
  }
35
- export declare function transformPiModels(models: AgentModelDefinition[]): AgentModelDefinition[];
36
35
  export declare class PiRpcAgentSession implements AgentSession {
37
36
  readonly provider: AgentProvider;
38
37
  readonly capabilities: AgentCapabilityFlags;
@@ -19,6 +19,7 @@ import { createPiExtensionHost, piExtensionRuntimeBridge, } from "./extensions/i
19
19
  import { resolveResumeProcessCwd } from "../resume-process-cwd.js";
20
20
  import { revertPiConversation } from "./rewind.js";
21
21
  import { copyPiSessionFileWithCwd, listPiImportableSessions, readPiImportSessionConfig, } from "./session-descriptor.js";
22
+ import { modelDisplayLabel } from "../model-label.js";
22
23
  import { PiUsagePoller } from "./usage-poller.js";
23
24
  import { mapToolDetail, parseToolArgs, parseToolResult, splitPiToolResultImages, } from "./tool-call-mapper.js";
24
25
  const PI_PROVIDER = "pi";
@@ -108,31 +109,6 @@ function isPiDefinitiveSteerRejection(error) {
108
109
  function isPiMissingClearQueueRpc(error) {
109
110
  return toDiagnosticErrorMessage(error) === "Unknown command: clear_queue";
110
111
  }
111
- function normalizePiModelLabel(label) {
112
- const normalizedLabel = label.trim().replace(/[_\s]+/g, " ");
113
- const vendorSeparatorIndex = normalizedLabel.indexOf(": ");
114
- if (vendorSeparatorIndex === -1) {
115
- return normalizedLabel;
116
- }
117
- return normalizedLabel.slice(vendorSeparatorIndex + 2).trim();
118
- }
119
- export function transformPiModels(models) {
120
- return models.map((model) => {
121
- if (!model.label.includes("/")) {
122
- return model;
123
- }
124
- const segments = model.label.split("/").filter((segment) => segment.length > 0);
125
- const rawLabel = segments.at(-1);
126
- if (!rawLabel) {
127
- return model;
128
- }
129
- return {
130
- ...model,
131
- label: normalizePiModelLabel(rawLabel),
132
- description: model.description ?? model.label,
133
- };
134
- });
135
- }
136
112
  function isPiThinkingLevel(value) {
137
113
  return (value === "off" ||
138
114
  value === "minimal" ||
@@ -836,7 +812,7 @@ function mapPiModel(model, provider) {
836
812
  return {
837
813
  provider,
838
814
  id: `${model.provider}/${model.id}`,
839
- label: `${model.provider}/${model.name ?? model.id}`,
815
+ label: modelDisplayLabel(model),
840
816
  description: `${model.provider}/${model.id}`,
841
817
  metadata: {
842
818
  provider: model.provider,
@@ -2294,13 +2270,13 @@ export class PiRpcAgentClient {
2294
2270
  const piModels = await runProviderRefreshActivity(context, "get_available_models", () => catalogSession.getAvailableModels(null));
2295
2271
  // A fresh Pi session starts on the model Pi resolves from its own settings.
2296
2272
  const { model: configuredModel } = await runProviderRefreshActivity(context, "get_state", () => catalogSession.getState());
2297
- const models = transformPiModels(piModels.map((model) => {
2273
+ const models = piModels.map((model) => {
2298
2274
  const mapped = mapPiModel(model, PI_PROVIDER);
2299
2275
  const isConfigured = model.provider === configuredModel?.provider && model.id === configuredModel?.id;
2300
2276
  if (isConfigured)
2301
2277
  mapped.isDefault = true;
2302
2278
  return mapped;
2303
- }));
2279
+ });
2304
2280
  return { models, modes: [] };
2305
2281
  }
2306
2282
  finally {
@@ -38,6 +38,12 @@ export declare function mergeToolCallItems(existing: Extract<AgentTimelineItem,
38
38
  }>): Extract<AgentTimelineItem, {
39
39
  type: "tool_call";
40
40
  }>;
41
+ /**
42
+ * Whether `next`, the row right after `previous`, is another chunk of the same assistant
43
+ * message. A turn id or message id change starts a new message, which matters where rows
44
+ * replayed from provider history carry no turn id.
45
+ */
46
+ export declare function continuesAssistantMessage(previous: Pick<AgentTimelineRow, "item" | "turnId">, next: Pick<AgentTimelineRow, "item" | "turnId">): boolean;
41
47
  /** A retained item. `seq` is its latest source event, not its display anchor. */
42
48
  export type ProjectedTimelineRow = AgentTimelineRow & TimelineProjectionEntry;
43
49
  interface ProjectedTimelinePageOptions {
@@ -165,26 +165,30 @@ function mergeReasoningChunks(entries) {
165
165
  }
166
166
  return output;
167
167
  }
168
+ /**
169
+ * Whether `next`, the row right after `previous`, is another chunk of the same assistant
170
+ * message. A turn id or message id change starts a new message, which matters where rows
171
+ * replayed from provider history carry no turn id.
172
+ */
173
+ export function continuesAssistantMessage(previous, next) {
174
+ return (previous.item.type === "assistant_message" &&
175
+ next.item.type === "assistant_message" &&
176
+ previous.turnId === next.turnId &&
177
+ (next.item.messageId === undefined || next.item.messageId === previous.item.messageId));
178
+ }
168
179
  function mergeAssistantChunks(entries) {
169
180
  const output = [];
170
181
  for (const entry of entries) {
171
182
  const previous = output[output.length - 1];
172
183
  const shouldMerge = previous &&
173
- previous.item.type === "assistant_message" &&
174
- entry.item.type === "assistant_message" &&
175
184
  previous.seqEnd + 1 === entry.seqStart &&
176
- previous.turnId === entry.turnId;
185
+ continuesAssistantMessage(previous, entry);
177
186
  if (!shouldMerge || !previous) {
178
187
  output.push(entry);
179
188
  continue;
180
189
  }
181
190
  const previousAssistant = previous.item;
182
191
  const entryAssistant = entry.item;
183
- if (entryAssistant.messageId !== undefined &&
184
- previousAssistant.messageId !== entryAssistant.messageId) {
185
- output.push(entry);
186
- continue;
187
- }
188
192
  const collapsedKinds = new Set([
189
193
  ...previous.collapsed,
190
194
  ...entry.collapsed,
@@ -1,6 +1,6 @@
1
1
  import { MAX_RELAY_WEBSOCKET_MESSAGE_BYTES } from "@getpaseo/protocol/websocket-message-limit";
2
2
  import { resolve, dirname, basename } from "path";
3
- import { open as openFile, readFile, stat as statFile, mkdtemp, copyFile, realpath, access, rm, } from "fs/promises";
3
+ import { open as openFile, readFile, stat as statFile, mkdtemp, copyFile, utimes, realpath, access, rm, } from "fs/promises";
4
4
  import { tmpdir } from "node:os";
5
5
  import { setImmediate } from "node:timers/promises";
6
6
  import { TTLCache } from "@isaacs/ttlcache";
@@ -2536,6 +2536,12 @@ export async function prepareAllChangesIndex(cwd, baseRef) {
2536
2536
  }
2537
2537
  // write-tree rewrites its index. A private snapshot prevents an index read from
2538
2538
  // invalidating the observation that requested it.
2539
+ //
2540
+ // Git re-reads a file whose stat matches its index entry only when the entry is
2541
+ // not older than the index file ("racy git"). A fresh copy would be newer than
2542
+ // every entry, so a same-size edit made in the tick the index was written would
2543
+ // read as unchanged. The copy takes the source's mtime, read before copying and
2544
+ // rounded down to the second, so it is never later than the source.
2539
2545
  export async function snapshotComparisonIndex(cwd) {
2540
2546
  const directory = await mkdtemp(resolve(tmpdir(), "paseo-comparison-index-"));
2541
2547
  const indexFile = resolve(directory, "index");
@@ -2548,7 +2554,9 @@ export async function snapshotComparisonIndex(cwd) {
2548
2554
  if (!source)
2549
2555
  throw new Error("Git did not return an index path");
2550
2556
  try {
2557
+ const { atime, mtimeMs } = await statFile(source);
2551
2558
  await copyFile(source, indexFile);
2559
+ await utimes(indexFile, atime, Math.floor(mtimeMs / 1000));
2552
2560
  }
2553
2561
  catch (error) {
2554
2562
  if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT")