deepline 0.3.46 → 0.3.48

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/dist/index.js CHANGED
@@ -175,6 +175,8 @@ var ToolExecutionError = class _ToolExecutionError extends DeeplineError {
175
175
  networkKind;
176
176
  /** Network boundary that failed, or `null` for non-network failures. */
177
177
  networkScope;
178
+ /** Explicitly allowlisted diagnostics safe for SDK and Play callers. */
179
+ publicDetails;
178
180
  /**
179
181
  * Construct a structured tool error.
180
182
  *
@@ -199,6 +201,7 @@ var ToolExecutionError = class _ToolExecutionError extends DeeplineError {
199
201
  this.retryAfterMs = options.retryAfterMs;
200
202
  this.networkKind = options.networkKind;
201
203
  this.networkScope = options.networkScope;
204
+ this.publicDetails = options.publicDetails ?? null;
202
205
  applyBrand(this, TOOL_EXECUTION_ERROR_BRAND);
203
206
  if (isProviderTransientFailure(options)) {
204
207
  applyBrand(this, PROVIDER_TRANSIENT_ERROR_BRAND);
@@ -324,6 +327,33 @@ function normalizeNetworkScope(value) {
324
327
  function isRecord(value) {
325
328
  return value !== null && typeof value === "object" && !Array.isArray(value);
326
329
  }
330
+ var MAX_PUBLIC_DETAIL_ENTRIES = 20;
331
+ var MAX_PUBLIC_DETAIL_KEY_LENGTH = 80;
332
+ var MAX_PUBLIC_DETAIL_STRING_LENGTH = 512;
333
+ function normalizeToolExecutionPublicDetails(value) {
334
+ if (!isRecord(value)) return null;
335
+ const details = {};
336
+ for (const [key, entry] of Object.entries(value)) {
337
+ if (Object.keys(details).length >= MAX_PUBLIC_DETAIL_ENTRIES) break;
338
+ if (key.length === 0 || key.length > MAX_PUBLIC_DETAIL_KEY_LENGTH || !/^[a-z][a-zA-Z0-9_]*$/.test(key)) {
339
+ continue;
340
+ }
341
+ if (typeof entry === "string") {
342
+ if (entry.length <= MAX_PUBLIC_DETAIL_STRING_LENGTH) details[key] = entry;
343
+ continue;
344
+ }
345
+ if (typeof entry === "number") {
346
+ if (Number.isFinite(entry)) details[key] = entry;
347
+ continue;
348
+ }
349
+ if (typeof entry === "boolean") {
350
+ details[key] = entry;
351
+ continue;
352
+ }
353
+ if (entry === null) details[key] = null;
354
+ }
355
+ return Object.keys(details).length > 0 ? details : null;
356
+ }
327
357
  function normalizeToolExecutionFailure(value) {
328
358
  if (!isRecord(value) || value.schemaVersion !== TOOL_EXECUTION_ERROR_SCHEMA_VERSION) {
329
359
  return null;
@@ -337,6 +367,7 @@ function normalizeToolExecutionFailure(value) {
337
367
  operation
338
368
  });
339
369
  const category = normalizeToolExecutionCategory(value.category);
370
+ const publicDetails = normalizeToolExecutionPublicDetails(value.publicDetails);
340
371
  const trustworthy = origin !== "unknown" && category !== "unknown" && typeof value.retryable === "boolean";
341
372
  return {
342
373
  schemaVersion: TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
@@ -351,7 +382,8 @@ function normalizeToolExecutionFailure(value) {
351
382
  requestId: boundedString(value.requestId),
352
383
  retryAfterMs: finiteNonNegativeInteger(value.retryAfterMs),
353
384
  networkKind: normalizeNetworkKind(value.networkKind),
354
- networkScope: normalizeNetworkScope(value.networkScope)
385
+ networkScope: normalizeNetworkScope(value.networkScope),
386
+ ...publicDetails ? { publicDetails } : {}
355
387
  };
356
388
  }
357
389
  function serializeToolExecutionFailure(error) {
@@ -369,7 +401,8 @@ function serializeToolExecutionFailure(error) {
369
401
  requestId: error.requestId,
370
402
  retryAfterMs: error.retryAfterMs,
371
403
  networkKind: error.networkKind,
372
- networkScope: error.networkScope
404
+ networkScope: error.networkScope,
405
+ publicDetails: error.publicDetails
373
406
  });
374
407
  }
375
408
  function deserializeToolExecutionFailure(message, value, acceptedSchemaVersion) {
@@ -427,6 +460,8 @@ var ToolRateLimitError = class extends RateLimitError {
427
460
  networkKind;
428
461
  /** Network boundary that failed, or `null` for non-network failures. */
429
462
  networkScope;
463
+ /** Explicitly allowlisted diagnostics safe for SDK callers. */
464
+ publicDetails;
430
465
  /** Constructed by the SDK after a structured tool HTTP 429. */
431
466
  constructor(message, options) {
432
467
  super(options.retryAfterMs ?? 5e3, message);
@@ -442,6 +477,7 @@ var ToolRateLimitError = class extends RateLimitError {
442
477
  this.requestId = options.requestId;
443
478
  this.networkKind = options.networkKind;
444
479
  this.networkScope = options.networkScope;
480
+ this.publicDetails = options.publicDetails ?? null;
445
481
  this.details = options.details;
446
482
  brandAsToolExecutionError(this);
447
483
  if (isProviderTransientFailure(this)) {
@@ -779,7 +815,7 @@ var SDK_RELEASE = {
779
815
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
780
816
  // getters keep their established compatibility behavior.
781
817
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
782
- version: "0.3.46",
818
+ version: "0.3.48",
783
819
  updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
784
820
  packageCapabilities: {
785
821
  updatePreferences: 1
@@ -1659,7 +1695,7 @@ var HttpClient = class {
1659
1695
  body: options?.body !== void 0 ? JSON.stringify(options.body) : void 0,
1660
1696
  signal: options?.signal
1661
1697
  });
1662
- if (!response.ok) {
1698
+ if (!response.ok || response.status === 202) {
1663
1699
  const body = await response.text();
1664
1700
  const parsed = parseResponseBody(body);
1665
1701
  if (response.status === 401 && !isProviderOriginatedHttpError(parsed)) {
@@ -5363,12 +5399,26 @@ var DeeplineClient = class {
5363
5399
  const headers = options?.lastEventId && options.lastEventId.trim() ? { "Last-Event-ID": options.lastEventId.trim() } : void 0;
5364
5400
  const params = new URLSearchParams();
5365
5401
  params.set("mode", options?.mode ?? "cli");
5366
- for await (const event of this.http.streamSse(
5367
- `/api/v2/runs/${encodeURIComponent(workflowId)}/tail?${params.toString()}`,
5368
- { signal: options?.signal, headers }
5369
- )) {
5370
- if (event.scope === "play") {
5371
- yield event;
5402
+ const projectionDeadline = Date.now() + 3e4;
5403
+ let projectionAttempt = 0;
5404
+ for (; ; ) {
5405
+ let sawEvent = false;
5406
+ try {
5407
+ for await (const event of this.http.streamSse(
5408
+ `/api/v2/runs/${encodeURIComponent(workflowId)}/tail?${params.toString()}`,
5409
+ { signal: options?.signal, headers }
5410
+ )) {
5411
+ sawEvent = true;
5412
+ if (event.scope === "play") {
5413
+ yield event;
5414
+ }
5415
+ }
5416
+ return;
5417
+ } catch (error) {
5418
+ const projectionPending = options?.waitForProjection === true && !sawEvent && error instanceof DeeplineError && (error.statusCode === 404 || error.statusCode === 202 && error.code === "RUN_PROJECTION_PENDING") && Date.now() < projectionDeadline;
5419
+ if (!projectionPending) throw error;
5420
+ await sleep2(streamReconnectDelayMs(projectionAttempt));
5421
+ projectionAttempt += 1;
5372
5422
  }
5373
5423
  }
5374
5424
  }
@@ -6397,7 +6447,8 @@ var DeeplineClient = class {
6397
6447
  }
6398
6448
  for await (const event of this.streamPlayRunEvents(workflowId, {
6399
6449
  mode: "cli",
6400
- signal: options?.signal
6450
+ signal: options?.signal,
6451
+ waitForProjection: true
6401
6452
  })) {
6402
6453
  if (options?.signal?.aborted) {
6403
6454
  await this.cancelPlay(workflowId);
package/dist/index.mjs CHANGED
@@ -98,6 +98,8 @@ var ToolExecutionError = class _ToolExecutionError extends DeeplineError {
98
98
  networkKind;
99
99
  /** Network boundary that failed, or `null` for non-network failures. */
100
100
  networkScope;
101
+ /** Explicitly allowlisted diagnostics safe for SDK and Play callers. */
102
+ publicDetails;
101
103
  /**
102
104
  * Construct a structured tool error.
103
105
  *
@@ -122,6 +124,7 @@ var ToolExecutionError = class _ToolExecutionError extends DeeplineError {
122
124
  this.retryAfterMs = options.retryAfterMs;
123
125
  this.networkKind = options.networkKind;
124
126
  this.networkScope = options.networkScope;
127
+ this.publicDetails = options.publicDetails ?? null;
125
128
  applyBrand(this, TOOL_EXECUTION_ERROR_BRAND);
126
129
  if (isProviderTransientFailure(options)) {
127
130
  applyBrand(this, PROVIDER_TRANSIENT_ERROR_BRAND);
@@ -247,6 +250,33 @@ function normalizeNetworkScope(value) {
247
250
  function isRecord(value) {
248
251
  return value !== null && typeof value === "object" && !Array.isArray(value);
249
252
  }
253
+ var MAX_PUBLIC_DETAIL_ENTRIES = 20;
254
+ var MAX_PUBLIC_DETAIL_KEY_LENGTH = 80;
255
+ var MAX_PUBLIC_DETAIL_STRING_LENGTH = 512;
256
+ function normalizeToolExecutionPublicDetails(value) {
257
+ if (!isRecord(value)) return null;
258
+ const details = {};
259
+ for (const [key, entry] of Object.entries(value)) {
260
+ if (Object.keys(details).length >= MAX_PUBLIC_DETAIL_ENTRIES) break;
261
+ if (key.length === 0 || key.length > MAX_PUBLIC_DETAIL_KEY_LENGTH || !/^[a-z][a-zA-Z0-9_]*$/.test(key)) {
262
+ continue;
263
+ }
264
+ if (typeof entry === "string") {
265
+ if (entry.length <= MAX_PUBLIC_DETAIL_STRING_LENGTH) details[key] = entry;
266
+ continue;
267
+ }
268
+ if (typeof entry === "number") {
269
+ if (Number.isFinite(entry)) details[key] = entry;
270
+ continue;
271
+ }
272
+ if (typeof entry === "boolean") {
273
+ details[key] = entry;
274
+ continue;
275
+ }
276
+ if (entry === null) details[key] = null;
277
+ }
278
+ return Object.keys(details).length > 0 ? details : null;
279
+ }
250
280
  function normalizeToolExecutionFailure(value) {
251
281
  if (!isRecord(value) || value.schemaVersion !== TOOL_EXECUTION_ERROR_SCHEMA_VERSION) {
252
282
  return null;
@@ -260,6 +290,7 @@ function normalizeToolExecutionFailure(value) {
260
290
  operation
261
291
  });
262
292
  const category = normalizeToolExecutionCategory(value.category);
293
+ const publicDetails = normalizeToolExecutionPublicDetails(value.publicDetails);
263
294
  const trustworthy = origin !== "unknown" && category !== "unknown" && typeof value.retryable === "boolean";
264
295
  return {
265
296
  schemaVersion: TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
@@ -274,7 +305,8 @@ function normalizeToolExecutionFailure(value) {
274
305
  requestId: boundedString(value.requestId),
275
306
  retryAfterMs: finiteNonNegativeInteger(value.retryAfterMs),
276
307
  networkKind: normalizeNetworkKind(value.networkKind),
277
- networkScope: normalizeNetworkScope(value.networkScope)
308
+ networkScope: normalizeNetworkScope(value.networkScope),
309
+ ...publicDetails ? { publicDetails } : {}
278
310
  };
279
311
  }
280
312
  function serializeToolExecutionFailure(error) {
@@ -292,7 +324,8 @@ function serializeToolExecutionFailure(error) {
292
324
  requestId: error.requestId,
293
325
  retryAfterMs: error.retryAfterMs,
294
326
  networkKind: error.networkKind,
295
- networkScope: error.networkScope
327
+ networkScope: error.networkScope,
328
+ publicDetails: error.publicDetails
296
329
  });
297
330
  }
298
331
  function deserializeToolExecutionFailure(message, value, acceptedSchemaVersion) {
@@ -350,6 +383,8 @@ var ToolRateLimitError = class extends RateLimitError {
350
383
  networkKind;
351
384
  /** Network boundary that failed, or `null` for non-network failures. */
352
385
  networkScope;
386
+ /** Explicitly allowlisted diagnostics safe for SDK callers. */
387
+ publicDetails;
353
388
  /** Constructed by the SDK after a structured tool HTTP 429. */
354
389
  constructor(message, options) {
355
390
  super(options.retryAfterMs ?? 5e3, message);
@@ -365,6 +400,7 @@ var ToolRateLimitError = class extends RateLimitError {
365
400
  this.requestId = options.requestId;
366
401
  this.networkKind = options.networkKind;
367
402
  this.networkScope = options.networkScope;
403
+ this.publicDetails = options.publicDetails ?? null;
368
404
  this.details = options.details;
369
405
  brandAsToolExecutionError(this);
370
406
  if (isProviderTransientFailure(this)) {
@@ -702,7 +738,7 @@ var SDK_RELEASE = {
702
738
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
703
739
  // getters keep their established compatibility behavior.
704
740
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
705
- version: "0.3.46",
741
+ version: "0.3.48",
706
742
  updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
707
743
  packageCapabilities: {
708
744
  updatePreferences: 1
@@ -1582,7 +1618,7 @@ var HttpClient = class {
1582
1618
  body: options?.body !== void 0 ? JSON.stringify(options.body) : void 0,
1583
1619
  signal: options?.signal
1584
1620
  });
1585
- if (!response.ok) {
1621
+ if (!response.ok || response.status === 202) {
1586
1622
  const body = await response.text();
1587
1623
  const parsed = parseResponseBody(body);
1588
1624
  if (response.status === 401 && !isProviderOriginatedHttpError(parsed)) {
@@ -5286,12 +5322,26 @@ var DeeplineClient = class {
5286
5322
  const headers = options?.lastEventId && options.lastEventId.trim() ? { "Last-Event-ID": options.lastEventId.trim() } : void 0;
5287
5323
  const params = new URLSearchParams();
5288
5324
  params.set("mode", options?.mode ?? "cli");
5289
- for await (const event of this.http.streamSse(
5290
- `/api/v2/runs/${encodeURIComponent(workflowId)}/tail?${params.toString()}`,
5291
- { signal: options?.signal, headers }
5292
- )) {
5293
- if (event.scope === "play") {
5294
- yield event;
5325
+ const projectionDeadline = Date.now() + 3e4;
5326
+ let projectionAttempt = 0;
5327
+ for (; ; ) {
5328
+ let sawEvent = false;
5329
+ try {
5330
+ for await (const event of this.http.streamSse(
5331
+ `/api/v2/runs/${encodeURIComponent(workflowId)}/tail?${params.toString()}`,
5332
+ { signal: options?.signal, headers }
5333
+ )) {
5334
+ sawEvent = true;
5335
+ if (event.scope === "play") {
5336
+ yield event;
5337
+ }
5338
+ }
5339
+ return;
5340
+ } catch (error) {
5341
+ const projectionPending = options?.waitForProjection === true && !sawEvent && error instanceof DeeplineError && (error.statusCode === 404 || error.statusCode === 202 && error.code === "RUN_PROJECTION_PENDING") && Date.now() < projectionDeadline;
5342
+ if (!projectionPending) throw error;
5343
+ await sleep2(streamReconnectDelayMs(projectionAttempt));
5344
+ projectionAttempt += 1;
5295
5345
  }
5296
5346
  }
5297
5347
  }
@@ -6320,7 +6370,8 @@ var DeeplineClient = class {
6320
6370
  }
6321
6371
  for await (const event of this.streamPlayRunEvents(workflowId, {
6322
6372
  mode: "cli",
6323
- signal: options?.signal
6373
+ signal: options?.signal,
6374
+ waitForProjection: true
6324
6375
  })) {
6325
6376
  if (options?.signal?.aborted) {
6326
6377
  await this.cancelPlay(workflowId);
@@ -257,8 +257,8 @@
257
257
  "dist/cli/index.js",
258
258
  "dist/cli/index.mjs",
259
259
  "dist/cli/text-imports.d.ts",
260
- "dist/compiler-manifest-BuoqasqI.d.mts",
261
- "dist/compiler-manifest-BuoqasqI.d.ts",
260
+ "dist/compiler-manifest-CbzdZrJj.d.mts",
261
+ "dist/compiler-manifest-CbzdZrJj.d.ts",
262
262
  "dist/helpers.d.mts",
263
263
  "dist/helpers.d.ts",
264
264
  "dist/helpers.js",
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./text-imports.d.ts" />
2
- import { P as PlayArtifactKind, a as PlayBundleArtifact, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-BuoqasqI.mjs';
3
- export { d as PLAY_ARTIFACT_KINDS, e as PlayArtifactCompatibility, f as PlayImportPolicy, g as PlayPackageImport, h as PlayRuntimeFeature } from '../compiler-manifest-BuoqasqI.mjs';
2
+ import { P as PlayArtifactKind, a as PlayBundleArtifact, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-CbzdZrJj.mjs';
3
+ export { d as PLAY_ARTIFACT_KINDS, e as PlayArtifactCompatibility, f as PlayImportPolicy, g as PlayPackageImport, h as PlayRuntimeFeature } from '../compiler-manifest-CbzdZrJj.mjs';
4
4
  import '@sinclair/typebox';
5
5
 
6
6
  type ImportedPlayDependency = {
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./text-imports.d.ts" />
2
- import { P as PlayArtifactKind, a as PlayBundleArtifact, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-BuoqasqI.js';
3
- export { d as PLAY_ARTIFACT_KINDS, e as PlayArtifactCompatibility, f as PlayImportPolicy, g as PlayPackageImport, h as PlayRuntimeFeature } from '../compiler-manifest-BuoqasqI.js';
2
+ import { P as PlayArtifactKind, a as PlayBundleArtifact, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-CbzdZrJj.js';
3
+ export { d as PLAY_ARTIFACT_KINDS, e as PlayArtifactCompatibility, f as PlayImportPolicy, g as PlayPackageImport, h as PlayRuntimeFeature } from '../compiler-manifest-CbzdZrJj.js';
4
4
  import '@sinclair/typebox';
5
5
 
6
6
  type ImportedPlayDependency = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.3.46",
3
+ "version": "0.3.48",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",