@wix/pathgrade 0.29.0

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 (238) hide show
  1. package/bin/pathgrade.js +2 -0
  2. package/dist/affected/anchor.d.ts +18 -0
  3. package/dist/affected/anchor.js +42 -0
  4. package/dist/affected/config.d.ts +25 -0
  5. package/dist/affected/config.js +98 -0
  6. package/dist/affected/format.d.ts +45 -0
  7. package/dist/affected/format.js +87 -0
  8. package/dist/affected/git.d.ts +33 -0
  9. package/dist/affected/git.js +68 -0
  10. package/dist/affected/glob.d.ts +17 -0
  11. package/dist/affected/glob.js +25 -0
  12. package/dist/affected/meta.d.ts +26 -0
  13. package/dist/affected/meta.js +158 -0
  14. package/dist/affected/select.d.ts +30 -0
  15. package/dist/affected/select.js +101 -0
  16. package/dist/affected/sidecar.d.ts +32 -0
  17. package/dist/affected/sidecar.js +86 -0
  18. package/dist/affected/types.d.ts +43 -0
  19. package/dist/affected/types.js +7 -0
  20. package/dist/agents/claude/ask-user-answer-store.d.ts +28 -0
  21. package/dist/agents/claude/ask-user-answer-store.js +29 -0
  22. package/dist/agents/claude/ask-user-bridge.d.ts +56 -0
  23. package/dist/agents/claude/ask-user-bridge.js +162 -0
  24. package/dist/agents/claude/sdk-message-projector.d.ts +43 -0
  25. package/dist/agents/claude/sdk-message-projector.js +208 -0
  26. package/dist/agents/claude/sdk-options.d.ts +52 -0
  27. package/dist/agents/claude/sdk-options.js +79 -0
  28. package/dist/agents/claude.d.ts +56 -0
  29. package/dist/agents/claude.js +143 -0
  30. package/dist/agents/codex-app-server/agent.d.ts +35 -0
  31. package/dist/agents/codex-app-server/agent.js +388 -0
  32. package/dist/agents/codex-app-server/fixtures/app-server-client.d.ts +19 -0
  33. package/dist/agents/codex-app-server/fixtures/app-server-client.js +104 -0
  34. package/dist/agents/codex-app-server/fixtures/run-gate.d.ts +25 -0
  35. package/dist/agents/codex-app-server/fixtures/run-gate.js +48 -0
  36. package/dist/agents/codex-app-server/protocol/ClientRequest.d.ts +27 -0
  37. package/dist/agents/codex-app-server/protocol/ClientRequest.js +7 -0
  38. package/dist/agents/codex-app-server/protocol/DynamicToolCallParams.d.ts +9 -0
  39. package/dist/agents/codex-app-server/protocol/DynamicToolCallParams.js +4 -0
  40. package/dist/agents/codex-app-server/protocol/GrantedPermissionProfile.d.ts +6 -0
  41. package/dist/agents/codex-app-server/protocol/GrantedPermissionProfile.js +7 -0
  42. package/dist/agents/codex-app-server/protocol/McpElicitationRequestParams.d.ts +23 -0
  43. package/dist/agents/codex-app-server/protocol/McpElicitationRequestParams.js +8 -0
  44. package/dist/agents/codex-app-server/protocol/Op.d.ts +11 -0
  45. package/dist/agents/codex-app-server/protocol/Op.js +5 -0
  46. package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalParams.d.ts +10 -0
  47. package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalParams.js +6 -0
  48. package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalResponse.d.ts +15 -0
  49. package/dist/agents/codex-app-server/protocol/PermissionsRequestApprovalResponse.js +4 -0
  50. package/dist/agents/codex-app-server/protocol/SandboxMode.d.ts +1 -0
  51. package/dist/agents/codex-app-server/protocol/SandboxMode.js +4 -0
  52. package/dist/agents/codex-app-server/protocol/ServerRequest.d.ts +42 -0
  53. package/dist/agents/codex-app-server/protocol/ServerRequest.js +7 -0
  54. package/dist/agents/codex-app-server/protocol/ThreadStartParams.d.ts +45 -0
  55. package/dist/agents/codex-app-server/protocol/ThreadStartParams.js +10 -0
  56. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputAnswer.d.ts +6 -0
  57. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputAnswer.js +4 -0
  58. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputOption.d.ts +7 -0
  59. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputOption.js +4 -0
  60. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputParams.d.ts +10 -0
  61. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputParams.js +4 -0
  62. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputQuestion.d.ts +12 -0
  63. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputQuestion.js +4 -0
  64. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputResponse.d.ts +9 -0
  65. package/dist/agents/codex-app-server/protocol/ToolRequestUserInputResponse.js +4 -0
  66. package/dist/agents/codex-app-server/protocol/TurnCompletedNotification.d.ts +5 -0
  67. package/dist/agents/codex-app-server/protocol/TurnCompletedNotification.js +4 -0
  68. package/dist/agents/codex-app-server/protocol/index.d.ts +16 -0
  69. package/dist/agents/codex-app-server/protocol/index.js +11 -0
  70. package/dist/agents/codex-app-server/transport.d.ts +84 -0
  71. package/dist/agents/codex-app-server/transport.js +246 -0
  72. package/dist/agents/codex-app-server/wire-translators.d.ts +19 -0
  73. package/dist/agents/codex-app-server/wire-translators.js +52 -0
  74. package/dist/agents/codex.d.ts +7 -0
  75. package/dist/agents/codex.js +164 -0
  76. package/dist/agents/cursor.d.ts +39 -0
  77. package/dist/agents/cursor.js +233 -0
  78. package/dist/agents/registry.d.ts +17 -0
  79. package/dist/agents/registry.js +27 -0
  80. package/dist/agents/transcript-agent.d.ts +14 -0
  81. package/dist/agents/transcript-agent.js +59 -0
  82. package/dist/analytics/engine.d.ts +18 -0
  83. package/dist/analytics/engine.js +66 -0
  84. package/dist/commands/affected.d.ts +31 -0
  85. package/dist/commands/affected.js +150 -0
  86. package/dist/commands/analyze.d.ts +21 -0
  87. package/dist/commands/analyze.js +167 -0
  88. package/dist/commands/init.d.ts +3 -0
  89. package/dist/commands/init.js +242 -0
  90. package/dist/commands/preview-reactions.d.ts +10 -0
  91. package/dist/commands/preview-reactions.js +88 -0
  92. package/dist/commands/preview.d.ts +5 -0
  93. package/dist/commands/preview.js +17 -0
  94. package/dist/commands/report.d.ts +39 -0
  95. package/dist/commands/report.js +108 -0
  96. package/dist/commands/run-args.d.ts +22 -0
  97. package/dist/commands/run-args.js +69 -0
  98. package/dist/commands/run-changed.d.ts +26 -0
  99. package/dist/commands/run-changed.js +138 -0
  100. package/dist/commands/validate.d.ts +13 -0
  101. package/dist/commands/validate.js +233 -0
  102. package/dist/core/mcp-mock.d.ts +3 -0
  103. package/dist/core/mcp-mock.js +23 -0
  104. package/dist/core/mcp-mock.types.d.ts +15 -0
  105. package/dist/core/mcp-mock.types.js +1 -0
  106. package/dist/core/skills.d.ts +15 -0
  107. package/dist/core/skills.js +76 -0
  108. package/dist/evals/discovery.d.ts +7 -0
  109. package/dist/evals/discovery.js +69 -0
  110. package/dist/mcp-mock-server.d.ts +1 -0
  111. package/dist/mcp-mock-server.js +116 -0
  112. package/dist/pathgrade.d.ts +10 -0
  113. package/dist/pathgrade.js +243 -0
  114. package/dist/plugin/index.d.ts +9 -0
  115. package/dist/plugin/index.js +81 -0
  116. package/dist/plugin/lifecycle.d.ts +45 -0
  117. package/dist/plugin/lifecycle.js +146 -0
  118. package/dist/plugin/reporter.d.ts +36 -0
  119. package/dist/plugin/reporter.js +275 -0
  120. package/dist/plugin/setup.d.ts +1 -0
  121. package/dist/plugin/setup.js +3 -0
  122. package/dist/providers/copy-filter.d.ts +18 -0
  123. package/dist/providers/copy-filter.js +66 -0
  124. package/dist/providers/credentials.d.ts +36 -0
  125. package/dist/providers/credentials.js +202 -0
  126. package/dist/providers/mcp-config.d.ts +34 -0
  127. package/dist/providers/mcp-config.js +55 -0
  128. package/dist/providers/sandbox-exec.d.ts +8 -0
  129. package/dist/providers/sandbox-exec.js +82 -0
  130. package/dist/providers/sandbox.d.ts +22 -0
  131. package/dist/providers/sandbox.js +158 -0
  132. package/dist/providers/sandboxed-claude-spawn.d.ts +24 -0
  133. package/dist/providers/sandboxed-claude-spawn.js +57 -0
  134. package/dist/providers/workspace.d.ts +15 -0
  135. package/dist/providers/workspace.js +73 -0
  136. package/dist/reporters/browser.d.ts +2 -0
  137. package/dist/reporters/browser.js +85 -0
  138. package/dist/reporters/cli.d.ts +2 -0
  139. package/dist/reporters/cli.js +131 -0
  140. package/dist/reporters/diagnostics.d.ts +46 -0
  141. package/dist/reporters/diagnostics.js +147 -0
  142. package/dist/reporters/github-comment.d.ts +67 -0
  143. package/dist/reporters/github-comment.js +252 -0
  144. package/dist/reporters/loader.d.ts +8 -0
  145. package/dist/reporters/loader.js +36 -0
  146. package/dist/reporters/results-path.d.ts +2 -0
  147. package/dist/reporters/results-path.js +10 -0
  148. package/dist/reporters/verbose-emitter.d.ts +69 -0
  149. package/dist/reporters/verbose-emitter.js +103 -0
  150. package/dist/sdk/agent-crash.d.ts +19 -0
  151. package/dist/sdk/agent-crash.js +20 -0
  152. package/dist/sdk/agent-resolution.d.ts +12 -0
  153. package/dist/sdk/agent-resolution.js +21 -0
  154. package/dist/sdk/agent-result-log.d.ts +19 -0
  155. package/dist/sdk/agent-result-log.js +45 -0
  156. package/dist/sdk/agent.d.ts +4 -0
  157. package/dist/sdk/agent.js +354 -0
  158. package/dist/sdk/ask-bus/bus.d.ts +21 -0
  159. package/dist/sdk/ask-bus/bus.js +129 -0
  160. package/dist/sdk/ask-bus/handler.d.ts +31 -0
  161. package/dist/sdk/ask-bus/handler.js +244 -0
  162. package/dist/sdk/ask-bus/parsers.d.ts +9 -0
  163. package/dist/sdk/ask-bus/parsers.js +30 -0
  164. package/dist/sdk/ask-bus/projection.d.ts +26 -0
  165. package/dist/sdk/ask-bus/projection.js +45 -0
  166. package/dist/sdk/ask-bus/types.d.ts +69 -0
  167. package/dist/sdk/ask-bus/types.js +1 -0
  168. package/dist/sdk/chat.d.ts +29 -0
  169. package/dist/sdk/chat.js +93 -0
  170. package/dist/sdk/conversation-window.d.ts +14 -0
  171. package/dist/sdk/conversation-window.js +38 -0
  172. package/dist/sdk/converse.d.ts +42 -0
  173. package/dist/sdk/converse.js +329 -0
  174. package/dist/sdk/eval-runtime.d.ts +10 -0
  175. package/dist/sdk/eval-runtime.js +17 -0
  176. package/dist/sdk/evaluate.d.ts +13 -0
  177. package/dist/sdk/evaluate.js +325 -0
  178. package/dist/sdk/index.d.ts +31 -0
  179. package/dist/sdk/index.js +20 -0
  180. package/dist/sdk/judge-pipeline.d.ts +7 -0
  181. package/dist/sdk/judge-pipeline.js +178 -0
  182. package/dist/sdk/judge-prompt-builder.d.ts +7 -0
  183. package/dist/sdk/judge-prompt-builder.js +76 -0
  184. package/dist/sdk/judge-tool-runner.d.ts +19 -0
  185. package/dist/sdk/judge-tool-runner.js +51 -0
  186. package/dist/sdk/judge-tool-session.d.ts +47 -0
  187. package/dist/sdk/judge-tool-session.js +213 -0
  188. package/dist/sdk/judge-tools.d.ts +29 -0
  189. package/dist/sdk/judge-tools.js +283 -0
  190. package/dist/sdk/managed-session.d.ts +50 -0
  191. package/dist/sdk/managed-session.js +110 -0
  192. package/dist/sdk/persona.d.ts +5 -0
  193. package/dist/sdk/persona.js +33 -0
  194. package/dist/sdk/reaction-loader.d.ts +4 -0
  195. package/dist/sdk/reaction-loader.js +119 -0
  196. package/dist/sdk/reaction-preview.d.ts +6 -0
  197. package/dist/sdk/reaction-preview.js +94 -0
  198. package/dist/sdk/run-scorer.d.ts +10 -0
  199. package/dist/sdk/run-scorer.js +124 -0
  200. package/dist/sdk/runtime-policy.d.ts +21 -0
  201. package/dist/sdk/runtime-policy.js +89 -0
  202. package/dist/sdk/scorer-utils.d.ts +6 -0
  203. package/dist/sdk/scorer-utils.js +39 -0
  204. package/dist/sdk/scorers.d.ts +64 -0
  205. package/dist/sdk/scorers.js +80 -0
  206. package/dist/sdk/snapshots.d.ts +41 -0
  207. package/dist/sdk/snapshots.js +148 -0
  208. package/dist/sdk/types.d.ts +416 -0
  209. package/dist/sdk/types.js +17 -0
  210. package/dist/sdk/visible-turn.d.ts +4 -0
  211. package/dist/sdk/visible-turn.js +23 -0
  212. package/dist/tool-events.d.ts +45 -0
  213. package/dist/tool-events.js +167 -0
  214. package/dist/types.d.ts +372 -0
  215. package/dist/types.js +37 -0
  216. package/dist/utils/cli.d.ts +55 -0
  217. package/dist/utils/cli.js +131 -0
  218. package/dist/utils/env.d.ts +8 -0
  219. package/dist/utils/env.js +26 -0
  220. package/dist/utils/llm-mocks.d.ts +43 -0
  221. package/dist/utils/llm-mocks.js +108 -0
  222. package/dist/utils/llm-providers/anthropic.d.ts +2 -0
  223. package/dist/utils/llm-providers/anthropic.js +132 -0
  224. package/dist/utils/llm-providers/cli.d.ts +20 -0
  225. package/dist/utils/llm-providers/cli.js +162 -0
  226. package/dist/utils/llm-providers/openai.d.ts +2 -0
  227. package/dist/utils/llm-providers/openai.js +56 -0
  228. package/dist/utils/llm-types.d.ts +107 -0
  229. package/dist/utils/llm-types.js +1 -0
  230. package/dist/utils/llm.d.ts +36 -0
  231. package/dist/utils/llm.js +209 -0
  232. package/dist/utils/shutdown.d.ts +15 -0
  233. package/dist/utils/shutdown.js +41 -0
  234. package/dist/utils/timeout.d.ts +8 -0
  235. package/dist/utils/timeout.js +32 -0
  236. package/dist/viewer.html +1178 -0
  237. package/package.json +88 -0
  238. package/templates/eval.ts.template +28 -0
