kaizenai 0.1.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 (74) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +246 -0
  3. package/bin/kaizen +15 -0
  4. package/dist/client/apple-touch-icon.png +0 -0
  5. package/dist/client/assets/index-D-ORCGrq.js +603 -0
  6. package/dist/client/assets/index-r28mcHqz.css +32 -0
  7. package/dist/client/favicon.png +0 -0
  8. package/dist/client/fonts/body-medium.woff2 +0 -0
  9. package/dist/client/fonts/body-regular-italic.woff2 +0 -0
  10. package/dist/client/fonts/body-regular.woff2 +0 -0
  11. package/dist/client/fonts/body-semibold.woff2 +0 -0
  12. package/dist/client/index.html +22 -0
  13. package/dist/client/manifest-dark.webmanifest +24 -0
  14. package/dist/client/manifest.webmanifest +24 -0
  15. package/dist/client/pwa-192.png +0 -0
  16. package/dist/client/pwa-512.png +0 -0
  17. package/dist/client/pwa-icon.svg +15 -0
  18. package/dist/client/pwa-splash.png +0 -0
  19. package/dist/client/pwa-splash.svg +15 -0
  20. package/package.json +103 -0
  21. package/src/server/acp-shared.ts +315 -0
  22. package/src/server/agent.ts +1120 -0
  23. package/src/server/attachments.ts +133 -0
  24. package/src/server/backgrounds.ts +74 -0
  25. package/src/server/cli-runtime.ts +333 -0
  26. package/src/server/cli-supervisor.ts +81 -0
  27. package/src/server/cli.ts +68 -0
  28. package/src/server/codex-app-server-protocol.ts +453 -0
  29. package/src/server/codex-app-server.ts +1350 -0
  30. package/src/server/cursor-acp.ts +819 -0
  31. package/src/server/discovery.ts +322 -0
  32. package/src/server/event-store.ts +1369 -0
  33. package/src/server/events.ts +244 -0
  34. package/src/server/external-open.ts +272 -0
  35. package/src/server/gemini-acp.ts +844 -0
  36. package/src/server/gemini-cli.ts +525 -0
  37. package/src/server/generate-title.ts +36 -0
  38. package/src/server/git-manager.ts +79 -0
  39. package/src/server/git-repository.ts +101 -0
  40. package/src/server/harness-types.ts +20 -0
  41. package/src/server/keybindings.ts +177 -0
  42. package/src/server/machine-name.ts +22 -0
  43. package/src/server/paths.ts +112 -0
  44. package/src/server/process-utils.ts +22 -0
  45. package/src/server/project-icon.ts +344 -0
  46. package/src/server/project-metadata.ts +10 -0
  47. package/src/server/provider-catalog.ts +85 -0
  48. package/src/server/provider-settings.ts +155 -0
  49. package/src/server/quick-response.ts +153 -0
  50. package/src/server/read-models.ts +275 -0
  51. package/src/server/recovery.ts +507 -0
  52. package/src/server/restart.ts +30 -0
  53. package/src/server/server.ts +244 -0
  54. package/src/server/terminal-manager.ts +350 -0
  55. package/src/server/theme-settings.ts +179 -0
  56. package/src/server/update-manager.ts +230 -0
  57. package/src/server/usage/base-provider-usage.ts +57 -0
  58. package/src/server/usage/claude-usage.ts +558 -0
  59. package/src/server/usage/codex-usage.ts +144 -0
  60. package/src/server/usage/cursor-browser.ts +120 -0
  61. package/src/server/usage/cursor-cookies.ts +390 -0
  62. package/src/server/usage/cursor-usage.ts +490 -0
  63. package/src/server/usage/gemini-usage.ts +24 -0
  64. package/src/server/usage/provider-usage.ts +61 -0
  65. package/src/server/usage/test-helpers.ts +9 -0
  66. package/src/server/usage/types.ts +54 -0
  67. package/src/server/usage/utils.ts +325 -0
  68. package/src/server/ws-router.ts +717 -0
  69. package/src/shared/branding.ts +83 -0
  70. package/src/shared/dev-ports.ts +43 -0
  71. package/src/shared/ports.ts +2 -0
  72. package/src/shared/protocol.ts +152 -0
  73. package/src/shared/tools.ts +251 -0
  74. package/src/shared/types.ts +1028 -0
