@parall/daemon 1.84.0 → 1.86.0

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.
@@ -127,6 +127,20 @@ var init_attention_types = __esm({
127
127
  }
128
128
  });
129
129
 
130
+ // ts/sdk/dist/billing-types.js
131
+ function refusedAccountOf(err) {
132
+ const e = err;
133
+ if (e?.code !== "INSUFFICIENT_CREDITS")
134
+ return null;
135
+ const account = e.extras?.details?.account;
136
+ return typeof account?.id === "string" && typeof account.display_name === "string" ? account : null;
137
+ }
138
+ var init_billing_types = __esm({
139
+ "ts/sdk/dist/billing-types.js"() {
140
+ "use strict";
141
+ }
142
+ });
143
+
130
144
  // ts/sdk/dist/browser-use.js
131
145
  function isBrowserUseEnabled(flags) {
132
146
  return flags?.[BROWSER_USE_FEATURE_FLAG] === true;
@@ -506,6 +520,118 @@ var init_chat_team_grant_types = __esm({
506
520
  }
507
521
  });
508
522
 
523
+ // ts/sdk/dist/wiki-upload.js
524
+ function createWikiUploadFormData(params) {
525
+ const form = new FormData();
526
+ form.append("path", params.path);
527
+ form.append("file", params.file);
528
+ if (params.message)
529
+ form.append("message", params.message);
530
+ if (params.uploadId)
531
+ form.append("upload_id", params.uploadId);
532
+ if (params.conflict)
533
+ form.append("conflict", params.conflict);
534
+ if ("contentRoute" in params && params.contentRoute) {
535
+ form.append("content_route", params.contentRoute);
536
+ }
537
+ return form;
538
+ }
539
+ function sendMultipartRequest(options) {
540
+ if (options.onProgress && typeof XMLHttpRequest !== "undefined") {
541
+ return multipartXHR(options, options.onProgress);
542
+ }
543
+ const timeoutSignal = AbortSignal.timeout(options.timeoutMs);
544
+ const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
545
+ return fetch(options.url, {
546
+ method: options.method,
547
+ headers: options.headers,
548
+ body: options.body,
549
+ signal
550
+ });
551
+ }
552
+ function multipartXHR(options, onProgress) {
553
+ return new Promise((resolve9, reject) => {
554
+ const xhr = new XMLHttpRequest();
555
+ let settled = false;
556
+ const finish = (fn) => {
557
+ if (settled)
558
+ return;
559
+ settled = true;
560
+ options.signal?.removeEventListener("abort", abortFromSignal);
561
+ fn();
562
+ };
563
+ const abortFromSignal = () => xhr.abort();
564
+ xhr.open(options.method, options.url, true);
565
+ xhr.timeout = options.timeoutMs;
566
+ for (const [name, value] of Object.entries(options.headers)) {
567
+ xhr.setRequestHeader(name, value);
568
+ }
569
+ xhr.upload.onprogress = (event) => {
570
+ try {
571
+ onProgress(event.loaded, event.lengthComputable ? event.total : 0);
572
+ } catch {
573
+ }
574
+ };
575
+ xhr.onload = () => finish(() => {
576
+ const responseHeaders = new Headers();
577
+ for (const line of xhr.getAllResponseHeaders().trim().split(/[\r\n]+/)) {
578
+ if (!line)
579
+ continue;
580
+ const separator = line.indexOf(":");
581
+ if (separator > 0) {
582
+ responseHeaders.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
583
+ }
584
+ }
585
+ const responseBody = xhr.status === 204 || xhr.responseText === "" ? null : xhr.responseText;
586
+ resolve9(new Response(responseBody, {
587
+ status: xhr.status,
588
+ statusText: xhr.statusText,
589
+ headers: responseHeaders
590
+ }));
591
+ });
592
+ xhr.onerror = () => finish(() => reject(new TypeError("Network request failed")));
593
+ xhr.ontimeout = () => finish(() => reject(new DOMException("Request timed out", "TimeoutError")));
594
+ xhr.onabort = () => finish(() => reject(new DOMException("Request aborted", "AbortError")));
595
+ if (options.signal?.aborted) {
596
+ finish(() => reject(new DOMException("Request aborted", "AbortError")));
597
+ return;
598
+ }
599
+ options.signal?.addEventListener("abort", abortFromSignal, { once: true });
600
+ xhr.send(options.body);
601
+ });
602
+ }
603
+ var init_wiki_upload = __esm({
604
+ "ts/sdk/dist/wiki-upload.js"() {
605
+ "use strict";
606
+ }
607
+ });
608
+
609
+ // ts/sdk/dist/fetch-cause.js
610
+ function describeFetchCause(err) {
611
+ const inner = err?.cause;
612
+ for (const candidate of [inner, err]) {
613
+ if (!(candidate instanceof Error))
614
+ continue;
615
+ const code = candidate.code;
616
+ const parts = [];
617
+ if (typeof code === "string" && code && !candidate.message.includes(code))
618
+ parts.push(code);
619
+ if (candidate.message && !GENERIC_FETCH_MESSAGES.has(candidate.message)) {
620
+ parts.push(candidate.message);
621
+ }
622
+ if (parts.length > 0)
623
+ return parts.join(" ");
624
+ }
625
+ return void 0;
626
+ }
627
+ var GENERIC_FETCH_MESSAGES;
628
+ var init_fetch_cause = __esm({
629
+ "ts/sdk/dist/fetch-cause.js"() {
630
+ "use strict";
631
+ GENERIC_FETCH_MESSAGES = /* @__PURE__ */ new Set(["Failed to fetch", "fetch failed"]);
632
+ }
633
+ });
634
+
509
635
  // ts/sdk/dist/app-template-endpoints.js
