Commit Graph

85 Commits

Author SHA1 Message Date
0b7f18253d feat(dynamic-trim): rename trim-tool-result, add self-compact, drop list-tool-results
Align the openclaw side of the dynamic-* tool family with the new
Plexum design (decision #31, 2026-06-04 revision):

- trim-tool-result → dynamic-trim (same on-wire schema; same semantics)
- Drop list-tool-results entirely. Agents find the opaque tool_call_id
  by reading their own prior assistant message's toolCall block id
  instead of querying a separate "directory" tool. This removes a
  workflow-step prerequisite and matches how Anthropic-shaped APIs
  surface tool_use ids to the model anyway.
- On agent_end drain, ALSO self-compact the dynamic-trim's own
  tool_use.input: rewrite to {tool_call_id, _self_compacted: true}.
  Without this the bulky `replacement` text sits duplicated — once in
  the rewritten target tool_result, once in dynamic-trim's call input.
  Picks up the selfCallId from openclaw's execute(toolCallId, ...) first
  arg (was previously discarded as _id).

Cross-runtime contract: tool name, input schema, return shape, and
sentinel prefix ("[trimmed by self] ") match Plexum's dynamic-trim
in internal/dynmem/trim.go + internal/persistence/trim.go.

Sim e2e tested: dynamic-trim queues, agent_end drain rewrites both
the target tool_result content AND the trim call's tool_use input.
No takeover errors. trimmed_bytes positive on real workloads.
2026-06-04 07:47:30 +01:00
209ab0d82e feat: trim-tool-result + list-tool-results for agent-driven session pruning
Two new openclaw tools that let an agent reclaim ctx tokens consumed by
past tool results once it has extracted what it needs:

  list-tool-results — enumerates past toolResults in the agent's own
    session jsonl (size, tool name, turns-ago, args summary, already-
    trimmed flag); does NOT return content body
  trim-tool-result — replaces a past toolResult's content[].text with a
    short sentinel-tagged replacement, identified by tool_call_id

The actual file rewrite is deferred to the `agent_end` hook (drained
from an in-memory queue) because writing during tool execute() trips
openclaw's session-file fence (EmbeddedAttemptSessionTakeoverError) —
the fingerprint check around releaseForPrompt rejects third-party
writes. By agent_end the lock window is closed and the next turn's
fence baseline picks up our mutation cleanly.

Queue-time validation rejects bad tool_call_ids up-front so weak
models that confuse opaque call_function_*_N ids with topic/fact
numeric ids get a clear error instead of a silent skip at drain time.

install.mjs now auto-sets plugins.entries.padded-cell.hooks.
allowConversationAccess=true (required for the agent_end hook on
non-bundled plugins; without it the drain never fires and queued
trims rot in memory).

Sim-verified end-to-end: model dispatches trim, drain fires on
agent_end, next turn's list shows already_trimmed=true.
2026-06-02 07:23:02 +01:00
zhi
787d88cd33 chore: convert plugin to ESM and migrate to current openclaw plugin SDK
ESM conversion:
- package.json: add "type": "module"; drop stale "main": "index.ts"
- tsconfig.json: switch module/moduleResolution to "nodenext"
- plugin/index.ts: replace `module.exports = { register }` and
  `module.exports.X = X` with `export default definePluginEntry({ ... })`
  plus named ESM re-exports; replace `require('os')`/`require('path')`
  with proper imports.
- plugin/tools/pcexec.ts: replace `require('child_process')` with import
  from "node:child_process".
- plugin/commands/ego-mgr-slash.ts: replace `require('path')` with
  proper path import.
- All relative imports/exports across plugin/ now carry .js extensions
  as required by Node ESM (nodenext module resolution).

Plugin SDK convention update:
- Wrap default export with definePluginEntry({ id, name, description,
  register }) per the current openclaw authoring contract.
- Type api parameter as OpenClawPluginApi (was `any`); the non-standard
  api.registerSlashCommand call is preserved behind a guarded any-cast,
  so the plugin remains a no-op for slash commands when the host doesn't
  expose that hook (matches the previous defensive guard).
- Add openclaw as a devDependency (file:/usr/lib/node_modules/openclaw)
  so tsc can resolve openclaw/plugin-sdk/* subpath types at build time.
- Modernize openclaw.plugin.json: drop entry/version, add
  activation.onStartup so gateway_start fires for this plugin at boot,
  declare contracts.tools listing pcexec/proxy-pcexec/safe_restart.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 08:02:30 +00:00
cb683c43bb fix: avoid clobbering sensitive config fields during configure
Reading the entire plugins tree via openclaw config get returns redacted
values for sensitive fields. Writing it back overwrites real secrets with
the __OPENCLAW_REDACTED__ sentinel. Changed to set individual leaf paths
only when missing.
2026-04-16 14:34:07 +00:00
h z
392eafccf2 Merge pull request 'feat(ego-mgr): add lookup subcommand' (#15) from feat/ego-mgr-lookup into main
Reviewed-on: #15
2026-04-14 21:35:37 +00:00
39856a3060 feat(ego-mgr): add lookup subcommand
ego-mgr lookup <username>
  - Finds agent whose default-username == username
  - Echoes the agent-id (map key in agent-scope)
  - Exits 7 if not found or column missing
2026-04-14 21:33:09 +00:00
c6f0393c65 fix: lock-mgr lock identifier if file does not exist 2026-04-13 16:00:40 +01:00
1a202986e8 fix: lock-mgr release meta-lock before exiting 2026-04-13 15:46:49 +01:00
dcc91ead9b fix: lock-mgr get key from arg instead of env 2026-04-13 15:37:13 +01:00
311d9f4d9f feat: add lock-mgr CLI tool and wire into install script
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 21:41:51 +01:00
h z
525436d64b Merge pull request 'feat/proxy-pcexec' (#14) from feat/proxy-pcexec into main
Reviewed-on: #14
2026-03-30 11:57:56 +00:00
nav
36f3c93484 fix: preserve existing plugin config on install 2026-03-30 11:56:52 +00:00
nav
1ac75f429c fix: load plugin config from api.pluginConfig 2026-03-30 11:47:42 +00:00
nav
a2b965094d chore: log proxy pcexec auth context 2026-03-30 11:38:05 +00:00
nav
98a75a50d3 feat: add proxy pcexec tool 2026-03-30 11:22:26 +00:00
nav
4a8a4b01cb docs: clarify proxy pcexec rules 2026-03-30 09:22:25 +00:00
nav
95fb9ba820 docs: update proxy pcexec env vars 2026-03-30 09:12:56 +00:00
nav
764ada7c60 chore: organize planning docs 2026-03-30 09:07:00 +00:00
81c0a4c289 Merge pull request 'feat: add default columns to ego.json' (#13) from feat/default-ego-columns into main
Reviewed-on: #13
2026-03-24 19:10:56 +00:00
zhi
4e8e264390 feat: add default columns to ego.json
Initialize ego.json with default columns on first install:
- columns (Agent Scope): default-username, name, discord-id, email, role,
  position, date-of-birth, agent-id, gender
- public-columns (Public Scope): git-host, keycloak-host
2026-03-24 19:10:23 +00:00
21d7a85ba1 Merge pull request 'feat: add /ego-mgr slash command' (#12) from feat/ego-mgr-slash-command into main
Reviewed-on: #12
2026-03-24 19:01:28 +00:00
zhi
7346c80c88 feat: add /ego-mgr slash command
Add /ego-mgr slash command with subcommands:
- get, set, list, delete, add-column, add-public-column, show
- Uses pcexec to call ego-mgr binary with proper env vars

Translate all Chinese text to English in responses.

Note: pcexec tool name and function names remain unchanged.
2026-03-24 10:59:05 +00:00
7fd2819a04 Merge pull request 'feat: rename pass_mgr → secret-mgr, add ego-mgr binary and skill' (#11) from feat/ego-mgr-and-rename into main
Reviewed-on: #11
2026-03-24 09:50:40 +00:00
zhi
98fc3da39c feat: rename pass_mgr → secret-mgr, add ego-mgr binary and skill
M1: Rename pass_mgr to secret-mgr
- Rename directory, binary, and Go module
- Update install.mjs to build/install secret-mgr
- Update pcexec.ts to support secret-mgr patterns (with legacy pass_mgr compat)
- Update plugin config schema (passMgrPath → secretMgrPath)
- Create new skills/secret-mgr/SKILL.md
- install.mjs now initializes ego.json on install

M2: Implement ego-mgr binary (Go)
- Agent Scope and Public Scope column management
- Commands: add column/public-column, delete, set, get, show, list columns
- pcexec environment validation (AGENT_VERIFY, AGENT_ID, AGENT_WORKSPACE)
- File locking for concurrent write safety
- Proper exit codes per spec (0-6)
- Agent auto-registration on read/write
- Global column name uniqueness enforcement

M3: ego-mgr Skill
- Create skills/ego-mgr/SKILL.md with usage guide and examples

Ref: REQUIREMENTS_EGO_MGR.md
2026-03-24 09:36:03 +00:00
nav
be0f194f47 docs: add pass_mgr to secret-mgr migration steps 2026-03-24 00:52:05 +00:00
nav
2816f3a862 docs: remove env var rename note 2026-03-24 00:45:11 +00:00
nav
ce79a782b9 docs: add agent auto-register & column validation rules 2026-03-24 00:43:22 +00:00
nav
63d7fb569e feat: add ego-mgr requirements & secret-mgr rename spec 2026-03-24 00:40:05 +00:00
nav
2f149ed1b4 Fix pass-mgr skill command syntax 2026-03-15 03:49:45 +00:00
123c73cfc6 Merge pull request 'fix(pcexec): include stderr in error message for better debugging' (#10) from fix/pcexec-error-message into main
Reviewed-on: #10
2026-03-15 03:43:58 +00:00
79c5f4cd27 fix(pcexec): include stderr in error message for better debugging 2026-03-09 08:53:04 +00:00
61cffae9ca Merge pull request 'fix: resolve issues #4 #6 #7 #8 for install and pass_mgr' (#9) from fix/issues-4-6-7-8 into main
Reviewed-on: #9
2026-03-09 07:44:39 +00:00
99787e6ded fix: resolve issues #4 #6 #7 #8 for install and pass_mgr 2026-03-08 23:09:16 +00:00
nav
2e38cb8fe2 tighten secret handling guidance 2026-03-08 21:50:44 +00:00
nav
c16149db9d note username optional for pass_mgr set 2026-03-08 21:47:20 +00:00
nav
b00086816c refine pass-mgr usage guidance 2026-03-08 21:44:47 +00:00
nav
a347908d9f add pass-mgr skill 2026-03-08 21:39:29 +00:00
bc2c5f8bd6 Merge pull request 'feat/refactor-and-pcguard' (#3) from feat/refactor-and-pcguard into main
Reviewed-on: #3
2026-03-08 21:32:53 +00:00
zhi
ddaea57f2d feat: rewrite pass_mgr with build-time AES key, update pcexec & install
pass_mgr:
- Complete rewrite using build-time AES key (injected via ldflags)
- New command format: get-secret/get-username --key, set --key --secret
- Admin commands: init, handoff, init-from (rejected when AGENT_* env set)
- Inline pcguard check for agent commands
- Legacy 'get <key>' kept for backward compat
- Storage: pc-pass-store/<agent-id>/<key>.gpg with AES-256-GCM
- Admin password stored as SHA-256 hash in .pass_mgr/admin.json

pcexec.ts:
- Support new 'get-secret --key' pattern alongside legacy 'get <key>'
- Pass environment to fetchPassword for pcguard validation
- Deduplicate matches, sanitize all resolved passwords from output

install.mjs:
- Generate random 32-byte hex build secret (.build-secret)
- Reuse existing secret on rebuilds
- Pass to go build via -ldflags -X main.buildSecret=<secret>

README.md:
- Document new pass_mgr command format
- Document admin handoff/init-from workflow
- Document security model limitations
- Update project structure
2026-03-08 21:12:27 +00:00
zhi
c186eb24ec fix: copy package.json to install dest for npm install 2026-03-08 12:02:11 +00:00
zhi
0569a5dcf5 feat: refactor project structure + add pcguard + AGENT_VERIFY injection
- Restructure: pcexec/ and safe-restart/ → plugin/{tools,core,commands}
- New pcguard Go binary: validates AGENT_VERIFY, AGENT_ID, AGENT_WORKSPACE
- pcexec now injects AGENT_VERIFY env + appends openclaw bin to PATH
- plugin/index.ts: unified TypeScript entry point with resolveOpenclawPath()
- install.mjs: support --openclaw-profile-path, install pcguard, new paths
- README: updated structure docs + security limitations note
- Removed old root index.js and openclaw.plugin.json
2026-03-08 11:48:53 +00:00
nav
239a6c3552 add NEW_FEAT and remove task lists 2026-03-08 11:40:40 +00:00
nav
59d72ef365 add PATH injection task 2026-03-07 16:55:44 +00:00
nav
0760fed8ff add pcguard tasks to agent tasks 2026-03-06 12:57:11 +00:00
nav
5134325794 add pcguard task list and README note 2026-03-06 12:48:13 +00:00
842a19a56c Merge pull request 'fix: remove shell:true default to fix command output' (#2) from fix/shell-option into main
Reviewed-on: #2
2026-03-06 09:24:57 +00:00
zhi
903e5efddb fix: remove shell:true default to fix command output
- Removed shell:true default that caused double shell wrapping
- This was causing echo and other commands to return empty output
- Now matches OpenClaw exec behavior which never uses shell:true
2026-03-06 09:20:38 +00:00
9c70cc33a5 Merge pull request 'dev/zhi' (#1) from dev/zhi into main
Reviewed-on: #1
2026-03-05 19:08:00 +00:00
zhi
c2fb28301c fix: rename init() to register() for OpenClaw plugin API
OpenClaw expects 'register' or 'activate' export, not 'init'
2026-03-05 19:02:53 +00:00
zhi
27a94d1da7 fix: use OpenClaw plugin SDK format with api.registerTool()
- Change index.js to export init() function that receives api
- Use api.registerTool() to dynamically register tools
- Remove tools array from manifest (not needed for dynamic registration)
- Add passMgrPath to configSchema
2026-03-05 18:57:58 +00:00