@@ -0,0 +1,8 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/McpServerElicitationRequestParams.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ //
5
+ // Filename localized to `McpElicitationRequestParams.ts` (spec §What to build).
6
+ // `JsonValue` and `McpElicitationSchema` are opaque aliases — v1 declines elicitations
7
+ // rather than interpreting them (decisions §7).
8
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { ToolRequestUserInputResponse } from './ToolRequestUserInputResponse.js';
2
+ /**
3
+ * The wire envelope for an UserInputAnswer op. `itemId` correlates with the
4
+ * originating `item/tool/requestUserInput` server request.
5
+ */
6
+ export interface OpUserInputAnswer {
7
+ type: 'Op::UserInputAnswer';
8
+ itemId: string;
9
+ answers: ToolRequestUserInputResponse['answers'];
10
+ }
11
+ export type Op = OpUserInputAnswer;
@@ -0,0 +1,5 @@
1
+ // Pathgrade-local composition; not a single upstream file.
2
+ // Upstream models the ops/event bus as discriminated payloads. The driver only
3
+ // writes the UserInputAnswer op (in response to an item/tool/requestUserInput
4
+ // server request); that shape is captured here.
5
+ export {};
@@ -0,0 +1,10 @@
1
+ export type AbsolutePathBuf = string;
2
+ export type RequestPermissionProfile = unknown;
3
+ export type PermissionsRequestApprovalParams = {
4
+ threadId: string;
5
+ turnId: string;
6
+ itemId: string;
7
+ cwd: AbsolutePathBuf;
8
+ reason: string | null;
9
+ permissions: RequestPermissionProfile;
10
+ };
@@ -0,0 +1,6 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/PermissionsRequestApprovalParams.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ //
5
+ // `AbsolutePathBuf` and `RequestPermissionProfile` are opaque to the driver today.
6
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { GrantedPermissionProfile } from './GrantedPermissionProfile.js';
2
+ /**
3
+ * Scope for a granted permission — `'turn'` auto-grants within the current
4
+ * turn only; `'thread'` persists until the thread ends. Upstream union is
5
+ * represented as a string literal set here.
6
+ */
7
+ export type PermissionGrantScope = 'turn' | 'thread';
8
+ export type PermissionsRequestApprovalResponse = {
9
+ permissions: GrantedPermissionProfile;
10
+ scope: PermissionGrantScope;
11
+ /**
12
+ * Review every subsequent command in this turn before normal sandboxed execution.
13
+ */
14
+ strictAutoReview?: boolean;
15
+ };
@@ -0,0 +1,4 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/PermissionsRequestApprovalResponse.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ export {};
@@ -0,0 +1 @@
1
+ export type SandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
@@ -0,0 +1,4 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/SandboxMode.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ export {};
@@ -0,0 +1,42 @@
1
+ import type { ToolRequestUserInputParams } from './ToolRequestUserInputParams.js';
2
+ import type { PermissionsRequestApprovalParams } from './PermissionsRequestApprovalParams.js';
3
+ import type { DynamicToolCallParams } from './DynamicToolCallParams.js';
4
+ import type { McpElicitationRequestParams } from './McpElicitationRequestParams.js';
5
+ export type ServerRequestMethod = 'item/tool/requestUserInput' | 'item/permissions/requestApproval' | 'item/tool/call' | 'mcpServer/elicitation/request' | 'item/commandExecution/requestApproval' | 'item/fileChange/requestApproval' | 'applyPatchApproval' | 'execCommandApproval' | 'account/chatgptAuthTokens/refresh';
6
+ export type ServerRequest = {
7
+ method: 'item/tool/requestUserInput';
8
+ id: number | string;
9
+ params: ToolRequestUserInputParams;
10
+ } | {
11
+ method: 'item/permissions/requestApproval';
12
+ id: number | string;
13
+ params: PermissionsRequestApprovalParams;
14
+ } | {
15
+ method: 'item/tool/call';
16
+ id: number | string;
17
+ params: DynamicToolCallParams;
18
+ } | {
19
+ method: 'mcpServer/elicitation/request';
20
+ id: number | string;
21
+ params: McpElicitationRequestParams;
22
+ } | {
23
+ method: 'item/commandExecution/requestApproval';
24
+ id: number | string;
25
+ params: unknown;
26
+ } | {
27
+ method: 'item/fileChange/requestApproval';
28
+ id: number | string;
29
+ params: unknown;
30
+ } | {
31
+ method: 'applyPatchApproval';
32
+ id: number | string;
33
+ params: unknown;
34
+ } | {
35
+ method: 'execCommandApproval';
36
+ id: number | string;
37
+ params: unknown;
38
+ } | {
39
+ method: 'account/chatgptAuthTokens/refresh';
40
+ id: number | string;
41
+ params: unknown;
42
+ };
@@ -0,0 +1,7 @@
1
+ // Pathgrade-local composition; not a single upstream file.
2
+ // Enumerates the 9 server-request variants the driver observes over the wire
3
+ // under rust-v0.124.0. Upstream ships the discriminated union at
4
+ // `codex-rs/app-server-protocol/schema/typescript/ServerRequest.ts`
5
+ // (top-level, NOT `typescript/v2/`); the per-variant params files this module
6
+ // imports live under the `v2/` subdirectory.
7
+ export {};
@@ -0,0 +1,45 @@
1
+ import type { SandboxMode } from './SandboxMode.js';
2
+ export type Personality = unknown;
3
+ export type ServiceTier = unknown;
4
+ export type JsonValue = unknown;
5
+ export type ApprovalsReviewer = unknown;
6
+ export type AskForApproval = unknown;
7
+ export type PermissionProfile = unknown;
8
+ export type ThreadStartSource = unknown;
9
+ export type ThreadStartParams = {
10
+ model?: string | null;
11
+ modelProvider?: string | null;
12
+ serviceTier?: ServiceTier | null | null;
13
+ cwd?: string | null;
14
+ approvalPolicy?: AskForApproval | null;
15
+ /**
16
+ * Override where approval requests are routed for review on this thread
17
+ * and subsequent turns.
18
+ */
19
+ approvalsReviewer?: ApprovalsReviewer | null;
20
+ sandbox?: SandboxMode | null;
21
+ /**
22
+ * Full permissions override for this thread. Cannot be combined with
23
+ * `sandbox`.
24
+ */
25
+ permissionProfile?: PermissionProfile | null;
26
+ config?: {
27
+ [key: string]: JsonValue | undefined;
28
+ } | null;
29
+ serviceName?: string | null;
30
+ baseInstructions?: string | null;
31
+ developerInstructions?: string | null;
32
+ personality?: Personality | null;
33
+ ephemeral?: boolean | null;
34
+ sessionStartSource?: ThreadStartSource | null;
35
+ /**
36
+ * If true, opt into emitting raw Responses API items on the event stream.
37
+ * This is for internal use only (e.g. Codex Cloud).
38
+ */
39
+ experimentalRawEvents: boolean;
40
+ /**
41
+ * If true, persist additional rollout EventMsg variants required to
42
+ * reconstruct a richer thread history on resume/fork/read.
43
+ */
44
+ persistExtendedHistory: boolean;
45
+ };
@@ -0,0 +1,10 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/ThreadStartParams.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ //
5
+ // NOTE: upstream imports additional shared types (Personality, ServiceTier, JsonValue,
6
+ // ApprovalsReviewer, AskForApproval, PermissionProfile, ThreadStartSource) that are not
7
+ // required by the pathgrade Codex driver. They are modelled here as opaque aliases so the
8
+ // vendored surface compiles standalone. Refresh policy: when a new upstream version lands,
9
+ // replace each alias with the vendored definition if the driver starts consuming it.
10
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * EXPERIMENTAL. Captures a user's answer to a request_user_input question.
3
+ */
4
+ export type ToolRequestUserInputAnswer = {
5
+ answers: Array<string>;
6
+ };
@@ -0,0 +1,4 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/ToolRequestUserInputAnswer.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * EXPERIMENTAL. Defines a single selectable option for request_user_input.
3
+ */
4
+ export type ToolRequestUserInputOption = {
5
+ label: string;
6
+ description: string;
7
+ };
@@ -0,0 +1,4 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/ToolRequestUserInputOption.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { ToolRequestUserInputQuestion } from './ToolRequestUserInputQuestion.js';
2
+ /**
3
+ * EXPERIMENTAL. Params sent with a request_user_input event.
4
+ */
5
+ export type ToolRequestUserInputParams = {
6
+ threadId: string;
7
+ turnId: string;
8
+ itemId: string;
9
+ questions: Array<ToolRequestUserInputQuestion>;
10
+ };
@@ -0,0 +1,4 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/ToolRequestUserInputParams.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { ToolRequestUserInputOption } from './ToolRequestUserInputOption.js';
2
+ /**
3
+ * EXPERIMENTAL. Represents one request_user_input question and its required options.
4
+ */
5
+ export type ToolRequestUserInputQuestion = {
6
+ id: string;
7
+ header: string;
8
+ question: string;
9
+ isOther: boolean;
10
+ isSecret: boolean;
11
+ options: Array<ToolRequestUserInputOption> | null;
12
+ };
@@ -0,0 +1,4 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/ToolRequestUserInputQuestion.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { ToolRequestUserInputAnswer } from './ToolRequestUserInputAnswer.js';
2
+ /**
3
+ * EXPERIMENTAL. Response payload mapping question ids to answers.
4
+ */
5
+ export type ToolRequestUserInputResponse = {
6
+ answers: {
7
+ [key: string]: ToolRequestUserInputAnswer | undefined;
8
+ };
9
+ };
@@ -0,0 +1,4 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/ToolRequestUserInputResponse.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ export {};
@@ -0,0 +1,5 @@
1
+ export type Turn = unknown;
2
+ export type TurnCompletedNotification = {
3
+ threadId: string;
4
+ turn: Turn;
5
+ };
@@ -0,0 +1,4 @@
1
+ // Vendored from openai/codex@rust-v0.124.0
2
+ // Source: codex-rs/app-server-protocol/schema/typescript/v2/TurnCompletedNotification.ts
3
+ // GENERATED CODE in upstream; do not modify locally either.
4
+ export {};
@@ -0,0 +1,16 @@
1
+ export type { ClientRequest, ClientRequestMethod } from './ClientRequest.js';
2
+ export type { ServerRequest, ServerRequestMethod } from './ServerRequest.js';
3
+ export type { Op, OpUserInputAnswer } from './Op.js';
4
+ export type { ToolRequestUserInputParams } from './ToolRequestUserInputParams.js';
5
+ export type { ToolRequestUserInputQuestion } from './ToolRequestUserInputQuestion.js';
6
+ export type { ToolRequestUserInputOption } from './ToolRequestUserInputOption.js';
7
+ export type { ToolRequestUserInputResponse } from './ToolRequestUserInputResponse.js';
8
+ export type { ToolRequestUserInputAnswer } from './ToolRequestUserInputAnswer.js';
9
+ export type { PermissionsRequestApprovalParams } from './PermissionsRequestApprovalParams.js';
10
+ export type { PermissionsRequestApprovalResponse, PermissionGrantScope, } from './PermissionsRequestApprovalResponse.js';
11
+ export type { GrantedPermissionProfile } from './GrantedPermissionProfile.js';
12
+ export type { DynamicToolCallParams } from './DynamicToolCallParams.js';
13
+ export type { McpElicitationRequestParams } from './McpElicitationRequestParams.js';
14
+ export type { ThreadStartParams } from './ThreadStartParams.js';
15
+ export type { SandboxMode } from './SandboxMode.js';
16
+ export type { TurnCompletedNotification } from './TurnCompletedNotification.js';
@@ -0,0 +1,11 @@
1
+ // Curated re-exports for the pathgrade Codex app-server driver and fixture
2
+ // tests. Every re-exported symbol is either vendored verbatim from
3
+ // openai/codex@rust-v0.124.0 (with an upstream-citation header in its file) or
4
+ // a pathgrade-local composition (ClientRequest, ServerRequest, Op) whose
5
+ // header spells out the composition rationale.
6
+ //
7
+ // Refresh policy: to bump the vendored version, update each file's header
8
+ // citation to the new tag, replace the `unknown` aliases with their vendored
9
+ // shapes as the driver starts consuming them, and re-run the protocol fixture
10
+ // suite (slice #10) to catch wire-format drift.
11
+ export {};
@@ -0,0 +1,84 @@
1
+ import type { Readable, Writable } from 'stream';
2
+ export type Unsubscribe = () => void;
3
+ export interface ServerRequestMessage {
4
+ readonly id: number | string;
5
+ readonly method: string;
6
+ readonly params: unknown;
7
+ }
8
+ export interface ServerNotificationMessage {
9
+ readonly method: string;
10
+ readonly params: unknown;
11
+ }
12
+ export interface TransportCloseInfo {
13
+ readonly exitCode: number | null;
14
+ readonly signal: NodeJS.Signals | null;
15
+ readonly pid?: number;
16
+ }
17
+ export interface AppServerTransport {
18
+ sendRequest<T = unknown>(method: string, params: unknown): Promise<T>;
19
+ sendNotification(method: string, params: unknown): void;
20
+ sendResponse(id: number | string, result: unknown): void;
21
+ sendErrorResponse(id: number | string, code: number, message: string): void;
22
+ onServerRequest(handler: (req: ServerRequestMessage) => void): Unsubscribe;
23
+ onNotification(handler: (n: ServerNotificationMessage) => void): Unsubscribe;
24
+ onClose(handler: (info: TransportCloseInfo) => void): Unsubscribe;
25
+ close(): Promise<void>;
26
+ readonly pid?: number;
27
+ }
28
+ export interface CreateNdjsonTransportInput {
29
+ /** Stream the driver writes JSON-RPC lines to (e.g. child.stdin). */
30
+ output: Writable;
31
+ /** Stream the driver reads JSON-RPC lines from (e.g. child.stdout). */
32
+ input: Readable;
33
+ /** Optional pid for diagnostics. */
34
+ pid?: number;
35
+ }
36
+ export declare function createNdjsonTransport(cfg: CreateNdjsonTransportInput): AppServerTransport;
37
+ export interface SpawnAppServerTransportInput {
38
+ binary?: string;
39
+ args?: readonly string[];
40
+ env?: NodeJS.ProcessEnv;
41
+ cwd?: string;
42
+ /**
43
+ * Grace period between SIGTERM and SIGKILL during handle close.
44
+ * Exposed for tests; defaults to 2s for production spawns.
45
+ */
46
+ killGracePeriodMs?: number;
47
+ }
48
+ export declare function buildAppServerSpawnArgs(args?: readonly string[], env?: NodeJS.ProcessEnv): string[];
49
+ /**
50
+ * Minimal child-process surface the session handle needs. Real spawns satisfy
51
+ * this via `ChildProcessWithoutNullStreams`; tests can substitute a fake that
52
+ * controls `kill` and `exit` timing without booting a subprocess.
53
+ */
54
+ export interface SessionChildHandle {
55
+ readonly pid?: number;
56
+ kill(signal?: NodeJS.Signals): boolean;
57
+ once(event: 'exit', listener: () => void): void;
58
+ readonly exitCode: number | null;
59
+ readonly signalCode: NodeJS.Signals | null;
60
+ }
61
+ /**
62
+ * Lifecycle-aware wrapper around the `codex app-server` subprocess and its
63
+ * NDJSON transport. Centralizes the close-then-kill sequence — SIGTERM, wait,
64
+ * escalate to SIGKILL if the child has not exited — so the rest of the driver
65
+ * does not have to coordinate the two resources.
66
+ */
67
+ export interface AppServerSessionHandle {
68
+ readonly transport: AppServerTransport;
69
+ readonly pid: number | undefined;
70
+ close(): Promise<void>;
71
+ }
72
+ interface CreateAppServerSessionHandleInput {
73
+ transport: AppServerTransport;
74
+ child: SessionChildHandle | null;
75
+ killGracePeriodMs?: number;
76
+ }
77
+ export declare function createAppServerSessionHandle(input: CreateAppServerSessionHandleInput): AppServerSessionHandle;
78
+ /**
79
+ * Spawn `codex ... app-server` and wrap its stdio in an NDJSON transport.
80
+ * --config overrides (if any) must appear in `args` before `app-server`,
81
+ * matching spike §1 which pins them to the parent `codex` binary.
82
+ */
83
+ export declare function spawnAppServerTransport(cfg?: SpawnAppServerTransportInput): AppServerSessionHandle;
84
+ export {};
@@ -0,0 +1,246 @@
1
+ import { spawn } from 'child_process';
2
+ import { createInterface } from 'readline';
3
+ export function createNdjsonTransport(cfg) {
4
+ return createNdjsonTransportInternal(cfg);
5
+ }
6
+ function createNdjsonTransportInternal(cfg) {
7
+ const { output, input, pid } = cfg;
8
+ let nextId = 1;
9
+ const pendingRequests = new Map();
10
+ const serverRequestHandlers = new Set();
11
+ const notificationHandlers = new Set();
12
+ const closeHandlers = new Set();
13
+ let closed = false;
14
+ const rl = createInterface({ input });
15
+ rl.on('line', (raw) => {
16
+ const line = raw.trim();
17
+ if (!line)
18
+ return;
19
+ let parsed;
20
+ try {
21
+ parsed = JSON.parse(line);
22
+ }
23
+ catch {
24
+ return;
25
+ }
26
+ // Response to a request we sent.
27
+ if (parsed.id !== undefined
28
+ && parsed.id !== null
29
+ && parsed.method === undefined
30
+ && (parsed.result !== undefined || parsed.error !== undefined)) {
31
+ const resolver = pendingRequests.get(parsed.id);
32
+ if (resolver) {
33
+ pendingRequests.delete(parsed.id);
34
+ resolver(parsed);
35
+ }
36
+ return;
37
+ }
38
+ // Server-initiated request.
39
+ if (parsed.method !== undefined && parsed.id !== undefined && parsed.id !== null) {
40
+ const msg = {
41
+ id: parsed.id,
42
+ method: parsed.method,
43
+ params: parsed.params,
44
+ };
45
+ for (const h of serverRequestHandlers) {
46
+ try {
47
+ h(msg);
48
+ }
49
+ catch (err) {
50
+ console.error('AppServerTransport serverRequest handler threw', err);
51
+ }
52
+ }
53
+ return;
54
+ }
55
+ // Notification.
56
+ if (parsed.method !== undefined) {
57
+ const msg = {
58
+ method: parsed.method,
59
+ params: parsed.params,
60
+ };
61
+ for (const h of notificationHandlers) {
62
+ try {
63
+ h(msg);
64
+ }
65
+ catch (err) {
66
+ console.error('AppServerTransport notification handler threw', err);
67
+ }
68
+ }
69
+ }
70
+ });
71
+ const writeLine = (obj) => {
72
+ if (closed)
73
+ return;
74
+ output.write(JSON.stringify(obj) + '\n');
75
+ };
76
+ return {
77
+ sendRequest(method, params) {
78
+ if (closed)
79
+ return Promise.reject(new Error('AppServerTransport closed'));
80
+ const id = nextId++;
81
+ return new Promise((resolve, reject) => {
82
+ pendingRequests.set(id, (env) => {
83
+ if (env.error) {
84
+ reject(new Error(`codex app-server '${method}' failed (${env.error.code}): ${env.error.message}`));
85
+ return;
86
+ }
87
+ resolve(env.result);
88
+ });
89
+ writeLine({ jsonrpc: '2.0', id, method, params });
90
+ });
91
+ },
92
+ sendNotification(method, params) {
93
+ writeLine({ jsonrpc: '2.0', method, params });
94
+ },
95
+ sendResponse(id, result) {
96
+ writeLine({ jsonrpc: '2.0', id, result });
97
+ },
98
+ sendErrorResponse(id, code, message) {
99
+ writeLine({ jsonrpc: '2.0', id, error: { code, message } });
100
+ },
101
+ onServerRequest(handler) {
102
+ serverRequestHandlers.add(handler);
103
+ return () => {
104
+ serverRequestHandlers.delete(handler);
105
+ };
106
+ },
107
+ onNotification(handler) {
108
+ notificationHandlers.add(handler);
109
+ return () => {
110
+ notificationHandlers.delete(handler);
111
+ };
112
+ },
113
+ onClose(handler) {
114
+ closeHandlers.add(handler);
115
+ return () => {
116
+ closeHandlers.delete(handler);
117
+ };
118
+ },
119
+ async close() {
120
+ if (closed)
121
+ return;
122
+ closed = true;
123
+ rl.close();
124
+ pendingRequests.clear();
125
+ },
126
+ notifyClose(info) {
127
+ for (const h of closeHandlers) {
128
+ try {
129
+ h(info);
130
+ }
131
+ catch (err) {
132
+ console.error('AppServerTransport close handler threw', err);
133
+ }
134
+ }
135
+ },
136
+ pid,
137
+ };
138
+ }
139
+ const CODEX_PROXY_PROVIDER_ID = 'pathgrade_openai_proxy';
140
+ function quoteCodexConfigString(value) {
141
+ return JSON.stringify(value);
142
+ }
143
+ export function buildAppServerSpawnArgs(args = [], env = process.env) {
144
+ const baseUrl = env.OPENAI_BASE_URL?.trim();
145
+ if (!baseUrl)
146
+ return [...args, 'app-server'];
147
+ return [
148
+ '-c', `model_provider=${quoteCodexConfigString(CODEX_PROXY_PROVIDER_ID)}`,
149
+ '-c', `model_providers.${CODEX_PROXY_PROVIDER_ID}.name=${quoteCodexConfigString('PathGrade OpenAI Proxy')}`,
150
+ '-c', `model_providers.${CODEX_PROXY_PROVIDER_ID}.base_url=${quoteCodexConfigString(baseUrl)}`,
151
+ '-c', `model_providers.${CODEX_PROXY_PROVIDER_ID}.env_key=${quoteCodexConfigString('OPENAI_API_KEY')}`,
152
+ '-c', `model_providers.${CODEX_PROXY_PROVIDER_ID}.wire_api=${quoteCodexConfigString('responses')}`,
153
+ '-c', `model_providers.${CODEX_PROXY_PROVIDER_ID}.supports_websockets=false`,
154
+ ...args,
155
+ 'app-server',
156
+ ];
157
+ }
158
+ export function createAppServerSessionHandle(input) {
159
+ const { transport, child } = input;
160
+ const killGrace = input.killGracePeriodMs ?? 2_000;
161
+ let closed = false;
162
+ return {
163
+ transport,
164
+ pid: child?.pid,
165
+ async close() {
166
+ if (closed)
167
+ return;
168
+ closed = true;
169
+ // Release the transport first so pending pipe writes are not lost.
170
+ await transport.close();
171
+ if (!child)
172
+ return;
173
+ if (child.exitCode !== null || child.signalCode !== null)
174
+ return;
175
+ const exited = new Promise((resolve) => {
176
+ child.once('exit', () => resolve());
177
+ });
178
+ try {
179
+ child.kill('SIGTERM');
180
+ }
181
+ catch {
182
+ // Already exited or missing permissions; ignore and let the
183
+ // exit listener settle if the kill actually landed.
184
+ }
185
+ const killTimer = setTimeout(() => {
186
+ if (child.exitCode !== null || child.signalCode !== null)
187
+ return;
188
+ try {
189
+ child.kill('SIGKILL');
190
+ }
191
+ catch {
192
+ // Best-effort escalation.
193
+ }
194
+ }, killGrace);
195
+ // Don't keep the Node event loop alive just for the kill timer.
196
+ if (typeof killTimer.unref === 'function')
197
+ killTimer.unref();
198
+ await exited;
199
+ clearTimeout(killTimer);
200
+ },
201
+ };
202
+ }
203
+ /**
204
+ * Spawn `codex ... app-server` and wrap its stdio in an NDJSON transport.
205
+ * --config overrides (if any) must appear in `args` before `app-server`,
206
+ * matching spike §1 which pins them to the parent `codex` binary.
207
+ */
208
+ export function spawnAppServerTransport(cfg = {}) {
209
+ const binary = cfg.binary ?? 'codex';
210
+ const args = cfg.args ?? [];
211
+ const env = cfg.env ?? process.env;
212
+ const child = spawn(binary, buildAppServerSpawnArgs(args, env), {
213
+ stdio: ['pipe', 'pipe', 'pipe'],
214
+ env,
215
+ cwd: cfg.cwd,
216
+ });
217
+ // Capture codex stderr so we can surface it on unexpected exits. Without
218
+ // this, a codex auth or connectivity failure just shows up as an empty
219
+ // turn with no explanation — especially painful in CI logs.
220
+ let stderrBuf = '';
221
+ const STDERR_CAP_BYTES = 8_192;
222
+ child.stderr.setEncoding('utf8');
223
+ child.stderr.on('data', (chunk) => {
224
+ if (stderrBuf.length >= STDERR_CAP_BYTES)
225
+ return;
226
+ stderrBuf += chunk;
227
+ if (stderrBuf.length > STDERR_CAP_BYTES)
228
+ stderrBuf = stderrBuf.slice(0, STDERR_CAP_BYTES);
229
+ });
230
+ const transport = createNdjsonTransportInternal({
231
+ output: child.stdin,
232
+ input: child.stdout,
233
+ pid: child.pid,
234
+ });
235
+ child.on('exit', (exitCode, signal) => {
236
+ if (stderrBuf.trim().length > 0) {
237
+ console.error(`[codex app-server pid=${child.pid}] exited with code=${exitCode} signal=${signal}. stderr:\n${stderrBuf}`);
238
+ }
239
+ transport.notifyClose({ exitCode, signal, pid: child.pid });
240
+ });
241
+ return createAppServerSessionHandle({
242
+ transport,
243
+ child,
244
+ ...(cfg.killGracePeriodMs !== undefined ? { killGracePeriodMs: cfg.killGracePeriodMs } : {}),
245
+ });
246
+ }