@nanhara/hara 0.127.2 → 0.129.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,47 @@ 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.129.0 — 2026-07-20 — durable revisions and workspace recovery
9
+
10
+ - Authenticated Serve clients can commit a user-selected file as a new immutable Artifact revision with
11
+ `artifact.commit`. Every write carries `baseRevisionId`; a stale editor receives the dedicated protocol
12
+ conflict code and cannot replace the current revision.
13
+ - `artifact.revert` restores an earlier ancestor by creating another immutable revision rather than moving
14
+ the pointer backward or mutating history. The imported original and every prior revision remain unchanged.
15
+ - Revision pointer updates now use a private-state compare-and-swap guard that also closes a cross-process
16
+ race. The authenticated host assigns the user actor, so a Desktop client cannot forge an Agent/migration
17
+ audit identity.
18
+ - This slice does not yet export files or claim Office fidelity. ExportReceipt, validation reports, worker
19
+ identity, format-specific editing, and Panel v2 remain separate release gates.
20
+ - Interactive launches from the home directory now offer an explicit, one-step switch to a recent or
21
+ registered project before provider and MCP startup. Hara never enumerates the home directory and never
22
+ changes workspace scope without confirmation.
23
+ - Repeated protected-home failures are now grouped by semantic root cause across `ls`, `grep`, `glob`, and
24
+ other filesystem tools. A run stops after the bounded retry threshold with a focused recovery instruction
25
+ instead of trying different tools against the same boundary indefinitely.
26
+ - Git plugin installation now rejects credential-bearing source URLs, bounds clone time, and safely
27
+ distinguishes missing Git, network, authentication/access, and private/not-found repository failures
28
+ without echoing URLs, tokens, or Git stderr.
29
+ - Feishu WebSocket gateways now report connected, disconnected, and reconnected lifecycle events with
30
+ one-hour and 24-hour counters. Repeated disconnects raise rate-limited alerts, while terminal SDK recovery
31
+ failures stop the adapter after a safe drain so a process supervisor can restart it.
32
+ - Upgrade with `npm i -g @nanhara/hara@0.129.0`.
33
+
34
+ ## 0.128.0 — 2026-07-20 — local deliverable foundation
35
+
36
+ - Hara Serve now provides the first `artifact/1` local runtime through authenticated
37
+ `artifact.import`, `artifact.list`, `artifact.get`, and `artifact.revisions` methods. Presentations,
38
+ spreadsheets, and documents receive opaque Artifact/revision identities and a stable content receipt.
39
+ - Import is copy-on-write and leaves the selected file untouched. The private store rejects relative paths,
40
+ symbolic links, hard links, protected credential/configuration files, macro-enabled Office extensions,
41
+ type-confused Office packages, empty files, and files over 64 MiB; activation and immutable binary writes
42
+ are crash-safe, owner-only, and digest-verified.
43
+ - Local metadata never retains the selected absolute path. Corrupt entries remain hidden without hiding
44
+ healthy work, and unexpected filesystem failures cross the Desktop RPC boundary as path-free errors.
45
+ - This release intentionally stores and verifies deliverables but does not render, edit, export, or execute
46
+ them. Those actions remain gated on a matching reviewed Office capability in the next vertical slices.
47
+ - Upgrade with `npm i -g @nanhara/hara@0.128.0`.
48
+
8
49
  ## 0.127.2 — 2026-07-20 — quiet scheduled monitoring
9
50
 
10
51
  - Cron delivery now supports `--deliver-mode always|on-output|on-error`. Existing jobs retain the
package/README.md CHANGED
@@ -272,6 +272,15 @@ Type-ahead Enter steers the exact live turn; `/next <message>` queues a separate
272
272
  clients use `session.steer` with `expectedTurnId` (durable before ACK) and may pass `newTask: true` to force a
273
273
  new execution. The `hara resume` launcher preserves terminal input in both npm/Node and standalone-binary
274
274
  installs.
275
+ **Local deliverables**: Hara Serve 0.128 adds the first local `artifact/1` foundation for presentations,
276
+ spreadsheets, and documents. An authenticated Desktop client can import, list, integrity-check, and inspect
277
+ version history through `artifact.import|list|get|revisions`. The next revision transaction slice also
278
+ advertises `artifact.commit|revert`: every edit supplies the version it started from, a stale edit fails with
279
+ an explicit conflict, and reverting creates a new immutable revision instead of rewriting history. Import and
280
+ commit make owner-only copies under `~/.hara/artifacts`, never change the selected source file, and never store
281
+ its absolute path. Relative, linked, protected, macro-enabled, type-confused, empty, and oversized inputs fail
282
+ closed. The runtime does **not** yet render, format-edit, export, or execute imported content; those operations
283
+ require matching reviewed Office capabilities and validation/export receipts.
275
284
  **MCP**: add an `mcpServers` map to global config (a reviewed project config additionally needs `HARA_TRUST_PROJECT_CONFIG=1` at launch). Hara starts with every configured server stopped and exposes only `mcp_connect`; when the current task first needs one server, the agent requests permission to connect that server and its tools appear on the next round as `mcp__<server>__<tool>`. Unrelated servers remain stopped. Configured MCP servers, like `external_agent`, are trusted host extensions outside Hara's protected-file boundary. Every interactive external-tool call requires confirmation (even in `full-auto`), and non-interactive runs disable them by default; reviewed automation can explicitly opt in before launch with `HARA_ALLOW_TRUSTED_EXTENSIONS=1`. hara can also **be** an MCP server — `hara mcp` exposes its read/search tools (esp. **`codebase_search`**) over stdio so other clients (Claude Desktop, Cursor, another hara) can use them; read-only by default (`HARA_MCP_TOOLS` to override).
