deepline 0.1.32 → 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/index.d.ts CHANGED
@@ -186,7 +186,7 @@ type PlayCompilerManifest = {
186
186
  interface DeeplineClientOptions {
187
187
  /** API key. Overrides `DEEPLINE_API_KEY` env var and CLI-stored keys. */
188
188
  apiKey?: string;
189
- /** Base URL of the Deepline API. Overrides `DEEPLINE_ORIGIN_URL` / `DEEPLINE_API_BASE_URL`. */
189
+ /** Base URL of the Deepline API. Overrides `DEEPLINE_HOST_URL`. */
190
190
  baseUrl?: string;
191
191
  /** Per-request timeout in milliseconds. Default: `60_000` (60 seconds). */
192
192
  timeout?: number;
@@ -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
- * Dotted paths for extracting list data from the tool's response.
260
- *
261
- * Used by {@link tryConvertToList} to automatically find the array of results
262
- * in a nested response. Example: `["people", "result.data"]`.
263
- */
264
- listExtractorPaths?: string[];
265
- /** Field mappings for extracting identity fields (email, phone, etc.) from results. */
266
- resultIdentityGetters?: Record<string, string[]>;
267
- /** Whether the output is a direct object or wrapped in a `result` envelope. */
268
- rowContextShape?: 'direct' | 'result_envelope';
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. */
@@ -393,6 +433,8 @@ interface PlayStatus {
393
433
  name?: string;
394
434
  /** Alias for `name` used by run/result APIs. */
395
435
  playName?: string;
436
+ /** Dashboard URL for inspecting the play and its run output in the app. */
437
+ dashboardUrl?: string;
396
438
  /** Product-level play-run state. */
397
439
  status: 'queued' | 'running' | 'waiting' | 'completed' | 'failed' | 'cancelled';
398
440
  /** Execution progress with logs and error details. */
@@ -820,9 +862,14 @@ type ExecuteToolRawOptions = {
820
862
  type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
821
863
  status: string;
822
864
  job_id?: string;
823
- result: {
824
- data: TData;
825
- meta?: TMeta;
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>;
826
873
  };
827
874
  billing?: Record<string, unknown>;
828
875
  [key: string]: unknown;
@@ -965,10 +1012,10 @@ declare class DeeplineClient {
965
1012
  /**
966
1013
  * Execute a tool and return the standard execution envelope.
967
1014
  *
968
- * The `result.data` field contains the provider payload. `result.meta`
969
- * contains provider/upstream metadata such as HTTP status or paging details.
1015
+ * The `toolExecutionResult.toolOutput.raw` field contains the raw tool output.
1016
+ * `toolExecutionResult.toolOutput.meta` contains tool/provider metadata.
970
1017
  * Top-level fields such as `status`, `job_id`, and `billing` describe the
971
- * Deepline execution.
1018
+ * Deepline execution envelope.
972
1019
  */
973
1020
  executeTool<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
974
1021
  executeToolRaw<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
@@ -1438,8 +1485,8 @@ declare class DeeplineClient {
1438
1485
  }>;
1439
1486
  }
1440
1487
 
1441
- declare const SDK_VERSION = "0.1.32";
1442
- declare const SDK_API_CONTRACT = "2026-05-generic-play-input-flags";
1488
+ declare const SDK_VERSION = "0.1.35";
1489
+ declare const SDK_API_CONTRACT = "2026-05-v2-tool-result-contract";
1443
1490
 
1444
1491
  /**
1445
1492
  * Base error class for all Deepline SDK errors.
@@ -1557,27 +1604,7 @@ declare class ConfigError extends DeeplineError {
1557
1604
  /** Production API base URL. */
1558
1605
  declare const PROD_URL = "https://code.deepline.com";
1559
1606
  /**
1560
- * Resolve SDK configuration from all available sources.
1561
- *
1562
- * Merges explicit options, environment variables, and CLI-managed config files
1563
- * into a fully validated {@link ResolvedConfig}. See the module-level docs for
1564
- * the complete resolution order.
1565
- *
1566
- * @param options - Optional overrides (highest priority)
1567
- * @returns Fully resolved configuration with all fields populated
1568
- * @throws {@link ConfigError} if no API key can be found from any source
1569
- *
1570
- * @example
1571
- * ```typescript
1572
- * import { resolveConfig } from 'deepline';
1573
- *
1574
- * // Auto-resolve everything:
1575
- * const config = resolveConfig();
1576
- * console.log(config.baseUrl); // "http://localhost:3000" or "https://code.deepline.com"
1577
- *
1578
- * // Override specific values:
1579
- * const config2 = resolveConfig({ baseUrl: 'http://localhost:4000', timeout: 10_000 });
1580
- * ```
1607
+ * Resolve SDK configuration from the public SDK CLI env contract.
1581
1608
  */
1582
1609
  declare function resolveConfig(options?: DeeplineClientOptions): ResolvedConfig;
1583
1610
 
@@ -1671,13 +1698,14 @@ type ToolResultTargetAccessor<T = unknown> = ToolResultTargetMetadata & {
1671
1698
  type ToolResultListAccessor<T = Record<string, unknown>> = ToolResultListMetadata & {
1672
1699
  get(): T[];
1673
1700
  };
1674
- type ToolResultEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
1675
- data: TData;
1701
+ type ToolOutputEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
1702
+ raw: TData;
1676
1703
  meta?: TMeta;
1677
1704
  };
1678
1705
  type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> = {
1679
1706
  status: string;
1680
- result: ToolResultEnvelope<TResult, TMeta>;
1707
+ toolOutput: ToolOutputEnvelope<TResult, TMeta>;
1708
+ meta: ToolResultExecutionMetadata;
1681
1709
  _metadata: {
1682
1710
  toolId: string;
1683
1711
  execution: ToolResultExecutionMetadata;
@@ -1693,10 +1721,10 @@ type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> =
1693
1721
  };
1694
1722
  };
1695
1723
  type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Record<string, unknown>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = {
1696
- extracted: {
1724
+ extractedValues: {
1697
1725
  [K in keyof TExtracted]: ToolResultTargetAccessor<TExtracted[K]>;
1698
1726
  };
1699
- lists: {
1727
+ extractedLists: {
1700
1728
  [K in keyof TLists]: ToolResultListAccessor<TLists[K]>;
1701
1729
  };
1702
1730
  };
@@ -1835,7 +1863,10 @@ type CsvOptions = {
1835
1863
  * ```typescript
1836
1864
  * definePlay('example', async (ctx, input: { domain: string }) => {
1837
1865
  * // Call a tool
1838
- * const company = await ctx.tools.execute('company_search', 'test_company_search', { domain: input.domain }, {
1866
+ * const company = await ctx.tools.execute({
1867
+ * id: 'company_search',
1868
+ * tool: 'test_company_search',
1869
+ * input: { domain: input.domain },
1839
1870
  * description: 'Look up company details by domain.',
1840
1871
  * });
1841
1872
  *
@@ -1904,24 +1935,30 @@ interface DeeplinePlayRuntimeContext {
1904
1935
  *
1905
1936
  * @example Single tool per row
1906
1937
  * ```typescript
1907
- * const results = await ctx
1908
- * .map('companies', leads)
1909
- * .step('company', (row, ctx) =>
1910
- * ctx.tools.execute('company_search', 'test_company_search', { domain: row.domain }, {
1911
- * description: 'Look up company details by domain.',
1912
- * }))
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
+ * }))
1913
1947
  * .run({ description: 'Look up companies.' });
1914
1948
  * // [{ domain: 'stripe.com', company: { name: 'Stripe', ... } }, ...]
1915
1949
  * ```
1916
1950
  *
1917
1951
  * @example Multiple columns with pre/post logic
1918
1952
  * ```typescript
1919
- * const results = await ctx
1920
- * .map('leads', leads)
1921
- * .step('company', (row, ctx) =>
1922
- * ctx.tools.execute('company_search', 'test_company_search', { domain: row.domain }, {
1923
- * description: 'Look up company details by domain.',
1924
- * }))
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
+ * }))
1925
1962
  * .step('score', (row) =>
1926
1963
  * row.company?.employeeCount > 100 ? 'enterprise' : 'smb')
1927
1964
  * .run({ description: 'Enrich leads.' });
@@ -1931,17 +1968,14 @@ interface DeeplinePlayRuntimeContext {
1931
1968
  /** Tool execution namespace. */
1932
1969
  tools: {
1933
1970
  /**
1934
- * Execute a single tool by stable step key and tool ID.
1971
+ * Execute a single tool with a keyword-style request object.
1935
1972
  *
1936
- * @param key - Stable step key for idempotent execution
1937
- * @param toolId - Tool identifier (e.g. `'test_company_search'`)
1938
- * @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
1939
1976
  * @returns The tool's output
1940
1977
  */
1941
1978
  execute<TOutput = LoosePlayObject>(request: ToolExecutionRequest): Promise<ToolExecuteResult<TOutput>>;
1942
- execute<TOutput = LoosePlayObject>(key: string, toolId: string, input: Record<string, unknown>, options?: {
1943
- description?: string;
1944
- }): Promise<ToolExecuteResult<TOutput>>;
1945
1979
  };
1946
1980
  /**
1947
1981
  * Execute a single tool by stable step key and tool ID.
@@ -2172,7 +2206,10 @@ declare function when<Row, Value>(predicate: (row: Row, index: number) => boolea
2172
2206
  * import { definePlay } from 'deepline';
2173
2207
  *
2174
2208
  * const myPlay = definePlay('my-play', async (ctx, input: { domain: string }) => {
2175
- * return await ctx.tools.execute('company_search', 'test_company_search', { domain: input.domain }, {
2209
+ * return await ctx.tools.execute({
2210
+ * id: 'company_search',
2211
+ * tool: 'test_company_search',
2212
+ * input: { domain: input.domain },
2176
2213
  * description: 'Look up company details by domain.',
2177
2214
  * });
2178
2215
  * });
@@ -2208,14 +2245,14 @@ type PlayMetadata = {
2208
2245
  *
2209
2246
  * @example
2210
2247
  * ```typescript
2211
- * const ctx = await Deepline.connect();
2248
+ * const deepline = await Deepline.connect();
2212
2249
  *
2213
2250
  * // Tools
2214
- * const tools = await ctx.tools.list();
2215
- * const result = await ctx.tools.execute('test_company_search', { domain: 'stripe.com' });
2251
+ * const tools = await deepline.tools.list();
2252
+ * const result = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
2216
2253
  *
2217
2254
  * // Plays
2218
- * const job = await ctx.play('email-waterfall').run({ domain: 'stripe.com' });
2255
+ * const job = await deepline.play('email-waterfall').run({ domain: 'stripe.com' });
2219
2256
  * const output = await job.get();
2220
2257
  * ```
2221
2258
  */
@@ -2227,10 +2264,10 @@ declare class DeeplineContext {
2227
2264
  *
2228
2265
  * @example
2229
2266
  * ```typescript
2230
- * const tools = await ctx.tools.list();
2231
- * const meta = await ctx.tools.get('apollo_people_search');
2232
- * const companyLookup = await ctx.tools.execute('test_company_search', { domain: 'stripe.com' });
2233
- * const company = companyLookup.result.data;
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;
2234
2271
  * ```
2235
2272
  */
2236
2273
  get tools(): {
@@ -2271,9 +2308,9 @@ declare class DeeplineContext {
2271
2308
  * ```typescript
2272
2309
  * import { Deepline } from 'deepline';
2273
2310
  *
2274
- * const ctx = await Deepline.connect();
2275
- * const tools = await ctx.tools.list();
2276
- * const result = await ctx.tools.execute('test_company_search', { domain: 'stripe.com' });
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' });
2277
2314
  * ```
2278
2315
  */
2279
2316
  declare class Deepline {
@@ -2325,7 +2362,10 @@ declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInput
2325
2362
  *
2326
2363
  * export default definePlay('company-lookup', async (ctx, input: { domain: string }) => {
2327
2364
  * ctx.log(`Searching for ${input.domain}`);
2328
- * const company = await ctx.tools.execute('company_search', 'test_company_search', { domain: input.domain }, {
2365
+ * const company = await ctx.tools.execute({
2366
+ * id: 'company_search',
2367
+ * tool: 'test_company_search',
2368
+ * input: { domain: input.domain },
2329
2369
  * description: 'Look up company details by domain.',
2330
2370
  * });
2331
2371
  * return company;
@@ -2340,7 +2380,10 @@ declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInput
2340
2380
  * const results = await ctx
2341
2381
  * .map('companies', leads)
2342
2382
  * .step('company', (row, ctx) =>
2343
- * ctx.tools.execute('company_search', 'test_company_search', { domain: row.domain }, {
2383
+ * ctx.tools.execute({
2384
+ * id: 'company_search',
2385
+ * tool: 'test_company_search',
2386
+ * input: { domain: row.domain },
2344
2387
  * description: 'Look up company details by domain.',
2345
2388
  * }))
2346
2389
  * .run({ description: 'Enrich lead companies.' });
@@ -2351,7 +2394,10 @@ declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInput
2351
2394
  * @example With cron binding
2352
2395
  * ```typescript
2353
2396
  * export default definePlay('daily-report', async (ctx) => {
2354
- * const data = await ctx.tools.execute('crm_export', 'crm_export', { since: 'yesterday' }, {
2397
+ * const data = await ctx.tools.execute({
2398
+ * id: 'crm_export',
2399
+ * tool: 'crm_export',
2400
+ * input: { since: 'yesterday' },
2355
2401
  * description: 'Export yesterday CRM records.',
2356
2402
  * });
2357
2403
  * return data;
@@ -2412,7 +2458,7 @@ declare function getDefinedPlayMetadata(value: unknown): PlayMetadata | null;
2412
2458
  * @example
2413
2459
  * ```typescript
2414
2460
  * const conversion = tryConvertToList(toolResponse, {
2415
- * listExtractorPaths: ['people', 'result.data'],
2461
+ * listExtractorPaths: ['people', 'output.body'],
2416
2462
  * });
2417
2463
  * if (conversion) {
2418
2464
  * console.log(`Found ${conversion.rows.length} rows via ${conversion.strategy}`);
@@ -2429,7 +2475,7 @@ type ListConversionResult = {
2429
2475
  * - `'auto_detected'` — found via recursive DFS (longest array wins)
2430
2476
  */
2431
2477
  strategy: 'configured_paths' | 'auto_detected';
2432
- /** Dotted path to where the list was found (e.g. `"result.data"`, `"people"`). */
2478
+ /** Dotted path to where the list was found (e.g. `"output.body"`, `"people"`). */
2433
2479
  sourcePath: string | null;
2434
2480
  };
2435
2481
  type Scalar = string | number | boolean | null;
@@ -2443,7 +2489,7 @@ type Scalar = string | number | boolean | null;
2443
2489
  * ## Extraction strategy
2444
2490
  *
2445
2491
  * 1. **Configured paths** — If `listExtractorPaths` is provided, each path is
2446
- * 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`).
2447
2493
  * First match wins.
2448
2494
  *
2449
2495
  * 2. **Auto-detection** — If no configured path matches, recursively searches
@@ -2530,7 +2576,7 @@ declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem:
2530
2576
  /**
2531
2577
  * Extract scalar (non-nested) fields from a tool response for summary display.
2532
2578
  *
2533
- * Searches through candidate roots (raw → `.result` → `.result.data`) and
2579
+ * Searches through candidate roots (raw → `.output.body` → legacy `.result` → legacy `.result.data`) and
2534
2580
  * returns the first set of scalar fields found. Useful for displaying a
2535
2581
  * quick summary of single-record responses.
2536
2582
  *