deepline 0.3.302 → 0.3.304

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 (100) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +31 -1
  3. package/dist/bundling-sources/shared_libs/play-runtime/execute-server-timing.ts +30 -0
  4. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +144 -1
  5. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +1 -0
  6. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +82 -0
  7. package/dist/bundling-sources/shared_libs/plays/tool-response-contract.ts +25 -0
  8. package/dist/cli/auth-UBWZC26A.js +31 -0
  9. package/dist/cli/{auth-WHKDFARX.mjs → auth-YKJHKHIQ.mjs} +4 -4
  10. package/dist/cli/{billing-IMFI76GS.js → billing-EOIKAZES.js} +71 -71
  11. package/dist/cli/{billing-7C66HEMK.mjs → billing-XEEW5SV2.mjs} +5 -5
  12. package/dist/cli/{chunk-AIIVF62D.mjs → chunk-35SCWK4Y.mjs} +1 -1
  13. package/dist/cli/{chunk-JCS5TPNY.mjs → chunk-4NIQA6S7.mjs} +1 -1
  14. package/dist/cli/{chunk-2TCHWWRP.mjs → chunk-7HYH533G.mjs} +1 -1
  15. package/dist/cli/{chunk-OTAGK5MS.js → chunk-7NQJDQPH.js} +48 -48
  16. package/dist/cli/{chunk-A4UUUINX.mjs → chunk-7OXXCRGZ.mjs} +1 -1
  17. package/dist/cli/{chunk-GHYU5YWJ.mjs → chunk-7QV545D7.mjs} +1 -1
  18. package/dist/cli/{chunk-DTGPHQFC.mjs → chunk-AOUGAM72.mjs} +2 -2
  19. package/dist/cli/{chunk-NRIVXKMQ.js → chunk-BBXO7APG.js} +6 -6
  20. package/dist/cli/{chunk-KEPIGAJS.js → chunk-DNBJRKVE.js} +57 -57
  21. package/dist/cli/{chunk-AAZBNN6N.js → chunk-DOCDA2YP.js} +4 -4
  22. package/dist/cli/{chunk-5FKCLTLS.js → chunk-FDEU7UY7.js} +11 -11
  23. package/dist/cli/{chunk-V4WVYW3G.mjs → chunk-IHT6XITB.mjs} +2 -2
  24. package/dist/cli/{chunk-KI5DPDF2.js → chunk-INOSSTSG.js} +15 -15
  25. package/dist/cli/{chunk-TVBPWUII.mjs → chunk-JKY2QANB.mjs} +4 -4
  26. package/dist/cli/{chunk-S6XS2ABF.mjs → chunk-JZWC4ES6.mjs} +2 -2
  27. package/dist/cli/{chunk-OUREAAOT.js → chunk-KP5TOAI4.js} +6 -6
  28. package/dist/cli/{chunk-7AXKBZWF.js → chunk-NC4JXVVS.js} +2 -2
  29. package/dist/cli/{chunk-J2PPXZE4.js → chunk-NJS3RHQO.js} +6 -6
  30. package/dist/cli/{chunk-PZOHVTQ3.mjs → chunk-NW7I3LDU.mjs} +3 -3
  31. package/dist/cli/{chunk-YLVIJZ2W.mjs → chunk-TABL2Q6H.mjs} +2 -2
  32. package/dist/cli/{chunk-JX3CNS4W.js → chunk-USJBSNRI.js} +26 -26
  33. package/dist/cli/{chunk-GONRLVV3.js → chunk-W7INSYJS.js} +9 -9
  34. package/dist/cli/{chunk-GWIY7C7U.mjs → chunk-YJ2QYYB5.mjs} +1 -1
  35. package/dist/cli/{chunk-GXYR7DV4.js → chunk-ZQSQCHG3.js} +1 -1
  36. package/dist/cli/{client-M7OBRULN.mjs → client-FZPHVNWV.mjs} +4 -4
  37. package/dist/cli/client-IMFLPCD7.js +20 -0
  38. package/dist/cli/{csv-SAJB2PYV.js → csv-ANJ4KSHF.js} +12 -12
  39. package/dist/cli/{csv-AKVUO3PP.mjs → csv-CCHVZPRD.mjs} +3 -3
  40. package/dist/cli/{db-AASVDGJB.js → db-AE3MLMRF.js} +21 -21
  41. package/dist/cli/{db-KREGQID3.mjs → db-JFVR6STL.mjs} +5 -5
  42. package/dist/cli/{executions-XSKRZWVG.js → executions-DGX53UEW.js} +7 -7
  43. package/dist/cli/{executions-YL5UM6BY.mjs → executions-WNXCURLN.mjs} +5 -5
  44. package/dist/cli/{feedback-XZNAGHZ4.js → feedback-DGEFG6JI.js} +6 -6
  45. package/dist/cli/{feedback-ITNK5A5V.mjs → feedback-L4A66OA2.mjs} +3 -3
  46. package/dist/cli/git-6QWUB6CR.js +23 -0
  47. package/dist/cli/{git-IXYZ5H7T.mjs → git-LIZ3FGVR.mjs} +4 -4
  48. package/dist/cli/index.d.mts +1 -6
  49. package/dist/cli/index.d.ts +1 -6
  50. package/dist/cli/index.js +100 -87
  51. package/dist/cli/index.mjs +54 -41
  52. package/dist/cli/{legacy-noops-BJZ3P455.js → legacy-noops-L7GGGAOR.js} +7 -7
  53. package/dist/cli/{legacy-noops-MT5VFDXS.mjs → legacy-noops-UCKGOSJA.mjs} +4 -4
  54. package/dist/cli/{monitors-XU62FCBX.js → monitors-NGACMMWV.js} +86 -86
  55. package/dist/cli/{monitors-QL4XDOQT.mjs → monitors-NLMFDD4C.mjs} +5 -5
  56. package/dist/cli/{org-NKFPS763.mjs → org-2OW6TPHF.mjs} +5 -5
  57. package/dist/cli/{org-6WSIPHVV.js → org-FJSCZ6S3.js} +61 -61
  58. package/dist/cli/{play-RZO7CZKL.js → play-GJC4AIAX.js} +229 -227
  59. package/dist/cli/{play-CKL7RDIS.mjs → play-ZZ4AQLL5.mjs} +21 -19
  60. package/dist/cli/{providers-UKNXDCPJ.mjs → providers-6BJNJUSG.mjs} +5 -5
  61. package/dist/cli/{providers-PQPH374E.js → providers-D7KLXB4S.js} +8 -8
  62. package/dist/cli/{proxy-env-M4ZHXHRL.mjs → proxy-env-NWUIGWS3.mjs} +34 -17
  63. package/dist/cli/{proxy-env-EBANZHPV.js → proxy-env-ZV2WZFAT.js} +37 -20
  64. package/dist/cli/{quickstart-3FFTESEL.js → quickstart-6WYRYZJZ.js} +5 -5
  65. package/dist/cli/{quickstart-JUTTMWIC.mjs → quickstart-FH4NGHEJ.mjs} +3 -3
  66. package/dist/cli/search-KOSJMN3U.js +18 -0
  67. package/dist/cli/{search-WGBQ5LE5.mjs → search-SUT5XFI6.mjs} +6 -6
  68. package/dist/cli/{secrets-EV6IOJLN.mjs → secrets-QK5QP4YU.mjs} +5 -5
  69. package/dist/cli/{secrets-GGQRCGLA.js → secrets-Y2OI2P7O.js} +14 -14
  70. package/dist/cli/{sessions-VZJ23U7E.js → sessions-MLDROWXY.js} +5 -5
  71. package/dist/cli/{sessions-HL3Q22O5.mjs → sessions-VQKZHOQJ.mjs} +4 -4
  72. package/dist/cli/{settings-LJB5VZWM.js → settings-6WOSPHBC.js} +75 -75
  73. package/dist/cli/{settings-M5MSM7U6.mjs → settings-SPUINZYG.mjs} +8 -8
  74. package/dist/cli/{setup-ASOUDNYM.js → setup-E2UJV6PW.js} +41 -41
  75. package/dist/cli/{setup-ZURYYFBI.mjs → setup-ZE2SDMC4.mjs} +6 -6
  76. package/dist/cli/skills-J3QIHO5L.js +28 -0
  77. package/dist/cli/{skills-4SRVGVA6.mjs → skills-OJYRPY2N.mjs} +4 -4
  78. package/dist/cli/{tools-UNDZCH7R.js → tools-BNHRVKLA.js} +51 -51
  79. package/dist/cli/{tools-UEFB5OPX.mjs → tools-O6EIDEKW.mjs} +6 -6
  80. package/dist/cli/{update-WUIQXM5B.mjs → update-NWESWMYF.mjs} +6 -6
  81. package/dist/cli/update-TDOIF3C4.js +28 -0
  82. package/dist/cli/{workflow-FUXRNNWD.js → workflow-SAJAOPYE.js} +16 -16
  83. package/dist/cli/{workflow-BCXLF24Z.mjs → workflow-YJHXDD57.mjs} +6 -6
  84. package/dist/index.js +7 -7
  85. package/dist/index.mjs +4 -4
  86. package/dist/install-integrity.json +74 -74
  87. package/dist/plays/bundle-play-file.mjs +2 -2
  88. package/dist/release.d.mts +1 -1
  89. package/dist/release.d.ts +1 -1
  90. package/dist/release.js +2 -2
  91. package/dist/release.mjs +1 -1
  92. package/package.json +1 -1
  93. package/dist/cli/auth-ZJDK7HFJ.js +0 -31
  94. package/dist/cli/client-FVPE6PB4.js +0 -20
  95. package/dist/cli/git-IOUJDZDJ.js +0 -23
  96. package/dist/cli/search-TKLHBKKK.js +0 -18
  97. package/dist/cli/skills-KMGB73LN.js +0 -28
  98. package/dist/cli/update-4AZ7S666.js +0 -28
  99. /package/dist/cli/{chunk-GVUJJJ5G.mjs → chunk-6IKARAYD.mjs} +0 -0
  100. /package/dist/cli/{chunk-6A3TJUWC.js → chunk-S6R3OX7B.js} +0 -0
