@parall/daemon 1.62.0 → 1.63.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.
@@ -52322,6 +52322,13 @@ function browserViewerRequestOptions(command, opts) {
52322
52322
  };
52323
52323
  }
52324
52324
 
52325
+ // ts/sdk/dist/clip-connection-endpoints.js
52326
+ var clipConnectionEndpoints = {
52327
+ CLIP_CONNECTIONS: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/connections`,
52328
+ CLIP_CONNECTION_ACCESS: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}/access`,
52329
+ CLIP_CONNECTION: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}`
52330
+ };
52331
+
52325
52332
  // ts/sdk/dist/attachment-endpoints.js
52326
52333
  function attachmentEndpoints(apiBase) {
52327
52334
  return {
@@ -52335,6 +52342,7 @@ function attachmentEndpoints(apiBase) {
52335
52342
  // ts/sdk/dist/edge-endpoints.js
52336
52343
  var API_BASE = "/api/v1";
52337
52344
  var edgeEndpoints = {
52345
+ ORG_EDGE_PROFILE_ACCESS: (orgId, edgeId, profileName) => `${API_BASE}/orgs/${orgId}/edge/${edgeId}/profiles/${encodeURIComponent(profileName)}/access`,
52338
52346
  ORG_EDGE: (orgId) => `${API_BASE}/orgs/${orgId}/edge`,
52339
52347
  ORG_EDGE_CONNECT: (orgId) => `${API_BASE}/orgs/${orgId}/edge/connect`,
52340
52348
  ORG_EDGE_DEVICES: (orgId) => `${API_BASE}/orgs/${orgId}/edge/devices`,
@@ -52526,6 +52534,7 @@ var ENDPOINTS = {
52526
52534
  MACHINES_ME_AGENTS: `${API_BASE2}/machines/me/agents`,
52527
52535
  MACHINES_ME_HEALTH: `${API_BASE2}/machines/me/health`,
52528
52536
  MACHINES_ME_RUNTIME_REPORT: `${API_BASE2}/machines/me/runtime-report`,
52537
+ MACHINES_ME_DIAGNOSTICS: `${API_BASE2}/machines/me/diagnostics`,
52529
52538
  MACHINES_ME_CLIPS: `${API_BASE2}/machines/me/clips`,
52530
52539
  MACHINES_ME_BROWSER_PROFILES: `${API_BASE2}/machines/me/browser-profiles`,
52531
52540
  MACHINES_ME_BROWSER_PROFILE_STATUS: (profileId) => `${API_BASE2}/machines/me/browser-profiles/${profileId}/status`,
@@ -52712,6 +52721,7 @@ var ENDPOINTS = {
52712
52721
  // Wiki History (commits, file commits, blame)
52713
52722
  WIKI_COMMITS: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/commits`,
52714
52723
  WIKI_FILE_COMMITS: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/file-commits`,
52724
+ WIKI_PATH_ACTIVITY: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/path-activity`,
52715
52725
  WIKI_BLAME: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/blame`,
52716
52726
  // Wiki Operations (audit log)
52717
52727
  WIKI_OPERATIONS: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/operations`,
@@ -52847,8 +52857,7 @@ var ENDPOINTS = {
52847
52857
  // Same request/reply shape as the v2 browser-profile viewer, on the v3 edge
52848
52858
  // pipe. Additive: does NOT replace BROWSER_PROFILE_VIEWER_COMMAND.
52849
52859
  ORG_EDGE_VIEWER_COMMAND: (orgId, edgeId) => `/api/v1/orgs/${orgId}/edge/${edgeId}/viewer/command`,
52850
- CLIP_CONNECTIONS: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/connections`,
52851
- CLIP_CONNECTION: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}`,
52860
+ ...clipConnectionEndpoints,
52852
52861
  // Clip registry (v3, org-scoped, served by api-server — `crg_` entries)
52853
52862
  ORG_CLIP_REGISTRY: (orgId) => `/api/v1/orgs/${orgId}/clip-registry`,
52854
52863
  ORG_CLIP_REGISTRY_RESOLVE: (orgId) => `/api/v1/orgs/${orgId}/clip-registry/resolve`,
@@ -53362,6 +53371,39 @@ var ChannelConversationClient = class extends SlackFilesClient {
53362
53371
  }
53363
53372
  };
53364
53373
 
53374
+ // ts/sdk/dist/clip-connection-client.js
53375
+ var ClipConnectionClient = class extends ChannelConversationClient {
53376
+ // ---- Clip connections ----
53377
+ async listClipConnections(orgId, clipId) {
53378
+ return this.request("GET", ENDPOINTS.CLIP_CONNECTIONS(orgId, clipId));
53379
+ }
53380
+ async createClipConnection(orgId, clipId, input) {
53381
+ return this.request("POST", ENDPOINTS.CLIP_CONNECTIONS(orgId, clipId), input);
53382
+ }
53383
+ async deleteClipConnection(orgId, connId) {
53384
+ return this.request("DELETE", ENDPOINTS.CLIP_CONNECTION(orgId, connId));
53385
+ }
53386
+ /** Organization members may read; personal connections are owner-only. */
53387
+ async getClipConnectionAccess(orgId, connId) {
53388
+ return this.request("GET", ENDPOINTS.CLIP_CONNECTION_ACCESS(orgId, connId));
53389
+ }
53390
+ /** Human org owner/admin; accepts JWT or personal key. */
53391
+ async putClipConnectionAccess(orgId, connId, input) {
53392
+ return this.request("PUT", ENDPOINTS.CLIP_CONNECTION_ACCESS(orgId, connId), input);
53393
+ }
53394
+ };
53395
+
53396
+ // ts/sdk/dist/browser-profile-client.js
53397
+ var BrowserProfileClient = class extends ClipConnectionClient {
53398
+ async getBrowserProfileAccess(orgId, edgeId, profileName) {
53399
+ return this.request("GET", ENDPOINTS.ORG_EDGE_PROFILE_ACCESS(orgId, edgeId, profileName));
53400
+ }
53401
+ /** Replace the complete access policy; requires a human org owner/admin. */
53402
+ async putBrowserProfileAccess(orgId, edgeId, profileName, access) {
53403
+ return this.request("PUT", ENDPOINTS.ORG_EDGE_PROFILE_ACCESS(orgId, edgeId, profileName), access);
53404
+ }
53405
+ };
53406
+
53365
53407
  // ts/sdk/dist/wiki-upload.js
