deepline 0.2.74 → 0.3.1

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.
Files changed (35) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +75 -4
  2. package/dist/bundling-sources/sdk/src/compat.ts +4 -0
  3. package/dist/bundling-sources/sdk/src/play.ts +7 -0
  4. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +15 -1
  5. package/dist/bundling-sources/sdk/src/release.ts +12 -1
  6. package/dist/bundling-sources/sdk/src/types.ts +7 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +146 -29
  8. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +3 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +3 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +57 -1
  11. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +20 -19
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +100 -25
  13. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +25 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +0 -9
  15. package/dist/bundling-sources/shared_libs/play-runtime/tool-response-contract.ts +89 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +29 -3
  17. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +203 -16
  18. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +6 -5
  19. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +3 -0
  20. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +1 -0
  21. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +5 -2
  22. package/dist/bundling-sources/shared_libs/plays/contracts.ts +14 -0
  23. package/dist/cli/index.js +123 -47
  24. package/dist/cli/index.mjs +86 -10
  25. package/dist/{compiler-manifest-DFuz9-0_.d.mts → compiler-manifest-BX85pKXW.d.mts} +7 -2
  26. package/dist/{compiler-manifest-DFuz9-0_.d.ts → compiler-manifest-BX85pKXW.d.ts} +7 -2
  27. package/dist/index.d.mts +14 -3
  28. package/dist/index.d.ts +14 -3
  29. package/dist/index.js +85 -4
  30. package/dist/index.mjs +85 -4
  31. package/dist/install-integrity.json +3 -2
  32. package/dist/plays/bundle-play-file.d.mts +12 -2
  33. package/dist/plays/bundle-play-file.d.ts +12 -2
  34. package/dist/plays/bundle-play-file.mjs +20 -4
  35. package/package.json +1 -1
