@m8tes/sdk 0.1.0-alpha.5 → 0.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -214,6 +214,19 @@ interface Run {
214
214
  retry_count?: number;
215
215
  output_data?: JsonObject | null;
216
216
  usage?: RunUsage | null;
217
+ /**
218
+ * Which meter the run settles on: "api" (prepaid balance — end-user-scoped /
219
+ * embedding work) or "platform" (subscription plan — first-party work, INCLUDING
220
+ * the account's own API-key calls). Stamped at creation.
221
+ */
222
+ billing_surface?: string;
223
+ /**
224
+ * Where the run came in: "api", "app", "cli", "email", "slack", "imessage",
225
+ * "webhook". Attribution only, never billing — a first-party API-key call is
226
+ * channel "api" but billing_surface "platform", so filtering a developer view
227
+ * on surface alone hides your own traffic.
228
+ */
229
+ channel?: string | null;
217
230
  }
218
231
  /** Condensed run result: what happened, without replaying the transcript. */
219
232
  interface RunOutcome {
@@ -244,10 +257,15 @@ interface PermissionRequest {
244
257
  created_at: string;
245
258
  resolved_at: string | null;
246
259
  auto_resolved?: boolean;
260
+ /** Actual saved cross-run grant outcome, also present on listings. Null means unknown. */
261
+ remembered?: boolean | null;
247
262
  /** False when the runtime would ignore an "always allow" for this tool. */
248
263
  can_remember?: boolean;
249
264
  /** False when the Always-allow control must start unticked (force-ask floor). */
250
265
  remember_default?: boolean;
266
+ ask_reason?: string;
267
+ surface?: string;
268
+ surface_label?: string | null;
251
269
  }
252
270
  interface Task {
253
271
  id: number;
@@ -409,6 +427,8 @@ interface Webhook {
409
427
  /** Signing secret. Returned on create only — store it, you cannot read it back. */
410
428
  secret: string | null;
411
429
  active: boolean;
430
+ /** End-user scope. Null/omitted = account-level. */
431
+ user_id?: string | null;
412
432
  created_at: string;
413
433
  updated_at?: string | null;
414
434
  }
@@ -442,12 +462,12 @@ interface WebhookDelivery {
442
462
  next_retry_at: string | null;
443
463
  created_at: string;
444
464
  }
445
- /** A standing tool permission policy: one pre-approved tool for one end-user.
446
- * Note the asymmetry you create it with `tool`, the API returns it as
447
- * `tool_name`. */
465
+ /** A standing tool permission policy: one pre-approved tool for one scope.
466
+ * `user_id` is null for the account-level scope. Note the asymmetry you
467
+ * create it with `tool`, the API returns it as `tool_name`. */
448
468
  interface PermissionPolicy {
449
469
  id: number;
450
- user_id: string;
470
+ user_id: string | null;
451
471
  tool_name: string;
452
472
  created_at: string;
453
473
  /** Which surface minted the grant ("run_approval" / "api"); null on legacy rows. */
@@ -469,7 +489,9 @@ interface Usage {
469
489
  cost_limit: string;
470
490
  period_end: string;
471
491
  subscription_status: string | null;
472
- /** Authoritative eligibility for the model-subscription-funded Free path. */
492
+ /** Current paid subscription cadence, when known. */
493
+ subscription_billing_period?: "monthly" | "annual" | null;
494
+ /** Authoritative eligibility for the model-subscription-funded Hobby path. */
473
495
  free_path_available: boolean;
474
496
  overage_enabled: boolean;
475
497
  overage_used_cents: number;
@@ -518,7 +540,7 @@ interface Receipt {
518
540
  receipt_url: string | null;
519
541
  created_at: string;
520
542
  }
521
- /** A public (paid) plan from the canonical catalog. All prices in cents. */
543
+ /** A public Hobby or paid plan from the canonical catalog. All prices in cents. */
522
544
  interface Plan {
523
545
  slug: string;
524
546
  display_name: string;
@@ -526,9 +548,20 @@ interface Plan {
526
548
  monthly_price_cents: number;
527
549
  annual_price_cents: number;
528
550
  overage_rate_cents: number;
551
+ /** `own_subscription` uses the customer's connected model plan; `platform` includes inference. */
552
+ inference_mode: "own_subscription" | "platform";
553
+ /** Whether this plan may opt into metered usage beyond its included runs. */
554
+ overage_available: boolean;
529
555
  /** Per-period model-spend fair-use cap; `0` on servers that predate the field. */
530
556
  fair_use_cost_limit_cents: number;
531
557
  }
558
+ type SubscriptionPlanId = "individual" | "pro" | "max_5x" | "max_20x";
559
+ type SubscriptionBillingPeriod = "monthly" | "annual";
560
+ /** Stripe redirect returned when starting checkout or managing the current plan. */
561
+ interface SubscriptionCheckout {
562
+ url: string;
563
+ destination: "checkout" | "portal" | "sales";
564
+ }
532
565
  /** One prepaid token-balance ledger entry. Micro-USD; debits are negative. */
533
566
  interface TokenTransaction {
534
567
  type: string;
@@ -842,6 +875,18 @@ interface OverageParams {
842
875
  /** Hard ceiling on overage spend per period, in cents. */
843
876
  monthly_cap_cents: number;
844
877
  }
878
+ interface SubscriptionCheckoutParams {
879
+ plan_id: SubscriptionPlanId;
880
+ billing_period?: SubscriptionBillingPeriod;
881
+ }
882
+ interface BillingPortalParams {
883
+ /** Kept for wire compatibility; `subscription_update` returns a sales-contact URL. */
884
+ flow?: "subscription_update";
885
+ }
886
+ interface BillingPlansParams {
887
+ /** Include Hobby, which is activated separately and cannot be submitted to checkout. */
888
+ include_free?: boolean;
889
+ }
845
890
  interface TopupParams {
846
891
  /** Cents to add. $5 minimum, $1M maximum. */
847
892
  amount_cents: number;
@@ -883,13 +928,19 @@ interface BillingResource {
883
928
  * `receipt_url` can be `null` when Stripe can no longer retrieve the session.
884
929
  */
885
930
  receipts(params?: PageParams): Promise<Page<Receipt>>;
886
- /** What the paid plans include and cost for your own pricing page or upgrade
887
- * prompt. Public (paid) plans only, straight from the canonical catalog, and
888
- * returned as a plain array rather than a page. */
889
- plans(): Promise<Plan[]>;
931
+ /** Purchasable plans from the canonical catalog. Pass `include_free` to also render Hobby. */
932
+ plans(params?: BillingPlansParams): Promise<Plan[]>;
933
+ /** Start a paid subscription. Existing customers may manage their current tier and cadence;
934
+ * changing either returns `destination="sales"` with a contact URL. */
935
+ checkout(params: SubscriptionCheckoutParams): Promise<SubscriptionCheckout>;
936
+ /** Open Stripe for payment methods, invoices, or cancellation. */
937
+ portal(params?: BillingPortalParams): Promise<string>;
938
+ /** Activate Hobby using a connected model subscription. */
939
+ activateFree(): Promise<Usage>;
890
940
  /**
891
941
  * Decide whether runs may continue past your plan's included allotment, and how
892
- * far. Off by default; once enabled, extra runs bill at the per-run overage rate
942
+ * far. Available only when the current catalog plan has `overage_available=true`.
943
+ * Off by default; once enabled, extra runs bill at the per-run overage rate
893
944
  * until `monthly_cap_cents` is reached. Returns the refreshed usage so you can
894
945
  * confirm the new state without a second call.
895
946
  */
@@ -1026,6 +1077,7 @@ interface ModelConnection {
1026
1077
  provider: ModelConnectionProvider;
1027
1078
  display_name: string;
1028
1079
  connected: boolean;
1080
+ is_default: boolean;
1029
1081
  status?: string | null;
1030
1082
  account_label?: string | null;
1031
1083
  expires_at?: string | null;
@@ -1060,46 +1112,72 @@ interface ModelConnectionsResource {
1060
1112
  declare function createModelConnectionsResource(http: Http): ModelConnectionsResource;
1061
1113
 
1062
1114
  /**
1063
- * `client.permissions` — standing tool allow-lists, one end-user at a time.
1115
+ * `client.permissions` — standing tool allow-lists.
1064
1116
  *
1065
1117
  * A run pauses whenever the agent reaches for a tool that is not pre-approved,
1066
1118
  * and stays paused until somebody answers. That is the right default for a first
1067
1119
  * run and the wrong one for a tool your product has already decided is fine. A
1068
- * policy here says "this end-user's runs may use this tool" once, so their runs
1069
- * stop stopping.
1120
+ * policy here says "these runs may use this tool" once, so they stop stopping.
1070
1121
  *
1071
- * Scope: policies are per end-user (`user_id` is required on every callthere
1072
- * is no account-wide policy) and outlive the run, unlike `runs.answerPermission()`
1073
- * which unblocks a single gate. `/docs/users` documents this surface; mirrors
1122
+ * TWO SCOPES, and `user_id` is what selects between themit is not a required
1123
+ * argument. Pass it to reach one end-user's policies. OMIT it to reach the
1124
+ * ACCOUNT-LEVEL scope (`end_user_id IS NULL`), which is the scope a run with no
1125
+ * `user_id` matches and the one the platform writes to when somebody picks
1126
+ * "always allow" on a first-party run. Requiring `user_id` here is exactly what
1127
+ * made those policies ungovernable — grantable, but never listable or revocable
1128
+ * through this SDK. The API stopped requiring it on 2026-08-01
1129
+ * (`PermissionPolicyCreate.user_id`, `_end_user_id_query`); this client did not
1130
+ * follow, and its own docstring asserted the account scope did not exist.
1131
+ *
1132
+ * The two scopes never overlap: a delete must name the SAME scope the policy
1133
+ * lives in, so an end-user-scoped delete cannot reach an account-level policy
1134
+ * (404), and neither can the reverse.
1135
+ *
1136
+ * One account setting narrows this: with strict multi-tenant mode on
1137
+ * (`require_end_user_id`, the default for API-key signups) the server rejects a
1138
+ * programmatic call that resolves to no end-user with a 422 naming the setting.
1139
+ * Omitting `user_id` is still how you ASK for the account scope — on those
1140
+ * accounts the answer is just no.
1141
+ *
1142
+ * Policies outlive the run, unlike `runs.answerPermission()` which unblocks a
1143
+ * single gate. `/docs/users` documents this surface; mirrors
1074
1144
  * `sdk/py/m8tes/_resources/permissions.py`.
1075
1145
  */
1076
1146
 
1077
1147
  interface PermissionCreateParams {
1078
- /** The end-user whose runs this policy applies to. Required — policies never span end-users. */
1079
- user_id: string;
1148
+ /**
1149
+ * The end-user whose runs this policy applies to. Omit for the account-level
1150
+ * scope — the one runs that carry no `user_id` match.
1151
+ */
1152
+ user_id?: string;
1080
1153
  /** The tool to pre-approve, e.g. `"Bash"` or an `mcp__*` tool name. */
1081
1154
  tool: string;
1082
1155
  }
1083
1156
  interface PermissionListParams extends PageParams {
1084
- /** Required: you list one end-user's policies, never the account's. */
1085
- user_id: string;
1157
+ /** One end-user's policies. Omit to list the account-level scope. */
1158
+ user_id?: string;
1159
+ }
1160
+ interface PermissionDeleteParams {
1161
+ /**
1162
+ * The scope the policy lives in. Omit to delete an account-level policy.
1163
+ * A scope that does not match the policy is a 404, never a silent no-op.
1164
+ */
1165
+ user_id?: string;
1086
1166
  }
1087
1167
  interface PermissionsResource {
1088
1168
  /**
1089
- * Pre-approve a tool so this end-user's runs no longer pause on it.
1169
+ * Pre-approve a tool so matching runs no longer pause on it.
1090
1170
  * Idempotent — re-approving the same tool returns the existing policy rather
1091
1171
  * than erroring or duplicating. Send `tool`; the policy comes back as `tool_name`.
1092
1172
  */
1093
1173
  create(params: PermissionCreateParams): Promise<PermissionPolicy>;
1094
- /** Audit what an end-user's runs are allowed to do without asking. */
1095
- list(params: PermissionListParams): Promise<Page<PermissionPolicy>>;
1174
+ /** Audit what one scope's runs are allowed to do without asking. */
1175
+ list(params?: PermissionListParams): Promise<Page<PermissionPolicy>>;
1096
1176
  /**
1097
1177
  * Revoke a pre-approval, so the tool gates again on the next run.
1098
- * `user_id` is required and scopes the delete an id alone will not resolve.
1178
+ * `user_id` scopes the delete and must match the policy's own scope.
1099
1179
  */
1100
- delete(permissionId: number, params: {
1101
- user_id: string;
1102
- }): Promise<void>;
1180
+ delete(permissionId: number, params?: PermissionDeleteParams): Promise<void>;
1103
1181
  }
1104
1182
  declare function createPermissionsResource(http: Http): PermissionsResource;
1105
1183
 
@@ -1192,6 +1270,7 @@ interface PollDeps {
1192
1270
  }, signal?: AbortSignal): Promise<unknown>;
1193
1271
  answer(runId: number, params: {
1194
1272
  answers: Record<string, string>;
1273
+ request_id?: string;
1195
1274
  }, signal?: AbortSignal): Promise<unknown>;
1196
1275
  }
1197
1276
  /** Thrown when the caller aborts the wait. */
@@ -1357,6 +1436,10 @@ interface RunListParams {
1357
1436
  teammate_id?: number;
1358
1437
  task_id?: number;
1359
1438
  status?: string;
1439
+ /** `created` (newest first, the default) or `priority` (runs waiting on a human first). */
1440
+ sort?: "created" | "priority";
1441
+ /** Hide Company Agent Day-1 / pulse / maintenance (Platform accounts only) — ask whether the user has run anything. */
1442
+ exclude_platform_runs?: boolean;
1360
1443
  limit?: number;
1361
1444
  starting_after?: number;
1362
1445
  }
@@ -1374,6 +1457,13 @@ interface ApproveParams {
1374
1457
  * stored policy).
1375
1458
  */
1376
1459
  remember?: boolean;
1460
+ /**
1461
+ * Steering in your own words, e.g. with `decision: "deny"`, "use the staging
1462
+ * board instead". The agent reads it and adapts rather than silently skipping
1463
+ * the action. Delivered on both decisions when the run is paused; a deny's
1464
+ * reason also reaches a still-live run.
1465
+ */
1466
+ reason?: string;
1377
1467
  }
1378
1468
  interface AnswerParams {
1379
1469
  /**
@@ -1381,6 +1471,20 @@ interface AnswerParams {
1381
1471
  * `question` strings from the `question` event.
1382
1472
  */
1383
1473
  answers: Record<string, string>;
1474
+ /**
1475
+ * The gate this answer is for — `requestId` off the `question` event (the
1476
+ * stream normalises it to camelCase), or `request_id` from
1477
+ * `runs.permissions()`. Required whenever the run has more than one
1478
+ * unresolved `AskUserQuestion`.
1479
+ *
1480
+ * A run accumulates asks over its life, and only some of them get resolved.
1481
+ * With no `request_id` the server does not know which one you answered, so it
1482
+ * falls back to position: the OLDEST ask that is not already allowed. A gate
1483
+ * that timed out earlier still matches that, so the answer you wrote for the
1484
+ * live question is merged into the stale one and the run resumes on the wrong
1485
+ * selection. Send the id and the server targets exactly that gate.
1486
+ */
1487
+ request_id?: string;
1384
1488
  }
1385
1489
  interface RunsResource {
1386
1490
  /** Start a run and stream it. */
@@ -1430,7 +1534,11 @@ interface RunsResource {
1430
1534
  }): Promise<Run>;
1431
1535
  /** Approve or deny a pending tool-permission gate. */
1432
1536
  approve(runId: number, params: ApproveParams): Promise<PermissionRequest>;
1433
- /** Answer a pending AskUserQuestion gate, resuming the run. */
1537
+ /**
1538
+ * Answer a pending AskUserQuestion gate, resuming the run. Pass `request_id`
1539
+ * when the run has more than one unresolved ask, or the server picks by
1540
+ * position instead.
1541
+ */
1434
1542
  answer(runId: number, params: AnswerParams): Promise<{
1435
1543
  status: string;
1436
1544
  resumed: boolean;
@@ -1649,6 +1757,9 @@ interface TasksResource {
1649
1757
  * byte on the signing scheme, so a payload verified by one SDK verifies in the
1650
1758
  * other.
1651
1759
  *
1760
+ * `user_id` scopes an endpoint to one end-user; omit for account-level. The
1761
+ * scopes never mix: an end-user run only delivers to that end-user's endpoints.
1762
+ *
1652
1763
  * Scheme: HMAC-SHA256 over `"{webhook-id}.{webhook-timestamp}.{raw body}"`, hex,
1653
1764
  * prefixed `v1=`, compared in constant time.
1654
1765
  */
@@ -1683,22 +1794,31 @@ interface WebhooksResource {
1683
1794
  create(params: {
1684
1795
  url: string;
1685
1796
  events?: string[];
1797
+ user_id?: string;
1686
1798
  }): Promise<Webhook>;
1687
1799
  list(params?: {
1688
1800
  limit?: number;
1689
1801
  starting_after?: number;
1802
+ user_id?: string;
1690
1803
  }): Promise<Page<Webhook>>;
1691
- get(webhookId: number): Promise<Webhook>;
1804
+ get(webhookId: number, params?: {
1805
+ user_id?: string;
1806
+ }): Promise<Webhook>;
1692
1807
  update(webhookId: number, params: {
1693
1808
  url?: string;
1694
1809
  events?: string[];
1695
1810
  active?: boolean;
1811
+ rotate_secret?: boolean;
1812
+ user_id?: string;
1696
1813
  }): Promise<Webhook>;
1697
- delete(webhookId: number): Promise<void>;
1814
+ delete(webhookId: number, params?: {
1815
+ user_id?: string;
1816
+ }): Promise<void>;
1698
1817
  /** Delivery attempts, for debugging a receiver that is not getting events. */
1699
1818
  listDeliveries(webhookId: number, params?: {
1700
1819
  limit?: number;
1701
1820
  starting_after?: number;
1821
+ user_id?: string;
1702
1822
  }): Promise<Page<WebhookDelivery>>;
1703
1823
  }
1704
1824
 
@@ -1726,7 +1846,7 @@ interface WebhooksResource {
1726
1846
  */
1727
1847
 
1728
1848
  /** Kept in lockstep with package.json "version" — guarded by test/version.test.ts. */
1729
- declare const M8TES_SDK_VERSION = "0.1.0-alpha.5";
1849
+ declare const M8TES_SDK_VERSION = "0.1.0-alpha.6";
1730
1850
  declare class M8tes {
1731
1851
  readonly runs: RunsResource;
1732
1852
  readonly agents: AgentsResource;
@@ -1748,4 +1868,4 @@ declare class M8tes {
1748
1868
  constructor(options?: ClientOptions);
1749
1869
  }
1750
1870
 
1751
- export { type AccountDeletion, type AccountExport, type AccountResource, type AccountSettings, type AccountSettingsUpdateParams, type Agent, type AgentCreateParams, type AgentListParams, type AgentUpdateParams, type AgentsResource, type AlertThresholdParams, type App, type AppConnectionInitiation, type AppConnectionResult, type AppsResource, type AuthorizableModelConnectionProvider, type AutoReloadParams, type Balance, type BillingResource, type ClientOptions, type CodeModelConnectionProvider, ConversationState, DEFAULT_BASE_URL, type DeviceModelConnectionProvider, type EmailInbox, type EndUser, type EndUserCreateParams, type EndUserUpdateParams, type EndUserUsage, type FetchLike, type Http, type JsonObject, type ListResponse, M8TES_SDK_VERSION, M8tes, M8tesStreamEvent, type MemoriesResource, type Memory, type MemoryCreateParams, type MemoryListParams, type MemoryUpdateParams, type Model, type ModelAuthorization, type ModelConnection, type ModelConnectionProvider, type ModelConnectionsResource, type ModelPricing, type ModelsResource, Normalizer, type OverageParams, Page, type PageParams, type PermissionCreateParams, type PermissionListParams, type PermissionMode, type PermissionPolicy, type PermissionRequest, type PermissionsResource, type Plan, type PollOptions, type Receipt, type Run, type RunCreateParams, type RunFile, type RunListParams, type RunOutcome, RunPausedError, RunStream, type RunStreamOptions, RunTimeoutError, type RunUsage, RunWaitAbortedError, type RunsResource, type SettingsResource, TERMINAL_STATUSES, type Task, type TaskCreateParams, type TaskListParams, type TaskRunParams, type TaskUpdateParams, type TasksResource, type Teammate, type TokenTransaction, type TopupParams, type Trigger, type TriggerCreateParams, type TriggerType, type TriggersResource, type Usage, type UsageBucket, type UsageModelSlice, type UsageTimeseries, type UsageTimeseriesParams, type UsageTotals, type UsersResource, type VerifySignatureOptions, type WaitOptions, type Webhook, type WebhookDelivery, type WebhookToggle, type WebhooksResource, createAccountResource, createBillingResource, createHttp, createMemoriesResource, createModelConnectionsResource, createModelsResource, createPermissionsResource, isPlanApproval, planText, pollRun, verifySignature, waitForRun };
1871
+ export { type AccountDeletion, type AccountExport, type AccountResource, type AccountSettings, type AccountSettingsUpdateParams, type Agent, type AgentCreateParams, type AgentListParams, type AgentUpdateParams, type AgentsResource, type AlertThresholdParams, type App, type AppConnectionInitiation, type AppConnectionResult, type AppsResource, type AuthorizableModelConnectionProvider, type AutoReloadParams, type Balance, type BillingPlansParams, type BillingPortalParams, type BillingResource, type ClientOptions, type CodeModelConnectionProvider, ConversationState, DEFAULT_BASE_URL, type DeviceModelConnectionProvider, type EmailInbox, type EndUser, type EndUserCreateParams, type EndUserUpdateParams, type EndUserUsage, type FetchLike, type Http, type JsonObject, type ListResponse, M8TES_SDK_VERSION, M8tes, M8tesStreamEvent, type MemoriesResource, type Memory, type MemoryCreateParams, type MemoryListParams, type MemoryUpdateParams, type Model, type ModelAuthorization, type ModelConnection, type ModelConnectionProvider, type ModelConnectionsResource, type ModelPricing, type ModelsResource, Normalizer, type OverageParams, Page, type PageParams, type PermissionCreateParams, type PermissionDeleteParams, type PermissionListParams, type PermissionMode, type PermissionPolicy, type PermissionRequest, type PermissionsResource, type Plan, type PollOptions, type Receipt, type Run, type RunCreateParams, type RunFile, type RunListParams, type RunOutcome, RunPausedError, RunStream, type RunStreamOptions, RunTimeoutError, type RunUsage, RunWaitAbortedError, type RunsResource, type SettingsResource, type SubscriptionBillingPeriod, type SubscriptionCheckout, type SubscriptionCheckoutParams, type SubscriptionPlanId, TERMINAL_STATUSES, type Task, type TaskCreateParams, type TaskListParams, type TaskRunParams, type TaskUpdateParams, type TasksResource, type Teammate, type TokenTransaction, type TopupParams, type Trigger, type TriggerCreateParams, type TriggerType, type TriggersResource, type Usage, type UsageBucket, type UsageModelSlice, type UsageTimeseries, type UsageTimeseriesParams, type UsageTotals, type UsersResource, type VerifySignatureOptions, type WaitOptions, type Webhook, type WebhookDelivery, type WebhookToggle, type WebhooksResource, createAccountResource, createBillingResource, createHttp, createMemoriesResource, createModelConnectionsResource, createModelsResource, createPermissionsResource, isPlanApproval, planText, pollRun, verifySignature, waitForRun };