@m8tes/sdk 0.1.0-alpha.1 → 0.1.0-alpha.2

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
@@ -1,5 +1,5 @@
1
1
  import { Normalizer, M8tesStreamEvent, ConversationState } from './protocol/index.cjs';
2
- export { APIError, Accumulator, ApiErrorFields, ApprovalRequestEvent, ApprovalResolvedEvent, AuthenticationError, BaseEvent, BillingError, CompactBoundaryEvent, CompactPart, ConflictError, ErrorFromResponseOptions, M8tesApiError, M8tesStreamEventType, MateMessage, MatePart, MateStatus, MessageEndEvent, MessageStartEvent, NotFoundError, NoticeEvent, NoticePart, PROTOCOL_VERSION, PermissionDeniedError, PlanDeltaEvent, PlanEndEvent, PlanStartEvent, ProtocolVersion, QuestionEvent, QuestionItem, QuestionOption, RateLimitError, ReasoningDeltaEvent, ReasoningEndEvent, ReasoningStartEvent, RunCancelledEvent, RunErrorCode, RunErrorEvent, RunFailedError, RunFinishEvent, RunMetricsEvent, RunNotStreamingError, RunStartEvent, RunStatus, RunStatusEvent, SandboxPart, SandboxStatusEvent, SseParserOptions, TERMINAL_EVENT_TYPES, TerminalEventType, TextDeltaEvent, TextEndEvent, TextLikeKind, TextPart, TextStartEvent, ToolInputAvailableEvent, ToolInputDeltaEvent, ToolInputStartEvent, ToolOutputAvailableEvent, ToolPart, ToolState, UnknownEvent, ValidationError, accumulate, createAccumulator, createNormalizer, createSseDecoder, errorClassForStatus, errorFromResponse, initialConversationState, isTerminalEvent, parseErrorEnvelope, parseRetryAfter, parseSse, splitConcatenatedJson } from './protocol/index.cjs';
2
+ export { APIError, Accumulator, ApiErrorFields, ApprovalRequestEvent, ApprovalResolvedEvent, AuthenticationError, BaseEvent, BillingError, CompactBoundaryEvent, CompactPart, ConflictError, ErrorFromResponseOptions, M8tesApiError, M8tesStreamEventType, MateMessage, MatePart, MateStatus, MessageEndEvent, MessageStartEvent, NotFoundError, NoticeEvent, NoticePart, PROTOCOL_VERSION, PermissionDeniedError, PlanDeltaEvent, PlanEndEvent, PlanStartEvent, ProtocolVersion, QuestionEvent, QuestionItem, QuestionOption, RateLimitError, ReasoningDeltaEvent, ReasoningEndEvent, ReasoningStartEvent, RunCancelledEvent, RunErrorCode, RunErrorEvent, RunFailedError, RunFinishEvent, RunMetricsEvent, RunNotStreamingError, RunStartEvent, RunStatus, RunStatusEvent, SandboxPart, SandboxStatusEvent, SseParserOptions, TERMINAL_EVENT_TYPES, TerminalEventType, TextDeltaEvent, TextEndEvent, TextLikeKind, TextPart, TextStartEvent, ToolInputAvailableEvent, ToolInputDeltaEvent, ToolInputStartEvent, ToolOutputAvailableEvent, ToolPart, ToolState, UnknownEvent, ValidationError, accumulate, createAccumulator, createNormalizer, createSseDecoder, errorClassForStatus, errorFromResponse, initialConversationState, isTerminalEvent, parseErrorEnvelope, parseRetryAfter, parseSse, seg, splitConcatenatedJson } from './protocol/index.cjs';
3
3
 
4
4
  /**
5
5
  * Server-side transport for the m8tes V2 API.
@@ -13,9 +13,11 @@ export { APIError, Accumulator, ApiErrorFields, ApprovalRequestEvent, ApprovalRe
13
13
  * two languages behave the same under load:
14
14
  * - 3 attempts total, 0.5s initial backoff, doubling
15
15
  * - retry only 429/500/502/503/504
16
- * - retry only idempotent methods (GET/HEAD/PUT/DELETE/OPTIONS). A POST that
17
- * timed out may already have started a billable run, so re-sending it could
18
- * double-charge; those fail immediately and let the caller decide.
16
+ * - retry GET/HEAD/PUT/DELETE/OPTIONS always, and a POST only when it carries
17
+ * an `Idempotency-Key`. Without one, a POST that timed out may already have
18
+ * started a billable run, so re-sending it could double-charge; with one, the
19
+ * server replays the run it already created, which is why the run-creating
20
+ * calls mint a key on every request.
19
21
  * - honour `Retry-After` on 429
20
22
  */
21
23
 
@@ -41,10 +43,31 @@ interface RequestOptions {
41
43
  query?: string;
42
44
  signal?: AbortSignal;
43
45
  headers?: Record<string, string>;
46
+ /**
47
+ * Send as multipart/form-data instead of JSON. Used by the file-upload route.
48
+ * `fetch` sets its own `content-type` with the boundary, so we must NOT set
49
+ * one — a hand-written header omits the boundary and the server cannot parse
50
+ * the body.
51
+ */
52
+ form?: FormData;
44
53
  }
45
54
  interface StreamRequestOptions extends RequestOptions {
46
55
  /** Reuse a normalizer across reconnects so its dedupe ledger persists. */
47
56
  normalizer?: Normalizer;
57
+ /**
58
+ * Called instead of decoding the body when the server answers a run-creating
59
+ * POST with `Idempotent-Replay: true`.
60
+ *
61
+ * A replay is JSON (the run), not SSE — a run that already exists has no fresh
62
+ * stream to emit — so the caller decides what to do with it, in practice
63
+ * joining that run's own stream. It lives here rather than in the resource
64
+ * because this is the only place the Response object exists; by the time
65
+ * `stream()` yields, the headers are gone.
66
+ */
67
+ onReplay?: (run: {
68
+ id: number;
69
+ status: string;
70
+ }) => AsyncGenerator<M8tesStreamEvent, void, unknown>;
48
71
  }
