deepline 0.3.69 → 0.3.71

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.
@@ -1233,6 +1233,29 @@ export type BillingPlansResult = {
1233
1233
  metrics: BillingMetricEntry[];
1234
1234
  };
1235
1235
 
1236
+ export type WorkspaceCreateResult = {
1237
+ org_id: string;
1238
+ org_name: string;
1239
+ org_slug: string;
1240
+ plan_sku: 'payg-v1';
1241
+ rate_policy_ref: 'payg-rates-v2';
1242
+ operation: {
1243
+ id: string;
1244
+ state: 'completed';
1245
+ replayed: boolean;
1246
+ };
1247
+ request_id?: string;
1248
+ };
1249
+
1250
+ /** Deliberate workspace lifecycle operations. */
1251
+ export type WorkspacesNamespace = {
1252
+ /** Create an additional workspace and provision its active PAYG Contract. */
1253
+ create: (options: {
1254
+ name: string;
1255
+ idempotencyKey: string;
1256
+ }) => Promise<WorkspaceCreateResult>;
1257
+ };
1258
+
1236
1259
  /**
1237
1260
  * Public billing namespace exposed as `client.billing`.
1238
1261
  *
@@ -1796,10 +1819,7 @@ function playRunStatusFromState(state: PlayLiveStatusState): PlayStatus {
1796
1819
  }
1797
1820
 
1798
1821
  /**
1799
- * Low-level client for the Deepline REST API.
1800
- *
1801
- * Provides typed methods for every API endpoint: tools, plays, auth, and health.
1802
- * Handles authentication, retries, and localhost failover automatically.
1822
+ * Low-level typed REST client with authentication, retries, and localhost failover.
1803
1823
  *
1804
1824
  * @example
1805
1825
  * ```typescript
@@ -1826,6 +1846,8 @@ export class DeeplineClient {
1826
1846
  readonly db: DbNamespace;
1827
1847
  /** Billing namespace: subscription status/cancel and invoice history. */
1828
1848
  readonly billing: BillingNamespace;
1849
+ /** Workspace lifecycle namespace. */
1850
+ readonly workspaces: WorkspacesNamespace;
1829
1851
  /** Monitors namespace: access, catalog, deploy/check, and lifecycle. */
1830
1852
  readonly monitors: MonitorsNamespace;
1831
1853
 
@@ -1875,6 +1897,9 @@ export class DeeplineClient {
1875
1897
  transitionPlan: (options) => this.transitionTargetBillingPlan(options),
1876
1898
  portalSession: () => this.createTargetBillingPortalSession(),
1877
1899
  };
