deepline 0.1.47 → 0.1.49

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.mts CHANGED
@@ -1032,7 +1032,11 @@ declare class DeeplineClient {
1032
1032
  * console.log(`Found ${searchTools.length} search tools`);
1033
1033
  * ```
1034
1034
  */
1035
- listTools(): Promise<ToolDefinition[]>;
1035
+ listTools(options?: {
1036
+ categories?: string;
1037
+ grep?: string;
1038
+ grepMode?: 'all' | 'any' | 'phrase';
1039
+ }): Promise<ToolDefinition[]>;
1036
1040
  /**
1037
1041
  * Search available tools using Deepline's ranked backend search.
1038
1042
  *
@@ -1392,7 +1396,11 @@ declare class DeeplineClient {
1392
1396
  stopRun(runId: string, options?: {
1393
1397
  reason?: string;
1394
1398
  }): Promise<StopPlayRunResult>;
1395
- listPlays(): Promise<PlayListItem[]>;
1399
+ listPlays(options?: {
1400
+ origin?: 'prebuilt' | 'owned';
1401
+ grep?: string;
1402
+ grepMode?: 'all' | 'any' | 'phrase';
1403
+ }): Promise<PlayListItem[]>;
1396
1404
  searchPlays(options: {
1397
1405
  query: string;
1398
1406
  origin?: 'prebuilt' | 'owned';
@@ -1533,7 +1541,7 @@ declare class DeeplineClient {
1533
1541
  }>;
1534
1542
  }
1535
1543
 
1536
- declare const SDK_VERSION = "0.1.47";
1544
+ declare const SDK_VERSION = "0.1.49";
1537
1545
  declare const SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
1538
1546
 
1539
1547
  /**
@@ -1851,6 +1859,7 @@ type ToolExecutionRequest = {
1851
1859
  tool: string;
1852
1860
  input: Record<string, unknown>;
1853
1861
  description?: string;
1862
+ staleAfterSeconds?: number;
1854
1863
  };
1855
1864
  type StepResolver<Row, Value> = (row: Row, ctx: DeeplinePlayRuntimeContext, index: number) => Value | Promise<Value>;
1856
1865
  type ConditionalStepResolver<Row, Value, Else = null> = {
@@ -1934,7 +1943,10 @@ type CsvOptions = {
1934
1943
  * const enriched = await ctx
1935
1944
  * .map('companies', [{ domain: 'a.com' }, { domain: 'b.com' }])
1936
1945
  * .step('company', (row, rowCtx) =>
1937
- * rowCtx.tool('company_search', 'test_company_search', { domain: row.domain }, {
1946
+ * rowCtx.tools.execute({
1947
+ * id: 'company_search',
1948
+ * tool: 'test_company_search',
1949
+ * input: { domain: row.domain },
1938
1950
  * description: 'Look up company details by domain.',
1939
1951
  * }))
1940
1952
  * .run({ description: 'Look up company details.' });
@@ -1995,30 +2007,30 @@ interface DeeplinePlayRuntimeContext {
1995
2007
  *
1996
2008
  * @example Single tool per row
1997
2009
  * ```typescript
1998
- * const results = await ctx
1999
- * .map('companies', leads)
2000
- * .step('company', (row, ctx) =>
2001
- * ctx.tools.execute({
2002
- * id: 'company_search',
2003
- * tool: 'test_company_search',
2004
- * input: { domain: row.domain },
2005
- * description: 'Look up company details by domain.',
2006
- * }))
2010
+ * const results = await ctx
2011
+ * .map('companies', leads)
2012
+ * .step('company', (row, ctx) =>
2013
+ * ctx.tools.execute({
2014
+ * id: 'company_search',
2015
+ * tool: 'test_company_search',
2016
+ * input: { domain: row.domain },
2017
+ * description: 'Look up company details by domain.',
2018
+ * }))
2007
2019
  * .run({ description: 'Look up companies.' });
2008
2020
  * // [{ domain: 'stripe.com', company: { name: 'Stripe', ... } }, ...]
2009
2021
  * ```
2010
2022
  *
2011
2023
  * @example Multiple columns with pre/post logic
2012
2024
  * ```typescript
2013
- * const results = await ctx
2014
- * .map('leads', leads)
2015
- * .step('company', (row, ctx) =>
2016
- * ctx.tools.execute({
2017
- * id: 'company_search',
2018
- * tool: 'test_company_search',
2019
- * input: { domain: row.domain },
2020
- * description: 'Look up company details by domain.',
2021
- * }))
2025
+ * const results = await ctx
2026
+ * .map('leads', leads)
2027
+ * .step('company', (row, ctx) =>
2028
+ * ctx.tools.execute({
2029
+ * id: 'company_search',
2030
+ * tool: 'test_company_search',
2031
+ * input: { domain: row.domain },
2032
+ * description: 'Look up company details by domain.',
2033
+ * }))
2022
2034
  * .step('score', (row) =>
2023
2035
  * row.company?.employeeCount > 100 ? 'enterprise' : 'smb')
2024
2036
  * .run({ description: 'Enrich leads.' });
@@ -2035,22 +2047,19 @@ interface DeeplinePlayRuntimeContext {
2035
2047
  * @param request.input - Tool-specific input parameters
2036
2048
  * @returns The tool's output
2037
2049
  */
2038
- execute<TOutput = LoosePlayObject>(request: ToolExecutionRequest): Promise<ToolExecuteResult<TOutput>>;
2050
+ execute<TOutput = LoosePlayObject>(request: ToolExecutionRequest & {
2051
+ staleAfterSeconds?: number;
2052
+ }): Promise<ToolExecuteResult<TOutput>>;
2039
2053
  };
2040
- /**
2041
- * Execute a single tool by stable step key and tool ID.
2042
- *
2043
- * Shorthand for `ctx.tools.execute(...)`; this is the preferred spelling in
2044
- * row-level step programs.
2045
- */
2046
- tool<TOutput = LoosePlayObject>(key: string, toolId: string, input: Record<string, unknown>, options?: {
2047
- description?: string;
2048
- }): Promise<ToolExecuteResult<TOutput>>;
2049
2054
  runSteps<TInput extends Record<string, unknown>, TOutput>(program: StepProgram<TInput, any, TOutput>, input: TInput, options?: {
2050
2055
  description?: string;
2051
2056
  }): Promise<TOutput>;
2052
- step<T>(id: string, run: () => T | Promise<T>): Promise<T>;
2053
- fetch(key: string, url: string | URL, init?: RequestInit): Promise<{
2057
+ step<T>(id: string, run: () => T | Promise<T>, options?: {
2058
+ staleAfterSeconds?: number;
2059
+ }): Promise<T>;
2060
+ fetch(key: string, url: string | URL, init?: RequestInit, options?: {
2061
+ staleAfterSeconds?: number;
2062
+ }): Promise<{
2054
2063
  ok: boolean;
2055
2064
  status: number;
2056
2065
  statusText: string;
@@ -2061,6 +2070,7 @@ interface DeeplinePlayRuntimeContext {
2061
2070
  }>;
2062
2071
  runPlay(key: string, playRef: string | PlayReferenceLike, input: Record<string, unknown>, options: {
2063
2072
  description?: string;
2073
+ staleAfterSeconds?: number;
2064
2074
  }): Promise<Record<string, unknown>>;
2065
2075
  /**
2066
2076
  * Emit a log line visible in `play tail` and the play's progress logs.
package/dist/index.d.ts CHANGED
@@ -1032,7 +1032,11 @@ declare class DeeplineClient {
1032
1032
  * console.log(`Found ${searchTools.length} search tools`);
1033
1033
  * ```
1034
1034
  */
1035
- listTools(): Promise<ToolDefinition[]>;
1035
+ listTools(options?: {
1036
+ categories?: string;
1037
+ grep?: string;
1038
+ grepMode?: 'all' | 'any' | 'phrase';
1039
+ }): Promise<ToolDefinition[]>;
1036
1040
  /**
1037
1041
  * Search available tools using Deepline's ranked backend search.
1038
1042
  *
@@ -1392,7 +1396,11 @@ declare class DeeplineClient {
1392
1396
  stopRun(runId: string, options?: {
1393
1397
  reason?: string;
1394
1398
  }): Promise<StopPlayRunResult>;
1395
- listPlays(): Promise<PlayListItem[]>;
1399
+ listPlays(options?: {
1400
+ origin?: 'prebuilt' | 'owned';
1401
+ grep?: string;
1402
+ grepMode?: 'all' | 'any' | 'phrase';
1403
+ }): Promise<PlayListItem[]>;
1396
1404
  searchPlays(options: {
1397
1405
  query: string;
1398
1406
  origin?: 'prebuilt' | 'owned';
@@ -1533,7 +1541,7 @@ declare class DeeplineClient {
1533
1541
  }>;
1534
1542
  }
1535
1543
 
1536
- declare const SDK_VERSION = "0.1.47";
1544
+ declare const SDK_VERSION = "0.1.49";
1537
1545
  declare const SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
1538
1546
 
1539
1547
  /**
@@ -1851,6 +1859,7 @@ type ToolExecutionRequest = {
1851
1859
  tool: string;
1852
1860
  input: Record<string, unknown>;
1853
1861
  description?: string;
1862
+ staleAfterSeconds?: number;
1854
1863
  };
1855
1864
  type StepResolver<Row, Value> = (row: Row, ctx: DeeplinePlayRuntimeContext, index: number) => Value | Promise<Value>;
1856
1865
  type ConditionalStepResolver<Row, Value, Else = null> = {
@@ -1934,7 +1943,10 @@ type CsvOptions = {
1934
1943
  * const enriched = await ctx
1935
1944
  * .map('companies', [{ domain: 'a.com' }, { domain: 'b.com' }])
1936
1945
  * .step('company', (row, rowCtx) =>
1937
- * rowCtx.tool('company_search', 'test_company_search', { domain: row.domain }, {
1946
+ * rowCtx.tools.execute({
1947
+ * id: 'company_search',
1948
+ * tool: 'test_company_search',
1949
+ * input: { domain: row.domain },
1938
1950
  * description: 'Look up company details by domain.',
1939
1951
  * }))
1940
1952
  * .run({ description: 'Look up company details.' });
@@ -1995,30 +2007,30 @@ interface DeeplinePlayRuntimeContext {
1995
2007
  *
1996
2008
  * @example Single tool per row
1997
2009
  * ```typescript
1998
- * const results = await ctx
1999
- * .map('companies', leads)
2000
- * .step('company', (row, ctx) =>
2001
- * ctx.tools.execute({
2002
- * id: 'company_search',
2003
- * tool: 'test_company_search',
2004
- * input: { domain: row.domain },
2005
- * description: 'Look up company details by domain.',
2006
- * }))
2010
+ * const results = await ctx
2011
+ * .map('companies', leads)
2012
+ * .step('company', (row, ctx) =>
2013
+ * ctx.tools.execute({
2014
+ * id: 'company_search',
2015
+ * tool: 'test_company_search',
2016
+ * input: { domain: row.domain },
2017
+ * description: 'Look up company details by domain.',
2018
+ * }))
2007
2019
  * .run({ description: 'Look up companies.' });
2008
2020
  * // [{ domain: 'stripe.com', company: { name: 'Stripe', ... } }, ...]
2009
2021
  * ```
2010
2022
  *
2011
2023
  * @example Multiple columns with pre/post logic
2012
2024
  * ```typescript
2013
- * const results = await ctx
2014
- * .map('leads', leads)
2015
- * .step('company', (row, ctx) =>
2016
- * ctx.tools.execute({
2017
- * id: 'company_search',
2018
- * tool: 'test_company_search',
2019
- * input: { domain: row.domain },
2020
- * description: 'Look up company details by domain.',
2021
- * }))
2025
+ * const results = await ctx
2026
+ * .map('leads', leads)
2027
+ * .step('company', (row, ctx) =>
2028
+ * ctx.tools.execute({
2029
+ * id: 'company_search',
2030
+ * tool: 'test_company_search',
2031
+ * input: { domain: row.domain },
2032
+ * description: 'Look up company details by domain.',
2033
+ * }))
2022
2034
  * .step('score', (row) =>
2023
2035
  * row.company?.employeeCount > 100 ? 'enterprise' : 'smb')
2024
2036
  * .run({ description: 'Enrich leads.' });
@@ -2035,22 +2047,19 @@ interface DeeplinePlayRuntimeContext {
2035
2047
  * @param request.input - Tool-specific input parameters
2036
2048
  * @returns The tool's output
2037
2049
  */
2038
- execute<TOutput = LoosePlayObject>(request: ToolExecutionRequest): Promise<ToolExecuteResult<TOutput>>;
2050
+ execute<TOutput = LoosePlayObject>(request: ToolExecutionRequest & {
2051
+ staleAfterSeconds?: number;
2052
+ }): Promise<ToolExecuteResult<TOutput>>;
2039
2053
  };
2040
- /**
2041
- * Execute a single tool by stable step key and tool ID.
2042
- *
2043
- * Shorthand for `ctx.tools.execute(...)`; this is the preferred spelling in
2044
- * row-level step programs.
2045
- */
2046
- tool<TOutput = LoosePlayObject>(key: string, toolId: string, input: Record<string, unknown>, options?: {
2047
- description?: string;
2048
- }): Promise<ToolExecuteResult<TOutput>>;
2049
2054
  runSteps<TInput extends Record<string, unknown>, TOutput>(program: StepProgram<TInput, any, TOutput>, input: TInput, options?: {
2050
2055
  description?: string;
2051
2056
  }): Promise<TOutput>;
2052
- step<T>(id: string, run: () => T | Promise<T>): Promise<T>;
2053
- fetch(key: string, url: string | URL, init?: RequestInit): Promise<{
2057
+ step<T>(id: string, run: () => T | Promise<T>, options?: {
2058
+ staleAfterSeconds?: number;
2059
+ }): Promise<T>;
2060
+ fetch(key: string, url: string | URL, init?: RequestInit, options?: {
2061
+ staleAfterSeconds?: number;
2062
+ }): Promise<{
2054
2063
  ok: boolean;
2055
2064
  status: number;
2056
2065
  statusText: string;
@@ -2061,6 +2070,7 @@ interface DeeplinePlayRuntimeContext {
2061
2070
  }>;
2062
2071
  runPlay(key: string, playRef: string | PlayReferenceLike, input: Record<string, unknown>, options: {
2063
2072
  description?: string;
2073
+ staleAfterSeconds?: number;
2064
2074
  }): Promise<Record<string, unknown>>;
2065
2075
  /**
2066
2076
  * Emit a log line visible in `play tail` and the play's progress logs.
package/dist/index.js CHANGED
@@ -215,7 +215,7 @@ function resolveConfig(options) {
215
215
  }
216
216
 
217
217
  // src/version.ts
218
- var SDK_VERSION = "0.1.47";
218
+ var SDK_VERSION = "0.1.49";
219
219
  var SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
220
220
 
221
221
  // ../shared_libs/play-runtime/coordinator-headers.ts
@@ -735,9 +735,18 @@ var DeeplineClient = class {
735
735
  * console.log(`Found ${searchTools.length} search tools`);
736
736
  * ```
737
737
  */
738
- async listTools() {
738
+ async listTools(options) {
739
+ const params = new URLSearchParams();
740
+ if (options?.categories?.trim()) {
741
+ params.set("categories", options.categories.trim());
742
+ }
743
+ if (options?.grep?.trim()) {
744
+ params.set("grep", options.grep.trim());
745
+ params.set("grep_mode", options.grepMode ?? "all");
746
+ }
747
+ const suffix = params.toString() ? `?${params.toString()}` : "";
739
748
  const res = await this.http.get(
740
- "/api/v2/tools"
749
+ `/api/v2/tools${suffix}`
741
750
  );
742
751
  return res.tools;
743
752
  }
@@ -1372,9 +1381,17 @@ var DeeplineClient = class {
1372
1381
  options?.reason ? { reason: options.reason } : {}
1373
1382
  );
1374
1383
  }
1375
- async listPlays() {
1384
+ async listPlays(options) {
1385
+ const params = new URLSearchParams();
1386
+ if (options?.origin) params.set("origin", options.origin);
1387
+ if (options?.grep?.trim()) {
1388
+ params.set("grep", options.grep.trim());
1389
+ params.set("grep_mode", options.grepMode ?? "all");
1390
+ params.set("limit", "60");
1391
+ }
1392
+ const suffix = params.toString() ? `?${params.toString()}` : "";
1376
1393
  const response = await this.http.get(
1377
- "/api/v2/plays"
1394
+ `/api/v2/plays${suffix}`
1378
1395
  );
1379
1396
  return response.plays ?? [];
1380
1397
  }
@@ -1620,7 +1637,7 @@ function toV2RawToolOutputPath(path) {
1620
1637
  if (normalized === "toolResponse.raw" || normalized.startsWith("toolResponse.raw.")) {
1621
1638
  return normalized;
1622
1639
  }
1623
- const rawPath = normalized.replace(/^result\.data\.?/, "").replace(/^result\.?/, "").replace(/^data\.?/, "").replace(/^\./, "");
1640
+ const rawPath = normalized.replace(/^result\.data\.?/, "").replace(/^result(?:\.|$)/, "").replace(/^data\.?/, "").replace(/^\./, "");
1624
1641
  return rawPath ? `toolResponse.raw.${rawPath}` : "toolResponse.raw";
1625
1642
  }
1626
1643
  function isMeaningfulValue(value) {
@@ -1672,7 +1689,30 @@ function valuesAtSegments(current, segments, path = []) {
1672
1689
  return valuesAtSegments(current[segment], rest, [...path, segment]);
1673
1690
  }
1674
1691
  if (!isRecord2(current)) return [];
1675
- return valuesAtSegments(current[segment], rest, [...path, segment]);
1692
+ const directMatches = valuesAtSegments(current[segment], rest, [
1693
+ ...path,
1694
+ segment
1695
+ ]);
1696
+ if (directMatches.length > 0 || typeof segment !== "string") {
1697
+ return directMatches;
1698
+ }
1699
+ {
1700
+ for (let end = segments.length; end > 1; end -= 1) {
1701
+ const literalSegments = segments.slice(0, end);
1702
+ if (!literalSegments.every((entry) => typeof entry === "string")) {
1703
+ continue;
1704
+ }
1705
+ const literalKey = literalSegments.join(".");
1706
+ if (!Object.prototype.hasOwnProperty.call(current, literalKey)) {
1707
+ continue;
1708
+ }
1709
+ return valuesAtSegments(current[literalKey], segments.slice(end), [
1710
+ ...path,
1711
+ literalKey
1712
+ ]);
1713
+ }
1714
+ }
1715
+ return directMatches;
1676
1716
  }
1677
1717
  function getValuesAtPath(root, path) {
1678
1718
  return valuesAtSegments(root, parsePath(path)).map((entry) => entry.value);
@@ -1696,7 +1736,7 @@ function toV2RawToolOutputPathPreservingProviderData(path) {
1696
1736
  if (normalized === "toolResponse.raw" || normalized.startsWith("toolResponse.raw.")) {
1697
1737
  return normalized;
1698
1738
  }
1699
- const rawPath = normalized.replace(/^result\.?/, "").replace(/^\./, "");
1739
+ const rawPath = normalized.replace(/^result(?:\.|$)/, "").replace(/^\./, "");
1700
1740
  return rawPath ? `toolResponse.raw.${rawPath}` : "toolResponse.raw";
1701
1741
  }
1702
1742
  function candidateResultPaths(path) {
@@ -1870,6 +1910,11 @@ function deriveListKeys(input) {
1870
1910
  for (const rawPath of paths) {
1871
1911
  const path = String(rawPath || "").trim().replace(/^\./, "");
1872
1912
  if (!path) continue;
1913
+ const firstRow = input.rows[0];
1914
+ if (firstRow && Object.prototype.hasOwnProperty.call(firstRow, path)) {
1915
+ keys[target] = path;
1916
+ break;
1917
+ }
1873
1918
  for (const resultPath of candidateResultPaths(path)) {
1874
1919
  const directPrefix = `${listPrefix}.`;
1875
1920
  if (resultPath.startsWith(directPrefix)) {
@@ -2195,11 +2240,9 @@ var DeeplineContext = class {
2195
2240
  get: (toolId) => this.client.getTool(toolId),
2196
2241
  /** Execute a tool and return the standard execution envelope. */
2197
2242
  execute: async (toolId, input) => {
2198
- const response = await this.client.executeTool(
2199
- toolId,
2200
- input,
2201
- { includeToolMetadata: true }
2202
- );
2243
+ const response = await this.client.executeTool(toolId, input, {
2244
+ includeToolMetadata: true
2245
+ });
2203
2246
  return toolExecutionEnvelopeToResult(toolId, response);
2204
2247
  }
2205
2248
  };
@@ -2348,9 +2391,7 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response) {
2348
2391
  metadata: {
2349
2392
  toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
2350
2393
  extractors: extractorDescriptorRecord(toolMetadata.extractors),
2351
- targetGetters: stringArrayRecord(
2352
- toolMetadata.targetGetters
2353
- ),
2394
+ targetGetters: stringArrayRecord(toolMetadata.targetGetters),
2354
2395
  listExtractorPaths: stringArray(toolMetadata.listExtractorPaths),
2355
2396
  listIdentityGetters: stringArrayRecord(toolMetadata.listIdentityGetters)
2356
2397
  },
package/dist/index.mjs CHANGED
@@ -169,7 +169,7 @@ function resolveConfig(options) {
169
169
  }
170
170
 
171
171
  // src/version.ts
172
- var SDK_VERSION = "0.1.47";
172
+ var SDK_VERSION = "0.1.49";
173
173
  var SDK_API_CONTRACT = "2026-05-stripe-promo-checkout";
174
174
 
175
175
  // ../shared_libs/play-runtime/coordinator-headers.ts
@@ -689,9 +689,18 @@ var DeeplineClient = class {
689
689
  * console.log(`Found ${searchTools.length} search tools`);
690
690
  * ```
691
691
  */
692
- async listTools() {
692
+ async listTools(options) {
693
+ const params = new URLSearchParams();
694
+ if (options?.categories?.trim()) {
695
+ params.set("categories", options.categories.trim());
696
+ }
697
+ if (options?.grep?.trim()) {
698
+ params.set("grep", options.grep.trim());
699
+ params.set("grep_mode", options.grepMode ?? "all");
700
+ }
701
+ const suffix = params.toString() ? `?${params.toString()}` : "";
693
702
  const res = await this.http.get(
694
- "/api/v2/tools"
703
+ `/api/v2/tools${suffix}`
695
704
  );
696
705
  return res.tools;
697
706
  }
@@ -1326,9 +1335,17 @@ var DeeplineClient = class {
1326
1335
  options?.reason ? { reason: options.reason } : {}
1327
1336
  );
1328
1337
  }
1329
- async listPlays() {
1338
+ async listPlays(options) {
1339
+ const params = new URLSearchParams();
1340
+ if (options?.origin) params.set("origin", options.origin);
1341
+ if (options?.grep?.trim()) {
1342
+ params.set("grep", options.grep.trim());
1343
+ params.set("grep_mode", options.grepMode ?? "all");
1344
+ params.set("limit", "60");
1345
+ }
1346
+ const suffix = params.toString() ? `?${params.toString()}` : "";
1330
1347
  const response = await this.http.get(
1331
- "/api/v2/plays"
1348
+ `/api/v2/plays${suffix}`
1332
1349
  );
1333
1350
  return response.plays ?? [];
1334
1351
  }
@@ -1574,7 +1591,7 @@ function toV2RawToolOutputPath(path) {
1574
1591
  if (normalized === "toolResponse.raw" || normalized.startsWith("toolResponse.raw.")) {
1575
1592
  return normalized;
1576
1593
  }
1577
- const rawPath = normalized.replace(/^result\.data\.?/, "").replace(/^result\.?/, "").replace(/^data\.?/, "").replace(/^\./, "");
1594
+ const rawPath = normalized.replace(/^result\.data\.?/, "").replace(/^result(?:\.|$)/, "").replace(/^data\.?/, "").replace(/^\./, "");
1578
1595
  return rawPath ? `toolResponse.raw.${rawPath}` : "toolResponse.raw";
1579
1596
  }
1580
1597
  function isMeaningfulValue(value) {
@@ -1626,7 +1643,30 @@ function valuesAtSegments(current, segments, path = []) {
1626
1643
  return valuesAtSegments(current[segment], rest, [...path, segment]);
1627
1644
  }
1628
1645
  if (!isRecord2(current)) return [];
1629
- return valuesAtSegments(current[segment], rest, [...path, segment]);
1646
+ const directMatches = valuesAtSegments(current[segment], rest, [
1647
+ ...path,
1648
+ segment
1649
+ ]);
1650
+ if (directMatches.length > 0 || typeof segment !== "string") {
1651
+ return directMatches;
1652
+ }
1653
+ {
1654
+ for (let end = segments.length; end > 1; end -= 1) {
1655
+ const literalSegments = segments.slice(0, end);
1656
+ if (!literalSegments.every((entry) => typeof entry === "string")) {
1657
+ continue;
1658
+ }
1659
+ const literalKey = literalSegments.join(".");
1660
+ if (!Object.prototype.hasOwnProperty.call(current, literalKey)) {
1661
+ continue;
1662
+ }
1663
+ return valuesAtSegments(current[literalKey], segments.slice(end), [
1664
+ ...path,
1665
+ literalKey
1666
+ ]);
1667
+ }
1668
+ }
1669
+ return directMatches;
1630
1670
  }
1631
1671
  function getValuesAtPath(root, path) {
1632
1672
  return valuesAtSegments(root, parsePath(path)).map((entry) => entry.value);
@@ -1650,7 +1690,7 @@ function toV2RawToolOutputPathPreservingProviderData(path) {
1650
1690
  if (normalized === "toolResponse.raw" || normalized.startsWith("toolResponse.raw.")) {
1651
1691
  return normalized;
1652
1692
  }
1653
- const rawPath = normalized.replace(/^result\.?/, "").replace(/^\./, "");
1693
+ const rawPath = normalized.replace(/^result(?:\.|$)/, "").replace(/^\./, "");
1654
1694
  return rawPath ? `toolResponse.raw.${rawPath}` : "toolResponse.raw";
1655
1695
  }
1656
1696
  function candidateResultPaths(path) {
@@ -1824,6 +1864,11 @@ function deriveListKeys(input) {
1824
1864
  for (const rawPath of paths) {
1825
1865
  const path = String(rawPath || "").trim().replace(/^\./, "");
1826
1866
  if (!path) continue;
1867
+ const firstRow = input.rows[0];
1868
+ if (firstRow && Object.prototype.hasOwnProperty.call(firstRow, path)) {
1869
+ keys[target] = path;
1870
+ break;
1871
+ }
1827
1872
  for (const resultPath of candidateResultPaths(path)) {
1828
1873
  const directPrefix = `${listPrefix}.`;
1829
1874
  if (resultPath.startsWith(directPrefix)) {
@@ -2149,11 +2194,9 @@ var DeeplineContext = class {
2149
2194
  get: (toolId) => this.client.getTool(toolId),
2150
2195
  /** Execute a tool and return the standard execution envelope. */
2151
2196
  execute: async (toolId, input) => {
2152
- const response = await this.client.executeTool(
2153
- toolId,
2154
- input,
2155
- { includeToolMetadata: true }
2156
- );
2197
+ const response = await this.client.executeTool(toolId, input, {
2198
+ includeToolMetadata: true
2199
+ });
2157
2200
  return toolExecutionEnvelopeToResult(toolId, response);
2158
2201
  }
2159
2202
  };
@@ -2302,9 +2345,7 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response) {
2302
2345
  metadata: {
2303
2346
  toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
2304
2347
  extractors: extractorDescriptorRecord(toolMetadata.extractors),
2305
- targetGetters: stringArrayRecord(
2306
- toolMetadata.targetGetters
2307
- ),
2348
+ targetGetters: stringArrayRecord(toolMetadata.targetGetters),
2308
2349
  listExtractorPaths: stringArray(toolMetadata.listExtractorPaths),
2309
2350
  listIdentityGetters: stringArrayRecord(toolMetadata.listIdentityGetters)
2310
2351
  },
@@ -2408,12 +2408,15 @@ export class RuntimeApi extends WorkerEntrypoint<CoordinatorEnv, undefined> {
2408
2408
  { status: 403, headers: { 'content-type': 'application/json' } },
2409
2409
  );
2410
2410
  }
2411
- const apiBaseUrl =
2411
+ const configuredApiBaseUrl =
2412
2412
  typeof this.env.DEEPLINE_API_BASE_URL === 'string' &&
2413
2413
  this.env.DEEPLINE_API_BASE_URL.trim()
2414
2414
  ? this.env.DEEPLINE_API_BASE_URL.trim()
2415
2415
  : 'https://code.deepline.com';
2416
- const target = new URL(incoming.pathname + incoming.search, apiBaseUrl);
2416
+ const target = new URL(
2417
+ incoming.pathname + incoming.search,
2418
+ configuredApiBaseUrl,
2419
+ );
2417
2420
  const forwarded = new Request(target.toString(), request);
2418
2421
  const bypassToken = this.env.VERCEL_PROTECTION_BYPASS_TOKEN;
2419
2422
  if (typeof bypassToken === 'string' && bypassToken) {