deepline 0.3.307 → 0.3.308

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 (102) hide show
  1. package/README.md +2 -1
  2. package/dist/bundling-sources/sdk/src/client.ts +270 -11
  3. package/dist/bundling-sources/sdk/src/compat.ts +27 -9
  4. package/dist/bundling-sources/sdk/src/index.ts +35 -0
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/shared_libs/play-runtime/batch-runtime.ts +4 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/batching-types.ts +3 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +46 -16
  9. package/dist/bundling-sources/shared_libs/play-runtime/fullenrich-batching.ts +24 -1
  10. package/dist/bundling-sources/shared_libs/play-runtime/run-event-query.ts +872 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +595 -0
  12. package/dist/cli/auth-LWNR7TQB.js +31 -0
  13. package/dist/cli/{auth-AJPTFFC7.mjs → auth-ZWX4BF5K.mjs} +4 -4
  14. package/dist/cli/{billing-LPDYJLIL.mjs → billing-CLV5QRFQ.mjs} +4 -4
  15. package/dist/cli/{billing-SPBWUEOS.js → billing-H24FGAKE.js} +70 -70
  16. package/dist/cli/{chunk-O4OESDIN.mjs → chunk-3GIUCJAT.mjs} +1 -1
  17. package/dist/cli/{chunk-D55NIPGU.mjs → chunk-ABMGEW3C.mjs} +1 -1
  18. package/dist/cli/{chunk-RXYYANYP.mjs → chunk-ASWZTTKT.mjs} +13 -5
  19. package/dist/cli/{chunk-G4SSYZND.mjs → chunk-BPD7TR27.mjs} +1 -1
  20. package/dist/cli/{chunk-ZGICKTW7.mjs → chunk-CXU7ME5X.mjs} +2 -2
  21. package/dist/cli/{chunk-HWCB5MHF.js → chunk-GBFIAI4L.js} +68 -60
  22. package/dist/cli/{chunk-MZQP7CIL.js → chunk-GONK2N7U.js} +1 -1
  23. package/dist/cli/{chunk-TLTKAJ6S.mjs → chunk-HGI6RGHB.mjs} +653 -5
  24. package/dist/cli/{chunk-K2CQ2RBJ.js → chunk-IFIGQWHC.js} +6 -6
  25. package/dist/cli/{chunk-7ONALPWY.mjs → chunk-JUAVGRD7.mjs} +4 -4
  26. package/dist/cli/{chunk-GUIQWUCB.js → chunk-O7NNH76S.js} +6 -6
  27. package/dist/cli/{chunk-2IKIG333.js → chunk-QJBJZVG6.js} +15 -4
  28. package/dist/cli/{chunk-AKE6ZFIJ.js → chunk-QTCFSRGC.js} +4 -4
  29. package/dist/cli/{chunk-ZIF6JOOI.js → chunk-SRZ6XDX3.js} +26 -26
  30. package/dist/cli/{chunk-MPVXXDWH.mjs → chunk-T3P4NRZU.mjs} +1 -1
  31. package/dist/cli/{chunk-KCHBE2J3.js → chunk-TH3YBIJT.js} +852 -204
  32. package/dist/cli/{chunk-DF3XJ2V2.js → chunk-UGTYNMRX.js} +48 -48
  33. package/dist/cli/{chunk-76MFV3AC.js → chunk-WEZVPZPE.js} +2 -2
  34. package/dist/cli/{chunk-UABLQKTZ.mjs → chunk-WXLOW623.mjs} +11 -0
  35. package/dist/cli/{chunk-ILOCS73R.mjs → chunk-XFYVL7EM.mjs} +2 -2
  36. package/dist/cli/{chunk-BDFVIOLY.mjs → chunk-XSDL3NHZ.mjs} +3 -3
  37. package/dist/cli/{chunk-JNHXSZPB.js → chunk-YEJMVAD3.js} +6 -6
  38. package/dist/cli/{chunk-QACDLYNO.mjs → chunk-YSZSERRZ.mjs} +1 -1
  39. package/dist/cli/{chunk-IVXD2KA2.js → chunk-ZHHF24O5.js} +15 -15
  40. package/dist/cli/client-3J76AMVE.js +20 -0
  41. package/dist/cli/{client-7ZL4ROII.mjs → client-A5ILG5GT.mjs} +3 -3
  42. package/dist/cli/{csv-Y3LYCTGD.mjs → csv-NZ7KAYEF.mjs} +3 -3
  43. package/dist/cli/{csv-JUDFG7JV.js → csv-VSSAAXFX.js} +12 -12
  44. package/dist/cli/{db-5IXGEXNT.js → db-ICLEBSNO.js} +20 -20
  45. package/dist/cli/{db-GCOJD2BD.mjs → db-YSAJUBLD.mjs} +4 -4
  46. package/dist/cli/{executions-FIICTMSY.mjs → executions-MUJRAT5R.mjs} +4 -4
  47. package/dist/cli/{executions-LIEQKFT7.js → executions-XCAJB5TF.js} +6 -6
  48. package/dist/cli/{feedback-3OVAA3C7.mjs → feedback-6C7Y2SCJ.mjs} +3 -3
  49. package/dist/cli/{feedback-FAADYNAR.js → feedback-DBZMBHZG.js} +6 -6
  50. package/dist/cli/git-2NSE4WIK.js +23 -0
  51. package/dist/cli/{git-ESMYCYJO.mjs → git-EAH67ITA.mjs} +4 -4
  52. package/dist/cli/index.js +79 -77
  53. package/dist/cli/index.mjs +33 -31
  54. package/dist/cli/{legacy-noops-PKI3RFZW.js → legacy-noops-EJTOLTVO.js} +7 -7
  55. package/dist/cli/{legacy-noops-KP5CPZRK.mjs → legacy-noops-O5INQP6Q.mjs} +4 -4
  56. package/dist/cli/{monitors-KCFBLAFZ.js → monitors-5OYO2DPJ.js} +85 -85
  57. package/dist/cli/{monitors-A6KGGSBO.mjs → monitors-SBBBMUFY.mjs} +4 -4
  58. package/dist/cli/{org-WI6DEXZQ.js → org-SJRPJG42.js} +60 -60
  59. package/dist/cli/{org-DHI24UOK.mjs → org-Z7LTOL3H.mjs} +4 -4
  60. package/dist/cli/{play-2YXLQD24.mjs → play-2JTIEOZM.mjs} +472 -55
  61. package/dist/cli/{play-4EUUN76H.js → play-VQJ6ABZ2.js} +961 -544
  62. package/dist/cli/{providers-DWS3XIM6.js → providers-43MR5XOV.js} +7 -7
  63. package/dist/cli/{providers-2WZ6KHH2.mjs → providers-MX4CV2EH.mjs} +4 -4
  64. package/dist/cli/{quickstart-TDTDKM6F.js → quickstart-A6W3HEE2.js} +5 -5
  65. package/dist/cli/{quickstart-ZFZVG6UO.mjs → quickstart-Y4YLKRZ3.mjs} +3 -3
  66. package/dist/cli/{search-GMPXRQF4.js → search-AMUFSAFP.js} +6 -6
  67. package/dist/cli/{search-BBE2ZMCI.mjs → search-FRKDLJQG.mjs} +5 -5
  68. package/dist/cli/{secrets-JEJL3KIM.mjs → secrets-E4EX7O3J.mjs} +4 -4
  69. package/dist/cli/{secrets-SMBX4IE6.js → secrets-XITHKZW2.js} +13 -13
  70. package/dist/cli/{sessions-S6AWG747.js → sessions-6HJFDIR2.js} +5 -5
  71. package/dist/cli/{sessions-AVU353UT.mjs → sessions-6YXAUJII.mjs} +4 -4
  72. package/dist/cli/{settings-KBW4ROHC.js → settings-J5NRLCV2.js} +74 -74
  73. package/dist/cli/{settings-GY5CYRLF.mjs → settings-LBJSZIET.mjs} +7 -7
  74. package/dist/cli/{setup-WSVIDSEV.js → setup-2ES4CTO5.js} +41 -41
  75. package/dist/cli/{setup-4CW3XGGX.mjs → setup-75FENNVH.mjs} +6 -6
  76. package/dist/cli/skills-VLTAVA4K.js +28 -0
  77. package/dist/cli/{skills-U3NXFSFK.mjs → skills-XGZDUXW6.mjs} +4 -4
  78. package/dist/cli/{tools-XU6KLJZT.mjs → tools-2LEKXOGY.mjs} +58 -42
  79. package/dist/cli/{tools-KZKELW25.js → tools-ZOQOGDKI.js} +111 -95
  80. package/dist/cli/update-5CZOVYQT.js +28 -0
  81. package/dist/cli/{update-RZLH46DR.mjs → update-SNK3IN3I.mjs} +6 -6
  82. package/dist/cli/{workflow-ZQUKQI35.mjs → workflow-G7ZM3MAC.mjs} +5 -5
  83. package/dist/cli/{workflow-GDOGDGTZ.js → workflow-W3AYTB3J.js} +15 -15
  84. package/dist/{client-Dj8MAkDc.d.mts → client-DpnkGBn-.d.mts} +324 -11
  85. package/dist/{client-DsrFGXJf.d.ts → client-ypdBvf1o.d.ts} +324 -11
  86. package/dist/index.d.mts +2 -2
  87. package/dist/index.d.ts +2 -2
  88. package/dist/index.js +8 -6
  89. package/dist/index.mjs +5 -3
  90. package/dist/install-integrity.json +73 -72
  91. package/dist/plays/run-request.d.mts +1 -1
  92. package/dist/plays/run-request.d.ts +1 -1
  93. package/dist/release.d.mts +1 -1
  94. package/dist/release.d.ts +1 -1
  95. package/dist/release.js +2 -2
  96. package/dist/release.mjs +1 -1
  97. package/package.json +1 -1
  98. package/dist/cli/auth-TUQTQIH4.js +0 -31
  99. package/dist/cli/client-S3MIFPM2.js +0 -20
  100. package/dist/cli/git-GG6LWE2R.js +0 -23
  101. package/dist/cli/skills-6AU3RRAD.js +0 -28
  102. package/dist/cli/update-LVXXQF4A.js +0 -28
