@usenaive-sdk/managed-agents 0.12.0 → 0.12.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.js CHANGED
@@ -466,6 +466,8 @@ var LedgerEntrySchema = z2.object({
466
466
  session_id: idOf("ses").nullable(),
467
467
  agent_id: idOf("agt").nullable(),
468
468
  deployment_id: idOf("dep").nullable(),
469
+ /** The computer (`cmp_`), browser (`brw_`) or phone (`mob_`) a debit bills; `null` for anything else, and from a server older than the field. */
470
+ resource_id: z2.string().nullable().default(null),
469
471
  line_items: z2.array(z2.object({ tier: LineItemTierSchema, amount_micro_usd: MicroUsdField })),
470
472
  created_at: Timestamp
471
473
  });
@@ -1932,7 +1934,11 @@ var transposed = (a, b) => {
1932
1934
  };
1933
1935
  function toolNameProblem(name) {
1934
1936
  if (BUILTIN_TOOLS.includes(name) || name in FOLLOWS_TOOL || PLATFORM_TOOLS.includes(name)) return null;
1935
- if (!/^[a-z0-9_-]+(\.[a-z0-9_-]+)+$/i.test(name)) return `\`${name}\` is not a tool: name a built-in, or a namespaced \`<namespace>.<tool>\``;
1937
+ if (!/^[a-z0-9_-]+(\.[a-z0-9_-]+)+$/i.test(name)) {
1938
+ const bare = [...BUILTIN_TOOLS, ...Object.keys(FOLLOWS_TOOL)].find((tool) => transposed(tool, name));
1939
+ const hint = bare === void 0 ? "name a built-in, or a namespaced `<namespace>.<tool>`" : `did you mean \`${bare}\`?`;
1940
+ return `\`${name}\` is not a tool; ${hint}`;
1941
+ }
1936
1942
  const namespace = name.slice(0, name.indexOf("."));
1937
1943
  if (PLATFORM_NAMESPACES.has(namespace)) {
1938
1944
  const known = [...PLATFORM_TOOLS, ...Object.keys(FOLLOWS_TOOL)].filter((tool) => tool.startsWith(`${namespace}.`));
@@ -1943,7 +1949,8 @@ function toolNameProblem(name) {
1943
1949
  }
1944
1950
  var isToolName = (name) => toolNameProblem(name) === null;
1945
1951
  var ToolConfigSchema = z12.object({
1946
- enabled: z12.boolean(),
1952
+ /** Absent is enabled (ADR-1911): naming a tool to set its permission already says it is wanted. */
1953
+ enabled: z12.boolean().default(true),
1947
1954
  permission: ToolPermissionSchema,
1948
1955
  config: z12.record(z12.string(), z12.unknown()).optional()
1949
1956
  });
@@ -2206,7 +2213,24 @@ var CREATOR_PROGRAM = {
2206
2213
  upload_token_minutes: 15,
2207
2214
  skill_max_bytes: 32 * 1024,
2208
2215
  /** The reviewer's install check (§42.5): the hard cap on its one session, never charged to the draft. */
2209
- review_check_budget_micro_usd: 5e6
2216
+ review_check_budget_micro_usd: 5e6,
2217
+ /** A `video` origin build (§42.14): one raw clip and its characters, recast by Mira. */
2218
+ video: {
2219
+ min_seconds: 3,
2220
+ max_seconds: 15,
2221
+ video_max_bytes: 95 * 1024 * 1024,
2222
+ image_max_bytes: 10 * 1024 * 1024,
2223
+ characters_min: 1,
2224
+ characters_max: 3,
2225
+ /** After the first render. A refused or failed render does not use one up. */
2226
+ revisions: 5,
2227
+ /** Per doomscroll account, until one of its templates is approved. */
2228
+ unapproved_templates: 2,
2229
+ /** Upload tickets a doomscroll account may ask for, per template. */
2230
+ upload_tickets: 20,
2231
+ /** A draft never submitted loses its source and character bytes this long after `updated_at`. */
2232
+ draft_retention_days: 30
2233
+ }
2210
2234
  }
2211
2235
  };
2212
2236
  var DOOMSCROLL_PROGRAM = {
@@ -2250,6 +2274,8 @@ var StudioStateSchema = z13.enum([
2250
2274
  "setup",
2251
2275
  "building",
2252
2276
  "ready",
2277
+ /** A `video` origin only: a version was submitted and its author is writing the skill. */
2278
+ "finalizing",
2253
2279
  "in_review",
2254
2280
  "live",
2255
2281
  "changes_requested"
@@ -2313,10 +2339,26 @@ var StudioSkillSchema = SavedSkillSchema.extend({
2313
2339
  id: idOf("skl").nullable(),
2314
2340
  version: z13.number().int().positive().nullable()
2315
2341
  });
2342
+ var StudioImageContentTypeSchema = z13.enum(["image/png", "image/jpeg", "image/webp"]);
2343
+ var StudioSourceVideoSchema = z13.object({
2344
+ file_id: z13.string().nullable(),
2345
+ bytes: z13.number().int().positive().max(CREATOR_PROGRAM.studio.video.video_max_bytes),
2346
+ content_type: StudioUploadContentTypeSchema,
2347
+ filename: z13.string().min(1).max(200),
2348
+ seconds: z13.number().nonnegative().nullable()
2349
+ });
2350
+ var CharacterPosition = z13.number().int().min(1).max(CREATOR_PROGRAM.studio.video.characters_max);
2351
+ var StudioCharacterSchema = z13.object({
2352
+ position: CharacterPosition,
2353
+ file_id: z13.string().nullable(),
2354
+ bytes: z13.number().int().positive().max(CREATOR_PROGRAM.studio.video.image_max_bytes),
2355
+ content_type: StudioImageContentTypeSchema,
2356
+ filename: z13.string().min(1).max(200)
2357
+ });
2316
2358
  var CreatorStudioSchema = z13.object({
2317
2359
  uploads: z13.array(StudioUploadSchema).max(CREATOR_PROGRAM.studio.uploads).default([]),
2318
- /** `links`: built from 1–3 reel links (`imports`), prompts optional; `upload`: the creator's three videos. */
2319
- origin: z13.enum(["upload", "links"]).default("upload"),
2360
+ /** `links`: built from 1–3 reel links (`imports`), prompts optional; `upload`: the creator's three videos; `video`: one raw clip recast by Mira (§42.14). */
2361
+ origin: z13.enum(["upload", "links", "video"]).default("upload"),
2320
2362
  imports: z13.array(StudioImportSchema).max(CREATOR_PROGRAM.studio.uploads).default([]),
2321
2363
  state: StudioStateSchema.default("setup"),
2322
2364
  spend_micro_usd: MicroUsdField.nonnegative().default(0),
@@ -2327,7 +2369,11 @@ var CreatorStudioSchema = z13.object({
2327
2369
  /** An org build's asked sample length (§57.2, ADR-1762); `null` is `sample_seconds`. */
2328
2370
  seconds: z13.number().int().min(10).max(60).nullable().default(null),
2329
2371
  /** An org build's own catalog text: its request's description when that fits a tagline; `null` lets the judge write one. */
2330
- tagline: z13.string().max(140).nullable().default(null)
2372
+ tagline: z13.string().max(140).nullable().default(null),
2373
+ /** A `video` origin's raw clip, its characters, and the round submitted (§42.14). */
2374
+ source_video: StudioSourceVideoSchema.nullable().default(null),
2375
+ characters: z13.array(StudioCharacterSchema).max(CREATOR_PROGRAM.studio.video.characters_max).default([]),
2376
+ chosen_round: z13.number().int().positive().nullable().default(null)
2331
2377
  });
2332
2378
  var CreatorTemplateListingSchema = z13.object({
2333
2379
  listed: z13.boolean(),
@@ -2381,7 +2427,15 @@ var CreatorTemplateRoundSchema = z13.object({
2381
2427
  spend_micro_usd: MicroUsdField.nonnegative(),
2382
2428
  error: z13.string().nullable(),
2383
2429
  created_at: Timestamp,
2384
- finished_at: Timestamp.nullable()
2430
+ finished_at: Timestamp.nullable(),
2431
+ /** A `video` origin round's Mira edit and its result (migration 0172, §42.14). */
2432
+ edit_job_id: z13.string().nullable().default(null),
2433
+ sample_file_id: z13.string().nullable().default(null)
2434
+ });
2435
+ var StudioPlateSchema = z13.object({
2436
+ file: z13.string().min(1),
2437
+ kind: z13.enum(["video", "image"]),
2438
+ file_id: z13.string().min(1)
2385
2439
  });
2386
2440
  var NicheVersionStudioSchema = z13.object({
2387
2441
  round: z13.number().int().positive(),
@@ -2390,7 +2444,9 @@ var NicheVersionStudioSchema = z13.object({
2390
2444
  frames: z13.array(StudioFrameSchema),
2391
2445
  samples: z13.array(StudioSampleSchema),
2392
2446
  tagline: z13.string().max(140),
2393
- hero_sample_index: z13.number().int().nonnegative()
2447
+ hero_sample_index: z13.number().int().nonnegative(),
2448
+ /** A `video` origin's default clip and characters. */
2449
+ plates: z13.array(StudioPlateSchema).optional()
2394
2450
  });
2395
2451
  var CreatorTemplateSchema = z13.object({
2396
2452
  id: idOf("ctp"),
@@ -2487,13 +2543,26 @@ var CreatorAnalyticsSchema = z13.object({
2487
2543
  install_windows: z13.array(z13.object({ install_id: idOf("bpi"), from: Day, until: Day })).optional()
2488
2544
  });
2489
2545
  var CreatorTemplateCreateKindSchema = z13.object({
2490
- kind: CreatorTemplateKindSchema.default("crew")
2546
+ kind: CreatorTemplateKindSchema.default("crew"),
2547
+ /** `video` makes a draft built from one raw clip (§42.14); it needs `kind: niche`. */
2548
+ origin: z13.literal("video").optional()
2491
2549
  });
2492
2550
  var StudioUploadCreateSchema = z13.object({
2493
- position: UploadPosition,
2551
+ purpose: z13.enum(["source", "character"]).optional(),
2552
+ position: UploadPosition.optional(),
2494
2553
  filename: z13.string().min(1).max(200),
2495
- content_type: StudioUploadContentTypeSchema,
2496
- bytes: z13.number().int().positive().max(CREATOR_PROGRAM.studio.upload_max_bytes)
2554
+ content_type: z13.union([StudioUploadContentTypeSchema, StudioImageContentTypeSchema]),
2555
+ bytes: z13.number().int().positive()
2556
+ }).superRefine((body, ctx) => {
2557
+ const { video, upload_max_bytes } = CREATOR_PROGRAM.studio;
2558
+ const character = body.purpose === "character";
2559
+ const issue = (path, message) => ctx.addIssue({ code: "custom", path: [path], message });
2560
+ if (body.purpose !== "source" && body.position === void 0) issue("position", "position is required");
2561
+ if (character !== StudioImageContentTypeSchema.safeParse(body.content_type).success) {
2562
+ issue("content_type", character ? "a character must be a PNG, JPEG or WebP image" : "this upload must be an MP4, MOV or WebM video");
2563
+ }
2564
+ const max = character ? video.image_max_bytes : body.purpose === "source" ? video.video_max_bytes : upload_max_bytes;
2565
+ if (body.bytes > max) issue("bytes", `this upload may be at most ${max} bytes`);
2497
2566
  });
2498
2567
  var StudioUploadTicketSchema = z13.object({
2499
2568
  object: z13.literal("studio_upload_ticket"),
@@ -2507,6 +2576,12 @@ var StudioUploadResultSchema = z13.object({
2507
2576
  template_id: idOf("ctp"),
2508
2577
  upload: StudioUploadSchema
2509
2578
  });
2579
+ var StudioVideoUploadResultSchema = z13.object({
2580
+ object: z13.literal("studio_upload"),
2581
+ template_id: idOf("ctp"),
2582
+ source_video: StudioSourceVideoSchema.nullable(),
2583
+ characters: z13.array(StudioCharacterSchema)
2584
+ });
2510
2585
  var StudioRoundCreateSchema = z13.object({
2511
2586
  feedback: z13.string().min(1).max(4e3).optional(),
2512
2587
  rights_attested: z13.boolean().optional()
@@ -2519,9 +2594,12 @@ var StudioBudgetSchema = z13.object({
2519
2594
  var CreatorStudioViewSchema = z13.object({
2520
2595
  object: z13.literal("creator_studio"),
2521
2596
  template_id: idOf("ctp"),
2522
- studio: CreatorStudioSchema,
2523
- /** Newest first. */
2524
- rounds: z13.array(CreatorTemplateRoundSchema),
2597
+ /** A `video` origin's `source_video` also carries a signed `url` once its bytes landed. */
2598
+ studio: CreatorStudioSchema.extend({
2599
+ source_video: StudioSourceVideoSchema.extend({ url: z13.string().nullable().optional() }).nullable().default(null)
2600
+ }),
2601
+ /** Newest first. A `video` round also carries a signed `sample_url`. */
2602
+ rounds: z13.array(CreatorTemplateRoundSchema.extend({ sample_url: z13.string().nullable().optional() })),
2525
2603
  budget: StudioBudgetSchema
2526
2604
  });
2527
2605
  var NicheSubmitSchema = z13.object({
@@ -2531,6 +2609,7 @@ var NicheSubmitSchema = z13.object({
2531
2609
  hero_sample_index: z13.number().int().nonnegative()
2532
2610
  })
2533
2611
  });
2612
+ var VideoSubmitSchema = z13.object({ round: z13.number().int().positive() });
2534
2613
  var CreatorListingPatchSchema = CreatorTemplateListingSchema.partial();
2535
2614
  var CreatorListingSchema = z13.object({
2536
2615
  object: z13.literal("creator_listing"),
@@ -2758,6 +2837,10 @@ var EventTypeSchema = z16.enum([
2758
2837
  "span.harness_build.end",
2759
2838
  "span.box_resume.start",
2760
2839
  "span.box_resume.end",
2840
+ "span.tools_resolve.start",
2841
+ "span.tools_resolve.end",
2842
+ "span.model_gate.start",
2843
+ "span.model_gate.end",
2761
2844
  /**
2762
2845
  * A delegated thread's lifecycle, on the **coordinator's** stream (§28). The child's own
2763
2846
  * `ses_…` rides inside `data.thread_id` — the event schema gains no field and `vetta.event` gains
@@ -4392,11 +4475,12 @@ var MusicGenerationSchema = z33.object({
4392
4475
  duration_seconds: Seconds2.nullable(),
4393
4476
  cost_micro_usd: MicroUsdField
4394
4477
  });
4478
+ var EditModeSchema = z33.enum(["scene", "outfit_or_object", "person_swap", "recast"]);
4395
4479
  var EditRequestSchema = z33.object({
4396
4480
  video: z33.string().min(1),
4397
4481
  prompt: z33.string().min(1).max(1e3),
4398
4482
  references: z33.array(z33.string().min(1)).max(4).optional(),
4399
- mode: z33.enum(["scene", "outfit_or_object", "person_swap"]).optional()
4483
+ mode: EditModeSchema.optional()
4400
4484
  });
4401
4485
  var EditFailureCodeSchema = z33.enum(["bad_source", "refused", "timed_out", "provider_error", "cancelled"]);
4402
4486
  var EditJobSchema = z33.object({
@@ -4406,7 +4490,7 @@ var EditJobSchema = z33.object({
4406
4490
  video: z33.string(),
4407
4491
  prompt: z33.string(),
4408
4492
  references: z33.array(z33.string()),
4409
- mode: z33.enum(["scene", "outfit_or_object", "person_swap"]).nullable(),
4493
+ mode: EditModeSchema.nullable(),
4410
4494
  result: z33.object({ file_id: z33.string().startsWith("fil_") }).nullable(),
4411
4495
  error: z33.object({ code: EditFailureCodeSchema, message: z33.string() }).nullable(),
4412
4496
  cost_micro_usd: MicroUsdField.nullable(),
@@ -5444,6 +5528,11 @@ function tolerantPage(item) {
5444
5528
  });
5445
5529
  }
5446
5530
  var DOT_SEGMENT = /^(?:\.|%2e){1,2}$/i;
5531
+ function pathId(value, name) {
5532
+ if (value !== void 0 && value !== null && String(value) !== "") return encodeURIComponent(value);
5533
+ const message = `${name} is required`;
5534
+ throw new ApiError(400, { type: "invalid_request", code: "validation_failed", message, param: name, request_id: "" });
5535
+ }
5447
5536
  function url(config, call) {
5448
5537
  const segments = call.path.split("/");
5449
5538
  if (segments.some((segment) => DOT_SEGMENT.test(segment)) || segments.at(-1) === "") {
@@ -5496,6 +5585,7 @@ var CODE_BY_STATUS = {
5496
5585
  var BLOCKED_AT_EDGE = "the request was blocked before it reached the API (HTTP 403); this can happen when a request body looks like SQL";
5497
5586
  function unreadableMessage(status) {
5498
5587
  if (status === 403) return BLOCKED_AT_EDGE;
5588
+ if (status === 401) return "HTTP 401: the API key was rejected and the response had no readable details; check the API key and that baseUrl points at the API";
5499
5589
  return `HTTP ${status}: the error response had no readable details`;
5500
5590
  }
5501
5591
  function apiErrorFrom(response, text3) {
@@ -6293,77 +6383,77 @@ var domains = (config) => ({
6293
6383
  delete: (id) => request(config, DeletedSchema, { method: "DELETE", path: `/v1/domains/${encodeURIComponent(id)}` })
6294
6384
  });
6295
6385
  var emails = (config) => ({
6296
- create: (identityId, body) => request(config, EmailInboxSchema, {
6386
+ create: async (identityId, body) => request(config, EmailInboxSchema, {
6297
6387
  method: "POST",
6298
- path: `/v1/identities/${encodeURIComponent(identityId)}/emails`,
6388
+ path: `/v1/identities/${pathId(identityId, "identityId")}/emails`,
6299
6389
  body
6300
6390
  }),
6301
- list: (identityId, query2 = {}) => request(config, page(EmailInboxSchema), {
6391
+ list: async (identityId, query2 = {}) => request(config, page(EmailInboxSchema), {
6302
6392
  method: "GET",
6303
- path: `/v1/identities/${encodeURIComponent(identityId)}/emails`,
6393
+ path: `/v1/identities/${pathId(identityId, "identityId")}/emails`,
6304
6394
  query: query2
6305
6395
  }),
6306
6396
  /** Turn on or off whether mail to the inbox wakes its owner. An inbox from before the wake shipped is off. */
6307
- update: (identityId, inboxId, body) => request(config, EmailInboxSchema, {
6397
+ update: async (identityId, inboxId, body) => request(config, EmailInboxSchema, {
6308
6398
  method: "PATCH",
6309
- path: `/v1/identities/${encodeURIComponent(identityId)}/emails/${encodeURIComponent(inboxId)}`,
6399
+ path: `/v1/identities/${pathId(identityId, "identityId")}/emails/${encodeURIComponent(inboxId)}`,
6310
6400
  body
6311
6401
  }),
6312
- delete: (identityId, inboxId) => request(config, DeletedSchema, {
6402
+ delete: async (identityId, inboxId) => request(config, DeletedSchema, {
6313
6403
  method: "DELETE",
6314
- path: `/v1/identities/${encodeURIComponent(identityId)}/emails/${encodeURIComponent(inboxId)}`
6404
+ path: `/v1/identities/${pathId(identityId, "identityId")}/emails/${encodeURIComponent(inboxId)}`
6315
6405
  }),
6316
6406
  /** Gated on the domain's `dns_status`; a premature send is a retryable `job_not_ready`. */
6317
- send: (identityId, inboxId, body) => request(config, EmailSendSchema, {
6407
+ send: async (identityId, inboxId, body) => request(config, EmailSendSchema, {
6318
6408
  method: "POST",
6319
- path: `/v1/identities/${encodeURIComponent(identityId)}/emails/${encodeURIComponent(inboxId)}/send`,
6409
+ path: `/v1/identities/${pathId(identityId, "identityId")}/emails/${encodeURIComponent(inboxId)}/send`,
6320
6410
  body
6321
6411
  }),
6322
6412
  /** Everything that arrived for this persona, both channels unless one is named. */
6323
- messages: (identityId, query2 = {}) => request(config, page(InboundMessageSchema), {
6413
+ messages: async (identityId, query2 = {}) => request(config, page(InboundMessageSchema), {
6324
6414
  method: "GET",
6325
- path: `/v1/identities/${encodeURIComponent(identityId)}/messages`,
6415
+ path: `/v1/identities/${pathId(identityId, "identityId")}/messages`,
6326
6416
  query: query2
6327
6417
  }),
6328
6418
  /** Mark one arrived message read or unread; a message already read keeps its first time. */
6329
- markRead: (identityId, messageId, read) => request(config, InboundMessageSchema, {
6419
+ markRead: async (identityId, messageId, read) => request(config, InboundMessageSchema, {
6330
6420
  method: "POST",
6331
- path: `/v1/identities/${encodeURIComponent(identityId)}/messages/${encodeURIComponent(messageId)}/read`,
6421
+ path: `/v1/identities/${pathId(identityId, "identityId")}/messages/${encodeURIComponent(messageId)}/read`,
6332
6422
  body: { read }
6333
6423
  }),
6334
6424
  /** What the persona sent, newest first — through the API and through its agent alike. */
6335
- sent: (identityId, query2 = {}) => request(config, page(OutboundMessageSchema), {
6425
+ sent: async (identityId, query2 = {}) => request(config, page(OutboundMessageSchema), {
6336
6426
  method: "GET",
6337
- path: `/v1/identities/${encodeURIComponent(identityId)}/sent`,
6427
+ path: `/v1/identities/${pathId(identityId, "identityId")}/sent`,
6338
6428
  query: query2
6339
6429
  })
6340
6430
  });
6341
6431
  var phones = (config) => ({
6342
6432
  /** 202, not 201: the number exists and can receive, but outbound waits on a carrier decision. */
6343
- provision: (identityId, body) => request(config, PhoneNumberSchema, {
6433
+ provision: async (identityId, body) => request(config, PhoneNumberSchema, {
6344
6434
  method: "POST",
6345
- path: `/v1/identities/${encodeURIComponent(identityId)}/phones`,
6435
+ path: `/v1/identities/${pathId(identityId, "identityId")}/phones`,
6346
6436
  body
6347
6437
  }),
6348
- list: (identityId, query2 = {}) => request(config, page(PhoneNumberSchema), {
6438
+ list: async (identityId, query2 = {}) => request(config, page(PhoneNumberSchema), {
6349
6439
  method: "GET",
6350
- path: `/v1/identities/${encodeURIComponent(identityId)}/phones`,
6440
+ path: `/v1/identities/${pathId(identityId, "identityId")}/phones`,
6351
6441
  query: query2
6352
6442
  }),
6353
6443
  /** Set, or clear with `null`, the agent this number's inbound texts are for. */
6354
- update: (identityId, phoneId, body) => request(config, PhoneNumberSchema, {
6444
+ update: async (identityId, phoneId, body) => request(config, PhoneNumberSchema, {
6355
6445
  method: "PATCH",
6356
- path: `/v1/identities/${encodeURIComponent(identityId)}/phones/${encodeURIComponent(phoneId)}`,
6446
+ path: `/v1/identities/${pathId(identityId, "identityId")}/phones/${encodeURIComponent(phoneId)}`,
6357
6447
  body
6358
6448
  }),
6359
- release: (identityId, phoneId) => request(config, DeletedSchema, {
6449
+ release: async (identityId, phoneId) => request(config, DeletedSchema, {
6360
6450
  method: "DELETE",
6361
- path: `/v1/identities/${encodeURIComponent(identityId)}/phones/${encodeURIComponent(phoneId)}`
6451
+ path: `/v1/identities/${pathId(identityId, "identityId")}/phones/${encodeURIComponent(phoneId)}`
6362
6452
  }),
6363
6453
  /** Refused with `compliance_pending` until the campaign is approved. That is a carrier rule. */
6364
- send: (identityId, phoneId, body) => request(config, SmsSendSchema, {
6454
+ send: async (identityId, phoneId, body) => request(config, SmsSendSchema, {
6365
6455
  method: "POST",
6366
- path: `/v1/identities/${encodeURIComponent(identityId)}/phones/${encodeURIComponent(phoneId)}/send`,
6456
+ path: `/v1/identities/${pathId(identityId, "identityId")}/phones/${encodeURIComponent(phoneId)}/send`,
6367
6457
  body
6368
6458
  })
6369
6459
  });
@@ -6954,7 +7044,7 @@ var wallet = (config) => {
6954
7044
  updatePolicy: (identity, body, select = {}) => request(config, WalletSchema, { method: "PATCH", path: `/v1/identities/${encodeURIComponent(identity)}/wallet/policy`, body, query: select }),
6955
7045
  freeze: (identity, select = {}) => request(config, WalletSchema, { method: "POST", path: `/v1/identities/${encodeURIComponent(identity)}/wallet/freeze`, query: select }),
6956
7046
  unfreeze: (identity, select = {}) => request(config, WalletSchema, { method: "POST", path: `/v1/identities/${encodeURIComponent(identity)}/wallet/unfreeze`, query: select }),
6957
- /** The three money moves take an `idempotencyKey` so a retry of one move reuses its key and moves the money once. */
7047
+ /** The money moves (and `pay`) take an `idempotencyKey` so a retry of one move reuses its key and moves the money once. */
6958
7048
  fund: (identity, body, select = {}, opts = {}) => request(config, WalletTransactionSchema, { method: "POST", path: `/v1/identities/${encodeURIComponent(identity)}/wallet/fund`, body, query: select, headers: keyed(opts) }),
6959
7049
  transfer: (identity, body, select = {}, opts = {}) => request(config, WalletTransactionSchema, { method: "POST", path: `/v1/identities/${encodeURIComponent(identity)}/wallet/transfer`, body, query: select, headers: keyed(opts) }),
6960
7050
  sweep: (identity, body = {}, select = {}, opts = {}) => request(config, WalletTransactionSchema, { method: "POST", path: `/v1/identities/${encodeURIComponent(identity)}/wallet/sweep`, body, query: select, headers: keyed(opts) }),
@@ -6966,7 +7056,7 @@ var wallet = (config) => {
6966
7056
  query: { ...query2, kind: "pay" }
6967
7057
  }),
6968
7058
  quote: (identity, body, select = {}) => request(config, WalletQuoteSchema, { method: "POST", path: `/v1/identities/${encodeURIComponent(identity)}/wallet/quote`, body, query: select }),
6969
- pay: (identity, body, select = {}) => request(config, WalletPaymentSchema, { method: "POST", path: `/v1/identities/${encodeURIComponent(identity)}/wallet/pay`, body, query: select })
7059
+ pay: (identity, body, select = {}, opts = {}) => request(config, WalletPaymentSchema, { method: "POST", path: `/v1/identities/${encodeURIComponent(identity)}/wallet/pay`, body, query: select, headers: keyed(opts) })
6970
7060
  };
6971
7061
  };
6972
7062
 
@@ -7176,65 +7266,65 @@ var SocialWorkspaceSchema = z62.object({
7176
7266
  });
7177
7267
  var SocialPortalSchema = z62.object({ object: z62.literal("social_portal_link"), url: z62.url() });
7178
7268
  var setup = (config) => ({
7179
- activate: (identity) => request(config, SocialWorkspaceSchema, {
7269
+ activate: async (identity) => request(config, SocialWorkspaceSchema, {
7180
7270
  method: "POST",
7181
- path: `/v1/identities/${encodeURIComponent(identity)}/social/activate`
7271
+ path: `/v1/identities/${pathId(identity, "identity")}/social/activate`
7182
7272
  }),
7183
- status: (identity) => request(config, SocialWorkspaceSchema, {
7273
+ status: async (identity) => request(config, SocialWorkspaceSchema, {
7184
7274
  method: "GET",
7185
- path: `/v1/identities/${encodeURIComponent(identity)}/social`
7275
+ path: `/v1/identities/${pathId(identity, "identity")}/social`
7186
7276
  }),
7187
- portal: (identity, body = {}) => request(config, SocialPortalSchema, {
7277
+ portal: async (identity, body = {}) => request(config, SocialPortalSchema, {
7188
7278
  method: "POST",
7189
- path: `/v1/identities/${encodeURIComponent(identity)}/social/portal`,
7279
+ path: `/v1/identities/${pathId(identity, "identity")}/social/portal`,
7190
7280
  body
7191
7281
  }),
7192
- accounts: (identity, query2 = {}) => request(config, page(SocialAccountSchema), {
7282
+ accounts: async (identity, query2 = {}) => request(config, page(SocialAccountSchema), {
7193
7283
  method: "GET",
7194
- path: `/v1/identities/${encodeURIComponent(identity)}/social/accounts`,
7284
+ path: `/v1/identities/${pathId(identity, "identity")}/social/accounts`,
7195
7285
  query: query2
7196
7286
  }),
7197
- accountAnalytics: (identity, account) => request(config, SocialAnalyticsSchema, {
7287
+ accountAnalytics: async (identity, account) => request(config, SocialAnalyticsSchema, {
7198
7288
  method: "GET",
7199
- path: `/v1/identities/${encodeURIComponent(identity)}/social/accounts/${encodeURIComponent(account)}/analytics`
7289
+ path: `/v1/identities/${pathId(identity, "identity")}/social/accounts/${encodeURIComponent(account)}/analytics`
7200
7290
  }),
7201
- upload: (identity, body) => request(config, SocialUploadSchema, {
7291
+ upload: async (identity, body) => request(config, SocialUploadSchema, {
7202
7292
  method: "POST",
7203
- path: `/v1/identities/${encodeURIComponent(identity)}/social/uploads`,
7293
+ path: `/v1/identities/${pathId(identity, "identity")}/social/uploads`,
7204
7294
  body
7205
7295
  })
7206
7296
  });
7207
7297
  var publishing = (config) => ({
7208
- createPost: (identity, body) => request(config, SocialPostSchema, {
7298
+ createPost: async (identity, body) => request(config, SocialPostSchema, {
7209
7299
  method: "POST",
7210
- path: `/v1/identities/${encodeURIComponent(identity)}/social/posts`,
7300
+ path: `/v1/identities/${pathId(identity, "identity")}/social/posts`,
7211
7301
  body
7212
7302
  }),
7213
- getPost: (identity, post) => request(config, SocialPostSchema, {
7303
+ getPost: async (identity, post) => request(config, SocialPostSchema, {
7214
7304
  method: "GET",
7215
- path: `/v1/identities/${encodeURIComponent(identity)}/social/posts/${encodeURIComponent(post)}`
7305
+ path: `/v1/identities/${pathId(identity, "identity")}/social/posts/${encodeURIComponent(post)}`
7216
7306
  }),
7217
- deletePost: (identity, post) => request(config, DeletedSchema, {
7307
+ deletePost: async (identity, post) => request(config, DeletedSchema, {
7218
7308
  method: "DELETE",
7219
- path: `/v1/identities/${encodeURIComponent(identity)}/social/posts/${encodeURIComponent(post)}`
7309
+ path: `/v1/identities/${pathId(identity, "identity")}/social/posts/${encodeURIComponent(post)}`
7220
7310
  }),
7221
- postAnalytics: (identity, post) => request(config, SocialAnalyticsSchema, {
7311
+ postAnalytics: async (identity, post) => request(config, SocialAnalyticsSchema, {
7222
7312
  method: "GET",
7223
- path: `/v1/identities/${encodeURIComponent(identity)}/social/posts/${encodeURIComponent(post)}/analytics`
7313
+ path: `/v1/identities/${pathId(identity, "identity")}/social/posts/${encodeURIComponent(post)}/analytics`
7224
7314
  }),
7225
7315
  /**
7226
7316
  * `GET /v1/posts` — every post the company files, across identities and sessions (§27.1): the
7227
7317
  * `social.post` calls waiting on a person (`pending`), and the ones sent, with their latest numbers.
7228
7318
  * `reconcile: false` lists what is stored without asking the provider about due posts first.
7229
7319
  */
7230
- listPosts: ({ reconcile, ...query2 } = {}) => request(config, page(PostSchema), {
7320
+ listPosts: async ({ reconcile, ...query2 } = {}) => request(config, page(PostSchema), {
7231
7321
  method: "GET",
7232
7322
  path: "/v1/posts",
7233
7323
  query: { ...query2, ...reconcile === void 0 ? {} : { reconcile: String(reconcile) } }
7234
7324
  }),
7235
- comments: (identity, post, query2 = {}) => request(config, page(SocialCommentSchema), {
7325
+ comments: async (identity, post, query2 = {}) => request(config, page(SocialCommentSchema), {
7236
7326
  method: "GET",
7237
- path: `/v1/identities/${encodeURIComponent(identity)}/social/posts/${encodeURIComponent(post)}/comments`,
7327
+ path: `/v1/identities/${pathId(identity, "identity")}/social/posts/${encodeURIComponent(post)}/comments`,
7238
7328
  query: query2
7239
7329
  })
7240
7330
  });
@@ -7407,10 +7497,10 @@ async function* streamFrames(config, schema, call) {
7407
7497
  yield parsed.data;
7408
7498
  }
7409
7499
  }
7410
- function settled(session, afterSeq, throughGrades) {
7411
- if (session.status === "running" || session.status === "queued") return false;
7412
- if (throughGrades && session.stop_reason === "awaiting_delegation") return false;
7413
- return session.last_seq <= afterSeq;
7500
+ function settledAt(session, throughGrades) {
7501
+ if (session.status === "running" || session.status === "queued") return null;
7502
+ if (throughGrades && session.stop_reason === "awaiting_delegation") return null;
7503
+ return session.last_seq;
7414
7504
  }
7415
7505
  async function* streamEvents(config, sessionId, options = {}) {
7416
7506
  const maxRetries = options.maxRetries ?? 5;
@@ -7419,7 +7509,8 @@ async function* streamEvents(config, sessionId, options = {}) {
7419
7509
  let failures = 0;
7420
7510
  const grading = /* @__PURE__ */ new Set();
7421
7511
  let held = false;
7422
- if (lastSeq > 0 && settled(await sessions(config).get(sessionId), lastSeq, throughGrades)) return;
7512
+ const endAt = lastSeq > 0 ? settledAt(await sessions(config).get(sessionId), throughGrades) : null;
7513
+ if (endAt !== null && endAt <= lastSeq) return;
7423
7514
  for (; ; ) {
7424
7515
  try {
7425
7516
  const call = {
@@ -7437,6 +7528,7 @@ async function* streamEvents(config, sessionId, options = {}) {
7437
7528
  if (event.type === "outcome.evaluation.started") grading.add(gradeKey(event));
7438
7529
  if (event.type === "outcome.evaluation.completed") grading.delete(gradeKey(event));
7439
7530
  yield event;
7531
+ if (endAt !== null && event.seq >= endAt) return;
7440
7532
  if (event.type === "session.idle") {
7441
7533
  held = throughGrades && grading.size > 0 && parkedOnGrade(event);
7442
7534
  if (!held) return;
@@ -7508,7 +7600,7 @@ var computers = (config) => ({
7508
7600
  path: `/v1/computers/${encodeURIComponent(id)}/exec`,
7509
7601
  body: { command, ...timeoutMs === void 0 ? {} : { timeout_ms: timeoutMs } }
7510
7602
  }),
7511
- /** Paused bills storage only — the first efficiency lever (`memory/context.md`). */
7603
+ /** Paused bills nothing (disk is never metered) — the first efficiency lever (`memory/context.md`). */
7512
7604
  pause: (id) => request(config, ComputerSchema, { method: "POST", path: `/v1/computers/${encodeURIComponent(id)}/pause`, body: {} }),
7513
7605
  resume: (id) => request(config, ComputerSchema, { method: "POST", path: `/v1/computers/${encodeURIComponent(id)}/resume`, body: {} }),
7514
7606
  /** An agent's computer only (§41.8): a person holds it, and its sessions wait until it is handed back. */
@@ -7733,9 +7825,11 @@ function withTool(tools, name, settings) {
7733
7825
  }
7734
7826
 
7735
7827
  // src/index.ts
7828
+ var DEFAULT_BASE_URL = "https://api.vetta.sh";
7736
7829
  function createClient(options) {
7737
7830
  const config = {
7738
7831
  ...options,
7832
+ baseUrl: (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "").replace(/\/v1$/, ""),
7739
7833
  fetch: options.fetch ?? ((input, init) => globalThis.fetch(input, init)),
7740
7834
  idempotencyKey: options.idempotencyKey ?? (() => crypto.randomUUID())
7741
7835
  };
@@ -7794,6 +7888,7 @@ function createClient(options) {
7794
7888
  export {
7795
7889
  ApiError,
7796
7890
  CONNECTION_AUTHS,
7891
+ DEFAULT_BASE_URL,
7797
7892
  ResponseParseError,
7798
7893
  SOCIAL_PLATFORMS,
7799
7894
  SOCIAL_TEXT_PLATFORMS,