deepline 0.1.246 → 0.1.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.
@@ -113,7 +113,7 @@ export const SDK_RELEASE = {
113
113
  // runtime intentionally no longer compiles at publish or launch time.
114
114
  // 0.1.242 removes the retired Workers/ESM compiler, generated bundles, and
115
115
  // deploy-time artifact migration. Play authoring now has one CJS contract.
116
- version: '0.1.246',
116
+ version: '0.1.248',
117
117
  apiContract: '2026-07-cjs-absurd-only-play-runtime-hard-cutover',
118
118
  supportPolicy: {
119
119
  minimumSupported: '0.1.53',
@@ -514,7 +514,7 @@ export interface ContextOptions {
514
514
  * Runtime-sheet transport selected by the runner. Daytona sandboxes use the
515
515
  * execution gateway and must never fall back to minting direct DB sessions.
516
516
  */
517
- dbSessionStrategy?: 'preloaded' | 'sandbox_public_key' | 'gateway_only';
517
+ dbSessionStrategy?: 'preloaded' | 'gateway_only' | 'trusted_dynamic';
518
518
  vercelProtectionBypassToken?: string | null;
519
519
  /** Optional per-run integration execution mode for provider calls. */
520
520
  integrationMode?: 'live' | 'eval_stub' | 'fixture';
@@ -1,9 +1,10 @@
1
1
  import {
2
- flattenStaticPipeline,
3
- resolveSheetContractForTableNamespace,
2
+ getCompiledPipelineSubsteps,
4
3
  type PlaySheetContract,
5
4
  type PlayStaticPipeline,
5
+ type PlayStaticSubstep,
6
6
  } from '../plays/static-pipeline';
7
+ import { normalizeTableNamespace } from '../plays/row-identity';
7
8
  import {
8
9
  RUNTIME_SHEET_ROWS_LOGICAL_TABLE,
9
10
  RUNTIME_WORK_RECEIPT_LOGICAL_TABLE,
@@ -21,27 +22,143 @@ export type RuntimeDbSessionRequirement = {
21
22
  sheetContract?: PlaySheetContract | null;
22
23
  };
23
24
 
24
- export function planRuntimeSheetDbSessionRequirements(
25
+ export type RuntimeSheetDbSessionPlanInspection = {
26
+ datasetCount: number;
27
+ datasetNamespaces: string[];
28
+ plannedNamespaces: string[];
29
+ errors: string[];
30
+ };
31
+
32
+ type DatasetSessionContract = {
33
+ tableNamespace: string;
34
+ sheetContract: PlaySheetContract | null;
35
+ error?: string;
36
+ };
37
+
38
+ function currentExecutionScopeSubsteps(
39
+ substeps: readonly PlayStaticSubstep[],
40
+ ): PlayStaticSubstep[] {
41
+ const flattened: PlayStaticSubstep[] = [];
42
+ for (const substep of substeps) {
43
+ flattened.push(substep);
44
+ if (
45
+ (substep.type === 'dataset' ||
46
+ substep.type === 'step_suite' ||
47
+ substep.type === 'control_flow') &&
48
+ substep.steps?.length
49
+ ) {
50
+ flattened.push(...currentExecutionScopeSubsteps(substep.steps));
51
+ }
52
+ // A child play with a dataset owns a separate run and session scope. Its
53
+ // nested pipeline must never reserve a table under the parent play token.
54
+ }
55
+ return flattened;
56
+ }
57
+
58
+ function datasetSessionContracts(
25
59
  pipeline: PlayStaticPipeline | null,
26
- ): RuntimeDbSessionRequirement[] {
27
- if (!pipeline) {
28
- return [];
60
+ ): DatasetSessionContract[] {
61
+ if (!pipeline) return [];
62
+ const rootNamespace = pipeline.tableNamespace?.trim();
63
+ let normalizedRootNamespace: string | null = null;
64
+ if (rootNamespace) {
65
+ try {
66
+ normalizedRootNamespace = normalizeTableNamespace(rootNamespace);
67
+ } catch {
68
+ normalizedRootNamespace = null;
69
+ }
29
70
  }
30
- const byNamespace = new Map<string, PlaySheetContract>();
31
- for (const substep of flattenStaticPipeline(pipeline)) {
32
- if (substep.type !== 'dataset') continue;
33
- const tableNamespace = (
34
- substep.tableNamespace ??
35
- substep.field ??
36
- ''
37
- ).trim();
38
- if (!tableNamespace) continue;
71
+ const rootContract = pipeline.sheetContract ?? null;
72
+ return currentExecutionScopeSubsteps(
73
+ getCompiledPipelineSubsteps(pipeline),
74
+ ).flatMap<DatasetSessionContract>((substep): DatasetSessionContract[] => {
75
+ if (substep.type !== 'dataset') return [];
76
+ const rawNamespace = (substep.tableNamespace ?? substep.field ?? '').trim();
77
+ if (!rawNamespace) {
78
+ return [{ tableNamespace: '', sheetContract: null }];
79
+ }
80
+ let tableNamespace: string;
81
+ try {
82
+ tableNamespace = normalizeTableNamespace(rawNamespace);
83
+ } catch (error) {
84
+ return [
85
+ {
86
+ tableNamespace: rawNamespace,
87
+ sheetContract: null,
88
+ error: error instanceof Error ? error.message : String(error),
89
+ },
90
+ ];
91
+ }
39
92
  const sheetContract =
40
- resolveSheetContractForTableNamespace(pipeline, tableNamespace) ??
41
93
  substep.sheetContract ??
42
- null;
43
- if (!sheetContract) continue;
44
- byNamespace.set(tableNamespace, sheetContract);
94
+ (normalizedRootNamespace === tableNamespace ? rootContract : null);
95
+ return [{ tableNamespace, sheetContract }];
96
+ });
97
+ }
98
+
99
+ export function inspectRuntimeSheetDbSessionPlan(
100
+ pipeline: PlayStaticPipeline | null,
101
+ ): RuntimeSheetDbSessionPlanInspection {
102
+ const datasets = datasetSessionContracts(pipeline);
103
+ const datasetNamespaces: string[] = [];
104
+ const plannedNamespaces: string[] = [];
105
+ const errors = [...(pipeline?.sheetContractErrors ?? [])];
106
+ const seen = new Set<string>();
107
+ for (const dataset of datasets) {
108
+ if (dataset.error) {
109
+ errors.push(dataset.error);
110
+ continue;
111
+ }
112
+ if (!dataset.tableNamespace) {
113
+ errors.push('Dataset is missing a Runtime Sheet namespace.');
114
+ continue;
115
+ }
116
+ datasetNamespaces.push(dataset.tableNamespace);
117
+ if (seen.has(dataset.tableNamespace)) {
118
+ errors.push(
119
+ `Dataset "${dataset.tableNamespace}" is declared more than once in the same play execution scope.`,
120
+ );
121
+ continue;
122
+ }
123
+ seen.add(dataset.tableNamespace);
124
+ if (!dataset.sheetContract) {
125
+ errors.push(
126
+ `Dataset "${dataset.tableNamespace}" is missing a compiled Runtime Sheet contract.`,
127
+ );
128
+ continue;
129
+ }
130
+ let contractNamespace: string;
131
+ try {
132
+ contractNamespace = normalizeTableNamespace(
133
+ dataset.sheetContract.tableNamespace,
134
+ );
135
+ } catch (error) {
136
+ errors.push(error instanceof Error ? error.message : String(error));
137
+ continue;
138
+ }
139
+ if (contractNamespace !== dataset.tableNamespace) {
140
+ errors.push(
141
+ `Dataset "${dataset.tableNamespace}" has a Runtime Sheet contract for "${contractNamespace}".`,
142
+ );
143
+ continue;
144
+ }
145
+ plannedNamespaces.push(dataset.tableNamespace);
146
+ }
147
+ return {
148
+ datasetCount: datasets.length,
149
+ datasetNamespaces,
150
+ plannedNamespaces,
151
+ errors,
152
+ };
153
+ }
154
+
155
+ export function planRuntimeSheetDbSessionRequirements(
156
+ pipeline: PlayStaticPipeline | null,
157
+ ): RuntimeDbSessionRequirement[] {
158
+ const byNamespace = new Map<string, PlaySheetContract>();
159
+ for (const dataset of datasetSessionContracts(pipeline)) {
160
+ if (!dataset.tableNamespace || !dataset.sheetContract) continue;
161
+ byNamespace.set(dataset.tableNamespace, dataset.sheetContract);
45
162
  }
46
163
  return [...byNamespace.entries()].map(([tableNamespace, sheetContract]) => ({
47
164
  tableNamespace,
@@ -111,15 +111,13 @@ export interface PlayRunnerContextConfig {
111
111
  /**
112
112
  * Controls how scoped Postgres sessions enter the runner. `preloaded` means
113
113
  * the launch config carries short-lived encrypted sessions minted before
114
- * dispatch; `sandbox_public_key` means the runner mints missing sessions
115
- * through the app runtime API with a per-request public key.
114
+ * dispatch. Daytona sandboxes never mint direct database sessions.
116
115
  */
117
- dbSessionStrategy?: 'preloaded' | 'sandbox_public_key' | 'gateway_only';
116
+ dbSessionStrategy?: 'preloaded' | 'gateway_only' | 'trusted_dynamic';
118
117
  /**
119
118
  * Short-lived scoped Postgres sessions minted by the worker before the runner
120
- * starts. They are only an initial fast path: the runner still renews through
121
- * the app runtime API when a session is absent, too close to expiry, or not an
122
- * exact-enough match for the requested play/table/operation scope.
119
+ * starts. A missing or mismatched session is a fatal launch-contract error;
120
+ * an external attempt token can never mint a replacement.
123
121
  */
124
122
  preloadedDbSessions?: PreloadedRuntimeDbSession[];
125
123
  /**
@@ -247,6 +247,7 @@ function remoteRuntimeContextForDaytona(
247
247
  vercelProtectionBypassToken: null,
248
248
  dbSessionStrategy: 'gateway_only',
249
249
  preloadedDbSessions: undefined,
250
+ postgresSessionUnwrapKey: undefined,
250
251
  };
251
252
  }
252
253
 
@@ -121,11 +121,7 @@ type RuntimeApiContext = {
121
121
  runId?: string | null;
122
122
  userEmail?: string | null;
123
123
  integrationMode?: 'live' | 'eval_stub' | 'fixture' | null;
124
- dbSessionStrategy?:
125
- | 'preloaded'
126
- | 'sandbox_public_key'
127
- | 'gateway_only'
128
- | null;
124
+ dbSessionStrategy?: 'preloaded' | 'gateway_only' | 'trusted_dynamic' | null;
129
125
  preloadedDbSessions?: PreloadedRuntimeDbSession[] | null;
130
126
  vercelProtectionBypassToken?: string | null;
131
127
  runtimeTestFaultHeader?: string | null;
@@ -1147,9 +1143,6 @@ function findPreloadedRuntimeDbSession(
1147
1143
  limits?: DbSessionLimits;
1148
1144
  },
1149
1145
  ): CreateDbSessionResponse | null {
1150
- if (context.dbSessionStrategy === 'sandbox_public_key') {
1151
- return null;
1152
- }
1153
1146
  const preloadedSessions = context.preloadedDbSessions ?? [];
1154
1147
  if (preloadedSessions.length === 0) {
1155
1148
  return null;
@@ -1289,6 +1282,12 @@ async function getRuntimeDbSession(
1289
1282
  return unwrappedPreloaded;
1290
1283
  }
1291
1284
 
1285
+ if (context.dbSessionStrategy !== 'trusted_dynamic') {
1286
+ throw new Error(
1287
+ `RUNTIME_DB_SESSION_PRELOAD_INCOMPLETE: no preloaded Runtime DB session matches play=${context.playName} table=${normalizeTableNamespace(input.tableNamespace)} logical_table=${input.logicalTable}. Dynamic database authority requires an explicit trusted control-plane context.`,
1288
+ );
1289
+ }
1290
+
1292
1291
  if (shouldEnsureRuntimeSheetBeforeSession(input)) {
1293
1292
  await ensureRuntimeSheet(context, {
1294
1293
  playName: context.playName,
@@ -1386,9 +1385,6 @@ function runtimeDbSessionRowLimit(rowCount: number): number {
1386
1385
  export async function prewarmRuntimePostgresSessions(
1387
1386
  context: RuntimeApiContext,
1388
1387
  ): Promise<void> {
1389
- if (context.dbSessionStrategy === 'sandbox_public_key') {
1390
- return;
1391
- }
1392
1388
  const sessions = context.preloadedDbSessions ?? [];
1393
1389
  if (sessions.length === 0) {
1394
1390
  return;
@@ -166,14 +166,74 @@ export function ensureCompiledSheetContract(
166
166
  if (!pipeline) {
167
167
  return pipeline;
168
168
  }
169
- if (pipeline.sheetContract) {
170
- return pipeline;
171
- }
172
- const compiled = compileSheetContract(pipeline);
173
- return {
169
+ const datasetErrors: string[] = [];
170
+ const compileDatasetSubsteps = (
171
+ substeps: PlayStaticSubstep[],
172
+ ): PlayStaticSubstep[] =>
173
+ substeps.map((substep) => {
174
+ if (substep.type === 'play_call' && substep.pipeline) {
175
+ return {
176
+ ...substep,
177
+ pipeline: ensureCompiledSheetContract(substep.pipeline) ?? null,
178
+ };
179
+ }
180
+ if (
181
+ substep.type !== 'dataset' &&
182
+ substep.type !== 'step_suite' &&
183
+ substep.type !== 'control_flow'
184
+ ) {
185
+ return substep;
186
+ }
187
+ const steps = substep.steps?.length
188
+ ? compileDatasetSubsteps(substep.steps)
189
+ : (substep.steps ?? []);
190
+ if (substep.type !== 'dataset' || substep.sheetContract) {
191
+ return { ...substep, steps } as PlayStaticSubstep;
192
+ }
193
+ const tableNamespace = (substep.tableNamespace ?? substep.field).trim();
194
+ const compiledDataset = compileSheetContract({
195
+ tableNamespace,
196
+ inputFields: substep.inputFields,
197
+ rowKeyFields: substep.rowKeyFields,
198
+ fields:
199
+ substep.outputFields ??
200
+ substep.columns?.map((column) => column.id) ??
201
+ [],
202
+ substeps: steps,
203
+ });
204
+ datasetErrors.push(
205
+ ...compiledDataset.errors.map(
206
+ (error) => `Dataset "${tableNamespace}": ${error}`,
207
+ ),
208
+ );
209
+ return {
210
+ ...substep,
211
+ steps,
212
+ sheetContract: compiledDataset.contract,
213
+ };
214
+ });
215
+ const withDatasetContracts: PlayStaticPipeline = {
174
216
  ...pipeline,
217
+ ...(pipeline.stages
218
+ ? { stages: compileDatasetSubsteps(pipeline.stages) }
219
+ : {}),
220
+ // Stored legacy rows can predate the required static-pipeline arrays.
221
+ // Preserve the missing field so compileSheetContract reports it instead
222
+ // of crashing or silently normalizing malformed persisted data.
223
+ ...(Array.isArray(pipeline.substeps)
224
+ ? { substeps: compileDatasetSubsteps(pipeline.substeps) }
225
+ : {}),
226
+ };
227
+ const compiled = pipeline.sheetContract
228
+ ? {
229
+ contract: pipeline.sheetContract,
230
+ errors: [...(pipeline.sheetContractErrors ?? [])],
231
+ }
232
+ : compileSheetContract(withDatasetContracts);
233
+ return {
234
+ ...withDatasetContracts,
175
235
  sheetContract: compiled.contract,
176
- sheetContractErrors: compiled.errors,
236
+ sheetContractErrors: [...compiled.errors, ...datasetErrors],
177
237
  };
178
238
  }
179
239
 
@@ -483,6 +543,16 @@ export function truncateStaticPipelineForStorage(
483
543
  );
484
544
  }
485
545
 
546
+ export function truncateStaticPipelineForRuntimeContract(
547
+ pipeline: PlayStaticPipeline | null | undefined,
548
+ ): PlayStaticPipeline | null | undefined {
549
+ return truncateStaticPipelineForStorage(pipeline, {
550
+ // Runtime admission must preserve every dataset contract. The caller's
551
+ // serialized artifact-size budget is the bound; a UI depth cap is not.
552
+ maxStoredSubstepDepth: Number.POSITIVE_INFINITY,
553
+ });
554
+ }
555
+
486
556
  export interface PlayStaticSourceRange {
487
557
  sourcePath?: string;
488
558
  startLine: number;
package/dist/cli/index.js CHANGED
@@ -632,7 +632,7 @@ var SDK_RELEASE = {
632
632
  // runtime intentionally no longer compiles at publish or launch time.
633
633
  // 0.1.242 removes the retired Workers/ESM compiler, generated bundles, and
634
634
  // deploy-time artifact migration. Play authoring now has one CJS contract.
635
- version: "0.1.246",
635
+ version: "0.1.248",
636
636
  apiContract: "2026-07-cjs-absurd-only-play-runtime-hard-cutover",
637
637
  supportPolicy: {
638
638
  minimumSupported: "0.1.53",
@@ -24350,42 +24350,24 @@ function renderAvailableToolsText(payload) {
24350
24350
  const returned = asFiniteNumber(payload.returned) ?? tools.length;
24351
24351
  const total = asFiniteNumber(payload.total);
24352
24352
  const lines = [
24353
- total !== void 0 ? `Signal Radar types you can deploy (${returned} of ${total}):` : "Signal Radar types you can deploy:"
24353
+ total !== void 0 ? `Monitor tools you can deploy (${returned} of ${total}):` : "Monitor tools you can deploy:"
24354
24354
  ];
24355
- let currentProvider;
24356
24355
  for (const raw of tools) {
24357
24356
  const entry = asRecord(raw);
24358
24357
  const id = entry ? asString(entry.tool) : void 0;
24359
24358
  if (!entry || !id) continue;
24360
24359
  const name = asString(entry.name) ?? asString(entry.display_name);
24361
24360
  const deployedCount = asFiniteNumber(entry.deployed_count);
24362
- const description = asString(entry.description);
24363
- const streams = Array.isArray(entry.streams) ? entry.streams.map((stream) => asString(stream)).filter((stream) => Boolean(stream)) : [];
24364
- const provider = id.split(".")[0];
24365
- if (provider && provider !== currentProvider) {
24366
- currentProvider = provider;
24367
- lines.push("", ` ${provider}:`);
24368
- }
24369
24361
  lines.push(
24370
- ` ${id.split(".").slice(1).join(".") || id}${name ? ` \u2014 ${name}` : ""}${deployedCount !== void 0 ? ` (${deployedCount} deployed)` : ""}`
24362
+ ` ${id}${name ? ` \u2014 ${name}` : ""}${deployedCount !== void 0 ? ` (deployed: ${deployedCount})` : ""}`
24371
24363
  );
24372
- if (description) lines.push(` ${description}`);
24373
- if (streams.length > 0) {
24374
- lines.push(` emits: ${streams.join(", ")}`);
24375
- }
24376
24364
  }
24377
24365
  if (payload.is_truncated === true) {
24378
24366
  lines.push("List truncated; raise --limit to see more.");
24379
24367
  }
24380
24368
  lines.push(
24381
24369
  "",
24382
- "Next:",
24383
- " Inspect payload fields, output columns, and a play binding:",
24384
- " deepline monitors available <provider.tool> --json",
24385
- " See monitors already deployed in this workspace:",
24386
- " deepline monitors list",
24387
- " Validate a monitor definition before deploying:",
24388
- ` deepline monitors check '{"key":"my-radar","tool":"<provider.tool>","payload":{...}}'`
24370
+ "Describe one (payload schema + output streams): deepline monitors available <tool-id> --json"
24389
24371
  );
24390
24372
  return `${lines.join("\n")}
24391
24373
  `;
@@ -617,7 +617,7 @@ var SDK_RELEASE = {
617
617
  // runtime intentionally no longer compiles at publish or launch time.
618
618
  // 0.1.242 removes the retired Workers/ESM compiler, generated bundles, and
619
619
  // deploy-time artifact migration. Play authoring now has one CJS contract.
620
- version: "0.1.246",
620
+ version: "0.1.248",
621
621
  apiContract: "2026-07-cjs-absurd-only-play-runtime-hard-cutover",
622
622
  supportPolicy: {
623
623
  minimumSupported: "0.1.53",
@@ -24386,42 +24386,24 @@ function renderAvailableToolsText(payload) {
24386
24386
  const returned = asFiniteNumber(payload.returned) ?? tools.length;
24387
24387
  const total = asFiniteNumber(payload.total);
24388
24388
  const lines = [
24389
- total !== void 0 ? `Signal Radar types you can deploy (${returned} of ${total}):` : "Signal Radar types you can deploy:"
24389
+ total !== void 0 ? `Monitor tools you can deploy (${returned} of ${total}):` : "Monitor tools you can deploy:"
24390
24390
  ];
24391
- let currentProvider;
24392
24391
  for (const raw of tools) {
24393
24392
  const entry = asRecord(raw);
24394
24393
  const id = entry ? asString(entry.tool) : void 0;
24395
24394
  if (!entry || !id) continue;
24396
24395
  const name = asString(entry.name) ?? asString(entry.display_name);
24397
24396
  const deployedCount = asFiniteNumber(entry.deployed_count);
24398
- const description = asString(entry.description);
24399
- const streams = Array.isArray(entry.streams) ? entry.streams.map((stream) => asString(stream)).filter((stream) => Boolean(stream)) : [];
24400
- const provider = id.split(".")[0];
24401
- if (provider && provider !== currentProvider) {
24402
- currentProvider = provider;
24403
- lines.push("", ` ${provider}:`);
24404
- }
24405
24397
  lines.push(
24406
- ` ${id.split(".").slice(1).join(".") || id}${name ? ` \u2014 ${name}` : ""}${deployedCount !== void 0 ? ` (${deployedCount} deployed)` : ""}`
24398
+ ` ${id}${name ? ` \u2014 ${name}` : ""}${deployedCount !== void 0 ? ` (deployed: ${deployedCount})` : ""}`
24407
24399
  );
24408
- if (description) lines.push(` ${description}`);
24409
- if (streams.length > 0) {
24410
- lines.push(` emits: ${streams.join(", ")}`);
24411
- }
24412
24400
  }
24413
24401
  if (payload.is_truncated === true) {
24414
24402
  lines.push("List truncated; raise --limit to see more.");
24415
24403
  }
24416
24404
  lines.push(
24417
24405
  "",
24418
- "Next:",
24419
- " Inspect payload fields, output columns, and a play binding:",
24420
- " deepline monitors available <provider.tool> --json",
24421
- " See monitors already deployed in this workspace:",
24422
- " deepline monitors list",
24423
- " Validate a monitor definition before deploying:",
24424
- ` deepline monitors check '{"key":"my-radar","tool":"<provider.tool>","payload":{...}}'`
24406
+ "Describe one (payload schema + output streams): deepline monitors available <tool-id> --json"
24425
24407
  );
24426
24408
  return `${lines.join("\n")}
24427
24409
  `;
package/dist/index.js CHANGED
@@ -431,7 +431,7 @@ var SDK_RELEASE = {
431
431
  // runtime intentionally no longer compiles at publish or launch time.
432
432
  // 0.1.242 removes the retired Workers/ESM compiler, generated bundles, and
433
433
  // deploy-time artifact migration. Play authoring now has one CJS contract.
434
- version: "0.1.246",
434
+ version: "0.1.248",
435
435
  apiContract: "2026-07-cjs-absurd-only-play-runtime-hard-cutover",
436
436
  supportPolicy: {
437
437
  minimumSupported: "0.1.53",
package/dist/index.mjs CHANGED
@@ -361,7 +361,7 @@ var SDK_RELEASE = {
361
361
  // runtime intentionally no longer compiles at publish or launch time.
362
362
  // 0.1.242 removes the retired Workers/ESM compiler, generated bundles, and
363
363
  // deploy-time artifact migration. Play authoring now has one CJS contract.
364
- version: "0.1.246",
364
+ version: "0.1.248",
365
365
  apiContract: "2026-07-cjs-absurd-only-play-runtime-hard-cutover",
366
366
  supportPolicy: {
367
367
  minimumSupported: "0.1.53",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.246",
3
+ "version": "0.1.248",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {