Repository navigation
feat(gateway): add usage report rpc - #4
Merged
Merged
Conversation
cryptolir
force-pushed
the
codex/system-reports
branch
from
March 28, 2026 12:51
6d15891 to
94b9b3b
Compare
cryptolir
pushed a commit
that referenced
this pull request
May 24, 2026
Three blockers from #47: 1. skills/manifest.json now oxfmt-clean. Generator runs `pnpm exec oxfmt skills/manifest.json` as a post-step on write, so future regenerations stay format-compliant. --check mode writes to a tempfile, oxfmts it, and compares against committed (catches both content drift and formatter drift in one shot). 2. Generator now strict by default. Three non-canonical skill directories (canvas, healthcheck, skill-creator) are explicitly allowlisted; any OTHER directory that fails frontmatter parse or lacks metadata.openclaw is a hard error (exit 1). Also enforces `frontmatter.name === directory name` — a mismatch is an error for canonical entries (verified by temporarily editing rain SKILL.md's name field and observing exit 1). 3. /skills/bundled/:name now rejects extra path segments. Previously /skills/bundled/rain/anything served `rain`; now it returns 404 like /skills/bundled/foo/bar. Test (e) tightened to assert 404 across {trailing slash, extra segment, deep extras, extras with unknown leading name}. Validation: - pnpm skills:manifest → writes + oxfmts cleanly - pnpm skills:manifest:check → passes (53 skills, 3 allowlisted) - pnpm exec oxfmt --check skills/manifest.json → clean - pnpm test src/gateway/routes/skills-bundled.test.ts → 13/13 pass - strict mode confirmed: temporarily breaking rain SKILL.md name causes exit 1 with a clear error. Codex's finding #4 (build-and-push.sh ops change) is captured as a follow-up in the PR description — that script lives outside this repo, so it ships as a separate ops change before the post-merge image rebuild. Co-Authored-By: Claude Opus 4.7 <[email protected]>
5 of 6 tasks
cryptolir
added a commit
that referenced
this pull request
May 24, 2026
) * feat(skills): canonical skill registry manifest + bundled endpoints Implements §6.1 of the canonical skill registry plan (PR #46, SHA 8686c48). - scripts/generate-skills-manifest.ts: walks skills/*/SKILL.md, parses frontmatter, computes sha256 contentHash over the full normalized SKILL.md (LF endings, trailing whitespace stripped per line, single trailing newline), writes skills/manifest.json. Also normalizes SKILL.md files on disk so the committed hash matches what is baked into the image. Skips skills without a valid metadata.openclaw block (canvas, healthcheck, skill-creator) with logged warnings. - skills/manifest.json: committed initial snapshot — 53 canonical skills, deterministic (sorted by name, keys sorted within each object). - src/gateway/routes/skills-bundled.ts: GET /skills/bundled returns the runtime envelope (manifest + imageTag/imageSha/sourceSha from build-time env vars OPENCLAW_IMAGE_TAG, OPENCLAW_IMAGE_SHA, OPENCLAW_SOURCE_SHA). GET /skills/bundled/:name returns the SKILL.md body. Both routes require gateway bearer auth. No filesystem traversal outside /app/skills/. - src/gateway/routes/skills-bundled.test.ts: 13 tests covering envelope shape, manifest-file consistency, contentHash verification, body-matches-disk, auth required, and unknown-name 404. - src/gateway/server-http.ts: wire skills-bundled handler into createGatewayHttpServer. - Dockerfile: add OPENCLAW_IMAGE_TAG, OPENCLAW_IMAGE_SHA, OPENCLAW_SOURCE_SHA ARG+ENV pairs for build-time provenance injection. - git-hooks/pre-commit: regenerate and validate manifest when any SKILL.md is staged. - .github/workflows/ci.yml: add skills-manifest-check job (pnpm skills:manifest:check). - package.json: add skills:manifest and skills:manifest:check npm scripts. - docs/skills-manifest.md: schema documentation. - skills/food-order/SKILL.md: quote description field to fix YAML parse error (unquoted colon in "Triggers: order food"). Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * fix(skills): address Codex v1 review on PR #47 Three blockers from #47: 1. skills/manifest.json now oxfmt-clean. Generator runs `pnpm exec oxfmt skills/manifest.json` as a post-step on write, so future regenerations stay format-compliant. --check mode writes to a tempfile, oxfmts it, and compares against committed (catches both content drift and formatter drift in one shot). 2. Generator now strict by default. Three non-canonical skill directories (canvas, healthcheck, skill-creator) are explicitly allowlisted; any OTHER directory that fails frontmatter parse or lacks metadata.openclaw is a hard error (exit 1). Also enforces `frontmatter.name === directory name` — a mismatch is an error for canonical entries (verified by temporarily editing rain SKILL.md's name field and observing exit 1). 3. /skills/bundled/:name now rejects extra path segments. Previously /skills/bundled/rain/anything served `rain`; now it returns 404 like /skills/bundled/foo/bar. Test (e) tightened to assert 404 across {trailing slash, extra segment, deep extras, extras with unknown leading name}. Validation: - pnpm skills:manifest → writes + oxfmts cleanly - pnpm skills:manifest:check → passes (53 skills, 3 allowlisted) - pnpm exec oxfmt --check skills/manifest.json → clean - pnpm test src/gateway/routes/skills-bundled.test.ts → 13/13 pass - strict mode confirmed: temporarily breaking rain SKILL.md name causes exit 1 with a clear error. Codex's finding #4 (build-and-push.sh ops change) is captured as a follow-up in the PR description — that script lives outside this repo, so it ships as a separate ops change before the post-merge image rebuild. Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Liran Peretz <[email protected]> Co-authored-by: Claude Sonnet 4.6 <[email protected]>
cryptolir
added a commit
that referenced
this pull request
Jun 18, 2026
…) (#74) * feat(skills): load_skill tool for app-user sessions (live skills, jailed) App-user sessions run jailed (tools.fs.workspaceOnly) and cannot read the shared SKILL.md by path, so the live dashboard skills listed in their prompt were unusable (the reason the Havaya Drive method was hard-embedded). Add a read-only, name-scoped load_skill tool that resolves a skill NAME — from the same filtered, prompt-visible set the model is shown — to its SKILL.md content, read server-side. The per-user file jail is untouched. Implements docs/experiments/plans/app-user-skill-access.md (Option A) with the codex 4517821566 refinements: - allowlist = the snapshot's resolvedSkills (filtered/prompt-visible), so it is never a side channel to disableModelInvocation/ineligible skills (#2); - confinement against the matched entry's own baseDir, not a hardcoded path, so multi-root (bundled/managed/workspace) skills resolve; symlink-escape rejected (#1); - gated on a resolved app user via resolveAppUserId ?? appUserIdFromSessionKey (turn-1-safe, excludes _no-app-user) (#3); - 24KB cap + truncated flag; no sibling files in v1 (#4). The app skills prompt lists name+description only (no <location>, no host-path leak) and instructs the model to call load_skill; normal sessions unchanged. Files: new src/agents/tools/load-skill.ts; buildAppSkillsPrompt in skills/workspace.ts; buildSkillsSection app branch (system-prompt.ts) threaded via buildEmbeddedSystemPrompt; appSkills wired through pi-tools -> openclaw-tools; attempt.ts resolves the app user, builds the single skills source, and branches. Gate: vitest load-skill 11 + system-prompt.skills 6 + save-user-section 13 (unchanged); tsgo clean on touched files; oxlint --type-aware 0/0; oxfmt. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(skills): address codex 4519976882 — tool-filter, compaction, limits Three P2 fixes to the load_skill app-session path: - [#1] derive appSkillLoad from the FINAL tool list (tools.some(load_skill)) rather than just appUserId, and suppress the app skills section when load_skill was filtered out by tool policy — so the model is never told to call a tool it does not have. The skills prompt is now built after tool creation in both attempt.ts and compact.ts. - [#2] mirror the whole app-session skill branch in compact.ts, so app-user COMPACTION also gets the path-free app prompt + load-by-name (no <location> leak, no loss of the load_skill behavior). - [#3] new limitAppSkills() applies the same maxSkillsInPrompt/char caps as the normal prompt; both the app prompt and the load_skill allowlist are built from it, so an app session can neither see nor load more skills than a normal prompt shows. Gate: vitest load-skill 11 + system-prompt.skills 8 (+2 limitAppSkills) + overflow-compaction; tsgo clean on touched files; oxlint --type-aware 0/0; oxfmt. Co-Authored-By: Claude Opus 4.8 <[email protected]> * docs(skills): clarify the load_skill allowlist is the prompt-limited subset Codex recheck 4520156223 non-blocking nit: comments in load-skill.ts and the appSkills option docs (openclaw-tools.ts, pi-tools.ts) described the allowlist as the snapshot's resolvedSkills; after the limit fix it is the prompt-limited subset (via limitAppSkills). Comment-only; keeps the security invariant easy to audit. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Liran Peretz <[email protected]> Co-authored-by: Claude Opus 4.8 <[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.
Summary
usage.reportgateway RPC for full-window model/provider cost reportingusage.costandsessions.usagebehavior unchangedTest Plan