@shipfox/api-logs 9.3.0 → 10.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 (52) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +35 -0
  3. package/dist/core/append-logs.d.ts.map +1 -1
  4. package/dist/core/append-logs.js +100 -12
  5. package/dist/core/append-logs.js.map +1 -1
  6. package/dist/core/close-stream.d.ts +6 -5
  7. package/dist/core/close-stream.d.ts.map +1 -1
  8. package/dist/core/close-stream.js +25 -7
  9. package/dist/core/close-stream.js.map +1 -1
  10. package/dist/core/entities/attempt-stream.d.ts +5 -0
  11. package/dist/core/entities/attempt-stream.d.ts.map +1 -1
  12. package/dist/core/entities/attempt-stream.js +1 -1
  13. package/dist/core/entities/attempt-stream.js.map +1 -1
  14. package/dist/core/session/claude/rows.d.ts +4 -2
  15. package/dist/core/session/claude/rows.d.ts.map +1 -1
  16. package/dist/core/session/claude/rows.js +137 -10
  17. package/dist/core/session/claude/rows.js.map +1 -1
  18. package/dist/core/session/claude-parser.d.ts +8 -1
  19. package/dist/core/session/claude-parser.d.ts.map +1 -1
  20. package/dist/core/session/claude-parser.js +30 -4
  21. package/dist/core/session/claude-parser.js.map +1 -1
  22. package/dist/core/session/parse-session.d.ts +6 -1
  23. package/dist/core/session/parse-session.d.ts.map +1 -1
  24. package/dist/core/session/parse-session.js +2 -2
  25. package/dist/core/session/parse-session.js.map +1 -1
  26. package/dist/db/db.d.ts +94 -0
  27. package/dist/db/db.d.ts.map +1 -1
  28. package/dist/db/schema/attempt-streams.d.ts +94 -0
  29. package/dist/db/schema/attempt-streams.d.ts.map +1 -1
  30. package/dist/db/schema/attempt-streams.js +9 -1
  31. package/dist/db/schema/attempt-streams.js.map +1 -1
  32. package/dist/db/streams.d.ts +17 -6
  33. package/dist/db/streams.d.ts.map +1 -1
  34. package/dist/db/streams.js +21 -6
  35. package/dist/db/streams.js.map +1 -1
  36. package/dist/tsconfig.test.tsbuildinfo +1 -1
  37. package/drizzle/0001_strong_major_mapleleaf.sql +4 -0
  38. package/drizzle/meta/0001_snapshot.json +555 -0
  39. package/drizzle/meta/_journal.json +7 -0
  40. package/package.json +5 -5
  41. package/src/core/append-logs.test.ts +144 -4
  42. package/src/core/append-logs.ts +158 -6
  43. package/src/core/close-stream.ts +26 -7
  44. package/src/core/entities/attempt-stream.ts +6 -0
  45. package/src/core/finalize-attempt-stream.test.ts +57 -0
  46. package/src/core/session/claude/rows.ts +176 -7
  47. package/src/core/session/claude-parser.test.ts +279 -2
  48. package/src/core/session/claude-parser.ts +55 -4
  49. package/src/core/session/parse-session.ts +10 -1
  50. package/src/db/schema/attempt-streams.ts +10 -0
  51. package/src/db/streams.ts +43 -7
  52. package/tsconfig.build.tsbuildinfo +1 -1