1900
+ this.workspaces = {
1901
+ create: (options) => this.createWorkspace(options),
1902
+ };
1878
1903
  this.monitors = {
1879
1904
  status: () => this.getMonitorsAccess(),
1880
1905
  available: (toolIdOrOptions, options) =>
@@ -4765,6 +4790,31 @@ export class DeeplineClient {
4765
4790
  return response.data;
4766
4791
  }
4767
4792
 
4793
+ /** Create an additional workspace through the durable PAYG workflow. */
4794
+ async createWorkspace(options: {
4795
+ name: string;
4796
+ idempotencyKey: string;
4797
+ }): Promise<WorkspaceCreateResult> {
4798
+ const idempotencyKey = requireTargetBillingIdempotencyKey(
4799
+ options.idempotencyKey,
4800
+ );
4801
+ const response = await this.http.post<{
4802
+ data: Omit<WorkspaceCreateResult, 'operation' | 'request_id'>;
4803
+ operation: WorkspaceCreateResult['operation'];
4804
+ request_id?: string;
4805
+ }>(
4806
+ '/api/v2/workspaces',
4807
+ { name: options.name },
4808
+ { 'Idempotency-Key': idempotencyKey },
4809
+ { maxRetries: 0, exactUrlOnly: true },
4810
+ );
4811
+ return {
4812
+ ...response.data,
4813
+ operation: response.operation,
4814
+ ...(response.request_id ? { request_id: response.request_id } : {}),
4815
+ };
4816
+ }
4817
+
4768
4818
  // ——————————————————————————————————————————————————————————
4769
4819
  // Monitors
4770
4820
  // ——————————————————————————————————————————————————————————
@@ -68,6 +68,8 @@ export type {
68
68
  BillingSubscriptionCancelResult,
69
69
  BillingSubscriptionStatus,
70
70
  BillingTopUpResult,
71
+ WorkspaceCreateResult,
72
+ WorkspacesNamespace,
71
73
  MonitorsNamespace,
72
74
  MonitorsAccessStatus,
73
75
  MonitorsAvailableOptions,
@@ -199,7 +199,7 @@ export const SDK_RELEASE = {
199
199
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
200
200
  // getters keep their established compatibility behavior.
201
201
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
202
- version: '0.3.69',
202
+ version: '0.3.71',
203
203
  updateSummary:
204
204
  '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.',
205
205
  packageCapabilities: {
@@ -3662,6 +3662,27 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
3662
3662
  };
3663
3663
  }
3664
3664
 
3665
+ /**
3666
+ * A Deepline admission limit is decided before provider dispatch; the
3667
+ * execute endpoint also releases its billing reservation on that path.
3668
+ * Reclaim only this explicit, structured failure. A timeout, unreadable
3669
+ * body, provider error, or unknown receipt can follow billable provider
3670
+ * work and must remain behind its durable idempotency fence.
3671
+ */
3672
+ private canRetryWithoutProviderDispatch(
3673
+ receipt: RuntimeStepReceipt,
3674
+ ): boolean {
3675
+ const failure = receipt.errorPayload;
3676
+ return (
3677
+ receipt.status === 'failed' &&
3678
+ failure?.schemaVersion === 1 &&
3679
+ failure.origin === 'deepline' &&
3680
+ failure.category === 'rate_limit' &&
3681
+ failure.code === 'RATE_LIMIT' &&
3682
+ failure.retryable === true
3683
+ );
3684
+ }
3685
+
3665
3686
  /**
3666
3687
  * Dispatch a batched runtime-step-receipt request in bounded chunks and
3667
3688
  * concatenate the aligned result arrays back into one array positioned
@@ -11010,6 +11031,22 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
11010
11031
  );
11011
11032
  for (const [key, receipt] of claimed) claims.set(key, receipt);
11012
11033
  }
11034
+ const safeFailedKeys = receipts.flatMap((receipt) => {
11035
+ const claimed = claims.get(receipt.resultReceiptKey);
11036
+ return claimed && this.canRetryWithoutProviderDispatch(claimed)
11037
+ ? [receipt.resultReceiptKey]
11038
+ : [];
11039
+ });
11040
+ if (safeFailedKeys.length > 0) {
11041
+ const refreshed = await this.claimRuntimeStepReceipts(
11042
+ safeFailedKeys,
11043
+ this.currentReceiptOwnerRunId,
11044
+ false,
11045
+ false,
11046
+ true,
11047
+ );
11048
+ for (const [key, receipt] of refreshed) claims.set(key, receipt);
11049
+ }
11013
11050
  return await recordsFor(
11014
11051
  receipts.map((receipt) => receipt.resultReceiptKey),
11015
11052
  claims,
@@ -12238,6 +12275,23 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
12238
12275
  for (const [receiptKey, claim] of failedRefreshClaims) {
12239
12276
  claims.set(receiptKey, claim);
12240
12277
  }
12278
+ const safeFailedReceiptKeys = [...claims]
12279
+ .filter(([, claim]) =>
12280
+ this.canRetryWithoutProviderDispatch(claim),
12281
+ )
12282
+ .map(([receiptKey]) => receiptKey);
12283
+ if (safeFailedReceiptKeys.length > 0) {
12284
+ const refreshed = await this.claimRuntimeStepReceipts(
12285
+ safeFailedReceiptKeys,
12286
+ this.currentReceiptOwnerRunId,
12287
+ false,
12288
+ false,
12289
+ true,
12290
+ );
12291
+ for (const [receiptKey, claim] of refreshed) {
12292
+ claims.set(receiptKey, claim);
12293
+ }
12294
+ }
12241
12295
  const claimedRequests: ToolCallRequest[] = [...localOnlyRequests];
12242
12296
  const durableRecoveredRequests: ToolCallRequest[] = [];
12243
12297
  const resolveRequestsFromReceipt = async (
@@ -13377,8 +13431,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
13377
13431
  );
13378
13432
  }
13379
13433
  const materialized = lifecycle.materialized!;
13380
- const selectedResponse =
13381
- lifecycle.finishResponse ?? lifecycle.pollResponse;
13434
+ const selectedResponse = lifecycle.finishResponse ?? lifecycle.pollResponse;
13382
13435
  return {
13383
13436
  ...selectedResponse,
13384
13437
  status: