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

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
@@ -91,14 +91,17 @@ declare function createHttp(options?: ClientOptions): Http;
91
91
  interface ListResponse<T> {
92
92
  data: T[];
93
93
  hasMore: boolean;
94
+ /** Cursor for `?starting_after=` when `hasMore` is true; mirrors the Python SDK. */
95
+ nextStartingAfter?: string | number | null;
94
96
  }
95
97
  /** A page of results. `for await (const item of page)` walks ALL pages. */
96
98
  declare class Page<T> implements ListResponse<T>, AsyncIterable<T> {
97
99
  readonly data: T[];
98
100
  readonly hasMore: boolean;
101
+ readonly nextStartingAfter?: string | number | null;
99
102
  /** Fetches the next page given a cursor. Absent on a terminal page. */
100
103
  private readonly fetchNext?;
101
- constructor(data: T[], hasMore: boolean, fetchNext?: (startingAfter: string | number) => Promise<Page<T>>);
104
+ constructor(data: T[], hasMore: boolean, fetchNext?: (startingAfter: string | number) => Promise<Page<T>>, nextStartingAfter?: string | number | null);
102
105
  /**
103
106
  * Auto-paging: yields every item across every page.
104
107
  *
@@ -168,6 +171,12 @@ interface Agent {
168
171
  enable_task_setup_tools?: boolean | null;
169
172
  enable_feedback?: boolean | null;
170
173
  enable_self_improvement?: boolean | null;
174
+ /** Most recent run activity in the last 90 days; null if idle longer. */
175
+ last_active_at?: string | null;
176
+ /** How many runs are executing or awaiting approval right now. */
177
+ active_run_count?: number;
178
+ /** Sole live run id when active_run_count is exactly 1; otherwise null. */
179
+ active_run_id?: number | null;
171
180
  }
172
181
  /** Permanent alias — the platform term is "agent", the DB model is `Teammate`. */
173
182
  type Teammate = Agent;
