@sayknow-cli/coding-agent 0.7.5 → 0.7.7

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 CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.7.7] - 2026-10-06
6
+
7
+ ### Added
8
+
9
+ - An interrupted step now resumes once on its own without a new message, on the same model. This covers a restart with an unfinished step, and a transient failure after tools ran or part of the answer was shown. Tool calls whose outcome was not observed are never re-run. While any exist, the resumed turn may only use built-in read-only tools. Turn it off with `retry.autoResume: false`.
10
+ - A step now stops after 3 consecutive timeouts without any output (`retry.maxSilentTimeouts`) instead of spending its whole retry budget.
11
+
12
+ ### Fixed
13
+
14
+ - Print mode, `/copy`, RPC, and SDK `session.last_assistant` now return the whole continued answer, including the preserved prefix.
15
+ - A session-owned model step now leaves request retries (including long `Retry-After` waits) to the session retry layer instead of waiting inside the provider SDK. After unobserved remote work is reported, no further resend is admitted for that step.
16
+ - An unanswered continuation instruction is no longer sent to the model after a new prompt. A continuation also stops if compaction removed the preserved prefix from the model context.
17
+ - Transient provider failures recover on the same model within one shared step budget (7 upstream requests, 15 minutes after the first failure) instead of retrying without a limit. A failure after public text keeps that text. On `openai-completions` and `anthropic-messages` models outside a managed fallback attempt, a plain-text tail continues from it on the same model; other cases pause with the output preserved until the next message. Completed tool calls are not re-run. Restarting a session never auto-sends an interrupted recovery.
18
+ - When a step has started remote credential or gateway work whose effects cannot be observed (broker credential refresh, custom OAuth refresh, pi-native gateway, Cursor agent run), a failure is no longer resent automatically and `/retry` is refused; send a new message to resume.
19
+ - Credential rotation and restore HTTP during recovery now counts against the same shared step budget, and runs only while that budget is active.
20
+
21
+ ## [0.7.6] - 2026-10-05
22
+
23
+ ### Fixed
24
+
25
+ - Session import keeps the real read error (e.g. `content_too_large`) when closing the source file also fails, instead of surfacing `EBADF: bad file descriptor, close`.
26
+
5
27
  ## [0.7.5] - 2026-10-05
6
28
 
7
29
  ### Fixed
@@ -1,5 +1,5 @@
1
1
  import { type Api, type AssistantMessageEventStream, type AuthCredentialSelector, type CacheRetention, type Context, type Model, type ModelRefreshStrategy, type ModelRequestTransform, type SimpleStreamOptions, type ThinkingConfig } from "@sayknow-cli/ai";
2
- import type { OAuthCredentials, OAuthLoginCallbacks } from "@sayknow-cli/ai/utils/oauth/types";
2
+ import type { OAuthCredentials, OAuthLoginCallbacks, OAuthRefreshOptions } from "@sayknow-cli/ai/utils/oauth/types";
3
3
  import { type ThemeColor } from "../modes/theme/theme";
4
4
  import type { AuthStorage } from "../session/auth-storage";
5
5
  import type { ActiveSearchModelContext, WebSearchMode } from "../web/search/types";
