@parall/daemon 1.63.0 → 1.65.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.
@@ -148,6 +148,32 @@ var init_dispatch_adapter = __esm({
148
148
  }
149
149
  });
150
150
 
151
+ // ts/agent-core/dist/redact.js
152
+ function redactSecrets(s, knownValues = []) {
153
+ return maskKnownValues(s, knownValues).replace(/\b(agk|mck|cpk)_[A-Za-z0-9_-]+/g, "$1_***").replace(/\b(sk|pk|rk)-[A-Za-z0-9_-]{8,}/g, "$1-***").replace(/\bAKIA[0-9A-Z]{16}\b/g, "AKIA***").replace(/\b((?:bearer|basic)\s+)[A-Za-z0-9._~+/=-]+/gi, "$1***").replace(/(\b(?:[\w-]*[_-])?(?:api[_-]?key|key|token|secret|password|passwd|authorization)["']?\s*[=:]\s*)(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s&;,}\]"']+)/gi, "$1***").replace(/[A-Za-z0-9_-]{32,}/g, "***");
154
+ }
155
+ function maskKnownValues(s, knownValues) {
156
+ let out = s;
157
+ for (const v of knownValues) {
158
+ if (typeof v === "string" && v.length >= 6)
159
+ out = out.split(v).join("***");
160
+ }
161
+ return out;
162
+ }
163
+ var init_redact = __esm({
164
+ "ts/agent-core/dist/redact.js"() {
165
+ "use strict";
166
+ }
167
+ });
168
+
169
+ // ts/agent-core/dist/runtime-observation.js
170
+ var init_runtime_observation = __esm({
171
+ "ts/agent-core/dist/runtime-observation.js"() {
172
+ "use strict";
173
+ init_redact();
174
+ }
175
+ });
176
+
151
177
  // ts/agent-core/dist/fork-prefix.js
152
178
  var init_fork_prefix = __esm({
153
179
  "ts/agent-core/dist/fork-prefix.js"() {
@@ -155,6 +181,22 @@ var init_fork_prefix = __esm({
155
181
  }
156
182
  });
157
183
 
184
+ // ts/agent-core/dist/gateway-runtime-step.js
185
+ var init_gateway_runtime_step = __esm({
186
+ "ts/agent-core/dist/gateway-runtime-step.js"() {
187
+ "use strict";
188
+ init_dispatch_adapter();
189
+ init_runtime_observation();
190
+ }
191
+ });
192
+
193
+ // ts/agent-core/dist/dispatch-recovery.js
194
+ var init_dispatch_recovery = __esm({
195
+ "ts/agent-core/dist/dispatch-recovery.js"() {
196
+ "use strict";
197
+ }
198
+ });
199
+
158
200
  // ts/agent-core/dist/change-source.js
159
201
  var init_change_source = __esm({
160
202
  "ts/agent-core/dist/change-source.js"() {
@@ -212,12 +254,32 @@ var init_channel_types = __esm({
212
254
  }
213
255
  });
214
256
 
257
+ // ts/sdk/dist/slack-endpoints.js
258
+ function slackEndpoints(apiBase) {
259
+ return {
260
+ SLACK_CHANNELS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/channels`,
261
+ SLACK_USERS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/users`,
262
+ SLACK_REPLIES: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/replies`,
263
+ SLACK_HISTORY: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/history`,
264
+ SLACK_MEMBERS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/members`,
265
+ SLACK_STATUS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/status`,
266
+ SLACK_FILE: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/file`,
267
+ SLACK_FILES: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/files`
268
+ };
269
+ }
270
+ var init_slack_endpoints = __esm({
271
+ "ts/sdk/dist/slack-endpoints.js"() {
272
+ "use strict";
273
+ }
274
+ });
275
+
215
276
  // ts/sdk/dist/clip-connection-endpoints.js
216
277
  var clipConnectionEndpoints;
217
278
  var init_clip_connection_endpoints = __esm({
218
279
  "ts/sdk/dist/clip-connection-endpoints.js"() {
219
280
  "use strict";
220
281
  clipConnectionEndpoints = {
282
+ ORG_CLIP_MCP_OAUTH_ATTEMPT: (orgId, clipId, attemptId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-oauth-attempts/${attemptId}`,
221
283
  CLIP_CONNECTIONS: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/connections`,
222
284
  CLIP_CONNECTION_ACCESS: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}/access`,
223
285
  CLIP_CONNECTION: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}`
@@ -328,6 +390,7 @@ var API_BASE2, WIKI_BASE, CLIP_BASE, PLATFORM_MODELS, PLATFORM_LEGACY_MODELS, PL
328
390
  var init_constants = __esm({
329
391
  "ts/sdk/dist/constants.js"() {
330
392
  "use strict";
393
+ init_slack_endpoints();
331
394
  init_clip_connection_endpoints();
332
395
  init_attachment_endpoints();
333
396
  init_edge_endpoints();
@@ -861,6 +924,7 @@ var init_constants = __esm({
861
924
  TRIGGER: (orgId, triggerId) => `${API_BASE2}/orgs/${orgId}/external-triggers/${triggerId}`,
862
925
  /** @deprecated Use TRIGGER. Same compatibility path. */
863
926
  EXTERNAL_TRIGGER: (orgId, triggerId) => `${API_BASE2}/orgs/${orgId}/external-triggers/${triggerId}`,
927
+ PLATFORM_TRIGGER_SCHEMA: (orgId) => `${API_BASE2}/orgs/${orgId}/platform-trigger-schema`,
864
928
  TRIGGER_RUNS: (orgId) => `${API_BASE2}/orgs/${orgId}/external-trigger-runs`,
865
929
  /** @deprecated Use TRIGGER_RUNS. Same compatibility path. */
866
930
  EXTERNAL_TRIGGER_RUNS: (orgId) => `${API_BASE2}/orgs/${orgId}/external-trigger-runs`,
@@ -885,13 +949,7 @@ var init_constants = __esm({
885
949
  // Tier-B platform verb (agent-only): send one message as the bound bot.
886
950
  CHANNEL_SEND: (orgId) => `${API_BASE2}/orgs/${orgId}/agents/me/channel-send`,
887
951
  // Tier-B read verbs (agent-only): workspace visibility as the bot sees it.
888
- SLACK_CHANNELS: (orgId) => `${API_BASE2}/orgs/${orgId}/agents/me/slack/channels`,
889
- SLACK_USERS: (orgId) => `${API_BASE2}/orgs/${orgId}/agents/me/slack/users`,
890
- SLACK_HISTORY: (orgId) => `${API_BASE2}/orgs/${orgId}/agents/me/slack/history`,
891
- SLACK_MEMBERS: (orgId) => `${API_BASE2}/orgs/${orgId}/agents/me/slack/members`,
892
- SLACK_STATUS: (orgId) => `${API_BASE2}/orgs/${orgId}/agents/me/slack/status`,
893
- SLACK_FILE: (orgId) => `${API_BASE2}/orgs/${orgId}/agents/me/slack/file`,
894
- SLACK_FILES: (orgId) => `${API_BASE2}/orgs/${orgId}/agents/me/slack/files`,
952
+ ...slackEndpoints(API_BASE2),
895
953
  // WeChat tier-B read verbs (agent-only; internal research preview).
896
954
  ...wechatEndpoints(API_BASE2),
897
955
  // Invitations (org-scoped, admin)
@@ -1038,6 +1096,8 @@ var init_constants = __esm({
1038
1096
  BILLING_CHECKOUT: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/checkout`,
1039
1097
  BILLING_AUTO_RELOAD: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/auto-reload`,
1040
1098
  BILLING_SETUP_INTENT: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/setup-intent`,
1099
+ BILLING_USAGE_DAILY: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/usage-daily`,
1100
+ BILLING_USAGE_HEATMAP: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/usage-heatmap`,
1041
1101
  COMPUTE_PRICING: () => `${API_BASE2}/billing/compute-pricing`,
1042
1102
  // Runtime capability table (public, no auth) — SSOT for the create/settings
1043
1103
  // interlock: per-runtime compute modes, native model family, cross-family
@@ -1072,16 +1132,6 @@ var init_constants = __esm({
1072
1132
  BROWSER_PROFILE_VIEWER_COMMAND: (orgId, profileId) => `${API_BASE2}/orgs/${orgId}/browser-profiles/${profileId}/viewer/command`,
1073
1133
  // Edge device endpoints
1074
1134
  ...edgeEndpoints,
1075
- ORG_BROWSER_ALIASES: (orgId) => `/api/v1/orgs/${orgId}/browser-aliases`,
1076
- ORG_BROWSER_ALIAS: (orgId, aliasId) => `/api/v1/orgs/${orgId}/browser-aliases/${aliasId}`,
1077
- ORG_BROWSER_ALIAS_READINESS_CHECKS: (orgId, aliasId) => `/api/v1/orgs/${orgId}/browser-aliases/${aliasId}/readiness-checks`,
1078
- ORG_BROWSER_ALIAS_READINESS_CHECK: (orgId, aliasId, checkId) => `/api/v1/orgs/${orgId}/browser-aliases/${aliasId}/readiness-checks/${checkId}`,
1079
- ORG_API_KEY_BROWSER_ALIAS_GRANTS: (orgId, keyId) => `/api/v1/orgs/${orgId}/api-keys/${keyId}/browser-alias-grants`,
1080
- ORG_API_KEY_BROWSER_ALIAS_GRANT: (orgId, keyId, aliasId) => `/api/v1/orgs/${orgId}/api-keys/${keyId}/browser-alias-grants/${aliasId}`,
1081
- ORG_MANAGED_ALIASES: (orgId) => `/api/v1/orgs/${orgId}/aliases`,
1082
- ORG_MANAGED_ALIAS: (orgId, aliasName) => `/api/v1/orgs/${orgId}/aliases/${encodeURIComponent(aliasName)}`,
1083
- ORG_BROWSER_ALIAS_EXECUTIONS: (orgId) => `/api/v1/orgs/${orgId}/executions`,
1084
- ORG_BROWSER_ALIAS_EXECUTION: (orgId, requestId) => `/api/v1/orgs/${orgId}/executions/${encodeURIComponent(requestId)}`,
1085
1135
  ORG_BROWSER_USE_OPERATIONS: (orgId) => `/api/v1/orgs/${orgId}/browser-use/operations`,
1086
1136
  ORG_BROWSER_USE_OPERATION: (orgId, operationId) => `/api/v1/orgs/${orgId}/browser-use/operations/${encodeURIComponent(operationId)}`,
1087
1137
  // Per-profile egress proxy (hosted Cloud Profiles; manager-only, human-only).
@@ -1644,14 +1694,16 @@ var init_slack_files_client = __esm({
1644
1694
  }
1645
1695
  /**
1646
1696
  * Tier-B file upload verb (agent-only): share a file into a Slack
1647
- * conversation this connection has seen inbound, with the same
1648
- * reply-anchor contract as the text send.
1697
+ * conversation or thread with the same addressing as text sends.
1698
+ * Native threadTs requires a server supporting Slack thread sends.
1649
1699
  */
1650
1700
  async sendSlackFile(orgId, input) {
1651
1701
  const fd = new FormData();
1652
1702
  fd.append("conversation_id", input.conversationId);
1653
1703
  if (input.replyTo)
1654
1704
  fd.append("reply_to", input.replyTo);
1705
+ if (input.threadTs)
1706
+ fd.append("thread_ts", input.threadTs);
1655
1707
  if (input.text)
1656
1708
  fd.append("text", input.text);
1657
1709
  fd.append("file", input.content, input.fileName);
@@ -1661,14 +1713,62 @@ var init_slack_files_client = __esm({
1661
1713
  }
1662
1714
  });
1663
1715
 
1716
+ // ts/sdk/dist/slack-read-client.js
1717
+ var SlackReadClient;
1718
+ var init_slack_read_client = __esm({
1719
+ "ts/sdk/dist/slack-read-client.js"() {
1720
+ "use strict";
1721
+ init_constants();
1722
+ init_slack_files_client();
1723
+ SlackReadClient = class extends SlackFilesClient {
1724
+ slackReadQuery(base, query, extra) {
1725
+ const params = new URLSearchParams();
1726
+ if (query?.cursor)
1727
+ params.set("cursor", query.cursor);
1728
+ if (query?.limit)
1729
+ params.set("limit", String(query.limit));
1730
+ for (const [k, v] of Object.entries(extra ?? {}))
1731
+ params.set(k, v);
1732
+ const qs = params.toString();
1733
+ return qs ? `${base}?${qs}` : base;
1734
+ }
1735
+ /**
1736
+ * Tier-B read verbs (agent-only): workspace visibility as the bot sees
1737
+ * it. Same live gate as the send verb; authorization beyond it is the
1738
+ * bot's own Slack permissions.
1739
+ */
1740
+ async listSlackChannels(orgId, query) {
1741
+ return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_CHANNELS(orgId), query));
1742
+ }
1743
+ async listSlackUsers(orgId, query) {
1744
+ return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_USERS(orgId), query));
1745
+ }
1746
+ async slackHistory(orgId, conversationId, query) {
1747
+ return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_HISTORY(orgId), query, { conversation: conversationId }));
1748
+ }
1749
+ /** Read a Slack thread (parent and replies), one page in Slack order. */
1750
+ async slackReplies(orgId, channel, ts, query) {
1751
+ return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_REPLIES(orgId), query, { channel, ts }));
1752
+ }
1753
+ async slackMembers(orgId, conversationId, query) {
1754
+ return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_MEMBERS(orgId), query, { conversation: conversationId }));
1755
+ }
1756
+ /** Set/clear the Agents-pane "typing…" indicator (best-effort cosmetic). */
1757
+ async setSlackStatus(orgId, input) {
1758
+ await this.request("POST", ENDPOINTS.SLACK_STATUS(orgId), input);
1759
+ }
1760
+ };
1761
+ }
1762
+ });
1763
+
1664
1764
  // ts/sdk/dist/channel-conversation-client.js
1665
1765
  var ChannelConversationClient;
1666
1766
  var init_channel_conversation_client = __esm({
1667
1767
  "ts/sdk/dist/channel-conversation-client.js"() {
1668
1768
  "use strict";
1669
1769
  init_constants();
1670
- init_slack_files_client();
1671
- ChannelConversationClient = class extends SlackFilesClient {
1770
+ init_slack_read_client();
1771
+ ChannelConversationClient = class extends SlackReadClient {
1672
1772
  /**
1673
1773
  * Org-admin write of what the agent receives from a group root
1674
1774
  * (`PATCH …/channel-conversations/{id}/attention`); the agent's own path
@@ -1707,6 +1807,20 @@ var init_clip_connection_client = __esm({
1707
1807
  async putClipConnectionAccess(orgId, connId, input) {
1708
1808
  return this.request("PUT", ENDPOINTS.CLIP_CONNECTION_ACCESS(orgId, connId), input);
1709
1809
  }
1810
+ /** Start OAuth using the reviewed platform app or provider registration ladder.
1811
+ * Allow discovery (30s), persistence (10s), and network overhead to finish. */
1812
+ async createClipMCPOAuthConnection(orgId, clipId, serverUrl, alias, oauthClient) {
1813
+ return this.request("POST", ENDPOINTS.ORG_CLIP_MCP_CONFIGS(orgId, clipId), {
1814
+ server_url: serverUrl,
1815
+ auth_type: "oauth",
1816
+ ...alias ? { alias } : {},
1817
+ ...oauthClient ? { oauth_client: oauthClient } : {}
1818
+ }, void 0, false, { timeoutMs: 5e4 });
1819
+ }
1820
+ /** Cancel exactly one pending attempt; requires its initiator or an org admin. */
1821
+ async cancelClipMCPOAuthAttempt(orgId, clipId, attemptId) {
1822
+ return this.request("DELETE", ENDPOINTS.ORG_CLIP_MCP_OAUTH_ATTEMPT(orgId, clipId, attemptId));
1823
+ }
1710
1824
  };
1711
1825
  }
1712
1826
  });
@@ -1719,6 +1833,44 @@ var init_browser_profile_client = __esm({
1719
1833
  init_clip_connection_client();
1720
1834
  init_constants();
1721
1835
  BrowserProfileClient = class extends ClipConnectionClient {
1836
+ /** Metadata-only compatibility discovery. Management scope errors propagate;
1837
+ * callers with a known Profile can execute without this discovery chain. */
1838
+ async listBrowserUseProfiles(orgId, profileId) {
1839
+ const me = await this.request("GET", ENDPOINTS.USERS_ME);
1840
+ const devices = await this.request("GET", ENDPOINTS.ORG_EDGE_DEVICES(orgId));
1841
+ const data = [];
1842
+ for (const device of devices.data) {
1843
+ const personal = device.managed_by === "member";
1844
+ if (personal && device.owner_user_id !== me.id)
1845
+ continue;
1846
+ const profiles = await this.request("GET", ENDPOINTS.ORG_EDGE_PROFILES(orgId, device.id));
1847
+ for (const profile of profiles) {
1848
+ if (profileId && profile.id !== profileId)
1849
+ continue;
1850
+ const access = personal ? null : await this.getBrowserProfileAccess(orgId, device.id, profile.name);
1851
+ if (!personal && !access?.org_public && !(access?.grants ?? []).some((g) => g.user_id === me.id && g.grants.length > 0))
1852
+ continue;
1853
+ data.push({
1854
+ profile_id: profile.id,
1855
+ name: profile.name,
1856
+ device_name: device.name,
1857
+ placement: device.placement ?? "byoc",
1858
+ lifecycle_state: profile.lifecycle_state,
1859
+ can_access: true,
1860
+ availability: device.placement === "hosted" ? device.hosted_state ?? "unknown" : device.status
1861
+ });
1862
+ }
1863
+ }
1864
+ return { data };
1865
+ }
1866
+ /** Submit once: even refresh-enabled clients must not replay browser actions. */
1867
+ async createBrowserUseOperation(orgId, request3) {
1868
+ return this.request("POST", ENDPOINTS.ORG_BROWSER_USE_OPERATIONS(orgId), request3, void 0, true);
1869
+ }
1870
+ /** Recover proof/data without creating a new browser operation. */
1871
+ async getBrowserUseOperation(orgId, operationId, opts) {
1872
+ return this.request("GET", ENDPOINTS.ORG_BROWSER_USE_OPERATION(orgId, operationId), void 0, void 0, false, opts);
1873
+ }
1722
1874
  async getBrowserProfileAccess(orgId, edgeId, profileName) {
1723
1875
  return this.request("GET", ENDPOINTS.ORG_EDGE_PROFILE_ACCESS(orgId, edgeId, profileName));
1724
1876
  }
@@ -2220,8 +2372,8 @@ var init_client = __esm({
2220
2372
  return this.request("POST", ENDPOINTS.AUTH_OAUTH_EXCHANGE, { code });
2221
2373
  }
2222
2374
  // ---- WebSocket ----
2223
- async getWsTicket() {
2224
- return this.request("POST", ENDPOINTS.WS_TICKET);
2375
+ async getWsTicket(req) {
2376
+ return this.request("POST", ENDPOINTS.WS_TICKET, req);
2225
2377
  }
2226
2378
  // ---- Users ----
2227
2379
  async getMe() {
@@ -3208,8 +3360,8 @@ var init_client = __esm({
3208
3360
  * no_action sweep otherwise. Idempotent.
3209
3361
  *
3210
3362
  * @deprecated Legacy ok-only alias — use {@link completeDispatch} with the
3211
- * `sources` form, which also carries `turn_outcome`. The endpoint retires
3212
- * at S3b (dispatch-convergence-design.md §3).
3363
+ * `sources` form, which also carries `turn_outcome`. Retirement conditions:
3364
+ * agent-dispatch-idempotency-design.md#compatibility.
3213
3365
  */
3214
3366
  async completeDispatchSources(orgId, req) {
3215
3367
  return this.request("POST", ENDPOINTS.DISPATCH_COMPLETE_SOURCES(orgId), req);
@@ -3364,38 +3516,6 @@ var init_client = __esm({
3364
3516
  async sendChannelMessage(orgId, input) {
3365
3517
  return this.request("POST", ENDPOINTS.CHANNEL_SEND(orgId), input);
3366
3518
  }
3367
- slackReadQuery(base, query, extra) {
3368
- const params = new URLSearchParams();
3369
- if (query?.cursor)
3370
- params.set("cursor", query.cursor);
3371
- if (query?.limit)
3372
- params.set("limit", String(query.limit));
3373
- for (const [k, v] of Object.entries(extra ?? {}))
3374
- params.set(k, v);
3375
- const qs = params.toString();
3376
- return qs ? `${base}?${qs}` : base;
3377
- }
3378
- /**
3379
- * Tier-B read verbs (agent-only): workspace visibility as the bot sees
3380
- * it. Same live gate as the send verb; authorization beyond it is the
3381
- * bot's own Slack permissions.
3382
- */
3383
- async listSlackChannels(orgId, query) {
3384
- return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_CHANNELS(orgId), query));
3385
- }
3386
- async listSlackUsers(orgId, query) {
3387
- return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_USERS(orgId), query));
3388
- }
3389
- async slackHistory(orgId, conversationId, query) {
3390
- return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_HISTORY(orgId), query, { conversation: conversationId }));
3391
- }
3392
- async slackMembers(orgId, conversationId, query) {
3393
- return this.request("GET", this.slackReadQuery(ENDPOINTS.SLACK_MEMBERS(orgId), query, { conversation: conversationId }));
3394
- }
3395
- /** Set/clear the Agents-pane "typing…" indicator (best-effort cosmetic). */
3396
- async setSlackStatus(orgId, input) {
3397
- await this.request("POST", ENDPOINTS.SLACK_STATUS(orgId), input);
3398
- }
3399
3519
  /**
3400
3520
  * Authorized raw GET (binary responses) with the same auth, 401
3401
3521
  * refresh-and-retry-once, and error-envelope handling as `request` — the
@@ -3452,6 +3572,9 @@ var init_client = __esm({
3452
3572
  async getTriggerSchema(orgId, connectionId) {
3453
3573
  return this.request("GET", ENDPOINTS.TRIGGER_SCHEMA(orgId, connectionId));
3454
3574
  }
3575
+ async getPlatformTriggerSchema(orgId, eventTypes) {
3576
+ return this.request("GET", ENDPOINTS.PLATFORM_TRIGGER_SCHEMA(orgId), void 0, eventTypes && eventTypes.length > 0 ? { event_types: eventTypes.join(",") } : void 0);
3577
+ }
3455
3578
  async listTriggerIngressEvents(orgId, filters) {
3456
3579
  return this.request("GET", ENDPOINTS.TRIGGER_INGRESS_EVENTS(orgId), void 0, filters);
3457
3580
  }
@@ -3553,8 +3676,8 @@ var init_client = __esm({
3553
3676
  return url;
3554
3677
  return `${this.baseUrlFor(url)}${url}`;
3555
3678
  }
3556
- async getWikiBlob(orgId, wikiId, params) {
3557
- const blob = await this.request("GET", ENDPOINTS.WIKI_BLOB(orgId, wikiId), void 0, params);
3679
+ async getWikiBlob(orgId, wikiId, params, opts) {
3680
+ const blob = await this.request("GET", ENDPOINTS.WIKI_BLOB(orgId, wikiId), void 0, params, false, opts);
3558
3681
  if (blob.signed_url)
3559
3682
  blob.signed_url = this.absoluteMediaUrl(blob.signed_url);
3560
3683
  return blob;
@@ -3927,6 +4050,21 @@ var init_client = __esm({
3927
4050
  async getBilling(orgId) {
3928
4051
  return this.request("GET", ENDPOINTS.BILLING(orgId));
3929
4052
  }
4053
+ async getUsageDaily(orgId, opts) {
4054
+ const params = new URLSearchParams();
4055
+ params.set("start_date", opts.start_date);
4056
+ params.set("end_date", opts.end_date);
4057
+ return this.request("GET", `${ENDPOINTS.BILLING_USAGE_DAILY(orgId)}?${params}`);
4058
+ }
4059
+ async getUsageHeatmap(orgId, opts) {
4060
+ const params = new URLSearchParams();
4061
+ params.set("start_time", opts.start_time);
4062
+ if (opts.limit != null)
4063
+ params.set("limit", String(opts.limit));
4064
+ if (opts.offset != null)
4065
+ params.set("offset", String(opts.offset));
4066
+ return this.request("GET", `${ENDPOINTS.BILLING_USAGE_HEATMAP(orgId)}?${params}`);
4067
+ }
3930
4068
  async listBillingTransactions(orgId, opts) {
3931
4069
  const params = new URLSearchParams();
3932
4070
  if (opts?.cursor)
@@ -4096,12 +4234,14 @@ var init_client = __esm({
4096
4234
  }
4097
4235
  // ---- Clip registry (v3, api-server org registry — `crg_` entries) ----
4098
4236
  /**
4099
- * List registry clips visible to the org: its own plus public+approved
4100
- * cross-org entries. This is the surface `installRegistryClip` and clip
4101
- * connections operate on.
4237
+ * List one page of registry clips visible to the org: its own plus
4238
+ * public+approved cross-org entries, used by installs and connections.
4102
4239
  */
4103
- async listOrgRegistryClips(orgId) {
4104
- const resp = await this.request("GET", `${ENDPOINTS.ORG_CLIP_REGISTRY(orgId)}?limit=100`);
4240
+ async listOrgRegistryClips(orgId, opts) {
4241
+ const params = new URLSearchParams({ limit: String(opts?.limit ?? 100) });
4242
+ if (opts?.offset !== void 0)
4243
+ params.set("offset", String(opts.offset));
4244
+ const resp = await this.request("GET", `${ENDPOINTS.ORG_CLIP_REGISTRY(orgId)}?${params}`);
4105
4245
  return resp ?? [];
4106
4246
  }
4107
4247
  /**
@@ -4182,7 +4322,6 @@ var init_client = __esm({
4182
4322
  /**
4183
4323
  * Read a clip's per-org exec access (by user id — humans and agents alike).
4184
4324
  * Org-member readable, so a denied caller can learn why exec answered
4185
- * `CONNECTION_NOT_ALLOWED` (retired: `CLIP_NOT_ALLOWED` / `CLIP_CONNECTION_NOT_ALLOWED`) (agents:
4186
4325
  * `CLIP_AGENT_NOT_ALLOWED` / `CLIP_AGENT_CONNECTION_NOT_ALLOWED`). Writing
4187
4326
  * it (`putClipAgentExecAccess`) is an org owner/admin's act.
4188
4327
  */
@@ -4263,69 +4402,6 @@ var init_client = __esm({
4263
4402
  async getEdgeProfileOperation(orgId, edgeId, operationId) {
4264
4403
  return this.request("GET", ENDPOINTS.ORG_EDGE_PROFILE_OPERATION(orgId, edgeId, operationId));
4265
4404
  }
4266
- /** Create and atomically materialize one Local BYOC Browser Alias. A replay
4267
- * with the same idempotency key and body returns the original stable ccn_. */
4268
- async createBrowserAlias(orgId, request3) {
4269
- return this.request("POST", ENDPOINTS.ORG_BROWSER_ALIASES(orgId), request3);
4270
- }
4271
- async listBrowserAliases(orgId) {
4272
- return this.request("GET", ENDPOINTS.ORG_BROWSER_ALIASES(orgId));
4273
- }
4274
- async getBrowserAlias(orgId, aliasId) {
4275
- return this.request("GET", ENDPOINTS.ORG_BROWSER_ALIAS(orgId, aliasId));
4276
- }
4277
- async renameBrowserAlias(orgId, aliasId, request3) {
4278
- return this.request("PATCH", ENDPOINTS.ORG_BROWSER_ALIAS(orgId, aliasId), request3);
4279
- }
4280
- async deleteBrowserAlias(orgId, aliasId, request3) {
4281
- return this.request("DELETE", ENDPOINTS.ORG_BROWSER_ALIAS(orgId, aliasId), request3);
4282
- }
4283
- /** Start one durable readiness check. The key is carried as the standard
4284
- * Idempotency-Key header; the request body is intentionally empty. */
4285
- async createBrowserAliasReadinessCheck(orgId, aliasId, request3) {
4286
- return this.request("POST", ENDPOINTS.ORG_BROWSER_ALIAS_READINESS_CHECKS(orgId, aliasId), void 0, void 0, false, { headers: { "Idempotency-Key": request3.idempotency_key } });
4287
- }
4288
- /** Sole durable recovery surface for one readiness request. */
4289
- async getBrowserAliasReadinessCheck(orgId, aliasId, checkId) {
4290
- return this.request("GET", ENDPOINTS.ORG_BROWSER_ALIAS_READINESS_CHECK(orgId, aliasId, checkId));
4291
- }
4292
- /** Organization Owner view. Hashes, reviewed snapshots and deltas are
4293
- * intentionally available only on this human-JWT management surface. */
4294
- async listBrowserAliasGrants(orgId, keyId) {
4295
- return this.request("GET", ENDPOINTS.ORG_API_KEY_BROWSER_ALIAS_GRANTS(orgId, keyId));
4296
- }
4297
- async getBrowserAliasGrant(orgId, keyId, aliasId) {
4298
- return this.request("GET", ENDPOINTS.ORG_API_KEY_BROWSER_ALIAS_GRANT(orgId, keyId, aliasId));
4299
- }
4300
- async replaceBrowserAliasGrant(orgId, keyId, aliasId, request3) {
4301
- return this.request("PUT", ENDPOINTS.ORG_API_KEY_BROWSER_ALIAS_GRANT(orgId, keyId, aliasId), request3);
4302
- }
4303
- /** Managed-key discovery. The response is already grant-filtered and never
4304
- * carries contract hashes, review snapshots, Edge IDs or Profile IDs. */
4305
- async listManagedBrowserAliases(orgId) {
4306
- return this.request("GET", ENDPOINTS.ORG_MANAGED_ALIASES(orgId));
4307
- }
4308
- async getManagedBrowserAlias(orgId, aliasName) {
4309
- return this.request("GET", ENDPOINTS.ORG_MANAGED_ALIAS(orgId, aliasName));
4310
- }
4311
- /** Accept and dispatch one @alias command. request_id is generated by the
4312
- * caller before local validation and is also the sole durable recovery key. */
4313
- async createBrowserAliasExecution(orgId, request3) {
4314
- return this.request("POST", ENDPOINTS.ORG_BROWSER_ALIAS_EXECUTIONS(orgId), request3);
4315
- }
4316
- async getBrowserAliasExecution(orgId, requestId) {
4317
- return this.request("GET", ENDPOINTS.ORG_BROWSER_ALIAS_EXECUTION(orgId, requestId));
4318
- }
4319
- /** Accept one idempotent Browser Use operation for an explicit Profile.
4320
- * JWT, personal, agent and managed keys use profile access. The Server resolves Profile→Edge. */
4321
- async createBrowserUseOperation(orgId, request3) {
4322
- return this.request("POST", ENDPOINTS.ORG_BROWSER_USE_OPERATIONS(orgId), request3);
4323
- }
4324
- /** Recover the durable receipt. Successful data is present only inside the
4325
- * Server's short encrypted result TTL; terminal proof remains afterwards. */
4326
- async getBrowserUseOperation(orgId, operationId) {
4327
- return this.request("GET", ENDPOINTS.ORG_BROWSER_USE_OPERATION(orgId, operationId));
4328
- }
4329
4405
  /**
4330
4406
  * Read a hosted Cloud Profile's egress-proxy status (manager-only: hosted
4331
4407
  * human maintainer or org admin). Sanitized — the password never comes back.
@@ -4435,7 +4511,6 @@ var init_client = __esm({
4435
4511
  * - `EDGE_HOSTED_DISABLED_FOR_ORG` 403, `EDGE_REPAIR` 503 (operator-held),
4436
4512
  * `EDGE_RUNTIME_UNAVAILABLE` 503 (deployment has no hosted runtime).
4437
4513
  * - Access errors (before side effects): human `CONNECTION_NOT_ALLOWED`.
4438
- * `CLIP_NOT_ALLOWED` / `CLIP_CONNECTION_NOT_ALLOWED` are retired.
4439
4514
  * Agent principals receive the historical
4440
4515
  * `CLIP_AGENT_NOT_ALLOWED` / `CLIP_AGENT_CONNECTION_NOT_ALLOWED` for one
4441
4516
  * release. An org owner/admin can widen access in the clip's settings.
@@ -4519,17 +4594,6 @@ var init_client = __esm({
4519
4594
  timeoutMs: 4e4
4520
4595
  });
4521
4596
  }
4522
- /** Start a new Official OAuth MCP connection with the platform-owned app.
4523
- * Omitting oauth_client is load-bearing: the server resolves the exact
4524
- * reviewed-version binding and never falls back to DCR/CIMD cross-org. */
4525
- async createClipMCPOAuthConnection(orgId, clipId, serverUrl, alias, oauthClient) {
4526
- return this.request("POST", ENDPOINTS.ORG_CLIP_MCP_CONFIGS(orgId, clipId), {
4527
- server_url: serverUrl,
4528
- auth_type: "oauth",
4529
- ...alias ? { alias } : {},
4530
- ...oauthClient ? { oauth_client: oauthClient } : {}
4531
- });
4532
- }
4533
4597
  /** Re-authorize an existing MCP credential slot. */
4534
4598
  async initiateClipMCPOAuthById(orgId, clipId, configId, serverUrl, expectedVersion, oauthClient) {
4535
4599
  const req = {
@@ -4735,7 +4799,7 @@ function mentionTargetsUser(mentionUserId, userId, userType) {
4735
4799
  return userType === "agent";
4736
4800
  return false;
4737
4801
  }
4738
- var MENTION_ALL_USER_ID, MENTION_ALL_HUMANS_USER_ID, MENTION_ALL_AGENTS_USER_ID, CLI_RUNTIME_TYPES, MACHINE_DIAGNOSTICS_NOTE_MAX_CHARS, BROWSER_ALIAS_READINESS_REASON_CODES;
4802
+ var MENTION_ALL_USER_ID, MENTION_ALL_HUMANS_USER_ID, MENTION_ALL_AGENTS_USER_ID, CLI_RUNTIME_TYPES, MACHINE_DIAGNOSTICS_NOTE_MAX_CHARS;
4739
4803
  var init_types = __esm({
4740
4804
  "ts/sdk/dist/types.js"() {
4741
4805
  "use strict";
@@ -4744,17 +4808,37 @@ var init_types = __esm({
4744
4808
  MENTION_ALL_AGENTS_USER_ID = "allagent";
4745
4809
  CLI_RUNTIME_TYPES = ["claude-code", "codex", "openclaw"];
4746
4810
  MACHINE_DIAGNOSTICS_NOTE_MAX_CHARS = 500;
4747
- BROWSER_ALIAS_READINESS_REASON_CODES = [
4748
- "edge_offline",
4749
- "profile_not_found",
4750
- "profile_damaged",
4751
- "artifact_invalid",
4752
- "runtime_incompatible",
4753
- "needs_login",
4754
- "target_service_unavailable",
4755
- "readiness_check_running",
4756
- "readiness_check_timeout",
4757
- "readiness_contract_error"
4811
+ }
4812
+ });
4813
+
4814
+ // ts/sdk/dist/runtime-observation.js
4815
+ var RUNTIME_OBSERVATION_EVENTS, RUNTIME_OBSERVATION_STATUSES;
4816
+ var init_runtime_observation2 = __esm({
4817
+ "ts/sdk/dist/runtime-observation.js"() {
4818
+ "use strict";
4819
+ RUNTIME_OBSERVATION_EVENTS = [
4820
+ "turn_started",
4821
+ "turn_completed",
4822
+ "thread_status",
4823
+ "hook_started",
4824
+ "hook_completed",
4825
+ "session_initialized",
4826
+ "request_completed",
4827
+ "session_status"
4828
+ ];
4829
+ RUNTIME_OBSERVATION_STATUSES = [
4830
+ "running",
4831
+ "completed",
4832
+ "failed",
4833
+ "blocked",
4834
+ "stopped",
4835
+ "interrupted",
4836
+ "idle",
4837
+ "not_loaded",
4838
+ "system_error",
4839
+ "initialized",
4840
+ "compacting",
4841
+ "unknown"
4758
4842
  ];
4759
4843
  }
4760
4844
  });
@@ -4784,6 +4868,11 @@ function describeWsStateDetail(detail) {
4784
4868
  function isRetryableNetworkError(err) {
4785
4869
  return err instanceof Error && err.name === "ApiError" && "status" in err && err.status === 0;
4786
4870
  }
4871
+ function authRejectionFrom(err) {
4872
+ if (!(err instanceof ApiError) || err.status !== 401)
4873
+ return null;
4874
+ return { status: err.status, code: err.code, message: err.message };
4875
+ }
4787
4876
  function isBrowserRuntime() {
4788
4877
  return typeof window !== "undefined";
4789
4878
  }
@@ -4791,15 +4880,19 @@ var ParallWs;
4791
4880
  var init_ws = __esm({
4792
4881
  "ts/sdk/dist/ws.js"() {
4793
4882
  "use strict";
4883
+ init_client();
4794
4884
  init_constants();
4795
4885
  ParallWs = class {
4796
4886
  ws = null;
4797
4887
  options;
4798
4888
  listeners = /* @__PURE__ */ new Map();
4799
4889
  stateListeners = /* @__PURE__ */ new Set();
4890
+ authInvalidListeners = /* @__PURE__ */ new Set();
4800
4891
  heartbeatTimer = null;
4801
4892
  reconnectTimer = null;
4802
4893
  reconnectAttempts = 0;
4894
+ /** Ticket attempts in the current auth-invalid episode (reset on success). */
4895
+ authAttempts = 0;
4803
4896
  lastSeq = 0;
4804
4897
  _state = "disconnected";
4805
4898
  intentionalClose = false;
@@ -4812,6 +4905,7 @@ var init_ws = __esm({
4812
4905
  reconnect: true,
4813
4906
  reconnectInterval: 1e3,
4814
4907
  maxReconnectInterval: 3e4,
4908
+ maxAuthAttempts: 3,
4815
4909
  ...options
4816
4910
  };
4817
4911
  this.lastSeq = options.lastSeq ?? 0;
@@ -4821,12 +4915,25 @@ var init_ws = __esm({
4821
4915
  }
4822
4916
  async connect() {
4823
4917
  this.intentionalClose = false;
4918
+ if (this._state === "auth-invalid")
4919
+ this.authAttempts = 0;
4824
4920
  this.setupBrowserListeners();
4825
4921
  this.setState("connecting");
4826
4922
  let ticket;
4827
4923
  try {
4828
4924
  ticket = await this.options.getTicket();
4829
4925
  } catch (err) {
4926
+ const authRejection = authRejectionFrom(err);
4927
+ if (authRejection) {
4928
+ this.authAttempts += 1;
4929
+ if (this.authAttempts < this.options.maxAuthAttempts && this.options.reconnect) {
4930
+ console.warn(`WS ticket auth rejected (attempt ${this.authAttempts}/${this.options.maxAuthAttempts}):`, err);
4931
+ this.scheduleReconnect({ cause: "ticket_failed" });
4932
+ } else {
4933
+ this.enterAuthInvalid(authRejection);
4934
+ }
4935
+ return;
4936
+ }
4830
4937
  if (isBrowserRuntime() && isRetryableNetworkError(err)) {
4831
4938
  console.warn("Failed to get WS ticket:", err);
4832
4939
  } else {
@@ -4873,6 +4980,7 @@ var init_ws = __esm({
4873
4980
  this.ws.onopen = () => {
4874
4981
  clearTimeout(connectTimeout);
4875
4982
  this.reconnectAttempts = 0;
4983
+ this.authAttempts = 0;
4876
4984
  this.lastReceivedAt = Date.now();
4877
4985
  this.setState("connected");
4878
4986
  };
@@ -4960,6 +5068,20 @@ var init_ws = __esm({
4960
5068
  this.stateListeners.delete(handler);
4961
5069
  };
4962
5070
  }
5071
+ /**
5072
+ * Subscribe to the auth-invalid transition. Fired exactly once when the
5073
+ * client enters the terminal 'auth-invalid' state (a second episode after
5074
+ * a recovered reconnect fires again — one event per transition edge).
5075
+ * Consumers: runtime bridges exit for supervisor re-mint (see
5076
+ * @parall/agent-core gateway-base), the daemon logs recovery guidance for
5077
+ * its machine key, UIs surface a re-authenticate action.
5078
+ */
5079
+ onAuthInvalid(handler) {
5080
+ this.authInvalidListeners.add(handler);
5081
+ return () => {
5082
+ this.authInvalidListeners.delete(handler);
5083
+ };
5084
+ }
4963
5085
  // ---- Internal ----
4964
5086
  send(frame) {
4965
5087
  if (this.ws?.readyState === WebSocket.OPEN) {
@@ -5005,6 +5127,8 @@ var init_ws = __esm({
5005
5127
  }
5006
5128
  }
5007
5129
  scheduleReconnect(detail) {
5130
+ if (this._state === "auth-invalid")
5131
+ return;
5008
5132
  this.setState("reconnecting", { ...detail, attempt: this.reconnectAttempts + 1 });
5009
5133
  this.clearReconnect();
5010
5134
  const base = Math.min(this.options.reconnectInterval * Math.pow(2, this.reconnectAttempts), this.options.maxReconnectInterval);
@@ -5020,6 +5144,20 @@ var init_ws = __esm({
5020
5144
  this.reconnectTimer = null;
5021
5145
  }
5022
5146
  }
5147
+ /**
5148
+ * Enter the terminal auth-invalid state and notify consumers once. Loud on
5149
+ * purpose: before this branch existed, a revoked key produced an infinite
5150
+ * silent connecting→reconnecting loop with no indication that the
5151
+ * credential — not the network — was the problem.
5152
+ */
5153
+ enterAuthInvalid(event) {
5154
+ this.clearReconnect();
5155
+ this.setState("auth-invalid");
5156
+ console.error(`WS auth-invalid: server rejected this credential (status ${event.status}${event.code ? `, code ${event.code}` : ""}) \u2014 ${event.message}. The key is invalid, expired, or revoked; retrying it cannot succeed, so reconnects are stopped. Recover by refreshing credentials (re-login, or issue a new API key), then connect again.`);
5157
+ for (const listener of this.authInvalidListeners) {
5158
+ listener(event);
5159
+ }
5160
+ }
5023
5161
  /** Force-close a dead/stale connection and trigger reconnect. */
5024
5162
  forceReconnect(cause) {
5025
5163
  this.stopHeartbeat();
@@ -5126,13 +5264,339 @@ var init_ws = __esm({
5126
5264
  }
5127
5265
  });
5128
5266
 
5267
+ // ts/sdk/dist/browser-use-contract.generated.js
5268
+ var browserUseContract;
5269
+ var init_browser_use_contract_generated = __esm({
5270
+ "ts/sdk/dist/browser-use-contract.generated.js"() {
5271
+ "use strict";
5272
+ browserUseContract = { "actions": { "read": { "grant": "browser.read", "target": "optional_tab", "params": { "required": [], "properties": { "url": { "type": "string", "min_length": 1, "max_length": 8192, "schemes": ["http", "https", "about:blank"] } }, "rules": ["exactly one of params.url or target is required", "params.url creates a hidden Profile-bound tab and closes it before terminal success or failure"], "additional_properties": false }, "success": { "base": null, "fields": { "profile_id": "ebp_identifier", "url": "string", "title": "string", "article": "nullable_article" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "tabs": { "grant": "browser.read", "target": "none", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": null, "fields": { "tabs": "tab_summary_array" } }, "errors": ["TAB_GONE"] }, "wait": { "grant": "browser.read", "target": "tab", "params": { "required": [], "properties": { "selector": { "type": "string", "min_length": 1, "max_length": 4096 }, "state": { "enum": ["attached", "detached", "visible", "hidden", "load"], "default": "attached" }, "timeout_ms": { "type": "integer", "minimum": 1, "maximum": 3e4, "default": 1e4 } }, "rules": ["selector is required unless state=load", "state=load forbids selector"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "matched": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "snapshot": { "grant": "browser.read", "target": "tab", "params": { "required": [], "properties": { "interactive": { "type": "boolean", "default": false }, "compact": { "type": "boolean", "default": false }, "depth": { "type": "integer", "minimum": 0, "maximum": 64 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "snapshot": "string", "snapshot_id": "identifier" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "get": { "grant": "browser.read", "target": "tab_or_ref", "params": { "required": ["prop"], "properties": { "selector": { "type": "string", "min_length": 1, "max_length": 4096 }, "prop": { "enum": ["text", "html", "value", "attr", "title", "url"] }, "name": { "type": "string", "min_length": 1, "max_length": 256 } }, "rules": ["title/url forbid locator and name", "text/html/value require exactly one locator", "attr requires exactly one locator and name"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "value": "nullable_string" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "screenshot": { "grant": "browser.read", "target": "tab", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "format": { "const": "png" }, "base64": "canonical_base64" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "open": { "grant": "browser.interact", "target": "none", "params": { "required": ["url"], "properties": { "url": { "type": "string", "min_length": 1, "max_length": 8192, "schemes": ["http", "https", "about:blank"] }, "hidden": { "type": "boolean", "default": false }, "viewport": { "type": "viewport" } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": {} }, "errors": ["PAGE_LOAD_FAILED"] }, "navigate": { "grant": "browser.interact", "target": "tab", "params": { "required": ["url"], "properties": { "url": { "type": "string", "min_length": 1, "max_length": 8192, "schemes": ["http", "https", "about:blank"] } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": {} }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "viewport": { "grant": "browser.interact", "target": "tab", "params": { "required": ["width", "height"], "properties": { "width": { "type": "integer", "minimum": 320, "maximum": 3840 }, "height": { "type": "integer", "minimum": 240, "maximum": 2160 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "viewport": "viewport" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE"] }, "click": { "grant": "browser.interact", "target": "tab_or_ref", "params": { "required": [], "properties": { "selector": "selector" }, "rules": ["exactly one of params.selector or target.ref"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "clicked": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "fill": { "grant": "browser.interact", "target": "tab_or_ref", "params": { "required": ["text"], "properties": { "selector": "selector", "text": { "type": "string", "allow_empty": true } }, "rules": ["exactly one of params.selector or target.ref"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "filled": { "const": true }, "characters": "non_negative_integer" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "type": { "grant": "browser.interact", "target": "tab_or_ref", "params": { "required": ["text"], "properties": { "selector": "selector", "text": { "type": "string", "min_length": 1 } }, "rules": ["exactly one of params.selector or target.ref"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "typed": { "const": true }, "characters": "non_negative_integer" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "press": { "grant": "browser.interact", "target": "tab", "params": { "required": ["key"], "properties": { "key": "single_unicode_character_or_named_key" }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "pressed": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "scroll": { "grant": "browser.interact", "target": "tab", "params": { "required": [], "properties": { "direction": { "enum": ["up", "down", "left", "right"], "default": "down" }, "pixels": { "type": "integer", "minimum": 1, "maximum": 1e5, "default": 500 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "scrolled": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "close": { "grant": "browser.interact", "target": "tab", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "closed": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE"] }, "recover": { "grant": "browser.interact", "target": "tab", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "recovered_from_tab_id": "identifier" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "eval": { "grant": "browser.advanced", "target": "tab", "params": { "required": ["expression"], "properties": { "expression": { "type": "string", "min_length": 1 }, "timeout_ms": { "type": "integer", "minimum": 1, "maximum": 15e3, "default": 15e3 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "value": "json_value_max_256_kib" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] } }, "successShapes": { "tab_state": { "required": ["tab_id", "profile_id", "browser_generation", "document_generation", "url", "title"], "fields": { "tab_id": "identifier", "profile_id": "ebp_identifier", "browser_generation": "positive_integer", "document_generation": "positive_integer", "url": "string", "title": "string" }, "additional_properties": false }, "tab_summary": { "base": "tab_state", "required_additions": ["loading"], "fields": { "loading": "boolean" }, "additional_properties": false }, "article": { "required": ["title", "byline", "excerpt", "text", "published_time", "site_name", "length"], "fields": { "title": "nullable_string", "byline": "nullable_string", "excerpt": "nullable_string", "text": "string", "published_time": "nullable_string", "site_name": "nullable_string", "length": "non_negative_integer" }, "additional_properties": false } } };
5273
+ }
5274
+ });
5275
+
5276
+ // ts/sdk/dist/browser-use-validation.js
5277
+ function browserUseObject(value) {
5278
+ if (!value || typeof value !== "object" || Array.isArray(value))
5279
+ throw new BrowserUseValidationError("Expected an object.");
5280
+ return value;
5281
+ }
5282
+ function browserUseIdentifier(value, prefix) {
5283
+ if (typeof value !== "string" || !value.startsWith(prefix) || value.length <= prefix.length || value.length > 128 || !/^[A-Za-z0-9_-]+$/.test(value) || ["__proto__", "constructor", "prototype"].includes(value))
5284
+ throw new BrowserUseValidationError(`Expected a ${prefix} identifier.`);
5285
+ return value;
5286
+ }
5287
+ function requireValid(condition, label) {
5288
+ if (!condition)
5289
+ throw new BrowserUseValidationError(`Invalid ${label}.`);
5290
+ }
5291
+ function exact(value, allowed, required = []) {
5292
+ requireValid(Object.keys(value).every((k) => allowed.includes(k)) && required.every((k) => Object.hasOwn(value, k)), "object fields");
5293
+ }
5294
+ function validateBrowserUseField(value, field, label) {
5295
+ if (typeof field === "string") {
5296
+ switch (field) {
5297
+ case "selector":
5298
+ return validateBrowserUseField(value, { type: "string", min_length: 1, max_length: 4096 }, label);
5299
+ case "single_unicode_character_or_named_key":
5300
+ requireValid(typeof value === "string" && ([...value].length === 1 || [
5301
+ "Enter",
5302
+ "Tab",
5303
+ "Escape",
5304
+ "Backspace",
5305
+ "Delete",
5306
+ "ArrowUp",
5307
+ "ArrowDown",
5308
+ "ArrowLeft",
5309
+ "ArrowRight",
5310
+ "Home",
5311
+ "End",
5312
+ "PageUp",
5313
+ "PageDown"
5314
+ ].includes(value)), label);
5315
+ return;
5316
+ case "viewport": {
5317
+ const obj = browserUseObject(value);
5318
+ exact(obj, ["width", "height"], ["width", "height"]);
5319
+ validateBrowserUseField(obj.width, { type: "integer", minimum: 320, maximum: 3840 }, label);
5320
+ validateBrowserUseField(obj.height, { type: "integer", minimum: 240, maximum: 2160 }, label);
5321
+ return;
5322
+ }
5323
+ case "identifier":
5324
+ browserUseIdentifier(value, label.includes("snapshot") ? "bsn_" : "btab_");
5325
+ return;
5326
+ case "ebp_identifier":
5327
+ browserUseIdentifier(value, "ebp_");
5328
+ return;
5329
+ case "positive_integer":
5330
+ return validateBrowserUseField(value, { type: "integer", minimum: 1 }, label);
5331
+ case "non_negative_integer":
5332
+ return validateBrowserUseField(value, { type: "integer", minimum: 0 }, label);
5333
+ case "nullable_string":
5334
+ if (value === null)
5335
+ return;
5336
+ return validateBrowserUseField(value, { type: "string", allow_empty: true }, label);
5337
+ case "string":
5338
+ return validateBrowserUseField(value, { type: "string", allow_empty: true }, label);
5339
+ case "boolean":
5340
+ requireValid(typeof value === "boolean", label);
5341
+ return;
5342
+ case "canonical_base64":
5343
+ requireValid(typeof value === "string" && value.length > 0 && /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value) && btoa(atob(value)) === value, label);
5344
+ return;
5345
+ case "nullable_article":
5346
+ if (value === null)
5347
+ return;
5348
+ return validateShape(value, browserUseContract.successShapes.article.fields);
5349
+ case "tab_summary_array":
5350
+ requireValid(Array.isArray(value), label);
5351
+ for (const tab of value)
5352
+ validateShape(tab, {
5353
+ ...browserUseContract.successShapes.tab_state.fields,
5354
+ loading: "boolean"
5355
+ });
5356
+ return;
5357
+ case "json_value_max_256_kib":
5358
+ requireValid(new TextEncoder().encode(canonicalBrowserUseJson(value)).length <= 256 * 1024, label);
5359
+ return;
5360
+ default:
5361
+ throw new BrowserUseValidationError(`Unknown contract field ${field}.`);
5362
+ }
5363
+ }
5364
+ if ("const" in field) {
5365
+ requireValid(value === field.const, label);
5366
+ return;
5367
+ }
5368
+ if (field.enum) {
5369
+ requireValid(field.enum.includes(value), label);
5370
+ return;
5371
+ }
5372
+ if (field.type === "viewport")
5373
+ return validateBrowserUseField(value, "viewport", label);
5374
+ if (field.type === "boolean") {
5375
+ requireValid(typeof value === "boolean", label);
5376
+ return;
5377
+ }
5378
+ if (field.type === "integer") {
5379
+ requireValid(typeof value === "number" && Number.isSafeInteger(value) && value >= (field.minimum ?? 0) && value <= (field.maximum ?? Number.MAX_SAFE_INTEGER), label);
5380
+ return;
5381
+ }
5382
+ requireValid(typeof value === "string" && [...value].length >= (field.allow_empty ? 0 : field.min_length ?? 1) && [...value].length <= (field.max_length ?? 1 << 20), label);
5383
+ if (field.schemes) {
5384
+ if (value === "about:blank")
5385
+ return;
5386
+ let url;
5387
+ try {
5388
+ url = new URL(value);
5389
+ } catch {
5390
+ throw new BrowserUseValidationError(`Invalid ${label} URL.`);
5391
+ }
5392
+ requireValid(url.protocol === "https:" || url.protocol === "http:", label);
5393
+ }
5394
+ }
5395
+ function validateShape(value, fields) {
5396
+ const obj = browserUseObject(value);
5397
+ exact(obj, Object.keys(fields), Object.keys(fields));
5398
+ for (const [key, field] of Object.entries(fields))
5399
+ validateBrowserUseField(obj[key], field, key);
5400
+ }
5401
+ function validateBrowserUseActionRequest(value) {
5402
+ const obj = browserUseObject(value);
5403
+ exact(obj, ["action", "target", "params"], ["action", "params"]);
5404
+ requireValid(typeof obj.action === "string", "action");
5405
+ if (!Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, obj.action))
5406
+ throw new BrowserUseValidationError(`Browser Use v1 does not support ${obj.action}.`, "UNSUPPORTED_ACTION");
5407
+ const action = obj.action;
5408
+ const schema = BROWSER_USE_ACTION_SCHEMAS[action];
5409
+ const params = browserUseObject(obj.params);
5410
+ exact(params, Object.keys(schema.params.properties), [...schema.params.required]);
5411
+ for (const [key, val] of Object.entries(params))
5412
+ validateBrowserUseField(val, schema.params.properties[key], key);
5413
+ let target;
5414
+ if (obj.target !== void 0) {
5415
+ requireValid(schema.target !== "none", "target");
5416
+ target = browserUseObject(obj.target);
5417
+ const base = ["tab_id", "browser_generation"];
5418
+ const refs = ["document_generation", "snapshot_id", "ref"];
5419
+ exact(target, schema.target === "tab_or_ref" ? [...base, ...refs] : base, base);
5420
+ browserUseIdentifier(target.tab_id, "btab_");
5421
+ validateBrowserUseField(target.browser_generation, "positive_integer", "browser_generation");
5422
+ if (refs.some((k) => Object.hasOwn(target, k))) {
5423
+ requireValid(refs.every((k) => Object.hasOwn(target, k)), "complete ref binding");
5424
+ validateBrowserUseField(target.document_generation, "positive_integer", "document_generation");
5425
+ browserUseIdentifier(target.snapshot_id, "bsn_");
5426
+ browserUseIdentifier(target.ref, "");
5427
+ }
5428
+ } else
5429
+ requireValid(schema.target === "none" || schema.target === "optional_tab", "required target");
5430
+ const locatorCount = Number(params.selector !== void 0) + Number(target?.ref !== void 0);
5431
+ if (action === "read")
5432
+ requireValid(params.url !== void 0 !== Boolean(target), "read URL or target");
5433
+ if (action === "wait")
5434
+ requireValid(params.state === "load" === (params.selector === void 0), "wait selector/state");
5435
+ if (["click", "fill", "type"].includes(action))
5436
+ requireValid(locatorCount === 1, "exactly one locator");
5437
+ if (action === "get") {
5438
+ const page = params.prop === "title" || params.prop === "url";
5439
+ requireValid(locatorCount === (page ? 0 : 1), "get locator");
5440
+ requireValid(params.prop === "attr" === (params.name !== void 0), "get attribute name");
5441
+ }
5442
+ requireValid(new TextEncoder().encode(JSON.stringify(obj)).length <= 1 << 20, "request size");
5443
+ return obj;
5444
+ }
5445
+ function validateBrowserUseSuccessData(action, value) {
5446
+ const schema = BROWSER_USE_ACTION_SCHEMAS[action].success;
5447
+ validateShape(value, {
5448
+ ...schema.base === "tab_state" ? browserUseContract.successShapes.tab_state.fields : {},
5449
+ ...schema.fields
5450
+ });
5451
+ }
5452
+ function canonicalBrowserUseJson(value, seen = /* @__PURE__ */ new Set()) {
5453
+ if (value === null || typeof value === "boolean" || typeof value === "string")
5454
+ return JSON.stringify(value);
5455
+ if (typeof value === "number" && Number.isFinite(value))
5456
+ return JSON.stringify(value);
5457
+ if (!value || typeof value !== "object" || seen.has(value))
5458
+ throw new BrowserUseValidationError("Invalid JSON result.");
5459
+ seen.add(value);
5460
+ const result = Array.isArray(value) ? `[${value.map((v) => canonicalBrowserUseJson(v, seen)).join(",")}]` : `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonicalBrowserUseJson(value[k], seen)}`).join(",")}}`;
5461
+ seen.delete(value);
5462
+ return result;
5463
+ }
5464
+ var BrowserUseValidationError, BROWSER_USE_ACTION_SCHEMAS, BROWSER_USE_ACTIONS;
5465
+ var init_browser_use_validation = __esm({
5466
+ "ts/sdk/dist/browser-use-validation.js"() {
5467
+ "use strict";
5468
+ init_browser_use_contract_generated();
5469
+ BrowserUseValidationError = class extends Error {
5470
+ code;
5471
+ constructor(message, code = "INVALID_ARGUMENT") {
5472
+ super(message);
5473
+ this.code = code;
5474
+ }
5475
+ };
5476
+ BROWSER_USE_ACTION_SCHEMAS = browserUseContract.actions;
5477
+ BROWSER_USE_ACTIONS = Object.freeze(Object.keys(BROWSER_USE_ACTION_SCHEMAS));
5478
+ }
5479
+ });
5480
+
5481
+ // ts/sdk/dist/browser-use-receipt.js
5482
+ function isBrowserUseTimestamp(value) {
5483
+ if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/.test(value))
5484
+ return false;
5485
+ const [year, month, day, hour, minute, second] = value.slice(0, 19).split(/[-T:]/).map(Number);
5486
+ return year >= 1 && month >= 1 && month <= 12 && day >= 1 && day <= new Date(Date.UTC(year, month, 0)).getUTCDate() && hour < 24 && minute < 60 && second < 60 && Number.isFinite(Date.parse(value));
5487
+ }
5488
+ async function browserUseResultDigest(value, maxBytes = 1 << 20, subtle = globalThis.crypto.subtle) {
5489
+ const bytes = new TextEncoder().encode(canonicalBrowserUseJson(value));
5490
+ if (bytes.length > maxBytes)
5491
+ throw new BrowserUseValidationError("Browser Use result exceeds contract size.");
5492
+ const digest = await subtle.digest("SHA-256", bytes);
5493
+ return `sha256:${Array.from(new Uint8Array(digest), (n) => n.toString(16).padStart(2, "0")).join("")}`;
5494
+ }
5495
+ function proof(condition) {
5496
+ if (!condition)
5497
+ throw new BrowserUseValidationError("The Browser Use response did not contain valid public status proof.", "INVALID_SERVER_RESPONSE");
5498
+ }
5499
+ async function validateBrowserUseReceipt(value, expected, subtle) {
5500
+ try {
5501
+ const r = browserUseObject(value);
5502
+ proof(Object.keys(r).every((k) => KEYS.includes(k)));
5503
+ proof(r.contract_version === "browser-use-operation-v1");
5504
+ browserUseIdentifier(r.operation_id, "buo_");
5505
+ browserUseIdentifier(r.request_id, "burq_");
5506
+ browserUseIdentifier(r.profile_id, "ebp_");
5507
+ proof(r.profile_id === expected.profileId && (!expected.operationId || r.operation_id === expected.operationId) && (!expected.requestId || r.request_id === expected.requestId) && (!expected.action || r.action === expected.action));
5508
+ proof(typeof r.action === "string" && Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, r.action));
5509
+ const action = r.action;
5510
+ proof(r.required_grant === BROWSER_USE_ACTION_SCHEMAS[action].grant);
5511
+ proof(positive(r.profile_version) && positive(r.profile_config_revision));
5512
+ proof(typeof r.phase === "string" && ["accepted", "started", ...terminal].includes(r.phase));
5513
+ proof(typeof r.result_available === "boolean");
5514
+ for (const k of ["deadline", "accepted_at", "updated_at"])
5515
+ proof(isBrowserUseTimestamp(r[k]));
5516
+ for (const k of ["occurred_at", "result_expires_at", "started_at", "terminal_at"])
5517
+ if (k in r)
5518
+ proof(isBrowserUseTimestamp(r[k]));
5519
+ if ("duration_ms" in r)
5520
+ proof(typeof r.duration_ms === "number" && Number.isSafeInteger(r.duration_ms) && r.duration_ms >= 0);
5521
+ if ("dispatched" in r)
5522
+ proof(typeof r.dispatched === "boolean");
5523
+ proof("tab_id" in r === "browser_generation" in r);
5524
+ if ("tab_id" in r) {
5525
+ browserUseIdentifier(r.tab_id, "btab_");
5526
+ proof(positive(r.browser_generation));
5527
+ }
5528
+ const isTerminal = terminal.has(r.phase);
5529
+ if (isTerminal) {
5530
+ browserUseIdentifier(r.receipt_id, "bur_");
5531
+ proof(hash(r.receipt_digest) && isBrowserUseTimestamp(r.occurred_at) && isBrowserUseTimestamp(r.terminal_at));
5532
+ } else {
5533
+ proof(!("terminal_at" in r));
5534
+ if ("receipt_id" in r || "receipt_digest" in r || "occurred_at" in r) {
5535
+ proof(r.phase === "started");
5536
+ browserUseIdentifier(r.receipt_id, "bur_");
5537
+ proof(hash(r.receipt_digest) && isBrowserUseTimestamp(r.occurred_at));
5538
+ }
5539
+ }
5540
+ const hasData = Object.hasOwn(r, "data");
5541
+ proof(r.result_available === hasData);
5542
+ if (r.phase === "succeeded")
5543
+ proof(!("error" in r) && hash(r.result_digest));
5544
+ else {
5545
+ proof(!hasData && !r.result_available);
5546
+ if (isTerminal) {
5547
+ const e = browserUseObject(r.error);
5548
+ proof(Object.keys(e).every((k) => ["code", "message", "hint"].includes(k)) && typeof e.code === "string" && /^[A-Z][A-Z0-9_]{0,127}$/.test(e.code));
5549
+ for (const k of ["message", "hint"])
5550
+ if (k in e)
5551
+ proof(typeof e[k] === "string" && e[k].length <= 1024);
5552
+ if (r.phase === "outcome_unknown")
5553
+ proof(e.code === "UNKNOWN_OUTCOME");
5554
+ } else
5555
+ proof(!("error" in r));
5556
+ }
5557
+ if (hasData) {
5558
+ validateBrowserUseSuccessData(action, r.data);
5559
+ proof(r.result_digest === await browserUseResultDigest(r.data, action === "eval" ? 256 * 1024 : 1 << 20, subtle));
5560
+ const data = browserUseObject(r.data);
5561
+ if (action === "tabs")
5562
+ proof(data.tabs.every((t) => t.profile_id === r.profile_id));
5563
+ else
5564
+ proof(data.profile_id === r.profile_id);
5565
+ if (!["read", "tabs"].includes(action))
5566
+ proof(data.tab_id === r.tab_id && data.browser_generation === r.browser_generation);
5567
+ if (expected.target) {
5568
+ if (action === "recover")
5569
+ proof(data.recovered_from_tab_id === expected.target.tab_id);
5570
+ else if (action !== "read")
5571
+ proof(data.tab_id === expected.target.tab_id && data.browser_generation === expected.target.browser_generation);
5572
+ }
5573
+ }
5574
+ return r;
5575
+ } catch {
5576
+ throw new BrowserUseValidationError("The Browser Use response did not contain valid public status proof.", "INVALID_SERVER_RESPONSE");
5577
+ }
5578
+ }
5579
+ var KEYS, terminal, hash, positive;
5580
+ var init_browser_use_receipt = __esm({
5581
+ "ts/sdk/dist/browser-use-receipt.js"() {
5582
+ "use strict";
5583
+ init_browser_use_validation();
5584
+ KEYS = "contract_version operation_id request_id profile_id profile_version profile_config_revision action required_grant phase dispatched receipt_id receipt_digest occurred_at tab_id browser_generation duration_ms result_digest result_available result_expires_at data error deadline accepted_at started_at terminal_at updated_at".split(" ");
5585
+ terminal = /* @__PURE__ */ new Set(["succeeded", "failed", "outcome_unknown"]);
5586
+ hash = (value) => typeof value === "string" && /^sha256:[0-9a-f]{64}$/.test(value);
5587
+ positive = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
5588
+ }
5589
+ });
5590
+
5129
5591
  // ts/sdk/dist/index.js
5130
5592
  var dist_exports = {};
5131
5593
  __export(dist_exports, {
5132
5594
  API_BASE: () => API_BASE2,
5133
5595
  ApiError: () => ApiError,
5134
- BROWSER_ALIAS_READINESS_REASON_CODES: () => BROWSER_ALIAS_READINESS_REASON_CODES,
5596
+ BROWSER_USE_ACTIONS: () => BROWSER_USE_ACTIONS,
5597
+ BROWSER_USE_ACTION_SCHEMAS: () => BROWSER_USE_ACTION_SCHEMAS,
5135
5598
  BROWSER_USE_FEATURE_FLAG: () => BROWSER_USE_FEATURE_FLAG,
5599
+ BrowserUseValidationError: () => BrowserUseValidationError,
5136
5600
  CLIP_BASE: () => CLIP_BASE,
5137
5601
  CLI_RUNTIME_TYPES: () => CLI_RUNTIME_TYPES,
5138
5602
  COMMENT_TARGET: () => COMMENT_TARGET,
@@ -5147,13 +5611,21 @@ __export(dist_exports, {
5147
5611
  PLATFORM_MODELS: () => PLATFORM_MODELS,
5148
5612
  ParallClient: () => ParallClient,
5149
5613
  ParallWs: () => ParallWs,
5614
+ RUNTIME_OBSERVATION_EVENTS: () => RUNTIME_OBSERVATION_EVENTS,
5615
+ RUNTIME_OBSERVATION_STATUSES: () => RUNTIME_OBSERVATION_STATUSES,
5150
5616
  WIKI_BASE: () => WIKI_BASE,
5151
5617
  WS_EVENTS: () => WS_EVENTS,
5618
+ authRejectionFrom: () => authRejectionFrom,
5619
+ browserUseIdentifier: () => browserUseIdentifier,
5620
+ browserUseObject: () => browserUseObject,
5621
+ browserUseResultDigest: () => browserUseResultDigest,
5152
5622
  browserViewerRequestOptions: () => browserViewerRequestOptions,
5623
+ canonicalBrowserUseJson: () => canonicalBrowserUseJson,
5153
5624
  describeFetchCause: () => describeFetchCause,
5154
5625
  describeWsStateDetail: () => describeWsStateDetail,
5155
5626
  isBroadcastMentionId: () => isBroadcastMentionId,
5156
5627
  isBrowserUseEnabled: () => isBrowserUseEnabled,
5628
+ isBrowserUseTimestamp: () => isBrowserUseTimestamp,
5157
5629
  isInWikiPersonalNamespace: () => isInWikiPersonalNamespace,
5158
5630
  isPlatformModelSelectableForRuntime: () => isPlatformModelSelectableForRuntime,
5159
5631
  isTeamSubject: () => isTeamSubject,
@@ -5162,6 +5634,10 @@ __export(dist_exports, {
5162
5634
  parseSubjectToken: () => parseSubjectToken,
5163
5635
  platformDefaultModelForRuntime: () => platformDefaultModelForRuntime,
5164
5636
  teamIdsFromSubjects: () => teamIdsFromSubjects,
5637
+ validateBrowserUseActionRequest: () => validateBrowserUseActionRequest,
5638
+ validateBrowserUseField: () => validateBrowserUseField,
5639
+ validateBrowserUseReceipt: () => validateBrowserUseReceipt,
5640
+ validateBrowserUseSuccessData: () => validateBrowserUseSuccessData,
5165
5641
  wikiPersonalNamespacePrefix: () => wikiPersonalNamespacePrefix
5166
5642
  });
5167
5643
  var init_dist = __esm({
@@ -5179,8 +5655,11 @@ var init_dist = __esm({
5179
5655
  init_subject();
5180
5656
  init_task_label_types();
5181
5657
  init_types();
5658
+ init_runtime_observation2();
5182
5659
  init_wechat_types();
5183
5660
  init_ws();
5661
+ init_browser_use_validation();
5662
+ init_browser_use_receipt();
5184
5663
  }
5185
5664
  });
5186
5665
 
@@ -5192,21 +5671,11 @@ var init_fork_state = __esm({
5192
5671
  }
5193
5672
  });
5194
5673
 
5195
- // ts/agent-core/dist/redact.js
5196
- function redactSecrets(s, knownValues = []) {
5197
- return maskKnownValues(s, knownValues).replace(/\b(agk|mck|cpk)_[A-Za-z0-9_-]+/g, "$1_***").replace(/\b(sk|pk|rk)-[A-Za-z0-9_-]{8,}/g, "$1-***").replace(/\bAKIA[0-9A-Z]{16}\b/g, "AKIA***").replace(/\b((?:bearer|basic)\s+)[A-Za-z0-9._~+/=-]+/gi, "$1***").replace(/(\b(?:[\w-]*[_-])?(?:api[_-]?key|key|token|secret|password|passwd|authorization)["']?\s*[=:]\s*)(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|[^\s&;,}\]"']+)/gi, "$1***").replace(/[A-Za-z0-9_-]{32,}/g, "***");
5198
- }
5199
- function maskKnownValues(s, knownValues) {
5200
- let out = s;
5201
- for (const v of knownValues) {
5202
- if (typeof v === "string" && v.length >= 6)
5203
- out = out.split(v).join("***");
5204
- }
5205
- return out;
5206
- }
5207
- var init_redact = __esm({
5208
- "ts/agent-core/dist/redact.js"() {
5674
+ // ts/agent-core/dist/gateway-steer.js
5675
+ var init_gateway_steer = __esm({
5676
+ "ts/agent-core/dist/gateway-steer.js"() {
5209
5677
  "use strict";
5678
+ init_fork_prefix();
5210
5679
  }
5211
5680
  });
5212
5681
 
@@ -5227,6 +5696,39 @@ var init_lane_target = __esm({
5227
5696
  }
5228
5697
  });
5229
5698
 
5699
+ // ts/agent-core/dist/lane-outcome.js
5700
+ var init_lane_outcome = __esm({
5701
+ "ts/agent-core/dist/lane-outcome.js"() {
5702
+ "use strict";
5703
+ }
5704
+ });
5705
+
5706
+ // ts/agent-core/dist/runtime-instance.js
5707
+ var init_runtime_instance = __esm({
5708
+ "ts/agent-core/dist/runtime-instance.js"() {
5709
+ "use strict";
5710
+ }
5711
+ });
5712
+
5713
+ // ts/agent-core/dist/lane-input-receipts.js
5714
+ var init_lane_input_receipts = __esm({
5715
+ "ts/agent-core/dist/lane-input-receipts.js"() {
5716
+ "use strict";
5717
+ init_dist();
5718
+ init_lane_outcome();
5719
+ init_redact();
5720
+ init_runtime_instance();
5721
+ }
5722
+ });
5723
+
5724
+ // ts/agent-core/dist/lane-confirmations.js
5725
+ var init_lane_confirmations = __esm({
5726
+ "ts/agent-core/dist/lane-confirmations.js"() {
5727
+ "use strict";
5728
+ init_dist();
5729
+ }
5730
+ });
5731
+
5230
5732
  // ts/agent-core/dist/lane-ledger.js
5231
5733
  var init_lane_ledger = __esm({
5232
5734
  "ts/agent-core/dist/lane-ledger.js"() {
@@ -5235,6 +5737,10 @@ var init_lane_ledger = __esm({
5235
5737
  init_lane_key();
5236
5738
  init_lane_target();
5237
5739
  init_redact();
5740
+ init_lane_input_receipts();
5741
+ init_lane_outcome();
5742
+ init_lane_confirmations();
5743
+ init_runtime_instance();
5238
5744
  }
5239
5745
  });
5240
5746
 
@@ -12348,12 +12854,12 @@ var require_longbits = __commonJS({
12348
12854
  return util.Long ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned)) : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
12349
12855
  };
12350
12856
  var charCodeAt = String.prototype.charCodeAt;
12351
- LongBits.fromHash = function fromHash(hash) {
12352
- if (hash === zeroHash)
12857
+ LongBits.fromHash = function fromHash(hash2) {
12858
+ if (hash2 === zeroHash)
12353
12859
  return zero;
12354
12860
  return new LongBits(
12355
- (charCodeAt.call(hash, 0) | charCodeAt.call(hash, 1) << 8 | charCodeAt.call(hash, 2) << 16 | charCodeAt.call(hash, 3) << 24) >>> 0,
12356
- (charCodeAt.call(hash, 4) | charCodeAt.call(hash, 5) << 8 | charCodeAt.call(hash, 6) << 16 | charCodeAt.call(hash, 7) << 24) >>> 0
12861
+ (charCodeAt.call(hash2, 0) | charCodeAt.call(hash2, 1) << 8 | charCodeAt.call(hash2, 2) << 16 | charCodeAt.call(hash2, 3) << 24) >>> 0,
12862
+ (charCodeAt.call(hash2, 4) | charCodeAt.call(hash2, 5) << 8 | charCodeAt.call(hash2, 6) << 16 | charCodeAt.call(hash2, 7) << 24) >>> 0
12357
12863
  );
12358
12864
  };
12359
12865
  LongBits.prototype.toHash = function toHash() {
@@ -12459,8 +12965,8 @@ var require_minimal = __commonJS({
12459
12965
  util.longToHash = function longToHash(value) {
12460
12966
  return value ? util.LongBits.from(value).toHash() : util.LongBits.zeroHash;
12461
12967
  };
12462
- util.longFromHash = function longFromHash(hash, unsigned) {
12463
- var bits = util.LongBits.fromHash(hash);
12968
+ util.longFromHash = function longFromHash(hash2, unsigned) {
12969
+ var bits = util.LongBits.fromHash(hash2);
12464
12970
  if (util.Long)
12465
12971
  return util.Long.fromBits(bits.lo, bits.hi, unsigned);
12466
12972
  return bits.toNumber(Boolean(unsigned));
@@ -24313,15 +24819,15 @@ var require_HashMap = __commonJS({
24313
24819
  return this._valueMap.get(hashCode);
24314
24820
  }
24315
24821
  getOrDefault(key, defaultFactory) {
24316
- const hash = this._hash(key);
24317
- if (this._valueMap.has(hash)) {
24318
- return this._valueMap.get(hash);
24822
+ const hash2 = this._hash(key);
24823
+ if (this._valueMap.has(hash2)) {
24824
+ return this._valueMap.get(hash2);
24319
24825
  }
24320
24826
  const val = defaultFactory();
24321
- if (!this._keyMap.has(hash)) {
24322
- this._keyMap.set(hash, key);
24827
+ if (!this._keyMap.has(hash2)) {
24828
+ this._keyMap.set(hash2, key);
24323
24829
  }
24324
- this._valueMap.set(hash, val);
24830
+ this._valueMap.set(hash2, val);
24325
24831
  return val;
24326
24832
  }
24327
24833
  set(key, value, hashCode) {
@@ -24523,13 +25029,13 @@ var require_TemporalMetricProcessor = __commonJS({
24523
25029
  const iterator = current.entries();
24524
25030
  let next = iterator.next();
24525
25031
  while (next.done !== true) {
24526
- const [key, record, hash] = next.value;
24527
- if (last.has(key, hash)) {
24528
- const lastAccumulation = last.get(key, hash);
25032
+ const [key, record, hash2] = next.value;
25033
+ if (last.has(key, hash2)) {
25034
+ const lastAccumulation = last.get(key, hash2);
24529
25035
  const accumulation = aggregator.merge(lastAccumulation, record);
24530
- result.set(key, accumulation, hash);
25036
+ result.set(key, accumulation, hash2);
24531
25037
  } else {
24532
- result.set(key, record, hash);
25038
+ result.set(key, record, hash2);
24533
25039
  }
24534
25040
  next = iterator.next();
24535
25041
  }
@@ -24540,8 +25046,8 @@ var require_TemporalMetricProcessor = __commonJS({
24540
25046
  * the new stream to be the initial observation time unchanged.
24541
25047
  */
24542
25048
  static calibrateStartTime(last, current, lastCollectionTime) {
24543
- for (const [key, hash] of last.keys()) {
24544
- const currentAccumulation = current.get(key, hash);
25049
+ for (const [key, hash2] of last.keys()) {
25050
+ const currentAccumulation = current.get(key, hash2);
24545
25051
  currentAccumulation === null || currentAccumulation === void 0 ? void 0 : currentAccumulation.setStartTime(lastCollectionTime);
24546
25052
  }
24547
25053
  return current;
@@ -32323,9 +32829,11 @@ var init_gateway_lane_flow = __esm({
32323
32829
  init_dist();
32324
32830
  init_change_source();
32325
32831
  init_fork_prefix();
32832
+ init_gateway_steer();
32326
32833
  init_lane_ledger();
32327
32834
  init_lane_target();
32328
32835
  init_telemetry();
32836
+ init_gateway_steer();
32329
32837
  TYPED_BACKOFF_CAP_MS = 5 * 6e4;
32330
32838
  }
32331
32839
  });
@@ -32344,6 +32852,7 @@ var init_gateway_runtime_turns = __esm({
32344
32852
  init_dispatch_adapter();
32345
32853
  init_redact();
32346
32854
  init_telemetry();
32855
+ init_runtime_observation();
32347
32856
  }
32348
32857
  });
32349
32858
 
@@ -32420,13 +32929,15 @@ var init_session_state = __esm({
32420
32929
  });
32421
32930
 
32422
32931
  // ts/agent-core/dist/gateway-base.js
32932
+ var AUTH_INVALID_EXIT_CODE;
32423
32933
  var init_gateway_base = __esm({
32424
32934
  "ts/agent-core/dist/gateway-base.js"() {
32425
32935
  "use strict";
32936
+ init_gateway_runtime_step();
32937
+ init_dispatch_recovery();
32426
32938
  init_change_source();
32427
32939
  init_dist();
32428
32940
  init_fork_prefix();
32429
- init_dispatch_adapter();
32430
32941
  init_fork_state();
32431
32942
  init_gateway_lane_flow();
32432
32943
  init_gateway_idle_compact();
@@ -32445,6 +32956,8 @@ var init_gateway_base = __esm({
32445
32956
  init_session_state();
32446
32957
  init_bridge_workspace();
32447
32958
  init_telemetry();
32959
+ init_gateway_steer();
32960
+ AUTH_INVALID_EXIT_CODE = 86;
32448
32961
  }
32449
32962
  });
32450
32963
 
@@ -46297,7 +46810,7 @@ var require_snapshot_recorder = __commonJS({
46297
46810
  return;
46298
46811
  }
46299
46812
  const request3 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
46300
- const hash = createRequestHash(request3);
46813
+ const hash2 = createRequestHash(request3);
46301
46814
  const normalizedHeaders = normalizeHeaders(response.headers);
46302
46815
  const responseData = {
46303
46816
  statusCode: response.statusCode,
@@ -46305,16 +46818,16 @@ var require_snapshot_recorder = __commonJS({
46305
46818
  body: Buffer.isBuffer(response.body) ? response.body.toString("base64") : Buffer.from(String(response.body || "")).toString("base64"),
46306
46819
  trailers: response.trailers
46307
46820
  };
46308
- if (this.#snapshots.size >= this.#maxSnapshots && !this.#snapshots.has(hash)) {
46821
+ if (this.#snapshots.size >= this.#maxSnapshots && !this.#snapshots.has(hash2)) {
46309
46822
  const oldestKey = this.#snapshots.keys().next().value;
46310
46823
  this.#snapshots.delete(oldestKey);
46311
46824
  }
46312
- const existingSnapshot = this.#snapshots.get(hash);
46825
+ const existingSnapshot = this.#snapshots.get(hash2);
46313
46826
  if (existingSnapshot && existingSnapshot.responses) {
46314
46827
  existingSnapshot.responses.push(responseData);
46315
46828
  existingSnapshot.timestamp = (/* @__PURE__ */ new Date()).toISOString();
46316
46829
  } else {
46317
- this.#snapshots.set(hash, {
46830
+ this.#snapshots.set(hash2, {
46318
46831
  request: request3,
46319
46832
  responses: [responseData],
46320
46833
  // Always store as array for consistency
@@ -46350,8 +46863,8 @@ var require_snapshot_recorder = __commonJS({
46350
46863
  return void 0;
46351
46864
  }
46352
46865
  const request3 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
46353
- const hash = createRequestHash(request3);
46354
- const snapshot = this.#snapshots.get(hash);
46866
+ const hash2 = createRequestHash(request3);
46867
+ const snapshot = this.#snapshots.get(hash2);
46355
46868
  if (!snapshot) return void 0;
46356
46869
  const currentCallCount = snapshot.callCount || 0;
46357
46870
  const responseIndex = Math.min(currentCallCount, snapshot.responses.length - 1);
@@ -46376,8 +46889,8 @@ var require_snapshot_recorder = __commonJS({
46376
46889
  const parsed = JSON.parse(data);
46377
46890
  if (Array.isArray(parsed)) {
46378
46891
  this.#snapshots.clear();
46379
- for (const { hash, snapshot } of parsed) {
46380
- this.#snapshots.set(hash, snapshot);
46892
+ for (const { hash: hash2, snapshot } of parsed) {
46893
+ this.#snapshots.set(hash2, snapshot);
46381
46894
  }
46382
46895
  } else {
46383
46896
  this.#snapshots = new Map(Object.entries(parsed));
@@ -46403,8 +46916,8 @@ var require_snapshot_recorder = __commonJS({
46403
46916
  }
46404
46917
  const resolvedPath = resolve9(path27);
46405
46918
  await mkdir2(dirname14(resolvedPath), { recursive: true });
46406
- const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
46407
- hash,
46919
+ const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
46920
+ hash: hash2,
46408
46921
  snapshot
46409
46922
  }));
46410
46923
  await writeFile2(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
@@ -46446,8 +46959,8 @@ var require_snapshot_recorder = __commonJS({
46446
46959
  */
46447
46960
  deleteSnapshot(requestOpts) {
46448
46961
  const request3 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
46449
- const hash = createRequestHash(request3);
46450
- return this.#snapshots.delete(hash);
46962
+ const hash2 = createRequestHash(request3);
46963
+ return this.#snapshots.delete(hash2);
46451
46964
  }
46452
46965
  /**
46453
46966
  * Gets information about a specific snapshot
@@ -46456,11 +46969,11 @@ var require_snapshot_recorder = __commonJS({
46456
46969
  */
46457
46970
  getSnapshotInfo(requestOpts) {
46458
46971
  const request3 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
46459
- const hash = createRequestHash(request3);
46460
- const snapshot = this.#snapshots.get(hash);
46972
+ const hash2 = createRequestHash(request3);
46973
+ const snapshot = this.#snapshots.get(hash2);
46461
46974
  if (!snapshot) return null;
46462
46975
  return {
46463
- hash,
46976
+ hash: hash2,
46464
46977
  request: snapshot.request,
46465
46978
  responseCount: snapshot.responses ? snapshot.responses.length : snapshot.response ? 1 : 0,
46466
46979
  // .response for legacy snapshots
@@ -46476,8 +46989,8 @@ var require_snapshot_recorder = __commonJS({
46476
46989
  replaceSnapshots(snapshotData) {
46477
46990
  this.#snapshots.clear();
46478
46991
  if (Array.isArray(snapshotData)) {
46479
- for (const { hash, snapshot } of snapshotData) {
46480
- this.#snapshots.set(hash, snapshot);
46992
+ for (const { hash: hash2, snapshot } of snapshotData) {
46993
+ this.#snapshots.set(hash2, snapshot);
46481
46994
  }
46482
46995
  } else if (snapshotData && typeof snapshotData === "object") {
46483
46996
  this.#snapshots = new Map(Object.entries(snapshotData));
@@ -58065,6 +58578,13 @@ var init_codex_message_delivery = __esm({
58065
58578
  }
58066
58579
  });
58067
58580
 
58581
+ // ts/agent-core/dist/skills/parall-browser.js
58582
+ var init_parall_browser = __esm({
58583
+ "ts/agent-core/dist/skills/parall-browser.js"() {
58584
+ "use strict";
58585
+ }
58586
+ });
58587
+
58068
58588
  // ts/agent-core/dist/skills/parall-platform.js
58069
58589
  var init_parall_platform = __esm({
58070
58590
  "ts/agent-core/dist/skills/parall-platform.js"() {
@@ -58118,6 +58638,8 @@ var init_parall_clip_authoring = __esm({
58118
58638
  var init_skills = __esm({
58119
58639
  "ts/agent-core/dist/skills/index.js"() {
58120
58640
  "use strict";
58641
+ init_parall_browser();
58642
+ init_parall_browser();
58121
58643
  init_parall_platform();
58122
58644
  init_parall_tasks();
58123
58645
  init_parall_wiki();
@@ -58211,6 +58733,7 @@ var init_dist2 = __esm({
58211
58733
  init_channel_capability();
58212
58734
  init_channel_token();
58213
58735
  init_dispatch_adapter();
58736
+ init_runtime_observation();
58214
58737
  init_fork_prefix();
58215
58738
  init_gateway_base();
58216
58739
  init_gateway_idle_compact();
@@ -58225,6 +58748,7 @@ var init_dist2 = __esm({
58225
58748
  init_provider_config();
58226
58749
  init_redact();
58227
58750
  init_routing();
58751
+ init_runtime_instance();
58228
58752
  init_runtime_activity_port();
58229
58753
  init_runtime_turn_base();
58230
58754
  init_session_state();
@@ -59289,11 +59813,6 @@ MCowBQYDK2VwAyEAQHQAZThNX7+deJNyHl/5DgiAa1OHx7UQoJotam0JhUk=
59289
59813
  async doUpdate(targetVersion) {
59290
59814
  const local = this.loadLocalManifest();
59291
59815
  const state = this.loadUpdateState();
59292
- if (state?.pending_version && local?.version === state.pending_version) {
59293
- this.log.info(`update: ${local.version} is still pending activation \u2014 skipping new update until confirmed`);
59294
- this.report("skipped", "pending_activation");
59295
- return false;
59296
- }
59297
59816
  const manifestUrl = targetVersion ? `${this.cdnBaseUrl}/${targetVersion}/manifest.json` : `${this.cdnBaseUrl}/latest/manifest.json`;
59298
59817
  let remoteJson;
59299
59818
  try {
@@ -59361,9 +59880,9 @@ MCowBQYDK2VwAyEAQHQAZThNX7+deJNyHl/5DgiAa1OHx7UQoJotam0JhUk=
59361
59880
  return false;
59362
59881
  }
59363
59882
  const content = fs4.readFileSync(filePath);
59364
- const hash = createHash("sha256").update(content).digest("hex");
59365
- if (hash !== meta.sha256) {
59366
- this.log.error(`update: sha256 mismatch for ${filename} (expected ${meta.sha256}, got ${hash})`);
59883
+ const hash2 = createHash("sha256").update(content).digest("hex");
59884
+ if (hash2 !== meta.sha256) {
59885
+ this.log.error(`update: sha256 mismatch for ${filename} (expected ${meta.sha256}, got ${hash2})`);
59367
59886
  this.cleanDir(stagingDir);
59368
59887
  this.report("failed", "sha256_mismatch");
59369
59888
  return false;
@@ -65518,10 +66037,10 @@ function verifyChecksum(filePath, algo, expectedHex) {
65518
66037
  console.warn(`[clip-installer] WARNING: no checksum provided by registry \u2014 installing without integrity verification`);
65519
66038
  return;
65520
66039
  }
65521
- const hash = crypto.createHash(algo);
66040
+ const hash2 = crypto.createHash(algo);
65522
66041
  const content = fs8.readFileSync(filePath);
65523
- hash.update(content);
65524
- const actual = hash.digest("hex");
66042
+ hash2.update(content);
66043
+ const actual = hash2.digest("hex");
65525
66044
  if (actual !== expectedHex) {
65526
66045
  throw new Error(`checksum mismatch for ${path14.basename(filePath)}: expected ${algo}:${expectedHex}, got ${algo}:${actual}`);
65527
66046
  }
@@ -70859,7 +71378,7 @@ function sleepCancellable(ms, signal) {
70859
71378
  signal.addEventListener("abort", onAbort, { once: true });
70860
71379
  });
70861
71380
  }
70862
- var RUNTIME_PACKAGES, WORKSPACE_SETUP_RETRY_DELAY_MS, AGENT_CONFIG_REFRESH_RETRY_DELAY_MS, CLIP_RECONCILE_INTERVAL_MS, RUNTIME_DETECT_INTERVAL_MS, DaemonSupervisor;
71381
+ var RUNTIME_PACKAGES, WORKSPACE_SETUP_RETRY_DELAY_MS, PARK_KEEPALIVE_MS, AGENT_CONFIG_REFRESH_RETRY_DELAY_MS, CLIP_RECONCILE_INTERVAL_MS, RUNTIME_DETECT_INTERVAL_MS, DaemonSupervisor;
70863
71382
  var init_supervisor = __esm({
70864
71383
  "ts/daemon/dist/supervisor.js"() {
70865
71384
  "use strict";
@@ -70889,6 +71408,7 @@ var init_supervisor = __esm({
70889
71408
  openclaw: "@parall/openclaw-agent"
70890
71409
  };
70891
71410
  WORKSPACE_SETUP_RETRY_DELAY_MS = 5e3;
71411
+ PARK_KEEPALIVE_MS = 6e4;
70892
71412
  AGENT_CONFIG_REFRESH_RETRY_DELAY_MS = 5e3;
70893
71413
  CLIP_RECONCILE_INTERVAL_MS = 5 * 6e4;
70894
71414
  RUNTIME_DETECT_INTERVAL_MS = 5 * 6e4;
@@ -71015,6 +71535,7 @@ var init_supervisor = __esm({
71015
71535
  if (this.running)
71016
71536
  throw new Error("supervisor already running");
71017
71537
  this.running = true;
71538
+ this.healthGate?.onSupervisorStarted();
71018
71539
  const onAbort = () => {
71019
71540
  this.stop().catch((err) => this.log.error(`stop() failed: ${String(err)}`));
71020
71541
  };
@@ -71023,11 +71544,13 @@ var init_supervisor = __esm({
71023
71544
  if (!await this.bootstrapWithRetry(signal)) {
71024
71545
  signal.removeEventListener("abort", onAbort);
71025
71546
  this.running = false;
71547
+ this.healthGate?.onSupervisorEnded();
71026
71548
  return;
71027
71549
  }
71028
71550
  } catch (err) {
71029
71551
  signal.removeEventListener("abort", onAbort);
71030
71552
  this.running = false;
71553
+ this.healthGate?.onSupervisorEnded();
71031
71554
  throw err;
71032
71555
  }
71033
71556
  this.migrateFlatLayout();
@@ -71084,7 +71607,6 @@ var init_supervisor = __esm({
71084
71607
  this.log.info(`machine WS connected (machine.hello)${skewMs === null ? "" : ` skew=${skewMs}ms`}`);
71085
71608
  if (skewMs !== null)
71086
71609
  this.daemonTelemetry?.recordClockSkew(skewMs);
71087
- this.healthGate?.onMachineHello();
71088
71610
  void this.launch.replayAll();
71089
71611
  void (async () => {
71090
71612
  await this.refreshMachineConfig();
@@ -71156,13 +71678,16 @@ var init_supervisor = __esm({
71156
71678
  void this.enqueueBrowserProfileOp(data.profile_id, () => handleBrowserProfileViewerCommand({ pool: this.browserProfilePool, client: this.client, log: this.log }, data));
71157
71679
  });
71158
71680
  this.ws.onStateChange((state, detail) => {
71159
- if (state === "disconnected" || state === "reconnecting") {
71681
+ if (state === "disconnected" || state === "reconnecting" || state === "auth-invalid") {
71160
71682
  this.log.warn(`machine WS state: ${state}${describeWsStateDetail(detail)}`);
71161
71683
  }
71162
71684
  if (state === "reconnecting") {
71163
71685
  this.daemonTelemetry?.recordWsReconnect({ cause: detail?.cause, closeCode: detail?.code });
71164
71686
  }
71165
71687
  });
71688
+ this.ws.onAuthInvalid((event) => {
71689
+ this.log.error(`machine WS auth-invalid: the server rejected this machine's key (status ${event.status}${event.code ? `, code ${event.code}` : ""}) \u2014 ${event.message}. Control-plane events (attach/detach, config updates, update signals) are OFFLINE and reconnects are stopped. Re-register or re-authenticate this machine (Desktop app or \`parall-daemon register\`) to install a new machine key, then restart the daemon.`);
71690
+ });
71166
71691
  await this.ws.connect();
71167
71692
  await new Promise((resolve9) => {
71168
71693
  this.stopResolve = resolve9;
@@ -71244,6 +71769,23 @@ var init_supervisor = __esm({
71244
71769
  this.log.info(`daemon online \u2014 machine_id=${machine.id} org=${machine.org_id} label=${machine.label}`);
71245
71770
  return true;
71246
71771
  } catch (err) {
71772
+ if (err instanceof ApiError && err.status === 401) {
71773
+ this.log.error(`machine key rejected by the server (status 401${err.code ? `, code ${err.code}` : ""}): ${err.message}. The daemon cannot start with this machine key and no automatic recovery exists \u2014 re-register or re-authenticate this machine (Desktop app or \`parall-daemon register\`) to install a new machine key, then restart the daemon.`);
71774
+ const parked = setInterval(() => {
71775
+ }, PARK_KEEPALIVE_MS);
71776
+ try {
71777
+ await new Promise((resolve9) => {
71778
+ if (signal.aborted) {
71779
+ resolve9();
71780
+ return;
71781
+ }
71782
+ signal.addEventListener("abort", () => resolve9(), { once: true });
71783
+ });
71784
+ } finally {
71785
+ clearInterval(parked);
71786
+ }
71787
+ return false;
71788
+ }
71247
71789
  if (this.config.bootstrapBackoffMs === 0) {
71248
71790
  this.log.error(`getMachineSelf failed: ${String(err)} (fail-fast mode)`);
71249
71791
  throw err;
@@ -72113,7 +72655,7 @@ var init_supervisor = __esm({
72113
72655
  this.agentConfigRefreshRetryTimers.delete(agentId);
72114
72656
  }
72115
72657
  }
72116
- async restartChildNow(state, reason) {
72658
+ async restartChildNow(state, reason, opts) {
72117
72659
  if (!this.running || state.shuttingDown || state.child || state.restartTimer) {
72118
72660
  return;
72119
72661
  }
@@ -72123,7 +72665,9 @@ var init_supervisor = __esm({
72123
72665
  this.restartingStates.add(state);
72124
72666
  try {
72125
72667
  state.credential = await this.client.mintLaunchCredential(state.agentId);
72126
- state.restartAttempts = 0;
72668
+ if (!opts?.preserveRestartBackoff) {
72669
+ state.restartAttempts = 0;
72670
+ }
72127
72671
  this.log.info(`agent ${state.agentId}: restarting child (${reason})`);
72128
72672
  this.startChild(state);
72129
72673
  } catch (err) {
@@ -72136,7 +72680,7 @@ var init_supervisor = __esm({
72136
72680
  this.log.warn(`agent ${state.agentId}: will retry restart in ${delay}ms`);
72137
72681
  state.restartTimer = setTimeout(() => {
72138
72682
  state.restartTimer = null;
72139
- void this.restartChildNow(state, reason);
72683
+ void this.restartChildNow(state, reason, opts);
72140
72684
  }, delay);
72141
72685
  }
72142
72686
  void this.launch.update(state.agentId, restartMintFailedReport(err, state.restartAttempts, retrying));
@@ -72335,6 +72879,10 @@ var init_supervisor = __esm({
72335
72879
  this.launch.forget(state.agentId);
72336
72880
  return;
72337
72881
  }
72882
+ const authInvalidExit = event === "exit" && code === AUTH_INVALID_EXIT_CODE;
72883
+ if (authInvalidExit) {
72884
+ this.log.warn(`agent ${state.agentId}: runtime reports the server rejected its launch credential (exit ${AUTH_INVALID_EXIT_CODE}) \u2014 the key was revoked, rotated, or expired. A fresh launch credential will be minted before the next start.`);
72885
+ }
72338
72886
  const delay = Math.min(this.config.restartBackoffMs * 2 ** state.restartAttempts, this.config.restartBackoffMaxMs);
72339
72887
  state.restartAttempts += 1;
72340
72888
  this.log.warn(`agent ${state.agentId} will restart in ${delay}ms`);
@@ -72348,7 +72896,13 @@ var init_supervisor = __esm({
72348
72896
  }));
72349
72897
  state.restartTimer = setTimeout(() => {
72350
72898
  state.restartTimer = null;
72351
- this.startChild(state);
72899
+ if (authInvalidExit) {
72900
+ void this.restartChildNow(state, "credential rejected (auth-invalid exit)", {
72901
+ preserveRestartBackoff: true
72902
+ });
72903
+ } else {
72904
+ this.startChild(state);
72905
+ }
72352
72906
  }, delay);
72353
72907
  };
72354
72908
  child.once("error", (err) => {
@@ -72428,11 +72982,11 @@ var init_update_health_gate = __esm({
72428
72982
  this.timers = timers;
72429
72983
  }
72430
72984
  /**
72431
- * Control-plane handshake. Arms the stability timer on the first hello that
72432
- * sees a pending (unconfirmed) update. No-op once confirmed, while a timer is
72985
+ * A supervisor instance started. Arms the stability timer when there is a
72986
+ * pending (unconfirmed) update. No-op once confirmed, while a timer is
72433
72987
  * already running, or when there is nothing pending to confirm.
72434
72988
  */
72435
- onMachineHello() {
72989
+ onSupervisorStarted() {
72436
72990
  if (this.confirmed || this.timer)
72437
72991
  return;
72438
72992
  if (!this.updater.hasPendingActivation())
@@ -72451,7 +73005,7 @@ var init_update_health_gate = __esm({
72451
73005
  * The current supervisor instance ended — a clean shutdown or a
72452
73006
  * runForever-caught soft crash. Reset the health window (cancel the pending
72453
73007
  * confirm timer) without recording any rollback failure; the next supervisor
72454
- * re-arms via `onMachineHello`.
73008
+ * re-arms via `onSupervisorStarted`.
72455
73009
  */
72456
73010
  onSupervisorEnded() {
72457
73011
  if (this.timer) {