@@ -0,0 +1,4 @@
1
+ ALTER TABLE "logs_attempt_streams" ADD COLUMN "claude_has_init" boolean DEFAULT false NOT NULL;--> statement-breakpoint
2
+ ALTER TABLE "logs_attempt_streams" ADD COLUMN "claude_session_id" text;--> statement-breakpoint
3
+ ALTER TABLE "logs_attempt_streams" ADD COLUMN "claude_turn" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
4
+ ALTER TABLE "logs_attempt_streams" ADD COLUMN "claude_pending_result" jsonb;
@@ -0,0 +1,555 @@
1
+ {
2
+ "id": "2d8b03a3-df94-4be5-a2cc-cd5b431bcd59",
3
+ "prevId": "7c2a5e18-c354-4792-a7b0-cc2cb07cc196",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.logs_attempt_streams": {
8
+ "name": "logs_attempt_streams",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "default": "uuidv7()"
17
+ },
18
+ "job_id": {
19
+ "name": "job_id",
20
+ "type": "uuid",
21
+ "primaryKey": false,
22
+ "notNull": true
23
+ },
24
+ "step_id": {
25
+ "name": "step_id",
26
+ "type": "uuid",
27
+ "primaryKey": false,
28
+ "notNull": true
29
+ },
30
+ "attempt": {
31
+ "name": "attempt",
32
+ "type": "integer",
33
+ "primaryKey": false,
34
+ "notNull": true
35
+ },
36
+ "workspace_id": {
37
+ "name": "workspace_id",
38
+ "type": "uuid",
39
+ "primaryKey": false,
40
+ "notNull": true
41
+ },
42
+ "project_id": {
43
+ "name": "project_id",
44
+ "type": "uuid",
45
+ "primaryKey": false,
46
+ "notNull": true
47
+ },
48
+ "workflow_run_attempt_id": {
49
+ "name": "workflow_run_attempt_id",
50
+ "type": "uuid",
51
+ "primaryKey": false,
52
+ "notNull": true
53
+ },
54
+ "committed_length": {
55
+ "name": "committed_length",
56
+ "type": "bigint",
57
+ "primaryKey": false,
58
+ "notNull": true,
59
+ "default": 0
60
+ },
61
+ "state": {
62
+ "name": "state",
63
+ "type": "text",
64
+ "primaryKey": false,
65
+ "notNull": true,
66
+ "default": "'open'"
67
+ },
68
+ "close_reason": {
69
+ "name": "close_reason",
70
+ "type": "text",
71
+ "primaryKey": false,
72
+ "notNull": false
73
+ },
74
+ "declared_total_bytes": {
75
+ "name": "declared_total_bytes",
76
+ "type": "bigint",
77
+ "primaryKey": false,
78
+ "notNull": false
79
+ },
80
+ "claude_has_init": {
81
+ "name": "claude_has_init",
82
+ "type": "boolean",
83
+ "primaryKey": false,
84
+ "notNull": true,
85
+ "default": false
86
+ },
87
+ "claude_session_id": {
88
+ "name": "claude_session_id",
89
+ "type": "text",
90
+ "primaryKey": false,
91
+ "notNull": false
92
+ },
93
+ "claude_turn": {
94
+ "name": "claude_turn",
95
+ "type": "integer",
96
+ "primaryKey": false,
97
+ "notNull": true,
98
+ "default": 0
99
+ },
100
+ "claude_pending_result": {
101
+ "name": "claude_pending_result",
102
+ "type": "jsonb",
103
+ "primaryKey": false,
104
+ "notNull": false
105
+ },
106
+ "truncated": {
107
+ "name": "truncated",
108
+ "type": "boolean",
109
+ "primaryKey": false,
110
+ "notNull": true,
111
+ "default": false
112
+ },
113
+ "object_key": {
114
+ "name": "object_key",
115
+ "type": "text",
116
+ "primaryKey": false,
117
+ "notNull": false
118
+ },
119
+ "created_at": {
120
+ "name": "created_at",
121
+ "type": "timestamp with time zone",
122
+ "primaryKey": false,
123
+ "notNull": true,
124
+ "default": "now()"
125
+ },
126
+ "updated_at": {
127
+ "name": "updated_at",
128
+ "type": "timestamp with time zone",
129
+ "primaryKey": false,
130
+ "notNull": true,
131
+ "default": "now()"
132
+ },
133
+ "closed_at": {
134
+ "name": "closed_at",
135
+ "type": "timestamp with time zone",
136
+ "primaryKey": false,
137
+ "notNull": false
138
+ }
139
+ },
140
+ "indexes": {
141
+ "logs_attempt_streams_identity_unique": {
142
+ "name": "logs_attempt_streams_identity_unique",
143
+ "columns": [
144
+ {
145
+ "expression": "job_id",
146
+ "isExpression": false,
147
+ "asc": true,
148
+ "nulls": "last"
149
+ },
150
+ {
151
+ "expression": "step_id",
152
+ "isExpression": false,
153
+ "asc": true,
154
+ "nulls": "last"
155
+ },
156
+ {
157
+ "expression": "attempt",
158
+ "isExpression": false,
159
+ "asc": true,
160
+ "nulls": "last"
161
+ }
162
+ ],
163
+ "isUnique": true,
164
+ "concurrently": false,
165
+ "method": "btree",
166
+ "with": {}
167
+ },
168
+ "logs_attempt_streams_step_attempt_idx": {
169
+ "name": "logs_attempt_streams_step_attempt_idx",
170
+ "columns": [
171
+ {
172
+ "expression": "step_id",
173
+ "isExpression": false,
174
+ "asc": true,
175
+ "nulls": "last"
176
+ },
177
+ {
178
+ "expression": "attempt",
179
+ "isExpression": false,
180
+ "asc": true,
181
+ "nulls": "last"
182
+ }
183
+ ],
184
+ "isUnique": false,
185
+ "concurrently": false,
186
+ "method": "btree",
187
+ "with": {}
188
+ },
189
+ "logs_attempt_streams_open_by_job_idx": {
190
+ "name": "logs_attempt_streams_open_by_job_idx",
191
+ "columns": [
192
+ {
193
+ "expression": "job_id",
194
+ "isExpression": false,
195
+ "asc": true,
196
+ "nulls": "last"
197
+ }
198
+ ],
199
+ "isUnique": false,
200
+ "where": "\"state\" = 'open'",
201
+ "concurrently": false,
202
+ "method": "btree",
203
+ "with": {}
204
+ },
205
+ "logs_attempt_streams_open_age_idx": {
206
+ "name": "logs_attempt_streams_open_age_idx",
207
+ "columns": [
208
+ {
209
+ "expression": "created_at",
210
+ "isExpression": false,
211
+ "asc": true,
212
+ "nulls": "last"
213
+ }
214
+ ],
215
+ "isUnique": false,
216
+ "where": "\"state\" = 'open'",
217
+ "concurrently": false,
218
+ "method": "btree",
219
+ "with": {}
220
+ },
221
+ "logs_attempt_streams_retention_idx": {
222
+ "name": "logs_attempt_streams_retention_idx",
223
+ "columns": [
224
+ {
225
+ "expression": "closed_at",
226
+ "isExpression": false,
227
+ "asc": true,
228
+ "nulls": "last"
229
+ }
230
+ ],
231
+ "isUnique": false,
232
+ "where": "\"state\" = 'closed'",
233
+ "concurrently": false,
234
+ "method": "btree",
235
+ "with": {}
236
+ },
237
+ "logs_attempt_streams_uncompacted_idx": {
238
+ "name": "logs_attempt_streams_uncompacted_idx",
239
+ "columns": [
240
+ {
241
+ "expression": "closed_at",
242
+ "isExpression": false,
243
+ "asc": true,
244
+ "nulls": "last"
245
+ }
246
+ ],
247
+ "isUnique": false,
248
+ "where": "\"state\" = 'closed' and \"object_key\" is null",
249
+ "concurrently": false,
250
+ "method": "btree",
251
+ "with": {}
252
+ }
253
+ },
254
+ "foreignKeys": {},
255
+ "compositePrimaryKeys": {},
256
+ "uniqueConstraints": {},
257
+ "policies": {},
258
+ "checkConstraints": {},
259
+ "isRLSEnabled": false
260
+ },
261
+ "public.logs_chunks": {
262
+ "name": "logs_chunks",
263
+ "schema": "",
264
+ "columns": {
265
+ "id": {
266
+ "name": "id",
267
+ "type": "uuid",
268
+ "primaryKey": true,
269
+ "notNull": true,
270
+ "default": "uuidv7()"
271
+ },
272
+ "stream_id": {
273
+ "name": "stream_id",
274
+ "type": "uuid",
275
+ "primaryKey": false,
276
+ "notNull": true
277
+ },
278
+ "seq": {
279
+ "name": "seq",
280
+ "type": "bigserial",
281
+ "primaryKey": false,
282
+ "notNull": true
283
+ },
284
+ "stream_offset": {
285
+ "name": "stream_offset",
286
+ "type": "bigint",
287
+ "primaryKey": false,
288
+ "notNull": true
289
+ },
290
+ "byte_len": {
291
+ "name": "byte_len",
292
+ "type": "integer",
293
+ "primaryKey": false,
294
+ "notNull": true
295
+ },
296
+ "data": {
297
+ "name": "data",
298
+ "type": "bytea",
299
+ "primaryKey": false,
300
+ "notNull": true
301
+ },
302
+ "origin": {
303
+ "name": "origin",
304
+ "type": "text",
305
+ "primaryKey": false,
306
+ "notNull": true
307
+ },
308
+ "created_at": {
309
+ "name": "created_at",
310
+ "type": "timestamp with time zone",
311
+ "primaryKey": false,
312
+ "notNull": true,
313
+ "default": "now()"
314
+ }
315
+ },
316
+ "indexes": {
317
+ "logs_chunks_stream_seq_idx": {
318
+ "name": "logs_chunks_stream_seq_idx",
319
+ "columns": [
320
+ {
321
+ "expression": "stream_id",
322
+ "isExpression": false,
323
+ "asc": true,
324
+ "nulls": "last"
325
+ },
326
+ {
327
+ "expression": "seq",
328
+ "isExpression": false,
329
+ "asc": true,
330
+ "nulls": "last"
331
+ }
332
+ ],
333
+ "isUnique": false,
334
+ "concurrently": false,
335
+ "method": "btree",
336
+ "with": {}
337
+ }
338
+ },
339
+ "foreignKeys": {
340
+ "logs_chunks_stream_id_logs_attempt_streams_id_fk": {
341
+ "name": "logs_chunks_stream_id_logs_attempt_streams_id_fk",
342
+ "tableFrom": "logs_chunks",
343
+ "tableTo": "logs_attempt_streams",
344
+ "columnsFrom": ["stream_id"],
345
+ "columnsTo": ["id"],
346
+ "onDelete": "cascade",
347
+ "onUpdate": "no action"
348
+ }
349
+ },
350
+ "compositePrimaryKeys": {},
351
+ "uniqueConstraints": {},
352
+ "policies": {},
353
+ "checkConstraints": {},
354
+ "isRLSEnabled": false
355
+ },
356
+ "public.logs_job_accounting": {
357
+ "name": "logs_job_accounting",
358
+ "schema": "",
359
+ "columns": {
360
+ "job_id": {
361
+ "name": "job_id",
362
+ "type": "uuid",
363
+ "primaryKey": true,
364
+ "notNull": true
365
+ },
366
+ "workspace_id": {
367
+ "name": "workspace_id",
368
+ "type": "uuid",
369
+ "primaryKey": false,
370
+ "notNull": true
371
+ },
372
+ "stored_bytes_used": {
373
+ "name": "stored_bytes_used",
374
+ "type": "bigint",
375
+ "primaryKey": false,
376
+ "notNull": true,
377
+ "default": 0
378
+ },
379
+ "started_at": {
380
+ "name": "started_at",
381
+ "type": "timestamp with time zone",
382
+ "primaryKey": false,
383
+ "notNull": true,
384
+ "default": "now()"
385
+ },
386
+ "capped_at": {
387
+ "name": "capped_at",
388
+ "type": "timestamp with time zone",
389
+ "primaryKey": false,
390
+ "notNull": false
391
+ },
392
+ "created_at": {
393
+ "name": "created_at",
394
+ "type": "timestamp with time zone",
395
+ "primaryKey": false,
396
+ "notNull": true,
397
+ "default": "now()"
398
+ },
399
+ "updated_at": {
400
+ "name": "updated_at",
401
+ "type": "timestamp with time zone",
402
+ "primaryKey": false,
403
+ "notNull": true,
404
+ "default": "now()"
405
+ }
406
+ },
407
+ "indexes": {},
408
+ "foreignKeys": {},
409
+ "compositePrimaryKeys": {},
410
+ "uniqueConstraints": {},
411
+ "policies": {},
412
+ "checkConstraints": {},
413
+ "isRLSEnabled": false
414
+ },
415
+ "public.logs_outbox": {
416
+ "name": "logs_outbox",
417
+ "schema": "",
418
+ "columns": {
419
+ "id": {
420
+ "name": "id",
421
+ "type": "uuid",
422
+ "primaryKey": true,
423
+ "notNull": true,
424
+ "default": "uuidv7()"
425
+ },
426
+ "event_type": {
427
+ "name": "event_type",
428
+ "type": "text",
429
+ "primaryKey": false,
430
+ "notNull": true
431
+ },
432
+ "ordering_key": {
433
+ "name": "ordering_key",
434
+ "type": "text",
435
+ "primaryKey": false,
436
+ "notNull": false
437
+ },
438
+ "payload": {
439
+ "name": "payload",
440
+ "type": "jsonb",
441
+ "primaryKey": false,
442
+ "notNull": true
443
+ },
444
+ "created_at": {
445
+ "name": "created_at",
446
+ "type": "timestamp with time zone",
447
+ "primaryKey": false,
448
+ "notNull": true,
449
+ "default": "now()"
450
+ },
451
+ "dispatched_at": {
452
+ "name": "dispatched_at",
453
+ "type": "timestamp with time zone",
454
+ "primaryKey": false,
455
+ "notNull": false
456
+ },
457
+ "dispatch_attempts": {
458
+ "name": "dispatch_attempts",
459
+ "type": "integer",
460
+ "primaryKey": false,
461
+ "notNull": true,
462
+ "default": 0
463
+ },
464
+ "next_dispatch_at": {
465
+ "name": "next_dispatch_at",
466
+ "type": "timestamp with time zone",
467
+ "primaryKey": false,
468
+ "notNull": true,
469
+ "default": "now()"
470
+ },
471
+ "last_dispatch_error": {
472
+ "name": "last_dispatch_error",
473
+ "type": "jsonb",
474
+ "primaryKey": false,
475
+ "notNull": false
476
+ },
477
+ "last_dispatch_failed_at": {
478
+ "name": "last_dispatch_failed_at",
479
+ "type": "timestamp with time zone",
480
+ "primaryKey": false,
481
+ "notNull": false
482
+ },
483
+ "dead_lettered_at": {
484
+ "name": "dead_lettered_at",
485
+ "type": "timestamp with time zone",
486
+ "primaryKey": false,
487
+ "notNull": false
488
+ }
489
+ },
490
+ "indexes": {
491
+ "logs_outbox_pending_idx": {
492
+ "name": "logs_outbox_pending_idx",
493
+ "columns": [
494
+ {
495
+ "expression": "next_dispatch_at",
496
+ "isExpression": false,
497
+ "asc": true,
498
+ "nulls": "last"
499
+ },
500
+ {
501
+ "expression": "created_at",
502
+ "isExpression": false,
503
+ "asc": true,
504
+ "nulls": "last"
505
+ }
506
+ ],
507
+ "isUnique": false,
508
+ "where": "\"dispatched_at\" IS NULL AND \"dead_lettered_at\" IS NULL",
509
+ "concurrently": false,
510
+ "method": "btree",
511
+ "with": {}
512
+ },
513
+ "logs_outbox_dispatched_retention_idx": {
514
+ "name": "logs_outbox_dispatched_retention_idx",
515
+ "columns": [
516
+ {
517
+ "expression": "dispatched_at",
518
+ "isExpression": false,
519
+ "asc": true,
520
+ "nulls": "last"
521
+ },
522
+ {
523
+ "expression": "id",
524
+ "isExpression": false,
525
+ "asc": true,
526
+ "nulls": "last"
527
+ }
528
+ ],
529
+ "isUnique": false,
530
+ "where": "\"dispatched_at\" IS NOT NULL",
531
+ "concurrently": false,
532
+ "method": "btree",
533
+ "with": {}
534
+ }
535
+ },
536
+ "foreignKeys": {},
537
+ "compositePrimaryKeys": {},
538
+ "uniqueConstraints": {},
539
+ "policies": {},
540
+ "checkConstraints": {},
541
+ "isRLSEnabled": false
542
+ }
543
+ },
544
+ "enums": {},
545
+ "schemas": {},
546
+ "sequences": {},
547
+ "roles": {},
548
+ "policies": {},
549
+ "views": {},
550
+ "_meta": {
551
+ "columns": {},
552
+ "schemas": {},
553
+ "tables": {}
554
+ }
555
+ }
@@ -8,6 +8,13 @@
8
8
  "when": 1782016439771,
