deepline 0.1.148 → 0.1.150
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.
- package/dist/bundling-sources/sdk/src/client.ts +5 -0
- package/dist/bundling-sources/sdk/src/config.ts +49 -0
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/bundling-sources/sdk/src/tool-output.ts +63 -17
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +1 -2
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +17 -4
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +343 -26
- package/dist/cli/index.js +342 -151
- package/dist/cli/index.mjs +349 -152
- package/dist/index.d.mts +12 -9
- package/dist/index.d.ts +12 -9
- package/dist/index.js +32 -19
- package/dist/index.mjs +39 -20
- package/package.json +1 -1
|
@@ -84,6 +84,7 @@ import type { EnrichCompiledConfig } from './cli/enrich-play-compiler.js';
|
|
|
84
84
|
const TERMINAL_PLAY_STATUSES = new Set(['completed', 'failed', 'cancelled']);
|
|
85
85
|
const INCLUDE_TOOL_METADATA_HEADER = 'x-deepline-include-tool-metadata';
|
|
86
86
|
const EXECUTE_RESPONSE_CONTRACT_HEADER = 'x-deepline-execute-response-contract';
|
|
87
|
+
const EXECUTE_RESPONSE_INTENT_HEADER = 'x-deepline-execute-response-intent';
|
|
87
88
|
const V2_EXECUTE_RESPONSE_CONTRACT = 'v2-tool-response';
|
|
88
89
|
const COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1_000];
|
|
89
90
|
const REGISTER_PLAY_ARTIFACTS_COMPILE_CONCURRENCY = 3;
|
|
@@ -163,6 +164,7 @@ function chunkRegisterPlayArtifacts<T>(artifacts: T[]): T[][] {
|
|
|
163
164
|
|
|
164
165
|
type ExecuteToolRawOptions = {
|
|
165
166
|
includeToolMetadata?: boolean;
|
|
167
|
+
responseIntent?: 'raw' | 'row_artifact';
|
|
166
168
|
};
|
|
167
169
|
|
|
168
170
|
/**
|
|
@@ -1156,6 +1158,9 @@ export class DeeplineClient {
|
|
|
1156
1158
|
...(options?.includeToolMetadata
|
|
1157
1159
|
? { [INCLUDE_TOOL_METADATA_HEADER]: 'true' }
|
|
1158
1160
|
: {}),
|
|
1161
|
+
...(options?.responseIntent
|
|
1162
|
+
? { [EXECUTE_RESPONSE_INTENT_HEADER]: options.responseIntent }
|
|
1163
|
+
: {}),
|
|
1159
1164
|
};
|
|
1160
1165
|
return this.http.post<ToolExecution<TData, TMeta>>(
|
|
1161
1166
|
`/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
|
|
@@ -58,6 +58,8 @@ const DEFAULT_TIMEOUT = 60_000;
|
|
|
58
58
|
const DEFAULT_MAX_RETRIES = 3;
|
|
59
59
|
|
|
60
60
|
const PROJECT_DEEPLINE_ENV_FILE = '.env.deepline';
|
|
61
|
+
const WORKSPACE_RESTORE_ENV_DIR = '.deepline';
|
|
62
|
+
const WORKSPACE_RESTORE_ENV_FILE = '.env';
|
|
61
63
|
const COWORK_IGNORED_WORKSPACE_DIRS = new Set([
|
|
62
64
|
'.auto-memory',
|
|
63
65
|
'.claude',
|
|
@@ -505,6 +507,27 @@ function ensureProjectEnvIsIgnored(dir: string): void {
|
|
|
505
507
|
writeFileSync(gitignorePath, `${existing}${prefix}${entry}\n`, 'utf-8');
|
|
506
508
|
}
|
|
507
509
|
|
|
510
|
+
function ensureWorkspaceRestoreEnvIsIgnored(workspaceDir: string): void {
|
|
511
|
+
const gitignorePath = join(workspaceDir, '.gitignore');
|
|
512
|
+
const entry = `${WORKSPACE_RESTORE_ENV_DIR}/`;
|
|
513
|
+
const existing = existsSync(gitignorePath)
|
|
514
|
+
? readFileSync(gitignorePath, 'utf-8')
|
|
515
|
+
: '';
|
|
516
|
+
const alreadyIgnored = existing
|
|
517
|
+
.split(/\r?\n/)
|
|
518
|
+
.map((line) => line.trim())
|
|
519
|
+
.some(
|
|
520
|
+
(line) =>
|
|
521
|
+
line === entry ||
|
|
522
|
+
line === `/${entry}` ||
|
|
523
|
+
line === WORKSPACE_RESTORE_ENV_DIR ||
|
|
524
|
+
line === `/${WORKSPACE_RESTORE_ENV_DIR}`,
|
|
525
|
+
);
|
|
526
|
+
if (alreadyIgnored) return;
|
|
527
|
+
const prefix = existing && !existing.endsWith('\n') ? '\n' : '';
|
|
528
|
+
writeFileSync(gitignorePath, `${existing}${prefix}${entry}\n`, 'utf-8');
|
|
529
|
+
}
|
|
530
|
+
|
|
508
531
|
export function saveProjectDeeplineEnvValues(
|
|
509
532
|
values: EnvValues,
|
|
510
533
|
startDir: string = process.cwd(),
|
|
@@ -522,6 +545,32 @@ export function saveProjectDeeplineEnvValues(
|
|
|
522
545
|
return [filePath];
|
|
523
546
|
}
|
|
524
547
|
|
|
548
|
+
export function saveCoworkWorkspaceRestoreEnvValues(
|
|
549
|
+
values: EnvValues,
|
|
550
|
+
startDir: string = process.cwd(),
|
|
551
|
+
): string[] {
|
|
552
|
+
if (!isCoworkLikeSandbox()) return [];
|
|
553
|
+
const target = resolveProjectPinTarget(startDir);
|
|
554
|
+
if (!target.ok || target.source === 'cwd') return [];
|
|
555
|
+
const workspaceDir = target.dir;
|
|
556
|
+
const filePath = join(
|
|
557
|
+
workspaceDir,
|
|
558
|
+
WORKSPACE_RESTORE_ENV_DIR,
|
|
559
|
+
WORKSPACE_RESTORE_ENV_FILE,
|
|
560
|
+
);
|
|
561
|
+
const existing = parseEnvFile(filePath);
|
|
562
|
+
const merged = { ...existing, ...values };
|
|
563
|
+
const dir = dirname(filePath);
|
|
564
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
565
|
+
ensureWorkspaceRestoreEnvIsIgnored(workspaceDir);
|
|
566
|
+
const allowedKeys = new Set([HOST_URL_ENV, API_KEY_ENV]);
|
|
567
|
+
const lines = Object.entries(merged)
|
|
568
|
+
.filter(([key, value]) => allowedKeys.has(key) && value !== '')
|
|
569
|
+
.map(([key, value]) => `${key}=${value}`);
|
|
570
|
+
writeFileSync(filePath, `${lines.join('\n')}\n`, 'utf-8');
|
|
571
|
+
return [filePath];
|
|
572
|
+
}
|
|
573
|
+
|
|
525
574
|
export function resolveProjectPinDir(startDir: string = process.cwd()): string {
|
|
526
575
|
const target = resolveProjectPinTarget(startDir);
|
|
527
576
|
if (!target.ok) {
|
|
@@ -102,10 +102,10 @@ export const SDK_RELEASE = {
|
|
|
102
102
|
// the SDK enrich generator's one-second stale policy.
|
|
103
103
|
// 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
|
|
104
104
|
// 0.1.111 ships dataset-native tool list getters and result row datasets.
|
|
105
|
-
version: '0.1.
|
|
105
|
+
version: '0.1.150',
|
|
106
106
|
apiContract: '2026-06-dataset-handle-results-hard-cutover',
|
|
107
107
|
supportPolicy: {
|
|
108
|
-
latest: '0.1.
|
|
108
|
+
latest: '0.1.150',
|
|
109
109
|
minimumSupported: '0.1.53',
|
|
110
110
|
deprecatedBelow: '0.1.53',
|
|
111
111
|
commandMinimumSupported: [
|
|
@@ -23,7 +23,13 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @module
|
|
25
25
|
*/
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
closeSync,
|
|
28
|
+
mkdirSync,
|
|
29
|
+
openSync,
|
|
30
|
+
writeFileSync,
|
|
31
|
+
writeSync,
|
|
32
|
+
} from 'node:fs';
|
|
27
33
|
import { homedir } from 'node:os';
|
|
28
34
|
import { dirname, join } from 'node:path';
|
|
29
35
|
|
|
@@ -54,6 +60,22 @@ export type ListConversionResult = {
|
|
|
54
60
|
sourcePath: string | null;
|
|
55
61
|
};
|
|
56
62
|
|
|
63
|
+
export type RowOutputProjection = {
|
|
64
|
+
rows: Array<Record<string, unknown>>;
|
|
65
|
+
rowCount: number;
|
|
66
|
+
columns: string[];
|
|
67
|
+
previewRows: Array<Record<string, unknown>>;
|
|
68
|
+
strategy: ListConversionResult['strategy'];
|
|
69
|
+
sourcePath: string | null;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type CsvOutputArtifact = {
|
|
73
|
+
path: string;
|
|
74
|
+
rowCount: number;
|
|
75
|
+
columns: string[];
|
|
76
|
+
preview: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
57
79
|
type Scalar = string | number | boolean | null;
|
|
58
80
|
|
|
59
81
|
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
@@ -109,6 +131,20 @@ function normalizeRows(value: unknown): Array<Record<string, unknown>> | null {
|
|
|
109
131
|
});
|
|
110
132
|
}
|
|
111
133
|
|
|
134
|
+
function columnsForRows(rows: readonly Record<string, unknown>[]): string[] {
|
|
135
|
+
const seen = new Set<string>();
|
|
136
|
+
const columns: string[] = [];
|
|
137
|
+
for (const row of rows) {
|
|
138
|
+
for (const key of Object.keys(row)) {
|
|
139
|
+
if (!seen.has(key)) {
|
|
140
|
+
seen.add(key);
|
|
141
|
+
columns.push(key);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return columns;
|
|
146
|
+
}
|
|
147
|
+
|
|
112
148
|
/**
|
|
113
149
|
* Generate candidate root objects to search for lists.
|
|
114
150
|
* Tries: raw payload → V2 toolResponse.raw → legacy payload.output.body → legacy payload.result → legacy payload.result.data.
|
|
@@ -271,6 +307,19 @@ export function tryConvertToList(
|
|
|
271
307
|
return null;
|
|
272
308
|
}
|
|
273
309
|
|
|
310
|
+
export function projectRowOutput(
|
|
311
|
+
conversion: ListConversionResult,
|
|
312
|
+
): RowOutputProjection {
|
|
313
|
+
return {
|
|
314
|
+
rows: conversion.rows,
|
|
315
|
+
rowCount: conversion.rows.length,
|
|
316
|
+
columns: columnsForRows(conversion.rows),
|
|
317
|
+
previewRows: conversion.rows.slice(0, 5),
|
|
318
|
+
strategy: conversion.strategy,
|
|
319
|
+
sourcePath: conversion.sourcePath,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
274
323
|
/** Ensure the shared output directory exists. Returns its path. */
|
|
275
324
|
function ensureOutputDir(): string {
|
|
276
325
|
const outputDir = join(homedir(), '.local', 'share', 'deepline', 'data');
|
|
@@ -330,21 +379,12 @@ export function writeCsvOutputFile(
|
|
|
330
379
|
rows: Array<Record<string, unknown>>,
|
|
331
380
|
stem: string,
|
|
332
381
|
options?: { outPath?: string },
|
|
333
|
-
):
|
|
382
|
+
): CsvOutputArtifact {
|
|
334
383
|
const outputPath = options?.outPath
|
|
335
384
|
? options.outPath
|
|
336
385
|
: join(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
|
|
337
386
|
mkdirSync(dirname(outputPath), { recursive: true });
|
|
338
|
-
const
|
|
339
|
-
const columns: string[] = [];
|
|
340
|
-
for (const row of rows) {
|
|
341
|
-
for (const key of Object.keys(row)) {
|
|
342
|
-
if (!seen.has(key)) {
|
|
343
|
-
seen.add(key);
|
|
344
|
-
columns.push(key);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
387
|
+
const columns = columnsForRows(rows);
|
|
348
388
|
|
|
349
389
|
const escapeCell = (value: unknown): string => {
|
|
350
390
|
const normalized =
|
|
@@ -361,12 +401,18 @@ export function writeCsvOutputFile(
|
|
|
361
401
|
return normalized;
|
|
362
402
|
};
|
|
363
403
|
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
404
|
+
const fd = openSync(outputPath, 'w');
|
|
405
|
+
try {
|
|
406
|
+
writeSync(fd, `${columns.map(escapeCell).join(',')}\n`);
|
|
407
|
+
for (const row of rows) {
|
|
408
|
+
writeSync(
|
|
409
|
+
fd,
|
|
410
|
+
`${columns.map((column) => escapeCell(row[column])).join(',')}\n`,
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
} finally {
|
|
414
|
+
closeSync(fd);
|
|
368
415
|
}
|
|
369
|
-
writeFileSync(outputPath, `${lines.join('\n')}\n`, 'utf-8');
|
|
370
416
|
|
|
371
417
|
const previewRows = rows.slice(0, 5);
|
|
372
418
|
const previewColumns = columns.slice(0, 5);
|
|
@@ -98,7 +98,6 @@ interface NeonModule {
|
|
|
98
98
|
query<R = Record<string, unknown>>(
|
|
99
99
|
text: string,
|
|
100
100
|
params?: unknown[],
|
|
101
|
-
options?: { fullResults?: boolean },
|
|
102
101
|
): Promise<{ rows: R[] }>;
|
|
103
102
|
};
|
|
104
103
|
}
|
|
@@ -186,7 +185,7 @@ export function installNeonServerlessRuntimePoolDriver(): void {
|
|
|
186
185
|
params?: unknown[],
|
|
187
186
|
) => {
|
|
188
187
|
const sql = await getSql();
|
|
189
|
-
return await sql.query<R>(text, params
|
|
188
|
+
return await sql.query<R>(text, params);
|
|
190
189
|
},
|
|
191
190
|
};
|
|
192
191
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EmailStatusExtractorConfig } from './email-status';
|
|
2
2
|
import type { DeeplineGetterValueMap } from './extractor-targets';
|
|
3
|
-
import type { PlayDataset } from '../plays/dataset';
|
|
3
|
+
import type { PlayDataset, SerializedPlayDataset } from '../plays/dataset';
|
|
4
4
|
|
|
5
5
|
export type ToolResultExecutionMetadata = {
|
|
6
6
|
idempotent: true;
|
|
@@ -73,10 +73,22 @@ export type ToolResultEnvelope<
|
|
|
73
73
|
export type SerializedToolExecuteResult = {
|
|
74
74
|
__kind: 'deepline.tool_execute_result.v1';
|
|
75
75
|
status: string;
|
|
76
|
+
job_id?: string;
|
|
77
|
+
/** Deepline-owned execution/result metadata. */
|
|
78
|
+
meta?: Record<string, unknown>;
|
|
76
79
|
toolResponse: {
|
|
80
|
+
/**
|
|
81
|
+
* Raw provider/tool data with declared row-list payloads clipped to bounded
|
|
82
|
+
* previews. Use list getters for row-shaped data.
|
|
83
|
+
*/
|
|
77
84
|
raw: unknown;
|
|
78
85
|
meta?: Record<string, unknown>;
|
|
79
86
|
};
|
|
87
|
+
listDatasets?: Record<string, SerializedPlayDataset<Record<string, unknown>>>;
|
|
88
|
+
/** Full declared list rows used to rehydrate list Dataset Handles. */
|
|
89
|
+
listRows?: Record<string, Array<Record<string, unknown>>>;
|
|
90
|
+
/** Computed scalar/object getters preserved before raw list previews are clipped. */
|
|
91
|
+
targetValues?: Record<string, ToolResultTargetMetadata>;
|
|
80
92
|
metadata: ToolResultMetadataInput;
|
|
81
93
|
execution: ToolResultExecutionMetadata;
|
|
82
94
|
};
|
|
@@ -142,9 +154,10 @@ export type ToolExecuteResultAccessors<
|
|
|
142
154
|
* getters live under `extractedValues.<name>.get()`, and list getters live
|
|
143
155
|
* under `extractedLists.<name>.get()`.
|
|
144
156
|
*
|
|
145
|
-
* Use extractors first when a tool contract exposes them.
|
|
146
|
-
* `toolResponse.raw`
|
|
147
|
-
*
|
|
157
|
+
* Use extractors first when a tool contract exposes them. Use list getters for
|
|
158
|
+
* row-shaped data. Drop to `toolResponse.raw` only for provider-specific scalar
|
|
159
|
+
* fields or bounded debugging context; persisted rows may clip declared lists to
|
|
160
|
+
* previews.
|
|
148
161
|
*
|
|
149
162
|
* @sdkReference runtime 200
|
|
150
163
|
*/
|