deepline 0.3.143 → 0.3.145

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.
@@ -3063,7 +3063,7 @@ var SDK_RELEASE = {
3063
3063
  // getters keep their established compatibility behavior.
3064
3064
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3065
3065
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3066
- version: "0.3.143",
3066
+ version: "0.3.145",
3067
3067
  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.",
3068
3068
  packageCapabilities: {
3069
3069
  updatePreferences: 1
@@ -7095,6 +7095,7 @@ var DeeplineClient = class _DeeplineClient {
7095
7095
  invoices: {
7096
7096
  list: (options2) => this.listBillingInvoices(options2)
7097
7097
  },
7098
+ usageEvent: (requestId) => this.getBillingUsageEvent(requestId),
7098
7099
  targetPlans: () => this.getTargetBillingPlans(),
7099
7100
  targetStatus: () => this.getTargetBillingStatus(),
7100
7101
  autoRecharge: {
@@ -9466,6 +9467,33 @@ var DeeplineClient = class _DeeplineClient {
9466
9467
  async getBillingPlans() {
9467
9468
  return this.http.get("/api/v2/billing/catalog/current");
9468
9469
  }
9470
+ /**
9471
+ * Read the authenticated usage record for one execution request. The
9472
+ * request id comes from the original `executeTool` result and is not a
9473
+ * retry or idempotency token.
9474
+ */
9475
+ async getBillingUsageEvent(requestId) {
9476
+ const normalizedRequestId = requestId.trim();
9477
+ if (normalizedRequestId.length === 0 || normalizedRequestId.length > 200 || normalizedRequestId !== requestId) {
9478
+ throw new DeeplineError(
9479
+ "Usage request_id must contain 1\u2013200 characters with no leading or trailing whitespace.",
9480
+ void 0,
9481
+ "INVALID_USAGE_REQUEST_ID"
9482
+ );
9483
+ }
9484
+ const response = await this.http.get(
9485
+ `/api/v2/usage/events?request_id=${encodeURIComponent(normalizedRequestId)}`
9486
+ );
9487
+ const event = response.entries?.[0];
9488
+ if (!event) {
9489
+ throw new DeeplineError(
9490
+ "No usage event was found for this request_id.",
9491
+ void 0,
9492
+ "USAGE_EVENT_NOT_FOUND"
9493
+ );
9494
+ }
9495
+ return event;
9496
+ }
9469
9497
  /**
9470
9498
  * Charge the saved payment method and add Deepline credits to the active
9471
9499
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -48103,6 +48131,7 @@ Notes:
48103
48131
  Examples:
48104
48132
  deepline tools execute hunter_email_verifier --input '{"email":"a@b.com"}'
48105
48133
  deepline tools execute hunter_email_verifier -p email=a@b.com
48134
+ deepline tools execute test_rate_limit --input '{"key":"smoke"}' --timeout 90s --json
48106
48135
  deepline tools execute test_rate_limit --input '{"key":"smoke"}' --json | jq '.status'
48107
48136
  deepline tools execute free_simple_company_search --input '{"sql":"SELECT company_name FROM companies LIMIT 10"}' --out companies.csv
48108
48137
  `
@@ -48123,6 +48152,9 @@ Examples:
48123
48152
  ).option(
48124
48153
  "--payload <payload>",
48125
48154
  "Merge a JSON object or @file path into the tool params"
48155
+ ).option(
48156
+ "--timeout <duration>",
48157
+ "Execution HTTP deadline (for example 90s, 5m, or 1h; bare numbers are seconds)"
48126
48158
  ).option(
48127
48159
  "--output-format <format>",
48128
48160
  "Output format: auto, csv, csv_file, json, or json_file"
@@ -48137,6 +48169,7 @@ Examples:
48137
48169
  ...typeof options.json === "string" ? ["--json", options.json] : [],
48138
48170
  ...options.input ? ["--input", options.input] : [],
48139
48171
  ...options.payload ? ["--payload", options.payload] : [],
48172
+ ...options.timeout ? ["--timeout", options.timeout] : [],
48140
48173
  ...options.outputFormat ? ["--output-format", options.outputFormat] : [],
48141
48174
  ...options.out ? ["--out", options.out] : [],
48142
48175
  ...options.preview === false ? ["--no-preview"] : []
@@ -48889,8 +48922,10 @@ function toolInputFieldsForDisplay(inputSchema) {
48889
48922
  const jsonSchemaField = typeof field.name === "string" ? jsonSchemaFields.get(field.name) : void 0;
48890
48923
  const minItems = typeof field.minItems === "number" ? field.minItems : jsonSchemaField?.minItems;
48891
48924
  const maxItems = typeof field.maxItems === "number" ? field.maxItems : jsonSchemaField?.maxItems;
48925
+ const items = isRecord12(field.items) ? field.items : jsonSchemaField?.items;
48892
48926
  return {
48893
48927
  ...field,
48928
+ ...isRecord12(items) ? { items } : {},
48894
48929
  ...typeof minItems === "number" ? { minItems } : {},
48895
48930
  ...typeof maxItems === "number" ? { maxItems } : {}
48896
48931
  };
@@ -48906,6 +48941,7 @@ function toolInputFieldsForDisplay(inputSchema) {
48906
48941
  type: typeof property.type === "string" ? property.type : "unknown",
48907
48942
  required: required.has(name),
48908
48943
  description: property.description,
48944
+ ...isRecord12(property.items) ? { items: property.items } : {},
48909
48945
  ...typeof property.minItems === "number" ? { minItems: property.minItems } : {},
48910
48946
  ...typeof property.maxItems === "number" ? { maxItems: property.maxItems } : {},
48911
48947
  ...Object.prototype.hasOwnProperty.call(property, "default") ? { default: property.default } : {}
@@ -49025,6 +49061,7 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
49025
49061
  required,
49026
49062
  description: schema.description,
49027
49063
  ...Array.isArray(schema.enum) ? { enum: schema.enum } : {},
49064
+ ...isRecord12(schema.items) ? { items: schema.items } : {},
49028
49065
  ...typeof schema.minItems === "number" ? { minItems: schema.minItems } : {},
49029
49066
  ...typeof schema.maxItems === "number" ? { maxItems: schema.maxItems } : {},
49030
49067
  ...Object.prototype.hasOwnProperty.call(schema, "default") ? { default: schema.default } : {}
@@ -49059,25 +49096,31 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
49059
49096
  return fields.size ? [...fields.values()] : toolInputFieldsForDisplay(inputSchema);
49060
49097
  }
49061
49098
  function inputFieldJsonForDescribe(field) {
49099
+ const publicItems = isRecord12(field.items) ? publicToolInputSchemaForDescribe({ items: field.items }).items : void 0;
49062
49100
  return {
49063
49101
  name: field.name,
49064
49102
  type: field.type ?? "unknown",
49065
49103
  required: Boolean(field.required),
49066
49104
  ...field.description ? { description: field.description } : {},
49105
+ ...isRecord12(publicItems) ? { items: publicItems } : {},
49067
49106
  ...typeof field.minItems === "number" ? { minItems: field.minItems } : {},
49068
49107
  ...typeof field.maxItems === "number" ? { maxItems: field.maxItems } : {},
49069
49108
  ...Object.prototype.hasOwnProperty.call(field, "default") ? { default: field.default } : {}
49070
49109
  };
49071
49110
  }
49072
49111
  function arrayItemBoundsSuffix(field) {
49112
+ const itemSchema = isRecord12(field.items) ? field.items : null;
49113
+ const itemType = itemSchema ? typeof itemSchema.type === "string" ? itemSchema.type : isRecord12(itemSchema.properties) ? "object" : "unknown" : null;
49114
+ const itemEnum = Array.isArray(itemSchema?.enum) ? ` enum=${itemSchema.enum.map(String).join("|")}` : "";
49115
+ const itemTypeSuffix = itemType && itemType !== "unknown" ? ` items=${itemType}${itemEnum}` : "";
49073
49116
  const minItems = typeof field.minItems === "number" && Number.isFinite(field.minItems) ? field.minItems : null;
49074
49117
  const maxItems = typeof field.maxItems === "number" && Number.isFinite(field.maxItems) ? field.maxItems : null;
49075
49118
  if (minItems !== null && maxItems !== null) {
49076
- return ` items=${minItems}..${maxItems}`;
49119
+ return itemTypeSuffix ? `${itemTypeSuffix} minItems=${minItems} maxItems=${maxItems}` : ` items=${minItems}..${maxItems}`;
49077
49120
  }
49078
- if (minItems !== null) return ` minItems=${minItems}`;
49079
- if (maxItems !== null) return ` maxItems=${maxItems}`;
49080
- return "";
49121
+ if (minItems !== null) return `${itemTypeSuffix} minItems=${minItems}`;
49122
+ if (maxItems !== null) return `${itemTypeSuffix} maxItems=${maxItems}`;
49123
+ return itemTypeSuffix;
49081
49124
  }
49082
49125
  function printToolExecutionHints(value) {
49083
49126
  const batchCapabilityRecord = recordField2(
@@ -49366,13 +49409,14 @@ function parseExecuteOptions(args) {
49366
49409
  const toolId = args[0];
49367
49410
  if (!toolId) {
49368
49411
  throw new Error(
49369
- `Usage: deepline tools execute <toolId> [--param key=value ...] [--input '{"k":"v"}'] [--out rows.csv] [--output-format auto|csv|csv_file|json|json_file] [--no-preview]`
49412
+ `Usage: deepline tools execute <toolId> [--param key=value ...] [--input '{"k":"v"}'] [--timeout <duration>] [--out rows.csv] [--output-format auto|csv|csv_file|json|json_file] [--no-preview]`
49370
49413
  );
49371
49414
  }
49372
49415
  const params = {};
49373
49416
  let outputFormat = "auto";
49374
49417
  let noPreview = false;
49375
49418
  let outPath = null;
49419
+ let timeoutMs;
49376
49420
  for (let index = 1; index < args.length; index += 1) {
49377
49421
  const arg = args[index];
49378
49422
  if ((arg === "--param" || arg === "-p") && args[index + 1]) {
@@ -49396,6 +49440,10 @@ function parseExecuteOptions(args) {
49396
49440
  Object.assign(params, parseJsonObjectArgument(args[++index], arg));
49397
49441
  continue;
49398
49442
  }
49443
+ if (arg === "--timeout" && args[index + 1]) {
49444
+ timeoutMs = parseToolExecuteTimeout(args[++index]);
49445
+ continue;
49446
+ }
49399
49447
  if (arg === "--output-format" && args[index + 1]) {
49400
49448
  outputFormat = normalizeOutputFormat(args[++index]);
49401
49449
  continue;
@@ -49410,7 +49458,25 @@ function parseExecuteOptions(args) {
49410
49458
  }
49411
49459
  throw new Error(`Unknown option: ${arg}`);
49412
49460
  }
49413
- return { toolId, params, outputFormat, noPreview, outPath };
49461
+ return { toolId, params, outputFormat, noPreview, outPath, timeoutMs };
49462
+ }
49463
+ function parseToolExecuteTimeout(raw) {
49464
+ const match = /^(\d+)(ms|s|m|h)?$/i.exec(raw.trim());
49465
+ if (!match) {
49466
+ throw new Error(
49467
+ "--timeout must be a duration like 500ms, 90s, 10m, or 1h (a bare number is seconds)."
49468
+ );
49469
+ }
49470
+ const value = Number(match[1]);
49471
+ const unit = (match[2] ?? "s").toLowerCase();
49472
+ const factor = unit === "ms" ? 1 : unit === "s" ? 1e3 : unit === "m" ? 6e4 : 36e5;
49473
+ const timeoutMs = value * factor;
49474
+ if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2147483647) {
49475
+ throw new Error(
49476
+ "--timeout must be between 1ms and 2147483647ms (24d 20h 31m 23s)."
49477
+ );
49478
+ }
49479
+ return timeoutMs;
49414
49480
  }
49415
49481
  function safeFileStem(value) {
49416
49482
  return value.trim().replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "tool";
@@ -49713,7 +49779,8 @@ async function executeTool(args) {
49713
49779
  return 2;
49714
49780
  }
49715
49781
  const rawResponse = await client2.executeTool(parsed.toolId, parsed.params, {
49716
- responseIntent: parsed.outPath || parsed.outputFormat === "csv" || parsed.outputFormat === "csv_file" ? "row_artifact" : "raw"
49782
+ responseIntent: parsed.outPath || parsed.outputFormat === "csv" || parsed.outputFormat === "csv_file" ? "row_artifact" : "raw",
49783
+ ...parsed.timeoutMs !== void 0 ? { timeout: parsed.timeoutMs } : {}
49717
49784
  });
49718
49785
  const listConversion = tryConvertToList(rawResponse, {
49719
49786
  listExtractorPaths: listExtractorPathsFromUsageGuidance(metadata)
@@ -334,7 +334,8 @@ type ToolResultBilling = {
334
334
  cost_usd?: number;
335
335
  /** Missing on historical responses. Pending pricing has no final amount. */
336
336
  pricing_status?: 'final' | 'pending';
337
- settlement_status?: 'pending' | 'queued' | 'settled' | 'requires_recovery';
337
+ settlement_status?: 'pending' | 'queued' | 'settled' | 'released' | 'requires_recovery';
338
+ billing_outcome_reason?: 'free_operation' | 'provider_no_billable_result' | 'provider_reported_zero_usage' | 'zero_price';
338
339
  estimated_credits?: number;
339
340
  estimated_cost_usd?: number;
340
341
  /** Preserve additive public pricing details across runtime/deployment skew. */
@@ -334,7 +334,8 @@ type ToolResultBilling = {
334
334
  cost_usd?: number;
335
335
  /** Missing on historical responses. Pending pricing has no final amount. */
336
336
  pricing_status?: 'final' | 'pending';
337
- settlement_status?: 'pending' | 'queued' | 'settled' | 'requires_recovery';
337
+ settlement_status?: 'pending' | 'queued' | 'settled' | 'released' | 'requires_recovery';
338
+ billing_outcome_reason?: 'free_operation' | 'provider_no_billable_result' | 'provider_reported_zero_usage' | 'zero_price';
338
339
  estimated_credits?: number;
339
340
  estimated_cost_usd?: number;
340
341
  /** Preserve additive public pricing details across runtime/deployment skew. */
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./text-imports.d.ts" />
2
- import { c as PlayCompilerManifest, T as ToolResultBilling, A as AsyncPlayRunRef$1, i as PlayAuthoringColumnMap, j as PlayAuthoringColumnResolver, k as PlayAuthoringRuntimeContext, l as PlayAuthoringConditionalStepResolver, m as PlayAuthoringCsvInput, n as PlayAuthoringCsvOptions, o as PlayAuthoringDatasetBuilder, p as PlayAuthoringDatasetColumnDefinition, q as PlayAuthoringDatasetColumnRunInput, r as ToolExecuteResult, s as PlayAuthoringReferenceLike, t as PlayReturnObject$1, u as PlayAuthoringDefineConfig, v as PlayAuthoringDefinedPlay, w as PlayAuthoringFetchOptions, x as PlayAuthoringFileInput, y as PlayAuthoringAsyncCallOptions, z as PlayAuthoringBindings, B as PlayAuthoringCallExecution, C as PlayAuthoringCallOptions, D as PlayAuthoringFetchResponse, E as PlayAuthoringInputContract, F as PlayRunId$1, G as PlayAuthoringStepProgramStep, H as PlayAuthoringRuntimeStepOptions, I as PlaySqlListenerDeclaration, J as PlaySqlListenerEvent, K as PlaySqlListenerOperation, L as PlaySqlQuery, M as PlayAuthoringStepOptions, N as PlayAuthoringStepProgram, O as PlayAuthoringStepProgramResolver, Q as PlayAuthoringStepResolver, R as PlayToolExecutionRequest, S as PlayAuthoringStepProgramOptions, U as DeeplineError, V as ToolExecutionError, W as ToolExecutionErrorOptions } from './compiler-manifest-BIqRyj5m.mjs';
3
- export { X as CtxFetchHttpError, Y as DEEPLINE_EXTRACTOR_TARGETS, Z as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, _ as DeeplineEmailStatusGetterValue, $ as DeeplineExtractorTarget, a0 as DeeplineGetterValue, a1 as DeeplineGetterValueMap, a2 as JOB_CHANGE_STATUS_VALUES, a3 as JobChangeStatus, a4 as PHONE_STATUS_VALUES, a5 as PhoneStatus, a6 as PlayDataset, a7 as PlayDatasetInput, a8 as PreviousCell, a9 as ProviderTransientError, aa as ProviderTransientErrorCategory, ab as ProviderUnavailableError, ac as ProviderUnavailableReason, ad as ToolExecutionErrorCategory, ae as ToolExecutionErrorOrigin, af as ToolExecutionFailureV1, ag as ToolExecutionNetworkKind, ah as ToolExecutionNetworkScope, ai as ToolExecutionPublicDetails, aj as getProviderUnavailableReason, ak as isDeeplineExtractorTarget, al as isProviderUnavailable, am as isProviderWaterfallUnavailableError } from './compiler-manifest-BIqRyj5m.mjs';
2
+ import { c as PlayCompilerManifest, T as ToolResultBilling, A as AsyncPlayRunRef$1, i as PlayAuthoringColumnMap, j as PlayAuthoringColumnResolver, k as PlayAuthoringRuntimeContext, l as PlayAuthoringConditionalStepResolver, m as PlayAuthoringCsvInput, n as PlayAuthoringCsvOptions, o as PlayAuthoringDatasetBuilder, p as PlayAuthoringDatasetColumnDefinition, q as PlayAuthoringDatasetColumnRunInput, r as ToolExecuteResult, s as PlayAuthoringReferenceLike, t as PlayReturnObject$1, u as PlayAuthoringDefineConfig, v as PlayAuthoringDefinedPlay, w as PlayAuthoringFetchOptions, x as PlayAuthoringFileInput, y as PlayAuthoringAsyncCallOptions, z as PlayAuthoringBindings, B as PlayAuthoringCallExecution, C as PlayAuthoringCallOptions, D as PlayAuthoringFetchResponse, E as PlayAuthoringInputContract, F as PlayRunId$1, G as PlayAuthoringStepProgramStep, H as PlayAuthoringRuntimeStepOptions, I as PlaySqlListenerDeclaration, J as PlaySqlListenerEvent, K as PlaySqlListenerOperation, L as PlaySqlQuery, M as PlayAuthoringStepOptions, N as PlayAuthoringStepProgram, O as PlayAuthoringStepProgramResolver, Q as PlayAuthoringStepResolver, R as PlayToolExecutionRequest, S as PlayAuthoringStepProgramOptions, U as DeeplineError, V as ToolExecutionError, W as ToolExecutionErrorOptions } from './compiler-manifest-BJBNPTWt.mjs';
3
+ export { X as CtxFetchHttpError, Y as DEEPLINE_EXTRACTOR_TARGETS, Z as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, _ as DeeplineEmailStatusGetterValue, $ as DeeplineExtractorTarget, a0 as DeeplineGetterValue, a1 as DeeplineGetterValueMap, a2 as JOB_CHANGE_STATUS_VALUES, a3 as JobChangeStatus, a4 as PHONE_STATUS_VALUES, a5 as PhoneStatus, a6 as PlayDataset, a7 as PlayDatasetInput, a8 as PreviousCell, a9 as ProviderTransientError, aa as ProviderTransientErrorCategory, ab as ProviderUnavailableError, ac as ProviderUnavailableReason, ad as ToolExecutionErrorCategory, ae as ToolExecutionErrorOrigin, af as ToolExecutionFailureV1, ag as ToolExecutionNetworkKind, ah as ToolExecutionNetworkScope, ai as ToolExecutionPublicDetails, aj as getProviderUnavailableReason, ak as isDeeplineExtractorTarget, al as isProviderUnavailable, am as isProviderWaterfallUnavailableError } from './compiler-manifest-BJBNPTWt.mjs';
4
4
  import { MonitorFleetDefinition } from './monitor-fleet-contract.mjs';
5
5
  export { AdmittedMonitorFleetAuthoringContract, MONITOR_FLEET_AUTHORING_CONTRACT_CHANGELOG, MONITOR_FLEET_AUTHORING_CONTRACT_EDITION, MONITOR_FLEET_DOCUMENTATION, MONITOR_FLEET_FRONTIER_MAX_ROWS, MONITOR_FLEET_MAX_MEMBERS, MonitorFleetAuthoringContractEdition, MonitorFleetAuthoringContractResult, MonitorFleetColumn, MonitorFleetContractIssue, MonitorFleetExpression, MonitorFleetTemplate, admitMonitorFleetAuthoringContract, defineMonitorFleet, fleetColumn, fleetKey, lintMonitorFleetInput, validateMonitorFleetDefinition } from './monitor-fleet-contract.mjs';
6
6
  export { BatchMonitorInput, MonitorInputIssue, MonitorSpec as MonitorInputSpec, lintMonitorBatchInput, lintMonitorSpecTemplate, renderMonitorSpecTemplate } from './monitor-input-contract.mjs';
@@ -770,45 +770,14 @@ declare const PRODUCT_NOTIFICATION_TYPE_REGISTRY: readonly [{
770
770
  readonly eventName: "credits.purchase.completed";
771
771
  readonly requiredFilter: {};
772
772
  readonly allowedTriggers: ["threshold_crossing"];
773
- readonly catalog: {
774
- readonly name: "Credit purchase thank-you";
775
- readonly category: "credits";
776
- readonly description: "Thank the workspace when a credit purchase of at least the chosen size completes.";
777
- readonly allowMultiple: false;
778
- readonly editor: {
779
- readonly kind: "threshold";
780
- readonly label: "Minimum credits";
781
- readonly defaultThreshold: 500;
782
- readonly minimum: 0;
783
- readonly suffix: "credits";
784
- };
785
- };
773
+ readonly catalog: undefined;
774
+ readonly shadow: true;
786
775
  readonly rule: {
787
776
  readonly default: {
788
777
  readonly ruleKey: "default.credits_purchased";
789
- readonly groupKey: "default";
778
+ readonly groupKey: "shadow";
790
779
  };
791
- readonly create: (input: ProductNotificationRuleInput, base: ProductNotificationRuleBase, editor: {
792
- kind: "threshold";
793
- label: string;
794
- defaultThreshold: number;
795
- minimum: number;
796
- maximum?: number;
797
- suffix?: string;
798
- /**
799
- * When set, editors show and accept `remainingOf - threshold` (for
800
- * example percent remaining) while the stored trigger stays in the
801
- * runtime's "used" terms. Bounds and defaults are stored values.
802
- */
803
- remainingOf?: number;
804
- } | {
805
- kind: "play_failure";
806
- defaultFailureCount: number;
807
- } | {
808
- kind: "play_scope";
809
- } | {
810
- kind: "none";
811
- }) => {
780
+ readonly create: (input: ProductNotificationRuleInput, base: ProductNotificationRuleBase) => {
812
781
  repeatMode: "every_match";
813
782
  trigger: {
814
783
  kind: "threshold_crossing";
@@ -859,19 +828,12 @@ declare const PRODUCT_NOTIFICATION_TYPE_REGISTRY: readonly [{
859
828
  readonly eventName: "billing.plan.purchased";
860
829
  readonly requiredFilter: {};
861
830
  readonly allowedTriggers: ["each_match"];
862
- readonly catalog: {
863
- readonly name: "Plan welcome";
864
- readonly category: "credits";
865
- readonly description: "Thank the workspace when it purchases a plan.";
866
- readonly allowMultiple: false;
867
- readonly editor: {
868
- readonly kind: "none";
869
- };
870
- };
831
+ readonly catalog: undefined;
832
+ readonly shadow: true;
871
833
  readonly rule: {
872
834
  readonly default: {
873
835
  readonly ruleKey: "default.plan_purchased";
874
- readonly groupKey: "default";
836
+ readonly groupKey: "shadow";
875
837
  };
876
838
  readonly create: (_input: ProductNotificationRuleInput, base: ProductNotificationRuleBase) => {
877
839
  repeatMode: "every_match";
@@ -4311,6 +4273,20 @@ type WorkspacesNamespace = {
4311
4273
  idempotencyKey: string;
4312
4274
  }) => Promise<WorkspaceCreateResult>;
4313
4275
  };
4276
+ /** One authenticated per-request usage event from `/api/v2/usage/events`. */
4277
+ type BillingUsageEvent = {
4278
+ id: string | null;
4279
+ provider: string;
4280
+ operation: string;
4281
+ status: string;
4282
+ request_id: string;
4283
+ billing_outcome_reason: string | null;
4284
+ credits: number | null;
4285
+ billing_mode: string | null;
4286
+ pricing_model: string | null;
4287
+ policy_id: string | null;
4288
+ created_at: string;
4289
+ };
4314
4290
  /**
4315
4291
  * Public `client.billing` namespace for CLI commands and programmatic callers.
4316
4292
  * Covers plans, subscription state, cancellation, and invoice/receipt history.
@@ -4342,6 +4318,8 @@ type BillingNamespace = {
4342
4318
  limit?: number;
4343
4319
  }) => Promise<BillingInvoicesResult>;
4344
4320
  };
4321
+ /** Read one exact execution outcome using the request_id returned by executeTool. */
4322
+ usageEvent: (requestId: string) => Promise<BillingUsageEvent>;
4345
4323
  /** Metronome-authored target catalog and current Contract projection. */
4346
4324
  targetPlans: () => Promise<TargetBillingPlansResult>;
4347
4325
  /** Normalized target billing state. */
@@ -5406,6 +5384,12 @@ declare class DeeplineClient {
5406
5384
  * @returns Snake_case catalog from `GET /api/v2/billing/catalog/current`
5407
5385
  */
5408
5386
  getBillingPlans(): Promise<BillingPlansResult>;
5387
+ /**
5388
+ * Read the authenticated usage record for one execution request. The
5389
+ * request id comes from the original `executeTool` result and is not a
5390
+ * retry or idempotency token.
5391
+ */
5392
+ getBillingUsageEvent(requestId: string): Promise<BillingUsageEvent>;
5409
5393
  /**
5410
5394
  * Charge the saved payment method and add Deepline credits to the active
5411
5395
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -6608,4 +6592,4 @@ declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem:
6608
6592
  */
6609
6593
  declare function extractSummaryFields(payload: unknown): Record<string, Scalar>;
6610
6594
 
6611
- export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, 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 DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, 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 };
6595
+ 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 DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, 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
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./text-imports.d.ts" />
2
- import { c as PlayCompilerManifest, T as ToolResultBilling, A as AsyncPlayRunRef$1, i as PlayAuthoringColumnMap, j as PlayAuthoringColumnResolver, k as PlayAuthoringRuntimeContext, l as PlayAuthoringConditionalStepResolver, m as PlayAuthoringCsvInput, n as PlayAuthoringCsvOptions, o as PlayAuthoringDatasetBuilder, p as PlayAuthoringDatasetColumnDefinition, q as PlayAuthoringDatasetColumnRunInput, r as ToolExecuteResult, s as PlayAuthoringReferenceLike, t as PlayReturnObject$1, u as PlayAuthoringDefineConfig, v as PlayAuthoringDefinedPlay, w as PlayAuthoringFetchOptions, x as PlayAuthoringFileInput, y as PlayAuthoringAsyncCallOptions, z as PlayAuthoringBindings, B as PlayAuthoringCallExecution, C as PlayAuthoringCallOptions, D as PlayAuthoringFetchResponse, E as PlayAuthoringInputContract, F as PlayRunId$1, G as PlayAuthoringStepProgramStep, H as PlayAuthoringRuntimeStepOptions, I as PlaySqlListenerDeclaration, J as PlaySqlListenerEvent, K as PlaySqlListenerOperation, L as PlaySqlQuery, M as PlayAuthoringStepOptions, N as PlayAuthoringStepProgram, O as PlayAuthoringStepProgramResolver, Q as PlayAuthoringStepResolver, R as PlayToolExecutionRequest, S as PlayAuthoringStepProgramOptions, U as DeeplineError, V as ToolExecutionError, W as ToolExecutionErrorOptions } from './compiler-manifest-BIqRyj5m.js';
3
- export { X as CtxFetchHttpError, Y as DEEPLINE_EXTRACTOR_TARGETS, Z as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, _ as DeeplineEmailStatusGetterValue, $ as DeeplineExtractorTarget, a0 as DeeplineGetterValue, a1 as DeeplineGetterValueMap, a2 as JOB_CHANGE_STATUS_VALUES, a3 as JobChangeStatus, a4 as PHONE_STATUS_VALUES, a5 as PhoneStatus, a6 as PlayDataset, a7 as PlayDatasetInput, a8 as PreviousCell, a9 as ProviderTransientError, aa as ProviderTransientErrorCategory, ab as ProviderUnavailableError, ac as ProviderUnavailableReason, ad as ToolExecutionErrorCategory, ae as ToolExecutionErrorOrigin, af as ToolExecutionFailureV1, ag as ToolExecutionNetworkKind, ah as ToolExecutionNetworkScope, ai as ToolExecutionPublicDetails, aj as getProviderUnavailableReason, ak as isDeeplineExtractorTarget, al as isProviderUnavailable, am as isProviderWaterfallUnavailableError } from './compiler-manifest-BIqRyj5m.js';
2
+ import { c as PlayCompilerManifest, T as ToolResultBilling, A as AsyncPlayRunRef$1, i as PlayAuthoringColumnMap, j as PlayAuthoringColumnResolver, k as PlayAuthoringRuntimeContext, l as PlayAuthoringConditionalStepResolver, m as PlayAuthoringCsvInput, n as PlayAuthoringCsvOptions, o as PlayAuthoringDatasetBuilder, p as PlayAuthoringDatasetColumnDefinition, q as PlayAuthoringDatasetColumnRunInput, r as ToolExecuteResult, s as PlayAuthoringReferenceLike, t as PlayReturnObject$1, u as PlayAuthoringDefineConfig, v as PlayAuthoringDefinedPlay, w as PlayAuthoringFetchOptions, x as PlayAuthoringFileInput, y as PlayAuthoringAsyncCallOptions, z as PlayAuthoringBindings, B as PlayAuthoringCallExecution, C as PlayAuthoringCallOptions, D as PlayAuthoringFetchResponse, E as PlayAuthoringInputContract, F as PlayRunId$1, G as PlayAuthoringStepProgramStep, H as PlayAuthoringRuntimeStepOptions, I as PlaySqlListenerDeclaration, J as PlaySqlListenerEvent, K as PlaySqlListenerOperation, L as PlaySqlQuery, M as PlayAuthoringStepOptions, N as PlayAuthoringStepProgram, O as PlayAuthoringStepProgramResolver, Q as PlayAuthoringStepResolver, R as PlayToolExecutionRequest, S as PlayAuthoringStepProgramOptions, U as DeeplineError, V as ToolExecutionError, W as ToolExecutionErrorOptions } from './compiler-manifest-BJBNPTWt.js';
3
+ export { X as CtxFetchHttpError, Y as DEEPLINE_EXTRACTOR_TARGETS, Z as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, _ as DeeplineEmailStatusGetterValue, $ as DeeplineExtractorTarget, a0 as DeeplineGetterValue, a1 as DeeplineGetterValueMap, a2 as JOB_CHANGE_STATUS_VALUES, a3 as JobChangeStatus, a4 as PHONE_STATUS_VALUES, a5 as PhoneStatus, a6 as PlayDataset, a7 as PlayDatasetInput, a8 as PreviousCell, a9 as ProviderTransientError, aa as ProviderTransientErrorCategory, ab as ProviderUnavailableError, ac as ProviderUnavailableReason, ad as ToolExecutionErrorCategory, ae as ToolExecutionErrorOrigin, af as ToolExecutionFailureV1, ag as ToolExecutionNetworkKind, ah as ToolExecutionNetworkScope, ai as ToolExecutionPublicDetails, aj as getProviderUnavailableReason, ak as isDeeplineExtractorTarget, al as isProviderUnavailable, am as isProviderWaterfallUnavailableError } from './compiler-manifest-BJBNPTWt.js';
4
4
  import { MonitorFleetDefinition } from './monitor-fleet-contract.js';
5
5
  export { AdmittedMonitorFleetAuthoringContract, MONITOR_FLEET_AUTHORING_CONTRACT_CHANGELOG, MONITOR_FLEET_AUTHORING_CONTRACT_EDITION, MONITOR_FLEET_DOCUMENTATION, MONITOR_FLEET_FRONTIER_MAX_ROWS, MONITOR_FLEET_MAX_MEMBERS, MonitorFleetAuthoringContractEdition, MonitorFleetAuthoringContractResult, MonitorFleetColumn, MonitorFleetContractIssue, MonitorFleetExpression, MonitorFleetTemplate, admitMonitorFleetAuthoringContract, defineMonitorFleet, fleetColumn, fleetKey, lintMonitorFleetInput, validateMonitorFleetDefinition } from './monitor-fleet-contract.js';
6
6
  export { BatchMonitorInput, MonitorInputIssue, MonitorSpec as MonitorInputSpec, lintMonitorBatchInput, lintMonitorSpecTemplate, renderMonitorSpecTemplate } from './monitor-input-contract.js';
@@ -770,45 +770,14 @@ declare const PRODUCT_NOTIFICATION_TYPE_REGISTRY: readonly [{
770
770
  readonly eventName: "credits.purchase.completed";
771
771
  readonly requiredFilter: {};
772
772
  readonly allowedTriggers: ["threshold_crossing"];
773
- readonly catalog: {
774
- readonly name: "Credit purchase thank-you";
775
- readonly category: "credits";
776
- readonly description: "Thank the workspace when a credit purchase of at least the chosen size completes.";
777
- readonly allowMultiple: false;
778
- readonly editor: {
779
- readonly kind: "threshold";
780
- readonly label: "Minimum credits";
781
- readonly defaultThreshold: 500;
782
- readonly minimum: 0;
783
- readonly suffix: "credits";
784
- };
785
- };
773
+ readonly catalog: undefined;
774
+ readonly shadow: true;
786
775
  readonly rule: {
787
776
  readonly default: {
788
777
  readonly ruleKey: "default.credits_purchased";
789
- readonly groupKey: "default";
778
+ readonly groupKey: "shadow";
790
779
  };
791
- readonly create: (input: ProductNotificationRuleInput, base: ProductNotificationRuleBase, editor: {
792
- kind: "threshold";
793
- label: string;
794
- defaultThreshold: number;
795
- minimum: number;
796
- maximum?: number;
797
- suffix?: string;
798
- /**
799
- * When set, editors show and accept `remainingOf - threshold` (for
800
- * example percent remaining) while the stored trigger stays in the
801
- * runtime's "used" terms. Bounds and defaults are stored values.
802
- */
803
- remainingOf?: number;
804
- } | {
805
- kind: "play_failure";
806
- defaultFailureCount: number;
807
- } | {
808
- kind: "play_scope";
809
- } | {
810
- kind: "none";
811
- }) => {
780
+ readonly create: (input: ProductNotificationRuleInput, base: ProductNotificationRuleBase) => {
812
781
  repeatMode: "every_match";
813
782
  trigger: {
814
783
  kind: "threshold_crossing";
@@ -859,19 +828,12 @@ declare const PRODUCT_NOTIFICATION_TYPE_REGISTRY: readonly [{
859
828
  readonly eventName: "billing.plan.purchased";
860
829
  readonly requiredFilter: {};
861
830
  readonly allowedTriggers: ["each_match"];
862
- readonly catalog: {
863
- readonly name: "Plan welcome";
864
- readonly category: "credits";
865
- readonly description: "Thank the workspace when it purchases a plan.";
866
- readonly allowMultiple: false;
867
- readonly editor: {
868
- readonly kind: "none";
869
- };
870
- };
831
+ readonly catalog: undefined;
832
+ readonly shadow: true;
871
833
  readonly rule: {
872
834
  readonly default: {
873
835
  readonly ruleKey: "default.plan_purchased";
874
- readonly groupKey: "default";
836
+ readonly groupKey: "shadow";
875
837
  };
876
838
  readonly create: (_input: ProductNotificationRuleInput, base: ProductNotificationRuleBase) => {
877
839
  repeatMode: "every_match";
@@ -4311,6 +4273,20 @@ type WorkspacesNamespace = {
4311
4273
  idempotencyKey: string;
4312
4274
  }) => Promise<WorkspaceCreateResult>;
4313
4275
  };
4276
+ /** One authenticated per-request usage event from `/api/v2/usage/events`. */
4277
+ type BillingUsageEvent = {
4278
+ id: string | null;
4279
+ provider: string;
4280
+ operation: string;
4281
+ status: string;
4282
+ request_id: string;
4283
+ billing_outcome_reason: string | null;
4284
+ credits: number | null;
4285
+ billing_mode: string | null;
4286
+ pricing_model: string | null;
4287
+ policy_id: string | null;
4288
+ created_at: string;
4289
+ };
4314
4290
  /**
4315
4291
  * Public `client.billing` namespace for CLI commands and programmatic callers.
4316
4292
  * Covers plans, subscription state, cancellation, and invoice/receipt history.
@@ -4342,6 +4318,8 @@ type BillingNamespace = {
4342
4318
  limit?: number;
4343
4319
  }) => Promise<BillingInvoicesResult>;
4344
4320
  };
4321
+ /** Read one exact execution outcome using the request_id returned by executeTool. */
4322
+ usageEvent: (requestId: string) => Promise<BillingUsageEvent>;
4345
4323
  /** Metronome-authored target catalog and current Contract projection. */
4346
4324
  targetPlans: () => Promise<TargetBillingPlansResult>;
4347
4325
  /** Normalized target billing state. */
@@ -5406,6 +5384,12 @@ declare class DeeplineClient {
5406
5384
  * @returns Snake_case catalog from `GET /api/v2/billing/catalog/current`
5407
5385
  */
5408
5386
  getBillingPlans(): Promise<BillingPlansResult>;
5387
+ /**
5388
+ * Read the authenticated usage record for one execution request. The
5389
+ * request id comes from the original `executeTool` result and is not a
5390
+ * retry or idempotency token.
5391
+ */
5392
+ getBillingUsageEvent(requestId: string): Promise<BillingUsageEvent>;
5409
5393
  /**
5410
5394
  * Charge the saved payment method and add Deepline credits to the active
5411
5395
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -6608,4 +6592,4 @@ declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem:
6608
6592
  */
6609
6593
  declare function extractSummaryFields(payload: unknown): Record<string, Scalar>;
6610
6594
 
6611
- export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, 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 DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, 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 };
6595
+ 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 DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, 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.143",
867
+ version: "0.3.145",
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
@@ -4774,6 +4774,7 @@ var DeeplineClient = class _DeeplineClient {
4774
4774
  invoices: {
4775
4775
  list: (options2) => this.listBillingInvoices(options2)
4776
4776
  },
4777
+ usageEvent: (requestId) => this.getBillingUsageEvent(requestId),
4777
4778
  targetPlans: () => this.getTargetBillingPlans(),
4778
4779
  targetStatus: () => this.getTargetBillingStatus(),
4779
4780
  autoRecharge: {
@@ -7145,6 +7146,33 @@ var DeeplineClient = class _DeeplineClient {
7145
7146
  async getBillingPlans() {
7146
7147
  return this.http.get("/api/v2/billing/catalog/current");
7147
7148
  }
7149
+ /**
7150
+ * Read the authenticated usage record for one execution request. The
7151
+ * request id comes from the original `executeTool` result and is not a
7152
+ * retry or idempotency token.
7153
+ */
7154
+ async getBillingUsageEvent(requestId) {
7155
+ const normalizedRequestId = requestId.trim();
7156
+ if (normalizedRequestId.length === 0 || normalizedRequestId.length > 200 || normalizedRequestId !== requestId) {
7157
+ throw new DeeplineError(
7158
+ "Usage request_id must contain 1\u2013200 characters with no leading or trailing whitespace.",
7159
+ void 0,
7160
+ "INVALID_USAGE_REQUEST_ID"
7161
+ );
7162
+ }
7163
+ const response = await this.http.get(
7164
+ `/api/v2/usage/events?request_id=${encodeURIComponent(normalizedRequestId)}`
7165
+ );
7166
+ const event = response.entries?.[0];
7167
+ if (!event) {
7168
+ throw new DeeplineError(
7169
+ "No usage event was found for this request_id.",
7170
+ void 0,
7171
+ "USAGE_EVENT_NOT_FOUND"
7172
+ );
7173
+ }
7174
+ return event;
7175
+ }
7148
7176
  /**
7149
7177
  * Charge the saved payment method and add Deepline credits to the active
7150
7178
  * workspace. Prefer `client.billing.topUp(...)`.
@@ -8844,6 +8872,17 @@ function findFirstTargetByPath(result, paths) {
8844
8872
  }
8845
8873
  return null;
8846
8874
  }
8875
+ function findFirstExplicitNullTargetByPath(result, paths) {
8876
+ for (const path of paths ?? []) {
8877
+ for (const candidate of candidateResultPaths(path)) {
8878
+ const explicitNull = valuesAtSegments(result, parsePath(candidate)).find(
8879
+ (entry) => entry.value === null
8880
+ );
8881
+ if (explicitNull) return { value: null, path: explicitNull.path };
8882
+ }
8883
+ }
8884
+ return null;
8885
+ }
8847
8886
  function firstValueForPaths(result, paths) {
8848
8887
  return findFirstTargetByPath(result, paths);
8849
8888
  }
@@ -9103,7 +9142,11 @@ function buildTargets(result, extractors, targetGetters) {
9103
9142
  continue;
9104
9143
  }
9105
9144
  const fromExtractor = findFirstTargetByPath(result, descriptor.paths);
9106
- if (!fromExtractor) continue;
9145
+ if (!fromExtractor) {
9146
+ const explicitNull = isSemanticStatus ? null : findFirstExplicitNullTargetByPath(result, descriptor.paths);
9147
+ if (explicitNull) targets[target] = explicitNull;
9148
+ continue;
9149
+ }
9107
9150
  const transformed = coerceToEnum(
9108
9151
  applyExtractorTransforms(fromExtractor.value, descriptor),
9109
9152
  descriptor
@@ -9126,6 +9169,14 @@ function buildTargets(result, extractors, targetGetters) {
9126
9169
  targets[target] = fromMetadata;
9127
9170
  continue;
9128
9171
  }
9172
+ const explicitNull = findFirstExplicitNullTargetByPath(
9173
+ result,
9174
+ targetGetters?.[target]
9175
+ );
9176
+ if (explicitNull) {
9177
+ targets[target] = explicitNull;
9178
+ continue;
9179
+ }
9129
9180
  const fallback = findFirstTargetByKey(result, target);
9130
9181
  if (fallback) {
9131
9182
  targets[target] = fallback;
@@ -9133,6 +9184,7 @@ function buildTargets(result, extractors, targetGetters) {
9133
9184
  }
9134
9185
  if (metadataTargets.size === 0) {
9135
9186
  for (const target of ["email", "phone", "linkedin", "domain", "status"]) {
9187
+ if (targets[target]) continue;
9136
9188
  const found = findFirstTargetByKey(result, target);
9137
9189
  if (found) targets[target] = found;
9138
9190
  }