deepline 0.1.12 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -6
- package/dist/cli/index.js +1298 -711
- package/dist/cli/index.mjs +1294 -707
- package/dist/index.d.mts +199 -23
- package/dist/index.d.ts +199 -23
- package/dist/index.js +219 -13
- package/dist/index.mjs +219 -13
- package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +68 -12
- package/dist/repo/apps/play-runner-workers/src/entry.ts +241 -51
- package/dist/repo/sdk/src/client.ts +237 -0
- package/dist/repo/sdk/src/config.ts +125 -8
- package/dist/repo/sdk/src/http.ts +10 -2
- package/dist/repo/sdk/src/play.ts +19 -36
- package/dist/repo/sdk/src/plays/bundle-play-file.ts +22 -8
- package/dist/repo/sdk/src/plays/local-file-discovery.ts +207 -160
- package/dist/repo/sdk/src/types.ts +25 -0
- package/dist/repo/sdk/src/version.ts +2 -2
- package/dist/repo/shared_libs/play-runtime/tool-result.ts +237 -145
- package/dist/repo/shared_libs/plays/bundling/index.ts +206 -229
- package/dist/repo/shared_libs/plays/dataset.ts +28 -0
- package/package.json +5 -4
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/index.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/repo/apps/play-runner-workers/src/runtime/README.md +0 -21
- package/dist/repo/apps/play-runner-workers/src/runtime/batching.ts +0 -177
- package/dist/repo/apps/play-runner-workers/src/runtime/execution-plan.ts +0 -52
- package/dist/repo/apps/play-runner-workers/src/runtime/tool-batch.ts +0 -100
- package/dist/repo/sdk/src/cli/commands/auth.ts +0 -500
- package/dist/repo/sdk/src/cli/commands/billing.ts +0 -188
- package/dist/repo/sdk/src/cli/commands/csv.ts +0 -123
- package/dist/repo/sdk/src/cli/commands/db.ts +0 -119
- package/dist/repo/sdk/src/cli/commands/feedback.ts +0 -40
- package/dist/repo/sdk/src/cli/commands/org.ts +0 -117
- package/dist/repo/sdk/src/cli/commands/play.ts +0 -3441
- package/dist/repo/sdk/src/cli/commands/tools.ts +0 -687
- package/dist/repo/sdk/src/cli/dataset-stats.ts +0 -415
- package/dist/repo/sdk/src/cli/index.ts +0 -148
- package/dist/repo/sdk/src/cli/progress.ts +0 -149
- package/dist/repo/sdk/src/cli/skills-sync.ts +0 -141
- package/dist/repo/sdk/src/cli/trace.ts +0 -61
- package/dist/repo/sdk/src/cli/utils.ts +0 -145
- package/dist/repo/sdk/src/compat.ts +0 -77
- package/dist/repo/shared_libs/observability/node-tracing.ts +0 -129
- package/dist/repo/shared_libs/observability/tracing.ts +0 -98
- package/dist/repo/shared_libs/play-runtime/context.ts +0 -4242
- package/dist/repo/shared_libs/play-runtime/ctx-contract.ts +0 -250
- package/dist/repo/shared_libs/play-runtime/ctx-types.ts +0 -725
- package/dist/repo/shared_libs/play-runtime/dataset-id.ts +0 -10
- package/dist/repo/shared_libs/play-runtime/db-session-crypto.ts +0 -304
- package/dist/repo/shared_libs/play-runtime/db-session.ts +0 -462
- package/dist/repo/shared_libs/play-runtime/live-events.ts +0 -214
- package/dist/repo/shared_libs/play-runtime/live-state-contract.ts +0 -50
- package/dist/repo/shared_libs/play-runtime/map-execution-frame.ts +0 -114
- package/dist/repo/shared_libs/play-runtime/map-row-identity.ts +0 -158
- package/dist/repo/shared_libs/play-runtime/progress-emitter.ts +0 -172
- package/dist/repo/shared_libs/play-runtime/protocol.ts +0 -121
- package/dist/repo/shared_libs/play-runtime/public-play-contract.ts +0 -42
- package/dist/repo/shared_libs/play-runtime/result-normalization.ts +0 -33
- package/dist/repo/shared_libs/play-runtime/runtime-api.ts +0 -1873
- package/dist/repo/shared_libs/play-runtime/runtime-constraints.ts +0 -2
- package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +0 -201
- package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-pg.ts +0 -48
- package/dist/repo/shared_libs/play-runtime/runtime-pg-driver.ts +0 -84
- package/dist/repo/shared_libs/play-runtime/static-pipeline-types.ts +0 -147
- package/dist/repo/shared_libs/play-runtime/suspension.ts +0 -68
- package/dist/repo/shared_libs/play-runtime/tracing.ts +0 -31
- package/dist/repo/shared_libs/play-runtime/waterfall-replay.ts +0 -75
- package/dist/repo/shared_libs/play-runtime/worker-api-types.ts +0 -140
- package/dist/repo/shared_libs/plays/artifact-transport.ts +0 -14
- package/dist/repo/shared_libs/plays/artifact-types.ts +0 -49
- package/dist/repo/shared_libs/plays/compiler-manifest.ts +0 -186
- package/dist/repo/shared_libs/plays/definition.ts +0 -264
- package/dist/repo/shared_libs/plays/file-refs.ts +0 -11
- package/dist/repo/shared_libs/plays/rate-limit-scheduler.ts +0 -206
- package/dist/repo/shared_libs/plays/resolve-static-pipeline.ts +0 -164
- package/dist/repo/shared_libs/plays/runtime-validation.ts +0 -395
- package/dist/repo/shared_libs/temporal/constants.ts +0 -39
- 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
|
|
130
|
+
function findNearestEnvFile(names, startDir = process.cwd()) {
|
|
127
131
|
let current = (0, import_node_path.resolve)(startDir);
|
|
128
132
|
while (true) {
|
|
129
|
-
const
|
|
130
|
-
|
|
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
|
|
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.
|
|
199
|
-
var SDK_API_CONTRACT = "2026-
|
|
244
|
+
var SDK_VERSION = "0.1.19";
|
|
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";
|
|
@@ -389,8 +435,12 @@ var HttpClient = class {
|
|
|
389
435
|
* @param path - API path
|
|
390
436
|
* @param body - Request body (will be JSON-serialized)
|
|
391
437
|
*/
|
|
392
|
-
async post(path, body) {
|
|
393
|
-
return this.request(path, {
|
|
438
|
+
async post(path, body, headers) {
|
|
439
|
+
return this.request(path, {
|
|
440
|
+
method: "POST",
|
|
441
|
+
body,
|
|
442
|
+
headers
|
|
443
|
+
});
|
|
394
444
|
}
|
|
395
445
|
/**
|
|
396
446
|
* Send a DELETE request.
|
|
@@ -470,6 +520,7 @@ function sleep(ms) {
|
|
|
470
520
|
|
|
471
521
|
// src/client.ts
|
|
472
522
|
var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
|
|
523
|
+
var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
|
|
473
524
|
function isRecord(value) {
|
|
474
525
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
475
526
|
}
|
|
@@ -502,6 +553,7 @@ function mapLegacyTemporalStatus(status) {
|
|
|
502
553
|
var DeeplineClient = class {
|
|
503
554
|
http;
|
|
504
555
|
config;
|
|
556
|
+
runs;
|
|
505
557
|
/**
|
|
506
558
|
* @param options - Optional overrides for API key, base URL, timeout, and retries.
|
|
507
559
|
* @throws {@link ConfigError} if no API key can be resolved from any source.
|
|
@@ -509,6 +561,13 @@ var DeeplineClient = class {
|
|
|
509
561
|
constructor(options) {
|
|
510
562
|
this.config = resolveConfig(options);
|
|
511
563
|
this.http = new HttpClient(this.config);
|
|
564
|
+
this.runs = {
|
|
565
|
+
get: (runId) => this.getRunStatus(runId),
|
|
566
|
+
list: (options2) => this.listRuns(options2),
|
|
567
|
+
tail: (runId, options2) => this.tailRun(runId, options2),
|
|
568
|
+
logs: (runId, options2) => this.getRunLogs(runId, options2),
|
|
569
|
+
stop: (runId, options2) => this.stopRun(runId, options2)
|
|
570
|
+
};
|
|
512
571
|
}
|
|
513
572
|
/** The resolved base URL this client is targeting (e.g. `"http://localhost:3000"`). */
|
|
514
573
|
get baseUrl() {
|
|
@@ -597,6 +656,31 @@ var DeeplineClient = class {
|
|
|
597
656
|
);
|
|
598
657
|
return res.tools;
|
|
599
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* Search available tools using Deepline's ranked backend search.
|
|
661
|
+
*
|
|
662
|
+
* This is the same discovery surface used by the legacy CLI: it ranks across
|
|
663
|
+
* tool metadata, categories, agent guidance, and input schema fields.
|
|
664
|
+
*/
|
|
665
|
+
async searchTools(options = {}) {
|
|
666
|
+
const params = new URLSearchParams();
|
|
667
|
+
const query = options.query?.trim() ?? "";
|
|
668
|
+
params.set("q", query);
|
|
669
|
+
params.set(
|
|
670
|
+
"include_search_debug",
|
|
671
|
+
options.includeSearchDebug ? "true" : "false"
|
|
672
|
+
);
|
|
673
|
+
params.set("search_mode", options.searchMode ?? "v2");
|
|
674
|
+
if (options.categories?.trim()) {
|
|
675
|
+
params.set("categories", options.categories.trim());
|
|
676
|
+
}
|
|
677
|
+
if (options.searchTerms?.trim()) {
|
|
678
|
+
params.set("search_terms", options.searchTerms.trim());
|
|
679
|
+
}
|
|
680
|
+
return this.http.get(
|
|
681
|
+
`/api/v2/integrations/list?${params.toString()}`
|
|
682
|
+
);
|
|
683
|
+
}
|
|
600
684
|
/**
|
|
601
685
|
* Get detailed metadata for a single tool.
|
|
602
686
|
*
|
|
@@ -632,12 +716,17 @@ var DeeplineClient = class {
|
|
|
632
716
|
* Top-level fields such as `status`, `job_id`, and `billing` describe the
|
|
633
717
|
* Deepline execution.
|
|
634
718
|
*/
|
|
635
|
-
async executeTool(toolId, input) {
|
|
719
|
+
async executeTool(toolId, input, options) {
|
|
720
|
+
const headers = options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : void 0;
|
|
636
721
|
return this.http.post(
|
|
637
722
|
`/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
|
|
638
|
-
{ payload: input }
|
|
723
|
+
{ payload: input },
|
|
724
|
+
headers
|
|
639
725
|
);
|
|
640
726
|
}
|
|
727
|
+
async executeToolRaw(toolId, input, options) {
|
|
728
|
+
return this.executeTool(toolId, input, options);
|
|
729
|
+
}
|
|
641
730
|
async queryCustomerDb(input) {
|
|
642
731
|
return this.http.post("/api/v2/db/query", {
|
|
643
732
|
sql: input.sql,
|
|
@@ -686,6 +775,7 @@ var DeeplineClient = class {
|
|
|
686
775
|
...request.revisionId ? { revisionId: request.revisionId } : {},
|
|
687
776
|
...request.artifactStorageKey ? { artifactStorageKey: request.artifactStorageKey } : {},
|
|
688
777
|
...request.sourceCode ? { sourceCode: request.sourceCode } : {},
|
|
778
|
+
...request.sourceFiles ? { sourceFiles: request.sourceFiles } : {},
|
|
689
779
|
..."staticPipeline" in request ? { staticPipeline: request.staticPipeline } : {},
|
|
690
780
|
...request.artifactHash ? { artifactHash: request.artifactHash } : {},
|
|
691
781
|
...request.graphHash ? { graphHash: request.graphHash } : {},
|
|
@@ -710,6 +800,7 @@ var DeeplineClient = class {
|
|
|
710
800
|
...request.revisionId ? { revisionId: request.revisionId } : {},
|
|
711
801
|
...request.artifactStorageKey ? { artifactStorageKey: request.artifactStorageKey } : {},
|
|
712
802
|
...request.sourceCode ? { sourceCode: request.sourceCode } : {},
|
|
803
|
+
...request.sourceFiles ? { sourceFiles: request.sourceFiles } : {},
|
|
713
804
|
..."staticPipeline" in request ? { staticPipeline: request.staticPipeline } : {},
|
|
714
805
|
...request.artifactHash ? { artifactHash: request.artifactHash } : {},
|
|
715
806
|
...request.graphHash ? { graphHash: request.graphHash } : {},
|
|
@@ -746,6 +837,7 @@ var DeeplineClient = class {
|
|
|
746
837
|
const compilerManifest = input.compilerManifest ?? await this.compilePlayManifest({
|
|
747
838
|
name: input.name,
|
|
748
839
|
sourceCode: input.sourceCode,
|
|
840
|
+
sourceFiles: input.sourceFiles,
|
|
749
841
|
artifact: input.artifact
|
|
750
842
|
});
|
|
751
843
|
return this.http.post("/api/v2/plays/artifacts", {
|
|
@@ -760,6 +852,7 @@ var DeeplineClient = class {
|
|
|
760
852
|
compilerManifest: artifact.compilerManifest ?? await this.compilePlayManifest({
|
|
761
853
|
name: artifact.name,
|
|
762
854
|
sourceCode: artifact.sourceCode,
|
|
855
|
+
sourceFiles: artifact.sourceFiles,
|
|
763
856
|
artifact: artifact.artifact
|
|
764
857
|
})
|
|
765
858
|
}))
|
|
@@ -786,11 +879,13 @@ var DeeplineClient = class {
|
|
|
786
879
|
const compilerManifest = input.compilerManifest ?? await this.compilePlayManifest({
|
|
787
880
|
name: input.name,
|
|
788
881
|
sourceCode: input.sourceCode,
|
|
882
|
+
sourceFiles: input.sourceFiles,
|
|
789
883
|
artifact: input.artifact
|
|
790
884
|
});
|
|
791
885
|
const registeredArtifact = await this.registerPlayArtifact({
|
|
792
886
|
name: input.name,
|
|
793
887
|
sourceCode: input.sourceCode,
|
|
888
|
+
sourceFiles: input.sourceFiles,
|
|
794
889
|
artifact: input.artifact,
|
|
795
890
|
compilerManifest,
|
|
796
891
|
publish: false
|
|
@@ -850,11 +945,13 @@ var DeeplineClient = class {
|
|
|
850
945
|
const compilerManifest = options?.compilerManifest ?? await this.compilePlayManifest({
|
|
851
946
|
name,
|
|
852
947
|
sourceCode,
|
|
948
|
+
sourceFiles: options?.sourceFiles,
|
|
853
949
|
artifact
|
|
854
950
|
});
|
|
855
951
|
const registeredArtifact = await this.registerPlayArtifact({
|
|
856
952
|
name,
|
|
857
953
|
sourceCode,
|
|
954
|
+
sourceFiles: options?.sourceFiles,
|
|
858
955
|
artifact,
|
|
859
956
|
compilerManifest,
|
|
860
957
|
publish: false
|
|
@@ -1038,6 +1135,112 @@ var DeeplineClient = class {
|
|
|
1038
1135
|
);
|
|
1039
1136
|
return response.runs ?? [];
|
|
1040
1137
|
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Get a run by id using the public runs resource model.
|
|
1140
|
+
*
|
|
1141
|
+
* This is the SDK equivalent of:
|
|
1142
|
+
*
|
|
1143
|
+
* ```bash
|
|
1144
|
+
* deepline runs get <run-id> --json
|
|
1145
|
+
* ```
|
|
1146
|
+
*/
|
|
1147
|
+
async getRunStatus(runId) {
|
|
1148
|
+
const response = await this.http.get(
|
|
1149
|
+
`/api/v2/runs/${encodeURIComponent(runId)}`
|
|
1150
|
+
);
|
|
1151
|
+
return normalizePlayStatus(response);
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* List play runs using the public runs resource model.
|
|
1155
|
+
*
|
|
1156
|
+
* This is the SDK equivalent of:
|
|
1157
|
+
*
|
|
1158
|
+
* ```bash
|
|
1159
|
+
* deepline runs list --play <play-name> --status failed --json
|
|
1160
|
+
* ```
|
|
1161
|
+
*/
|
|
1162
|
+
async listRuns(options) {
|
|
1163
|
+
const playName = options.play.trim();
|
|
1164
|
+
if (!playName) {
|
|
1165
|
+
throw new Error("runs.list requires options.play.");
|
|
1166
|
+
}
|
|
1167
|
+
const params = new URLSearchParams({ play: playName });
|
|
1168
|
+
const status = options.status?.trim();
|
|
1169
|
+
if (status) {
|
|
1170
|
+
params.set("status", status);
|
|
1171
|
+
}
|
|
1172
|
+
const response = await this.http.get(
|
|
1173
|
+
`/api/v2/runs?${params.toString()}`
|
|
1174
|
+
);
|
|
1175
|
+
return response.runs ?? [];
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Fetch the lightweight tail status for a run using the public runs resource model.
|
|
1179
|
+
*
|
|
1180
|
+
* This is the SDK equivalent of:
|
|
1181
|
+
*
|
|
1182
|
+
* ```bash
|
|
1183
|
+
* deepline runs tail <run-id> --json
|
|
1184
|
+
* ```
|
|
1185
|
+
*/
|
|
1186
|
+
async tailRun(runId, options) {
|
|
1187
|
+
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;
|
|
1188
|
+
const params = new URLSearchParams();
|
|
1189
|
+
if (Number.isFinite(afterLogIndex)) {
|
|
1190
|
+
params.set("afterLogIndex", String(Number(afterLogIndex)));
|
|
1191
|
+
}
|
|
1192
|
+
if (typeof options?.waitMs === "number") {
|
|
1193
|
+
params.set("waitMs", String(options.waitMs));
|
|
1194
|
+
}
|
|
1195
|
+
if (options?.terminalOnly) {
|
|
1196
|
+
params.set("terminalOnly", "true");
|
|
1197
|
+
}
|
|
1198
|
+
const suffix = params.toString() ? `?${params.toString()}` : "";
|
|
1199
|
+
const response = await this.http.get(
|
|
1200
|
+
`/api/v2/runs/${encodeURIComponent(runId)}/tail${suffix}`
|
|
1201
|
+
);
|
|
1202
|
+
return normalizePlayStatus(response);
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Fetch persisted logs for a run using the public runs resource model.
|
|
1206
|
+
*
|
|
1207
|
+
* This is the SDK equivalent of:
|
|
1208
|
+
*
|
|
1209
|
+
* ```bash
|
|
1210
|
+
* deepline runs logs <run-id> --limit 200 --json
|
|
1211
|
+
* ```
|
|
1212
|
+
*/
|
|
1213
|
+
async getRunLogs(runId, options) {
|
|
1214
|
+
const status = await this.getRunStatus(runId);
|
|
1215
|
+
const logs = status.progress?.logs ?? [];
|
|
1216
|
+
const limit = typeof options?.limit === "number" && Number.isFinite(options.limit) ? Math.max(0, Math.trunc(options.limit)) : 200;
|
|
1217
|
+
const entries = logs.slice(Math.max(0, logs.length - limit));
|
|
1218
|
+
return {
|
|
1219
|
+
runId: status.runId,
|
|
1220
|
+
totalCount: logs.length,
|
|
1221
|
+
returnedCount: entries.length,
|
|
1222
|
+
firstSequence: logs.length === 0 ? null : logs.length - entries.length + 1,
|
|
1223
|
+
lastSequence: logs.length === 0 ? null : logs.length,
|
|
1224
|
+
truncated: logs.length > entries.length,
|
|
1225
|
+
hasMore: logs.length > entries.length,
|
|
1226
|
+
entries
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Stop a run by id using the public runs resource model.
|
|
1231
|
+
*
|
|
1232
|
+
* This is the SDK equivalent of:
|
|
1233
|
+
*
|
|
1234
|
+
* ```bash
|
|
1235
|
+
* deepline runs stop <run-id> --reason "stale lock" --json
|
|
1236
|
+
* ```
|
|
1237
|
+
*/
|
|
1238
|
+
async stopRun(runId, options) {
|
|
1239
|
+
return this.http.post(
|
|
1240
|
+
`/api/v2/runs/${encodeURIComponent(runId)}/stop`,
|
|
1241
|
+
options?.reason ? { reason: options.reason } : {}
|
|
1242
|
+
);
|
|
1243
|
+
}
|
|
1041
1244
|
async listPlays() {
|
|
1042
1245
|
const response = await this.http.get(
|
|
1043
1246
|
"/api/v2/plays"
|
|
@@ -1403,7 +1606,11 @@ var DeeplineContext = class {
|
|
|
1403
1606
|
/** Get detailed metadata for a tool. */
|
|
1404
1607
|
get: (toolId) => this.client.getTool(toolId),
|
|
1405
1608
|
/** Execute a tool and return the standard execution envelope. */
|
|
1406
|
-
execute: async (toolId, input) => this.client.executeTool(
|
|
1609
|
+
execute: async (toolId, input) => this.client.executeTool(
|
|
1610
|
+
toolId,
|
|
1611
|
+
input,
|
|
1612
|
+
{ includeToolMetadata: true }
|
|
1613
|
+
)
|
|
1407
1614
|
};
|
|
1408
1615
|
}
|
|
1409
1616
|
get plays() {
|
|
@@ -1771,4 +1978,3 @@ function extractSummaryFields(payload) {
|
|
|
1771
1978
|
writeCsvOutputFile,
|
|
1772
1979
|
writeJsonOutputFile
|
|
1773
1980
|
});
|
|
1774
|
-
//# sourceMappingURL=index.js.map
|