deepline 0.3.385 → 0.3.387

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 (93) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/run-event-catalog.ts +9 -0
  3. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +18 -5
  4. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +118 -2
  5. package/dist/cli/{auth-4D4IBZZN.mjs → auth-CKRRMJQU.mjs} +4 -4
  6. package/dist/cli/auth-M65RW5ZI.js +39 -0
  7. package/dist/cli/{billing-6LXNCN5G.js → billing-CVBGUOM6.js} +73 -73
  8. package/dist/cli/{billing-4RSI4634.mjs → billing-QXZB3SP4.mjs} +4 -4
  9. package/dist/cli/{chunk-JFYOV3HL.js → chunk-3W3AW37A.js} +15 -15
  10. package/dist/cli/{chunk-K5JZ3JMP.mjs → chunk-4HFMNLCQ.mjs} +4 -4
  11. package/dist/cli/{chunk-SC2MM6IY.mjs → chunk-4KTBZLGR.mjs} +2 -2
  12. package/dist/cli/{chunk-XFS5MNSM.js → chunk-7AOECVD3.js} +226 -226
  13. package/dist/cli/{chunk-NV5VCWNJ.mjs → chunk-7F5HBT3S.mjs} +1 -1
  14. package/dist/cli/{chunk-IFKSXI4W.js → chunk-7JETEXCL.js} +1 -1
  15. package/dist/cli/{chunk-3PGTFASB.js → chunk-A5L54JX6.js} +4 -4
  16. package/dist/cli/{chunk-DIZYEI6O.mjs → chunk-BEEH7ZAL.mjs} +5 -5
  17. package/dist/cli/{chunk-TIBMH2VI.mjs → chunk-BXRWG6ZG.mjs} +1 -1
  18. package/dist/cli/{chunk-CJVB4RVY.js → chunk-CPB7PL4B.js} +61 -61
  19. package/dist/cli/{chunk-MW6IPE3M.js → chunk-CQ6B46NN.js} +10 -9
  20. package/dist/cli/{chunk-TTIISDJB.mjs → chunk-CWZRBSMO.mjs} +1 -1
  21. package/dist/cli/{chunk-LEDRQPBQ.js → chunk-DVVYOV2O.js} +50 -50
  22. package/dist/cli/{chunk-Q2NRMSOJ.mjs → chunk-EUFASY6H.mjs} +2 -1
  23. package/dist/cli/{chunk-F44OPZOG.mjs → chunk-EWKW7ADZ.mjs} +2 -2
  24. package/dist/cli/{chunk-CMIRZZT4.js → chunk-FUTYFVJR.js} +6 -6
  25. package/dist/cli/{chunk-VCW425WW.js → chunk-GJGHN34W.js} +26 -26
  26. package/dist/cli/{chunk-KKKKBDVM.mjs → chunk-HMSWH2JW.mjs} +6 -6
  27. package/dist/cli/{chunk-2IXAMP5J.js → chunk-LA6WXHEG.js} +2 -2
  28. package/dist/cli/{chunk-KIZ7QHY5.mjs → chunk-LQUNC2VM.mjs} +1 -1
  29. package/dist/cli/{chunk-VUEQBNG7.mjs → chunk-MTGIBXYZ.mjs} +2 -2
  30. package/dist/cli/{chunk-RST4XEI7.mjs → chunk-MZBR5BX2.mjs} +3 -3
  31. package/dist/cli/{chunk-WGPPCGGS.js → chunk-NJRWEFAY.js} +8 -8
  32. package/dist/cli/{chunk-EGMLX2NR.mjs → chunk-RKYFX5G5.mjs} +2 -2
  33. package/dist/cli/{chunk-POQ7QWVA.js → chunk-S7HRCOFT.js} +48 -48
  34. package/dist/cli/{chunk-YHSAUVJ3.js → chunk-UKBXVON4.js} +8 -8
  35. package/dist/cli/{csv-DZY7OAFK.js → csv-IBQSV2LF.js} +12 -12
  36. package/dist/cli/{csv-Q7XLUTXX.mjs → csv-L3NMNEK2.mjs} +3 -3
  37. package/dist/cli/{db-5CLCESHQ.mjs → db-6OPCFP3J.mjs} +4 -4
  38. package/dist/cli/{db-FRJFSTIF.js → db-AWKMYFXN.js} +29 -29
  39. package/dist/cli/{describe-Y7E6FPUC.js → describe-IFJ34VUV.js} +18 -18
  40. package/dist/cli/{describe-QDIM53RP.mjs → describe-NEHPRI33.mjs} +8 -8
  41. package/dist/cli/{executions-YISFXRPZ.js → executions-FLGLIGRM.js} +6 -6
  42. package/dist/cli/{executions-M2QRHUDM.mjs → executions-LDZEOSBO.mjs} +4 -4
  43. package/dist/cli/{feedback-FICCIDJQ.mjs → feedback-PWFQTP4G.mjs} +3 -3
  44. package/dist/cli/{feedback-HNJVF6AQ.js → feedback-W3LOHQOV.js} +7 -7
  45. package/dist/cli/{git-WRTQIX6R.mjs → git-E3G5SPN7.mjs} +4 -4
  46. package/dist/cli/git-UJJKVNZ5.js +23 -0
  47. package/dist/cli/index.js +89 -89
  48. package/dist/cli/index.mjs +32 -32
  49. package/dist/cli/{legacy-noops-6HJZDXLH.mjs → legacy-noops-43UAYJOG.mjs} +4 -4
  50. package/dist/cli/{legacy-noops-E2R3P424.js → legacy-noops-LLIS3SCA.js} +7 -7
  51. package/dist/cli/{monitors-DRWEUXDG.js → monitors-IRTHA34J.js} +85 -85
  52. package/dist/cli/{monitors-HGIB7TPZ.mjs → monitors-VFSBTSHJ.mjs} +4 -4
  53. package/dist/cli/{org-467XUTRD.js → org-3Z5SRXPW.js} +64 -64
  54. package/dist/cli/{org-NHILTL3P.mjs → org-C3BNJMYT.mjs} +4 -4
  55. package/dist/cli/play-4QE3H5KN.js +157 -0
  56. package/dist/cli/{play-JEI3F2M4.mjs → play-W5XTHGLT.mjs} +7 -7
  57. package/dist/cli/{providers-6INAFXGV.mjs → providers-ANLUHMBV.mjs} +4 -4
  58. package/dist/cli/{providers-KOKGN5YP.js → providers-W3O4DRDG.js} +7 -7
  59. package/dist/cli/{quickstart-QMRYNXDM.mjs → quickstart-5G65T2IR.mjs} +3 -3
  60. package/dist/cli/{quickstart-ELSP2FZI.js → quickstart-6JAZF3FG.js} +5 -5
  61. package/dist/cli/search-HIY4H3T3.js +26 -0
  62. package/dist/cli/{search-HFUSEL3S.mjs → search-XQRGKA3F.mjs} +5 -5
  63. package/dist/cli/{secrets-TSFBMX65.mjs → secrets-DF3EL5RU.mjs} +4 -4
  64. package/dist/cli/{secrets-6OUGIWPM.js → secrets-PUWRCDTC.js} +13 -13
  65. package/dist/cli/{sessions-6VJUWBCJ.js → sessions-OTRBNAPA.js} +5 -5
  66. package/dist/cli/{sessions-GE3GEQY3.mjs → sessions-OYFE2CUC.mjs} +4 -4
  67. package/dist/cli/{settings-G5FDUOZJ.mjs → settings-JSB64G57.mjs} +7 -7
  68. package/dist/cli/{settings-633RRITH.js → settings-R7H4JXVO.js} +74 -74
  69. package/dist/cli/{setup-WOMOSJWB.mjs → setup-AJD5R5TW.mjs} +6 -6
  70. package/dist/cli/{setup-X2U5RX5R.js → setup-PL4QRM4U.js} +41 -41
  71. package/dist/cli/skills-HJXJ2R6P.js +28 -0
  72. package/dist/cli/{skills-NDHK6HRC.mjs → skills-YN2BR22T.mjs} +4 -4
  73. package/dist/cli/{tools-GILOEDEQ.mjs → tools-ATIA3P4H.mjs} +6 -6
  74. package/dist/cli/tools-Y3HQI53B.js +40 -0
  75. package/dist/cli/{update-H6APTLX7.mjs → update-CWAXNG5N.mjs} +6 -6
  76. package/dist/cli/update-F6RQFNQ5.js +28 -0
  77. package/dist/cli/{workflow-MLYJQCP3.mjs → workflow-ENCTHGP4.mjs} +5 -5
  78. package/dist/cli/{workflow-TC72DBUF.js → workflow-O2CW5YKT.js} +15 -15
  79. package/dist/index.js +6 -6
  80. package/dist/index.mjs +3 -3
  81. package/dist/install-integrity.json +72 -72
  82. package/dist/release.d.mts +1 -1
  83. package/dist/release.d.ts +1 -1
  84. package/dist/release.js +2 -2
  85. package/dist/release.mjs +1 -1
  86. package/package.json +1 -1
  87. package/dist/cli/auth-A4UKONKC.js +0 -39
  88. package/dist/cli/git-RBHELB5Y.js +0 -23
  89. package/dist/cli/play-Y66Z4I7K.js +0 -157
  90. package/dist/cli/search-P5HU6U6X.js +0 -26
  91. package/dist/cli/skills-BZCMRUZZ.js +0 -28
  92. package/dist/cli/tools-Y6BDEUS3.js +0 -40
  93. package/dist/cli/update-RQWIZOBF.js +0 -28
