Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(eve): split self-modification into local and remote mounts (#4251)

prha9de88f7012db
diff --git a/.changeset/self-modification-mount-split.md b/.changeset/self-modification-mount-split.md
new file mode 100644
index 000000000..71def4661
--- /dev/null
+++ b/.changeset/self-modification-mount-split.md
@@ -0,0 +1,5 @@
+---
+"eve": minor
+---
+
+Split self-modification into separate `eve/self-modification/local` and `eve/self-modification/remote` mounts, so `eve dev` no longer loads deployed sandbox dependencies. `eve/self-modification` remains an alias for the local mount and now rejects the `deployed` option; move that configuration to its own mount, for example `agent/extensions/self-modification-remote/extension.ts`, with the former `deployed` fields at the top level.
diff --git a/docs/guides/self-modification.md b/docs/guides/self-modification.md
index 310897b6c..0d413f324 100644
--- a/docs/guides/self-modification.md
+++ b/docs/guides/self-modification.md
@@ -1,11 +1,11 @@
---
title: "Self-Modification"
-description: "Ask your agent to update its own instructions, tools, skills, and other authored files during local development."
+description: "Ask your agent to update its own authored files during local development, or let a deployed agent propose changes as draft pull requests."
---
When `eve dev` starts a local server, it mounts the bundled self-modification extension by default. Ask your agent to change its instructions, tools, skills, or other files under `agent/`; eve delegates the source work to the `self-modification__agent` subagent. Connecting to an existing server with `eve remote connect --url <url>` does not add the bundled extension to that server.
-The bundled extension is for local development and is not included in production builds.
+The bundled extension is `eve/self-modification/local`. It is for local development and is not included in production builds. To let a deployed agent propose source changes, mount the separate [`eve/self-modification/remote`](#propose-changes-from-a-deployed-agent) extension.
```bash
eve dev
@@ -27,7 +27,54 @@ The subagent uses your agent's model by default. To give it a different model or
Switch the self-modification subagent to openai/gpt-6-sol with low reasoning.
```
-The first time, this creates `agent/extensions/self-modification/extension.ts` with those settings. After that file exists, later changes edit it. You can also edit the file yourself: it accepts `model` and `reasoning` options.
+The first time, this creates `agent/extensions/self-modification/extension.ts` with those settings. After that file exists, later changes edit it. You can also edit the file yourself: it accepts `model`, `reasoning`, and `local.enabled` options.
+
+```ts
+// agent/extensions/self-modification/extension.ts
+import selfModification from "eve/self-modification/local";
+
+export default selfModification({
+ model: "openai/gpt-6-sol",
+ reasoning: "low",
+});
+```
+
+Mounts that import `eve/self-modification` still work; that specifier is an alias for `eve/self-modification/local`. Neither specifier accepts a `deployed` option. If your mount sets `deployed`, eve rejects it and asks you to move that configuration to an `eve/self-modification/remote` mount.
+
+## Propose changes from a deployed agent
+
+`eve/self-modification/remote` is a separate extension for deployed agents. It adds a subagent that checks out your repository in a sandbox, edits the authored source, and opens a draft pull request against a target branch. It never changes the running deployment. Changes take effect only after you review, merge, and redeploy.
+
+Mount it under its own namespace so it does not replace the local extension:
+
+```ts
+// agent/extensions/self-modification-remote/extension.ts
+import selfModification from "eve/self-modification/remote";
+
+export default selfModification({
+ source: {
+ git: {
+ repository: "github.com/acme/agents",
+ directory: "apps/support",
+ },
+ },
+ target: { branch: "main" },
+ credentials: { pat: true },
+ authorize: ({ channel, principal }) =>
+ channel.kind === "http" && principal?.principalId === "release-bot",
+});
+```
+
+| Option | Description |
+| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `source.git.repository` | GitHub repository in `github.com/owner/repo` form. |
+| `source.git.directory` | Application directory relative to the repository root. Use `"."` for the root. |
+| `target.branch` | Branch that is checked out and targeted by draft pull requests. |
+| `authorize` | Required. Receives the requesting `channel` and `principal` and returns whether that caller can use the subagent. The subagent is hidden when it returns `false` or throws. |
+| `credentials` | Required. An object with a `resolve({ capability, repository })` function that returns a GitHub token, or `{ pat: true }` to read `EVE_SELF_MODIFICATION_GITHUB_TOKEN` from the deployment environment. |
+| `model`, `reasoning` | Optional model and reasoning level for the deployed subagent. It defaults to the parent agent's model. |
+
+The deployed subagent is never offered during `eve dev`. In a deployment, it needs a sandbox provider that supports runtime credential transforms: Vercel Sandbox on Vercel, or microsandbox on a supported self-hosted system. eve applies the GitHub token as a sandbox network credential only while it checks out or publishes, so commands in the sandbox cannot read it.
## Run without self-modification
diff --git a/packages/eve/package.json b/packages/eve/package.json
index 713a6897a..d86fa4133 100644
--- a/packages/eve/package.json
+++ b/packages/eve/package.json
@@ -333,6 +333,18 @@
"import": "./dist/src/self-modification/extension/extension.js",
"default": "./dist/src/self-modification/extension/extension.js"
},
+ "./self-modification/local": {
+ "eve-source": "./dist/src/self-modification/extension/extension.js",
+ "types": "./dist/src/self-modification/extension/extension.d.ts",
+ "import": "./dist/src/self-modification/extension/extension.js",
+ "default": "./dist/src/self-modification/extension/extension.js"
+ },
+ "./self-modification/remote": {
+ "eve-source": "./dist/src/self-modification/remote/extension.js",
+ "types": "./dist/src/self-modification/remote/extension.d.ts",
+ "import": "./dist/src/self-modification/remote/extension.js",
+ "default": "./dist/src/self-modification/remote/extension.js"
+ },
"./self-modification/agent": {
"eve-source": "./dist/src/self-modification/agent.js",
"types": "./dist/src/self-modification/agent.d.ts",
@@ -642,6 +654,12 @@
"./self-modification": {
"dist": "./dist/src/self-modification/extension"
},
+ "./self-modification/local": {
+ "dist": "./dist/src/self-modification/extension"
+ },
+ "./self-modification/remote": {
+ "dist": "./dist/src/self-modification/remote"
+ },
"./extensions/code": {
"dist": "./dist/src/extensions/code/extension"
},
diff --git a/packages/eve/src/compiler/development-extensions.integration.test.ts b/packages/eve/src/compiler/development-extensions.integration.test.ts
index 2ad3078d6..41faf42c8 100644
--- a/packages/eve/src/compiler/development-extensions.integration.test.ts
+++ b/packages/eve/src/compiler/development-extensions.integration.test.ts
@@ -47,9 +47,8 @@ describe("development extensions", () => {
expect(subagent.agent.tools.map((tool) => tool.name)).toEqual(
expect.arrayContaining(["edit_file", "search_models", "search_registry"]),
);
- expect(subagent.agent.dynamicTools.map((tool) => tool.slug)).toEqual(
- expect.arrayContaining(["publish", "registry_add"]),
- );
+ expect(subagent.agent.dynamicTools.map((tool) => tool.slug)).toContain("registry_add");
+ expect(subagent.agent.dynamicTools.map((tool) => tool.slug)).not.toContain("publish");
expect(subagent.agent.dynamicInstructions).toHaveLength(1);
const moduleMap = await createProgrammaticCompiledModuleMap(compiled, [
@@ -61,7 +60,9 @@ describe("development extensions", () => {
manifest: compiled,
moduleMapPath: "/virtual/source-test/.eve/compile/module-map.mjs",
});
- expect(generated).toContain("eve/self-modification?eve-mount=extensions%2Fself-modification");
+ expect(generated).toContain(
+ "eve/self-modification/local?eve-mount=extensions%2Fself-modification",
+ );
});
it("does not replace an authored self-modification mount", async () => {
diff --git a/packages/eve/src/compiler/development-extensions.ts b/packages/eve/src/compiler/development-extensions.ts
index a943fa67f..eb02c7cac 100644
--- a/packages/eve/src/compiler/development-extensions.ts
+++ b/packages/eve/src/compiler/development-extensions.ts
@@ -41,7 +41,7 @@ function getBundledExtensionById(): ReadonlyMap<string, BundledExtensionMount> {
[
{
namespace: "self-modification",
- importSpecifier: "eve/self-modification",
+ importSpecifier: "eve/self-modification/local",
entryPath: resolvePackageSourceFilePath("src/self-modification/extension/extension.ts"),
config: SELF_MODIFICATION_CONFIG,
sourceDirectory: resolvePackageSourceDirectoryPath("src/self-modification/extension"),
diff --git a/packages/eve/src/internal/authored-package-boundary.test.ts b/packages/eve/src/internal/authored-package-boundary.test.ts
index 068ed91a6..87a645665 100644
--- a/packages/eve/src/internal/authored-package-boundary.test.ts
+++ b/packages/eve/src/internal/authored-package-boundary.test.ts
@@ -36,16 +36,17 @@ describe("createGenerationPackageBoundaryPlugin", () => {
kind: "import-statement",
}),
).resolves.toEqual({ external: true, id: "eve/tools" });
- await expect(
- resolveId.call(
- context,
- "eve/self-modification",
- join(PACKAGE_ROOT, "agent/extensions/edit.ts"),
- {
+ for (const specifier of [
+ "eve/self-modification",
+ "eve/self-modification/local",
+ "eve/self-modification/remote",
+ ]) {
+ await expect(
+ resolveId.call(context, specifier, join(PACKAGE_ROOT, "agent/extensions/edit.ts"), {
kind: "import-statement",
- },
- ),
- ).resolves.toBeUndefined();
+ }),
+ ).resolves.toBeUndefined();
+ }
});
it("resolves package-private imports from the importing dependency", async () => {
diff --git a/packages/eve/src/internal/authored-package-boundary.ts b/packages/eve/src/internal/authored-package-boundary.ts
index 9036ef45d..da819ffd9 100644
--- a/packages/eve/src/internal/authored-package-boundary.ts
+++ b/packages/eve/src/internal/authored-package-boundary.ts
@@ -409,9 +409,15 @@ export function isPathImport(source: string): boolean {
return source.startsWith(".") || source.startsWith("/") || /^[A-Za-z]:[\\/]/.test(source);
}
+const SELF_MODIFICATION_MOUNT_SPECIFIERS = new Set([
+ "eve/self-modification",
+ "eve/self-modification/local",
+ "eve/self-modification/remote",
+]);
+
function isFrameworkRuntimeImport(source: string, importer: string | undefined): boolean {
- // The packaged extension is authored code: its mount and child must share a scoped handle.
- if (source === "eve/self-modification") return false;
+ // Packaged extension mounts are authored code: each mount and its child must share a scoped handle.
+ if (SELF_MODIFICATION_MOUNT_SPECIFIERS.has(source)) return false;
if (source === "eve" || source.startsWith("eve/")) {
return true;
}
diff --git a/packages/eve/src/self-modification/config.test.ts b/packages/eve/src/self-modification/config.test.ts
index b4376c4fe..8bf4c4937 100644
--- a/packages/eve/src/self-modification/config.test.ts
+++ b/packages/eve/src/self-modification/config.test.ts
@@ -1,180 +1,41 @@
import { afterEach, describe, expect, it } from "vitest";
-import { resolveSelfModificationConfig } from "./config.js";
-import { createGitHubCredentialProvider } from "./credentials.js";
-import { resolveSelfModificationMode } from "./mode.js";
+import { DEPLOYED_OPTION_MOVED_MESSAGE, resolveSelfModificationConfig } from "./config.js";
+import { isDeployedRuntime, isLocalSelfModificationEnabled } from "./mode.js";
afterEach(() => {
delete process.env.EVE_DEV;
- delete process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN;
});
-const deployed = {
- deployed: {
- source: { git: { directory: "apps/weather", repository: "github.com/vercel/eve" } },
- target: { branch: "main" },
- authorize: () => true,
- credentials: { pat: true },
- },
-} as const;
-
-describe("self-modification deployed configuration", () => {
- it("resolves a repository-root application", () => {
- expect(
- resolveSelfModificationConfig({
- deployed: {
- ...deployed.deployed,
- source: { git: { ...deployed.deployed.source.git, directory: "." } },
- },
- }),
- ).toMatchObject({
- deployed: {
- directory: ".",
- repository: { owner: "vercel", repo: "eve" },
- targetBranch: "main",
- },
- });
- });
-
- it("requires opting into the self-hosted PAT exception", () => {
- expect(resolveSelfModificationConfig(deployed)).toMatchObject({
- localEnabled: true,
- deployed: { credentials: { kind: "pat" } },
- });
- expect(() =>
- resolveSelfModificationConfig({
- deployed: { ...deployed.deployed, credentials: undefined },
- }),
- ).toThrow("must explicitly configure");
- });
-
- it("resolves an application-supplied credential provider", () => {
- const provider = { resolve: async () => "github-token" };
- const config = resolveSelfModificationConfig({
- deployed: {
- ...deployed.deployed,
- credentials: provider,
- },
+describe("local self-modification configuration", () => {
+ it("enables local editing by default", () => {
+ expect(resolveSelfModificationConfig()).toEqual({ localEnabled: true });
+ expect(resolveSelfModificationConfig({ local: { enabled: false } })).toEqual({
+ localEnabled: false,
});
-
- expect(config.deployed?.credentials).toEqual({ kind: "provider", provider });
- expect(resolveSelfModificationMode(config)).toBe("deployed");
- });
-
- it.each(["", "/agent", "agent/../other", "agent//other", "agent\\other"])(
- "rejects unsafe application directories: %s",
- (directory) => {
- expect(() =>
- resolveSelfModificationConfig({
- deployed: {
- ...deployed.deployed,
- source: { git: { ...deployed.deployed.source.git, directory } },
- },
- }),
- ).toThrow("safe repository-relative");
- },
- );
-
- it("requires complete deployed configuration", () => {
- expect(() =>
- resolveSelfModificationConfig({ deployed: { source: deployed.deployed.source } } as never),
- ).toThrow("source, target, and authorization");
- });
-
- it("requires a deployed authorization policy", () => {
- expect(() => {
- const { authorize: _authorize, ...withoutAuthorize } = deployed.deployed;
- resolveSelfModificationConfig({ deployed: withoutAuthorize } as never);
- }).toThrow("source, target, and authorization");
- expect(() =>
- resolveSelfModificationConfig({
- deployed: { ...deployed.deployed, authorize: true as never },
- }),
- ).toThrow("authorize must be a function");
- });
-
- it("rejects ambiguous or malformed credential configuration", () => {
- expect(() =>
- resolveSelfModificationConfig({
- deployed: {
- ...deployed.deployed,
- credentials: { pat: true, resolve: async () => "token" },
- },
- }),
- ).toThrow("not both");
- expect(() =>
- resolveSelfModificationConfig({
- deployed: { ...deployed.deployed, credentials: { pat: false } as never },
- }),
- ).toThrow("pat must be true");
- expect(() =>
- resolveSelfModificationConfig({
- deployed: { ...deployed.deployed, credentials: { resolve: true } as never },
- }),
- ).toThrow("resolve function");
});
it.each([
[null, "configuration must be an object"],
[{ local: null }, "local must be an object"],
- [
- {
- deployed: {
- authorize: deployed.deployed.authorize,
- source: null,
- target: deployed.deployed.target,
- },
- },
- "deployed.source must be an object",
- ],
- [
- {
- deployed: {
- authorize: deployed.deployed.authorize,
- source: {},
- target: deployed.deployed.target,
- },
- },
- "deployed.source.git must be an object",
- ],
- [
- {
- deployed: {
- authorize: deployed.deployed.authorize,
- source: deployed.deployed.source,
- target: null,
- },
- },
- "deployed.target must be an object",
- ],
- ])("rejects malformed nested configuration", (config, message) => {
+ [{ local: { enabled: "yes" } }, "local.enabled must be a boolean"],
+ ])("rejects malformed configuration", (config, message) => {
expect(() => resolveSelfModificationConfig(config as never)).toThrow(message);
});
- it("rejects a fully qualified target ref", () => {
- expect(() =>
- resolveSelfModificationConfig({
- deployed: { ...deployed.deployed, target: { branch: "refs/heads/main" } },
- }),
- ).toThrow("must be a branch name");
+ it("points the former deployed option at the deployed mount", () => {
+ expect(() => resolveSelfModificationConfig({ deployed: {} } as never)).toThrow(
+ DEPLOYED_OPTION_MOVED_MESSAGE,
+ );
});
- it("activates deployed while keeping local editing local", () => {
- const config = resolveSelfModificationConfig(deployed);
- expect(resolveSelfModificationMode(config)).toBe("deployed");
+ it("enables local editing only inside eve dev", () => {
+ const config = resolveSelfModificationConfig();
+ expect(isLocalSelfModificationEnabled(config)).toBe(false);
+ expect(isDeployedRuntime()).toBe(true);
process.env.EVE_DEV = "1";
- expect(resolveSelfModificationMode(config)).toBe("local");
- });
-
- it("resolves the GitHub token for each capability", async () => {
- process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN = " secret-token ";
- const { credentials, repository } = resolveSelfModificationConfig(deployed).deployed!;
- const provider = createGitHubCredentialProvider(credentials);
- await expect(provider.resolve({ capability: "checkout", repository })).resolves.toBe(
- "secret-token",
- );
- await expect(provider.resolve({ capability: "publish", repository })).resolves.toBe(
- "secret-token",
- );
+ expect(isLocalSelfModificationEnabled(config)).toBe(true);
+ expect(isLocalSelfModificationEnabled({ localEnabled: false })).toBe(false);
+ expect(isDeployedRuntime()).toBe(false);
});
});
diff --git a/packages/eve/src/self-modification/config.ts b/packages/eve/src/self-modification/config.ts
index f5336676e..763bacb3c 100644
--- a/packages/eve/src/self-modification/config.ts
+++ b/packages/eve/src/self-modification/config.ts
@@ -1,67 +1,14 @@
-import type { SessionAuthContext } from "#channel/types.js";
import type { AgentReasoningDefinition, AgentStaticModelDefinition } from "#public/index.js";
-import { assertGitRef, assertRepositoryPart } from "./identifiers.js";
-
-/** Principal and channel that requested a deployed source modification. */
-export interface SelfModificationAuthorizationContext {
- readonly channel: {
- /** Channel adapter family, such as `"slack"` or `"http"`. */
- readonly kind?: string;
- readonly metadata?: Readonly<Record<string, unknown>>;
- };
- readonly principal: SessionAuthContext | null;
-}
-
-/** Decides whether a principal may use deployed self-modification. */
-export type SelfModificationAuthorization = (
- context: SelfModificationAuthorizationContext,
-) => boolean | Promise<boolean>;
-
-export interface GitHubRepository {
- readonly owner: string;
- readonly repo: string;
-}
-
-export type GitHubCredentialCapability = "checkout" | "publish";
-
-export interface GitHubCredentialRequest {
- readonly capability: GitHubCredentialCapability;
- readonly repository: GitHubRepository;
-}
-
-/** Application-supplied GitHub credentials for deployed self-modification. */
-export interface GitHubCredentialProvider {
- resolve(request: GitHubCredentialRequest): Promise<string>;
-}
+export const DEPLOYED_OPTION_MOVED_MESSAGE =
+ "The `deployed` option moved to the separate `eve/self-modification/remote` mount. Remove it from this local self-modification mount and mount `eve/self-modification/remote` instead.";
+/** Local self-modification settings shared by its bundled child and sandbox. */
export interface SelfModificationConfig {
readonly local?: { readonly enabled?: boolean };
- readonly deployed?: {
- readonly source: {
- readonly git: {
- /** GitHub repository in github.com/owner/repository form. */
- readonly repository: string;
- /** Application directory relative to the repository root. */
- readonly directory: string;
- };
- };
- readonly target: { readonly branch: string };
- /** Fail-closed policy for principals that may create draft proposals. */
- readonly authorize: SelfModificationAuthorization;
- readonly credentials?:
- | GitHubCredentialProvider
- | {
- /**
- * Self-hosted exception. Reads `EVE_SELF_MODIFICATION_GITHUB_TOKEN` from
- * the trusted deployment environment; never injects it into the sandbox.
- */
- readonly pat: true;
- };
- };
}
-/** Values accepted by the self-modification extension mount. */
+/** Values accepted by the local self-modification extension mount. */
export interface SelfModificationExtensionConfig extends SelfModificationConfig {
readonly model?: AgentStaticModelDefinition;
readonly reasoning?: AgentReasoningDefinition;
@@ -69,22 +16,9 @@ export interface SelfModificationExtensionConfig extends SelfModificationConfig
export interface ResolvedSelfModificationConfig {
readonly localEnabled: boolean;
- readonly deployed?: ResolvedDeployedSelfModificationConfig;
}
-export interface ResolvedDeployedSelfModificationConfig {
- readonly authorize: SelfModificationAuthorization;
- readonly credentials: ResolvedGitHubCredentials;
- readonly directory: string;
- readonly repository: GitHubRepository;
- readonly targetBranch: string;
-}
-
-export type ResolvedGitHubCredentials =
- | { readonly kind: "pat" }
- | { readonly kind: "provider"; readonly provider: GitHubCredentialProvider };
-
-/** Defines the policy shared by the self-modification agent, sandbox, and extension. */
+/** Defines the local self-modification policy. */
export function defineSelfModificationConfig(
config: SelfModificationConfig = {},
): SelfModificationConfig {
@@ -96,6 +30,7 @@ export function resolveSelfModificationConfig(
config: SelfModificationConfig = {},
): ResolvedSelfModificationConfig {
if (!isRecord(config)) throw new Error("Self-modification configuration must be an object.");
+ if ("deployed" in config) throw new Error(DEPLOYED_OPTION_MOVED_MESSAGE);
const local = config.local;
if (local !== undefined && !isRecord(local)) {
@@ -105,112 +40,7 @@ export function resolveSelfModificationConfig(
if (typeof localEnabled !== "boolean") {
throw new Error("Self-modification local.enabled must be a boolean.");
}
-
- const deployed = config.deployed;
- if (deployed === undefined) return { localEnabled };
- if (!isRecord(deployed)) throw new Error("Self-modification deployed must be an object.");
- const { source, target, authorize, credentials } = deployed;
- if (source === undefined || target === undefined || authorize === undefined) {
- throw new Error(
- "Self-modification deployed requires source, target, and authorization configuration.",
- );
- }
- if (!isRecord(source)) throw new Error("Self-modification deployed.source must be an object.");
- if (!isRecord(source.git)) {
- throw new Error("Self-modification deployed.source.git must be an object.");
- }
- if (!isRecord(target)) throw new Error("Self-modification deployed.target must be an object.");
- if (typeof authorize !== "function") {
- throw new Error("Self-modification deployed.authorize must be a function.");
- }
-
- const { git } = source;
- if (typeof git.repository !== "string" || typeof git.directory !== "string") {
- throw new Error(
- "Self-modification deployed.source.git.repository and deployed.source.git.directory must be strings.",
- );
- }
- if (typeof target.branch !== "string") {
- throw new Error("Self-modification deployed.target.branch must be a string.");
- }
- return {
- deployed: {
- authorize: authorize as SelfModificationAuthorization,
- credentials: parseCredentials(credentials),
- directory: parseDirectory(git.directory),
- repository: parseGitHubRepository(git.repository),
- targetBranch: parseBranch(target.branch),
- },
- localEnabled,
- };
-}
-
-function parseCredentials(value: unknown): ResolvedGitHubCredentials {
- if (!isRecord(value)) {
- throw new Error(
- "Self-modification deployed.credentials must explicitly configure a credential provider or the self-hosted PAT exception.",
- );
- }
- const hasProvider = value.resolve !== undefined;
- const hasPat = value.pat !== undefined;
- if (hasProvider && hasPat) {
- throw new Error(
- "Self-modification deployed.credentials must configure either a credential provider or pat, not both.",
- );
- }
- if (hasPat) {
- if (value.pat !== true) {
- throw new Error("Self-modification deployed.credentials.pat must be true.");
- }
- return { kind: "pat" };
- }
- if (!isGitHubCredentialProvider(value)) {
- throw new Error(
- "Self-modification deployed.credentials must be an object with a resolve function.",
- );
- }
- return { kind: "provider", provider: value };
-}
-
-function isGitHubCredentialProvider(value: unknown): value is GitHubCredentialProvider {
- return isRecord(value) && typeof value.resolve === "function";
-}
-
-function parseGitHubRepository(repository: string): GitHubRepository {
- const match = /^github\.com\/([^/]+)\/([^/]+)$/u.exec(repository);
- if (match?.[1] === undefined || match[2] === undefined) {
- throw new Error(
- "Self-modification deployed.source.git.repository must use github.com/owner/repo form.",
- );
- }
- assertRepositoryPart(match[1], "repository owner");
- assertRepositoryPart(match[2], "repository name");
- return { owner: match[1], repo: match[2] };
-}
-
-function parseDirectory(directory: string): string {
- if (
- directory !== "." &&
- (directory.length === 0 ||
- directory.startsWith("/") ||
- directory.includes("\\") ||
- directory.split("/").some((part) => part === "" || part === "." || part === ".."))
- ) {
- throw new Error(
- "Self-modification deployed.source.git.directory must be a safe repository-relative path.",
- );
- }
- return directory;
-}
-
-function parseBranch(branch: string): string {
- assertGitRef(branch, "target branch");
- if (branch.startsWith("refs/")) {
- throw new Error(
- "Self-modification deployed.target.branch must be a branch name, not a full Git ref.",
- );
- }
- return branch;
+ return { localEnabled };
}
function isRecord(value: unknown): value is Record<string, unknown> {
diff --git a/packages/eve/src/self-modification/credentials.ts b/packages/eve/src/self-modification/credentials.ts
index db6cc4817..d8ba8d031 100644
--- a/packages/eve/src/self-modification/credentials.ts
+++ b/packages/eve/src/self-modification/credentials.ts
@@ -1,4 +1,4 @@
-import type { GitHubCredentialProvider, ResolvedGitHubCredentials } from "./config.js";
+import type { GitHubCredentialProvider, ResolvedGitHubCredentials } from "./remote/config.js";
export const SELF_MODIFICATION_GITHUB_TOKEN_ENV = "EVE_SELF_MODIFICATION_GITHUB_TOKEN";
diff --git a/packages/eve/src/self-modification/sandbox.test.ts b/packages/eve/src/self-modification/deployed-sandbox.test.ts
similarity index 54%
rename from packages/eve/src/self-modification/sandbox.test.ts
rename to packages/eve/src/self-modification/deployed-sandbox.test.ts
index ebf9f8aa7..c36b6d798 100644
--- a/packages/eve/src/self-modification/sandbox.test.ts
+++ b/packages/eve/src/self-modification/deployed-sandbox.test.ts
@@ -1,23 +1,21 @@
import { afterEach, describe, expect, it, vi } from "vitest";
-import type { SelfModificationConfig } from "./config.js";
+import type { DeployedSelfModificationConfig } from "./remote/config.js";
import {
- defineSelfModificationSandbox,
+ defineDeployedSelfModificationSandbox,
selectDeployedSelfModificationEnvironment,
-} from "./sandbox.js";
+} from "./deployed-sandbox.js";
-const connectConfig: SelfModificationConfig = {
- deployed: {
- authorize: () => true,
- credentials: { pat: true },
- source: { git: { directory: ".", repository: "github.com/acme/agent" } },
- target: { branch: "main" },
- },
+const connectConfig: DeployedSelfModificationConfig = {
+ authorize: () => true,
+ credentials: { pat: true },
+ source: { git: { directory: ".", repository: "github.com/acme/agent" } },
+ target: { branch: "main" },
};
afterEach(() => vi.unstubAllEnvs());
-describe("self-modification sandbox", () => {
+describe("deployed self-modification sandbox", () => {
it("selects Vercel Sandbox on Vercel", () => {
expect(
selectDeployedSelfModificationEnvironment({
@@ -45,8 +43,11 @@ describe("self-modification sandbox", () => {
).toThrow("No supported provider is available");
});
- it("returns a callback definition", () => {
- vi.stubEnv("VERCEL", "1");
- expect(defineSelfModificationSandbox({ config: connectConfig })).toBeTypeOf("function");
+ it("does not probe deployed providers during eve dev", () => {
+ vi.stubEnv("EVE_DEV", "1");
+ const probes = { isDeployedOnVercel: vi.fn(), isMicrosandboxSupported: vi.fn() };
+ expect(defineDeployedSelfModificationSandbox(connectConfig, probes)).toBeTypeOf("function");
+ expect(probes.isDeployedOnVercel).not.toHaveBeenCalled();
+ expect(probes.isMicrosandboxSupported).not.toHaveBeenCalled();
});
});
diff --git a/packages/eve/src/self-modification/deployed-sandbox.ts b/packages/eve/src/self-modification/deployed-sandbox.ts
new file mode 100644
index 000000000..a3bb86d03
--- /dev/null
+++ b/packages/eve/src/self-modification/deployed-sandbox.ts
@@ -0,0 +1,88 @@
+import { defineSandbox } from "#public/definitions/sandbox.js";
+import { JustBashSandbox } from "#sandbox/providers/just-bash.js";
+import { MicrosandboxSandbox } from "#sandbox/providers/microsandbox.js";
+import { SANDBOX_PROVIDER_PROBES, type DefaultSandboxProbes } from "#sandbox/providers/default.js";
+import { VercelSandbox } from "#sandbox/providers/vercel.js";
+import { bindSandboxEnvironment, type SandboxSelector } from "#shared/sandbox-environment.js";
+import { shellQuote } from "#shared/shell-quote.js";
+
+import { createGitHubCredentialProvider } from "./credentials.js";
+import { prepareSelfModificationWorkspace, REPOSITORY_PATH } from "./git-workspace.js";
+import { isDeployedRuntime } from "./mode.js";
+import { SELF_MODIFICATION_BASELINE_NETWORK_POLICY } from "./network-policy.js";
+import {
+ resolveDeployedSelfModificationConfig,
+ type DeployedSelfModificationConfig,
+} from "./remote/config.js";
+
+type Probes = Pick<DefaultSandboxProbes, "isDeployedOnVercel" | "isMicrosandboxSupported">;
+type DeployedSelfModificationEnvironment =
+ | ReturnType<typeof MicrosandboxSandbox.environment>
+ | ReturnType<typeof VercelSandbox.environment>;
+
+/**
+ * Defines the deployed child's sandbox. During `eve dev` the deployed child is never
+ * offered, so its sandbox binds an inert environment instead of probing providers.
+ */
+export function defineDeployedSelfModificationSandbox(
+ config: DeployedSelfModificationConfig,
+ probes: Probes = SANDBOX_PROVIDER_PROBES,
+): SandboxSelector {
+ if (!isDeployedRuntime()) {
+ const environment = JustBashSandbox.environment();
+ return bindSandboxEnvironment(
+ defineSandbox(() => environment.open()),
+ environment,
+ );
+ }
+
+ const deployed = resolveDeployedSelfModificationConfig(config);
+ const environment = selectDeployedSelfModificationEnvironment(probes);
+ return bindSandboxEnvironment(
+ defineSandbox(async ({ session }) => {
+ const sandbox = await environment.open({
+ networkPolicy: SELF_MODIFICATION_BASELINE_NETWORK_POLICY,
+ });
+ if (session.parent === undefined)
+ throw new Error("Production self-modification requires a child session.");
+ if (sandbox.setNetworkPolicy === undefined) {
+ throw new Error("Production self-modification requires mutable sandbox network policy.");
+ }
+ const capableSandbox = { ...sandbox, setNetworkPolicy: sandbox.setNetworkPolicy };
+ const token = await createGitHubCredentialProvider(deployed.credentials).resolve({
+ capability: "checkout",
+ repository: deployed.repository,
+ });
+ await prepareSelfModificationWorkspace({
+ directory: deployed.directory,
+ repository: deployed.repository,
+ sandbox: capableSandbox,
+ targetBranch: deployed.targetBranch,
+ token,
+ });
+ const root =
+ deployed.directory === "." ? REPOSITORY_PATH : `${REPOSITORY_PATH}/${deployed.directory}`;
+ const result = await sandbox.run({
+ command: `rm -rf /source && ln -s ${shellQuote(`${root}/agent`)} /source`,
+ });
+ if (result.exitCode !== 0)
+ throw new Error("Self-modification could not mount the agent source.");
+ return sandbox;
+ }),
+ environment,
+ );
+}
+
+export function selectDeployedSelfModificationEnvironment(
+ probes: Probes,
+): DeployedSelfModificationEnvironment {
+ if (probes.isDeployedOnVercel()) {
+ return VercelSandbox.environment();
+ }
+ if (probes.isMicrosandboxSupported()) {
+ return MicrosandboxSandbox.environment();
+ }
+ throw new Error(
+ "Deployed self-modification requires runtime credential transforms. No supported provider is available. Use Vercel Sandbox or microsandbox on a supported self-hosted system.",
+ );
+}
diff --git a/packages/eve/src/self-modification/extension/config-schema.ts b/packages/eve/src/self-modification/extension/config-schema.ts
index a17083967..3417d5510 100644
--- a/packages/eve/src/self-modification/extension/config-schema.ts
+++ b/packages/eve/src/self-modification/extension/config-schema.ts
@@ -1,35 +1,21 @@
import { z } from "#compiled/zod/index.js";
import { isAgentReasoningDefinition, isRuntimeLanguageModel } from "#internal/runtime-model.js";
import type { AgentReasoningDefinition, AgentStaticModelDefinition } from "#public/index.js";
-import type { GitHubCredentialProvider, SelfModificationAuthorization } from "../config.js";
-export const selfModificationConfigSchema = z.object({
- model: z
- .custom<AgentStaticModelDefinition>(
- (value) => typeof value === "string" || isRuntimeLanguageModel(value),
- )
- .optional(),
- reasoning: z.custom<AgentReasoningDefinition>(isAgentReasoningDefinition).optional(),
- local: z.object({ enabled: z.boolean().optional() }).optional(),
- deployed: z
- .object({
- credentials: z
- .union([
- z.object({ pat: z.literal(true) }),
- z.custom<GitHubCredentialProvider>(
- (value) =>
- typeof value === "object" &&
- value !== null &&
- "resolve" in value &&
- typeof value.resolve === "function",
- ),
- ])
- .optional(),
- source: z.object({
- git: z.object({ directory: z.string(), repository: z.string() }),
- }),
- target: z.object({ branch: z.string() }),
- authorize: z.custom<SelfModificationAuthorization>((value) => typeof value === "function"),
- })
- .optional(),
-});
+import { DEPLOYED_OPTION_MOVED_MESSAGE } from "../config.js";
+
+export const selfModificationConfigSchema = z
+ .object({
+ model: z
+ .custom<AgentStaticModelDefinition>(
+ (value) => typeof value === "string" || isRuntimeLanguageModel(value),
+ )
+ .optional(),
+ reasoning: z.custom<AgentReasoningDefinition>(isAgentReasoningDefinition).optional(),
+ local: z.object({ enabled: z.boolean().optional() }).optional(),
+ // Kept only to reject the former combined mount with a migration message.
+ deployed: z
+ .custom<never>((value) => value === undefined, DEPLOYED_OPTION_MOVED_MESSAGE)
+ .optional(),
+ })
+ .strict();
diff --git a/packages/eve/src/self-modification/extension/extension.test.ts b/packages/eve/src/self-modification/extension/extension.test.ts
index 5b96e8a9c..00471ec2e 100644
--- a/packages/eve/src/self-modification/extension/extension.test.ts
+++ b/packages/eve/src/self-modification/extension/extension.test.ts
@@ -1,6 +1,7 @@
import { MockLanguageModelV3 } from "ai/test";
import { describe, expect, it } from "vitest";
+import { deployedSelfModificationConfigSchema } from "../remote/config-schema.js";
import { selfModificationConfigSchema } from "./config-schema.js";
class StatefulCredentialProvider {
@@ -34,23 +35,27 @@ describe("self-modification extension config", () => {
expect(() => selfModificationConfigSchema.parse(config)).toThrow();
});
- it("preserves application-supplied credential providers", async () => {
+ it("rejects the former deployed option with migration guidance", () => {
+ expect(() => selfModificationConfigSchema.parse({ deployed: {} })).toThrow(
+ "eve/self-modification/remote",
+ );
+ });
+
+ it("preserves application-supplied credential providers on the deployed mount", async () => {
const credentials = new StatefulCredentialProvider("github-token");
- const parsed = selfModificationConfigSchema.parse({
- deployed: {
- authorize: () => true,
- credentials,
- source: { git: { directory: ".", repository: "github.com/acme/agent" } },
- target: { branch: "main" },
- },
+ const parsed = deployedSelfModificationConfigSchema.parse({
+ authorize: () => true,
+ credentials,
+ source: { git: { directory: ".", repository: "github.com/acme/agent" } },
+ target: { branch: "main" },
});
- expect(parsed.deployed?.credentials).toBe(credentials);
- if (parsed.deployed?.credentials === undefined || "pat" in parsed.deployed.credentials) {
+ expect(parsed.credentials).toBe(credentials);
+ if (parsed.credentials === undefined || "pat" in parsed.credentials) {
throw new Error("Expected credential provider.");
}
await expect(
- parsed.deployed.credentials.resolve({
+ parsed.credentials.resolve({
capability: "publish",
repository: { owner: "acme", repo: "agent" },
}),
diff --git a/packages/eve/src/self-modification/extension/local-only.ts b/packages/eve/src/self-modification/extension/local-only.ts
index a6ea2b5b5..12dd5c1c7 100644
--- a/packages/eve/src/self-modification/extension/local-only.ts
+++ b/packages/eve/src/self-modification/extension/local-only.ts
@@ -1,7 +1,7 @@
import { defineDynamic } from "#dynamic/definition.js";
import { resolveSelfModificationConfig, type ResolvedSelfModificationConfig } from "../config.js";
-import { resolveSelfModificationMode } from "../mode.js";
+import { isLocalSelfModificationEnabled } from "../mode.js";
import selfModification from "./extension.js";
/** Returns a definition only when self-modification is running locally. */
@@ -9,10 +9,10 @@ export function resolveLocalOnly<T>(
config: ResolvedSelfModificationConfig,
definition: T,
): T | null {
- return resolveSelfModificationMode(config) === "local" ? definition : null;
+ return isLocalSelfModificationEnabled(config) ? definition : null;
}
-/** Creates a dynamic definition that is absent from deployed self-modification. */
+/** Creates a dynamic definition that is present only during local development. */
export function defineLocalOnlyDynamic<T>(definition: T) {
return defineDynamic({
events: {
diff --git a/packages/eve/src/self-modification/extension/subagents/agent/agent.ts b/packages/eve/src/self-modification/extension/subagents/agent/agent.ts
index faa3ac538..8fe0e97b2 100644
--- a/packages/eve/src/self-modification/extension/subagents/agent/agent.ts
+++ b/packages/eve/src/self-modification/extension/subagents/agent/agent.ts
@@ -13,8 +13,15 @@ import { getLocalDevCapability } from "eve/local-dev";
import selfModification from "../../extension.js";
import { resolveSelfModificationConfig, type SelfModificationConfig } from "../../../config.js";
-import { hasGitHubCredential } from "../../../credentials.js";
-import { resolveSelfModificationMode } from "../../../mode.js";
+import { isLocalSelfModificationEnabled } from "../../../mode.js";
+import {
+ followUpDelegation,
+ namedInstallationDelegation,
+ persistenceDelegation,
+ renderDescription,
+ repairDelegation,
+ sourceDelegation,
+} from "../../../subagent-guidance.js";
/** Fallback model when neither the self-modification agent nor its parent configures one. */
export const FALLBACK_SELF_MODIFICATION_MODEL = DEFAULT_AGENT_MODEL_ID;
@@ -31,88 +38,42 @@ export interface SelfModificationAgentOptions {
readonly reasoning?: AgentReasoningDefinition;
}
-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 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.";
-
-const namedInstallationDelegation =
- "Treat questions phrased as whether you can install, add, enable, or connect to a named product or service as requests to extend this eve agent and delegate immediately. Do not assume they refer to device software, ask what kind of installation they mean, or deny them because you lack access to the user's device. The subagent determines whether the request maps to an integration, channel, connection, or other capability, then checks registry availability and any required setup.";
-
-const followUpDelegation =
- "Resolve short follow-ups such as “yes” or “do it” against the preceding conversation. " +
- "If whether the requested change should persist is genuinely ambiguous, ask one concise clarifying question.";
-
-const repairDelegation =
- "If a tool or capability created or changed by this subagent later fails or behaves incorrectly, explain the observed problem and offer to delegate a repair. " +
- "Do not start the repair until the user confirms. Treat that confirmation as a source-modification request and delegate it immediately, including the exact identifier, failing behavior, expected behavior, and existing constraints.";
-
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. */
+/** Defines the local development self-modification dynamic subagent. */
export function defineSelfModificationAgent(
options: SelfModificationAgentOptions = {},
): DynamicSentinel<DynamicSubagentDefinition | null> {
const resolve = async (_event: unknown, ctx: DynamicResolveContext) => {
const bound = selfModification.config;
+ const config = resolveSelfModificationConfig(options.config ?? bound);
+ if (!isLocalSelfModificationEnabled(config) || getLocalDevCapability() === undefined) {
+ return null;
+ }
const configuredModel = options.model ?? bound.model ?? ctx.model?.id;
const reasoning =
options.reasoning ??
bound.reasoning ??
(configuredModel === undefined ? DEFAULT_AGENT_REASONING : undefined);
- const config = resolveSelfModificationConfig(options.config ?? bound);
- const mode = resolveSelfModificationMode(config);
const model = configuredModel ?? FALLBACK_SELF_MODIFICATION_MODEL;
const description = renderDescription([
"Delegate here immediately when the user asks to change the self-modification subagent's model, reasoning, or configuration. Also delegate when the user asks to change this eve agent or its authored source.",
sourceDelegation,
persistenceDelegation,
namedInstallationDelegation,
- mode === "local" ? localIntegrationDelegation : deployedIntegrationDelegation,
- mode === "local" ? localTraceDelegation : "",
+ localIntegrationDelegation,
+ localTraceDelegation,
followUpDelegation,
repairDelegation,
- mode === "local" ? localEffectiveEdits : deployedEffectiveEdits,
+ localEffectiveEdits,
]);
- if (mode === "local") {
- if (getLocalDevCapability() === undefined) return null;
- return defineAgent({ description, model, reasoning });
- }
- if (mode !== "deployed" || config.deployed === undefined) return null;
- if (config.deployed.credentials.kind === "pat" && !hasGitHubCredential()) return null;
- try {
- if (
- !(await config.deployed.authorize({
- channel: ctx.channel,
- principal: ctx.session.auth.current,
- }))
- ) {
- return null;
- }
- } catch {
- return null;
- }
return defineAgent({ description, model, reasoning });
};
diff --git a/packages/eve/src/self-modification/extension/subagents/agent/instructions.ts b/packages/eve/src/self-modification/extension/subagents/agent/instructions.ts
index 2d67ec3c6..68d36107e 100644
--- a/packages/eve/src/self-modification/extension/subagents/agent/instructions.ts
+++ b/packages/eve/src/self-modification/extension/subagents/agent/instructions.ts
@@ -1,49 +1,19 @@
import { defineDynamic, defineInstructions } from "eve/instructions";
import { resolveSelfModificationConfig } from "../../../config.js";
-import { resolveSelfModificationMode } from "../../../mode.js";
-import selfModification from "../../extension.js";
+import { isLocalSelfModificationEnabled } from "../../../mode.js";
import { renderLocalSelfModificationExtension } from "../../../scaffold.js";
-
-const role = `## Role
-
-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 sourceWorkspace = `## Source workspace
-
-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. edit_file instead validates exact matches against current contents. Never modify source files with bash, sed, awk, redirection, or scripting.
-
-Resolve named tools by filename under /source/tools before searching contents. Tool identifiers derive from filenames and may not occur in the implementation.`;
-
-const sourceEditing = `## Implement changes
-
-Use 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.
-
-Once paths are known, batch independent file reads and edits to different files. Never edit the same file concurrently.`;
-
-const toolAuthoring = `## Add model-callable actions
-
-When the requester wants this agent to gain a reusable action or capability that it can invoke in future turns, implement it as an authored eve tool under /source/tools. This applies even when the request describes the action without using the word “tool.” Follow the path-derived naming and defineTool conventions in the mounted eve tools documentation and existing source.
-
-Do not substitute a loose Python, shell, or JavaScript file for a model-callable tool. A support script is acceptable only when an authored eve tool invokes it as an implementation detail, or when the requester explicitly asks for a standalone script instead of an agent capability.`;
-
-const registryWorkflow = `## Add integrations
-
-Before adding a new eve-managed channel, connection, extension, instrumentation, or memory integration, call search_registry alongside source discovery. If an item fulfills the requirement, install it with 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.
-
-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 registry_add separately from file edits and other registry installations.
-
-Registry installation is outside the source sandbox.`;
-
-const documentationGuidance = `## Consult documentation
-
-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.`;
+import {
+ documentationInstructions,
+ registryWorkflowInstructions,
+ renderInstructions,
+ roleInstructions,
+ sourceEditingInstructions,
+ sourceWorkspaceInstructions,
+ toolAuthoringInstructions,
+ workingInstructions,
+} from "../../../subagent-guidance.js";
+import selfModification from "../../extension.js";
const localReportingGuidance = `## Report results
@@ -51,12 +21,6 @@ For source-modification tasks, return a concise handoff to the caller. Use at mo
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 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, if a \`needs-terminal\` result includes \`nextCommand\`, present that exact value as the only shell command in your response. Never infer, construct, or rewrite a command: installing an item uses \`eve add <item>\`; \`eve registry add\` configures registry namespace mappings and does not install items.
@@ -71,38 +35,25 @@ Only when the requester explicitly names the self-modification subagent, edit wh
\`\`\`ts
${renderLocalSelfModificationExtension()}\`\`\``;
-const deployedGuidance = `## Deployed environment
-
-The 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.
-
-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.`;
-
-function renderInstructions(sections: readonly string[]): string {
- return sections.filter((section) => section.length > 0).join("\n\n");
-}
-
export default defineDynamic({
events: {
"session.started": () => {
- const mode = resolveSelfModificationMode(
- resolveSelfModificationConfig(selfModification.config),
- );
- if (mode !== "local" && mode !== "deployed") return null;
+ if (!isLocalSelfModificationEnabled(resolveSelfModificationConfig(selfModification.config))) {
+ return null;
+ }
return defineInstructions({
markdown: renderInstructions([
- role,
- sourceWorkspace,
- sourceEditing,
- toolAuthoring,
- registryWorkflow,
- documentationGuidance,
- mode === "local" ? localGuidance : deployedGuidance,
- workingGuidance,
+ roleInstructions,
+ sourceWorkspaceInstructions,
+ sourceEditingInstructions,
+ toolAuthoringInstructions,
+ registryWorkflowInstructions,
+ documentationInstructions,
+ localGuidance,
+ workingInstructions,
selfModificationSubagentGuidance,
- mode === "local" ? localReportingGuidance : deployedReportingGuidance,
+ localReportingGuidance,
]),
});
},
diff --git a/packages/eve/src/self-modification/extension/subagents/agent/tools/registry_add.ts b/packages/eve/src/self-modification/extension/subagents/agent/tools/registry_add.ts
index d30431d72..26d39666f 100644
--- a/packages/eve/src/self-modification/extension/subagents/agent/tools/registry_add.ts
+++ b/packages/eve/src/self-modification/extension/subagents/agent/tools/registry_add.ts
@@ -1,24 +1,13 @@
import { getLocalDevCapability, type LocalDevCapability } from "eve/local-dev";
-import { defineDynamic, defineTool, type ToolContext } from "eve/tools";
+import { defineTool } from "eve/tools";
-import {
- resolveSelfModificationConfig,
- type ResolvedDeployedSelfModificationConfig,
- type ResolvedSelfModificationConfig,
-} from "../../../../config.js";
-import { readPreparedSelfModificationWorkspace } from "../../../../git-workspace.js";
-import { resolveSelfModificationMode } from "../../../../mode.js";
+import type { ResolvedSelfModificationConfig } from "../../../../config.js";
import { withSelfModificationWorkspaceLock } from "../../../../workspace-lock.js";
-import selfModification from "../../../extension.js";
import { classifyCatalogEntry } from "../../../classify-registry-item.js";
import { runEveAdd, type SpawnLike } from "../../../eve-add.js";
-import {
- assertOfficialRegistryAddress,
- installProductionRegistryItem,
-} from "../../../production-registry-add.js";
+import { defineLocalOnlyDynamic, resolveLocalOnly } from "../../../local-only.js";
import {
loadRegistryIndex,
- officialRegistryIndexUrl,
resolveRegistryIndexUrl,
type CatalogEntry,
} from "./search_registry.js";
@@ -27,11 +16,6 @@ import {
* Local installation mutates the developer's project through `eve dev`. It may
* hand setup-bearing items to the TUI or terminal, supports the configured
* registry, and reports any local files that could not be restored on failure.
- *
- * Production installation mutates only the disposable proposal checkout. It is
- * restricted to the official registry, supports resumable non-secret setup and
- * external authorization boundaries, and reports paths destined for the draft
- * pull request rather than claiming that those changes are deployed.
*/
const localInputSchema = {
type: "object",
@@ -76,64 +60,6 @@ const localOutputSchema = {
required: ["status", "address", "message"],
} as const;
-const productionInputSchema = {
- type: "object",
- additionalProperties: false,
- properties: {
- address: {
- type: "string",
- minLength: 1,
- maxLength: 200,
- description:
- "Exact official eve registry address, for example `channel/slack` or `extension/browserbase`.",
- },
- answers: {
- type: "object",
- additionalProperties: true,
- description: "Non-secret answers to the setup question returned by the previous call.",
- },
- installed: {
- type: "boolean",
- description:
- "Set to true with answers when the previous input-required result installed the source.",
- },
- },
- required: ["address"],
-} as const;
-
-const productionOutputSchema = {
- type: "object",
- additionalProperties: false,
- properties: {
- status: {
- type: "string",
- enum: ["completed", "input-required", "external-action-required", "failed", "cancelled"],
- },
- address: { type: "string" },
- changedPaths: {
- type: "array",
- items: { type: "string" },
- description: "Repository-relative paths installed into the proposal.",
- },
- completedItems: { type: "array", items: { type: "string" } },
- deploymentRequired: { type: "boolean" },
- installed: {
- type: "boolean",
- description: "Whether source installation completed before setup paused.",
- },
- question: {
- type: "object",
- additionalProperties: true,
- description:
- "The current setup question. Supply only its non-secret answer on the next call.",
- },
- message: { type: "string" },
- url: { type: "string", description: "External authorization URL the developer must open." },
- userCode: { type: "string" },
- },
- required: ["status", "address"],
-} as const;
-
interface RegistryAddDependencies {
readonly getCapability?: () => LocalDevCapability | undefined;
readonly spawn?: SpawnLike;
@@ -152,30 +78,6 @@ export interface LocalRegistryAddResult {
readonly changed?: readonly string[];
}
-type ProductionRegistryAddResult =
- | {
- readonly address: string;
- readonly status: "completed";
- readonly completedItems: readonly string[];
- readonly changedPaths: readonly string[];
- readonly deploymentRequired: boolean;
- }
- | {
- readonly address: string;
- readonly status: "input-required";
- readonly installed: boolean;
- readonly question: unknown;
- }
- | {
- readonly address: string;
- readonly status: "external-action-required";
- readonly installed: boolean;
- readonly message: string;
- readonly url: string;
- readonly userCode?: string;
- }
- | { readonly address: string; readonly status: "failed" | "cancelled"; readonly message: string };
-
/**
* Names the item's declared environment variables that are not set.
*
@@ -324,51 +226,6 @@ export async function addLocalRegistryItem(
};
}
-async function addProductionRegistryItem(
- address: string,
- context: ToolContext,
- deployed: ResolvedDeployedSelfModificationConfig,
- continuation: {
- readonly answers?: Readonly<Record<string, unknown>>;
- readonly installed?: boolean;
- },
-): Promise<ProductionRegistryAddResult> {
- assertOfficialRegistryAddress(address);
- const entries = await loadRegistryIndex({
- nowMs: Date.now(),
- signal: context.abortSignal,
- url: officialRegistryIndexUrl(),
- });
- const entry = entries.find((candidate) => candidate.address === address);
- if (entry === undefined) {
- throw new Error(`No official eve registry item is published at "${address}".`);
- }
- const classification = classifyCatalogEntry(entry);
- if (classification.kind === "self-modification-mount") {
- throw new Error(classification.reason);
- }
- const sandbox = await context.getSandbox();
- const result = await withSelfModificationWorkspaceLock(
- `sandbox:${context.session.id}`,
- async () => {
- const workspace = await readPreparedSelfModificationWorkspace({ ...deployed, sandbox });
- return await installProductionRegistryItem({
- address,
- answers: continuation.answers,
- installed: continuation.installed,
- sandbox,
- signal: context.abortSignal,
- workspace,
- });
- },
- );
- if (result.kind === "completed") return { address, ...result, status: "completed" };
- if (result.kind === "input-required") return { address, ...result, status: "input-required" };
- if (result.kind === "external-action-required")
- return { address, ...result, status: "external-action-required" };
- return { address, ...result, status: result.kind };
-}
-
function localRegistryAddTool() {
return defineTool({
description:
@@ -385,42 +242,8 @@ function localRegistryAddTool() {
});
}
-function productionRegistryAddTool(deployed: ResolvedDeployedSelfModificationConfig) {
- return defineTool({
- description:
- "Install an exact item from the official eve registry into the current production change proposal. If setup pauses, call this tool again with the non-secret answers and the installed state from its result. External authorization and secret binding must be completed by the developer.",
- inputSchema: productionInputSchema,
- outputSchema: productionOutputSchema,
- async execute(input, ctx) {
- const { address } = input;
- if (typeof address !== "string" || address.length === 0) {
- throw new Error("address must be an exact item address from the official eve registry.");
- }
- const answers =
- "answers" in input &&
- typeof input.answers === "object" &&
- input.answers !== null &&
- !Array.isArray(input.answers)
- ? (input.answers as Record<string, unknown>)
- : undefined;
- const installed = "installed" in input && input.installed === true;
- return await addProductionRegistryItem(address, ctx, deployed, { answers, installed });
- },
- });
-}
-
export function resolveRegistryAddTool(config: ResolvedSelfModificationConfig) {
- const mode = resolveSelfModificationMode(config);
- if (mode === "local") return localRegistryAddTool();
- if (mode === "deployed" && config.deployed !== undefined) {
- return productionRegistryAddTool(config.deployed);
- }
- return null;
+ return resolveLocalOnly(config, localRegistryAddTool());
}
-export default defineDynamic({
- events: {
- "session.started": () =>
- resolveRegistryAddTool(resolveSelfModificationConfig(selfModification.config)),
- },
-});
+export default defineLocalOnlyDynamic(localRegistryAddTool());
diff --git a/packages/eve/src/self-modification/git-workspace.ts b/packages/eve/src/self-modification/git-workspace.ts
index 9ee4db703..1fb3c71a3 100644
--- a/packages/eve/src/self-modification/git-workspace.ts
+++ b/packages/eve/src/self-modification/git-workspace.ts
@@ -8,11 +8,10 @@ type NetworkPolicySandboxSession = SandboxSession & {
import { gitHubRemoteUrl } from "#shared/git.js";
import { shellQuote } from "#shared/shell-quote.js";
-import type { GitHubRepository } from "./config.js";
+import type { GitHubRepository } from "./remote/config.js";
import { gitOutput, runGitCommand, withBrokeredGitHubCredential } from "./git.js";
import { assertFullSha, assertGitRef } from "./identifiers.js";
-export const SELF_MODIFICATION_CONFIG_PATH = "agent/extensions/self-modification/extension.ts";
const WORKSPACE_PATH = "/workspace";
export const REPOSITORY_PATH = `${WORKSPACE_PATH}/repository`;
const BASE_REF = "refs/eve-self-modification/base";
diff --git a/packages/eve/src/self-modification/github-publisher.ts b/packages/eve/src/self-modification/github-publisher.ts
index a3d52ec3c..20ab0b69d 100644
--- a/packages/eve/src/self-modification/github-publisher.ts
+++ b/packages/eve/src/self-modification/github-publisher.ts
@@ -1,6 +1,6 @@
import { createHash } from "node:crypto";
-import type { GitHubCredentialProvider, GitHubRepository } from "./config.js";
+import type { GitHubCredentialProvider, GitHubRepository } from "./remote/config.js";
import type { PreparedSelfModificationWorkspace } from "./git-workspace.js";
import { assertFullSha, assertGitRef, assertOperationId } from "./identifiers.js";
import {
diff --git a/packages/eve/src/self-modification/migration.integration.test.ts b/packages/eve/src/self-modification/migration.integration.test.ts
index 91c5a0549..8ea3249ec 100644
--- a/packages/eve/src/self-modification/migration.integration.test.ts
+++ b/packages/eve/src/self-modification/migration.integration.test.ts
@@ -55,6 +55,7 @@ function setupOperations(): SelfModificationSetupOperations {
detectGitRepository: vi.fn(async () => ({ remoteKind: "missing" as const })),
findOrCreateConnector: vi.fn(async () => "github/example"),
readConfig: vi.fn(async () => undefined),
+ readLocalConfig: vi.fn(async () => undefined),
writeConfig: vi.fn(),
};
}
diff --git a/packages/eve/src/self-modification/mode.ts b/packages/eve/src/self-modification/mode.ts
index 5a5004802..eeb7911a0 100644
--- a/packages/eve/src/self-modification/mode.ts
+++ b/packages/eve/src/self-modification/mode.ts
@@ -1,11 +1,11 @@
import type { ResolvedSelfModificationConfig } from "./config.js";
-type SelfModificationMode = "local" | "disabled" | "deployed";
+/** Local self-modification runs only inside the development runtime. */
+export function isLocalSelfModificationEnabled(config: ResolvedSelfModificationConfig): boolean {
+ return process.env.EVE_DEV === "1" && config.localEnabled;
+}
-/** Resolves the mutually exclusive local or deployed editing mode. */
-export function resolveSelfModificationMode(
- config: ResolvedSelfModificationConfig,
-): SelfModificationMode {
- if (process.env.EVE_DEV === "1") return config.localEnabled ? "local" : "disabled";
- return config.deployed === undefined ? "disabled" : "deployed";
+/** Deployed self-modification is offered only outside the development runtime. */
+export function isDeployedRuntime(): boolean {
+ return process.env.EVE_DEV !== "1";
}
diff --git a/packages/eve/src/self-modification/package-consumption.scenario.test.ts b/packages/eve/src/self-modification/package-consumption.scenario.test.ts
index e7f496e68..346a95450 100644
--- a/packages/eve/src/self-modification/package-consumption.scenario.test.ts
+++ b/packages/eve/src/self-modification/package-consumption.scenario.test.ts
@@ -7,7 +7,7 @@ import { promisify } from "node:util";
import { afterEach, describe, expect, it } from "vitest";
-import { renderSelfModificationConfig } from "./setup.js";
+import { DEPLOYED_SELF_MODIFICATION_CONFIG_PATH, renderSelfModificationConfig } from "./setup.js";
const runFile = promisify(execFile);
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
@@ -81,6 +81,7 @@ describe("packed package consumption", () => {
await access(join(packageRoot, "dist/src/self-modification/config.js"));
await access(join(packageRoot, "dist/src/self-modification/sandbox.js"));
await access(join(packageRoot, "dist/src/self-modification/setup.js"));
+ await access(join(packageRoot, "dist/src/self-modification/remote/extension.js"));
await Promise.all([
access(
join(
@@ -163,7 +164,7 @@ describe("packed package consumption", () => {
await writeAppFile(appRoot, "agent/instructions.md", "You are a test agent.\n");
await writeAppFile(
appRoot,
- "agent/extensions/self-modification/extension.ts",
+ DEPLOYED_SELF_MODIFICATION_CONFIG_PATH,
renderSelfModificationConfig({
branch: "main",
channelNames: [],
@@ -201,6 +202,22 @@ if (compiled.subagents.length !== 1 || subagent === undefined || !subagent.agent
`,
);
await run("node", ["verify-development-extension.mjs"], appRoot);
+ await writeAppFile(
+ appRoot,
+ "verify-remote-extension.mjs",
+ `import assert from "node:assert/strict";
+import { discoverAgent } from "./node_modules/eve/dist/src/discover/discover-agent.js";
+import { compileAgentManifest } from "./node_modules/eve/dist/src/compiler/normalize-manifest.js";
+
+const discovered = await discoverAgent({ appRoot: process.cwd(), agentRoot: process.cwd() + "/agent" });
+assert.deepEqual(discovered.diagnostics.filter((entry) => entry.severity === "error"), []);
+const compiled = await compileAgentManifest(discovered.manifest);
+assert.deepEqual(compiled.subagents.map((entry) => entry.name), ["self-modification-remote__agent"]);
+const slugs = compiled.subagents[0].agent.dynamicTools.map((tool) => tool.slug);
+assert.ok(slugs.includes("publish") && slugs.includes("registry_add"));
+`,
+ );
+ await run("node", ["verify-remote-extension.mjs"], appRoot);
const build = await run("pnpm", ["exec", "eve", "build", "--skip-sandbox-prewarm"], appRoot);
const output = `${build.stdout}\n${build.stderr}`;
if (output.includes("Could not resolve '#shared/")) {
diff --git a/packages/eve/src/self-modification/production-registry-add.test.ts b/packages/eve/src/self-modification/production-registry-add.test.ts
index 09a7e075f..778a7f8d3 100644
--- a/packages/eve/src/self-modification/production-registry-add.test.ts
+++ b/packages/eve/src/self-modification/production-registry-add.test.ts
@@ -4,7 +4,7 @@ import {
acceptsNonSecretSetupAnswers,
assertOfficialRegistryAddress,
installProductionRegistryItem,
-} from "./extension/production-registry-add.js";
+} from "./remote/production-registry-add.js";
const SHA = "a".repeat(40);
const workspace = {
diff --git a/packages/eve/src/self-modification/publish-tool.test.ts b/packages/eve/src/self-modification/publish-tool.test.ts
index 14f700304..493485b02 100644
--- a/packages/eve/src/self-modification/publish-tool.test.ts
+++ b/packages/eve/src/self-modification/publish-tool.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
-import { publicationOperationId } from "./extension/subagents/agent/tools/publish.js";
+import { publicationOperationId } from "./remote/subagents/agent/tools/publish.js";
describe("production publish tool", () => {
it("derives operation identity from trusted parent lineage", () => {
diff --git a/packages/eve/src/self-modification/registry-add.test.ts b/packages/eve/src/self-modification/registry-add.test.ts
index 4d9763b1a..3a8e75b44 100644
--- a/packages/eve/src/self-modification/registry-add.test.ts
+++ b/packages/eve/src/self-modification/registry-add.test.ts
@@ -24,6 +24,7 @@ import {
unsetEnvVars,
} from "./extension/subagents/agent/tools/registry_add.js";
import { clearRegistryIndexCache } from "./extension/subagents/agent/tools/search_registry.js";
+import { productionRegistryAddTool } from "./remote/subagents/agent/tools/registry_add.js";
const APP_ROOT = "/workspace/agent";
const originalEveDev = process.env.EVE_DEV;
@@ -160,17 +161,12 @@ describe("resolveRegistryAddTool", () => {
});
it("resolves the deployed lifecycle with continuation arguments and outcomes", () => {
- delete process.env.EVE_DEV;
-
- const tool = resolveRegistryAddTool({
- localEnabled: true,
- deployed: {
- authorize: () => true,
- credentials: { kind: "pat" },
- directory: ".",
- repository: { owner: "acme", repo: "agent" },
- targetBranch: "main",
- },
+ const tool = productionRegistryAddTool({
+ authorize: () => true,
+ credentials: { kind: "pat" },
+ directory: ".",
+ repository: { owner: "acme", repo: "agent" },
+ targetBranch: "main",
});
expect(tool).toMatchObject({
diff --git a/packages/eve/src/self-modification/remote/config-schema.ts b/packages/eve/src/self-modification/remote/config-schema.ts
new file mode 100644
index 000000000..40fba9fc7
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/config-schema.ts
@@ -0,0 +1,33 @@
+import { z } from "#compiled/zod/index.js";
+import { isAgentReasoningDefinition, isRuntimeLanguageModel } from "#internal/runtime-model.js";
+import type { AgentReasoningDefinition, AgentStaticModelDefinition } from "#public/index.js";
+
+import type { GitHubCredentialProvider, SelfModificationAuthorization } from "./config.js";
+
+export const deployedSelfModificationConfigSchema = z
+ .object({
+ model: z
+ .custom<AgentStaticModelDefinition>(
+ (value) => typeof value === "string" || isRuntimeLanguageModel(value),
+ )
+ .optional(),
+ reasoning: z.custom<AgentReasoningDefinition>(isAgentReasoningDefinition).optional(),
+ credentials: z
+ .union([
+ z.object({ pat: z.literal(true) }),
+ z.custom<GitHubCredentialProvider>(
+ (value) =>
+ typeof value === "object" &&
+ value !== null &&
+ "resolve" in value &&
+ typeof value.resolve === "function",
+ ),
+ ])
+ .optional(),
+ source: z.object({
+ git: z.object({ directory: z.string(), repository: z.string() }),
+ }),
+ target: z.object({ branch: z.string() }),
+ authorize: z.custom<SelfModificationAuthorization>((value) => typeof value === "function"),
+ })
+ .strict();
diff --git a/packages/eve/src/self-modification/remote/config.test.ts b/packages/eve/src/self-modification/remote/config.test.ts
new file mode 100644
index 000000000..741e04df5
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/config.test.ts
@@ -0,0 +1,122 @@
+import { afterEach, describe, expect, it } from "vitest";
+
+import { createGitHubCredentialProvider } from "../credentials.js";
+import { resolveDeployedSelfModificationConfig } from "./config.js";
+
+afterEach(() => {
+ delete process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN;
+});
+
+const deployed = {
+ source: { git: { directory: "apps/weather", repository: "github.com/vercel/eve" } },
+ target: { branch: "main" },
+ authorize: () => true,
+ credentials: { pat: true },
+} as const;
+
+describe("deployed self-modification configuration", () => {
+ it("resolves a repository-root application", () => {
+ expect(
+ resolveDeployedSelfModificationConfig({
+ ...deployed,
+ source: { git: { ...deployed.source.git, directory: "." } },
+ }),
+ ).toMatchObject({
+ directory: ".",
+ repository: { owner: "vercel", repo: "eve" },
+ targetBranch: "main",
+ });
+ });
+
+ it("requires opting into the self-hosted PAT exception", () => {
+ expect(resolveDeployedSelfModificationConfig(deployed)).toMatchObject({
+ credentials: { kind: "pat" },
+ });
+ expect(() =>
+ resolveDeployedSelfModificationConfig({ ...deployed, credentials: undefined }),
+ ).toThrow("must explicitly configure");
+ });
+
+ it("resolves an application-supplied credential provider", () => {
+ const provider = { resolve: async () => "github-token" };
+ const config = resolveDeployedSelfModificationConfig({ ...deployed, credentials: provider });
+
+ expect(config.credentials).toEqual({ kind: "provider", provider });
+ });
+
+ it.each(["", "/agent", "agent/../other", "agent//other", "agent\\other"])(
+ "rejects unsafe application directories: %s",
+ (directory) => {
+ expect(() =>
+ resolveDeployedSelfModificationConfig({
+ ...deployed,
+ source: { git: { ...deployed.source.git, directory } },
+ }),
+ ).toThrow("safe repository-relative");
+ },
+ );
+
+ it("requires complete configuration", () => {
+ expect(() =>
+ resolveDeployedSelfModificationConfig({ source: deployed.source } as never),
+ ).toThrow("source, target, and authorization");
+ });
+
+ it("requires an authorization policy", () => {
+ expect(() => {
+ const { authorize: _authorize, ...withoutAuthorize } = deployed;
+ resolveDeployedSelfModificationConfig(withoutAuthorize as never);
+ }).toThrow("source, target, and authorization");
+ expect(() =>
+ resolveDeployedSelfModificationConfig({ ...deployed, authorize: true as never }),
+ ).toThrow("authorize must be a function");
+ });
+
+ it("rejects ambiguous or malformed credential configuration", () => {
+ expect(() =>
+ resolveDeployedSelfModificationConfig({
+ ...deployed,
+ credentials: { pat: true, resolve: async () => "token" } as never,
+ }),
+ ).toThrow("not both");
+ expect(() =>
+ resolveDeployedSelfModificationConfig({ ...deployed, credentials: { pat: false } as never }),
+ ).toThrow("pat must be true");
+ expect(() =>
+ resolveDeployedSelfModificationConfig({
+ ...deployed,
+ credentials: { resolve: true } as never,
+ }),
+ ).toThrow("resolve function");
+ });
+
+ it.each([
+ [null, "configuration must be an object"],
+ [{ ...deployed, source: null }, "source must be an object"],
+ [{ ...deployed, source: {} }, "source.git must be an object"],
+ [{ ...deployed, target: null }, "target must be an object"],
+ ])("rejects malformed nested configuration", (config, message) => {
+ expect(() => resolveDeployedSelfModificationConfig(config as never)).toThrow(message);
+ });
+
+ it("rejects a fully qualified target ref", () => {
+ expect(() =>
+ resolveDeployedSelfModificationConfig({
+ ...deployed,
+ target: { branch: "refs/heads/main" },
+ }),
+ ).toThrow("must be a branch name");
+ });
+
+ it("resolves the GitHub token for each capability", async () => {
+ process.env.EVE_SELF_MODIFICATION_GITHUB_TOKEN = " secret-token ";
+ const { credentials, repository } = resolveDeployedSelfModificationConfig(deployed);
+ const provider = createGitHubCredentialProvider(credentials);
+ await expect(provider.resolve({ capability: "checkout", repository })).resolves.toBe(
+ "secret-token",
+ );
+ await expect(provider.resolve({ capability: "publish", repository })).resolves.toBe(
+ "secret-token",
+ );
+ });
+});
diff --git a/packages/eve/src/self-modification/remote/config.ts b/packages/eve/src/self-modification/remote/config.ts
new file mode 100644
index 000000000..ddcbbe91c
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/config.ts
@@ -0,0 +1,186 @@
+import type { SessionAuthContext } from "#channel/types.js";
+import type { AgentReasoningDefinition, AgentStaticModelDefinition } from "#public/index.js";
+
+import { assertGitRef, assertRepositoryPart } from "../identifiers.js";
+
+/** Principal and channel that requested a deployed source modification. */
+export interface SelfModificationAuthorizationContext {
+ readonly channel: {
+ /** Channel adapter family, such as `"slack"` or `"http"`. */
+ readonly kind?: string;
+ readonly metadata?: Readonly<Record<string, unknown>>;
+ };
+ readonly principal: SessionAuthContext | null;
+}
+
+/** Decides whether a principal may use deployed self-modification. */
+export type SelfModificationAuthorization = (
+ context: SelfModificationAuthorizationContext,
+) => boolean | Promise<boolean>;
+
+export interface GitHubRepository {
+ readonly owner: string;
+ readonly repo: string;
+}
+
+export type GitHubCredentialCapability = "checkout" | "publish";
+
+export interface GitHubCredentialRequest {
+ readonly capability: GitHubCredentialCapability;
+ readonly repository: GitHubRepository;
+}
+
+/** Application-supplied GitHub credentials for deployed self-modification. */
+export interface GitHubCredentialProvider {
+ resolve(request: GitHubCredentialRequest): Promise<string>;
+}
+
+/** Values accepted by the `eve/self-modification/remote` extension mount. */
+export interface DeployedSelfModificationConfig {
+ readonly source: {
+ readonly git: {
+ /** GitHub repository in github.com/owner/repository form. */
+ readonly repository: string;
+ /** Application directory relative to the repository root. */
+ readonly directory: string;
+ };
+ };
+ readonly target: { readonly branch: string };
+ /** Fail-closed policy for principals that may create draft proposals. */
+ readonly authorize: SelfModificationAuthorization;
+ readonly credentials?:
+ | GitHubCredentialProvider
+ | {
+ /**
+ * Self-hosted exception. Reads `EVE_SELF_MODIFICATION_GITHUB_TOKEN` from
+ * the trusted deployment environment; never injects it into the sandbox.
+ */
+ readonly pat: true;
+ };
+ /** Model used by the deployed self-modification subagent; defaults to the parent model. */
+ readonly model?: AgentStaticModelDefinition;
+ readonly reasoning?: AgentReasoningDefinition;
+}
+
+export interface ResolvedDeployedSelfModificationConfig {
+ readonly authorize: SelfModificationAuthorization;
+ readonly credentials: ResolvedGitHubCredentials;
+ readonly directory: string;
+ readonly repository: GitHubRepository;
+ readonly targetBranch: string;
+}
+
+export type ResolvedGitHubCredentials =
+ | { readonly kind: "pat" }
+ | { readonly kind: "provider"; readonly provider: GitHubCredentialProvider };
+
+export function resolveDeployedSelfModificationConfig(
+ config: DeployedSelfModificationConfig,
+): ResolvedDeployedSelfModificationConfig {
+ if (!isRecord(config)) {
+ throw new Error("Deployed self-modification configuration must be an object.");
+ }
+ const { source, target, authorize, credentials } = config;
+ if (source === undefined || target === undefined || authorize === undefined) {
+ throw new Error(
+ "Deployed self-modification requires source, target, and authorization configuration.",
+ );
+ }
+ if (!isRecord(source)) throw new Error("Deployed self-modification source must be an object.");
+ if (!isRecord(source.git)) {
+ throw new Error("Deployed self-modification source.git must be an object.");
+ }
+ if (!isRecord(target)) throw new Error("Deployed self-modification target must be an object.");
+ if (typeof authorize !== "function") {
+ throw new Error("Deployed self-modification authorize must be a function.");
+ }
+
+ const { git } = source;
+ if (typeof git.repository !== "string" || typeof git.directory !== "string") {
+ throw new Error(
+ "Deployed self-modification source.git.repository and source.git.directory must be strings.",
+ );
+ }
+ if (typeof target.branch !== "string") {
+ throw new Error("Deployed self-modification target.branch must be a string.");
+ }
+ return {
+ authorize: authorize as SelfModificationAuthorization,
+ credentials: parseCredentials(credentials),
+ directory: parseDirectory(git.directory),
+ repository: parseGitHubRepository(git.repository),
+ targetBranch: parseBranch(target.branch),
+ };
+}
+
+function parseCredentials(value: unknown): ResolvedGitHubCredentials {
+ if (!isRecord(value)) {
+ throw new Error(
+ "Deployed self-modification credentials must explicitly configure a credential provider or the self-hosted PAT exception.",
+ );
+ }
+ const hasProvider = value.resolve !== undefined;
+ const hasPat = value.pat !== undefined;
+ if (hasProvider && hasPat) {
+ throw new Error(
+ "Deployed self-modification credentials must configure either a credential provider or pat, not both.",
+ );
+ }
+ if (hasPat) {
+ if (value.pat !== true) {
+ throw new Error("Deployed self-modification credentials.pat must be true.");
+ }
+ return { kind: "pat" };
+ }
+ if (!isGitHubCredentialProvider(value)) {
+ throw new Error(
+ "Deployed self-modification credentials must be an object with a resolve function.",
+ );
+ }
+ return { kind: "provider", provider: value };
+}
+
+function isGitHubCredentialProvider(value: unknown): value is GitHubCredentialProvider {
+ return isRecord(value) && typeof value.resolve === "function";
+}
+
+function parseGitHubRepository(repository: string): GitHubRepository {
+ const match = /^github\.com\/([^/]+)\/([^/]+)$/u.exec(repository);
+ if (match?.[1] === undefined || match[2] === undefined) {
+ throw new Error(
+ "Deployed self-modification source.git.repository must use github.com/owner/repo form.",
+ );
+ }
+ assertRepositoryPart(match[1], "repository owner");
+ assertRepositoryPart(match[2], "repository name");
+ return { owner: match[1], repo: match[2] };
+}
+
+function parseDirectory(directory: string): string {
+ if (
+ directory !== "." &&
+ (directory.length === 0 ||
+ directory.startsWith("/") ||
+ directory.includes("\\") ||
+ directory.split("/").some((part) => part === "" || part === "." || part === ".."))
+ ) {
+ throw new Error(
+ "Deployed self-modification source.git.directory must be a safe repository-relative path.",
+ );
+ }
+ return directory;
+}
+
+function parseBranch(branch: string): string {
+ assertGitRef(branch, "target branch");
+ if (branch.startsWith("refs/")) {
+ throw new Error(
+ "Deployed self-modification target.branch must be a branch name, not a full Git ref.",
+ );
+ }
+ return branch;
+}
+
+function isRecord(value: unknown): value is Record<string, unknown> {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
diff --git a/packages/eve/src/self-modification/remote/extension.ts b/packages/eve/src/self-modification/remote/extension.ts
new file mode 100644
index 000000000..a9d0afa55
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/extension.ts
@@ -0,0 +1,13 @@
+import { defineExtension } from "eve/extension";
+
+import type { StandardSchemaV1 } from "#compiled/@standard-schema/spec/index.js";
+import type { DeployedSelfModificationConfig } from "./config.js";
+import { deployedSelfModificationConfigSchema } from "./config-schema.js";
+
+// Typed as a Standard Schema so the public declaration names eve's own
+// config type instead of Zod's.
+const config: StandardSchemaV1<DeployedSelfModificationConfig> =
+ deployedSelfModificationConfigSchema;
+
+/** Deployed self-modification mount; independent of the local development extension. */
+export default defineExtension({ config });
diff --git a/packages/eve/src/self-modification/extension/production-registry-add.ts b/packages/eve/src/self-modification/remote/production-registry-add.ts
similarity index 99%
rename from packages/eve/src/self-modification/extension/production-registry-add.ts
rename to packages/eve/src/self-modification/remote/production-registry-add.ts
index 85afbecca..6c7a8d626 100644
--- a/packages/eve/src/self-modification/extension/production-registry-add.ts
+++ b/packages/eve/src/self-modification/remote/production-registry-add.ts
@@ -5,7 +5,7 @@ import { shellQuote } from "#shared/shell-quote.js";
import type { PreparedSelfModificationWorkspace } from "../git-workspace.js";
import { gitOutput, runGitCommand } from "../git.js";
import { assertFullSha } from "../identifiers.js";
-import { readTerminalHeadlessEvent } from "./eve-add.js";
+import { readTerminalHeadlessEvent } from "../extension/eve-add.js";
const OFFICIAL_ADDRESS =
/^(?:(?:channel|connection|extension|instrumentation)\/)?[a-z0-9][a-z0-9._-]*$/u;
diff --git a/packages/eve/src/self-modification/remote/subagents/agent/agent.ts b/packages/eve/src/self-modification/remote/subagents/agent/agent.ts
new file mode 100644
index 000000000..18e7dc7c8
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/subagents/agent/agent.ts
@@ -0,0 +1,73 @@
+import type { DynamicResolveContext } from "#dynamic/definition.js";
+import {
+ defineAgent,
+ defineDynamic,
+ type DynamicSentinel,
+ type DynamicSubagentDefinition,
+} from "eve";
+
+import { DEFAULT_AGENT_MODEL_ID, DEFAULT_AGENT_REASONING } from "#shared/default-agent-model.js";
+
+import { hasGitHubCredential } from "../../../credentials.js";
+import { isDeployedRuntime } from "../../../mode.js";
+import {
+ followUpDelegation,
+ namedInstallationDelegation,
+ persistenceDelegation,
+ renderDescription,
+ repairDelegation,
+ sourceDelegation,
+} from "../../../subagent-guidance.js";
+import { resolveDeployedSelfModificationConfig } from "../../config.js";
+import selfModification from "../../extension.js";
+
+const integrationDelegation =
+ "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 effectiveEdits =
+ "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.";
+
+const description = renderDescription([
+ "Delegate here immediately when the user asks to change this eve agent or its authored source.",
+ sourceDelegation,
+ persistenceDelegation,
+ namedInstallationDelegation,
+ integrationDelegation,
+ followUpDelegation,
+ repairDelegation,
+ effectiveEdits,
+]);
+
+const resolve = async (_event: unknown, ctx: DynamicResolveContext) => {
+ if (!isDeployedRuntime()) return null;
+ const bound = selfModification.config;
+ const config = resolveDeployedSelfModificationConfig(bound);
+ if (config.credentials.kind === "pat" && !hasGitHubCredential()) return null;
+ try {
+ const authorized = await config.authorize({
+ channel: ctx.channel,
+ principal: ctx.session.auth.current,
+ });
+ if (!authorized) return null;
+ } catch {
+ return null;
+ }
+ const configuredModel = bound.model ?? ctx.model?.id;
+ return defineAgent({
+ description,
+ model: configuredModel ?? DEFAULT_AGENT_MODEL_ID,
+ reasoning:
+ bound.reasoning ?? (configuredModel === undefined ? DEFAULT_AGENT_REASONING : undefined),
+ });
+};
+
+/** Offers the deployed self-modification child only to authorized principals outside `eve dev`. */
+const deployedSelfModificationAgent: DynamicSentinel<DynamicSubagentDefinition | null> =
+ defineDynamic({
+ events: {
+ "session.started": resolve,
+ "turn.started": resolve,
+ },
+ });
+
+export default deployedSelfModificationAgent;
diff --git a/packages/eve/src/self-modification/remote/subagents/agent/instructions.ts b/packages/eve/src/self-modification/remote/subagents/agent/instructions.ts
new file mode 100644
index 000000000..597a2f122
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/subagents/agent/instructions.ts
@@ -0,0 +1,49 @@
+import { defineDynamic, defineInstructions } from "eve/instructions";
+
+import { isDeployedRuntime } from "../../../mode.js";
+import {
+ documentationInstructions,
+ registryWorkflowInstructions,
+ renderInstructions,
+ roleInstructions,
+ sourceEditingInstructions,
+ sourceWorkspaceInstructions,
+ toolAuthoringInstructions,
+ workingInstructions,
+} from "../../../subagent-guidance.js";
+
+const deployedGuidance = `## Deployed environment
+
+The 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.
+
+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.`;
+
+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.`;
+
+export default defineDynamic({
+ events: {
+ "session.started": () => {
+ if (!isDeployedRuntime()) return null;
+
+ return defineInstructions({
+ markdown: renderInstructions([
+ roleInstructions,
+ sourceWorkspaceInstructions,
+ sourceEditingInstructions,
+ toolAuthoringInstructions,
+ registryWorkflowInstructions,
+ documentationInstructions,
+ deployedGuidance,
+ workingInstructions,
+ deployedReportingGuidance,
+ ]),
+ });
+ },
+ },
+});
diff --git a/packages/eve/src/self-modification/remote/subagents/agent/sandbox.ts b/packages/eve/src/self-modification/remote/subagents/agent/sandbox.ts
new file mode 100644
index 000000000..dc8340f9d
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/subagents/agent/sandbox.ts
@@ -0,0 +1,4 @@
+import selfModification from "../../extension.js";
+import { defineDeployedSelfModificationSandbox } from "../../../deployed-sandbox.js";
+
+export default defineDeployedSelfModificationSandbox(selfModification.config);
diff --git a/packages/eve/src/self-modification/remote/subagents/agent/tools/edit_file.ts b/packages/eve/src/self-modification/remote/subagents/agent/tools/edit_file.ts
new file mode 100644
index 000000000..00d14304e
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/subagents/agent/tools/edit_file.ts
@@ -0,0 +1 @@
+export { default } from "../../../../extension/subagents/agent/tools/edit_file.js";
diff --git a/packages/eve/src/self-modification/extension/subagents/agent/tools/publish.ts b/packages/eve/src/self-modification/remote/subagents/agent/tools/publish.ts
similarity index 84%
rename from packages/eve/src/self-modification/extension/subagents/agent/tools/publish.ts
rename to packages/eve/src/self-modification/remote/subagents/agent/tools/publish.ts
index a405d92a2..ccd1392ed 100644
--- a/packages/eve/src/self-modification/extension/subagents/agent/tools/publish.ts
+++ b/packages/eve/src/self-modification/remote/subagents/agent/tools/publish.ts
@@ -1,11 +1,11 @@
import { defineDynamic, defineTool, type ToolContext } from "eve/tools";
-import { resolveSelfModificationConfig } from "../../../../config.js";
import { createGitHubCredentialProvider } from "../../../../credentials.js";
import { readPreparedSelfModificationWorkspace } from "../../../../git-workspace.js";
import { publishGitHubDraftPullRequest } from "../../../../github-publisher.js";
-import { resolveSelfModificationMode } from "../../../../mode.js";
+import { isDeployedRuntime } from "../../../../mode.js";
import { withSelfModificationWorkspaceLock } from "../../../../workspace-lock.js";
+import { resolveDeployedSelfModificationConfig } from "../../../config.js";
import selfModification from "../../../extension.js";
const inputSchema = {
@@ -56,9 +56,7 @@ const outputSchema = {
} as const;
function resolveTool() {
- const config = resolveSelfModificationConfig(selfModification.config);
- if (resolveSelfModificationMode(config) !== "deployed" || config.deployed === undefined)
- return null;
+ if (!isDeployedRuntime()) return null;
return defineTool({
description:
"Publish the complete validated agent source change as one draft pull request. Merge and deployment do not occur.",
@@ -81,11 +79,10 @@ async function publish(input: unknown, toolContext: ToolContext) {
) {
throw new Error("Production publication requires a valid title and summary.");
}
- const config = resolveSelfModificationConfig(selfModification.config);
- if (resolveSelfModificationMode(config) !== "deployed" || config.deployed === undefined) {
- throw new Error("Production publication requires deployed self-modification configuration.");
+ if (!isDeployedRuntime()) {
+ throw new Error("Production publication is unavailable during eve dev.");
}
- const deployed = config.deployed;
+ const deployed = resolveDeployedSelfModificationConfig(selfModification.config);
const summary = input.summary;
const title = input.title;
const operationId = publicationOperationId(toolContext);
diff --git a/packages/eve/src/self-modification/remote/subagents/agent/tools/registry_add.ts b/packages/eve/src/self-modification/remote/subagents/agent/tools/registry_add.ts
new file mode 100644
index 000000000..4198b93e1
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/subagents/agent/tools/registry_add.ts
@@ -0,0 +1,185 @@
+import { defineDynamic, defineTool, type ToolContext } from "eve/tools";
+
+import { classifyCatalogEntry } from "../../../../extension/classify-registry-item.js";
+import {
+ loadRegistryIndex,
+ officialRegistryIndexUrl,
+} from "../../../../extension/subagents/agent/tools/search_registry.js";
+import { readPreparedSelfModificationWorkspace } from "../../../../git-workspace.js";
+import { isDeployedRuntime } from "../../../../mode.js";
+import { withSelfModificationWorkspaceLock } from "../../../../workspace-lock.js";
+import {
+ resolveDeployedSelfModificationConfig,
+ type ResolvedDeployedSelfModificationConfig,
+} from "../../../config.js";
+import selfModification from "../../../extension.js";
+import {
+ assertOfficialRegistryAddress,
+ installProductionRegistryItem,
+} from "../../../production-registry-add.js";
+
+/**
+ * Production installation mutates only the disposable proposal checkout. It is
+ * restricted to the official registry, supports resumable non-secret setup and
+ * external authorization boundaries, and reports paths destined for the draft
+ * pull request rather than claiming that those changes are deployed.
+ */
+const productionInputSchema = {
+ type: "object",
+ additionalProperties: false,
+ properties: {
+ address: {
+ type: "string",
+ minLength: 1,
+ maxLength: 200,
+ description:
+ "Exact official eve registry address, for example `channel/slack` or `extension/browserbase`.",
+ },
+ answers: {
+ type: "object",
+ additionalProperties: true,
+ description: "Non-secret answers to the setup question returned by the previous call.",
+ },
+ installed: {
+ type: "boolean",
+ description:
+ "Set to true with answers when the previous input-required result installed the source.",
+ },
+ },
+ required: ["address"],
+} as const;
+
+const productionOutputSchema = {
+ type: "object",
+ additionalProperties: false,
+ properties: {
+ status: {
+ type: "string",
+ enum: ["completed", "input-required", "external-action-required", "failed", "cancelled"],
+ },
+ address: { type: "string" },
+ changedPaths: {
+ type: "array",
+ items: { type: "string" },
+ description: "Repository-relative paths installed into the proposal.",
+ },
+ completedItems: { type: "array", items: { type: "string" } },
+ deploymentRequired: { type: "boolean" },
+ installed: {
+ type: "boolean",
+ description: "Whether source installation completed before setup paused.",
+ },
+ question: {
+ type: "object",
+ additionalProperties: true,
+ description:
+ "The current setup question. Supply only its non-secret answer on the next call.",
+ },
+ message: { type: "string" },
+ url: { type: "string", description: "External authorization URL the developer must open." },
+ userCode: { type: "string" },
+ },
+ required: ["status", "address"],
+} as const;
+
+type ProductionRegistryAddResult =
+ | {
+ readonly address: string;
+ readonly status: "completed";
+ readonly completedItems: readonly string[];
+ readonly changedPaths: readonly string[];
+ readonly deploymentRequired: boolean;
+ }
+ | {
+ readonly address: string;
+ readonly status: "input-required";
+ readonly installed: boolean;
+ readonly question: unknown;
+ }
+ | {
+ readonly address: string;
+ readonly status: "external-action-required";
+ readonly installed: boolean;
+ readonly message: string;
+ readonly url: string;
+ readonly userCode?: string;
+ }
+ | { readonly address: string; readonly status: "failed" | "cancelled"; readonly message: string };
+
+async function addProductionRegistryItem(
+ address: string,
+ context: ToolContext,
+ deployed: ResolvedDeployedSelfModificationConfig,
+ continuation: {
+ readonly answers?: Readonly<Record<string, unknown>>;
+ readonly installed?: boolean;
+ },
+): Promise<ProductionRegistryAddResult> {
+ assertOfficialRegistryAddress(address);
+ const entries = await loadRegistryIndex({
+ nowMs: Date.now(),
+ signal: context.abortSignal,
+ url: officialRegistryIndexUrl(),
+ });
+ const entry = entries.find((candidate) => candidate.address === address);
+ if (entry === undefined) {
+ throw new Error(`No official eve registry item is published at "${address}".`);
+ }
+ const classification = classifyCatalogEntry(entry);
+ if (classification.kind === "self-modification-mount") {
+ throw new Error(classification.reason);
+ }
+ const sandbox = await context.getSandbox();
+ const result = await withSelfModificationWorkspaceLock(
+ `sandbox:${context.session.id}`,
+ async () => {
+ const workspace = await readPreparedSelfModificationWorkspace({ ...deployed, sandbox });
+ return await installProductionRegistryItem({
+ address,
+ answers: continuation.answers,
+ installed: continuation.installed,
+ sandbox,
+ signal: context.abortSignal,
+ workspace,
+ });
+ },
+ );
+ if (result.kind === "completed") return { address, ...result, status: "completed" };
+ if (result.kind === "input-required") return { address, ...result, status: "input-required" };
+ if (result.kind === "external-action-required")
+ return { address, ...result, status: "external-action-required" };
+ return { address, ...result, status: result.kind };
+}
+
+export function productionRegistryAddTool(deployed: ResolvedDeployedSelfModificationConfig) {
+ return defineTool({
+ description:
+ "Install an exact item from the official eve registry into the current production change proposal. If setup pauses, call this tool again with the non-secret answers and the installed state from its result. External authorization and secret binding must be completed by the developer.",
+ inputSchema: productionInputSchema,
+ outputSchema: productionOutputSchema,
+ async execute(input, ctx) {
+ const { address } = input;
+ if (typeof address !== "string" || address.length === 0) {
+ throw new Error("address must be an exact item address from the official eve registry.");
+ }
+ const answers =
+ "answers" in input &&
+ typeof input.answers === "object" &&
+ input.answers !== null &&
+ !Array.isArray(input.answers)
+ ? (input.answers as Record<string, unknown>)
+ : undefined;
+ const installed = "installed" in input && input.installed === true;
+ return await addProductionRegistryItem(address, ctx, deployed, { answers, installed });
+ },
+ });
+}
+
+export default defineDynamic({
+ events: {
+ "session.started": () =>
+ isDeployedRuntime()
+ ? productionRegistryAddTool(resolveDeployedSelfModificationConfig(selfModification.config))
+ : null,
+ },
+});
diff --git a/packages/eve/src/self-modification/remote/subagents/agent/tools/search_models.ts b/packages/eve/src/self-modification/remote/subagents/agent/tools/search_models.ts
new file mode 100644
index 000000000..0f54e0309
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/subagents/agent/tools/search_models.ts
@@ -0,0 +1 @@
+export { default } from "../../../../extension/subagents/agent/tools/search_models.js";
diff --git a/packages/eve/src/self-modification/remote/subagents/agent/tools/search_registry.ts b/packages/eve/src/self-modification/remote/subagents/agent/tools/search_registry.ts
new file mode 100644
index 000000000..5a8e57418
--- /dev/null
+++ b/packages/eve/src/self-modification/remote/subagents/agent/tools/search_registry.ts
@@ -0,0 +1 @@
+export { default } from "../../../../extension/subagents/agent/tools/search_registry.js";
diff --git a/packages/eve/src/self-modification/sandbox.ts b/packages/eve/src/self-modification/sandbox.ts
index 00f13d133..b6a6f5215 100644
--- a/packages/eve/src/self-modification/sandbox.ts
+++ b/packages/eve/src/self-modification/sandbox.ts
@@ -4,17 +4,11 @@ import {
type SandboxSelectorContext,
} from "#public/definitions/sandbox.js";
import { JustBashSandbox } from "#sandbox/providers/just-bash.js";
-import { MicrosandboxSandbox } from "#sandbox/providers/microsandbox.js";
-import { SANDBOX_PROVIDER_PROBES, type DefaultSandboxProbes } from "#sandbox/providers/default.js";
-import { VercelSandbox } from "#sandbox/providers/vercel.js";
import { bindSandboxEnvironment } from "#shared/sandbox-environment.js";
-import { shellQuote } from "#shared/shell-quote.js";
+
import { resolveSelfModificationConfig, type SelfModificationConfig } from "./config.js";
-import { createGitHubCredentialProvider } from "./credentials.js";
import { createSelfModificationFilesystem } from "./filesystem.js";
-import { prepareSelfModificationWorkspace, REPOSITORY_PATH } from "./git-workspace.js";
-import { resolveSelfModificationMode } from "./mode.js";
-import { SELF_MODIFICATION_BASELINE_NETWORK_POLICY } from "./network-policy.js";
+import { isLocalSelfModificationEnabled } from "./mode.js";
export interface SelfModificationSandboxOptions {
readonly config?: SelfModificationConfig;
@@ -24,77 +18,17 @@ export interface SelfModificationSandbox {
(context: SandboxSelectorContext): Promise<RuntimeSandboxSession> | RuntimeSandboxSession;
}
-type Probes = Pick<DefaultSandboxProbes, "isDeployedOnVercel" | "isMicrosandboxSupported">;
-type DeployedSelfModificationEnvironment =
- | ReturnType<typeof MicrosandboxSandbox.environment>
- | ReturnType<typeof VercelSandbox.environment>;
-
+/** Defines the local self-modification sandbox; source mounts exist only during development. */
export function defineSelfModificationSandbox(
options: SelfModificationSandboxOptions = {},
): SelfModificationSandbox {
- const config = resolveSelfModificationConfig(options.config);
- const mode = resolveSelfModificationMode(config);
- if (mode !== "deployed") {
- const environment =
- mode === "local"
- ? JustBashSandbox.environment({ filesystem: createSelfModificationFilesystem })
- : JustBashSandbox.environment();
- return bindSandboxEnvironment(
- defineSandbox(() => environment.open()),
- environment,
- );
- }
-
- const environment = selectDeployedSelfModificationEnvironment(SANDBOX_PROVIDER_PROBES);
+ const environment = isLocalSelfModificationEnabled(resolveSelfModificationConfig(options.config))
+ ? JustBashSandbox.environment({ filesystem: createSelfModificationFilesystem })
+ : JustBashSandbox.environment();
return bindSandboxEnvironment(
- defineSandbox(async ({ session }) => {
- const sandbox = await environment.open({
- networkPolicy: SELF_MODIFICATION_BASELINE_NETWORK_POLICY,
- });
- if (config.deployed === undefined) return sandbox;
- if (session.parent === undefined)
- throw new Error("Production self-modification requires a child session.");
- if (sandbox.setNetworkPolicy === undefined) {
- throw new Error("Production self-modification requires mutable sandbox network policy.");
- }
- const capableSandbox = { ...sandbox, setNetworkPolicy: sandbox.setNetworkPolicy };
- const deployed = config.deployed;
- const token = await createGitHubCredentialProvider(deployed.credentials).resolve({
- capability: "checkout",
- repository: deployed.repository,
- });
- await prepareSelfModificationWorkspace({
- directory: deployed.directory,
- repository: deployed.repository,
- sandbox: capableSandbox,
- targetBranch: deployed.targetBranch,
- token,
- });
- const root =
- deployed.directory === "." ? REPOSITORY_PATH : `${REPOSITORY_PATH}/${deployed.directory}`;
- const result = await sandbox.run({
- command: `rm -rf /source && ln -s ${shellQuote(`${root}/agent`)} /source`,
- });
- if (result.exitCode !== 0)
- throw new Error("Self-modification could not mount the agent source.");
- return sandbox;
- }),
+ defineSandbox(() => environment.open()),
environment,
);
}
-export function selectDeployedSelfModificationEnvironment(
- probes: Probes,
-): DeployedSelfModificationEnvironment {
- if (probes.isDeployedOnVercel()) {
- return VercelSandbox.environment();
- }
- if (probes.isMicrosandboxSupported()) {
- return MicrosandboxSandbox.environment();
- }
- throw new Error(
- "Deployed self-modification requires runtime credential transforms. No supported provider is available. Use Vercel Sandbox or microsandbox on a supported self-hosted system.",
- );
-}
-
export default defineSelfModificationSandbox();
diff --git a/packages/eve/src/self-modification/scaffold.ts b/packages/eve/src/self-modification/scaffold.ts
index adabbe6bd..07d02e354 100644
--- a/packages/eve/src/self-modification/scaffold.ts
+++ b/packages/eve/src/self-modification/scaffold.ts
@@ -1,4 +1,4 @@
/** Default authored mount for locally configured self-modification. */
export function renderLocalSelfModificationExtension(): string {
- return `import selfModification from "eve/self-modification";\n\nexport default selfModification({\n // model: "provider/model",\n // reasoning: "high",\n});\n`;
+ return `import selfModification from "eve/self-modification/local";\n\nexport default selfModification({\n // model: "provider/model",\n // reasoning: "high",\n});\n`;
}
diff --git a/packages/eve/src/self-modification/setup.test.ts b/packages/eve/src/self-modification/setup.test.ts
index 0263dad92..1335feebf 100644
--- a/packages/eve/src/self-modification/setup.test.ts
+++ b/packages/eve/src/self-modification/setup.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, it, vi } from "vitest";
import { win32 } from "node:path";
import { runInNewContext } from "node:vm";
-import { defineSelfModificationConfig } from "./config.js";
+import type { DeployedSelfModificationConfig } from "./remote/config.js";
import { captureVercel, runVercelCaptureStdout } from "#setup/primitives/run-vercel.js";
@@ -21,25 +21,31 @@ function evaluateGeneratedConfig(source: string, getToken = vi.fn()) {
return runInNewContext(
source
.replace('import { getToken } from "@vercel/connect";', "")
- .replace('import { defineSelfModificationConfig } from "eve/self-modification/config";', "")
- .replace('import selfModification from "eve/self-modification";', "")
- .replace("export default ", "")
- .replace("selfModification(", "defineSelfModificationConfig("),
+ .replace('import selfModification from "eve/self-modification/remote";', "")
+ .replace("export default ", ""),
{
- defineSelfModificationConfig,
getToken,
process: { env: { VERCEL_PROJECT_ID: "prj_123" } },
+ selfModification: (config: DeployedSelfModificationConfig) => config,
},
- ) as ReturnType<typeof defineSelfModificationConfig>;
+ ) as DeployedSelfModificationConfig;
}
describe("self-modification setup", () => {
it("recognizes default local configurations", () => {
expect(renderSelfModificationConfig()).toContain(
- 'import selfModification from "eve/self-modification";',
+ 'import selfModification from "eve/self-modification/local";',
);
expect(renderSelfModificationConfig()).toContain('// model: "provider/model"');
expect(classifySelfModificationConfig(renderSelfModificationConfig())).toBe("local");
+ expect(
+ classifySelfModificationConfig(
+ renderSelfModificationConfig().replace(
+ '"eve/self-modification/local"',
+ '"eve/self-modification"',
+ ),
+ ),
+ ).toBe("local");
expect(
classifySelfModificationConfig(
'import { defineSelfModificationConfig } from "eve/self-modification/config";\n\nexport default defineSelfModificationConfig({});\n',
@@ -60,7 +66,8 @@ describe("self-modification setup", () => {
expect(source).toContain('directory: "apps/support"');
expect(source).toContain('target: { branch: "release/production" }');
expect(source).toContain('import { getToken } from "@vercel/connect"');
- expect(source).toContain('import selfModification from "eve/self-modification"');
+ expect(source).toContain('import selfModification from "eve/self-modification/remote"');
+ expect(source).not.toContain("deployed: {");
expect(source).toContain('return await getToken("github/selfmod-acme-agents"');
expect(source).toContain("async resolve({ capability, repository })");
expect(source).toContain('case "http"');
@@ -72,7 +79,7 @@ describe("self-modification setup", () => {
"// Authorize trusted principals for this channel before returning true.\n return false;",
);
expect(source).toContain(
- "// Add another branch when you add a trusted channel.\n return false;",
+ "// Add another branch when you add a trusted channel.\n return false;",
);
expect(source).not.toContain("authorize: () => false");
expect(source).not.toContain("EVE_SELF_MODIFICATION_GITHUB_TOKEN");
@@ -90,7 +97,7 @@ describe("self-modification setup", () => {
});
const getToken = vi.fn().mockResolvedValue("github-token");
const config = evaluateGeneratedConfig(source, getToken);
- const credentials = config.deployed?.credentials;
+ const credentials = config.credentials;
if (credentials === undefined || "pat" in credentials) {
throw new Error("Expected generated credential provider.");
}
@@ -125,7 +132,7 @@ describe("self-modification setup", () => {
});
const failure = new Error("connector is not attached");
const config = evaluateGeneratedConfig(source, vi.fn().mockRejectedValue(failure));
- const credentials = config.deployed?.credentials;
+ const credentials = config.credentials;
if (credentials === undefined || "pat" in credentials) {
throw new Error("Expected generated credential provider.");
}
@@ -160,7 +167,7 @@ describe("self-modification setup", () => {
vercelBackend: true,
});
const config = evaluateGeneratedConfig(source);
- const authorize = config.deployed!.authorize;
+ const authorize = config.authorize;
const principal = {
attributes: { project_id: "prj_123" },
authenticator: "oidc",
@@ -200,7 +207,7 @@ describe("self-modification setup", () => {
expect(source).not.toContain('case "channel:');
expect(source).not.toContain("VERCEL_PROJECT_ID");
expect(source).toContain(
- "switch (channel.kind) {\n default:\n // Add another branch when you add a trusted channel.",
+ "switch (channel.kind) {\n default:\n // Add another branch when you add a trusted channel.",
);
});
diff --git a/packages/eve/src/self-modification/setup.ts b/packages/eve/src/self-modification/setup.ts
index 8271ee178..8986dca86 100644
--- a/packages/eve/src/self-modification/setup.ts
+++ b/packages/eve/src/self-modification/setup.ts
@@ -13,14 +13,21 @@ import {
} from "#setup/primitives/run-vercel.js";
import type { VercelProjectReference } from "#setup/project-resolution.js";
-import { SELF_MODIFICATION_CONFIG_PATH } from "./git-workspace.js";
import { renderLocalSelfModificationExtension } from "./scaffold.js";
+export const SELF_MODIFICATION_CONFIG_PATH = "agent/extensions/self-modification/extension.ts";
+export const DEPLOYED_SELF_MODIFICATION_CONFIG_PATH =
+ "agent/extensions/self-modification-remote/extension.ts";
+
const runFile = promisify(execFile);
const GENERATED_MARKER = "// eve-self-modification: generated-v1";
const LEGACY_LOCAL_CONFIG =
'import { defineSelfModificationConfig } from "eve/self-modification/config";\n\nexport default defineSelfModificationConfig({});\n';
const DEFAULT_EXTENSION = renderLocalSelfModificationExtension();
+const LEGACY_DEFAULT_EXTENSION = DEFAULT_EXTENSION.replace(
+ '"eve/self-modification/local"',
+ '"eve/self-modification"',
+);
export interface SelfModificationSetupValues {
readonly branch: string;
@@ -42,7 +49,11 @@ export interface SelfModificationSetupOperations {
detectChannelNames(): Promise<readonly string[]>;
detectGitRepository(): Promise<DetectedGitRepository>;
findOrCreateConnector(name: string, project: VercelProjectReference): Promise<string>;
+ /** Reads the deployed mount at {@link DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}. */
readConfig(): Promise<string | undefined>;
+ /** Reads the local mount at {@link SELF_MODIFICATION_CONFIG_PATH}. */
+ readLocalConfig(): Promise<string | undefined>;
+ /** Writes the deployed mount at {@link DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}. */
writeConfig(source: string): Promise<void>;
}
@@ -72,62 +83,60 @@ export function renderSelfModificationConfig(values?: SelfModificationSetupValue
)
.join("\n");
const httpCase = values.vercelBackend
- ? ` case "http": {
- const projectId = process.env.VERCEL_PROJECT_ID;
- return (
- projectId !== undefined &&
- projectId.length > 0 &&
- principal?.authenticator === "oidc" &&
- (principal.issuer === "https://oidc.vercel.com" ||
- principal.issuer?.startsWith("https://oidc.vercel.com/") === true) &&
- principal.attributes.project_id === projectId
- );
- }
+ ? ` case "http": {
+ const projectId = process.env.VERCEL_PROJECT_ID;
+ return (
+ projectId !== undefined &&
+ projectId.length > 0 &&
+ principal?.authenticator === "oidc" &&
+ (principal.issuer === "https://oidc.vercel.com" ||
+ principal.issuer?.startsWith("https://oidc.vercel.com/") === true) &&
+ principal.attributes.project_id === projectId
+ );
+ }
`
: "";
const switchCases = `${httpCase}${channelCases}`;
const credentialErrorMessage = `Self-modification could not obtain a GitHub credential from Vercel Connect for ${values.connector}. Install and attach the configured GitHub connector to this Vercel project, install the managed GitHub App for the configured repository, then retry.`;
const body = `import { getToken } from "@vercel/connect";
-import selfModification from "eve/self-modification";
+import selfModification from "eve/self-modification/remote";
export default selfModification({
- deployed: {
- source: {
- git: {
- repository: ${JSON.stringify(values.repository)},
- directory: ${JSON.stringify(values.directory)},
- },
+ source: {
+ git: {
+ repository: ${JSON.stringify(values.repository)},
+ directory: ${JSON.stringify(values.directory)},
},
- target: { branch: ${JSON.stringify(values.branch)} },
- credentials: {
- async resolve({ capability, repository }) {
- try {
- return await getToken(${JSON.stringify(values.connector)}, {
- authorizationDetails: [
- {
- type: "github_app_installation",
- repositories: [repository.owner + "/" + repository.repo],
- },
- ],
- scopes:
- capability === "checkout"
- ? ["contents:read", "metadata:read"]
- : ["contents:write", "pull_requests:write", "metadata:read"],
- subject: { type: "app" },
- });
- } catch (error) {
- throw new Error(${JSON.stringify(credentialErrorMessage)}, { cause: error });
- }
- },
- },
- authorize: ({ channel, principal }) => {
- switch (channel.kind) {
-${switchCases} default:
- // Add another branch when you add a trusted channel.
- return false;
+ },
+ target: { branch: ${JSON.stringify(values.branch)} },
+ credentials: {
+ async resolve({ capability, repository }) {
+ try {
+ return await getToken(${JSON.stringify(values.connector)}, {
+ authorizationDetails: [
+ {
+ type: "github_app_installation",
+ repositories: [repository.owner + "/" + repository.repo],
+ },
+ ],
+ scopes:
+ capability === "checkout"
+ ? ["contents:read", "metadata:read"]
+ : ["contents:write", "pull_requests:write", "metadata:read"],
+ subject: { type: "app" },
+ });
+ } catch (error) {
+ throw new Error(${JSON.stringify(credentialErrorMessage)}, { cause: error });
}
},
},
+ authorize: ({ channel, principal }) => {
+ switch (channel.kind) {
+${switchCases} default:
+ // Add another branch when you add a trusted channel.
+ return false;
+ }
+ },
});
`;
return `${GENERATED_MARKER} digest:${createHash("sha256").update(body).digest("hex")}\n${body}`;
@@ -138,7 +147,13 @@ export function classifySelfModificationConfig(
source: string | undefined,
): "missing" | "local" | "generated" | "authored" {
if (source === undefined) return "missing";
- if (source === renderSelfModificationConfig() || source === LEGACY_LOCAL_CONFIG) return "local";
+ if (
+ source === DEFAULT_EXTENSION ||
+ source === LEGACY_DEFAULT_EXTENSION ||
+ source === LEGACY_LOCAL_CONFIG
+ ) {
+ return "local";
+ }
const [marker, ...body] = source.split("\n");
const match = /^\/\/ eve-self-modification: generated-v1 digest:([a-f0-9]{64})$/u.exec(
marker ?? "",
@@ -164,7 +179,7 @@ export function defaultSelfModificationSetupOperations(
deps: SelfModificationSetupDependencies = defaultDependencies,
projectRoot: string = appRoot,
): SelfModificationSetupOperations {
- const configPath = join(appRoot, SELF_MODIFICATION_CONFIG_PATH);
+ const configPath = join(appRoot, DEPLOYED_SELF_MODIFICATION_CONFIG_PATH);
return {
async detectChannelNames() {
const discovered = await discoverAgent({ appRoot, agentRoot: join(appRoot, "agent") });
@@ -193,14 +208,8 @@ export function defaultSelfModificationSetupOperations(
remote === undefined ? "missing" : repository === undefined ? "other" : "github",
};
},
- async readConfig() {
- try {
- return await readFile(configPath, "utf8");
- } catch (error) {
- if ((error as NodeJS.ErrnoException).code === "ENOENT") return undefined;
- throw error;
- }
- },
+ readConfig: () => readOptionalFile(configPath),
+ readLocalConfig: () => readOptionalFile(join(appRoot, SELF_MODIFICATION_CONFIG_PATH)),
async writeConfig(source) {
await mkdir(join(configPath, ".."), { recursive: true });
await writeFile(configPath, source, "utf8");
@@ -247,6 +256,15 @@ export function defaultSelfModificationSetupOperations(
};
}
+async function readOptionalFile(path: string): Promise<string | undefined> {
+ try {
+ return await readFile(path, "utf8");
+ } catch (error) {
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return undefined;
+ throw error;
+ }
+}
+
function parseCreatedConnector(stdout: string): string | undefined {
try {
const value = JSON.parse(stdout) as { uid?: unknown };
diff --git a/packages/eve/src/self-modification/subagent-guidance.ts b/packages/eve/src/self-modification/subagent-guidance.ts
new file mode 100644
index 000000000..dfb4abb04
--- /dev/null
+++ b/packages/eve/src/self-modification/subagent-guidance.ts
@@ -0,0 +1,70 @@
+/** Delegation and instruction text shared by the local and deployed self-modification children. */
+
+export function renderDescription(sections: readonly string[]): string {
+ return sections.filter((section) => section.length > 0).join(" ");
+}
+
+export function renderInstructions(sections: readonly string[]): string {
+ return sections.filter((section) => section.length > 0).join("\n\n");
+}
+
+export 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.";
+
+export 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.";
+
+export const namedInstallationDelegation =
+ "Treat questions phrased as whether you can install, add, enable, or connect to a named product or service as requests to extend this eve agent and delegate immediately. Do not assume they refer to device software, ask what kind of installation they mean, or deny them because you lack access to the user's device. The subagent determines whether the request maps to an integration, channel, connection, or other capability, then checks registry availability and any required setup.";
+
+export const followUpDelegation =
+ "Resolve short follow-ups such as “yes” or “do it” against the preceding conversation. " +
+ "If whether the requested change should persist is genuinely ambiguous, ask one concise clarifying question.";
+
+export const repairDelegation =
+ "If a tool or capability created or changed by this subagent later fails or behaves incorrectly, explain the observed problem and offer to delegate a repair. " +
+ "Do not start the repair until the user confirms. Treat that confirmation as a source-modification request and delegate it immediately, including the exact identifier, failing behavior, expected behavior, and existing constraints.";
+
+export const roleInstructions = `## Role
+
+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.`;
+
+export const sourceWorkspaceInstructions = `## Source workspace
+
+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. edit_file instead validates exact matches against current contents. Never modify source files with bash, sed, awk, redirection, or scripting.
+
+Resolve named tools by filename under /source/tools before searching contents. Tool identifiers derive from filenames and may not occur in the implementation.`;
+
+export const sourceEditingInstructions = `## Implement changes
+
+Use 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.
+
+Once paths are known, batch independent file reads and edits to different files. Never edit the same file concurrently.`;
+
+export const toolAuthoringInstructions = `## Add model-callable actions
+
+When the requester wants this agent to gain a reusable action or capability that it can invoke in future turns, implement it as an authored eve tool under /source/tools. This applies even when the request describes the action without using the word “tool.” Follow the path-derived naming and defineTool conventions in the mounted eve tools documentation and existing source.
+
+Do not substitute a loose Python, shell, or JavaScript file for a model-callable tool. A support script is acceptable only when an authored eve tool invokes it as an implementation detail, or when the requester explicitly asks for a standalone script instead of an agent capability.`;
+
+export const registryWorkflowInstructions = `## Add integrations
+
+Before adding a new eve-managed channel, connection, extension, instrumentation, or memory integration, call search_registry alongside source discovery. If an item fulfills the requirement, install it with 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.
+
+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 registry_add separately from file edits and other registry installations.
+
+Registry installation is outside the source sandbox.`;
+
+export const documentationInstructions = `## Consult documentation
+
+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.`;
+
+export const workingInstructions = `## 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.`;
diff --git a/packages/eve/src/setup/integrations/self-modification/setup.test.ts b/packages/eve/src/setup/integrations/self-modification/setup.test.ts
index 7573047dd..f1f79bd9b 100644
--- a/packages/eve/src/setup/integrations/self-modification/setup.test.ts
+++ b/packages/eve/src/setup/integrations/self-modification/setup.test.ts
@@ -33,6 +33,7 @@ function operations(config?: string): SelfModificationSetupOperations & {
})),
findOrCreateConnector: vi.fn(async () => "github/selfmod-acme-agents"),
readConfig: vi.fn(async () => config),
+ readLocalConfig: vi.fn(async () => config),
writeConfig: vi.fn(async () => {}),
};
}
@@ -156,6 +157,9 @@ describe("self-modification integration setup", () => {
expect(deps.installScaffoldDependencies).toHaveBeenCalledWith(
expect.objectContaining({ changed: true, projectPath: "/project" }),
);
+ expect(effects.writeConfig).toHaveBeenCalledWith(
+ expect.stringContaining('import selfModification from "eve/self-modification/remote"'),
+ );
expect(effects.writeConfig).toHaveBeenCalledWith(
expect.stringContaining('repository: "github.com/acme/agents"'),
);
diff --git a/packages/eve/src/setup/integrations/self-modification/setup.ts b/packages/eve/src/setup/integrations/self-modification/setup.ts
index 5770968a0..c696831b1 100644
--- a/packages/eve/src/setup/integrations/self-modification/setup.ts
+++ b/packages/eve/src/setup/integrations/self-modification/setup.ts
@@ -4,15 +4,16 @@ import { confirm, select, text } from "#setup/ask.js";
import {
classifySelfModificationConfig,
connectorName,
+ DEPLOYED_SELF_MODIFICATION_CONFIG_PATH,
defaultSelfModificationSetupOperations,
directoryError,
gitRefError,
renderSelfModificationConfig,
repositoryPartError,
+ SELF_MODIFICATION_CONFIG_PATH,
type SelfModificationSetupOperations,
type SelfModificationSetupValues,
} from "#self-modification/setup.js";
-import { SELF_MODIFICATION_CONFIG_PATH } from "#self-modification/git-workspace.js";
import {
detectLegacySelfModificationScaffold,
removeLegacySelfModificationScaffold,
@@ -99,7 +100,7 @@ export async function prepareSelfModificationSetup(
const existing = await operations.readConfig();
if (classifySelfModificationConfig(existing) === "authored") {
context.presenter.note(
- `The existing ${SELF_MODIFICATION_CONFIG_PATH} contains authored configuration and was not overwritten.`,
+ `The existing ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH} contains authored configuration and was not overwritten.`,
"Manual update required",
{ tone: "warning" },
);
@@ -182,7 +183,7 @@ export async function prepareSelfModificationSetup(
};
context.presenter.note(
renderSelfModificationConfig(values),
- `Generated ${SELF_MODIFICATION_CONFIG_PATH}`,
+ `Generated ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}`,
);
context.presenter.note(
"Vercel Connect will issue short-lived GitHub App credentials restricted to this repository. Install the managed GitHub App and select only this repository. Review, merge, and deployment remain separate operator boundaries.",
@@ -238,12 +239,12 @@ export async function applySelfModificationSetup(
signal: context.signal,
});
await operations.writeConfig(renderSelfModificationConfig({ ...plan.values, connector }));
- context.presenter.log.success(`Updated ${SELF_MODIFICATION_CONFIG_PATH}.`);
+ context.presenter.log.success(`Updated ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}.`);
context.presenter.nextSteps([
"Install the managed GitHub App for the configured repository, then deploy or redeploy.",
plan.values.vercelBackend
- ? "After deployment, try self-modification by running `eve dev <deployment-url>` from this linked project. The generated policy admits its Vercel OIDC identity over HTTP; configured channels remain denied until you update `agent/extensions/self-modification/extension.ts`."
- : "Before deployment, configure `deployed.authorize` in `agent/extensions/self-modification/extension.ts` to admit a trusted principal for your deployment's channel. After deployment, use that channel to try self-modification.",
+ ? `After deployment, try self-modification by running \`eve dev <deployment-url>\` from this linked project. The generated policy admits its Vercel OIDC identity over HTTP; configured channels remain denied until you update \`${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}\`.`
+ : `Before deployment, configure \`authorize\` in \`${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}\` to admit a trusted principal for your deployment's channel. After deployment, use that channel to try self-modification.`,
]);
return {
deploymentRequired: true as const,
@@ -265,7 +266,7 @@ export async function prepareLocalSelfModificationSetup(
),
): Promise<SelfModificationSetupPlan> {
const legacyScaffold = await prepareLegacyScaffoldCleanup(context);
- const existing = await operations.readConfig();
+ const existing = await operations.readLocalConfig();
if (classifySelfModificationConfig(existing) === "authored") {
context.presenter.note(
`The existing ${SELF_MODIFICATION_CONFIG_PATH} contains authored configuration and was not overwritten.`,