@nanhara/hara 0.125.3 → 0.126.1

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 (43) hide show
  1. package/CHANGELOG.md +59 -1
  2. package/README.md +10 -4
  3. package/SECURITY.md +7 -3
  4. package/dist/agent/limits.js +2 -2
  5. package/dist/agent/loop.js +270 -98
  6. package/dist/config.js +172 -4
  7. package/dist/gateway/flows-pending.js +14 -36
  8. package/dist/gateway/wecom.js +9 -1
  9. package/dist/index.js +372 -159
  10. package/dist/mcp/client.js +2 -0
  11. package/dist/plugins/manifest.js +317 -0
  12. package/dist/plugins/plugins.js +476 -139
  13. package/dist/providers/bounded-turn.js +6 -0
  14. package/dist/providers/factory.js +54 -0
  15. package/dist/providers/openai.js +6 -1
  16. package/dist/providers/registry.js +1 -0
  17. package/dist/providers/target.js +98 -0
  18. package/dist/security/guardian.js +6 -1
  19. package/dist/security/private-state.js +1 -1
  20. package/dist/security/secrets.js +19 -0
  21. package/dist/serve/protocol.js +7 -2
  22. package/dist/serve/server.js +139 -35
  23. package/dist/serve/sessions.js +11 -2
  24. package/dist/session/operation-drain.js +45 -0
  25. package/dist/tools/agent.js +1 -0
  26. package/dist/tools/all.js +1 -0
  27. package/dist/tools/ask_user.js +8 -3
  28. package/dist/tools/builtin.js +19 -1
  29. package/dist/tools/codebase.js +1 -0
  30. package/dist/tools/computer.js +1 -0
  31. package/dist/tools/cron.js +10 -0
  32. package/dist/tools/external_agent.js +1 -0
  33. package/dist/tools/memory.js +2 -0
  34. package/dist/tools/registry.js +95 -4
  35. package/dist/tools/result-limit.js +172 -2
  36. package/dist/tools/runtime.js +67 -0
  37. package/dist/tools/search.js +3 -0
  38. package/dist/tools/skill.js +1 -0
  39. package/dist/tools/task.js +5 -0
  40. package/dist/tools/todo.js +3 -2
  41. package/dist/tools/web.js +4 -0
  42. package/dist/tui/App.js +5 -1
  43. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,64 @@ All notable changes to `@nanhara/hara`.
5
5
  > Versioning (pre-1.0, SemVer-style): the **minor** (middle) number bumps for a **new feature**; the
6
6
  > **patch** (last) number bumps for **optimizations/fixes of existing features**.
7
7
 
