deepline 0.2.74 → 0.3.0

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.
@@ -1030,7 +1030,11 @@ var SDK_RELEASE = {
1030
1030
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1031
1031
  // exposed storage-dependent synchronous access. This deliberate minor
1032
1032
  // release keeps lazy paging semantics independent of row residency.
1033
- version: "0.2.74",
1033
+ // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
1034
+ // available at toolResponse.rawV2 while toolResponse.raw and all declared
1035
+ // getters keep their established compatibility behavior.
1036
+ version: "0.3.0",
1037
+ updateSummary: "New raw-v2 tool responses preserve complete scrubbed provider envelopes at toolResponse.rawV2, including JSON:API included resources, links, cursors, and totals. Existing toolResponse.raw and declared getters keep working unchanged.",
1034
1038
  contracts: {
1035
1039
  api: {
1036
1040
  name: "sdk-http-api",
@@ -3745,12 +3749,33 @@ function normalizePlayRuntimeEnvironment(value) {
3745
3749
  return typeof value === "string" && PLAY_RUNTIME_ENVIRONMENTS.includes(value) ? value : null;
3746
3750
  }
3747
3751
 
3752
+ // ../shared_libs/play-runtime/tool-response-contract.ts
3753
+ var RAW_V2_TOOL_RESPONSE_CONTRACT = "raw-v2";
3754
+ function legacyRawFromToolResponseRawV2(rawV2, view, responseMeta) {
3755
+ const legacyRaw = view === "data" && rawV2 && typeof rawV2 === "object" && !Array.isArray(rawV2) ? rawV2.data : rawV2;
3756
+ const deeplineBilling = responseMeta?.deepline_billing;
3757
+ if (view === "rawV2" && deeplineBilling !== void 0 && legacyRaw && typeof legacyRaw === "object" && !Array.isArray(legacyRaw)) {
3758
+ return {
3759
+ ...legacyRaw,
3760
+ deepline_billing: deeplineBilling
3761
+ };
3762
+ }
3763
+ return legacyRaw;
3764
+ }
3765
+ function providerMetaFromToolResponseRawV2(rawV2, view) {
3766
+ if (view !== "data" || !rawV2 || typeof rawV2 !== "object" || Array.isArray(rawV2)) {
3767
+ return void 0;
3768
+ }
3769
+ const meta = rawV2.meta;
3770
+ return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : void 0;
3771
+ }
3772
+
3748
3773
  // src/client.ts
3749
3774
  var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
3750
3775
  var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
3751
3776
  var EXECUTE_RESPONSE_CONTRACT_HEADER = "x-deepline-execute-response-contract";
3752
3777
  var EXECUTE_RESPONSE_INTENT_HEADER = "x-deepline-execute-response-intent";
3753
- var V2_EXECUTE_RESPONSE_CONTRACT = "v2-tool-response";
3778
+ var RAW_V2_EXECUTE_RESPONSE_CONTRACT = RAW_V2_TOOL_RESPONSE_CONTRACT;
3754
3779
  var COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1e3];
3755
3780
  var REGISTER_PLAY_ARTIFACTS_COMPILE_CONCURRENCY = 3;
3756
3781
  var REGISTER_PLAY_ARTIFACTS_MAX_BATCH_COUNT = 3;
@@ -3965,6 +3990,50 @@ function requireTargetBillingIdempotencyKey(value) {
3965
3990
  function isRecord7(value) {
3966
3991
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
3967
3992
  }
3993
+ function materializeToolExecutionResponse(response) {
3994
+ const toolResponse = response.toolResponse;
3995
+ if (!toolResponse && isRecord7(response.result)) {
3996
+ const legacyResult = response.result;
3997
+ if (Object.prototype.hasOwnProperty.call(legacyResult, "data")) {
3998
+ const legacyMeta = isRecord7(legacyResult.meta) ? legacyResult.meta : void 0;
3999
+ return {
4000
+ ...response,
4001
+ toolResponse: {
4002
+ raw: legacyResult.data,
4003
+ ...legacyMeta ? { meta: legacyMeta } : {}
4004
+ }
4005
+ };
4006
+ }
4007
+ }
4008
+ if (!toolResponse || Object.prototype.hasOwnProperty.call(toolResponse, "raw")) {
4009
+ return response;
4010
+ }
4011
+ const rawV2 = toolResponse.rawV2;
4012
+ const view = toolResponse.view;
4013
+ const providerMeta = providerMetaFromToolResponseRawV2(
4014
+ rawV2,
4015
+ view ?? "rawV2"
4016
+ );
4017
+ const responseMeta = isRecord7(toolResponse.responseMeta) ? toolResponse.responseMeta : void 0;
4018
+ return {
4019
+ ...response,
4020
+ toolResponse: {
4021
+ ...toolResponse,
4022
+ raw: legacyRawFromToolResponseRawV2(
4023
+ rawV2,
4024
+ view ?? "rawV2",
4025
+ responseMeta
4026
+ ),
4027
+ ...toolResponse.meta || providerMeta || responseMeta ? {
4028
+ meta: {
4029
+ ...toolResponse.meta ?? {},
4030
+ ...providerMeta ?? {},
4031
+ ...responseMeta ?? {}
4032
+ }
4033
+ } : {}
4034
+ }
4035
+ };
4036
+ }
3968
4037
  function isPrebuiltPlayDescription(play) {
3969
4038
  return play.origin === "prebuilt" || play.ownerType === "deepline";
3970
4039
  }
@@ -4514,14 +4583,14 @@ var DeeplineClient = class {
4514
4583
  */
4515
4584
  async executeTool(toolId, input2, options) {
4516
4585
  const headers = {
4517
- [EXECUTE_RESPONSE_CONTRACT_HEADER]: V2_EXECUTE_RESPONSE_CONTRACT,
4586
+ [EXECUTE_RESPONSE_CONTRACT_HEADER]: RAW_V2_EXECUTE_RESPONSE_CONTRACT,
4518
4587
  [TOOL_EXECUTION_ERROR_SCHEMA_HEADER]: String(
4519
4588
  TOOL_EXECUTION_ERROR_SCHEMA_VERSION
4520
4589
  ),
4521
4590
  ...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
4522
4591
  [EXECUTE_RESPONSE_INTENT_HEADER]: options?.responseIntent ?? "raw"
4523
4592
  };
4524
- return this.http.post(
4593
+ const response = await this.http.post(
4525
4594
  `/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
4526
4595
  {
4527
4596
  payload: input2,
@@ -4535,6 +4604,7 @@ var DeeplineClient = class {
4535
4604
  toolId
4536
4605
  }
4537
4606
  );
4607
+ return materializeToolExecutionResponse(response);
4538
4608
  }
4539
4609
  /**
4540
4610
  * Back-compatible alias for {@link executeTool}.
@@ -40850,9 +40920,7 @@ function shouldSkipSelfUpdate() {
40850
40920
  function parseSemver(version) {
40851
40921
  const trimmed = version?.trim();
40852
40922
  if (!trimmed) return null;
40853
- const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(
40854
- trimmed
40855
- );
40923
+ const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(trimmed);
40856
40924
  if (!match) return null;
40857
40925
  return {
40858
40926
  major: Number(match[1]),
@@ -40943,7 +41011,12 @@ async function maybeAutoUpdateAndRelaunch(response) {
40943
41011
  );
40944
41012
  return false;
40945
41013
  }
40946
- process.stderr.write("Deepline SDK/CLI updated; rerunning command.\n");
41014
+ const updateSummary = response.update_summary ? `
41015
+ What changed in ${response.update_summary.version}: ${response.update_summary.summary}` : "";
41016
+ process.stderr.write(
41017
+ `Deepline SDK/CLI updated; rerunning command.${updateSummary}
41018
+ `
41019
+ );
40947
41020
  const exitCode = await relaunchCurrentCommand(plan);
40948
41021
  process.exit(exitCode);
40949
41022
  return true;
@@ -724,6 +724,10 @@ type ToolResultListAccessor<T = Record<string, unknown>, TKey extends string = s
724
724
  };
725
725
  type ToolResponseEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
726
726
  raw: TData;
727
+ /** Complete parsed and scrubbed provider response, materialized from raw-v2. */
728
+ rawV2?: unknown;
729
+ /** Durable descriptor for deriving the legacy raw view from `rawV2`. */
730
+ view?: 'data' | 'rawV2';
727
731
  meta?: TMeta;
728
732
  };
729
733
  type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> = {
@@ -765,8 +769,9 @@ type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Par
765
769
  * Canonical result returned by Deepline tool execution.
766
770
  *
767
771
  * The top-level object is Deepline-owned execution metadata and semantic
768
- * extraction state. Raw tool/provider data lives under `toolResponse.raw`;
769
- * response metadata lives under `toolResponse.meta`. Semantic single-value
772
+ * extraction state. The canonical provider response lives under
773
+ * `toolResponse.rawV2`; `toolResponse.raw` remains the legacy compatibility
774
+ * projection. Response metadata lives under `toolResponse.meta`. Semantic single-value
770
775
  * getters live under `extractedValues.<name>.get()`, and list getters live
771
776
  * under `extractedLists.<name>.get()`.
772
777
  *
@@ -724,6 +724,10 @@ type ToolResultListAccessor<T = Record<string, unknown>, TKey extends string = s
724
724
  };
725
725
  type ToolResponseEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
726
726
  raw: TData;
727
+ /** Complete parsed and scrubbed provider response, materialized from raw-v2. */
728
+ rawV2?: unknown;
729
+ /** Durable descriptor for deriving the legacy raw view from `rawV2`. */
730
+ view?: 'data' | 'rawV2';
727
731
  meta?: TMeta;
728
732
  };
729
733
  type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> = {
@@ -765,8 +769,9 @@ type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Par
765
769
  * Canonical result returned by Deepline tool execution.
766
770
  *
767
771
  * The top-level object is Deepline-owned execution metadata and semantic
768
- * extraction state. Raw tool/provider data lives under `toolResponse.raw`;
769
- * response metadata lives under `toolResponse.meta`. Semantic single-value
772
+ * extraction state. The canonical provider response lives under
773
+ * `toolResponse.rawV2`; `toolResponse.raw` remains the legacy compatibility
774
+ * projection. Response metadata lives under `toolResponse.meta`. Semantic single-value
770
775
  * getters live under `extractedValues.<name>.get()`, and list getters live
771
776
  * under `extractedLists.<name>.get()`.
772
777
  *
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { e as PlayRuntimeBackendId, c as PlayCompilerManifest, D as DeeplineError, f as ToolExecutionError, g as ToolExecutionErrorOptions, h as PlayAuthoringColumnMap, i as PlayAuthoringColumnResolver, j as PlayAuthoringRuntimeContext, k as PlayAuthoringConditionalStepResolver, l as PlayAuthoringCsvInput, m as PlayAuthoringCsvOptions, n as PlayAuthoringDatasetBuilder, o as PlayAuthoringDatasetColumnDefinition, p as PlayAuthoringDatasetColumnRunInput, q as ToolExecuteResult, r as PlayAuthoringReferenceLike, s as PlayReturnObject$1, t as PlayAuthoringDefineConfig, u as PlayAuthoringDefinedPlay, v as PlayAuthoringFetchOptions, w as PlayAuthoringFileInput, x as PlayAuthoringBindings, y as PlayAuthoringCallExecution, z as PlayAuthoringCallOptions, A as PlayAuthoringFetchResponse, B as PlayAuthoringInputContract, C as PlayAuthoringStepProgramStep, E as PlayAuthoringRuntimeStepOptions, F as PlaySqlListenerDeclaration, G as PlaySqlListenerEvent, H as PlaySqlListenerOperation, I as PlaySqlQuery, J as PlayAuthoringStepOptions, K as PlayAuthoringStepProgram, L as PlayAuthoringStepProgramResolver, M as PlayAuthoringStepResolver, N as PlayToolExecutionRequest, O as PlayAuthoringStepProgramOptions } from './compiler-manifest-DFuz9-0_.mjs';
2
- export { Q as DEEPLINE_EXTRACTOR_TARGETS, R as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, S as DeeplineEmailStatusGetterValue, U as DeeplineExtractorTarget, V as DeeplineGetterValue, W as DeeplineGetterValueMap, X as JOB_CHANGE_STATUS_VALUES, Y as JobChangeStatus, Z as PHONE_STATUS_VALUES, _ as PhoneStatus, $ as PlayDataset, a0 as PlayDatasetInput, a1 as PreviousCell, a2 as ProviderTransientError, a3 as ProviderTransientErrorCategory, a4 as ProviderUnavailableError, a5 as ProviderUnavailableReason, a6 as ToolExecutionErrorCategory, a7 as ToolExecutionErrorOrigin, a8 as ToolExecutionFailureV1, a9 as ToolExecutionNetworkKind, aa as ToolExecutionNetworkScope, ab as getProviderUnavailableReason, ac as isDeeplineExtractorTarget, ad as isProviderUnavailable, ae as isProviderWaterfallUnavailableError } from './compiler-manifest-DFuz9-0_.mjs';
1
+ import { e as PlayRuntimeBackendId, c as PlayCompilerManifest, D as DeeplineError, f as ToolExecutionError, g as ToolExecutionErrorOptions, h as PlayAuthoringColumnMap, i as PlayAuthoringColumnResolver, j as PlayAuthoringRuntimeContext, k as PlayAuthoringConditionalStepResolver, l as PlayAuthoringCsvInput, m as PlayAuthoringCsvOptions, n as PlayAuthoringDatasetBuilder, o as PlayAuthoringDatasetColumnDefinition, p as PlayAuthoringDatasetColumnRunInput, q as ToolExecuteResult, r as PlayAuthoringReferenceLike, s as PlayReturnObject$1, t as PlayAuthoringDefineConfig, u as PlayAuthoringDefinedPlay, v as PlayAuthoringFetchOptions, w as PlayAuthoringFileInput, x as PlayAuthoringBindings, y as PlayAuthoringCallExecution, z as PlayAuthoringCallOptions, A as PlayAuthoringFetchResponse, B as PlayAuthoringInputContract, C as PlayAuthoringStepProgramStep, E as PlayAuthoringRuntimeStepOptions, F as PlaySqlListenerDeclaration, G as PlaySqlListenerEvent, H as PlaySqlListenerOperation, I as PlaySqlQuery, J as PlayAuthoringStepOptions, K as PlayAuthoringStepProgram, L as PlayAuthoringStepProgramResolver, M as PlayAuthoringStepResolver, N as PlayToolExecutionRequest, O as PlayAuthoringStepProgramOptions } from './compiler-manifest-BX85pKXW.mjs';
2
+ export { Q as DEEPLINE_EXTRACTOR_TARGETS, R as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, S as DeeplineEmailStatusGetterValue, U as DeeplineExtractorTarget, V as DeeplineGetterValue, W as DeeplineGetterValueMap, X as JOB_CHANGE_STATUS_VALUES, Y as JobChangeStatus, Z as PHONE_STATUS_VALUES, _ as PhoneStatus, $ as PlayDataset, a0 as PlayDatasetInput, a1 as PreviousCell, a2 as ProviderTransientError, a3 as ProviderTransientErrorCategory, a4 as ProviderUnavailableError, a5 as ProviderUnavailableReason, a6 as ToolExecutionErrorCategory, a7 as ToolExecutionErrorOrigin, a8 as ToolExecutionFailureV1, a9 as ToolExecutionNetworkKind, aa as ToolExecutionNetworkScope, ab as getProviderUnavailableReason, ac as isDeeplineExtractorTarget, ad as isProviderUnavailable, ae as isProviderWaterfallUnavailableError } from './compiler-manifest-BX85pKXW.mjs';
3
3
  import '@sinclair/typebox';
4
4
 
5
5
  declare const FIXTURE_BEHAVIOR_VERSION: 1;
@@ -338,12 +338,19 @@ interface ToolDefinition {
338
338
  expression?: string;
339
339
  meaning?: string;
340
340
  };
341
+ canonicalToolResponse?: {
342
+ expression?: string;
343
+ meaning?: string;
344
+ };
341
345
  invalidGetterHint?: string;
342
346
  };
343
347
  toolExecutionResult?: {
344
348
  type?: 'ToolExecutionResult';
345
349
  toolResponse?: {
346
350
  raw?: string;
351
+ rawV2?: string;
352
+ view?: string;
353
+ responseMeta?: string;
347
354
  meta?: string;
348
355
  };
349
356
  meta?: string;
@@ -1948,7 +1955,8 @@ type ExecuteToolRawOptions = {
1948
1955
  /**
1949
1956
  * Standard provider/tool execution envelope returned by low-level SDK calls.
1950
1957
  *
1951
- * `toolResponse.raw` contains the provider result. `extractedValues` and
1958
+ * `toolResponse.rawV2` contains the complete scrubbed provider response;
1959
+ * `toolResponse.raw` is derived locally as the legacy provider-result projection. `extractedValues` and
1952
1960
  * `extractedLists` contain Deepline-normalized getters when the tool exposes
1953
1961
  * them. Billing fields are Deepline-facing and must not expose provider spend.
1954
1962
  */
@@ -1958,7 +1966,10 @@ type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
1958
1966
  meta?: Record<string, unknown>;
1959
1967
  toolResponse: {
1960
1968
  raw: TData;
1969
+ rawV2?: unknown;
1970
+ view?: 'data' | 'rawV2';
1961
1971
  meta?: TMeta;
1972
+ responseMeta?: TMeta;
1962
1973
  };
1963
1974
  extractedLists?: Record<string, unknown>;
1964
1975
  extractedValues?: Record<string, unknown>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { e as PlayRuntimeBackendId, c as PlayCompilerManifest, D as DeeplineError, f as ToolExecutionError, g as ToolExecutionErrorOptions, h as PlayAuthoringColumnMap, i as PlayAuthoringColumnResolver, j as PlayAuthoringRuntimeContext, k as PlayAuthoringConditionalStepResolver, l as PlayAuthoringCsvInput, m as PlayAuthoringCsvOptions, n as PlayAuthoringDatasetBuilder, o as PlayAuthoringDatasetColumnDefinition, p as PlayAuthoringDatasetColumnRunInput, q as ToolExecuteResult, r as PlayAuthoringReferenceLike, s as PlayReturnObject$1, t as PlayAuthoringDefineConfig, u as PlayAuthoringDefinedPlay, v as PlayAuthoringFetchOptions, w as PlayAuthoringFileInput, x as PlayAuthoringBindings, y as PlayAuthoringCallExecution, z as PlayAuthoringCallOptions, A as PlayAuthoringFetchResponse, B as PlayAuthoringInputContract, C as PlayAuthoringStepProgramStep, E as PlayAuthoringRuntimeStepOptions, F as PlaySqlListenerDeclaration, G as PlaySqlListenerEvent, H as PlaySqlListenerOperation, I as PlaySqlQuery, J as PlayAuthoringStepOptions, K as PlayAuthoringStepProgram, L as PlayAuthoringStepProgramResolver, M as PlayAuthoringStepResolver, N as PlayToolExecutionRequest, O as PlayAuthoringStepProgramOptions } from './compiler-manifest-DFuz9-0_.js';
2
- export { Q as DEEPLINE_EXTRACTOR_TARGETS, R as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, S as DeeplineEmailStatusGetterValue, U as DeeplineExtractorTarget, V as DeeplineGetterValue, W as DeeplineGetterValueMap, X as JOB_CHANGE_STATUS_VALUES, Y as JobChangeStatus, Z as PHONE_STATUS_VALUES, _ as PhoneStatus, $ as PlayDataset, a0 as PlayDatasetInput, a1 as PreviousCell, a2 as ProviderTransientError, a3 as ProviderTransientErrorCategory, a4 as ProviderUnavailableError, a5 as ProviderUnavailableReason, a6 as ToolExecutionErrorCategory, a7 as ToolExecutionErrorOrigin, a8 as ToolExecutionFailureV1, a9 as ToolExecutionNetworkKind, aa as ToolExecutionNetworkScope, ab as getProviderUnavailableReason, ac as isDeeplineExtractorTarget, ad as isProviderUnavailable, ae as isProviderWaterfallUnavailableError } from './compiler-manifest-DFuz9-0_.js';
1
+ import { e as PlayRuntimeBackendId, c as PlayCompilerManifest, D as DeeplineError, f as ToolExecutionError, g as ToolExecutionErrorOptions, h as PlayAuthoringColumnMap, i as PlayAuthoringColumnResolver, j as PlayAuthoringRuntimeContext, k as PlayAuthoringConditionalStepResolver, l as PlayAuthoringCsvInput, m as PlayAuthoringCsvOptions, n as PlayAuthoringDatasetBuilder, o as PlayAuthoringDatasetColumnDefinition, p as PlayAuthoringDatasetColumnRunInput, q as ToolExecuteResult, r as PlayAuthoringReferenceLike, s as PlayReturnObject$1, t as PlayAuthoringDefineConfig, u as PlayAuthoringDefinedPlay, v as PlayAuthoringFetchOptions, w as PlayAuthoringFileInput, x as PlayAuthoringBindings, y as PlayAuthoringCallExecution, z as PlayAuthoringCallOptions, A as PlayAuthoringFetchResponse, B as PlayAuthoringInputContract, C as PlayAuthoringStepProgramStep, E as PlayAuthoringRuntimeStepOptions, F as PlaySqlListenerDeclaration, G as PlaySqlListenerEvent, H as PlaySqlListenerOperation, I as PlaySqlQuery, J as PlayAuthoringStepOptions, K as PlayAuthoringStepProgram, L as PlayAuthoringStepProgramResolver, M as PlayAuthoringStepResolver, N as PlayToolExecutionRequest, O as PlayAuthoringStepProgramOptions } from './compiler-manifest-BX85pKXW.js';
2
+ export { Q as DEEPLINE_EXTRACTOR_TARGETS, R as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, S as DeeplineEmailStatusGetterValue, U as DeeplineExtractorTarget, V as DeeplineGetterValue, W as DeeplineGetterValueMap, X as JOB_CHANGE_STATUS_VALUES, Y as JobChangeStatus, Z as PHONE_STATUS_VALUES, _ as PhoneStatus, $ as PlayDataset, a0 as PlayDatasetInput, a1 as PreviousCell, a2 as ProviderTransientError, a3 as ProviderTransientErrorCategory, a4 as ProviderUnavailableError, a5 as ProviderUnavailableReason, a6 as ToolExecutionErrorCategory, a7 as ToolExecutionErrorOrigin, a8 as ToolExecutionFailureV1, a9 as ToolExecutionNetworkKind, aa as ToolExecutionNetworkScope, ab as getProviderUnavailableReason, ac as isDeeplineExtractorTarget, ad as isProviderUnavailable, ae as isProviderWaterfallUnavailableError } from './compiler-manifest-BX85pKXW.js';
3
3
  import '@sinclair/typebox';
4
4
 
5
5
  declare const FIXTURE_BEHAVIOR_VERSION: 1;
@@ -338,12 +338,19 @@ interface ToolDefinition {
338
338
  expression?: string;
339
339
  meaning?: string;
340
340
  };
341
+ canonicalToolResponse?: {
342
+ expression?: string;
343
+ meaning?: string;
344
+ };
341
345
  invalidGetterHint?: string;
342
346
  };
343
347
  toolExecutionResult?: {
344
348
  type?: 'ToolExecutionResult';
345
349
  toolResponse?: {
346
350
  raw?: string;
351
+ rawV2?: string;
352
+ view?: string;
353
+ responseMeta?: string;
347
354
  meta?: string;
348
355
  };
349
356
  meta?: string;
@@ -1948,7 +1955,8 @@ type ExecuteToolRawOptions = {
1948
1955
  /**
1949
1956
  * Standard provider/tool execution envelope returned by low-level SDK calls.
1950
1957
  *
1951
- * `toolResponse.raw` contains the provider result. `extractedValues` and
1958
+ * `toolResponse.rawV2` contains the complete scrubbed provider response;
1959
+ * `toolResponse.raw` is derived locally as the legacy provider-result projection. `extractedValues` and
1952
1960
  * `extractedLists` contain Deepline-normalized getters when the tool exposes
1953
1961
  * them. Billing fields are Deepline-facing and must not expose provider spend.
1954
1962
  */
@@ -1958,7 +1966,10 @@ type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
1958
1966
  meta?: Record<string, unknown>;
1959
1967
  toolResponse: {
1960
1968
  raw: TData;
1969
+ rawV2?: unknown;
1970
+ view?: 'data' | 'rawV2';
1961
1971
  meta?: TMeta;
1972
+ responseMeta?: TMeta;
1962
1973
  };
1963
1974
  extractedLists?: Record<string, unknown>;
1964
1975
  extractedValues?: Record<string, unknown>;
package/dist/index.js CHANGED
@@ -780,7 +780,11 @@ var SDK_RELEASE = {
780
780
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
781
781
  // exposed storage-dependent synchronous access. This deliberate minor
782
782
  // release keeps lazy paging semantics independent of row residency.
783
- version: "0.2.74",
783
+ // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
784
+ // available at toolResponse.rawV2 while toolResponse.raw and all declared
785
+ // getters keep their established compatibility behavior.
786
+ version: "0.3.0",
787
+ updateSummary: "New raw-v2 tool responses preserve complete scrubbed provider envelopes at toolResponse.rawV2, including JSON:API included resources, links, cursors, and totals. Existing toolResponse.raw and declared getters keep working unchanged.",
784
788
  contracts: {
785
789
  api: {
786
790
  name: "sdk-http-api",
@@ -3495,12 +3499,33 @@ function normalizePlayRuntimeEnvironment(value) {
3495
3499
  return typeof value === "string" && PLAY_RUNTIME_ENVIRONMENTS.includes(value) ? value : null;
3496
3500
  }
3497
3501
 
3502
+ // ../shared_libs/play-runtime/tool-response-contract.ts
3503
+ var RAW_V2_TOOL_RESPONSE_CONTRACT = "raw-v2";
3504
+ function legacyRawFromToolResponseRawV2(rawV2, view, responseMeta) {
3505
+ const legacyRaw = view === "data" && rawV2 && typeof rawV2 === "object" && !Array.isArray(rawV2) ? rawV2.data : rawV2;
3506
+ const deeplineBilling = responseMeta?.deepline_billing;
3507
+ if (view === "rawV2" && deeplineBilling !== void 0 && legacyRaw && typeof legacyRaw === "object" && !Array.isArray(legacyRaw)) {
3508
+ return {
3509
+ ...legacyRaw,
3510
+ deepline_billing: deeplineBilling
3511
+ };
3512
+ }
3513
+ return legacyRaw;
3514
+ }
3515
+ function providerMetaFromToolResponseRawV2(rawV2, view) {
3516
+ if (view !== "data" || !rawV2 || typeof rawV2 !== "object" || Array.isArray(rawV2)) {
3517
+ return void 0;
3518
+ }
3519
+ const meta = rawV2.meta;
3520
+ return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : void 0;
3521
+ }
3522
+
3498
3523
  // src/client.ts
3499
3524
  var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
3500
3525
  var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
3501
3526
  var EXECUTE_RESPONSE_CONTRACT_HEADER = "x-deepline-execute-response-contract";
3502
3527
  var EXECUTE_RESPONSE_INTENT_HEADER = "x-deepline-execute-response-intent";
3503
- var V2_EXECUTE_RESPONSE_CONTRACT = "v2-tool-response";
3528
+ var RAW_V2_EXECUTE_RESPONSE_CONTRACT = RAW_V2_TOOL_RESPONSE_CONTRACT;
3504
3529
  var COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1e3];
3505
3530
  var REGISTER_PLAY_ARTIFACTS_COMPILE_CONCURRENCY = 3;
3506
3531
  var REGISTER_PLAY_ARTIFACTS_MAX_BATCH_COUNT = 3;
@@ -3715,6 +3740,50 @@ function requireTargetBillingIdempotencyKey(value) {
3715
3740
  function isRecord7(value) {
3716
3741
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
3717
3742
  }
3743
+ function materializeToolExecutionResponse(response) {
3744
+ const toolResponse = response.toolResponse;
3745
+ if (!toolResponse && isRecord7(response.result)) {
3746
+ const legacyResult = response.result;
3747
+ if (Object.prototype.hasOwnProperty.call(legacyResult, "data")) {
3748
+ const legacyMeta = isRecord7(legacyResult.meta) ? legacyResult.meta : void 0;
3749
+ return {
3750
+ ...response,
3751
+ toolResponse: {
3752
+ raw: legacyResult.data,
3753
+ ...legacyMeta ? { meta: legacyMeta } : {}
3754
+ }
3755
+ };
3756
+ }
3757
+ }
3758
+ if (!toolResponse || Object.prototype.hasOwnProperty.call(toolResponse, "raw")) {
3759
+ return response;
3760
+ }
3761
+ const rawV2 = toolResponse.rawV2;
3762
+ const view = toolResponse.view;
3763
+ const providerMeta = providerMetaFromToolResponseRawV2(
3764
+ rawV2,
3765
+ view ?? "rawV2"
3766
+ );
3767
+ const responseMeta = isRecord7(toolResponse.responseMeta) ? toolResponse.responseMeta : void 0;
3768
+ return {
3769
+ ...response,
3770
+ toolResponse: {
3771
+ ...toolResponse,
3772
+ raw: legacyRawFromToolResponseRawV2(
3773
+ rawV2,
3774
+ view ?? "rawV2",
3775
+ responseMeta
3776
+ ),
3777
+ ...toolResponse.meta || providerMeta || responseMeta ? {
3778
+ meta: {
3779
+ ...toolResponse.meta ?? {},
3780
+ ...providerMeta ?? {},
3781
+ ...responseMeta ?? {}
3782
+ }
3783
+ } : {}
3784
+ }
3785
+ };
3786
+ }
3718
3787
  function isPrebuiltPlayDescription(play) {
3719
3788
  return play.origin === "prebuilt" || play.ownerType === "deepline";
3720
3789
  }
@@ -4264,14 +4333,14 @@ var DeeplineClient = class {
4264
4333
  */
4265
4334
  async executeTool(toolId, input, options) {
4266
4335
  const headers = {
4267
- [EXECUTE_RESPONSE_CONTRACT_HEADER]: V2_EXECUTE_RESPONSE_CONTRACT,
4336
+ [EXECUTE_RESPONSE_CONTRACT_HEADER]: RAW_V2_EXECUTE_RESPONSE_CONTRACT,
4268
4337
  [TOOL_EXECUTION_ERROR_SCHEMA_HEADER]: String(
4269
4338
  TOOL_EXECUTION_ERROR_SCHEMA_VERSION
4270
4339
  ),
4271
4340
  ...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
4272
4341
  [EXECUTE_RESPONSE_INTENT_HEADER]: options?.responseIntent ?? "raw"
4273
4342
  };
4274
- return this.http.post(
4343
+ const response = await this.http.post(
4275
4344
  `/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
4276
4345
  {
4277
4346
  payload: input,
@@ -4285,6 +4354,7 @@ var DeeplineClient = class {
4285
4354
  toolId
4286
4355
  }
4287
4356
  );
4357
+ return materializeToolExecutionResponse(response);
4288
4358
  }
4289
4359
  /**
4290
4360
  * Back-compatible alias for {@link executeTool}.
@@ -7731,6 +7801,8 @@ function createToolExecuteResult(input) {
7731
7801
  const resultRoot = {
7732
7802
  toolResponse: {
7733
7803
  raw: result.data,
7804
+ ...input.response && "rawV2" in input.response ? { rawV2: input.response.rawV2 } : {},
7805
+ ...input.response?.view ? { view: input.response.view } : {},
7734
7806
  ...result.meta ? { meta: result.meta } : {}
7735
7807
  }
7736
7808
  };
@@ -7754,6 +7826,8 @@ function createToolExecuteResult(input) {
7754
7826
  };
7755
7827
  const toolResponse = {
7756
7828
  raw: result.data,
7829
+ ...input.response && "rawV2" in input.response ? { rawV2: input.response.rawV2 } : {},
7830
+ ...input.response?.view ? { view: input.response.view } : {},
7757
7831
  ...result.meta ? { meta: result.meta } : {}
7758
7832
  };
7759
7833
  const extractedValues = buildExtractedAccessors(targets);
@@ -8384,6 +8458,8 @@ function attachSdkQueryResultDatasetResult(toolId, result, options) {
8384
8458
  }
8385
8459
  function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
8386
8460
  const raw = response.toolResponse?.raw ?? null;
8461
+ const rawV2 = response.toolResponse?.rawV2;
8462
+ const view = response.toolResponse?.view;
8387
8463
  const meta = response.toolResponse?.meta;
8388
8464
  const metadata = isRecord9(response._metadata) ? response._metadata.tool : null;
8389
8465
  const toolMetadata = isRecord9(metadata) ? metadata : {};
@@ -8396,6 +8472,11 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
8396
8472
  data: raw,
8397
8473
  ...isRecord9(meta) ? { meta } : {}
8398
8474
  },
8475
+ response: {
8476
+ ...rawV2 !== void 0 ? { rawV2 } : {},
8477
+ ...view === "data" || view === "rawV2" ? { view } : {},
8478
+ ...isRecord9(meta) ? { meta } : {}
8479
+ },
8399
8480
  metadata: {
8400
8481
  toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
8401
8482
  extractors: extractorDescriptorRecord(toolMetadata.extractors),
package/dist/index.mjs CHANGED
@@ -703,7 +703,11 @@ var SDK_RELEASE = {
703
703
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
704
704
  // exposed storage-dependent synchronous access. This deliberate minor
705
705
  // release keeps lazy paging semantics independent of row residency.
706
- version: "0.2.74",
706
+ // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
707
+ // available at toolResponse.rawV2 while toolResponse.raw and all declared
708
+ // getters keep their established compatibility behavior.
709
+ version: "0.3.0",
710
+ updateSummary: "New raw-v2 tool responses preserve complete scrubbed provider envelopes at toolResponse.rawV2, including JSON:API included resources, links, cursors, and totals. Existing toolResponse.raw and declared getters keep working unchanged.",
707
711
  contracts: {
708
712
  api: {
709
713
  name: "sdk-http-api",
@@ -3418,12 +3422,33 @@ function normalizePlayRuntimeEnvironment(value) {
3418
3422
  return typeof value === "string" && PLAY_RUNTIME_ENVIRONMENTS.includes(value) ? value : null;
3419
3423
  }
3420
3424
 
3425
+ // ../shared_libs/play-runtime/tool-response-contract.ts
3426
+ var RAW_V2_TOOL_RESPONSE_CONTRACT = "raw-v2";
3427
+ function legacyRawFromToolResponseRawV2(rawV2, view, responseMeta) {
3428
+ const legacyRaw = view === "data" && rawV2 && typeof rawV2 === "object" && !Array.isArray(rawV2) ? rawV2.data : rawV2;
3429
+ const deeplineBilling = responseMeta?.deepline_billing;
3430
+ if (view === "rawV2" && deeplineBilling !== void 0 && legacyRaw && typeof legacyRaw === "object" && !Array.isArray(legacyRaw)) {
3431
+ return {
3432
+ ...legacyRaw,
3433
+ deepline_billing: deeplineBilling
3434
+ };
3435
+ }
3436
+ return legacyRaw;
3437
+ }
3438
+ function providerMetaFromToolResponseRawV2(rawV2, view) {
3439
+ if (view !== "data" || !rawV2 || typeof rawV2 !== "object" || Array.isArray(rawV2)) {
3440
+ return void 0;
3441
+ }
3442
+ const meta = rawV2.meta;
3443
+ return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : void 0;
3444
+ }
3445
+
3421
3446
  // src/client.ts
3422
3447
  var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
3423
3448
  var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
3424
3449
  var EXECUTE_RESPONSE_CONTRACT_HEADER = "x-deepline-execute-response-contract";
3425
3450
  var EXECUTE_RESPONSE_INTENT_HEADER = "x-deepline-execute-response-intent";
3426
- var V2_EXECUTE_RESPONSE_CONTRACT = "v2-tool-response";
3451
+ var RAW_V2_EXECUTE_RESPONSE_CONTRACT = RAW_V2_TOOL_RESPONSE_CONTRACT;
3427
3452
  var COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1e3];
3428
3453
  var REGISTER_PLAY_ARTIFACTS_COMPILE_CONCURRENCY = 3;
3429
3454
  var REGISTER_PLAY_ARTIFACTS_MAX_BATCH_COUNT = 3;
@@ -3638,6 +3663,50 @@ function requireTargetBillingIdempotencyKey(value) {
3638
3663
  function isRecord7(value) {
3639
3664
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
3640
3665
  }
3666
+ function materializeToolExecutionResponse(response) {
3667
+ const toolResponse = response.toolResponse;
3668
+ if (!toolResponse && isRecord7(response.result)) {
3669
+ const legacyResult = response.result;
3670
+ if (Object.prototype.hasOwnProperty.call(legacyResult, "data")) {
3671
+ const legacyMeta = isRecord7(legacyResult.meta) ? legacyResult.meta : void 0;
3672
+ return {
3673
+ ...response,
3674
+ toolResponse: {
3675
+ raw: legacyResult.data,
3676
+ ...legacyMeta ? { meta: legacyMeta } : {}
3677
+ }
3678
+ };
3679
+ }
3680
+ }
3681
+ if (!toolResponse || Object.prototype.hasOwnProperty.call(toolResponse, "raw")) {
3682
+ return response;
3683
+ }
3684
+ const rawV2 = toolResponse.rawV2;
3685
+ const view = toolResponse.view;
3686
+ const providerMeta = providerMetaFromToolResponseRawV2(
3687
+ rawV2,
3688
+ view ?? "rawV2"
3689
+ );
3690
+ const responseMeta = isRecord7(toolResponse.responseMeta) ? toolResponse.responseMeta : void 0;
3691
+ return {
3692
+ ...response,
3693
+ toolResponse: {
3694
+ ...toolResponse,
3695
+ raw: legacyRawFromToolResponseRawV2(
3696
+ rawV2,
3697
+ view ?? "rawV2",
3698
+ responseMeta
3699
+ ),
3700
+ ...toolResponse.meta || providerMeta || responseMeta ? {
3701
+ meta: {
3702
+ ...toolResponse.meta ?? {},
3703
+ ...providerMeta ?? {},
3704
+ ...responseMeta ?? {}
3705
+ }
3706
+ } : {}
3707
+ }
3708
+ };
3709
+ }
3641
3710
  function isPrebuiltPlayDescription(play) {
3642
3711
  return play.origin === "prebuilt" || play.ownerType === "deepline";
3643
3712
  }
@@ -4187,14 +4256,14 @@ var DeeplineClient = class {
4187
4256
  */
4188
4257
  async executeTool(toolId, input, options) {
4189
4258
  const headers = {
4190
- [EXECUTE_RESPONSE_CONTRACT_HEADER]: V2_EXECUTE_RESPONSE_CONTRACT,
4259
+ [EXECUTE_RESPONSE_CONTRACT_HEADER]: RAW_V2_EXECUTE_RESPONSE_CONTRACT,
4191
4260
  [TOOL_EXECUTION_ERROR_SCHEMA_HEADER]: String(
4192
4261
  TOOL_EXECUTION_ERROR_SCHEMA_VERSION
4193
4262
  ),
4194
4263
  ...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
4195
4264
  [EXECUTE_RESPONSE_INTENT_HEADER]: options?.responseIntent ?? "raw"
4196
4265
  };
4197
- return this.http.post(
4266
+ const response = await this.http.post(
4198
4267
  `/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
4199
4268
  {
4200
4269
  payload: input,
@@ -4208,6 +4277,7 @@ var DeeplineClient = class {
4208
4277
  toolId
4209
4278
  }
4210
4279
  );
4280
+ return materializeToolExecutionResponse(response);
4211
4281
  }
4212
4282
  /**
4213
4283
  * Back-compatible alias for {@link executeTool}.
@@ -7654,6 +7724,8 @@ function createToolExecuteResult(input) {
7654
7724
  const resultRoot = {
7655
7725
  toolResponse: {
7656
7726
  raw: result.data,
7727
+ ...input.response && "rawV2" in input.response ? { rawV2: input.response.rawV2 } : {},
7728
+ ...input.response?.view ? { view: input.response.view } : {},
7657
7729
  ...result.meta ? { meta: result.meta } : {}
7658
7730
  }
7659
7731
  };
@@ -7677,6 +7749,8 @@ function createToolExecuteResult(input) {
7677
7749
  };
7678
7750
  const toolResponse = {
7679
7751
  raw: result.data,
7752
+ ...input.response && "rawV2" in input.response ? { rawV2: input.response.rawV2 } : {},
7753
+ ...input.response?.view ? { view: input.response.view } : {},
7680
7754
  ...result.meta ? { meta: result.meta } : {}
7681
7755
  };
7682
7756
  const extractedValues = buildExtractedAccessors(targets);
@@ -8307,6 +8381,8 @@ function attachSdkQueryResultDatasetResult(toolId, result, options) {
8307
8381
  }
8308
8382
  function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
8309
8383
  const raw = response.toolResponse?.raw ?? null;
8384
+ const rawV2 = response.toolResponse?.rawV2;
8385
+ const view = response.toolResponse?.view;
8310
8386
  const meta = response.toolResponse?.meta;
8311
8387
  const metadata = isRecord9(response._metadata) ? response._metadata.tool : null;
8312
8388
  const toolMetadata = isRecord9(metadata) ? metadata : {};
@@ -8319,6 +8395,11 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
8319
8395
  data: raw,
8320
8396
  ...isRecord9(meta) ? { meta } : {}
8321
8397
  },
8398
+ response: {
8399
+ ...rawV2 !== void 0 ? { rawV2 } : {},
8400
+ ...view === "data" || view === "rawV2" ? { view } : {},
8401
+ ...isRecord9(meta) ? { meta } : {}
8402
+ },
8322
8403
  metadata: {
8323
8404
  toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
8324
8405
  extractors: extractorDescriptorRecord(toolMetadata.extractors),
@@ -173,6 +173,7 @@
173
173
  "dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts",
174
174
  "dist/bundling-sources/shared_libs/play-runtime/tool-execution-outcome.ts",
175
175
  "dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts",
176
+ "dist/bundling-sources/shared_libs/play-runtime/tool-response-contract.ts",
176
177
  "dist/bundling-sources/shared_libs/play-runtime/tool-result-paths.ts",
177
178
  "dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts",
178
179
  "dist/bundling-sources/shared_libs/play-runtime/tool-result.ts",
@@ -225,8 +226,8 @@
225
226
  "dist/cli/index.d.ts",
226
227
  "dist/cli/index.js",
227
228
  "dist/cli/index.mjs",
228
- "dist/compiler-manifest-DFuz9-0_.d.mts",
229
- "dist/compiler-manifest-DFuz9-0_.d.ts",
229
+ "dist/compiler-manifest-BX85pKXW.d.mts",
230
+ "dist/compiler-manifest-BX85pKXW.d.ts",
230
231
  "dist/helpers.d.mts",
231
232
  "dist/helpers.d.ts",
232
233
  "dist/helpers.js",