@humain/humain-code 0.8.2 → 0.8.3

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/bundle/chunks/{chunk-EFY2QPVP.js → chunk-2XD7TLKB.js} +4 -4
  3. package/dist/bundle/chunks/{chunk-U4EAJPMO.js → chunk-4GB7A76U.js} +39 -35
  4. package/dist/bundle/chunks/{chunk-PJXBU6CR.js → chunk-7LSTTCSC.js} +111 -89
  5. package/dist/bundle/chunks/{chunk-H2B3WLIM.js → chunk-AW24RHGJ.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-3PJ7NPWN.js → chunk-B3ZLWVDA.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-H7UPU2SH.js → chunk-MUN4ZZZP.js} +706 -703
  8. package/dist/bundle/chunks/chunk-S2US54IU.js +37 -0
  9. package/dist/bundle/chunks/{chunk-G2QMON4O.js → chunk-VSXVZVBE.js} +3 -3
  10. package/dist/bundle/chunks/{chunk-JQBZUFH7.js → chunk-ZAHVC5V2.js} +175 -164
  11. package/dist/bundle/chunks/{compat-ELBUCH6U.js → compat-4ILE5BEC.js} +1 -1
  12. package/dist/bundle/chunks/{dist-QSYDYE3Y.js → dist-I6CI3CG5.js} +6 -6
  13. package/dist/bundle/chunks/{dist-NERIS6SW.js → dist-NXHRL2KY.js} +1 -1
  14. package/dist/bundle/chunks/{entry-SRYLSS5P.js → entry-6XDR2IDE.js} +1 -1
  15. package/dist/bundle/chunks/{flow-implementer-3P3BHQ7E.js → flow-implementer-XOP4MG5X.js} +3 -3
  16. package/dist/bundle/chunks/{inprocess-3PDJKE5F.js → inprocess-MBKFGDM2.js} +4 -4
  17. package/dist/bundle/chunks/{interactive-mode-SDUO5OLD.js → interactive-mode-3322RQEH.js} +2 -2
  18. package/dist/bundle/chunks/{virtual-modules-IU5KWB2C.js → virtual-modules-47MGUPYN.js} +3 -3
  19. package/dist/bundle/cli-runtime.js +3 -3
  20. package/dist/bundle/index.js +6 -6
  21. package/dist/bundle/rpc-entry.js +3 -3
  22. package/dist/coordination/adapter/delivery.d.ts +27 -0
  23. package/dist/coordination/adapter/delivery.d.ts.map +1 -1
  24. package/dist/coordination/adapter/delivery.js +164 -4
  25. package/dist/coordination/adapter/delivery.js.map +1 -1
  26. package/dist/coordination/adapter/index.d.ts.map +1 -1
  27. package/dist/coordination/adapter/index.js +31 -5
  28. package/dist/coordination/adapter/index.js.map +1 -1
  29. package/dist/coordination/adapter/presence.d.ts +5 -0
  30. package/dist/coordination/adapter/presence.d.ts.map +1 -1
  31. package/dist/coordination/adapter/presence.js +25 -3
  32. package/dist/coordination/adapter/presence.js.map +1 -1
  33. package/dist/coordination/adapter/question-routing.d.ts +7 -0
  34. package/dist/coordination/adapter/question-routing.d.ts.map +1 -0
  35. package/dist/coordination/adapter/question-routing.js +40 -0
  36. package/dist/coordination/adapter/question-routing.js.map +1 -0
  37. package/dist/coordination/adapter/receipts.d.ts +7 -0
  38. package/dist/coordination/adapter/receipts.d.ts.map +1 -1
  39. package/dist/coordination/adapter/receipts.js +25 -2
  40. package/dist/coordination/adapter/receipts.js.map +1 -1
  41. package/dist/coordination/adapter/tool.d.ts +19 -3
  42. package/dist/coordination/adapter/tool.d.ts.map +1 -1
  43. package/dist/coordination/adapter/tool.js +93 -19
  44. package/dist/coordination/adapter/tool.js.map +1 -1
  45. package/dist/coordination/client/client.d.ts +2 -2
  46. package/dist/coordination/client/client.d.ts.map +1 -1
  47. package/dist/coordination/client/client.js +4 -0
  48. package/dist/coordination/client/client.js.map +1 -1
  49. package/dist/coordination/transport/protocol.d.ts.map +1 -1
  50. package/dist/coordination/transport/protocol.js +23 -0
  51. package/dist/coordination/transport/protocol.js.map +1 -1
  52. package/dist/coordination/transport/types.d.ts +11 -1
  53. package/dist/coordination/transport/types.d.ts.map +1 -1
  54. package/dist/coordination/transport/types.js.map +1 -1
  55. package/dist/core/model-runtime.d.ts.map +1 -1
  56. package/dist/core/model-runtime.js +14 -8
  57. package/dist/core/model-runtime.js.map +1 -1
  58. package/dist/core/oauth-account-pool.d.ts +14 -0
  59. package/dist/core/oauth-account-pool.d.ts.map +1 -1
  60. package/dist/core/oauth-account-pool.js +166 -14
  61. package/dist/core/oauth-account-pool.js.map +1 -1
  62. package/dist/core/run-outcome.d.ts +1 -1
  63. package/dist/core/run-outcome.d.ts.map +1 -1
  64. package/dist/core/run-outcome.js +2 -2
  65. package/dist/core/run-outcome.js.map +1 -1
  66. package/dist/core/run-preflight.d.ts.map +1 -1
  67. package/dist/core/run-preflight.js +15 -8
  68. package/dist/core/run-preflight.js.map +1 -1
  69. package/dist/main.d.ts.map +1 -1
  70. package/dist/main.js +2 -0
  71. package/dist/main.js.map +1 -1
  72. package/docs/cli.md +6 -0
  73. package/docs/coordination.md +16 -4
  74. package/docs/environment-variables.md +2 -1
  75. package/docs/providers.md +5 -1
  76. package/npm-shrinkwrap.json +2 -2
  77. package/package.json +1 -1
  78. package/dist/bundle/chunks/chunk-UEW6TUSP.js +0 -36