package/README.md CHANGED
@@ -44,7 +44,8 @@ pagination and retention. `runs logs` reads text or structured events;
44
44
  `runs get`, `runs watch`, `runs export` and `runs receipt` cover status, live
45
45
  observation, dataset rows and retained tool results. These inspection commands
46
46
  read existing evidence without starting provider work. TypeScript callers use
47
- `client.runs.logs`, `client.runs.searchEvents` and `client.runs.getReceipts`;
47
+ `client.runs.logs`, its structured `query`/`count`/`summarize`/`fields` methods,
48
+ `client.runs.events`, `client.runs.searchEvents` and `client.runs.getReceipts`;
48
49
  their source JSDoc and the generated SDK/API references describe the same reads.
49
50
 
50
51
  Paste this into Claude Code, Codex, or another coding agent:
@@ -77,6 +77,20 @@ import {
77
77
  } from '../../shared_libs/product-notifications/configuration.js';
78
78
  import { watchRunEvents as pollRunSnapshotEvents } from './runs/watch-polling.js';
79
79
  import { encodeRunLogsCursor, parseRunLogsCursor } from './runs/log-cursor.js';
80
+ import {
81
+ normalizeRunEventOperationRequest,
82
+ RunEventQueryInputError,
83
+ type RunEventOperationRequest,
84
+ type RunEventQueryCriteria,
85
+ type RunEventQueryOptions,
86
+ type RunEventSummaryOptions,
87
+ type RunEventLogsResult,
88
+ type RunEventEventsResult,
89
+ type RunEventCountResult,
90
+ type RunEventSummaryResult,
91
+ type RunEventFieldsResult,
92
+ type NormalizedRunEventQuery,
93
+ } from '../../shared_libs/play-runtime/run-event-query';
80
94
  import type {
81
95
  DeeplineClientOptions,
82
96
  ResolvedConfig,
@@ -942,6 +956,84 @@ export type RunsEventPayload = {
942
956
  errorPayload: unknown | null;
943
957
  };
944
958
 
959
+ /** Structured log criteria; relative `since` values such as `1h` are resolved once. */
960
+ export type RunsLogCriteria = Omit<RunEventQueryCriteria, 'runId'> & {
961
+ /** Read an explicitly authorized Preview scope using its runtime credential. */
962
+ runtime?: PlayRuntimeSelection;
963
+ };
964
+
965
+ /** One structured log page; filters are evaluated before the page limit. */
966
+ export type RunsLogsQueryOptions = RunsLogCriteria & RunEventQueryOptions;
967
+ type RunQueryResultWithRuntime<T extends { query: NormalizedRunEventQuery }> =
968
+ Omit<T, 'query'> & {
969
+ query: T['query'] & { runtime?: PlayRuntimeSelection };
970
+ };
971
+ type RunLogQueryResult<T extends { query: NormalizedRunEventQuery }> = Omit<
972
+ T,
973
+ 'query'
974
+ > & {
975
+ query: Omit<T['query'], 'runId'> & { runtime?: PlayRuntimeSelection };
976
+ };
977
+ export type RunsLogsQueryResult = RunLogQueryResult<RunEventLogsResult>;
978
+ export type RunsLogsCountResult = RunLogQueryResult<RunEventCountResult>;
979
+ export type RunsLogsSummaryOptions = RunsLogCriteria & RunEventSummaryOptions;
980
+ export type RunsLogsSummaryResult = RunLogQueryResult<RunEventSummaryResult>;
981
+
982
+ /** Event criteria may span the active organization or target one run. */
983
+ export type RunsEventsCriteria = RunsLogCriteria & { runId?: string };
984
+ export type RunsEventsListOptions = RunsEventsCriteria & RunEventQueryOptions;
985
+ export type RunsEventsListResult =
986
+ RunQueryResultWithRuntime<RunEventEventsResult>;
987
+ export type RunsEventsCountResult =
988
+ RunQueryResultWithRuntime<RunEventCountResult>;
989
+ export type RunsEventsSummaryResult =
990
+ RunQueryResultWithRuntime<RunEventSummaryResult>;
991
+ export type RunsEventsSummaryOptions = RunsEventsCriteria &
992
+ RunEventSummaryOptions;
993
+ export type RunsEventsFieldsOptions = { runtime?: PlayRuntimeSelection };
994
+
995
+ /**
996
+ * Use `client.runs.logs(runId, options)` for the established text reader, or
997
+ * `client.runs.logs.query/count/summarize/fields` for structured retained logs.
998
+ */
999
+ export type RunsLogsNamespace = {
1000
+ (runId: string, options?: RunsLogsOptions): Promise<RunsLogsResult>;
1001
+ /** Filter retained log records, newest first, in one server page. */
1002
+ query: (
1003
+ runId: string,
1004
+ options?: RunsLogsQueryOptions,
1005
+ ) => Promise<RunsLogsQueryResult>;
1006
+ /** Exact count of matching retained records; does not list or retrieve payloads. */
1007
+ count: (
1008
+ runId: string,
1009
+ criteria?: RunsLogCriteria,
1010
+ ) => Promise<RunsLogsCountResult>;
1011
+ /** Group matching retained records; groups have their own continuation cursor. */
1012
+ summarize: (
1013
+ runId: string,
1014
+ options: RunsLogsSummaryOptions,
1015
+ ) => Promise<RunsLogsSummaryResult>;
1016
+ /** Discover filter fields, operators, types and availability. */
1017
+ fields: (options?: RunsEventsFieldsOptions) => Promise<RunEventFieldsResult>;
1018
+ };
1019
+
1020
+ /**
1021
+ * Use `client.runs.events` for lifecycle, receipt and organization-wide events.
1022
+ * Omit `runId` to query the active organization's retained events.
1023
+ */
1024
+ export type RunsEventsNamespace = {
1025
+ /** Filter retained events, newest first, in one server page. */
1026
+ list: (options?: RunsEventsListOptions) => Promise<RunsEventsListResult>;
1027
+ /** Exact count of matching retained events without listing or payload reads. */
1028
+ count: (criteria?: RunsEventsCriteria) => Promise<RunsEventsCountResult>;
1029
+ /** Group matching retained events with an independent continuation cursor. */
1030
+ summarize: (
1031
+ options: RunsEventsSummaryOptions,
1032
+ ) => Promise<RunsEventsSummaryResult>;
1033
+ /** Discover declared filter fields, operators, types and availability. */
1034
+ fields: (options?: RunsEventsFieldsOptions) => Promise<RunEventFieldsResult>;
1035
+ };
1036
+
945
1037
  /** Server page cap for GET /api/v2/runs/:runId/logs (ADR-0009). */
946
1038
  const RUN_LOGS_PAGE_LIMIT = 1_000;
947
1039
 
@@ -1014,7 +1106,7 @@ export type PlaySecretCheck = {
1014
1106
  };
1015
1107
 
1016
1108
  /**
1017
- * Use `client.runs` (`/api/v2/runs`) to watch, stop, read logs, and export durable dataset rows.
1109
+ * Use `client.runs` to watch, stop, query logs/events, and export durable dataset rows.
1018
1110
  *
1019
1111
  * @sdkReference client 020 client.runs
1020
1112
  */
@@ -1056,8 +1148,10 @@ export type RunsNamespace = {
1056
1148
  watch: (runId: string, options?: RunsWatchOptions) => Promise<PlayStatus>;
1057
1149
  /** @deprecated Use `watch`; retained as a source-compatible alias. */
1058
1150
  tail: (runId: string, options?: RunsTailOptions) => Promise<PlayStatus>;
1059
- /** Read a run's retained text tail, full stream (`all`) or terminal failure window (`failed`). For structured filters and payloads, see [run logs and events](run-events.md). */
1060
- logs: (runId: string, options?: RunsLogsOptions) => Promise<RunsLogsResult>;
1151
+ /** Call for the retained text tail, full stream (`all`) or terminal failure window (`failed`). Use `logs.query/count/summarize/fields` for structured filters and exact aggregates; see [run logs and events](run-events.md). */
1152
+ logs: RunsLogsNamespace;
1153
+ /** Use `events.list/count/summarize/fields` for lifecycle, receipt and organization-wide events; see [run logs and events](run-events.md). */
1154
+ events: RunsEventsNamespace;
1061
1155
  /** Search existing events across the active organization; default last hour, up to 200 events per page (ten with payloads). See [run logs and events](run-events.md) for the catalog, query fields and response types. */
1062
1156
  searchEvents: (
1063
1157
  options?: RunsEventSearchOptions,
@@ -1858,13 +1952,9 @@ export type MonitorsRepairResult = {
1858
1952
  };
1859
1953
 
1860
1954
  /**
1861
- * Public monitors namespace exposed as `client.monitors`.
1862
- *
1863
- * Mirrors the /api/v2/monitors resource family so the monitors CLI and
1864
- * programmatic callers share one product surface — every `deepline monitors`
1865
- * verb maps to a method here. Monitors are fully expressible as SDK code: author
1866
- * a definition with {@link defineMonitor}, then check/deploy/list/get/update/
1867
- * delete/reactivate through this namespace.
1955
+ * Use `client.monitors` for the /api/v2/monitors resource family.
1956
+ * Every `deepline monitors` verb maps here. Author a definition with {@link defineMonitor},
1957
+ * then check/deploy/list/get/update/delete/reactivate through this namespace.
1868
1958
  *
1869
1959
  * @sdkReference client 040 client.monitors
1870
1960
  */
@@ -2799,7 +2889,26 @@ export class DeeplineClient {
2799
2889
  history: (options) => this.getRunsHistory(options),
2800
2890
  watch: (runId, options) => this.watchRunToTerminal(runId, options),
2801
2891
  tail: (runId, options) => this.tailRun(runId, options),
2802
- logs: (runId, options) => this.getRunLogs(runId, options),
2892
+ logs: Object.assign(
2893
+ (runId: string, options?: RunsLogsOptions) =>
2894
+ this.getRunLogs(runId, options),
2895
+ {
2896
+ query: (runId: string, options?: RunsLogsQueryOptions) =>
2897
+ this.queryRunLogs(runId, options),
2898
+ count: (runId: string, criteria?: RunsLogCriteria) =>
2899
+ this.countRunLogs(runId, criteria),
2900
+ summarize: (runId: string, options: RunsLogsSummaryOptions) =>
2901
+ this.summarizeRunLogs(runId, options),
2902
+ fields: (options?: RunsEventsFieldsOptions) =>
2903
+ this.getRunEventFields('logs', options),
2904
+ },
2905
+ ),
2906
+ events: {
2907
+ list: (options) => this.listRunEvents(options),
2908
+ count: (criteria) => this.countRunEvents(criteria),
2909
+ summarize: (options) => this.summarizeRunEvents(options),
2910
+ fields: (options) => this.getRunEventFields('events', options),
2911
+ },
2803
2912
  searchEvents: (options) => this.searchRunEvents(options),
2804
2913
  input: (runId) => this.getRunInput(runId),
2805
2914
  rerun: (runId, options) => this.rerun(runId, options),
@@ -4726,6 +4835,156 @@ export class DeeplineClient {
4726
4835
  };
4727
4836
  }
4728
4837
 
4838
+ /** Query one page of this run's retained logs. `where` accepts typed objects or the shared filter language. */
4839
+ private async queryRunLogs(
4840
+ runId: string,
4841
+ options: RunsLogsQueryOptions = {},
4842
+ ): Promise<RunsLogsQueryResult> {
4843
+ this.assertRunLogQueryRunId(runId, options);
4844
+ const { runtime, ...query } = options;
4845
+ return this.postRunEventQuery(
4846
+ { ...query, operation: 'list', resource: 'logs', runId },
4847
+ runtime,
4848
+ );
4849
+ }
4850
+
4851
+ /** Count matching retained logs exactly, without fetching list pages or saved results. */
4852
+ private async countRunLogs(
4853
+ runId: string,
4854
+ criteria: RunsLogCriteria = {},
4855
+ ): Promise<RunsLogsCountResult> {
4856
+ this.assertRunLogQueryRunId(runId, criteria);
4857
+ const { runtime, ...query } = criteria;
4858
+ return this.postRunEventQuery(
4859
+ { ...query, operation: 'count', resource: 'logs', runId },
4860
+ runtime,
4861
+ );
4862
+ }
4863
+
4864
+ /** Summarize retained logs with explicit group pagination and count or numeric sums. */
4865
+ private async summarizeRunLogs(
4866
+ runId: string,
4867
+ options: RunsLogsSummaryOptions,
4868
+ ): Promise<RunsLogsSummaryResult> {
4869
+ this.assertRunLogQueryRunId(runId, options);
4870
+ const { runtime, ...query } = options;
4871
+ return this.postRunEventQuery(
4872
+ { ...query, operation: 'summarize', resource: 'logs', runId },
4873
+ runtime,
4874
+ );
4875
+ }
4876
+
4877
+ /** Query one page of retained lifecycle, log and receipt events in the active organization. */
4878
+ private async listRunEvents(
4879
+ options: RunsEventsListOptions = {},
4880
+ ): Promise<RunsEventsListResult> {
4881
+ const { runtime, ...query } = options;
4882
+ return this.postRunEventQuery(
4883
+ { ...query, operation: 'list', resource: 'events' },
4884
+ runtime,
4885
+ );
4886
+ }
4887
+
4888
+ /** Count matching retained events exactly in one server query. */
4889
+ private async countRunEvents(
4890
+ criteria: RunsEventsCriteria = {},
4891
+ ): Promise<RunsEventsCountResult> {
4892
+ const { runtime, ...query } = criteria;
4893
+ return this.postRunEventQuery(
4894
+ { ...query, operation: 'count', resource: 'events' },
4895
+ runtime,
4896
+ );
4897
+ }
4898
+
4899
+ /**
4900
+ * Group retained events with exact counts, numeric sums and continuation.
4901
+ * Fractional sums use JavaScript number precision.
4902
+ */
4903
+ private async summarizeRunEvents(
4904
+ options: RunsEventsSummaryOptions,
4905
+ ): Promise<RunsEventsSummaryResult> {
4906
+ const { runtime, ...query } = options;
4907
+ return this.postRunEventQuery(
4908
+ { ...query, operation: 'summarize', resource: 'events' },
4909
+ runtime,
4910
+ );
4911
+ }
4912
+
4913
+ /** Discover query fields and their recorded types; custom scalar fields use `context.<key>`. */
4914
+ private async getRunEventFields(
4915
+ resource: 'logs' | 'events' = 'events',
4916
+ options: RunsEventsFieldsOptions = {},
4917
+ ): Promise<RunEventFieldsResult> {
4918
+ const { runtime, ...query } = options;
4919
+ return this.postRunEventQuery(
4920
+ { ...query, operation: 'fields', resource },
4921
+ runtime,
4922
+ );
4923
+ }
4924
+
4925
+ private async postRunEventQuery<T>(
4926
+ input: RunEventOperationRequest,
4927
+ selection?: PlayRuntimeSelection,
4928
+ ): Promise<T> {
4929
+ const request = normalizeRunEventOperationRequest(input);
4930
+ const params = new URLSearchParams();
4931
+ let headers: Record<string, string> | undefined;
4932
+ let selectedRuntime: PlayRuntimeSelection | undefined;
4933
+ if (selection !== undefined) {
4934
+ const runtime = normalizePlayRuntimeSelection(selection);
4935
+ if (!runtime) {
4936
+ throw new DeeplineError(
4937
+ 'Run event queries require a valid Preview runtime selection.',
4938
+ undefined,
4939
+ 'INVALID_RUNTIME_SELECTION',
4940
+ );
4941
+ }
4942
+ params.set('runtime', 'preview');
4943
+ params.set('namespace', runtime.namespace);
4944
+ if (runtime.backend) params.set('backend', runtime.backend);
4945
+ headers = runtimeSelectionHeaders(runtime);
4946
+ selectedRuntime = runtime;
4947
+ } else {
4948
+ headers = isolatedCiRuntimeEventReadHeaders();
4949
+ }
4950
+ const suffix = params.size > 0 ? `?${params.toString()}` : '';
4951
+ const result = await this.http.post<T>(
4952
+ `/api/v2/runs/events${suffix}`,
4953
+ request,
4954
+ headers,
4955
+ { retryApiErrors: true },
4956
+ );
4957
+ if (
4958
+ selectedRuntime &&
4959
+ result &&
4960
+ typeof result === 'object' &&
4961
+ 'query' in result
4962
+ ) {
4963
+ return {
4964
+ ...result,
4965
+ query: {
4966
+ ...(result as { query: NormalizedRunEventQuery }).query,
4967
+ runtime: selectedRuntime,
4968
+ },
4969
+ };
4970
+ }
4971
+ return result;
4972
+ }
4973
+
4974
+ private assertRunLogQueryRunId(runId: string, criteria: unknown): void {
4975
+ if (
4976
+ criteria &&
4977
+ typeof criteria === 'object' &&
4978
+ 'runId' in criteria &&
4979
+ criteria.runId !== undefined &&
4980
+ criteria.runId !== runId
4981
+ ) {
4982
+ throw new RunEventQueryInputError(
4983
+ 'Log criteria runId conflicts with the positional run ID. Pass the run ID only as the first argument.',
4984
+ );
4985
+ }
4986
+ }
4987
+
4729
4988
  /** Read structured history across the active organization without requiring a run ID. Defaults to the last hour, newest first; use the returned cursor and exact time bounds to continue. See [run logs and events](run-events.md) for all kinds, indexed fields, payloads and SDK/API response types. */
4730
4989
  async searchRunEvents(
4731
4990
  options: RunsEventSearchOptions = {},
@@ -10,7 +10,7 @@ import {
10
10
  } from 'node:fs';
11
11
  import { homedir } from 'node:os';
12
12
  import { dirname, join } from 'node:path';
13
- import { sdkCliStateDirPath } from './config.js';
13
+ import { resolveApiKeyForBaseUrl, sdkCliStateDirPath } from './config.js';
14
14
  import { deploymentProtectionHeaders } from './deployment-protection.js';
15
15
 
16
16
  export type SdkCompatibilityStatus =
@@ -338,6 +338,11 @@ export async function checkSdkCompatibility(
338
338
  skillsVersion?: string | null;
339
339
  /** Blocking budget for the live request; defaults to the full timeout. */
340
340
  timeoutMs?: number;
341
+ /** Optional read-only catalog result carried by the same live check. */
342
+ catalog?: {
343
+ toolId: string;
344
+ acceptMetadata: (metadata: unknown) => void;
345
+ };
341
346
  } = {},
342
347
  ): Promise<{
343
348
  response: SdkCompatibilityResponse | null;
@@ -360,6 +365,9 @@ export async function checkSdkCompatibility(
360
365
  if (options.skillsVersion !== undefined) {
361
366
  url.searchParams.set('skills_version', options.skillsVersion ?? '');
362
367
  }
368
+ if (options.catalog) {
369
+ url.searchParams.set('catalog_tool_id', options.catalog.toolId);
370
+ }
363
371
  const response = await fetch(url, {
364
372
  method: 'GET',
365
373
  headers: {
@@ -369,30 +377,40 @@ export async function checkSdkCompatibility(
369
377
  'X-Deepline-API-Major': String(SDK_API_MAJOR),
370
378
  'X-Deepline-API-Contract': SDK_API_CONTRACT,
371
379
  'X-Deepline-CLI-Update-Preferences': '1',
380
+ ...(options.catalog
381
+ ? { Authorization: `Bearer ${resolveApiKeyForBaseUrl(baseUrl)}` }
382
+ : {}),
372
383
  },
373
384
  signal: controller.signal,
374
385
  });
375
- const data = (await response
376
- .json()
377
- .catch(() => null)) as SdkCompatibilityResponse | null;
386
+ const raw = (await response.json().catch(() => null)) as
387
+ | (SdkCompatibilityResponse & { catalog_metadata?: unknown })
388
+ | null;
378
389
  // Only a policy-shaped body counts as a response. A JSON error page from
379
390
  // a proxy is a failed check: it is never cached, and it falls through to
380
391
  // the cached-policy fallback below like a network error would.
381
- if (
382
- !data ||
383
- typeof data.ok !== 'boolean' ||
384
- typeof data.status !== 'string'
385
- ) {
392
+ if (!raw || typeof raw.ok !== 'boolean' || typeof raw.status !== 'string') {
386
393
  throw new Error(
387
394
  `SDK compatibility endpoint returned a non-policy response (HTTP ${response.status}).`,
388
395
  );
389
396
  }
397
+ // Catalog results belong to this command only, never the policy cache.
398
+ const { catalog_metadata: catalogMetadata, ...data } = raw;
390
399
  writeCachedCompatibility(
391
400
  baseUrl,
392
401
  options.command,
393
402
  options.skillsVersion,
394
403
  data,
395
404
  );
405
+ if (
406
+ options.catalog &&
407
+ catalogMetadata &&
408
+ typeof catalogMetadata === 'object' &&
409
+ 'toolId' in catalogMetadata &&
410
+ catalogMetadata.toolId === options.catalog.toolId
411
+ ) {
412
+ options.catalog.acceptMetadata(catalogMetadata);
413
+ }
396
414
  return { response: data, error: null };
397
415
  } catch (error) {
398
416
  // Live compat policy must win when the server is reachable: rollback and
@@ -78,6 +78,26 @@ export {
78
78
  } from './client.js';
79
79
  export { CtxFetchHttpError } from './play.js';
80
80
  export { RunObserveTransportUnavailableError } from './runs/observe-transport.js';
81
+ export { RunEventQueryInputError } from '../../shared_libs/play-runtime/run-event-query';
82
+ export type {
83
+ RunEventField,
84
+ RunEventFieldOperators,
85
+ RunEventFieldDescriptor,
86
+ RunEventScalar,
87
+ RunEventWhere,
88
+ RunEventMeasure,
89
+ RunEventQueryCriteria,
90
+ RunEventQueryOptions,
91
+ NormalizedRunEventQuery,
92
+ RunEventQueryPage,
93
+ RunEventQueryRetention,
94
+ RunEventSummaryOptions,
95
+ RunEventQueryEvent,
96
+ RunEventCountResult,
97
+ RunEventSummaryResult,
98
+ RunEventFieldsResult,
99
+ RunEventGroupValue,
100
+ } from '../../shared_libs/play-runtime/run-event-query';
81
101
  export type {
82
102
  BillingCreditPool,
83
103
  BillingInvoiceEntry,
@@ -147,6 +167,21 @@ export type {
147
167
  PlaysListPage,
148
168
  RunsLogsOptions,
149
169
  RunsLogsResult,
170
+ RunsLogCriteria,
171
+ RunsLogsNamespace,
172
+ RunsLogsQueryOptions,
173
+ RunsLogsQueryResult,
174
+ RunsLogsCountResult,
175
+ RunsLogsSummaryOptions,
176
+ RunsLogsSummaryResult,
177
+ RunsEventsNamespace,
178
+ RunsEventsCriteria,
179
+ RunsEventsListOptions,
180
+ RunsEventsListResult,
181
+ RunsEventsCountResult,
182
+ RunsEventsSummaryResult,
183
+ RunsEventsSummaryOptions,
184
+ RunsEventsFieldsOptions,
150
185
  RunChildrenPage,
151
186
  RunsChildrenOptions,
152
187
  RunsEventSearchOptions,
@@ -200,7 +200,7 @@ export const SDK_RELEASE = {
200
200
  // getters keep their established compatibility behavior.
201
201
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
202
202
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
203
- version: '0.3.307',
203
+ version: '0.3.308',
204
204
  updateSummary:
205
205
  'Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.',
206
206
  packageCapabilities: {
@@ -23,6 +23,7 @@ export interface CompiledRequestBatch<TRequest> {
23
23
  batchOperation: string;
24
24
  memberRequests: TRequest[];
25
25
  batchPayload: Record<string, unknown>;
26
+ resultView?: 'rawV2';
26
27
  splitResults: (value: unknown) => Array<unknown | null>;
27
28
  }
28
29
 
@@ -190,6 +191,9 @@ export function compileRequestsWithStrategy<TRequest>(input: {
190
191
  batchOperation: compiled.batchOperation,
191
192
  memberRequests,
192
193
  batchPayload: compiled.batchPayload as Record<string, unknown>,
194
+ ...(input.strategy.resultView
195
+ ? { resultView: input.strategy.resultView }
196
+ : {}),
193
197
  splitResults: (value: unknown) => {
194
198
  const splitResults = input.strategy.splitResult(
195
199
  value as never,
@@ -45,6 +45,8 @@ export type BatchOperationStrategy<
45
45
  batchOperation: string;
46
46
  kind: BatchStrategyKind;
47
47
  maxBatchSize: number;
48
+ /** Omitted keeps the historical legacy raw input to the splitter. */
49
+ resultView?: 'rawV2';
48
50
  /**
49
51
  * Payload field names that can change the batch bucket. Static map planning
50
52
  * may treat a tool call as one bucket only when these fields are absent from
@@ -68,6 +70,7 @@ export type AnyBatchOperationStrategy = {
68
70
  batchOperation: string;
69
71
  kind: BatchStrategyKind;
70
72
  maxBatchSize: number;
73
+ resultView?: 'rawV2';
71
74
  bucketKeyPayloadFields?: string[];
72
75
  canBatchWith(
73
76
  left: Record<string, unknown>,
@@ -1504,16 +1504,25 @@ function publicToolResponseForBatchedItem(
1504
1504
  }
1505
1505
 
1506
1506
  /**
1507
- * Batch splitters predate raw-v2 and receive the same legacy value they got
1508
- * from callToolAPI. Keep that input contract stable; raw-v2 is attached to the
1509
- * completed logical call separately by publicToolResponseForBatchedItem.
1507
+ * Batch splitters default to their historical legacy input. A strategy whose
1508
+ * provider envelope is lost by that projection can explicitly select rawV2.
1509
+ * Older responses without rawV2 retain the historical input.
1510
1510
  *
1511
1511
  * Physical map dispatch now crosses the Tool Call Module, which returns the
1512
1512
  * public ToolExecuteResult rather than leaking its private HTTP parse shape.
1513
1513
  * This adapter deliberately projects that result back to the splitter's
1514
1514
  * long-lived legacy input contract at the edge.
1515
1515
  */
1516
- function legacyResultForBatchSplitter(execution: ToolExecuteResult): unknown {
1516
+ function resultForBatchSplitter(
1517
+ execution: ToolExecuteResult,
1518
+ resultView?: 'rawV2',
1519
+ ): unknown {
1520
+ if (
1521
+ resultView === 'rawV2' &&
1522
+ Object.prototype.hasOwnProperty.call(execution.toolResponse, 'rawV2')
1523
+ ) {
1524
+ return execution.toolResponse.rawV2;
1525
+ }
1517
1526
  return execution.toolResponse.raw;
1518
1527
  }
1519
1528
 
@@ -1856,6 +1865,8 @@ type ToolExecutionApiOptions = {
1856
1865
  } | null;
1857
1866
  /** The receipt key is a completed-result cache for this read-only call. */
1858
1867
  completedResultCache?: boolean;
1868
+ /** Runner-local projection required by this native batch's splitter. */
1869
+ batchResultView?: 'rawV2';
1859
1870
  executionAuthScopeDigest?: string | null;
1860
1871
  providerIdempotencyKey?: string | null;
1861
1872
  /** Invocation identities that participate in the canonical operation key. */
@@ -16165,6 +16176,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
16165
16176
  },
16166
16177
  ],
16167
16178
  completedResultCache: true,
16179
+ batchResultView: detail.compiled.resultView,
16168
16180
  memoryLedgerRowScopes: detail.members.map((member) => ({
16169
16181
  rowKey: member.rowKey,
16170
16182
  fieldName: member.fieldName,
@@ -16389,7 +16401,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
16389
16401
  );
16390
16402
  }
16391
16403
  const split = detail.compiled.splitResults(
16392
- legacyResultForBatchSplitter(aggregate),
16404
+ resultForBatchSplitter(aggregate, detail.compiled.resultView),
16393
16405
  );
16394
16406
  // The members are separable now, so the body stops being an
16395
16407
  // average and becomes each row's own slice. A batch where one
@@ -16766,6 +16778,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
16766
16778
  resultReceiptKey: aggregateReceiptKey,
16767
16779
  providerOperationKey: aggregateProviderOperationKey,
16768
16780
  apiOptions: {
16781
+ batchResultView: batch.resultView,
16769
16782
  durableCallReceiptKey: aggregateReceiptKey,
16770
16783
  onProviderAdmissionPending: () =>
16771
16784
  admissionObserver?.pending(batch.memberRequests),
@@ -16859,8 +16872,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
16859
16872
  const splitResults =
16860
16873
  batchExecution != null
16861
16874
  ? entry.request.splitResults(
16862
- legacyResultForBatchSplitter(
16875
+ resultForBatchSplitter(
16863
16876
  batchExecution.execution,
16877
+ entry.request.resultView,
16864
16878
  ),
16865
16879
  )
16866
16880
  : entry.request.memberRequests.map(() => null);
@@ -17336,6 +17350,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17336
17350
  contract: AsyncOperationContractWire;
17337
17351
  startInput: Record<string, unknown>;
17338
17352
  startResponse: ParsedToolExecuteResponse;
17353
+ batchResultView?: 'rawV2';
17339
17354
  }): Promise<ParsedToolExecuteResponse> {
17340
17355
  const startResult = input.startResponse.toolResponse?.raw;
17341
17356
  const startClassificationFallback = input.startResponse.toolResponse?.rawV2;
@@ -17416,7 +17431,14 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17416
17431
  skipAsyncOperationResolution: true,
17417
17432
  uncachedAsyncLifecycleCall: true,
17418
17433
  }),
17419
- responseValue: (response) => response.toolResponse?.raw,
17434
+ responseValue: (response) =>
17435
+ input.batchResultView === 'rawV2' &&
17436
+ Object.prototype.hasOwnProperty.call(
17437
+ response.toolResponse ?? {},
17438
+ 'rawV2',
17439
+ )
17440
+ ? response.toolResponse?.rawV2
17441
+ : response.toolResponse?.raw,
17420
17442
  classificationFallback: (response) => response.toolResponse?.rawV2,
17421
17443
  onJobStarted: () => {
17422
17444
  this.runtimeLog(
@@ -17494,14 +17516,16 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17494
17516
  const materialized = lifecycle.materialized;
17495
17517
  const originalRawV2 = input.startResponse.toolResponse?.rawV2;
17496
17518
  const rawV2 =
17497
- originalRawV2 &&
17498
- typeof originalRawV2 === 'object' &&
17499
- !Array.isArray(originalRawV2)
17500
- ? {
17501
- ...(originalRawV2 as Record<string, unknown>),
17502
- data: materialized.result,
17503
- }
17504
- : { data: materialized.result };
17519
+ input.batchResultView === 'rawV2'
17520
+ ? materialized.result
17521
+ : originalRawV2 &&
17522
+ typeof originalRawV2 === 'object' &&
17523
+ !Array.isArray(originalRawV2)
17524
+ ? {
17525
+ ...(originalRawV2 as Record<string, unknown>),
17526
+ data: materialized.result,
17527
+ }
17528
+ : { data: materialized.result };
17505
17529
  const responseMeta = input.startResponse.toolResponse?.meta;
17506
17530
  return {
17507
17531
  ...input.startResponse,
@@ -17961,7 +17985,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17961
17985
  : {}),
17962
17986
  }
17963
17987
  : {}),
17964
- ...(options?.relayReceiptOutput
17988
+ // Runtime-managed polling replaces the launch body locally.
17989
+ // The relay can publish only its own body, so terminal cache
17990
+ // publication must remain with the runner for these calls.
17991
+ ...(options?.relayReceiptOutput &&
17992
+ !shouldResolveAsyncOperationInRuntime
17965
17993
  ? {
17966
17994
  runtime_receipt_output: {
17967
17995
  receipt_key: options.relayReceiptOutput.receiptKey,
@@ -19482,6 +19510,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
19482
19510
  contract: asyncContract!,
19483
19511
  startInput: toolInputSnapshot,
19484
19512
  startResponse: parsed,
19513
+ batchResultView: options?.batchResultView,
19485
19514
  })
19486
19515
  : parsed;
19487
19516
  // Only the configured execution relay may mint this header. The
@@ -19489,6 +19518,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
19489
19518
  // established full-payload completion behavior even if an
19490
19519
  // upstream response happens to contain a lookalike header.
19491
19520
  const receiptOutputRef =
19521
+ !shouldResolveAsyncOperationInRuntime &&
19492
19522
  this.#options.executionGatewayBaseUrl?.trim()
19493
19523
  ? parseExecutionGatewayReceiptOutputReference(
19494
19524
  response.headers.get(