276
285
  **Vim mode**: `hara config set vimMode true` makes the prompt modal — Esc → normal, `i/a/A/I` insert, `h l 0 $ w b e` motions, `x D C dd cw p` edits. Off by default.
277
286
  **Scheduled tasks**: `hara cron add "0 9 * * 1-5" "<task>"` (or `"every 30m"`, `"in 2h"`) runs a task on a schedule — each run is a fresh hara session. `hara cron install` wires a per-minute tick into launchd/crontab (no daemon); `--org` routes through the role org. Manage with `hara cron list/run/enable/disable/remove/logs`. Every job has a 30-minute deadline and the whole sequential tick has a non-renewable 60-minute watchdog: a job timeout kills its process tree, records `timed out` + duration/error, then continues with the next due job; a tick timeout stops the remainder and releases the global lock. Add `--deliver feishu:<chatId>` (or Telegram/WeChat/webhook) for outcomes. `--deliver-mode always` preserves the existing every-run heartbeat, `on-output` sends only when redacted stdout is non-empty, and `on-error` sends only failed runs; `--alert-after N` remains independent and still raises the consecutive-failure 🚨 threshold alarm (default 3). Delivery intent is durable before transport, uses a stable idempotency key, and retries with bounded backoff on later ticks until confirmed. A failed channel cannot grow `jobs.json` forever: each job keeps at most 64 pending effects, reserves outcome/alert room before launch, and disables itself with a visible backlog error when full; restore delivery, let the queue drain, then re-enable it. Tune milliseconds with `HARA_CRON_JOB_TIMEOUT_MS` (hard max 24h) and `HARA_CRON_TICK_TIMEOUT_MS` (hard max 5h); scheduled jobs are also capped by the tick. After upgrading from a version whose tick is already stuck, terminate that specific legacy `hara cron tick` process tree once (or reboot); the next scheduler minute marks over-age state interrupted/disabled and recovers the lock without replaying a possibly orphaned task.
@@ -9,7 +9,7 @@ import { runHooks } from "../hooks.js";
9
9
  import { mapLimit, maxParallel } from "../concurrency.js";
10
10
  import { decideCommand, isReadOnlyCommand, loadPermissionRules, splitCompound, } from "../security/permissions.js";
11
11
  import { classifyRisk, guardianVeto, guardianEnabled, newBreaker, recordBlock } from "../security/guardian.js";
12
- import { keyOf, looksFailed, recordCall } from "./repeat-guard.js";
12
+ import { failureIdentity, looksFailed, recordCall } from "./repeat-guard.js";
13
13
  import { agentMaxRounds, agentRunTimeoutMs, formatAgentDuration } from "./limits.js";
14
14
  import { subdirHint } from "../context/subdir-hints.js";
15
15
  import { classifyError, failoverAction, errorHint } from "./failover.js";