53366
53408
  function createWikiUploadFormData(params) {
53367
53409
  const form = new FormData();
@@ -53498,7 +53540,7 @@ function legacyHeartbeatFromReport(report) {
53498
53540
  detectedRuntimes
53499
53541
  };
53500
53542
  }
53501
- var ParallClient = class _ParallClient extends ChannelConversationClient {
53543
+ var ParallClient = class _ParallClient extends BrowserProfileClient {
53502
53544
  baseUrl;
53503
53545
  wikiBaseUrl;
53504
53546
  token;
@@ -54532,6 +54574,17 @@ var ParallClient = class _ParallClient extends ChannelConversationClient {
54532
54574
  await this.postMachineHeartbeat(legacyHeartbeatFromReport(report));
54533
54575
  return "legacy";
54534
54576
  }
54577
+ /**
54578
+ * Upload a diagnostics bundle from the machine itself (`mck_` bearer):
54579
+ * a gzip body the daemon assembled and redacted locally. Multipart so the
54580
+ * meta travels beside the file; the server indexes it for platform staff.
54581
+ */
54582
+ async uploadMachineDiagnostics(bundle, meta = {}) {
54583
+ const form = new FormData();
54584
+ form.append("meta", JSON.stringify(meta));
54585
+ form.append("bundle", new Blob([new Uint8Array(bundle)], { type: "application/gzip" }), "diagnostics.json.gz");
54586
+ return this.multipartRequest("POST", ENDPOINTS.MACHINES_ME_DIAGNOSTICS, form, false, { timeoutMs: 2 * 60 * 1e3 });
54587
+ }
54535
54588
  /**
54536
54589
  * @deprecated Legacy form of `putMachineRuntimeReport`, kept for servers
54537
54590
  * that predate it. `POST /machines/me/health` — report daemon state. All
@@ -55313,6 +55366,10 @@ var ParallClient = class _ParallClient extends ChannelConversationClient {
55313
55366
  ...params
55314
55367
  });
55315
55368
  }
55369
+ /** Bounded, ACL-safe activity for one Wiki file path. */
55370
+ async getWikiPathActivity(orgId, wikiId, path14, opts) {
55371
+ return this.request("GET", ENDPOINTS.WIKI_PATH_ACTIVITY(orgId, wikiId), void 0, { path: path14 }, false, opts);
55372
+ }
55316
55373
  async getWikiBlame(orgId, wikiId, path14, ref) {
55317
55374
  return this.request("GET", ENDPOINTS.WIKI_BLAME(orgId, wikiId), void 0, { path: path14, ref });
55318
55375
  }
@@ -55743,7 +55800,7 @@ var ParallClient = class _ParallClient extends ChannelConversationClient {
55743
55800
  /**
55744
55801
  * Read a clip's per-org exec access (by user id — humans and agents alike).
55745
55802
  * Org-member readable, so a denied caller can learn why exec answered
55746
- * `CLIP_NOT_ALLOWED` / `CLIP_CONNECTION_NOT_ALLOWED` (agents:
55803
+ * `CONNECTION_NOT_ALLOWED` (retired: `CLIP_NOT_ALLOWED` / `CLIP_CONNECTION_NOT_ALLOWED`) (agents:
55747
55804
  * `CLIP_AGENT_NOT_ALLOWED` / `CLIP_AGENT_CONNECTION_NOT_ALLOWED`). Writing
55748
55805
  * it (`putClipAgentExecAccess`) is an org owner/admin's act.
55749
55806
  */
@@ -55783,6 +55840,19 @@ var ParallClient = class _ParallClient extends ChannelConversationClient {
55783
55840
  async deleteEdgeDevice(orgId, edgeId) {
55784
55841
  return this.request("DELETE", ENDPOINTS.ORG_EDGE_DEVICE(orgId, edgeId));
55785
55842
  }
55843
+ /** Move the human caller's OWN BYOC device between the org layer and their
55844
+ * personal layer (ADR-020). `member` takes the device — and every clip
55845
+ * connection bound to it — out of the org's sight and into the owner's sole
55846
+ * custody; `org` shares it back, after which an org admin binds clips to it
55847
+ * and the clip's access list governs exec. Idempotent. Refused for hosted
55848
+ * profiles (`EDGE_NOT_PERSONALIZABLE`), for anyone but the owner
55849
+ * (`FORBIDDEN`; someone else's personal device is `NOT_FOUND`), and for
55850
+ * agents. */
55851
+ async setEdgeManagedBy(orgId, edgeId, managedBy) {
55852
+ return this.request("PATCH", ENDPOINTS.ORG_EDGE_DEVICE(orgId, edgeId), {
55853
+ managed_by: managedBy
55854
+ });
55855
+ }
55786
55856
  /** Idempotently remove the human caller's own offline BYOC registration.
55787
55857
  * A live connection returns `EDGE_ONLINE`. */
55788
55858
  async unregisterEdgeDevice(orgId, edgeId) {
@@ -55865,7 +55935,7 @@ var ParallClient = class _ParallClient extends ChannelConversationClient {
55865
55935
  return this.request("GET", ENDPOINTS.ORG_BROWSER_ALIAS_EXECUTION(orgId, requestId));
55866
55936
  }
55867
55937
  /** Accept one idempotent Browser Use operation for an explicit Profile.
55868
- * The Server resolves Profile→Edge; callers never select an Edge directly. */
55938
+ * JWT, personal, agent and managed keys use profile access. The Server resolves Profile→Edge. */
55869
55939
  async createBrowserUseOperation(orgId, request3) {
55870
55940
  return this.request("POST", ENDPOINTS.ORG_BROWSER_USE_OPERATIONS(orgId), request3);
55871
55941
  }
@@ -55982,9 +56052,9 @@ var ParallClient = class _ParallClient extends ChannelConversationClient {
55982
56052
  * - `EDGE_DEADLINE_EXCEEDED` 504 — arrived late, provably NOT executed.
55983
56053
  * - `EDGE_HOSTED_DISABLED_FOR_ORG` 403, `EDGE_REPAIR` 503 (operator-held),
55984
56054
  * `EDGE_RUNTIME_UNAVAILABLE` 503 (deployment has no hosted runtime).
55985
- * - Access errors (decided before any side effect): `CLIP_NOT_ALLOWED`
55986
- * (no grant for this clip), `CLIP_CONNECTION_NOT_ALLOWED` (grant does
55987
- * not cover this connection) — agent principals receive the historical
56055
+ * - Access errors (before side effects): human `CONNECTION_NOT_ALLOWED`.
56056
+ * `CLIP_NOT_ALLOWED` / `CLIP_CONNECTION_NOT_ALLOWED` are retired.
56057
+ * Agent principals receive the historical
55988
56058
  * `CLIP_AGENT_NOT_ALLOWED` / `CLIP_AGENT_CONNECTION_NOT_ALLOWED` for one
55989
56059
  * release. An org owner/admin can widen access in the clip's settings.
55990
56060
  * - Routing errors: `CONNECTION_REQUIRED`, `CONNECTION_NOT_FOUND`,
@@ -56006,16 +56076,6 @@ var ParallClient = class _ParallClient extends ChannelConversationClient {
56006
56076
  throw err;
56007
56077
  }
56008
56078
  }
56009
- // ---- Clip connections ----
56010
- async listClipConnections(orgId, clipId) {
56011
- return this.request("GET", ENDPOINTS.CLIP_CONNECTIONS(orgId, clipId));
56012
- }
56013
- async createClipConnection(orgId, clipId, input) {
56014
- return this.request("POST", ENDPOINTS.CLIP_CONNECTIONS(orgId, clipId), input);
56015
- }
56016
- async deleteClipConnection(orgId, connId) {
56017
- return this.request("DELETE", ENDPOINTS.CLIP_CONNECTION(orgId, connId));
56018
- }
56019
56079
  // ---- MCP clip server config (same-org or reviewed Official OAuth) ----
56020
56080
  /**
56021
56081
  * Read the redacted MCP config. 404 NOT_FOUND when the clip has none yet —
@@ -56663,12 +56723,15 @@ function createActiveForkState(fork, targetId, continuationPrefix) {
56663
56723
 
56664
56724
  // ts/agent-core/dist/redact.js
56665
56725
  function redactSecrets(s, knownValues = []) {
56726
+ 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, "***");
56727
+ }
56728
+ function maskKnownValues(s, knownValues) {
56666
56729
  let out = s;
56667
56730
  for (const v of knownValues) {
56668
56731
  if (typeof v === "string" && v.length >= 6)
56669
56732
  out = out.split(v).join("***");
56670
56733
  }
56671
- return out.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\s+)[A-Za-z0-9._~+/=-]{8,}/gi, "$1***").replace(/[A-Za-z0-9_-]{32,}/g, "***");
56734
+ return out;
56672
56735
  }
56673
56736
  function redactTurnOutcome(event, knownValues) {
56674
56737
  const redacted = { ...event };
@@ -56689,6 +56752,16 @@ function describeTurnOutcomeFailure(outcome) {
56689
56752
  stepMessage: `LLM turn ${outcome.outcome}${retryNote}${outcome.detail ? `: ${outcome.detail}` : ""}`
56690
56753
  };
56691
56754
  }
56755
+ function redactLogger(log2, knownValues) {
56756
+ if (!log2)
56757
+ return void 0;
56758
+ return {
56759
+ info: (message) => log2.info(redactSecrets(message, knownValues)),
56760
+ warn: (message) => log2.warn(redactSecrets(message, knownValues)),
56761
+ error: (message) => log2.error(redactSecrets(message, knownValues)),
56762
+ ...log2.child ? { child: (name) => redactLogger(log2.child(name), knownValues) } : {}
56763
+ };
56764
+ }
56692
56765
 
56693
56766
  // ts/agent-core/dist/lane-ledger.js
56694
56767
  import * as fs2 from "node:fs";
@@ -57023,10 +57096,10 @@ ${frame}` : frame;
57023
57096
  return {
57024
57097
  deliveryKey: dispatchEventIds.join(","),
57025
57098
  dispatchEventIds,
57026
- update: explicit ? (state) => this.updateInputState(lane, dispatchEventIds, state) : async () => void 0
57099
+ update: explicit ? (state, failure) => this.updateInputState(lane, dispatchEventIds, state, failure) : async () => void 0
57027
57100
  };
57028
57101
  }
57029
- async updateInputState(lane, dispatchEventIds, state) {
57102
+ async updateInputState(lane, dispatchEventIds, state, failure) {
57030
57103
  const failed = new Set(state === "failed" ? dispatchEventIds : []);
57031
57104
  const failedSourceIds = [...lane.folded].filter(([, dispatchEventId]) => failed.has(dispatchEventId)).map(([sourceId]) => sourceId);
57032
57105
  const restoreLocalClaims = failedSourceIds.length > 0 ? this.opts.releaseLocalClaims?.(failedSourceIds) : void 0;
@@ -57036,7 +57109,11 @@ ${frame}` : frame;
57036
57109
  target_uri: lane.targetUri,
57037
57110
  thread_root_id: lane.threadRootId,
57038
57111
  dispatch_event_ids: dispatchEventIds,
57039
- state
57112
+ state,
57113
+ ...state === "failed" && failure ? {
57114
+ outcome_class: errorWireClass(failure.outcomeClass),
57115
+ detail: failure.detail ? redactSecrets(failure.detail, this.opts.knownSecrets).slice(0, 500) : void 0
57116
+ } : {}
57040
57117
  });
57041
57118
  if (result.recognized !== dispatchEventIds.length) {
57042
57119
  throw new Error(`input lifecycle ${state} recognized ${result.recognized}/${dispatchEventIds.length} WorkItems`);
@@ -57057,19 +57134,7 @@ ${frame}` : frame;
57057
57134
  }
57058
57135
  return { retry: state === "failed" };
57059
57136
  }
57060
- /**
57061
- * Complete the lane when no local work remains for it: the server sweeps
57062
- * still-leased members as no_action, releases the occupancy row, and
57063
- * re-drives any same-target pending work. A STALE_LANE answer means a
57064
- * takeover already owns the resource — local state is dropped either way.
57065
- */
57066
- /**
57067
- * Record that the turn on this lane surfaced a runtime error. The flow
57068
- * settles an errored lane immediately (dispatchLaneGroup returns 'failed'
57069
- * after a forced complete), so the bit normally lives for one turn only —
57070
- * it is the transport between the gateway's per-session error signal and
57071
- * this lane's complete request.
57072
- */
57137
+ /** Carry the runtime error into the lane's forced completion. */
57073
57138
  markTurnError(laneKey, info = {}) {
57074
57139
  const lane = this.lanes.get(laneKey);
57075
57140
  if (lane)
@@ -58459,6 +58524,9 @@ async function consumeTypedDispatch(host, ref, run, hooks) {
58459
58524
  }
58460
58525
  }
58461
58526
  }
58527
+ } catch (err) {
58528
+ ledger.markTurnError(claimed.laneKey, releaseErrorInfo(err, [host.opts.config.api_key]));
58529
+ throw err;
58462
58530
  } finally {
58463
58531
  settle(resolved);
58464
58532
  span.setAttribute("dispatch.lane_result", resolved ? "dispatched" : "released");
@@ -59990,12 +60058,14 @@ var ParallAgentGateway = class {
59990
60058
  DISPATCH_DEADLINE_MS;
59991
60059
  constructor(opts) {
59992
60060
  this.opts = opts;
60061
+ opts = this.opts = { ...opts, log: redactLogger(opts.log, [opts.config.api_key]) };
59993
60062
  if (opts.dispatchContextDir) {
59994
60063
  this.laneLedger = new LaneLedger({
59995
60064
  client: opts.client,
59996
60065
  orgId: opts.config.org_id,
59997
60066
  contextDir: opts.dispatchContextDir,
59998
60067
  log: opts.log,
60068
+ knownSecrets: [opts.config.api_key],
59999
60069
  coverageMode: opts.dispatchAdapter.inputLifecycleMode ?? "implicit",
60000
60070
  releaseLocalClaims: (sourceIds) => releaseLocalMessageClaims(this.dispatchedMessages, sourceIds)
60001
60071
  });
@@ -60166,12 +60236,6 @@ var ParallAgentGateway = class {
60166
60236
  * this safe: every bridge emits its error events before the turn-boundary
60167
60237
  * turn_outcome.
60168
60238
  */
60169
- /**
60170
- * Redaction for every runtime-error text that gets persisted or shown: the
60171
- * turn-outcome detail, the runtime error step and the dispatch-failure
60172
- * step all surface in the product, and a runtime error can echo the agent
60173
- * key or a provider credential.
60174
- */
60175
60239
  redactRuntimeText(text) {
60176
60240
  return redactSecrets(text, [this.opts.config.api_key]).slice(0, 2e3);
60177
60241
  }
@@ -62715,12 +62779,16 @@ parall clip tools <clip> # MCP clips only: live tool schemas
62715
62779
  \`\`\`
62716
62780
 
62717
62781
  \`clip list\` answers both discovery questions at once: WHICH clip (name,
62718
- description, version) and WHERE it can run \u2014 every connection with its
62719
- \`ccn_\u2026\` id, alias, and target kind:
62782
+ description, version) and WHERE it could run \u2014 every connection you can SEE
62783
+ (public org-layer rows or those the clip's access list admits you to, plus rows on your
62784
+ own personal device; an admin's list is a management view of the whole org
62785
+ layer and does not by itself grant exec) with its \`ccn_\u2026\` id, alias, and
62786
+ target kind:
62720
62787
 
62721
62788
  - \`cloud\` \u2014 an org-shared cloud profile (a maintainer's signed-in browser)
62722
62789
  - \`desktop\` \u2014 a member's device: org-shared (\`layer: org\` \u2014 an org admin
62723
- binds it, the clip's access list decides, same as cloud and MCP) or
62790
+ binds it; public connections admit everyone, otherwise the clip's access
62791
+ list decides, same as cloud and MCP) or
62724
62792
  personal (\`layer: personal\` \u2014 its owner alone, nobody else sees it)
62725
62793
  - \`mcp\` \u2014 a remote MCP tool server
62726
62794
  - \`device\` \u2014 a device whose placement could not be resolved just now (the
@@ -62760,6 +62828,8 @@ bound to the clip, and the connection is what your access is granted on.
62760
62828
 
62761
62829
  - Without a connection the server answers \`AGENT_CONNECTION_REQUIRED\`; the
62762
62830
  fix is to discover the clip's connections and name one, never to retry.
62831
+ - human \u8C03\u7528\u8FD4\u56DE \`CONNECTION_NOT_ALLOWED\` \u65F6\uFF0C\u8BF7 org admin \u516C\u5F00\u8BE5 connection
62832
+ \u6216\u628A\u8C03\u7528\u8005\u52A0\u5165 Clip \u540D\u5355\uFF1Bagent \u672C\u7248\u4ECD\u8FD4\u56DE\u4E0B\u8FF0\u4E24\u4E2A\u9519\u8BEF\u7801\u3002
62763
62833
  - \`CLIP_AGENT_NOT_ALLOWED\` / \`CLIP_AGENT_CONNECTION_NOT_ALLOWED\` mean a
62764
62834
  human has restricted who may run this clip (or through which account);
62765
62835
  ask them to widen access \u2014 you cannot grant it to yourself.
@@ -62809,10 +62879,20 @@ parall clip exec <clip> <tool> [json-args] --connection <ccn_|alias>
62809
62879
  - \`OUTCOME_UNKNOWN\` follows the rule below: dispatched and MAY HAVE
62810
62880
  EXECUTED \u2014 never auto-retry.
62811
62881
 
62882
+ ## Browser Use
62883
+
62884
+ Browser Use \u63A5\u53D7 personal key \u548C agent key\uFF0C\u65E0\u9700 managed key\uFF1B\u6743\u9650\u6309\u8C03\u7528\u8005
62885
+ \u5728\u76EE\u6807\u8BBE\u5907 profile \u4E0A\u7684\u6388\u6743\u88C1\u51B3\u3002\`PROFILE_NOT_ALLOWED\` \u8868\u793A\u672A\u83B7\u6388\u6743\uFF0C
62886
+ \u8BF7 org admin \u8C03\u6574\u8BE5 profile \u7684\u516C\u5F00\u72B6\u6001\u6216\u540D\u5355\uFF0C\u4E0D\u8981\u91CD\u8BD5\u6216\u6539\u7528\u5176\u4ED6 key \u7ED5\u8FC7\u3002
62887
+ profile \u516C\u5F00\u53EA\u6388\u4E88 browser.read / browser.interact\uFF0Cbrowser.advanced \u4ECD\u9700\u663E\u5F0F\u6388\u6743\u3002
62888
+ Clip exec \u7684 connection \u662F\u53E6\u4E00\u79CD\u76EE\u6807\uFF1Aagent \u8C03\u7528\u4ECD\u5FC5\u987B\u5E26 connection\uFF0C\u7F3A\u5931\u4F1A\u8FD4\u56DE
62889
+ \`AGENT_CONNECTION_REQUIRED\`\uFF0C\u5148\u53D1\u73B0 connection \u518D\u8C03\u7528\u3002
62890
+
62812
62891
  ## Behavior rules
62813
62892
 
62814
62893
  - An authorization error (\`CLIP_AGENT_NOT_ALLOWED\`,
62815
- \`CLIP_AGENT_CONNECTION_NOT_ALLOWED\`, \`FORBIDDEN\`) is a fail-fast: ask
62894
+ \`CLIP_AGENT_CONNECTION_NOT_ALLOWED\`, \`CONNECTION_NOT_ALLOWED\`,
62895
+ \`PROFILE_NOT_ALLOWED\`, \`FORBIDDEN\`) is a fail-fast: ask
62816
62896
  an org admin to grant the clip or the connection \u2014 do not retry or work
62817
62897
  around it.
62818
62898
  - If the target device is offline or the call times out, report that
@@ -64230,6 +64310,131 @@ function aggregateBusyState(states) {
64230
64310
  // ts/claude-agent/dist/input-lifecycle.js
64231
64311
  import { randomUUID as randomUUID4 } from "node:crypto";
64232
64312
 
64313
+ // ts/claude-agent/dist/turn-outcome.js
64314
+ var LIMIT_TEXT = /you'?ve (hit|reached) your .*limit|usage limit reached|weekly limit/i;
64315
+ var AUTH_TEXT = /not logged in|please run \/login|authentication_error|invalid api key|oauth token (has )?expired|\[action required\]/i;
64316
+ var CONTEXT_TEXT = /prompt is too long|context (window|length) exceeded|request too large/i;
64317
+ var DETAIL_MAX = 500;
64318
+ function minutesOfDayInZone(fmt, at) {
64319
+ const parts = Object.fromEntries(fmt.formatToParts(at).filter((p) => p.type !== "literal").map((p) => [p.type, Number(p.value)]));
64320
+ const hour = parts.hour === 24 ? 0 : parts.hour;
64321
+ return hour * 60 + parts.minute;
64322
+ }
64323
+ function parseClaudeResetTime(text, now) {
64324
+ const m = /resets\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\s*\(([^)]+)\)/i.exec(text);
64325
+ if (!m)
64326
+ return void 0;
64327
+ let hour = Number(m[1]);
64328
+ const minute = m[2] ? Number(m[2]) : 0;
64329
+ const meridiem = m[3]?.toLowerCase();
64330
+ const timeZone = m[4].trim();
64331
+ if (!Number.isFinite(hour) || hour > 23 || minute > 59)
64332
+ return void 0;
64333
+ if (meridiem === "pm" && hour < 12)
64334
+ hour += 12;
64335
+ if (meridiem === "am" && hour === 12)
64336
+ hour = 0;
64337
+ let fmt;
64338
+ let nowMinutesOfDay;
64339
+ try {
64340
+ fmt = new Intl.DateTimeFormat("en-US", {
64341
+ timeZone,
64342
+ hour12: false,
64343
+ hour: "2-digit",
64344
+ minute: "2-digit"
64345
+ });
64346
+ nowMinutesOfDay = minutesOfDayInZone(fmt, now);
64347
+ } catch {
64348
+ return void 0;
64349
+ }
64350
+ const targetMinutesOfDay = hour * 60 + minute;
64351
+ let deltaMinutes = targetMinutesOfDay - nowMinutesOfDay;
64352
+ if (deltaMinutes <= 0)
64353
+ deltaMinutes += 24 * 60;
64354
+ const anchored = now.getTime() - (now.getSeconds() * 1e3 + now.getMilliseconds());
64355
+ let target = anchored + deltaMinutes * 6e4;
64356
+ for (let i = 0; i < 2; i++) {
64357
+ let diff = targetMinutesOfDay - minutesOfDayInZone(fmt, new Date(target));
64358
+ if (diff > 720)
64359
+ diff -= 1440;
64360
+ if (diff < -720)
64361
+ diff += 1440;
64362
+ if (diff === 0)
64363
+ break;
64364
+ target += diff * 6e4;
64365
+ }
64366
+ if (target <= now.getTime())
64367
+ target += 24 * 60 * 6e4;
64368
+ return new Date(target).toISOString();
64369
+ }
64370
+ function usageOf(meta) {
64371
+ const usage = {};
64372
+ if (meta.inputTokens !== void 0)
64373
+ usage.inputTokens = meta.inputTokens;
64374
+ if (meta.outputTokens !== void 0)
64375
+ usage.outputTokens = meta.outputTokens;
64376
+ if (meta.cacheReadTokens !== void 0)
64377
+ usage.cacheReadTokens = meta.cacheReadTokens;
64378
+ if (meta.cacheCreationTokens !== void 0)
64379
+ usage.cacheCreationTokens = meta.cacheCreationTokens;
64380
+ if (meta.totalCostUsd !== void 0)
64381
+ usage.costUsd = meta.totalCostUsd;
64382
+ if (meta.durationMs !== void 0)
64383
+ usage.durationMs = meta.durationMs;
64384
+ if (meta.durationApiMs !== void 0)
64385
+ usage.durationApiMs = meta.durationApiMs;
64386
+ return Object.keys(usage).length > 0 ? usage : void 0;
64387
+ }
64388
+ function classifyClaudeTurn(meta, noticeTexts, now = /* @__PURE__ */ new Date()) {
64389
+ if (!meta) {
64390
+ return { type: "turn_outcome", outcome: "runtime_crash" };
64391
+ }
64392
+ const usage = usageOf(meta);
64393
+ const evidence = [meta.resultText, ...noticeTexts].filter(Boolean).join("\n");
64394
+ const base = {
64395
+ type: "turn_outcome",
64396
+ ...usage ? { usage } : {},
64397
+ ...meta.model ? { model: meta.model } : {},
64398
+ raw: {
64399
+ ...meta.subtype ? { subtype: meta.subtype } : {},
64400
+ ...meta.terminalReason ? { terminal_reason: meta.terminalReason } : {},
64401
+ ...meta.apiErrorStatus !== void 0 ? { api_error_status: meta.apiErrorStatus } : {},
64402
+ ...meta.stopReason ? { stop_reason: meta.stopReason } : {}
64403
+ }
64404
+ };
64405
+ const withDetail = (outcome, retryAt) => ({
64406
+ ...base,
64407
+ outcome,
64408
+ ...evidence ? { detail: evidence.slice(0, DETAIL_MAX) } : {},
64409
+ ...retryAt ? { retryAt } : {}
64410
+ });
64411
+ if (meta.apiErrorStatus === 401 || meta.apiErrorStatus === 403)
64412
+ return withDetail("auth");
64413
+ if (meta.apiErrorStatus === 413)
64414
+ return withDetail("context_overflow");
64415
+ if (meta.apiErrorStatus === 429) {
64416
+ return withDetail("usage_limit", evidence ? parseClaudeResetTime(evidence, now) : void 0);
64417
+ }
64418
+ const failed = meta.isError || // Claude CLI 2.1.220 sets terminal_reason=completed on clean result
64419
+ // frames. Any other terminal reason stays fail-closed.
64420
+ meta.terminalReason !== void 0 && meta.terminalReason !== "completed" || meta.subtype !== void 0 && meta.subtype !== "success";
64421
+ const syntheticQuiet = !failed && // A "successful" turn that never touched the API and produced no tool
64422
+ // activity is the synthetic-notice shape (limit/auth text emitted
64423
+ // locally by the CLI): zero usage + stop_sequence.
64424
+ meta.stopReason === "stop_sequence" && (meta.inputTokens ?? 0) === 0 && (meta.outputTokens ?? 0) === 0 && (meta.durationApiMs ?? 0) === 0;
64425
+ if (failed || syntheticQuiet || noticeTexts.length > 0) {
64426
+ if (CONTEXT_TEXT.test(evidence))
64427
+ return withDetail("context_overflow");
64428
+ if (LIMIT_TEXT.test(evidence)) {
64429
+ return withDetail("usage_limit", parseClaudeResetTime(evidence, now));
64430
+ }
64431
+ if (AUTH_TEXT.test(evidence))
64432
+ return withDetail("auth");
64433
+ return withDetail("api_error");
64434
+ }
64435
+ return { ...base, outcome: "ok" };
64436
+ }
64437
+
64233
64438
  // ts/agent-core/dist/internal/async-queue.js
64234
64439
  var AsyncQueue = class {
64235
64440
  opts;
@@ -64409,7 +64614,7 @@ var ClaudeInputRegistry = class {
64409
64614
  if (delivery.drained)
64410
64615
  this.remove(delivery);
64411
64616
  }
64412
- async fail(delivery) {
64617
+ async fail(delivery, detail) {
64413
64618
  if (delivery.terminal)
64414
64619
  return;
64415
64620
  if (delivery.suppressFailReport) {
@@ -64420,7 +64625,11 @@ var ClaudeInputRegistry = class {
64420
64625
  }
64421
64626
  try {
64422
64627
  if (delivery.reportedState !== "failed") {
64423
- const result = await delivery.lifecycle?.update("failed");
64628
+ const classified = classifyClaudeTurn(delivery.evidence.lastResultMeta, delivery.evidence.noticeTexts);
64629
+ const result = await delivery.lifecycle?.update("failed", {
64630
+ outcomeClass: classified.outcome === "ok" || classified.outcome === "usage_limit" ? "runtime_crash" : classified.outcome,
64631
+ detail: detail ?? classified.detail ?? "Claude input failed"
64632
+ });
64424
64633
  delivery.reportedState = "failed";
64425
64634
  delivery.terminal = result?.retry === false ? "settled" : "failed";
64426
64635
  }
@@ -64430,15 +64639,15 @@ var ClaudeInputRegistry = class {
64430
64639
  this.remove(delivery);
64431
64640
  }
64432
64641
  }
64433
- async failBestEffort(delivery, log2) {
64642
+ async failBestEffort(delivery, log2, detail) {
64434
64643
  try {
64435
- await this.fail(delivery);
64644
+ await this.fail(delivery, detail);
64436
64645
  } catch (err) {
64437
64646
  log2?.warn?.(`failed to report Claude input ${delivery.commandUuid} as failed: ${String(err)}`);
64438
64647
  }
64439
64648
  }
64440
- async failAllBestEffort(log2) {
64441
- await Promise.all([...this.byKey.values()].filter((delivery) => !delivery.terminal).map((delivery) => this.failBestEffort(delivery, log2)));
64649
+ async failAllBestEffort(log2, detail) {
64650
+ await Promise.all([...this.byKey.values()].filter((delivery) => !delivery.terminal).map((delivery) => this.failBestEffort(delivery, log2, detail)));
64442
64651
  }
64443
64652
  };
64444
64653
 
@@ -64794,131 +65003,6 @@ function extractResultMeta(frame, isError, numTurns) {
64794
65003
  return meta;
64795
65004
  }
64796
65005
 
64797
- // ts/claude-agent/dist/turn-outcome.js
64798
- var LIMIT_TEXT = /you'?ve (hit|reached) your .*limit|usage limit reached|weekly limit/i;
64799
- var AUTH_TEXT = /not logged in|please run \/login|authentication_error|invalid api key|oauth token (has )?expired|\[action required\]/i;
64800
- var CONTEXT_TEXT = /prompt is too long|context (window|length) exceeded|request too large/i;
64801
- var DETAIL_MAX = 500;
64802
- function minutesOfDayInZone(fmt, at) {
64803
- const parts = Object.fromEntries(fmt.formatToParts(at).filter((p) => p.type !== "literal").map((p) => [p.type, Number(p.value)]));
64804
- const hour = parts.hour === 24 ? 0 : parts.hour;
64805
- return hour * 60 + parts.minute;
64806
- }
64807
- function parseClaudeResetTime(text, now) {
64808
- const m = /resets\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\s*\(([^)]+)\)/i.exec(text);
64809
- if (!m)
64810
- return void 0;
64811
- let hour = Number(m[1]);
64812
- const minute = m[2] ? Number(m[2]) : 0;
64813
- const meridiem = m[3]?.toLowerCase();
64814
- const timeZone = m[4].trim();
64815
- if (!Number.isFinite(hour) || hour > 23 || minute > 59)
64816
- return void 0;
64817
- if (meridiem === "pm" && hour < 12)
64818
- hour += 12;
64819
- if (meridiem === "am" && hour === 12)
64820
- hour = 0;
64821
- let fmt;
64822
- let nowMinutesOfDay;
64823
- try {
64824
- fmt = new Intl.DateTimeFormat("en-US", {
64825
- timeZone,
64826
- hour12: false,
64827
- hour: "2-digit",
64828
- minute: "2-digit"
64829
- });
64830
- nowMinutesOfDay = minutesOfDayInZone(fmt, now);
64831
- } catch {
64832
- return void 0;
64833
- }
64834
- const targetMinutesOfDay = hour * 60 + minute;
64835
- let deltaMinutes = targetMinutesOfDay - nowMinutesOfDay;
64836
- if (deltaMinutes <= 0)
64837
- deltaMinutes += 24 * 60;
64838
- const anchored = now.getTime() - (now.getSeconds() * 1e3 + now.getMilliseconds());
64839
- let target = anchored + deltaMinutes * 6e4;
64840
- for (let i = 0; i < 2; i++) {
64841
- let diff = targetMinutesOfDay - minutesOfDayInZone(fmt, new Date(target));
64842
- if (diff > 720)
64843
- diff -= 1440;
64844
- if (diff < -720)
64845
- diff += 1440;
64846
- if (diff === 0)
64847
- break;
64848
- target += diff * 6e4;
64849
- }
64850
- if (target <= now.getTime())
64851
- target += 24 * 60 * 6e4;
64852
- return new Date(target).toISOString();
64853
- }
64854
- function usageOf(meta) {
64855
- const usage = {};
64856
- if (meta.inputTokens !== void 0)
64857
- usage.inputTokens = meta.inputTokens;
64858
- if (meta.outputTokens !== void 0)
64859
- usage.outputTokens = meta.outputTokens;
64860
- if (meta.cacheReadTokens !== void 0)
64861
- usage.cacheReadTokens = meta.cacheReadTokens;
64862
- if (meta.cacheCreationTokens !== void 0)
64863
- usage.cacheCreationTokens = meta.cacheCreationTokens;
64864
- if (meta.totalCostUsd !== void 0)
64865
- usage.costUsd = meta.totalCostUsd;
64866
- if (meta.durationMs !== void 0)
64867
- usage.durationMs = meta.durationMs;
64868
- if (meta.durationApiMs !== void 0)
64869
- usage.durationApiMs = meta.durationApiMs;
64870
- return Object.keys(usage).length > 0 ? usage : void 0;
64871
- }
64872
- function classifyClaudeTurn(meta, noticeTexts, now = /* @__PURE__ */ new Date()) {
64873
- if (!meta) {
64874
- return { type: "turn_outcome", outcome: "runtime_crash" };
64875
- }
64876
- const usage = usageOf(meta);
64877
- const evidence = [meta.resultText, ...noticeTexts].filter(Boolean).join("\n");
64878
- const base = {
64879
- type: "turn_outcome",
64880
- ...usage ? { usage } : {},
64881
- ...meta.model ? { model: meta.model } : {},
64882
- raw: {
64883
- ...meta.subtype ? { subtype: meta.subtype } : {},
64884
- ...meta.terminalReason ? { terminal_reason: meta.terminalReason } : {},
64885
- ...meta.apiErrorStatus !== void 0 ? { api_error_status: meta.apiErrorStatus } : {},
64886
- ...meta.stopReason ? { stop_reason: meta.stopReason } : {}
64887
- }
64888
- };
64889
- const withDetail = (outcome, retryAt) => ({
64890
- ...base,
64891
- outcome,
64892
- ...evidence ? { detail: evidence.slice(0, DETAIL_MAX) } : {},
64893
- ...retryAt ? { retryAt } : {}
64894
- });
64895
- if (meta.apiErrorStatus === 401 || meta.apiErrorStatus === 403)
64896
- return withDetail("auth");
64897
- if (meta.apiErrorStatus === 413)
64898
- return withDetail("context_overflow");
64899
- if (meta.apiErrorStatus === 429) {
64900
- return withDetail("usage_limit", evidence ? parseClaudeResetTime(evidence, now) : void 0);
64901
- }
64902
- const failed = meta.isError || // Claude CLI 2.1.220 sets terminal_reason=completed on clean result
64903
- // frames. Any other terminal reason stays fail-closed.
64904
- meta.terminalReason !== void 0 && meta.terminalReason !== "completed" || meta.subtype !== void 0 && meta.subtype !== "success";
64905
- const syntheticQuiet = !failed && // A "successful" turn that never touched the API and produced no tool
64906
- // activity is the synthetic-notice shape (limit/auth text emitted
64907
- // locally by the CLI): zero usage + stop_sequence.
64908
- meta.stopReason === "stop_sequence" && (meta.inputTokens ?? 0) === 0 && (meta.outputTokens ?? 0) === 0 && (meta.durationApiMs ?? 0) === 0;
64909
- if (failed || syntheticQuiet || noticeTexts.length > 0) {
64910
- if (CONTEXT_TEXT.test(evidence))
64911
- return withDetail("context_overflow");
64912
- if (LIMIT_TEXT.test(evidence)) {
64913
- return withDetail("usage_limit", parseClaudeResetTime(evidence, now));
64914
- }
64915
- if (AUTH_TEXT.test(evidence))
64916
- return withDetail("auth");
64917
- return withDetail("api_error");
64918
- }
64919
- return { ...base, outcome: "ok" };
64920
- }
64921
-
64922
65006
  // ts/claude-agent/dist/runtime-turn.js
64923
65007
  var ClaudeRuntimeTurn = class extends RuntimeTurnBase {
64924
65008
  sink;
@@ -65341,8 +65425,9 @@ var ClaudeProcessPump = class {
65341
65425
  if (!delivery.terminal && settledAsLimit(delivery.evidence))
65342
65426
  delivery.suppressFailReport = true;
65343
65427
  }
65344
- await inputs.failAllBestEffort(log2);
65345
- for (const delivery of inputs.values()) {
65428
+ const deliveries = [...inputs.values()];
65429
+ await inputs.failAllBestEffort(log2, message);
65430
+ for (const delivery of deliveries) {
65346
65431
  delivery.sink.push({ kind: "ended", reason: "eof", message });
65347
65432
  delivery.sink.close();
65348
65433
  }
@@ -65653,7 +65738,10 @@ var ClaudeCodeAdapter = class {
65653
65738
  state = this.ensureProcess(sessionKey, log2);
65654
65739
  } catch (err) {
65655
65740
  try {
65656
- await lifecycle?.update("failed");
65741
+ await lifecycle?.update("failed", {
65742
+ outcomeClass: "runtime_crash",
65743
+ detail: `Claude spawn failed: ${String(err)}`
65744
+ });
65657
65745
  } catch (reportErr) {
65658
65746
  log2?.warn?.(`failed to report rejected Claude input as failed: ${String(reportErr)}`);
65659
65747
  }
@@ -65664,7 +65752,7 @@ var ClaudeCodeAdapter = class {
65664
65752
  try {
65665
65753
  this.writeUserMessage(state.handle, promptBody, delivery.commandUuid);
65666
65754
  } catch (err) {
65667
- await state.inputs.failBestEffort(delivery, log2);
65755
+ await state.inputs.failBestEffort(delivery, log2, `Claude stdin write failed: ${String(err)}`);
65668
65756
  state.inputs.remove(delivery);
65669
65757
  yield { type: "error", message: `Claude stdin write failed: ${String(err)}` };
65670
65758
  this.killProcess(sessionKey, state);
@@ -65898,7 +65986,9 @@ var ClaudeCodeAdapter = class {
65898
65986
  proc.stderr.on("data", (chunk) => {
65899
65987
  stderrChunks.push(chunk.toString());
65900
65988
  });
65901
- proc.stdin.on("error", () => {
65989
+ proc.stdin.on("error", (err) => {
65990
+ stderrChunks.push(`Claude stdin failed: ${String(err)}
65991
+ `);
65902
65992
  proc.stdin.destroy();
65903
65993
  if (proc.exitCode === null && proc.signalCode === null) {
65904
65994
  if (!IS_WIN32 || !proc.pid || !killWin32Tree(proc.pid)) {