510
636
  function appTemplateEndpoints(apiBase) {
511
637
  return {
@@ -606,6 +732,26 @@ var init_chat_team_grant_endpoints = __esm({
606
732
  }
607
733
  });
608
734
 
735
+ // ts/sdk/dist/team-invite-endpoints.js
736
+ function teamInviteEndpoints(apiBase) {
737
+ const seg = encodeURIComponent;
738
+ return {
739
+ TEMPLATE_INVITE_LINK: (orgId, templateId) => `${apiBase}/orgs/${seg(orgId)}/templates/${seg(templateId)}/invite-link`,
740
+ TEMPLATE_INVITE_REQUESTS: (orgId, templateId) => `${apiBase}/orgs/${seg(orgId)}/templates/${seg(templateId)}/invite-link/requests`,
741
+ TEMPLATE_INVITE_REQUEST_DECIDE: (orgId, templateId, requestId) => `${apiBase}/orgs/${seg(orgId)}/templates/${seg(templateId)}/invite-link/requests/${seg(requestId)}/decide`,
742
+ TEAM_INVITE: (token) => `${apiBase}/team-invites/${seg(token)}`,
743
+ TEAM_INVITE_REQUESTS: (token) => `${apiBase}/team-invites/${seg(token)}/requests`,
744
+ TEAM_INVITE_REQUEST_MINE: (token) => `${apiBase}/team-invites/${seg(token)}/requests/mine`,
745
+ TEAM_INVITE_REQUEST_CANCEL: (requestId) => `${apiBase}/team-invite-requests/${seg(requestId)}/cancel`,
746
+ TEAM_INVITE_REQUEST_RETRY: (requestId) => `${apiBase}/team-invite-requests/${seg(requestId)}/retry`
747
+ };
748
+ }
749
+ var init_team_invite_endpoints = __esm({
750
+ "ts/sdk/dist/team-invite-endpoints.js"() {
751
+ "use strict";
752
+ }
753
+ });
754
+
609
755
  // ts/sdk/dist/wechat-endpoints.js
610
756
  function wechatEndpoints(apiBase) {
611
757
  const agentBase = (orgId) => `${apiBase}/orgs/${orgId}/agents/me/wechat`;
@@ -624,6 +770,55 @@ var init_wechat_endpoints = __esm({
624
770
  }
625
771
  });
626
772
 
773
+ // ts/sdk/dist/billing-endpoints.js
774
+ function billingEndpoints(apiBase) {
775
+ const billingBase = (orgId, accountId) => accountId ? `${apiBase}/orgs/${orgId}/billing/accounts/${accountId}` : `${apiBase}/orgs/${orgId}/billing`;
776
+ return {
777
+ // Billing & Credits (org-scoped). An account's endpoints live under
778
+ // /billing/accounts/{accountId}; without an accountId they are the org's
779
+ // own account's /billing routes.
780
+ BILLING: (orgId, accountId) => billingBase(orgId, accountId),
781
+ BILLING_TRANSACTIONS: (orgId, accountId) => `${billingBase(orgId, accountId)}/transactions`,
782
+ BILLING_CHECKOUT: (orgId, accountId) => `${billingBase(orgId, accountId)}/checkout`,
783
+ BILLING_AUTO_RELOAD: (orgId, accountId) => `${billingBase(orgId, accountId)}/auto-reload`,
784
+ BILLING_SETUP_INTENT: (orgId, accountId) => `${billingBase(orgId, accountId)}/setup-intent`,
785
+ BILLING_PORTAL_SESSION: (orgId, accountId) => `${billingBase(orgId, accountId)}/portal-session`,
786
+ BILLING_USAGE_DAILY: (orgId, accountId) => `${billingBase(orgId, accountId)}/usage-daily`,
787
+ BILLING_USAGE_HEATMAP: (orgId, accountId) => `${billingBase(orgId, accountId)}/usage-heatmap`,
788
+ BILLING_ACCOUNTS: (orgId) => `${apiBase}/orgs/${orgId}/billing/accounts`,
789
+ BILLING_ACCOUNT_CLOSE: (orgId, accountId) => `${apiBase}/orgs/${orgId}/billing/accounts/${accountId}/close`,
790
+ BILLING_SETTINGS: (orgId) => `${apiBase}/orgs/${orgId}/billing/settings`,
791
+ COMPUTE_PRICING: () => `${apiBase}/billing/compute-pricing`
792
+ };
793
+ }
794
+ var init_billing_endpoints = __esm({
795
+ "ts/sdk/dist/billing-endpoints.js"() {
796
+ "use strict";
797
+ }
798
+ });
799
+
800
+ // ts/sdk/dist/team-endpoints.js
801
+ function teamEndpoints(apiBase) {
802
+ return {
803
+ TEAMS: (orgId) => `${apiBase}/orgs/${orgId}/teams`,
804
+ /** The whole team tree in one read (team-chart-design.md §5). */
805
+ TEAM_GRAPH: (orgId) => `${apiBase}/orgs/${orgId}/team-graph`,
806
+ TEAM: (orgId, teamId) => `${apiBase}/orgs/${orgId}/teams/${teamId}`,
807
+ TEAM_PARENT: (orgId, teamId) => `${apiBase}/orgs/${orgId}/teams/${teamId}/parent`,
808
+ /** What moving a team would change (team-chart-design.md §7). */
809
+ TEAM_PARENT_PREVIEW: (orgId, teamId) => `${apiBase}/orgs/${orgId}/teams/${teamId}/parent/preview`,
810
+ TEAM_MEMBERS: (orgId, teamId) => `${apiBase}/orgs/${orgId}/teams/${teamId}/members`,
811
+ TEAM_MEMBER: (orgId, teamId, userId) => `${apiBase}/orgs/${orgId}/teams/${teamId}/members/${userId}`,
812
+ /** An agent's owning Team (agent-team-attribution-design.md §5.4). */
813
+ AGENT_OWNING_TEAM: (orgId, agentId) => `${apiBase}/orgs/${orgId}/agents/${agentId}/owning-team`
814
+ };
815
+ }
816
+ var init_team_endpoints = __esm({
817
+ "ts/sdk/dist/team-endpoints.js"() {
818
+ "use strict";
819
+ }
820
+ });
821
+
627
822
  // ts/sdk/dist/constants.js
628
823
  function isPlatformModelSelectableForRuntime(model, runtime) {
629
824
  if (!model.upstream_id)
@@ -679,7 +874,10 @@ var init_constants = __esm({
679
874
  init_edge_endpoints();
680
875
  init_slack_endpoints();
681
876
  init_chat_team_grant_endpoints();
877
+ init_team_invite_endpoints();
682
878
  init_wechat_endpoints();
879
+ init_billing_endpoints();
880
+ init_team_endpoints();
683
881
  API_BASE2 = "/api/v1";
684
882
  WIKI_BASE = "/wiki/v1";
685
883
  CLIP_BASE = "/clip/v1";
@@ -984,11 +1182,7 @@ var init_constants = __esm({
984
1182
  ORG: (orgId) => `${API_BASE2}/orgs/${orgId}`,
985
1183
  ORG_MEMBERS: (orgId) => `${API_BASE2}/orgs/${orgId}/members`,
986
1184
  ORG_MEMBERS_FORMER: (orgId) => `${API_BASE2}/orgs/${orgId}/members/former`,
987
- TEAMS: (orgId) => `${API_BASE2}/orgs/${orgId}/teams`,
988
- TEAM: (orgId, teamId) => `${API_BASE2}/orgs/${orgId}/teams/${teamId}`,
989
- TEAM_PARENT: (orgId, teamId) => `${API_BASE2}/orgs/${orgId}/teams/${teamId}/parent`,
990
- TEAM_MEMBERS: (orgId, teamId) => `${API_BASE2}/orgs/${orgId}/teams/${teamId}/members`,
991
- TEAM_MEMBER: (orgId, teamId, userId) => `${API_BASE2}/orgs/${orgId}/teams/${teamId}/members/${userId}`,
1185
+ ...teamEndpoints(API_BASE2),
992
1186
  ORG_MEMBERS_ONLINE: (orgId) => `${API_BASE2}/orgs/${orgId}/members/online`,
993
1187
  LLM_PROVIDERS: (orgId) => `${API_BASE2}/orgs/${orgId}/llm-providers`,
994
1188
  LLM_PROVIDER: (orgId, providerId) => `${API_BASE2}/orgs/${orgId}/llm-providers/${providerId}`,
@@ -1446,19 +1640,12 @@ var init_constants = __esm({
1446
1640
  TEMPLATE: (orgId, templateId) => `${API_BASE2}/orgs/${orgId}/templates/${templateId}`,
1447
1641
  TEMPLATE_DEPLOYMENTS: (orgId) => `${API_BASE2}/orgs/${orgId}/template-deployments`,
1448
1642
  TEMPLATE_DEPLOYMENT: (orgId, deploymentId) => `${API_BASE2}/orgs/${orgId}/template-deployments/${deploymentId}`,
1643
+ // Team launch / team invite links (public preview + signed-in requests)
1644
+ ...teamInviteEndpoints(API_BASE2),
1449
1645
  CLIP_DEPENDENCIES_CHECK: (orgId) => `${API_BASE2}/orgs/${orgId}/clip-dependencies/check`,
1450
1646
  // Onboarding wizard progress (org-scoped, self)
1451
1647
  ONBOARDING_PROGRESS: (orgId) => `${API_BASE2}/orgs/${orgId}/onboarding`,
1452
- // Billing & Credits (org-scoped)
1453
- BILLING: (orgId) => `${API_BASE2}/orgs/${orgId}/billing`,
1454
- BILLING_TRANSACTIONS: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/transactions`,
1455
- BILLING_CHECKOUT: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/checkout`,
1456
- BILLING_AUTO_RELOAD: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/auto-reload`,
1457
- BILLING_SETUP_INTENT: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/setup-intent`,
1458
- BILLING_PORTAL_SESSION: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/portal-session`,
1459
- BILLING_USAGE_DAILY: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/usage-daily`,
1460
- BILLING_USAGE_HEATMAP: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/usage-heatmap`,
1461
- COMPUTE_PRICING: () => `${API_BASE2}/billing/compute-pricing`,
1648
+ ...billingEndpoints(API_BASE2),
1462
1649
  // Runtime capability table (public, no auth) — SSOT for the create/settings
1463
1650
  // interlock: per-runtime compute modes, native model family, cross-family
1464
1651
  // availability, and recommended model.
@@ -3081,115 +3268,253 @@ var init_agent_caller_scope_client = __esm({
3081
3268
  }
3082
3269
  });
3083
3270
 
3084
- // ts/sdk/dist/wiki-upload.js
3085
- function createWikiUploadFormData(params) {
3086
- const form = new FormData();
3087
- form.append("path", params.path);
3088
- form.append("file", params.file);
3089
- if (params.message)
3090
- form.append("message", params.message);
3091
- if (params.uploadId)
3092
- form.append("upload_id", params.uploadId);
3093
- if (params.conflict)
3094
- form.append("conflict", params.conflict);
3095
- if ("contentRoute" in params && params.contentRoute) {
3096
- form.append("content_route", params.contentRoute);
3097
- }
3098
- return form;
3099
- }
3100
- function sendMultipartRequest(options) {
3101
- if (options.onProgress && typeof XMLHttpRequest !== "undefined") {
3102
- return multipartXHR(options, options.onProgress);
3103
- }
3104
- const timeoutSignal = AbortSignal.timeout(options.timeoutMs);
3105
- const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
3106
- return fetch(options.url, {
3107
- method: options.method,
3108
- headers: options.headers,
3109
- body: options.body,
3110
- signal
3111
- });
3112
- }
3113
- function multipartXHR(options, onProgress) {
3114
- return new Promise((resolve9, reject) => {
3115
- const xhr = new XMLHttpRequest();
3116
- let settled = false;
3117
- const finish = (fn) => {
3118
- if (settled)
3119
- return;
3120
- settled = true;
3121
- options.signal?.removeEventListener("abort", abortFromSignal);
3122
- fn();
3123
- };
3124
- const abortFromSignal = () => xhr.abort();
3125
- xhr.open(options.method, options.url, true);
3126
- xhr.timeout = options.timeoutMs;
3127
- for (const [name, value] of Object.entries(options.headers)) {
3128
- xhr.setRequestHeader(name, value);
3129
- }
3130
- xhr.upload.onprogress = (event) => {
3131
- try {
3132
- onProgress(event.loaded, event.lengthComputable ? event.total : 0);
3133
- } catch {
3271
+ // ts/sdk/dist/agent-owning-team-client.js
3272
+ var AgentOwningTeamClient;
3273
+ var init_agent_owning_team_client = __esm({
3274
+ "ts/sdk/dist/agent-owning-team-client.js"() {
3275
+ "use strict";
3276
+ init_agent_caller_scope_client();
3277
+ init_constants();
3278
+ AgentOwningTeamClient = class extends AgentCallerScopeClient {
3279
+ /**
3280
+ * Moves the agent to another Team, or to the organization with `team_id`
3281
+ * null. Pass the Team you saw as `expected_team_id`: someone else's change
3282
+ * in between answers 409 OWNING_TEAM_CHANGED.
3283
+ */
3284
+ async setAgentOwningTeam(orgId, agentId, req) {
3285
+ return this.request("PUT", ENDPOINTS.AGENT_OWNING_TEAM(orgId, agentId), req);
3134
3286
  }
3135
3287
  };
3136
- xhr.onload = () => finish(() => {
3137
- const responseHeaders = new Headers();
3138
- for (const line of xhr.getAllResponseHeaders().trim().split(/[\r\n]+/)) {
3139
- if (!line)
3140
- continue;
3141
- const separator = line.indexOf(":");
3142
- if (separator > 0) {
3143
- responseHeaders.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
3144
- }
3145
- }
3146
- const responseBody = xhr.status === 204 || xhr.responseText === "" ? null : xhr.responseText;
3147
- resolve9(new Response(responseBody, {
3148
- status: xhr.status,
3149
- statusText: xhr.statusText,
3150
- headers: responseHeaders
3151
- }));
3152
- });
3153
- xhr.onerror = () => finish(() => reject(new TypeError("Network request failed")));
3154
- xhr.ontimeout = () => finish(() => reject(new DOMException("Request timed out", "TimeoutError")));
3155
- xhr.onabort = () => finish(() => reject(new DOMException("Request aborted", "AbortError")));
3156
- if (options.signal?.aborted) {
3157
- finish(() => reject(new DOMException("Request aborted", "AbortError")));
3158
- return;
3159
- }
3160
- options.signal?.addEventListener("abort", abortFromSignal, { once: true });
3161
- xhr.send(options.body);
3162
- });
3163
- }
3164
- var init_wiki_upload = __esm({
3165
- "ts/sdk/dist/wiki-upload.js"() {
3288
+ }
3289
+ });
3290
+
3291
+ // ts/sdk/dist/team-graph-client.js
3292
+ var TeamGraphClient;
3293
+ var init_team_graph_client = __esm({
3294
+ "ts/sdk/dist/team-graph-client.js"() {
3166
3295
  "use strict";
3296
+ init_agent_owning_team_client();
3297
+ init_constants();
3298
+ TeamGraphClient = class extends AgentOwningTeamClient {
3299
+ async getTeamGraph(orgId, opts) {
3300
+ const query = opts?.includeAccess ? "?include=access" : "";
3301
+ return this.request("GET", `${ENDPOINTS.TEAM_GRAPH(orgId)}${query}`);
3302
+ }
3303
+ /**
3304
+ * Who would come to see more or less through teams if the team moved under
3305
+ * `parentTeamId`, or to the top level with null, without moving it
3306
+ * (team-chart-design.md §7). Org owners and admins only. Refuses what the move
3307
+ * would refuse, with the same codes. 503 when it cannot compute the whole answer
3308
+ * (`TEAM_MOVE_PREVIEW_WIKI_UNAVAILABLE`, `TEAM_MOVE_PREVIEW_TIMEOUT`,
3309
+ * `TEAM_MOVE_PREVIEW_TOO_LARGE`). Send `tree_revision` back on `setTeamParent`.
3310
+ */
3311
+ async previewTeamMove(orgId, teamId, parentTeamId) {
3312
+ return this.request("POST", ENDPOINTS.TEAM_PARENT_PREVIEW(orgId, teamId), {
3313
+ parent_team_id: parentTeamId
3314
+ });
3315
+ }
3316
+ };
3167
3317
  }
3168
3318
  });
3169
3319
 
3170
- // ts/sdk/dist/fetch-cause.js
3171
- function describeFetchCause(err) {
3172
- const inner = err?.cause;
3173
- for (const candidate of [inner, err]) {
3174
- if (!(candidate instanceof Error))
3175
- continue;
3176
- const code = candidate.code;
3177
- const parts = [];
3178
- if (typeof code === "string" && code && !candidate.message.includes(code))
3179
- parts.push(code);
3180
- if (candidate.message && !GENERIC_FETCH_MESSAGES.has(candidate.message)) {
3181
- parts.push(candidate.message);
3182
- }
3183
- if (parts.length > 0)
3184
- return parts.join(" ");
3320
+ // ts/sdk/dist/billing-client.js
3321
+ var BillingClient;
3322
+ var init_billing_client = __esm({
3323
+ "ts/sdk/dist/billing-client.js"() {
3324
+ "use strict";
3325
+ init_constants();
3326
+ init_team_graph_client();
3327
+ BillingClient = class extends TeamGraphClient {
3328
+ // ---- Billing & Credits (org-scoped) ----
3329
+ //
3330
+ // Every account method takes an optional trailing accountId: omitted, it
3331
+ // acts on the org's own account through the org's /billing routes; given,
3332
+ // on that account under /billing/accounts/{accountId}.
3333
+ async getBilling(orgId, accountId) {
3334
+ return this.request("GET", ENDPOINTS.BILLING(orgId, accountId));
3335
+ }
3336
+ async getUsageDaily(orgId, opts, accountId) {
3337
+ const params = new URLSearchParams();
3338
+ params.set("start_date", opts.start_date);
3339
+ params.set("end_date", opts.end_date);
3340
+ return this.request("GET", `${ENDPOINTS.BILLING_USAGE_DAILY(orgId, accountId)}?${params}`);
3341
+ }
3342
+ async getUsageHeatmap(orgId, opts, accountId) {
3343
+ const params = new URLSearchParams();
3344
+ params.set("start_time", opts.start_time);
3345
+ if (opts.limit != null)
3346
+ params.set("limit", String(opts.limit));
3347
+ if (opts.offset != null)
3348
+ params.set("offset", String(opts.offset));
3349
+ return this.request("GET", `${ENDPOINTS.BILLING_USAGE_HEATMAP(orgId, accountId)}?${params}`);
3350
+ }
3351
+ async listBillingTransactions(orgId, opts, accountId) {
3352
+ const params = new URLSearchParams();
3353
+ if (opts?.cursor)
3354
+ params.set("cursor", opts.cursor);
3355
+ if (opts?.limit)
3356
+ params.set("limit", String(opts.limit));
3357
+ if (opts?.types?.length)
3358
+ params.set("types", opts.types.join(","));
3359
+ if (opts?.user_id)
3360
+ params.set("user_id", opts.user_id);
3361
+ if (opts?.unresolved_actor)
3362
+ params.set("unresolved_actor", "true");
3363
+ if (opts?.machine_id)
3364
+ params.set("machine_id", opts.machine_id);
3365
+ if (opts?.unresolved_machine)
3366
+ params.set("unresolved_machine", "true");
3367
+ if (opts?.from)
3368
+ params.set("from", opts.from);
3369
+ if (opts?.to)
3370
+ params.set("to", opts.to);
3371
+ const qs = params.toString();
3372
+ return this.request("GET", `${ENDPOINTS.BILLING_TRANSACTIONS(orgId, accountId)}${qs ? `?${qs}` : ""}`);
3373
+ }
3374
+ async listBillingTransactionAgentGroups(orgId, opts, accountId) {
3375
+ const params = new URLSearchParams({ group_by: "agent" });
3376
+ if (opts?.from)
3377
+ params.set("from", opts.from);
3378
+ if (opts?.to)
3379
+ params.set("to", opts.to);
3380
+ return this.request("GET", `${ENDPOINTS.BILLING_TRANSACTIONS(orgId, accountId)}?${params}`);
3381
+ }
3382
+ async listBillingTransactionMachineGroups(orgId, opts, accountId) {
3383
+ const params = new URLSearchParams({ group_by: "machine" });
3384
+ if (opts?.from)
3385
+ params.set("from", opts.from);
3386
+ if (opts?.to)
3387
+ params.set("to", opts.to);
3388
+ return this.request("GET", `${ENDPOINTS.BILLING_TRANSACTIONS(orgId, accountId)}?${params}`);
3389
+ }
3390
+ async createCheckout(orgId, req, accountId) {
3391
+ return this.request("POST", ENDPOINTS.BILLING_CHECKOUT(orgId, accountId), req);
3392
+ }
3393
+ /**
3394
+ * Creates a Stripe-hosted card-collection session (Checkout in mode=setup)
3395
+ * and returns the redirect URL. The frontend navigates to `setup_url` and
3396
+ * Stripe handles the card form; the resulting payment_method is recorded
3397
+ * server-side via the `setup_intent.succeeded` webhook. Mirrors
3398
+ * `POST /billing/setup-intent`.
3399
+ */
3400
+ async createSetupIntent(orgId, req, accountId) {
3401
+ return this.request("POST", ENDPOINTS.BILLING_SETUP_INTENT(orgId, accountId), req);
3402
+ }
3403
+ /**
3404
+ * Returns a link to the Stripe-hosted customer portal for the account,
3405
+ * where its managers download invoices and edit the billing details
3406
+ * printed on them. Mirrors `POST /billing/portal-session`.
3407
+ */
3408
+ async createBillingPortalSession(orgId, accountId) {
3409
+ return this.request("POST", ENDPOINTS.BILLING_PORTAL_SESSION(orgId, accountId));
3410
+ }
3411
+ async getAutoReloadSettings(orgId, accountId) {
3412
+ return this.request("GET", ENDPOINTS.BILLING_AUTO_RELOAD(orgId, accountId));
3413
+ }
3414
+ async updateAutoReloadSettings(orgId, req, accountId) {
3415
+ return this.request("PUT", ENDPOINTS.BILLING_AUTO_RELOAD(orgId, accountId), req);
3416
+ }
3417
+ /** The org's billing accounts the caller may view, the org's own first. */
3418
+ async listBillingAccounts(orgId) {
3419
+ const res = await this.request("GET", ENDPOINTS.BILLING_ACCOUNTS(orgId));
3420
+ return res.data;
3421
+ }
3422
+ /** Opens a Team's account (org owners and admins, while Team accounts are
3423
+ * on). Reopening a closed account starts it at zero. */
3424
+ async openBillingAccount(orgId, teamId) {
3425
+ return this.request("POST", ENDPOINTS.BILLING_ACCOUNTS(orgId), { team_id: teamId });
3426
+ }
3427
+ /** Closes a Team account and moves its balance into the org's account. */
3428
+ async closeBillingAccount(orgId, accountId) {
3429
+ await this.request("POST", ENDPOINTS.BILLING_ACCOUNT_CLOSE(orgId, accountId));
3430
+ }
3431
+ async getBillingSettings(orgId) {
3432
+ return this.request("GET", ENDPOINTS.BILLING_SETTINGS(orgId));
3433
+ }
3434
+ /** Sets the org's rules for Team accounts (the org owner only). */
3435
+ async updateBillingSettings(orgId, req) {
3436
+ return this.request("PATCH", ENDPOINTS.BILLING_SETTINGS(orgId), req);
3437
+ }
3438
+ // The admin grant endpoints (POST/GET /internal/admin/orgs/
3439
+ // {id}/grants) intentionally do NOT live on this public client — they
3440
+ // are mounted on the unauthenticated `/internal/*` surface and reachable
3441
+ // only via internal network paths. The admin dashboard maintains its
3442
+ // own thin client (`ts/admin/lib/api.ts`) that hits these directly.
3443
+ async getComputePricing() {
3444
+ const resp = await this.request("GET", ENDPOINTS.COMPUTE_PRICING());
3445
+ return resp.data;
3446
+ }
3447
+ };
3185
3448
  }
3186
- return void 0;
3449
+ });
3450
+
3451
+ // ts/sdk/dist/team-invite-client.js
3452
+ function errorCode(err) {
3453
+ return typeof err === "object" && err !== null ? err.code : void 0;
3187
3454
  }
3188
- var GENERIC_FETCH_MESSAGES;
3189
- var init_fetch_cause = __esm({
3190
- "ts/sdk/dist/fetch-cause.js"() {
3455
+ var TeamInviteClient;
3456
+ var init_team_invite_client = __esm({
3457
+ "ts/sdk/dist/team-invite-client.js"() {
3191
3458
  "use strict";
3192
- GENERIC_FETCH_MESSAGES = /* @__PURE__ */ new Set(["Failed to fetch", "fetch failed"]);
3459
+ init_billing_client();
3460
+ init_constants();
3461
+ TeamInviteClient = class extends BillingClient {
3462
+ /** Org owner/admin: the template's current launch link, or null while it
3463
+ * has none (`TEAM_INVITE_LINK_NOT_FOUND`). Never creates one. */
3464
+ async getTemplateInviteLink(orgId, templateId) {
3465
+ try {
3466
+ return await this.request("GET", ENDPOINTS.TEMPLATE_INVITE_LINK(orgId, templateId));
3467
+ } catch (err) {
3468
+ if (errorCode(err) === "TEAM_INVITE_LINK_NOT_FOUND")
3469
+ return null;
3470
+ throw err;
3471
+ }
3472
+ }
3473
+ /** Org owner/admin: a new launch link, replacing the template's previous
3474
+ * one, whose URL stops working. Every new team waits for an admin's
3475
+ * approval unless `requireApproval` is false (the server's default is
3476
+ * true). */
3477
+ async createTemplateInviteLink(orgId, templateId, options = {}) {
3478
+ return this.request("POST", ENDPOINTS.TEMPLATE_INVITE_LINK(orgId, templateId), options.requireApproval !== void 0 ? { require_approval: options.requireApproval } : {});
3479
+ }
3480
+ /** Org owner/admin: the requests waiting for approval on the template's
3481
+ * current link, oldest first. */
3482
+ async listTemplateInviteRequests(orgId, templateId) {
3483
+ const res = await this.request("GET", ENDPOINTS.TEMPLATE_INVITE_REQUESTS(orgId, templateId));
3484
+ return res.requests ?? [];
3485
+ }
3486
+ /** Org owner/admin: approve or decline a waiting request. Approving brings
3487
+ * a requester from outside the org in as a member and starts their team.
3488
+ * `ALREADY_DECIDED` (409) when someone decided first. */
3489
+ async decideTemplateInviteRequest(orgId, templateId, requestId, decision) {
3490
+ return this.request("POST", ENDPOINTS.TEMPLATE_INVITE_REQUEST_DECIDE(orgId, templateId, requestId), { decision });
3491
+ }
3492
+ /** Public, no login needed: what a link shows before anyone signs in.
3493
+ * `TEAM_INVITE_NOT_FOUND` (404) for an unknown, revoked or switched-off
3494
+ * link; `TEAM_INVITE_EXPIRED` (410) once it lapsed. */
3495
+ async getTeamInvite(token) {
3496
+ return this.request("GET", ENDPOINTS.TEAM_INVITE(token));
3497
+ }
3498
+ /** Ask for a new team through a link. Submitting again returns the
3499
+ * caller's open request instead of making another. */
3500
+ async createTeamInviteRequest(token, body) {
3501
+ return this.request("POST", ENDPOINTS.TEAM_INVITE_REQUESTS(token), body);
3502
+ }
3503
+ /** The caller's latest request through this link, with its derived phase.
3504
+ * `TEAM_INVITE_REQUEST_NOT_FOUND` (404) while they have none. */
3505
+ async getMyTeamInviteRequest(token) {
3506
+ return this.request("GET", ENDPOINTS.TEAM_INVITE_REQUEST_MINE(token));
3507
+ }
3508
+ /** The requester withdraws a request that is still waiting. */
3509
+ async cancelTeamInviteRequest(requestId) {
3510
+ return this.request("POST", ENDPOINTS.TEAM_INVITE_REQUEST_CANCEL(requestId));
3511
+ }
3512
+ /** The requester retries a failed launch; the server never makes a second
3513
+ * squad for the same request. */
3514
+ async retryTeamInviteRequest(requestId) {
3515
+ return this.request("POST", ENDPOINTS.TEAM_INVITE_REQUEST_RETRY(requestId));
3516
+ }
3517
+ };
3193
3518
  }
3194
3519
  });
3195
3520
 
@@ -3268,12 +3593,12 @@ var init_client = __esm({
3268
3593
  "ts/sdk/dist/client.js"() {
3269
3594
  "use strict";
3270
3595
  init_browser_viewer();
3271
- init_agent_caller_scope_client();
3272
3596
  init_wiki_upload();
3273
3597
  init_fetch_cause();
3598
+ init_team_invite_client();
3274
3599
  init_wiki_changeset();
3275
3600
  init_constants();
3276
- ParallClient = class _ParallClient extends AgentCallerScopeClient {
3601
+ ParallClient = class _ParallClient extends TeamInviteClient {
3277
3602
  baseUrl;
3278
3603
  wikiBaseUrl;
3279
3604
  token;
@@ -3674,10 +3999,16 @@ var init_client = __esm({
3674
3999
  async deleteTeam(orgId, teamId) {
3675
4000
  return this.request("DELETE", ENDPOINTS.TEAM(orgId, teamId));
3676
4001
  }
3677
- /** Moves a team under `parentTeamId`, or to the top level with null. Org-admin action. */
3678
- async setTeamParent(orgId, teamId, parentTeamId) {
4002
+ /**
4003
+ * Moves a team under `parentTeamId`, or to the top level with null. Org-admin
4004
+ * action. `expectedTreeRevision` is the revision the move's preview returned: if
4005
+ * the org's team tree changed since, nothing moves and it answers 409
4006
+ * `TEAM_TREE_CHANGED`. Without it nothing is checked.
4007
+ */
4008
+ async setTeamParent(orgId, teamId, parentTeamId, opts) {
3679
4009
  return this.request("PUT", ENDPOINTS.TEAM_PARENT(orgId, teamId), {
3680
- parent_team_id: parentTeamId
4010
+ parent_team_id: parentTeamId,
4011
+ ...opts?.expectedTreeRevision ? { expected_tree_revision: opts.expectedTreeRevision } : {}
3681
4012
  });
3682
4013
  }
3683
4014
  /** Roster with display info, minus members who left the org; `includeSubteams` adds subteam rows. */
@@ -5341,100 +5672,6 @@ var init_client = __esm({
5341
5672
  async updateOnboardingProgress(orgId, request3) {
5342
5673
  return this.request("PATCH", ENDPOINTS.ONBOARDING_PROGRESS(orgId), request3);
5343
5674
  }
5344
- // ---- Billing & Credits (org-scoped) ----
5345
- async getBilling(orgId) {
5346
- return this.request("GET", ENDPOINTS.BILLING(orgId));
5347
- }
5348
- async getUsageDaily(orgId, opts) {
5349
- const params = new URLSearchParams();
5350
- params.set("start_date", opts.start_date);
5351
- params.set("end_date", opts.end_date);
5352
- return this.request("GET", `${ENDPOINTS.BILLING_USAGE_DAILY(orgId)}?${params}`);
5353
- }
5354
- async getUsageHeatmap(orgId, opts) {
5355
- const params = new URLSearchParams();
5356
- params.set("start_time", opts.start_time);
5357
- if (opts.limit != null)
5358
- params.set("limit", String(opts.limit));
5359
- if (opts.offset != null)
5360
- params.set("offset", String(opts.offset));
5361
- return this.request("GET", `${ENDPOINTS.BILLING_USAGE_HEATMAP(orgId)}?${params}`);
5362
- }
5363
- async listBillingTransactions(orgId, opts) {
5364
- const params = new URLSearchParams();
5365
- if (opts?.cursor)
5366
- params.set("cursor", opts.cursor);
5367
- if (opts?.limit)
5368
- params.set("limit", String(opts.limit));
5369
- if (opts?.types?.length)
5370
- params.set("types", opts.types.join(","));
5371
- if (opts?.user_id)
5372
- params.set("user_id", opts.user_id);
5373
- if (opts?.unresolved_actor)
5374
- params.set("unresolved_actor", "true");
5375
- if (opts?.machine_id)
5376
- params.set("machine_id", opts.machine_id);
5377
- if (opts?.unresolved_machine)
5378
- params.set("unresolved_machine", "true");
5379
- if (opts?.from)
5380
- params.set("from", opts.from);
5381
- if (opts?.to)
5382
- params.set("to", opts.to);
5383
- const qs = params.toString();
5384
- return this.request("GET", `${ENDPOINTS.BILLING_TRANSACTIONS(orgId)}${qs ? `?${qs}` : ""}`);
5385
- }
5386
- async listBillingTransactionAgentGroups(orgId, opts) {
5387
- const params = new URLSearchParams({ group_by: "agent" });
5388
- if (opts?.from)
5389
- params.set("from", opts.from);
5390
- if (opts?.to)
5391
- params.set("to", opts.to);
5392
- return this.request("GET", `${ENDPOINTS.BILLING_TRANSACTIONS(orgId)}?${params}`);
5393
- }
5394
- async listBillingTransactionMachineGroups(orgId, opts) {
5395
- const params = new URLSearchParams({ group_by: "machine" });
5396
- if (opts?.from)
5397
- params.set("from", opts.from);
5398
- if (opts?.to)
5399
- params.set("to", opts.to);
5400
- return this.request("GET", `${ENDPOINTS.BILLING_TRANSACTIONS(orgId)}?${params}`);
5401
- }
5402
- async createCheckout(orgId, req) {
5403
- return this.request("POST", ENDPOINTS.BILLING_CHECKOUT(orgId), req);
5404
- }
5405
- /**
5406
- * Creates a Stripe-hosted card-collection session (Checkout in mode=setup)
5407
- * and returns the redirect URL. The frontend navigates to `setup_url` and
5408
- * Stripe handles the card form; the resulting payment_method is recorded
5409
- * server-side via the `setup_intent.succeeded` webhook. Mirrors
5410
- * `POST /billing/setup-intent`.
5411
- */
5412
- async createSetupIntent(orgId, req) {
5413
- return this.request("POST", ENDPOINTS.BILLING_SETUP_INTENT(orgId), req);
5414
- }
5415
- /**
5416
- * Returns a link to the Stripe-hosted customer portal for the org, where
5417
- * admins download invoices and edit the billing details printed on them.
5418
- * Mirrors `POST /billing/portal-session`.
5419
- */
5420
- async createBillingPortalSession(orgId) {
5421
- return this.request("POST", ENDPOINTS.BILLING_PORTAL_SESSION(orgId));
5422
- }
5423
- async getAutoReloadSettings(orgId) {
5424
- return this.request("GET", ENDPOINTS.BILLING_AUTO_RELOAD(orgId));
5425
- }
5426
- async updateAutoReloadSettings(orgId, req) {
5427
- return this.request("PUT", ENDPOINTS.BILLING_AUTO_RELOAD(orgId), req);
5428
- }
5429
- // The admin grant endpoints (POST/GET /internal/admin/orgs/
5430
- // {id}/grants) intentionally do NOT live on this public client — they
5431
- // are mounted on the unauthenticated `/internal/*` surface and reachable
5432
- // only via internal network paths. The admin dashboard maintains its
5433
- // own thin client (`ts/admin/lib/api.ts`) that hits these directly.
5434
- async getComputePricing() {
5435
- const resp = await this.request("GET", ENDPOINTS.COMPUTE_PRICING());
5436
- return resp.data;
5437
- }
5438
5675
  /** Runtime capability table (public) — SSOT for the create/settings interlock. */
5439
5676
  async getRuntimes() {
5440
5677
  const resp = await this.request("GET", ENDPOINTS.RUNTIMES());
@@ -6235,6 +6472,13 @@ var init_task_label_types = __esm({
6235
6472
  }
6236
6473
  });
6237
6474
 
6475
+ // ts/sdk/dist/team-invite-types.js
6476
+ var init_team_invite_types = __esm({
6477
+ "ts/sdk/dist/team-invite-types.js"() {
6478
+ "use strict";
6479
+ }
6480
+ });
6481
+
6238
6482
  // ts/sdk/dist/trigger-judge-types.js
6239
6483
  var init_trigger_judge_types = __esm({
6240
6484
  "ts/sdk/dist/trigger-judge-types.js"() {
@@ -6767,6 +7011,7 @@ __export(dist_exports, {
6767
7011
  parseSubjectToken: () => parseSubjectToken,
6768
7012
  platformDefaultModelForRuntime: () => platformDefaultModelForRuntime,
6769
7013
  readReceiptOf: () => readReceiptOf,
7014
+ refusedAccountOf: () => refusedAccountOf,
6770
7015
  resolveChatListMode: () => resolveChatListMode,
6771
7016
  sameWikiDraftScope: () => sameWikiDraftScope,
6772
7017
  showsReadReceipt: () => showsReadReceipt,
@@ -6787,6 +7032,7 @@ var init_dist = __esm({
6787
7032
  init_attachment_types();
6788
7033
  init_approval_policy_types();
6789
7034
  init_attention_types();
7035
+ init_billing_types();
6790
7036
  init_browser_use();
6791
7037
  init_browser_use_receipt();
6792
7038
  init_browser_use_validation();
@@ -6808,6 +7054,7 @@ var init_dist = __esm({
6808
7054
  init_subject();
6809
7055
  init_user_preferences_types();
6810
7056
  init_task_label_types();
7057
+ init_team_invite_types();
6811
7058
  init_trigger_judge_types();
6812
7059
  init_types();
6813
7060
  init_wechat_types();
@@ -42467,8 +42714,8 @@ var require_client_h2 = __commonJS({
42467
42714
  this.destroy(err);
42468
42715
  util.destroy(this[kSocket], err);
42469
42716
  }
42470
- function onHttp2SessionGoAway(errorCode) {
42471
- const err = this[kError] || new SocketError(`HTTP/2: "GOAWAY" frame received with code ${errorCode}`, util.getSocketInfo(this[kSocket]));
42717
+ function onHttp2SessionGoAway(errorCode2) {
42718
+ const err = this[kError] || new SocketError(`HTTP/2: "GOAWAY" frame received with code ${errorCode2}`, util.getSocketInfo(this[kSocket]));
42472
42719
  const client = this[kClient];
42473
42720
  client[kSocket] = null;
42474
42721
  client[kHTTPContext] = null;
@@ -64376,14 +64623,14 @@ var require_receiver2 = __commonJS({
64376
64623
  * @return {(Error|RangeError)} The error
64377
64624
  * @private
64378
64625
  */
64379
- createError(ErrorCtor, message, prefix, statusCode, errorCode) {
64626
+ createError(ErrorCtor, message, prefix, statusCode, errorCode2) {
64380
64627
  this._loop = false;
64381
64628
  this._errored = true;
64382
64629
  const err = new ErrorCtor(
64383
64630
  prefix ? `Invalid WebSocket frame: ${message}` : message
64384
64631
  );
64385
64632
  Error.captureStackTrace(err, this.createError);
64386
- err.code = errorCode;
64633
+ err.code = errorCode2;
64387
64634
  err[kStatusCode] = statusCode;
64388
64635
  return err;
64389
64636
  }