deepline 0.1.33 → 0.1.35
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/cli/index.js +959 -207
- package/dist/cli/index.mjs +892 -140
- package/dist/index.d.mts +127 -63
- package/dist/index.d.ts +127 -63
- package/dist/index.js +516 -45
- package/dist/index.mjs +516 -45
- package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +212 -1
- package/dist/repo/apps/play-runner-workers/src/dedup-do.ts +129 -2
- package/dist/repo/apps/play-runner-workers/src/entry.ts +147 -64
- package/dist/repo/apps/play-runner-workers/src/workflow-retry.ts +50 -0
- package/dist/repo/sdk/src/client.ts +46 -33
- package/dist/repo/sdk/src/http.ts +44 -4
- package/dist/repo/sdk/src/index.ts +8 -5
- package/dist/repo/sdk/src/play.ts +124 -45
- package/dist/repo/sdk/src/plays/harness-stub.ts +2 -2
- package/dist/repo/sdk/src/tool-output.ts +26 -7
- package/dist/repo/sdk/src/types.ts +45 -11
- package/dist/repo/sdk/src/version.ts +2 -2
- package/dist/repo/shared_libs/play-runtime/run-failure.ts +49 -0
- package/dist/repo/shared_libs/play-runtime/tool-result.ts +138 -35
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -255,17 +255,57 @@ interface ToolDefinition {
|
|
|
255
255
|
inputSchema?: Record<string, unknown>;
|
|
256
256
|
/** JSON Schema describing the tool's output shape. */
|
|
257
257
|
outputSchema?: Record<string, unknown>;
|
|
258
|
-
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
258
|
+
/** Copyable play-runtime guidance for V2 tool execution results. */
|
|
259
|
+
usageGuidance?: {
|
|
260
|
+
execute?: string;
|
|
261
|
+
toolExecutionResult?: {
|
|
262
|
+
type?: 'ToolExecutionResult';
|
|
263
|
+
toolOutput?: {
|
|
264
|
+
raw?: string | {
|
|
265
|
+
path?: string;
|
|
266
|
+
schema?: Record<string, unknown>;
|
|
267
|
+
};
|
|
268
|
+
meta?: string | {
|
|
269
|
+
path?: string;
|
|
270
|
+
schema?: Record<string, unknown>;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
meta?: string;
|
|
274
|
+
extractedLists?: Array<{
|
|
275
|
+
name: string;
|
|
276
|
+
expression: string;
|
|
277
|
+
details?: {
|
|
278
|
+
strategy?: string;
|
|
279
|
+
rawToolOutputPaths?: string[];
|
|
280
|
+
candidatePaths?: string[];
|
|
281
|
+
};
|
|
282
|
+
}> | Record<string, {
|
|
283
|
+
expression: string;
|
|
284
|
+
details?: {
|
|
285
|
+
strategy?: string;
|
|
286
|
+
rawToolOutputPaths?: string[];
|
|
287
|
+
candidatePaths?: string[];
|
|
288
|
+
};
|
|
289
|
+
}>;
|
|
290
|
+
extractedValues?: Array<{
|
|
291
|
+
name: string;
|
|
292
|
+
expression: string;
|
|
293
|
+
details?: {
|
|
294
|
+
strategy?: string;
|
|
295
|
+
rawToolOutputPaths?: string[];
|
|
296
|
+
candidatePaths?: string[];
|
|
297
|
+
};
|
|
298
|
+
}> | Record<string, {
|
|
299
|
+
expression: string;
|
|
300
|
+
details?: {
|
|
301
|
+
strategy?: string;
|
|
302
|
+
rawToolOutputPaths?: string[];
|
|
303
|
+
candidatePaths?: string[];
|
|
304
|
+
};
|
|
305
|
+
}>;
|
|
306
|
+
[key: string]: unknown;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
269
309
|
/** Search relevance score returned by ranked tool search. */
|
|
270
310
|
search_score?: number;
|
|
271
311
|
/** Search match snippets returned by ranked tool search. */
|
|
@@ -822,9 +862,14 @@ type ExecuteToolRawOptions = {
|
|
|
822
862
|
type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
|
|
823
863
|
status: string;
|
|
824
864
|
job_id?: string;
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
865
|
+
toolExecutionResult: {
|
|
866
|
+
toolOutput: {
|
|
867
|
+
raw: TData;
|
|
868
|
+
meta?: TMeta;
|
|
869
|
+
};
|
|
870
|
+
extractedLists?: Record<string, unknown>;
|
|
871
|
+
extractedValues?: Record<string, unknown>;
|
|
872
|
+
meta?: Record<string, unknown>;
|
|
828
873
|
};
|
|
829
874
|
billing?: Record<string, unknown>;
|
|
830
875
|
[key: string]: unknown;
|
|
@@ -967,10 +1012,10 @@ declare class DeeplineClient {
|
|
|
967
1012
|
/**
|
|
968
1013
|
* Execute a tool and return the standard execution envelope.
|
|
969
1014
|
*
|
|
970
|
-
* The `
|
|
971
|
-
* contains provider
|
|
1015
|
+
* The `toolExecutionResult.toolOutput.raw` field contains the raw tool output.
|
|
1016
|
+
* `toolExecutionResult.toolOutput.meta` contains tool/provider metadata.
|
|
972
1017
|
* Top-level fields such as `status`, `job_id`, and `billing` describe the
|
|
973
|
-
* Deepline execution.
|
|
1018
|
+
* Deepline execution envelope.
|
|
974
1019
|
*/
|
|
975
1020
|
executeTool<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
|
|
976
1021
|
executeToolRaw<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
|
|
@@ -1440,8 +1485,8 @@ declare class DeeplineClient {
|
|
|
1440
1485
|
}>;
|
|
1441
1486
|
}
|
|
1442
1487
|
|
|
1443
|
-
declare const SDK_VERSION = "0.1.
|
|
1444
|
-
declare const SDK_API_CONTRACT = "2026-05-
|
|
1488
|
+
declare const SDK_VERSION = "0.1.35";
|
|
1489
|
+
declare const SDK_API_CONTRACT = "2026-05-v2-tool-result-contract";
|
|
1445
1490
|
|
|
1446
1491
|
/**
|
|
1447
1492
|
* Base error class for all Deepline SDK errors.
|
|
@@ -1653,13 +1698,14 @@ type ToolResultTargetAccessor<T = unknown> = ToolResultTargetMetadata & {
|
|
|
1653
1698
|
type ToolResultListAccessor<T = Record<string, unknown>> = ToolResultListMetadata & {
|
|
1654
1699
|
get(): T[];
|
|
1655
1700
|
};
|
|
1656
|
-
type
|
|
1657
|
-
|
|
1701
|
+
type ToolOutputEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
|
|
1702
|
+
raw: TData;
|
|
1658
1703
|
meta?: TMeta;
|
|
1659
1704
|
};
|
|
1660
1705
|
type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> = {
|
|
1661
1706
|
status: string;
|
|
1662
|
-
|
|
1707
|
+
toolOutput: ToolOutputEnvelope<TResult, TMeta>;
|
|
1708
|
+
meta: ToolResultExecutionMetadata;
|
|
1663
1709
|
_metadata: {
|
|
1664
1710
|
toolId: string;
|
|
1665
1711
|
execution: ToolResultExecutionMetadata;
|
|
@@ -1675,10 +1721,10 @@ type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> =
|
|
|
1675
1721
|
};
|
|
1676
1722
|
};
|
|
1677
1723
|
type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Record<string, unknown>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = {
|
|
1678
|
-
|
|
1724
|
+
extractedValues: {
|
|
1679
1725
|
[K in keyof TExtracted]: ToolResultTargetAccessor<TExtracted[K]>;
|
|
1680
1726
|
};
|
|
1681
|
-
|
|
1727
|
+
extractedLists: {
|
|
1682
1728
|
[K in keyof TLists]: ToolResultListAccessor<TLists[K]>;
|
|
1683
1729
|
};
|
|
1684
1730
|
};
|
|
@@ -1817,7 +1863,10 @@ type CsvOptions = {
|
|
|
1817
1863
|
* ```typescript
|
|
1818
1864
|
* definePlay('example', async (ctx, input: { domain: string }) => {
|
|
1819
1865
|
* // Call a tool
|
|
1820
|
-
* const company = await ctx.tools.execute(
|
|
1866
|
+
* const company = await ctx.tools.execute({
|
|
1867
|
+
* id: 'company_search',
|
|
1868
|
+
* tool: 'test_company_search',
|
|
1869
|
+
* input: { domain: input.domain },
|
|
1821
1870
|
* description: 'Look up company details by domain.',
|
|
1822
1871
|
* });
|
|
1823
1872
|
*
|
|
@@ -1886,24 +1935,30 @@ interface DeeplinePlayRuntimeContext {
|
|
|
1886
1935
|
*
|
|
1887
1936
|
* @example Single tool per row
|
|
1888
1937
|
* ```typescript
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1938
|
+
* const results = await ctx
|
|
1939
|
+
* .map('companies', leads)
|
|
1940
|
+
* .step('company', (row, ctx) =>
|
|
1941
|
+
* ctx.tools.execute({
|
|
1942
|
+
* id: 'company_search',
|
|
1943
|
+
* tool: 'test_company_search',
|
|
1944
|
+
* input: { domain: row.domain },
|
|
1945
|
+
* description: 'Look up company details by domain.',
|
|
1946
|
+
* }))
|
|
1895
1947
|
* .run({ description: 'Look up companies.' });
|
|
1896
1948
|
* // [{ domain: 'stripe.com', company: { name: 'Stripe', ... } }, ...]
|
|
1897
1949
|
* ```
|
|
1898
1950
|
*
|
|
1899
1951
|
* @example Multiple columns with pre/post logic
|
|
1900
1952
|
* ```typescript
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1953
|
+
* const results = await ctx
|
|
1954
|
+
* .map('leads', leads)
|
|
1955
|
+
* .step('company', (row, ctx) =>
|
|
1956
|
+
* ctx.tools.execute({
|
|
1957
|
+
* id: 'company_search',
|
|
1958
|
+
* tool: 'test_company_search',
|
|
1959
|
+
* input: { domain: row.domain },
|
|
1960
|
+
* description: 'Look up company details by domain.',
|
|
1961
|
+
* }))
|
|
1907
1962
|
* .step('score', (row) =>
|
|
1908
1963
|
* row.company?.employeeCount > 100 ? 'enterprise' : 'smb')
|
|
1909
1964
|
* .run({ description: 'Enrich leads.' });
|
|
@@ -1913,17 +1968,14 @@ interface DeeplinePlayRuntimeContext {
|
|
|
1913
1968
|
/** Tool execution namespace. */
|
|
1914
1969
|
tools: {
|
|
1915
1970
|
/**
|
|
1916
|
-
* Execute a single tool
|
|
1971
|
+
* Execute a single tool with a keyword-style request object.
|
|
1917
1972
|
*
|
|
1918
|
-
* @param
|
|
1919
|
-
* @param
|
|
1920
|
-
* @param input - Tool-specific input parameters
|
|
1973
|
+
* @param request.id - Stable step key for idempotent execution
|
|
1974
|
+
* @param request.tool - Tool identifier (e.g. `'test_company_search'`)
|
|
1975
|
+
* @param request.input - Tool-specific input parameters
|
|
1921
1976
|
* @returns The tool's output
|
|
1922
1977
|
*/
|
|
1923
1978
|
execute<TOutput = LoosePlayObject>(request: ToolExecutionRequest): Promise<ToolExecuteResult<TOutput>>;
|
|
1924
|
-
execute<TOutput = LoosePlayObject>(key: string, toolId: string, input: Record<string, unknown>, options?: {
|
|
1925
|
-
description?: string;
|
|
1926
|
-
}): Promise<ToolExecuteResult<TOutput>>;
|
|
1927
1979
|
};
|
|
1928
1980
|
/**
|
|
1929
1981
|
* Execute a single tool by stable step key and tool ID.
|
|
@@ -2154,7 +2206,10 @@ declare function when<Row, Value>(predicate: (row: Row, index: number) => boolea
|
|
|
2154
2206
|
* import { definePlay } from 'deepline';
|
|
2155
2207
|
*
|
|
2156
2208
|
* const myPlay = definePlay('my-play', async (ctx, input: { domain: string }) => {
|
|
2157
|
-
* return await ctx.tools.execute(
|
|
2209
|
+
* return await ctx.tools.execute({
|
|
2210
|
+
* id: 'company_search',
|
|
2211
|
+
* tool: 'test_company_search',
|
|
2212
|
+
* input: { domain: input.domain },
|
|
2158
2213
|
* description: 'Look up company details by domain.',
|
|
2159
2214
|
* });
|
|
2160
2215
|
* });
|
|
@@ -2190,14 +2245,14 @@ type PlayMetadata = {
|
|
|
2190
2245
|
*
|
|
2191
2246
|
* @example
|
|
2192
2247
|
* ```typescript
|
|
2193
|
-
* const
|
|
2248
|
+
* const deepline = await Deepline.connect();
|
|
2194
2249
|
*
|
|
2195
2250
|
* // Tools
|
|
2196
|
-
* const tools = await
|
|
2197
|
-
* const result = await
|
|
2251
|
+
* const tools = await deepline.tools.list();
|
|
2252
|
+
* const result = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
|
|
2198
2253
|
*
|
|
2199
2254
|
* // Plays
|
|
2200
|
-
* const job = await
|
|
2255
|
+
* const job = await deepline.play('email-waterfall').run({ domain: 'stripe.com' });
|
|
2201
2256
|
* const output = await job.get();
|
|
2202
2257
|
* ```
|
|
2203
2258
|
*/
|
|
@@ -2209,10 +2264,10 @@ declare class DeeplineContext {
|
|
|
2209
2264
|
*
|
|
2210
2265
|
* @example
|
|
2211
2266
|
* ```typescript
|
|
2212
|
-
* const tools = await
|
|
2213
|
-
* const meta = await
|
|
2214
|
-
* const companyLookup = await
|
|
2215
|
-
* const company = companyLookup.
|
|
2267
|
+
* const tools = await deepline.tools.list();
|
|
2268
|
+
* const meta = await deepline.tools.get('apollo_people_search');
|
|
2269
|
+
* const companyLookup = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
|
|
2270
|
+
* const company = companyLookup.toolOutput.raw;
|
|
2216
2271
|
* ```
|
|
2217
2272
|
*/
|
|
2218
2273
|
get tools(): {
|
|
@@ -2253,9 +2308,9 @@ declare class DeeplineContext {
|
|
|
2253
2308
|
* ```typescript
|
|
2254
2309
|
* import { Deepline } from 'deepline';
|
|
2255
2310
|
*
|
|
2256
|
-
* const
|
|
2257
|
-
* const tools = await
|
|
2258
|
-
* const result = await
|
|
2311
|
+
* const deepline = await Deepline.connect();
|
|
2312
|
+
* const tools = await deepline.tools.list();
|
|
2313
|
+
* const result = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
|
|
2259
2314
|
* ```
|
|
2260
2315
|
*/
|
|
2261
2316
|
declare class Deepline {
|
|
@@ -2307,7 +2362,10 @@ declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInput
|
|
|
2307
2362
|
*
|
|
2308
2363
|
* export default definePlay('company-lookup', async (ctx, input: { domain: string }) => {
|
|
2309
2364
|
* ctx.log(`Searching for ${input.domain}`);
|
|
2310
|
-
* const company = await ctx.tools.execute(
|
|
2365
|
+
* const company = await ctx.tools.execute({
|
|
2366
|
+
* id: 'company_search',
|
|
2367
|
+
* tool: 'test_company_search',
|
|
2368
|
+
* input: { domain: input.domain },
|
|
2311
2369
|
* description: 'Look up company details by domain.',
|
|
2312
2370
|
* });
|
|
2313
2371
|
* return company;
|
|
@@ -2322,7 +2380,10 @@ declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInput
|
|
|
2322
2380
|
* const results = await ctx
|
|
2323
2381
|
* .map('companies', leads)
|
|
2324
2382
|
* .step('company', (row, ctx) =>
|
|
2325
|
-
* ctx.tools.execute(
|
|
2383
|
+
* ctx.tools.execute({
|
|
2384
|
+
* id: 'company_search',
|
|
2385
|
+
* tool: 'test_company_search',
|
|
2386
|
+
* input: { domain: row.domain },
|
|
2326
2387
|
* description: 'Look up company details by domain.',
|
|
2327
2388
|
* }))
|
|
2328
2389
|
* .run({ description: 'Enrich lead companies.' });
|
|
@@ -2333,7 +2394,10 @@ declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInput
|
|
|
2333
2394
|
* @example With cron binding
|
|
2334
2395
|
* ```typescript
|
|
2335
2396
|
* export default definePlay('daily-report', async (ctx) => {
|
|
2336
|
-
* const data = await ctx.tools.execute(
|
|
2397
|
+
* const data = await ctx.tools.execute({
|
|
2398
|
+
* id: 'crm_export',
|
|
2399
|
+
* tool: 'crm_export',
|
|
2400
|
+
* input: { since: 'yesterday' },
|
|
2337
2401
|
* description: 'Export yesterday CRM records.',
|
|
2338
2402
|
* });
|
|
2339
2403
|
* return data;
|
|
@@ -2394,7 +2458,7 @@ declare function getDefinedPlayMetadata(value: unknown): PlayMetadata | null;
|
|
|
2394
2458
|
* @example
|
|
2395
2459
|
* ```typescript
|
|
2396
2460
|
* const conversion = tryConvertToList(toolResponse, {
|
|
2397
|
-
* listExtractorPaths: ['people', '
|
|
2461
|
+
* listExtractorPaths: ['people', 'output.body'],
|
|
2398
2462
|
* });
|
|
2399
2463
|
* if (conversion) {
|
|
2400
2464
|
* console.log(`Found ${conversion.rows.length} rows via ${conversion.strategy}`);
|
|
@@ -2411,7 +2475,7 @@ type ListConversionResult = {
|
|
|
2411
2475
|
* - `'auto_detected'` — found via recursive DFS (longest array wins)
|
|
2412
2476
|
*/
|
|
2413
2477
|
strategy: 'configured_paths' | 'auto_detected';
|
|
2414
|
-
/** Dotted path to where the list was found (e.g. `"
|
|
2478
|
+
/** Dotted path to where the list was found (e.g. `"output.body"`, `"people"`). */
|
|
2415
2479
|
sourcePath: string | null;
|
|
2416
2480
|
};
|
|
2417
2481
|
type Scalar = string | number | boolean | null;
|
|
@@ -2425,7 +2489,7 @@ type Scalar = string | number | boolean | null;
|
|
|
2425
2489
|
* ## Extraction strategy
|
|
2426
2490
|
*
|
|
2427
2491
|
* 1. **Configured paths** — If `listExtractorPaths` is provided, each path is
|
|
2428
|
-
* tried against multiple candidate roots (raw payload, `.result`, `.result.data`).
|
|
2492
|
+
* tried against multiple candidate roots (raw payload, `.output.body`, legacy `.result`, legacy `.result.data`).
|
|
2429
2493
|
* First match wins.
|
|
2430
2494
|
*
|
|
2431
2495
|
* 2. **Auto-detection** — If no configured path matches, recursively searches
|
|
@@ -2512,7 +2576,7 @@ declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem:
|
|
|
2512
2576
|
/**
|
|
2513
2577
|
* Extract scalar (non-nested) fields from a tool response for summary display.
|
|
2514
2578
|
*
|
|
2515
|
-
* Searches through candidate roots (raw → `.result` → `.result.data`) and
|
|
2579
|
+
* Searches through candidate roots (raw → `.output.body` → legacy `.result` → legacy `.result.data`) and
|
|
2516
2580
|
* returns the first set of scalar fields found. Useful for displaying a
|
|
2517
2581
|
* quick summary of single-record responses.
|
|
2518
2582
|
*
|