@@ -209,6 +218,9 @@ interface RunOutcome {
209
218
  summary: string | null;
210
219
  headline: string | null;
211
220
  needs_reply: boolean;
221
+ needs_reply_count: number | null;
222
+ /** How the agent chose to deliver this outcome: email, slack, or none. */
223
+ delivery_channel: string;
212
224
  output_data: JsonObject | null;
213
225
  message_count: number;
214
226
  input_tokens: number;
@@ -228,6 +240,10 @@ interface PermissionRequest {
228
240
  created_at: string;
229
241
  resolved_at: string | null;
230
242
  auto_resolved?: boolean;
243
+ /** False when the runtime would ignore an "always allow" for this tool. */
244
+ can_remember?: boolean;
245
+ /** False when the Always-allow control must start unticked (force-ask floor). */
246
+ remember_default?: boolean;
231
247
  }
232
248
  interface Task {
233
249
  id: number;
@@ -250,6 +266,7 @@ interface Task {
250
266
  enable_task_setup_tools?: boolean | null;
251
267
  enable_feedback?: boolean | null;
252
268
  enable_lessons?: boolean;
269
+ permission_mode?: PermissionMode | null;
253
270
  }
254
271
  type TriggerType = "schedule" | "webhook" | "email" | "app";
255
272
  interface Trigger {
@@ -429,6 +446,8 @@ interface PermissionPolicy {
429
446
  user_id: string;
430
447
  tool_name: string;
431
448
  created_at: string;
449
+ /** Which surface minted the grant ("run_approval" / "api"); null on legacy rows. */
450
+ source?: string | null;
432
451
  }
433
452
  /**
434
453
  * Billing usage and limits for the current period.
@@ -452,6 +471,8 @@ interface Usage {
452
471
  overage_cap_cents: number;
453
472
  overage_rate_cents: number;
454
473
  trial_ends_at?: string | null;
474
+ /** True when the account bypasses the included-runs meter (admin/unlimited). */
475
+ unlimited_runs?: boolean;
455
476
  }
456
477
  /** Token + USD totals over a usage-timeseries window. `cost_usd` is a string. */
457
478
  interface UsageTotals {
@@ -585,6 +606,8 @@ interface AgentUpdateParams {
585
606
  model?: string | null;
586
607
  effort?: string | null;
587
608
  default_permission_mode?: PermissionMode | null;
609
+ /** Who can see this agent. Omit or null leaves it unchanged. */
610
+ visibility?: "personal" | "organization" | null;
588
611
  allowed_senders?: string[] | null;
589
612
  enable_memory?: boolean | null;
590
613
  enable_history?: boolean | null;
@@ -1025,6 +1048,8 @@ interface ModelConnectionsResource {
1025
1048
  cancelAuthorization(provider: AuthorizableModelConnectionProvider, state: string): Promise<void>;
1026
1049
  /** Delete m8tes' encrypted copy of the provider credentials. */
1027
1050
  disconnect(provider: ModelConnectionProvider): Promise<ModelConnection>;
1051
+ /** Clear the account model-plan default so platform mates use m8tes credits again. */
1052
+ clearDefault(): Promise<boolean>;
1028
1053
  }
1029
1054
  declare function createModelConnectionsResource(http: Http): ModelConnectionsResource;
1030
1055
 
@@ -1104,6 +1129,11 @@ interface PollOptions {
1104
1129
  timeout?: number;
1105
1130
  /** Abort the wait early. The in-flight request is cancelled with it. */
1106
1131
  signal?: AbortSignal;
1132
+ /**
1133
+ * End-user scope for each `GET /runs/{id}` poll. Required when the account
1134
+ * has strict multi-tenant mode on — without it every poll 422s.
1135
+ */
1136
+ user_id?: string;
1107
1137
  }
1108
1138
  interface WaitOptions extends PollOptions {
1109
1139
  /**
@@ -1329,8 +1359,13 @@ interface ApproveParams {
1329
1359
  request_id: string;
1330
1360
  decision: "allow" | "deny";
1331
1361
  /**
1332
- * Apply the same decision to matching tool requests for the rest of THIS run.
1333
- * For a policy that outlives the run, use the permissions API instead.
1362
+ * Persist beyond this single gate.
1363
+ * - `false` (default): this request only.
1364
+ * - `true` + allow: also silence matching tools for the rest of THIS run AND
1365
+ * store a cross-run always-allow policy (scoped to the run's end-user when
1366
+ * set; revoke via `/permissions`).
1367
+ * - `true` + deny: deny matching tools for the rest of THIS run only (no
1368
+ * stored policy).
1334
1369
  */
1335
1370
  remember?: boolean;
1336
1371
  }
@@ -1366,17 +1401,23 @@ interface RunsResource {
1366
1401
  */
1367
1402
  retry(runId: number, params?: {
1368
1403
  confirm?: boolean;
1404
+ use_credits?: boolean;
1369
1405
  }): Promise<Run>;
1370
1406
  /** Join a run already in flight. Throws `RunNotStreamingError` if it has finished. */
1371
1407
  stream(runId: number, options?: RunStreamOptions): RunStream;
1372
1408
  /** Continue the conversation on an existing run, streaming the reply. */
1373
1409
  reply(runId: number, message: string, options?: RunStreamOptions): RunStream;
1374
- /** GET /runs/{id} takes NO query params it is already account-scoped, and
1375
- * sending `user_id` returns 422 `unknown_query_parameter`. */
1376
- get(runId: number): Promise<Run>;
1410
+ /** GET /runs/{id}. Pass `user_id` to scope to one end-user (required when the
1411
+ * account has strict multi-tenant mode on). */
1412
+ get(runId: number, params?: {
1413
+ user_id?: string;
1414
+ }): Promise<Run>;
1377
1415
  list(params?: RunListParams): Promise<Page<Run>>;
1378
- /** Cancel a running run. Returns the updated Run, like the Python SDK. */
1379
- cancel(runId: number): Promise<Run>;
1416
+ /** Cancel a running run. Returns the updated Run, like the Python SDK.
1417
+ * Pass `user_id` when the account has strict multi-tenant mode on. */
1418
+ cancel(runId: number, params?: {
1419
+ user_id?: string;
1420
+ }): Promise<Run>;
1380
1421
  /** Approve or deny a pending tool-permission gate. */
1381
1422
  approve(runId: number, params: ApproveParams): Promise<PermissionRequest>;
1382
1423
  /** Answer a pending AskUserQuestion gate, resuming the run. */
@@ -1481,6 +1522,8 @@ interface TaskCreateFields {
1481
1522
  enable_feedback?: boolean;
1482
1523
  /** Accumulate self-improvement lessons across this task's runs. Default true. */
1483
1524
  enable_lessons?: boolean;
1525
+ /** How this task's runs ask for approval. Default: the agent's default. */
1526
+ permission_mode?: PermissionMode;
1484
1527
  }
1485
1528
  /**
1486
1529
  * PATCH /tasks/{id} accepts exactly these fields (backend `DevTaskUpdate`).
@@ -1502,6 +1545,7 @@ interface TaskUpdateParams {
1502
1545
  enable_task_setup_tools?: boolean | null;
1503
1546
  enable_feedback?: boolean | null;
1504
1547
  enable_lessons?: boolean | null;
1548
+ permission_mode?: PermissionMode | null;
1505
1549
  }
1506
1550
  interface TaskListParams {
1507
1551
  user_id?: string;
@@ -1672,7 +1716,7 @@ interface WebhooksResource {
1672
1716
  */
1673
1717
 
1674
1718
  /** Kept in lockstep with package.json "version" — guarded by test/version.test.ts. */
1675
- declare const M8TES_SDK_VERSION = "0.1.0-alpha.2";
1719
+ declare const M8TES_SDK_VERSION = "0.1.0-alpha.4";
1676
1720
  declare class M8tes {
1677
1721
  readonly runs: RunsResource;
1678
1722
  readonly agents: AgentsResource;
package/dist/index.d.ts CHANGED
@@ -91,14 +91,17 @@ declare function createHttp(options?: ClientOptions): Http;
91
91
  interface ListResponse<T> {
92
92
  data: T[];
93
93
  hasMore: boolean;
94
+ /** Cursor for `?starting_after=` when `hasMore` is true; mirrors the Python SDK. */
95
+ nextStartingAfter?: string | number | null;
94
96
  }
95
97
  /** A page of results. `for await (const item of page)` walks ALL pages. */
96
98
  declare class Page<T> implements ListResponse<T>, AsyncIterable<T> {
97
99
  readonly data: T[];
98
100
  readonly hasMore: boolean;
101
+ readonly nextStartingAfter?: string | number | null;
99
102
  /** Fetches the next page given a cursor. Absent on a terminal page. */
100
103
  private readonly fetchNext?;
101
- constructor(data: T[], hasMore: boolean, fetchNext?: (startingAfter: string | number) => Promise<Page<T>>);
104
+ constructor(data: T[], hasMore: boolean, fetchNext?: (startingAfter: string | number) => Promise<Page<T>>, nextStartingAfter?: string | number | null);
102
105
  /**
103
106
  * Auto-paging: yields every item across every page.
104
107
  *
@@ -168,6 +171,12 @@ interface Agent {
168
171
  enable_task_setup_tools?: boolean | null;
169
172
  enable_feedback?: boolean | null;
170
173
  enable_self_improvement?: boolean | null;
174
+ /** Most recent run activity in the last 90 days; null if idle longer. */
175
+ last_active_at?: string | null;
176
+ /** How many runs are executing or awaiting approval right now. */
177
+ active_run_count?: number;
178
+ /** Sole live run id when active_run_count is exactly 1; otherwise null. */
179
+ active_run_id?: number | null;
171
180
  }
172
181
  /** Permanent alias — the platform term is "agent", the DB model is `Teammate`. */
173
182
  type Teammate = Agent;
@@ -209,6 +218,9 @@ interface RunOutcome {
209
218
  summary: string | null;
210
219
  headline: string | null;
211
220
  needs_reply: boolean;
221
+ needs_reply_count: number | null;
222
+ /** How the agent chose to deliver this outcome: email, slack, or none. */
223
+ delivery_channel: string;
212
224
  output_data: JsonObject | null;
213
225
  message_count: number;
214
226
  input_tokens: number;
@@ -228,6 +240,10 @@ interface PermissionRequest {
228
240
  created_at: string;
229
241
  resolved_at: string | null;
230
242
  auto_resolved?: boolean;
243
+ /** False when the runtime would ignore an "always allow" for this tool. */
244
+ can_remember?: boolean;
245
+ /** False when the Always-allow control must start unticked (force-ask floor). */
246
+ remember_default?: boolean;
231
247
  }
232
248
  interface Task {
233
249
  id: number;
@@ -250,6 +266,7 @@ interface Task {
250
266
  enable_task_setup_tools?: boolean | null;
251
267
  enable_feedback?: boolean | null;
252
268
  enable_lessons?: boolean;
269
+ permission_mode?: PermissionMode | null;
253
270
  }
254
271
  type TriggerType = "schedule" | "webhook" | "email" | "app";
255
272
  interface Trigger {
@@ -429,6 +446,8 @@ interface PermissionPolicy {
429
446
  user_id: string;
430
447
  tool_name: string;
431
448
  created_at: string;
449
+ /** Which surface minted the grant ("run_approval" / "api"); null on legacy rows. */
450
+ source?: string | null;
432
451
  }
433
452
  /**
434
453
  * Billing usage and limits for the current period.
@@ -452,6 +471,8 @@ interface Usage {
452
471
  overage_cap_cents: number;
453
472
  overage_rate_cents: number;
454
473
  trial_ends_at?: string | null;
474
+ /** True when the account bypasses the included-runs meter (admin/unlimited). */
475
+ unlimited_runs?: boolean;
455
476
  }
456
477
  /** Token + USD totals over a usage-timeseries window. `cost_usd` is a string. */
457
478
  interface UsageTotals {
@@ -585,6 +606,8 @@ interface AgentUpdateParams {
585
606
  model?: string | null;
586
607
  effort?: string | null;
587
608
  default_permission_mode?: PermissionMode | null;
609
+ /** Who can see this agent. Omit or null leaves it unchanged. */
610
+ visibility?: "personal" | "organization" | null;
588
611
  allowed_senders?: string[] | null;
589
612
  enable_memory?: boolean | null;
590
613
  enable_history?: boolean | null;
@@ -1025,6 +1048,8 @@ interface ModelConnectionsResource {
1025
1048
  cancelAuthorization(provider: AuthorizableModelConnectionProvider, state: string): Promise<void>;
1026
1049
  /** Delete m8tes' encrypted copy of the provider credentials. */
1027
1050
  disconnect(provider: ModelConnectionProvider): Promise<ModelConnection>;
1051
+ /** Clear the account model-plan default so platform mates use m8tes credits again. */
1052
+ clearDefault(): Promise<boolean>;
1028
1053
  }
1029
1054
  declare function createModelConnectionsResource(http: Http): ModelConnectionsResource;
1030
1055
 
@@ -1104,6 +1129,11 @@ interface PollOptions {
1104
1129
  timeout?: number;
1105
1130
  /** Abort the wait early. The in-flight request is cancelled with it. */
1106
1131
  signal?: AbortSignal;
1132
+ /**
1133
+ * End-user scope for each `GET /runs/{id}` poll. Required when the account
1134
+ * has strict multi-tenant mode on — without it every poll 422s.
1135
+ */
1136
+ user_id?: string;
1107
1137
  }
1108
1138
  interface WaitOptions extends PollOptions {
1109
1139
  /**
@@ -1329,8 +1359,13 @@ interface ApproveParams {
1329
1359
  request_id: string;
1330
1360
  decision: "allow" | "deny";
1331
1361
  /**
1332
- * Apply the same decision to matching tool requests for the rest of THIS run.
1333
- * For a policy that outlives the run, use the permissions API instead.
1362
+ * Persist beyond this single gate.
1363
+ * - `false` (default): this request only.
1364
+ * - `true` + allow: also silence matching tools for the rest of THIS run AND
1365
+ * store a cross-run always-allow policy (scoped to the run's end-user when
1366
+ * set; revoke via `/permissions`).
1367
+ * - `true` + deny: deny matching tools for the rest of THIS run only (no
1368
+ * stored policy).
1334
1369
  */
1335
1370
  remember?: boolean;
1336
1371
  }
@@ -1366,17 +1401,23 @@ interface RunsResource {
1366
1401
  */
1367
1402
  retry(runId: number, params?: {
1368
1403
  confirm?: boolean;
1404
+ use_credits?: boolean;
1369
1405
  }): Promise<Run>;
1370
1406
  /** Join a run already in flight. Throws `RunNotStreamingError` if it has finished. */
1371
1407
  stream(runId: number, options?: RunStreamOptions): RunStream;
1372
1408
  /** Continue the conversation on an existing run, streaming the reply. */
1373
1409
  reply(runId: number, message: string, options?: RunStreamOptions): RunStream;
1374
- /** GET /runs/{id} takes NO query params it is already account-scoped, and
1375
- * sending `user_id` returns 422 `unknown_query_parameter`. */
1376
- get(runId: number): Promise<Run>;
1410
+ /** GET /runs/{id}. Pass `user_id` to scope to one end-user (required when the
1411
+ * account has strict multi-tenant mode on). */
1412
+ get(runId: number, params?: {
1413
+ user_id?: string;
1414
+ }): Promise<Run>;
1377
1415
  list(params?: RunListParams): Promise<Page<Run>>;
1378
- /** Cancel a running run. Returns the updated Run, like the Python SDK. */
1379
- cancel(runId: number): Promise<Run>;
1416
+ /** Cancel a running run. Returns the updated Run, like the Python SDK.
1417
+ * Pass `user_id` when the account has strict multi-tenant mode on. */
1418
+ cancel(runId: number, params?: {
1419
+ user_id?: string;
1420
+ }): Promise<Run>;
1380
1421
  /** Approve or deny a pending tool-permission gate. */
1381
1422
  approve(runId: number, params: ApproveParams): Promise<PermissionRequest>;
1382
1423
  /** Answer a pending AskUserQuestion gate, resuming the run. */
@@ -1481,6 +1522,8 @@ interface TaskCreateFields {
1481
1522
  enable_feedback?: boolean;
1482
1523
  /** Accumulate self-improvement lessons across this task's runs. Default true. */
1483
1524
  enable_lessons?: boolean;
1525
+ /** How this task's runs ask for approval. Default: the agent's default. */
1526
+ permission_mode?: PermissionMode;
1484
1527
  }
1485
1528
  /**
1486
1529
  * PATCH /tasks/{id} accepts exactly these fields (backend `DevTaskUpdate`).
@@ -1502,6 +1545,7 @@ interface TaskUpdateParams {
1502
1545
  enable_task_setup_tools?: boolean | null;
1503
1546
  enable_feedback?: boolean | null;
1504
1547
  enable_lessons?: boolean | null;
1548
+ permission_mode?: PermissionMode | null;
1505
1549
  }
1506
1550
  interface TaskListParams {
1507
1551
  user_id?: string;
@@ -1672,7 +1716,7 @@ interface WebhooksResource {
1672
1716
  */
1673
1717
 
1674
1718
  /** Kept in lockstep with package.json "version" — guarded by test/version.test.ts. */
1675
- declare const M8TES_SDK_VERSION = "0.1.0-alpha.2";
1719
+ declare const M8TES_SDK_VERSION = "0.1.0-alpha.4";
1676
1720
  declare class M8tes {
1677
1721
  readonly runs: RunsResource;
1678
1722
  readonly agents: AgentsResource;
package/dist/index.js CHANGED
@@ -195,12 +195,14 @@ function createHttp(options = {}) {
195
195
  var Page = class {
196
196
  data;
197
197
  hasMore;
198
+ nextStartingAfter;
198
199
  /** Fetches the next page given a cursor. Absent on a terminal page. */
199
200
  fetchNext;
200
- constructor(data, hasMore, fetchNext) {
201
+ constructor(data, hasMore, fetchNext, nextStartingAfter) {
201
202
  this.data = data;
202
203
  this.hasMore = hasMore;
203
204
  this.fetchNext = fetchNext;
205
+ this.nextStartingAfter = nextStartingAfter ?? null;
204
206
  }
205
207
  /**
206
208
  * Auto-paging: yields every item across every page.
@@ -218,7 +220,10 @@ var Page = class {
218
220
  yield* page.data;
219
221
  const last = page.data.at(-1);
220
222
  if (!page.hasMore || !last || !page.fetchNext) return;
221
- const cursor = typeof last.id === "number" || typeof last.id === "string" ? last.id : typeof last.name === "string" ? last.name : void 0;
223
+ let cursor = page.nextStartingAfter === null || page.nextStartingAfter === void 0 ? void 0 : page.nextStartingAfter;
224
+ if (cursor === void 0) {
225
+ cursor = typeof last.id === "number" || typeof last.id === "string" ? last.id : typeof last.name === "string" ? last.name : void 0;
226
+ }
222
227
  if (cursor === void 0 || seen.has(cursor)) return;
223
228
  seen.add(cursor);
224
229
  page = await page.fetchNext(cursor);
@@ -270,7 +275,8 @@ function createAgentsResource(http) {
270
275
  return new Page(
271
276
  res?.data ?? [],
272
277
  res?.has_more ?? false,
273
- (starting_after) => fetchPage({ ...p, starting_after })
278
+ (starting_after) => fetchPage({ ...p, starting_after }),
279
+ res?.next_starting_after
274
280
  );
275
281
  };
276
282
  return fetchPage({ ...params });
@@ -315,7 +321,7 @@ function createAppsResource(http) {
315
321
  const res = await http.request("GET", "/apps/", {
316
322
  query: toQuery({ user_id: params.user_id })
317
323
  });
318
- return new Page(res?.data ?? [], res?.has_more ?? false);
324
+ return new Page(res?.data ?? [], res?.has_more ?? false, void 0, res?.next_starting_after);
319
325
  };
320
326
  return {
321
327
  list,
@@ -365,7 +371,8 @@ function pager(http, path) {
365
371
  return new Page(
366
372
  res?.data ?? [],
367
373
  res?.has_more ?? false,
368
- (starting_after) => fetchPage({ ...p, starting_after })
374
+ (starting_after) => fetchPage({ ...p, starting_after }),
375
+ res?.next_starting_after
369
376
  );
370
377
  };
371
378
  return fetchPage;
@@ -467,7 +474,7 @@ function createModelsResource(http) {
467
474
  return {
468
475
  async list() {
469
476
  const res = await http.request("GET", "/models/");
470
- return new Page(res?.data ?? [], res?.has_more ?? false);
477
+ return new Page(res?.data ?? [], res?.has_more ?? false, void 0, res?.next_starting_after);
471
478
  }
472
479
  };
473
480
  }
@@ -503,6 +510,13 @@ function createModelConnectionsResource(http) {
503
510
  },
504
511
  disconnect(provider) {
505
512
  return http.request("DELETE", `/model-connections/${seg(provider)}`);
513
+ },
514
+ async clearDefault() {
515
+ const res = await http.request(
516
+ "DELETE",
517
+ "/model-connections/preferred-default"
518
+ );
519
+ return Boolean(res?.cleared);
506
520
  }
507
521
  };
508
522
  }
@@ -935,12 +949,15 @@ function createRunsResource(http) {
935
949
  return form;
936
950
  };
937
951
  const hasFiles = (p) => (p.files?.length ?? 0) > 0;
938
- const deps = {
939
- get: (runId, signal) => http.request("GET", `/runs/${seg(runId)}`, { signal }),
952
+ const pollDeps = (userId) => ({
953
+ get: (runId, signal) => http.request("GET", `/runs/${seg(runId)}`, {
954
+ query: toQuery({ user_id: userId }),
955
+ signal
956
+ }),
940
957
  permissions: async (runId, signal) => items(await http.request("GET", `/runs/${seg(runId)}/permissions`, { signal })),
941
958
  approve: (runId, params, signal) => http.request("POST", `/runs/${seg(runId)}/approve`, { body: { remember: false, ...params }, signal }),
942
959
  answer: (runId, params, signal) => http.request("POST", `/runs/${seg(runId)}/answer`, { body: params, signal })
943
- };
960
+ });
944
961
  const createAsync = async (params) => {
945
962
  const headers = idempotencyHeaders(params.idempotencyKey);
946
963
  return hasFiles(params) ? http.request("POST", "/runs/with-files", { form: createForm(params, false), headers }) : http.request("POST", "/runs", { body: createBody(params, false), headers });
@@ -958,24 +975,35 @@ function createRunsResource(http) {
958
975
  createAsync,
959
976
  async createAndWait(params, options = {}) {
960
977
  if (options.signal?.aborted) throw new RunWaitAbortedError();
961
- const started = await createAsync(params);
978
+ if (options.user_id != null && params.user_id != null && options.user_id !== params.user_id) {
979
+ throw new ValidationError(
980
+ `createAndWait: options.user_id (${JSON.stringify(options.user_id)}) conflicts with params.user_id (${JSON.stringify(params.user_id)}). Use one scope for create and poll.`,
981
+ { type: "invalid_request_error", code: 0, status: 0 }
982
+ );
983
+ }
984
+ const createParams = params.user_id == null && options.user_id != null ? { ...params, user_id: options.user_id } : params;
985
+ const started = await createAsync(createParams);
986
+ const userId = started.user_id ?? createParams.user_id ?? void 0;
962
987
  try {
963
- return await waitForRun(deps, started.id, options);
988
+ return await waitForRun(pollDeps(userId), started.id, { ...options, user_id: userId });
964
989
  } catch (err) {
965
990
  throw withRunId(err, started.id);
966
991
  }
967
992
  },
968
- poll(runId, options) {
969
- return pollRun(deps, runId, options);
993
+ poll(runId, options = {}) {
994
+ return pollRun(pollDeps(options.user_id), runId, options);
970
995
  },
971
- wait(runId, options) {
972
- return waitForRun(deps, runId, options);
996
+ wait(runId, options = {}) {
997
+ return waitForRun(pollDeps(options.user_id), runId, options);
973
998
  },
974
- // `confirm` is a QUERY param and the route takes no body (verified against
975
- // fastapi/app/routers/v2/runs.py::retry_run), so send neither.
999
+ // `confirm` / `use_credits` are QUERY params and the route takes no body
1000
+ // (verified against fastapi/app/routers/v2/runs.py::retry_run).
976
1001
  retry(runId, params = {}) {
977
1002
  return http.request("POST", `/runs/${seg(runId)}/retry`, {
978
- query: params.confirm ? toQuery({ confirm: true }) : ""
1003
+ query: toQuery({
1004
+ confirm: params.confirm ? true : void 0,
1005
+ use_credits: params.use_credits ? true : void 0
1006
+ })
979
1007
  });
980
1008
  },
981
1009
  stream(runId, options) {
@@ -991,8 +1019,10 @@ function createRunsResource(http) {
991
1019
  options
992
1020
  );
993
1021
  },
994
- get(runId) {
995
- return http.request("GET", `/runs/${seg(runId)}`);
1022
+ get(runId, params = {}) {
1023
+ return http.request("GET", `/runs/${seg(runId)}`, {
1024
+ query: toQuery({ user_id: params.user_id })
1025
+ });
996
1026
  },
997
1027
  async list(params = {}) {
998
1028
  const { agent_id, teammate_id, ...rest } = params;
@@ -1004,13 +1034,16 @@ function createRunsResource(http) {
1004
1034
  return new Page(
1005
1035
  res?.data ?? [],
1006
1036
  res?.has_more ?? false,
1007
- (starting_after) => fetchPage({ ...p, starting_after })
1037
+ (starting_after) => fetchPage({ ...p, starting_after }),
1038
+ res?.next_starting_after
1008
1039
  );
1009
1040
  };
1010
1041
  return fetchPage(q);
1011
1042
  },
1012
- cancel(runId) {
1013
- return http.request("POST", `/runs/${seg(runId)}/cancel`, { body: {} });
1043
+ cancel(runId, params = {}) {
1044
+ return http.request("POST", `/runs/${seg(runId)}/cancel`, {
1045
+ query: toQuery({ user_id: params.user_id })
1046
+ });
1014
1047
  },
1015
1048
  approve(runId, params) {
1016
1049
  return http.request("POST", `/runs/${seg(runId)}/approve`, {
@@ -1101,7 +1134,8 @@ function createTasksResource(http) {
1101
1134
  return new Page(
1102
1135
  res?.data ?? [],
1103
1136
  res?.has_more ?? false,
1104
- (starting_after) => fetchPage({ ...p, starting_after })
1137
+ (starting_after) => fetchPage({ ...p, starting_after }),
1138
+ res?.next_starting_after
1105
1139
  );
1106
1140
  };
1107
1141
  return fetchPage(q);
@@ -1204,7 +1238,7 @@ function createWebhooksResource(http) {
1204
1238
  }
1205
1239
 
1206
1240
  // src/index.ts
1207
- var M8TES_SDK_VERSION = "0.1.0-alpha.2";
1241
+ var M8TES_SDK_VERSION = "0.1.0-alpha.4";
1208
1242
  var M8tes = class {
1209
1243
  runs;
1210
1244
  agents;