The Open Framework for Building Agents
Refine self-modification discovery and editing guidance (#3260)
prha84c9604c17a4
diff --git a/.changeset/quick-cats-edit.md b/.changeset/quick-cats-edit.mdnew file mode 100644index 000000000..633d5abf6--- /dev/null+++ b/.changeset/quick-cats-edit.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Make self-modification source edits more efficient by clarifying file and documentation discovery, guarded reads, edit selection, contract preservation, outbound request safety, registry scope, and concise completion reports. Memory providers can now be selected as a registry search category.diff --git a/apps/docs/registry/experimental/self-modification/agent.ts b/apps/docs/registry/experimental/self-modification/agent.tsindex b1fd88b57..574eaa1f5 100644--- a/apps/docs/registry/experimental/self-modification/agent.ts+++ b/apps/docs/registry/experimental/self-modification/agent.ts@@ -2,4 +2,9 @@ import { defineSelfModificationAgent } from "eve/self-modification/agent";import config from "./config";-export default defineSelfModificationAgent({ config });+export default defineSelfModificationAgent({+ config,++ // To use a specific model instead of eve's default, add:+ // model: "provider/model",+});diff --git a/packages/eve/src/self-modification/agent.test.ts b/packages/eve/src/self-modification/agent.test.tsdeleted file mode 100644index 31b05b1e0..000000000--- a/packages/eve/src/self-modification/agent.test.ts+++ /dev/null@@ -1,142 +0,0 @@-import { afterEach, describe, expect, it, vi } from "vitest";--import type { DynamicResolveContext } from "#dynamic/definition.js";--import { DEFAULT_SELF_MODIFICATION_MODEL, defineSelfModificationAgent } from "./agent.js";--const originalEveDev = process.env.EVE_DEV;-const originalGitHubToken = process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN;-const deployed = {- deployed: {- source: { git: { directory: ".", repository: "github.com/acme/agent" } },- target: { branch: "main" },- authorize: () => true,- credentials: { pat: true },- },-} as const;--afterEach(() => {- if (originalEveDev === undefined) {- delete process.env.EVE_DEV;- } else {- process.env.EVE_DEV = originalEveDev;- }- if (originalGitHubToken === undefined) {- delete process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN;- } else {- process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN = originalGitHubToken;- }-});--describe("defineSelfModificationAgent", () => {- it("uses the default model", async () => {- process.env.EVE_DEV = "1";-- const agent = defineSelfModificationAgent();- const definition = await agent.events["session.started"]?.({}, {} as never);-- expect(definition).toMatchObject({- description: expect.stringContaining(- "investigate, diagnose, or optimize the agent's behavior from local traces",- ),- model: DEFAULT_SELF_MODIFICATION_MODEL,- });- });-- it("configures the subagent model", async () => {- process.env.EVE_DEV = "1";-- const agent = defineSelfModificationAgent({ model: "openai/gpt-5" });- const definition = await agent.events["session.started"]?.({}, {} as never);-- expect(definition).toMatchObject({ model: "openai/gpt-5" });- });-- it("requires configured deployment and credential preflight", async () => {- delete process.env.EVE_DEV;- const agent = defineSelfModificationAgent({ config: deployed });- const ctx = { channel: {}, session: { auth: { current: null, initiator: null } } } as never;- await expect(agent.events["session.started"]?.({}, ctx)).resolves.toBeNull();-- process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN = "secret";- const definition = await agent.events["session.started"]?.({}, ctx);- expect(definition?.description).toContain("draft pull request");- expect(definition?.description).toContain("non-secret answers");- });-- it("authorizes the current principal from its channel family", async () => {- delete process.env.EVE_DEV;- process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN = "secret";- const authorize = vi.fn(- ({- channel,- principal,- }: {- channel: { kind?: string };- principal: { principalId: string } | null;- }) => channel.kind === "slack" && principal?.principalId === "slack:T1:U1",- );- const agent = defineSelfModificationAgent({- config: { deployed: { ...deployed.deployed, authorize } },- });- const ctx = {- channel: { kind: "slack" },- session: {- id: "session-1",- auth: {- current: {- attributes: {},- authenticator: "slack-webhook",- principalId: "slack:T1:U1",- principalType: "user",- },- initiator: null,- },- },- } as DynamicResolveContext;-- expect(await agent.events["session.started"]?.({}, ctx)).toMatchObject({- model: DEFAULT_SELF_MODIFICATION_MODEL,- });- expect(authorize).toHaveBeenCalledWith({- channel: ctx.channel,- principal: ctx.session.auth.current,- });- expect(- await agent.events["turn.started"]?.(- {},- {- ...ctx,- session: { ...ctx.session, auth: { ...ctx.session.auth, current: null } },- },- ),- ).toBeNull();- });-- it("fails closed when authorization rejects or throws", async () => {- delete process.env.EVE_DEV;- process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN = "secret";- const ctx = { channel: {}, session: { auth: { current: null, initiator: null } } } as never;-- for (const authorize of [- () => false,- () => {- throw new Error("no");- },- ]) {- const agent = defineSelfModificationAgent({- config: { deployed: { ...deployed.deployed, authorize } },- });- expect(await agent.events["session.started"]?.({}, ctx)).toBeNull();- }- });-- it("keeps configured deployment local under eve dev", async () => {- process.env.EVE_DEV = "1";- process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN = "secret";- const agent = defineSelfModificationAgent({ config: deployed });- const definition = await agent.events["session.started"]?.({}, {} as never);- expect(definition?.description).toContain("developer");- expect(definition?.description).not.toContain("draft pull request");- });-});diff --git a/packages/eve/src/self-modification/agent.ts b/packages/eve/src/self-modification/agent.tsindex b6fc2de24..bffbb6dd1 100644--- a/packages/eve/src/self-modification/agent.ts+++ b/packages/eve/src/self-modification/agent.ts@@ -20,29 +20,38 @@ export interface SelfModificationAgentOptions {readonly model?: AgentStaticModelDefinition;}-const localDescription =- "Delegate here when the developer asks to change this eve agent or its authored source. " +- "Describe the requested behavior change without guessing source paths or passing runtime skill paths under $HOME/.agents or /workspace/skills; the subagent discovers authored files under its /source mount. " +- "Treat requests for persistent changes to future behavior or capabilities as source-modification requests, even when the developer does not mention files or source code. " +- "Infer persistence from the request and conversation rather than waiting for phrases such as “modify your source.” " +- "For example, asking the agent to stop always doing something, add a capability, or change future responses calls for inspecting and editing the authored source instead of providing a one-turn workaround. " +- "Also delegate questions about which integrations, channels, connections, or capabilities are available to add: the subagent searches the eve registry and reports exact item addresses instead of guessing them. " +- "Delegate requests to investigate, diagnose, or optimize the agent's behavior from local traces to this subagent: it can inspect the invoking session's trace and make persistent source changes when warranted. " +- "Resolve short follow-ups such as “yes” or “do it” against the preceding conversation. " +- "Source edits do not affect the caller’s current turn. After this subagent reports changes, do not invoke edited tools or attempt runtime verification until a new user turn. " +- "If whether the requested change should persist is genuinely ambiguous, ask one concise clarifying question.";+function renderDescription(sections: readonly string[]): string {+ return sections.filter((section) => section.length > 0).join(" ");+}++const sourceDelegation =+ "If the requested change references a tool or skill, include the exact identifier. " ++ "Do not infer source paths; let the child resolve the appropriate file under /source. " ++ "Delegate the requested change and existing constraints without adding unrequested features, implementation steps, or reporting requirements.";-const deployedDescription =- "Delegate here when the user asks to change this eve agent or its authored source. " +- "Describe the requested behavior change without guessing source paths or passing runtime skill paths under $HOME/.agents or /workspace/skills; the subagent discovers authored files in an isolated checkout under its /source mount. " +- "Treat requests for persistent changes to future behavior or capabilities as source-modification requests, even when the user does not mention files or source code. " ++const persistenceDelegation =+ "Treat requests for persistent changes to future behavior or capabilities as source-modification requests, even when the requester does not mention files or source code. " +"Infer persistence from the request and conversation rather than waiting for phrases such as “modify your source.” " +- "For example, asking the agent to stop always doing something, add a capability, or change future responses calls for inspecting and editing the authored source instead of providing a one-turn workaround. " +- "Also delegate requests to add integrations, channels, connections, or capabilities: the subagent searches the official eve registry and can install source changes into the draft proposal. Setup may require non-secret answers or an external action, and secret binding remains separate. " ++ "For example, asking the agent to stop always doing something, add a capability, or change future responses calls for inspecting and editing the authored source instead of providing a one-turn workaround.";++const followUpDelegation ="Resolve short follow-ups such as “yes” or “do it” against the preceding conversation. " +- "Source edits do not affect the caller’s current turn. The subagent can publish only a draft pull request, and changes become effective only after review, merge, and redeployment. " +"If whether the requested change should persist is genuinely ambiguous, ask one concise clarifying question.";+const localIntegrationDelegation =+ "Delegate questions about which integrations, channels, connections, or capabilities are available to add: the subagent searches the eve registry and reports exact item addresses instead of guessing them.";++const deployedIntegrationDelegation =+ "Delegate requests to add integrations, channels, connections, or capabilities: the subagent searches the official eve registry and can install source changes into the draft proposal. Setup may require non-secret answers or an external action, and secret binding remains separate.";++const localTraceDelegation =+ "Delegate requests to investigate, diagnose, or optimize the agent's behavior from local traces to this subagent: it can inspect the invoking session's trace and make persistent source changes when warranted.";++const localEffectiveEdits =+ "Source edits do not affect the caller’s current turn. After this subagent reports changes, do not invoke edited tools or attempt runtime verification until a new user turn.";+const deployedEffectiveEdits =+ "Source edits do not affect the caller’s current turn. The subagent can publish only a draft pull request, and changes become effective only after review, merge, and redeployment.";+/** Defines the environment-aware self-modification dynamic subagent. */export function defineSelfModificationAgent(options: SelfModificationAgentOptions = {}) {const model = options.model ?? DEFAULT_SELF_MODIFICATION_MODEL;@@ -50,7 +59,16 @@ export function defineSelfModificationAgent(options: SelfModificationAgentOptionconst resolve = async (_event: unknown, ctx: DynamicResolveContext) => {const mode = resolveSelfModificationMode(config);- if (mode === "local") return defineAgent({ description: localDescription, model });+ const description = renderDescription([+ "Delegate here when the user asks to change this eve agent or its authored source.",+ sourceDelegation,+ persistenceDelegation,+ mode === "local" ? localIntegrationDelegation : deployedIntegrationDelegation,+ mode === "local" ? localTraceDelegation : "",+ followUpDelegation,+ mode === "local" ? localEffectiveEdits : deployedEffectiveEdits,+ ]);+ if (mode === "local") return defineAgent({ description, model });if (mode !== "deployed" || config.deployed === undefined) return null;if (config.deployed.credentials.kind === "pat" && !hasGitHubCredential()) return null;try {@@ -65,7 +83,7 @@ export function defineSelfModificationAgent(options: SelfModificationAgentOption} catch {return null;}- return defineAgent({ description: deployedDescription, model });+ return defineAgent({ description, model });};return defineDynamic({diff --git a/packages/eve/src/self-modification/edit-file.test.ts b/packages/eve/src/self-modification/edit-file.test.tsindex 91c742180..3c1b227a9 100644--- a/packages/eve/src/self-modification/edit-file.test.ts+++ b/packages/eve/src/self-modification/edit-file.test.ts@@ -3,6 +3,12 @@ import { describe, expect, it } from "vitest";import editFile, { applyExactEdits } from "./extension/tools/edit_file.js";describe("applyExactEdits", () => {+ it("describes exact matching and JSON-safe encoding", () => {+ const schema = JSON.stringify(editFile.inputSchema);+ expect(schema).toContain("Unique exact text from the current file");+ expect(schema).toContain("Encode control characters, quotes, and backslashes");+ });+it("replaces one exact match", () => {expect(applyExactEdits("before old after", [{ oldText: "old", newText: "new" }])).toBe("before new after",@@ -57,6 +63,28 @@ describe("applyExactEdits", () => {);});+ it("applies one multiline exact edit from JSON-encoded arguments", async () => {+ let content = "before\nold first\nold second\nafter";+ let writes = 0;+ const sandbox = {+ readTextFile: async () => content,+ resolvePath: (path: string) => path,+ writeTextFile: async (input: { readonly content: string }) => {+ writes += 1;+ content = input.content;+ },+ };+ const input = JSON.parse(+ '{"path":"/source/file.ts","edits":[{"oldText":"old first\\nold second","newText":"new first\\nnew second"}]}',+ );++ await expect(+ editFile.execute(input, { getSandbox: async () => sandbox } as never),+ ).resolves.toEqual({ path: "/source/file.ts", replacements: 1 });+ expect(content).toBe("before\nnew first\nnew second\nafter");+ expect(writes).toBe(1);+ });+it("edits the current sandbox file", async () => {let content = "before old after";const sandbox = {diff --git a/packages/eve/src/self-modification/extension/instructions.ts b/packages/eve/src/self-modification/extension/instructions.tsindex 0727abee6..3eeae301a 100644--- a/packages/eve/src/self-modification/extension/instructions.ts+++ b/packages/eve/src/self-modification/extension/instructions.ts@@ -4,55 +4,80 @@ import { resolveSelfModificationConfig } from "../config.js";import { resolveSelfModificationMode } from "../mode.js";import selfModification from "./extension.js";-const introduction = `You are an expert coding assistant operating inside of an eve agent. You help users by reading files, editing code, and writing new files that shape the behavior of the agent itself.+const role = `## Role-The source code of the eve agent is mounted read-write at /source. Use bash only for read-only discovery and available validation commands. Never modify source files with bash, sed, awk, redirection, or scripting. /source is the authored agent directory.+You are an expert coding assistant operating inside of an eve agent. You help users by reading files, editing code, and writing new files that shape the behavior of the agent itself.`;-Use selfmod__edit_file for precise changes to existing files; every edits[].oldText must match exactly. When changing multiple separate locations in one file, use one call with multiple entries in edits[]. Each oldText is matched against the original file, not after earlier edits are applied. Do not emit overlapping or nested edits; merge nearby changes into one edit. Keep oldText as small as possible while still being unique. Use write_file only for new files or complete rewrites.+const sourceWorkspace = `## Source workspace-Use selfmod__search_models to get the list of available models.`;+The source code of the eve agent is mounted read-write at /source. /source is the authored agent directory. Locate source files with bash. Read source contents with read_file, not shell commands. Before generating an overwrite, ensure read_file has succeeded for that path. Shell reads do not satisfy write_file's read-before-write requirement. selfmod__edit_file instead validates exact matches against current contents. Never modify source files with bash, sed, awk, redirection, or scripting.-const workingGuidance = `Batch independent read-only tool calls and edits to different files in one response. Do not edit the same file concurrently.+Resolve named tools by filename under /source/tools before searching contents. Tool identifiers derive from filenames and may not occur in the implementation.`;-Run selfmod__registry_add separately from file edits and other registry installations. Complete all edits and registry installations before publication, and call publish by itself.+const sourceEditing = `## Implement changes-Skip task lists for simple work - only use them for complex actions. Never spend a turn only reporting status or updating the task list - batch them with other calls.+Use selfmod__edit_file for localized changes; include only the unique matching text. For a complete rewrite, use read_file then write_file; do not encode the whole old file as one replacement. If tool arguments fail argument parsing, retry the same tool with corrected encoding.-Registry installation is outside the source sandbox.+Once paths are known, batch independent file reads and edits to different files. Never edit the same file concurrently.`;-The eve framework documentation is mounted read-only at /eve-docs. Read the eve guide directly relevant to an unfamiliar public API. Prefer an existing local implementation pattern over broad documentation research.`;+const registryWorkflow = `## Add integrations-const developmentMarkdown = `${introduction}+Before adding a new eve-managed channel, connection, extension, instrumentation, or memory integration, call selfmod__search_registry alongside source discovery. If an item fulfills the requirement, install it with selfmod__registry_add using its exact address. If no matching item fulfills the requirement, or if the developer asks for a custom implementation, write the integration yourself.-Before writing an integration by hand, check whether the eve registry already ships it with selfmod__search_registry. If it has an item that fulfills the requirement, install it with selfmod__registry_add using its address. If the registry does not have any matches that will fulfill the requirement, or if the developer asks for a custom implementation, write the integration yourself.+Modifying the behavior of an existing skill or tool does not require a registry search. Registry search blocks implementation, not source inspection. Serialize registry installation and dependent edits. Run selfmod__registry_add separately from file edits and other registry installations.-The selfmod__registry_add tool will complete installation for items that need no setup. In the local dev TUI, a \`needs-terminal\` result from the tool call automatically opens the existing setup panel for the user to complete setup there. In headless development, relay the terminal command the tool names.+Registry installation is outside the source sandbox.`;-${workingGuidance}+const documentationGuidance = `## Consult documentation-Local eve dev logs are available read-only at /logs.+The eve framework documentation is mounted read-only at /eve-docs. Prefer source and existing local patterns. Before reading docs, identify the specific unresolved API question. Search the relevant file for its heading or term, then read only the bounded surrounding section. Do not concatenate wildcard files or read a full page when a section answers the question. Stop when the question is resolved.`;++const workingGuidance = `## Work efficiently++Skip task lists for simple work - only use them for complex actions. Never spend a turn only reporting status or updating the task list - batch them with other calls.++Treat a successful file-edit tool result as confirmation; do not reread a file solely to verify that the edit succeeded. Do not approximate unavailable build or test commands with broad source searches.`;-You cannot access application files outside the authored agent directory or run host binaries such as git, node, pnpm, or tsc.+const localReportingGuidance = `## Report results-Treat a successful file-edit tool result as confirmation; do not reread a file solely to verify that the edit succeeded. Do not approximate unavailable build or test commands with broad source searches.+For source-modification tasks, return a concise handoff to the caller. Use at most four short bullets covering changed paths and behavior, and any required setup or unresolved issues.-Local trace segments are mounted read-only at /traces when available. Inspect other traces only when the user asks about another session or broader behavior.`;+For investigation tasks, report the findings and supporting evidence requested by the caller.`;++const deployedReportingGuidance = `## Report results++For source-modification tasks, return a concise handoff to the caller. Use at most four short bullets covering changed paths and behavior, and any required setup or unresolved issues. Include the draft pull request URL if one was published.++For investigation tasks, report the findings and supporting evidence requested by the caller.`;++const localGuidance = `## Local environment++The selfmod__registry_add tool will complete installation for items that need no setup. In the local dev TUI, a \`needs-terminal\` result from the tool call automatically opens the existing setup panel for the user to complete setup there. In headless development, relay the terminal command the tool names.-const developmentInstructions = defineInstructions({ markdown: developmentMarkdown });+Local eve dev logs are available read-only at /logs.+Local trace segments are mounted read-only at /traces when available. Inspect other traces only when the user asks about another session or broader behavior.-const deployedInstructions = defineInstructions({- markdown: `${introduction}+The application package.json is not mounted. Do not search outside /source for application files. You cannot run host binaries such as git, node, pnpm, or tsc. Use existing imports and selfmod__registry_add for supported registry installations.`;-Before writing an integration by hand, check whether the official eve registry already ships it with selfmod__search_registry. If it has a suitable item, call selfmod__registry_add with the exact address. The tool may return \`completed\`, \`input-required\`, \`external-action-required\`, \`cancelled\`, or \`failed\`. Supply only non-secret structured answers when continuing an \`input-required\` setup; set \`installed: true\` so the continuation does not reinstall source. Never request, accept, or repeat secret values. External authorization and secret binding are incomplete follow-up boundaries, not evidence that an integration is active.+const deployedGuidance = `## Deployed environment-${workingGuidance}+The selfmod__registry_add tool may return \`completed\`, \`input-required\`, \`external-action-required\`, \`cancelled\`, or \`failed\`. Supply only non-secret structured answers when continuing an \`input-required\` setup; set \`installed: true\` so the continuation does not reinstall source. Never request, accept, or repeat secret values. External authorization and secret binding are incomplete follow-up boundaries, not evidence that an integration is active.The configured target branch is checked out as a disposable workspace under /workspace/repository. Make ordinary changes through /source, which is the writable view of the configured application's agent/ directory. Publication validates the final repository snapshot, including registry, manifest, and lockfile changes. Never modify Git refs, access GitHub directly, or use shell commands to write files. The sandbox has no reusable GitHub credential after checkout.-Before publication, review and summarize the complete intended scope. Call publish once with a concise title and summary. A successful result is only a draft pull request. Return its URL and changed paths, and state that merge and deployment have not occurred.+Complete all edits and registry installations before publication, and call publish by itself. Before publication, review and summarize the complete intended scope. Call publish once with a concise title and summary. A successful result is only a draft pull request. Return its URL and changed paths, and state that merge and deployment have not occurred.`;-Treat a successful file-edit tool result as confirmation; do not reread a file solely to verify that the edit succeeded. Do not approximate unavailable build or test commands with broad source searches.`,-});+function readSubagentSourceGuidance(event: unknown): string {+ const invocation = (+ event as {+ readonly data?: { readonly invocation?: { readonly kind?: string; readonly name?: string } };+ }+ ).data?.invocation;+ if (invocation?.kind !== "subagent" || invocation.name === undefined) return "";++ const sourcePath = `/source/subagents/${invocation.name}`;+ return `Your authored self-modification subagent source is mounted at ${sourcePath}. For changes to this subagent itself, inspect that directory directly instead of searching /source. Its agent.ts owns agent options such as model; config.ts owns policy shared by the self-modification agent, sandbox, and extension.`;+}function readTrace(event: unknown,@@ -66,25 +91,38 @@ function readTrace().data?.trace;}+function localTraceGuidance(event: unknown): string {+ const trace = readTrace(event);+ if (trace === undefined) return "";++ return `The invoking trace has ID ${trace.traceId}. ${(trace.traceFlags & 1) === 1 ? "If local segments were captured," : "This trace was not sampled, so local segments may be absent. If any are present,"} inspect them at /traces/${trace.traceId}.`;+}++function renderInstructions(sections: readonly string[]): string {+ return sections.filter((section) => section.length > 0).join("\n\n");+}+export default defineDynamic({events: {"session.started": (event) => {const mode = resolveSelfModificationMode(resolveSelfModificationConfig(selfModification.config),);- if (mode === "deployed") return deployedInstructions;- if (mode !== "local") return null;-- const trace = readTrace(event);- if (trace === undefined) return developmentInstructions;-- const availability =- (trace.traceFlags & 1) === 1- ? "If local segments were captured,"- : "This trace was not sampled, so local segments may be absent. If any are present,";+ if (mode !== "local" && mode !== "deployed") return null;return defineInstructions({- markdown: `${developmentMarkdown}\n\nThe invoking trace has ID ${trace.traceId}. ${availability} inspect them at /traces/${trace.traceId}.`,+ markdown: renderInstructions([+ role,+ sourceWorkspace,+ readSubagentSourceGuidance(event),+ sourceEditing,+ registryWorkflow,+ documentationGuidance,+ mode === "local" ? localGuidance : deployedGuidance,+ mode === "local" ? localTraceGuidance(event) : "",+ workingGuidance,+ mode === "local" ? localReportingGuidance : deployedReportingGuidance,+ ]),});},},diff --git a/packages/eve/src/self-modification/extension/tools/edit_file.ts b/packages/eve/src/self-modification/extension/tools/edit_file.tsindex 0e46e45e6..43354a256 100644--- a/packages/eve/src/self-modification/extension/tools/edit_file.ts+++ b/packages/eve/src/self-modification/extension/tools/edit_file.ts@@ -8,11 +8,12 @@ const replacementSchema = {type: "string",minLength: 1,description:- "Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.",+ "Unique exact text from the current file. Encode control characters, quotes, and backslashes as JSON escapes.",},newText: {type: "string",- description: "Replacement text for this targeted edit.",+ description:+ "Exact replacement text. Encode control characters, quotes, and backslashes as JSON escapes.",},},required: ["oldText", "newText"],diff --git a/packages/eve/src/self-modification/extension/tools/search_registry.ts b/packages/eve/src/self-modification/extension/tools/search_registry.tsindex b0eb4b2ff..b302b019e 100644--- a/packages/eve/src/self-modification/extension/tools/search_registry.ts+++ b/packages/eve/src/self-modification/extension/tools/search_registry.ts@@ -1,7 +1,7 @@import { defineTool, type ToolContext } from "eve/tools";/** Registry categories an integration search can be narrowed to. */-const CATEGORIES = ["channel", "connection", "extension", "instrumentation"] as const;+const CATEGORIES = ["channel", "connection", "extension", "instrumentation", "memory"] as const;type Category = (typeof CATEGORIES)[number];@@ -501,7 +501,7 @@ async function annotateInstalled(input: {export default defineTool({description:- "Search the eve registry for integrations this project can add: channels, MCP connections, extensions, and observability. Read-only — it installs nothing. Call it before writing an integration by hand, then pass an exact item address (for example `channel/slack`) to selfmod__registry_add.",+ "Search the eve registry for integrations this project can add: channels, MCP connections, extensions, memory providers, and observability. Read-only — it installs nothing. Call it before writing an integration by hand, then pass an exact item address (for example `channel/slack`) to selfmod__registry_add.",inputSchema,outputSchema,async execute(input, ctx) {diff --git a/packages/eve/src/self-modification/instructions.test.ts b/packages/eve/src/self-modification/instructions.test.tsdeleted file mode 100644index 2466eaf7f..000000000--- a/packages/eve/src/self-modification/instructions.test.ts+++ /dev/null@@ -1,54 +0,0 @@-import { afterEach, describe, expect, it } from "vitest";--import instructions from "./extension/instructions.js";--const originalEveDev = process.env.EVE_DEV;--afterEach(() => {- if (originalEveDev === undefined) {- delete process.env.EVE_DEV;- } else {- process.env.EVE_DEV = originalEveDev;- }-});--describe("self-modification instructions", () => {- const ctx = {- channel: {},- messages: [],- session: { auth: { current: null, initiator: null }, id: "selfmod" },- };-- it("points at the trace that invoked selfmod", () => {- process.env.EVE_DEV = "1";- const traceId = "a".repeat(32);- const definition = instructions.events["session.started"]?.(- {- data: { trace: { spanId: "b".repeat(16), traceFlags: 1, traceId } },- type: "session.started",- },- ctx,- );-- expect(definition).toMatchObject({- markdown: expect.stringContaining(`invoking trace has ID ${traceId}`),- });- expect(definition).toMatchObject({ markdown: expect.stringContaining(`/traces/${traceId}`) });- });-- it("does not claim that trace coordinates guarantee local segments", () => {- process.env.EVE_DEV = "1";- const traceId = "a".repeat(32);- const definition = instructions.events["session.started"]?.(- {- data: { trace: { spanId: "b".repeat(16), traceFlags: 0, traceId } },- type: "session.started",- },- ctx,- );-- expect(definition).toMatchObject({- markdown: expect.stringContaining("not sampled, so local segments may be absent"),- });- });-});diff --git a/packages/eve/src/self-modification/search-registry.test.ts b/packages/eve/src/self-modification/search-registry.test.tsindex 63bac50f7..78ce784bd 100644--- a/packages/eve/src/self-modification/search-registry.test.ts+++ b/packages/eve/src/self-modification/search-registry.test.ts@@ -90,6 +90,16 @@ describe("parseRegistryIndex", () => {expect(bundle?.components).toEqual(["channel/linear-agent", "connection/linear"]);});+ it("recognizes memory registry items", () => {+ expect(parseRegistryIndex({ items: [{ name: "memory/file", title: "File memory" }] })).toEqual([+ {+ address: "memory/file",+ category: "memory",+ title: "File memory",+ },+ ]);+ });+it("labels an item that publishes no title", () => {const entry = catalog().find((row) => row.address === "instrumentation/langfuse-tracing");@@ -177,6 +187,20 @@ describe("selectIntegrations", () => {).toEqual(["channel/slack", "channel/discord", "linear"]);});+ it("filters memory integrations", () => {+ const entries = parseRegistryIndex({+ items: [+ { name: "memory/file", title: "File memory" },+ { name: "extension/browser", title: "Browser" },+ ],+ });++ expect(selectIntegrations({ category: "memory", entries })).toEqual([+ { address: "memory/file", category: "memory", title: "File memory" },+ ]);+ expect(JSON.stringify(searchRegistry.inputSchema)).toContain('"memory"');+ });+it("bounds the result count", () => {expect(selectIntegrations({ entries: catalog(), limit: 2 })).toHaveLength(2);expect(selectIntegrations({ entries: catalog(), limit: 500 })).toHaveLength(5);diff --git a/packages/eve/src/setup/integrations/self-modification/setup.test.ts b/packages/eve/src/setup/integrations/self-modification/setup.test.tsindex 2ff7fac6d..f70be0d9f 100644--- a/packages/eve/src/setup/integrations/self-modification/setup.test.ts+++ b/packages/eve/src/setup/integrations/self-modification/setup.test.ts@@ -60,7 +60,7 @@ describe("self-modification integration setup", () => {const plan = await prepareLocalSelfModificationSetup(ctx.prepare, effects);await expect(applySelfModificationSetup(plan, ctx.apply, effects)).resolves.toEqual({- facts: [{ label: "Self-modification", value: "local editing" }],+ facts: [],});expect(effects.findOrCreateConnector).not.toHaveBeenCalled();expect(effects.writeConfig).not.toHaveBeenCalled();diff --git a/packages/eve/src/setup/integrations/self-modification/setup.ts b/packages/eve/src/setup/integrations/self-modification/setup.tsindex 133a8e7d2..a7ef27299 100644--- a/packages/eve/src/setup/integrations/self-modification/setup.ts+++ b/packages/eve/src/setup/integrations/self-modification/setup.ts@@ -131,7 +131,7 @@ export async function applySelfModificationSetup(};}if (plan.kind === "local") {- return { facts: [{ label: "Self-modification", value: "local editing" }] };+ return { facts: [] };}const connector = await operations.findOrCreateConnector(plan.connectorName);