deepline 0.3.128 → 0.3.129

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 (128) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +34 -9
  2. package/dist/bundling-sources/sdk/src/http.ts +22 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +22 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +265 -2
  6. package/dist/bundling-sources/shared_libs/play-runtime/bounded-batch-function.ts +682 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/child-execution-strategy.ts +21 -5
  8. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +5390 -1732
  9. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +107 -1
  10. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +7 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +229 -7
  12. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +25 -4
  13. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-capacity.ts +71 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-drain.ts +1 -1
  15. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +4 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +694 -28
  17. package/dist/bundling-sources/shared_libs/play-runtime/egress-bandwidth-probe.ts +167 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/execute-server-timing.ts +103 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-receipt-output-reference.ts +34 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-response-size.ts +27 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/gateway-postgres-admission.ts +66 -1
  22. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +425 -71
  23. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +210 -32
  24. package/dist/bundling-sources/shared_libs/play-runtime/governor/in-memory-rate-state-backend.ts +27 -13
  25. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +19 -6
  26. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +61 -2
  27. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/contracts.ts +33 -1
  28. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/job.ts +42 -1
  29. package/dist/bundling-sources/shared_libs/play-runtime/launch-source-policy.ts +11 -11
  30. package/dist/bundling-sources/shared_libs/play-runtime/ledger-safe-payload.ts +49 -16
  31. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +1653 -98
  32. package/dist/bundling-sources/shared_libs/play-runtime/memory-ledger.ts +807 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/memory-pressure-signal.ts +138 -0
  34. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +85 -3
  35. package/dist/bundling-sources/shared_libs/play-runtime/persistence-latch.ts +60 -2
  36. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +46 -1
  37. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/contracts.ts +2 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/job.ts +1 -0
  39. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/ports.ts +1 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +1 -0
  41. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +70 -27
  42. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +56 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/adaptive-provider-capacity-controller.ts +192 -0
  44. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/epoch-aimd-rate-controller.ts +194 -0
  45. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/fixture-capacity-simulator.ts +220 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/gradient2-concurrency-controller.ts +214 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-capacity-policy.ts +43 -0
  48. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-concurrency-policy.ts +30 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-rate-policy.ts +95 -0
  50. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-throttle-classifier.ts +40 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +1535 -11
  52. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +49 -2
  53. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +6 -1
  54. package/dist/bundling-sources/shared_libs/play-runtime/run-log-buffer.ts +55 -0
  55. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/egress-probe.ts +221 -0
  56. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +339 -29
  57. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-deadline.ts +28 -1
  58. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +192 -165
  59. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +6 -0
  60. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +90 -5
  61. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +281 -6
  62. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +27 -1
  63. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +19 -0
  64. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +108 -0
  65. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +40 -0
  66. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +11 -5
  67. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +30 -0
  68. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +276 -0
  69. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +723 -115
  70. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +98 -2
  71. package/dist/bundling-sources/shared_libs/play-runtime/runtime-contract.ts +3 -2
  72. package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +41 -4
  73. package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +448 -0
  74. package/dist/bundling-sources/shared_libs/play-runtime/runtime-map-row-feed.ts +215 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +11 -0
  76. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +161 -14
  77. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-value.ts +184 -0
  78. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +607 -121
  79. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-placement-policy.ts +4 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-writer.ts +21 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +15 -2
  82. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +71 -14
  83. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-deploy-task.ts +2 -2
  84. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +288 -119
  85. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +8 -6
  86. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +28 -3
  87. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/canonical-integration-operation-store.ts +179 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-heavy-request-admission.ts +80 -2
  89. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +31 -2
  90. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-store-contract.ts +104 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-reference.ts +47 -0
  92. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-retirement.ts +193 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +420 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +41 -0
  95. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +134 -3
  96. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +1657 -95
  97. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +885 -73
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-completion-coalescer.ts +452 -0
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +601 -42
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-terminal-transition.ts +1 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +371 -0
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-resource-metrics.ts +86 -7
  103. package/dist/bundling-sources/shared_libs/play-runtime/secret-redaction.ts +153 -22
  104. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/index.ts +1 -0
  105. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/receipt-cohort.ts +188 -38
  106. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +28 -13
  107. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +44 -1
  108. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +56 -4
  109. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +2 -0
  110. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +16 -10
  111. package/dist/bundling-sources/shared_libs/plays/dataset.ts +4 -1
  112. package/dist/cli/index.js +250 -38
  113. package/dist/cli/index.mjs +250 -38
  114. package/dist/{compiler-manifest-DfSnbCTW.d.mts → compiler-manifest-BIqRyj5m.d.mts} +1 -1
  115. package/dist/{compiler-manifest-DfSnbCTW.d.ts → compiler-manifest-BIqRyj5m.d.ts} +1 -1
  116. package/dist/index.d.mts +4 -2
  117. package/dist/index.d.ts +4 -2
  118. package/dist/index.js +231 -35
  119. package/dist/index.mjs +231 -35
  120. package/dist/install-integrity.json +31 -2
  121. package/dist/plays/bundle-play-file.d.mts +2 -2
  122. package/dist/plays/bundle-play-file.d.ts +2 -2
  123. package/dist/plays/bundle-play-file.mjs +65 -1
  124. package/dist/release.d.mts +1 -1
  125. package/dist/release.d.ts +1 -1
  126. package/dist/release.js +1 -1
  127. package/dist/release.mjs +1 -1
  128. package/package.json +1 -1