@@ -10,7 +10,7 @@ Turn it off with `--no-coordinate`, the `coordination.enabled` setting, or `--no
10
10
 
11
11
  ## Messages
12
12
 
13
- The agent uses the `coordination` tool with `peers`, `send`, or `broadcast` for messages. Its record, artifact and handoff actions are described in [Shared records](#shared-records), [Artifacts](#artifacts) and [Handoffs and integration](#handoffs-and-integration). Incoming messages appear as advisory cards with `repo · branch — focus (handle)`. The session name replaces a missing focus; missing location parts are omitted. Handles are the shortest unique suffix of a session ID among live sessions, at least four characters, with hyphens removed. They grow when suffixes collide. Metadata is sanitized, bounded and displayed as literal text, never markup or commands.
13
+ The agent uses the `coordination` tool with `peers`, `ask`, `send`, `broadcast`, `inbox` and `resolve` for messages. Its record, artifact and handoff actions are described in [Shared records](#shared-records), [Artifacts](#artifacts) and [Handoffs and integration](#handoffs-and-integration). Incoming messages appear as advisory cards with `repo · branch — focus (handle)`. The session name replaces a missing focus; missing location parts are omitted. Handles are the shortest unique suffix of a session ID among live sessions, at least four characters, with hyphens removed. They grow when suffixes collide. Metadata is sanitized, bounded and displayed as literal text, never markup or commands.
14
14
 
15
15
  Cards are on by default, with no extra setting. Incoming cards start with `⇠ peer`; outgoing sends start with `⇢ to` and show `✓ delivered`, `⏳ queued`, or `✗ failed: <reason>`. Uncertain delivery stays explicitly uncertain: it is not confirmation or permission to send a new message. The existing expand-tool-output keybinding (`ctrl+o` by default) reveals the full sender or recipient ID and message ID. Inbound expansion also shows the worktree path and the full safety sentence. The model still receives the original full peer header, disclaimer and message body, and unchanged send-result text.
16
16
 
@@ -18,13 +18,25 @@ Cards are on by default, with no extra setting. Incoming cards start with `⇠ p
18
18
 
19
19
  1. Run `coordination action:"peers"` with optional `repo`, `query` and `path` filters. Results are grouped by repository, your repository first. Filters combine with AND: `repo` is a case-insensitive label substring, `query` matches repository, branch, name or focus, and `path` is a prefix of the session's repository-relative working directory or written paths. Each result includes focus and at most five matching written paths per session. Brackets in displayed paths are percent-escaped (`[` as `%5B`, `]` as `%5D`; existing `%` becomes `%25`). Oversized lists are truncated; narrow the filters.
20
20
  2. Send to the chosen session with `action:"send" to:"<session id>" text:"..."`. Exact targets resolve first, live sessions before offline ones: a session ID, `to:"<repo>/<name>"` (an exact, case-sensitive repository label and name; both must be defined), or a bare name, which matches case-insensitively in your repository first, then across the device. After exact IDs and names, a unique live suffix handle resolves device-wide (for example `to:"8b2c"`). Ambiguous handles are refused with full candidate IDs; they never fall through to a prefix guess. Disconnected sessions still need an exact ID or name, or an existing ID prefix. Only when no exact target or live handle matches does a unique ID prefix or the name prefix of a connected session resolve, in your repository first and never to the sender. Multiple matches return `E_AMBIGUOUS_TARGET` with at most five candidates formatted as `<repo>/<name> (<id>)`, followed by `... and N more` when needed. Repository labels and names are self-reported by sessions; the broker does not verify them. Continue the thread with `replyTo:"<message id>"` and send to the original sender's ID.
21
- 3. Only if lookup finds nothing, ask with `action:"broadcast" scope:"device"`. Responders should answer with directed `send`. Broadcast without `scope` defaults to `"repo"`; unrelated repositories receive nothing.
21
+ 3. Prefer `action:"ask" text:"Who owns #261 in src/router.ts?"`. Routing deterministically selects the best 1–3 status matches (exact ID/name tokens, MR/issue references in focus, paths/prefixes, repository and branch), breaking score ties by session ID. The result explains the matched fields. With no match it broadcasts in the current repository, inferring the repository audience and path hints from the question; `scope:"device"` explicitly widens fallback discovery. No classifier runs. Respond with directed `send`, `replyTo` and `kind:"answer"` (or `"ack"` / `"decline"`). Broadcast without `scope` defaults to `"repo"`; unrelated repositories receive nothing.
22
22
  4. Update `action:"presence_set" focus:"..."` when your task changes materially. An empty focus clears the override.
23
23
 
24
24
  Repository labels come from the `origin` remote path (for example `humain/deploynow`), falling back to the worktree root basename. Focus is one line, at most 256 characters: an explicit override wins until cleared, otherwise the session name wins, otherwise the first line of the latest user prompt. **Automatic focus copies prompt text into presence, visible to every same-user session on this device.**
25
25
 
26
+ MR (`!996`) and issue (`#261`) references from user prompts are automatically retained in the published focus, even when a session name or explicit focus is set (up to 16 references within the 256-character focus limit). The next model turn nudges a refresh after a successful commit/push command, a new user task phase, or about 15 minutes without a refresh. Branch and worktree are derived automatically; no model classifier is involved.
27
+
26
28
  Presence retains the most recent 20 repository-relative paths successfully written through this session's own `edit` and `write` tools, deduplicated and timestamped, newest first. Reads, bash-driven writes, failed writes and paths outside the worktree are not tracked. `subpath` is the working directory relative to the worktree root.
27
29
 