@@ -405,7 +405,7 @@ function hardStop(opts, life, kind, detail) {
405
405
  ? `⏸ agent run paused: active-execution deadline ${formatAgentDuration(life.timeoutMs)} reached after ${life.rounds} round(s). Waiting for your answers did not consume this budget. No further model or tool calls will start in this turn. Session-backed work keeps its task and checklist checkpoint; type \`/continue\` to resume in a fresh bounded turn. Only for intentionally long single turns, use \`hara config set runTimeoutMs 45m\` (maximum 2h).`
406
406
  : kind === "max_rounds"
407
407
  ? `⛔ agent run stopped: ${life.maxRounds}-round safety limit reached after ${formatAgentDuration(elapsedMs)}. This usually means the model is looping. Increase it with \`hara config set maxAgentRounds <n>\` (maximum 256) only if the extra rounds are intentional.`
408
- : `⛔ agent run stopped: the same failing ${detail?.tool ?? "tool"} call repeated ${detail?.count ?? REPEATED_FAILURE_LIMIT} times. Change the approach or fix the reported cause before retrying.`;
408
+ : `⛔ agent run stopped: the same failing ${detail?.label ?? "tool call"} repeated ${detail?.count ?? REPEATED_FAILURE_LIMIT} times. Change the approach or fix the reported cause before retrying.`;
409
409
  const event = { kind, message, elapsedMs, rounds: life.rounds, timeoutMs: life.timeoutMs, maxRounds: life.maxRounds };
410
410
  if (!life.limitAnnounced) {
411
411
  life.limitAnnounced = true;
@@ -944,16 +944,16 @@ async function runAgentInner(history, opts, life) {
944
944
  let repeatHalt = null;
945
945
  const noteCall = (name, input, content, isError = false) => {
946
946
  const note = recordCall(name, input, content, isError, ctx.todoScope);
947
- const key = keyOf(name, input);
947
+ const identity = failureIdentity(name, input, content, isError);
948
948
  if (isError || looksFailed(content, name)) {
949
- const count = (life.failedCalls.get(key) ?? 0) + 1;
949
+ const count = (life.failedCalls.get(identity.key) ?? 0) + 1;
950
950
  // This is a *consecutive no-progress* streak, not a lifetime counter for the call. A different
951
951
  // failure is a changed attempt; keep only that new streak instead of letting an old failure
952
952
  // silently accumulate across intervening work.
953
953
  life.failedCalls.clear();
954
- life.failedCalls.set(key, count);
954
+ life.failedCalls.set(identity.key, count);
955
955
  if (count >= REPEATED_FAILURE_LIMIT && !repeatHalt)
956
- repeatHalt = { tool: name, count };
956
+ repeatHalt = { label: identity.label, count };
957
957
  }
958
958
  else {
959
959
  // Any successful action is progress (in particular edit/exec calls that may have fixed the
@@ -8,6 +8,7 @@
8
8
  // sessions in one process, so streaks are keyed by the same run scope as todo/reminder state.
9
9
  const DEFAULT_SCOPE = "default";
10
10
  const seenByScope = new Map();
11
+ const HOME_WORKSPACE_BOUNDARY_KEY = "root-cause:home-workspace-boundary";
11
12
  function scopedSeen(scope) {
12
13
  const key = scope?.trim() || DEFAULT_SCOPE;
13
14
  const seen = seenByScope.get(key) ?? new Map();
@@ -68,23 +69,52 @@ export function looksFailed(content, name) {
68
69
  }
69
70
  return false;
70
71
  }
72
+ /** Several different filesystem tools can hit the same protected Home-workspace boundary. Treating each
73
+ * tool name/argument tuple as a fresh idea lets a model spin through grep → glob → ls even though the
74
+ * root cause cannot change inside that run. Only Hara's own stable boundary diagnostics are coalesced. */
75
+ function isHomeWorkspaceBoundaryFailure(content) {
76
+ return (/will not recursively scan the home directory\b/i.test(content)
77
+ || /will not enumerate or recursively scan directories while Hara is rooted at the home directory\b/i.test(content)
78
+ || /workspace that is the home directory or contains it\b/i.test(content));
79
+ }
80
+ /** Stable identity used by both the warning note and the run-level hard breaker. */
81
+ export function failureIdentity(name, input, content, isError = false) {
82
+ const failed = isError || looksFailed(content, name);
83
+ if (failed && isHomeWorkspaceBoundaryFailure(content)) {
84
+ return {
85
+ key: HOME_WORKSPACE_BOUNDARY_KEY,
86
+ label: "Home workspace boundary",
87
+ semantic: true,
88
+ };
89
+ }
90
+ return {
91
+ key: keyOf(name, input),
92
+ label: `${name} call`,
93
+ semantic: false,
94
+ };
95
+ }
71
96
  /** Record a completed call; returns a warning to APPEND to the tool result when the same call has now
72
97
  * failed >=2x in a row (empty string otherwise). Pure aside from the session-scoped map. */
73
98
  export function recordCall(name, input, content, isError = false, scope) {
74
- const k = keyOf(name, input);
75
99
  const failed = isError || looksFailed(content, name);
100
+ const identity = failureIdentity(name, input, content, isError);
76
101
  const seen = scopedSeen(scope);
77
102
  if (!failed) {
78
103
  seen.clear(); // any success is progress; a later failure starts a fresh no-progress streak
79
104
  return "";
80
105
  }
81
- const s = seen.get(k) ?? { fails: 0 };
106
+ const s = seen.get(identity.key) ?? { fails: 0 };
82
107
  s.fails++;
83
108
  // "In a row" is literal: a different failed call is a changed attempt and breaks the old streak.
84
109
  seen.clear();
85
- seen.set(k, s);
110
+ seen.set(identity.key, s);
86
111
  if (s.fails < 2)
87
112
  return "";
113
+ if (identity.semantic) {
114
+ return (`\n\n⟳ hara: the same ${identity.label} has now blocked ${s.fails} consecutive tool calls — ` +
115
+ "another filesystem/search tool cannot bypass it. Ask the user to switch with `/cd <project>` " +
116
+ "or stop this run; do not probe another directory tool from Home.");
117
+ }
88
118
  return (`\n\n⟳ hara: this exact ${name} call has now FAILED ${s.fails}× with identical arguments — ` +
89
119
  `repeating it unchanged will fail again. Read the error above, change something (arguments / approach / tool), ` +
90
120
  `or step back and re-plan; if you're out of ideas, ask the user and say what you tried.`);