@@ -0,0 +1,184 @@
1
+ /**
2
+ * An immutable body stored outside a runtime receipt row.
3
+ *
4
+ * Receipt rows remain the authority for whether an outcome exists. A reference
5
+ * carries bytes only; it is never a cache miss, execution lease, or permission
6
+ * to run a provider operation again.
7
+ */
8
+ /**
9
+ * R2 owns a referenced receipt's complete result body. These are the small,
10
+ * selected fields that may travel with its manifest for routing, presentation,
11
+ * and admission without redeeming that body.
12
+ */
13
+ export const RUNTIME_RECEIPT_VALUE_INLINE_FIELDS_MAX_BYTES = 16 * 1024;
14
+ export const RUNTIME_RECEIPT_VALUE_INLINE_FIELDS_MAX_KEYS = 32;
15
+ const RUNTIME_RECEIPT_VALUE_INLINE_FIELDS_MAX_DEPTH = 16;
16
+
17
+ export type RuntimeReceiptValueInlineValue =
18
+ | string
19
+ | number
20
+ | boolean
21
+ | null
22
+ | RuntimeReceiptValueInlineValue[]
23
+ | { [key: string]: RuntimeReceiptValueInlineValue };
24
+
25
+ export type RuntimeReceiptValueInlineFields = Record<
26
+ string,
27
+ RuntimeReceiptValueInlineValue
28
+ >;
29
+
30
+ export type RuntimeReceiptValueReference = {
31
+ storage: 'r2';
32
+ /**
33
+ * New manifests use the named JSON codec. The compatibility reader accepts
34
+ * the already-written legacy spelling without promoting a numeric protocol.
35
+ */
36
+ codec: 'json' | 'json-v1';
37
+ key: string;
38
+ digest: string;
39
+ byteLength: number;
40
+ /** SHA-256 binding for the authenticated organization, never its raw id. */
41
+ orgBinding: string;
42
+ /** SHA-256 binding for the receipt key that owns this value. */
43
+ receiptBinding: string;
44
+ /**
45
+ * Bounded selected fields beside an R2 body. Never a second full result.
46
+ * This field is additive so readers that predate it still use the reference.
47
+ */
48
+ inlineFields?: RuntimeReceiptValueInlineFields;
49
+ };
50
+
51
+ /**
52
+ * Canonicalize the small manifest payload before it crosses a receipt boundary.
53
+ * It is intentionally stricter than JSON.stringify: undefined values, Dates,
54
+ * non-finite numbers, and custom objects fail rather than changing meaning.
55
+ */
56
+ export function normalizeRuntimeReceiptValueInlineFields(
57
+ value: unknown,
58
+ ): RuntimeReceiptValueInlineFields {
59
+ if (!isPlainRecord(value)) {
60
+ throw new Error('Runtime receipt inline fields must be a plain object.');
61
+ }
62
+ const keys = Object.keys(value);
63
+ if (keys.length > RUNTIME_RECEIPT_VALUE_INLINE_FIELDS_MAX_KEYS) {
64
+ throw new Error(
65
+ `Runtime receipt inline fields exceed ${RUNTIME_RECEIPT_VALUE_INLINE_FIELDS_MAX_KEYS} keys.`,
66
+ );
67
+ }
68
+ const copied = copyInlineValue(value, '$', new Set<object>(), 0);
69
+ if (!isPlainRecord(copied)) {
70
+ throw new Error('Runtime receipt inline fields must normalize to an object.');
71
+ }
72
+ const serialized = JSON.stringify(copied);
73
+ const bytes = new TextEncoder().encode(serialized).byteLength;
74
+ if (bytes > RUNTIME_RECEIPT_VALUE_INLINE_FIELDS_MAX_BYTES) {
75
+ throw new Error(
76
+ `Runtime receipt inline fields exceed ${RUNTIME_RECEIPT_VALUE_INLINE_FIELDS_MAX_BYTES} bytes.`,
77
+ );
78
+ }
79
+ return copied;
80
+ }
81
+
82
+ export function isRuntimeReceiptValueReference(
83
+ value: unknown,
84
+ ): value is RuntimeReceiptValueReference {
85
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
86
+ const candidate = value as Record<string, unknown>;
87
+ return (
88
+ candidate.storage === 'r2' &&
89
+ (candidate.codec === 'json' || candidate.codec === 'json-v1') &&
90
+ typeof candidate.key === 'string' &&
91
+ candidate.key.length > 0 &&
92
+ /^[a-f0-9]{64}$/i.test(String(candidate.digest ?? '')) &&
93
+ Number.isSafeInteger(candidate.byteLength) &&
94
+ Number(candidate.byteLength) >= 0 &&
95
+ /^[a-f0-9]{64}$/i.test(String(candidate.orgBinding ?? '')) &&
96
+ /^[a-f0-9]{64}$/i.test(String(candidate.receiptBinding ?? '')) &&
97
+ (candidate.inlineFields === undefined ||
98
+ isRuntimeReceiptValueInlineFields(candidate.inlineFields))
99
+ );
100
+ }
101
+
102
+ function isRuntimeReceiptValueInlineFields(
103
+ value: unknown,
104
+ ): value is RuntimeReceiptValueInlineFields {
105
+ try {
106
+ normalizeRuntimeReceiptValueInlineFields(value);
107
+ return true;
108
+ } catch {
109
+ return false;
110
+ }
111
+ }
112
+
113
+ function copyInlineValue(
114
+ value: unknown,
115
+ path: string,
116
+ ancestors: Set<object>,
117
+ depth: number,
118
+ ): RuntimeReceiptValueInlineValue {
119
+ if (depth > RUNTIME_RECEIPT_VALUE_INLINE_FIELDS_MAX_DEPTH) {
120
+ throw new Error(
121
+ `Runtime receipt inline field ${path} exceeds ${RUNTIME_RECEIPT_VALUE_INLINE_FIELDS_MAX_DEPTH} nested levels.`,
122
+ );
123
+ }
124
+ if (value === null) return null;
125
+ if (typeof value === 'string' || typeof value === 'boolean') return value;
126
+ if (typeof value === 'number') {
127
+ if (Number.isFinite(value)) return value;
128
+ throw new Error(`Runtime receipt inline field ${path} must be finite.`);
129
+ }
130
+ if (Array.isArray(value)) {
131
+ if (ancestors.has(value)) {
132
+ throw new Error(`Runtime receipt inline field ${path} cannot be cyclic.`);
133
+ }
134
+ ancestors.add(value);
135
+ try {
136
+ return value.map((entry, index) =>
137
+ copyInlineValue(entry, `${path}[${index}]`, ancestors, depth + 1),
138
+ );
139
+ } finally {
140
+ ancestors.delete(value);
141
+ }
142
+ }
143
+ if (isPlainRecord(value)) {
144
+ if (ancestors.has(value)) {
145
+ throw new Error(`Runtime receipt inline field ${path} cannot be cyclic.`);
146
+ }
147
+ ancestors.add(value);
148
+ try {
149
+ const copied: Record<string, RuntimeReceiptValueInlineValue> = {};
150
+ for (const [key, entry] of Object.entries(value)) {
151
+ copied[key] = copyInlineValue(
152
+ entry,
153
+ `${path}.${key}`,
154
+ ancestors,
155
+ depth + 1,
156
+ );
157
+ }
158
+ return copied;
159
+ } finally {
160
+ ancestors.delete(value);
161
+ }
162
+ }
163
+ throw new Error(
164
+ `Runtime receipt inline field ${path} must be JSON data, not ${
165
+ value === undefined ? 'undefined' : typeof value
166
+ }.`,
167
+ );
168
+ }
169
+
170
+ function isPlainRecord(value: unknown): value is Record<string, unknown> {
171
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
172
+ const prototype = Object.getPrototypeOf(value);
173
+ return prototype === Object.prototype || prototype === null;
174
+ }
175
+
176
+ export class RuntimeReceiptValueReadError extends Error {
177
+ constructor(
178
+ readonly code: 'missing' | 'corrupt' | 'unavailable' | 'scope_mismatch',
179
+ message: string,
180
+ ) {
181
+ super(message);
182
+ this.name = 'RuntimeReceiptValueReadError';
183
+ }
184
+ }