49
72
  interface Http {
50
73
  baseUrl: string;
@@ -166,7 +189,13 @@ interface Run {
166
189
  updated_at: string | null;
167
190
  task_id?: number | null;
168
191
  permission_mode?: string | null;
192
+ /** Reply-to address when the run's agent has an email inbox. */
193
+ email_address?: string | null;
169
194
  error_code?: string | null;
195
+ /** Credential route used for this run. */
196
+ auth_method?: string | null;
197
+ /** Provider behind an OAuth subscription route: claude, openai, xai, or gemini. */
198
+ auth_provider?: string | null;
170
199
  retryable?: boolean;
171
200
  retry_of_run_id?: number | null;
172
201
  retry_count?: number;
@@ -276,6 +305,18 @@ interface EndUserUsage {
276
305
  period_end: string;
277
306
  rate_per_minute?: number | null;
278
307
  }
308
+ /**
309
+ * One saved memory. `user_id` is the scope: your end-user's id, or `null` for an
310
+ * account-level memory. `source` says who wrote it — `"api"` for ones you create
311
+ * here, versus memories an agent saved for itself during a run.
312
+ */
313
+ interface Memory {
314
+ id: number;
315
+ user_id: string | null;
316
+ content: string;
317
+ source: string;
318
+ created_at: string;
319
+ }
279
320
  interface App {
280
321
  name: string;
281
322
  display_name: string;
@@ -294,6 +335,52 @@ interface AppConnectionResult {
294
335
  connected?: boolean;
295
336
  message?: string | null;
296
337
  }
338
+ /**
339
+ * USD price per MILLION tokens, from the same table that bills your runs.
340
+ *
341
+ * `cache_read_per_mtok` / `cache_write_per_mtok` are the prompt-cache rates: on
342
+ * Anthropic models cache reads are discounted and cache writes carry a premium;
343
+ * on providers without prompt caching both equal the input rate, so an estimate
344
+ * built from these numbers never under-counts.
345
+ */
346
+ interface ModelPricing {
347
+ input_per_mtok: number;
348
+ output_per_mtok: number;
349
+ cache_read_per_mtok: number;
350
+ cache_write_per_mtok: number;
351
+ currency: string;
352
+ }
353
+ /** A selectable model. Pass its `id` as `model` on an agent or a run. */
354
+ interface Model {
355
+ id: string;
356
+ name: string;
357
+ description: string;
358
+ /** Who serves it — `"anthropic"`, `"openai"`, … */
359
+ provider: string;
360
+ /** True for the model used when `model` is omitted or null. */
361
+ default: boolean;
362
+ /** Highest effort tier this model accepts (`"max"` on Claude, `"high"` on
363
+ * others). A higher requested effort is clamped, never rejected. */
364
+ max_effort: string;
365
+ /** Absent on older backends that predate pricing on this route. */
366
+ pricing?: ModelPricing | null;
367
+ /**
368
+ * At least one provider behind this model supports zero data retention.
369
+ *
370
+ * Read that precisely: it does NOT promise your particular request avoids a
371
+ * retaining provider. Routing can still land on one unless the account is
372
+ * constrained. Treat `true` as "ZDR is available here", not "ZDR is in
373
+ * effect" — see `zdr_providers` and `retention_note`, and confirm the account
374
+ * constraint before sending regulated data.
375
+ */
376
+ zdr_supported?: boolean;
377
+ /** Deprecated alias of `zdr_supported`. Still sent, so still typed. */
378
+ zdr?: boolean;
379
+ /** Which providers behind this route carry ZDR. */
380
+ zdr_providers?: string[];
381
+ /** Human-readable retention caveat, when there is one. */
382
+ retention_note?: string | null;
383
+ }
297
384
  interface Webhook {
298
385
  id: number;
299
386
  url: string;
@@ -304,6 +391,23 @@ interface Webhook {
304
391
  created_at: string;
305
392
  updated_at?: string | null;
306
393
  }
394
+ /**
395
+ * The full account data dump from `client.account.export()`.
396
+ *
397
+ * Deliberately untyped JSON: the document is a GDPR/CCPA access export whose
398
+ * shape follows whatever the account happens to hold (agents, tasks, runs,
399
+ * documents, memories, integration metadata), and the API grows it without a
400
+ * version bump. The Python SDK returns a bare `dict[str, Any]` for the same
401
+ * reason — typing fields here would invent a contract neither SDK has. Secrets
402
+ * are never included.
403
+ */
404
+ type AccountExport = JsonObject;
405
+ /**
406
+ * The status payload from `client.account.delete()`.
407
+ *
408
+ * Untyped for parity with the Python SDK, which returns the API's raw dict.
409
+ */
410
+ type AccountDeletion = JsonObject;
307
411
  interface WebhookDelivery {
308
412
  id: number;
309
413
  webhook_endpoint_id: number;
@@ -317,6 +421,115 @@ interface WebhookDelivery {
317
421
  next_retry_at: string | null;
318
422
  created_at: string;
319
423
  }
424
+ /** A standing tool permission policy: one pre-approved tool for one end-user.
425
+ * Note the asymmetry — you create it with `tool`, the API returns it as
426
+ * `tool_name`. */
427
+ interface PermissionPolicy {
428
+ id: number;
429
+ user_id: string;
430
+ tool_name: string;
431
+ created_at: string;
432
+ }
433
+ /**
434
+ * Billing usage and limits for the current period.
435
+ *
436
+ * The overage fields describe the opt-in usage overage (see
437
+ * `client.billing.setOverage`) and are all zero/false on accounts that never
438
+ * enabled it. Cost fields are USD strings, not numbers, so they survive a round
439
+ * trip without float drift.
440
+ */
441
+ interface Usage {
442
+ plan: string;
443
+ runs_used: number;
444
+ runs_limit: number;
445
+ cost_used: string;
446
+ cost_limit: string;
447
+ period_end: string;
448
+ subscription_status: string | null;
449
+ overage_enabled: boolean;
450
+ overage_used_cents: number;
451
+ /** Ceiling on overage spend per period. Runs stop billing overage once reached. */
452
+ overage_cap_cents: number;
453
+ overage_rate_cents: number;
454
+ trial_ends_at?: string | null;
455
+ }
456
+ /** Token + USD totals over a usage-timeseries window. `cost_usd` is a string. */
457
+ interface UsageTotals {
458
+ input_tokens: number;
459
+ output_tokens: number;
460
+ cache_read_tokens: number;
461
+ cache_creation_tokens: number;
462
+ total_tokens: number;
463
+ cost_usd: string;
464
+ }
465
+ /** One model's share of a day bucket. `"unknown"` covers pre-attribution history. */
466
+ interface UsageModelSlice extends UsageTotals {
467
+ model: string;
468
+ }
469
+ /** One UTC-day bucket of token + USD usage. */
470
+ interface UsageBucket extends UsageTotals {
471
+ /** ISO date, e.g. `"2026-07-01"`. */
472
+ date: string;
473
+ /** Per-model slices — present only when the series was requested with
474
+ * `group_by: "model"`; `null` otherwise. */
475
+ models?: UsageModelSlice[] | null;
476
+ }
477
+ /** Daily usage buckets, zero-filled across `[start_date, end_date]` (UTC days). */
478
+ interface UsageTimeseries {
479
+ start_date: string;
480
+ end_date: string;
481
+ buckets: UsageBucket[];
482
+ totals: UsageTotals;
483
+ }
484
+ /** One prepaid top-up. `receipt_url` is `null` when the underlying Stripe
485
+ * checkout session is no longer retrievable. */
486
+ interface Receipt {
487
+ id: number;
488
+ amount_cents: number;
489
+ currency: string;
490
+ description: string | null;
491
+ receipt_url: string | null;
492
+ created_at: string;
493
+ }
494
+ /** A public (paid) plan from the canonical catalog. All prices in cents. */
495
+ interface Plan {
496
+ slug: string;
497
+ display_name: string;
498
+ included_runs: number;
499
+ monthly_price_cents: number;
500
+ annual_price_cents: number;
501
+ overage_rate_cents: number;
502
+ /** Per-period model-spend fair-use cap; `0` on servers that predate the field. */
503
+ fair_use_cost_limit_cents: number;
504
+ }
505
+ /** One prepaid token-balance ledger entry. Micro-USD; debits are negative. */
506
+ interface TokenTransaction {
507
+ type: string;
508
+ amount_micros: number;
509
+ balance_after_micros: number;
510
+ run_id: number | null;
511
+ description: string | null;
512
+ created_at: string;
513
+ }
514
+ /**
515
+ * Prepaid token balance plus a recent ledger (prepaid-billed accounts).
516
+ *
517
+ * Balances are micro-USD (1e-6 USD); `balance_usd` is a rounded display string.
518
+ * Runs debit this balance at official provider prices.
519
+ */
520
+ interface Balance {
521
+ balance_micros: number;
522
+ balance_usd: string;
523
+ currency: string;
524
+ /** Configurable low-balance warning level (micro-USD). */
525
+ low_balance_threshold_micros: number;
526
+ /** Fixed at 20% of the low threshold; depletion is 0. */
527
+ critical_balance_threshold_micros: number;
528
+ transactions: TokenTransaction[];
529
+ auto_reload_enabled: boolean;
530
+ auto_reload_threshold_cents?: number | null;
531
+ auto_reload_amount_cents?: number | null;
532
+ }
320
533
 
321
534
  /**
322
535
  * `client.agents` — the reusable agent personas runs execute as.
@@ -396,12 +609,21 @@ interface AgentsResource {
396
609
  delete(agentId: number, params?: {
397
610
  user_id?: string;
398
611
  }): Promise<void>;
399
- /** Turn on the webhook trigger; returns the URL to POST to. */
400
- enableWebhook(agentId: number): Promise<WebhookToggle>;
401
- disableWebhook(agentId: number): Promise<void>;
612
+ /** Turn on the webhook trigger; returns the URL to POST to.
613
+ * `user_id` scopes to one end-user (404 on mismatch), like get/update/delete. */
614
+ enableWebhook(agentId: number, params?: {
615
+ user_id?: string;
616
+ }): Promise<WebhookToggle>;
617
+ disableWebhook(agentId: number, params?: {
618
+ user_id?: string;
619
+ }): Promise<void>;
402
620
  /** Turn on the agent's email inbox; returns the address that starts runs. */
403
- enableEmailInbox(agentId: number): Promise<EmailInbox>;
404
- disableEmailInbox(agentId: number): Promise<void>;
621
+ enableEmailInbox(agentId: number, params?: {
622
+ user_id?: string;
623
+ }): Promise<EmailInbox>;
624
+ disableEmailInbox(agentId: number, params?: {
625
+ user_id?: string;
626
+ }): Promise<void>;
405
627
  }
406
628
 
407
629
  /**
@@ -459,6 +681,509 @@ interface AppsResource {
459
681
  }): Promise<void>;
460
682
  }
461
683
 
684
+ /**
685
+ * `client.account` — the two operations that act on the whole account rather
686
+ * than anything inside it: take your data out, and shut the account down.
687
+ *
688
+ * Both exist to satisfy the GDPR/CCPA rights to access and to erasure, so they
689
+ * are here for compliance flows you have to be able to run programmatically —
690
+ * a data-subject request you are forwarding, or an offboarding path in your own
691
+ * product. Neither takes parameters: they always apply to the account behind
692
+ * the API key you authenticated with, and there is no `user_id` scoping. To
693
+ * remove one end-user's data instead, use `client.users.delete()`.
694
+ *
695
+ * Mirrors `sdk/py/m8tes/_resources/account.py`.
696
+ */
697
+
698
+ interface AccountResource {
699
+ /**
700
+ * Hand a customer (or a regulator) everything the account holds — the
701
+ * GDPR/CCPA right to access.
702
+ *
703
+ * The document covers the account's agents, tasks, runs, documents, memories,
704
+ * and integration metadata. Credentials and other secrets are never included,
705
+ * so an export is safe to forward but is NOT a backup you can restore from.
706
+ * It is a single JSON body, not a stream: a large account produces a large
707
+ * response, so allow for it in your request timeout.
708
+ */
709
+ export(): Promise<AccountExport>;
710
+ /**
711
+ * Close the account — the GDPR/CCPA right to erasure.
712
+ *
713
+ * Soft-delete, and it takes effect at once: sessions and the API key are
714
+ * revoked, billing is canceled, and all automation stops, with the data
715
+ * erased after a grace period. In other words the key you just called this
716
+ * with is dead afterwards, so nothing else in the SDK will work.
717
+ */
718
+ delete(): Promise<AccountDeletion>;
719
+ }
720
+ declare function createAccountResource(http: Http): AccountResource;
721
+
722
+ /**
723
+ * `client.users` — your end-users, the multi-tenancy boundary.
724
+ *
725
+ * `user_id` is YOUR identifier for a customer; the platform stores it as
726
+ * `end_user_id` and isolates that person's memory, run history, and tool
727
+ * connections strictly. There is no fallback to account-level data.
728
+ *
729
+ * Registering an end-user here is optional — passing `user_id` on a run creates
730
+ * them implicitly. Do it explicitly when you want per-user budgets and rate
731
+ * limits. Mirrors `sdk/py/m8tes/_resources/users.py`.
732
+ */
733
+
734
+ interface EndUserCreateParams {
735
+ /** Your id for this person. Any stable string. */
736
+ user_id: string;
737
+ name?: string;
738
+ email?: string;
739
+ company?: string;
740
+ metadata?: JsonObject;
741
+ /** Cap this end-user's runs per billing period. */
742
+ run_limit?: number;
743
+ /** Cap this end-user's spend per billing period, in cents. */
744
+ cost_limit_cents?: number;
745
+ /** Cap this end-user's runs per minute. Exceeding it returns 429. */
746
+ rate_per_minute?: number;
747
+ }
748
+ /** `null` CLEARS a cap (inherit the account default); omitting leaves it alone. */
749
+ interface EndUserUpdateParams {
750
+ name?: string | null;
751
+ email?: string | null;
752
+ company?: string | null;
753
+ metadata?: JsonObject | null;
754
+ run_limit?: number | null;
755
+ cost_limit_cents?: number | null;
756
+ rate_per_minute?: number | null;
757
+ }
758
+ interface PageParams {
759
+ limit?: number;
760
+ starting_after?: number;
761
+ }
762
+ interface UsersResource {
763
+ create(params: EndUserCreateParams): Promise<EndUser>;
764
+ list(params?: PageParams): Promise<Page<EndUser>>;
765
+ get(userId: string): Promise<EndUser>;
766
+ update(userId: string, params: EndUserUpdateParams): Promise<EndUser>;
767
+ delete(userId: string): Promise<void>;
768
+ /** Per-end-user token, run, and cost usage against their limits. */
769
+ usage(params?: PageParams & {
770
+ user_id?: string;
771
+ }): Promise<Page<EndUserUsage>>;
772
+ }
773
+
774
+ /**
775
+ * `client.billing` — what you have spent, what you may spend, and the ceiling.
776
+ *
777
+ * This is the resource you reach for when cost is a product requirement rather
778
+ * than an afterthought: read current-period usage (runs, model spend, accrued
779
+ * overage), break spend down by day / end-user / agent / model, fetch the public
780
+ * plan catalog, and set the caps — the monthly overage cap on plan accounts, and
781
+ * on prepaid accounts the token balance, top-ups, auto-reload, and the
782
+ * low-balance alert threshold.
783
+ *
784
+ * An embed developer capping what their own customers can burn lives here: pair
785
+ * `usageTimeseries({ user_id })` with the per-end-user limits on `client.users`
786
+ * to meter each tenant, and `setOverage` / `setAutoReload` to bound the account
787
+ * as a whole.
788
+ *
789
+ * Mirrors `sdk/py/m8tes/_resources/billing.py`.
790
+ */
791
+
792
+ interface UsageTimeseriesParams {
793
+ /** Inclusive ISO date (`"2026-07-01"`), UTC days. Defaults to 30 days ago. */
794
+ start_date?: string;
795
+ /** Inclusive ISO date. Defaults to today. */
796
+ end_date?: string;
797
+ /** Scope to one end-user. */
798
+ user_id?: string;
799
+ /** Scope to one agent. */
800
+ agent_id?: number;
801
+ /** Permanent legacy alias for `agent_id` — the same wire field. */
802
+ teammate_id?: number;
803
+ /** Creation stamp: `"api"` embedding, `"platform"` first-party. Not settlement. */
804
+ surface?: "api" | "platform";
805
+ /** Where the run settled: `"wallet"` is the prepaid ledger. */
806
+ settled_meter?: "wallet" | "plan" | "released" | "own_sub";
807
+ /** `"model"` adds per-model slices to every bucket's `models`. The route
808
+ * accepts this one value only, so it is a literal rather than a string. */
809
+ group_by?: "model";
810
+ }
811
+ interface OverageParams {
812
+ enabled: boolean;
813
+ /** Hard ceiling on overage spend per period, in cents. */
814
+ monthly_cap_cents: number;
815
+ }
816
+ interface TopupParams {
817
+ /** Cents to add. $5 minimum, $1M maximum. */
818
+ amount_cents: number;
819
+ }
820
+ /**
821
+ * Enabling auto-reload REQUIRES both amounts; disabling takes neither. Modelled
822
+ * as a union so `{ enabled: true }` alone is a compile error rather than a 422.
823
+ */
824
+ type AutoReloadParams = {
825
+ enabled: true;
826
+ /** Reload when the balance drops below this, in cents. */
827
+ threshold_cents: number;
828
+ /** Cents to charge per reload. $5–$10,000. */
829
+ amount_cents: number;
830
+ } | {
831
+ enabled: false;
832
+ /** Amounts may still be updated while disabled; the API applies them. */
833
+ threshold_cents?: number;
834
+ amount_cents?: number;
835
+ };
836
+ interface AlertThresholdParams {
837
+ /** Balance (cents) at which the low-balance warning fires. `0` warns only on depletion. */
838
+ low_balance_threshold_cents: number;
839
+ }
840
+ interface BillingResource {
841
+ /** Where you stand this period: plan, runs used vs included, model spend, and overage state. */
842
+ usage(): Promise<Usage>;
843
+ /**
844
+ * Spend broken down by UTC day — the series to chart, alert on, or reconcile
845
+ * against an invoice. Buckets are zero-filled across the whole window, so the
846
+ * array is safe to plot without gap-handling. Cost matches `usage().cost_used`
847
+ * semantics, so the series always reconciles with period totals. With
848
+ * `group_by: "model"`, runs that predate model attribution fold
849
+ * into a `"unknown"` slice rather than disappearing.
850
+ */
851
+ usageTimeseries(params?: UsageTimeseriesParams): Promise<UsageTimeseries>;
852
+ /**
853
+ * Proof of payment for finance: one row per paid prepaid top-up, newest first.
854
+ * `receipt_url` can be `null` when Stripe can no longer retrieve the session.
855
+ */
856
+ receipts(params?: PageParams): Promise<Page<Receipt>>;
857
+ /** What the paid plans include and cost — for your own pricing page or upgrade
858
+ * prompt. Public (paid) plans only, straight from the canonical catalog, and
859
+ * returned as a plain array rather than a page. */
860
+ plans(): Promise<Plan[]>;
861
+ /**
862
+ * Decide whether runs may continue past your plan's included allotment, and how
863
+ * far. Off by default; once enabled, extra runs bill at the per-run overage rate
864
+ * until `monthly_cap_cents` is reached. Returns the refreshed usage so you can
865
+ * confirm the new state without a second call.
866
+ */
867
+ setOverage(params: OverageParams): Promise<Usage>;
868
+ /** How much prepaid credit is left, and where it went (prepaid-billed accounts).
869
+ * Amounts are micro-USD; `balance_usd` is a rounded display string. */
870
+ balance(): Promise<Balance>;
871
+ /**
872
+ * Add credit when a human is present to pay. Returns a Stripe Checkout URL to
873
+ * send the buyer to — nothing is credited until they complete payment.
874
+ */
875
+ topup(params: TopupParams): Promise<string>;
876
+ /**
877
+ * Keep credit topped up without a human, so runs never stop for an empty wallet:
878
+ * a balance below `threshold_cents` charges `amount_cents` to the saved card
879
+ * off-session. Enabling requires a saved payment method (any completed top-up
880
+ * Checkout saves one) — without it this throws a billing error with code
881
+ * `NO_SAVED_PAYMENT_METHOD`. Disabling needs only `enabled: false`. At most one
882
+ * reload fires per 6-hour window. Returns the refreshed balance.
883
+ */
884
+ setAutoReload(params: AutoReloadParams): Promise<Balance>;
885
+ /**
886
+ * Choose when you want to hear about a draining balance. The critical tier is
887
+ * fixed at 20% of the value you set, and `0` warns only on depletion. Warnings
888
+ * arrive by email and as `balance.low` / `balance.critical` / `balance.depleted`
889
+ * webhook events. Returns the refreshed balance.
890
+ */
891
+ setAlertThreshold(params: AlertThresholdParams): Promise<Balance>;
892
+ }
893
+ declare function createBillingResource(http: Http): BillingResource;
894
+
895
+ /**
896
+ * `client.memories` — pre-load what an agent already knows about someone.
897
+ *
898
+ * A run starts cold unless it has memories to draw on. Writing them here lets you
899
+ * seed an end-user's context from data you already hold (plan, timezone, past
900
+ * decisions, preferences) so the first run behaves like the tenth, instead of
901
+ * waiting for the agent to learn it over several conversations.
902
+ *
903
+ * `user_id` is the scope, and the scopes never mix: with it, the memory belongs to
904
+ * that one end-user and is visible only to runs carrying the same `user_id`;
905
+ * without it, the memory is account-level and visible only to runs that carry no
906
+ * `user_id`. There is no inheritance between the two — an account-level memory is
907
+ * NOT a fallback for an end-user run.
908
+ *
909
+ * Documented at `/docs/users`. Mirrors `sdk/py/m8tes/_resources/memories.py`.
910
+ */
911
+
912
+ interface MemoryCreateParams {
913
+ /** The fact to remember, in plain language. */
914
+ content: string;
915
+ /** Scope it to one end-user. Omit for an account-level memory. */
916
+ user_id?: string;
917
+ }
918
+ interface MemoryListParams {
919
+ /** Scope to read. Omit to read account-level memories. */
920
+ user_id?: string;
921
+ /**
922
+ * Keyword filter on content (case-insensitive substring). It only narrows the
923
+ * chosen scope — it never reaches across into the other one — and paging
924
+ * applies to the filtered set.
925
+ */
926
+ query?: string;
927
+ limit?: number;
928
+ starting_after?: number;
929
+ }
930
+ interface MemoryUpdateParams {
931
+ /** Replaces the stored text outright. */
932
+ content: string;
933
+ /** The scope the memory lives in. Must match, or the memory is not found. */
934
+ user_id?: string;
935
+ }
936
+ interface MemoriesResource {
937
+ /**
938
+ * Teach an agent a fact up front, before anyone runs it.
939
+ *
940
+ * Throws a `ConflictError` (409) when the scope is already at its memory
941
+ * capacity, or when identical content is already stored in it — so this is
942
+ * safe to call repeatedly only if you handle that error.
943
+ */
944
+ create(params: MemoryCreateParams): Promise<Memory>;
945
+ /** Audit or display what an agent knows about one end-user (or the account). */
946
+ list(params?: MemoryListParams): Promise<Page<Memory>>;
947
+ /** Correct a fact that changed, keeping its id — rather than delete + re-create. */
948
+ update(memoryId: number, params: MemoryUpdateParams): Promise<Memory>;
949
+ /** Make an agent forget something, e.g. on an end-user's erasure request. */
950
+ delete(memoryId: number, params?: {
951
+ user_id?: string;
952
+ }): Promise<void>;
953
+ }
954
+ declare function createMemoriesResource(http: Http): MemoriesResource;
955
+
956
+ /**
957
+ * `client.models` — find out which `model` values are actually valid, and what
958
+ * they cost, instead of guessing from the docs.
959
+ *
960
+ * `model` is a plain string everywhere in this SDK, which keeps new models
961
+ * usable the day they're enabled but means a typo is only caught by the API. Ask
962
+ * this route instead: it returns the models your account can select right now
963
+ * (Anthropic and not — the set grows without an SDK release), which one is the
964
+ * default, and the per-million-token prices the platform bills you at, so you
965
+ * can estimate spend before starting a run.
966
+ *
967
+ * Mirrors `sdk/py/m8tes/_resources/models.py`.
968
+ */
969
+
970
+ interface ModelsResource {
971
+ /**
972
+ * The models you can pass as `model` on an agent or a run, with USD pricing
973
+ * per million tokens.
974
+ *
975
+ * Omit `model` on an agent/run to get the entry flagged `default: true` — that
976
+ * flag is per-viewer, so the default you see here is the default you'd get.
977
+ *
978
+ * Takes no arguments and has no cursor: `GET /models/` returns the whole
979
+ * catalog in one response. A `Page` is still returned so `for await` works the
980
+ * same as on every other list, but it never fetches a second page.
981
+ */
982
+ /**
983
+ * The model catalog. Check `zdr_supported` before sending customer data: a
984
+ * non-ZDR model is allowed on the API but may retain inputs and outputs.
985
+ */
986
+ list(): Promise<Page<Model>>;
987
+ }
988
+ declare function createModelsResource(http: Http): ModelsResource;
989
+
990
+ /** Account-level OAuth subscriptions used by the Claude Code execution harness. */
991
+
992
+ type ModelConnectionProvider = "claude" | "openai" | "xai" | "gemini";
993
+ type AuthorizableModelConnectionProvider = "openai" | "xai" | "gemini";
994
+ type DeviceModelConnectionProvider = "openai" | "xai";
995
+ type CodeModelConnectionProvider = "gemini";
996
+ interface ModelConnection {
997
+ provider: ModelConnectionProvider;
998
+ display_name: string;
999
+ connected: boolean;
1000
+ status?: string | null;
1001
+ account_label?: string | null;
1002
+ expires_at?: string | null;
1003
+ }
1004
+ interface ModelAuthorization {
1005
+ provider: AuthorizableModelConnectionProvider;
1006
+ state: string;
1007
+ status: "pending" | "connected";
1008
+ authorization_url?: string | null;
1009
+ user_code?: string | null;
1010
+ expires_at?: string | null;
1011
+ interval_seconds: number;
1012
+ }
1013
+ interface ModelConnectionsResource {
1014
+ /** List supported providers. Credential material is never returned. */
1015
+ list(): Promise<ModelConnection[]>;
1016
+ /** Start provider-native authorization; show the returned URL and device code when used. */
1017
+ authorize(provider: AuthorizableModelConnectionProvider): Promise<ModelAuthorization>;
1018
+ /** Poll once; successful device authorization is saved automatically. */
1019
+ authorizationStatus(provider: DeviceModelConnectionProvider, state: string): Promise<ModelAuthorization>;
1020
+ /** Exchange a pasted authorization code and store the connection. */
1021
+ completeAuthorization(provider: CodeModelConnectionProvider, state: string, params: {
1022
+ code: string;
1023
+ }): Promise<ModelAuthorization>;
1024
+ /** Cancel a short-lived provider authorization session. */
1025
+ cancelAuthorization(provider: AuthorizableModelConnectionProvider, state: string): Promise<void>;
1026
+ /** Delete m8tes' encrypted copy of the provider credentials. */
1027
+ disconnect(provider: ModelConnectionProvider): Promise<ModelConnection>;
1028
+ }
1029
+ declare function createModelConnectionsResource(http: Http): ModelConnectionsResource;
1030
+
1031
+ /**
1032
+ * `client.permissions` — standing tool allow-lists, one end-user at a time.
1033
+ *
1034
+ * A run pauses whenever the agent reaches for a tool that is not pre-approved,
1035
+ * and stays paused until somebody answers. That is the right default for a first
1036
+ * run and the wrong one for a tool your product has already decided is fine. A
1037
+ * policy here says "this end-user's runs may use this tool" once, so their runs
1038
+ * stop stopping.
1039
+ *
1040
+ * Scope: policies are per end-user (`user_id` is required on every call — there
1041
+ * is no account-wide policy) and outlive the run, unlike `runs.answerPermission()`
1042
+ * which unblocks a single gate. `/docs/users` documents this surface; mirrors
1043
+ * `sdk/py/m8tes/_resources/permissions.py`.
1044
+ */
1045
+
1046
+ interface PermissionCreateParams {
1047
+ /** The end-user whose runs this policy applies to. Required — policies never span end-users. */
1048
+ user_id: string;
1049
+ /** The tool to pre-approve, e.g. `"Bash"` or an `mcp__*` tool name. */
1050
+ tool: string;
1051
+ }
1052
+ interface PermissionListParams extends PageParams {
1053
+ /** Required: you list one end-user's policies, never the account's. */
1054
+ user_id: string;
1055
+ }
1056
+ interface PermissionsResource {
1057
+ /**
1058
+ * Pre-approve a tool so this end-user's runs no longer pause on it.
1059
+ * Idempotent — re-approving the same tool returns the existing policy rather
1060
+ * than erroring or duplicating. Send `tool`; the policy comes back as `tool_name`.
1061
+ */
1062
+ create(params: PermissionCreateParams): Promise<PermissionPolicy>;
1063
+ /** Audit what an end-user's runs are allowed to do without asking. */
1064
+ list(params: PermissionListParams): Promise<Page<PermissionPolicy>>;
1065
+ /**
1066
+ * Revoke a pre-approval, so the tool gates again on the next run.
1067
+ * `user_id` is required and scopes the delete — an id alone will not resolve.
1068
+ */
1069
+ delete(permissionId: number, params: {
1070
+ user_id: string;
1071
+ }): Promise<void>;
1072
+ }
1073
+ declare function createPermissionsResource(http: Http): PermissionsResource;
1074
+
1075
+ /**
1076
+ * Wait for a run to finish.
1077
+ *
1078
+ * Streaming is the good path: you see the work as it happens. But plenty of
1079
+ * integrations are a queue worker or a cron job that just wants the answer, and
1080
+ * without this every one of them hand-rolls the same loop — with its own idea of
1081
+ * which statuses are terminal, its own backoff, and usually no timeout. That is
1082
+ * the single most common thing a developer had to build themselves.
1083
+ *
1084
+ * Mirrors `sdk/py/m8tes/_resources/runs.py` (`poll`, `wait`): same terminal set,
1085
+ * same 2s interval and 300s default timeout, same "a transient API error is not
1086
+ * a failure, keep polling until the deadline" behaviour.
1087
+ */
1088
+
1089
+ /**
1090
+ * A run is done when it reaches one of these.
1091
+ *
1092
+ * Mirrors `TERMINAL_RUN_STATUSES` in `fastapi/app/models/run.py`, which is the
1093
+ * canonical set — including `"closed"` (a user-closed chat that cannot resume).
1094
+ * Both SDKs previously omitted it, so a closed run polled until the timeout.
1095
+ * The backend's own comment on that set warns these lists drift and that "a
1096
+ * 'closed' chat run burned tokens too". `archived` is deliberately NOT here:
1097
+ * it is a display state applied to already-terminal runs.
1098
+ */
1099
+ declare const TERMINAL_STATUSES: Set<string>;
1100
+ interface PollOptions {
1101
+ /** Seconds between polls. Default 2. */
1102
+ interval?: number;
1103
+ /** Seconds before giving up. Default 300. */
1104
+ timeout?: number;
1105
+ /** Abort the wait early. The in-flight request is cancelled with it. */
1106
+ signal?: AbortSignal;
1107
+ }
1108
+ interface WaitOptions extends PollOptions {
1109
+ /**
1110
+ * Called when a tool needs a decision. Return "allow" or "deny".
1111
+ * Without it, a run that pauses for a tool throws rather than hanging until
1112
+ * the timeout — silence would look identical to a slow run.
1113
+ */
1114
+ onApproval?: (request: PermissionRequest) => "allow" | "deny" | Promise<"allow" | "deny">;
1115
+ /**
1116
+ * Called when the agent asks a question. Return `{ [question text]: answer }`.
1117
+ * The keys must be the exact `question` strings from the request.
1118
+ */
1119
+ onQuestion?: (request: PermissionRequest) => Record<string, string> | Promise<Record<string, string>>;
1120
+ }
1121
+ /** Thrown when a run does not reach a terminal status before the deadline. */
1122
+ declare class RunTimeoutError extends Error {
1123
+ readonly runId: number;
1124
+ readonly timeoutSeconds: number;
1125
+ /** The last error seen while polling, if any. Without it a timeout hides the
1126
+ * transient failure that actually caused it. */
1127
+ readonly cause?: unknown;
1128
+ /** The run's status when the deadline hit, when one was ever observed. */
1129
+ readonly lastStatus?: string;
1130
+ constructor(runId: number, timeoutSeconds: number, cause?: unknown, lastStatus?: string);
1131
+ }
1132
+ /**
1133
+ * Thrown when a run pauses for a human and no handler was supplied. Better than
1134
+ * waiting out the full timeout, which gives the caller no idea what happened.
1135
+ */
1136
+ declare class RunPausedError extends Error {
1137
+ readonly runId: number;
1138
+ readonly request: PermissionRequest;
1139
+ constructor(runId: number, request: PermissionRequest, hint: string);
1140
+ }
1141
+ /** True for an AskUserQuestion pause carrying a plan for approval (plan mode). */
1142
+ declare function isPlanApproval(request: PermissionRequest): boolean;
1143
+ /** The proposed plan text, for a plan-approval pause. Null otherwise. */
1144
+ declare function planText(request: PermissionRequest): string | null;
1145
+ /**
1146
+ * Injected by the runs resource so this module stays free of transport concerns.
1147
+ * Every call takes the caller's `signal`, so an abort cancels the in-flight HTTP
1148
+ * request instead of only shortening the next sleep.
1149
+ */
1150
+ interface PollDeps {
1151
+ get(runId: number, signal?: AbortSignal): Promise<Run>;
1152
+ permissions(runId: number, signal?: AbortSignal): Promise<PermissionRequest[]>;
1153
+ approve(runId: number, params: {
1154
+ request_id: string;
1155
+ decision: "allow" | "deny";
1156
+ }, signal?: AbortSignal): Promise<unknown>;
1157
+ answer(runId: number, params: {
1158
+ answers: Record<string, string>;
1159
+ }, signal?: AbortSignal): Promise<unknown>;
1160
+ }
1161
+ /** Thrown when the caller aborts the wait. */
1162
+ declare class RunWaitAbortedError extends Error {
1163
+ /**
1164
+ * The run being waited on — `undefined` when the abort landed BEFORE any run
1165
+ * was created, which is the one case where there is nothing to go back to.
1166
+ * Previously this path passed a literal 0, producing "Waiting on run 0 was
1167
+ * aborted" and pointing the reader at a run that never existed.
1168
+ */
1169
+ readonly runId?: number;
1170
+ constructor(runId?: number);
1171
+ }
1172
+ /**
1173
+ * Poll until the run is terminal.
1174
+ *
1175
+ * A run that pauses for a human never becomes terminal, so this would spin until
1176
+ * the timeout — `waitForRun` handles that case. `poll` is for autonomous runs.
1177
+ */
1178
+ declare function pollRun(deps: PollDeps, runId: number, options?: PollOptions): Promise<Run>;
1179
+ /**
1180
+ * Wait for a run, answering human-in-the-loop pauses through callbacks.
1181
+ *
1182
+ * Same loop as `pollRun`, plus: on `awaiting_approval`, resolve every pending
1183
+ * request and let the run continue.
1184
+ */
1185
+ declare function waitForRun(deps: PollDeps, runId: number, options?: WaitOptions): Promise<Run>;
1186
+
462
1187
  /**
463
1188
  * `RunStream` — the developer-facing view of a streaming run.
464
1189
  *
@@ -481,6 +1206,13 @@ interface RunStreamOptions {
481
1206
  * Defaults to false, matching the Python SDK.
482
1207
  */
483
1208
  raiseOnError?: boolean;
1209
+ /**
1210
+ * Reuse this key to retry the same call safely — the server replays the run the
1211
+ * first attempt produced instead of starting (and billing) a second one. One is
1212
+ * minted per call automatically; supply your own only when a retry must survive
1213
+ * a process restart. Sent as the `Idempotency-Key` header.
1214
+ */
1215
+ idempotencyKey?: string;
484
1216
  }
485
1217
  declare class RunStream implements AsyncIterable<M8tesStreamEvent> {
486
1218
  private readonly source;
@@ -548,6 +1280,40 @@ interface RunCreateParams {
548
1280
  output_schema?: JsonObject;
549
1281
  /** Give this run's agent an email inbox. */
550
1282
  email_inbox?: boolean;
1283
+ /**
1284
+ * Reuse this key to retry the same create safely — the server returns the run
1285
+ * the first attempt made instead of starting (and billing) a second one.
1286
+ *
1287
+ * One is minted per call automatically, which is what makes the SDK's own
1288
+ * retries safe. Supply your own only when a retry must survive a process
1289
+ * restart: a job runner re-driving the same unit of work should pass its job
1290
+ * id. Sent as the `Idempotency-Key` header; never part of the request body.
1291
+ */
1292
+ idempotencyKey?: string;
1293
+ /**
1294
+ * Files the agent can read: a CSV to analyze, a PDF to summarize. Each is a
1295
+ * `{ name, data }` pair; `data` accepts anything `FormData` takes (Blob,
1296
+ * Uint8Array, ArrayBuffer, string). Sending files switches the request to the
1297
+ * multipart `/runs/with-files` endpoint; every other option behaves the same.
1298
+ *
1299
+ * Attachments require sandbox execution (the agent reads them with its file
1300
+ * tools from the run's working directory).
1301
+ */
1302
+ files?: RunFileInput[];
1303
+ }
1304
+ /** One attachment for `runs.create({ files })`. */
1305
+ interface RunFileInput {
1306
+ /** Filename the agent will see. Its extension determines the content type. */
1307
+ name: string;
1308
+ /** Contents. `Blob`/`File` pass straight through; bytes and strings are wrapped. */
1309
+ data: Blob | ArrayBuffer | ArrayBufferView | string;
1310
+ /**
1311
+ * Content type, if the extension does not imply it. The upload endpoint
1312
+ * validates against an allowlist and rejects the batch on a miss, so this is
1313
+ * inferred from `name` by default rather than defaulting to
1314
+ * `application/octet-stream` (which the server refuses).
1315
+ */
1316
+ type?: string;
551
1317
  }
552
1318
  interface RunListParams {
553
1319
  user_id?: string;
@@ -580,6 +1346,27 @@ interface RunsResource {
580
1346
  create(params: RunCreateParams, options?: RunStreamOptions): RunStream;
581
1347
  /** Start a run and return immediately; poll `get()` or use a webhook for the result. */
582
1348
  createAsync(params: RunCreateParams): Promise<Run>;
1349
+ /**
1350
+ * Start a run and wait for the result. The batch/cron counterpart to `create()`.
1351
+ * Pass `onApproval`/`onQuestion` to answer human-in-the-loop pauses inline;
1352
+ * without them a paused run throws `RunPausedError` rather than hanging.
1353
+ */
1354
+ createAndWait(params: RunCreateParams, options?: WaitOptions): Promise<Run>;
1355
+ /** Poll an existing run until it is terminal. Throws `RunTimeoutError` on deadline. */
1356
+ poll(runId: number, options?: PollOptions): Promise<Run>;
1357
+ /** Like `poll`, but resolves human-in-the-loop pauses through callbacks. */
1358
+ wait(runId: number, options?: WaitOptions): Promise<Run>;
1359
+ /**
1360
+ * Retry a failed or cancelled run. Returns a NEW run — poll that one's id, the
1361
+ * original stays failed. Idempotent: an in-flight retry is returned as-is.
1362
+ *
1363
+ * If the run already did something visible (sent a message, changed data), the
1364
+ * API refuses with a 409 `retry_needs_confirmation`; pass `confirm: true` to
1365
+ * proceed. Check `run.retryable` first to avoid a guaranteed conflict.
1366
+ */
1367
+ retry(runId: number, params?: {
1368
+ confirm?: boolean;
1369
+ }): Promise<Run>;
583
1370
  /** Join a run already in flight. Throws `RunNotStreamingError` if it has finished. */
584
1371
  stream(runId: number, options?: RunStreamOptions): RunStream;
585
1372
  /** Continue the conversation on an existing run, streaming the reply. */
@@ -743,17 +1530,35 @@ interface TriggerCreateParams {
743
1530
  }
744
1531
  interface TriggersResource {
745
1532
  create(taskId: number, params: TriggerCreateParams): Promise<Trigger>;
746
- list(taskId: number): Promise<Trigger[]>;
1533
+ list(taskId: number, params?: {
1534
+ user_id?: string;
1535
+ }): Promise<Trigger[]>;
747
1536
  /** Only the schedule shape and the enabled flag are mutable — a trigger's
748
1537
  * `type`/`app`/`trigger_name` are fixed at creation and are silently ignored
749
- * on PATCH. Delete and recreate to change those. */
1538
+ * on PATCH. Delete and recreate to change those. `user_id` scopes to one
1539
+ * end-user (404 on mismatch). */
750
1540
  update(taskId: number, triggerId: number, params: {
751
1541
  cron?: string;
752
1542
  interval_seconds?: number;
753
1543
  timezone?: string;
754
1544
  enabled?: boolean;
1545
+ user_id?: string;
755
1546
  }): Promise<Trigger>;
756
- delete(taskId: number, triggerId: number): Promise<void>;
1547
+ delete(taskId: number, triggerId: number, params?: {
1548
+ user_id?: string;
1549
+ }): Promise<void>;
1550
+ }
1551
+ interface TaskRunParams {
1552
+ /** Run on behalf of this end-user. */
1553
+ user_id?: string;
1554
+ /**
1555
+ * Reuse this key to retry the same call safely — the server returns the run the
1556
+ * first attempt made instead of starting (and billing) a second one. One is
1557
+ * minted per call automatically; supply your own (e.g. a scheduler's job id)
1558
+ * only when a retry must survive a process restart. Sent as the
1559
+ * `Idempotency-Key` header, never in the body.
1560
+ */
1561
+ idempotencyKey?: string;
757
1562
  }
758
1563
  interface TasksResource {
759
1564
  triggers: TriggersResource;
@@ -769,67 +1574,16 @@ interface TasksResource {
769
1574
  user_id?: string;
770
1575
  }): Promise<void>;
771
1576
  /** Run the task now, streaming it. */
772
- run(taskId: number, params?: {
773
- user_id?: string;
774
- }, options?: RunStreamOptions): RunStream;
1577
+ run(taskId: number, params?: TaskRunParams, options?: RunStreamOptions): RunStream;
775
1578
  /** Run the task now without streaming; poll `runs.get()` for the result. */
776
- runAsync(taskId: number, params?: {
1579
+ runAsync(taskId: number, params?: TaskRunParams): Promise<Run>;
1580
+ /** `user_id` scopes to one end-user (404 on mismatch), like get/update/delete. */
1581
+ enableWebhook(taskId: number, params?: {
777
1582
  user_id?: string;
778
- }): Promise<Run>;
779
- enableWebhook(taskId: number): Promise<WebhookToggle>;
780
- disableWebhook(taskId: number): Promise<void>;
781
- }
782
-
783
- /**
784
- * `client.users` — your end-users, the multi-tenancy boundary.
785
- *
786
- * `user_id` is YOUR identifier for a customer; the platform stores it as
787
- * `end_user_id` and isolates that person's memory, run history, and tool
788
- * connections strictly. There is no fallback to account-level data.
789
- *
790
- * Registering an end-user here is optional — passing `user_id` on a run creates
791
- * them implicitly. Do it explicitly when you want per-user budgets and rate
792
- * limits. Mirrors `sdk/py/m8tes/_resources/users.py`.
793
- */
794
-
795
- interface EndUserCreateParams {
796
- /** Your id for this person. Any stable string. */
797
- user_id: string;
798
- name?: string;
799
- email?: string;
800
- company?: string;
801
- metadata?: JsonObject;
802
- /** Cap this end-user's runs per billing period. */
803
- run_limit?: number;
804
- /** Cap this end-user's spend per billing period, in cents. */
805
- cost_limit_cents?: number;
806
- /** Cap this end-user's runs per minute. Exceeding it returns 429. */
807
- rate_per_minute?: number;
808
- }
809
- /** `null` CLEARS a cap (inherit the account default); omitting leaves it alone. */
810
- interface EndUserUpdateParams {
811
- name?: string | null;
812
- email?: string | null;
813
- company?: string | null;
814
- metadata?: JsonObject | null;
815
- run_limit?: number | null;
816
- cost_limit_cents?: number | null;
817
- rate_per_minute?: number | null;
818
- }
819
- interface PageParams {
820
- limit?: number;
821
- starting_after?: number;
822
- }
823
- interface UsersResource {
824
- create(params: EndUserCreateParams): Promise<EndUser>;
825
- list(params?: PageParams): Promise<Page<EndUser>>;
826
- get(userId: string): Promise<EndUser>;
827
- update(userId: string, params: EndUserUpdateParams): Promise<EndUser>;
828
- delete(userId: string): Promise<void>;
829
- /** Per-end-user token, run, and cost usage against their limits. */
830
- usage(params?: PageParams & {
1583
+ }): Promise<WebhookToggle>;
1584
+ disableWebhook(taskId: number, params?: {
831
1585
  user_id?: string;
832
- }): Promise<Page<EndUserUsage>>;
1586
+ }): Promise<void>;
833
1587
  }
834
1588
 
835
1589
  /**
@@ -918,7 +1672,7 @@ interface WebhooksResource {
918
1672
  */
919
1673
 
920
1674
  /** Kept in lockstep with package.json "version" — guarded by test/version.test.ts. */
921
- declare const M8TES_SDK_VERSION = "0.1.0-alpha.1";
1675
+ declare const M8TES_SDK_VERSION = "0.1.0-alpha.2";
922
1676
  declare class M8tes {
923
1677
  readonly runs: RunsResource;
924
1678
  readonly agents: AgentsResource;
@@ -929,9 +1683,15 @@ declare class M8tes {
929
1683
  readonly apps: AppsResource;
930
1684
  readonly webhooks: WebhooksResource;
931
1685
  readonly settings: SettingsResource;
1686
+ readonly memories: MemoriesResource;
1687
+ readonly permissions: PermissionsResource;
1688
+ readonly models: ModelsResource;
1689
+ readonly modelConnections: ModelConnectionsResource;
1690
+ readonly billing: BillingResource;
1691
+ readonly account: AccountResource;
932
1692
  /** The underlying transport. Use it to call an endpoint this version does not wrap yet. */
933
1693
  readonly http: Http;
934
1694
  constructor(options?: ClientOptions);
935
1695
  }
936
1696
 
937
- export { type AccountSettings, type AccountSettingsUpdateParams, type Agent, type AgentCreateParams, type AgentListParams, type AgentUpdateParams, type AgentsResource, type App, type AppConnectionInitiation, type AppConnectionResult, type AppsResource, type ClientOptions, ConversationState, DEFAULT_BASE_URL, type EmailInbox, type EndUser, type EndUserCreateParams, type EndUserUpdateParams, type EndUserUsage, type FetchLike, type Http, type JsonObject, type ListResponse, M8TES_SDK_VERSION, M8tes, M8tesStreamEvent, Normalizer, Page, type PageParams, type PermissionMode, type PermissionRequest, type Run, type RunCreateParams, type RunFile, type RunListParams, type RunOutcome, RunStream, type RunStreamOptions, type RunUsage, type RunsResource, type SettingsResource, type Task, type TaskCreateParams, type TaskListParams, type TaskUpdateParams, type TasksResource, type Teammate, type Trigger, type TriggerCreateParams, type TriggerType, type TriggersResource, type UsersResource, type VerifySignatureOptions, type Webhook, type WebhookDelivery, type WebhookToggle, type WebhooksResource, createHttp, verifySignature };
1697
+ 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 };