deepline 0.1.35 → 0.1.36
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 +79 -59
- package/dist/cli/index.mjs +79 -59
- package/dist/index.d.mts +23 -25
- package/dist/index.d.ts +23 -25
- package/dist/index.js +44 -38
- package/dist/index.mjs +44 -38
- package/dist/repo/apps/play-runner-workers/src/entry.ts +40 -12
- package/dist/repo/apps/play-runner-workers/src/runtime/receipts.ts +138 -0
- package/dist/repo/sdk/src/client.ts +9 -11
- package/dist/repo/sdk/src/index.ts +1 -1
- package/dist/repo/sdk/src/play.ts +5 -3
- package/dist/repo/sdk/src/tool-output.ts +8 -12
- package/dist/repo/sdk/src/types.ts +3 -3
- package/dist/repo/sdk/src/version.ts +2 -2
- package/dist/repo/shared_libs/play-runtime/tool-result.ts +50 -34
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -260,15 +260,9 @@ interface ToolDefinition {
|
|
|
260
260
|
execute?: string;
|
|
261
261
|
toolExecutionResult?: {
|
|
262
262
|
type?: 'ToolExecutionResult';
|
|
263
|
-
|
|
264
|
-
raw?: string
|
|
265
|
-
|
|
266
|
-
schema?: Record<string, unknown>;
|
|
267
|
-
};
|
|
268
|
-
meta?: string | {
|
|
269
|
-
path?: string;
|
|
270
|
-
schema?: Record<string, unknown>;
|
|
271
|
-
};
|
|
263
|
+
toolResponse?: {
|
|
264
|
+
raw?: string;
|
|
265
|
+
meta?: string;
|
|
272
266
|
};
|
|
273
267
|
meta?: string;
|
|
274
268
|
extractedLists?: Array<{
|
|
@@ -862,15 +856,13 @@ type ExecuteToolRawOptions = {
|
|
|
862
856
|
type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
|
|
863
857
|
status: string;
|
|
864
858
|
job_id?: string;
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
};
|
|
870
|
-
extractedLists?: Record<string, unknown>;
|
|
871
|
-
extractedValues?: Record<string, unknown>;
|
|
872
|
-
meta?: Record<string, unknown>;
|
|
859
|
+
meta?: Record<string, unknown>;
|
|
860
|
+
toolResponse: {
|
|
861
|
+
raw: TData;
|
|
862
|
+
meta?: TMeta;
|
|
873
863
|
};
|
|
864
|
+
extractedLists?: Record<string, unknown>;
|
|
865
|
+
extractedValues?: Record<string, unknown>;
|
|
874
866
|
billing?: Record<string, unknown>;
|
|
875
867
|
[key: string]: unknown;
|
|
876
868
|
};
|
|
@@ -1012,8 +1004,8 @@ declare class DeeplineClient {
|
|
|
1012
1004
|
/**
|
|
1013
1005
|
* Execute a tool and return the standard execution envelope.
|
|
1014
1006
|
*
|
|
1015
|
-
* The `
|
|
1016
|
-
* `
|
|
1007
|
+
* The `toolResponse.raw` field contains the raw tool response.
|
|
1008
|
+
* `toolResponse.meta` contains tool/provider metadata.
|
|
1017
1009
|
* Top-level fields such as `status`, `job_id`, and `billing` describe the
|
|
1018
1010
|
* Deepline execution envelope.
|
|
1019
1011
|
*/
|
|
@@ -1485,8 +1477,8 @@ declare class DeeplineClient {
|
|
|
1485
1477
|
}>;
|
|
1486
1478
|
}
|
|
1487
1479
|
|
|
1488
|
-
declare const SDK_VERSION = "0.1.
|
|
1489
|
-
declare const SDK_API_CONTRACT = "2026-05-v2-tool-
|
|
1480
|
+
declare const SDK_VERSION = "0.1.36";
|
|
1481
|
+
declare const SDK_API_CONTRACT = "2026-05-v2-tool-response";
|
|
1490
1482
|
|
|
1491
1483
|
/**
|
|
1492
1484
|
* Base error class for all Deepline SDK errors.
|
|
@@ -1698,14 +1690,20 @@ type ToolResultTargetAccessor<T = unknown> = ToolResultTargetMetadata & {
|
|
|
1698
1690
|
type ToolResultListAccessor<T = Record<string, unknown>> = ToolResultListMetadata & {
|
|
1699
1691
|
get(): T[];
|
|
1700
1692
|
};
|
|
1701
|
-
type
|
|
1693
|
+
type ToolResponseEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
|
|
1702
1694
|
raw: TData;
|
|
1703
1695
|
meta?: TMeta;
|
|
1704
1696
|
};
|
|
1705
1697
|
type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> = {
|
|
1706
1698
|
status: string;
|
|
1707
|
-
|
|
1708
|
-
|
|
1699
|
+
job_id?: string;
|
|
1700
|
+
/** Deepline-owned execution/result metadata. */
|
|
1701
|
+
meta?: Record<string, unknown>;
|
|
1702
|
+
toolResponse: ToolResponseEnvelope<TResult, TMeta>;
|
|
1703
|
+
extractedValues: Record<string, ToolResultTargetAccessor>;
|
|
1704
|
+
extractedLists: Record<string, ToolResultListAccessor>;
|
|
1705
|
+
/** Convenience alias for play code. Serialized output uses toolResponse. */
|
|
1706
|
+
toolOutput: ToolResponseEnvelope<TResult, TMeta>;
|
|
1709
1707
|
_metadata: {
|
|
1710
1708
|
toolId: string;
|
|
1711
1709
|
execution: ToolResultExecutionMetadata;
|
|
@@ -2267,7 +2265,7 @@ declare class DeeplineContext {
|
|
|
2267
2265
|
* const tools = await deepline.tools.list();
|
|
2268
2266
|
* const meta = await deepline.tools.get('apollo_people_search');
|
|
2269
2267
|
* const companyLookup = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
|
|
2270
|
-
* const company = companyLookup.
|
|
2268
|
+
* const company = companyLookup.toolResponse.raw;
|
|
2271
2269
|
* ```
|
|
2272
2270
|
*/
|
|
2273
2271
|
get tools(): {
|
package/dist/index.d.ts
CHANGED
|
@@ -260,15 +260,9 @@ interface ToolDefinition {
|
|
|
260
260
|
execute?: string;
|
|
261
261
|
toolExecutionResult?: {
|
|
262
262
|
type?: 'ToolExecutionResult';
|
|
263
|
-
|
|
264
|
-
raw?: string
|
|
265
|
-
|
|
266
|
-
schema?: Record<string, unknown>;
|
|
267
|
-
};
|
|
268
|
-
meta?: string | {
|
|
269
|
-
path?: string;
|
|
270
|
-
schema?: Record<string, unknown>;
|
|
271
|
-
};
|
|
263
|
+
toolResponse?: {
|
|
264
|
+
raw?: string;
|
|
265
|
+
meta?: string;
|
|
272
266
|
};
|
|
273
267
|
meta?: string;
|
|
274
268
|
extractedLists?: Array<{
|
|
@@ -862,15 +856,13 @@ type ExecuteToolRawOptions = {
|
|
|
862
856
|
type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
|
|
863
857
|
status: string;
|
|
864
858
|
job_id?: string;
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
};
|
|
870
|
-
extractedLists?: Record<string, unknown>;
|
|
871
|
-
extractedValues?: Record<string, unknown>;
|
|
872
|
-
meta?: Record<string, unknown>;
|
|
859
|
+
meta?: Record<string, unknown>;
|
|
860
|
+
toolResponse: {
|
|
861
|
+
raw: TData;
|
|
862
|
+
meta?: TMeta;
|
|
873
863
|
};
|
|
864
|
+
extractedLists?: Record<string, unknown>;
|
|
865
|
+
extractedValues?: Record<string, unknown>;
|
|
874
866
|
billing?: Record<string, unknown>;
|
|
875
867
|
[key: string]: unknown;
|
|
876
868
|
};
|
|
@@ -1012,8 +1004,8 @@ declare class DeeplineClient {
|
|
|
1012
1004
|
/**
|
|
1013
1005
|
* Execute a tool and return the standard execution envelope.
|
|
1014
1006
|
*
|
|
1015
|
-
* The `
|
|
1016
|
-
* `
|
|
1007
|
+
* The `toolResponse.raw` field contains the raw tool response.
|
|
1008
|
+
* `toolResponse.meta` contains tool/provider metadata.
|
|
1017
1009
|
* Top-level fields such as `status`, `job_id`, and `billing` describe the
|
|
1018
1010
|
* Deepline execution envelope.
|
|
1019
1011
|
*/
|
|
@@ -1485,8 +1477,8 @@ declare class DeeplineClient {
|
|
|
1485
1477
|
}>;
|
|
1486
1478
|
}
|
|
1487
1479
|
|
|
1488
|
-
declare const SDK_VERSION = "0.1.
|
|
1489
|
-
declare const SDK_API_CONTRACT = "2026-05-v2-tool-
|
|
1480
|
+
declare const SDK_VERSION = "0.1.36";
|
|
1481
|
+
declare const SDK_API_CONTRACT = "2026-05-v2-tool-response";
|
|
1490
1482
|
|
|
1491
1483
|
/**
|
|
1492
1484
|
* Base error class for all Deepline SDK errors.
|
|
@@ -1698,14 +1690,20 @@ type ToolResultTargetAccessor<T = unknown> = ToolResultTargetMetadata & {
|
|
|
1698
1690
|
type ToolResultListAccessor<T = Record<string, unknown>> = ToolResultListMetadata & {
|
|
1699
1691
|
get(): T[];
|
|
1700
1692
|
};
|
|
1701
|
-
type
|
|
1693
|
+
type ToolResponseEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
|
|
1702
1694
|
raw: TData;
|
|
1703
1695
|
meta?: TMeta;
|
|
1704
1696
|
};
|
|
1705
1697
|
type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> = {
|
|
1706
1698
|
status: string;
|
|
1707
|
-
|
|
1708
|
-
|
|
1699
|
+
job_id?: string;
|
|
1700
|
+
/** Deepline-owned execution/result metadata. */
|
|
1701
|
+
meta?: Record<string, unknown>;
|
|
1702
|
+
toolResponse: ToolResponseEnvelope<TResult, TMeta>;
|
|
1703
|
+
extractedValues: Record<string, ToolResultTargetAccessor>;
|
|
1704
|
+
extractedLists: Record<string, ToolResultListAccessor>;
|
|
1705
|
+
/** Convenience alias for play code. Serialized output uses toolResponse. */
|
|
1706
|
+
toolOutput: ToolResponseEnvelope<TResult, TMeta>;
|
|
1709
1707
|
_metadata: {
|
|
1710
1708
|
toolId: string;
|
|
1711
1709
|
execution: ToolResultExecutionMetadata;
|
|
@@ -2267,7 +2265,7 @@ declare class DeeplineContext {
|
|
|
2267
2265
|
* const tools = await deepline.tools.list();
|
|
2268
2266
|
* const meta = await deepline.tools.get('apollo_people_search');
|
|
2269
2267
|
* const companyLookup = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
|
|
2270
|
-
* const company = companyLookup.
|
|
2268
|
+
* const company = companyLookup.toolResponse.raw;
|
|
2271
2269
|
* ```
|
|
2272
2270
|
*/
|
|
2273
2271
|
get tools(): {
|
package/dist/index.js
CHANGED
|
@@ -215,8 +215,8 @@ function resolveConfig(options) {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
// src/version.ts
|
|
218
|
-
var SDK_VERSION = "0.1.
|
|
219
|
-
var SDK_API_CONTRACT = "2026-05-v2-tool-
|
|
218
|
+
var SDK_VERSION = "0.1.36";
|
|
219
|
+
var SDK_API_CONTRACT = "2026-05-v2-tool-response";
|
|
220
220
|
|
|
221
221
|
// ../shared_libs/play-runtime/coordinator-headers.ts
|
|
222
222
|
var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
|
|
@@ -527,7 +527,7 @@ function sleep(ms) {
|
|
|
527
527
|
var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
|
|
528
528
|
var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
|
|
529
529
|
var EXECUTE_RESPONSE_CONTRACT_HEADER = "x-deepline-execute-response-contract";
|
|
530
|
-
var V2_EXECUTE_RESPONSE_CONTRACT = "v2-tool-
|
|
530
|
+
var V2_EXECUTE_RESPONSE_CONTRACT = "v2-tool-response";
|
|
531
531
|
var COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1e3];
|
|
532
532
|
function sleep2(ms) {
|
|
533
533
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
@@ -796,8 +796,8 @@ var DeeplineClient = class {
|
|
|
796
796
|
/**
|
|
797
797
|
* Execute a tool and return the standard execution envelope.
|
|
798
798
|
*
|
|
799
|
-
* The `
|
|
800
|
-
* `
|
|
799
|
+
* The `toolResponse.raw` field contains the raw tool response.
|
|
800
|
+
* `toolResponse.meta` contains tool/provider metadata.
|
|
801
801
|
* Top-level fields such as `status`, `job_id`, and `billing` describe the
|
|
802
802
|
* Deepline execution envelope.
|
|
803
803
|
*/
|
|
@@ -1624,12 +1624,12 @@ function isRecord2(value) {
|
|
|
1624
1624
|
}
|
|
1625
1625
|
function toV2RawToolOutputPath(path) {
|
|
1626
1626
|
const normalized = String(path || "").trim().replace(/^\./, "");
|
|
1627
|
-
if (!normalized) return "
|
|
1628
|
-
if (normalized === "
|
|
1627
|
+
if (!normalized) return "toolResponse.raw";
|
|
1628
|
+
if (normalized === "toolResponse.raw" || normalized.startsWith("toolResponse.raw.")) {
|
|
1629
1629
|
return normalized;
|
|
1630
1630
|
}
|
|
1631
1631
|
const rawPath = normalized.replace(/^result\.data\.?/, "").replace(/^result\.?/, "").replace(/^data\.?/, "").replace(/^\./, "");
|
|
1632
|
-
return rawPath ? `
|
|
1632
|
+
return rawPath ? `toolResponse.raw.${rawPath}` : "toolResponse.raw";
|
|
1633
1633
|
}
|
|
1634
1634
|
function isMeaningfulValue(value) {
|
|
1635
1635
|
if (value == null) return false;
|
|
@@ -1700,12 +1700,12 @@ function normalizeResultPath(path) {
|
|
|
1700
1700
|
}
|
|
1701
1701
|
function toV2RawToolOutputPathPreservingProviderData(path) {
|
|
1702
1702
|
const normalized = String(path || "").trim().replace(/^\./, "");
|
|
1703
|
-
if (!normalized) return "
|
|
1704
|
-
if (normalized === "
|
|
1703
|
+
if (!normalized) return "toolResponse.raw";
|
|
1704
|
+
if (normalized === "toolResponse.raw" || normalized.startsWith("toolResponse.raw.")) {
|
|
1705
1705
|
return normalized;
|
|
1706
1706
|
}
|
|
1707
1707
|
const rawPath = normalized.replace(/^result\.?/, "").replace(/^\./, "");
|
|
1708
|
-
return rawPath ? `
|
|
1708
|
+
return rawPath ? `toolResponse.raw.${rawPath}` : "toolResponse.raw";
|
|
1709
1709
|
}
|
|
1710
1710
|
function candidateResultPaths(path) {
|
|
1711
1711
|
const candidates = [
|
|
@@ -1949,11 +1949,9 @@ function buildListAccessors(result, lists) {
|
|
|
1949
1949
|
function createToolExecuteResult(input) {
|
|
1950
1950
|
const result = toResultEnvelope(input.result);
|
|
1951
1951
|
const resultRoot = {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
...result.meta ? { meta: result.meta } : {}
|
|
1956
|
-
}
|
|
1952
|
+
toolResponse: {
|
|
1953
|
+
raw: result.data,
|
|
1954
|
+
...result.meta ? { meta: result.meta } : {}
|
|
1957
1955
|
}
|
|
1958
1956
|
};
|
|
1959
1957
|
const targets = buildTargets(
|
|
@@ -1967,16 +1965,26 @@ function createToolExecuteResult(input) {
|
|
|
1967
1965
|
targets,
|
|
1968
1966
|
lists
|
|
1969
1967
|
};
|
|
1968
|
+
const toolResponse = {
|
|
1969
|
+
raw: result.data,
|
|
1970
|
+
...result.meta ? { meta: result.meta } : {}
|
|
1971
|
+
};
|
|
1972
|
+
const extractedValues = buildExtractedAccessors(targets);
|
|
1973
|
+
const extractedLists = buildListAccessors(resultRoot, lists);
|
|
1970
1974
|
const wrapper = {
|
|
1971
1975
|
status: input.status,
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
extractedValues: buildExtractedAccessors(targets),
|
|
1978
|
-
extractedLists: buildListAccessors(resultRoot, lists)
|
|
1976
|
+
...input.jobId ? { job_id: input.jobId } : {},
|
|
1977
|
+
...input.meta ? { meta: input.meta } : {},
|
|
1978
|
+
toolResponse,
|
|
1979
|
+
extractedValues,
|
|
1980
|
+
extractedLists
|
|
1979
1981
|
};
|
|
1982
|
+
Object.defineProperties(wrapper, {
|
|
1983
|
+
toolOutput: {
|
|
1984
|
+
value: toolResponse,
|
|
1985
|
+
enumerable: false
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1980
1988
|
Object.defineProperty(wrapper, "_metadata", {
|
|
1981
1989
|
value: metadata,
|
|
1982
1990
|
enumerable: false
|
|
@@ -2123,7 +2131,7 @@ var DeeplineContext = class {
|
|
|
2123
2131
|
* const tools = await deepline.tools.list();
|
|
2124
2132
|
* const meta = await deepline.tools.get('apollo_people_search');
|
|
2125
2133
|
* const companyLookup = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
|
|
2126
|
-
* const company = companyLookup.
|
|
2134
|
+
* const company = companyLookup.toolResponse.raw;
|
|
2127
2135
|
* ```
|
|
2128
2136
|
*/
|
|
2129
2137
|
get tools() {
|
|
@@ -2251,12 +2259,13 @@ function stringArray(value) {
|
|
|
2251
2259
|
return Array.isArray(value) ? value.map(String) : [];
|
|
2252
2260
|
}
|
|
2253
2261
|
function toolExecutionEnvelopeToResult(fallbackToolId, response) {
|
|
2254
|
-
const raw = response.
|
|
2255
|
-
const meta = response.
|
|
2262
|
+
const raw = response.toolResponse?.raw ?? null;
|
|
2263
|
+
const meta = response.toolResponse?.meta;
|
|
2256
2264
|
const metadata = isRecord3(response._metadata) ? response._metadata.tool : null;
|
|
2257
2265
|
const toolMetadata = isRecord3(metadata) ? metadata : {};
|
|
2258
2266
|
return createToolExecuteResult({
|
|
2259
2267
|
status: typeof response.status === "string" ? response.status : "completed",
|
|
2268
|
+
jobId: typeof response.job_id === "string" ? response.job_id : void 0,
|
|
2260
2269
|
result: {
|
|
2261
2270
|
data: raw,
|
|
2262
2271
|
...isRecord3(meta) ? { meta } : {}
|
|
@@ -2273,7 +2282,8 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response) {
|
|
|
2273
2282
|
idempotent: true,
|
|
2274
2283
|
cached: false,
|
|
2275
2284
|
source: "live"
|
|
2276
|
-
}
|
|
2285
|
+
},
|
|
2286
|
+
meta: isRecord3(response.meta) ? response.meta : void 0
|
|
2277
2287
|
});
|
|
2278
2288
|
}
|
|
2279
2289
|
function defineInput(schema) {
|
|
@@ -2411,17 +2421,13 @@ function normalizeRows2(value) {
|
|
|
2411
2421
|
}
|
|
2412
2422
|
function candidateRoots(payload) {
|
|
2413
2423
|
const roots = [{ path: null, value: payload }];
|
|
2414
|
-
if (isPlainObject(payload) && isPlainObject(payload.
|
|
2415
|
-
roots.push({ path: "
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
path: "toolExecutionResult.toolOutput.raw",
|
|
2422
|
-
value: toolOutput.raw
|
|
2423
|
-
});
|
|
2424
|
-
}
|
|
2424
|
+
if (isPlainObject(payload) && isPlainObject(payload.toolResponse)) {
|
|
2425
|
+
roots.push({ path: "toolResponse", value: payload.toolResponse });
|
|
2426
|
+
if (Object.prototype.hasOwnProperty.call(payload.toolResponse, "raw")) {
|
|
2427
|
+
roots.push({
|
|
2428
|
+
path: "toolResponse.raw",
|
|
2429
|
+
value: payload.toolResponse.raw
|
|
2430
|
+
});
|
|
2425
2431
|
}
|
|
2426
2432
|
}
|
|
2427
2433
|
if (isPlainObject(payload) && isPlainObject(payload.output)) {
|
package/dist/index.mjs
CHANGED
|
@@ -169,8 +169,8 @@ function resolveConfig(options) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// src/version.ts
|
|
172
|
-
var SDK_VERSION = "0.1.
|
|
173
|
-
var SDK_API_CONTRACT = "2026-05-v2-tool-
|
|
172
|
+
var SDK_VERSION = "0.1.36";
|
|
173
|
+
var SDK_API_CONTRACT = "2026-05-v2-tool-response";
|
|
174
174
|
|
|
175
175
|
// ../shared_libs/play-runtime/coordinator-headers.ts
|
|
176
176
|
var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
|
|
@@ -481,7 +481,7 @@ function sleep(ms) {
|
|
|
481
481
|
var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
|
|
482
482
|
var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
|
|
483
483
|
var EXECUTE_RESPONSE_CONTRACT_HEADER = "x-deepline-execute-response-contract";
|
|
484
|
-
var V2_EXECUTE_RESPONSE_CONTRACT = "v2-tool-
|
|
484
|
+
var V2_EXECUTE_RESPONSE_CONTRACT = "v2-tool-response";
|
|
485
485
|
var COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1e3];
|
|
486
486
|
function sleep2(ms) {
|
|
487
487
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
@@ -750,8 +750,8 @@ var DeeplineClient = class {
|
|
|
750
750
|
/**
|
|
751
751
|
* Execute a tool and return the standard execution envelope.
|
|
752
752
|
*
|
|
753
|
-
* The `
|
|
754
|
-
* `
|
|
753
|
+
* The `toolResponse.raw` field contains the raw tool response.
|
|
754
|
+
* `toolResponse.meta` contains tool/provider metadata.
|
|
755
755
|
* Top-level fields such as `status`, `job_id`, and `billing` describe the
|
|
756
756
|
* Deepline execution envelope.
|
|
757
757
|
*/
|
|
@@ -1578,12 +1578,12 @@ function isRecord2(value) {
|
|
|
1578
1578
|
}
|
|
1579
1579
|
function toV2RawToolOutputPath(path) {
|
|
1580
1580
|
const normalized = String(path || "").trim().replace(/^\./, "");
|
|
1581
|
-
if (!normalized) return "
|
|
1582
|
-
if (normalized === "
|
|
1581
|
+
if (!normalized) return "toolResponse.raw";
|
|
1582
|
+
if (normalized === "toolResponse.raw" || normalized.startsWith("toolResponse.raw.")) {
|
|
1583
1583
|
return normalized;
|
|
1584
1584
|
}
|
|
1585
1585
|
const rawPath = normalized.replace(/^result\.data\.?/, "").replace(/^result\.?/, "").replace(/^data\.?/, "").replace(/^\./, "");
|
|
1586
|
-
return rawPath ? `
|
|
1586
|
+
return rawPath ? `toolResponse.raw.${rawPath}` : "toolResponse.raw";
|
|
1587
1587
|
}
|
|
1588
1588
|
function isMeaningfulValue(value) {
|
|
1589
1589
|
if (value == null) return false;
|
|
@@ -1654,12 +1654,12 @@ function normalizeResultPath(path) {
|
|
|
1654
1654
|
}
|
|
1655
1655
|
function toV2RawToolOutputPathPreservingProviderData(path) {
|
|
1656
1656
|
const normalized = String(path || "").trim().replace(/^\./, "");
|
|
1657
|
-
if (!normalized) return "
|
|
1658
|
-
if (normalized === "
|
|
1657
|
+
if (!normalized) return "toolResponse.raw";
|
|
1658
|
+
if (normalized === "toolResponse.raw" || normalized.startsWith("toolResponse.raw.")) {
|
|
1659
1659
|
return normalized;
|
|
1660
1660
|
}
|
|
1661
1661
|
const rawPath = normalized.replace(/^result\.?/, "").replace(/^\./, "");
|
|
1662
|
-
return rawPath ? `
|
|
1662
|
+
return rawPath ? `toolResponse.raw.${rawPath}` : "toolResponse.raw";
|
|
1663
1663
|
}
|
|
1664
1664
|
function candidateResultPaths(path) {
|
|
1665
1665
|
const candidates = [
|
|
@@ -1903,11 +1903,9 @@ function buildListAccessors(result, lists) {
|
|
|
1903
1903
|
function createToolExecuteResult(input) {
|
|
1904
1904
|
const result = toResultEnvelope(input.result);
|
|
1905
1905
|
const resultRoot = {
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
...result.meta ? { meta: result.meta } : {}
|
|
1910
|
-
}
|
|
1906
|
+
toolResponse: {
|
|
1907
|
+
raw: result.data,
|
|
1908
|
+
...result.meta ? { meta: result.meta } : {}
|
|
1911
1909
|
}
|
|
1912
1910
|
};
|
|
1913
1911
|
const targets = buildTargets(
|
|
@@ -1921,16 +1919,26 @@ function createToolExecuteResult(input) {
|
|
|
1921
1919
|
targets,
|
|
1922
1920
|
lists
|
|
1923
1921
|
};
|
|
1922
|
+
const toolResponse = {
|
|
1923
|
+
raw: result.data,
|
|
1924
|
+
...result.meta ? { meta: result.meta } : {}
|
|
1925
|
+
};
|
|
1926
|
+
const extractedValues = buildExtractedAccessors(targets);
|
|
1927
|
+
const extractedLists = buildListAccessors(resultRoot, lists);
|
|
1924
1928
|
const wrapper = {
|
|
1925
1929
|
status: input.status,
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
extractedValues: buildExtractedAccessors(targets),
|
|
1932
|
-
extractedLists: buildListAccessors(resultRoot, lists)
|
|
1930
|
+
...input.jobId ? { job_id: input.jobId } : {},
|
|
1931
|
+
...input.meta ? { meta: input.meta } : {},
|
|
1932
|
+
toolResponse,
|
|
1933
|
+
extractedValues,
|
|
1934
|
+
extractedLists
|
|
1933
1935
|
};
|
|
1936
|
+
Object.defineProperties(wrapper, {
|
|
1937
|
+
toolOutput: {
|
|
1938
|
+
value: toolResponse,
|
|
1939
|
+
enumerable: false
|
|
1940
|
+
}
|
|
1941
|
+
});
|
|
1934
1942
|
Object.defineProperty(wrapper, "_metadata", {
|
|
1935
1943
|
value: metadata,
|
|
1936
1944
|
enumerable: false
|
|
@@ -2077,7 +2085,7 @@ var DeeplineContext = class {
|
|
|
2077
2085
|
* const tools = await deepline.tools.list();
|
|
2078
2086
|
* const meta = await deepline.tools.get('apollo_people_search');
|
|
2079
2087
|
* const companyLookup = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
|
|
2080
|
-
* const company = companyLookup.
|
|
2088
|
+
* const company = companyLookup.toolResponse.raw;
|
|
2081
2089
|
* ```
|
|
2082
2090
|
*/
|
|
2083
2091
|
get tools() {
|
|
@@ -2205,12 +2213,13 @@ function stringArray(value) {
|
|
|
2205
2213
|
return Array.isArray(value) ? value.map(String) : [];
|
|
2206
2214
|
}
|
|
2207
2215
|
function toolExecutionEnvelopeToResult(fallbackToolId, response) {
|
|
2208
|
-
const raw = response.
|
|
2209
|
-
const meta = response.
|
|
2216
|
+
const raw = response.toolResponse?.raw ?? null;
|
|
2217
|
+
const meta = response.toolResponse?.meta;
|
|
2210
2218
|
const metadata = isRecord3(response._metadata) ? response._metadata.tool : null;
|
|
2211
2219
|
const toolMetadata = isRecord3(metadata) ? metadata : {};
|
|
2212
2220
|
return createToolExecuteResult({
|
|
2213
2221
|
status: typeof response.status === "string" ? response.status : "completed",
|
|
2222
|
+
jobId: typeof response.job_id === "string" ? response.job_id : void 0,
|
|
2214
2223
|
result: {
|
|
2215
2224
|
data: raw,
|
|
2216
2225
|
...isRecord3(meta) ? { meta } : {}
|
|
@@ -2227,7 +2236,8 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response) {
|
|
|
2227
2236
|
idempotent: true,
|
|
2228
2237
|
cached: false,
|
|
2229
2238
|
source: "live"
|
|
2230
|
-
}
|
|
2239
|
+
},
|
|
2240
|
+
meta: isRecord3(response.meta) ? response.meta : void 0
|
|
2231
2241
|
});
|
|
2232
2242
|
}
|
|
2233
2243
|
function defineInput(schema) {
|
|
@@ -2365,17 +2375,13 @@ function normalizeRows2(value) {
|
|
|
2365
2375
|
}
|
|
2366
2376
|
function candidateRoots(payload) {
|
|
2367
2377
|
const roots = [{ path: null, value: payload }];
|
|
2368
|
-
if (isPlainObject(payload) && isPlainObject(payload.
|
|
2369
|
-
roots.push({ path: "
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
path: "toolExecutionResult.toolOutput.raw",
|
|
2376
|
-
value: toolOutput.raw
|
|
2377
|
-
});
|
|
2378
|
-
}
|
|
2378
|
+
if (isPlainObject(payload) && isPlainObject(payload.toolResponse)) {
|
|
2379
|
+
roots.push({ path: "toolResponse", value: payload.toolResponse });
|
|
2380
|
+
if (Object.prototype.hasOwnProperty.call(payload.toolResponse, "raw")) {
|
|
2381
|
+
roots.push({
|
|
2382
|
+
path: "toolResponse.raw",
|
|
2383
|
+
value: payload.toolResponse.raw
|
|
2384
|
+
});
|
|
2379
2385
|
}
|
|
2380
2386
|
}
|
|
2381
2387
|
if (isPlainObject(payload) && isPlainObject(payload.output)) {
|
|
@@ -62,6 +62,7 @@ import type { PlayRuntimeManifestMap } from '../../../shared_libs/plays/compiler
|
|
|
62
62
|
import {
|
|
63
63
|
derivePlayRowIdentity,
|
|
64
64
|
derivePlayRowIdentityFromKey,
|
|
65
|
+
deriveToolRequestIdentity,
|
|
65
66
|
} from '../../../shared_libs/plays/row-identity';
|
|
66
67
|
import {
|
|
67
68
|
getTopLevelPipelineSubsteps,
|
|
@@ -95,6 +96,7 @@ import {
|
|
|
95
96
|
type WorkerDatasetHandle,
|
|
96
97
|
type WorkerDatasetInput,
|
|
97
98
|
} from './runtime/dataset-handles';
|
|
99
|
+
import { runWorkerRuntimeReceiptBoundary } from './runtime/receipts';
|
|
98
100
|
// The harness stub forwards leaf calls (validation, runtime-api HTTP) into
|
|
99
101
|
// the long-lived Play Harness Worker via env.HARNESS. We import the
|
|
100
102
|
// `setHarnessBinding` setter eagerly so it's available the moment
|
|
@@ -3013,6 +3015,19 @@ function createMinimalWorkerCtx(
|
|
|
3013
3015
|
};
|
|
3014
3016
|
const rootGovernance = req.playCallGovernance;
|
|
3015
3017
|
const rootRunId = rootGovernance?.rootRunId ?? req.runId;
|
|
3018
|
+
const executeWithRuntimeReceipt = async <T>(
|
|
3019
|
+
key: string,
|
|
3020
|
+
execute: () => Promise<T> | T,
|
|
3021
|
+
): Promise<T> =>
|
|
3022
|
+
runWorkerRuntimeReceiptBoundary({
|
|
3023
|
+
baseUrl: req.baseUrl,
|
|
3024
|
+
executorToken: req.executorToken,
|
|
3025
|
+
playName: req.playName,
|
|
3026
|
+
runId: req.runId,
|
|
3027
|
+
key,
|
|
3028
|
+
postRuntimeApi,
|
|
3029
|
+
execute,
|
|
3030
|
+
});
|
|
3016
3031
|
// Local ancestry chain that always ENDS with the currently-executing play
|
|
3017
3032
|
// (req.playName). The /api/v2/plays/run lineage validator requires the
|
|
3018
3033
|
// submitted ancestry's tail to equal the executor token's play name (i.e.
|
|
@@ -3743,13 +3758,14 @@ function createMinimalWorkerCtx(
|
|
|
3743
3758
|
},
|
|
3744
3759
|
async step<T>(name: string, callback: () => Promise<T> | T): Promise<T> {
|
|
3745
3760
|
assertNotAborted(abortSignal);
|
|
3746
|
-
|
|
3761
|
+
const normalizedName = name.trim();
|
|
3762
|
+
if (!normalizedName) {
|
|
3747
3763
|
throw new Error('ctx.step(name, callback) requires a name.');
|
|
3748
3764
|
}
|
|
3749
3765
|
// Static pipeline JS blocks are already Workflow steps in the Workers
|
|
3750
3766
|
// backend. Nesting another `step.do` here can leave preview runs parked
|
|
3751
3767
|
// inside the JS stage before they reach subsequent event waits.
|
|
3752
|
-
return await callback
|
|
3768
|
+
return await executeWithRuntimeReceipt(`step:${normalizedName}`, callback);
|
|
3753
3769
|
},
|
|
3754
3770
|
async runSteps<T>(
|
|
3755
3771
|
program: WorkerStepProgram,
|
|
@@ -3909,21 +3925,33 @@ function createMinimalWorkerCtx(
|
|
|
3909
3925
|
input: Record<string, unknown>,
|
|
3910
3926
|
): Promise<unknown> => {
|
|
3911
3927
|
assertNotAborted(abortSignal);
|
|
3912
|
-
return
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3928
|
+
return await executeWithRuntimeReceipt(
|
|
3929
|
+
deriveToolRequestIdentity({ toolId, requestInput: input }),
|
|
3930
|
+
() =>
|
|
3931
|
+
executeToolWithLifecycle(
|
|
3932
|
+
req,
|
|
3933
|
+
{ id: key, toolId, input },
|
|
3934
|
+
workflowStep,
|
|
3935
|
+
callbacks,
|
|
3936
|
+
),
|
|
3917
3937
|
);
|
|
3918
3938
|
},
|
|
3919
3939
|
tools: {
|
|
3920
3940
|
async execute(requestArg: unknown): Promise<unknown> {
|
|
3921
3941
|
assertNotAborted(abortSignal);
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3942
|
+
const request = normalizeToolExecuteArgs(requestArg);
|
|
3943
|
+
return await executeWithRuntimeReceipt(
|
|
3944
|
+
deriveToolRequestIdentity({
|
|
3945
|
+
toolId: request.toolId,
|
|
3946
|
+
requestInput: request.input,
|
|
3947
|
+
}),
|
|
3948
|
+
() =>
|
|
3949
|
+
executeToolWithLifecycle(
|
|
3950
|
+
req,
|
|
3951
|
+
request,
|
|
3952
|
+
workflowStep,
|
|
3953
|
+
callbacks,
|
|
3954
|
+
),
|
|
3927
3955
|
);
|
|
3928
3956
|
},
|
|
3929
3957
|
},
|