@parall/daemon 1.46.0 → 1.47.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.
@@ -324,10 +324,17 @@ var init_constants = __esm({
324
324
  CHANNEL_CONVERSATION_SESSION: (orgId, conversationId) => `${API_BASE}/orgs/${orgId}/channel-conversations/${conversationId}/session`,
325
325
  CHANNEL_MESSAGE: (orgId, messageId) => `${API_BASE}/orgs/${orgId}/channel-messages/${messageId}`,
326
326
  CHANNEL_PROVISIONING: (orgId) => `${API_BASE}/orgs/${orgId}/channel-provisioning`,
327
+ CHANNEL_SLACK_MANIFEST_LINK: (orgId) => `${API_BASE}/orgs/${orgId}/channel-provisioning/slack/manifest-link`,
327
328
  CHANNEL_PROVISIONING_SESSION: (orgId, sessionId) => `${API_BASE}/orgs/${orgId}/channel-provisioning/${sessionId}`,
328
329
  CHANNEL_PROVISIONING_CANCEL: (orgId, sessionId) => `${API_BASE}/orgs/${orgId}/channel-provisioning/${sessionId}/cancel`,
329
330
  // Tier-B platform verb (agent-only): send one message as the bound bot.
330
331
  CHANNEL_SEND: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/channel-send`,
332
+ // Tier-B read verbs (agent-only): workspace visibility as the bot sees it.
333
+ SLACK_CHANNELS: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/slack/channels`,
334
+ SLACK_USERS: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/slack/users`,
335
+ SLACK_HISTORY: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/slack/history`,
336
+ SLACK_MEMBERS: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/slack/members`,
337
+ SLACK_STATUS: (orgId) => `${API_BASE}/orgs/${orgId}/agents/me/slack/status`,
331
338
  // Invitations (org-scoped, admin)
332
339
  ORG_INVITATIONS: (orgId) => `${API_BASE}/orgs/${orgId}/invitations`,
333
340
  ORG_INVITATION: (orgId, invId) => `${API_BASE}/orgs/${orgId}/invitations/${invId}`,
@@ -422,6 +429,7 @@ var init_constants = __esm({
422
429
  ORG_UNREAD: (orgId) => `${API_BASE}/orgs/${orgId}/unread`,
423
430
  CHAT_READ: (orgId, chatId) => `${API_BASE}/orgs/${orgId}/chats/${chatId}/read`,
424
431
  THREAD_UNREAD: (orgId, chatId, threadRootId) => `${API_BASE}/orgs/${orgId}/chats/${chatId}/threads/${threadRootId}/unread`,
432
+ THREAD_READ: (orgId, chatId, threadRootId) => `${API_BASE}/orgs/${orgId}/chats/${chatId}/threads/${threadRootId}/read`,
425
433
  // References (org-scoped)
426
434
  REFS_RESOLVE: (orgId) => `${API_BASE}/orgs/${orgId}/refs/resolve`,
427
435
  REFS_BACKLINKS: (orgId) => `${API_BASE}/orgs/${orgId}/refs/backlinks`,
@@ -656,7 +664,7 @@ var init_client = __esm({
656
664
  return apiError;
657
665
  }
658
666
  /** Build headers common to all requests (auth, swimlane). */
659
- buildHeaders(path22, extra) {
667
+ buildHeaders(path23, extra) {
660
668
  const headers = {
661
669
  "Content-Type": "application/json",
662
670
  ...extra
@@ -667,7 +675,7 @@ var init_client = __esm({
667
675
  if (this.swimlaneName) {
668
676
  headers["X-Prll-Swimlane"] = this.swimlaneName;
669
677
  }
670
- if (path22.startsWith(API_BASE)) {
678
+ if (path23.startsWith(API_BASE)) {
671
679
  const overrides = this.getFeatureFlagOverrides?.();
672
680
  if (overrides)
673
681
  headers["X-Prll-FF-Override"] = overrides;
@@ -690,8 +698,8 @@ var init_client = __esm({
690
698
  * is authoritative, so wiki vs api routing can't drift from how a caller
691
699
  * happens to invoke the client.
692
700
  */
693
- baseUrlFor(path22) {
694
- return path22.startsWith(WIKI_BASE) ? this.wikiBaseUrl : this.baseUrl;
701
+ baseUrlFor(path23) {
702
+ return path23.startsWith(WIKI_BASE) ? this.wikiBaseUrl : this.baseUrl;
695
703
  }
696
704
  setToken(token) {
697
705
  this.token = token;
@@ -718,10 +726,10 @@ var init_client = __esm({
718
726
  * REFRESH_THRESHOLD_S, refresh it **before** sending the request.
719
727
  * No-op when the token is still fresh, missing, or un-parseable.
720
728
  */
721
- async ensureFreshToken(path22) {
729
+ async ensureFreshToken(path23) {
722
730
  if (!this.token || !this.getRefreshToken)
723
731
  return;
724
- const pathSuffix = path22.replace(/^\/api\/v1/, "");
732
+ const pathSuffix = path23.replace(/^\/api\/v1/, "");
725
733
  if (_ParallClient.AUTH_PATHS.has(pathSuffix))
726
734
  return;
727
735
  const exp = _ParallClient.decodeJwtExp(this.token);
@@ -753,11 +761,11 @@ var init_client = __esm({
753
761
  this.refreshPromise = null;
754
762
  }
755
763
  }
756
- async request(method, path22, body, query, retried = false, opts) {
764
+ async request(method, path23, body, query, retried = false, opts) {
757
765
  if (!retried) {
758
- await this.ensureFreshToken(path22);
766
+ await this.ensureFreshToken(path23);
759
767
  }
760
- let url = `${this.baseUrlFor(path22)}${path22}`;
768
+ let url = `${this.baseUrlFor(path23)}${path23}`;
761
769
  if (query) {
762
770
  const params = new URLSearchParams();
763
771
  for (const [key, value] of Object.entries(query)) {
@@ -769,7 +777,7 @@ var init_client = __esm({
769
777
  if (qs)
770
778
  url += `?${qs}`;
771
779
  }
772
- const headers = this.buildHeaders(path22);
780
+ const headers = this.buildHeaders(path23);
773
781
  const timeoutSignal = AbortSignal.timeout(opts?.timeoutMs ?? 15e3);
774
782
  const signal = opts?.signal ? AbortSignal.any([opts.signal, timeoutSignal]) : timeoutSignal;
775
783
  let res;
@@ -787,12 +795,12 @@ var init_client = __esm({
787
795
  throw _ParallClient.normalizeFetchError(err);
788
796
  }
789
797
  if (res.status === 401) {
790
- const pathSuffix = path22.replace(/^\/api\/v1/, "");
798
+ const pathSuffix = path23.replace(/^\/api\/v1/, "");
791
799
  const isAuthPath = _ParallClient.AUTH_PATHS.has(pathSuffix);
792
800
  if (!retried && !isAuthPath && this.getRefreshToken) {
793
801
  const refreshed = await this.tryRefresh();
794
802
  if (refreshed) {
795
- return this.request(method, path22, body, query, true, opts);
803
+ return this.request(method, path23, body, query, true, opts);
796
804
  }
797
805
  }
798
806
  if (this.onTokenExpired && !isAuthPath) {
@@ -822,15 +830,15 @@ var init_client = __esm({
822
830
  * hit the 100 MiB cap, so a longer 5-minute timeout is used so a
823
831
  * 50 MiB blob on a slow connection doesn't get chopped at 15 s.
824
832
  */
825
- async multipartRequest(method, path22, body, retried = false) {
833
+ async multipartRequest(method, path23, body, retried = false) {
826
834
  if (!retried) {
827
- await this.ensureFreshToken(path22);
835
+ await this.ensureFreshToken(path23);
828
836
  }
829
- const { "Content-Type": _drop, ...headers } = this.buildHeaders(path22);
837
+ const { "Content-Type": _drop, ...headers } = this.buildHeaders(path23);
830
838
  void _drop;
831
839
  let res;
832
840
  try {
833
- res = await fetch(`${this.baseUrlFor(path22)}${path22}`, {
841
+ res = await fetch(`${this.baseUrlFor(path23)}${path23}`, {
834
842
  method,
835
843
  headers,
836
844
  body,
@@ -840,12 +848,12 @@ var init_client = __esm({
840
848
  throw _ParallClient.normalizeFetchError(err);
841
849
  }
842
850
  if (res.status === 401) {
843
- const pathSuffix = path22.replace(/^\/api\/v1/, "");
851
+ const pathSuffix = path23.replace(/^\/api\/v1/, "");
844
852
  const isAuthPath = _ParallClient.AUTH_PATHS.has(pathSuffix);
845
853
  if (!retried && !isAuthPath && this.getRefreshToken) {
846
854
  const refreshed = await this.tryRefresh();
847
855
  if (refreshed) {
848
- return this.multipartRequest(method, path22, body, true);
856
+ return this.multipartRequest(method, path23, body, true);
849
857
  }
850
858
  }
851
859
  if (this.onTokenExpired && !isAuthPath) {
@@ -1553,12 +1561,18 @@ var init_client = __esm({
1553
1561
  async resizeMachine(orgId, machineId, spec) {
1554
1562
  return this.request("PATCH", ENDPOINTS.MACHINE_SPEC(orgId, machineId), spec);
1555
1563
  }
1556
- /** Signal a local daemon-mode Machine to check for and apply an update. */
1564
+ /** @deprecated Retired server-side (daemon-control-authorization §4.2):
1565
+ * daemons update autonomously (CDN poll + platform release signal). The
1566
+ * endpoint now answers 409 LOCAL_UPDATE_NOT_SUPPORTED unconditionally. */
1557
1567
  async requestMachineUpdate(orgId, machineId, mandatory = false) {
1558
1568
  await this.request("POST", ENDPOINTS.MACHINE_REQUEST_UPDATE(orgId, machineId), { mandatory });
1559
1569
  }
1560
- async browseMachineFilesystem(orgId, machineId, path22) {
1561
- return this.request("POST", ENDPOINTS.MACHINE_BROWSE(orgId, machineId), { path: path22 }, void 0, false, { timeoutMs: 15e3 });
1570
+ /** @deprecated Retired server-side (daemon-control-authorization §4.2):
1571
+ * remote filesystem browse of a member's machine was remote device access.
1572
+ * The endpoint now answers 409 LOCAL_BROWSE_NOT_SUPPORTED unconditionally;
1573
+ * workspace paths are typed in (or picked on the machine's own Desktop). */
1574
+ async browseMachineFilesystem(orgId, machineId, path23) {
1575
+ return this.request("POST", ENDPOINTS.MACHINE_BROWSE(orgId, machineId), { path: path23 }, void 0, false, { timeoutMs: 15e3 });
1562
1576
  }
1563
1577
  /** Create a new machine key. Returns the raw key string (shown once) + metadata. */
1564
1578
  async createMachineKey(orgId, machineId, name) {
@@ -1581,6 +1595,14 @@ var init_client = __esm({
1581
1595
  async getThreadUnread(orgId, chatId, threadRootId) {
1582
1596
  return this.request("GET", ENDPOINTS.THREAD_UNREAD(orgId, chatId, threadRootId));
1583
1597
  }
1598
+ /** Advance the per-thread read cursor (forward-only). The server auto-clears
1599
+ * thread-scoped inbox items (thread_reply + in-thread mentions) the cursor
1600
+ * now covers. */
1601
+ async markThreadRead(orgId, chatId, threadRootId, messageId) {
1602
+ return this.request("POST", ENDPOINTS.THREAD_READ(orgId, chatId, threadRootId), {
1603
+ message_id: messageId
1604
+ });
1605
+ }
1584
1606
  // ---- Inbox ----
1585
1607
  async getInbox(orgId, params) {
1586
1608
  return this.request("GET", ENDPOINTS.INBOX(orgId), void 0, params);
@@ -1604,9 +1626,12 @@ var init_client = __esm({
1604
1626
  async archiveAllInbox(orgId) {
1605
1627
  return this.request("POST", ENDPOINTS.INBOX_ARCHIVE_ALL(orgId));
1606
1628
  }
1607
- /** Mark an inbox item as read by its source (source_type + source_id) rather than inbox item ID. */
1608
- async ackInbox(orgId, source) {
1609
- return this.request("POST", ENDPOINTS.INBOX_ACK(orgId), source);
1629
+ /** Mark inbox items as read by their source (source_type + source_id) or by
1630
+ * group_key, rather than by inbox item ID. The group_key form clears a whole
1631
+ * group at once (e.g. `task:{taskId}` — task_assign/task_update/task_comment
1632
+ * share it), used by the task detail view's auto-ack on open. */
1633
+ async ackInbox(orgId, target) {
1634
+ return this.request("POST", ENDPOINTS.INBOX_ACK(orgId), target);
1610
1635
  }
1611
1636
  async deleteInboxItem(orgId, id) {
1612
1637
  return this.request("DELETE", ENDPOINTS.INBOX_ITEM(orgId, id));
@@ -1888,6 +1913,15 @@ var init_client = __esm({
1888
1913
  async initiateChannelProvisioning(orgId, input) {
1889
1914
  return this.request("POST", ENDPOINTS.CHANNEL_PROVISIONING(orgId), input);
1890
1915
  }
1916
+ /**
1917
+ * Mint a pending slack connection + api.slack.com manifest-prefill link
1918
+ * (guided manual path). Activate the returned connection_id with
1919
+ * deliverChannelCredentials once the user brings back the bot token +
1920
+ * signing secret.
1921
+ */
1922
+ async createSlackManifestLink(orgId, input) {
1923
+ return this.request("POST", ENDPOINTS.CHANNEL_SLACK_MANIFEST_LINK(orgId), input);
1924
+ }
1891
1925
  /**
1892
1926
  * Lazy status poll — server-side this may forward one provider poll, so
1893
1927
  * call it at the session's `poll_interval_seconds` cadence, not faster.
@@ -1906,6 +1940,38 @@ var init_client = __esm({
1906
1940
  async sendChannelMessage(orgId, input) {
1907
1941
  return this.request("POST", ENDPOINTS.CHANNEL_SEND(orgId), input);
1908
1942
  }
1943
+ slackReadQuery(base, query, extra) {
1944
+ const params = new URLSearchParams();
1945
+ if (query?.cursor)
1946
+ params.set("cursor", query.cursor);
1947
+ if (query?.limit)
1948
+ params.set("limit", String(query.limit));
1949
+ for (const [k, v] of Object.entries(extra ?? {}))
1950
+ params.set(k, v);
1951
+ const qs = params.toString();
1952
+ return qs ? `${base}?${qs}` : base;
1953
+ }
1954
+ /**
1955
+ * Tier-B read verbs (agent-only): workspace visibility as the bot sees
1956
+ * it. Same live gate as the send verb; authorization beyond it is the
1957
+ * bot's own Slack permissions.
1958
+ */
1959
+ async listSlackChannels(orgId, query) {
1960
+ return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_CHANNELS(orgId), query));
1961
+ }
1962
+ async listSlackUsers(orgId, query) {
1963
+ return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_USERS(orgId), query));
1964
+ }
1965
+ async slackHistory(orgId, conversationId, query) {
1966
+ return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_HISTORY(orgId), query, { conversation: conversationId }));
1967
+ }
1968
+ async slackMembers(orgId, conversationId, query) {
1969
+ return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_MEMBERS(orgId), query, { conversation: conversationId }));
1970
+ }
1971
+ /** Set/clear the Agents-pane "typing…" indicator (best-effort cosmetic). */
1972
+ async setSlackStatus(orgId, input) {
1973
+ await this.request("POST", ENDPOINTS.SLACK_STATUS(orgId), input);
1974
+ }
1909
1975
  async listChannelConversations(orgId, connectionId) {
1910
1976
  return this.request("GET", ENDPOINTS.CHANNEL_CONNECTION_CONVERSATIONS(orgId, connectionId));
1911
1977
  }
@@ -2141,8 +2207,8 @@ var init_client = __esm({
2141
2207
  async deleteWikiRestriction(orgId, wikiId, restrictionId) {
2142
2208
  await this.request("DELETE", ENDPOINTS.WIKI_RESTRICTION(orgId, wikiId, restrictionId));
2143
2209
  }
2144
- async getWikiAccessStatus(orgId, wikiId, path22) {
2145
- return this.request("GET", ENDPOINTS.WIKI_ACCESS_STATUS(orgId, wikiId), void 0, path22 ? { path: path22 } : void 0);
2210
+ async getWikiAccessStatus(orgId, wikiId, path23) {
2211
+ return this.request("GET", ENDPOINTS.WIKI_ACCESS_STATUS(orgId, wikiId), void 0, path23 ? { path: path23 } : void 0);
2146
2212
  }
2147
2213
  async createWikiAccessRequest(orgId, wikiId, data) {
2148
2214
  await this.request("POST", ENDPOINTS.WIKI_ACCESS_REQUESTS(orgId, wikiId), data);
@@ -2151,14 +2217,14 @@ var init_client = __esm({
2151
2217
  async getWikiCommits(orgId, wikiId, params) {
2152
2218
  return this.request("GET", ENDPOINTS.WIKI_COMMITS(orgId, wikiId), void 0, params);
2153
2219
  }
2154
- async getWikiFileCommits(orgId, wikiId, path22, params) {
2220
+ async getWikiFileCommits(orgId, wikiId, path23, params) {
2155
2221
  return this.request("GET", ENDPOINTS.WIKI_FILE_COMMITS(orgId, wikiId), void 0, {
2156
- path: path22,
2222
+ path: path23,
2157
2223
  ...params
2158
2224
  });
2159
2225
  }
2160
- async getWikiBlame(orgId, wikiId, path22, ref) {
2161
- return this.request("GET", ENDPOINTS.WIKI_BLAME(orgId, wikiId), void 0, { path: path22, ref });
2226
+ async getWikiBlame(orgId, wikiId, path23, ref) {
2227
+ return this.request("GET", ENDPOINTS.WIKI_BLAME(orgId, wikiId), void 0, { path: path23, ref });
2162
2228
  }
2163
2229
  // ---- Wiki Operations (audit log) ----
2164
2230
  async getWikiOperations(orgId, wikiId, params) {
@@ -20619,9 +20685,9 @@ var require_getMachineId_linux = __commonJS({
20619
20685
  var api_1 = (init_esm(), __toCommonJS(esm_exports));
20620
20686
  async function getMachineId() {
20621
20687
  const paths = ["/etc/machine-id", "/var/lib/dbus/machine-id"];
20622
- for (const path22 of paths) {
20688
+ for (const path23 of paths) {
20623
20689
  try {
20624
- const result = await fs_1.promises.readFile(path22, { encoding: "utf8" });
20690
+ const result = await fs_1.promises.readFile(path23, { encoding: "utf8" });
20625
20691
  return result.trim();
20626
20692
  } catch (e) {
20627
20693
  api_1.diag.debug(`error reading machine id: ${e}`);
@@ -24024,7 +24090,7 @@ function appendRootPathToUrlIfNeeded(url) {
24024
24090
  return void 0;
24025
24091
  }
24026
24092
  }
24027
- function appendResourcePathToUrl(url, path22) {
24093
+ function appendResourcePathToUrl(url, path23) {
24028
24094
  try {
24029
24095
  new URL(url);
24030
24096
  } catch (_a) {
@@ -24034,11 +24100,11 @@ function appendResourcePathToUrl(url, path22) {
24034
24100
  if (!url.endsWith("/")) {
24035
24101
  url = url + "/";
24036
24102
  }
24037
- url += path22;
24103
+ url += path23;
24038
24104
  try {
24039
24105
  new URL(url);
24040
24106
  } catch (_b) {
24041
- diag2.warn("Configuration: Provided URL appended with '" + path22 + "' is not a valid URL, using 'undefined' instead of '" + url + "'");
24107
+ diag2.warn("Configuration: Provided URL appended with '" + path23 + "' is not a valid URL, using 'undefined' instead of '" + url + "'");
24042
24108
  return void 0;
24043
24109
  }
24044
24110
  return url;
@@ -30492,7 +30558,7 @@ var require_util2 = __commonJS({
30492
30558
  var { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
30493
30559
  var { IncomingMessage } = __require("node:http");
30494
30560
  var stream = __require("node:stream");
30495
- var net2 = __require("node:net");
30561
+ var net3 = __require("node:net");
30496
30562
  var { stringify } = __require("node:querystring");
30497
30563
  var { EventEmitter: EE } = __require("node:events");
30498
30564
  var timers = require_timers();
@@ -30604,14 +30670,14 @@ var require_util2 = __commonJS({
30604
30670
  }
30605
30671
  const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
30606
30672
  let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
30607
- let path22 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
30673
+ let path23 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
30608
30674
  if (origin[origin.length - 1] === "/") {
30609
30675
  origin = origin.slice(0, origin.length - 1);
30610
30676
  }
30611
- if (path22 && path22[0] !== "/") {
30612
- path22 = `/${path22}`;
30677
+ if (path23 && path23[0] !== "/") {
30678
+ path23 = `/${path23}`;
30613
30679
  }
30614
- return new URL(`${origin}${path22}`);
30680
+ return new URL(`${origin}${path23}`);
30615
30681
  }
30616
30682
  if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
30617
30683
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -30641,7 +30707,7 @@ var require_util2 = __commonJS({
30641
30707
  }
30642
30708
  assert(typeof host === "string");
30643
30709
  const servername = getHostname(host);
30644
- if (net2.isIP(servername)) {
30710
+ if (net3.isIP(servername)) {
30645
30711
  return "";
30646
30712
  }
30647
30713
  return servername;
@@ -31432,9 +31498,9 @@ var require_diagnostics = __commonJS({
31432
31498
  "undici:client:sendHeaders",
31433
31499
  (evt) => {
31434
31500
  const {
31435
- request: { method, path: path22, origin }
31501
+ request: { method, path: path23, origin }
31436
31502
  } = evt;
31437
- debugLog("sending request to %s %s%s", method, origin, path22);
31503
+ debugLog("sending request to %s %s%s", method, origin, path23);
31438
31504
  }
31439
31505
  );
31440
31506
  }
@@ -31452,14 +31518,14 @@ var require_diagnostics = __commonJS({
31452
31518
  "undici:request:headers",
31453
31519
  (evt) => {
31454
31520
  const {
31455
- request: { method, path: path22, origin },
31521
+ request: { method, path: path23, origin },
31456
31522
  response: { statusCode }
31457
31523
  } = evt;
31458
31524
  debugLog(
31459
31525
  "received response to %s %s%s - HTTP %d",
31460
31526
  method,
31461
31527
  origin,
31462
- path22,
31528
+ path23,
31463
31529
  statusCode
31464
31530
  );
31465
31531
  }
@@ -31468,23 +31534,23 @@ var require_diagnostics = __commonJS({
31468
31534
  "undici:request:trailers",
31469
31535
  (evt) => {
31470
31536
  const {
31471
- request: { method, path: path22, origin }
31537
+ request: { method, path: path23, origin }
31472
31538
  } = evt;
31473
- debugLog("trailers received from %s %s%s", method, origin, path22);
31539
+ debugLog("trailers received from %s %s%s", method, origin, path23);
31474
31540
  }
31475
31541
  );
31476
31542
  diagnosticsChannel.subscribe(
31477
31543
  "undici:request:error",
31478
31544
  (evt) => {
31479
31545
  const {
31480
- request: { method, path: path22, origin },
31546
+ request: { method, path: path23, origin },
31481
31547
  error
31482
31548
  } = evt;
31483
31549
  debugLog(
31484
31550
  "request to %s %s%s errored - %s",
31485
31551
  method,
31486
31552
  origin,
31487
- path22,
31553
+ path23,
31488
31554
  error.message
31489
31555
  );
31490
31556
  }
@@ -31587,7 +31653,7 @@ var require_request = __commonJS({
31587
31653
  var kHandler = Symbol("handler");
31588
31654
  var Request = class {
31589
31655
  constructor(origin, {
31590
- path: path22,
31656
+ path: path23,
31591
31657
  method,
31592
31658
  body,
31593
31659
  headers,
@@ -31604,11 +31670,11 @@ var require_request = __commonJS({
31604
31670
  maxRedirections,
31605
31671
  typeOfService
31606
31672
  }, handler) {
31607
- if (typeof path22 !== "string") {
31673
+ if (typeof path23 !== "string") {
31608
31674
  throw new InvalidArgumentError("path must be a string");
31609
- } else if (path22[0] !== "/" && !(path22.startsWith("http://") || path22.startsWith("https://")) && method !== "CONNECT") {
31675
+ } else if (path23[0] !== "/" && !(path23.startsWith("http://") || path23.startsWith("https://")) && method !== "CONNECT") {
31610
31676
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
31611
- } else if (invalidPathRegex.test(path22)) {
31677
+ } else if (invalidPathRegex.test(path23)) {
31612
31678
  throw new InvalidArgumentError("invalid request path");
31613
31679
  }
31614
31680
  if (typeof method !== "string") {
@@ -31683,7 +31749,7 @@ var require_request = __commonJS({
31683
31749
  this.completed = false;
31684
31750
  this.aborted = false;
31685
31751
  this.upgrade = upgrade || null;
31686
- this.path = query ? serializePathWithQuery(path22, query) : path22;
31752
+ this.path = query ? serializePathWithQuery(path23, query) : path23;
31687
31753
  this.origin = origin;
31688
31754
  this.protocol = getProtocolFromUrlString(origin);
31689
31755
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
@@ -32262,7 +32328,7 @@ var require_dispatcher_base = __commonJS({
32262
32328
  var require_connect = __commonJS({
32263
32329
  "ts/node_modules/.pnpm/undici@7.24.8/node_modules/undici/lib/core/connect.js"(exports2, module2) {
32264
32330
  "use strict";
32265
- var net2 = __require("node:net");
32331
+ var net3 = __require("node:net");
32266
32332
  var assert = __require("node:assert");
32267
32333
  var util = require_util2();
32268
32334
  var { InvalidArgumentError } = require_errors();
@@ -32301,7 +32367,7 @@ var require_connect = __commonJS({
32301
32367
  const sessionCache = new SessionCache(maxCachedSessions == null ? 100 : maxCachedSessions);
32302
32368
  timeout = timeout == null ? 1e4 : timeout;
32303
32369
  allowH2 = allowH2 != null ? allowH2 : false;
32304
- return function connect3({ hostname, host, protocol, port, servername, localAddress, httpSocket }, callback) {
32370
+ return function connect4({ hostname, host, protocol, port, servername, localAddress, httpSocket }, callback) {
32305
32371
  let socket;
32306
32372
  if (protocol === "https:") {
32307
32373
  if (!tls) {
@@ -32331,7 +32397,7 @@ var require_connect = __commonJS({
32331
32397
  } else {
32332
32398
  assert(!httpSocket, "httpSocket can only be sent on TLS update");
32333
32399
  port = port || 80;
32334
- socket = net2.connect({
32400
+ socket = net3.connect({
32335
32401
  highWaterMark: 64 * 1024,
32336
32402
  // Same as nodejs fs streams.
32337
32403
  ...options,
@@ -36722,7 +36788,7 @@ var require_client_h1 = __commonJS({
36722
36788
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
36723
36789
  }
36724
36790
  function writeH1(client, request3) {
36725
- const { method, path: path22, host, upgrade, blocking, reset } = request3;
36791
+ const { method, path: path23, host, upgrade, blocking, reset } = request3;
36726
36792
  let { body, headers, contentLength } = request3;
36727
36793
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
36728
36794
  if (util.isFormDataLike(body)) {
@@ -36791,7 +36857,7 @@ var require_client_h1 = __commonJS({
36791
36857
  if (socket.setTypeOfService) {
36792
36858
  socket.setTypeOfService(request3.typeOfService);
36793
36859
  }
36794
- let header = `${method} ${path22} HTTP/1.1\r
36860
+ let header = `${method} ${path23} HTTP/1.1\r
36795
36861
  `;
36796
36862
  if (typeof host === "string") {
36797
36863
  header += `host: ${host}\r
@@ -37444,7 +37510,7 @@ var require_client_h2 = __commonJS({
37444
37510
  function writeH2(client, request3) {
37445
37511
  const requestTimeout = request3.bodyTimeout ?? client[kBodyTimeout];
37446
37512
  const session = client[kHTTP2Session];
37447
- const { method, path: path22, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request3;
37513
+ const { method, path: path23, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request3;
37448
37514
  let { body } = request3;
37449
37515
  if (upgrade != null && upgrade !== "websocket") {
37450
37516
  util.errorRequest(client, request3, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
@@ -37512,7 +37578,7 @@ var require_client_h2 = __commonJS({
37512
37578
  }
37513
37579
  headers[HTTP2_HEADER_METHOD] = "CONNECT";
37514
37580
  headers[HTTP2_HEADER_PROTOCOL] = "websocket";
37515
- headers[HTTP2_HEADER_PATH] = path22;
37581
+ headers[HTTP2_HEADER_PATH] = path23;
37516
37582
  if (protocol === "ws:" || protocol === "wss:") {
37517
37583
  headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
37518
37584
  } else {
@@ -37553,7 +37619,7 @@ var require_client_h2 = __commonJS({
37553
37619
  stream.setTimeout(requestTimeout);
37554
37620
  return true;
37555
37621
  }
37556
- headers[HTTP2_HEADER_PATH] = path22;
37622
+ headers[HTTP2_HEADER_PATH] = path23;
37557
37623
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
37558
37624
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
37559
37625
  if (body && typeof body.read === "function") {
@@ -37869,7 +37935,7 @@ var require_client = __commonJS({
37869
37935
  "ts/node_modules/.pnpm/undici@7.24.8/node_modules/undici/lib/dispatcher/client.js"(exports2, module2) {
37870
37936
  "use strict";
37871
37937
  var assert = __require("node:assert");
37872
- var net2 = __require("node:net");
37938
+ var net3 = __require("node:net");
37873
37939
  var http3 = __require("node:http");
37874
37940
  var util = require_util2();
37875
37941
  var { ClientStats } = require_stats();
@@ -37960,7 +38026,7 @@ var require_client = __commonJS({
37960
38026
  tls,
37961
38027
  strictContentLength,
37962
38028
  maxCachedSessions,
37963
- connect: connect4,
38029
+ connect: connect5,
37964
38030
  maxRequestsPerClient,
37965
38031
  localAddress,
37966
38032
  maxResponseSize,
@@ -38017,13 +38083,13 @@ var require_client = __commonJS({
38017
38083
  if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) {
38018
38084
  throw new InvalidArgumentError("bodyTimeout must be a positive integer or zero");
38019
38085
  }
38020
- if (connect4 != null && typeof connect4 !== "function" && typeof connect4 !== "object") {
38086
+ if (connect5 != null && typeof connect5 !== "function" && typeof connect5 !== "object") {
38021
38087
  throw new InvalidArgumentError("connect must be a function or an object");
38022
38088
  }
38023
38089
  if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) {
38024
38090
  throw new InvalidArgumentError("maxRequestsPerClient must be a positive number");
38025
38091
  }
38026
- if (localAddress != null && (typeof localAddress !== "string" || net2.isIP(localAddress) === 0)) {
38092
+ if (localAddress != null && (typeof localAddress !== "string" || net3.isIP(localAddress) === 0)) {
38027
38093
  throw new InvalidArgumentError("localAddress must be valid string IP address");
38028
38094
  }
38029
38095
  if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) {
@@ -38051,8 +38117,8 @@ var require_client = __commonJS({
38051
38117
  throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
38052
38118
  }
38053
38119
  super();
38054
- if (typeof connect4 !== "function") {
38055
- connect4 = buildConnector({
38120
+ if (typeof connect5 !== "function") {
38121
+ connect5 = buildConnector({
38056
38122
  ...tls,
38057
38123
  maxCachedSessions,
38058
38124
  allowH2,
@@ -38060,14 +38126,14 @@ var require_client = __commonJS({
38060
38126
  socketPath,
38061
38127
  timeout: connectTimeout,
38062
38128
  ...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
38063
- ...connect4
38129
+ ...connect5
38064
38130
  });
38065
38131
  } else if (socketPath != null) {
38066
- const customConnect = connect4;
38067
- connect4 = (opts, callback) => customConnect({ ...opts, socketPath }, callback);
38132
+ const customConnect = connect5;
38133
+ connect5 = (opts, callback) => customConnect({ ...opts, socketPath }, callback);
38068
38134
  }
38069
38135
  this[kUrl] = util.parseOrigin(url);
38070
- this[kConnector] = connect4;
38136
+ this[kConnector] = connect5;
38071
38137
  this[kPipelining] = pipelining != null ? pipelining : 1;
38072
38138
  this[kMaxHeadersSize] = maxHeaderSize;
38073
38139
  this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout;
@@ -38125,7 +38191,7 @@ var require_client = __commonJS({
38125
38191
  );
38126
38192
  }
38127
38193
  [kConnect](cb) {
38128
- connect3(this);
38194
+ connect4(this);
38129
38195
  this.once("connect", cb);
38130
38196
  }
38131
38197
  [kDispatch](opts, handler) {
@@ -38187,7 +38253,7 @@ var require_client = __commonJS({
38187
38253
  assert(client[kSize] === 0);
38188
38254
  }
38189
38255
  }
38190
- function connect3(client) {
38256
+ function connect4(client) {
38191
38257
  assert(!client[kConnecting]);
38192
38258
  assert(!client[kHTTPContext]);
38193
38259
  let { host, hostname, protocol, port } = client[kUrl];
@@ -38195,7 +38261,7 @@ var require_client = __commonJS({
38195
38261
  const idx = hostname.indexOf("]");
38196
38262
  assert(idx !== -1);
38197
38263
  const ip = hostname.substring(1, idx);
38198
- assert(net2.isIPv6(ip));
38264
+ assert(net3.isIPv6(ip));
38199
38265
  hostname = ip;
38200
38266
  }
38201
38267
  client[kConnecting] = true;
@@ -38366,7 +38432,7 @@ var require_client = __commonJS({
38366
38432
  return;
38367
38433
  }
38368
38434
  if (!client[kHTTPContext]) {
38369
- connect3(client);
38435
+ connect4(client);
38370
38436
  return;
38371
38437
  }
38372
38438
  if (client[kHTTPContext].destroyed) {
@@ -38662,7 +38728,7 @@ var require_pool2 = __commonJS({
38662
38728
  constructor(origin, {
38663
38729
  connections,
38664
38730
  factory = defaultFactory,
38665
- connect: connect3,
38731
+ connect: connect4,
38666
38732
  connectTimeout,
38667
38733
  tls,
38668
38734
  maxCachedSessions,
@@ -38679,24 +38745,24 @@ var require_pool2 = __commonJS({
38679
38745
  if (typeof factory !== "function") {
38680
38746
  throw new InvalidArgumentError("factory must be a function.");
38681
38747
  }
38682
- if (connect3 != null && typeof connect3 !== "function" && typeof connect3 !== "object") {
38748
+ if (connect4 != null && typeof connect4 !== "function" && typeof connect4 !== "object") {
38683
38749
  throw new InvalidArgumentError("connect must be a function or an object");
38684
38750
  }
38685
- if (typeof connect3 !== "function") {
38686
- connect3 = buildConnector({
38751
+ if (typeof connect4 !== "function") {
38752
+ connect4 = buildConnector({
38687
38753
  ...tls,
38688
38754
  maxCachedSessions,
38689
38755
  allowH2,
38690
38756
  socketPath,
38691
38757
  timeout: connectTimeout,
38692
38758
  ...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
38693
- ...connect3
38759
+ ...connect4
38694
38760
  });
38695
38761
  }
38696
38762
  super();
38697
38763
  this[kConnections] = connections || null;
38698
38764
  this[kUrl] = util.parseOrigin(origin);
38699
- this[kOptions] = { ...util.deepClone(options), connect: connect3, allowH2, clientTtl, socketPath };
38765
+ this[kOptions] = { ...util.deepClone(options), connect: connect4, allowH2, clientTtl, socketPath };
38700
38766
  this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
38701
38767
  this[kFactory] = factory;
38702
38768
  this.on("connect", (origin2, targets) => {
@@ -38913,7 +38979,7 @@ var require_round_robin_pool = __commonJS({
38913
38979
  constructor(origin, {
38914
38980
  connections,
38915
38981
  factory = defaultFactory,
38916
- connect: connect3,
38982
+ connect: connect4,
38917
38983
  connectTimeout,
38918
38984
  tls,
38919
38985
  maxCachedSessions,
@@ -38930,24 +38996,24 @@ var require_round_robin_pool = __commonJS({
38930
38996
  if (typeof factory !== "function") {
38931
38997
  throw new InvalidArgumentError("factory must be a function.");
38932
38998
  }
38933
- if (connect3 != null && typeof connect3 !== "function" && typeof connect3 !== "object") {
38999
+ if (connect4 != null && typeof connect4 !== "function" && typeof connect4 !== "object") {
38934
39000
  throw new InvalidArgumentError("connect must be a function or an object");
38935
39001
  }
38936
- if (typeof connect3 !== "function") {
38937
- connect3 = buildConnector({
39002
+ if (typeof connect4 !== "function") {
39003
+ connect4 = buildConnector({
38938
39004
  ...tls,
38939
39005
  maxCachedSessions,
38940
39006
  allowH2,
38941
39007
  socketPath,
38942
39008
  timeout: connectTimeout,
38943
39009
  ...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
38944
- ...connect3
39010
+ ...connect4
38945
39011
  });
38946
39012
  }
38947
39013
  super();
38948
39014
  this[kConnections] = connections || null;
38949
39015
  this[kUrl] = util.parseOrigin(origin);
38950
- this[kOptions] = { ...util.deepClone(options), connect: connect3, allowH2, clientTtl, socketPath };
39016
+ this[kOptions] = { ...util.deepClone(options), connect: connect4, allowH2, clientTtl, socketPath };
38951
39017
  this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
38952
39018
  this[kFactory] = factory;
38953
39019
  this[kIndex] = -1;
@@ -39021,21 +39087,21 @@ var require_agent = __commonJS({
39021
39087
  return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
39022
39088
  }
39023
39089
  var Agent4 = class extends DispatcherBase {
39024
- constructor({ factory = defaultFactory, maxOrigins = Infinity, connect: connect3, ...options } = {}) {
39090
+ constructor({ factory = defaultFactory, maxOrigins = Infinity, connect: connect4, ...options } = {}) {
39025
39091
  if (typeof factory !== "function") {
39026
39092
  throw new InvalidArgumentError("factory must be a function.");
39027
39093
  }
39028
- if (connect3 != null && typeof connect3 !== "function" && typeof connect3 !== "object") {
39094
+ if (connect4 != null && typeof connect4 !== "function" && typeof connect4 !== "object") {
39029
39095
  throw new InvalidArgumentError("connect must be a function or an object");
39030
39096
  }
39031
39097
  if (typeof maxOrigins !== "number" || Number.isNaN(maxOrigins) || maxOrigins <= 0) {
39032
39098
  throw new InvalidArgumentError("maxOrigins must be a number greater than 0");
39033
39099
  }
39034
39100
  super();
39035
- if (connect3 && typeof connect3 !== "function") {
39036
- connect3 = { ...connect3 };
39101
+ if (connect4 && typeof connect4 !== "function") {
39102
+ connect4 = { ...connect4 };
39037
39103
  }
39038
- this[kOptions] = { ...util.deepClone(options), maxOrigins, connect: connect3 };
39104
+ this[kOptions] = { ...util.deepClone(options), maxOrigins, connect: connect4 };
39039
39105
  this[kFactory] = factory;
39040
39106
  this[kClients] = /* @__PURE__ */ new Map();
39041
39107
  this[kOrigins] = /* @__PURE__ */ new Set();
@@ -39138,10 +39204,10 @@ var require_socks5_utils = __commonJS({
39138
39204
  "ts/node_modules/.pnpm/undici@7.24.8/node_modules/undici/lib/core/socks5-utils.js"(exports2, module2) {
39139
39205
  "use strict";
39140
39206
  var { Buffer: Buffer2 } = __require("node:buffer");
39141
- var net2 = __require("node:net");
39207
+ var net3 = __require("node:net");
39142
39208
  var { InvalidArgumentError } = require_errors();
39143
39209
  function parseAddress(address) {
39144
- if (net2.isIPv4(address)) {
39210
+ if (net3.isIPv4(address)) {
39145
39211
  const parts = address.split(".").map(Number);
39146
39212
  return {
39147
39213
  type: 1,
@@ -39149,7 +39215,7 @@ var require_socks5_utils = __commonJS({
39149
39215
  buffer: Buffer2.from(parts)
39150
39216
  };
39151
39217
  }
39152
- if (net2.isIPv6(address)) {
39218
+ if (net3.isIPv6(address)) {
39153
39219
  return {
39154
39220
  type: 4,
39155
39221
  // IPv6
@@ -39609,7 +39675,7 @@ var require_socks5_client = __commonJS({
39609
39675
  var require_socks5_proxy_agent = __commonJS({
39610
39676
  "ts/node_modules/.pnpm/undici@7.24.8/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js"(exports2, module2) {
39611
39677
  "use strict";
39612
- var net2 = __require("node:net");
39678
+ var net3 = __require("node:net");
39613
39679
  var { URL: URL2 } = __require("node:url");
39614
39680
  var tls;
39615
39681
  var DispatcherBase = require_dispatcher_base();
@@ -39671,7 +39737,7 @@ var require_socks5_proxy_agent = __commonJS({
39671
39737
  socket2.removeListener("connect", onConnect);
39672
39738
  reject(err);
39673
39739
  };
39674
- const socket2 = net2.connect({
39740
+ const socket2 = net3.connect({
39675
39741
  host: proxyHost,
39676
39742
  port: proxyPort
39677
39743
  });
@@ -39830,16 +39896,16 @@ var require_proxy_agent = __commonJS({
39830
39896
  }
39831
39897
  var Http1ProxyWrapper = class extends DispatcherBase {
39832
39898
  #client;
39833
- constructor(proxyUrl, { headers = {}, connect: connect3, factory }) {
39899
+ constructor(proxyUrl, { headers = {}, connect: connect4, factory }) {
39834
39900
  if (!proxyUrl) {
39835
39901
  throw new InvalidArgumentError("Proxy URL is mandatory");
39836
39902
  }
39837
39903
  super();
39838
39904
  this[kProxyHeaders] = headers;
39839
39905
  if (factory) {
39840
- this.#client = factory(proxyUrl, { connect: connect3 });
39906
+ this.#client = factory(proxyUrl, { connect: connect4 });
39841
39907
  } else {
39842
- this.#client = new Client(proxyUrl, { connect: connect3 });
39908
+ this.#client = new Client(proxyUrl, { connect: connect4 });
39843
39909
  }
39844
39910
  }
39845
39911
  [kDispatch](opts, handler) {
@@ -39855,10 +39921,10 @@ var require_proxy_agent = __commonJS({
39855
39921
  };
39856
39922
  const {
39857
39923
  origin,
39858
- path: path22 = "/",
39924
+ path: path23 = "/",
39859
39925
  headers = {}
39860
39926
  } = opts;
39861
- opts.path = origin + path22;
39927
+ opts.path = origin + path23;
39862
39928
  if (!("host" in headers) && !("Host" in headers)) {
39863
39929
  const { host } = new URL(origin);
39864
39930
  headers.host = host;
@@ -39900,7 +39966,7 @@ var require_proxy_agent = __commonJS({
39900
39966
  } else if (username && password) {
39901
39967
  this[kProxyHeaders]["proxy-authorization"] = `Basic ${Buffer.from(`${decodeURIComponent(username)}:${decodeURIComponent(password)}`).toString("base64")}`;
39902
39968
  }
39903
- const connect3 = buildConnector({ ...opts.proxyTls });
39969
+ const connect4 = buildConnector({ ...opts.proxyTls });
39904
39970
  this[kConnectEndpoint] = buildConnector({ ...opts.requestTls });
39905
39971
  const agentFactory = opts.factory || defaultAgentFactory;
39906
39972
  const factory = (origin2, options) => {
@@ -39908,7 +39974,7 @@ var require_proxy_agent = __commonJS({
39908
39974
  if (this[kProxy].protocol === "socks5:" || this[kProxy].protocol === "socks:") {
39909
39975
  return new Socks5ProxyAgent(this[kProxy].uri, {
39910
39976
  headers: this[kProxyHeaders],
39911
- connect: connect3,
39977
+ connect: connect4,
39912
39978
  factory: agentFactory,
39913
39979
  username: opts.username || username,
39914
39980
  password: opts.password || password,
@@ -39918,7 +39984,7 @@ var require_proxy_agent = __commonJS({
39918
39984
  if (!this[kTunnelProxy] && protocol2 === "http:" && this[kProxy].protocol === "http:") {
39919
39985
  return new Http1ProxyWrapper(this[kProxy].uri, {
39920
39986
  headers: this[kProxyHeaders],
39921
- connect: connect3,
39987
+ connect: connect4,
39922
39988
  factory: agentFactory
39923
39989
  });
39924
39990
  }
@@ -39927,7 +39993,7 @@ var require_proxy_agent = __commonJS({
39927
39993
  if (protocol === "socks5:" || protocol === "socks:") {
39928
39994
  this[kClient] = null;
39929
39995
  } else {
39930
- this[kClient] = clientFactory(url, { connect: connect3 });
39996
+ this[kClient] = clientFactory(url, { connect: connect4 });
39931
39997
  }
39932
39998
  this[kAgent] = new Agent4({
39933
39999
  ...opts,
@@ -40533,7 +40599,7 @@ var require_h2c_client = __commonJS({
40533
40599
  "h2c-client: Only h2c protocol is supported"
40534
40600
  );
40535
40601
  }
40536
- const { connect: connect3, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
40602
+ const { connect: connect4, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
40537
40603
  let defaultMaxConcurrentStreams = 100;
40538
40604
  let defaultPipelining = 100;
40539
40605
  if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) {
@@ -41715,10 +41781,10 @@ var require_api_connect = __commonJS({
41715
41781
  }
41716
41782
  }
41717
41783
  };
41718
- function connect3(opts, callback) {
41784
+ function connect4(opts, callback) {
41719
41785
  if (callback === void 0) {
41720
41786
  return new Promise((resolve9, reject) => {
41721
- connect3.call(this, opts, (err, data) => {
41787
+ connect4.call(this, opts, (err, data) => {
41722
41788
  return err ? reject(err) : resolve9(data);
41723
41789
  });
41724
41790
  });
@@ -41735,7 +41801,7 @@ var require_api_connect = __commonJS({
41735
41801
  queueMicrotask(() => callback(err, { opaque }));
41736
41802
  }
41737
41803
  }
41738
- module2.exports = connect3;
41804
+ module2.exports = connect4;
41739
41805
  }
41740
41806
  });
41741
41807
 
@@ -41921,20 +41987,20 @@ var require_mock_utils = __commonJS({
41921
41987
  }
41922
41988
  return normalizedQp;
41923
41989
  }
41924
- function safeUrl(path22) {
41925
- if (typeof path22 !== "string") {
41926
- return path22;
41990
+ function safeUrl(path23) {
41991
+ if (typeof path23 !== "string") {
41992
+ return path23;
41927
41993
  }
41928
- const pathSegments = path22.split("?", 3);
41994
+ const pathSegments = path23.split("?", 3);
41929
41995
  if (pathSegments.length !== 2) {
41930
- return path22;
41996
+ return path23;
41931
41997
  }
41932
41998
  const qp = new URLSearchParams(pathSegments.pop());
41933
41999
  qp.sort();
41934
42000
  return [...pathSegments, qp.toString()].join("?");
41935
42001
  }
41936
- function matchKey(mockDispatch2, { path: path22, method, body, headers }) {
41937
- const pathMatch = matchValue(mockDispatch2.path, path22);
42002
+ function matchKey(mockDispatch2, { path: path23, method, body, headers }) {
42003
+ const pathMatch = matchValue(mockDispatch2.path, path23);
41938
42004
  const methodMatch = matchValue(mockDispatch2.method, method);
41939
42005
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
41940
42006
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -41959,8 +42025,8 @@ var require_mock_utils = __commonJS({
41959
42025
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
41960
42026
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
41961
42027
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
41962
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path22, ignoreTrailingSlash }) => {
41963
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path22)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path22), resolvedPath);
42028
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path23, ignoreTrailingSlash }) => {
42029
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path23)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path23), resolvedPath);
41964
42030
  });
41965
42031
  if (matchedMockDispatches.length === 0) {
41966
42032
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -41999,19 +42065,19 @@ var require_mock_utils = __commonJS({
41999
42065
  mockDispatches.splice(index, 1);
42000
42066
  }
42001
42067
  }
42002
- function removeTrailingSlash(path22) {
42003
- while (path22.endsWith("/")) {
42004
- path22 = path22.slice(0, -1);
42068
+ function removeTrailingSlash(path23) {
42069
+ while (path23.endsWith("/")) {
42070
+ path23 = path23.slice(0, -1);
42005
42071
  }
42006
- if (path22.length === 0) {
42007
- path22 = "/";
42072
+ if (path23.length === 0) {
42073
+ path23 = "/";
42008
42074
  }
42009
- return path22;
42075
+ return path23;
42010
42076
  }
42011
42077
  function buildKey(opts) {
42012
- const { path: path22, method, body, headers, query } = opts;
42078
+ const { path: path23, method, body, headers, query } = opts;
42013
42079
  return {
42014
- path: path22,
42080
+ path: path23,
42015
42081
  method,
42016
42082
  body,
42017
42083
  headers,
@@ -42701,10 +42767,10 @@ var require_pending_interceptors_formatter = __commonJS({
42701
42767
  }
42702
42768
  format(pendingInterceptors) {
42703
42769
  const withPrettyHeaders = pendingInterceptors.map(
42704
- ({ method, path: path22, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
42770
+ ({ method, path: path23, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
42705
42771
  Method: method,
42706
42772
  Origin: origin,
42707
- Path: path22,
42773
+ Path: path23,
42708
42774
  "Status code": statusCode,
42709
42775
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
42710
42776
  Invocations: timesInvoked,
@@ -42786,9 +42852,9 @@ var require_mock_agent = __commonJS({
42786
42852
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
42787
42853
  const dispatchOpts = { ...opts };
42788
42854
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
42789
- const [path22, searchParams] = dispatchOpts.path.split("?");
42855
+ const [path23, searchParams] = dispatchOpts.path.split("?");
42790
42856
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
42791
- dispatchOpts.path = `${path22}?${normalizedSearchParams}`;
42857
+ dispatchOpts.path = `${path23}?${normalizedSearchParams}`;
42792
42858
  }
42793
42859
  return this[kAgent].dispatch(dispatchOpts, handler);
42794
42860
  }
@@ -42993,7 +43059,7 @@ var require_snapshot_recorder = __commonJS({
42993
43059
  "ts/node_modules/.pnpm/undici@7.24.8/node_modules/undici/lib/mock/snapshot-recorder.js"(exports2, module2) {
42994
43060
  "use strict";
42995
43061
  var { writeFile, readFile, mkdir } = __require("node:fs/promises");
42996
- var { dirname: dirname12, resolve: resolve9 } = __require("node:path");
43062
+ var { dirname: dirname13, resolve: resolve9 } = __require("node:path");
42997
43063
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
42998
43064
  var { InvalidArgumentError, UndiciError } = require_errors();
42999
43065
  var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
@@ -43189,12 +43255,12 @@ var require_snapshot_recorder = __commonJS({
43189
43255
  * @return {Promise<void>} - Resolves when snapshots are loaded
43190
43256
  */
43191
43257
  async loadSnapshots(filePath) {
43192
- const path22 = filePath || this.#snapshotPath;
43193
- if (!path22) {
43258
+ const path23 = filePath || this.#snapshotPath;
43259
+ if (!path23) {
43194
43260
  throw new InvalidArgumentError("Snapshot path is required");
43195
43261
  }
43196
43262
  try {
43197
- const data = await readFile(resolve9(path22), "utf8");
43263
+ const data = await readFile(resolve9(path23), "utf8");
43198
43264
  const parsed = JSON.parse(data);
43199
43265
  if (Array.isArray(parsed)) {
43200
43266
  this.#snapshots.clear();
@@ -43208,7 +43274,7 @@ var require_snapshot_recorder = __commonJS({
43208
43274
  if (error.code === "ENOENT") {
43209
43275
  this.#snapshots.clear();
43210
43276
  } else {
43211
- throw new UndiciError(`Failed to load snapshots from ${path22}`, { cause: error });
43277
+ throw new UndiciError(`Failed to load snapshots from ${path23}`, { cause: error });
43212
43278
  }
43213
43279
  }
43214
43280
  }
@@ -43219,12 +43285,12 @@ var require_snapshot_recorder = __commonJS({
43219
43285
  * @returns {Promise<void>} - Resolves when snapshots are saved
43220
43286
  */
43221
43287
  async saveSnapshots(filePath) {
43222
- const path22 = filePath || this.#snapshotPath;
43223
- if (!path22) {
43288
+ const path23 = filePath || this.#snapshotPath;
43289
+ if (!path23) {
43224
43290
  throw new InvalidArgumentError("Snapshot path is required");
43225
43291
  }
43226
- const resolvedPath = resolve9(path22);
43227
- await mkdir(dirname12(resolvedPath), { recursive: true });
43292
+ const resolvedPath = resolve9(path23);
43293
+ await mkdir(dirname13(resolvedPath), { recursive: true });
43228
43294
  const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
43229
43295
  hash,
43230
43296
  snapshot
@@ -43848,15 +43914,15 @@ var require_redirect_handler = __commonJS({
43848
43914
  return;
43849
43915
  }
43850
43916
  const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
43851
- const path22 = search ? `${pathname}${search}` : pathname;
43852
- const redirectUrlString = `${origin}${path22}`;
43917
+ const path23 = search ? `${pathname}${search}` : pathname;
43918
+ const redirectUrlString = `${origin}${path23}`;
43853
43919
  for (const historyUrl of this.history) {
43854
43920
  if (historyUrl.toString() === redirectUrlString) {
43855
43921
  throw new InvalidArgumentError(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
43856
43922
  }
43857
43923
  }
43858
43924
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
43859
- this.opts.path = path22;
43925
+ this.opts.path = path23;
43860
43926
  this.opts.origin = origin;
43861
43927
  this.opts.query = null;
43862
43928
  }
@@ -50063,11 +50129,11 @@ var require_fetch = __commonJS({
50063
50129
  function dispatch({ body }) {
50064
50130
  const url = requestCurrentURL(request3);
50065
50131
  const agent = fetchParams.controller.dispatcher;
50066
- const path22 = url.pathname + url.search;
50132
+ const path23 = url.pathname + url.search;
50067
50133
  const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
50068
50134
  return new Promise((resolve9, reject) => agent.dispatch(
50069
50135
  {
50070
- path: hasTrailingQuestionMark ? `${path22}?` : path22,
50136
+ path: hasTrailingQuestionMark ? `${path23}?` : path23,
50071
50137
  origin: url.origin,
50072
50138
  method: request3.method,
50073
50139
  body: agent.isMockActive ? request3.body && (request3.body.source || request3.body.stream) : body,
@@ -51014,9 +51080,9 @@ var require_util5 = __commonJS({
51014
51080
  }
51015
51081
  }
51016
51082
  }
51017
- function validateCookiePath(path22) {
51018
- for (let i = 0; i < path22.length; ++i) {
51019
- const code = path22.charCodeAt(i);
51083
+ function validateCookiePath(path23) {
51084
+ for (let i = 0; i < path23.length; ++i) {
51085
+ const code = path23.charCodeAt(i);
51020
51086
  if (code < 32 || // exclude CTLs (0-31)
51021
51087
  code === 127 || // DEL
51022
51088
  code === 59) {
@@ -54186,11 +54252,11 @@ var require_undici = __commonJS({
54186
54252
  if (typeof opts.path !== "string") {
54187
54253
  throw new InvalidArgumentError("invalid opts.path");
54188
54254
  }
54189
- let path22 = opts.path;
54255
+ let path23 = opts.path;
54190
54256
  if (!opts.path.startsWith("/")) {
54191
- path22 = `/${path22}`;
54257
+ path23 = `/${path23}`;
54192
54258
  }
54193
- url = new URL(util.parseOrigin(url).origin + path22);
54259
+ url = new URL(util.parseOrigin(url).origin + path23);
54194
54260
  } else {
54195
54261
  if (!opts) {
54196
54262
  opts = typeof url === "object" ? url : {};
@@ -58161,7 +58227,7 @@ var require_websocket2 = __commonJS({
58161
58227
  var EventEmitter = __require("events");
58162
58228
  var https3 = __require("https");
58163
58229
  var http3 = __require("http");
58164
- var net2 = __require("net");
58230
+ var net3 = __require("net");
58165
58231
  var tls = __require("tls");
58166
58232
  var { randomBytes: randomBytes2, createHash: createHash5 } = __require("crypto");
58167
58233
  var { Duplex, Readable: Readable2 } = __require("stream");
@@ -58895,12 +58961,12 @@ var require_websocket2 = __commonJS({
58895
58961
  }
58896
58962
  function netConnect(options) {
58897
58963
  options.path = options.socketPath;
58898
- return net2.connect(options);
58964
+ return net3.connect(options);
58899
58965
  }
58900
58966
  function tlsConnect(options) {
58901
58967
  options.path = void 0;
58902
58968
  if (!options.servername && options.servername !== "") {
58903
- options.servername = net2.isIP(options.host) ? "" : options.host;
58969
+ options.servername = net3.isIP(options.host) ? "" : options.host;
58904
58970
  }
58905
58971
  return tls.connect(options);
58906
58972
  }
@@ -64914,9 +64980,280 @@ var init_filesystem = __esm({
64914
64980
  }
64915
64981
  });
64916
64982
 
64983
+ // ts/daemon/dist/local-control.js
64984
+ import { chmodSync as chmodSync2, existsSync as existsSync10, mkdirSync as mkdirSync8, rmSync as rmSync4, statSync } from "node:fs";
64985
+ import * as net2 from "node:net";
64986
+ import * as path17 from "node:path";
64987
+ function localControlSocketPath(env = process.env) {
64988
+ return path17.join(daemonConfigDir(env), "run", "control.sock");
64989
+ }
64990
+ function isSocketLive(sockPath) {
64991
+ return new Promise((resolve9) => {
64992
+ const probe = net2.connect(sockPath);
64993
+ const done = (live) => {
64994
+ probe.removeAllListeners();
64995
+ probe.destroy();
64996
+ clearTimeout(timer);
64997
+ resolve9(live);
64998
+ };
64999
+ const timer = setTimeout(() => done(true), 1e3);
65000
+ probe.once("connect", () => done(true));
65001
+ probe.once("error", (err) => {
65002
+ done(!(err.code === "ECONNREFUSED" || err.code === "ENOENT"));
65003
+ });
65004
+ });
65005
+ }
65006
+ var LocalControlError, MAX_LINE_BYTES, LocalControlServer;
65007
+ var init_local_control = __esm({
65008
+ "ts/daemon/dist/local-control.js"() {
65009
+ "use strict";
65010
+ init_daemon_paths();
65011
+ LocalControlError = class extends Error {
65012
+ code;
65013
+ constructor(code, message) {
65014
+ super(message);
65015
+ this.code = code;
65016
+ this.name = "LocalControlError";
65017
+ }
65018
+ };
65019
+ MAX_LINE_BYTES = 16 * 1024;
65020
+ LocalControlServer = class {
65021
+ opts;
65022
+ server = null;
65023
+ sockets = /* @__PURE__ */ new Set();
65024
+ constructor(opts) {
65025
+ this.opts = opts;
65026
+ }
65027
+ async start() {
65028
+ if (this.server)
65029
+ throw new Error("local control server already started");
65030
+ const sockPath = this.opts.socketPath;
65031
+ const dir = path17.dirname(sockPath);
65032
+ mkdirSync8(dir, { recursive: true, mode: 448 });
65033
+ try {
65034
+ chmodSync2(dir, 448);
65035
+ } catch (err) {
65036
+ throw new Error(`could not restrict control socket directory: ${String(err)}`);
65037
+ }
65038
+ if (existsSync10(sockPath)) {
65039
+ let st;
65040
+ try {
65041
+ st = statSync(sockPath);
65042
+ } catch (err) {
65043
+ throw new Error(`could not inspect existing control socket: ${String(err)}`);
65044
+ }
65045
+ if (st.isSocket()) {
65046
+ if (await isSocketLive(sockPath)) {
65047
+ throw new Error(`another process is already serving the local control socket at ${sockPath}`);
65048
+ }
65049
+ rmSync4(sockPath, { force: true });
65050
+ }
65051
+ }
65052
+ const server = net2.createServer((socket) => this.handleConnection(socket));
65053
+ this.server = server;
65054
+ await new Promise((resolve9, reject) => {
65055
+ const onError = (err) => {
65056
+ this.server = null;
65057
+ reject(err);
65058
+ };
65059
+ server.once("error", onError);
65060
+ server.listen(sockPath, () => {
65061
+ server.removeListener("error", onError);
65062
+ try {
65063
+ chmodSync2(sockPath, 384);
65064
+ } catch (err) {
65065
+ server.close();
65066
+ this.server = null;
65067
+ reject(new Error(`could not restrict control socket permissions: ${String(err)}`));
65068
+ return;
65069
+ }
65070
+ resolve9();
65071
+ });
65072
+ });
65073
+ server.on("error", (err) => this.opts.log.warn(`local control server error: ${String(err)}`));
65074
+ this.opts.log.info(`local control socket listening at ${sockPath}`);
65075
+ }
65076
+ async stop() {
65077
+ const server = this.server;
65078
+ if (!server)
65079
+ return;
65080
+ this.server = null;
65081
+ for (const s of this.sockets)
65082
+ s.destroy();
65083
+ this.sockets.clear();
65084
+ await new Promise((resolve9) => server.close(() => resolve9()));
65085
+ try {
65086
+ rmSync4(this.opts.socketPath, { force: true });
65087
+ } catch {
65088
+ }
65089
+ }
65090
+ handleConnection(socket) {
65091
+ this.sockets.add(socket);
65092
+ socket.on("close", () => this.sockets.delete(socket));
65093
+ socket.on("error", () => socket.destroy());
65094
+ socket.setEncoding("utf8");
65095
+ let buffer = "";
65096
+ socket.on("data", (chunk) => {
65097
+ buffer += chunk;
65098
+ if (Buffer.byteLength(buffer) > MAX_LINE_BYTES) {
65099
+ this.reply(socket, void 0, { code: "INVALID_REQUEST", message: "request too large" });
65100
+ socket.end();
65101
+ return;
65102
+ }
65103
+ let newline = buffer.indexOf("\n");
65104
+ while (newline !== -1) {
65105
+ const line = buffer.slice(0, newline).trim();
65106
+ buffer = buffer.slice(newline + 1);
65107
+ if (line)
65108
+ void this.handleLine(socket, line);
65109
+ newline = buffer.indexOf("\n");
65110
+ }
65111
+ });
65112
+ }
65113
+ async handleLine(socket, line) {
65114
+ let req;
65115
+ try {
65116
+ const parsed = JSON.parse(line);
65117
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
65118
+ throw new Error("not an object");
65119
+ }
65120
+ req = parsed;
65121
+ } catch {
65122
+ this.reply(socket, void 0, { code: "INVALID_REQUEST", message: "invalid JSON request" });
65123
+ socket.end();
65124
+ return;
65125
+ }
65126
+ const id = typeof req.id === "string" ? req.id : void 0;
65127
+ try {
65128
+ switch (req.command) {
65129
+ case "ping": {
65130
+ const result = await this.opts.handlers.ping();
65131
+ this.reply(socket, id, void 0, result);
65132
+ return;
65133
+ }
65134
+ case "profile.open":
65135
+ case "profile.stop":
65136
+ case "profile.reset": {
65137
+ const action = req.command.slice("profile.".length);
65138
+ const profileId = typeof req.profile_id === "string" ? req.profile_id.trim() : "";
65139
+ const requester = typeof req.requester_user_id === "string" ? req.requester_user_id.trim() : "";
65140
+ if (!profileId || !requester) {
65141
+ throw new LocalControlError("INVALID_REQUEST", "profile_id and requester_user_id are required");
65142
+ }
65143
+ await this.opts.handlers.profileControl(action, profileId, requester);
65144
+ this.reply(socket, id, void 0, { status: "ok" });
65145
+ return;
65146
+ }
65147
+ default:
65148
+ throw new LocalControlError("UNKNOWN_COMMAND", `unknown command ${String(req.command)}`);
65149
+ }
65150
+ } catch (err) {
65151
+ if (err instanceof LocalControlError) {
65152
+ this.reply(socket, id, { code: err.code, message: err.message });
65153
+ } else {
65154
+ this.opts.log.warn(`local control command failed: ${String(err)}`);
65155
+ this.reply(socket, id, {
65156
+ code: "INTERNAL",
65157
+ message: err instanceof Error ? err.message : String(err)
65158
+ });
65159
+ }
65160
+ }
65161
+ }
65162
+ reply(socket, id, error, result) {
65163
+ if (socket.destroyed)
65164
+ return;
65165
+ const payload = { ok: !error };
65166
+ if (id !== void 0)
65167
+ payload.id = id;
65168
+ if (error)
65169
+ payload.error = error;
65170
+ if (result !== void 0)
65171
+ payload.result = result;
65172
+ try {
65173
+ socket.write(`${JSON.stringify(payload)}
65174
+ `);
65175
+ } catch {
65176
+ socket.destroy();
65177
+ }
65178
+ }
65179
+ };
65180
+ }
65181
+ });
65182
+
65183
+ // ts/daemon/dist/local-profile-control.js
65184
+ async function startLocalProfileControl(deps) {
65185
+ if (process.env.KUBERNETES_SERVICE_HOST || process.platform === "win32")
65186
+ return null;
65187
+ const server = new LocalControlServer({
65188
+ socketPath: localControlSocketPath(),
65189
+ log: deps.log,
65190
+ handlers: {
65191
+ ping: async () => ({
65192
+ machine_id: deps.machineId(),
65193
+ org_id: deps.orgId(),
65194
+ profile_control: deps.pool() !== null
65195
+ }),
65196
+ profileControl: (action, profileId, requesterUserId) => handleLocalProfileControl(deps, action, profileId, requesterUserId)
65197
+ }
65198
+ });
65199
+ try {
65200
+ await server.start();
65201
+ return server;
65202
+ } catch (err) {
65203
+ deps.log.warn(`local control socket unavailable: ${String(err)}`);
65204
+ return null;
65205
+ }
65206
+ }
65207
+ async function handleLocalProfileControl(deps, action, profileId, requesterUserId) {
65208
+ const owner = deps.owner();
65209
+ if (!owner || !requesterUserId || requesterUserId !== owner) {
65210
+ throw new LocalControlError("OWNER_MISMATCH", "Only the machine owner can control local browser profiles");
65211
+ }
65212
+ const pool = deps.pool();
65213
+ if (!pool) {
65214
+ throw new LocalControlError("RUNTIME_DISABLED", "Browser profile runtime is disabled on this daemon");
65215
+ }
65216
+ let profiles;
65217
+ try {
65218
+ profiles = await deps.listProfiles();
65219
+ } catch (err) {
65220
+ throw new LocalControlError("SERVER_UNAVAILABLE", `could not verify the profile with the server: ${String(err)}`);
65221
+ }
65222
+ const profile = profiles.find((p) => p.id === profileId && p.machine_id);
65223
+ if (!profile) {
65224
+ throw new LocalControlError("PROFILE_NOT_ON_MACHINE", "Browser profile is not assigned to this machine");
65225
+ }
65226
+ const generation = profile.lifecycle_generation;
65227
+ if (action === "open") {
65228
+ const resetGen = profile.reset_generation ?? 0;
65229
+ const wipeGen = resetGen > pool.appliedResetGeneration(profileId) ? resetGen : null;
65230
+ if (wipeGen !== null)
65231
+ pool.fence(profileId);
65232
+ const sinceSeq = pool.stopSeqOf(profileId);
65233
+ await deps.enqueueRevive(profileId, async () => {
65234
+ if (wipeGen !== null)
65235
+ await deps.wipeBeforeRevive(pool, profileId, wipeGen, generation);
65236
+ await pool.openProfile(profileId, void 0, sinceSeq, generation);
65237
+ });
65238
+ return;
65239
+ }
65240
+ pool.fence(profileId);
65241
+ if (action === "stop") {
65242
+ await deps.enqueueOp(profileId, () => pool.stopProfile(profileId, generation));
65243
+ return;
65244
+ }
65245
+ await deps.enqueueOp(profileId, () => pool.resetProfile(profileId, generation, profile.reset_generation));
65246
+ }
65247
+ var init_local_profile_control = __esm({
65248
+ "ts/daemon/dist/local-profile-control.js"() {
65249
+ "use strict";
65250
+ init_local_control();
65251
+ }
65252
+ });
65253
+
64917
65254
  // ts/daemon/dist/home-isolation.js
64918
65255
  import * as fs10 from "node:fs";
64919
- import * as path17 from "node:path";
65256
+ import * as path18 from "node:path";
64920
65257
  function ensureIsolatedHome(spec, agentId, log2, platform2 = process.platform) {
64921
65258
  fs10.mkdirSync(spec.homeDir, { recursive: true });
64922
65259
  const failures = [];
@@ -64928,18 +65265,18 @@ function ensureIsolatedHome(spec, agentId, log2, platform2 = process.platform) {
64928
65265
  }
64929
65266
  };
64930
65267
  attempt(".claude link", () => {
64931
- fs10.mkdirSync(path17.join(spec.claudeStateRoot, ".claude"), { recursive: true });
64932
- ensureLink(path17.join(spec.homeDir, ".claude"), path17.join(spec.claudeStateRoot, ".claude"), agentId, log2);
65268
+ fs10.mkdirSync(path18.join(spec.claudeStateRoot, ".claude"), { recursive: true });
65269
+ ensureLink(path18.join(spec.homeDir, ".claude"), path18.join(spec.claudeStateRoot, ".claude"), agentId, log2);
64933
65270
  });
64934
- attempt(".claude.json link", () => ensureLink(path17.join(spec.homeDir, ".claude.json"), path17.join(spec.claudeStateRoot, ".claude.json"), agentId, log2));
65271
+ attempt(".claude.json link", () => ensureLink(path18.join(spec.homeDir, ".claude.json"), path18.join(spec.claudeStateRoot, ".claude.json"), agentId, log2));
64935
65272
  if (platform2 === "darwin") {
64936
65273
  attempt("Library/Keychains link", () => {
64937
- fs10.mkdirSync(path17.join(spec.homeDir, "Library"), { recursive: true });
64938
- ensureLink(path17.join(spec.homeDir, "Library", "Keychains"), path17.join(spec.systemHome, "Library", "Keychains"), agentId, log2);
65274
+ fs10.mkdirSync(path18.join(spec.homeDir, "Library"), { recursive: true });
65275
+ ensureLink(path18.join(spec.homeDir, "Library", "Keychains"), path18.join(spec.systemHome, "Library", "Keychains"), agentId, log2);
64939
65276
  });
64940
65277
  }
64941
65278
  attempt(".gitconfig", () => {
64942
- const gitconfig = path17.join(spec.homeDir, ".gitconfig");
65279
+ const gitconfig = path18.join(spec.homeDir, ".gitconfig");
64943
65280
  if (!fs10.existsSync(gitconfig)) {
64944
65281
  fs10.writeFileSync(gitconfig, `[user]
64945
65282
  name = ${gitConfigValue(spec.gitUserName)}
@@ -64965,7 +65302,7 @@ function ensureLink(linkPath, target, agentId, log2) {
64965
65302
  if (existing) {
64966
65303
  if (existing.isSymbolicLink()) {
64967
65304
  const current = fs10.readlinkSync(linkPath);
64968
- if (path17.resolve(path17.dirname(linkPath), current) === path17.resolve(target))
65305
+ if (path18.resolve(path18.dirname(linkPath), current) === path18.resolve(target))
64969
65306
  return;
64970
65307
  fs10.unlinkSync(linkPath);
64971
65308
  log2.info(`agent ${agentId}: relinking ${linkPath} \u2192 ${target}`);
@@ -64978,16 +65315,16 @@ function ensureLink(linkPath, target, agentId, log2) {
64978
65315
  fs10.symlinkSync(target, linkPath);
64979
65316
  }
64980
65317
  function ensureSharedCredentialLink(rootClaudeHome, agentClaudeHome, agentId, log2) {
64981
- const sharedCredentials = path17.resolve(sharedClaudeCredentialsFileFor(rootClaudeHome));
65318
+ const sharedCredentials = path18.resolve(sharedClaudeCredentialsFileFor(rootClaudeHome));
64982
65319
  const agentCredentials = agentClaudeCredentialsFileFor(agentClaudeHome);
64983
- const agentCredentialsDir = path17.dirname(agentCredentials);
64984
- fs10.mkdirSync(path17.dirname(sharedCredentials), { recursive: true });
65320
+ const agentCredentialsDir = path18.dirname(agentCredentials);
65321
+ fs10.mkdirSync(path18.dirname(sharedCredentials), { recursive: true });
64985
65322
  fs10.mkdirSync(agentCredentialsDir, { recursive: true });
64986
65323
  try {
64987
65324
  const existing = fs10.lstatSync(agentCredentials);
64988
65325
  if (existing.isSymbolicLink()) {
64989
65326
  const currentTarget = fs10.readlinkSync(agentCredentials);
64990
- if (path17.resolve(agentCredentialsDir, currentTarget) === sharedCredentials) {
65327
+ if (path18.resolve(agentCredentialsDir, currentTarget) === sharedCredentials) {
64991
65328
  return;
64992
65329
  }
64993
65330
  fs10.unlinkSync(agentCredentials);
@@ -65015,7 +65352,7 @@ var init_home_isolation = __esm({
65015
65352
  import { execFileSync as execFileSync4 } from "node:child_process";
65016
65353
  import * as fs11 from "node:fs";
65017
65354
  import * as os6 from "node:os";
65018
- import * as path18 from "node:path";
65355
+ import * as path19 from "node:path";
65019
65356
  function runtimeBinaryEnvVar(runtimeType) {
65020
65357
  return RUNTIME_BINARIES[runtimeType]?.envVar;
65021
65358
  }
@@ -65092,16 +65429,16 @@ function resolveRuntimeCommand(command, env, inheritedPath, primaryPath, fallbac
65092
65429
  function resolveDirectPath(command) {
65093
65430
  if (!command.includes("/") && !command.includes("\\"))
65094
65431
  return null;
65095
- const abs = path18.isAbsolute(command) ? command : path18.resolve(process.cwd(), command);
65432
+ const abs = path19.isAbsolute(command) ? command : path19.resolve(process.cwd(), command);
65096
65433
  return isExecutable(abs) ? abs : null;
65097
65434
  }
65098
65435
  function resolveFromPath(command, pathValue, env, platform2) {
65099
65436
  if (!pathValue || command.includes("/") || command.includes("\\"))
65100
65437
  return null;
65101
- const dirs = pathValue.split(path18.delimiter).filter(Boolean);
65438
+ const dirs = pathValue.split(path19.delimiter).filter(Boolean);
65102
65439
  for (const dir of dirs) {
65103
65440
  for (const file of commandCandidates(command, env, platform2)) {
65104
- const candidate = path18.join(dir, file);
65441
+ const candidate = path19.join(dir, file);
65105
65442
  if (isExecutable(candidate))
65106
65443
  return { binaryPath: candidate, pathValue };
65107
65444
  }
@@ -65142,7 +65479,7 @@ __PRLL_PATH__%s
65142
65479
  if (line.startsWith("__PRLL_PATH__"))
65143
65480
  pathValue = line.slice("__PRLL_PATH__".length);
65144
65481
  }
65145
- if (path18.isAbsolute(binaryPath) && isExecutable(binaryPath)) {
65482
+ if (path19.isAbsolute(binaryPath) && isExecutable(binaryPath)) {
65146
65483
  return { binaryPath, pathValue: pathValue || void 0 };
65147
65484
  }
65148
65485
  } catch {
@@ -65162,18 +65499,18 @@ function cachedCandidatePathPlan(env, platform2) {
65162
65499
  function candidatePathPlan(env, platform2 = process.platform) {
65163
65500
  const home = env.HOME || os6.homedir();
65164
65501
  if (platform2 === "win32") {
65165
- const appData = env.APPDATA || path18.join(home, "AppData", "Roaming");
65166
- const localAppData = env.LOCALAPPDATA || path18.join(home, "AppData", "Local");
65502
+ const appData = env.APPDATA || path19.join(home, "AppData", "Roaming");
65503
+ const localAppData = env.LOCALAPPDATA || path19.join(home, "AppData", "Local");
65167
65504
  const winPrimaryDirs = [
65168
65505
  ...splitPath(env.PRLL_DAEMON_RUNTIME_PATH),
65169
65506
  ...splitPath(env.PRLL_DAEMON_EXTRA_PATH),
65170
- path18.dirname(process.execPath),
65507
+ path19.dirname(process.execPath),
65171
65508
  env.PNPM_HOME,
65172
- path18.join(appData, "npm"),
65173
- path18.join(localAppData, "pnpm"),
65174
- path18.join(localAppData, "Volta", "bin"),
65175
- path18.join(home, ".volta", "bin"),
65176
- path18.join(home, ".bun", "bin")
65509
+ path19.join(appData, "npm"),
65510
+ path19.join(localAppData, "pnpm"),
65511
+ path19.join(localAppData, "Volta", "bin"),
65512
+ path19.join(home, ".volta", "bin"),
65513
+ path19.join(home, ".bun", "bin")
65177
65514
  ];
65178
65515
  return {
65179
65516
  primaryDirs: unique(winPrimaryDirs).filter((dir) => !!dir && isDirectory(dir)),
@@ -65183,21 +65520,21 @@ function candidatePathPlan(env, platform2 = process.platform) {
65183
65520
  const primaryDirs = [
65184
65521
  ...splitPath(env.PRLL_DAEMON_RUNTIME_PATH),
65185
65522
  ...splitPath(env.PRLL_DAEMON_EXTRA_PATH),
65186
- path18.dirname(process.execPath),
65187
- path18.join(path18.dirname(process.execPath), "bin"),
65188
- path18.resolve(path18.dirname(process.execPath), "..", "Resources", "bin"),
65189
- path18.join(home, ".local", "bin"),
65190
- path18.join(home, "bin"),
65191
- path18.join(home, ".npm-global", "bin"),
65192
- path18.join(home, "Library", "pnpm"),
65193
- path18.join(home, ".local", "share", "pnpm"),
65194
- path18.join(home, ".volta", "bin"),
65195
- path18.join(home, ".bun", "bin"),
65196
- path18.join(home, ".asdf", "shims"),
65197
- path18.join(home, ".local", "share", "mise", "shims"),
65198
- path18.join(home, ".mise", "shims"),
65199
- path18.join(home, ".fnm", "aliases", "default", "bin"),
65200
- path18.join(home, "Library", "Application Support", "fnm", "aliases", "default", "bin"),
65523
+ path19.dirname(process.execPath),
65524
+ path19.join(path19.dirname(process.execPath), "bin"),
65525
+ path19.resolve(path19.dirname(process.execPath), "..", "Resources", "bin"),
65526
+ path19.join(home, ".local", "bin"),
65527
+ path19.join(home, "bin"),
65528
+ path19.join(home, ".npm-global", "bin"),
65529
+ path19.join(home, "Library", "pnpm"),
65530
+ path19.join(home, ".local", "share", "pnpm"),
65531
+ path19.join(home, ".volta", "bin"),
65532
+ path19.join(home, ".bun", "bin"),
65533
+ path19.join(home, ".asdf", "shims"),
65534
+ path19.join(home, ".local", "share", "mise", "shims"),
65535
+ path19.join(home, ".mise", "shims"),
65536
+ path19.join(home, ".fnm", "aliases", "default", "bin"),
65537
+ path19.join(home, "Library", "Application Support", "fnm", "aliases", "default", "bin"),
65201
65538
  "/opt/homebrew/bin",
65202
65539
  "/usr/local/bin",
65203
65540
  "/usr/bin",
@@ -65216,19 +65553,19 @@ function candidatePathPlan(env, platform2 = process.platform) {
65216
65553
  };
65217
65554
  }
65218
65555
  function nvmVersionBinDirs(home) {
65219
- const root = path18.join(home, ".nvm", "versions", "node");
65556
+ const root = path19.join(home, ".nvm", "versions", "node");
65220
65557
  let versions;
65221
65558
  try {
65222
65559
  versions = fs11.readdirSync(root);
65223
65560
  } catch {
65224
65561
  return [];
65225
65562
  }
65226
- return sortVersionNamesDesc(versions).map((version) => path18.join(root, version, "bin"));
65563
+ return sortVersionNamesDesc(versions).map((version) => path19.join(root, version, "bin"));
65227
65564
  }
65228
65565
  function fnmVersionBinDirs(home) {
65229
65566
  const roots = [
65230
- path18.join(home, ".fnm", "node-versions"),
65231
- path18.join(home, "Library", "Application Support", "fnm", "node-versions")
65567
+ path19.join(home, ".fnm", "node-versions"),
65568
+ path19.join(home, "Library", "Application Support", "fnm", "node-versions")
65232
65569
  ];
65233
65570
  const dirs = [];
65234
65571
  for (const root of roots) {
@@ -65238,7 +65575,7 @@ function fnmVersionBinDirs(home) {
65238
65575
  } catch {
65239
65576
  continue;
65240
65577
  }
65241
- dirs.push(...sortVersionNamesDesc(versions).map((version) => path18.join(root, version, "installation", "bin")));
65578
+ dirs.push(...sortVersionNamesDesc(versions).map((version) => path19.join(root, version, "installation", "bin")));
65242
65579
  }
65243
65580
  return dirs;
65244
65581
  }
@@ -65260,13 +65597,13 @@ function parseVersionName(value) {
65260
65597
  return value.replace(/^v/i, "").split(".").map((part) => Number.parseInt(part, 10)).filter((part) => Number.isFinite(part));
65261
65598
  }
65262
65599
  function splitPath(value) {
65263
- return value?.split(path18.delimiter).filter(Boolean) ?? [];
65600
+ return value?.split(path19.delimiter).filter(Boolean) ?? [];
65264
65601
  }
65265
65602
  function mergePath(prependDirs, existing) {
65266
- return unique([...prependDirs, ...splitPath(existing)]).join(path18.delimiter);
65603
+ return unique([...prependDirs, ...splitPath(existing)]).join(path19.delimiter);
65267
65604
  }
65268
65605
  function anchorResolvedPath(pathValue, resolution) {
65269
- return mergePath([path18.dirname(resolution.binaryPath), ...splitPath(resolution.pathValue)], pathValue);
65606
+ return mergePath([path19.dirname(resolution.binaryPath), ...splitPath(resolution.pathValue)], pathValue);
65270
65607
  }
65271
65608
  function commandCandidates(command, env, platform2 = process.platform) {
65272
65609
  if (platform2 !== "win32")
@@ -65421,7 +65758,7 @@ var init_runtime_detector = __esm({
65421
65758
  import { spawn as spawn5 } from "node:child_process";
65422
65759
  import { createHash as createHash4 } from "node:crypto";
65423
65760
  import * as fs12 from "node:fs";
65424
- import * as path19 from "node:path";
65761
+ import * as path20 from "node:path";
65425
65762
  async function prepareWorkspace(opts) {
65426
65763
  const prior = opts.attached.workspace_state;
65427
65764
  const plan = buildWorkspacePlan(opts.attached.daemon_config, opts.defaultWorkspaceDir, prior?.config_hash);
@@ -65566,8 +65903,8 @@ async function ensureWorkspace(plan, log2) {
65566
65903
  assertSafeCustomWorkspacePath(plan);
65567
65904
  }
65568
65905
  if (!fs12.existsSync(plan.workspaceDir)) {
65569
- fs12.mkdirSync(path19.dirname(plan.workspaceDir), { recursive: true });
65570
- assertWritableWorkspaceDir(path19.dirname(plan.workspaceDir));
65906
+ fs12.mkdirSync(path20.dirname(plan.workspaceDir), { recursive: true });
65907
+ assertWritableWorkspaceDir(path20.dirname(plan.workspaceDir));
65571
65908
  await runCommand("git", ["clone", remote, plan.workspaceDir], process.cwd());
65572
65909
  } else {
65573
65910
  const st = fs12.statSync(plan.workspaceDir);
@@ -65749,10 +66086,10 @@ ${tail}`)));
65749
66086
  });
65750
66087
  }
65751
66088
  function requireAbsolute(value, field) {
65752
- if (!value || !path19.isAbsolute(value)) {
66089
+ if (!value || !path20.isAbsolute(value)) {
65753
66090
  throw new Error(`${field} must be an absolute path`);
65754
66091
  }
65755
- return path19.resolve(value);
66092
+ return path20.resolve(value);
65756
66093
  }
65757
66094
  function assertSafeCustomWorkspacePath(plan, candidate = plan.workspaceDir) {
65758
66095
  if (!plan.customWorkspaceField)
@@ -65762,14 +66099,14 @@ function assertSafeCustomWorkspacePath(plan, candidate = plan.workspaceDir) {
65762
66099
  if (reason) {
65763
66100
  throw new Error(`${plan.customWorkspaceField} must point to a project folder, not ${reason}: ${normalized}`);
65764
66101
  }
65765
- const defaultWorkspace = path19.resolve(plan.defaultWorkspaceDir);
66102
+ const defaultWorkspace = path20.resolve(plan.defaultWorkspaceDir);
65766
66103
  if (isAncestorPath(normalized, defaultWorkspace) || normalized === defaultWorkspace) {
65767
66104
  throw new Error(`${plan.customWorkspaceField} must not point at daemon state directories: ${normalized}`);
65768
66105
  }
65769
66106
  }
65770
66107
  function assertWritableWorkspaceDir(dir) {
65771
66108
  fs12.accessSync(dir, fs12.constants.R_OK | fs12.constants.W_OK | fs12.constants.X_OK);
65772
- const probe = path19.join(dir, `.parall-workspace-check-${process.pid}-${Date.now()}`);
66109
+ const probe = path20.join(dir, `.parall-workspace-check-${process.pid}-${Date.now()}`);
65773
66110
  const fd = fs12.openSync(probe, "wx", 384);
65774
66111
  fs12.closeSync(fd);
65775
66112
  fs12.unlinkSync(probe);
@@ -65833,11 +66170,11 @@ function workspacePathDenyReason(value) {
65833
66170
  return "";
65834
66171
  }
65835
66172
  function isAncestorPath(parent, child) {
65836
- const relative2 = path19.relative(parent, child);
65837
- return relative2 !== "" && !relative2.startsWith("..") && !path19.isAbsolute(relative2);
66173
+ const relative2 = path20.relative(parent, child);
66174
+ return relative2 !== "" && !relative2.startsWith("..") && !path20.isAbsolute(relative2);
65838
66175
  }
65839
66176
  function toPolicyPath(value) {
65840
- return path19.resolve(value).split(path19.sep).join("/");
66177
+ return path20.resolve(value).split(path20.sep).join("/");
65841
66178
  }
65842
66179
  function isNodeError(err) {
65843
66180
  return err instanceof Error && "code" in err;
@@ -65856,7 +66193,7 @@ var init_workspace = __esm({
65856
66193
  import { spawn as spawn6 } from "node:child_process";
65857
66194
  import * as fs13 from "node:fs";
65858
66195
  import * as os7 from "node:os";
65859
- import * as path20 from "node:path";
66196
+ import * as path21 from "node:path";
65860
66197
  function sleepCancellable(ms, signal) {
65861
66198
  if (signal.aborted)
65862
66199
  return Promise.resolve(false);
@@ -65885,6 +66222,7 @@ var init_supervisor = __esm({
65885
66222
  init_config();
65886
66223
  init_browser_profile_reconcile();
65887
66224
  init_filesystem();
66225
+ init_local_profile_control();
65888
66226
  init_home_isolation();
65889
66227
  init_runtimes();
65890
66228
  init_runtime_bin_resolver();
@@ -65938,6 +66276,11 @@ var init_supervisor = __esm({
65938
66276
  running = false;
65939
66277
  machineId = null;
65940
66278
  machineOrgId = null;
66279
+ // machines.created_by — the machine owner. The local control socket's profile
66280
+ // commands are authorized against it (requester must BE the owner); kept
66281
+ // fresh via bootstrap + refreshMachineConfig. Null until bootstrap → the
66282
+ // local control plane fails closed.
66283
+ machineCreatedBy = null;
65941
66284
  machineLlmSource = "parall";
65942
66285
  // Whether this machine contributes its local clips as a hub provider. The
65943
66286
  // org admin toggles it via PATCH /machines/{id}/provider-enabled; default true.
@@ -65956,6 +66299,7 @@ var init_supervisor = __esm({
65956
66299
  // browserProfilePool replaces the old single browserProfileManager.
65957
66300
  healthGate = null;
65958
66301
  browserProfilePool = null;
66302
+ localControl = null;
65959
66303
  clipManager = null;
65960
66304
  clipProvider = null;
65961
66305
  clipReconcileTimer = null;
@@ -66009,7 +66353,7 @@ var init_supervisor = __esm({
66009
66353
  this.migrateFlatLayout();
66010
66354
  if (process.env.PRLL_CLIP_RUNTIME_ENABLED === "true") {
66011
66355
  this.browserProfilePool = new BrowserProfilePool({
66012
- baseHomeDir: path20.join(this.config.rootStateDir, "bb-browser"),
66356
+ baseHomeDir: path21.join(this.config.rootStateDir, "bb-browser"),
66013
66357
  log: this.log,
66014
66358
  reportStatus: (profileId, status, errorMsg, generation) => {
66015
66359
  this.client.reportBrowserProfileStatus(profileId, status, errorMsg, generation).catch((err) => this.log.warn(`browser profile status report failed: ${String(err)}`));
@@ -66018,8 +66362,8 @@ var init_supervisor = __esm({
66018
66362
  proxyProbeUrl: this.resolveBrowserProxyProbeUrl()
66019
66363
  });
66020
66364
  this.clipManager = new ClipProcessManager({
66021
- clipsDir: path20.join(this.config.rootStateDir, "clips"),
66022
- dataDir: path20.join(this.config.rootStateDir, "clip-data"),
66365
+ clipsDir: path21.join(this.config.rootStateDir, "clips"),
66366
+ dataDir: path21.join(this.config.rootStateDir, "clip-data"),
66023
66367
  browserProfileManager: this.browserProfilePool,
66024
66368
  // Execution side: nested browser dependency invokes resolve their
66025
66369
  // binding and route through the hub (no local shortcut).
@@ -66039,6 +66383,7 @@ var init_supervisor = __esm({
66039
66383
  await this.applyClipProviderState();
66040
66384
  this.startClipReconcileTimer();
66041
66385
  }
66386
+ this.localControl = await startLocalProfileControl(this.localProfileControlDeps());
66042
66387
  void this.detectAndReportRuntimes(true);
66043
66388
  this.runtimeDetectTimer = setInterval(() => {
66044
66389
  void this.detectAndReportRuntimes(false);
@@ -66164,6 +66509,10 @@ var init_supervisor = __esm({
66164
66509
  }
66165
66510
  exits.push(this.terminateChild(state));
66166
66511
  }
66512
+ if (this.localControl) {
66513
+ exits.push(this.localControl.stop());
66514
+ this.localControl = null;
66515
+ }
66167
66516
  if (this.clipProvider) {
66168
66517
  exits.push(this.clipProvider.disconnect());
66169
66518
  this.clipProvider = null;
@@ -66192,6 +66541,7 @@ var init_supervisor = __esm({
66192
66541
  const machine = await this.client.getMachineSelf();
66193
66542
  this.machineId = machine.id;
66194
66543
  this.machineOrgId = machine.org_id;
66544
+ this.machineCreatedBy = machine.created_by ?? null;
66195
66545
  this.machineLlmSource = machine.llm_source ?? "parall";
66196
66546
  this.machineProviderEnabled = machine.provider_enabled ?? true;
66197
66547
  this.machineClipProviderUrl = machine.clip_provider_url ?? null;
@@ -66365,12 +66715,12 @@ var init_supervisor = __esm({
66365
66715
  */
66366
66716
  migrateFlatLayout() {
66367
66717
  const root = this.config.rootStateDir;
66368
- const agentsDir = path20.join(root, "agents");
66369
- const flatWorkspace = path20.join(root, "workspace");
66718
+ const agentsDir = path21.join(root, "agents");
66719
+ const flatWorkspace = path21.join(root, "workspace");
66370
66720
  if (!fs13.existsSync(flatWorkspace) || fs13.existsSync(agentsDir))
66371
66721
  return;
66372
66722
  let ownerAgentId;
66373
- const sessionsDir = path20.join(root, "sessions");
66723
+ const sessionsDir = path21.join(root, "sessions");
66374
66724
  if (fs13.existsSync(sessionsDir)) {
66375
66725
  try {
66376
66726
  for (const file of fs13.readdirSync(sessionsDir)) {
@@ -66387,13 +66737,13 @@ var init_supervisor = __esm({
66387
66737
  }
66388
66738
  }
66389
66739
  const targetId = ownerAgentId ?? "_orphan";
66390
- const targetDir = path20.join(agentsDir, targetId);
66740
+ const targetDir = path21.join(agentsDir, targetId);
66391
66741
  try {
66392
66742
  fs13.mkdirSync(targetDir, { recursive: true });
66393
66743
  for (const sub of ["workspace", "sessions", "dispatch-context"]) {
66394
- const src = path20.join(root, sub);
66744
+ const src = path21.join(root, sub);
66395
66745
  if (fs13.existsSync(src)) {
66396
- fs13.renameSync(src, path20.join(targetDir, sub));
66746
+ fs13.renameSync(src, path21.join(targetDir, sub));
66397
66747
  }
66398
66748
  }
66399
66749
  this.log.info(`migrated legacy flat state \u2192 agents/${targetId}/`);
@@ -66527,6 +66877,28 @@ var init_supervisor = __esm({
66527
66877
  const op = () => this.handleBrowserProfileLifecycle(data, sinceSeq);
66528
66878
  return data.action === "open" ? this.enqueueBrowserProfileRevive(data.profile_id, op) : this.enqueueBrowserProfileOp(data.profile_id, op);
66529
66879
  }
66880
+ /**
66881
+ * What the supervisor lends the local control plane: identity, pool, queues.
66882
+ * Getters, not values — owner and pool both change over the daemon's life
66883
+ * (bootstrap / refresh / provider state), so the handler must read what is
66884
+ * true AT CALL TIME; a snapshot could authorize against a stale owner.
66885
+ *
66886
+ * One definition, used by both `run()` and the authorization tests, so the
66887
+ * matrix under test is wired exactly like production.
66888
+ */
66889
+ localProfileControlDeps() {
66890
+ return {
66891
+ log: this.log,
66892
+ machineId: () => this.machineId,
66893
+ orgId: () => this.machineOrgId,
66894
+ owner: () => this.machineCreatedBy,
66895
+ pool: () => this.browserProfilePool,
66896
+ listProfiles: () => this.client.listMachineBrowserProfiles(),
66897
+ enqueueRevive: (id, op) => this.enqueueBrowserProfileRevive(id, op),
66898
+ enqueueOp: (id, op) => this.enqueueBrowserProfileOp(id, op),
66899
+ wipeBeforeRevive: (pool, id, resetGen, gen) => this.wipeBeforeRevive(pool, id, resetGen, gen)
66900
+ };
66901
+ }
66530
66902
  enqueueBrowserProfileOp(profileId, op) {
66531
66903
  const previous = this.browserProfileOpQueues.get(profileId) ?? Promise.resolve();
66532
66904
  const next = previous.catch(() => {
@@ -66689,7 +67061,7 @@ var init_supervisor = __esm({
66689
67061
  return this.runtimeDetectInFlight;
66690
67062
  }
66691
67063
  machineClipToConfig(clip) {
66692
- const clipPath = path20.join(this.config.rootStateDir, "clips", clip.alias);
67064
+ const clipPath = path21.join(this.config.rootStateDir, "clips", clip.alias);
66693
67065
  return {
66694
67066
  clipId: clip.clip_id,
66695
67067
  name: clip.alias,
@@ -66755,7 +67127,7 @@ var init_supervisor = __esm({
66755
67127
  if (!sourceRef) {
66756
67128
  throw new Error(`registry clip "${config.name}" is missing source_ref`);
66757
67129
  }
66758
- const expectedPath = path20.join(this.config.rootStateDir, "clips", config.name);
67130
+ const expectedPath = path21.join(this.config.rootStateDir, "clips", config.name);
66759
67131
  const localVersion = this.readInstalledClipVersion(expectedPath);
66760
67132
  if (localVersion && (!config.version || localVersion === config.version)) {
66761
67133
  return { ...config, path: expectedPath, source: expectedPath };
@@ -66773,7 +67145,7 @@ var init_supervisor = __esm({
66773
67145
  const result = await installClip({
66774
67146
  source,
66775
67147
  alias: config.name,
66776
- clipsDir: path20.join(this.config.rootStateDir, "clips"),
67148
+ clipsDir: path21.join(this.config.rootStateDir, "clips"),
66777
67149
  registryUrl: process.env.PRLL_PINIX_REGISTRY_URL?.trim() || void 0
66778
67150
  });
66779
67151
  this.log.info(`clip ensured: ${result.alias} v${result.version} at ${result.path}`);
@@ -66788,7 +67160,7 @@ var init_supervisor = __esm({
66788
67160
  readInstalledClipVersion(dir) {
66789
67161
  for (const file of ["clip.json", "package.json"]) {
66790
67162
  try {
66791
- const raw = fs13.readFileSync(path20.join(dir, file), "utf-8");
67163
+ const raw = fs13.readFileSync(path21.join(dir, file), "utf-8");
66792
67164
  const parsed = JSON.parse(raw);
66793
67165
  if (typeof parsed.version === "string" && parsed.version.trim()) {
66794
67166
  return parsed.version.trim();
@@ -66857,6 +67229,7 @@ var init_supervisor = __esm({
66857
67229
  async refreshMachineConfig() {
66858
67230
  try {
66859
67231
  const machine = await this.client.getMachineSelf();
67232
+ this.machineCreatedBy = machine.created_by ?? null;
66860
67233
  const newSource = machine.llm_source ?? "parall";
66861
67234
  if (newSource !== this.machineLlmSource) {
66862
67235
  this.log.info(`machine config refreshed: llm_source ${this.machineLlmSource} \u2192 ${newSource}`);
@@ -67511,7 +67884,7 @@ var init_daemon_main = __esm({
67511
67884
  init_daemon_paths();
67512
67885
  init_daemon_update_mode();
67513
67886
  import * as fs14 from "node:fs";
67514
- import * as path21 from "node:path";
67887
+ import * as path22 from "node:path";
67515
67888
  var UPDATE_EXIT_CODE2 = 42;
67516
67889
  function formatError2(reason) {
67517
67890
  if (reason instanceof Error) {
@@ -67536,7 +67909,7 @@ function clearRunningMarker(markerPath) {
67536
67909
  }
67537
67910
  function prepareDaemonBootstrap(env = process.env, args = process.argv.slice(2)) {
67538
67911
  const bundleDir = resolveBundleDir(env);
67539
- const runningMarker = path21.join(bundleDir, "daemon-running");
67912
+ const runningMarker = path22.join(bundleDir, "daemon-running");
67540
67913
  const lifecycleMarkerEnabled = args.length === 0 && !isSelfUpdateDisabledByEnv(env) && isSelfUpdateManaged(bundleDir, env);
67541
67914
  if (!lifecycleMarkerEnabled) {
67542
67915
  return { lifecycleMarkerEnabled: false, runningMarker, uncleanPrevExit: false };