9
9
  "tag": "0000_initial",
10
10
  "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "7",
15
+ "when": 1785166831100,
16
+ "tag": "0001_strong_major_mapleleaf",
17
+ "breakpoints": true
11
18
  }
12
19
  ]
13
20
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipfox/api-logs",
3
3
  "license": "MIT",
4
- "version": "9.3.0",
4
+ "version": "10.1.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ShipfoxHQ/shipfox.git",
@@ -25,15 +25,15 @@
25
25
  "@temporalio/workflow": "1.18.1",
26
26
  "drizzle-orm": "^0.45.2",
27
27
  "zod": "^4.4.3",
28
- "@shipfox/api-auth-context": "9.3.0",
28
+ "@shipfox/api-auth-context": "10.1.0",
29
29
  "@shipfox/api-logs-dto": "9.0.2",
30
- "@shipfox/api-workflows-dto": "9.3.0",
30
+ "@shipfox/api-workflows-dto": "10.0.0",
31
31
  "@shipfox/workflow-document": "2.1.3",
32
32
  "@shipfox/config": "1.2.4",
33
33
  "@shipfox/node-drizzle": "0.3.4",
34
34
  "@shipfox/node-error-monitoring": "0.3.0",
35
- "@shipfox/node-fastify": "0.3.4",
36
- "@shipfox/node-module": "1.0.3",
35
+ "@shipfox/node-fastify": "0.4.0",
36
+ "@shipfox/node-module": "1.0.4",
37
37
  "@shipfox/node-opentelemetry": "0.6.3",
38
38
  "@shipfox/node-outbox": "0.2.6",
39
39
  "@shipfox/node-postgres": "0.4.4",