@@ -393,14 +393,13 @@ export declare class ModelRegistry {
393
393
  /**
394
394
  * Get API key for a model.
395
395
  */
396
- getApiKey(model: Model<Api>, sessionId?: string, options?: {
396
+ getApiKey(model: Model<Api>, sessionId?: string, options?: OAuthRefreshOptions & {
397
397
  credentialSelector?: AuthCredentialSelector;
398
- signal?: AbortSignal;
399
398
  }): Promise<string | undefined>;
400
399
  /**
401
400
  * Get API key for a provider (e.g., "openai").
402
401
  */
403
- getApiKeyForProvider(provider: string, sessionId?: string, baseUrl?: string, options?: {
402
+ getApiKeyForProvider(provider: string, sessionId?: string, baseUrl?: string, options?: OAuthRefreshOptions & {
404
403
  credentialSelector?: AuthCredentialSelector;
405
404
  }): Promise<string | undefined>;
406
405
  /**
@@ -1506,6 +1506,20 @@ export declare const SETTINGS_SCHEMA: {
1506
1506
  readonly type: "boolean";
1507
1507
  readonly default: true;
1508
1508
  };
1509
+ /**
1510
+ * Resume an interrupted step once per user turn without a new message, on the same
1511
+ * model. Tool calls with unobserved outcomes are never re-run; while any exist the
1512
+ * resumed turn only gets built-in read-only tools.
1513
+ */
1514
+ readonly "retry.autoResume": {
1515
+ readonly type: "boolean";
1516
+ readonly default: true;
1517
+ };
1518
+ /** Consecutive timeouts without any output that stop a step early (1-7). */
1519
+ readonly "retry.maxSilentTimeouts": {
1520
+ readonly type: "number";
1521
+ readonly default: 3;
1522
+ };
1509
1523
  readonly "retry.maxRetries": {
1510
1524
  readonly type: "number";
1511
1525
  readonly default: 3;
@@ -1,3 +1,5 @@
1
+ /** The innermost tool behind any chain of applyToolProxy wrappers. */
2
+ export declare function unwrapProxiedTool(tool: object): object;
1
3
  /**
2
4
  * Defines lazy proxy properties on a wrapper so it forwards to the underlying tool.
3
5
  */
@@ -1268,9 +1268,11 @@ export declare class AgentSession {
1268
1268
  * Manually retry the last failed assistant turn, or resume an interrupted tail
1269
1269
  * left by a non-graceful process exit after the user/custom/tool-result message
1270
1270
  * was persisted but before the agent emitted a terminal assistant response.
1271
- * Removes failed/aborted/unresolved tool-use assistant tails before
1272
- * re-attempting with a fresh retry budget.
1273
- * @returns true if retry/resume was initiated, false if no retryable tail exists or agent is busy
1271
+ * Removes only a failed/aborted assistant tail with no visible output or tool
1272
+ * calls, then re-attempts with a fresh retry budget.
1273
+ * @returns false when the agent is busy, no retryable tail exists, the tail shows
1274
+ * output or tool calls, a persisted recovery is unresolved, or the step dispatched
1275
+ * unobservable remote work; true when a retry/resume was scheduled.
1274
1276
  */
1275
1277
  retry(): Promise<boolean>;
1276
1278
  /**
@@ -1451,6 +1453,8 @@ export declare class AgentSession {
1451
1453
  * @returns Text content, or undefined if no assistant message exists
1452
1454
  */
1453
1455
  getLastAssistantText(): string | undefined;
1456
+ /** The assistant messages that together form the visible answer ending at `assistant`. */
1457
+ getVisibleAnswerChain(assistant: AssistantMessage): AssistantMessage[];
1454
1458
  hasCopyCandidateAssistantMessage(): boolean;
1455
1459
  /**
1456
1460
  * Get text content of the most recent visible handoff message.
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Automatic, same-model resume of an interrupted model step.
3
+ *
4
+ * A step interrupted by a process restart, or by a transient failure after tools ran
5
+ * or part of the answer was shown (managed fallback chains included), resumes at most once per user turn without a
6
+ * new user message, pinned to the interrupted model. Calls whose outcome was never observed are answered with an error
7
+ * placeholder and never re-run; while such calls exist the resumed turn may only
8
+ * use built-in read-only tools.
9
+ */
10
+ import type { AgentMessage, AgentTool } from "@sayknow-cli/agent-core";
11
+ import type { ToolCall } from "@sayknow-cli/ai";
12
+ export declare const AUTO_RESUME_MARKER_CUSTOM_TYPE = "auto_resume_marker";
13
+ /** Requests and time a restart resume may spend; the interrupted step's own budget is unknown. */
14
+ export declare const RESTART_RESUME_MAX_REQUESTS = 2;
15
+ export declare const RESTART_RESUME_WINDOW_MS = 120000;
16
+ export declare const INTERRUPTED_TOOL_RESULT_TEXT = "Interrupted before its outcome was observed; it was not re-run. Check the current state with read-only tools before assuming it either happened or did not.";
17
+ export declare const AUTO_RESUME_RESTRICTED_PROMPT = "The previous step was interrupted and some tool calls have unknown outcomes; they were not re-run. Only read-only tools are available now. Verify the current state, then finish your answer or tell the user what still needs to be done. Do not repeat the interrupted actions.";
18
+ export declare const AUTO_RESUME_FULL_PROMPT = "The previous step was interrupted before it finished. Everything above is preserved exactly as the user saw it. Continue from where it stopped: do not repeat any of it and do not redo completed work.";
19
+ export type AutoResumeTrigger = "restart" | "interrupted";
20
+ export type AutoResumeMode = "full" | "restricted";
21
+ export type AutoResumePauseReason = "disabled" | "already_resumed" | "uncertain_upstream" | "unsafe_tail" | "budget_exhausted" | "user_input_pending" | "selector_unavailable" | "no_restart_safe_tools" | "not_interrupted";
22
+ export type AutoResumeDecision = {
23
+ type: "pause";
24
+ reason: AutoResumePauseReason;
25
+ } | {
26
+ type: "resume";
27
+ mode: AutoResumeMode;
28
+ interruptedCalls: ToolCall[];
29
+ };
30
+ export interface AutoResumeMarker {
31
+ version: 1;
32
+ trigger: AutoResumeTrigger;
33
+ mode: AutoResumeMode;
34
+ selector: string;
35
+ interruptedCallIds: string[];
36
+ }
37
+ /**
38
+ * Restart-safe means: an instance of a built-in read-only tool class (seen through
39
+ * extension/hook interception wrappers) whose wire name is unique among the selected
40
+ * tools. Name-alikes from MCP, extensions or custom tools never qualify, and a
41
+ * shadowed wire name disqualifies every holder.
42
+ */
43
+ export declare function isRestartSafeTool(tool: AgentTool, selectedTools: readonly AgentTool[]): boolean;
44
+ /** Marks an in-memory pairing result the SDK adds on resume; it observed no outcome. */
45
+ export declare const SYNTHESIZED_ON_RESUME_DETAIL = "synthesizedOnResume";
46
+ /** A pairing result synthesized on resume: the call's real outcome is unknown. */
47
+ export declare function isSynthesizedResumeResult(message: AgentMessage): boolean;
48
+ /** Tool calls of the current user turn whose outcome no result in the transcript observed. */
49
+ export declare function findInterruptedToolCalls(messages: readonly AgentMessage[]): ToolCall[];
50
+ /** The trailing failed assistant shows a text prefix the user already saw. */
51
+ export declare function hasVisibleFailedPrefix(messages: readonly AgentMessage[]): boolean;
52
+ export interface AutoResumePolicyInput {
53
+ enabled: boolean;
54
+ trigger: AutoResumeTrigger;
55
+ /** Transcript the resume would be sent with. */
56
+ messages: readonly AgentMessage[];
57
+ /** An auto-resume marker exists after the last user message. */
58
+ resumedThisTurn: boolean;
59
+ /** Remote work with an unobservable outcome happened in the interrupted step. */
60
+ uncertainUpstream: boolean;
61
+ /** The provider transport executes work remotely (Cursor, pi-native). */
62
+ opaqueTransport: boolean;
63
+ /** The budget the resume would spend can still admit a request. */
64
+ budgetAdmits: boolean;
65
+ /** A user message, steer or follow-up is queued. */
66
+ userInputPending: boolean;
67
+ /** The interrupted step's selector still resolves to the current model. */
68
+ selectorAvailable: boolean;
69
+ /** The current serializer projects a failed plain-text prefix faithfully. */
70
+ prefixReplayable: boolean;
71
+ /** Currently selected tools. */
72
+ selectedTools: readonly AgentTool[];
73
+ }
74
+ /** Single decision point for every automatic resume. */
75
+ export declare function resolveAutoResumePolicy(input: AutoResumePolicyInput): AutoResumeDecision;
76
+ /** Whether an auto-resume marker was written after the last user message of `entries`. */
77
+ export declare function hasAutoResumeMarkerSinceLastUser(entries: readonly {
78
+ type: string;
79
+ customType?: string;
80
+ message?: {
81
+ role: string;
82
+ };
83
+ }[]): boolean;
@@ -39,6 +39,13 @@ export declare class FallbackChainController {
39
39
  reason: string;
40
40
  }>;
41
41
  exhaustedForTurn: boolean;
42
+ /**
43
+ * When true, the session's shared same-model recovery budget (bounded wire
44
+ * count and deadline) owns transient failures instead of the per-entry
45
+ * attempt cap. Set only while `fallback.maxAttempts` is not explicitly
46
+ * configured; quota and auth keep their per-entry chain semantics.
47
+ */
48
+ sessionBudgetOwnsTransient: boolean;
42
49
  constructor(chain: ConfiguredFallbackChain, maxAttempts: number);
43
50
  get totalAttemptsUsed(): number;
44
51
  currentSelector(): string | undefined;
@@ -47,6 +47,38 @@ export interface SkillPromptDetails {
47
47
  * #buildTranscriptLines`, `runPrintMode`, and `AcpAgent#replayAssistantMessage`
48
48
  * (fallback error emission) read it via `isSilentAbort`. */
49
49
  export declare const SILENT_ABORT_MARKER = "__skc.silent_abort__";
50
+ /** Custom message type of the hidden instruction that resumes an interrupted visible answer. */
51
+ export declare const VISIBLE_CONTINUATION_CUSTOM_TYPE = "stream-continuation";
52
+ /** Hidden instruction that drives an automatic resume of an interrupted step. */
53
+ export declare const AUTO_RESUME_CUSTOM_TYPE = "auto-resume";
54
+ /**
55
+ * The assistant messages that together form one visible answer: a preserved prefix
56
+ * interrupted mid-stream and each same-step continuation that resumed it. Returns
57
+ * `[assistant]` when the message did not resume an interrupted answer.
58
+ */
59
+ export declare function getVisibleAnswerChain(messages: readonly ({
60
+ role: string;
61
+ customType?: string;
62
+ } | AssistantMessage)[], assistant: AssistantMessage): AssistantMessage[];
63
+ /**
64
+ * Text of the last visible answer on a persisted branch, including the preserved
65
+ * prefix of a continued answer. Entries are projected to messages and continuation
66
+ * instructions; everything else breaks a chain.
67
+ */
68
+ export declare function lastVisibleAnswerText(branch: readonly ({
69
+ type: "message";
70
+ message: {
71
+ role: string;
72
+ } | AssistantMessage;
73
+ } | {
74
+ type: "custom_message";
75
+ customType: string;
76
+ } | {
77
+ type: string;
78
+ })[]): string | undefined;
79
+ export declare function isAssistantMessage(message: {
80
+ role: string;
81
+ } | AssistantMessage): message is AssistantMessage;
50
82
  /** Type-guard for `SILENT_ABORT_MARKER`. Renderers MUST branch on this rather
51
83
  * than string-comparing inline so refactors to the marker constant (e.g.,
52
84
  * namespacing changes) propagate through every consumer in lockstep. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@sayknow-cli/coding-agent",
4
- "version": "0.7.5",
4
+ "version": "0.7.7",
5
5
  "description": "Sayknow-CLI CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://sayknow-cli.com",
7
7
  "author": "jaybeyond",
@@ -54,12 +54,12 @@
54
54
  "@agentclientprotocol/sdk": "1.3.0",
55
55
  "@babel/parser": "^7.29.3",
56
56
  "@mozilla/readability": "^0.6.0",
57
- "@sayknow-cli/stats": "0.7.5",
58
- "@sayknow-cli/agent-core": "0.7.5",
59
- "@sayknow-cli/ai": "0.7.5",
60
- "@sayknow-cli/natives": "0.7.5",
61
- "@sayknow-cli/tui": "0.7.5",
62
- "@sayknow-cli/utils": "0.7.5",
57
+ "@sayknow-cli/stats": "0.7.7",
58
+ "@sayknow-cli/agent-core": "0.7.7",
59
+ "@sayknow-cli/ai": "0.7.7",
60
+ "@sayknow-cli/natives": "0.7.7",
61
+ "@sayknow-cli/tui": "0.7.7",
62
+ "@sayknow-cli/utils": "0.7.7",
63
63
  "@puppeteer/browsers": "^2.13.0",
64
64
  "@types/turndown": "5.0.6",
65
65
  "@xterm/headless": "^6.0.0",
@@ -185,6 +185,7 @@ const LOCKED_EXCLUSIONS: Readonly<Record<string, string>> = {
185
185
  "agent_session:navigateTree": "internal accessor/plumbing, not a user-facing control seam",
186
186
  "agent_session:hasCopyCandidateAssistantMessage": "internal accessor/plumbing, not a user-facing control seam",
187
187
  "agent_session:getLastVisibleHandoffText": "internal accessor/plumbing, not a user-facing control seam",
188
+ "agent_session:getVisibleAnswerChain": "internal accessor/plumbing, not a user-facing control seam",
188
189
  "agent_session:hasExtensionHandlers": "internal accessor/plumbing, not a user-facing control seam",
189
190
  "agent_session:registerBeforeAgentStartContributor": "internal accessor/plumbing, not a user-facing control seam",
190
191
  "agent_session:setSdkPermissionProvider": "internal reverse-provider plumbing, not a user-facing SDK control seam",
@@ -36,7 +36,7 @@ import { detectDiscoveredApiFamily } from "@sayknow-cli/ai/utils/discovery/opena
36
36
  const DEFAULT_LOCAL_TOKEN = "lm-studio-local";
37
37
 
38
38
  import { registerOAuthProvider, unregisterOAuthProviders } from "@sayknow-cli/ai/utils/oauth";
39
- import type { OAuthCredentials, OAuthLoginCallbacks } from "@sayknow-cli/ai/utils/oauth/types";
39
+ import type { OAuthCredentials, OAuthLoginCallbacks, OAuthRefreshOptions } from "@sayknow-cli/ai/utils/oauth/types";
40
40
  import { $pickCredentialEnv, isRecord, logger } from "@sayknow-cli/utils";
41
41
  import { parseModelString, resolveProviderModelReference } from "../config/model-resolver";
42
42
  import { isValidThemeColor, type ThemeColor } from "../modes/theme/theme";
@@ -2864,16 +2864,15 @@ export class ModelRegistry {
2864
2864
  async getApiKey(
2865
2865
  model: Model<Api>,
2866
2866
  sessionId?: string,
2867
- options: { credentialSelector?: AuthCredentialSelector; signal?: AbortSignal } = {},
2867
+ options: OAuthRefreshOptions & { credentialSelector?: AuthCredentialSelector } = {},
2868
2868
  ): Promise<string | undefined> {
2869
2869
  if (this.#keylessProviders.has(model.provider) && !this.authStorage.hasAuth(model.provider)) {
2870
2870
  return kNoAuth;
2871
2871
  }
2872
2872
  return this.authStorage.getApiKey(model.provider, sessionId, {
2873
+ ...options,
2873
2874
  baseUrl: model.baseUrl,
2874
2875
  modelId: model.id,
2875
- credentialSelector: options.credentialSelector,
2876
- signal: options.signal,
2877
2876
  });
2878
2877
  }
2879
2878
 
@@ -2884,14 +2883,14 @@ export class ModelRegistry {
2884
2883
  provider: string,
2885
2884
  sessionId?: string,
2886
2885
  baseUrl?: string,
2887
- options: { credentialSelector?: AuthCredentialSelector } = {},
2886
+ options: OAuthRefreshOptions & { credentialSelector?: AuthCredentialSelector } = {},
2888
2887
  ): Promise<string | undefined> {
2889
2888
  if (this.#keylessProviders.has(provider) && !this.authStorage.hasAuth(provider)) {
2890
2889
  return kNoAuth;
2891
2890
  }
2892
2891
  return this.authStorage.getApiKey(provider, sessionId, {
2892
+ ...options,
2893
2893
  baseUrl,
2894
- credentialSelector: options.credentialSelector,
2895
2894
  });
2896
2895
  }
2897
2896
 
@@ -1261,6 +1261,14 @@ export const SETTINGS_SCHEMA = {
1261
1261
 
1262
1262
  // Retries
1263
1263
  "retry.enabled": { type: "boolean", default: true },
1264
+ /**
1265
+ * Resume an interrupted step once per user turn without a new message, on the same
1266
+ * model. Tool calls with unobserved outcomes are never re-run; while any exist the
1267
+ * resumed turn only gets built-in read-only tools.
1268
+ */
1269
+ "retry.autoResume": { type: "boolean", default: true },
1270
+ /** Consecutive timeouts without any output that stop a step early (1-7). */
1271
+ "retry.maxSilentTimeouts": { type: "number", default: 3 },
1264
1272
 
1265
1273
  "retry.maxRetries": {
1266
1274
  type: "number",
@@ -1,7 +1,18 @@
1
+ /** Wrapper → the tool it forwards to. Only wrappers built by applyToolProxy are recorded. */
2
+ const proxiedTools = new WeakMap<object, object>();
3
+
4
+ /** The innermost tool behind any chain of applyToolProxy wrappers. */
5
+ export function unwrapProxiedTool(tool: object): object {
6
+ let current = tool;
7
+ for (let next = proxiedTools.get(current); next !== undefined; next = proxiedTools.get(current)) current = next;
8
+ return current;
9
+ }
10
+
1
11
  /**
2
12
  * Defines lazy proxy properties on a wrapper so it forwards to the underlying tool.
3
13
  */
4
14
  export function applyToolProxy<TTool extends object>(tool: TTool, wrapper: object): void {
15
+ proxiedTools.set(wrapper, tool);
5
16
  const visited = new Set<PropertyKey>();
6
17
  let current: object | null = tool;
7
18