@@ -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.1",
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.1",
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",
@@ -1,7 +1,15 @@
1
- import { T as ToolExecutionErrorSchemaVersion, P as PlayAuthoringContractEdition, a as PlayArtifactKind$1, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-DFuz9-0_.mjs';
2
- export { d as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-DFuz9-0_.mjs';
1
+ import { T as ToolExecutionErrorSchemaVersion, P as PlayAuthoringContractEdition, a as PlayArtifactKind$1, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-BX85pKXW.mjs';
2
+ export { d as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-BX85pKXW.mjs';
3
3
  import '@sinclair/typebox';
4
4
 
5
+ /**
6
+ * Public tool-response contracts shared by the API, SDK, Play bundler, and
7
+ * runtime. A response contract is transport behavior, never Play authoring.
8
+ */
9
+ declare const V2_TOOL_RESPONSE_CONTRACT: "v2-tool-response";
10
+ declare const RAW_V2_TOOL_RESPONSE_CONTRACT: "raw-v2";
11
+ type ToolResponseContract = typeof V2_TOOL_RESPONSE_CONTRACT | typeof RAW_V2_TOOL_RESPONSE_CONTRACT;
12
+
5
13
  type PlayPackageImport = {
6
14
  name: string;
7
15
  version: string | null;
@@ -22,6 +30,8 @@ type PlayArtifactCompatibility = {
22
30
  toolErrorSchemaVersion?: ToolExecutionErrorSchemaVersion;
23
31
  /** Missing preserves edition 1 for artifacts created before authoring contracts were pinned. */
24
32
  authoringContractEdition?: PlayAuthoringContractEdition;
33
+ /** Missing preserves the raw-only V2 execute response contract. */
34
+ toolResponseContract?: ToolResponseContract;
25
35
  };
26
36
  /** The only executable Play artifact contract. */
27
37
  type PlayArtifactKind = 'cjs_node20';
@@ -1,7 +1,15 @@
1
- import { T as ToolExecutionErrorSchemaVersion, P as PlayAuthoringContractEdition, a as PlayArtifactKind$1, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-DFuz9-0_.js';
2
- export { d as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-DFuz9-0_.js';
1
+ import { T as ToolExecutionErrorSchemaVersion, P as PlayAuthoringContractEdition, a as PlayArtifactKind$1, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-BX85pKXW.js';
2
+ export { d as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-BX85pKXW.js';
3
3
  import '@sinclair/typebox';
4
4
 
5
+ /**
6
+ * Public tool-response contracts shared by the API, SDK, Play bundler, and
7
+ * runtime. A response contract is transport behavior, never Play authoring.
8
+ */
9
+ declare const V2_TOOL_RESPONSE_CONTRACT: "v2-tool-response";
10
+ declare const RAW_V2_TOOL_RESPONSE_CONTRACT: "raw-v2";
11
+ type ToolResponseContract = typeof V2_TOOL_RESPONSE_CONTRACT | typeof RAW_V2_TOOL_RESPONSE_CONTRACT;
12
+
5
13
  type PlayPackageImport = {
6
14
  name: string;
7
15
  version: string | null;
@@ -22,6 +30,8 @@ type PlayArtifactCompatibility = {
22
30
  toolErrorSchemaVersion?: ToolExecutionErrorSchemaVersion;
23
31
  /** Missing preserves edition 1 for artifacts created before authoring contracts were pinned. */
24
32
  authoringContractEdition?: PlayAuthoringContractEdition;
33
+ /** Missing preserves the raw-only V2 execute response contract. */
34
+ toolResponseContract?: ToolResponseContract;
25
35
  };
26
36
  /** The only executable Play artifact contract. */
27
37
  type PlayArtifactKind = 'cjs_node20';
@@ -9,6 +9,7 @@ import { tmpdir as tmpdir2 } from "os";
9
9
  import { dirname as dirname3, join as join3, resolve as resolve3 } from "path";
10
10
  import { fileURLToPath } from "url";
11
11
  import { existsSync as existsSync2 } from "fs";
12
+ import { realpath as realpath2 } from "fs/promises";
12
13
 
13
14
  // ../shared_libs/plays/bundling/index.ts
14
15
  import { createHash } from "crypto";
@@ -4001,6 +4002,9 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
4001
4002
  "export type DefinedPlay<TInput, TOutput extends PlayReturnObject> = ((ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>) & { readonly name: string; readonly __inputType?: TInput; readonly __outputType?: TOutput; readonly runtime?: PlayBindings['runtime']; readonly compatibility?: PlayBindings['compatibility'] };"
4002
4003
  ];
4003
4004
 
4005
+ // ../shared_libs/play-runtime/tool-response-contract.ts
4006
+ var RAW_V2_TOOL_RESPONSE_CONTRACT = "raw-v2";
4007
+
4004
4008
  // ../shared_libs/plays/contracts.ts
4005
4009
  var PLAY_PUBLIC_API_VERSION = 1;
4006
4010
  var PLAY_ARTIFACT_VERSION = CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION;
@@ -4019,7 +4023,8 @@ function buildPlayContractCompatibility(input) {
4019
4023
  runtimeFeatures: [...PLAY_RUNTIME_FEATURES],
4020
4024
  runtimeBackend: input?.runtimeBackend ?? null,
4021
4025
  toolErrorSchemaVersion: input?.toolErrorSchemaVersion ?? TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
4022
- authoringContractEdition: input?.authoringContractEdition ?? PLAY_AUTHORING_CONTRACT_EDITION
4026
+ authoringContractEdition: input?.authoringContractEdition ?? PLAY_AUTHORING_CONTRACT_EDITION,
4027
+ toolResponseContract: input?.toolResponseContract ?? RAW_V2_TOOL_RESPONSE_CONTRACT
4023
4028
  };
4024
4029
  }
4025
4030
 
@@ -5282,8 +5287,12 @@ function sha256(value) {
5282
5287
  function sourceIdentityPath(filePath, sourceIdentityRoot) {
5283
5288
  if (!sourceIdentityRoot) return filePath;
5284
5289
  const identityRoot = resolve(sourceIdentityRoot);
5285
- const logicalPath = relative(identityRoot, resolve(filePath));
5286
- if (!logicalPath || logicalPath === ".." || logicalPath.startsWith(`..${sep}`) || isAbsolute(logicalPath)) {
5290
+ const resolvedFilePath = resolve(filePath);
5291
+ const logicalPath = relative(identityRoot, resolvedFilePath);
5292
+ if (!logicalPath) {
5293
+ return basename(resolvedFilePath);
5294
+ }
5295
+ if (logicalPath === ".." || logicalPath.startsWith(`..${sep}`) || isAbsolute(logicalPath)) {
5287
5296
  return filePath;
5288
5297
  }
5289
5298
  return logicalPath.split(/[\\/]+/).join("/");
@@ -7197,10 +7206,17 @@ function createSdkPlayBundlingAdapter() {
7197
7206
  };
7198
7207
  }
7199
7208
  async function bundlePlayFile2(filePath, options = {}) {
7209
+ const localWorkspaceRoot = dirname3(resolve3(filePath));
7210
+ const sourceIdentityRoot = await realpath2(localWorkspaceRoot).catch(
7211
+ () => localWorkspaceRoot
7212
+ );
7200
7213
  const result = await bundlePlayFile(filePath, {
7201
7214
  target: options.target ?? defaultPlayBundleTarget(),
7202
7215
  exportName: options.exportName,
7203
- adapter: createSdkPlayBundlingAdapter()
7216
+ adapter: {
7217
+ ...createSdkPlayBundlingAdapter(),
7218
+ sourceIdentityRoot
7219
+ }
7204
7220
  });
7205
7221
  if (result.success)
7206
7222
  validatePlaySourceFilesHaveNoInlineSecrets(result.sourceFiles);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.2.74",
3
+ "version": "0.3.1",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",