@@ -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.302',
203
+ version: '0.3.304',
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: {
@@ -2452,7 +2452,9 @@ export async function projectRunEventsViaAppRuntime(
2452
2452
  const batches = partitionRunEventsForAppRuntime(input.events);
2453
2453
  const receiptBatch = runLedgerReceiptBatchIndex(batches);
2454
2454
  for (const [index, events] of batches.entries()) {
2455
+ const beforeBatchStartedAt = Date.now();
2455
2456
  await input.beforeBatch();
2457
+ const beforeBatchMs = Math.max(0, Date.now() - beforeBatchStartedAt);
2456
2458
  // Retain the original receipt for the terminal (or final) piece so an acknowledged
2457
2459
  // legacy delivery stays acknowledged across the reader rollout.
2458
2460
  const idempotencyKey =
@@ -2476,7 +2478,16 @@ export async function projectRunEventsViaAppRuntime(
2476
2478
  };
2477
2479
  // The durable outbox owns recovery; this helper does not retry OCCs or
2478
2480
  // other delivery failures inside an already-leased invocation.
2479
- const deliveryContext = { ...context, retryPolicy: 'none' as const };
2481
+ let responseMeta: RuntimeApiResponseMeta | null = null;
2482
+ const deliveryContext = {
2483
+ ...context,
2484
+ retryPolicy: 'none' as const,
2485
+ onResponseMeta(meta: RuntimeApiResponseMeta) {
2486
+ context.onResponseMeta?.(meta);
2487
+ if (meta.action === 'project_run_events') responseMeta = meta;
2488
+ },
2489
+ };
2490
+ const requestStartedAt = Date.now();
2480
2491
  try {
2481
2492
  await postAppRuntimeApi(deliveryContext, {
2482
2493
  action: 'project_run_events',
@@ -2501,6 +2512,25 @@ export async function projectRunEventsViaAppRuntime(
2501
2512
  ...request,
2502
2513
  });
2503
2514
  }
2515
+ const requestWallMs = Math.max(0, Date.now() - requestStartedAt);
2516
+ if (beforeBatchMs >= 500 || requestWallMs >= 500) {
2517
+ const observedResponse = responseMeta as RuntimeApiResponseMeta | null;
2518
+ console.info('[run-ledger-outbox.project_transport_slow]', {
2519
+ runId: input.playId,
2520
+ eventCount: events.length,
2521
+ batchIndex: index,
2522
+ batchCount: batches.length,
2523
+ beforeBatchMs,
2524
+ requestWallMs,
2525
+ roundTripMs: observedResponse?.roundTripMs ?? null,
2526
+ requestId: observedResponse?.requestId ?? null,
2527
+ requestBodyRawBytes: observedResponse?.requestBodyRawBytes ?? null,
2528
+ requestBodyWireBytes: observedResponse?.requestBodyWireBytes ?? null,
2529
+ requestBodySerializeMs:
2530
+ observedResponse?.requestBodySerializeMs ?? null,
2531
+ requestBodyPackMs: observedResponse?.requestBodyPackMs ?? null,
2532
+ });
2533
+ }
2504
2534
  }
2505
2535
  }
2506
2536
 
@@ -33,6 +33,36 @@ export const EXECUTE_SERVER_TIMING_STAGES = [
33
33
  'execute',
34
34
  'identity',
35
35
  'usage_schedule',
36
+ // Managed AI inference slices: `ai_prepare` includes request preparation and
37
+ // contains `ai_billing_authorize`; `ai_provider_work_start` is the durable
38
+ // pre-call transition; `ai_gateway_first_output` is the time to the first
39
+ // model-output part (excluding SDK control chunks); and
40
+ // `ai_gateway_stream_wall` is the end-to-end SDK stream
41
+ // collection wall. Stream wall includes awaited finish callbacks, so evidence
42
+ // persistence and settlement overlap it. First-output and stream wall both
43
+ // include Gateway/network/upstream time; neither claims provider-internal
44
+ // model time.
45
+ 'ai_prepare',
46
+ 'ai_billing_authorize',
47
+ 'ai_provider_work_start',
48
+ 'ai_gateway_first_output',
49
+ 'ai_gateway_stream_wall',
50
+ 'ai_generation_evidence_persist',
51
+ 'ai_billing_settlement',
52
+ 'ai_output_canonicalization',
53
+ 'ai_result_persist',
54
+ // Provider HTTP slices are only nonzero for calls that take this path:
55
+ // admission; `provider_fetch_headers` until response headers arrive (or
56
+ // `provider_fetch_error_wait` for a rejected fetch); retry backoff; body
57
+ // read, JSON parse, result transform and output normalization are separate.
58
+ 'provider_admission',
59
+ 'provider_fetch_headers',
60
+ 'provider_fetch_error_wait',
61
+ 'provider_retry_wait',
62
+ 'provider_body_read',
63
+ 'provider_json_parse',
64
+ 'provider_result_transform',
65
+ 'provider_output_normalization',
36
66
  'total',
37
67
  // The execution gateway preserves these disjoint stages beside the app
38
68
  // handler's stages. They are deliberately part of this small, additive
@@ -12,7 +12,10 @@ import type {
12
12
  ProviderConcurrencyGrant,
13
13
  ProviderPacingGrant,
14
14
  } from './governor/rate-state-backend';
15
- import type { ExecuteServerTiming } from './execute-server-timing';
15
+ import type {
16
+ ExecuteServerTiming,
17
+ ExecuteServerTimingStage,
18
+ } from './execute-server-timing';
16
19
 
17
20
  export type RuntimeResourceLease = WorkLease;
18
21
  export type RuntimeProviderPermit = ProviderPermit;
@@ -511,6 +514,29 @@ export type RuntimePhaseTiming = {
511
514
  ewmaMs: number | null;
512
515
  };
513
516
 
517
+ const AI_INFERENCE_EXECUTE_STAGES = [
518
+ 'ai_prepare',
519
+ 'ai_billing_authorize',
520
+ 'ai_provider_work_start',
521
+ 'ai_gateway_first_output',
522
+ 'ai_gateway_stream_wall',
523
+ 'ai_generation_evidence_persist',
524
+ 'ai_billing_settlement',
525
+ 'ai_output_canonicalization',
526
+ 'ai_result_persist',
527
+ ] as const satisfies readonly ExecuteServerTimingStage[];
528
+
529
+ const PROVIDER_HTTP_EXECUTE_STAGES = [
530
+ 'provider_admission',
531
+ 'provider_fetch_headers',
532
+ 'provider_fetch_error_wait',
533
+ 'provider_retry_wait',
534
+ 'provider_body_read',
535
+ 'provider_json_parse',
536
+ 'provider_result_transform',
537
+ 'provider_output_normalization',
538
+ ] as const satisfies readonly ExecuteServerTimingStage[];
539
+
514
540
  /**
515
541
  * Selected execute-route stages for the same population as `fetchToHeaders`.
516
542
  * These are nested because they partition handler work inside that wall; they
@@ -523,6 +549,26 @@ export type RuntimeExecuteRouteTiming = {
523
549
  chargeOpenMs: number;
524
550
  fixtureLoadMs: number;
525
551
  executeMs: number;
552
+ /**
553
+ * Managed `ai_inference` stages, accumulated independently because each can
554
+ * observe a different request population. `count` is the number of requests
555
+ * with a non-zero `ai_prepare` marker. Stage counters include positive
556
+ * durations only: the header serializes milliseconds to three decimal
557
+ * places, so an absent stage cannot be distinguished from a duration
558
+ * rounded to zero. These slices overlap; in particular stream wall contains
559
+ * awaited evidence persistence and billing settlement.
560
+ */
561
+ aiInference?: RuntimeExecuteStageGroup<
562
+ (typeof AI_INFERENCE_EXECUTE_STAGES)[number]
563
+ >;
564
+ /**
565
+ * Deepline-owned HTTP provider stages. `count` is the number of requests
566
+ * with a non-zero provider-admission marker; each stage retains its own
567
+ * positive-duration denominator for rolling-build compatibility.
568
+ */
569
+ providerHttp?: RuntimeExecuteStageGroup<
570
+ (typeof PROVIDER_HTTP_EXECUTE_STAGES)[number]
571
+ >;
526
572
  /**
527
573
  * Where `chargeOpenMs` went, nested rather than summed: these are disjoint
528
574
  * slices of it, never independent phases. Present only when the deployed app
@@ -557,6 +603,18 @@ export type RuntimeExecuteRouteTiming = {
557
603
  };
558
604
  };
559
605
 
606
+ /** Fixed-size run summary for one execute-route stage. */
607
+ export type RuntimeExecuteStageTiming = {
608
+ count: number;
609
+ totalMs: number;
610
+ maxMs: number | null;
611
+ };
612
+
613
+ /** A fixed set of named execute stages with one run-level request count. */
614
+ export type RuntimeExecuteStageGroup<Stage extends ExecuteServerTimingStage> = {
615
+ count: number;
616
+ } & Record<Stage, RuntimeExecuteStageTiming>;
617
+
560
618
  /**
561
619
  * A compact, unitless sample aggregate. Provider permits use it for bucket
562
620
  * occupancy at admission, rather than mislabelling an in-flight count as ms.
@@ -854,6 +912,71 @@ function createPhaseTiming(): {
854
912
  };
855
913
  }
856
914
 
915
+ function createExecuteStageAccumulator(): {
916
+ observe(value: number): void;
917
+ snapshot(): RuntimeExecuteStageTiming;
918
+ } {
919
+ let count = 0;
920
+ let totalMs = 0;
921
+ let maxMs: number | null = null;
922
+ return {
923
+ observe(value) {
924
+ count += 1;
925
+ totalMs += value;
926
+ maxMs = maxMs === null ? value : Math.max(maxMs, value);
927
+ },
928
+ snapshot() {
929
+ return { count, totalMs, maxMs };
930
+ },
931
+ };
932
+ }
933
+
934
+ function createExecuteStageGroup<
935
+ const Stages extends readonly ExecuteServerTimingStage[],
936
+ >(stages: Stages) {
937
+ type Stage = Stages[number];
938
+ // Keep the tuple's element type explicit through iteration. TypeScript can
939
+ // widen a generic readonly tuple to the full timing-stage union in loops,
940
+ // even though every value here came from this group's stage list.
941
+ const stageNames = stages as readonly Stage[];
942
+ const metrics = Object.fromEntries(
943
+ stageNames.map((stage) => [stage, createExecuteStageAccumulator()]),
944
+ ) as Record<Stage, ReturnType<typeof createExecuteStageAccumulator>>;
945
+ let count = 0;
946
+ return {
947
+ get count() {
948
+ return count;
949
+ },
950
+ observe(markerMs: number | null, timing: ExecuteServerTiming) {
951
+ // The execute header renders absent stages as zero, so zero cannot be
952
+ // attributed to an observed stage with confidence. The positive marker
953
+ // selects calls in this group; stage populations remain explicit.
954
+ if (markerMs === null || !Number.isFinite(markerMs) || markerMs <= 0) {
955
+ return;
956
+ }
957
+ count += 1;
958
+ for (const stage of stageNames) {
959
+ const durationMs = timing[stage];
960
+ if (
961
+ durationMs !== null &&
962
+ Number.isFinite(durationMs) &&
963
+ durationMs > 0
964
+ ) {
965
+ metrics[stage].observe(durationMs);
966
+ }
967
+ }
968
+ },
969
+ snapshot(): RuntimeExecuteStageGroup<Stage> {
970
+ return {
971
+ count,
972
+ ...Object.fromEntries(
973
+ stageNames.map((stage) => [stage, metrics[stage].snapshot()]),
974
+ ),
975
+ } as RuntimeExecuteStageGroup<Stage>;
976
+ },
977
+ };
978
+ }
979
+
857
980
  function createSampleTiming(): {
858
981
  observe(value: number | null | undefined): void;
859
982
  snapshot(): RuntimeSampleTiming;
@@ -979,6 +1102,12 @@ export function createRuntimeResourceGovernor(input: {
979
1102
  fixtureLoadMs: 0,
980
1103
  executeMs: 0,
981
1104
  };
1105
+ const executeAiInference = createExecuteStageGroup(
1106
+ AI_INFERENCE_EXECUTE_STAGES,
1107
+ );
1108
+ const executeProviderHttp = createExecuteStageGroup(
1109
+ PROVIDER_HTTP_EXECUTE_STAGES,
1110
+ );
982
1111
  const executeChargeOpen = {
983
1112
  count: 0,
984
1113
  eligibilityMs: 0,
@@ -1288,6 +1417,14 @@ export function createRuntimeResourceGovernor(input: {
1288
1417
  executeRoute.chargeOpenMs += executeRouteTiming.charge_open;
1289
1418
  executeRoute.fixtureLoadMs += executeRouteTiming.fixture_load;
1290
1419
  executeRoute.executeMs += executeRouteTiming.execute;
1420
+ executeAiInference.observe(
1421
+ executeRouteTiming.ai_prepare,
1422
+ executeRouteTiming,
1423
+ );
1424
+ executeProviderHttp.observe(
1425
+ executeRouteTiming.provider_admission,
1426
+ executeRouteTiming,
1427
+ );
1291
1428
  // Same rule as the gateway block below: require the complete substage
1292
1429
  // set this app version emits, so an older build that reports only
1293
1430
  // `charge_open` does not silently contribute a partial split.
@@ -1734,6 +1871,12 @@ export function createRuntimeResourceGovernor(input: {
1734
1871
  ? {
1735
1872
  executeRoute: {
1736
1873
  ...executeRoute,
1874
+ ...(executeAiInference.count > 0
1875
+ ? { aiInference: executeAiInference.snapshot() }
1876
+ : {}),
1877
+ ...(executeProviderHttp.count > 0
1878
+ ? { providerHttp: executeProviderHttp.snapshot() }
1879
+ : {}),
1737
1880
  ...(executeChargeOpen.count > 0
1738
1881
  ? { chargeOpen: { ...executeChargeOpen } }
1739
1882
  : {}),
@@ -20733,6 +20733,7 @@ async function dispatchRunLedgerOutboxBatchWithScope(
20733
20733
  eventIds: events.map((event) => event.eventId),
20734
20734
  error: error instanceof Error ? error.message : String(error),
20735
20735
  code: failure.code,
20736
+ responseStatus: failure.status,
20736
20737
  failureReason: failure.failureReason,
20737
20738
  ...(failure.projectionMismatch
20738
20739
  ? { projectionMismatch: failure.projectionMismatch }
@@ -1032,6 +1032,88 @@ export async function setRuntimeEventDeferredProjection(
1032
1032
  }
1033
1033
  }
1034
1034
 
1035
+ export type RuntimeEventProjectionModes = {
1036
+ runtimeScope: string;
1037
+ deferred: boolean | null;
1038
+ independent: boolean | null;
1039
+ unavailableReason:
1040
+ | 'projection_mode_readers_missing'
1041
+ | 'deferred_projection_reader_missing'
1042
+ | 'independent_projection_reader_missing'
1043
+ | null;
1044
+ };
1045
+
1046
+ /** Read installed operator modes without scanning or changing the outbox. */
1047
+ export async function readRuntimeEventProjectionModes(
1048
+ client: PostgresSchedulerQueryClient,
1049
+ runtimeScope: string,
1050
+ ): Promise<RuntimeEventProjectionModes> {
1051
+ const scope = requiredScope(runtimeScope);
1052
+ const schema = quoteIdent(scope);
1053
+ const installed = await client.query<{
1054
+ deferred_installed: boolean;
1055
+ independent_installed: boolean;
1056
+ }>(
1057
+ `SELECT to_regprocedure($1) IS NOT NULL AS deferred_installed,
1058
+ to_regprocedure($2) IS NOT NULL AS independent_installed`,
1059
+ [
1060
+ `${schema}.defer_runtime_event_projection()`,
1061
+ `${schema}.independent_runtime_event_projection()`,
1062
+ ],
1063
+ );
1064
+ const readers = installed.rows[0];
1065
+ if (
1066
+ !readers ||
1067
+ typeof readers.deferred_installed !== 'boolean' ||
1068
+ typeof readers.independent_installed !== 'boolean'
1069
+ ) {
1070
+ throw new Error('Runtime projection mode lookup returned no reader state.');
1071
+ }
1072
+ const unavailableReason = readers.deferred_installed
1073
+ ? readers.independent_installed
1074
+ ? null
1075
+ : 'independent_projection_reader_missing'
1076
+ : readers.independent_installed
1077
+ ? 'deferred_projection_reader_missing'
1078
+ : 'projection_mode_readers_missing';
1079
+ if (!readers.deferred_installed && !readers.independent_installed) {
1080
+ return {
1081
+ runtimeScope: scope,
1082
+ deferred: null,
1083
+ independent: null,
1084
+ unavailableReason,
1085
+ };
1086
+ }
1087
+ // An absent function cannot appear in the SQL, even in an unselected CASE.
1088
+ const deferredExpression = readers.deferred_installed
1089
+ ? `${schema}.defer_runtime_event_projection()`
1090
+ : 'NULL::boolean';
1091
+ const independentExpression = readers.independent_installed
1092
+ ? `${schema}.independent_runtime_event_projection()`
1093
+ : 'NULL::boolean';
1094
+ const result = await client.query<{
1095
+ deferred: boolean | null;
1096
+ independent: boolean | null;
1097
+ }>(
1098
+ `SELECT ${deferredExpression} AS deferred,
1099
+ ${independentExpression} AS independent`,
1100
+ );
1101
+ const modes = result.rows[0];
1102
+ if (
1103
+ !modes ||
1104
+ (readers.deferred_installed && typeof modes.deferred !== 'boolean') ||
1105
+ (readers.independent_installed && typeof modes.independent !== 'boolean')
1106
+ ) {
1107
+ throw new Error('Runtime projection mode lookup returned invalid values.');
1108
+ }
1109
+ return {
1110
+ runtimeScope: scope,
1111
+ deferred: modes.deferred,
1112
+ independent: modes.independent,
1113
+ unavailableReason,
1114
+ };
1115
+ }
1116
+
1035
1117
  /** Operator state uses the same durable pending set as the outbox projector. */
1036
1118
  export async function inspectRuntimeEventProjection(
1037
1119
  client: PostgresSchedulerQueryClient,
@@ -23,6 +23,31 @@ export type ToolResponseContract =
23
23
 
24
24
  export type ToolResponseView = 'data' | 'rawV2';
25
25
 
26
+ /** Authoring guidance shared by provider descriptions and the public CLI. */
27
+ export const TOOL_RESPONSE_AUTHORING_GUIDANCE = {
28
+ prefer: [
29
+ 'Use toolExecutionResult.extractedLists.<name>.get() only for declared extracted lists listed below.',
30
+ 'Use toolExecutionResult.extractedValues.<name>.get() only for declared extracted values listed below. Values may be scalars or normalized objects such as EmailStatus; inspect each entry details.strategy and details.valueType.',
31
+ 'Use toolExecutionResult.toolResponse.rawV2 for provider/tool-specific scalar fields, fields in outputSchema that are not declared extracted values, and debugging. Inspect the observed response envelope before selecting nested fields. For declared row/list outputs, use extractedLists.<name>.get().',
32
+ 'toolResponse.rawV2 is the complete parsed and scrubbed provider response, including JSON:API included resources, cursors, links, and totals. It is not the original HTTP bytes or headers.',
33
+ ],
34
+ rawMeaning:
35
+ 'Complete parsed and scrubbed provider response for provider/tool-specific scalar fields and debugging. Inspect its envelope before selecting nested fields. Declared row/list outputs should use extractedLists.<name>.get().',
36
+ invalidGetterHint:
37
+ 'If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter; inspect toolResponse.rawV2 for provider/tool-specific scalar fields, and use extractedLists.<name>.get() for declared row/list outputs.',
38
+ responseShape: {
39
+ canonicalResponse: 'toolResponse.rawV2',
40
+ nesting:
41
+ 'rawV2 preserves the provider/tool adapter envelope. The payload may be at rawV2, rawV2.data, or rawV2.data.data; there is no universal unwrap depth. view: "data" does not flatten rawV2. Prefer declared getters; otherwise inspect the retained response from the same execution surface and assert the exact field path before bulk execution.',
42
+ outputSchema:
43
+ 'outputSchema describes the declared normalized tool output, not an observed rawV2 envelope. Do not derive a rawV2 field path from it.',
44
+ extractorPaths:
45
+ 'details.rawToolOutputPaths records compatibility extractor provenance, not copyable rawV2 paths. Use the getter expression; do not mechanically replace raw with rawV2.',
46
+ missingFields:
47
+ 'An absent expected field is an extraction contract mismatch, not proof of a provider miss or invalid email. Keep legitimate no-result responses distinct from unexpected shapes.',
48
+ },
49
+ } as const;
50
+
26
51
  export function isToolResponseContract(
27
52
  value: unknown,
28
53
  ): value is ToolResponseContract {
@@ -0,0 +1,31 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ var _chunk7NQJDQPHjs = require('./chunk-7NQJDQPH.js');
13
+ require('./chunk-BBXO7APG.js');
14
+ require('./chunk-DOCDA2YP.js');
15
+ require('./chunk-XNYIZMNQ.js');
16
+ require('./chunk-ZQSQCHG3.js');
17
+ require('./chunk-7P5AA3SN.js');
18
+ require('./chunk-OG64RBAC.js');
19
+ require('./chunk-COGTRVWW.js');
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ exports.EXIT_WORKSPACE_MISMATCH = _chunk7NQJDQPHjs.EXIT_WORKSPACE_MISMATCH; exports.clearPendingClaim = _chunk7NQJDQPHjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunk7NQJDQPHjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunk7NQJDQPHjs.handleRegister; exports.handleStatus = _chunk7NQJDQPHjs.handleStatus; exports.handleWait = _chunk7NQJDQPHjs.handleWait; exports.readPendingAuthClaim = _chunk7NQJDQPHjs.readPendingAuthClaim; exports.registerAuthCommands = _chunk7NQJDQPHjs.registerAuthCommands; exports.reportSetupCompleted = _chunk7NQJDQPHjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunk7NQJDQPHjs.resolvePendingAuthClaimForResume;
@@ -9,11 +9,11 @@ import {
9
9
  registerAuthCommands,
10
10
  reportSetupCompleted,
11
11
  resolvePendingAuthClaimForResume
12
- } from "./chunk-V4WVYW3G.mjs";
13
- import "./chunk-AIIVF62D.mjs";
14
- import "./chunk-GHYU5YWJ.mjs";
12
+ } from "./chunk-IHT6XITB.mjs";
13
+ import "./chunk-35SCWK4Y.mjs";
14
+ import "./chunk-7QV545D7.mjs";
15
15
  import "./chunk-DLIRSHV6.mjs";
16
- import "./chunk-A4UUUINX.mjs";
16
+ import "./chunk-7OXXCRGZ.mjs";
17
17
  import "./chunk-NXGCO4JB.mjs";
18
18
  import "./chunk-WZYKRD7T.mjs";
19
19
  import "./chunk-KRD6H754.mjs";