Repository navigation
feat(tools): save_user_section — agent writes per-user app sections - #49
Merged
Merged
Conversation
Write half of the Havaya per-user integration (the openclaw-dashboard reader endpoint serves what this writes). Lets the `life` agent persist an allowlisted field (User_D_Prompt, app_note) into the chatting user's per-user workspace file users/<appUserId>.md as an HTML-comment marker section, so the connected app can display it. Identity is resolved SERVER-SIDE, never by the model: the integrating app (Havaya) sends an explicit appUserId on chat.send; the gateway persists it on the session entry; the tool reads it back via loadSessionEntry. The id is lowercased to match the dashboard reader (which lowercases the query userId). Sections are upserted (replace if present, append otherwise); duplicate/malformed markers fail closed rather than corrupt the file. Lazy provisioning — the file is created on first write. Changes: - src/agents/tools/save-user-section.ts: the tool + pure upsertSection(). - src/agents/openclaw-tools.ts: register it (conditional, needs workspaceDir). - src/config/sessions/types.ts: SessionEntry.appUserId (optional, additive). - src/gateway/protocol/schema/logs-chat.ts: chat.send accepts appUserId (required because the schema is additionalProperties:false). - src/gateway/server-methods/chat.ts: persist appUserId onto the session entry before dispatch (best-effort; never blocks the turn). Tests: src/agents/tools/save-user-section.test.ts — 9 vitest cases for upsertSection (append / replace-in-place / isolation / trim / duplicate fail-closed / round-trip) + the writable-section allowlist. Gates: npx vitest run save-user-section.test.ts → 9/9; npx tsgo --noEmit introduces 0 new errors (9 pre-existing on origin/main, unchanged). NOTE: requires the heavyweight gateway deploy (build-and-push + deploy.sh) to take effect on the `life` host — NOT auto-deployed. Pairs with a dashboard PR (appUserId passthrough) and a Havaya PR (send appUserId). Co-Authored-By: Claude Opus 4.8 <[email protected]>
cryptolir
pushed a commit
that referenced
this pull request
Jun 1, 2026
Adds docs/tools/save-user-section.md describing the save_user_section agent tool shipped in #49: the writable allowlist (User_D_Prompt, app_note), the users/<appUserId>.md marker-section upsert, server-side appUserId identity resolution (chat.send -> SessionEntry -> resolveAppUserId), wiring, and the security model. Registers the page under 'Built-in tools' in docs.json. Docs-only; reflects code already on main. Co-Authored-By: Claude Opus 4.8 <[email protected]>
cryptolir
added a commit
that referenced
this pull request
Jun 1, 2026
…51) Adds docs/tools/save-user-section.md describing the save_user_section agent tool shipped in #49: the writable allowlist (User_D_Prompt, app_note), the users/<appUserId>.md marker-section upsert, server-side appUserId identity resolution (chat.send -> SessionEntry -> resolveAppUserId), wiring, and the security model. Registers the page under 'Built-in tools' in docs.json. Docs-only; reflects code already on main. Co-authored-by: Liran Peretz <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
cryptolir
added a commit
that referenced
this pull request
Jun 2, 2026
…ssion (#52) Records the 2026-06-01/02 session: save_user_section gateway tool (PR #49), appUserId passthrough (dashboard #108/#110), reader endpoint (#107), life-only deploy to v2026.06.01.1, AGENTS.md update, security remediation (key rotation + history scrub), and prod validation results. Co-authored-by: Liran Peretz <[email protected]> Co-authored-by: Claude Sonnet 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Write half of the Havaya per-user integration. The
openclaw-dashboardreader endpoint (PR #107) serves what this writes. Plan:openclaw-dashboard:docs/peruser-user-file-plan.md; contract:AGENTGLOB_USER_FILE_API.md.What it does
Adds a
save_user_section(section, content)agent tool. Thelifeagent calls it mid-chat to persist an allowlisted field (User_D_Prompt,app_note) into the chatting user's per-user fileusers/<appUserId>.md, as an<!-- app:<section>:start -->…end -->marker block. Upsert semantics (replace in place if present, else append); lazy file creation.Identity (the key design point)
Resolved server-side, never by the model: Havaya sends an explicit
appUserIdonchat.send→ the gateway persists it on theSessionEntry→ the tool reads it back vialoadSessionEntry(agentSessionKey). The id is lowercased to match the reader (which lowercases the queryuserId). This keeps the gateway free of any Havaya sessionKey-format parsing (Guidance §1: partitioning stays app-owned).Changes
src/agents/tools/save-user-section.ts— tool + pureupsertSection().src/agents/openclaw-tools.ts— register (conditional onworkspaceDir).src/config/sessions/types.ts—SessionEntry.appUserId?(additive).src/gateway/protocol/schema/logs-chat.ts—chat.sendacceptsappUserId(required since schema isadditionalProperties:false).src/gateway/server-methods/chat.ts— persistappUserIdbefore dispatch (best-effort; never blocks the turn).Gates
npx vitest run -c vitest.unit.config.ts src/agents/tools/save-user-section.test.ts→ 9/9.npx tsgo --noEmit→ 0 new errors (9 pre-existing onorigin/main—self-info-tool.e2e,skills-bundled,login-qr,chat.ts:417— verified identical by stashing this branch's changes).Deploy / coordination
build-and-push.sh+deploy.sh vYYYY.MM.DD.N) to take effect on thelifehost — not auto-deployed. Holding for explicit authorization.appUserIdthroughchatSendAndWait+ the public chat route) and a Havaya PR (sendappUserIdinsrc/lib/agentglob.ts). Until all three + deploy land, the reader keeps returning 404 (Havaya degrades to empty UI by design).life'sAGENTS.mdwill want a line telling the agent when to callsave_user_section— intentionally not included here (it's per-agent workspace config on the host, not repo code).🤖 Generated with Claude Code