deepline 0.1.12 → 0.1.20

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 (82) hide show
  1. package/README.md +14 -6
  2. package/dist/cli/index.js +1346 -717
  3. package/dist/cli/index.mjs +1342 -713
  4. package/dist/index.d.mts +199 -23
  5. package/dist/index.d.ts +199 -23
  6. package/dist/index.js +221 -14
  7. package/dist/index.mjs +221 -14
  8. package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +214 -77
  9. package/dist/repo/apps/play-runner-workers/src/dedup-do.ts +85 -60
  10. package/dist/repo/apps/play-runner-workers/src/entry.ts +385 -66
  11. package/dist/repo/sdk/src/client.ts +237 -0
  12. package/dist/repo/sdk/src/config.ts +125 -8
  13. package/dist/repo/sdk/src/http.ts +29 -5
  14. package/dist/repo/sdk/src/play.ts +19 -36
  15. package/dist/repo/sdk/src/plays/bundle-play-file.ts +22 -8
  16. package/dist/repo/sdk/src/plays/local-file-discovery.ts +207 -160
  17. package/dist/repo/sdk/src/types.ts +25 -0
  18. package/dist/repo/sdk/src/version.ts +2 -2
  19. package/dist/repo/shared_libs/play-runtime/tool-result.ts +237 -145
  20. package/dist/repo/shared_libs/plays/bundling/index.ts +206 -229
  21. package/dist/repo/shared_libs/plays/dataset.ts +28 -0
  22. package/dist/repo/shared_libs/plays/row-identity.ts +59 -4
  23. package/package.json +5 -4
  24. package/dist/cli/index.js.map +0 -1
  25. package/dist/cli/index.mjs.map +0 -1
  26. package/dist/index.js.map +0 -1
  27. package/dist/index.mjs.map +0 -1
  28. package/dist/repo/apps/play-runner-workers/src/runtime/README.md +0 -21
  29. package/dist/repo/apps/play-runner-workers/src/runtime/batching.ts +0 -177
  30. package/dist/repo/apps/play-runner-workers/src/runtime/execution-plan.ts +0 -52
  31. package/dist/repo/apps/play-runner-workers/src/runtime/tool-batch.ts +0 -100
  32. package/dist/repo/sdk/src/cli/commands/auth.ts +0 -500
  33. package/dist/repo/sdk/src/cli/commands/billing.ts +0 -188
  34. package/dist/repo/sdk/src/cli/commands/csv.ts +0 -123
  35. package/dist/repo/sdk/src/cli/commands/db.ts +0 -119
  36. package/dist/repo/sdk/src/cli/commands/feedback.ts +0 -40
  37. package/dist/repo/sdk/src/cli/commands/org.ts +0 -117
  38. package/dist/repo/sdk/src/cli/commands/play.ts +0 -3441
  39. package/dist/repo/sdk/src/cli/commands/tools.ts +0 -687
  40. package/dist/repo/sdk/src/cli/dataset-stats.ts +0 -415
  41. package/dist/repo/sdk/src/cli/index.ts +0 -148
  42. package/dist/repo/sdk/src/cli/progress.ts +0 -149
  43. package/dist/repo/sdk/src/cli/skills-sync.ts +0 -141
  44. package/dist/repo/sdk/src/cli/trace.ts +0 -61
  45. package/dist/repo/sdk/src/cli/utils.ts +0 -145
  46. package/dist/repo/sdk/src/compat.ts +0 -77
  47. package/dist/repo/shared_libs/observability/node-tracing.ts +0 -129
  48. package/dist/repo/shared_libs/observability/tracing.ts +0 -98
  49. package/dist/repo/shared_libs/play-runtime/context.ts +0 -4242
  50. package/dist/repo/shared_libs/play-runtime/ctx-contract.ts +0 -250
  51. package/dist/repo/shared_libs/play-runtime/ctx-types.ts +0 -725
  52. package/dist/repo/shared_libs/play-runtime/dataset-id.ts +0 -10
  53. package/dist/repo/shared_libs/play-runtime/db-session-crypto.ts +0 -304
  54. package/dist/repo/shared_libs/play-runtime/db-session.ts +0 -462
  55. package/dist/repo/shared_libs/play-runtime/live-events.ts +0 -214
  56. package/dist/repo/shared_libs/play-runtime/live-state-contract.ts +0 -50
  57. package/dist/repo/shared_libs/play-runtime/map-execution-frame.ts +0 -114
  58. package/dist/repo/shared_libs/play-runtime/map-row-identity.ts +0 -158
  59. package/dist/repo/shared_libs/play-runtime/progress-emitter.ts +0 -172
  60. package/dist/repo/shared_libs/play-runtime/protocol.ts +0 -121
  61. package/dist/repo/shared_libs/play-runtime/public-play-contract.ts +0 -42
  62. package/dist/repo/shared_libs/play-runtime/result-normalization.ts +0 -33
  63. package/dist/repo/shared_libs/play-runtime/runtime-api.ts +0 -1873
  64. package/dist/repo/shared_libs/play-runtime/runtime-constraints.ts +0 -2
  65. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +0 -201
  66. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-pg.ts +0 -48
  67. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver.ts +0 -84
  68. package/dist/repo/shared_libs/play-runtime/static-pipeline-types.ts +0 -147
  69. package/dist/repo/shared_libs/play-runtime/suspension.ts +0 -68
  70. package/dist/repo/shared_libs/play-runtime/tracing.ts +0 -31
  71. package/dist/repo/shared_libs/play-runtime/waterfall-replay.ts +0 -75
  72. package/dist/repo/shared_libs/play-runtime/worker-api-types.ts +0 -140
  73. package/dist/repo/shared_libs/plays/artifact-transport.ts +0 -14
  74. package/dist/repo/shared_libs/plays/artifact-types.ts +0 -49
  75. package/dist/repo/shared_libs/plays/compiler-manifest.ts +0 -186
  76. package/dist/repo/shared_libs/plays/definition.ts +0 -264
  77. package/dist/repo/shared_libs/plays/file-refs.ts +0 -11
  78. package/dist/repo/shared_libs/plays/rate-limit-scheduler.ts +0 -206
  79. package/dist/repo/shared_libs/plays/resolve-static-pipeline.ts +0 -164
  80. package/dist/repo/shared_libs/plays/runtime-validation.ts +0 -395
  81. package/dist/repo/shared_libs/temporal/constants.ts +0 -39
  82. package/dist/repo/shared_libs/temporal/preview-config.ts +0 -153