30
+ ### Wake rules and quiet inbox
31
+
32
+ All routing fields are optional. Broadcasts default to `intent:"notice"`; use `intent:"question"` for a question. New senders mark broadcast deliveries on the wire even when intent is omitted. Older senders implemented broadcast as independent, unmarked directed sends; receivers cannot distinguish those from legacy direct messages, so they retain direct-send behavior. Older receivers may ignore the new fields and still wake for notices. Optional `audience` is an object with `repo`, `paths` (prefixes) and/or `sessions` (exact IDs or names). Direct sends always qualify to wake, including status/verdict messages and typed or untyped replies, except `ack`/`decline` replies and replies to resolved questions. Existing wake budgets and busy-session delivery still apply. Broadcasts naming this session by an exact ID/name token, matching its audience, or mentioning a recently written path wake too; substrings of names do not match. Broadcasts targeting more than three named live sessions or more than three audience sessions stay quiet, even if this session is named. Peer-supplied intent alone never forces a wake.
33
+
34
+ A reply with `replyTo` referencing this session's prior message counts as an answer even when `kind` is omitted, unless it is explicitly `ack` or `decline`. Answers to direct sends (including status-matched `ask` deliveries) wake immediately without batching. For a locally registered broadcast question, answers from addressed peers open a 30-second batching window; all addressed peers answering flushes early. One combined message uses the existing wake budget and held queue. Pending answers reserve their sender/message-ID receipt claim on arrival, before batching; a different sender reusing a held ID is deferred for broker redelivery, never allowed to displace the original answer. Reserved answers are not judged missing from the conversation until handed to the host. Every member must fit receipt tracking before the combined message is handed to the host; a partially admitted batch is refused, never injected with contradictory receipts. All answers received during an active window are included, including multipart and untyped replies. Subsequent answers can start another batch while the question remains open. Typed question context includes the exact sender ID, question ID and reply fields. Close broadcast-question batching with `action:"resolve" messageId:"<question ID>"` (the broadcast/fallback ask result prints the group ID). Pending answers move to the quiet inbox on resolution; later replies to the resolved question, typed or untyped, also stay quiet. New direct messages still qualify to wake.
35
+
36
+ Replies to resolved questions, `ack`/`decline` replies and unaddressed broadcasts are quiet under these routing rules; an acknowledgement or decline reply stays quiet even if its body or audience names this receiver. Quiet messages never trigger a turn or steer. They remain in a session-local inbox for 15 minutes, capped at 64 entries and 1 MiB (oldest entries evicted). A one-line digest is added to the next model turn's context (including the next turn of an already-running session), without starting a turn. `action:"inbox"` reads the retained messages even while disconnected, preserving the peer-content safety banner. This inbox is in memory, not durable across process exit; its messages receive `not_injected` with a quiet-inbox explanation. Batches and open-question tracking are also session-local and bounded.
37
+
38
+ For messages that qualify to wake:
39
+
28
40
  - A busy session sees the message at its next safe point.
29
41
  - An idle interactive or RPC session starts a turn for it, up to `coordination.peerWakeLimit` turns per 10 minutes (default 6). Set it to `0` to never wake. The setting is clamped to the range 0-60.
30
42
  - An idle print or JSON session keeps the message for its next turn.
@@ -32,11 +44,11 @@ Presence retains the most recent 20 repository-relative paths successfully writt
32
44
 
33
45
  ### Delivery guarantees
34
46
 
35
- If a send reports uncertain delivery, the tool returns the accepted message ID, delivery state, error code, `retryable` and `outcomeKnown`. The message may still arrive. Retry with `action:"send" messageId:"<returned ID>"` and the same recipient, text and `replyTo`; do not create a new message ID. An uncertain broadcast returns one ID per recipient: retry those messages individually with directed `send`, not another broadcast.
47
+ If a send reports uncertain delivery, the tool returns the accepted message ID, delivery state, error code, `retryable` and `outcomeKnown`. The message may still arrive. Retry with `action:"send" messageId:"<returned ID>"` and the same recipient, text, `replyTo`, `intent`, `audience` and `kind`; preserve `broadcast:true` when retrying a broadcast (omit it when originally absent). Do not create a new message ID. An uncertain broadcast returns one ID per recipient: retry those messages individually with directed `send`, not another broadcast.
36
48
 
37
49
  - **Confirmed socket delivery.** Built-in HUMAIN recipients promise receipts. A send reports `socket_delivered` only after the receiving endpoint confirms arrival, not merely because its socket accepted a write. This confirms receipt, not injection. If no confirmation arrives within 5 seconds, or the receiver disconnects first, the result is `delivery: "unknown"`, `retryable: true`, `outcomeKnown: false` (`E_RECEIPT_TIMEOUT` or `E_RECEIVER_DISCONNECTED`). The message may still arrive; it remains durable, and retrying the same authored message ID never creates a second mailbox entry. Plain protocol clients that do not promise receipts retain immediate socket results. Set `HUMAIN_TERMINAL_COORDINATION_RECEIPT_TIMEOUT_MS` before the broker starts to change the deadline (positive integer below 10000).
38
50
  - **Durable until acknowledged.** The broker saves every accepted message to its mailbox before it writes anything to the recipient and before it tells the sender `socket_delivered` or `queued`. A message stays in the mailbox after it is written to the recipient's socket. It is removed only when the recipient reports a final outcome (`injected` or `not_injected`), when it expires after 24 hours, when the sender cancels it, or when a later message supersedes it. `receiver_received` does not remove it, and a receipt from any other session is ignored.
39
- - **Deferred at shutdown.** If the recipient session ends before a message reaches its conversation, it reports `deferred`. The broker keeps the message and delivers it again when that same session resumes. A session that never resumes (for example one started with `--no-session`) loses it when it expires after 24 hours. `not_injected` is reserved for messages the recipient refuses, such as oversized ones.
51
+ - **Deferred at shutdown.** If the recipient session ends before a message reaches its conversation, it reports `deferred`. The broker keeps the message and delivers it again when that same session resumes. A session that never resumes (for example one started with `--no-session`) loses it when it expires after 24 hours. `not_injected` also covers messages retained only in the bounded quiet inbox, as well as refused messages such as oversized ones.
40
52
  - **At least once, deduplicated.** If the recipient disconnects, or the broker restarts, before the final outcome arrives, the message is delivered again on reconnect. A recipient never injects the same message twice: a repeat of a message it already handled is answered with the same final outcome, and after a restart a message already present in the resumed session is reported as `injected` without being added again. A sender's retry of a message the broker still holds is answered from the broker's record and queues nothing new. A message id already used by another sender is refused with `E_INVALID_REQUEST`. Reusing your own id with different content returns `E_MESSAGE_ID_REUSE`.
