deepline 0.3.162 → 0.3.164

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.
@@ -2117,9 +2117,79 @@ export type BillingUsageEvent = {
2117
2117
  created_at: string;
2118
2118
  };
2119
2119
 
2120
+ /** One customer-facing recent billing operation from `/api/v2/billing/usage`. */
2121
+ export type BillingRecentUsageEntry = {
2122
+ id: string;
2123
+ provider: string;
2124
+ operation: string;
2125
+ status: string;
2126
+ request_id: string;
2127
+ run_id: string | null;
2128
+ /** Play execution run for this charge, when the call ran inside a Play. */
2129
+ play_run_id?: string | null;
2130
+ workflow_id?: string | null;
2131
+ billing_run_id?: string | null;
2132
+ execution_run_id?: string | null;
2133
+ included_in_run_id?: string | null;
2134
+ billing_scope?: string | null;
2135
+ step_block_id?: string | null;
2136
+ step_alias?: string | null;
2137
+ credits: number;
2138
+ billing_mode: string | null;
2139
+ pricing_model: string | null;
2140
+ outcome: string | null;
2141
+ billing_note: string | null;
2142
+ charge_state:
2143
+ | 'posted'
2144
+ | 'temporary_hold'
2145
+ | 'hold_release'
2146
+ | 'pending'
2147
+ | 'free'
2148
+ | 'failed';
2149
+ rough_usd_cost: number | null;
2150
+ created_at: string;
2151
+ };
2152
+
2153
+ export type BillingUsageOptions = {
2154
+ /** Return the one exact call identified by `executeTool().job_id`. */
2155
+ requestId?: string;
2156
+ /** Bound the recent-call page. Ignored for an exact requestId lookup. */
2157
+ limit?: number;
2158
+ offset?: number;
2159
+ cursor?: string;
2160
+ runId?: string;
2161
+ };
2162
+
2163
+ export type BillingUsageResult = {
2164
+ org_id: string;
2165
+ balance?: number;
2166
+ rough_usd_balance?: number;
2167
+ plan?: { usd_per_credit: number };
2168
+ usage?: {
2169
+ last_30_days_usage_credits: number;
2170
+ rough_usd_last_30_days_usage: number;
2171
+ temporary_hold_credits: number;
2172
+ rough_usd_temporary_holds: number;
2173
+ };
2174
+ recent: {
2175
+ run_id: string | null;
2176
+ request_id?: string;
2177
+ total: number;
2178
+ offset: number;
2179
+ limit: number;
2180
+ next_offset: number;
2181
+ next_cursor: string | null;
2182
+ has_more: boolean;
2183
+ incomplete: boolean;
2184
+ entries: BillingRecentUsageEntry[];
2185
+ };
2186
+ [key: string]: unknown;
2187
+ };
2188
+
2120
2189
  /**
2121
2190
  * Public `client.billing` namespace for CLI commands and programmatic callers.
2122
- * Covers plans, subscription state, cancellation, and invoice/receipt history.
2191
+ * Covers usage, plans, subscription state, cancellation, and invoice/receipt
2192
+ * history.
2123
2193
  *
2124
2194
  * @sdkReference client 030 client.billing
2125
2195
  */
@@ -2148,6 +2218,8 @@ export type BillingNamespace = {
2148
2218
  };
2149
2219
  /** Read one exact execution outcome using the request_id returned by executeTool. */
2150
2220
  usageEvent: (requestId: string) => Promise<BillingUsageEvent>;
2221
+ /** Read current billing usage, or look up one exact execution charge by request ID. */
2222
+ usage: (options?: BillingUsageOptions) => Promise<BillingUsageResult>;
2151
2223
  /** Metronome-authored target catalog and current Contract projection. */
2152
2224
  targetPlans: () => Promise<TargetBillingPlansResult>;
2153
2225
  /** Normalized target billing state. */
@@ -2760,6 +2832,7 @@ export class DeeplineClient {
2760
2832
  list: (options) => this.listBillingInvoices(options),
2761
2833
  },
2762
2834
  usageEvent: (requestId) => this.getBillingUsageEvent(requestId),
2835
+ usage: (options) => this.getBillingUsage(options),
2763
2836
  targetPlans: () => this.getTargetBillingPlans(),
2764
2837
  targetStatus: () => this.getTargetBillingStatus(),