@@ -200,7 +200,7 @@ export const SDK_RELEASE = {
200
200
  // getters keep their established compatibility behavior.
201
201
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
202
202
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
203
- version: '0.3.385',
203
+ version: '0.3.387',
204
204
  updateSummary:
205
205
  'Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.',
206
206
  packageCapabilities: {
@@ -485,6 +485,15 @@ export const RUN_LOG_RETENTION_MAX_LINES = 25_000;
485
485
  export const RUN_LOG_RETENTION_MAX_BYTES = 5 * 1024 * 1024;
486
486
  export const RUN_LOG_PAGE_MAX_LIMIT = 1_000;
487
487
  export const RUN_LOG_PAGE_DEFAULT_LIMIT = RUN_LOG_PAGE_MAX_LIMIT;
488
+ /**
489
+ * Per-fact bound for a retained terminal log tail. Deferred projection splits
490
+ * a larger tail into consecutive facts at write time, so one materialization
491
+ * prefix projects at most eight such facts whatever the tail length. The byte
492
+ * bound counts each line with its context, metadata and identity; a single
493
+ * entry larger than it travels alone rather than being truncated.
494
+ */
495
+ export const RUN_LOG_TERMINAL_FACT_MAX_LINES = RUN_LOG_PAGE_MAX_LIMIT;
496
+ export const RUN_LOG_TERMINAL_FACT_MAX_BYTES = 256 * 1024;
488
497
  export const RUN_LOG_TAIL_DEFAULT_LIMIT = 200;
489
498
  export const RUN_LOG_FAILED_VIEW_MAX_LINES = 20;
490
499
  export const RUN_LOG_RATE_LIMIT_POLICY = {
@@ -18021,6 +18021,18 @@ function outboxByEventIdSql(
18021
18021
  )`;
18022
18022
  }
18023
18023
 
18024
+ /**
18025
+ * `failed_at IS NULL` in a form the planner cannot use to choose a partial
18026
+ * index. Every outbox partial index that run_id does not lead requires
18027
+ * `failed_at IS NULL`, and statistics taken between bursts record those
18028
+ * indexes as empty. A run-scoped probe that proves their predicate therefore
18029
+ * scans every run's pending facts instead of its own. The check still applies
18030
+ * to each row, including a concurrently updated row under FOR UPDATE.
18031
+ */
18032
+ function outboxNotFailedSql(alias: string): string {
18033
+ return `coalesce(${alias}.failed_at IS NULL, false)`;
18034
+ }
18035
+
18024
18036
  // A projection receipt has always admitted at most eight ordered outbox facts.
18025
18037
  // Share that existing boundary between its SQL snapshot and prefix validation.
18026
18038
  const RUN_LEDGER_PROJECTION_PREFIX_MAX_FACTS = 8;
@@ -18290,7 +18302,7 @@ function runLedgerTerminalPendingSql(
18290
18302
  AND terminal_event.run_id = ${alias}.run_id
18291
18303
  AND terminal_event.event_type IN (${RUN_EVENT_KIND_SQL_LITERAL.runCompleted}, ${RUN_EVENT_KIND_SQL_LITERAL.runFailed}, ${RUN_EVENT_KIND_SQL_LITERAL.runCancelled})
18292
18304
  AND terminal_event.delivered_at IS NULL
18293
- AND terminal_event.failed_at IS NULL
18305
+ AND ${outboxNotFailedSql('terminal_event')}
18294
18306
  AND coalesce(terminal_event.next_attempt_at, terminal_event.created_at) <= now()
18295
18307
  )`;
18296
18308
  }
@@ -18307,7 +18319,7 @@ function runLedgerWaitingPendingSql(
18307
18319
  -- Detached runner parks are transport-only and project no public wait.
18308
18320
  AND waiting_event.payload_json->>'kind' IS DISTINCT FROM 'detached_runner'
18309
18321
  AND waiting_event.delivered_at IS NULL
18310
- AND waiting_event.failed_at IS NULL
18322
+ AND ${outboxNotFailedSql('waiting_event')}
18311
18323
  AND coalesce(waiting_event.next_attempt_at, waiting_event.created_at) <= now())`;
18312
18324
  }
18313
18325
 
@@ -18481,7 +18493,7 @@ async function claimPostgresSchedulerOutboxPrefix(
18481
18493
  AND EXISTS (
18482
18494
  SELECT 1 FROM ${tableName('outbox', options)} AS target
18483
18495
  WHERE target.run_id = $2 AND target.event_id = $6
18484
- AND ${pending('target')} AND target.failed_at IS NULL
18496
+ AND ${pending('target')} AND ${outboxNotFailedSql('target')}
18485
18497
  )`
18486
18498
  : ''
18487
18499
  }
@@ -18491,9 +18503,10 @@ async function claimPostgresSchedulerOutboxPrefix(
18491
18503
  AND candidate.lease_owner = $3 AND candidate.lease_expires_at > clock_timestamp()`
18492
18504
  : ''
18493
18505
  }
18494
- AND candidate.failed_at IS NULL
18506
+ AND ${outboxNotFailedSql('candidate')}
18495
18507
  AND coalesce(candidate.next_attempt_at, candidate.created_at) <= now()
18496
18508
  AND ($2::text IS NULL OR candidate.run_id = $2)
18509
+ ${runId !== null ? 'AND candidate.run_id = $2::text' : ''}
18497
18510
  AND (
18498
18511
  $3::text IS NULL
18499
18512
  OR candidate.lease_owner = $3::text
@@ -18621,7 +18634,7 @@ async function claimPostgresSchedulerOutboxPrefix(
18621
18634
  ${runId !== null ? 'AND outbox.run_id = $2::text' : ''}
18622
18635
  ${findSearchBlockersOnce ? 'AND outbox.event_id = ANY(ARRAY(SELECT event_id FROM search_facts))' : ''}
18623
18636
  AND ${searchLaneSql('outbox')} = ${input.searchOnly === true ? 'true' : 'false'}
18624
- AND outbox.failed_at IS NULL
18637
+ AND ${outboxNotFailedSql('outbox')}
18625
18638
  -- Admission is causally first and must be projected alone. A later
18626
18639
  -- start/terminal append may not leapfrog a delayed queued row.
18627
18640
  AND (
@@ -35,7 +35,12 @@ import {
35
35
  type RunEventQueryRetention,
36
36
  type RunEventSummaryResult,
37
37
  } from '../run-event-query';
38
- import { RUN_LOG_LEVELS, type RunLogLevel } from '../run-event-catalog';
38
+ import {
39
+ RUN_LOG_LEVELS,
40
+ RUN_LOG_TERMINAL_FACT_MAX_BYTES,
41
+ RUN_LOG_TERMINAL_FACT_MAX_LINES,
42
+ type RunLogLevel,
43
+ } from '../run-event-catalog';
39
44
  import type { PostgresSchedulerQueryClient } from './postgres';
40
45
  import {
41
46
  RUN_EVENT_CONVEX_INTERNAL_KIND_SQL_LITERAL,
@@ -86,7 +91,7 @@ const RUNTIME_EVENT_LOG_POSITION_EXPRESSION = `jsonb_set(
86
91
  // Migration readiness tracks this projection body independently of scheduler
87
92
  // wire and schema versions. Bump when a changed trigger must be reinstalled.
88
93
  export const RUNTIME_EVENT_SEARCH_OUTBOX_PROJECTION_MARKER =
89
- 'runtime-event-search-primary-key-fence-direct-independent-receipts';
94
+ 'runtime-event-search-direct-receipts-bounded-terminal-log-facts';
90
95
  /** Trusted trigger-authored state; absent on already-projected legacy rows. */
91
96
  export const RUNTIME_EVENT_DEFERRED_PROJECTION_FIELD =
92
97
  '_runtimeSearchProjectionPending';
@@ -2965,6 +2970,112 @@ export async function attachRuntimeEventSearchTriggers(
2965
2970
  END
2966
2971
  $function$
2967
2972
  `);
2973
+ // A retained terminal tail can hold the whole runner log. Split it here, at
2974
+ // the write every producer build shares, so no deferred fact grows with it.
2975
+ // Each chunk is the log.appended item the projector already builds from
2976
+ // terminalLogLines, with its own channelOffset: positions, origin IDs,
2977
+ // contexts and metadata are unchanged, and older projectors read it as is.
2978
+ // Earlier chunks become preceding runner.logs facts; the carrier keeps the
2979
+ // last chunk after its own progress events, so lines stay in causal order.
2980
+ await client.query(`
2981
+ CREATE OR REPLACE FUNCTION ${schema}.split_terminal_log_envelope(observation ${schema}.outbox)
2982
+ RETURNS ${schema}.outbox
2983
+ LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog AS $function$
2984
+ DECLARE payload jsonb := observation.payload_json; attempt jsonb; line_count integer;
2985
+ has_contexts boolean; has_metadata boolean; has_ids boolean;
2986
+ sizes integer[]; starts integer[] := ARRAY[0]; items jsonb[];
2987
+ chunk_lines integer := 0; chunk_bytes bigint := 0; line_position integer; chunk_number integer;
2988
+ BEGIN
2989
+ attempt := coalesce(NULLIF(payload->'producerAttempt', 'null'::jsonb),
2990
+ payload->'terminalWorkCounterSegment'->'attempt');
2991
+ has_contexts := jsonb_typeof(payload->'terminalLogContexts') = 'array';
2992
+ has_metadata := payload ? 'terminalLogMetadata';
2993
+ has_ids := jsonb_typeof(payload->'terminalLogIds') = 'array';
2994
+ line_count := jsonb_array_length(payload->'terminalLogLines');
2995
+ -- Malformed or unpositioned envelopes stay whole so the projector
2996
+ -- reports them exactly as before. Legacy runs deliver these lines to
2997
+ -- the Convex ledger and keep their single carrier.
2998
+ IF line_count = 0
2999
+ OR NOT coalesce((attempt #>> '{}') ~ '^[1-9][0-9]{0,5}$', false)
3000
+ OR (payload ? 'terminalLogContexts' AND jsonb_typeof(payload->'terminalLogContexts') <> 'null'
3001
+ AND NOT (has_contexts AND jsonb_array_length(payload->'terminalLogContexts') = line_count))
3002
+ OR (has_metadata AND NOT (jsonb_typeof(payload->'terminalLogMetadata') = 'array'
3003
+ AND jsonb_array_length(payload->'terminalLogMetadata') = line_count))
3004
+ OR (payload ? 'terminalLogIds' AND jsonb_typeof(payload->'terminalLogIds') <> 'null'
3005
+ AND NOT (has_ids AND jsonb_array_length(payload->'terminalLogIds') = line_count))
3006
+ OR (payload ? 'terminalProgressEvents'
3007
+ AND jsonb_typeof(payload->'terminalProgressEvents') IS DISTINCT FROM 'array')
3008
+ OR NOT EXISTS (SELECT 1 FROM ${schema}.runs WHERE run_id = observation.run_id
3009
+ AND (run_log_store = 'planet_scale' OR run_event_store = 'planet_scale'))
3010
+ -- A retried producer write conflicts and inserts nothing.
3011
+ OR EXISTS (SELECT 1 FROM ${schema}.outbox WHERE event_id = observation.event_id) THEN
3012
+ RETURN observation;
3013
+ END IF;
3014
+ SELECT array_agg(octet_length(entry.line::text)
3015
+ + coalesce(octet_length(entry.context::text), 0)
3016
+ + coalesce(octet_length(entry.metadata::text), 0)
3017
+ + coalesce(octet_length(entry.id::text), 0) + 8 ORDER BY entry.position)
3018
+ INTO sizes
3019
+ FROM ROWS FROM (
3020
+ jsonb_array_elements(payload->'terminalLogLines'),
3021
+ jsonb_array_elements(CASE WHEN has_contexts THEN payload->'terminalLogContexts' ELSE '[]'::jsonb END),
3022
+ jsonb_array_elements(CASE WHEN has_metadata THEN payload->'terminalLogMetadata' ELSE '[]'::jsonb END),
3023
+ jsonb_array_elements(CASE WHEN has_ids THEN payload->'terminalLogIds' ELSE '[]'::jsonb END)
3024
+ ) WITH ORDINALITY AS entry(line, context, metadata, id, position);
3025
+ FOR line_position IN 1..line_count LOOP
3026
+ IF chunk_lines > 0 AND (chunk_lines >= ${RUN_LOG_TERMINAL_FACT_MAX_LINES}
3027
+ OR chunk_bytes + sizes[line_position] > ${RUN_LOG_TERMINAL_FACT_MAX_BYTES}) THEN
3028
+ starts := starts || (line_position - 1);
3029
+ chunk_lines := 0;
3030
+ chunk_bytes := 0;
3031
+ END IF;
3032
+ chunk_lines := chunk_lines + 1;
3033
+ chunk_bytes := chunk_bytes + sizes[line_position];
3034
+ END LOOP;
3035
+ IF cardinality(starts) = 1 THEN
3036
+ RETURN observation;
3037
+ END IF;
3038
+ -- Same item, with the same null stripping, as the projector's envelope.
3039
+ SELECT array_agg(chunked.item ORDER BY chunked.number) INTO items
3040
+ FROM (
3041
+ SELECT width_bucket((entry.position - 1)::integer, starts) AS number,
3042
+ jsonb_strip_nulls(jsonb_build_object(
3043
+ 'type', ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}, 'runId', observation.run_id,
3044
+ 'source', 'terminal', 'producerAttempt', attempt,
3045
+ 'channelOffset', min(entry.position) - 1,
3046
+ 'lines', jsonb_agg(entry.line ORDER BY entry.position),
3047
+ 'lineContexts', CASE WHEN has_contexts THEN jsonb_agg(entry.context ORDER BY entry.position) END,
3048
+ 'lineMetadata', CASE WHEN has_metadata THEN jsonb_agg(entry.metadata ORDER BY entry.position) END,
3049
+ 'lineIds', CASE WHEN has_ids THEN jsonb_agg(entry.id ORDER BY entry.position) END
3050
+ )) AS item
3051
+ FROM ROWS FROM (
3052
+ jsonb_array_elements(payload->'terminalLogLines'),
3053
+ jsonb_array_elements(CASE WHEN has_contexts THEN payload->'terminalLogContexts' ELSE '[]'::jsonb END),
3054
+ jsonb_array_elements(CASE WHEN has_metadata THEN payload->'terminalLogMetadata' ELSE '[]'::jsonb END),
3055
+ jsonb_array_elements(CASE WHEN has_ids THEN payload->'terminalLogIds' ELSE '[]'::jsonb END)
3056
+ ) WITH ORDINALITY AS entry(line, context, metadata, id, position)
3057
+ GROUP BY 1
3058
+ ) AS chunked;
3059
+ FOR chunk_number IN 1..cardinality(items) - 1 LOOP
3060
+ INSERT INTO ${schema}.outbox (event_id, run_id, event_type, payload_json, created_at)
3061
+ VALUES ('terminal-log-chunk:' || observation.event_id || ':' || chunk_number, observation.run_id,
3062
+ ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runnerLogs},
3063
+ jsonb_build_object('producerAttempt', attempt,
3064
+ 'terminalProgressEvents', jsonb_build_array(items[chunk_number])),
3065
+ observation.created_at + (chunk_number - 1) * interval '1 microsecond')
3066
+ ON CONFLICT (event_id) DO NOTHING;
3067
+ END LOOP;
3068
+ observation.created_at := observation.created_at
3069
+ + (cardinality(items) - 1) * interval '1 microsecond';
3070
+ observation.payload_json := (payload - 'terminalLogLines' - 'terminalLogContexts'
3071
+ - 'terminalLogMetadata' - 'terminalLogIds')
3072
+ || jsonb_build_object('terminalProgressEvents',
3073
+ coalesce(payload->'terminalProgressEvents', '[]'::jsonb)
3074
+ || jsonb_build_array(items[cardinality(items)]));
3075
+ RETURN observation;
3076
+ END
3077
+ $function$
3078
+ `);
2968
3079
  await client.query(`
2969
3080
  CREATE OR REPLACE FUNCTION ${schema}.search_outbox_event() RETURNS trigger
2970
3081
  LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog AS $function$
@@ -2973,6 +3084,10 @@ export async function attachRuntimeEventSearchTriggers(
2973
3084
  IF NEW.payload_json->'${RUNTIME_EVENT_SEARCH_ONLY_FIELD}' = 'true'::jsonb THEN RETURN NEW; END IF;
2974
3085
  IF ${schema}.defer_runtime_event_projection_for_run(NEW.run_id)
2975
3086
  AND NEW.event_type <> ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runCreated} THEN
3087
+ IF NEW.event_type IN (${RUN_EVENT_TERMINAL_LOG_CARRIER_SQL_LIST})
3088
+ AND jsonb_typeof(NEW.payload_json->'terminalLogLines') = 'array' THEN
3089
+ NEW := ${schema}.split_terminal_log_envelope(NEW);
3090
+ END IF;
2976
3091
  IF NEW.event_type = ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runEvents} THEN
2977
3092
  -- One cheap Run fence captures whether ingress preceded terminal
2978
3093
  -- closure. No indexed log lookup or search mutex runs under it.
@@ -3204,6 +3319,7 @@ export async function attachRuntimeEventSearchTriggers(
3204
3319
  ${schema}.guard_runtime_outbox_ack(),
3205
3320
  ${schema}.compact_runtime_outbox_payload(${schema}.outbox),
3206
3321
  ${schema}.accept_runner_log_payload(), ${schema}.search_outbox_event(),
3322
+ ${schema}.split_terminal_log_envelope(${schema}.outbox),
3207
3323
  ${schema}.compact_run_log_result(), ${schema}.without_log_events(jsonb),
3208
3324
  ${schema}.convex_projection_event(jsonb), ${schema}.convex_projection_events(jsonb),
3209
3325
  ${schema}.run_log_metadata(text, jsonb, timestamptz), ${schema}.compact_runner_log_envelope(jsonb), ${schema}.without_runtime_log_tail(jsonb)
@@ -13,12 +13,12 @@ import {
13
13
  reportSetupCompleted,
14
14
  resolvePendingAuthClaimForResume,
15
15
  statusBannerLine
16
- } from "./chunk-SC2MM6IY.mjs";
17
- import "./chunk-TIBMH2VI.mjs";
18
- import "./chunk-NV5VCWNJ.mjs";
16
+ } from "./chunk-4KTBZLGR.mjs";
17
+ import "./chunk-BXRWG6ZG.mjs";
18
+ import "./chunk-7F5HBT3S.mjs";
19
19
  import "./chunk-DLIRSHV6.mjs";
20
20
  import "./chunk-NXGCO4JB.mjs";
21
- import "./chunk-TTIISDJB.mjs";
21
+ import "./chunk-CWZRBSMO.mjs";
22
22
  import "./chunk-WZYKRD7T.mjs";
23
23
  import "./chunk-KRD6H754.mjs";
24
24
  export {
@@ -0,0 +1,39 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ var _chunkDVVYOV2Ojs = require('./chunk-DVVYOV2O.js');
17
+ require('./chunk-FUTYFVJR.js');
18
+ require('./chunk-A5L54JX6.js');
19
+ require('./chunk-XNYIZMNQ.js');
20
+ require('./chunk-7P5AA3SN.js');
21
+ require('./chunk-7JETEXCL.js');
22
+ require('./chunk-OG64RBAC.js');
23
+ require('./chunk-COGTRVWW.js');
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ exports.EXIT_WORKSPACE_MISMATCH = _chunkDVVYOV2Ojs.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunkDVVYOV2Ojs.authStatusLine; exports.clearPendingClaim = _chunkDVVYOV2Ojs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunkDVVYOV2Ojs.clearSatisfiedPendingClaim; exports.handleRegister = _chunkDVVYOV2Ojs.handleRegister; exports.handleStatus = _chunkDVVYOV2Ojs.handleStatus; exports.handleWait = _chunkDVVYOV2Ojs.handleWait; exports.httpJson = _chunkDVVYOV2Ojs.httpJson; exports.readPendingAuthClaim = _chunkDVVYOV2Ojs.readPendingAuthClaim; exports.readStatusBanner = _chunkDVVYOV2Ojs.readStatusBanner; exports.registerAuthCommands = _chunkDVVYOV2Ojs.registerAuthCommands; exports.reportSetupCompleted = _chunkDVVYOV2Ojs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunkDVVYOV2Ojs.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunkDVVYOV2Ojs.statusBannerLine;