deepline 0.3.246 → 0.3.248

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 (67) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +177 -13
  2. package/dist/bundling-sources/sdk/src/index.ts +8 -0
  3. package/dist/bundling-sources/sdk/src/plays/input-example.ts +40 -0
  4. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  5. package/dist/bundling-sources/sdk/src/runs/overview.ts +457 -0
  6. package/dist/bundling-sources/sdk/src/runs/receipts.ts +23 -0
  7. package/dist/bundling-sources/sdk/src/tool-calls.ts +21 -1
  8. package/dist/bundling-sources/sdk/src/types.ts +16 -1
  9. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +37 -1
  10. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -0
  11. package/dist/bundling-sources/shared_libs/play-data-plane/column-names.ts +17 -3
  12. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +40 -8
  13. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +26 -1
  14. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +150 -19
  15. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +2 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/daytona-runtime-config.ts +6 -3
  17. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +26 -21
  18. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +23 -21
  19. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +17 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/log-context.ts +105 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +8 -1
  22. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +9 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-event-transport.ts +40 -4
  24. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +50 -5
  25. package/dist/bundling-sources/shared_libs/play-runtime/run-lifecycle-policy.ts +3 -1
  26. package/dist/bundling-sources/shared_libs/play-runtime/run-log-buffer.ts +28 -1
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +14 -1
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +56 -16
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-control-transport.ts +184 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +327 -0
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +87 -30
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +24 -13
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-start-admission.ts +23 -6
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +76 -33
  35. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +90 -35
  36. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +16 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +62 -21
  38. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +368 -66
  39. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +22 -4
  40. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +106 -81
  41. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +1347 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-queue-health.ts +16 -19
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +14 -6
  44. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +16 -0
  45. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +40 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +3 -2
  47. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +5 -2
  48. package/dist/bundling-sources/shared_libs/plays/dataset-summary.ts +11 -7
  49. package/dist/bundling-sources/shared_libs/plays/static-pipeline-storage-codec.ts +5 -2
  50. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +11 -2
  51. package/dist/cli/index.js +3504 -2368
  52. package/dist/cli/index.mjs +3188 -2052
  53. package/dist/{compiler-manifest-n8ZtPv2h.d.mts → compiler-manifest-DavmLa8y.d.mts} +1 -0
  54. package/dist/{compiler-manifest-n8ZtPv2h.d.ts → compiler-manifest-DavmLa8y.d.ts} +1 -0
  55. package/dist/index.d.mts +97 -5
  56. package/dist/index.d.ts +97 -5
  57. package/dist/index.js +135 -15
  58. package/dist/index.mjs +135 -15
  59. package/dist/install-integrity.json +9 -2
  60. package/dist/plays/bundle-play-file.d.mts +2 -2
  61. package/dist/plays/bundle-play-file.d.ts +2 -2
  62. package/dist/plays/bundle-play-file.mjs +1 -1
  63. package/dist/release.d.mts +1 -1
  64. package/dist/release.d.ts +1 -1
  65. package/dist/release.js +1 -1
  66. package/dist/release.mjs +1 -1
  67. package/package.json +1 -1
