@parall/daemon 1.85.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.
@@ -34486,8 +34486,8 @@ var require_client_h2 = __commonJS({
34486
34486
  this.destroy(err);
34487
34487
  util.destroy(this[kSocket], err);
34488
34488
  }
34489
- function onHttp2SessionGoAway(errorCode) {
34490
- const err = this[kError] || new SocketError(`HTTP/2: "GOAWAY" frame received with code ${errorCode}`, util.getSocketInfo(this[kSocket]));
34489
+ function onHttp2SessionGoAway(errorCode2) {
34490
+ const err = this[kError] || new SocketError(`HTTP/2: "GOAWAY" frame received with code ${errorCode2}`, util.getSocketInfo(this[kSocket]));
34491
34491
  const client = this[kClient];
34492
34492
  client[kSocket] = null;
34493
34493
  client[kHTTPContext] = null;
@@ -52032,6 +52032,107 @@ function browserViewerRequestOptions(command, opts) {
52032
52032
  };
52033
52033
  }
52034
52034
 
52035
+ // ts/sdk/dist/wiki-upload.js
52036
+ function createWikiUploadFormData(params) {
52037
+ const form = new FormData();
52038
+ form.append("path", params.path);
52039
+ form.append("file", params.file);
52040
+ if (params.message)
52041
+ form.append("message", params.message);
52042
+ if (params.uploadId)
52043
+ form.append("upload_id", params.uploadId);
52044
+ if (params.conflict)
52045
+ form.append("conflict", params.conflict);
52046
+ if ("contentRoute" in params && params.contentRoute) {
52047
+ form.append("content_route", params.contentRoute);
52048
+ }
52049
+ return form;
52050
+ }
52051
+ function sendMultipartRequest(options) {
52052
+ if (options.onProgress && typeof XMLHttpRequest !== "undefined") {
52053
+ return multipartXHR(options, options.onProgress);
52054
+ }
52055
+ const timeoutSignal = AbortSignal.timeout(options.timeoutMs);
52056
+ const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
52057
+ return fetch(options.url, {
52058
+ method: options.method,
52059
+ headers: options.headers,
52060
+ body: options.body,
52061
+ signal
52062
+ });
52063
+ }
52064
+ function multipartXHR(options, onProgress) {
52065
+ return new Promise((resolve3, reject) => {
52066
+ const xhr = new XMLHttpRequest();
52067
+ let settled = false;
52068
+ const finish = (fn) => {
52069
+ if (settled)
52070
+ return;
52071
+ settled = true;
52072
+ options.signal?.removeEventListener("abort", abortFromSignal);
52073
+ fn();
52074
+ };
52075
+ const abortFromSignal = () => xhr.abort();
52076
+ xhr.open(options.method, options.url, true);
52077
+ xhr.timeout = options.timeoutMs;
52078
+ for (const [name, value] of Object.entries(options.headers)) {
52079
+ xhr.setRequestHeader(name, value);
52080
+ }
52081
+ xhr.upload.onprogress = (event) => {
52082
+ try {
52083
+ onProgress(event.loaded, event.lengthComputable ? event.total : 0);
52084
+ } catch {
52085
+ }
52086
+ };
52087
+ xhr.onload = () => finish(() => {
52088
+ const responseHeaders = new Headers();
52089
+ for (const line of xhr.getAllResponseHeaders().trim().split(/[\r\n]+/)) {
52090
+ if (!line)
52091
+ continue;
52092
+ const separator = line.indexOf(":");
52093
+ if (separator > 0) {
52094
+ responseHeaders.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
52095
+ }
52096
+ }
52097
+ const responseBody = xhr.status === 204 || xhr.responseText === "" ? null : xhr.responseText;
52098
+ resolve3(new Response(responseBody, {
52099
+ status: xhr.status,
52100
+ statusText: xhr.statusText,
52101
+ headers: responseHeaders
52102
+ }));
52103
+ });
52104
+ xhr.onerror = () => finish(() => reject(new TypeError("Network request failed")));
52105
+ xhr.ontimeout = () => finish(() => reject(new DOMException("Request timed out", "TimeoutError")));
52106
+ xhr.onabort = () => finish(() => reject(new DOMException("Request aborted", "AbortError")));
52107
+ if (options.signal?.aborted) {
52108
+ finish(() => reject(new DOMException("Request aborted", "AbortError")));
52109
+ return;
52110
+ }
52111
+ options.signal?.addEventListener("abort", abortFromSignal, { once: true });
52112
+ xhr.send(options.body);
52113
+ });
52114
+ }
52115
+
52116
+ // ts/sdk/dist/fetch-cause.js
52117
+ var GENERIC_FETCH_MESSAGES = /* @__PURE__ */ new Set(["Failed to fetch", "fetch failed"]);
52118
+ function describeFetchCause(err) {
52119
+ const inner = err?.cause;
52120
+ for (const candidate of [inner, err]) {
52121
+ if (!(candidate instanceof Error))
52122
+ continue;
52123
+ const code = candidate.code;
52124
+ const parts = [];
52125
+ if (typeof code === "string" && code && !candidate.message.includes(code))
52126
+ parts.push(code);
52127
+ if (candidate.message && !GENERIC_FETCH_MESSAGES.has(candidate.message)) {
52128
+ parts.push(candidate.message);
52129
+ }
52130
+ if (parts.length > 0)
52131
+ return parts.join(" ");
52132
+ }
52133
+ return void 0;
52134
+ }
52135
+
52035
52136
  // ts/sdk/dist/app-template-endpoints.js
52036
52137
  function appTemplateEndpoints(apiBase) {
52037
52138
  return {
@@ -52100,6 +52201,21 @@ function chatTeamGrantEndpoints(apiBase) {
52100
52201
  };
52101
52202
  }
52102
52203
 
52204
+ // ts/sdk/dist/team-invite-endpoints.js
52205
+ function teamInviteEndpoints(apiBase) {
52206
+ const seg = encodeURIComponent;
52207
+ return {
52208
+ TEMPLATE_INVITE_LINK: (orgId, templateId) => `${apiBase}/orgs/${seg(orgId)}/templates/${seg(templateId)}/invite-link`,
52209
+ TEMPLATE_INVITE_REQUESTS: (orgId, templateId) => `${apiBase}/orgs/${seg(orgId)}/templates/${seg(templateId)}/invite-link/requests`,
52210
+ TEMPLATE_INVITE_REQUEST_DECIDE: (orgId, templateId, requestId) => `${apiBase}/orgs/${seg(orgId)}/templates/${seg(templateId)}/invite-link/requests/${seg(requestId)}/decide`,
52211
+ TEAM_INVITE: (token) => `${apiBase}/team-invites/${seg(token)}`,
52212
+ TEAM_INVITE_REQUESTS: (token) => `${apiBase}/team-invites/${seg(token)}/requests`,
52213
+ TEAM_INVITE_REQUEST_MINE: (token) => `${apiBase}/team-invites/${seg(token)}/requests/mine`,
52214
+ TEAM_INVITE_REQUEST_CANCEL: (requestId) => `${apiBase}/team-invite-requests/${seg(requestId)}/cancel`,
52215
+ TEAM_INVITE_REQUEST_RETRY: (requestId) => `${apiBase}/team-invite-requests/${seg(requestId)}/retry`
52216
+ };
52217
+ }
52218
+
52103
52219
  // ts/sdk/dist/wechat-endpoints.js
52104
52220
  function wechatEndpoints(apiBase) {
52105
52221
  const agentBase = (orgId) => `${apiBase}/orgs/${orgId}/agents/me/wechat`;
@@ -52139,8 +52255,12 @@ function billingEndpoints(apiBase) {
52139
52255
  function teamEndpoints(apiBase) {
52140
52256
  return {
52141
52257
  TEAMS: (orgId) => `${apiBase}/orgs/${orgId}/teams`,
52258
+ /** The whole team tree in one read (team-chart-design.md §5). */
52259
+ TEAM_GRAPH: (orgId) => `${apiBase}/orgs/${orgId}/team-graph`,
52142
52260
  TEAM: (orgId, teamId) => `${apiBase}/orgs/${orgId}/teams/${teamId}`,
52143
52261
  TEAM_PARENT: (orgId, teamId) => `${apiBase}/orgs/${orgId}/teams/${teamId}/parent`,
52262
+ /** What moving a team would change (team-chart-design.md §7). */
52263
+ TEAM_PARENT_PREVIEW: (orgId, teamId) => `${apiBase}/orgs/${orgId}/teams/${teamId}/parent/preview`,
52144
52264
  TEAM_MEMBERS: (orgId, teamId) => `${apiBase}/orgs/${orgId}/teams/${teamId}/members`,
52145
52265
  TEAM_MEMBER: (orgId, teamId, userId) => `${apiBase}/orgs/${orgId}/teams/${teamId}/members/${userId}`,
52146
52266
  /** An agent's owning Team (agent-team-attribution-design.md §5.4). */
@@ -52638,6 +52758,8 @@ var ENDPOINTS = {
52638
52758
  TEMPLATE: (orgId, templateId) => `${API_BASE2}/orgs/${orgId}/templates/${templateId}`,
52639
52759
  TEMPLATE_DEPLOYMENTS: (orgId) => `${API_BASE2}/orgs/${orgId}/template-deployments`,
52640
52760
  TEMPLATE_DEPLOYMENT: (orgId, deploymentId) => `${API_BASE2}/orgs/${orgId}/template-deployments/${deploymentId}`,
52761
+ // Team launch / team invite links (public preview + signed-in requests)
52762
+ ...teamInviteEndpoints(API_BASE2),
52641
52763
  CLIP_DEPENDENCIES_CHECK: (orgId) => `${API_BASE2}/orgs/${orgId}/clip-dependencies/check`,
52642
52764
  // Onboarding wizard progress (org-scoped, self)
52643
52765
  ONBOARDING_PROGRESS: (orgId) => `${API_BASE2}/orgs/${orgId}/onboarding`,
@@ -53916,8 +54038,29 @@ var AgentOwningTeamClient = class extends AgentCallerScopeClient {
53916
54038
  }
53917
54039
  };
53918
54040
 
54041
+ // ts/sdk/dist/team-graph-client.js
54042
+ var TeamGraphClient = class extends AgentOwningTeamClient {
54043
+ async getTeamGraph(orgId, opts) {
54044
+ const query = opts?.includeAccess ? "?include=access" : "";
54045
+ return this.request("GET", `${ENDPOINTS.TEAM_GRAPH(orgId)}${query}`);
54046
+ }
54047
+ /**
54048
+ * Who would come to see more or less through teams if the team moved under
54049
+ * `parentTeamId`, or to the top level with null, without moving it
54050
+ * (team-chart-design.md §7). Org owners and admins only. Refuses what the move
54051
+ * would refuse, with the same codes. 503 when it cannot compute the whole answer
54052
+ * (`TEAM_MOVE_PREVIEW_WIKI_UNAVAILABLE`, `TEAM_MOVE_PREVIEW_TIMEOUT`,
54053
+ * `TEAM_MOVE_PREVIEW_TOO_LARGE`). Send `tree_revision` back on `setTeamParent`.
54054
+ */
54055
+ async previewTeamMove(orgId, teamId, parentTeamId) {
54056
+ return this.request("POST", ENDPOINTS.TEAM_PARENT_PREVIEW(orgId, teamId), {
54057
+ parent_team_id: parentTeamId
54058
+ });
54059
+ }
54060
+ };
54061
+
53919
54062
  // ts/sdk/dist/billing-client.js
53920
- var BillingClient = class extends AgentOwningTeamClient {
54063
+ var BillingClient = class extends TeamGraphClient {
53921
54064
  // ---- Billing & Credits (org-scoped) ----
53922
54065
  //
53923
54066
  // Every account method takes an optional trailing accountId: omitted, it
@@ -54039,105 +54182,66 @@ var BillingClient = class extends AgentOwningTeamClient {
54039
54182
  }
54040
54183
  };
54041
54184
 
54042
- // ts/sdk/dist/wiki-upload.js
54043
- function createWikiUploadFormData(params) {
54044
- const form = new FormData();
54045
- form.append("path", params.path);
54046
- form.append("file", params.file);
54047
- if (params.message)
54048
- form.append("message", params.message);
54049
- if (params.uploadId)
54050
- form.append("upload_id", params.uploadId);
54051
- if (params.conflict)
54052
- form.append("conflict", params.conflict);
54053
- if ("contentRoute" in params && params.contentRoute) {
54054
- form.append("content_route", params.contentRoute);
54055
- }
54056
- return form;
54057
- }
54058
- function sendMultipartRequest(options) {
54059
- if (options.onProgress && typeof XMLHttpRequest !== "undefined") {
54060
- return multipartXHR(options, options.onProgress);
54061
- }
54062
- const timeoutSignal = AbortSignal.timeout(options.timeoutMs);
54063
- const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
54064
- return fetch(options.url, {
54065
- method: options.method,
54066
- headers: options.headers,
54067
- body: options.body,
54068
- signal
54069
- });
54070
- }
54071
- function multipartXHR(options, onProgress) {
54072
- return new Promise((resolve3, reject) => {
54073
- const xhr = new XMLHttpRequest();
54074
- let settled = false;
54075
- const finish = (fn) => {
54076
- if (settled)
54077
- return;
54078
- settled = true;
54079
- options.signal?.removeEventListener("abort", abortFromSignal);
54080
- fn();
54081
- };
54082
- const abortFromSignal = () => xhr.abort();
54083
- xhr.open(options.method, options.url, true);
54084
- xhr.timeout = options.timeoutMs;
54085
- for (const [name, value] of Object.entries(options.headers)) {
54086
- xhr.setRequestHeader(name, value);
54087
- }
54088
- xhr.upload.onprogress = (event) => {
54089
- try {
54090
- onProgress(event.loaded, event.lengthComputable ? event.total : 0);
54091
- } catch {
54092
- }
54093
- };
54094
- xhr.onload = () => finish(() => {
54095
- const responseHeaders = new Headers();
54096
- for (const line of xhr.getAllResponseHeaders().trim().split(/[\r\n]+/)) {
54097
- if (!line)
54098
- continue;
54099
- const separator = line.indexOf(":");
54100
- if (separator > 0) {
54101
- responseHeaders.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
54102
- }
54103
- }
54104
- const responseBody = xhr.status === 204 || xhr.responseText === "" ? null : xhr.responseText;
54105
- resolve3(new Response(responseBody, {
54106
- status: xhr.status,
54107
- statusText: xhr.statusText,
54108
- headers: responseHeaders
54109
- }));
54110
- });
54111
- xhr.onerror = () => finish(() => reject(new TypeError("Network request failed")));
54112
- xhr.ontimeout = () => finish(() => reject(new DOMException("Request timed out", "TimeoutError")));
54113
- xhr.onabort = () => finish(() => reject(new DOMException("Request aborted", "AbortError")));
54114
- if (options.signal?.aborted) {
54115
- finish(() => reject(new DOMException("Request aborted", "AbortError")));
54116
- return;
54117
- }
54118
- options.signal?.addEventListener("abort", abortFromSignal, { once: true });
54119
- xhr.send(options.body);
54120
- });
54121
- }
54122
-
54123
- // ts/sdk/dist/fetch-cause.js
54124
- var GENERIC_FETCH_MESSAGES = /* @__PURE__ */ new Set(["Failed to fetch", "fetch failed"]);
54125
- function describeFetchCause(err) {
54126
- const inner = err?.cause;
54127
- for (const candidate of [inner, err]) {
54128
- if (!(candidate instanceof Error))
54129
- continue;
54130
- const code = candidate.code;
54131
- const parts = [];
54132
- if (typeof code === "string" && code && !candidate.message.includes(code))
54133
- parts.push(code);
54134
- if (candidate.message && !GENERIC_FETCH_MESSAGES.has(candidate.message)) {
54135
- parts.push(candidate.message);
54185
+ // ts/sdk/dist/team-invite-client.js
54186
+ var TeamInviteClient = class extends BillingClient {
54187
+ /** Org owner/admin: the template's current launch link, or null while it
54188
+ * has none (`TEAM_INVITE_LINK_NOT_FOUND`). Never creates one. */
54189
+ async getTemplateInviteLink(orgId, templateId) {
54190
+ try {
54191
+ return await this.request("GET", ENDPOINTS.TEMPLATE_INVITE_LINK(orgId, templateId));
54192
+ } catch (err) {
54193
+ if (errorCode(err) === "TEAM_INVITE_LINK_NOT_FOUND")
54194
+ return null;
54195
+ throw err;
54136
54196
  }
54137
- if (parts.length > 0)
54138
- return parts.join(" ");
54139
54197
  }
54140
- return void 0;
54198
+ /** Org owner/admin: a new launch link, replacing the template's previous
54199
+ * one, whose URL stops working. Every new team waits for an admin's
54200
+ * approval unless `requireApproval` is false (the server's default is
54201
+ * true). */
54202
+ async createTemplateInviteLink(orgId, templateId, options = {}) {
54203
+ return this.request("POST", ENDPOINTS.TEMPLATE_INVITE_LINK(orgId, templateId), options.requireApproval !== void 0 ? { require_approval: options.requireApproval } : {});
54204
+ }
54205
+ /** Org owner/admin: the requests waiting for approval on the template's
54206
+ * current link, oldest first. */
54207
+ async listTemplateInviteRequests(orgId, templateId) {
54208
+ const res = await this.request("GET", ENDPOINTS.TEMPLATE_INVITE_REQUESTS(orgId, templateId));
54209
+ return res.requests ?? [];
54210
+ }
54211
+ /** Org owner/admin: approve or decline a waiting request. Approving brings
54212
+ * a requester from outside the org in as a member and starts their team.
54213
+ * `ALREADY_DECIDED` (409) when someone decided first. */
54214
+ async decideTemplateInviteRequest(orgId, templateId, requestId, decision) {
54215
+ return this.request("POST", ENDPOINTS.TEMPLATE_INVITE_REQUEST_DECIDE(orgId, templateId, requestId), { decision });
54216
+ }
54217
+ /** Public, no login needed: what a link shows before anyone signs in.
54218
+ * `TEAM_INVITE_NOT_FOUND` (404) for an unknown, revoked or switched-off
54219
+ * link; `TEAM_INVITE_EXPIRED` (410) once it lapsed. */
54220
+ async getTeamInvite(token) {
54221
+ return this.request("GET", ENDPOINTS.TEAM_INVITE(token));
54222
+ }
54223
+ /** Ask for a new team through a link. Submitting again returns the
54224
+ * caller's open request instead of making another. */
54225
+ async createTeamInviteRequest(token, body) {
54226
+ return this.request("POST", ENDPOINTS.TEAM_INVITE_REQUESTS(token), body);
54227
+ }
54228
+ /** The caller's latest request through this link, with its derived phase.
54229
+ * `TEAM_INVITE_REQUEST_NOT_FOUND` (404) while they have none. */
54230
+ async getMyTeamInviteRequest(token) {
54231
+ return this.request("GET", ENDPOINTS.TEAM_INVITE_REQUEST_MINE(token));
54232
+ }
54233
+ /** The requester withdraws a request that is still waiting. */
54234
+ async cancelTeamInviteRequest(requestId) {
54235
+ return this.request("POST", ENDPOINTS.TEAM_INVITE_REQUEST_CANCEL(requestId));
54236
+ }
54237
+ /** The requester retries a failed launch; the server never makes a second
54238
+ * squad for the same request. */
54239
+ async retryTeamInviteRequest(requestId) {
54240
+ return this.request("POST", ENDPOINTS.TEAM_INVITE_REQUEST_RETRY(requestId));
54241
+ }
54242
+ };
54243
+ function errorCode(err) {
54244
+ return typeof err === "object" && err !== null ? err.code : void 0;
54141
54245
  }
54142
54246
 
54143
54247
  // ts/sdk/dist/wiki-changeset.js
@@ -54175,7 +54279,7 @@ function legacyHeartbeatFromReport(report) {
54175
54279
  detectedRuntimes
54176
54280
  };
54177
54281
  }
54178
- var ParallClient = class _ParallClient extends BillingClient {
54282
+ var ParallClient = class _ParallClient extends TeamInviteClient {
54179
54283
  baseUrl;
54180
54284
  wikiBaseUrl;
54181
54285
  token;
@@ -54576,10 +54680,16 @@ var ParallClient = class _ParallClient extends BillingClient {
54576
54680
  async deleteTeam(orgId, teamId) {
54577
54681
  return this.request("DELETE", ENDPOINTS.TEAM(orgId, teamId));
54578
54682
  }
54579
- /** Moves a team under `parentTeamId`, or to the top level with null. Org-admin action. */
54580
- async setTeamParent(orgId, teamId, parentTeamId) {
54683
+ /**
54684
+ * Moves a team under `parentTeamId`, or to the top level with null. Org-admin
54685
+ * action. `expectedTreeRevision` is the revision the move's preview returned: if
54686
+ * the org's team tree changed since, nothing moves and it answers 409
54687
+ * `TEAM_TREE_CHANGED`. Without it nothing is checked.
54688
+ */
54689
+ async setTeamParent(orgId, teamId, parentTeamId, opts) {
54581
54690
  return this.request("PUT", ENDPOINTS.TEAM_PARENT(orgId, teamId), {
54582
- parent_team_id: parentTeamId
54691
+ parent_team_id: parentTeamId,
54692
+ ...opts?.expectedTreeRevision ? { expected_tree_revision: opts.expectedTreeRevision } : {}
54583
54693
  });
54584
54694
  }
54585
54695
  /** Roster with display info, minus members who left the org; `includeSubteams` adds subteam rows. */
@@ -57883,6 +57993,11 @@ The conversation history above is the main session's context, not your task. Do
57883
57993
 
57884
57994
  End with a brief "Fork summary": what you did, where you replied, and anything the main session should know.]
57885
57995
 
57996
+ `;
57997
+ }
57998
+ function buildForkSteerNotice(event) {
57999
+ return `[Fork scope: the message(s) below arrived from ${forkScopeLabel(event)} while you were working \u2014 the same place as the event this fork was opened for. They are yours too: handle them as you would that event, replying where they came from when they call for a reply. The main session will not answer them.]
58000
+
57886
58001
  `;
57887
58002
  }
57888
58003
  function forkResultBlocks(results) {
@@ -58191,7 +58306,8 @@ async function steerLaneMessageInner(host, event, runner) {
58191
58306
  if (!folded.frame)
58192
58307
  return;
58193
58308
  event.frame = folded.frame;
58194
- const injected = await adapter.enqueueDuringDispatch(runner.sessionKey, eventBody(event), folded.inputLifecycle);
58309
+ const body = runner.fork ? buildForkSteerNotice(event) + eventBody(event) : eventBody(event);
58310
+ const injected = await adapter.enqueueDuringDispatch(runner.sessionKey, body, folded.inputLifecycle);
58195
58311
  if (injected) {
58196
58312
  runner.injected.add(event);
58197
58313
  ledger.markSeen(event, folded.covered);