feat(knowledge): rebuild the project notes panel as Project knowledge (#2973)
The panel stored notes, todos and plans inside one shared JSON file that six unrelated domains also wrote to, synchronised itself through window CustomEvents, and could only read plans. It is now Project knowledge: server-owned storage with explicit routes, a store with rollback, a section sidebar, plans that open and edit in place, and search across all of it. Notes and plans the user pins travel with every message sent in that project. Pinning is project state, not an attachment to one message, so it holds until unpinned and the work status panel names what is riding along and can detach it. Agent memory is added alongside, in two scopes: what is true about the user, and what is true about this codebase. The split is not cosmetic — a wrong project fact costs one project and is noticed, while a wrong global fact quietly shapes every session everywhere and the user has no code to check it against. It stays separate from notes so an agent mistake cannot land in what the user wrote. Sessions receive an index of titles only; bodies are read on demand, because an index carrying full text grows until it crowds out the conversation. Deciding what a session must be told, and whether it has been told, now lives on the server. The client owned it before, which meant sessions started without a UI — scheduled tasks, sessions the agent dispatches — received nothing at all, and a tab's record of what it had sent outlived the conversation: after compaction the agent no longer held the block while the tab went on believing it did. What was delivered is recorded in the session's own metadata, and compaction restores it through the runtime that already restores pinned messages, in the same turn. Agent memory ships dark behind OPENCHAMBER_MEMORY_ENABLE: unset, there is no tool, no routes, no session index, no settings row and no panel tab. Absent rather than switched off, so nothing invites turning on a feature that has not been announced. Pinned notes and plans are unaffected and ship as normal.
This commit is contained in:
committed by
GitHub
parent
7611076436
commit
34e8a24b20
@@ -181,7 +181,7 @@ describe('managed agent tool runtime', () => {
|
||||
|
||||
it('omits a tool the user turned off', async () => {
|
||||
const { runtime, dataDir } = await createRuntime();
|
||||
await runtime.prepareManagedOpenCodeEnv({ includeControl: false, includeWeb: true });
|
||||
await runtime.prepareManagedOpenCodeEnv({ includeControl: false, includeWeb: true, includeMemory: false });
|
||||
const pluginPath = path.join(dataDir, 'agent-tool', 'openchamber-plugin.js');
|
||||
const pluginModule = await import(`${pathToFileURL(pluginPath).href}?web=${Date.now()}`);
|
||||
const { tool } = await pluginModule.OpenChamberPlugin();
|
||||
@@ -189,17 +189,100 @@ describe('managed agent tool runtime', () => {
|
||||
expect(Object.keys(tool)).toEqual(['openchamber_web']);
|
||||
});
|
||||
|
||||
it('exposes memory as its own tool carrying only its own inputs', async () => {
|
||||
const { runtime, dataDir } = await createRuntime();
|
||||
await runtime.prepareManagedOpenCodeEnv({ includeControl: true, includeWeb: false, includeMemory: true });
|
||||
const pluginPath = path.join(dataDir, 'agent-tool', 'openchamber-plugin.js');
|
||||
const pluginModule = await import(`${pathToFileURL(pluginPath).href}?memory=${Date.now()}`);
|
||||
const { tool } = await pluginModule.OpenChamberPlugin();
|
||||
|
||||
expect(Object.keys(tool)).toEqual(['openchamber', 'openchamber_memory']);
|
||||
expect(Object.keys(tool.openchamber_memory.args.parameters.properties).sort())
|
||||
.toEqual(['body', 'memoryId', 'scope', 'title', 'type']);
|
||||
// Memory inputs must not leak into the control tool's schema, which the
|
||||
// model pays for on every unrelated call.
|
||||
expect(Object.keys(tool.openchamber.args.parameters.properties)).not.toContain('memoryId');
|
||||
});
|
||||
|
||||
it('omits memory entirely when the user turns it off', async () => {
|
||||
const { runtime, dataDir } = await createRuntime();
|
||||
await runtime.prepareManagedOpenCodeEnv({ includeControl: true, includeWeb: false, includeMemory: false });
|
||||
const pluginPath = path.join(dataDir, 'agent-tool', 'openchamber-plugin.js');
|
||||
const pluginModule = await import(`${pathToFileURL(pluginPath).href}?nomemory=${Date.now()}`);
|
||||
const { tool } = await pluginModule.OpenChamberPlugin();
|
||||
|
||||
expect(Object.keys(tool)).toEqual(['openchamber']);
|
||||
});
|
||||
|
||||
it('injects the plugin when memory is the only tool left on', async () => {
|
||||
const { runtime, dataDir } = await createRuntime();
|
||||
await runtime.prepareManagedOpenCodeEnv({ includeControl: false, includeWeb: false, includeMemory: true });
|
||||
const pluginPath = path.join(dataDir, 'agent-tool', 'openchamber-plugin.js');
|
||||
const pluginModule = await import(`${pathToFileURL(pluginPath).href}?onlymemory=${Date.now()}`);
|
||||
const { tool } = await pluginModule.OpenChamberPlugin();
|
||||
|
||||
expect(Object.keys(tool)).toEqual(['openchamber_memory']);
|
||||
});
|
||||
|
||||
it('refuses to inject a plugin with no tools in it', async () => {
|
||||
const { runtime } = await createRuntime();
|
||||
let failed = false;
|
||||
try {
|
||||
await runtime.prepareManagedOpenCodeEnv({ includeControl: false, includeWeb: false });
|
||||
await runtime.prepareManagedOpenCodeEnv({ includeControl: false, includeWeb: false, includeMemory: false });
|
||||
} catch {
|
||||
failed = true;
|
||||
}
|
||||
expect(failed).toBe(true);
|
||||
});
|
||||
|
||||
it('accepts the bare action a tool name already qualifies', async () => {
|
||||
// Observed: the model called `read` on openchamber_memory, having taken the
|
||||
// tool's own name for the namespace.
|
||||
const executeAction = vi.fn(async () => ({ memory: {} }));
|
||||
const { runtime } = await createRuntime({ executeAction });
|
||||
|
||||
const result = await runtime.execute({
|
||||
input: { action: 'read', title: 'Uses bun' },
|
||||
contextDirectory: '/work/project',
|
||||
tool: 'openchamber_memory',
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.action).toBe('memory.read');
|
||||
expect(executeAction).toHaveBeenCalledWith(
|
||||
'memory.read',
|
||||
{ action: 'memory.read', title: 'Uses bun' },
|
||||
'/work/project',
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
it('tells an unresolvable action what the calling tool can do', async () => {
|
||||
const { runtime } = await createRuntime();
|
||||
|
||||
const result = await runtime.execute({
|
||||
input: { action: 'get' },
|
||||
tool: 'openchamber_memory',
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.error.message).toContain('memory.read');
|
||||
expect(result.error.message).not.toContain('browser.open');
|
||||
});
|
||||
|
||||
it('does not let one tool reach another tool\'s actions', async () => {
|
||||
const executeAction = vi.fn(async () => ({}));
|
||||
const { runtime } = await createRuntime({ executeAction });
|
||||
|
||||
const result = await runtime.execute({
|
||||
input: { action: 'open', url: 'https://example.test' },
|
||||
tool: 'openchamber_memory',
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(executeAction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('executes actions through the shared control service', async () => {
|
||||
const executeAction = vi.fn(async () => ({ projects: [] }));
|
||||
const { runtime } = await createRuntime({ executeAction });
|
||||
|
||||
Reference in New Issue
Block a user