deepline 0.3.47 → 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.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.47",
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.47",
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",