lark-remote 0.1.6 → 0.1.8

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 (216) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/README.en.md +9 -1
  3. package/README.md +14 -2
  4. package/dist/bridge/approval-coordinator.d.ts +71 -34
  5. package/dist/bridge/approval-coordinator.js +225 -41
  6. package/dist/bridge/inbound-media.d.ts +62 -0
  7. package/dist/bridge/inbound-media.js +282 -0
  8. package/dist/bridge/index.d.ts +97 -13
  9. package/dist/bridge/index.js +227 -87
  10. package/dist/bridge/queue-manager.d.ts +2 -1
  11. package/dist/bridge/queue-manager.js +1 -0
  12. package/dist/card/approval-render.js +294 -36
  13. package/dist/card/bash-card-session.d.ts +2 -24
  14. package/dist/card/bash-card-session.js +6 -73
  15. package/dist/card/bash-renderer.js +2 -3
  16. package/dist/card/card-budget.js +29 -75
  17. package/dist/card/card-session.d.ts +48 -0
  18. package/dist/card/card-session.js +86 -0
  19. package/dist/card/card-shared.d.ts +7 -16
  20. package/dist/card/card-shared.js +7 -30
  21. package/dist/card/run-card-session.d.ts +2 -55
  22. package/dist/card/run-card-session.js +6 -104
  23. package/dist/card/run-renderer.d.ts +7 -0
  24. package/dist/card/run-renderer.js +116 -238
  25. package/dist/card/run-state.d.ts +13 -0
  26. package/dist/card/run-state.js +25 -16
  27. package/dist/card/text-truncate.d.ts +13 -12
  28. package/dist/card/text-truncate.js +13 -63
  29. package/dist/common/fs.d.ts +8 -0
  30. package/dist/common/fs.js +17 -0
  31. package/dist/common/guards.d.ts +0 -20
  32. package/dist/common/guards.js +0 -43
  33. package/dist/common/sleep.d.ts +2 -0
  34. package/dist/common/sleep.js +5 -0
  35. package/dist/common/truncate.d.ts +39 -0
  36. package/dist/common/truncate.js +92 -0
  37. package/dist/config/codex-config.d.ts +1 -1
  38. package/dist/config/codex-config.js +1 -1
  39. package/dist/config/index.d.ts +112 -24
  40. package/dist/config/index.js +139 -37
  41. package/dist/connector/index.d.ts +69 -2
  42. package/dist/connector/index.js +107 -1
  43. package/dist/index.js +150 -118
  44. package/dist/instance-lock.js +4 -12
  45. package/dist/order/alias-resolve.d.ts +13 -0
  46. package/dist/order/alias-resolve.js +22 -0
  47. package/dist/order/alias-store.d.ts +38 -0
  48. package/dist/order/alias-store.js +106 -0
  49. package/dist/persistence/atomic-write.d.ts +8 -2
  50. package/dist/persistence/atomic-write.js +23 -7
  51. package/dist/restart.js +2 -1
  52. package/dist/router/card-action-payload.d.ts +30 -0
  53. package/dist/router/card-action-payload.js +39 -0
  54. package/dist/router/card-helpers.d.ts +63 -0
  55. package/dist/router/card-helpers.js +146 -0
  56. package/dist/router/config/claude.js +30 -1
  57. package/dist/router/config/codex.js +29 -50
  58. package/dist/router/config/common/model-patch.d.ts +22 -0
  59. package/dist/router/config/common/model-patch.js +26 -0
  60. package/dist/router/config/common/render.js +5 -4
  61. package/dist/router/config/dsh.d.ts +51 -0
  62. package/dist/router/config/dsh.js +179 -0
  63. package/dist/router/config/index.d.ts +12 -0
  64. package/dist/router/config/index.js +28 -1
  65. package/dist/router/config/kimi.d.ts +4 -1
  66. package/dist/router/config/kimi.js +27 -0
  67. package/dist/router/config/opencode.js +18 -5
  68. package/dist/router/config/pi.js +4 -5
  69. package/dist/router/config/types.d.ts +17 -2
  70. package/dist/router/index.d.ts +76 -22
  71. package/dist/router/index.js +479 -548
  72. package/dist/router/utils.d.ts +2 -0
  73. package/dist/router/utils.js +16 -2
  74. package/dist/runner/agent-choices-common.d.ts +16 -0
  75. package/dist/runner/agent-choices-common.js +34 -0
  76. package/dist/runner/claude/runner.d.ts +47 -10
  77. package/dist/runner/claude/runner.js +117 -46
  78. package/dist/runner/claude/session.d.ts +166 -0
  79. package/dist/runner/claude/session.js +768 -0
  80. package/dist/runner/codex/app-server/protocol-types.d.ts +66 -39
  81. package/dist/runner/codex/app-server/protocol-types.js +2 -13
  82. package/dist/runner/codex/app-server/runner.d.ts +52 -59
  83. package/dist/runner/codex/app-server/runner.js +216 -338
  84. package/dist/runner/codex/app-server/translator.d.ts +8 -21
  85. package/dist/runner/codex/app-server/translator.js +45 -18
  86. package/dist/runner/codex/index.d.ts +0 -2
  87. package/dist/runner/codex/index.js +0 -2
  88. package/dist/runner/common/acp/protocol-helpers.d.ts +14 -0
  89. package/dist/runner/common/acp/protocol-helpers.js +21 -0
  90. package/dist/runner/common/acp/protocol-types.d.ts +271 -0
  91. package/dist/runner/common/acp/protocol-types.js +77 -0
  92. package/dist/runner/common/connection-based-runner.d.ts +111 -0
  93. package/dist/runner/common/connection-based-runner.js +261 -0
  94. package/dist/runner/{codex/app-server → common/jsonrpc}/client.d.ts +14 -7
  95. package/dist/runner/{codex/app-server → common/jsonrpc}/client.js +27 -18
  96. package/dist/runner/common/jsonrpc/connection-manager.d.ts +125 -0
  97. package/dist/runner/{codex/app-server → common/jsonrpc}/connection-manager.js +63 -28
  98. package/dist/runner/{codex/app-server → common/jsonrpc}/transport.d.ts +5 -4
  99. package/dist/runner/{codex/app-server → common/jsonrpc}/transport.js +18 -19
  100. package/dist/runner/common/jsonrpc/types.d.ts +32 -0
  101. package/dist/runner/common/jsonrpc/types.js +9 -0
  102. package/dist/runner/common/process-stopper.d.ts +2 -1
  103. package/dist/runner/common/process-stopper.js +1 -0
  104. package/dist/runner/common/runner-utils.d.ts +6 -13
  105. package/dist/runner/common/runner-utils.js +6 -47
  106. package/dist/runner/common/spawning-runner.d.ts +24 -70
  107. package/dist/runner/common/spawning-runner.js +98 -152
  108. package/dist/runner/dsh/client.d.ts +95 -0
  109. package/dist/runner/dsh/client.js +418 -0
  110. package/dist/runner/dsh/fake-dsh-server.d.ts +60 -0
  111. package/dist/runner/dsh/fake-dsh-server.js +156 -0
  112. package/dist/runner/dsh/index.d.ts +3 -0
  113. package/dist/runner/dsh/index.js +4 -0
  114. package/dist/runner/dsh/runner.d.ts +57 -0
  115. package/dist/runner/dsh/runner.js +191 -0
  116. package/dist/runner/dsh/translator.d.ts +28 -0
  117. package/dist/runner/dsh/translator.js +98 -0
  118. package/dist/runner/dsh/types.d.ts +155 -0
  119. package/dist/runner/dsh/types.js +14 -0
  120. package/dist/runner/index.d.ts +5 -4
  121. package/dist/runner/index.js +5 -4
  122. package/dist/runner/kimi/acp/runner.d.ts +106 -0
  123. package/dist/runner/kimi/acp/runner.js +516 -0
  124. package/dist/runner/kimi/acp/translator.d.ts +138 -0
  125. package/dist/runner/kimi/acp/translator.js +441 -0
  126. package/dist/runner/kimi/index.d.ts +1 -1
  127. package/dist/runner/kimi/index.js +1 -1
  128. package/dist/runner/opencode/acp/index.d.ts +1 -0
  129. package/dist/runner/opencode/acp/index.js +2 -0
  130. package/dist/runner/opencode/acp/runner.d.ts +121 -0
  131. package/dist/runner/opencode/acp/runner.js +429 -0
  132. package/dist/runner/opencode/acp/translator.d.ts +119 -0
  133. package/dist/runner/opencode/acp/translator.js +345 -0
  134. package/dist/runner/opencode/index.d.ts +1 -1
  135. package/dist/runner/opencode/index.js +1 -1
  136. package/dist/runner/pi/index.d.ts +1 -1
  137. package/dist/runner/pi/index.js +1 -1
  138. package/dist/runner/pi/rpc/client.d.ts +52 -0
  139. package/dist/runner/pi/rpc/client.js +114 -0
  140. package/dist/runner/pi/rpc/index.d.ts +4 -0
  141. package/dist/runner/pi/rpc/index.js +4 -0
  142. package/dist/runner/pi/rpc/protocol-types.d.ts +127 -0
  143. package/dist/runner/pi/rpc/protocol-types.js +21 -0
  144. package/dist/runner/pi/rpc/runner.d.ts +74 -0
  145. package/dist/runner/pi/rpc/runner.js +190 -0
  146. package/dist/runner/pi/rpc/translator.d.ts +55 -0
  147. package/dist/runner/pi/rpc/translator.js +258 -0
  148. package/dist/runner/probe.js +6 -1
  149. package/dist/runner/question-common.d.ts +26 -0
  150. package/dist/runner/question-common.js +42 -0
  151. package/dist/runner/registry.d.ts +7 -8
  152. package/dist/runner/registry.js +3 -4
  153. package/dist/runner/resolve-agent-choices.js +18 -59
  154. package/dist/runner/sync-agent-choices.js +16 -67
  155. package/dist/runner/types.d.ts +97 -14
  156. package/dist/session/claude/session-index.js +2 -3
  157. package/dist/session/claude/session-reader.js +3 -6
  158. package/dist/session/claude/sessions.js +43 -28
  159. package/dist/session/codex/rollout-reader.d.ts +2 -2
  160. package/dist/session/codex/rollout-reader.js +14 -17
  161. package/dist/session/codex/sessions.d.ts +1 -1
  162. package/dist/session/codex/sessions.js +2 -2
  163. package/dist/session/common/content-blocks.d.ts +7 -0
  164. package/dist/session/common/content-blocks.js +13 -9
  165. package/dist/session/common/jsonl.d.ts +8 -25
  166. package/dist/session/common/jsonl.js +126 -261
  167. package/dist/session/common/pagination.d.ts +28 -0
  168. package/dist/session/common/pagination.js +33 -0
  169. package/dist/session/dsh/index.d.ts +1 -0
  170. package/dist/session/dsh/index.js +2 -0
  171. package/dist/session/dsh/sessions.d.ts +39 -0
  172. package/dist/session/dsh/sessions.js +237 -0
  173. package/dist/session/index.d.ts +1 -0
  174. package/dist/session/index.js +1 -0
  175. package/dist/session/kimi/sessions.d.ts +34 -1
  176. package/dist/session/kimi/sessions.js +208 -98
  177. package/dist/session/opencode/sessions.d.ts +17 -3
  178. package/dist/session/opencode/sessions.js +29 -29
  179. package/dist/session/pi/sessions.d.ts +5 -1
  180. package/dist/session/pi/sessions.js +12 -16
  181. package/dist/session/session-store.d.ts +11 -1
  182. package/dist/session/session-store.js +75 -178
  183. package/dist/update/index.d.ts +2 -2
  184. package/dist/update/index.js +2 -2
  185. package/dist/update/install.d.ts +20 -2
  186. package/dist/update/install.js +51 -7
  187. package/dist/workspace/index.d.ts +4 -0
  188. package/dist/workspace/index.js +8 -1
  189. package/package.json +2 -1
  190. package/dist/runner/codex/app-server/connection-manager.d.ts +0 -56
  191. package/dist/runner/codex/argv.d.ts +0 -33
  192. package/dist/runner/codex/argv.js +0 -40
  193. package/dist/runner/codex/factory.d.ts +0 -29
  194. package/dist/runner/codex/factory.js +0 -39
  195. package/dist/runner/codex/jsonl.d.ts +0 -37
  196. package/dist/runner/codex/jsonl.js +0 -221
  197. package/dist/runner/codex/runner.d.ts +0 -66
  198. package/dist/runner/codex/runner.js +0 -129
  199. package/dist/runner/common/exec-translator.d.ts +0 -73
  200. package/dist/runner/common/exec-translator.js +0 -105
  201. package/dist/runner/kimi/jsonl.d.ts +0 -28
  202. package/dist/runner/kimi/jsonl.js +0 -143
  203. package/dist/runner/kimi/runner.d.ts +0 -49
  204. package/dist/runner/kimi/runner.js +0 -105
  205. package/dist/runner/opencode/argv.d.ts +0 -32
  206. package/dist/runner/opencode/argv.js +0 -35
  207. package/dist/runner/opencode/jsonl.d.ts +0 -68
  208. package/dist/runner/opencode/jsonl.js +0 -295
  209. package/dist/runner/opencode/runner.d.ts +0 -61
  210. package/dist/runner/opencode/runner.js +0 -93
  211. package/dist/runner/pi/jsonl.d.ts +0 -128
  212. package/dist/runner/pi/jsonl.js +0 -249
  213. package/dist/runner/pi/runner.d.ts +0 -36
  214. package/dist/runner/pi/runner.js +0 -76
  215. package/dist/session/common/catch-up.d.ts +0 -12
  216. package/dist/session/common/catch-up.js +0 -31