8
+ ## 0.126.1 — 2026-07-19 — verified plugin packages and ownership-safe lifecycle
9
+
10
+ - **Plugin packages now fail closed at staging.** Hara validates a bounded manifest schema, portable IDs and
11
+ relative paths, declared Skills/roles/binaries/panels, and MCP entry points before activation. Complete
12
+ package scans reject symbolic links, hard-linked or special files, protected credential-shaped files,
13
+ filesystem-boundary crossings, and excessive file/byte counts.
14
+ - **Install, update, and removal have an ownership transaction.** A same-filesystem private staging directory
15
+ is atomically activated; command collisions never overwrite foreign entries; and a private receipt binds the
16
+ installed root device/inode, manifest digest, and exact command links. Update rollback preserves the previous
17
+ package and commands, while uninstall refuses a changed root, a foreign command replacement, or an older
18
+ unreceipted install. A legacy plugin remains usable; reinstalling it from the same reviewed source performs
19
+ the one-time receipt migration, after which later updates and removal use the verified ownership path.
20
+ - **Plugin MCP processes are rooted in their installed package.** Relative executables and conventional
21
+ Node/Bun/Deno/Python entry scripts are verified and converted to absolute installed paths, and each server
22
+ receives the immutable plugin root as its working directory instead of the user's project.
23
+ - Install warnings no longer echo manifest-provided MCP arguments or hook command bodies, which could contain
24
+ credentials. They still identify each executable surface so the package source can be reviewed before use.
25
+ - Upgrade with `npm i -g @nanhara/hara@0.126.1`.
26
+
27
+ ## 0.126.0 — 2026-07-19 — provider control plane, bounded tools, and honest execution time
28
+
29
+ - **Desktop can configure providers through an authenticated, redacted Serve control plane.** The shared
30
+ catalog distinguishes cloud, local, OAuth, and managed routes; settings can list, test, and save a Personal
31
+ route without returning credentials to the UI. Switching provider or endpoint requires a matching new key
32
+ instead of replaying another vendor's credential, named/managed profiles remain explicit, and launch-time
33
+ environment overrides stay immutable from Desktop.
34
+ - **Ollama and LM Studio are first-class local providers.** They require no fake API key, accept only
35
+ loopback HTTP endpoints, omit the Authorization header on the wire, and can discover installed models
36
+ through the same bounded connection-test path. Cloud custom endpoints continue to require HTTPS except
37
+ for an explicit loopback target.
38
+ - **Tool execution has conservative runtime traits.** Tools without a complete declaration default to
39
+ side-effect-capable and serial; input-level classification can narrow a real read but cannot turn a
40
+ mutating call into an inherited read approval. Parallel calls share an aggregate result budget so one
41
+ round cannot flood the next model request.
42
+ - **Long-tail tool schemas and large results are demand-loaded.** `tool_search` activates only matched,
43
+ role-allowed capabilities for the next model round. Oversized, redacted tool output is kept in a
44
+ quota/TTL-bounded private store and exposed only through opaque `tool_result_read` continuation IDs, never
45
+ arbitrary filesystem paths.
46
+
47
+ - Human clarification and approval waits no longer consume `runTimeoutMs`. The non-renewable budget now
48
+ measures active model/tool execution, resumes with the exact remaining time after an answer, and still
49
+ stops genuinely stuck providers, tools, and loops. Esc, shutdown, and explicit cancellation continue to
50
+ dismiss a waiting prompt immediately.
51
+ - The TUI distinguishes this state as `waiting for your answer · task timer paused`; five-minute and 80%
52
+ lifecycle notices no longer fire while Hara is waiting for a person.
53
+ - `hara serve` now exposes authenticated `server.shutdown` so Desktop can gracefully release sessions and
54
+ locks before relaunching after an update.
55
+ - Timed-out or interrupted provider/tool calls retain their Serve session lease until the underlying
56
+ operation physically settles. A second turn, session deletion, or updater shutdown receives `BUSY`
57
+ instead of overlapping a non-cooperative request or releasing its lock early.
58
+ - Headless resumed sessions use the same physical-lifetime rule for dynamically nested sub-agents and
59
+ automatic compaction, so a late child request cannot escape a cleanup snapshot and release the
60
+ cross-process lock early.
61
+ - The WeCom gateway now uses the bundled `ws` transport because Node 22's native WebSocket handshake is
62
+ rejected by WeCom's production endpoint before authentication. A late authentication frame can no longer
63
+ revive an already-aborted connection or install a heartbeat after cleanup.
64
+ - Upgrade with `npm i -g @nanhara/hara@0.126.0`.
65
+
8
66
  ## 0.125.3 — 2026-07-18 — conversation/task boundary and deliberate execution
9
67
 
10
68
  - **Chat delivery is now separate from task execution.** Slash controls such as `/model` no longer create a
@@ -38,7 +96,7 @@ All notable changes to `@nanhara/hara`.
38
96
  unless `HARA_ALLOW_TRUSTED_EXTENSIONS=1` was set before launch.
39
97
  - MCP stderr now drops only npm 11's repeated `Unknown user config "always-auth"` and `"home"` deprecation
40
98
  lines. Other npm warnings and all actual server errors remain visible and redacted. Hara does not read,
41
- rewrite, or weaken the user's `.npmrc`. Esc, interruption, and the total task deadline now also cancel a
99
+ rewrite, or weaken the user's `.npmrc`. Esc, interruption, and the active-execution deadline now also cancel a
42
100
  lazy MCP startup/tool call and close an unresponsive child instead of leaving it behind.
43
101
  - Upgrade with `npm i -g @nanhara/hara@0.125.3`.
44
102
 