2765
2838
  autoRecharge: {
@@ -6194,6 +6267,60 @@ export class DeeplineClient {
6194
6267
  return event;
6195
6268
  }
6196
6269
 
6270
+ /**
6271
+ * Read workspace usage and recent customer-facing Deepline charges. Pass
6272
+ * the `job_id` from `executeTool` as `requestId` to retrieve one exact call,
6273
+ * including whether its charge is final or still a temporary hold. Exact
6274
+ * request lookups return only the `org_id` and `recent` result fields.
6275
+ */
6276
+ async getBillingUsage(
6277
+ options: BillingUsageOptions = {},
6278
+ ): Promise<BillingUsageResult> {
6279
+ const params = new URLSearchParams();
6280
+ if (options.requestId !== undefined) {
6281
+ const requestId = options.requestId.trim();
6282
+ if (
6283
+ requestId.length === 0 ||
6284
+ requestId.length > 200 ||
6285
+ requestId !== options.requestId
6286
+ ) {
6287
+ throw new DeeplineError(
6288
+ 'Usage request_id must contain 1–200 characters with no leading or trailing whitespace.',
6289
+ undefined,
6290
+ 'INVALID_USAGE_REQUEST_ID',
6291
+ );
6292
+ }
6293
+ if (
6294
+ options.runId !== undefined ||
6295
+ options.cursor !== undefined ||
6296
+ options.offset !== undefined
6297
+ ) {
6298
+ throw new DeeplineError(
6299
+ 'requestId cannot be combined with runId, cursor, or offset.',
6300
+ undefined,
6301
+ 'INVALID_USAGE_FILTERS',
6302
+ );
6303
+ }
6304
+ params.set('request_id', requestId);
6305
+ } else {
6306
+ if (options.limit !== undefined) {
6307
+ params.set('recent_limit', String(options.limit));
6308
+ }
6309
+ if (options.offset !== undefined) {
6310
+ params.set('recent_offset', String(options.offset));
6311
+ }
6312
+ if (options.cursor !== undefined) {
6313
+ params.set('recent_cursor', options.cursor);
6314
+ }
6315
+ if (options.runId !== undefined) {
6316
+ params.set('run_id', options.runId);
6317
+ }
6318
+ }
6319
+ const serializedParams = params.toString();
6320
+ const query = serializedParams ? `?${serializedParams}` : '';
6321
+ return this.http.get<BillingUsageResult>(`/api/v2/billing/usage${query}`);
6322
+ }
6323
+
6197
6324
  /**
6198
6325
  * Charge the saved payment method and add Deepline credits to the active
6199
6326
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -68,12 +68,15 @@ export type {
68
68
  BillingInvoiceEntry,
69
69
  BillingInvoicesResult,
70
70
  BillingNamespace,
71
+ BillingRecentUsageEntry,
71
72
  DbNamespace,
72
73
  BillingPaymentMethodSummary,
73
74
  BillingSubscriptionCancelResult,
74
75
  BillingSubscriptionStatus,
75
76
  BillingTopUpResult,
76
77
  BillingUsageEvent,
78
+ BillingUsageOptions,
79
+ BillingUsageResult,
77
80
  WorkspaceCreateResult,
78
81
  WorkspacesNamespace,
79
82
  MonitorsNamespace,
@@ -110,6 +110,7 @@ import type {
110
110
  ToolMetadata,
111
111
  } from './types.js';
112
112
  import type {
113
+ BillingNamespace,
113
114
  ExecutionByKeyResult,
114
115
  ExecutionRecovery,
115
116
  ToolExecution,
@@ -1064,6 +1065,7 @@ function createNamedPlayHandle<
1064
1065
  * // Tools
1065
1066
  * const tools = await deepline.tools.list();
1066
1067
  * const result = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
1068
+ * const charge = await deepline.billing.usage({ requestId: result.job_id });
1067
1069
  *
1068
1070
  * // Plays
1069
1071
  * const job = await deepline.play('email-waterfall').run({ domain: 'stripe.com' });
@@ -1075,6 +1077,11 @@ function createNamedPlayHandle<
1075
1077
  export class DeeplineContext {
1076
1078
  private readonly client: DeeplineClient;
1077
1079
 
1080
+ /** Read current billing usage and exact per-request Deepline charges. */
1081
+ get billing(): BillingNamespace {
1082
+ return this.client.billing;
1083
+ }
1084
+
1078
1085
  /**
1079
1086
  * Create a high-level SDK context.
1080
1087
  *
@@ -200,7 +200,7 @@ export const SDK_RELEASE = {
200
200
  // getters keep their established compatibility behavior.
201
201
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
202
202
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
203
- version: '0.3.162',
203
+ version: '0.3.164',
204
204
  updateSummary:
205
205
  'Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.',
206
206
  packageCapabilities: {
@@ -585,6 +585,7 @@ export function normalizeQueueItemState(nativeState: string): QueueItemState {
585
585
  state === 'open' ||
586
586
  state === 'pending' ||
587
587
  state === 'queued' ||
588
+ state === 'continuation_pending' ||
588
589
  state === 'active' ||
589
590
  state === 'received' ||
590
591
  state === 'partial'
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Owner-neutral control port for cataloged scheduled work.
3
+ *
4
+ * The shared operations surface routes by stable job id. Scheduler adapters
5
+ * own authorization details and durable execution; callers never invoke a
6
+ * GitHub workflow, Vercel route, Inngest function, or Convex root directly.
7
+ */
8
+ export const SCHEDULED_WORK_CONTROL_CONTRACT_VERSION = 1 as const;
9
+
10
+ export type ScheduledWorkControlAction = 'run';
11
+
12
+ export type ScheduledWorkControlContext = {
13
+ readonly jobId: string;
14
+ readonly environment: string;
15
+ readonly requestedByUserId: string;
16
+ readonly requestedByEmail: string;
17
+ readonly reason: string;
18
+ readonly idempotencyKey: string;
19
+ };
20
+
21
+ export type ScheduledWorkRunResult = {
22
+ readonly operationId: string;
23
+ readonly status: 'queued' | 'running' | 'succeeded' | 'failed';
24
+ readonly replayed: boolean;
25
+ };
26
+
27
+ export type ScheduledWorkControlConnector = {
28
+ readonly id: string;
29
+ /** Stable implementation identity, such as `convex_cron` or `github_actions`. */
30
+ readonly scheduler: string;
31
+ readonly jobIds: readonly string[];
32
+ readonly actions: readonly ScheduledWorkControlAction[];
33
+ /** Registered owners may expose an honest read-only adapter before a safe
34
+ * mutation exists. These reasons are returned by the same capability API. */
35
+ readonly unavailableActions?: Partial<
36
+ Record<ScheduledWorkControlAction, string>
37
+ >;
38
+ run?: (
39
+ context: ScheduledWorkControlContext,
40
+ ) => Promise<ScheduledWorkRunResult>;
41
+ };
42
+
43
+ export type ScheduledWorkControlRegisterOptions = {
44
+ /** Permit replacing an explicitly read-only startup adapter with its owner. */
45
+ readonly replaceUnavailable?: boolean;
46
+ };
47
+
48
+ export type ScheduledWorkControlCapability =
49
+ | {
50
+ readonly available: true;
51
+ readonly action: ScheduledWorkControlAction;
52
+ readonly connectorId: string;
53
+ readonly scheduler: string;
54
+ }
55
+ | {
56
+ readonly available: false;
57
+ readonly action: ScheduledWorkControlAction;
58
+ readonly reason: string;
59
+ };
60
+
61
+ /**
62
+ * Dispatch boundary shared by all scheduled-work implementations. Duplicate
63
+ * job ownership is a startup error so one scheduler cannot shadow another.
64
+ */
65
+ export class ScheduledWorkControlRegistry {
66
+ private readonly connectorsByJobId = new Map<
67
+ string,
68
+ ScheduledWorkControlConnector
69
+ >();
70
+
71
+ register(
72
+ connector: ScheduledWorkControlConnector,
73
+ options: ScheduledWorkControlRegisterOptions = {},
74
+ ): this {
75
+ if (!connector.id.trim())
76
+ throw new Error('Scheduled-work connector id is required.');
77
+ if (!connector.scheduler.trim())
78
+ throw new Error('Scheduled-work connector scheduler is required.');
79
+ if (connector.jobIds.length === 0)
80
+ throw new Error(
81
+ `Scheduled-work connector ${connector.id} must own at least one job.`,
82
+ );
83
+ if (
84
+ connector.actions.includes('run') &&
85
+ typeof connector.run !== 'function'
86
+ ) {
87
+ throw new Error(
88
+ `Scheduled-work connector ${connector.id} declares run without an implementation.`,
89
+ );
90
+ }
91
+ if (
92
+ connector.actions.length === 0 &&
93
+ Object.keys(connector.unavailableActions ?? {}).length === 0
94
+ ) {
95
+ throw new Error(
96
+ `Scheduled-work connector ${connector.id} must declare a supported action or an explicit unavailable reason.`,
97
+ );
98
+ }
99
+ const jobIds = new Set<string>();
100
+ for (const jobId of connector.jobIds) {
101
+ if (!jobId.trim())
102
+ throw new Error(
103
+ `Scheduled-work connector ${connector.id} has an empty job id.`,
104
+ );
105
+ if (jobIds.has(jobId))
106
+ throw new Error(
107
+ `Scheduled-work connector ${connector.id} repeats job ${jobId}.`,
108
+ );
109
+ jobIds.add(jobId);
110
+ const existing = this.connectorsByJobId.get(jobId);
111
+ if (existing && !options.replaceUnavailable) {
112
+ throw new Error(
113
+ `Scheduled-work job ${jobId} is already owned by ${existing.id}.`,
114
+ );
115
+ }
116
+ if (
117
+ existing &&
118
+ options.replaceUnavailable &&
119
+ existing.actions.length > 0
120
+ ) {
121
+ throw new Error(
122
+ `Scheduled-work job ${jobId} is already owned by ${existing.id}; replacement is not allowed.`,
123
+ );
124
+ }
125
+ }
126
+ for (const jobId of jobIds) this.connectorsByJobId.set(jobId, connector);
127
+ return this;
128
+ }
129
+
130
+ get(jobId: string): ScheduledWorkControlConnector | undefined {
131
+ return this.connectorsByJobId.get(jobId);
132
+ }
133
+
134
+ capability(
135
+ jobId: string,
136
+ action: ScheduledWorkControlAction = 'run',
137
+ ): ScheduledWorkControlCapability {
138
+ const connector = this.get(jobId);
139
+ if (connector?.actions.includes(action)) {
140
+ return {
141
+ available: true,
142
+ action,
143
+ connectorId: connector.id,
144
+ scheduler: connector.scheduler,
145
+ };
146
+ }
147
+ return {
148
+ available: false,
149
+ action,
150
+ reason: connector
151
+ ? (connector.unavailableActions?.[action] ??
152
+ `Scheduler connector ${connector.id} does not support ${action}.`)
153
+ : `No shared control connector is registered for scheduler work ${jobId}.`,
154
+ };
155
+ }
156
+ }
package/dist/cli/index.js CHANGED
@@ -3051,7 +3051,7 @@ var SDK_RELEASE = {
3051
3051
  // getters keep their established compatibility behavior.
3052
3052
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3053
3053
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3054
- version: "0.3.162",
3054
+ version: "0.3.164",
3055
3055
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
3056
3056
  packageCapabilities: {
3057
3057
  updatePreferences: 1
@@ -7156,6 +7156,7 @@ var DeeplineClient = class _DeeplineClient {
7156
7156
  list: (options2) => this.listBillingInvoices(options2)
7157
7157
  },
7158
7158
  usageEvent: (requestId) => this.getBillingUsageEvent(requestId),
7159
+ usage: (options2) => this.getBillingUsage(options2),
7159
7160
  targetPlans: () => this.getTargetBillingPlans(),
7160
7161
  targetStatus: () => this.getTargetBillingStatus(),
7161
7162
  autoRecharge: {
@@ -9710,6 +9711,49 @@ var DeeplineClient = class _DeeplineClient {
9710
9711
  }
9711
9712
  return event;
9712
9713
  }
9714
+ /**
9715
+ * Read workspace usage and recent customer-facing Deepline charges. Pass
9716
+ * the `job_id` from `executeTool` as `requestId` to retrieve one exact call,
9717
+ * including whether its charge is final or still a temporary hold. Exact
9718
+ * request lookups return only the `org_id` and `recent` result fields.
9719
+ */
9720
+ async getBillingUsage(options = {}) {
9721
+ const params = new URLSearchParams();
9722
+ if (options.requestId !== void 0) {
9723
+ const requestId = options.requestId.trim();
9724
+ if (requestId.length === 0 || requestId.length > 200 || requestId !== options.requestId) {
9725
+ throw new DeeplineError(
9726
+ "Usage request_id must contain 1\u2013200 characters with no leading or trailing whitespace.",
9727
+ void 0,
9728
+ "INVALID_USAGE_REQUEST_ID"
9729
+ );
9730
+ }
9731
+ if (options.runId !== void 0 || options.cursor !== void 0 || options.offset !== void 0) {
9732
+ throw new DeeplineError(
9733
+ "requestId cannot be combined with runId, cursor, or offset.",
9734
+ void 0,
9735
+ "INVALID_USAGE_FILTERS"
9736
+ );
9737
+ }
9738
+ params.set("request_id", requestId);
9739
+ } else {
9740
+ if (options.limit !== void 0) {
9741
+ params.set("recent_limit", String(options.limit));
9742
+ }
9743
+ if (options.offset !== void 0) {
9744
+ params.set("recent_offset", String(options.offset));
9745
+ }
9746
+ if (options.cursor !== void 0) {
9747
+ params.set("recent_cursor", options.cursor);
9748
+ }
9749
+ if (options.runId !== void 0) {
9750
+ params.set("run_id", options.runId);
9751
+ }
9752
+ }
9753
+ const serializedParams = params.toString();
9754
+ const query = serializedParams ? `?${serializedParams}` : "";
9755
+ return this.http.get(`/api/v2/billing/usage${query}`);
9756
+ }
9713
9757
  /**
9714
9758
  * Charge the saved payment method and add Deepline credits to the active
9715
9759
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -12454,12 +12498,18 @@ function recentUsageLines(entries) {
12454
12498
  const lines = ["Recent activity:"];
12455
12499
  for (const entry of entries) {
12456
12500
  const op = `${humanize(entry.provider)} ${humanize(entry.operation)}`.trim();
12457
- const charge = entry.billing_mode === "no_bill" ? "free" : `${entry.credits ?? 0} cr`;
12458
- const state = entry.charge_state === "temporary_hold" ? "temporary hold, awaiting actual usage" : entry.status || "completed";
12501
+ const roughUsd = Number(entry.rough_usd_cost);
12502
+ const usdText = entry.charge_state !== "pending" && entry.rough_usd_cost !== null && entry.rough_usd_cost !== void 0 && Number.isFinite(roughUsd) ? ` (\u2248$${roughUsd.toFixed(2)})` : "";
12503
+ const charge = entry.billing_mode === "no_bill" ? "free" : entry.charge_state === "temporary_hold" ? `${entry.credits ?? 0} cr held${usdText}, not final` : entry.charge_state === "pending" ? "final Deepline charge pending" : `${entry.credits ?? 0} cr${usdText}`;
12504
+ const state = entry.charge_state === "temporary_hold" ? "temporary hold, final charge pending" : entry.charge_state === "pending" ? "no final charge recorded yet" : entry.status || "completed";
12459
12505
  const auditBits = [
12460
12506
  entry.outcome ? `outcome=${entry.outcome}` : null,
12461
12507
  entry.pricing_basis ? `priced_by=${entry.pricing_basis}` : null,
12462
12508
  entry.run_id ? `run=${entry.run_id}` : null,
12509
+ entry.play_run_id || entry.execution_run_id ? `play_run=${entry.play_run_id ?? entry.execution_run_id}` : null,
12510
+ entry.billing_run_id ? `billing_run=${entry.billing_run_id}` : null,
12511
+ entry.workflow_id ? `workflow=${entry.workflow_id}` : null,
12512
+ entry.step_alias ? `step=${entry.step_alias}` : null,
12463
12513
  entry.request_id ? `request=${entry.request_id}` : null
12464
12514
  ].filter(Boolean);
12465
12515
  lines.push(
@@ -12587,21 +12637,68 @@ function quoteShellArgument(value) {
12587
12637
  async function handleUsage(options) {
12588
12638
  const { http } = getAuthedHttpClient();
12589
12639
  const params = new URLSearchParams();
12590
- if (options.limit) params.set("recent_limit", options.limit);
12591
- if (options.offset) params.set("recent_offset", options.offset);
12592
- if (options.cursor) params.set("recent_cursor", options.cursor);
12593
- if (options.runId) params.set("run_id", options.runId);
12640
+ if (options.requestId !== void 0) {
12641
+ const requestId = options.requestId.trim();
12642
+ if (requestId.length === 0 || requestId.length > 200 || requestId !== options.requestId) {
12643
+ reportBillingFailure(
12644
+ {
12645
+ exitCode: 2,
12646
+ code: "INVALID_REQUEST_ID",
12647
+ message: "--request-id must contain 1\u2013200 characters with no leading or trailing whitespace."
12648
+ },
12649
+ options
12650
+ );
12651
+ return;
12652
+ }
12653
+ if (options.offset || options.cursor || options.runId) {
12654
+ reportBillingFailure(
12655
+ {
12656
+ exitCode: 2,
12657
+ code: "CONFLICTING_USAGE_FILTERS",
12658
+ message: "--request-id cannot be combined with --offset, --cursor, or --run-id."
12659
+ },
12660
+ options
12661
+ );
12662
+ return;
12663
+ }
12664
+ params.set("request_id", requestId);
12665
+ } else {
12666
+ if (options.limit) params.set("recent_limit", options.limit);
12667
+ if (options.offset) params.set("recent_offset", options.offset);
12668
+ if (options.cursor) params.set("recent_cursor", options.cursor);
12669
+ if (options.runId) params.set("run_id", options.runId);
12670
+ }
12594
12671
  const suffix = Array.from(params).length > 0 ? `?${params.toString()}` : "";
12595
- const payload = await http.get(
12596
- `/api/v2/billing/usage${suffix}`
12597
- );
12672
+ let payload;
12673
+ try {
12674
+ payload = await http.get(
12675
+ `/api/v2/billing/usage${suffix}`
12676
+ );
12677
+ } catch (error) {
12678
+ if (options.requestId && error instanceof DeeplineError && error.statusCode === 404) {
12679
+ reportBillingFailure(
12680
+ {
12681
+ exitCode: 4,
12682
+ code: "USAGE_REQUEST_NOT_FOUND",
12683
+ message: `No billing record for request_id ${options.requestId} in the active workspace.`,
12684
+ next: "deepline billing usage --json"
12685
+ },
12686
+ options
12687
+ );
12688
+ return;
12689
+ }
12690
+ throw error;
12691
+ }
12598
12692
  const usage = payload.usage ?? {};
12599
12693
  const quota = payload.quota ?? {};
12600
12694
  const recent = payload.recent ?? {};
12601
12695
  const last30Usage = usage.last_30_days_usage_credits ?? usage.month_spent_credits;
12602
12696
  const temporaryHolds = Number(usage.temporary_hold_credits ?? 0);
12603
12697
  const nextPage = typeof recent.next_cursor === "string" && recent.next_cursor.length > 0 ? `deepline billing usage --cursor ${quoteShellArgument(recent.next_cursor)}${options.limit ? ` --limit ${options.limit}` : ""}${options.runId ? ` --run-id ${quoteShellArgument(options.runId)}` : ""} --json` : null;
12604
- const lines = [
12698
+ const recentLines = recentUsageLines(
12699
+ Array.isArray(recent.entries) ? recent.entries : []
12700
+ );
12701
+ const lines = options.requestId ? [`Charge lookup: ${options.requestId}`, ...recentLines] : [
12605
12702
  `Balance: ${payload.balance ?? "(unknown)"}`,
12606
12703
  `Last 30 days usage: ${last30Usage ?? "(unknown)"}`,
12607
12704
  ...Number.isFinite(temporaryHolds) && temporaryHolds > 0 ? [`Temporary holds: ${temporaryHolds}`] : [],
@@ -12609,9 +12706,7 @@ async function handleUsage(options) {
12609
12706
  ...options.runId && recent.run_id ? [
12610
12707
  `Run spend: ${(payload.run ?? {}).spent_credits ?? "(unknown)"} Deepline Credits`
12611
12708
  ] : [],
12612
- ...recentUsageLines(
12613
- Array.isArray(recent.entries) ? recent.entries : []
12614
- ),
12709
+ ...recentLines,
12615
12710
  ...recent.has_more === true || recent.incomplete === true ? ["List truncated \u2014 more recent calls match this query."] : [],
12616
12711
  ...nextPage ? [`Next page: ${nextPage}`] : [],
12617
12712
  ...!nextPage && (recent.has_more === true || recent.incomplete === true) ? [
@@ -13518,11 +13613,15 @@ Examples:
13518
13613
  deepline billing usage
13519
13614
  deepline billing usage --limit 50 --cursor <next_cursor> --json
13520
13615
  deepline billing usage --run-id play/example/run/20260630t120000-000-abcdef --json
13616
+ deepline billing usage --request-id <job_id> --json
13521
13617
  `
13522
13618
  ).option("--limit <n>", "Recent-call page size").option("--offset <n>", "Recent-call offset").option(
13523
13619
  "--cursor <cursor>",
13524
13620
  "Recent-call cursor from the previous response"
13525
- ).option("--run-id <run_id>", "Show recent usage for one play run").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleUsage);
13621
+ ).option("--run-id <run_id>", "Show recent usage for one play run").option(
13622
+ "--request-id <job_id>",
13623
+ "Show the exact Deepline charge for one execution job_id"
13624
+ ).option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleUsage);
13526
13625
  billing.command("limit").description("Show configured monthly usage cap.").addHelpText(
13527
13626
  "after",
13528
13627
  `
@@ -3046,7 +3046,7 @@ var SDK_RELEASE = {
3046
3046
  // getters keep their established compatibility behavior.
3047
3047
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3048
3048
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3049
- version: "0.3.162",
3049
+ version: "0.3.164",
3050
3050
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
3051
3051
  packageCapabilities: {
3052
3052
  updatePreferences: 1
@@ -7151,6 +7151,7 @@ var DeeplineClient = class _DeeplineClient {
7151
7151
  list: (options2) => this.listBillingInvoices(options2)
7152
7152
  },
7153
7153
  usageEvent: (requestId) => this.getBillingUsageEvent(requestId),
7154
+ usage: (options2) => this.getBillingUsage(options2),
7154
7155
  targetPlans: () => this.getTargetBillingPlans(),
7155
7156
  targetStatus: () => this.getTargetBillingStatus(),
7156
7157
  autoRecharge: {
@@ -9705,6 +9706,49 @@ var DeeplineClient = class _DeeplineClient {
9705
9706
  }
9706
9707
  return event;
9707
9708
  }
9709
+ /**
9710
+ * Read workspace usage and recent customer-facing Deepline charges. Pass
9711
+ * the `job_id` from `executeTool` as `requestId` to retrieve one exact call,
9712
+ * including whether its charge is final or still a temporary hold. Exact
9713
+ * request lookups return only the `org_id` and `recent` result fields.
9714
+ */
9715
+ async getBillingUsage(options = {}) {
9716
+ const params = new URLSearchParams();
9717
+ if (options.requestId !== void 0) {
9718
+ const requestId = options.requestId.trim();
9719
+ if (requestId.length === 0 || requestId.length > 200 || requestId !== options.requestId) {
9720
+ throw new DeeplineError(
9721
+ "Usage request_id must contain 1\u2013200 characters with no leading or trailing whitespace.",
9722
+ void 0,
9723
+ "INVALID_USAGE_REQUEST_ID"
9724
+ );
9725
+ }
9726
+ if (options.runId !== void 0 || options.cursor !== void 0 || options.offset !== void 0) {
9727
+ throw new DeeplineError(
9728
+ "requestId cannot be combined with runId, cursor, or offset.",
9729
+ void 0,
9730
+ "INVALID_USAGE_FILTERS"
9731
+ );
9732
+ }
9733
+ params.set("request_id", requestId);
9734
+ } else {
9735
+ if (options.limit !== void 0) {
9736
+ params.set("recent_limit", String(options.limit));
9737
+ }
9738
+ if (options.offset !== void 0) {
9739
+ params.set("recent_offset", String(options.offset));
9740
+ }
9741
+ if (options.cursor !== void 0) {
9742
+ params.set("recent_cursor", options.cursor);
9743
+ }
9744
+ if (options.runId !== void 0) {
9745
+ params.set("run_id", options.runId);
9746
+ }
9747
+ }
9748
+ const serializedParams = params.toString();
9749
+ const query = serializedParams ? `?${serializedParams}` : "";
9750
+ return this.http.get(`/api/v2/billing/usage${query}`);
9751
+ }
9708
9752
  /**
9709
9753
  * Charge the saved payment method and add Deepline credits to the active
9710
9754
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -12461,12 +12505,18 @@ function recentUsageLines(entries) {
12461
12505
  const lines = ["Recent activity:"];
12462
12506
  for (const entry of entries) {
12463
12507
  const op = `${humanize(entry.provider)} ${humanize(entry.operation)}`.trim();
12464
- const charge = entry.billing_mode === "no_bill" ? "free" : `${entry.credits ?? 0} cr`;
12465
- const state = entry.charge_state === "temporary_hold" ? "temporary hold, awaiting actual usage" : entry.status || "completed";
12508
+ const roughUsd = Number(entry.rough_usd_cost);
12509
+ const usdText = entry.charge_state !== "pending" && entry.rough_usd_cost !== null && entry.rough_usd_cost !== void 0 && Number.isFinite(roughUsd) ? ` (\u2248$${roughUsd.toFixed(2)})` : "";
12510
+ const charge = entry.billing_mode === "no_bill" ? "free" : entry.charge_state === "temporary_hold" ? `${entry.credits ?? 0} cr held${usdText}, not final` : entry.charge_state === "pending" ? "final Deepline charge pending" : `${entry.credits ?? 0} cr${usdText}`;
12511
+ const state = entry.charge_state === "temporary_hold" ? "temporary hold, final charge pending" : entry.charge_state === "pending" ? "no final charge recorded yet" : entry.status || "completed";
12466
12512
  const auditBits = [
12467
12513
  entry.outcome ? `outcome=${entry.outcome}` : null,
12468
12514
  entry.pricing_basis ? `priced_by=${entry.pricing_basis}` : null,
12469
12515
  entry.run_id ? `run=${entry.run_id}` : null,
12516
+ entry.play_run_id || entry.execution_run_id ? `play_run=${entry.play_run_id ?? entry.execution_run_id}` : null,
12517
+ entry.billing_run_id ? `billing_run=${entry.billing_run_id}` : null,
12518
+ entry.workflow_id ? `workflow=${entry.workflow_id}` : null,
12519
+ entry.step_alias ? `step=${entry.step_alias}` : null,
12470
12520
  entry.request_id ? `request=${entry.request_id}` : null
12471
12521
  ].filter(Boolean);
12472
12522
  lines.push(
@@ -12594,21 +12644,68 @@ function quoteShellArgument(value) {
12594
12644
  async function handleUsage(options) {
12595
12645
  const { http } = getAuthedHttpClient();
12596
12646
  const params = new URLSearchParams();
12597
- if (options.limit) params.set("recent_limit", options.limit);
12598
- if (options.offset) params.set("recent_offset", options.offset);
12599
- if (options.cursor) params.set("recent_cursor", options.cursor);
12600
- if (options.runId) params.set("run_id", options.runId);
12647
+ if (options.requestId !== void 0) {
12648
+ const requestId = options.requestId.trim();
12649
+ if (requestId.length === 0 || requestId.length > 200 || requestId !== options.requestId) {
12650
+ reportBillingFailure(
12651
+ {
12652
+ exitCode: 2,
12653
+ code: "INVALID_REQUEST_ID",
12654
+ message: "--request-id must contain 1\u2013200 characters with no leading or trailing whitespace."
12655
+ },
12656
+ options
12657
+ );
12658
+ return;
12659
+ }
12660
+ if (options.offset || options.cursor || options.runId) {
12661
+ reportBillingFailure(
12662
+ {
12663
+ exitCode: 2,
12664
+ code: "CONFLICTING_USAGE_FILTERS",
12665
+ message: "--request-id cannot be combined with --offset, --cursor, or --run-id."
12666
+ },
12667
+ options
12668
+ );
12669
+ return;
12670
+ }
12671
+ params.set("request_id", requestId);
12672
+ } else {
12673
+ if (options.limit) params.set("recent_limit", options.limit);
12674
+ if (options.offset) params.set("recent_offset", options.offset);
12675
+ if (options.cursor) params.set("recent_cursor", options.cursor);
12676
+ if (options.runId) params.set("run_id", options.runId);
12677
+ }
12601
12678
  const suffix = Array.from(params).length > 0 ? `?${params.toString()}` : "";
12602
- const payload = await http.get(
12603
- `/api/v2/billing/usage${suffix}`
12604
- );
12679
+ let payload;
12680
+ try {
12681
+ payload = await http.get(
12682
+ `/api/v2/billing/usage${suffix}`
12683
+ );
12684
+ } catch (error) {
12685
+ if (options.requestId && error instanceof DeeplineError && error.statusCode === 404) {
12686
+ reportBillingFailure(
12687
+ {
12688
+ exitCode: 4,
12689
+ code: "USAGE_REQUEST_NOT_FOUND",
12690
+ message: `No billing record for request_id ${options.requestId} in the active workspace.`,
12691
+ next: "deepline billing usage --json"
12692
+ },
12693
+ options
12694
+ );
12695
+ return;
12696
+ }
12697
+ throw error;
12698
+ }
12605
12699
  const usage = payload.usage ?? {};
12606
12700
  const quota = payload.quota ?? {};
12607
12701
  const recent = payload.recent ?? {};
12608
12702
  const last30Usage = usage.last_30_days_usage_credits ?? usage.month_spent_credits;
12609
12703
  const temporaryHolds = Number(usage.temporary_hold_credits ?? 0);
12610
12704
  const nextPage = typeof recent.next_cursor === "string" && recent.next_cursor.length > 0 ? `deepline billing usage --cursor ${quoteShellArgument(recent.next_cursor)}${options.limit ? ` --limit ${options.limit}` : ""}${options.runId ? ` --run-id ${quoteShellArgument(options.runId)}` : ""} --json` : null;
12611
- const lines = [
12705
+ const recentLines = recentUsageLines(
12706
+ Array.isArray(recent.entries) ? recent.entries : []
12707
+ );
12708
+ const lines = options.requestId ? [`Charge lookup: ${options.requestId}`, ...recentLines] : [
12612
12709
  `Balance: ${payload.balance ?? "(unknown)"}`,
12613
12710
  `Last 30 days usage: ${last30Usage ?? "(unknown)"}`,
12614
12711
  ...Number.isFinite(temporaryHolds) && temporaryHolds > 0 ? [`Temporary holds: ${temporaryHolds}`] : [],
@@ -12616,9 +12713,7 @@ async function handleUsage(options) {
12616
12713
  ...options.runId && recent.run_id ? [
12617
12714
  `Run spend: ${(payload.run ?? {}).spent_credits ?? "(unknown)"} Deepline Credits`
12618
12715
  ] : [],
12619
- ...recentUsageLines(
12620
- Array.isArray(recent.entries) ? recent.entries : []
12621
- ),
12716
+ ...recentLines,
12622
12717
  ...recent.has_more === true || recent.incomplete === true ? ["List truncated \u2014 more recent calls match this query."] : [],
12623
12718
  ...nextPage ? [`Next page: ${nextPage}`] : [],
12624
12719
  ...!nextPage && (recent.has_more === true || recent.incomplete === true) ? [
@@ -13525,11 +13620,15 @@ Examples:
13525
13620
  deepline billing usage
13526
13621
  deepline billing usage --limit 50 --cursor <next_cursor> --json
13527
13622
  deepline billing usage --run-id play/example/run/20260630t120000-000-abcdef --json
13623
+ deepline billing usage --request-id <job_id> --json
13528
13624
  `
13529
13625
  ).option("--limit <n>", "Recent-call page size").option("--offset <n>", "Recent-call offset").option(
13530
13626
  "--cursor <cursor>",
13531
13627
  "Recent-call cursor from the previous response"
13532
- ).option("--run-id <run_id>", "Show recent usage for one play run").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleUsage);
13628
+ ).option("--run-id <run_id>", "Show recent usage for one play run").option(
13629
+ "--request-id <job_id>",
13630
+ "Show the exact Deepline charge for one execution job_id"
13631
+ ).option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleUsage);
13533
13632
  billing.command("limit").description("Show configured monthly usage cap.").addHelpText(
13534
13633
  "after",
13535
13634
  `
package/dist/index.d.mts CHANGED
@@ -4323,9 +4323,72 @@ type BillingUsageEvent = {
4323
4323
  policy_id: string | null;
4324
4324
  created_at: string;
4325
4325
  };
4326
+ /** One customer-facing recent billing operation from `/api/v2/billing/usage`. */
4327
+ type BillingRecentUsageEntry = {
4328
+ id: string;
4329
+ provider: string;
4330
+ operation: string;
4331
+ status: string;
4332
+ request_id: string;
4333
+ run_id: string | null;
4334
+ /** Play execution run for this charge, when the call ran inside a Play. */
4335
+ play_run_id?: string | null;
4336
+ workflow_id?: string | null;
4337
+ billing_run_id?: string | null;
4338
+ execution_run_id?: string | null;
4339
+ included_in_run_id?: string | null;
4340
+ billing_scope?: string | null;
4341
+ step_block_id?: string | null;
4342
+ step_alias?: string | null;
4343
+ credits: number;
4344
+ billing_mode: string | null;
4345
+ pricing_model: string | null;
4346
+ outcome: string | null;
4347
+ billing_note: string | null;
4348
+ charge_state: 'posted' | 'temporary_hold' | 'hold_release' | 'pending' | 'free' | 'failed';
4349
+ rough_usd_cost: number | null;
4350
+ created_at: string;
4351
+ };
4352
+ type BillingUsageOptions = {
4353
+ /** Return the one exact call identified by `executeTool().job_id`. */
4354
+ requestId?: string;
4355
+ /** Bound the recent-call page. Ignored for an exact requestId lookup. */
4356
+ limit?: number;
4357
+ offset?: number;
4358
+ cursor?: string;
4359
+ runId?: string;
4360
+ };
4361
+ type BillingUsageResult = {
4362
+ org_id: string;
4363
+ balance?: number;
4364
+ rough_usd_balance?: number;
4365
+ plan?: {
4366
+ usd_per_credit: number;
4367
+ };
4368
+ usage?: {
4369
+ last_30_days_usage_credits: number;
4370
+ rough_usd_last_30_days_usage: number;
4371
+ temporary_hold_credits: number;
4372
+ rough_usd_temporary_holds: number;
4373
+ };
4374
+ recent: {
4375
+ run_id: string | null;
4376
+ request_id?: string;
4377
+ total: number;
4378
+ offset: number;
4379
+ limit: number;
4380
+ next_offset: number;
4381
+ next_cursor: string | null;
4382
+ has_more: boolean;
4383
+ incomplete: boolean;
4384
+ entries: BillingRecentUsageEntry[];
4385
+ };
4386
+ [key: string]: unknown;
4387
+ };
4326
4388
  /**
4327
4389
  * Public `client.billing` namespace for CLI commands and programmatic callers.
4328
- * Covers plans, subscription state, cancellation, and invoice/receipt history.
4390
+ * Covers usage, plans, subscription state, cancellation, and invoice/receipt
4391
+ * history.
4329
4392
  *
4330
4393
  * @sdkReference client 030 client.billing
4331
4394
  */
@@ -4356,6 +4419,8 @@ type BillingNamespace = {
4356
4419
  };
4357
4420
  /** Read one exact execution outcome using the request_id returned by executeTool. */
4358
4421
  usageEvent: (requestId: string) => Promise<BillingUsageEvent>;
4422
+ /** Read current billing usage, or look up one exact execution charge by request ID. */
4423
+ usage: (options?: BillingUsageOptions) => Promise<BillingUsageResult>;
4359
4424
  /** Metronome-authored target catalog and current Contract projection. */
4360
4425
  targetPlans: () => Promise<TargetBillingPlansResult>;
4361
4426
  /** Normalized target billing state. */
@@ -5433,6 +5498,13 @@ declare class DeeplineClient {
5433
5498
  * retry or idempotency token.
5434
5499
  */
5435
5500
  getBillingUsageEvent(requestId: string): Promise<BillingUsageEvent>;
5501
+ /**
5502
+ * Read workspace usage and recent customer-facing Deepline charges. Pass
5503
+ * the `job_id` from `executeTool` as `requestId` to retrieve one exact call,
5504
+ * including whether its charge is final or still a temporary hold. Exact
5505
+ * request lookups return only the `org_id` and `recent` result fields.
5506
+ */
5507
+ getBillingUsage(options?: BillingUsageOptions): Promise<BillingUsageResult>;
5436
5508
  /**
5437
5509
  * Charge the saved payment method and add Deepline credits to the active
5438
5510
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -6129,6 +6201,7 @@ type PlayMetadata<TInput = Record<string, unknown>> = {
6129
6201
  * // Tools
6130
6202
  * const tools = await deepline.tools.list();
6131
6203
  * const result = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
6204
+ * const charge = await deepline.billing.usage({ requestId: result.job_id });
6132
6205
  *
6133
6206
  * // Plays
6134
6207
  * const job = await deepline.play('email-waterfall').run({ domain: 'stripe.com' });
@@ -6139,6 +6212,8 @@ type PlayMetadata<TInput = Record<string, unknown>> = {
6139
6212
  */
6140
6213
  declare class DeeplineContext {
6141
6214
  private readonly client;
6215
+ /** Read current billing usage and exact per-request Deepline charges. */
6216
+ get billing(): BillingNamespace;
6142
6217
  /**
6143
6218
  * Create a high-level SDK context.
6144
6219
  *
@@ -6655,4 +6730,4 @@ declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem:
6655
6730
  */
6656
6731
  declare function extractSummaryFields(payload: unknown): Record<string, Scalar>;
6657
6732
 
6658
- export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, type BillingUsageEvent, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CreateNotificationGroupInput, type CreateNotificationGroupResult, type CsvInput, type CsvOptions, type CustomerDbQueryResult, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, type DatasetColumnDefinition, type DatasetColumnRunInput, type DbNamespace, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, DeeplineError, type DeeplineExecutionsNamespace, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolExecuteResult, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, type ExecutionByKeyResult, type ExecutionRecovery, type FetchOptions, type FileInput, type IngestionStorageRepairResult, type LegacyMonitorStatusFilter, type LiveEventEnvelope, MONITOR_JOB_PHASES, MONITOR_JOB_RECONCILIATION_STATES, MONITOR_JOB_STATES, type MonitorBatchNamespace, type MonitorCheckResult, type MonitorDefinition, type MonitorDeleteResult, type MonitorDependents, type MonitorDeployResult, type MonitorDetail, type MonitorFleetDeactivateOptions, MonitorFleetDefinition, type MonitorFleetGetOptions, type MonitorFleetReactivateOptions, type MonitorFleetResult, type MonitorFleetStatus, type MonitorFleetSyncOptions, type MonitorFleetWaitOptions, type MonitorFleetsNamespace, type MonitorJobDeployOptions, type MonitorJobLogsOptions, type MonitorJobPhase, type MonitorJobReconciliationState, type MonitorJobResult, type MonitorJobState, type MonitorJobWaitOptions, type MonitorJobsNamespace, type MonitorListEntry, type MonitorPayload, type MonitorReactivateResult, type MonitorSpec, type MonitorState, type MonitorStateFilter, type MonitorUpdateChangeSummary, type MonitorUpdateResult, type MonitorsAccessStatus, type MonitorsAvailableOptions, type MonitorsAvailableResult, type MonitorsListOptions, type MonitorsListResult, type MonitorsNamespace, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PlayActivityObservation, type PlayActivityState, type PlayActivityTarget, type PlayAsyncCallOptions, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayCallExecution, type PlayCallOptions, type PlayCostEstimate, type PlayFetchResponse, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayReferenceLike, type PlayRevisionSummary, type PlayRunActionPackage, type PlayRunActivityProjection, type PlayRunDatasetActions, type PlayRunId, type PlayRunPackage, type PlayRunResult, type PlayRunStart, type PlaySheetRow, type PlaySheetRowsResult, type PlayStatus, type PlayStepProgramStep, type PlaysListOptions, type PlaysListPage, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type RerunOptions, type RerunPlayRunResult, type ResolvedConfig, RunObserveTransportUnavailableError, type RunsListOptions, type RunsListPage, type RunsLogsOptions, type RunsLogsResult, type RunsNamespace, type RunsTailOptions, type RuntimeStepOptions, SDK_API_CONTRACT, SDK_VERSION, type SqlListenerDeclaration, type SqlListenerEvent, type SqlListenerOperation, type SqlQuery, type StartPlayRunRequest, type StepOptions, type StepProgram, type StepProgramResolver, type StepResolver, type StopAllCandidate, type StopAllPlayRunsDryRunResult, type StopAllPlayRunsResult, type StopAllPlayRunsStopResult, type StopAllRunsOptions, type StopPlayRunResult, type ToolDefinition, ToolExecuteResult, type ToolExecution, ToolExecutionError, ToolExecutionErrorOptions, type ToolExecutionRequest, type ToolMetadata, ToolRateLimitError, ToolResultBilling, type ToolSearchOptions, type ToolSearchResult, type WorkspaceCreateResult, type WorkspacesNamespace, defineInput, defineMonitor, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, isStopAllPlayRunsDryRunResult, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };
6733
+ export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingRecentUsageEntry, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, type BillingUsageEvent, type BillingUsageOptions, type BillingUsageResult, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CreateNotificationGroupInput, type CreateNotificationGroupResult, type CsvInput, type CsvOptions, type CustomerDbQueryResult, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, type DatasetColumnDefinition, type DatasetColumnRunInput, type DbNamespace, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, DeeplineError, type DeeplineExecutionsNamespace, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolExecuteResult, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, type ExecutionByKeyResult, type ExecutionRecovery, type FetchOptions, type FileInput, type IngestionStorageRepairResult, type LegacyMonitorStatusFilter, type LiveEventEnvelope, MONITOR_JOB_PHASES, MONITOR_JOB_RECONCILIATION_STATES, MONITOR_JOB_STATES, type MonitorBatchNamespace, type MonitorCheckResult, type MonitorDefinition, type MonitorDeleteResult, type MonitorDependents, type MonitorDeployResult, type MonitorDetail, type MonitorFleetDeactivateOptions, MonitorFleetDefinition, type MonitorFleetGetOptions, type MonitorFleetReactivateOptions, type MonitorFleetResult, type MonitorFleetStatus, type MonitorFleetSyncOptions, type MonitorFleetWaitOptions, type MonitorFleetsNamespace, type MonitorJobDeployOptions, type MonitorJobLogsOptions, type MonitorJobPhase, type MonitorJobReconciliationState, type MonitorJobResult, type MonitorJobState, type MonitorJobWaitOptions, type MonitorJobsNamespace, type MonitorListEntry, type MonitorPayload, type MonitorReactivateResult, type MonitorSpec, type MonitorState, type MonitorStateFilter, type MonitorUpdateChangeSummary, type MonitorUpdateResult, type MonitorsAccessStatus, type MonitorsAvailableOptions, type MonitorsAvailableResult, type MonitorsListOptions, type MonitorsListResult, type MonitorsNamespace, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PlayActivityObservation, type PlayActivityState, type PlayActivityTarget, type PlayAsyncCallOptions, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayCallExecution, type PlayCallOptions, type PlayCostEstimate, type PlayFetchResponse, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayReferenceLike, type PlayRevisionSummary, type PlayRunActionPackage, type PlayRunActivityProjection, type PlayRunDatasetActions, type PlayRunId, type PlayRunPackage, type PlayRunResult, type PlayRunStart, type PlaySheetRow, type PlaySheetRowsResult, type PlayStatus, type PlayStepProgramStep, type PlaysListOptions, type PlaysListPage, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type RerunOptions, type RerunPlayRunResult, type ResolvedConfig, RunObserveTransportUnavailableError, type RunsListOptions, type RunsListPage, type RunsLogsOptions, type RunsLogsResult, type RunsNamespace, type RunsTailOptions, type RuntimeStepOptions, SDK_API_CONTRACT, SDK_VERSION, type SqlListenerDeclaration, type SqlListenerEvent, type SqlListenerOperation, type SqlQuery, type StartPlayRunRequest, type StepOptions, type StepProgram, type StepProgramResolver, type StepResolver, type StopAllCandidate, type StopAllPlayRunsDryRunResult, type StopAllPlayRunsResult, type StopAllPlayRunsStopResult, type StopAllRunsOptions, type StopPlayRunResult, type ToolDefinition, ToolExecuteResult, type ToolExecution, ToolExecutionError, ToolExecutionErrorOptions, type ToolExecutionRequest, type ToolMetadata, ToolRateLimitError, ToolResultBilling, type ToolSearchOptions, type ToolSearchResult, type WorkspaceCreateResult, type WorkspacesNamespace, defineInput, defineMonitor, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, isStopAllPlayRunsDryRunResult, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };
package/dist/index.d.ts CHANGED
@@ -4323,9 +4323,72 @@ type BillingUsageEvent = {
4323
4323
  policy_id: string | null;
4324
4324
  created_at: string;
4325
4325
  };
4326
+ /** One customer-facing recent billing operation from `/api/v2/billing/usage`. */
4327
+ type BillingRecentUsageEntry = {
4328
+ id: string;
4329
+ provider: string;
4330
+ operation: string;
4331
+ status: string;
4332
+ request_id: string;
4333
+ run_id: string | null;
4334
+ /** Play execution run for this charge, when the call ran inside a Play. */
4335
+ play_run_id?: string | null;
4336
+ workflow_id?: string | null;
4337
+ billing_run_id?: string | null;
4338
+ execution_run_id?: string | null;
4339
+ included_in_run_id?: string | null;
4340
+ billing_scope?: string | null;
4341
+ step_block_id?: string | null;
4342
+ step_alias?: string | null;
4343
+ credits: number;
4344
+ billing_mode: string | null;
4345
+ pricing_model: string | null;
4346
+ outcome: string | null;
4347
+ billing_note: string | null;
4348
+ charge_state: 'posted' | 'temporary_hold' | 'hold_release' | 'pending' | 'free' | 'failed';
4349
+ rough_usd_cost: number | null;
4350
+ created_at: string;
4351
+ };
4352
+ type BillingUsageOptions = {
4353
+ /** Return the one exact call identified by `executeTool().job_id`. */
4354
+ requestId?: string;
4355
+ /** Bound the recent-call page. Ignored for an exact requestId lookup. */
4356
+ limit?: number;
4357
+ offset?: number;
4358
+ cursor?: string;
4359
+ runId?: string;
4360
+ };
4361
+ type BillingUsageResult = {
4362
+ org_id: string;
4363
+ balance?: number;
4364
+ rough_usd_balance?: number;
4365
+ plan?: {
4366
+ usd_per_credit: number;
4367
+ };
4368
+ usage?: {
4369
+ last_30_days_usage_credits: number;
4370
+ rough_usd_last_30_days_usage: number;
4371
+ temporary_hold_credits: number;
4372
+ rough_usd_temporary_holds: number;
4373
+ };
4374
+ recent: {
4375
+ run_id: string | null;
4376
+ request_id?: string;
4377
+ total: number;
4378
+ offset: number;
4379
+ limit: number;
4380
+ next_offset: number;
4381
+ next_cursor: string | null;
4382
+ has_more: boolean;
4383
+ incomplete: boolean;
4384
+ entries: BillingRecentUsageEntry[];
4385
+ };
4386
+ [key: string]: unknown;
4387
+ };
4326
4388
  /**
4327
4389
  * Public `client.billing` namespace for CLI commands and programmatic callers.
4328
- * Covers plans, subscription state, cancellation, and invoice/receipt history.
4390
+ * Covers usage, plans, subscription state, cancellation, and invoice/receipt
4391
+ * history.
4329
4392
  *
4330
4393
  * @sdkReference client 030 client.billing
4331
4394
  */
@@ -4356,6 +4419,8 @@ type BillingNamespace = {
4356
4419
  };
4357
4420
  /** Read one exact execution outcome using the request_id returned by executeTool. */
4358
4421
  usageEvent: (requestId: string) => Promise<BillingUsageEvent>;
4422
+ /** Read current billing usage, or look up one exact execution charge by request ID. */
4423
+ usage: (options?: BillingUsageOptions) => Promise<BillingUsageResult>;
4359
4424
  /** Metronome-authored target catalog and current Contract projection. */
4360
4425
  targetPlans: () => Promise<TargetBillingPlansResult>;
4361
4426
  /** Normalized target billing state. */
@@ -5433,6 +5498,13 @@ declare class DeeplineClient {
5433
5498
  * retry or idempotency token.
5434
5499
  */
5435
5500
  getBillingUsageEvent(requestId: string): Promise<BillingUsageEvent>;
5501
+ /**
5502
+ * Read workspace usage and recent customer-facing Deepline charges. Pass
5503
+ * the `job_id` from `executeTool` as `requestId` to retrieve one exact call,
5504
+ * including whether its charge is final or still a temporary hold. Exact
5505
+ * request lookups return only the `org_id` and `recent` result fields.
5506
+ */
5507
+ getBillingUsage(options?: BillingUsageOptions): Promise<BillingUsageResult>;
5436
5508
  /**
5437
5509
  * Charge the saved payment method and add Deepline credits to the active
5438
5510
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -6129,6 +6201,7 @@ type PlayMetadata<TInput = Record<string, unknown>> = {
6129
6201
  * // Tools
6130
6202
  * const tools = await deepline.tools.list();
6131
6203
  * const result = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
6204
+ * const charge = await deepline.billing.usage({ requestId: result.job_id });
6132
6205
  *
6133
6206
  * // Plays
6134
6207
  * const job = await deepline.play('email-waterfall').run({ domain: 'stripe.com' });
@@ -6139,6 +6212,8 @@ type PlayMetadata<TInput = Record<string, unknown>> = {
6139
6212
  */
6140
6213
  declare class DeeplineContext {
6141
6214
  private readonly client;
6215
+ /** Read current billing usage and exact per-request Deepline charges. */
6216
+ get billing(): BillingNamespace;
6142
6217
  /**
6143
6218
  * Create a high-level SDK context.
6144
6219
  *
@@ -6655,4 +6730,4 @@ declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem:
6655
6730
  */
6656
6731
  declare function extractSummaryFields(payload: unknown): Record<string, Scalar>;
6657
6732
 
6658
- export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, type BillingUsageEvent, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CreateNotificationGroupInput, type CreateNotificationGroupResult, type CsvInput, type CsvOptions, type CustomerDbQueryResult, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, type DatasetColumnDefinition, type DatasetColumnRunInput, type DbNamespace, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, DeeplineError, type DeeplineExecutionsNamespace, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolExecuteResult, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, type ExecutionByKeyResult, type ExecutionRecovery, type FetchOptions, type FileInput, type IngestionStorageRepairResult, type LegacyMonitorStatusFilter, type LiveEventEnvelope, MONITOR_JOB_PHASES, MONITOR_JOB_RECONCILIATION_STATES, MONITOR_JOB_STATES, type MonitorBatchNamespace, type MonitorCheckResult, type MonitorDefinition, type MonitorDeleteResult, type MonitorDependents, type MonitorDeployResult, type MonitorDetail, type MonitorFleetDeactivateOptions, MonitorFleetDefinition, type MonitorFleetGetOptions, type MonitorFleetReactivateOptions, type MonitorFleetResult, type MonitorFleetStatus, type MonitorFleetSyncOptions, type MonitorFleetWaitOptions, type MonitorFleetsNamespace, type MonitorJobDeployOptions, type MonitorJobLogsOptions, type MonitorJobPhase, type MonitorJobReconciliationState, type MonitorJobResult, type MonitorJobState, type MonitorJobWaitOptions, type MonitorJobsNamespace, type MonitorListEntry, type MonitorPayload, type MonitorReactivateResult, type MonitorSpec, type MonitorState, type MonitorStateFilter, type MonitorUpdateChangeSummary, type MonitorUpdateResult, type MonitorsAccessStatus, type MonitorsAvailableOptions, type MonitorsAvailableResult, type MonitorsListOptions, type MonitorsListResult, type MonitorsNamespace, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PlayActivityObservation, type PlayActivityState, type PlayActivityTarget, type PlayAsyncCallOptions, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayCallExecution, type PlayCallOptions, type PlayCostEstimate, type PlayFetchResponse, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayReferenceLike, type PlayRevisionSummary, type PlayRunActionPackage, type PlayRunActivityProjection, type PlayRunDatasetActions, type PlayRunId, type PlayRunPackage, type PlayRunResult, type PlayRunStart, type PlaySheetRow, type PlaySheetRowsResult, type PlayStatus, type PlayStepProgramStep, type PlaysListOptions, type PlaysListPage, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type RerunOptions, type RerunPlayRunResult, type ResolvedConfig, RunObserveTransportUnavailableError, type RunsListOptions, type RunsListPage, type RunsLogsOptions, type RunsLogsResult, type RunsNamespace, type RunsTailOptions, type RuntimeStepOptions, SDK_API_CONTRACT, SDK_VERSION, type SqlListenerDeclaration, type SqlListenerEvent, type SqlListenerOperation, type SqlQuery, type StartPlayRunRequest, type StepOptions, type StepProgram, type StepProgramResolver, type StepResolver, type StopAllCandidate, type StopAllPlayRunsDryRunResult, type StopAllPlayRunsResult, type StopAllPlayRunsStopResult, type StopAllRunsOptions, type StopPlayRunResult, type ToolDefinition, ToolExecuteResult, type ToolExecution, ToolExecutionError, ToolExecutionErrorOptions, type ToolExecutionRequest, type ToolMetadata, ToolRateLimitError, ToolResultBilling, type ToolSearchOptions, type ToolSearchResult, type WorkspaceCreateResult, type WorkspacesNamespace, defineInput, defineMonitor, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, isStopAllPlayRunsDryRunResult, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };
6733
+ export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingRecentUsageEntry, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, type BillingUsageEvent, type BillingUsageOptions, type BillingUsageResult, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CreateNotificationGroupInput, type CreateNotificationGroupResult, type CsvInput, type CsvOptions, type CustomerDbQueryResult, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, type DatasetColumnDefinition, type DatasetColumnRunInput, type DbNamespace, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, DeeplineError, type DeeplineExecutionsNamespace, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolExecuteResult, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, type ExecutionByKeyResult, type ExecutionRecovery, type FetchOptions, type FileInput, type IngestionStorageRepairResult, type LegacyMonitorStatusFilter, type LiveEventEnvelope, MONITOR_JOB_PHASES, MONITOR_JOB_RECONCILIATION_STATES, MONITOR_JOB_STATES, type MonitorBatchNamespace, type MonitorCheckResult, type MonitorDefinition, type MonitorDeleteResult, type MonitorDependents, type MonitorDeployResult, type MonitorDetail, type MonitorFleetDeactivateOptions, MonitorFleetDefinition, type MonitorFleetGetOptions, type MonitorFleetReactivateOptions, type MonitorFleetResult, type MonitorFleetStatus, type MonitorFleetSyncOptions, type MonitorFleetWaitOptions, type MonitorFleetsNamespace, type MonitorJobDeployOptions, type MonitorJobLogsOptions, type MonitorJobPhase, type MonitorJobReconciliationState, type MonitorJobResult, type MonitorJobState, type MonitorJobWaitOptions, type MonitorJobsNamespace, type MonitorListEntry, type MonitorPayload, type MonitorReactivateResult, type MonitorSpec, type MonitorState, type MonitorStateFilter, type MonitorUpdateChangeSummary, type MonitorUpdateResult, type MonitorsAccessStatus, type MonitorsAvailableOptions, type MonitorsAvailableResult, type MonitorsListOptions, type MonitorsListResult, type MonitorsNamespace, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PlayActivityObservation, type PlayActivityState, type PlayActivityTarget, type PlayAsyncCallOptions, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayCallExecution, type PlayCallOptions, type PlayCostEstimate, type PlayFetchResponse, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayReferenceLike, type PlayRevisionSummary, type PlayRunActionPackage, type PlayRunActivityProjection, type PlayRunDatasetActions, type PlayRunId, type PlayRunPackage, type PlayRunResult, type PlayRunStart, type PlaySheetRow, type PlaySheetRowsResult, type PlayStatus, type PlayStepProgramStep, type PlaysListOptions, type PlaysListPage, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type RerunOptions, type RerunPlayRunResult, type ResolvedConfig, RunObserveTransportUnavailableError, type RunsListOptions, type RunsListPage, type RunsLogsOptions, type RunsLogsResult, type RunsNamespace, type RunsTailOptions, type RuntimeStepOptions, SDK_API_CONTRACT, SDK_VERSION, type SqlListenerDeclaration, type SqlListenerEvent, type SqlListenerOperation, type SqlQuery, type StartPlayRunRequest, type StepOptions, type StepProgram, type StepProgramResolver, type StepResolver, type StopAllCandidate, type StopAllPlayRunsDryRunResult, type StopAllPlayRunsResult, type StopAllPlayRunsStopResult, type StopAllRunsOptions, type StopPlayRunResult, type ToolDefinition, ToolExecuteResult, type ToolExecution, ToolExecutionError, ToolExecutionErrorOptions, type ToolExecutionRequest, type ToolMetadata, ToolRateLimitError, ToolResultBilling, type ToolSearchOptions, type ToolSearchResult, type WorkspaceCreateResult, type WorkspacesNamespace, defineInput, defineMonitor, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, isStopAllPlayRunsDryRunResult, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };
package/dist/index.js CHANGED
@@ -864,7 +864,7 @@ var SDK_RELEASE = {
864
864
  // getters keep their established compatibility behavior.
865
865
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
866
866
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
867
- version: "0.3.162",
867
+ version: "0.3.164",
868
868
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
869
869
  packageCapabilities: {
870
870
  updatePreferences: 1
@@ -4847,6 +4847,7 @@ var DeeplineClient = class _DeeplineClient {
4847
4847
  list: (options2) => this.listBillingInvoices(options2)
4848
4848
  },
4849
4849
  usageEvent: (requestId) => this.getBillingUsageEvent(requestId),
4850
+ usage: (options2) => this.getBillingUsage(options2),
4850
4851
  targetPlans: () => this.getTargetBillingPlans(),
4851
4852
  targetStatus: () => this.getTargetBillingStatus(),
4852
4853
  autoRecharge: {
@@ -7401,6 +7402,49 @@ var DeeplineClient = class _DeeplineClient {
7401
7402
  }
7402
7403
  return event;
7403
7404
  }
7405
+ /**
7406
+ * Read workspace usage and recent customer-facing Deepline charges. Pass
7407
+ * the `job_id` from `executeTool` as `requestId` to retrieve one exact call,
7408
+ * including whether its charge is final or still a temporary hold. Exact
7409
+ * request lookups return only the `org_id` and `recent` result fields.
7410
+ */
7411
+ async getBillingUsage(options = {}) {
7412
+ const params = new URLSearchParams();
7413
+ if (options.requestId !== void 0) {
7414
+ const requestId = options.requestId.trim();
7415
+ if (requestId.length === 0 || requestId.length > 200 || requestId !== options.requestId) {
7416
+ throw new DeeplineError(
7417
+ "Usage request_id must contain 1\u2013200 characters with no leading or trailing whitespace.",
7418
+ void 0,
7419
+ "INVALID_USAGE_REQUEST_ID"
7420
+ );
7421
+ }
7422
+ if (options.runId !== void 0 || options.cursor !== void 0 || options.offset !== void 0) {
7423
+ throw new DeeplineError(
7424
+ "requestId cannot be combined with runId, cursor, or offset.",
7425
+ void 0,
7426
+ "INVALID_USAGE_FILTERS"
7427
+ );
7428
+ }
7429
+ params.set("request_id", requestId);
7430
+ } else {
7431
+ if (options.limit !== void 0) {
7432
+ params.set("recent_limit", String(options.limit));
7433
+ }
7434
+ if (options.offset !== void 0) {
7435
+ params.set("recent_offset", String(options.offset));
7436
+ }
7437
+ if (options.cursor !== void 0) {
7438
+ params.set("recent_cursor", options.cursor);
7439
+ }
7440
+ if (options.runId !== void 0) {
7441
+ params.set("run_id", options.runId);
7442
+ }
7443
+ }
7444
+ const serializedParams = params.toString();
7445
+ const query = serializedParams ? `?${serializedParams}` : "";
7446
+ return this.http.get(`/api/v2/billing/usage${query}`);
7447
+ }
7404
7448
  /**
7405
7449
  * Charge the saved payment method and add Deepline credits to the active
7406
7450
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -11465,6 +11509,10 @@ function createNamedPlayHandle(clientFactory, name) {
11465
11509
  }
11466
11510
  var DeeplineContext = class {
11467
11511
  client;
11512
+ /** Read current billing usage and exact per-request Deepline charges. */
11513
+ get billing() {
11514
+ return this.client.billing;
11515
+ }
11468
11516
  /**
11469
11517
  * Create a high-level SDK context.
11470
11518
  *
package/dist/index.mjs CHANGED
@@ -768,7 +768,7 @@ var SDK_RELEASE = {
768
768
  // getters keep their established compatibility behavior.
769
769
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
770
770
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
771
- version: "0.3.162",
771
+ version: "0.3.164",
772
772
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
773
773
  packageCapabilities: {
774
774
  updatePreferences: 1
@@ -4751,6 +4751,7 @@ var DeeplineClient = class _DeeplineClient {
4751
4751
  list: (options2) => this.listBillingInvoices(options2)
4752
4752
  },
4753
4753
  usageEvent: (requestId) => this.getBillingUsageEvent(requestId),
4754
+ usage: (options2) => this.getBillingUsage(options2),
4754
4755
  targetPlans: () => this.getTargetBillingPlans(),
4755
4756
  targetStatus: () => this.getTargetBillingStatus(),
4756
4757
  autoRecharge: {
@@ -7305,6 +7306,49 @@ var DeeplineClient = class _DeeplineClient {
7305
7306
  }
7306
7307
  return event;
7307
7308
  }
7309
+ /**
7310
+ * Read workspace usage and recent customer-facing Deepline charges. Pass
7311
+ * the `job_id` from `executeTool` as `requestId` to retrieve one exact call,
7312
+ * including whether its charge is final or still a temporary hold. Exact
7313
+ * request lookups return only the `org_id` and `recent` result fields.
7314
+ */
7315
+ async getBillingUsage(options = {}) {
7316
+ const params = new URLSearchParams();
7317
+ if (options.requestId !== void 0) {
7318
+ const requestId = options.requestId.trim();
7319
+ if (requestId.length === 0 || requestId.length > 200 || requestId !== options.requestId) {
7320
+ throw new DeeplineError(
7321
+ "Usage request_id must contain 1\u2013200 characters with no leading or trailing whitespace.",
7322
+ void 0,
7323
+ "INVALID_USAGE_REQUEST_ID"
7324
+ );
7325
+ }
7326
+ if (options.runId !== void 0 || options.cursor !== void 0 || options.offset !== void 0) {
7327
+ throw new DeeplineError(
7328
+ "requestId cannot be combined with runId, cursor, or offset.",
7329
+ void 0,
7330
+ "INVALID_USAGE_FILTERS"
7331
+ );
7332
+ }
7333
+ params.set("request_id", requestId);
7334
+ } else {
7335
+ if (options.limit !== void 0) {
7336
+ params.set("recent_limit", String(options.limit));
7337
+ }
7338
+ if (options.offset !== void 0) {
7339
+ params.set("recent_offset", String(options.offset));
7340
+ }
7341
+ if (options.cursor !== void 0) {
7342
+ params.set("recent_cursor", options.cursor);
7343
+ }
7344
+ if (options.runId !== void 0) {
7345
+ params.set("run_id", options.runId);
7346
+ }
7347
+ }
7348
+ const serializedParams = params.toString();
7349
+ const query = serializedParams ? `?${serializedParams}` : "";
7350
+ return this.http.get(`/api/v2/billing/usage${query}`);
7351
+ }
7308
7352
  /**
7309
7353
  * Charge the saved payment method and add Deepline credits to the active
7310
7354
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -11369,6 +11413,10 @@ function createNamedPlayHandle(clientFactory, name) {
11369
11413
  }
11370
11414
  var DeeplineContext = class {
11371
11415
  client;
11416
+ /** Read current billing usage and exact per-request Deepline charges. */
11417
+ get billing() {
11418
+ return this.client.billing;
11419
+ }
11372
11420
  /**
11373
11421
  * Create a high-level SDK context.
11374
11422
  *
@@ -101,6 +101,7 @@
101
101
  "dist/bundling-sources/shared_libs/observability/runtime-console.ts",
102
102
  "dist/bundling-sources/shared_libs/observability/scheduled-job-errors.ts",
103
103
  "dist/bundling-sources/shared_libs/observability/scheduled-jobs.json",
104
+ "dist/bundling-sources/shared_libs/observability/scheduled-work-control.ts",
104
105
  "dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts",
105
106
  "dist/bundling-sources/shared_libs/observability/scheduled-work-v2.ts",
106
107
  "dist/bundling-sources/shared_libs/observability/scheduled-work.ts",
@@ -149,7 +149,7 @@ type SdkRelease = {
149
149
  supportPolicy: SdkSupportPolicy;
150
150
  };
151
151
  declare const SDK_RELEASE: {
152
- readonly version: "0.3.162";
152
+ readonly version: "0.3.164";
153
153
  readonly updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.";
154
154
  readonly packageCapabilities: {
155
155
  readonly updatePreferences: 1;
package/dist/release.d.ts CHANGED
@@ -149,7 +149,7 @@ type SdkRelease = {
149
149
  supportPolicy: SdkSupportPolicy;
150
150
  };
151
151
  declare const SDK_RELEASE: {
152
- readonly version: "0.3.162";
152
+ readonly version: "0.3.164";
153
153
  readonly updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.";
154
154
  readonly packageCapabilities: {
155
155
  readonly updatePreferences: 1;
package/dist/release.js CHANGED
@@ -74,7 +74,7 @@ var SDK_RELEASE = {
74
74
  // getters keep their established compatibility behavior.
75
75
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
76
76
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
77
- version: "0.3.162",
77
+ version: "0.3.164",
78
78
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
79
79
  packageCapabilities: {
80
80
  updatePreferences: 1
package/dist/release.mjs CHANGED
@@ -48,7 +48,7 @@ var SDK_RELEASE = {
48
48
  // getters keep their established compatibility behavior.
49
49
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
50
50
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
51
- version: "0.3.162",
51
+ version: "0.3.164",
52
52
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
53
53
  packageCapabilities: {
54
54
  updatePreferences: 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.3.162",
3
+ "version": "0.3.164",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",