@@ -7,51 +7,20 @@
7
7
  * (`item/agentMessage/delta`) and snake_case only where the server requires it
8
8
  * (e.g. permission profile fields).
9
9
  */
10
- export interface JsonRpcRequest {
11
- jsonrpc: '2.0';
12
- id: number | string;
13
- method: string;
14
- params?: unknown;
15
- }
16
- export interface JsonRpcNotification {
17
- jsonrpc: '2.0';
18
- method: string;
19
- params?: unknown;
20
- }
21
- export interface JsonRpcSuccessResponse {
22
- jsonrpc: '2.0';
23
- id: number | string;
24
- result: unknown;
25
- }
26
- export interface JsonRpcErrorResponse {
27
- jsonrpc: '2.0';
28
- id: number | string | null;
29
- error: {
30
- code: number;
31
- message: string;
32
- data?: unknown;
33
- };
34
- }
35
- export type ServerMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcSuccessResponse | JsonRpcErrorResponse;
36
- /** Standard JSON-RPC error codes. */
37
- export declare const RpcErrorCode: {
38
- readonly PARSE_ERROR: -32700;
39
- readonly INVALID_REQUEST: -32600;
40
- readonly METHOD_NOT_FOUND: -32601;
41
- readonly INVALID_PARAMS: -32602;
42
- readonly INTERNAL_ERROR: -32603;
43
- /** Timeout error (custom, not standard JSON-RPC). */
44
- readonly TIMEOUT_ERROR: -32000;
45
- /** Connection lost / transport error (custom). */
46
- readonly CONNECTION_LOST: -32001;
47
- };
10
+ export type { JsonRpcRequest, JsonRpcNotification, JsonRpcSuccessResponse, JsonRpcErrorResponse, } from '../../common/jsonrpc/types.js';
48
11
  export interface ClientInfo {
49
12
  name: string;
50
13
  version: string;
51
14
  }