package/README.md CHANGED
@@ -238,7 +238,10 @@ and a near-duplicate is flagged so it updates instead of piling up. `assetCaptur
238
238
  **Plugins** — bundle skills + roles + MCP servers in one installable unit (Claude-Code-compatible
239
239
  `plugin.json` / `.claude-plugin/`). `hara plugin add file:<path> | github:<owner/repo> | git:<url>` installs it;
240
240
  `hara plugin` lists; `enable`/`disable`/`remove`. A plugin's skills/roles/MCP auto-contribute (your project &
241
- global override them). `.claude/agents/*.md` subagents load as roles too.
241
+ global override them). Installation validates the full package in a private stage, activates it atomically,
242
+ and records an owner-only receipt for the exact root and command links. Plugins installed before `0.126.1`
243
+ remain usable; reinstall the same reviewed source once to create the receipt before removing them.
244
+ `.claude/agents/*.md` subagents load as roles too.
242
245
 
243
246
  **Recall** — `hara recall --init` creates a personal `~/.hara/code-assets` library (snippets as `*.md`);
244
247
  `hara recall "<query>"` searches it **plus your skills** (one corpus), and `/recall <query>` pulls the best
@@ -286,9 +289,12 @@ checkpointed in its own model/tool round. Mixed tools are classified by action (
286
289
  a brief revision cannot share its round with a side effect. `/task` shows the current execution identity and brief. See
287
290
  [`docs/conversation-task-execution.md`](docs/conversation-task-execution.md).
288
291
  **Notifications**: `hara config set notify bell` (terminal bell) or `notify system` (OS notification) pings you when a turn finishes — handy for long runs you've stepped away from. Gated on elapsed time so quick turns stay quiet; off by default.
289
- **Run limits and loop alarms**: every agent turn has a non-renewable 30-minute total deadline and a 64-round
290
- model/tool cap. Hara warns after five minutes or at 75% of the round budget, stops the third identical failing
291
- tool call, and surfaces the final reason in CLI, Desktop, or gateway output. Tune intentional long work with
292
+ **Run limits and loop alarms**: every agent turn has a non-renewable 30-minute active-execution budget and a
293
+ 64-round model/tool cap. Time spent waiting for an engine-owned question or approval does not consume that
294
+ budget; the status row says the task timer is paused, while Esc, shutdown, and explicit cancellation still
295
+ take effect immediately. Answering resumes the remaining budget rather than resetting it. Hara warns after
296
+ five active minutes or at 75% of the round budget, stops the third identical failing tool call, and surfaces
297
+ the final reason in CLI, Desktop, or gateway output. Tune intentional long work with
292
298
  `hara config set runTimeoutMs 45m` (1s..2h) and `hara config set maxAgentRounds 96` (1..256), or
293
299
  `HARA_RUN_TIMEOUT_MS` / `HARA_MAX_AGENT_ROUNDS`; neither boundary can be disabled. Sub-agents are capped at
294
300
  8 minutes/24 rounds and inherit the parent's cancellation. Auxiliary model work (planning, verification,
package/SECURITY.md CHANGED
@@ -74,9 +74,13 @@ local user (who already has your shell).
74
74
  permission and starts one named server only when a task needs it. Their inherited environment is still
75
75
  scrubbed, but the extension may use its own credentials or access anything its host process permits.
76
76
  - **Plugins are code you trust.** Installing a plugin (`hara plugin add`) grants its author code execution:
77
- its MCP servers may run on first relevant use and its hooks may run around matching tool calls. `hara plugin
78
- add` **prints the exact commands** a plugin can run so you can review them; disable with
79
- `hara plugin disable <name>`.
77
+ its MCP servers may run on first relevant use and its hooks may run around matching tool calls. Installation
78
+ validates the complete package in a private same-filesystem stage, binds executable contributions to portable
79
+ package-relative paths, and records an owner-only root/manifest/command receipt before removal is allowed.
80
+ `hara plugin add` identifies each executable surface without echoing manifest-provided arguments or hook
81
+ bodies, which may contain credentials; review the package source itself, and disable it with
82
+ `hara plugin disable <name>`. Plugins installed before `0.126.1` remain usable; reinstalling one from the same
83
+ reviewed source creates the receipt required for later ownership-safe updates and removal.
80
84
  - **Coding-plan keys.** Provider keys you configure are used only to call the model endpoint you set.
81
85
 
82
86
  ## What is *not* a security boundary
@@ -19,8 +19,8 @@ export function parseAgentRunTimeoutMs(value) {
19
19
  const parsed = amount * multiplier;
20
20
  return Number.isFinite(parsed) ? parsed : undefined;
21
21
  }
22
- /** Parse a total run deadline. Invalid/zero values cannot disable the safety boundary. Human values such
23
- * as `30m`, `90s`, and `1h` are accepted in config; HARA_RUN_TIMEOUT_MS also accepts plain milliseconds. */
22
+ /** Parse the active execution deadline. Invalid/zero values cannot disable the safety boundary. Human values
23
+ * such as `30m`, `90s`, and `1h` are accepted in config; HARA_RUN_TIMEOUT_MS also accepts plain milliseconds. */
24
24
  export function agentRunTimeoutMs(value = process.env.HARA_RUN_TIMEOUT_MS) {
25
25
  const parsed = parseAgentRunTimeoutMs(value);
26
26
  if (parsed === undefined || parsed <= 0)