feat(tools): resident-owned visibility, descriptions, and component defaults - #162
LariTesserae wants to merge 1 commit into
Conversation
|
| const queued = [...this.agents.values()].flatMap((agent) => { | ||
| const cm = agent.getContextManager(); | ||
| const tools = this.getToolsForAgent(agent.name).filter((tool) => agent.canUseTool(tool.name)); | ||
| const tools = this.advertisedToolsForAgent(agent.name); |
There was a problem hiding this comment.
Hidden tools disrupt compression When a resident hides a tool it used earlier, maintenance now passes only visible tools to the context manager, even though the transcript still contains calls to the hidden tool. The context manager requires those tool definitions for compression, so Anthropic can refuse the compression request. Keep historical tool definitions available to maintenance without advertising hidden tools to the resident.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/framework.ts
Line: 2047
Comment:
**Hidden tools disrupt compression** When a resident hides a tool it used earlier, maintenance now passes only visible tools to the context manager, even though the transcript still contains calls to the hidden tool. The context manager requires those tool definitions for compression, so Anthropic can refuse the compression request. Keep historical tool definitions available to maintenance without advertising hidden tools to the resident.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| async handleToolCall(call: ToolCall): Promise<ToolResult> { | ||
| try { | ||
| const input = call.input as Record<string, unknown>; | ||
| const generated = typeof input?.path === 'string' ? this.generatedTextFiles.get(input.path) : undefined; |
There was a problem hiding this comment.
Path aliases bypass catalogue protection The generated-file guard matches only the exact path string. If a writable mount has auto-materialization enabled, a write to
board/./tools.md bypasses a catalogue registered at board/tools.md and writes to the same physical location. Reading through the alias can also return stored or physical content instead of the generated catalogue, so the virtual file is neither consistently read-only nor authoritative.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/modules/workspace/index.ts
Line: 1092
Comment:
**Path aliases bypass catalogue protection** The generated-file guard matches only the exact path string. If a writable mount has auto-materialization enabled, a write to `board/./tools.md` bypasses a catalogue registered at `board/tools.md` and writes to the same physical location. Reading through the alias can also return stored or physical content instead of the generated catalogue, so the virtual file is neither consistently read-only nor authoritative.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const componentDefault = defaults.get(tool.name); | ||
| let description = override?.description ?? componentDefault?.description ?? tool.description; | ||
| const descriptionSource = override?.description !== undefined ? this.config.path : componentDefault?.path ?? "installed component"; | ||
| if (isPresentationTool(tool.name) && override?.description !== undefined) |
There was a problem hiding this comment.
Defaults remove catalogue signposts If a
Framework defaults profile supplies descriptions for both editing tools, those descriptions replace the installed wording, but this branch restores the catalogue path only for resident overrides. A resident with hidden tools then has no guaranteed signpost to discover their names and restore them. Preserve the catalogue instructions for component-default descriptions as well.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/tool-presentation.ts
Line: 103
Comment:
**Defaults remove catalogue signposts** If a `Framework` defaults profile supplies descriptions for both editing tools, those descriptions replace the installed wording, but this branch restores the catalogue path only for resident overrides. A resident with hidden tools then has no guaranteed signpost to discover their names and restore them. Preserve the catalogue instructions for component-default descriptions as well.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| parsePresentation(next); | ||
| if (Buffer.byteLength(next)>MAX_BYTES) throw new Error('Presentation exceeds 256 KiB'); | ||
| temp = this.config.path + '.' + randomUUID() + '.tmp'; | ||
| writeFileSync(temp,next,{flag:'wx',mode}); |
There was a problem hiding this comment.
Edits can change file permissions Creating the temporary file with the original mode does not preserve permissions if the process umask masks some bits. For example, editing a group-writable
0664 file under umask 0022 replaces it with a 0644 file, preventing other group editors from updating shared overrides. Apply the original mode after creating the temporary file.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/tool-presentation.ts
Line: 136
Comment:
**Edits can change file permissions** Creating the temporary file with the original mode does not preserve permissions if the process umask masks some bits. For example, editing a group-writable `0664` file under umask `0022` replaces it with a `0644` file, preventing other group editors from updating shared overrides. Apply the original mode after creating the temporary file.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Problem
Residents receive every allowed tool definition even when many are irrelevant to their current work, and shared descriptions cannot be adapted without changing component code. Hiding a definition should preserve the ability to discover and restore it.
Changes
Add opt-in file-backed description/visibility overrides, two resident editing tools, and an agent-scoped generated catalogue. The catalogue groups exact tool names by registered component, includes hidden definitions and schemas, and supplies line offsets for detailed reads. Optional source-bound profiles supply reusable description defaults; resident wording wins, while visibility remains resident-owned.
Preview, inference and maintenance use the same advertised surface. Execution permissions remain independent. Editing uses a sibling lock, atomic replacement and a concurrent-change check; recovery tools stay visible. Native queued tool calls carry the authenticated caller identity through to generated-file reads. Preview metadata is captured with the corresponding request.
Tests
Framework build passes. Targeted presentation/defaults tests: 4 pass / 0 fail. Related workspace text/image/path containment and explicit prose routing tests: 42 pass / 0 fail. Tests cover reset, malformed files, source scoping, absent components, resident precedence, both tool dispatch paths, catalogue ownership and preview consistency.
A compatibility deployment was also checked through normalized previews; this is not evidence that the current upstream branch was deployed unchanged.
Not verified / limitations
Full framework suite and all provider transports were not run. Ordinary-use feedback across models is pending. Catalogue files are virtual and do not appear in ls/glob or ordinary host downloads. Changes affect newly compiled requests, not in-flight streams. Profiles are explicit deployment configuration, not automatic package discovery. File coordination cannot make uncooperative external editors transactional. Parameter-schema description overrides are out of scope.
Companion PRs / merge order
Merge and release this framework change first. The companion connectome-host PR adds recipe configuration and matching debug metadata, and must update its dependency floor and lockfile to that actual release before merge. The Discord wording PR is independent. No personal resident visibility list or conversation data is included.
Companion review links: framework #162, host #135, Discord #32.