41
53
  - **Per-sender ordering.** Messages from one sender to one recipient are delivered in the order they were sent, across live delivery, queued mail, reconnects, broker restarts, and retries. A new message never overtakes an older one that has not been written yet, for example while the recipient is reading slowly.
42
54
  - **Limits.** Each recipient can hold up to 256 messages and 8 MiB, and the broker holds up to 12 MiB in total (each message counted as its saved size, including messages written but not yet acknowledged). A message that would exceed a limit is refused with the retryable error `E_MAILBOX_FULL` before anything changes; accepted mail is never dropped to make room. When the broker restarts it keeps each recipient's newest messages that fit these limits. Message ids are 1-128 characters; a longer id is refused with `E_MESSAGE_ID_TOO_LONG` before anything is saved.
@@ -105,7 +105,8 @@ These variables are read by HUMAIN Code CLI itself:
105
105
  | `HUMAIN_TERMINAL_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase if Alt-key input is misread as Escape |
106
106
  | `HUMAIN_TERMINAL_CLIPBOARD_OSC52` | Set to `1` to also send copied text to the terminal with OSC 52 after the local clipboard write, as HUMAIN Code CLI does over SSH. Use it when a remote client reaches HUMAIN Code CLI without SSH variables, such as a multiplexer attached from another machine or a remote IDE daemon |
107
107
  | `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