15
+ export interface InitializeCapabilities {
16
+ experimentalApi?: boolean;
17
+ requestAttestation?: boolean;
18
+ optOutNotificationMethods?: string[];
19
+ mcpServerOpenaiFormElicitation?: boolean;
20
+ }
52
21
  export interface InitializeParams {
53
22
  clientInfo: ClientInfo;
54
- capabilities?: Record<string, unknown>;
23
+ capabilities?: InitializeCapabilities;
55
24
  }
56
25
  export interface InitializeResult {
57
26
  serverInfo?: {
@@ -114,6 +83,8 @@ export interface ThreadResumeParams {
114
83
  modelProvider?: string | null;
115
84
  approvalPolicy?: AskForApproval;
116
85
  sandbox?: SandboxMode;
86
+ /** Configuration overrides for the resumed thread (codex v2 wire field). */
87
+ config?: Record<string, unknown> | null;
117
88
  }
118
89
  export interface ThreadResumeResponse {
119
90
  thread: Thread;
@@ -121,6 +92,28 @@ export interface ThreadResumeResponse {
121
92
  model: string;
122
93
  modelProvider: string;
123
94
  }
95
+ /** `thread/settings/update` params (real v2 protocol). */
96
+ export interface ThreadSettingsUpdateParams {
97
+ threadId: string;
98
+ /** Override the approval policy for subsequent turns. */
99
+ approvalPolicy?: AskForApproval;
100
+ /** Override the sandbox policy for subsequent turns. */
101
+ sandboxPolicy?: SandboxPolicy;
102
+ /** Override the model for subsequent turns. */
103
+ model?: string | null;
104
+ /** Override the model provider for subsequent turns. */
105
+ modelProvider?: string | null;
106
+ }
107
+ export interface ThreadSettingsUpdateResponse {
108
+ }
109
+ /** Server→client notification after a settings update is applied. */
110
+ export interface ThreadSettingsUpdatedNotification {
111
+ method: 'thread/settings/updated';
112
+ params: {
113
+ threadId: string;
114
+ threadSettings: unknown;
115
+ };
116
+ }
124
117
  export interface ThreadCompactStartParams {
125
118
  threadId: string;
126
119
  }
@@ -268,6 +261,7 @@ export declare const NotificationMethod: {
268
261
  readonly WARNING: "warning";
269
262
  readonly THREAD_STARTED: "thread/started";
270
263
  readonly THREAD_STATUS_CHANGED: "thread/status/changed";
264
+ readonly THREAD_SETTINGS_UPDATED: "thread/settings/updated";
271
265
  readonly THREAD_COMPACTED: "thread/compacted";
272
266
  readonly MODEL_REROUTED: "model/rerouted";
273
267
  };
@@ -440,6 +434,7 @@ export declare const ServerRequestMethod: {
440
434
  readonly COMMAND_EXECUTION_APPROVAL: "item/commandExecution/requestApproval";
441
435
  readonly FILE_CHANGE_APPROVAL: "item/fileChange/requestApproval";
442
436
  readonly PERMISSIONS_APPROVAL: "item/permissions/requestApproval";
437
+ readonly REQUEST_USER_INPUT: "item/tool/requestUserInput";
443
438
  };
444
439
  export interface NetworkApprovalContext {
445
440
  host: string;
@@ -523,5 +518,37 @@ export interface PermissionsRequestApprovalResponse {
523
518
  permissions: GrantedPermissionProfile;
524
519
  scope?: 'turn' | 'session';
525
520
  }
521
+ /**
522
+ * Codex AskUserQuestion(request_user_input)协议形状。
523
+ * 来源:codex-rs/codex-rs/protocol/src/request_user_input.rs +
524
+ * app-server-protocol v2/item.rs ToolRequestUserInput*(EXPERIMENTAL)。
525
+ * isOther=true → 渲染层提供自定义答案输入;isSecret 仅影响展示(按普通输入
526
+ * 处理);options 为 null/空 → 自由文本题。
527
+ */
528
+ export interface ToolRequestUserInputOption {
529
+ label: string;
530
+ description: string;
531
+ }
532
+ export interface ToolRequestUserInputQuestion {
533
+ id: string;
534
+ header: string;
535
+ question: string;
536
+ isOther: boolean;
537
+ isSecret: boolean;
538
+ options: ToolRequestUserInputOption[] | null;
539
+ }
540
+ export interface ToolRequestUserInputParams {
541
+ threadId: string;
542
+ turnId: string;
543
+ itemId: string;
544
+ questions: ToolRequestUserInputQuestion[];
545
+ autoResolutionMs?: number | null;
546
+ }
547
+ export interface ToolRequestUserInputAnswer {
548
+ answers: string[];
549
+ }
550
+ export interface ToolRequestUserInputResponse {
551
+ answers: Record<string, ToolRequestUserInputAnswer>;
552
+ }
526
553
  /** Unsupported / ignored server request methods. */
527
554
  export declare const UNSUPPORTED_SERVER_REQUEST_METHODS: Set<string>;
@@ -7,18 +7,6 @@
7
7
  * (`item/agentMessage/delta`) and snake_case only where the server requires it
8
8
  * (e.g. permission profile fields).
9
9
  */
10
- /** Standard JSON-RPC error codes. */
11
- export const RpcErrorCode = {
12
- PARSE_ERROR: -32700,
13
- INVALID_REQUEST: -32600,
14
- METHOD_NOT_FOUND: -32601,
15
- INVALID_PARAMS: -32602,
16
- INTERNAL_ERROR: -32603,
17
- /** Timeout error (custom, not standard JSON-RPC). */
18
- TIMEOUT_ERROR: -32000,
19
- /** Connection lost / transport error (custom). */
20
- CONNECTION_LOST: -32001,
21
- };
22
10
  // =============================================================================
23
11
  // Notifications (server → client)
24
12
  // =============================================================================
@@ -42,6 +30,7 @@ export const NotificationMethod = {
42
30
  WARNING: 'warning',
43
31
  THREAD_STARTED: 'thread/started',
44
32
  THREAD_STATUS_CHANGED: 'thread/status/changed',
33
+ THREAD_SETTINGS_UPDATED: 'thread/settings/updated',
45
34
  THREAD_COMPACTED: 'thread/compacted',
46
35
  MODEL_REROUTED: 'model/rerouted',
47
36
  };
@@ -52,10 +41,10 @@ export const ServerRequestMethod = {
52
41
  COMMAND_EXECUTION_APPROVAL: 'item/commandExecution/requestApproval',
53
42
  FILE_CHANGE_APPROVAL: 'item/fileChange/requestApproval',
54
43
  PERMISSIONS_APPROVAL: 'item/permissions/requestApproval',
44
+ REQUEST_USER_INPUT: 'item/tool/requestUserInput',
55
45
  };
56
46
  /** Unsupported / ignored server request methods. */
57
47
  export const UNSUPPORTED_SERVER_REQUEST_METHODS = new Set([
58
- 'item/tool/requestUserInput',
59
48
  'mcpServer/elicitation/request',
60
49
  'item/tool/call',
61
50
  'account/chatgptAuthTokens/refresh',
@@ -5,9 +5,16 @@
5
5
  * Flow per run: acquire persistent connection → thread/start or thread/resume
6
6
  * → turn/start → consume notifications (agent message deltas, approval server
7
7
  * requests, …) until turn/completed → synthesize ResultEvent.
8
+ *
9
+ * Shares the ConnectionBasedRunner base with kimi/opencode: same notification
10
+ * queue + waitResolve pump, forceFinish/stopRequested semantics, turn idle
11
+ * watchdog, and ConnectionLostError respawn-and-retry-once.
8
12
  */
9
- import type { AgentKind, AgentSessionReader, AgentEvent, AgentRunner, AgentStatusInfo, SpawnOptions } from '../../types.js';
10
- import { type AskForApproval, type SandboxMode } from './protocol-types.js';
13
+ import type { AgentKind, AgentSessionReader, AgentEvent, AgentStatusInfo, SpawnOptions } from '../../types.js';
14
+ import { JsonRpcClient } from '../../common/jsonrpc/client.js';
15
+ import { type TranslatorEvent } from './translator.js';
16
+ import { type AskForApproval, type SandboxMode, type SandboxPolicy, type InitializeResult } from './protocol-types.js';
17
+ import { ConnectionBasedRunner } from '../../common/connection-based-runner.js';
11
18
  export interface CodexAppServerRunnerOptions {
12
19
  kind: AgentKind;
13
20
  sessionReader: AgentSessionReader;
@@ -31,90 +38,76 @@ export interface CodexAppServerRunnerOptions {
31
38
  /** Configured approval policy (Codex 官方 AskForApproval 标准值). */
32
39
  approvalPolicy?: AskForApproval;
33
40
  }
34
- export declare class CodexAppServerRunner implements AgentRunner {
35
- readonly kind: AgentKind;
36
- readonly sessionReader: AgentSessionReader;
37
- readonly lifetime: "workspace";
41
+ /**
42
+ * Map the client-side SandboxMode enum to the response-side SandboxPolicy
43
+ * object used by `thread/settings/update` (`sandboxPolicy`).
44
+ */
45
+ export declare function sandboxModeToSandboxPolicy(mode: SandboxMode): SandboxPolicy;
46
+ /**
47
+ * Codex 官方 feature override(thread/start·resume 的 `config` 字段):
48
+ * 让 `request_user_input` 在 Default 协作模式下也可用,无需改 codex
49
+ * config.toml。协议键与 openai/codex 的 feature registry 一致
50
+ * (key `default_mode_request_user_input`),app-server 官方测试
51
+ * (turn_start.rs)验证同一路径。
52
+ */
53
+ export declare const THREAD_CONFIG_DEFAULT_MODE_REQUEST_USER_INPUT: {
54
+ readonly 'features.default_mode_request_user_input': true;
55
+ };
56
+ export declare class CodexAppServerRunner extends ConnectionBasedRunner<JsonRpcClient<InitializeResult>, TranslatorEvent> {
38
57
  private connectionManager;
39
- private currentClient;
40
58
  private currentTranslator;
41
- private currentThreadId;
42
- private currentTurnId;
43
- private lastEventAt;
44
- private _isRunning;
59
+ private activeThreadId;
45
60
  private model?;
46
61
  private modelProvider?;
47
62
  private reasoningEffort?;
48
63
  private sandboxConfig?;
49
64
  private approvalPolicyConfig?;
50
- private readonly turnTimeoutMs;
51
65
  /** Pending approval requests: requestId (JSON-RPC id) → kind + view. */
52
66
  private pendingApprovals;
53
- /** Notification queue consumed by the active run generator. */
54
- private notificationQueue;
55
- private waitResolve;
56
- private forceFinish;
57
- /** stop() 在 turn/start 响应前到达时置位,turn/start 完成后补发 interrupt。 */
58
- private stopRequested;
59
67
  constructor(opts: CodexAppServerRunnerOptions);
60
- get isRunning(): boolean;
61
- /**
62
- * Run a message in the current thread.
63
- *
64
- * 进程容错:若 app-server 子进程被外部误杀或自身异常退出(连接丢失),
65
- * 自动重拉进程并重试一次 setup(thread/start 或按 sessionId thread/resume
66
- * 继续处理),保证消费用户消息时进程挂了也能恢复。
67
- */
68
- run(message: string, opts: SpawnOptions): AsyncGenerator<AgentEvent>;
69
- /**
70
- * Acquire the connection and set up the turn: thread/start(新会话)或
71
- * thread/resume(按 sessionId 恢复既有线程)→ turn/start。
72
- */
73
- private setupTurn;
68
+ protected get logTag(): string;
69
+ protected get turnTimeoutErrorMessage(): string;
70
+ protected get turnInterruptedErrorMessage(): string;
71
+ protected currentSessionId(): string | null;
72
+ protected shouldDeferStop(): boolean;
73
+ protected cancelCurrentTurn(): Promise<void>;
74
+ protected clearTurnState(): void;
75
+ protected releaseConnection(cwd: string): Promise<void>;
76
+ protected notifyIdle(cwd: string): void;
77
+ protected disposeConnections(): Promise<void>;
74
78
  /**
75
79
  * Run a compact operation on the current thread.
76
80
  */
77
81
  runCompact(_message: string, opts: SpawnOptions): AsyncGenerator<AgentEvent>;
78
- /**
79
- * Stop the current turn by interrupting it.
80
- */
81
- stop(_opts?: {
82
- immediate?: boolean;
83
- }): Promise<void>;
84
82
  /**
85
83
  * Respond to an approval server request. `response` is the bridge
86
84
  * ApprovalAction (`{ action: 'accept' | 'accept_for_session' | 'decline' | 'cancel' }`).
87
85
  */
88
86
  respondApproval(requestId: number | string, response: unknown): Promise<void>;
87
+ getStatusInfo(): AgentStatusInfo;
89
88
  /**
90
- * Dispose the runner: release the connection.
89
+ * Unified approval-mode hot-update entry (called by the bridge via duck
90
+ * typing on active runs). Codex's `thread/settings/update` applies the new
91
+ * approval/sandbox policy to subsequent turns, even while the current turn
92
+ * is still active. This lets `/config` take effect without waiting for this
93
+ * workspace-lifetime runner to be recreated/evicted. Local fields are always
94
+ * updated so `/status` reflects the new config immediately; if there is no
95
+ * live thread, the next `thread/start`/`thread/resume` uses the new values
96
+ * anyway.
91
97
  */
92
- dispose(): Promise<void>;
93
- getUsageAuthority(): 'live';
94
- killOrphan(): void;
95
- registerExitHandlers(): void;
96
- unregisterExitHandlers(): void;
97
- getStatusInfo(): AgentStatusInfo;
98
+ updateApprovalMode(settings: {
99
+ approvalPolicy?: AskForApproval;
100
+ sandbox?: SandboxMode;
101
+ }): Promise<void>;
98
102
  private buildThreadParams;
99
103
  private buildTurnParams;
100
104
  /**
101
- * Consume the notification queue until a result event arrives or the turn
102
- * times out / is interrupted.
103
- */
104
- private consumeTurn;
105
- /**
106
- * Compute the current idle deadline. 0 disables the idle timeout; otherwise
107
- * the deadline is based on the last received event, not the turn start time.
105
+ * Acquire the connection and set up the turn: thread/start(新会话)或
106
+ * thread/resume(按 sessionId 恢复既有线程)→ turn/start。
108
107
  */
109
- private nextTurnIdleDeadline;
110
- private interruptCurrentTurn;
111
- private waitForEvents;
108
+ protected setupTurn(message: string, opts: SpawnOptions): Promise<void>;
112
109
  private handleNotification;
113
110
  private handleServerRequest;
114
- private pushEvents;
115
- private wakeWaiters;
116
- private failTurn;
117
- private resetRunState;
118
111
  private buildGrantedPermissions;
119
112
  /** 拒绝权限审批:空 fileSystem + 关闭网络(真实 GrantedPermissionProfile)。 */
120
113
  private denyAllPermissions;