@parall/daemon 1.63.0 → 1.64.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.
- package/bundle/manifest.json +11 -11
- package/bundle/parall-browser-pod.js +97 -97
- package/bundle/parall-claude-agent.js +863 -319
- package/bundle/parall-codex-agent.js +815 -302
- package/bundle/parall-daemon.js +626 -169
- package/dist/config.d.ts +5 -5
- package/dist/daemon-telemetry.d.ts +1 -1
- package/dist/daemon-telemetry.d.ts.map +1 -1
- package/dist/supervisor.d.ts.map +1 -1
- package/dist/supervisor.js +95 -10
- package/dist/update-health-gate.d.ts +18 -14
- package/dist/update-health-gate.d.ts.map +1 -1
- package/dist/update-health-gate.js +18 -14
- package/dist/updater.d.ts.map +1 -1
- package/dist/updater.js +5 -9
- package/package.json +6 -6
package/bundle/parall-daemon.js
CHANGED
|
@@ -155,6 +155,13 @@ var init_fork_prefix = __esm({
|
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
+
// ts/agent-core/dist/dispatch-recovery.js
|
|
159
|
+
var init_dispatch_recovery = __esm({
|
|
160
|
+
"ts/agent-core/dist/dispatch-recovery.js"() {
|
|
161
|
+
"use strict";
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
158
165
|
// ts/agent-core/dist/change-source.js
|
|
159
166
|
var init_change_source = __esm({
|
|
160
167
|
"ts/agent-core/dist/change-source.js"() {
|
|
@@ -218,6 +225,7 @@ var init_clip_connection_endpoints = __esm({
|
|
|
218
225
|
"ts/sdk/dist/clip-connection-endpoints.js"() {
|
|
219
226
|
"use strict";
|
|
220
227
|
clipConnectionEndpoints = {
|
|
228
|
+
ORG_CLIP_MCP_OAUTH_ATTEMPT: (orgId, clipId, attemptId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-oauth-attempts/${attemptId}`,
|
|
221
229
|
CLIP_CONNECTIONS: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/connections`,
|
|
222
230
|
CLIP_CONNECTION_ACCESS: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}/access`,
|
|
223
231
|
CLIP_CONNECTION: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}`
|
|
@@ -861,6 +869,7 @@ var init_constants = __esm({
|
|
|
861
869
|
TRIGGER: (orgId, triggerId) => `${API_BASE2}/orgs/${orgId}/external-triggers/${triggerId}`,
|
|
862
870
|
/** @deprecated Use TRIGGER. Same compatibility path. */
|
|
863
871
|
EXTERNAL_TRIGGER: (orgId, triggerId) => `${API_BASE2}/orgs/${orgId}/external-triggers/${triggerId}`,
|
|
872
|
+
PLATFORM_TRIGGER_SCHEMA: (orgId) => `${API_BASE2}/orgs/${orgId}/platform-trigger-schema`,
|
|
864
873
|
TRIGGER_RUNS: (orgId) => `${API_BASE2}/orgs/${orgId}/external-trigger-runs`,
|
|
865
874
|
/** @deprecated Use TRIGGER_RUNS. Same compatibility path. */
|
|
866
875
|
EXTERNAL_TRIGGER_RUNS: (orgId) => `${API_BASE2}/orgs/${orgId}/external-trigger-runs`,
|
|
@@ -1038,6 +1047,8 @@ var init_constants = __esm({
|
|
|
1038
1047
|
BILLING_CHECKOUT: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/checkout`,
|
|
1039
1048
|
BILLING_AUTO_RELOAD: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/auto-reload`,
|
|
1040
1049
|
BILLING_SETUP_INTENT: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/setup-intent`,
|
|
1050
|
+
BILLING_USAGE_DAILY: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/usage-daily`,
|
|
1051
|
+
BILLING_USAGE_HEATMAP: (orgId) => `${API_BASE2}/orgs/${orgId}/billing/usage-heatmap`,
|
|
1041
1052
|
COMPUTE_PRICING: () => `${API_BASE2}/billing/compute-pricing`,
|
|
1042
1053
|
// Runtime capability table (public, no auth) — SSOT for the create/settings
|
|
1043
1054
|
// interlock: per-runtime compute modes, native model family, cross-family
|
|
@@ -1072,16 +1083,6 @@ var init_constants = __esm({
|
|
|
1072
1083
|
BROWSER_PROFILE_VIEWER_COMMAND: (orgId, profileId) => `${API_BASE2}/orgs/${orgId}/browser-profiles/${profileId}/viewer/command`,
|
|
1073
1084
|
// Edge device endpoints
|
|
1074
1085
|
...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
1086
|
ORG_BROWSER_USE_OPERATIONS: (orgId) => `/api/v1/orgs/${orgId}/browser-use/operations`,
|
|
1086
1087
|
ORG_BROWSER_USE_OPERATION: (orgId, operationId) => `/api/v1/orgs/${orgId}/browser-use/operations/${encodeURIComponent(operationId)}`,
|
|
1087
1088
|
// Per-profile egress proxy (hosted Cloud Profiles; manager-only, human-only).
|
|
@@ -1707,6 +1708,20 @@ var init_clip_connection_client = __esm({
|
|
|
1707
1708
|
async putClipConnectionAccess(orgId, connId, input) {
|
|
1708
1709
|
return this.request("PUT", ENDPOINTS.CLIP_CONNECTION_ACCESS(orgId, connId), input);
|
|
1709
1710
|
}
|
|
1711
|
+
/** Start OAuth using the reviewed platform app or provider registration ladder.
|
|
1712
|
+
* Allow discovery (30s), persistence (10s), and network overhead to finish. */
|
|
1713
|
+
async createClipMCPOAuthConnection(orgId, clipId, serverUrl, alias, oauthClient) {
|
|
1714
|
+
return this.request("POST", ENDPOINTS.ORG_CLIP_MCP_CONFIGS(orgId, clipId), {
|
|
1715
|
+
server_url: serverUrl,
|
|
1716
|
+
auth_type: "oauth",
|
|
1717
|
+
...alias ? { alias } : {},
|
|
1718
|
+
...oauthClient ? { oauth_client: oauthClient } : {}
|
|
1719
|
+
}, void 0, false, { timeoutMs: 5e4 });
|
|
1720
|
+
}
|
|
1721
|
+
/** Cancel exactly one pending attempt; requires its initiator or an org admin. */
|
|
1722
|
+
async cancelClipMCPOAuthAttempt(orgId, clipId, attemptId) {
|
|
1723
|
+
return this.request("DELETE", ENDPOINTS.ORG_CLIP_MCP_OAUTH_ATTEMPT(orgId, clipId, attemptId));
|
|
1724
|
+
}
|
|
1710
1725
|
};
|
|
1711
1726
|
}
|
|
1712
1727
|
});
|
|
@@ -1719,6 +1734,44 @@ var init_browser_profile_client = __esm({
|
|
|
1719
1734
|
init_clip_connection_client();
|
|
1720
1735
|
init_constants();
|
|
1721
1736
|
BrowserProfileClient = class extends ClipConnectionClient {
|
|
1737
|
+
/** Metadata-only compatibility discovery. Management scope errors propagate;
|
|
1738
|
+
* callers with a known Profile can execute without this discovery chain. */
|
|
1739
|
+
async listBrowserUseProfiles(orgId, profileId) {
|
|
1740
|
+
const me = await this.request("GET", ENDPOINTS.USERS_ME);
|
|
1741
|
+
const devices = await this.request("GET", ENDPOINTS.ORG_EDGE_DEVICES(orgId));
|
|
1742
|
+
const data = [];
|
|
1743
|
+
for (const device of devices.data) {
|
|
1744
|
+
const personal = device.managed_by === "member";
|
|
1745
|
+
if (personal && device.owner_user_id !== me.id)
|
|
1746
|
+
continue;
|
|
1747
|
+
const profiles = await this.request("GET", ENDPOINTS.ORG_EDGE_PROFILES(orgId, device.id));
|
|
1748
|
+
for (const profile of profiles) {
|
|
1749
|
+
if (profileId && profile.id !== profileId)
|
|
1750
|
+
continue;
|
|
1751
|
+
const access = personal ? null : await this.getBrowserProfileAccess(orgId, device.id, profile.name);
|
|
1752
|
+
if (!personal && !access?.org_public && !(access?.grants ?? []).some((g) => g.user_id === me.id && g.grants.length > 0))
|
|
1753
|
+
continue;
|
|
1754
|
+
data.push({
|
|
1755
|
+
profile_id: profile.id,
|
|
1756
|
+
name: profile.name,
|
|
1757
|
+
device_name: device.name,
|
|
1758
|
+
placement: device.placement ?? "byoc",
|
|
1759
|
+
lifecycle_state: profile.lifecycle_state,
|
|
1760
|
+
can_access: true,
|
|
1761
|
+
availability: device.placement === "hosted" ? device.hosted_state ?? "unknown" : device.status
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
return { data };
|
|
1766
|
+
}
|
|
1767
|
+
/** Submit once: even refresh-enabled clients must not replay browser actions. */
|
|
1768
|
+
async createBrowserUseOperation(orgId, request3) {
|
|
1769
|
+
return this.request("POST", ENDPOINTS.ORG_BROWSER_USE_OPERATIONS(orgId), request3, void 0, true);
|
|
1770
|
+
}
|
|
1771
|
+
/** Recover proof/data without creating a new browser operation. */
|
|
1772
|
+
async getBrowserUseOperation(orgId, operationId, opts) {
|
|
1773
|
+
return this.request("GET", ENDPOINTS.ORG_BROWSER_USE_OPERATION(orgId, operationId), void 0, void 0, false, opts);
|
|
1774
|
+
}
|
|
1722
1775
|
async getBrowserProfileAccess(orgId, edgeId, profileName) {
|
|
1723
1776
|
return this.request("GET", ENDPOINTS.ORG_EDGE_PROFILE_ACCESS(orgId, edgeId, profileName));
|
|
1724
1777
|
}
|
|
@@ -2220,8 +2273,8 @@ var init_client = __esm({
|
|
|
2220
2273
|
return this.request("POST", ENDPOINTS.AUTH_OAUTH_EXCHANGE, { code });
|
|
2221
2274
|
}
|
|
2222
2275
|
// ---- WebSocket ----
|
|
2223
|
-
async getWsTicket() {
|
|
2224
|
-
return this.request("POST", ENDPOINTS.WS_TICKET);
|
|
2276
|
+
async getWsTicket(req) {
|
|
2277
|
+
return this.request("POST", ENDPOINTS.WS_TICKET, req);
|
|
2225
2278
|
}
|
|
2226
2279
|
// ---- Users ----
|
|
2227
2280
|
async getMe() {
|
|
@@ -3208,8 +3261,8 @@ var init_client = __esm({
|
|
|
3208
3261
|
* no_action sweep otherwise. Idempotent.
|
|
3209
3262
|
*
|
|
3210
3263
|
* @deprecated Legacy ok-only alias — use {@link completeDispatch} with the
|
|
3211
|
-
* `sources` form, which also carries `turn_outcome`.
|
|
3212
|
-
*
|
|
3264
|
+
* `sources` form, which also carries `turn_outcome`. Retirement conditions:
|
|
3265
|
+
* agent-dispatch-idempotency-design.md#compatibility.
|
|
3213
3266
|
*/
|
|
3214
3267
|
async completeDispatchSources(orgId, req) {
|
|
3215
3268
|
return this.request("POST", ENDPOINTS.DISPATCH_COMPLETE_SOURCES(orgId), req);
|
|
@@ -3452,6 +3505,9 @@ var init_client = __esm({
|
|
|
3452
3505
|
async getTriggerSchema(orgId, connectionId) {
|
|
3453
3506
|
return this.request("GET", ENDPOINTS.TRIGGER_SCHEMA(orgId, connectionId));
|
|
3454
3507
|
}
|
|
3508
|
+
async getPlatformTriggerSchema(orgId, eventTypes) {
|
|
3509
|
+
return this.request("GET", ENDPOINTS.PLATFORM_TRIGGER_SCHEMA(orgId), void 0, eventTypes && eventTypes.length > 0 ? { event_types: eventTypes.join(",") } : void 0);
|
|
3510
|
+
}
|
|
3455
3511
|
async listTriggerIngressEvents(orgId, filters) {
|
|
3456
3512
|
return this.request("GET", ENDPOINTS.TRIGGER_INGRESS_EVENTS(orgId), void 0, filters);
|
|
3457
3513
|
}
|
|
@@ -3553,8 +3609,8 @@ var init_client = __esm({
|
|
|
3553
3609
|
return url;
|
|
3554
3610
|
return `${this.baseUrlFor(url)}${url}`;
|
|
3555
3611
|
}
|
|
3556
|
-
async getWikiBlob(orgId, wikiId, params) {
|
|
3557
|
-
const blob = await this.request("GET", ENDPOINTS.WIKI_BLOB(orgId, wikiId), void 0, params);
|
|
3612
|
+
async getWikiBlob(orgId, wikiId, params, opts) {
|
|
3613
|
+
const blob = await this.request("GET", ENDPOINTS.WIKI_BLOB(orgId, wikiId), void 0, params, false, opts);
|
|
3558
3614
|
if (blob.signed_url)
|
|
3559
3615
|
blob.signed_url = this.absoluteMediaUrl(blob.signed_url);
|
|
3560
3616
|
return blob;
|
|
@@ -3927,6 +3983,21 @@ var init_client = __esm({
|
|
|
3927
3983
|
async getBilling(orgId) {
|
|
3928
3984
|
return this.request("GET", ENDPOINTS.BILLING(orgId));
|
|
3929
3985
|
}
|
|
3986
|
+
async getUsageDaily(orgId, opts) {
|
|
3987
|
+
const params = new URLSearchParams();
|
|
3988
|
+
params.set("start_date", opts.start_date);
|
|
3989
|
+
params.set("end_date", opts.end_date);
|
|
3990
|
+
return this.request("GET", `${ENDPOINTS.BILLING_USAGE_DAILY(orgId)}?${params}`);
|
|
3991
|
+
}
|
|
3992
|
+
async getUsageHeatmap(orgId, opts) {
|
|
3993
|
+
const params = new URLSearchParams();
|
|
3994
|
+
params.set("start_time", opts.start_time);
|
|
3995
|
+
if (opts.limit != null)
|
|
3996
|
+
params.set("limit", String(opts.limit));
|
|
3997
|
+
if (opts.offset != null)
|
|
3998
|
+
params.set("offset", String(opts.offset));
|
|
3999
|
+
return this.request("GET", `${ENDPOINTS.BILLING_USAGE_HEATMAP(orgId)}?${params}`);
|
|
4000
|
+
}
|
|
3930
4001
|
async listBillingTransactions(orgId, opts) {
|
|
3931
4002
|
const params = new URLSearchParams();
|
|
3932
4003
|
if (opts?.cursor)
|
|
@@ -4096,12 +4167,14 @@ var init_client = __esm({
|
|
|
4096
4167
|
}
|
|
4097
4168
|
// ---- Clip registry (v3, api-server org registry — `crg_` entries) ----
|
|
4098
4169
|
/**
|
|
4099
|
-
* List registry clips visible to the org: its own plus
|
|
4100
|
-
* cross-org entries
|
|
4101
|
-
* connections operate on.
|
|
4170
|
+
* List one page of registry clips visible to the org: its own plus
|
|
4171
|
+
* public+approved cross-org entries, used by installs and connections.
|
|
4102
4172
|
*/
|
|
4103
|
-
async listOrgRegistryClips(orgId) {
|
|
4104
|
-
const
|
|
4173
|
+
async listOrgRegistryClips(orgId, opts) {
|
|
4174
|
+
const params = new URLSearchParams({ limit: String(opts?.limit ?? 100) });
|
|
4175
|
+
if (opts?.offset !== void 0)
|
|
4176
|
+
params.set("offset", String(opts.offset));
|
|
4177
|
+
const resp = await this.request("GET", `${ENDPOINTS.ORG_CLIP_REGISTRY(orgId)}?${params}`);
|
|
4105
4178
|
return resp ?? [];
|
|
4106
4179
|
}
|
|
4107
4180
|
/**
|
|
@@ -4182,7 +4255,6 @@ var init_client = __esm({
|
|
|
4182
4255
|
/**
|
|
4183
4256
|
* Read a clip's per-org exec access (by user id — humans and agents alike).
|
|
4184
4257
|
* 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
4258
|
* `CLIP_AGENT_NOT_ALLOWED` / `CLIP_AGENT_CONNECTION_NOT_ALLOWED`). Writing
|
|
4187
4259
|
* it (`putClipAgentExecAccess`) is an org owner/admin's act.
|
|
4188
4260
|
*/
|
|
@@ -4263,69 +4335,6 @@ var init_client = __esm({
|
|
|
4263
4335
|
async getEdgeProfileOperation(orgId, edgeId, operationId) {
|
|
4264
4336
|
return this.request("GET", ENDPOINTS.ORG_EDGE_PROFILE_OPERATION(orgId, edgeId, operationId));
|
|
4265
4337
|
}
|
|
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
4338
|
/**
|
|
4330
4339
|
* Read a hosted Cloud Profile's egress-proxy status (manager-only: hosted
|
|
4331
4340
|
* human maintainer or org admin). Sanitized — the password never comes back.
|
|
@@ -4435,7 +4444,6 @@ var init_client = __esm({
|
|
|
4435
4444
|
* - `EDGE_HOSTED_DISABLED_FOR_ORG` 403, `EDGE_REPAIR` 503 (operator-held),
|
|
4436
4445
|
* `EDGE_RUNTIME_UNAVAILABLE` 503 (deployment has no hosted runtime).
|
|
4437
4446
|
* - Access errors (before side effects): human `CONNECTION_NOT_ALLOWED`.
|
|
4438
|
-
* `CLIP_NOT_ALLOWED` / `CLIP_CONNECTION_NOT_ALLOWED` are retired.
|
|
4439
4447
|
* Agent principals receive the historical
|
|
4440
4448
|
* `CLIP_AGENT_NOT_ALLOWED` / `CLIP_AGENT_CONNECTION_NOT_ALLOWED` for one
|
|
4441
4449
|
* release. An org owner/admin can widen access in the clip's settings.
|
|
@@ -4519,17 +4527,6 @@ var init_client = __esm({
|
|
|
4519
4527
|
timeoutMs: 4e4
|
|
4520
4528
|
});
|
|
4521
4529
|
}
|
|
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
4530
|
/** Re-authorize an existing MCP credential slot. */
|
|
4534
4531
|
async initiateClipMCPOAuthById(orgId, clipId, configId, serverUrl, expectedVersion, oauthClient) {
|
|
4535
4532
|
const req = {
|
|
@@ -4735,7 +4732,7 @@ function mentionTargetsUser(mentionUserId, userId, userType) {
|
|
|
4735
4732
|
return userType === "agent";
|
|
4736
4733
|
return false;
|
|
4737
4734
|
}
|
|
4738
|
-
var MENTION_ALL_USER_ID, MENTION_ALL_HUMANS_USER_ID, MENTION_ALL_AGENTS_USER_ID, CLI_RUNTIME_TYPES, MACHINE_DIAGNOSTICS_NOTE_MAX_CHARS
|
|
4735
|
+
var MENTION_ALL_USER_ID, MENTION_ALL_HUMANS_USER_ID, MENTION_ALL_AGENTS_USER_ID, CLI_RUNTIME_TYPES, MACHINE_DIAGNOSTICS_NOTE_MAX_CHARS;
|
|
4739
4736
|
var init_types = __esm({
|
|
4740
4737
|
"ts/sdk/dist/types.js"() {
|
|
4741
4738
|
"use strict";
|
|
@@ -4744,18 +4741,6 @@ var init_types = __esm({
|
|
|
4744
4741
|
MENTION_ALL_AGENTS_USER_ID = "allagent";
|
|
4745
4742
|
CLI_RUNTIME_TYPES = ["claude-code", "codex", "openclaw"];
|
|
4746
4743
|
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"
|
|
4758
|
-
];
|
|
4759
4744
|
}
|
|
4760
4745
|
});
|
|
4761
4746
|
|
|
@@ -4784,6 +4769,11 @@ function describeWsStateDetail(detail) {
|
|
|
4784
4769
|
function isRetryableNetworkError(err) {
|
|
4785
4770
|
return err instanceof Error && err.name === "ApiError" && "status" in err && err.status === 0;
|
|
4786
4771
|
}
|
|
4772
|
+
function authRejectionFrom(err) {
|
|
4773
|
+
if (!(err instanceof ApiError) || err.status !== 401)
|
|
4774
|
+
return null;
|
|
4775
|
+
return { status: err.status, code: err.code, message: err.message };
|
|
4776
|
+
}
|
|
4787
4777
|
function isBrowserRuntime() {
|
|
4788
4778
|
return typeof window !== "undefined";
|
|
4789
4779
|
}
|
|
@@ -4791,15 +4781,19 @@ var ParallWs;
|
|
|
4791
4781
|
var init_ws = __esm({
|
|
4792
4782
|
"ts/sdk/dist/ws.js"() {
|
|
4793
4783
|
"use strict";
|
|
4784
|
+
init_client();
|
|
4794
4785
|
init_constants();
|
|
4795
4786
|
ParallWs = class {
|
|
4796
4787
|
ws = null;
|
|
4797
4788
|
options;
|
|
4798
4789
|
listeners = /* @__PURE__ */ new Map();
|
|
4799
4790
|
stateListeners = /* @__PURE__ */ new Set();
|
|
4791
|
+
authInvalidListeners = /* @__PURE__ */ new Set();
|
|
4800
4792
|
heartbeatTimer = null;
|
|
4801
4793
|
reconnectTimer = null;
|
|
4802
4794
|
reconnectAttempts = 0;
|
|
4795
|
+
/** Ticket attempts in the current auth-invalid episode (reset on success). */
|
|
4796
|
+
authAttempts = 0;
|
|
4803
4797
|
lastSeq = 0;
|
|
4804
4798
|
_state = "disconnected";
|
|
4805
4799
|
intentionalClose = false;
|
|
@@ -4812,6 +4806,7 @@ var init_ws = __esm({
|
|
|
4812
4806
|
reconnect: true,
|
|
4813
4807
|
reconnectInterval: 1e3,
|
|
4814
4808
|
maxReconnectInterval: 3e4,
|
|
4809
|
+
maxAuthAttempts: 3,
|
|
4815
4810
|
...options
|
|
4816
4811
|
};
|
|
4817
4812
|
this.lastSeq = options.lastSeq ?? 0;
|
|
@@ -4821,12 +4816,25 @@ var init_ws = __esm({
|
|
|
4821
4816
|
}
|
|
4822
4817
|
async connect() {
|
|
4823
4818
|
this.intentionalClose = false;
|
|
4819
|
+
if (this._state === "auth-invalid")
|
|
4820
|
+
this.authAttempts = 0;
|
|
4824
4821
|
this.setupBrowserListeners();
|
|
4825
4822
|
this.setState("connecting");
|
|
4826
4823
|
let ticket;
|
|
4827
4824
|
try {
|
|
4828
4825
|
ticket = await this.options.getTicket();
|
|
4829
4826
|
} catch (err) {
|
|
4827
|
+
const authRejection = authRejectionFrom(err);
|
|
4828
|
+
if (authRejection) {
|
|
4829
|
+
this.authAttempts += 1;
|
|
4830
|
+
if (this.authAttempts < this.options.maxAuthAttempts && this.options.reconnect) {
|
|
4831
|
+
console.warn(`WS ticket auth rejected (attempt ${this.authAttempts}/${this.options.maxAuthAttempts}):`, err);
|
|
4832
|
+
this.scheduleReconnect({ cause: "ticket_failed" });
|
|
4833
|
+
} else {
|
|
4834
|
+
this.enterAuthInvalid(authRejection);
|
|
4835
|
+
}
|
|
4836
|
+
return;
|
|
4837
|
+
}
|
|
4830
4838
|
if (isBrowserRuntime() && isRetryableNetworkError(err)) {
|
|
4831
4839
|
console.warn("Failed to get WS ticket:", err);
|
|
4832
4840
|
} else {
|
|
@@ -4873,6 +4881,7 @@ var init_ws = __esm({
|
|
|
4873
4881
|
this.ws.onopen = () => {
|
|
4874
4882
|
clearTimeout(connectTimeout);
|
|
4875
4883
|
this.reconnectAttempts = 0;
|
|
4884
|
+
this.authAttempts = 0;
|
|
4876
4885
|
this.lastReceivedAt = Date.now();
|
|
4877
4886
|
this.setState("connected");
|
|
4878
4887
|
};
|
|
@@ -4960,6 +4969,20 @@ var init_ws = __esm({
|
|
|
4960
4969
|
this.stateListeners.delete(handler);
|
|
4961
4970
|
};
|
|
4962
4971
|
}
|
|
4972
|
+
/**
|
|
4973
|
+
* Subscribe to the auth-invalid transition. Fired exactly once when the
|
|
4974
|
+
* client enters the terminal 'auth-invalid' state (a second episode after
|
|
4975
|
+
* a recovered reconnect fires again — one event per transition edge).
|
|
4976
|
+
* Consumers: runtime bridges exit for supervisor re-mint (see
|
|
4977
|
+
* @parall/agent-core gateway-base), the daemon logs recovery guidance for
|
|
4978
|
+
* its machine key, UIs surface a re-authenticate action.
|
|
4979
|
+
*/
|
|
4980
|
+
onAuthInvalid(handler) {
|
|
4981
|
+
this.authInvalidListeners.add(handler);
|
|
4982
|
+
return () => {
|
|
4983
|
+
this.authInvalidListeners.delete(handler);
|
|
4984
|
+
};
|
|
4985
|
+
}
|
|
4963
4986
|
// ---- Internal ----
|
|
4964
4987
|
send(frame) {
|
|
4965
4988
|
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
@@ -5005,6 +5028,8 @@ var init_ws = __esm({
|
|
|
5005
5028
|
}
|
|
5006
5029
|
}
|
|
5007
5030
|
scheduleReconnect(detail) {
|
|
5031
|
+
if (this._state === "auth-invalid")
|
|
5032
|
+
return;
|
|
5008
5033
|
this.setState("reconnecting", { ...detail, attempt: this.reconnectAttempts + 1 });
|
|
5009
5034
|
this.clearReconnect();
|
|
5010
5035
|
const base = Math.min(this.options.reconnectInterval * Math.pow(2, this.reconnectAttempts), this.options.maxReconnectInterval);
|
|
@@ -5020,6 +5045,20 @@ var init_ws = __esm({
|
|
|
5020
5045
|
this.reconnectTimer = null;
|
|
5021
5046
|
}
|
|
5022
5047
|
}
|
|
5048
|
+
/**
|
|
5049
|
+
* Enter the terminal auth-invalid state and notify consumers once. Loud on
|
|
5050
|
+
* purpose: before this branch existed, a revoked key produced an infinite
|
|
5051
|
+
* silent connecting→reconnecting loop with no indication that the
|
|
5052
|
+
* credential — not the network — was the problem.
|
|
5053
|
+
*/
|
|
5054
|
+
enterAuthInvalid(event) {
|
|
5055
|
+
this.clearReconnect();
|
|
5056
|
+
this.setState("auth-invalid");
|
|
5057
|
+
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.`);
|
|
5058
|
+
for (const listener of this.authInvalidListeners) {
|
|
5059
|
+
listener(event);
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5023
5062
|
/** Force-close a dead/stale connection and trigger reconnect. */
|
|
5024
5063
|
forceReconnect(cause) {
|
|
5025
5064
|
this.stopHeartbeat();
|
|
@@ -5126,13 +5165,339 @@ var init_ws = __esm({
|
|
|
5126
5165
|
}
|
|
5127
5166
|
});
|
|
5128
5167
|
|
|
5168
|
+
// ts/sdk/dist/browser-use-contract.generated.js
|
|
5169
|
+
var browserUseContract;
|
|
5170
|
+
var init_browser_use_contract_generated = __esm({
|
|
5171
|
+
"ts/sdk/dist/browser-use-contract.generated.js"() {
|
|
5172
|
+
"use strict";
|
|
5173
|
+
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 } } };
|
|
5174
|
+
}
|
|
5175
|
+
});
|
|
5176
|
+
|
|
5177
|
+
// ts/sdk/dist/browser-use-validation.js
|
|
5178
|
+
function browserUseObject(value) {
|
|
5179
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
5180
|
+
throw new BrowserUseValidationError("Expected an object.");
|
|
5181
|
+
return value;
|
|
5182
|
+
}
|
|
5183
|
+
function browserUseIdentifier(value, prefix) {
|
|
5184
|
+
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))
|
|
5185
|
+
throw new BrowserUseValidationError(`Expected a ${prefix} identifier.`);
|
|
5186
|
+
return value;
|
|
5187
|
+
}
|
|
5188
|
+
function requireValid(condition, label) {
|
|
5189
|
+
if (!condition)
|
|
5190
|
+
throw new BrowserUseValidationError(`Invalid ${label}.`);
|
|
5191
|
+
}
|
|
5192
|
+
function exact(value, allowed, required = []) {
|
|
5193
|
+
requireValid(Object.keys(value).every((k) => allowed.includes(k)) && required.every((k) => Object.hasOwn(value, k)), "object fields");
|
|
5194
|
+
}
|
|
5195
|
+
function validateBrowserUseField(value, field, label) {
|
|
5196
|
+
if (typeof field === "string") {
|
|
5197
|
+
switch (field) {
|
|
5198
|
+
case "selector":
|
|
5199
|
+
return validateBrowserUseField(value, { type: "string", min_length: 1, max_length: 4096 }, label);
|
|
5200
|
+
case "single_unicode_character_or_named_key":
|
|
5201
|
+
requireValid(typeof value === "string" && ([...value].length === 1 || [
|
|
5202
|
+
"Enter",
|
|
5203
|
+
"Tab",
|
|
5204
|
+
"Escape",
|
|
5205
|
+
"Backspace",
|
|
5206
|
+
"Delete",
|
|
5207
|
+
"ArrowUp",
|
|
5208
|
+
"ArrowDown",
|
|
5209
|
+
"ArrowLeft",
|
|
5210
|
+
"ArrowRight",
|
|
5211
|
+
"Home",
|
|
5212
|
+
"End",
|
|
5213
|
+
"PageUp",
|
|
5214
|
+
"PageDown"
|
|
5215
|
+
].includes(value)), label);
|
|
5216
|
+
return;
|
|
5217
|
+
case "viewport": {
|
|
5218
|
+
const obj = browserUseObject(value);
|
|
5219
|
+
exact(obj, ["width", "height"], ["width", "height"]);
|
|
5220
|
+
validateBrowserUseField(obj.width, { type: "integer", minimum: 320, maximum: 3840 }, label);
|
|
5221
|
+
validateBrowserUseField(obj.height, { type: "integer", minimum: 240, maximum: 2160 }, label);
|
|
5222
|
+
return;
|
|
5223
|
+
}
|
|
5224
|
+
case "identifier":
|
|
5225
|
+
browserUseIdentifier(value, label.includes("snapshot") ? "bsn_" : "btab_");
|
|
5226
|
+
return;
|
|
5227
|
+
case "ebp_identifier":
|
|
5228
|
+
browserUseIdentifier(value, "ebp_");
|
|
5229
|
+
return;
|
|
5230
|
+
case "positive_integer":
|
|
5231
|
+
return validateBrowserUseField(value, { type: "integer", minimum: 1 }, label);
|
|
5232
|
+
case "non_negative_integer":
|
|
5233
|
+
return validateBrowserUseField(value, { type: "integer", minimum: 0 }, label);
|
|
5234
|
+
case "nullable_string":
|
|
5235
|
+
if (value === null)
|
|
5236
|
+
return;
|
|
5237
|
+
return validateBrowserUseField(value, { type: "string", allow_empty: true }, label);
|
|
5238
|
+
case "string":
|
|
5239
|
+
return validateBrowserUseField(value, { type: "string", allow_empty: true }, label);
|
|
5240
|
+
case "boolean":
|
|
5241
|
+
requireValid(typeof value === "boolean", label);
|
|
5242
|
+
return;
|
|
5243
|
+
case "canonical_base64":
|
|
5244
|
+
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);
|
|
5245
|
+
return;
|
|
5246
|
+
case "nullable_article":
|
|
5247
|
+
if (value === null)
|
|
5248
|
+
return;
|
|
5249
|
+
return validateShape(value, browserUseContract.successShapes.article.fields);
|
|
5250
|
+
case "tab_summary_array":
|
|
5251
|
+
requireValid(Array.isArray(value), label);
|
|
5252
|
+
for (const tab of value)
|
|
5253
|
+
validateShape(tab, {
|
|
5254
|
+
...browserUseContract.successShapes.tab_state.fields,
|
|
5255
|
+
loading: "boolean"
|
|
5256
|
+
});
|
|
5257
|
+
return;
|
|
5258
|
+
case "json_value_max_256_kib":
|
|
5259
|
+
requireValid(new TextEncoder().encode(canonicalBrowserUseJson(value)).length <= 256 * 1024, label);
|
|
5260
|
+
return;
|
|
5261
|
+
default:
|
|
5262
|
+
throw new BrowserUseValidationError(`Unknown contract field ${field}.`);
|
|
5263
|
+
}
|
|
5264
|
+
}
|
|
5265
|
+
if ("const" in field) {
|
|
5266
|
+
requireValid(value === field.const, label);
|
|
5267
|
+
return;
|
|
5268
|
+
}
|
|
5269
|
+
if (field.enum) {
|
|
5270
|
+
requireValid(field.enum.includes(value), label);
|
|
5271
|
+
return;
|
|
5272
|
+
}
|
|
5273
|
+
if (field.type === "viewport")
|
|
5274
|
+
return validateBrowserUseField(value, "viewport", label);
|
|
5275
|
+
if (field.type === "boolean") {
|
|
5276
|
+
requireValid(typeof value === "boolean", label);
|
|
5277
|
+
return;
|
|
5278
|
+
}
|
|
5279
|
+
if (field.type === "integer") {
|
|
5280
|
+
requireValid(typeof value === "number" && Number.isSafeInteger(value) && value >= (field.minimum ?? 0) && value <= (field.maximum ?? Number.MAX_SAFE_INTEGER), label);
|
|
5281
|
+
return;
|
|
5282
|
+
}
|
|
5283
|
+
requireValid(typeof value === "string" && [...value].length >= (field.allow_empty ? 0 : field.min_length ?? 1) && [...value].length <= (field.max_length ?? 1 << 20), label);
|
|
5284
|
+
if (field.schemes) {
|
|
5285
|
+
if (value === "about:blank")
|
|
5286
|
+
return;
|
|
5287
|
+
let url;
|
|
5288
|
+
try {
|
|
5289
|
+
url = new URL(value);
|
|
5290
|
+
} catch {
|
|
5291
|
+
throw new BrowserUseValidationError(`Invalid ${label} URL.`);
|
|
5292
|
+
}
|
|
5293
|
+
requireValid(url.protocol === "https:" || url.protocol === "http:", label);
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5296
|
+
function validateShape(value, fields) {
|
|
5297
|
+
const obj = browserUseObject(value);
|
|
5298
|
+
exact(obj, Object.keys(fields), Object.keys(fields));
|
|
5299
|
+
for (const [key, field] of Object.entries(fields))
|
|
5300
|
+
validateBrowserUseField(obj[key], field, key);
|
|
5301
|
+
}
|
|
5302
|
+
function validateBrowserUseActionRequest(value) {
|
|
5303
|
+
const obj = browserUseObject(value);
|
|
5304
|
+
exact(obj, ["action", "target", "params"], ["action", "params"]);
|
|
5305
|
+
requireValid(typeof obj.action === "string", "action");
|
|
5306
|
+
if (!Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, obj.action))
|
|
5307
|
+
throw new BrowserUseValidationError(`Browser Use v1 does not support ${obj.action}.`, "UNSUPPORTED_ACTION");
|
|
5308
|
+
const action = obj.action;
|
|
5309
|
+
const schema = BROWSER_USE_ACTION_SCHEMAS[action];
|
|
5310
|
+
const params = browserUseObject(obj.params);
|
|
5311
|
+
exact(params, Object.keys(schema.params.properties), [...schema.params.required]);
|
|
5312
|
+
for (const [key, val] of Object.entries(params))
|
|
5313
|
+
validateBrowserUseField(val, schema.params.properties[key], key);
|
|
5314
|
+
let target;
|
|
5315
|
+
if (obj.target !== void 0) {
|
|
5316
|
+
requireValid(schema.target !== "none", "target");
|
|
5317
|
+
target = browserUseObject(obj.target);
|
|
5318
|
+
const base = ["tab_id", "browser_generation"];
|
|
5319
|
+
const refs = ["document_generation", "snapshot_id", "ref"];
|
|
5320
|
+
exact(target, schema.target === "tab_or_ref" ? [...base, ...refs] : base, base);
|
|
5321
|
+
browserUseIdentifier(target.tab_id, "btab_");
|
|
5322
|
+
validateBrowserUseField(target.browser_generation, "positive_integer", "browser_generation");
|
|
5323
|
+
if (refs.some((k) => Object.hasOwn(target, k))) {
|
|
5324
|
+
requireValid(refs.every((k) => Object.hasOwn(target, k)), "complete ref binding");
|
|
5325
|
+
validateBrowserUseField(target.document_generation, "positive_integer", "document_generation");
|
|
5326
|
+
browserUseIdentifier(target.snapshot_id, "bsn_");
|
|
5327
|
+
browserUseIdentifier(target.ref, "");
|
|
5328
|
+
}
|
|
5329
|
+
} else
|
|
5330
|
+
requireValid(schema.target === "none" || schema.target === "optional_tab", "required target");
|
|
5331
|
+
const locatorCount = Number(params.selector !== void 0) + Number(target?.ref !== void 0);
|
|
5332
|
+
if (action === "read")
|
|
5333
|
+
requireValid(params.url !== void 0 !== Boolean(target), "read URL or target");
|
|
5334
|
+
if (action === "wait")
|
|
5335
|
+
requireValid(params.state === "load" === (params.selector === void 0), "wait selector/state");
|
|
5336
|
+
if (["click", "fill", "type"].includes(action))
|
|
5337
|
+
requireValid(locatorCount === 1, "exactly one locator");
|
|
5338
|
+
if (action === "get") {
|
|
5339
|
+
const page = params.prop === "title" || params.prop === "url";
|
|
5340
|
+
requireValid(locatorCount === (page ? 0 : 1), "get locator");
|
|
5341
|
+
requireValid(params.prop === "attr" === (params.name !== void 0), "get attribute name");
|
|
5342
|
+
}
|
|
5343
|
+
requireValid(new TextEncoder().encode(JSON.stringify(obj)).length <= 1 << 20, "request size");
|
|
5344
|
+
return obj;
|
|
5345
|
+
}
|
|
5346
|
+
function validateBrowserUseSuccessData(action, value) {
|
|
5347
|
+
const schema = BROWSER_USE_ACTION_SCHEMAS[action].success;
|
|
5348
|
+
validateShape(value, {
|
|
5349
|
+
...schema.base === "tab_state" ? browserUseContract.successShapes.tab_state.fields : {},
|
|
5350
|
+
...schema.fields
|
|
5351
|
+
});
|
|
5352
|
+
}
|
|
5353
|
+
function canonicalBrowserUseJson(value, seen = /* @__PURE__ */ new Set()) {
|
|
5354
|
+
if (value === null || typeof value === "boolean" || typeof value === "string")
|
|
5355
|
+
return JSON.stringify(value);
|
|
5356
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
5357
|
+
return JSON.stringify(value);
|
|
5358
|
+
if (!value || typeof value !== "object" || seen.has(value))
|
|
5359
|
+
throw new BrowserUseValidationError("Invalid JSON result.");
|
|
5360
|
+
seen.add(value);
|
|
5361
|
+
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(",")}}`;
|
|
5362
|
+
seen.delete(value);
|
|
5363
|
+
return result;
|
|
5364
|
+
}
|
|
5365
|
+
var BrowserUseValidationError, BROWSER_USE_ACTION_SCHEMAS, BROWSER_USE_ACTIONS;
|
|
5366
|
+
var init_browser_use_validation = __esm({
|
|
5367
|
+
"ts/sdk/dist/browser-use-validation.js"() {
|
|
5368
|
+
"use strict";
|
|
5369
|
+
init_browser_use_contract_generated();
|
|
5370
|
+
BrowserUseValidationError = class extends Error {
|
|
5371
|
+
code;
|
|
5372
|
+
constructor(message, code = "INVALID_ARGUMENT") {
|
|
5373
|
+
super(message);
|
|
5374
|
+
this.code = code;
|
|
5375
|
+
}
|
|
5376
|
+
};
|
|
5377
|
+
BROWSER_USE_ACTION_SCHEMAS = browserUseContract.actions;
|
|
5378
|
+
BROWSER_USE_ACTIONS = Object.freeze(Object.keys(BROWSER_USE_ACTION_SCHEMAS));
|
|
5379
|
+
}
|
|
5380
|
+
});
|
|
5381
|
+
|
|
5382
|
+
// ts/sdk/dist/browser-use-receipt.js
|
|
5383
|
+
function isBrowserUseTimestamp(value) {
|
|
5384
|
+
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))
|
|
5385
|
+
return false;
|
|
5386
|
+
const [year, month, day, hour, minute, second] = value.slice(0, 19).split(/[-T:]/).map(Number);
|
|
5387
|
+
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));
|
|
5388
|
+
}
|
|
5389
|
+
async function browserUseResultDigest(value, maxBytes = 1 << 20, subtle = globalThis.crypto.subtle) {
|
|
5390
|
+
const bytes = new TextEncoder().encode(canonicalBrowserUseJson(value));
|
|
5391
|
+
if (bytes.length > maxBytes)
|
|
5392
|
+
throw new BrowserUseValidationError("Browser Use result exceeds contract size.");
|
|
5393
|
+
const digest = await subtle.digest("SHA-256", bytes);
|
|
5394
|
+
return `sha256:${Array.from(new Uint8Array(digest), (n) => n.toString(16).padStart(2, "0")).join("")}`;
|
|
5395
|
+
}
|
|
5396
|
+
function proof(condition) {
|
|
5397
|
+
if (!condition)
|
|
5398
|
+
throw new BrowserUseValidationError("The Browser Use response did not contain valid public status proof.", "INVALID_SERVER_RESPONSE");
|
|
5399
|
+
}
|
|
5400
|
+
async function validateBrowserUseReceipt(value, expected, subtle) {
|
|
5401
|
+
try {
|
|
5402
|
+
const r = browserUseObject(value);
|
|
5403
|
+
proof(Object.keys(r).every((k) => KEYS.includes(k)));
|
|
5404
|
+
proof(r.contract_version === "browser-use-operation-v1");
|
|
5405
|
+
browserUseIdentifier(r.operation_id, "buo_");
|
|
5406
|
+
browserUseIdentifier(r.request_id, "burq_");
|
|
5407
|
+
browserUseIdentifier(r.profile_id, "ebp_");
|
|
5408
|
+
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));
|
|
5409
|
+
proof(typeof r.action === "string" && Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, r.action));
|
|
5410
|
+
const action = r.action;
|
|
5411
|
+
proof(r.required_grant === BROWSER_USE_ACTION_SCHEMAS[action].grant);
|
|
5412
|
+
proof(positive(r.profile_version) && positive(r.profile_config_revision));
|
|
5413
|
+
proof(typeof r.phase === "string" && ["accepted", "started", ...terminal].includes(r.phase));
|
|
5414
|
+
proof(typeof r.result_available === "boolean");
|
|
5415
|
+
for (const k of ["deadline", "accepted_at", "updated_at"])
|
|
5416
|
+
proof(isBrowserUseTimestamp(r[k]));
|
|
5417
|
+
for (const k of ["occurred_at", "result_expires_at", "started_at", "terminal_at"])
|
|
5418
|
+
if (k in r)
|
|
5419
|
+
proof(isBrowserUseTimestamp(r[k]));
|
|
5420
|
+
if ("duration_ms" in r)
|
|
5421
|
+
proof(typeof r.duration_ms === "number" && Number.isSafeInteger(r.duration_ms) && r.duration_ms >= 0);
|
|
5422
|
+
if ("dispatched" in r)
|
|
5423
|
+
proof(typeof r.dispatched === "boolean");
|
|
5424
|
+
proof("tab_id" in r === "browser_generation" in r);
|
|
5425
|
+
if ("tab_id" in r) {
|
|
5426
|
+
browserUseIdentifier(r.tab_id, "btab_");
|
|
5427
|
+
proof(positive(r.browser_generation));
|
|
5428
|
+
}
|
|
5429
|
+
const isTerminal = terminal.has(r.phase);
|
|
5430
|
+
if (isTerminal) {
|
|
5431
|
+
browserUseIdentifier(r.receipt_id, "bur_");
|
|
5432
|
+
proof(hash(r.receipt_digest) && isBrowserUseTimestamp(r.occurred_at) && isBrowserUseTimestamp(r.terminal_at));
|
|
5433
|
+
} else {
|
|
5434
|
+
proof(!("terminal_at" in r));
|
|
5435
|
+
if ("receipt_id" in r || "receipt_digest" in r || "occurred_at" in r) {
|
|
5436
|
+
proof(r.phase === "started");
|
|
5437
|
+
browserUseIdentifier(r.receipt_id, "bur_");
|
|
5438
|
+
proof(hash(r.receipt_digest) && isBrowserUseTimestamp(r.occurred_at));
|
|
5439
|
+
}
|
|
5440
|
+
}
|
|
5441
|
+
const hasData = Object.hasOwn(r, "data");
|
|
5442
|
+
proof(r.result_available === hasData);
|
|
5443
|
+
if (r.phase === "succeeded")
|
|
5444
|
+
proof(!("error" in r) && hash(r.result_digest));
|
|
5445
|
+
else {
|
|
5446
|
+
proof(!hasData && !r.result_available);
|
|
5447
|
+
if (isTerminal) {
|
|
5448
|
+
const e = browserUseObject(r.error);
|
|
5449
|
+
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));
|
|
5450
|
+
for (const k of ["message", "hint"])
|
|
5451
|
+
if (k in e)
|
|
5452
|
+
proof(typeof e[k] === "string" && e[k].length <= 1024);
|
|
5453
|
+
if (r.phase === "outcome_unknown")
|
|
5454
|
+
proof(e.code === "UNKNOWN_OUTCOME");
|
|
5455
|
+
} else
|
|
5456
|
+
proof(!("error" in r));
|
|
5457
|
+
}
|
|
5458
|
+
if (hasData) {
|
|
5459
|
+
validateBrowserUseSuccessData(action, r.data);
|
|
5460
|
+
proof(r.result_digest === await browserUseResultDigest(r.data, action === "eval" ? 256 * 1024 : 1 << 20, subtle));
|
|
5461
|
+
const data = browserUseObject(r.data);
|
|
5462
|
+
if (action === "tabs")
|
|
5463
|
+
proof(data.tabs.every((t) => t.profile_id === r.profile_id));
|
|
5464
|
+
else
|
|
5465
|
+
proof(data.profile_id === r.profile_id);
|
|
5466
|
+
if (!["read", "tabs"].includes(action))
|
|
5467
|
+
proof(data.tab_id === r.tab_id && data.browser_generation === r.browser_generation);
|
|
5468
|
+
if (expected.target) {
|
|
5469
|
+
if (action === "recover")
|
|
5470
|
+
proof(data.recovered_from_tab_id === expected.target.tab_id);
|
|
5471
|
+
else if (action !== "read")
|
|
5472
|
+
proof(data.tab_id === expected.target.tab_id && data.browser_generation === expected.target.browser_generation);
|
|
5473
|
+
}
|
|
5474
|
+
}
|
|
5475
|
+
return r;
|
|
5476
|
+
} catch {
|
|
5477
|
+
throw new BrowserUseValidationError("The Browser Use response did not contain valid public status proof.", "INVALID_SERVER_RESPONSE");
|
|
5478
|
+
}
|
|
5479
|
+
}
|
|
5480
|
+
var KEYS, terminal, hash, positive;
|
|
5481
|
+
var init_browser_use_receipt = __esm({
|
|
5482
|
+
"ts/sdk/dist/browser-use-receipt.js"() {
|
|
5483
|
+
"use strict";
|
|
5484
|
+
init_browser_use_validation();
|
|
5485
|
+
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(" ");
|
|
5486
|
+
terminal = /* @__PURE__ */ new Set(["succeeded", "failed", "outcome_unknown"]);
|
|
5487
|
+
hash = (value) => typeof value === "string" && /^sha256:[0-9a-f]{64}$/.test(value);
|
|
5488
|
+
positive = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
5489
|
+
}
|
|
5490
|
+
});
|
|
5491
|
+
|
|
5129
5492
|
// ts/sdk/dist/index.js
|
|
5130
5493
|
var dist_exports = {};
|
|
5131
5494
|
__export(dist_exports, {
|
|
5132
5495
|
API_BASE: () => API_BASE2,
|
|
5133
5496
|
ApiError: () => ApiError,
|
|
5134
|
-
|
|
5497
|
+
BROWSER_USE_ACTIONS: () => BROWSER_USE_ACTIONS,
|
|
5498
|
+
BROWSER_USE_ACTION_SCHEMAS: () => BROWSER_USE_ACTION_SCHEMAS,
|
|
5135
5499
|
BROWSER_USE_FEATURE_FLAG: () => BROWSER_USE_FEATURE_FLAG,
|
|
5500
|
+
BrowserUseValidationError: () => BrowserUseValidationError,
|
|
5136
5501
|
CLIP_BASE: () => CLIP_BASE,
|
|
5137
5502
|
CLI_RUNTIME_TYPES: () => CLI_RUNTIME_TYPES,
|
|
5138
5503
|
COMMENT_TARGET: () => COMMENT_TARGET,
|
|
@@ -5149,11 +5514,17 @@ __export(dist_exports, {
|
|
|
5149
5514
|
ParallWs: () => ParallWs,
|
|
5150
5515
|
WIKI_BASE: () => WIKI_BASE,
|
|
5151
5516
|
WS_EVENTS: () => WS_EVENTS,
|
|
5517
|
+
authRejectionFrom: () => authRejectionFrom,
|
|
5518
|
+
browserUseIdentifier: () => browserUseIdentifier,
|
|
5519
|
+
browserUseObject: () => browserUseObject,
|
|
5520
|
+
browserUseResultDigest: () => browserUseResultDigest,
|
|
5152
5521
|
browserViewerRequestOptions: () => browserViewerRequestOptions,
|
|
5522
|
+
canonicalBrowserUseJson: () => canonicalBrowserUseJson,
|
|
5153
5523
|
describeFetchCause: () => describeFetchCause,
|
|
5154
5524
|
describeWsStateDetail: () => describeWsStateDetail,
|
|
5155
5525
|
isBroadcastMentionId: () => isBroadcastMentionId,
|
|
5156
5526
|
isBrowserUseEnabled: () => isBrowserUseEnabled,
|
|
5527
|
+
isBrowserUseTimestamp: () => isBrowserUseTimestamp,
|
|
5157
5528
|
isInWikiPersonalNamespace: () => isInWikiPersonalNamespace,
|
|
5158
5529
|
isPlatformModelSelectableForRuntime: () => isPlatformModelSelectableForRuntime,
|
|
5159
5530
|
isTeamSubject: () => isTeamSubject,
|
|
@@ -5162,6 +5533,10 @@ __export(dist_exports, {
|
|
|
5162
5533
|
parseSubjectToken: () => parseSubjectToken,
|
|
5163
5534
|
platformDefaultModelForRuntime: () => platformDefaultModelForRuntime,
|
|
5164
5535
|
teamIdsFromSubjects: () => teamIdsFromSubjects,
|
|
5536
|
+
validateBrowserUseActionRequest: () => validateBrowserUseActionRequest,
|
|
5537
|
+
validateBrowserUseField: () => validateBrowserUseField,
|
|
5538
|
+
validateBrowserUseReceipt: () => validateBrowserUseReceipt,
|
|
5539
|
+
validateBrowserUseSuccessData: () => validateBrowserUseSuccessData,
|
|
5165
5540
|
wikiPersonalNamespacePrefix: () => wikiPersonalNamespacePrefix
|
|
5166
5541
|
});
|
|
5167
5542
|
var init_dist = __esm({
|
|
@@ -5181,6 +5556,8 @@ var init_dist = __esm({
|
|
|
5181
5556
|
init_types();
|
|
5182
5557
|
init_wechat_types();
|
|
5183
5558
|
init_ws();
|
|
5559
|
+
init_browser_use_validation();
|
|
5560
|
+
init_browser_use_receipt();
|
|
5184
5561
|
}
|
|
5185
5562
|
});
|
|
5186
5563
|
|
|
@@ -5227,6 +5604,39 @@ var init_lane_target = __esm({
|
|
|
5227
5604
|
}
|
|
5228
5605
|
});
|
|
5229
5606
|
|
|
5607
|
+
// ts/agent-core/dist/lane-outcome.js
|
|
5608
|
+
var init_lane_outcome = __esm({
|
|
5609
|
+
"ts/agent-core/dist/lane-outcome.js"() {
|
|
5610
|
+
"use strict";
|
|
5611
|
+
}
|
|
5612
|
+
});
|
|
5613
|
+
|
|
5614
|
+
// ts/agent-core/dist/runtime-instance.js
|
|
5615
|
+
var init_runtime_instance = __esm({
|
|
5616
|
+
"ts/agent-core/dist/runtime-instance.js"() {
|
|
5617
|
+
"use strict";
|
|
5618
|
+
}
|
|
5619
|
+
});
|
|
5620
|
+
|
|
5621
|
+
// ts/agent-core/dist/lane-input-receipts.js
|
|
5622
|
+
var init_lane_input_receipts = __esm({
|
|
5623
|
+
"ts/agent-core/dist/lane-input-receipts.js"() {
|
|
5624
|
+
"use strict";
|
|
5625
|
+
init_dist();
|
|
5626
|
+
init_lane_outcome();
|
|
5627
|
+
init_redact();
|
|
5628
|
+
init_runtime_instance();
|
|
5629
|
+
}
|
|
5630
|
+
});
|
|
5631
|
+
|
|
5632
|
+
// ts/agent-core/dist/lane-confirmations.js
|
|
5633
|
+
var init_lane_confirmations = __esm({
|
|
5634
|
+
"ts/agent-core/dist/lane-confirmations.js"() {
|
|
5635
|
+
"use strict";
|
|
5636
|
+
init_dist();
|
|
5637
|
+
}
|
|
5638
|
+
});
|
|
5639
|
+
|
|
5230
5640
|
// ts/agent-core/dist/lane-ledger.js
|
|
5231
5641
|
var init_lane_ledger = __esm({
|
|
5232
5642
|
"ts/agent-core/dist/lane-ledger.js"() {
|
|
@@ -5235,6 +5645,10 @@ var init_lane_ledger = __esm({
|
|
|
5235
5645
|
init_lane_key();
|
|
5236
5646
|
init_lane_target();
|
|
5237
5647
|
init_redact();
|
|
5648
|
+
init_lane_input_receipts();
|
|
5649
|
+
init_lane_outcome();
|
|
5650
|
+
init_lane_confirmations();
|
|
5651
|
+
init_runtime_instance();
|
|
5238
5652
|
}
|
|
5239
5653
|
});
|
|
5240
5654
|
|
|
@@ -12348,12 +12762,12 @@ var require_longbits = __commonJS({
|
|
|
12348
12762
|
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
12763
|
};
|
|
12350
12764
|
var charCodeAt = String.prototype.charCodeAt;
|
|
12351
|
-
LongBits.fromHash = function fromHash(
|
|
12352
|
-
if (
|
|
12765
|
+
LongBits.fromHash = function fromHash(hash2) {
|
|
12766
|
+
if (hash2 === zeroHash)
|
|
12353
12767
|
return zero;
|
|
12354
12768
|
return new LongBits(
|
|
12355
|
-
(charCodeAt.call(
|
|
12356
|
-
(charCodeAt.call(
|
|
12769
|
+
(charCodeAt.call(hash2, 0) | charCodeAt.call(hash2, 1) << 8 | charCodeAt.call(hash2, 2) << 16 | charCodeAt.call(hash2, 3) << 24) >>> 0,
|
|
12770
|
+
(charCodeAt.call(hash2, 4) | charCodeAt.call(hash2, 5) << 8 | charCodeAt.call(hash2, 6) << 16 | charCodeAt.call(hash2, 7) << 24) >>> 0
|
|
12357
12771
|
);
|
|
12358
12772
|
};
|
|
12359
12773
|
LongBits.prototype.toHash = function toHash() {
|
|
@@ -12459,8 +12873,8 @@ var require_minimal = __commonJS({
|
|
|
12459
12873
|
util.longToHash = function longToHash(value) {
|
|
12460
12874
|
return value ? util.LongBits.from(value).toHash() : util.LongBits.zeroHash;
|
|
12461
12875
|
};
|
|
12462
|
-
util.longFromHash = function longFromHash(
|
|
12463
|
-
var bits = util.LongBits.fromHash(
|
|
12876
|
+
util.longFromHash = function longFromHash(hash2, unsigned) {
|
|
12877
|
+
var bits = util.LongBits.fromHash(hash2);
|
|
12464
12878
|
if (util.Long)
|
|
12465
12879
|
return util.Long.fromBits(bits.lo, bits.hi, unsigned);
|
|
12466
12880
|
return bits.toNumber(Boolean(unsigned));
|
|
@@ -24313,15 +24727,15 @@ var require_HashMap = __commonJS({
|
|
|
24313
24727
|
return this._valueMap.get(hashCode);
|
|
24314
24728
|
}
|
|
24315
24729
|
getOrDefault(key, defaultFactory) {
|
|
24316
|
-
const
|
|
24317
|
-
if (this._valueMap.has(
|
|
24318
|
-
return this._valueMap.get(
|
|
24730
|
+
const hash2 = this._hash(key);
|
|
24731
|
+
if (this._valueMap.has(hash2)) {
|
|
24732
|
+
return this._valueMap.get(hash2);
|
|
24319
24733
|
}
|
|
24320
24734
|
const val = defaultFactory();
|
|
24321
|
-
if (!this._keyMap.has(
|
|
24322
|
-
this._keyMap.set(
|
|
24735
|
+
if (!this._keyMap.has(hash2)) {
|
|
24736
|
+
this._keyMap.set(hash2, key);
|
|
24323
24737
|
}
|
|
24324
|
-
this._valueMap.set(
|
|
24738
|
+
this._valueMap.set(hash2, val);
|
|
24325
24739
|
return val;
|
|
24326
24740
|
}
|
|
24327
24741
|
set(key, value, hashCode) {
|
|
@@ -24523,13 +24937,13 @@ var require_TemporalMetricProcessor = __commonJS({
|
|
|
24523
24937
|
const iterator = current.entries();
|
|
24524
24938
|
let next = iterator.next();
|
|
24525
24939
|
while (next.done !== true) {
|
|
24526
|
-
const [key, record,
|
|
24527
|
-
if (last.has(key,
|
|
24528
|
-
const lastAccumulation = last.get(key,
|
|
24940
|
+
const [key, record, hash2] = next.value;
|
|
24941
|
+
if (last.has(key, hash2)) {
|
|
24942
|
+
const lastAccumulation = last.get(key, hash2);
|
|
24529
24943
|
const accumulation = aggregator.merge(lastAccumulation, record);
|
|
24530
|
-
result.set(key, accumulation,
|
|
24944
|
+
result.set(key, accumulation, hash2);
|
|
24531
24945
|
} else {
|
|
24532
|
-
result.set(key, record,
|
|
24946
|
+
result.set(key, record, hash2);
|
|
24533
24947
|
}
|
|
24534
24948
|
next = iterator.next();
|
|
24535
24949
|
}
|
|
@@ -24540,8 +24954,8 @@ var require_TemporalMetricProcessor = __commonJS({
|
|
|
24540
24954
|
* the new stream to be the initial observation time unchanged.
|
|
24541
24955
|
*/
|
|
24542
24956
|
static calibrateStartTime(last, current, lastCollectionTime) {
|
|
24543
|
-
for (const [key,
|
|
24544
|
-
const currentAccumulation = current.get(key,
|
|
24957
|
+
for (const [key, hash2] of last.keys()) {
|
|
24958
|
+
const currentAccumulation = current.get(key, hash2);
|
|
24545
24959
|
currentAccumulation === null || currentAccumulation === void 0 ? void 0 : currentAccumulation.setStartTime(lastCollectionTime);
|
|
24546
24960
|
}
|
|
24547
24961
|
return current;
|
|
@@ -32420,9 +32834,11 @@ var init_session_state = __esm({
|
|
|
32420
32834
|
});
|
|
32421
32835
|
|
|
32422
32836
|
// ts/agent-core/dist/gateway-base.js
|
|
32837
|
+
var AUTH_INVALID_EXIT_CODE;
|
|
32423
32838
|
var init_gateway_base = __esm({
|
|
32424
32839
|
"ts/agent-core/dist/gateway-base.js"() {
|
|
32425
32840
|
"use strict";
|
|
32841
|
+
init_dispatch_recovery();
|
|
32426
32842
|
init_change_source();
|
|
32427
32843
|
init_dist();
|
|
32428
32844
|
init_fork_prefix();
|
|
@@ -32445,6 +32861,7 @@ var init_gateway_base = __esm({
|
|
|
32445
32861
|
init_session_state();
|
|
32446
32862
|
init_bridge_workspace();
|
|
32447
32863
|
init_telemetry();
|
|
32864
|
+
AUTH_INVALID_EXIT_CODE = 86;
|
|
32448
32865
|
}
|
|
32449
32866
|
});
|
|
32450
32867
|
|
|
@@ -46297,7 +46714,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
46297
46714
|
return;
|
|
46298
46715
|
}
|
|
46299
46716
|
const request3 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
|
|
46300
|
-
const
|
|
46717
|
+
const hash2 = createRequestHash(request3);
|
|
46301
46718
|
const normalizedHeaders = normalizeHeaders(response.headers);
|
|
46302
46719
|
const responseData = {
|
|
46303
46720
|
statusCode: response.statusCode,
|
|
@@ -46305,16 +46722,16 @@ var require_snapshot_recorder = __commonJS({
|
|
|
46305
46722
|
body: Buffer.isBuffer(response.body) ? response.body.toString("base64") : Buffer.from(String(response.body || "")).toString("base64"),
|
|
46306
46723
|
trailers: response.trailers
|
|
46307
46724
|
};
|
|
46308
|
-
if (this.#snapshots.size >= this.#maxSnapshots && !this.#snapshots.has(
|
|
46725
|
+
if (this.#snapshots.size >= this.#maxSnapshots && !this.#snapshots.has(hash2)) {
|
|
46309
46726
|
const oldestKey = this.#snapshots.keys().next().value;
|
|
46310
46727
|
this.#snapshots.delete(oldestKey);
|
|
46311
46728
|
}
|
|
46312
|
-
const existingSnapshot = this.#snapshots.get(
|
|
46729
|
+
const existingSnapshot = this.#snapshots.get(hash2);
|
|
46313
46730
|
if (existingSnapshot && existingSnapshot.responses) {
|
|
46314
46731
|
existingSnapshot.responses.push(responseData);
|
|
46315
46732
|
existingSnapshot.timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
46316
46733
|
} else {
|
|
46317
|
-
this.#snapshots.set(
|
|
46734
|
+
this.#snapshots.set(hash2, {
|
|
46318
46735
|
request: request3,
|
|
46319
46736
|
responses: [responseData],
|
|
46320
46737
|
// Always store as array for consistency
|
|
@@ -46350,8 +46767,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
46350
46767
|
return void 0;
|
|
46351
46768
|
}
|
|
46352
46769
|
const request3 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
|
|
46353
|
-
const
|
|
46354
|
-
const snapshot = this.#snapshots.get(
|
|
46770
|
+
const hash2 = createRequestHash(request3);
|
|
46771
|
+
const snapshot = this.#snapshots.get(hash2);
|
|
46355
46772
|
if (!snapshot) return void 0;
|
|
46356
46773
|
const currentCallCount = snapshot.callCount || 0;
|
|
46357
46774
|
const responseIndex = Math.min(currentCallCount, snapshot.responses.length - 1);
|
|
@@ -46376,8 +46793,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
46376
46793
|
const parsed = JSON.parse(data);
|
|
46377
46794
|
if (Array.isArray(parsed)) {
|
|
46378
46795
|
this.#snapshots.clear();
|
|
46379
|
-
for (const { hash, snapshot } of parsed) {
|
|
46380
|
-
this.#snapshots.set(
|
|
46796
|
+
for (const { hash: hash2, snapshot } of parsed) {
|
|
46797
|
+
this.#snapshots.set(hash2, snapshot);
|
|
46381
46798
|
}
|
|
46382
46799
|
} else {
|
|
46383
46800
|
this.#snapshots = new Map(Object.entries(parsed));
|
|
@@ -46403,8 +46820,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
46403
46820
|
}
|
|
46404
46821
|
const resolvedPath = resolve9(path27);
|
|
46405
46822
|
await mkdir2(dirname14(resolvedPath), { recursive: true });
|
|
46406
|
-
const data = Array.from(this.#snapshots.entries()).map(([
|
|
46407
|
-
hash,
|
|
46823
|
+
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
46824
|
+
hash: hash2,
|
|
46408
46825
|
snapshot
|
|
46409
46826
|
}));
|
|
46410
46827
|
await writeFile2(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
|
|
@@ -46446,8 +46863,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
46446
46863
|
*/
|
|
46447
46864
|
deleteSnapshot(requestOpts) {
|
|
46448
46865
|
const request3 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
|
|
46449
|
-
const
|
|
46450
|
-
return this.#snapshots.delete(
|
|
46866
|
+
const hash2 = createRequestHash(request3);
|
|
46867
|
+
return this.#snapshots.delete(hash2);
|
|
46451
46868
|
}
|
|
46452
46869
|
/**
|
|
46453
46870
|
* Gets information about a specific snapshot
|
|
@@ -46456,11 +46873,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
46456
46873
|
*/
|
|
46457
46874
|
getSnapshotInfo(requestOpts) {
|
|
46458
46875
|
const request3 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
|
|
46459
|
-
const
|
|
46460
|
-
const snapshot = this.#snapshots.get(
|
|
46876
|
+
const hash2 = createRequestHash(request3);
|
|
46877
|
+
const snapshot = this.#snapshots.get(hash2);
|
|
46461
46878
|
if (!snapshot) return null;
|
|
46462
46879
|
return {
|
|
46463
|
-
hash,
|
|
46880
|
+
hash: hash2,
|
|
46464
46881
|
request: snapshot.request,
|
|
46465
46882
|
responseCount: snapshot.responses ? snapshot.responses.length : snapshot.response ? 1 : 0,
|
|
46466
46883
|
// .response for legacy snapshots
|
|
@@ -46476,8 +46893,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
46476
46893
|
replaceSnapshots(snapshotData) {
|
|
46477
46894
|
this.#snapshots.clear();
|
|
46478
46895
|
if (Array.isArray(snapshotData)) {
|
|
46479
|
-
for (const { hash, snapshot } of snapshotData) {
|
|
46480
|
-
this.#snapshots.set(
|
|
46896
|
+
for (const { hash: hash2, snapshot } of snapshotData) {
|
|
46897
|
+
this.#snapshots.set(hash2, snapshot);
|
|
46481
46898
|
}
|
|
46482
46899
|
} else if (snapshotData && typeof snapshotData === "object") {
|
|
46483
46900
|
this.#snapshots = new Map(Object.entries(snapshotData));
|
|
@@ -58065,6 +58482,13 @@ var init_codex_message_delivery = __esm({
|
|
|
58065
58482
|
}
|
|
58066
58483
|
});
|
|
58067
58484
|
|
|
58485
|
+
// ts/agent-core/dist/skills/parall-browser.js
|
|
58486
|
+
var init_parall_browser = __esm({
|
|
58487
|
+
"ts/agent-core/dist/skills/parall-browser.js"() {
|
|
58488
|
+
"use strict";
|
|
58489
|
+
}
|
|
58490
|
+
});
|
|
58491
|
+
|
|
58068
58492
|
// ts/agent-core/dist/skills/parall-platform.js
|
|
58069
58493
|
var init_parall_platform = __esm({
|
|
58070
58494
|
"ts/agent-core/dist/skills/parall-platform.js"() {
|
|
@@ -58118,6 +58542,8 @@ var init_parall_clip_authoring = __esm({
|
|
|
58118
58542
|
var init_skills = __esm({
|
|
58119
58543
|
"ts/agent-core/dist/skills/index.js"() {
|
|
58120
58544
|
"use strict";
|
|
58545
|
+
init_parall_browser();
|
|
58546
|
+
init_parall_browser();
|
|
58121
58547
|
init_parall_platform();
|
|
58122
58548
|
init_parall_tasks();
|
|
58123
58549
|
init_parall_wiki();
|
|
@@ -58225,6 +58651,7 @@ var init_dist2 = __esm({
|
|
|
58225
58651
|
init_provider_config();
|
|
58226
58652
|
init_redact();
|
|
58227
58653
|
init_routing();
|
|
58654
|
+
init_runtime_instance();
|
|
58228
58655
|
init_runtime_activity_port();
|
|
58229
58656
|
init_runtime_turn_base();
|
|
58230
58657
|
init_session_state();
|
|
@@ -59289,11 +59716,6 @@ MCowBQYDK2VwAyEAQHQAZThNX7+deJNyHl/5DgiAa1OHx7UQoJotam0JhUk=
|
|
|
59289
59716
|
async doUpdate(targetVersion) {
|
|
59290
59717
|
const local = this.loadLocalManifest();
|
|
59291
59718
|
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
59719
|
const manifestUrl = targetVersion ? `${this.cdnBaseUrl}/${targetVersion}/manifest.json` : `${this.cdnBaseUrl}/latest/manifest.json`;
|
|
59298
59720
|
let remoteJson;
|
|
59299
59721
|
try {
|
|
@@ -59361,9 +59783,9 @@ MCowBQYDK2VwAyEAQHQAZThNX7+deJNyHl/5DgiAa1OHx7UQoJotam0JhUk=
|
|
|
59361
59783
|
return false;
|
|
59362
59784
|
}
|
|
59363
59785
|
const content = fs4.readFileSync(filePath);
|
|
59364
|
-
const
|
|
59365
|
-
if (
|
|
59366
|
-
this.log.error(`update: sha256 mismatch for ${filename} (expected ${meta.sha256}, got ${
|
|
59786
|
+
const hash2 = createHash("sha256").update(content).digest("hex");
|
|
59787
|
+
if (hash2 !== meta.sha256) {
|
|
59788
|
+
this.log.error(`update: sha256 mismatch for ${filename} (expected ${meta.sha256}, got ${hash2})`);
|
|
59367
59789
|
this.cleanDir(stagingDir);
|
|
59368
59790
|
this.report("failed", "sha256_mismatch");
|
|
59369
59791
|
return false;
|
|
@@ -65518,10 +65940,10 @@ function verifyChecksum(filePath, algo, expectedHex) {
|
|
|
65518
65940
|
console.warn(`[clip-installer] WARNING: no checksum provided by registry \u2014 installing without integrity verification`);
|
|
65519
65941
|
return;
|
|
65520
65942
|
}
|
|
65521
|
-
const
|
|
65943
|
+
const hash2 = crypto.createHash(algo);
|
|
65522
65944
|
const content = fs8.readFileSync(filePath);
|
|
65523
|
-
|
|
65524
|
-
const actual =
|
|
65945
|
+
hash2.update(content);
|
|
65946
|
+
const actual = hash2.digest("hex");
|
|
65525
65947
|
if (actual !== expectedHex) {
|
|
65526
65948
|
throw new Error(`checksum mismatch for ${path14.basename(filePath)}: expected ${algo}:${expectedHex}, got ${algo}:${actual}`);
|
|
65527
65949
|
}
|
|
@@ -70859,7 +71281,7 @@ function sleepCancellable(ms, signal) {
|
|
|
70859
71281
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
70860
71282
|
});
|
|
70861
71283
|
}
|
|
70862
|
-
var RUNTIME_PACKAGES, WORKSPACE_SETUP_RETRY_DELAY_MS, AGENT_CONFIG_REFRESH_RETRY_DELAY_MS, CLIP_RECONCILE_INTERVAL_MS, RUNTIME_DETECT_INTERVAL_MS, DaemonSupervisor;
|
|
71284
|
+
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
71285
|
var init_supervisor = __esm({
|
|
70864
71286
|
"ts/daemon/dist/supervisor.js"() {
|
|
70865
71287
|
"use strict";
|
|
@@ -70889,6 +71311,7 @@ var init_supervisor = __esm({
|
|
|
70889
71311
|
openclaw: "@parall/openclaw-agent"
|
|
70890
71312
|
};
|
|
70891
71313
|
WORKSPACE_SETUP_RETRY_DELAY_MS = 5e3;
|
|
71314
|
+
PARK_KEEPALIVE_MS = 6e4;
|
|
70892
71315
|
AGENT_CONFIG_REFRESH_RETRY_DELAY_MS = 5e3;
|
|
70893
71316
|
CLIP_RECONCILE_INTERVAL_MS = 5 * 6e4;
|
|
70894
71317
|
RUNTIME_DETECT_INTERVAL_MS = 5 * 6e4;
|
|
@@ -71015,6 +71438,7 @@ var init_supervisor = __esm({
|
|
|
71015
71438
|
if (this.running)
|
|
71016
71439
|
throw new Error("supervisor already running");
|
|
71017
71440
|
this.running = true;
|
|
71441
|
+
this.healthGate?.onSupervisorStarted();
|
|
71018
71442
|
const onAbort = () => {
|
|
71019
71443
|
this.stop().catch((err) => this.log.error(`stop() failed: ${String(err)}`));
|
|
71020
71444
|
};
|
|
@@ -71023,11 +71447,13 @@ var init_supervisor = __esm({
|
|
|
71023
71447
|
if (!await this.bootstrapWithRetry(signal)) {
|
|
71024
71448
|
signal.removeEventListener("abort", onAbort);
|
|
71025
71449
|
this.running = false;
|
|
71450
|
+
this.healthGate?.onSupervisorEnded();
|
|
71026
71451
|
return;
|
|
71027
71452
|
}
|
|
71028
71453
|
} catch (err) {
|
|
71029
71454
|
signal.removeEventListener("abort", onAbort);
|
|
71030
71455
|
this.running = false;
|
|
71456
|
+
this.healthGate?.onSupervisorEnded();
|
|
71031
71457
|
throw err;
|
|
71032
71458
|
}
|
|
71033
71459
|
this.migrateFlatLayout();
|
|
@@ -71084,7 +71510,6 @@ var init_supervisor = __esm({
|
|
|
71084
71510
|
this.log.info(`machine WS connected (machine.hello)${skewMs === null ? "" : ` skew=${skewMs}ms`}`);
|
|
71085
71511
|
if (skewMs !== null)
|
|
71086
71512
|
this.daemonTelemetry?.recordClockSkew(skewMs);
|
|
71087
|
-
this.healthGate?.onMachineHello();
|
|
71088
71513
|
void this.launch.replayAll();
|
|
71089
71514
|
void (async () => {
|
|
71090
71515
|
await this.refreshMachineConfig();
|
|
@@ -71156,13 +71581,16 @@ var init_supervisor = __esm({
|
|
|
71156
71581
|
void this.enqueueBrowserProfileOp(data.profile_id, () => handleBrowserProfileViewerCommand({ pool: this.browserProfilePool, client: this.client, log: this.log }, data));
|
|
71157
71582
|
});
|
|
71158
71583
|
this.ws.onStateChange((state, detail) => {
|
|
71159
|
-
if (state === "disconnected" || state === "reconnecting") {
|
|
71584
|
+
if (state === "disconnected" || state === "reconnecting" || state === "auth-invalid") {
|
|
71160
71585
|
this.log.warn(`machine WS state: ${state}${describeWsStateDetail(detail)}`);
|
|
71161
71586
|
}
|
|
71162
71587
|
if (state === "reconnecting") {
|
|
71163
71588
|
this.daemonTelemetry?.recordWsReconnect({ cause: detail?.cause, closeCode: detail?.code });
|
|
71164
71589
|
}
|
|
71165
71590
|
});
|
|
71591
|
+
this.ws.onAuthInvalid((event) => {
|
|
71592
|
+
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.`);
|
|
71593
|
+
});
|
|
71166
71594
|
await this.ws.connect();
|
|
71167
71595
|
await new Promise((resolve9) => {
|
|
71168
71596
|
this.stopResolve = resolve9;
|
|
@@ -71244,6 +71672,23 @@ var init_supervisor = __esm({
|
|
|
71244
71672
|
this.log.info(`daemon online \u2014 machine_id=${machine.id} org=${machine.org_id} label=${machine.label}`);
|
|
71245
71673
|
return true;
|
|
71246
71674
|
} catch (err) {
|
|
71675
|
+
if (err instanceof ApiError && err.status === 401) {
|
|
71676
|
+
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.`);
|
|
71677
|
+
const parked = setInterval(() => {
|
|
71678
|
+
}, PARK_KEEPALIVE_MS);
|
|
71679
|
+
try {
|
|
71680
|
+
await new Promise((resolve9) => {
|
|
71681
|
+
if (signal.aborted) {
|
|
71682
|
+
resolve9();
|
|
71683
|
+
return;
|
|
71684
|
+
}
|
|
71685
|
+
signal.addEventListener("abort", () => resolve9(), { once: true });
|
|
71686
|
+
});
|
|
71687
|
+
} finally {
|
|
71688
|
+
clearInterval(parked);
|
|
71689
|
+
}
|
|
71690
|
+
return false;
|
|
71691
|
+
}
|
|
71247
71692
|
if (this.config.bootstrapBackoffMs === 0) {
|
|
71248
71693
|
this.log.error(`getMachineSelf failed: ${String(err)} (fail-fast mode)`);
|
|
71249
71694
|
throw err;
|
|
@@ -72113,7 +72558,7 @@ var init_supervisor = __esm({
|
|
|
72113
72558
|
this.agentConfigRefreshRetryTimers.delete(agentId);
|
|
72114
72559
|
}
|
|
72115
72560
|
}
|
|
72116
|
-
async restartChildNow(state, reason) {
|
|
72561
|
+
async restartChildNow(state, reason, opts) {
|
|
72117
72562
|
if (!this.running || state.shuttingDown || state.child || state.restartTimer) {
|
|
72118
72563
|
return;
|
|
72119
72564
|
}
|
|
@@ -72123,7 +72568,9 @@ var init_supervisor = __esm({
|
|
|
72123
72568
|
this.restartingStates.add(state);
|
|
72124
72569
|
try {
|
|
72125
72570
|
state.credential = await this.client.mintLaunchCredential(state.agentId);
|
|
72126
|
-
|
|
72571
|
+
if (!opts?.preserveRestartBackoff) {
|
|
72572
|
+
state.restartAttempts = 0;
|
|
72573
|
+
}
|
|
72127
72574
|
this.log.info(`agent ${state.agentId}: restarting child (${reason})`);
|
|
72128
72575
|
this.startChild(state);
|
|
72129
72576
|
} catch (err) {
|
|
@@ -72136,7 +72583,7 @@ var init_supervisor = __esm({
|
|
|
72136
72583
|
this.log.warn(`agent ${state.agentId}: will retry restart in ${delay}ms`);
|
|
72137
72584
|
state.restartTimer = setTimeout(() => {
|
|
72138
72585
|
state.restartTimer = null;
|
|
72139
|
-
void this.restartChildNow(state, reason);
|
|
72586
|
+
void this.restartChildNow(state, reason, opts);
|
|
72140
72587
|
}, delay);
|
|
72141
72588
|
}
|
|
72142
72589
|
void this.launch.update(state.agentId, restartMintFailedReport(err, state.restartAttempts, retrying));
|
|
@@ -72335,6 +72782,10 @@ var init_supervisor = __esm({
|
|
|
72335
72782
|
this.launch.forget(state.agentId);
|
|
72336
72783
|
return;
|
|
72337
72784
|
}
|
|
72785
|
+
const authInvalidExit = event === "exit" && code === AUTH_INVALID_EXIT_CODE;
|
|
72786
|
+
if (authInvalidExit) {
|
|
72787
|
+
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.`);
|
|
72788
|
+
}
|
|
72338
72789
|
const delay = Math.min(this.config.restartBackoffMs * 2 ** state.restartAttempts, this.config.restartBackoffMaxMs);
|
|
72339
72790
|
state.restartAttempts += 1;
|
|
72340
72791
|
this.log.warn(`agent ${state.agentId} will restart in ${delay}ms`);
|
|
@@ -72348,7 +72799,13 @@ var init_supervisor = __esm({
|
|
|
72348
72799
|
}));
|
|
72349
72800
|
state.restartTimer = setTimeout(() => {
|
|
72350
72801
|
state.restartTimer = null;
|
|
72351
|
-
|
|
72802
|
+
if (authInvalidExit) {
|
|
72803
|
+
void this.restartChildNow(state, "credential rejected (auth-invalid exit)", {
|
|
72804
|
+
preserveRestartBackoff: true
|
|
72805
|
+
});
|
|
72806
|
+
} else {
|
|
72807
|
+
this.startChild(state);
|
|
72808
|
+
}
|
|
72352
72809
|
}, delay);
|
|
72353
72810
|
};
|
|
72354
72811
|
child.once("error", (err) => {
|
|
@@ -72428,11 +72885,11 @@ var init_update_health_gate = __esm({
|
|
|
72428
72885
|
this.timers = timers;
|
|
72429
72886
|
}
|
|
72430
72887
|
/**
|
|
72431
|
-
*
|
|
72432
|
-
*
|
|
72888
|
+
* A supervisor instance started. Arms the stability timer when there is a
|
|
72889
|
+
* pending (unconfirmed) update. No-op once confirmed, while a timer is
|
|
72433
72890
|
* already running, or when there is nothing pending to confirm.
|
|
72434
72891
|
*/
|
|
72435
|
-
|
|
72892
|
+
onSupervisorStarted() {
|
|
72436
72893
|
if (this.confirmed || this.timer)
|
|
72437
72894
|
return;
|
|
72438
72895
|
if (!this.updater.hasPendingActivation())
|
|
@@ -72451,7 +72908,7 @@ var init_update_health_gate = __esm({
|
|
|
72451
72908
|
* The current supervisor instance ended — a clean shutdown or a
|
|
72452
72909
|
* runForever-caught soft crash. Reset the health window (cancel the pending
|
|
72453
72910
|
* confirm timer) without recording any rollback failure; the next supervisor
|
|
72454
|
-
* re-arms via `
|
|
72911
|
+
* re-arms via `onSupervisorStarted`.
|
|
72455
72912
|
*/
|
|
72456
72913
|
onSupervisorEnded() {
|
|
72457
72914
|
if (this.timer) {
|