108
- | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
108
+ | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests, including early Forge Run catalog discovery and auth startup. Desktop setup initializes transport before auth; native Run initializes before discovery without desktop settings. Later desktop settings/timeout updates still reconfigure transport |
109
+ | `NO_PROXY` | Hosts that bypass the outbound HTTP proxy |
109
110
  | `HUMAIN_TERMINAL_RPC_SUBAGENT_PROGRESS` | Set to exactly `1` before starting RPC mode to enable optional subagent progress metadata. Default off; unset and all other values disable it. Read once per RPC runtime, not persisted in settings; reload and session replacement retain the startup choice. See [RPC subagent progress](rpc.md#subagent-progress). |
110
111
  | `HUMAIN_TERMINAL_SUBAGENT_MAX_DEPTH` | Maximum nesting depth for the `subagent` tool. Default `1`, ceiling `3`. |
111
112
  | `HUMAIN_TERMINAL_SUBAGENT_MAX_CONCURRENCY` | Maximum children running at once in parallel mode. Default `4`, ceiling `8`. |
package/docs/providers.md CHANGED
@@ -459,6 +459,10 @@ The design spec's `zai-coding` wording names the global Coding Plan product, not
459
459
 
460
460
  Legacy unidentified Codex credentials have a separate removal action in `/logout`, alongside any saved-account choices. Its confirmation defaults to keeping the credential. Removing that credential keeps unrelated saved accounts; selecting a saved account removes only that account. Concurrent credential changes prevent deletion. Account-read and removal failures display sanitized guidance, never backend error details or credential values.
461
461
 
462
+ Refresh results stay bound to the local entry and upstream account that issued the refresh grant, under the existing credential locks and current-credential checks. Provider-returned local keys cannot redirect a refresh; a different upstream account or workspace is rejected. Switching changes only the selection and never moves credentials between entries. Codex reconciliation uses the access token's account identity rather than a conflicting local stamp. Load-time quarantine requires another existing slot as ownership evidence: a foreign local stamp must point to an existing neighbor; a Codex token/account-ID mismatch must name an existing neighbor through either identity. A self-stamped legacy Codex upstream-key slot holding a different token identity is quarantined only when the token's canonical neighboring slot exists and holds that identity, retaining the original slot identity for reauthentication. Detected crosslinks stay in place, not restamped or deleted. An unstamped alias (including an expired one), a stamp pointing to an absent slot, or inconsistent identity metadata in a single-entry pool is not enough to infer corruption on load. Loading preserves those grants unchanged and performs no refresh or persistence. Auth reconciliation repairs conflicting account-ID metadata only when the stamp names a different stored owner (or fills a missing ID); otherwise it retains the mismatch for downstream identity validation instead of silently making it valid. These load constraints do not weaken refresh-time binding or upstream-identity checks. Generated local keys are not upstream IDs; independent grants in those slots remain valid. Reads detect quarantine without writing; the next successful mutation persists its ownership evidence alongside the unchanged credential. Quarantined entries cannot activate, refresh, serve inference, rotate, return automatically, or become removal/credit fallback targets. Use `/accounts` → Reauthenticate with the slot's expected upstream identity to replace its grant and clear quarantine; a different or unidentifiable identity is rejected. If no identity can be established, use Add another account instead. Equal upstream identities alone are not corruption: independent grants are retained. Signing in again to the same upstream account updates its matching entry. Request and refresh-failure attribution uses the credential actually consumed, not a later active selection, including failures during stream request preparation. Preflight authentication and quota errors name the observed account label and upstream ID when available, not the account selected after dispatch; raw provider errors and credentials remain hidden.
463
+
464
+ Refresh and switching use the same auth lock; pool operations acquire the pool lock before the auth lock. Before consuming a grant, usage refresh re-reads auth under both locks and replans if the complete credential value differs (including account key, upstream identity, access token, refresh token and expiry). Inference likewise refreshes the credential re-read under the auth lock, not its optimistic pre-lock snapshot. Refresh stays under that lock through persistence, so a switch cannot commit over an in-flight refresh. This is a full credential-value comparison, not a separate monotonic grant-revision counter. A delayed caller may complete after another account is selected without moving its refreshed grant to that account.
465
+
462
466
  Pooled accounts remain in `~/.humain-terminal/agent/oauth-accounts.json`, while `auth.json` holds the active credential. The first mutation migrates a legacy pool to `{ "version": 2, "providers": { ... } }` after saving a private migration backup. Both pool and backup use mode `0600`. Corrupt or unsupported documents refuse mutation. Custom SDK credential stores use an in-memory pool unless the host explicitly supplies one.
463
467
 
464
468
  Automatic usage-limit rotation tries another usable account of the same credential type and keeps the same provider and model. OAuth rotation keeps its existing defaults. API-key rotation requires subscription-marked API-key authentication, such as `zai`, `zai-coding-cn` or Kimi Coding; ordinary paid API keys do not rotate implicitly. The global `oauthAccounts.autoSwitch` default is `true`; `oauthAccounts.providers.<id>.autoSwitch` overrides it for one provider. See [Settings](settings.md#oauth-accounts).
@@ -477,4 +481,4 @@ Account recovery happens inside the shared request dispatch. An orchestrator see
477
481
 
478
482
  OpenAI Codex additionally supports usage-limit rotation and its existing credit-related behavior. Run `/login openai-codex` again to add another ChatGPT account. Each account is tried at most once per prompt during quota rotation; exhausted or otherwise unusable accounts may be skipped. When no untried usable account remains, Codex can continue with credits automatically only on an account observed serving responses that may have been billed to credits. The provider does not confirm billing.
479
483
 
480
- For credentials created by an older HUMAIN Code version without an account identity stamp, a refresh is treated as a refresh of the currently active account. If that older version logs in to a different account and writes an unstamped credential, it can overwrite the active account's stored entry.
484
+ For opaque credentials created by an older HUMAIN Code version without any resolvable upstream identity or account stamp, a refresh is treated as a refresh of the currently active account. If that older version logs in to a different account and writes an unstamped credential, it can overwrite the active account's stored entry.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@humain/humain-code",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@humain/humain-code",
9
- "version": "0.8.2",
9
+ "version": "0.8.3",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@humain/humain-code-contracts": "0.4.22",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humain/humain-code",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "humainTerminalConfig": {
@@ -1,36 +0,0 @@
1
- import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- function peerHandle(id,liveIds){let compact=id.replace(/-/g,""),length=Math.min(4,compact.length);for(;length<compact.length&&liveIds.some(other=>other!==id&&other.replace(/-/g,"").endsWith(compact.slice(-length)));)length++;return compact.slice(-length)}function resolveHandleTargets(sessions,target){let compact=target.replace(/-/g,"");return compact.length<4?[]:sessions.filter(session=>session.info.id.replace(/-/g,"").endsWith(compact))}function resolveExactTargets(sessions,target,scopeId){let exact=sessions.
3
- filter(session=>session.info.id===target);if(exact.length)return exact;let lower=target.toLowerCase(),qualified=sessions.filter(session=>session.info.repo!==void 0&&session.info.name!==void 0&&`${session.info.repo}/${session.info.name}`===target);if(qualified.length)return qualified;let names=sessions.filter(session=>session.info.name?.toLowerCase()===lower),local=names.filter(session=>session.scopeId===scopeId);return local.length?local:names}function resolvePrefixTargets(sessions,target,scopeId){
4
- if(!target)return[];let ids=sessions.filter(session=>session.info.id.startsWith(target));if(ids.length)return ids;let lower=target.toLowerCase(),names=sessions.filter(session=>session.info.name?.toLowerCase().startsWith(lower)),local=names.filter(session=>session.scopeId===scopeId);return local.length?local:names}function matchesPeer(session,filters){return(!filters.repo||(session.repo??"").toLowerCase().includes(filters.repo.toLowerCase()))&&(!filters.query||[session.repo,session.branch,session.
5
- name,session.focus].some(field=>field?.toLowerCase().includes(filters.query.toLowerCase())))&&(!filters.path||(session.subpath??"").startsWith(filters.path)||(session.touchedPaths??[]).some(entry=>entry.path.startsWith(filters.path)))}import{createHash}from"node:crypto";var MAX_MESSAGE_ID_CHARS=128,ID_IN_USE_DETAIL="message id is still held by another sender; retry later";function isValidMessageId(value){return typeof value=="string"&&value.length>0&&value.length<=MAX_MESSAGE_ID_CHARS}var MAX_SESSION_FIELD_CHARS={id:256,name:256,model:256,status:256,branch:256,cwd:4096,worktreeRoot:4096,repo:256,focus:256,subpath:4096};function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function isBoundedString(value,maxChars){
6
- return typeof value=="string"&&value.length<=maxChars}function isOptionalBoundedString(value,maxChars){return value===void 0||isBoundedString(value,maxChars)}function isMessageReceiptStatus(value){return value==="receiver_received"||value==="queued"||value==="injected"||value==="not_injected"||value==="deferred"||value==="acknowledged"||value==="expired"||value==="cancelled"||value==="superseded"||value==="cancellation_requested"}var MAX_RECEIPT_DETAIL_CHARS=1024,MAX_REQUEST_ID_CHARS=256,WORST_CASE_REQUEST_ID="\
7
- ".repeat(MAX_REQUEST_ID_CHARS);function truncateChars(text,maxChars){if(text.length<=maxChars)return text;let cut=text.slice(0,maxChars),last=cut.charCodeAt(cut.length-1);return last>=55296&&last<=56319?cut.slice(0,-1):cut}function canonicalMessageReceipt(receipt){return{messageId:receipt.messageId,status:receipt.status,timestamp:receipt.timestamp,...receipt.detail!==void 0?{detail:truncateChars(receipt.detail,MAX_RECEIPT_DETAIL_CHARS)}:{}}}function isMessageReceipt(value){return!isRecord(value)||
8
- typeof value.messageId!="string"||!isMessageReceiptStatus(value.status)||typeof value.timestamp!="number"?!1:value.detail===void 0||typeof value.detail=="string"}function isMessageControl(value){return!isRecord(value)||typeof value.messageId!="string"||typeof value.timestamp!="number"||value.action!=="cancel"&&value.action!=="supersede"||value.supersededBy!==void 0&&typeof value.supersededBy!="string"?!1:value.detail===void 0||typeof value.detail=="string"}function isAttachment(value){return!isRecord(
9
- value)||value.type!=="file"&&value.type!=="snippet"&&value.type!=="context"||typeof value.name!="string"||typeof value.content!="string"?!1:value.language===void 0||typeof value.language=="string"}function isMessageProvenance(value){return isRecord(value)?value.type==="extension_outbox"&&typeof value.extensionId=="string"&&typeof value.extensionName=="string"&&typeof value.requestId=="string":!1}function isMessage(value){if(!isRecord(value)||typeof value.id!="string"||typeof value.timestamp!="nu\
10
- mber")return!1;for(let key of["senderSequence","brokerReceivedAt","brokerDeliveredAt","receiverReceivedAt","injectedAt"])if(value[key]!==void 0&&typeof value[key]!="number")return!1;return value.supersedes!==void 0&&typeof value.supersedes!="string"||value.retryOf!==void 0&&typeof value.retryOf!="string"||value.replyTo!==void 0&&typeof value.replyTo!="string"||value.expectsReply!==void 0&&typeof value.expectsReply!="boolean"||value.provenance!==void 0&&!isMessageProvenance(value.provenance)||!isRecord(
11
- value.content)||typeof value.content.text!="string"?!1:value.content.attachments===void 0||Array.isArray(value.content.attachments)&&value.content.attachments.every(isAttachment)}function messageDeliveryFingerprint(message,targetId){let canonical=JSON.stringify({targetId,text:message.content.text,attachments:message.content.attachments,replyTo:message.replyTo,expectsReply:message.expectsReply,supersedes:message.supersedes,retryOf:message.retryOf,provenance:message.provenance});return createHash(
12
- "sha256").update(canonical).digest("hex")}function isTouchedPaths(value){return Array.isArray(value)&&value.length<=20&&value.every(entry=>isRecord(entry)&&isBoundedString(entry.path,4096)&&entry.path.length>0&&!entry.path.startsWith("/")&&!entry.path.split("/").includes("..")&&typeof entry.timestamp=="number"&&Number.isFinite(entry.timestamp)&&entry.timestamp>=0)&&new Set(value.map(entry=>entry.path)).size===value.length}function isDiscoveryPresence(value){return isOptionalBoundedString(value.repo,
13
- 256)&&isOptionalBoundedString(value.focus,256)&&(value.focus===void 0||!/[\r\n\u2028\u2029]/.test(String(value.focus)))&&isOptionalBoundedString(value.subpath,4096)&&(value.touchedPaths===void 0||isTouchedPaths(value.touchedPaths))}function isSessionInfo(value){if(!isRecord(value)||!isBoundedString(value.id,MAX_SESSION_FIELD_CHARS.id)||!isBoundedString(value.cwd,MAX_SESSION_FIELD_CHARS.cwd)||!isBoundedString(value.model,MAX_SESSION_FIELD_CHARS.model)||typeof value.pid!="number"||typeof value.startedAt!=
14
- "number"||typeof value.lastActivity!="number"||!isOptionalBoundedString(value.handle,MAX_SESSION_FIELD_CHARS.id)||value.endpointEpoch!==void 0&&typeof value.endpointEpoch!="string"||!isOptionalBoundedString(value.name,MAX_SESSION_FIELD_CHARS.name)||value.runtimeFallbackAlias!==void 0&&typeof value.runtimeFallbackAlias!="boolean"||!isOptionalBoundedString(value.status,MAX_SESSION_FIELD_CHARS.status)||value.peerUid!==void 0&&typeof value.peerUid!="number")return!1;for(let key of["contextPct","cont\
15
- extTokens","contextWindow"])if(value[key]!==void 0&&typeof value[key]!="number")return!1;return!isOptionalBoundedString(value.worktreeRoot,MAX_SESSION_FIELD_CHARS.worktreeRoot)||!isOptionalBoundedString(value.branch,MAX_SESSION_FIELD_CHARS.branch)?!1:isDiscoveryPresence(value)&&(value.trustedLocal===void 0||typeof value.trustedLocal=="boolean")}function isSessionId(value){return isBoundedString(value,MAX_SESSION_FIELD_CHARS.id)&&value.trim().length>0}function isSessionRegistration(value){return!isRecord(
16
- value)||!isBoundedString(value.cwd,MAX_SESSION_FIELD_CHARS.cwd)||!isBoundedString(value.model,MAX_SESSION_FIELD_CHARS.model)||typeof value.pid!="number"||typeof value.startedAt!="number"||typeof value.lastActivity!="number"||!isOptionalBoundedString(value.name,MAX_SESSION_FIELD_CHARS.name)||value.runtimeFallbackAlias!==void 0&&typeof value.runtimeFallbackAlias!="boolean"||value.extensions!==void 0&&!Array.isArray(value.extensions)||!isOptionalBoundedString(value.worktreeRoot,MAX_SESSION_FIELD_CHARS.
17
- worktreeRoot)||!isOptionalBoundedString(value.branch,MAX_SESSION_FIELD_CHARS.branch)||value.ownership!==void 0&&!isOwnershipMode(value.ownership)||value.acknowledgesReceipts!==void 0&&typeof value.acknowledgesReceipts!="boolean"||value.livenessIntervalMs!==void 0&&(typeof value.livenessIntervalMs!="number"||!Number.isSafeInteger(value.livenessIntervalMs)||value.livenessIntervalMs<=0)?!1:isDiscoveryPresence(value)&&isOptionalBoundedString(value.status,MAX_SESSION_FIELD_CHARS.status)}var MAX_RECORD_VALUE_BYTES=65536,
18
- MAX_RECORD_VALUE_DEPTH=16,MAX_RECORD_ARTIFACT_REFS=64,MAX_RECORDS=1024,RECORD_KEY_PATTERN=/^[a-z0-9][a-z0-9._-]{0,127}$/,RESERVED_RECORD_KEYS=["presence","policy","integration"],RESERVED_NAMESPACE_PREFIX="humain.coord.",RECORD_NAMESPACE_PREFIX="humain.coord.record:",POLICY_NAMESPACE="humain.coord.policy",ARTIFACT_NAMESPACE_PREFIX="humain.coord.artifact:",MAX_ARTIFACT_BYTES=16*1024*1024,ARTIFACT_QUOTA_BYTES=256*1024*1024,MAX_ARTIFACTS=1024,MAX_ARTIFACT_NAME_CHARS=256,MAX_ARTIFACT_NAME_SEGMENTS=8,
19
- ARTIFACT_SEGMENT_PATTERN=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,STAGED_FILE_PATTERN=/^[a-f0-9]{32}\.part$/,ARTIFACT_RETENTION_MS=10080*60*1e3,RECORD_TOMBSTONE_RETENTION_MS=ARTIFACT_RETENTION_MS,STALE_STAGED_FILE_MS=3600*1e3,FORBIDDEN_JSON_KEYS=new Set(["__proto__","constructor","prototype"]);function findJsonUnsafe(value,depth,maxDepth,ancestors,budget){let overBudget=`value is larger than the limit of ${budget.limit} bytes`;if(value===null)return budget.remaining-=4,budget.remaining<0?overBudget:void 0;
20
- switch(typeof value){case"boolean":return budget.remaining-=4,budget.remaining<0?overBudget:void 0;case"string":return budget.remaining-=2,budget.remaining<0?overBudget:void 0;case"number":return Number.isFinite(value)?(budget.remaining-=1,budget.remaining<0?overBudget:void 0):"numbers must be finite";case"object":break;default:return`${typeof value} values are not JSON`}if(ancestors.has(value))return"value contains a cycle";if(depth>maxDepth)return`value is nested deeper than ${maxDepth} levels`;
21
- ancestors.add(value);try{if(Array.isArray(value)){if(Object.getPrototypeOf(value)!==Array.prototype)return"only plain arrays are allowed";if(budget.remaining-=2+Math.max(0,value.length-1),budget.remaining<0)return overBudget;for(let key of Reflect.ownKeys(value)){if(typeof key=="symbol")return"symbol keys are not JSON";if(key==="length")continue;let index=Number(key);if(!Number.isInteger(index)||index<0||index>=value.length||String(index)!==key)return`arrays must not have non-index key "${key}"`;
22
- if(!Object.getOwnPropertyDescriptor(value,key)?.enumerable)return`non-enumerable key "${key}" is not JSON`}for(let index=0;index<value.length;index+=1){if(!Object.hasOwn(value,index))return"arrays must not have holes";let reason=findJsonUnsafe(value[index],depth+1,maxDepth,ancestors,budget);if(reason)return reason}return}let prototype=Object.getPrototypeOf(value);if(prototype!==Object.prototype&&prototype!==null)return"only plain objects are allowed";if(budget.remaining-=2,budget.remaining<0)return overBudget;
23
- let first=!0;for(let key of Reflect.ownKeys(value)){if(typeof key=="symbol")return"symbol keys are not JSON";if(!Object.getOwnPropertyDescriptor(value,key)?.enumerable)return`non-enumerable key "${key}" is not JSON`;if(budget.remaining-=first?3:4,budget.remaining<0)return overBudget;if(first=!1,FORBIDDEN_JSON_KEYS.has(key))return`key "${key}" is not allowed`;let reason=findJsonUnsafe(value[key],depth+1,maxDepth,ancestors,budget);if(reason)return reason}return}finally{ancestors.delete(value)}}function validateJsonSafe(value,limits){
24
- let reason=findJsonUnsafe(value,1,limits.maxDepth,new Set,{remaining:limits.maxBytes,limit:limits.maxBytes});if(reason)return{ok:!1,reason};let bytes=Buffer.byteLength(JSON.stringify(value),"utf8");return bytes>limits.maxBytes?{ok:!1,reason:`value is ${bytes} bytes; the limit is ${limits.maxBytes}`}:{ok:!0,bytes}}function isRequestId(value){return isBoundedString(value,MAX_REQUEST_ID_CHARS)&&value.length>0}function isOwnershipMode(value){return value==="on"||value==="off"}function isRecordKey(value){
25
- return typeof value=="string"&&RECORD_KEY_PATTERN.test(value)}function isReservedRecordKey(key){return RESERVED_RECORD_KEYS.some(reserved=>key===reserved||key.startsWith(`${reserved}.`))}function isReservedNamespace(namespace){return namespace.startsWith(RESERVED_NAMESPACE_PREFIX)}function isSha256Hex(value){return typeof value=="string"&&/^[a-f0-9]{64}$/.test(value)}function isArtifactName(value){if(typeof value!="string"||value.length===0||value.length>MAX_ARTIFACT_NAME_CHARS)return!1;let segments=value.
26
- split("/");return segments.length<=MAX_ARTIFACT_NAME_SEGMENTS&&segments.every(segment=>ARTIFACT_SEGMENT_PATTERN.test(segment))}function isRecordState(value){return value==="open"||value==="done"}var INTEGRATION_NAMESPACE="humain.coord.integration",HANDOFF_KEY_PREFIX="integration.handoff.",RESOLUTION_KEY_PREFIX="integration.resolution.",MAX_HANDOFFS=48,MAX_HANDOFF_COMMITS=32,MAX_HANDOFF_DEPENDENCIES=16,MAX_HANDOFF_VERIFICATIONS=16,MAX_HANDOFF_ARTIFACT_REFS=16,MAX_BRANCH_NAME_CHARS=200,MAX_VERIFICATION_COMMAND_CHARS=256,
27
- MAX_VERIFICATION_SUMMARY_CHARS=512,MAX_HANDOFF_NOTE_CHARS=1024,MAX_ATTEMPTS=6,MAX_WRITERS=6,MAX_CHECKOUT_ROOT_CHARS=512,MAX_CONFLICT_FILES=10,MAX_CONFLICT_FILE_CHARS=80,MAX_EVIDENCE_CHARS=256;function hasControlChars(value,allowNewline=!1){for(let index=0;index<value.length;index+=1){let code=value.charCodeAt(index);if(!(code===10&&allowNewline)&&(code<32||code===127))return!0}return!1}function isGitObjectId(value){return typeof value=="string"&&/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(value)}function isHandoffId(value){return typeof value=="string"&&/^[a-f0-9]{16}$/.test(value)}function isValidBranchName(value){return typeof value!="string"||value.length===0||value.length>MAX_BRANCH_NAME_CHARS||
28
- !/^[\x21-\x7e]+$/.test(value)||value==="@"||value==="HEAD"||value.startsWith("-")||value.startsWith("/")||value.endsWith("/")||value.endsWith(".")||value.includes("..")||value.includes("//")||value.includes("@{")||/[~^:?*[\\]/.test(value)?!1:value.split("/").every(part=>!part.startsWith(".")&&!part.endsWith(".lock"))}function uniqueStrings(values,isValid){for(let index=0;index<values.length;index+=1)if(!Object.hasOwn(values,index)||!isValid(values[index]))return!1;return new Set(values).size===values.
29
- length}function parseVerification(value){if(!isRecord(value))return"each verification must be an object";let{command,result,summary}=value;return typeof command!="string"||command.length===0||command.length>MAX_VERIFICATION_COMMAND_CHARS||hasControlChars(command)?`verification command must be 1-${MAX_VERIFICATION_COMMAND_CHARS} characters without control characters`:result!=="passed"&&result!=="failed"&&result!=="not_run"?'verification result must be "passed", "failed" or "not_run"':summary!==void 0&&
30
- (typeof summary!="string"||summary.length>MAX_VERIFICATION_SUMMARY_CHARS||hasControlChars(summary))?`verification summary must be at most ${MAX_VERIFICATION_SUMMARY_CHARS} characters without control characters`:{command,result,...summary!==void 0?{summary}:{}}}function validateHandoffInput(value){if(!isRecord(value))return{ok:!1,reason:"handoff must be an object"};let{branch,commits,base,target,dependencies=[],verification=[],artifactRefs=[],note}=value;if(!isValidBranchName(branch))return{ok:!1,
31
- reason:"branch is not a valid branch name"};if(!isValidBranchName(target))return{ok:!1,reason:"target is not a valid branch name"};if(!isGitObjectId(base))return{ok:!1,reason:"base must be a full commit id"};if(!Array.isArray(commits)||commits.length===0||commits.length>MAX_HANDOFF_COMMITS||!uniqueStrings(commits,isGitObjectId))return{ok:!1,reason:`commits must be 1-${MAX_HANDOFF_COMMITS} unique full commit ids`};if(commits.includes(base)||commits.some(commit=>commit.length!==base.length))return{
32
- ok:!1,reason:"commits must not contain the base and must use the same id length as it"};if(!Array.isArray(dependencies)||dependencies.length>MAX_HANDOFF_DEPENDENCIES||!uniqueStrings(dependencies,isHandoffId))return{ok:!1,reason:`dependencies must be at most ${MAX_HANDOFF_DEPENDENCIES} unique handoff ids`};if(!Array.isArray(verification)||verification.length>MAX_HANDOFF_VERIFICATIONS)return{ok:!1,reason:`verification must be an array of at most ${MAX_HANDOFF_VERIFICATIONS} entries`};let checks=[];
33
- for(let entry of verification){let parsed=parseVerification(entry);if(typeof parsed=="string")return{ok:!1,reason:parsed};checks.push(parsed)}return!Array.isArray(artifactRefs)||artifactRefs.length>MAX_HANDOFF_ARTIFACT_REFS||!uniqueStrings(artifactRefs,isSha256Hex)?{ok:!1,reason:`artifactRefs must be at most ${MAX_HANDOFF_ARTIFACT_REFS} unique SHA-256 hex strings`}:note!==void 0&&(typeof note!="string"||note.length>MAX_HANDOFF_NOTE_CHARS||hasControlChars(note,!0))?{ok:!1,reason:`note must be at \
34
- most ${MAX_HANDOFF_NOTE_CHARS} characters without control characters`}:{ok:!0,value:{branch,commits:[...commits],base,target,dependencies:[...dependencies],verification:checks,artifactRefs:[...artifactRefs],...note!==void 0?{note}:{}}}}var EXTENSION_BUS_FEATURE="extension-bus-v1",EXACT_SEND_FEATURE="exact-send-v1",SESSION_HELD_ERROR_CODE="E_SESSION_HELD",COORD_RECORDS_FEATURE="coord-records-v1",COORD_INTEGRATION_FEATURE="coord-integration-v1";export{peerHandle,resolveHandleTargets,resolveExactTargets,resolvePrefixTargets,matchesPeer,MAX_MESSAGE_ID_CHARS,ID_IN_USE_DETAIL,isValidMessageId,MAX_SESSION_FIELD_CHARS,isBoundedString,MAX_REQUEST_ID_CHARS,WORST_CASE_REQUEST_ID,truncateChars,canonicalMessageReceipt,isMessageReceipt,isMessageControl,isMessage,messageDeliveryFingerprint,isTouchedPaths,isSessionInfo,isSessionId,isSessionRegistration,MAX_RECORD_VALUE_BYTES,MAX_RECORD_VALUE_DEPTH,MAX_RECORD_ARTIFACT_REFS,MAX_RECORDS,RECORD_NAMESPACE_PREFIX,
35
- POLICY_NAMESPACE,ARTIFACT_NAMESPACE_PREFIX,MAX_ARTIFACT_BYTES,ARTIFACT_QUOTA_BYTES,MAX_ARTIFACTS,STAGED_FILE_PATTERN,ARTIFACT_RETENTION_MS,RECORD_TOMBSTONE_RETENTION_MS,STALE_STAGED_FILE_MS,validateJsonSafe,isRequestId,isOwnershipMode,isRecordKey,isReservedRecordKey,isReservedNamespace,isSha256Hex,isArtifactName,isRecordState,INTEGRATION_NAMESPACE,HANDOFF_KEY_PREFIX,RESOLUTION_KEY_PREFIX,MAX_HANDOFFS,MAX_HANDOFF_COMMITS,MAX_BRANCH_NAME_CHARS,MAX_ATTEMPTS,MAX_WRITERS,MAX_CHECKOUT_ROOT_CHARS,MAX_CONFLICT_FILES,
36
- MAX_CONFLICT_FILE_CHARS,MAX_EVIDENCE_CHARS,isGitObjectId,isHandoffId,isValidBranchName,validateHandoffInput,EXTENSION_BUS_FEATURE,EXACT_SEND_FEATURE,SESSION_HELD_ERROR_CODE,COORD_RECORDS_FEATURE,COORD_INTEGRATION_FEATURE};