@@ -0,0 +1,453 @@
1
+ // Minimal typed subset vendored from `codex app-server generate-ts`.
2
+ // Keep names and field shapes aligned with the official app-server protocol.
3
+
4
+ import type { CodexReasoningEffort, ServiceTier } from "../shared/types"
5
+
6
+ export type CodexRequestId = string | number
7
+
8
+ export interface JsonRpcResponse<TResult = unknown> {
9
+ id: CodexRequestId
10
+ result?: TResult
11
+ error?: {
12
+ code?: number
13
+ message?: string
14
+ }
15
+ }
16
+
17
+ export interface InitializeParams {
18
+ clientInfo: {
19
+ name: string
20
+ title: string
21
+ version: string
22
+ }
23
+ capabilities: {
24
+ experimentalApi: boolean
25
+ }
26
+ }
27
+
28
+ export interface ThreadStartParams {
29
+ model?: string | null
30
+ cwd?: string | null
31
+ serviceTier?: ServiceTier | null
32
+ approvalPolicy?: "never" | "on-request" | "on-failure" | "untrusted" | null
33
+ sandbox?: "read-only" | "workspace-write" | "danger-full-access" | null
34
+ experimentalRawEvents: boolean
35
+ persistExtendedHistory: boolean
36
+ }
37
+
38
+ export interface ThreadResumeParams {
39
+ threadId: string
40
+ model?: string | null
41
+ cwd?: string | null
42
+ serviceTier?: ServiceTier | null
43
+ approvalPolicy?: "never" | "on-request" | "on-failure" | "untrusted" | null
44
+ sandbox?: "read-only" | "workspace-write" | "danger-full-access" | null
45
+ persistExtendedHistory: boolean
46
+ }
47
+
48
+ export interface TextUserInput {
49
+ type: "text"
50
+ text: string
51
+ text_elements: []
52
+ }
53
+
54
+ export interface ImageUserInput {
55
+ type: "image"
56
+ url: string
57
+ }
58
+
59
+ export interface LocalImageUserInput {
60
+ type: "localImage"
61
+ path: string
62
+ }
63
+
64
+ export type CodexUserInput = TextUserInput | ImageUserInput | LocalImageUserInput
65
+
66
+ export interface CollaborationMode {
67
+ mode: "default" | "plan"
68
+ settings: {
69
+ model: string | null
70
+ reasoning_effort: ReasoningEffort | null
71
+ developer_instructions: string | null
72
+ }
73
+ }
74
+
75
+ export type ReasoningEffort = CodexReasoningEffort
76
+
77
+ export interface TurnStartParams {
78
+ threadId: string
79
+ input: CodexUserInput[]
80
+ approvalPolicy?: "never" | "on-request" | "on-failure" | "untrusted" | null
81
+ model?: string | null
82
+ effort?: ReasoningEffort | null
83
+ serviceTier?: ServiceTier | null
84
+ collaborationMode?: CollaborationMode | null
85
+ }
86
+
87
+ export interface TurnInterruptParams {
88
+ threadId: string
89
+ turnId: string
90
+ }
91
+
92
+ export interface ThreadSummary {
93
+ id: string
94
+ }
95
+
96
+ export interface ThreadStartResponse {
97
+ thread: ThreadSummary
98
+ model: string
99
+ reasoningEffort: ReasoningEffort | null
100
+ }
101
+
102
+ export type ThreadResumeResponse = ThreadStartResponse
103
+
104
+ export interface TurnSummary {
105
+ id: string
106
+ status: "inProgress" | "completed" | "failed" | "interrupted"
107
+ error: {
108
+ message?: string
109
+ } | null
110
+ }
111
+
112
+ export interface TurnStartResponse {
113
+ turn: TurnSummary
114
+ }
115
+
116
+ export interface ThreadStartedNotification {
117
+ thread: ThreadSummary
118
+ }
119
+
120
+ export interface TurnStartedNotification {
121
+ threadId: string
122
+ turn: TurnSummary
123
+ }
124
+
125
+ export interface TurnCompletedNotification {
126
+ threadId: string
127
+ turn: TurnSummary
128
+ }
129
+
130
+ export interface TurnPlanStep {
131
+ step: string
132
+ status: "pending" | "inProgress" | "completed"
133
+ }
134
+
135
+ export interface TurnPlanUpdatedNotification {
136
+ threadId: string
137
+ turnId: string
138
+ explanation: string | null
139
+ plan: TurnPlanStep[]
140
+ }
141
+
142
+ export interface PlanDeltaNotification {
143
+ threadId: string
144
+ turnId: string
145
+ itemId: string
146
+ delta: string
147
+ }
148
+
149
+ export interface ContextCompactedNotification {
150
+ threadId: string
151
+ turnId: string
152
+ }
153
+
154
+ export interface ToolRequestUserInputOption {
155
+ label: string
156
+ description?: string | null
157
+ }
158
+
159
+ export interface ToolRequestUserInputQuestion {
160
+ id: string
161
+ header: string
162
+ question: string
163
+ isOther: boolean
164
+ isSecret: boolean
165
+ options: ToolRequestUserInputOption[] | null
166
+ }
167
+
168
+ export interface ToolRequestUserInputParams {
169
+ threadId: string
170
+ turnId: string
171
+ itemId: string
172
+ questions: ToolRequestUserInputQuestion[]
173
+ }
174
+
175
+ export interface ToolRequestUserInputResponse {
176
+ answers: Record<string, { answers: string[] }>
177
+ }
178
+
179
+ export interface CommandExecutionRequestApprovalParams {
180
+ threadId: string
181
+ turnId: string
182
+ itemId: string
183
+ approvalId?: string | null
184
+ reason?: string | null
185
+ command?: string | null
186
+ cwd?: string | null
187
+ }
188
+
189
+ export interface FileChangeRequestApprovalParams {
190
+ threadId: string
191
+ turnId: string
192
+ itemId: string
193
+ reason?: string | null
194
+ grantRoot?: string | null
195
+ }
196
+
197
+ export type CommandExecutionApprovalDecision =
198
+ | "accept"
199
+ | "acceptForSession"
200
+ | "decline"
201
+ | "cancel"
202
+
203
+ export type FileChangeApprovalDecision =
204
+ | "accept"
205
+ | "acceptForSession"
206
+ | "decline"
207
+ | "cancel"
208
+
209
+ export interface CommandExecutionRequestApprovalResponse {
210
+ decision: CommandExecutionApprovalDecision
211
+ }
212
+
213
+ export interface FileChangeRequestApprovalResponse {
214
+ decision: FileChangeApprovalDecision
215
+ }
216
+
217
+ export interface ToolRequestUserInputRequest {
218
+ id: CodexRequestId
219
+ method: "item/tool/requestUserInput"
220
+ params: ToolRequestUserInputParams
221
+ }
222
+
223
+ export interface DynamicToolCallParams {
224
+ threadId: string
225
+ turnId: string
226
+ callId: string
227
+ tool: string
228
+ arguments: Record<string, unknown> | unknown[] | string | number | boolean | null
229
+ }
230
+
231
+ export interface DynamicToolCallOutputContentItem {
232
+ type: "inputText" | "inputImage"
233
+ text?: string
234
+ imageUrl?: string
235
+ }
236
+
237
+ export interface DynamicToolCallResponse {
238
+ contentItems: DynamicToolCallOutputContentItem[]
239
+ success: boolean
240
+ }
241
+
242
+ export interface DynamicToolCallRequest {
243
+ id: CodexRequestId
244
+ method: "item/tool/call"
245
+ params: DynamicToolCallParams
246
+ }
247
+
248
+ export interface CommandExecutionRequestApprovalRequest {
249
+ id: CodexRequestId
250
+ method: "item/commandExecution/requestApproval"
251
+ params: CommandExecutionRequestApprovalParams
252
+ }
253
+
254
+ export interface FileChangeRequestApprovalRequest {
255
+ id: CodexRequestId
256
+ method: "item/fileChange/requestApproval"
257
+ params: FileChangeRequestApprovalParams
258
+ }
259
+
260
+ export type ServerRequest =
261
+ | ToolRequestUserInputRequest
262
+ | DynamicToolCallRequest
263
+ | CommandExecutionRequestApprovalRequest
264
+ | FileChangeRequestApprovalRequest
265
+
266
+ export interface UserMessageItem {
267
+ type: "userMessage"
268
+ id: string
269
+ content: CodexUserInput[]
270
+ }
271
+
272
+ export interface ReasoningItem {
273
+ type: "reasoning"
274
+ id: string
275
+ summary: unknown[]
276
+ content: unknown[]
277
+ }
278
+
279
+ export interface AgentMessageItem {
280
+ type: "agentMessage"
281
+ id: string
282
+ text: string
283
+ phase?: string
284
+ }
285
+
286
+ export interface PlanItem {
287
+ type: "plan"
288
+ id: string
289
+ text: string
290
+ }
291
+
292
+ export interface CommandExecutionItem {
293
+ type: "commandExecution"
294
+ id: string
295
+ command: string
296
+ cwd?: string
297
+ processId?: string
298
+ status: "inProgress" | "completed" | "failed" | "declined"
299
+ aggregatedOutput?: string | null
300
+ exitCode?: number | null
301
+ durationMs?: number | null
302
+ }
303
+
304
+ export interface McpToolCallItem {
305
+ type: "mcpToolCall"
306
+ id: string
307
+ server: string
308
+ tool: string
309
+ arguments?: Record<string, unknown> | null
310
+ result?: {
311
+ content?: unknown[]
312
+ structuredContent?: unknown
313
+ } | null
314
+ error?: {
315
+ message?: string
316
+ } | null
317
+ status: "inProgress" | "completed" | "failed"
318
+ }
319
+
320
+ export interface DynamicToolCallItem {
321
+ type: "dynamicToolCall"
322
+ id: string
323
+ tool: string
324
+ arguments?: Record<string, unknown> | unknown[] | string | number | boolean | null
325
+ status: "inProgress" | "completed" | "failed"
326
+ contentItems?: DynamicToolCallOutputContentItem[] | null
327
+ success?: boolean | null
328
+ durationMs?: number | null
329
+ }
330
+
331
+ export interface CollabAgentToolCallItem {
332
+ type: "collabAgentToolCall"
333
+ id: string
334
+ tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent"
335
+ status: "inProgress" | "completed" | "failed"
336
+ senderThreadId: string
337
+ receiverThreadIds: string[]
338
+ prompt?: string | null
339
+ agentsStates?: Record<string, { status: string; message: string | null }> | null
340
+ }
341
+
342
+ export interface WebSearchItem {
343
+ type: "webSearch"
344
+ id: string
345
+ query: string
346
+ action?: {
347
+ type?: string
348
+ query?: string
349
+ queries?: string[]
350
+ } | null
351
+ }
352
+
353
+ export interface FileChangeItem {
354
+ type: "fileChange"
355
+ id: string
356
+ changes: Array<{
357
+ path: string
358
+ kind:
359
+ | "add"
360
+ | "delete"
361
+ | "update"
362
+ | {
363
+ type: "add" | "delete" | "update"
364
+ move_path?: string | null
365
+ }
366
+ diff?: string | null
367
+ }>
368
+ status: "inProgress" | "completed" | "failed" | "declined"
369
+ }
370
+
371
+ export interface ErrorItem {
372
+ type: "error"
373
+ id: string
374
+ message: string
375
+ }
376
+
377
+ export type ThreadItem =
378
+ | UserMessageItem
379
+ | ReasoningItem
380
+ | AgentMessageItem
381
+ | PlanItem
382
+ | CommandExecutionItem
383
+ | McpToolCallItem
384
+ | DynamicToolCallItem
385
+ | CollabAgentToolCallItem
386
+ | WebSearchItem
387
+ | FileChangeItem
388
+ | ErrorItem
389
+
390
+ export interface ItemStartedNotification {
391
+ item: ThreadItem
392
+ threadId: string
393
+ turnId: string
394
+ }
395
+
396
+ export interface ItemCompletedNotification {
397
+ item: ThreadItem
398
+ threadId: string
399
+ turnId: string
400
+ }
401
+
402
+ export interface ErrorNotification {
403
+ error: {
404
+ message: string
405
+ codexErrorInfo?: string
406
+ additionalDetails?: unknown
407
+ }
408
+ willRetry: boolean
409
+ threadId?: string
410
+ turnId?: string
411
+ }
412
+
413
+ export type ServerNotification =
414
+ | { method: "thread/started"; params: ThreadStartedNotification }
415
+ | { method: "turn/started"; params: TurnStartedNotification }
416
+ | { method: "turn/completed"; params: TurnCompletedNotification }
417
+ | { method: "turn/plan/updated"; params: TurnPlanUpdatedNotification }
418
+ | { method: "item/started"; params: ItemStartedNotification }
419
+ | { method: "item/completed"; params: ItemCompletedNotification }
420
+ | { method: "item/plan/delta"; params: PlanDeltaNotification }
421
+ | { method: "thread/compacted"; params: ContextCompactedNotification }
422
+ | { method: "error"; params: ErrorNotification }
423
+
424
+ export function isJsonRpcResponse(value: unknown): value is JsonRpcResponse {
425
+ return Boolean(value) && typeof value === "object" && "id" in (value as Record<string, unknown>)
426
+ && ("result" in (value as Record<string, unknown>) || "error" in (value as Record<string, unknown>))
427
+ && !("method" in (value as Record<string, unknown>))
428
+ }
429
+
430
+ export function isServerRequest(value: unknown): value is ServerRequest {
431
+ if (!value || typeof value !== "object") return false
432
+ const candidate = value as Record<string, unknown>
433
+ if (typeof candidate.method !== "string" || !("id" in candidate)) return false
434
+ return candidate.method === "item/tool/requestUserInput"
435
+ || candidate.method === "item/tool/call"
436
+ || candidate.method === "item/commandExecution/requestApproval"
437
+ || candidate.method === "item/fileChange/requestApproval"
438
+ }
439
+
440
+ export function isServerNotification(value: unknown): value is ServerNotification {
441
+ if (!value || typeof value !== "object") return false
442
+ const candidate = value as Record<string, unknown>
443
+ if (typeof candidate.method !== "string" || "id" in candidate) return false
444
+ return candidate.method === "thread/started"
445
+ || candidate.method === "turn/started"
446
+ || candidate.method === "turn/completed"
447
+ || candidate.method === "turn/plan/updated"
448
+ || candidate.method === "item/started"
449
+ || candidate.method === "item/completed"
450
+ || candidate.method === "item/plan/delta"
451
+ || candidate.method === "thread/compacted"
452
+ || candidate.method === "error"
453
+ }