@@ -20,6 +20,10 @@ import {
20
20
  import type { PlayVisualNodeProgressMap } from '../worker-api-types';
21
21
  import type { PlayExecutionEvent } from '../ctx-types';
22
22
  import type { PlayActivityObservation } from '../activity-observation';
23
+ import {
24
+ normalizePlayLogContext,
25
+ type PlayLogContext,
26
+ } from '../log-context';
23
27
  import type {
24
28
  PlayRunnerLogEvent,
25
29
  PlayRunnerResult,
@@ -274,33 +278,53 @@ type TerminalLogReplayPayload = NonNullable<
274
278
  RuntimeStatusUpdate['terminalLogReplay']
275
279
  >;
276
280
 
277
- function terminalReplayLinesForMode(input: {
281
+ function terminalReplayEntriesForMode(input: {
278
282
  resultLogs: readonly string[];
283
+ resultLogContexts?: readonly (PlayLogContext | null)[];
279
284
  durableLogMode: PostgresSchedulerDurableLogMode;
280
- }): string[] {
281
- return input.resultLogs
282
- .map((line) => line.trim())
283
- .filter(
284
- (line) =>
285
- line.length > 0 &&
286
- shouldPublishTerminalResultLog(input.durableLogMode, line),
287
- );
285
+ }): Array<{ line: string; context: PlayLogContext | null }> {
286
+ if (
287
+ input.resultLogContexts !== undefined &&
288
+ input.resultLogContexts.length !== input.resultLogs.length
289
+ ) {
290
+ throw new TypeError('Terminal log contexts must align with result logs.');
291
+ }
292
+ return input.resultLogs.flatMap((rawLine, index) => {
293
+ const line = rawLine.trim();
294
+ if (
295
+ line.length === 0 ||
296
+ !shouldPublishTerminalResultLog(input.durableLogMode, line)
297
+ ) {
298
+ return [];
299
+ }
300
+ return [
301
+ {
302
+ line,
303
+ context: normalizePlayLogContext(input.resultLogContexts?.[index]),
304
+ },
305
+ ];
306
+ });
288
307
  }
289
308
 
290
309
  function terminalReplayPayloadForMode(input: {
291
310
  resultLogs: readonly string[];
311
+ resultLogContexts?: readonly (PlayLogContext | null)[];
292
312
  durableLogMode: PostgresSchedulerDurableLogMode;
293
313
  liveLogs: readonly string[];
314
+ liveLogContexts: readonly (PlayLogContext | null)[];
294
315
  liveLogsTotalCount: number;
295
316
  replayAllTerminalLogs: boolean;
296
317
  producerAttempt?: number;
297
318
  }): TerminalLogReplayPayload | null {
298
- let lines = terminalReplayLinesForMode(input);
319
+ if (input.liveLogs.length !== input.liveLogContexts.length) {
320
+ throw new TypeError('Live log contexts must align with live log lines.');
321
+ }
322
+ let entries = terminalReplayEntriesForMode(input);
299
323
  // Detached recovery is a complete attempt-local buffer. Its total count
300
324
  // gives the replay an offset of zero on that attempt's positional channel;
301
325
  // producerAttempt fences stale deliveries while the ledger absorbs only an
302
326
  // exact retransmission from that same attempt.
303
- let totalCount = lines.length;
327
+ let totalCount = entries.length;
304
328
  if (
305
329
  input.durableLogMode === 'direct_worker' &&
306
330
  !input.replayAllTerminalLogs
@@ -311,24 +335,27 @@ function terminalReplayPayloadForMode(input: {
311
335
  if (!key) continue;
312
336
  observedCounts.set(key, (observedCounts.get(key) ?? 0) + 1);
313
337
  }
314
- const boundedLines: string[] = [];
315
- for (const line of lines) {
316
- const key = line.trim().replace(CTX_LOG_TIMESTAMP_PREFIX_RE, '');
338
+ const boundedEntries: typeof entries = [];
339
+ for (const entry of entries) {
340
+ const key = entry.line.trim().replace(CTX_LOG_TIMESTAMP_PREFIX_RE, '');
317
341
  const remaining = observedCounts.get(key) ?? 0;
318
342
  if (remaining > 0) {
319
343
  observedCounts.set(key, remaining - 1);
320
344
  continue;
321
345
  }
322
- boundedLines.push(line);
346
+ boundedEntries.push(entry);
323
347
  }
324
- lines = boundedLines;
325
- totalCount = input.liveLogsTotalCount + lines.length;
348
+ entries = boundedEntries;
349
+ totalCount = input.liveLogsTotalCount + entries.length;
326
350
  }
327
- if (lines.length === 0) {
351
+ if (entries.length === 0) {
328
352
  return null;
329
353
  }
354
+ const lines = entries.map((entry) => entry.line);
355
+ const lineContexts = entries.map((entry) => entry.context);
330
356
  return {
331
357
  lines,
358
+ ...(lineContexts.some(Boolean) ? { lineContexts } : {}),
332
359
  ...(input.replayAllTerminalLogs ? { dedupeMode: 'exact' as const } : {}),
333
360
  ...(typeof input.producerAttempt === 'number'
334
361
  ? { producerAttempt: input.producerAttempt }
@@ -385,6 +412,7 @@ export function createPostgresSchedulerProgressReporter(input: {
385
412
  let liveNodeProgress: PlayVisualNodeProgressMap = {};
386
413
  let liveNodeProgressDirty = false;
387
414
  let liveLogs: string[] = [];
415
+ let liveLogContexts: Array<PlayLogContext | null> = [];
388
416
  let liveLogsTotalCount = input.initialLiveLogTotalCount ?? 0;
389
417
  let liveLogsDirty = false;
390
418
  let workCounters: RuntimeStatusUpdate['workCounters'];
@@ -461,6 +489,7 @@ export function createPostgresSchedulerProgressReporter(input: {
461
489
 
462
490
  const nextProgress = { ...liveNodeProgress };
463
491
  const nextLogs = liveLogs.slice();
492
+ const nextLogContexts = liveLogContexts.slice();
464
493
  const nextLogTotalCount = liveLogsTotalCount;
465
494
  const nextDatasetLifecycleEvents = pendingDatasetLifecycleEvents;
466
495
  pendingDatasetLifecycleEvents = [];
@@ -480,6 +509,7 @@ export function createPostgresSchedulerProgressReporter(input: {
480
509
  status: request.status,
481
510
  liveNodeProgress: nextProgress,
482
511
  liveLogs: nextLogs,
512
+ liveLogContexts: nextLogContexts,
483
513
  liveLogTotalCount: nextLogTotalCount,
484
514
  liveLogProducerAttempt: producerAttempt,
485
515
  datasetLifecycleEvents: nextDatasetLifecycleEvents,
@@ -579,15 +609,19 @@ export function createPostgresSchedulerProgressReporter(input: {
579
609
  void flush({ force }).catch(() => undefined);
580
610
  };
581
611
 
582
- const appendLiveLog = (line: string) => {
612
+ const appendLiveLog = (line: string, context?: unknown) => {
583
613
  const trimmed = line.trim();
584
614
  if (!trimmed) {
585
615
  return;
586
616
  }
587
617
  liveLogsTotalCount += 1;
588
618
  liveLogs = [...liveLogs, trimmed];
619
+ liveLogContexts = [...liveLogContexts, normalizePlayLogContext(context)];
589
620
  if (liveLogs.length > LIVE_LOG_TAIL_LIMIT) {
590
621
  liveLogs = liveLogs.slice(liveLogs.length - LIVE_LOG_TAIL_LIMIT);
622
+ liveLogContexts = liveLogContexts.slice(
623
+ liveLogContexts.length - LIVE_LOG_TAIL_LIMIT,
624
+ );
591
625
  }
592
626
  liveLogsDirty = true;
593
627
  };
@@ -1138,13 +1172,17 @@ export function createPostgresSchedulerProgressReporter(input: {
1138
1172
  return;
1139
1173
  }
1140
1174
  if (type === 'log') {
1141
- const logEvent = event as { line?: unknown; source?: unknown };
1175
+ const logEvent = event as {
1176
+ line?: unknown;
1177
+ source?: unknown;
1178
+ context?: unknown;
1179
+ };
1142
1180
  const rawLine = logEvent.line;
1143
1181
  if (typeof rawLine !== 'string' || !rawLine) {
1144
1182
  return;
1145
1183
  }
1146
1184
  if (shouldPublishDurableLogEvent(durableLogMode, logEvent)) {
1147
- appendLiveLog(rawLine);
1185
+ appendLiveLog(rawLine, logEvent.context);
1148
1186
  }
1149
1187
  markMapStartedFromLog(rawLine);
1150
1188
  markMapStartedFromPerfLog(rawLine);
@@ -1423,8 +1461,10 @@ export function createPostgresSchedulerProgressReporter(input: {
1423
1461
  ? null
1424
1462
  : terminalReplayPayloadForMode({
1425
1463
  resultLogs: result.logs,
1464
+ resultLogContexts: result.logContexts,
1426
1465
  durableLogMode,
1427
1466
  liveLogs,
1467
+ liveLogContexts,
1428
1468
  liveLogsTotalCount,
1429
1469
  replayAllTerminalLogs: options.replayAllTerminalLogs === true,
1430
1470
  producerAttempt:
@@ -1502,6 +1542,7 @@ export async function collectGatewayRunnerTerminalProgressLedgerEvents(input: {
1502
1542
  lastCheckpointAt: finalUpdate.lastCheckpointAt,
1503
1543
  liveNodeProgress: finalUpdate.liveNodeProgress,
1504
1544
  liveLogs,
1545
+ liveLogContexts: finalUpdate.liveLogContexts,
1505
1546
  liveLogsChannelOffset: Math.max(0, liveLogTotalCount - liveLogs.length),
1506
1547
  liveLogsProducerAttempt:
1507
1548
  finalUpdate.liveLogProducerAttempt ?? input.attempt,