package/dist/index.js CHANGED
@@ -88,6 +88,10 @@ var ConfigError = class extends DeeplineError {
88
88
  var PROD_URL = "https://code.deepline.com";
89
89
  var DEFAULT_TIMEOUT = 6e4;
90
90
  var DEFAULT_MAX_RETRIES = 3;
91
+ var ACTIVE_DEEPLINE_ENV_FILE = ".env.deepline";
92
+ function projectEnvStartDir() {
93
+ return process.env.DEEPLINE_PROJECT_ENV_DIR?.trim() || process.cwd();
94
+ }
91
95
  function baseUrlSlug(baseUrl) {
92
96
  let url;
93
97
  try {
@@ -123,16 +127,52 @@ function parseEnvFile(filePath) {
123
127
  }
124
128
  return env;
125
129
  }
126
- function findNearestWorktreeEnv(startDir = process.cwd()) {
130
+ function findNearestEnvFile(names, startDir = process.cwd()) {
127
131
  let current = (0, import_node_path.resolve)(startDir);
128
132
  while (true) {
129
- const values = parseEnvFile((0, import_node_path.join)(current, ".env.worktree"));
130
- if (Object.keys(values).length > 0) return values;
133
+ for (const name of names) {
134
+ const filePath = (0, import_node_path.join)(current, name);
135
+ if ((0, import_node_fs.existsSync)(filePath)) return filePath;
136
+ }
131
137
  const parent = (0, import_node_path.dirname)(current);
132
- if (parent === current) return {};
138
+ if (parent === current) return null;
133
139
  current = parent;
134
140
  }
135
141
  }
142
+ function findNearestEnv(names, startDir = process.cwd()) {
143
+ const filePath = findNearestEnvFile(names, startDir);
144
+ return filePath ? parseEnvFile(filePath) : {};
145
+ }
146
+ function findNearestWorktreeEnv(startDir = process.cwd()) {
147
+ return findNearestEnv([".env.worktree"], startDir);
148
+ }
149
+ function resolveProfileEnvFileNames() {
150
+ const explicitProfile = process.env.DEEPLINE_ENV_PROFILE?.trim() || process.env.DEEPLINE_PROFILE?.trim() || "";
151
+ const names = [];
152
+ if (explicitProfile) names.push(`.env.deepline.${explicitProfile}`);
153
+ const nodeEnv = process.env.NODE_ENV?.trim();
154
+ if (nodeEnv === "production") names.push(".env.deepline.prod");
155
+ else if (nodeEnv === "staging") names.push(".env.deepline.staging");
156
+ names.push(ACTIVE_DEEPLINE_ENV_FILE);
157
+ return names;
158
+ }
159
+ function resolveProjectAppEnvFileNames() {
160
+ const nodeEnv = process.env.NODE_ENV?.trim();
161
+ const names = [];
162
+ if (nodeEnv === "production") names.push(".env.prod");
163
+ if (nodeEnv === "staging") names.push(".env.staging");
164
+ names.push(".env.local", ".env");
165
+ return names;
166
+ }
167
+ function resolveBaseUrlFromEnvValues(env) {
168
+ return env.DEEPLINE_ORIGIN_URL?.trim() || env.DEEPLINE_API_BASE_URL?.trim() || "";
169
+ }
170
+ function loadProjectDeeplineEnv() {
171
+ return findNearestEnv(resolveProfileEnvFileNames(), projectEnvStartDir());
172
+ }
173
+ function loadProjectAppEnv() {
174
+ return findNearestEnv(resolveProjectAppEnvFileNames(), projectEnvStartDir());
175
+ }
136
176
  function normalizeWorktreeBaseUrl(baseUrl, worktreeEnv = findNearestWorktreeEnv()) {
137
177
  const trimmed = baseUrl.trim().replace(/\/$/, "");
138
178
  if (!trimmed) return trimmed;
@@ -169,6 +209,10 @@ function autoDetectBaseUrl() {
169
209
  if (envOrigin) return normalizeWorktreeBaseUrl(envOrigin);
170
210
  const envBase = process.env.DEEPLINE_API_BASE_URL?.trim();
171
211
  if (envBase) return normalizeWorktreeBaseUrl(envBase);
212
+ const projectDeeplineBaseUrl = resolveBaseUrlFromEnvValues(loadProjectDeeplineEnv());
213
+ if (projectDeeplineBaseUrl) return normalizeWorktreeBaseUrl(projectDeeplineBaseUrl);
214
+ const projectAppBaseUrl = resolveBaseUrlFromEnvValues(loadProjectAppEnv());
215
+ if (projectAppBaseUrl) return normalizeWorktreeBaseUrl(projectAppBaseUrl);
172
216
  const worktreeBaseUrl = resolveWorktreeBaseUrl();
173
217
  if (worktreeBaseUrl) return worktreeBaseUrl;
174
218
  const globalEnv = loadGlobalCliEnv();
@@ -180,7 +224,9 @@ function resolveConfig(options) {
180
224
  const requestedBaseUrl = options?.baseUrl?.trim() || autoDetectBaseUrl();
181
225
  const baseUrl = normalizeWorktreeBaseUrl(requestedBaseUrl);
182
226
  const cliEnv = loadCliEnv(baseUrl);
183
- const apiKey = options?.apiKey?.trim() || process.env.DEEPLINE_API_KEY?.trim() || cliEnv.DEEPLINE_API_KEY || "";
227
+ const projectDeeplineEnv = loadProjectDeeplineEnv();
228
+ const projectAppEnv = loadProjectAppEnv();
229
+ const apiKey = options?.apiKey?.trim() || process.env.DEEPLINE_API_KEY?.trim() || projectDeeplineEnv.DEEPLINE_API_KEY || projectAppEnv.DEEPLINE_API_KEY || cliEnv.DEEPLINE_API_KEY || "";
184
230
  if (!apiKey) {
185
231
  throw new ConfigError(
186
232
  `No API key found. Set DEEPLINE_API_KEY env var, pass apiKey option, or run: deepline auth register`
@@ -195,8 +241,8 @@ function resolveConfig(options) {
195
241
  }
196
242
 
197
243
  // src/version.ts
198
- var SDK_VERSION = "0.1.12";
199
- var SDK_API_CONTRACT = "2026-04-plays-v1";
244
+ var SDK_VERSION = "0.1.20";
245
+ var SDK_API_CONTRACT = "2026-05-runs-v2";
200
246
 
201
247
  // ../shared_libs/play-runtime/coordinator-headers.ts
202
248
  var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
@@ -302,7 +348,8 @@ var HttpClient = class {
302
348
  parsed = body;
303
349
  }
304
350
  if (!response.ok) {
305
- const msg = typeof parsed === "object" && parsed && "error" in parsed ? String(parsed.error) : `HTTP ${response.status}`;
351
+ const errorValue = typeof parsed === "object" && parsed && "error" in parsed ? parsed.error : void 0;
352
+ const msg = typeof errorValue === "string" ? errorValue : errorValue && typeof errorValue === "object" && "message" in errorValue && typeof errorValue.message === "string" ? errorValue.message : typeof parsed === "object" && parsed && "message" in parsed && typeof parsed.message === "string" ? parsed.message : `HTTP ${response.status}`;
306
353
  throw new DeeplineError(msg, response.status, "API_ERROR", {
307
354
  response: parsed
308
355
  });
@@ -389,8 +436,12 @@ var HttpClient = class {
389
436
  * @param path - API path
390
437
  * @param body - Request body (will be JSON-serialized)
391
438
  */
392
- async post(path, body) {
393
- return this.request(path, { method: "POST", body });
439
+ async post(path, body, headers) {
440
+ return this.request(path, {
441
+ method: "POST",
442
+ body,
443
+ headers
444
+ });
394
445
  }
395
446
  /**
396
447
  * Send a DELETE request.
@@ -470,6 +521,7 @@ function sleep(ms) {
470
521
 
471
522
  // src/client.ts
472
523
  var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
524
+ var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
473
525
  function isRecord(value) {
474
526
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
475
527
  }
@@ -502,6 +554,7 @@ function mapLegacyTemporalStatus(status) {
502
554
  var DeeplineClient = class {
503
555
  http;
504
556
  config;
557
+ runs;
505
558
  /**
506
559
  * @param options - Optional overrides for API key, base URL, timeout, and retries.
507
560
  * @throws {@link ConfigError} if no API key can be resolved from any source.
@@ -509,6 +562,13 @@ var DeeplineClient = class {
509
562
  constructor(options) {
510
563
  this.config = resolveConfig(options);
511
564
  this.http = new HttpClient(this.config);
565
+ this.runs = {
566
+ get: (runId) => this.getRunStatus(runId),
567
+ list: (options2) => this.listRuns(options2),
568
+ tail: (runId, options2) => this.tailRun(runId, options2),
569
+ logs: (runId, options2) => this.getRunLogs(runId, options2),
570
+ stop: (runId, options2) => this.stopRun(runId, options2)
571
+ };
512
572
  }
513
573
  /** The resolved base URL this client is targeting (e.g. `"http://localhost:3000"`). */
514
574
  get baseUrl() {
@@ -597,6 +657,31 @@ var DeeplineClient = class {
597
657
  );
598
658
  return res.tools;
599
659
  }
660
+ /**
661
+ * Search available tools using Deepline's ranked backend search.
662
+ *
663
+ * This is the same discovery surface used by the legacy CLI: it ranks across
664
+ * tool metadata, categories, agent guidance, and input schema fields.
665
+ */
666
+ async searchTools(options = {}) {
667
+ const params = new URLSearchParams();
668
+ const query = options.query?.trim() ?? "";
669
+ params.set("q", query);
670
+ params.set(
671
+ "include_search_debug",
672
+ options.includeSearchDebug ? "true" : "false"
673
+ );
674
+ params.set("search_mode", options.searchMode ?? "v2");
675
+ if (options.categories?.trim()) {
676
+ params.set("categories", options.categories.trim());
677
+ }
678
+ if (options.searchTerms?.trim()) {
679
+ params.set("search_terms", options.searchTerms.trim());
680
+ }
681
+ return this.http.get(
682
+ `/api/v2/integrations/list?${params.toString()}`
683
+ );
684
+ }
600
685
  /**
601
686
  * Get detailed metadata for a single tool.
602
687
  *
@@ -632,12 +717,17 @@ var DeeplineClient = class {
632
717
  * Top-level fields such as `status`, `job_id`, and `billing` describe the
633
718
  * Deepline execution.
634
719
  */
635
- async executeTool(toolId, input) {
720
+ async executeTool(toolId, input, options) {
721
+ const headers = options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : void 0;
636
722
  return this.http.post(
637
723
  `/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
638
- { payload: input }
724
+ { payload: input },
725
+ headers
639
726
  );
640
727
  }
728
+ async executeToolRaw(toolId, input, options) {
729
+ return this.executeTool(toolId, input, options);
730
+ }
641
731
  async queryCustomerDb(input) {
642
732
  return this.http.post("/api/v2/db/query", {
643
733
  sql: input.sql,
@@ -686,6 +776,7 @@ var DeeplineClient = class {
686
776
  ...request.revisionId ? { revisionId: request.revisionId } : {},
687
777
  ...request.artifactStorageKey ? { artifactStorageKey: request.artifactStorageKey } : {},
688
778
  ...request.sourceCode ? { sourceCode: request.sourceCode } : {},
779
+ ...request.sourceFiles ? { sourceFiles: request.sourceFiles } : {},
689
780
  ..."staticPipeline" in request ? { staticPipeline: request.staticPipeline } : {},
690
781
  ...request.artifactHash ? { artifactHash: request.artifactHash } : {},
691
782
  ...request.graphHash ? { graphHash: request.graphHash } : {},
@@ -710,6 +801,7 @@ var DeeplineClient = class {
710
801
  ...request.revisionId ? { revisionId: request.revisionId } : {},
711
802
  ...request.artifactStorageKey ? { artifactStorageKey: request.artifactStorageKey } : {},
712
803
  ...request.sourceCode ? { sourceCode: request.sourceCode } : {},
804
+ ...request.sourceFiles ? { sourceFiles: request.sourceFiles } : {},
713
805
  ..."staticPipeline" in request ? { staticPipeline: request.staticPipeline } : {},
714
806
  ...request.artifactHash ? { artifactHash: request.artifactHash } : {},
715
807
  ...request.graphHash ? { graphHash: request.graphHash } : {},
@@ -746,6 +838,7 @@ var DeeplineClient = class {
746
838
  const compilerManifest = input.compilerManifest ?? await this.compilePlayManifest({
747
839
  name: input.name,
748
840
  sourceCode: input.sourceCode,
841
+ sourceFiles: input.sourceFiles,
749
842
  artifact: input.artifact
750
843
  });
751
844
  return this.http.post("/api/v2/plays/artifacts", {
@@ -760,6 +853,7 @@ var DeeplineClient = class {
760
853
  compilerManifest: artifact.compilerManifest ?? await this.compilePlayManifest({
761
854
  name: artifact.name,
762
855
  sourceCode: artifact.sourceCode,
856
+ sourceFiles: artifact.sourceFiles,
763
857
  artifact: artifact.artifact
764
858
  })
765
859
  }))
@@ -786,11 +880,13 @@ var DeeplineClient = class {
786
880
  const compilerManifest = input.compilerManifest ?? await this.compilePlayManifest({
787
881
  name: input.name,
788
882
  sourceCode: input.sourceCode,
883
+ sourceFiles: input.sourceFiles,
789
884
  artifact: input.artifact
790
885
  });
791
886
  const registeredArtifact = await this.registerPlayArtifact({
792
887
  name: input.name,
793
888
  sourceCode: input.sourceCode,
889
+ sourceFiles: input.sourceFiles,
794
890
  artifact: input.artifact,
795
891
  compilerManifest,
796
892
  publish: false
@@ -850,11 +946,13 @@ var DeeplineClient = class {
850
946
  const compilerManifest = options?.compilerManifest ?? await this.compilePlayManifest({
851
947
  name,
852
948
  sourceCode,
949
+ sourceFiles: options?.sourceFiles,
853
950
  artifact
854
951
  });
855
952
  const registeredArtifact = await this.registerPlayArtifact({
856
953
  name,
857
954
  sourceCode,
955
+ sourceFiles: options?.sourceFiles,
858
956
  artifact,
859
957
  compilerManifest,
860
958
  publish: false
@@ -1038,6 +1136,112 @@ var DeeplineClient = class {
1038
1136
  );
1039
1137
  return response.runs ?? [];
1040
1138
  }
1139
+ /**
1140
+ * Get a run by id using the public runs resource model.
1141
+ *
1142
+ * This is the SDK equivalent of:
1143
+ *
1144
+ * ```bash
1145
+ * deepline runs get <run-id> --json
1146
+ * ```
1147
+ */
1148
+ async getRunStatus(runId) {
1149
+ const response = await this.http.get(
1150
+ `/api/v2/runs/${encodeURIComponent(runId)}`
1151
+ );
1152
+ return normalizePlayStatus(response);
1153
+ }
1154
+ /**
1155
+ * List play runs using the public runs resource model.
1156
+ *
1157
+ * This is the SDK equivalent of:
1158
+ *
1159
+ * ```bash
1160
+ * deepline runs list --play <play-name> --status failed --json
1161
+ * ```
1162
+ */
1163
+ async listRuns(options) {
1164
+ const playName = options.play.trim();
1165
+ if (!playName) {
1166
+ throw new Error("runs.list requires options.play.");
1167
+ }
1168
+ const params = new URLSearchParams({ play: playName });
1169
+ const status = options.status?.trim();
1170
+ if (status) {
1171
+ params.set("status", status);
1172
+ }
1173
+ const response = await this.http.get(
1174
+ `/api/v2/runs?${params.toString()}`
1175
+ );
1176
+ return response.runs ?? [];
1177
+ }
1178
+ /**
1179
+ * Fetch the lightweight tail status for a run using the public runs resource model.
1180
+ *
1181
+ * This is the SDK equivalent of:
1182
+ *
1183
+ * ```bash
1184
+ * deepline runs tail <run-id> --json
1185
+ * ```
1186
+ */
1187
+ async tailRun(runId, options) {
1188
+ const afterLogIndex = typeof options?.afterLogIndex === "number" ? options.afterLogIndex : typeof options?.cursor === "number" ? options.cursor : typeof options?.cursor === "string" && options.cursor.trim() ? Number(options.cursor) : void 0;
1189
+ const params = new URLSearchParams();
1190
+ if (Number.isFinite(afterLogIndex)) {
1191
+ params.set("afterLogIndex", String(Number(afterLogIndex)));
1192
+ }
1193
+ if (typeof options?.waitMs === "number") {
1194
+ params.set("waitMs", String(options.waitMs));
1195
+ }
1196
+ if (options?.terminalOnly) {
1197
+ params.set("terminalOnly", "true");
1198
+ }
1199
+ const suffix = params.toString() ? `?${params.toString()}` : "";
1200
+ const response = await this.http.get(
1201
+ `/api/v2/runs/${encodeURIComponent(runId)}/tail${suffix}`
1202
+ );
1203
+ return normalizePlayStatus(response);
1204
+ }
1205
+ /**
1206
+ * Fetch persisted logs for a run using the public runs resource model.
1207
+ *
1208
+ * This is the SDK equivalent of:
1209
+ *
1210
+ * ```bash
1211
+ * deepline runs logs <run-id> --limit 200 --json
1212
+ * ```
1213
+ */
1214
+ async getRunLogs(runId, options) {
1215
+ const status = await this.getRunStatus(runId);
1216
+ const logs = status.progress?.logs ?? [];
1217
+ const limit = typeof options?.limit === "number" && Number.isFinite(options.limit) ? Math.max(0, Math.trunc(options.limit)) : 200;
1218
+ const entries = logs.slice(Math.max(0, logs.length - limit));
1219
+ return {
1220
+ runId: status.runId,
1221
+ totalCount: logs.length,
1222
+ returnedCount: entries.length,
1223
+ firstSequence: logs.length === 0 ? null : logs.length - entries.length + 1,
1224
+ lastSequence: logs.length === 0 ? null : logs.length,
1225
+ truncated: logs.length > entries.length,
1226
+ hasMore: logs.length > entries.length,
1227
+ entries
1228
+ };
1229
+ }
1230
+ /**
1231
+ * Stop a run by id using the public runs resource model.
1232
+ *
1233
+ * This is the SDK equivalent of:
1234
+ *
1235
+ * ```bash
1236
+ * deepline runs stop <run-id> --reason "stale lock" --json
1237
+ * ```
1238
+ */
1239
+ async stopRun(runId, options) {
1240
+ return this.http.post(
1241
+ `/api/v2/runs/${encodeURIComponent(runId)}/stop`,
1242
+ options?.reason ? { reason: options.reason } : {}
1243
+ );
1244
+ }
1041
1245
  async listPlays() {
1042
1246
  const response = await this.http.get(
1043
1247
  "/api/v2/plays"
@@ -1403,7 +1607,11 @@ var DeeplineContext = class {
1403
1607
  /** Get detailed metadata for a tool. */
1404
1608
  get: (toolId) => this.client.getTool(toolId),
1405
1609
  /** Execute a tool and return the standard execution envelope. */
1406
- execute: async (toolId, input) => this.client.executeTool(toolId, input)
1610
+ execute: async (toolId, input) => this.client.executeTool(
1611
+ toolId,
1612
+ input,
1613
+ { includeToolMetadata: true }
1614
+ )
1407
1615
  };
1408
1616
  }
1409
1617
  get plays() {
@@ -1771,4 +1979,3 @@ function extractSummaryFields(payload) {
1771
1979
  writeCsvOutputFile,
1772
1980
  writeJsonOutputFile
1773
1981
  });
1774
- //# sourceMappingURL=index.js.map