eve 0.72.1 → 0.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/src/channel/agent-description.d.ts +49 -9
- package/dist/src/channel/agent-description.js +1 -1
- package/dist/src/channel/invoke-tool.d.ts +26 -4
- package/dist/src/channel/invoke-tool.js +1 -1
- package/dist/src/channel/principal-identity.d.ts +9 -0
- package/dist/src/channel/principal-identity.js +1 -0
- package/dist/src/channel/prompt-queue.d.ts +31 -0
- package/dist/src/channel/prompt-queue.js +1 -0
- package/dist/src/channel/routes.d.ts +19 -4
- package/dist/src/channel/schedule.js +1 -1
- package/dist/src/channel/skill-files.d.ts +114 -0
- package/dist/src/channel/skill-files.js +1 -0
- package/dist/src/cli/commands/agent-instructions.js +1 -1
- package/dist/src/cli/commands/extension-init.js +1 -1
- package/dist/src/cli/commands/init-agent-workspace.js +1 -1
- package/dist/src/cli/commands/init-project.js +1 -1
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/diagnostic-dump.js +1 -1
- package/dist/src/cli/dev/tui/blocks.d.ts +6 -0
- package/dist/src/cli/dev/tui/blocks.js +2 -2
- package/dist/src/cli/dev/tui/markdown.d.ts +5 -0
- package/dist/src/cli/dev/tui/markdown.js +2 -2
- package/dist/src/cli/dev/tui/transcript-parts.d.ts +4 -1
- package/dist/src/cli/dev/tui/transcript-parts.js +2 -2
- package/dist/src/cli/dev/tui/transcript.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +8 -8
- package/dist/src/compiled/@eve/catalog/index.js +1 -1
- package/dist/src/compiled/@modelcontextprotocol/server/index.d.ts +68 -7
- package/dist/src/compiled/@workflow/core/capabilities.d.ts +33 -6
- package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/index.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +6 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +8 -8
- package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +13 -5
- package/dist/src/compiled/@workflow/core/serialization.d.ts +9 -9
- package/dist/src/compiled/@workflow/core/serialization.js +1 -1
- package/dist/src/compiled/@workflow/core/symbols.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/index.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/events.d.ts +11 -0
- package/dist/src/compiled/@workflow/world/hooks.d.ts +2 -0
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +6 -0
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +13 -13
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-VaTKT4K8.js → attribute-changes-CSqvJx6j.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-B7NC1c9-.js → dist-DmXynLVH.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/dist-T5NnW-0k.js +3 -0
- package/dist/src/compiled/_chunks/workflow/helpers-BXCuoPUb.js +1 -0
- package/dist/src/compiled/_chunks/workflow/private-Dlf90Zvn.js +1 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-CvENCrxc.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{run-DYKeqbob.js → run-8pLWuR2U.js} +6 -6
- package/dist/src/compiled/_chunks/workflow/serialization-vDozzDhh.js +16 -0
- package/dist/src/compiled/_chunks/workflow/sleep-BMqbraZM.js +1 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-A344L2AG.js +1 -0
- package/dist/src/compiled/shadcn-registry/index.js +3408 -35163
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/compile-agent.js +1 -1
- package/dist/src/compiler/development-extensions.js +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +6 -6
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/context/providers/session.js +1 -1
- package/dist/src/context/turn-principals.d.ts +12 -0
- package/dist/src/context/turn-principals.js +1 -0
- package/dist/src/evals/cli/eval-client.js +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/invoke-tool.d.ts +6 -2
- package/dist/src/execution/invoke-tool.js +1 -1
- package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
- package/dist/src/execution/node-step.d.ts +1 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-errors.d.ts +11 -0
- package/dist/src/execution/sandbox/bindings/vercel-errors.js +2 -1
- package/dist/src/execution/sandbox/bindings/vercel-tool-sessions.d.ts +7 -0
- package/dist/src/execution/sandbox/bindings/vercel-tool-sessions.js +1 -0
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/sandbox/development-lazy-prewarm.js +1 -1
- package/dist/src/execution/sandbox/ensure.d.ts +14 -1
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/execution/session/active-turn.d.ts +2 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/entry.d.ts +10 -1
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/program.d.ts +4 -0
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/timeout-control.d.ts +1 -2
- package/dist/src/execution/session/timeout-control.js +1 -1
- package/dist/src/execution/session/turn-control.d.ts +7 -0
- package/dist/src/execution/session/turn-control.js +1 -0
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +2 -0
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/tool-session/id.d.ts +22 -0
- package/dist/src/execution/tool-session/id.js +1 -0
- package/dist/src/execution/tool-session/sandbox.d.ts +22 -0
- package/dist/src/execution/tool-session/sandbox.js +1 -0
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/harness/hitl/approvals.d.ts +1 -1
- package/dist/src/harness/hitl/approvals.js +1 -1
- package/dist/src/harness/hitl/delivery.d.ts +9 -2
- package/dist/src/harness/hitl/delivery.js +1 -1
- package/dist/src/harness/hitl/intake.js +1 -1
- package/dist/src/harness/model-call/usage.js +1 -1
- package/dist/src/harness/open-input-request.d.ts +8 -0
- package/dist/src/harness/open-input-request.js +1 -0
- package/dist/src/harness/session-machine/current.js +1 -1
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/types.d.ts +2 -0
- package/dist/src/internal/application/cache-metadata.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/application/runtime-compiled-artifacts-source.js +1 -1
- package/dist/src/internal/authored-definition/connection.js +1 -1
- package/dist/src/internal/authored-module-loader.js +1 -1
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/invocation/metadata.js +1 -1
- package/dist/src/internal/mcp/forwarded-principal-header.d.ts +31 -0
- package/dist/src/internal/mcp/forwarded-principal-header.js +1 -0
- package/dist/src/internal/mcp/published-tools.d.ts +9 -2
- package/dist/src/internal/mcp/published-tools.js +1 -1
- package/dist/src/internal/mcp/skills.d.ts +57 -0
- package/dist/src/internal/mcp/skills.js +1 -0
- package/dist/src/internal/mcp/streamable-http-server.d.ts +38 -6
- package/dist/src/internal/mcp/streamable-http-server.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-extension.js +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-runner.js +1 -1
- package/dist/src/internal/nitro/host/local-tracing-runtime-plugin.js +1 -1
- package/dist/src/internal/nitro/host/skill-server-assets.d.ts +29 -0
- package/dist/src/internal/nitro/host/skill-server-assets.js +1 -0
- package/dist/src/internal/nitro/host/start-production-server.js +1 -1
- package/dist/src/internal/nitro/host/workspace-extensions.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-route-context.d.ts +4 -0
- package/dist/src/internal/nitro/routes/channel-route-context.js +1 -1
- package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/internal/workflow/validate-world.js +1 -1
- package/dist/src/internal/workflow/vercel-world-defaults.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.js +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/public/channels/chat-sdk/authorization.js +1 -1
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +7 -1
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
- package/dist/src/public/channels/discord/defaults.d.ts +8 -7
- package/dist/src/public/channels/discord/discordChannel.d.ts +21 -1
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/discord/index.d.ts +1 -1
- package/dist/src/public/channels/github/defaults.js +3 -3
- package/dist/src/public/channels/github/githubChannel.d.ts +4 -1
- package/dist/src/public/channels/github/state.d.ts +2 -1
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/linear/defaults.js +1 -1
- package/dist/src/public/channels/linear/linearChannel.d.ts +4 -1
- package/dist/src/public/channels/mcp.d.ts +26 -5
- package/dist/src/public/channels/mcp.js +1 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +6 -0
- package/dist/src/public/channels/twilio/defaults.js +2 -4
- package/dist/src/public/channels/twilio/twilioChannel.d.ts +4 -1
- package/dist/src/public/definitions/channel.d.ts +1 -1
- package/dist/src/public/definitions/connections/mcp.d.ts +11 -0
- package/dist/src/public/sveltekit/dev-server.js +1 -1
- package/dist/src/runtime/cache-key.js +1 -1
- package/dist/src/runtime/connections/mcp-client.js +1 -1
- package/dist/src/runtime/loaders/compile-metadata.js +1 -1
- package/dist/src/runtime/loaders/manifest.js +1 -1
- package/dist/src/runtime/loaders/module-map.js +1 -1
- package/dist/src/runtime/resolve-connection.js +1 -1
- package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -1
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/runtime/sessions/runtime-session.d.ts +10 -0
- package/dist/src/runtime/sessions/runtime-session.js +1 -1
- package/dist/src/runtime/types.d.ts +2 -0
- package/dist/src/self-modification/config.d.ts +4 -63
- package/dist/src/self-modification/config.js +1 -1
- package/dist/src/self-modification/credentials.d.ts +1 -1
- package/dist/src/self-modification/deployed-sandbox.d.ts +14 -0
- package/dist/src/self-modification/deployed-sandbox.js +1 -0
- package/dist/src/self-modification/extension/config-schema.d.ts +2 -17
- package/dist/src/self-modification/extension/config-schema.js +1 -1
- package/dist/src/self-modification/extension/local-only.d.ts +1 -1
- package/dist/src/self-modification/extension/local-only.js +1 -1
- package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +1 -1
- package/dist/src/self-modification/extension/subagents/agent/agent.js +1 -1
- package/dist/src/self-modification/extension/subagents/agent/instructions.js +3 -35
- package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.d.ts +3 -31
- package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.js +1 -1
- package/dist/src/self-modification/git-workspace.d.ts +1 -2
- package/dist/src/self-modification/git-workspace.js +1 -1
- package/dist/src/self-modification/github-publisher.d.ts +1 -1
- package/dist/src/self-modification/mode.d.ts +4 -4
- package/dist/src/self-modification/mode.js +1 -1
- package/dist/src/self-modification/proposal.js +1 -1
- package/dist/src/self-modification/remote/config-schema.d.ts +20 -0
- package/dist/src/self-modification/remote/config-schema.js +1 -0
- package/dist/src/self-modification/remote/config.d.ts +66 -0
- package/dist/src/self-modification/remote/config.js +1 -0
- package/dist/src/self-modification/remote/extension.d.ts +5 -0
- package/dist/src/self-modification/remote/extension.js +1 -0
- package/dist/src/self-modification/remote/production-registry-add.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/agent.d.ts +4 -0
- package/dist/src/self-modification/remote/subagents/agent/agent.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/instructions.d.ts +2 -0
- package/dist/src/self-modification/remote/subagents/agent/instructions.js +5 -0
- package/dist/src/self-modification/remote/subagents/agent/sandbox.d.ts +2 -0
- package/dist/src/self-modification/remote/subagents/agent/sandbox.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/edit_file.d.ts +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/edit_file.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/publish.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/registry_add.d.ts +32 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/registry_add.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/search_models.d.ts +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/search_models.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/search_registry.d.ts +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/search_registry.js +1 -0
- package/dist/src/self-modification/sandbox.d.ts +1 -6
- package/dist/src/self-modification/sandbox.js +1 -1
- package/dist/src/self-modification/scaffold.js +1 -1
- package/dist/src/self-modification/setup.d.ts +6 -0
- package/dist/src/self-modification/setup.js +46 -48
- package/dist/src/self-modification/subagent-guidance.d.ts +15 -0
- package/dist/src/self-modification/subagent-guidance.js +29 -0
- package/dist/src/services/dev-client/request-headers.js +1 -1
- package/dist/src/setup/flows/model-source-change.js +1 -1
- package/dist/src/setup/integrations/self-modification/setup.js +1 -1
- package/dist/src/setup/project-resolution.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/verified-remote-client.d.ts +3 -0
- package/dist/src/setup/verified-remote-client.js +1 -1
- package/dist/src/shared/framework-eve-server.js +1 -1
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tracing/invoke-tool-span.d.ts +1 -0
- package/docs/channels/chat-sdk.mdx +27 -0
- package/docs/channels/custom.mdx +5 -2
- package/docs/channels/discord.mdx +22 -0
- package/docs/channels/mcp.mdx +102 -4
- package/docs/channels/slack.mdx +1 -1
- package/docs/connections/mcp.mdx +19 -0
- package/docs/evals/targets.mdx +5 -1
- package/docs/guides/self-modification.md +50 -3
- package/docs/tools/human-in-the-loop.md +14 -2
- package/docs/tutorial/guard-the-spend.mdx +1 -1
- package/package.json +25 -7
- package/dist/src/compiled/@workflow/core/runtime/vm-serde-bundle.generated.d.ts +0 -14
- package/dist/src/compiled/_chunks/workflow/dist-CaNNONeg.js +0 -3
- package/dist/src/compiled/_chunks/workflow/global-DKbOgrts.js +0 -1
- package/dist/src/compiled/_chunks/workflow/helpers-CP9TjeO8.js +0 -1
- package/dist/src/compiled/_chunks/workflow/logger-oqfblE3p.js +0 -14
- package/dist/src/compiled/_chunks/workflow/resume-hook-yq-NAdBu.js +0 -1
- package/dist/src/compiled/_chunks/workflow/serialization-APSKphN5.js +0 -3
- package/dist/src/compiled/_chunks/workflow/sleep-Ba8SExMt.js +0 -1
- package/dist/src/compiled/_chunks/workflow/wait-until-Dc9s3yyP.js +0 -1
- package/dist/src/self-modification/extension/production-registry-add.js +0 -1
- package/dist/src/self-modification/extension/subagents/agent/tools/publish.js +0 -1
- /package/dist/src/self-modification/{extension → remote}/production-registry-add.d.ts +0 -0
- /package/dist/src/self-modification/{extension → remote}/subagents/agent/tools/publish.d.ts +0 -0
|
@@ -1,62 +1,60 @@
|
|
|
1
|
-
import{renderLocalSelfModificationExtension}from"./scaffold.js";import{
|
|
1
|
+
import{renderLocalSelfModificationExtension}from"./scaffold.js";import{createHash}from"node:crypto";import{mkdir,readFile,writeFile}from"node:fs/promises";import{join,relative}from"node:path";import{execFile}from"node:child_process";import{promisify}from"node:util";import{stripLogicalPathExtension}from"#discover/filesystem.js";import{captureVercel,runVercelCaptureStdout}from"#setup/primitives/run-vercel.js";import{discoverAgent}from"#discover/discover-agent.js";const SELF_MODIFICATION_CONFIG_PATH=`agent/extensions/self-modification/extension.ts`,DEPLOYED_SELF_MODIFICATION_CONFIG_PATH=`agent/extensions/self-modification-remote/extension.ts`,runFile=promisify(execFile),DEFAULT_EXTENSION=renderLocalSelfModificationExtension(),LEGACY_DEFAULT_EXTENSION=DEFAULT_EXTENSION.replace(`"eve/self-modification/local"`,`"eve/self-modification"`),defaultDependencies={captureVercel,runVercelCaptureStdout};function connectorName(e,t){return`selfmod-${e}-${t}`.toLowerCase().replaceAll(/[^a-z0-9-]/gu,`-`)}function renderSelfModificationConfig(e){if(e===void 0)return DEFAULT_EXTENSION;let t=[...new Set(e.channelNames)].filter(e=>e!==`eve`).sort(),n=(e.vercelBackend?t:[]).map(e=>` case ${JSON.stringify(`channel:${e}`)}:
|
|
2
2
|
// Authorize trusted principals for this channel before returning true.
|
|
3
3
|
return false;`).join(`
|
|
4
|
-
`),r=`${e.vercelBackend?`
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
`),r=`${e.vercelBackend?` case "http": {
|
|
5
|
+
const projectId = process.env.VERCEL_PROJECT_ID;
|
|
6
|
+
return (
|
|
7
|
+
projectId !== undefined &&
|
|
8
|
+
projectId.length > 0 &&
|
|
9
|
+
principal?.authenticator === "oidc" &&
|
|
10
|
+
(principal.issuer === "https://oidc.vercel.com" ||
|
|
11
|
+
principal.issuer?.startsWith("https://oidc.vercel.com/") === true) &&
|
|
12
|
+
principal.attributes.project_id === projectId
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
15
|
`:``}${n}`,i=`Self-modification could not obtain a GitHub credential from Vercel Connect for ${e.connector}. Install and attach the configured GitHub connector to this Vercel project, install the managed GitHub App for the configured repository, then retry.`,a=`import { getToken } from "@vercel/connect";
|
|
16
|
-
import selfModification from "eve/self-modification";
|
|
16
|
+
import selfModification from "eve/self-modification/remote";
|
|
17
17
|
|
|
18
18
|
export default selfModification({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
directory: ${JSON.stringify(e.directory)},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
target: { branch: ${JSON.stringify(e.branch)} },
|
|
27
|
-
credentials: {
|
|
28
|
-
async resolve({ capability, repository }) {
|
|
29
|
-
try {
|
|
30
|
-
return await getToken(${JSON.stringify(e.connector)}, {
|
|
31
|
-
authorizationDetails: [
|
|
32
|
-
{
|
|
33
|
-
type: "github_app_installation",
|
|
34
|
-
repositories: [repository.owner + "/" + repository.repo],
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
scopes:
|
|
38
|
-
capability === "checkout"
|
|
39
|
-
? ["contents:read", "metadata:read"]
|
|
40
|
-
: ["contents:write", "pull_requests:write", "metadata:read"],
|
|
41
|
-
subject: { type: "app" },
|
|
42
|
-
});
|
|
43
|
-
} catch (error) {
|
|
44
|
-
throw new Error(${JSON.stringify(i)}, { cause: error });
|
|
45
|
-
}
|
|
46
|
-
},
|
|
19
|
+
source: {
|
|
20
|
+
git: {
|
|
21
|
+
repository: ${JSON.stringify(e.repository)},
|
|
22
|
+
directory: ${JSON.stringify(e.directory)},
|
|
47
23
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
24
|
+
},
|
|
25
|
+
target: { branch: ${JSON.stringify(e.branch)} },
|
|
26
|
+
credentials: {
|
|
27
|
+
async resolve({ capability, repository }) {
|
|
28
|
+
try {
|
|
29
|
+
return await getToken(${JSON.stringify(e.connector)}, {
|
|
30
|
+
authorizationDetails: [
|
|
31
|
+
{
|
|
32
|
+
type: "github_app_installation",
|
|
33
|
+
repositories: [repository.owner + "/" + repository.repo],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
scopes:
|
|
37
|
+
capability === "checkout"
|
|
38
|
+
? ["contents:read", "metadata:read"]
|
|
39
|
+
: ["contents:write", "pull_requests:write", "metadata:read"],
|
|
40
|
+
subject: { type: "app" },
|
|
41
|
+
});
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new Error(${JSON.stringify(i)}, { cause: error });
|
|
53
44
|
}
|
|
54
45
|
},
|
|
55
46
|
},
|
|
47
|
+
authorize: ({ channel, principal }) => {
|
|
48
|
+
switch (channel.kind) {
|
|
49
|
+
${r} default:
|
|
50
|
+
// Add another branch when you add a trusted channel.
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
56
54
|
});
|
|
57
|
-
`;return`// eve-self-modification: generated-v1 digest:${createHash(`sha256`).update(a).digest(`hex`)}\n${a}`}function classifySelfModificationConfig(e){if(e===void 0)return`missing`;if(e===
|
|
55
|
+
`;return`// eve-self-modification: generated-v1 digest:${createHash(`sha256`).update(a).digest(`hex`)}\n${a}`}function classifySelfModificationConfig(e){if(e===void 0)return`missing`;if(e===DEFAULT_EXTENSION||e===LEGACY_DEFAULT_EXTENSION||e===`import { defineSelfModificationConfig } from "eve/self-modification/config";
|
|
58
56
|
|
|
59
57
|
export default defineSelfModificationConfig({});
|
|
60
58
|
`)return`local`;let[t,...n]=e.split(`
|
|
61
59
|
`);return/^\/\/ eve-self-modification: generated-v1 digest:([a-f0-9]{64})$/u.exec(t??``)?.[1]===createHash(`sha256`).update(n.join(`
|
|
62
|
-
`)).digest(`hex`)?`generated`:`authored`}function parseGitHubRemote(e){let t=e.trim().match(/^(?:https?:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^/]+)\/([^/]+?)(?:\.git)?$/u);return t?.[1]===void 0||t[2]===void 0?void 0:{owner:t[1],repo:t[2]}}function defaultSelfModificationSetupOperations(e,t=defaultDependencies,n=e){let r=join(e,
|
|
60
|
+
`)).digest(`hex`)?`generated`:`authored`}function parseGitHubRemote(e){let t=e.trim().match(/^(?:https?:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^/]+)\/([^/]+?)(?:\.git)?$/u);return t?.[1]===void 0||t[2]===void 0?void 0:{owner:t[1],repo:t[2]}}function defaultSelfModificationSetupOperations(e,t=defaultDependencies,n=e){let r=join(e,DEPLOYED_SELF_MODIFICATION_CONFIG_PATH);return{async detectChannelNames(){return(await discoverAgent({appRoot:e,agentRoot:join(e,`agent`)})).manifest.channels.map(e=>stripLogicalPathExtension(e.logicalPath).replace(/^channels\//,``))},async detectGitRepository(){let t=await gitOutput(e,[`config`,`--get`,`remote.origin.url`]),n=t===void 0?void 0:parseGitHubRemote(t),r=await gitOutput(e,[`symbolic-ref`,`--quiet`,`--short`,`refs/remotes/origin/HEAD`]),i=await gitOutput(e,[`rev-parse`,`--show-toplevel`]);return{...n,branch:r?.replace(/^origin\//u,``),directory:i===void 0?void 0:repositoryRelativeDirectory(i,e),remoteKind:t===void 0?`missing`:n===void 0?`other`:`github`}},readConfig:()=>readOptionalFile(r),readLocalConfig:()=>readOptionalFile(join(e,SELF_MODIFICATION_CONFIG_PATH)),async writeConfig(e){await mkdir(join(r,`..`),{recursive:!0}),await writeFile(r,e,`utf8`)},async findOrCreateConnector(e,r){let i=await listGitHubConnectors(n,r,t.captureVercel),a=`github/${e}`,o=i.find(e=>e.uid===a);if(o!==void 0){if(o.type!==`github`)throw Error(`The existing connector ${a} is not a GitHub connector.`);return o.uid}let s=await t.runVercelCaptureStdout([`connect`,`create`,`github`,`--name`,e,`-F`,`json`,`--scope`,r.orgId],{cwd:n}),c=s.ok?parseCreatedConnector(s.stdout):void 0;if(c===void 0||!c.startsWith(`github/`))throw Error(`Could not create a GitHub Vercel Connect connector.`);return c},async attachConnector(e,r){if(!(await t.runVercelCaptureStdout([`connect`,`attach`,e,`--project`,r.projectId,`--environment`,`production`,`--yes`,`--scope`,r.orgId],{cwd:n})).ok)throw Error(`Could not attach ${e} to the selected Vercel project for Production.`)}}}async function readOptionalFile(e){try{return await readFile(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return;throw e}}function parseCreatedConnector(e){try{let t=JSON.parse(e);return typeof t.uid==`string`?t.uid:void 0}catch{return}}function parseConnectorListPage(e){try{let t=JSON.parse(e);if(!Array.isArray(t.connectors))return;let n=t.connectors.flatMap(e=>typeof e==`object`&&e&&typeof e.uid==`string`&&typeof e.type==`string`?[{uid:e.uid,type:e.type}]:[]);return typeof t.cursor==`string`?{connectors:n,cursor:t.cursor}:{connectors:n}}catch{return}}async function listGitHubConnectors(e,t,n){let r=[],i=new Set,a;do{let o=[`connect`,`list`,`--all-projects`,`--service`,`github`,`-F`,`json`,`--scope`,t.orgId];a!==void 0&&o.push(`--next`,a);let s=await n(o,{cwd:e});if(!s.ok)throw Error(`Could not list GitHub connectors for the selected Vercel project. ${s.failure.message}`);let c=parseConnectorListPage(s.stdout);if(c===void 0)throw Error(`Vercel returned an invalid GitHub connector list for the selected project.`);if(r.push(...c.connectors),c.cursor!==void 0&&i.has(c.cursor))throw Error(`The GitHub connector list repeated cursor ${c.cursor}.`);c.cursor!==void 0&&i.add(c.cursor),a=c.cursor}while(a!==void 0);return r}function repositoryRelativeDirectory(e,t,n=relative){return n(e,t).replaceAll(`\\`,`/`)||`.`}function repositoryPartError(e){return/^[A-Za-z0-9_.-]+$/u.test(e)?void 0:`Enter a valid GitHub owner or repository name.`}function directoryError(e){return e===`.`||e.length>0&&!e.startsWith(`/`)&&!e.includes(`\\`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)?void 0:`Enter a safe repository-relative directory or ".".`}function gitRefError(e){return/^[A-Za-z0-9][A-Za-z0-9._/-]*$/u.test(e)&&!e.endsWith(`.`)&&!e.endsWith(`/`)&&!e.includes(`..`)&&!e.includes(`//`)&&!e.includes(`@{`)?void 0:`Enter a valid branch name.`}async function gitOutput(e,t){try{return(await runFile(`git`,t,{cwd:e})).stdout.trim()||void 0}catch{return}}export{DEPLOYED_SELF_MODIFICATION_CONFIG_PATH,SELF_MODIFICATION_CONFIG_PATH,classifySelfModificationConfig,connectorName,defaultSelfModificationSetupOperations,directoryError,gitRefError,parseGitHubRemote,renderSelfModificationConfig,repositoryPartError,repositoryRelativeDirectory};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Delegation and instruction text shared by the local and deployed self-modification children. */
|
|
2
|
+
export declare function renderDescription(sections: readonly string[]): string;
|
|
3
|
+
export declare function renderInstructions(sections: readonly string[]): string;
|
|
4
|
+
export declare const sourceDelegation: string;
|
|
5
|
+
export declare const persistenceDelegation: string;
|
|
6
|
+
export declare 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.";
|
|
7
|
+
export declare const followUpDelegation: string;
|
|
8
|
+
export declare const repairDelegation: string;
|
|
9
|
+
export declare const roleInstructions = "## Role\n\nYou 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.";
|
|
10
|
+
export declare const sourceWorkspaceInstructions = "## Source workspace\n\nThe 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.\n\nResolve named tools by filename under /source/tools before searching contents. Tool identifiers derive from filenames and may not occur in the implementation.";
|
|
11
|
+
export declare const sourceEditingInstructions = "## Implement changes\n\nUse 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.\n\nOnce paths are known, batch independent file reads and edits to different files. Never edit the same file concurrently.";
|
|
12
|
+
export declare const toolAuthoringInstructions = "## Add model-callable actions\n\nWhen 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 \u201Ctool.\u201D Follow the path-derived naming and defineTool conventions in the mounted eve tools documentation and existing source.\n\nDo 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.";
|
|
13
|
+
export declare const registryWorkflowInstructions = "## Add integrations\n\nBefore 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.\n\nModifying 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.\n\nRegistry installation is outside the source sandbox.";
|
|
14
|
+
export declare const documentationInstructions = "## Consult documentation\n\nThe 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.";
|
|
15
|
+
export declare const workingInstructions = "## Work efficiently\n\nSkip 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.\n\nTreat 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.";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function renderDescription(e){return e.filter(e=>e.length>0).join(` `)}function renderInstructions(e){return e.filter(e=>e.length>0).join(`
|
|
2
|
+
|
|
3
|
+
`)}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.`,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.`,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.`,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.`,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.`,roleInstructions=`## Role
|
|
4
|
+
|
|
5
|
+
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.`,sourceWorkspaceInstructions=`## Source workspace
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
Resolve named tools by filename under /source/tools before searching contents. Tool identifiers derive from filenames and may not occur in the implementation.`,sourceEditingInstructions=`## Implement changes
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
Once paths are known, batch independent file reads and edits to different files. Never edit the same file concurrently.`,toolAuthoringInstructions=`## Add model-callable actions
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
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.`,registryWorkflowInstructions=`## Add integrations
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
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.
|
|
22
|
+
|
|
23
|
+
Registry installation is outside the source sandbox.`,documentationInstructions=`## Consult documentation
|
|
24
|
+
|
|
25
|
+
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.`,workingInstructions=`## Work efficiently
|
|
26
|
+
|
|
27
|
+
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.
|
|
28
|
+
|
|
29
|
+
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.`;export{documentationInstructions,followUpDelegation,namedInstallationDelegation,persistenceDelegation,registryWorkflowInstructions,renderDescription,renderInstructions,repairDelegation,roleInstructions,sourceDelegation,sourceEditingInstructions,sourceWorkspaceInstructions,toolAuthoringInstructions,workingInstructions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{toErrorMessage}from"#shared/errors.js";import{
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{toErrorMessage}from"#shared/errors.js";import{readVercelProjectLink}from"#internal/vercel/project-link.js";import{getVercelOidcToken}from"#compiled/@vercel/oidc/index.js";const VercelOidcClaimsSchema=z.object({owner_id:z.string().min(1),project_id:z.string().min(1)}),LocalDevelopmentUserOidcClaimsSchema=VercelOidcClaimsSchema.extend({environment:z.literal(`development`),user_id:z.string().min(1)});async function resolveDevelopmentOidcToken(e){try{let t={team:e.ownerId,project:e.projectId};return e.forceRefresh===!0&&(t.expirationBufferMs=2**53-1),validateDevelopmentOidcToken((await getVercelOidcToken(t)).trim(),e)}catch(e){return{kind:`resolution-failed`,message:toErrorMessage(e)}}}async function resolveLinkedDevelopmentOidcToken(e){let t=await readVercelProjectLink(e);if(t===void 0)return``;let n={ownerId:t.orgId,projectId:t.projectId},r=await resolveDevelopmentOidcToken(n);if(r.kind===`resolved`&&isLocalDevelopmentUserToken(r.token))return r.token;if(r.kind!==`resolved`&&r.kind!==`target-mismatch`)return``;let i=await resolveDevelopmentOidcToken({...n,forceRefresh:!0});return i.kind===`resolved`&&isLocalDevelopmentUserToken(i.token)?i.token:``}function isLocalDevelopmentUserToken(e){let t=decodeOidcPayload(e);return t!==void 0&&z.validate(LocalDevelopmentUserOidcClaimsSchema,t)}function validateDevelopmentOidcToken(e,t){let n=decodeOidcPayload(e);if(n===void 0)return e.split(`.`)[1]?{kind:`malformed-token`,reason:`invalid-json-payload`}:{kind:`malformed-token`,reason:`missing-payload`};let r=VercelOidcClaimsSchema.safeParse(n);if(!r.success)return{kind:`invalid-claims`,invalidClaims:r.error.issues.map(e=>{let t=e.path[0];return t===`owner_id`||t===`project_id`?t:`claims`})};let i=[];return r.data.owner_id!==t.ownerId&&i.push(`owner_id`),r.data.project_id!==t.projectId&&i.push(`project_id`),i.length>0?{kind:`target-mismatch`,mismatchedClaims:i}:{kind:`resolved`,token:e}}function decodeOidcPayload(e){let t=e.split(`.`)[1];if(t)try{return JSON.parse(Buffer.from(t,`base64url`).toString(`utf8`))}catch{return}}const VERCEL_PROTECTION_BYPASS_HEADER=`x-vercel-protection-bypass`;export{VERCEL_PROTECTION_BYPASS_HEADER,resolveDevelopmentOidcToken,resolveLinkedDevelopmentOidcToken};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile}from"node:fs/promises";import{resolveDiscoveryProject}from"#discover/project.js";import pc from"#compiled/picocolors/index.js";import{
|
|
1
|
+
import{readFile}from"node:fs/promises";import{join}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import pc from"#compiled/picocolors/index.js";import{parseModelHelper}from"#shared/model-helper.js";import{discoverAgent}from"#discover/discover-agent.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{CHATGPT_MODEL_SELECTION_PREFIX}from"#shared/chatgpt-model.js";import{createCompiledRuntimeModelCatalogLoader}from"#compiler/model-catalog.js";import{readModelSelectionFromSource}from"#source-change/apply-model-selection.js";import{createStaticSourceChange}from"#source-change/static-source-change.js";function formatApplyModelSettingsOutcome(e){return e.kind===`rejected`?e.message:e.kind===`unchanged`?`Model settings are already up to date.`:e.changed.length===1&&e.changed[0]===`model`&&e.model!==void 0?`Model changed to ${pc.bold(e.model)}. Live on your next prompt.`:`Model settings updated: ${e.changed.map(t=>t===`model`?`model ${e.model??`updated`}`:t===`reasoning`?`reasoning ${e.reasoning??`provider default`}`:`Fast mode ${e.fastMode?`on`:`off`}`).join(`, `)}. Live on your next prompt.`}async function changeAgentModelSettings(e){let{appRoot:t,patch:n}=e;if(n.model.kind===`set`){let e=await validateModelSlug(t,n.model.value);if(e!==null)return{kind:`rejected`,message:e}}let r=await resolveDiscoveryProject(t),{manifest:i}=await discoverAgent(r),a=await createStaticSourceChange(i).updateModelSettings(n);if(a.kind===`bail`)return{kind:`rejected`,message:`Couldn't edit ${a.at.logicalPath}: ${a.reason}. Change the model settings by hand.`};if(a.changed.length===0)return{kind:`unchanged`};let o={kind:`changed`,changed:a.changed};return n.model.kind===`set`&&(o.model=n.model.value),n.reasoning.kind!==`keep`&&(o.reasoning=n.reasoning.kind===`set`?n.reasoning.value:null),n.gatewayServiceTier.kind!==`keep`&&(o.fastMode=n.gatewayServiceTier.kind===`set`),o}async function changeAgentModel(e){let{appRoot:t,slug:n}=e,r=await validateModelSlug(t,n);return r===null?changeValidatedAgentModel(e):{kind:`rejected`,message:r}}async function changeValidatedAgentModel(e){let{appRoot:t,slug:n}=e,r=await resolveDiscoveryProject(t),{manifest:i}=await discoverAgent(r),a=await createStaticSourceChange(i).updateModelName(n);return a.kind===`bail`?{kind:`rejected`,message:`Couldn't edit ${a.at.logicalPath}: ${a.reason}. Change \`model\` by hand.`}:a.from===a.to?{kind:`unchanged`,model:a.to}:{kind:`changed`,to:a.to}}async function validateModelSlug(e,t){if(parseModelHelper(t)!==void 0)return null;if(t.startsWith(CHATGPT_MODEL_SELECTION_PREFIX))return"Choose a bare OpenAI model id after `chatgpt/`.";if(!t.includes(`/`))return`\`${t}\` isn't a provider/model id (e.g. anthropic/claude-sonnet-5).`;let n=createCompiledRuntimeModelCatalogLoader(e);try{if(await n.getModelLimits(formatLanguageModelGatewayId(t))===null)return`I couldn't confirm \`${t}\` in the AI Gateway model catalog, so I didn't change agent.ts.`}catch{return null}return null}async function readAuthoredModelSelection(e){let t=await resolveDiscoveryProject(e),{manifest:n}=await discoverAgent(t);if(!n.configModule)return;let r=await readFile(join(t.agentRoot,n.configModule.logicalPath),`utf8`);return readModelSelectionFromSource(r)}export{changeAgentModel,changeAgentModelSettings,changeValidatedAgentModel,formatApplyModelSettingsOutcome,readAuthoredModelSelection,validateModelSlug};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineSetupIntegration}from"../types.js";import{describeIntegrationSetupEnvironment}from"../shared/environment.js";import{installScaffoldDependencies}from"../shared/scaffold.js";import{relative}from"node:path";import{ensurePackageDependencies}from"#setup/scaffold/index.js";import{confirm,select,text}from"#setup/ask.js";import{classifySelfModificationConfig,connectorName,defaultSelfModificationSetupOperations,directoryError,gitRefError,renderSelfModificationConfig,repositoryPartError}from"#self-modification/setup.js";import{
|
|
1
|
+
import{defineSetupIntegration}from"../types.js";import{describeIntegrationSetupEnvironment}from"../shared/environment.js";import{installScaffoldDependencies}from"../shared/scaffold.js";import{relative}from"node:path";import{ensurePackageDependencies}from"#setup/scaffold/index.js";import{confirm,select,text}from"#setup/ask.js";import{DEPLOYED_SELF_MODIFICATION_CONFIG_PATH,SELF_MODIFICATION_CONFIG_PATH,classifySelfModificationConfig,connectorName,defaultSelfModificationSetupOperations,directoryError,gitRefError,renderSelfModificationConfig,repositoryPartError}from"#self-modification/setup.js";import{detectLegacySelfModificationScaffold,removeLegacySelfModificationScaffold}from"#self-modification/migration.js";import{DEFAULT_CONNECT_PACKAGE_VERSION,DEFAULT_MICROSANDBOX_PACKAGE_VERSION}from"#setup/scaffold/version-tokens.js";const defaultApplyDependencies={ensurePackageDependencies,installScaffoldDependencies},SELF_MODIFICATION_PRODUCTION_DEPENDENCIES={"@vercel/connect":DEFAULT_CONNECT_PACKAGE_VERSION,microsandbox:DEFAULT_MICROSANDBOX_PACKAGE_VERSION};function validationResult(e){return e??null}async function prepareLegacyScaffoldCleanup(e){let t=await detectLegacySelfModificationScaffold(e.appRoot);return t===void 0?void 0:await e.asker.ask(confirm({key:`self-modification-cleanup`,message:`A legacy self-modification scaffold was found at ${relative(e.appRoot,t.root)}. This scaffold format is no longer supported. Do you want to remove it?`,recommended:!0,required:!0}))?t:void 0}function withLegacyScaffold(e,t){return t===void 0?e:{...e,legacyScaffold:t}}async function prepareSelfModificationSetup(e,t=defaultSelfModificationSetupOperations(e.appRoot,void 0,e.projectRoot)){let n=await prepareLegacyScaffoldCleanup(e),r=await t.readConfig();if(classifySelfModificationConfig(r)===`authored`)return e.presenter.note(`The existing ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH} contains authored configuration and was not overwritten.`,`Manual update required`,{tone:`warning`}),withLegacyScaffold({kind:`authored`},n);if(await e.asker.ask(select({key:`self-modification-mode`,message:`How should self-modification be enabled?`,options:[{id:`deployed`,value:`deployed`,label:`Enable for deployed`,hint:`Let deployed agents propose source changes through draft pull requests`},{id:`local`,value:`local`,label:`Keep local`,hint:`Only enable source editing during local development`}],recommended:`local`,required:!0}))===`local`)return withLegacyScaffold({kind:`local`},n);let[i,a,o]=await Promise.all([e.resolveVercelProject(`self-modification`),t.detectGitRepository(),t.detectChannelNames()]),s=await e.asker.ask(text({key:`self-modification-repository-owner`,message:`GitHub repository owner`,detected:a.owner,required:!0,validate:e=>validationResult(repositoryPartError(e))})),c=await e.asker.ask(text({key:`self-modification-repository-name`,message:`GitHub repository name`,detected:a.repo,required:!0,validate:e=>validationResult(repositoryPartError(e))})),l=await e.asker.ask(text({key:`self-modification-repository-directory`,message:`Application directory relative to the repository root`,detected:a.directory??`.`,required:!0,validate:e=>validationResult(directoryError(e))})),u=await e.asker.ask(text({key:`self-modification-target-branch`,message:`Target branch`,detected:a.branch??`main`,required:!0,validate:e=>validationResult(gitRefError(e))})),d=connectorName(s,c),f={branch:u,channelNames:o,connector:`github/${d}`,directory:l,repository:`github.com/${s}/${c}`,vercelBackend:!0};return e.presenter.note(renderSelfModificationConfig(f),`Generated ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}`),e.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.`,`Security summary`),withLegacyScaffold(await e.asker.ask(confirm({key:`self-modification-confirm`,message:`Create or attach this GitHub connector and write this configuration?`,recommended:!1,required:!0}))?{kind:`deployed`,connectorName:d,project:i,values:f}:{kind:`local`},n)}async function applySelfModificationSetup(e,t,n=defaultSelfModificationSetupOperations(t.appRoot,void 0,t.projectRoot),r=defaultApplyDependencies){if(e.legacyScaffold!==void 0&&(await removeLegacySelfModificationScaffold(t.appRoot,e.legacyScaffold),t.presenter.log.success(`Removed the retired self-modification scaffold.`)),e.kind===`authored`)return{facts:[{label:`Self-modification`,value:`manual configuration update required`}]};if(e.kind===`local`)return{facts:[]};let i=await n.findOrCreateConnector(e.connectorName,e.project);await n.attachConnector(i,e.project);let a=await r.ensurePackageDependencies({dependencies:SELF_MODIFICATION_PRODUCTION_DEPENDENCIES,projectRoot:t.appRoot});return await r.installScaffoldDependencies({changed:a.length>0,log:t.presenter.log,projectPath:t.appRoot,signal:t.signal}),await n.writeConfig(renderSelfModificationConfig({...e.values,connector:i})),t.presenter.log.success(`Updated ${DEPLOYED_SELF_MODIFICATION_CONFIG_PATH}.`),t.presenter.nextSteps([`Install the managed GitHub App for the configured repository, then deploy or redeploy.`,e.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 \`${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.`]),{deploymentRequired:!0,facts:[{label:`Repository`,value:e.values.repository},{label:`Application directory`,value:e.values.directory},{label:`Target branch`,value:e.values.branch},{label:`Credential`,value:i}]}}async function prepareLocalSelfModificationSetup(e,t=defaultSelfModificationSetupOperations(e.appRoot,void 0,e.projectRoot)){let n=await prepareLegacyScaffoldCleanup(e),r=await t.readLocalConfig();return classifySelfModificationConfig(r)===`authored`?(e.presenter.note(`The existing ${SELF_MODIFICATION_CONFIG_PATH} contains authored configuration and was not overwritten.`,`Manual update required`,{tone:`warning`}),withLegacyScaffold({kind:`authored`},n)):withLegacyScaffold({kind:`local`},n)}function describeEnvironment(e){if(e.vercel.kind===`available`)return describeIntegrationSetupEnvironment(e);switch(e.vercel.reason){case`logged-out`:return`No authenticated Vercel account found. Local editing remains available; deployed proposals require Vercel Connect.`;case`cli-missing`:return`Vercel CLI not found. Local editing remains available; deployed proposals require Vercel Connect.`;case`unavailable`:return`Could not verify the Vercel account. Local editing remains available; deployed proposals require Vercel Connect.`}}const SELF_MODIFICATION_SETUP=defineSetupIntegration({kind:`self-modification`,label:`Self-modification`,hint:`Local source editing is enabled`,describeEnvironment,prepare:prepareLocalSelfModificationSetup,apply:applySelfModificationSetup}),SELF_MODIFICATION_PRODUCTION_SETUP=defineSetupIntegration({kind:`self-modification-production`,label:`Self-modification production`,hint:`Configure deployed draft pull requests`,describeEnvironment,prepare:prepareSelfModificationSetup,apply:applySelfModificationSetup});export{SELF_MODIFICATION_PRODUCTION_SETUP,SELF_MODIFICATION_SETUP,applySelfModificationSetup,prepareLocalSelfModificationSetup,prepareSelfModificationSetup};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{captureVercel}from"./primitives/run-vercel.js";import{stat}from"node:fs/promises";import{join}from"node:path";import{
|
|
1
|
+
import{captureVercel}from"./primitives/run-vercel.js";import{stat}from"node:fs/promises";import{join}from"node:path";import{readVercelProjectLink}from"#internal/vercel/project-link.js";import{readVercelResourceName}from"#internal/vercel/api-resource.js";async function assertNoLegacyProjectLinkDirectory(e){try{if(!(await stat(join(e,`.now`))).isDirectory())return}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}throw Error("Legacy Vercel link directory `.now` is not supported. Remove `.now` before linking this project.")}async function readProjectLink(e){return await assertNoLegacyProjectLinkDirectory(e),await readVercelProjectLink(e)}function pickShortestAlias(e){if(!Array.isArray(e))return;let t;for(let n of e)typeof n==`string`&&n.length!==0&&(t===void 0||n.length<t.length)&&(t=n);return t}async function fetchProductionAlias(e,t,n,r){let i=await captureVercel([`api`,`/v9/projects/${e}?teamId=${t}`,`--scope`,t],{cwd:n,signal:r.signal});if(i.ok)try{let e=pickShortestAlias(JSON.parse(i.stdout).targets?.production?.alias);return e?`https://${e}`:void 0}catch{return}}async function detectDeployment(e,t={}){t.signal?.throwIfAborted();let n=await readProjectLink(e);if(n===void 0)return{state:`unlinked`};let r=await fetchProductionAlias(n.projectId,n.orgId,e,t);return t.signal?.throwIfAborted(),{state:r?`deployed`:`linked`,projectId:n.projectId,orgId:n.orgId,productionUrl:r}}async function fetchVercelName(e,t,n,r){let i=await captureVercel([`api`,e,`--scope`,t],{cwd:n,signal:r.signal});if(i.ok)try{return readVercelResourceName(JSON.parse(i.stdout))}catch{return}}async function detectProjectIdentity(e,t={}){t.signal?.throwIfAborted();let n=await readProjectLink(e);if(n===void 0)return;let[r,i]=await Promise.all([fetchVercelName(`/v9/projects/${n.projectId}?teamId=${n.orgId}`,n.orgId,e,t).then(e=>e??n.projectId),n.orgId.startsWith(`team_`)?fetchVercelName(`/v2/teams/${n.orgId}`,n.orgId,e,t):Promise.resolve(void 0)]);return t.signal?.throwIfAborted(),{projectName:r,teamName:i}}function projectResolutionFromDeployment(e){return e.state===`unlinked`||e.projectId===void 0?{kind:`unresolved`}:e.state===`deployed`&&e.productionUrl!==void 0?{kind:`deployed`,projectId:e.projectId,productionUrl:e.productionUrl}:{kind:`linked`,projectId:e.projectId}}async function detectProjectResolution(e,t={}){return projectResolutionFromDeployment(await detectDeployment(e,t))}function mergeProjectResolution(e,t){return t.kind===`unresolved`||e.kind===`deployed`&&e.projectId===t.projectId?e:t}function projectResolutionFromDeployResult(e,t){return e.kind===`unresolved`||!t.deployed||t.productionUrl===void 0?e:{kind:`deployed`,projectId:e.projectId,productionUrl:t.productionUrl}}function isProjectResolved(e){return e.kind!==`unresolved`}function projectProductionUrlFromResolution(e){return e.kind===`deployed`?e.productionUrl:void 0}export{assertNoLegacyProjectLinkDirectory,detectDeployment,detectProjectIdentity,detectProjectResolution,isProjectResolved,mergeProjectResolution,projectProductionUrlFromResolution,projectResolutionFromDeployResult,projectResolutionFromDeployment,readProjectLink};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{parseChatGptModelSelection}from"../../../shared/chatgpt-model.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{DEFAULT_CONNECT_PACKAGE_VERSION,resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_CHANNEL_TEMPLATES}from"./web-template.js";import{AGENT_INSTRUCTIONS_TEMPLATE}from"./instructions-template.js";import{SCAFFOLDED_AGENT_PATHS}from"./agent-paths.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.128`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.
|
|
1
|
+
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{parseChatGptModelSelection}from"../../../shared/chatgpt-model.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{DEFAULT_CONNECT_PACKAGE_VERSION,resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_CHANNEL_TEMPLATES}from"./web-template.js";import{AGENT_INSTRUCTIONS_TEMPLATE}from"./instructions-template.js";import{SCAFFOLDED_AGENT_PATHS}from"./agent-paths.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.128`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.73.0`,nodeEngine:`>=24`};function resolveEvePackageContract(e=DEFAULT_EVE_PACKAGE_CONTRACT){return{version:resolveVersionToken(`evePackage.version`,e.version),nodeEngine:resolveVersionToken(`evePackage.nodeEngine`,e.nodeEngine)}}function modelProviderSlug(e){let t=(e.split(`/`)[0]??``).replaceAll(/[^A-Za-z0-9._-]/gu,``);return t.length>0?t:`anthropic`}function byokProviderEnvVar(e){let t=modelProviderSlug(e).toUpperCase().replaceAll(/[^A-Z0-9]/gu,`_`);return`${/^[0-9]/.test(t)?`_`:``}${t}_API_KEY`}function agentTemplateFiles(e,t){return{[SCAFFOLDED_AGENT_PATHS.config]:renderAgentTemplate(e,t),[SCAFFOLDED_AGENT_PATHS.channel]:WEB_CHANNEL_TEMPLATES.default,[SCAFFOLDED_AGENT_PATHS.instructions]:AGENT_INSTRUCTIONS_TEMPLATE}}function renderAgentTemplate(e,t){let n=parseChatGptModelSelection(e);return n===void 0?BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t)):`import { defineAgent } from "eve";\nimport { chatgpt } from "eve/models/openai";\n\nexport default defineAgent({\n model: chatgpt(${JSON.stringify(n)}),\n${reasoningTemplateLine(t)}});\n`}function reasoningTemplateLine(e){return e===void 0||e===`provider-default`?``:` reasoning: "${e}",\n`}function renderTemplate(e,t){return e===BASE_AGENT_TEMPLATE&&parseChatGptModelSelection(t.model)!==void 0?renderAgentTemplate(t.model,t.reasoning):e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t.reasoning)).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TYPESCRIPT_VERSION__`,t.typescriptPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
|
|
2
2
|
|
|
3
3
|
export default defineAgent({
|
|
4
4
|
model: "__EVE_INIT_MODEL__",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClientOptions } from "#client/index.js";
|
|
2
2
|
import { type DevelopmentOidcTokenFailure, resolveDevelopmentOidcToken } from "#services/dev-client/request-headers.js";
|
|
3
|
+
import type { VercelProjectReference } from "#setup/project-resolution.js";
|
|
3
4
|
import { resolveVercelDeployment, type VercelDeploymentResolution } from "./vercel-deployment.js";
|
|
4
5
|
/** Dependencies for verifying one remote client (injectable for tests). */
|
|
5
6
|
export interface VerifiedRemoteDevelopmentClientDeps {
|
|
@@ -21,6 +22,8 @@ export declare function resolveVerifiedRemoteDevelopmentClient(input: {
|
|
|
21
22
|
readonly headers?: Readonly<Record<string, string>>;
|
|
22
23
|
readonly serverUrl: string;
|
|
23
24
|
readonly signal?: AbortSignal;
|
|
25
|
+
/** Expected project identity, used to scope and cross-check the deployment lookup. */
|
|
26
|
+
readonly projectSource?: VercelProjectReference;
|
|
24
27
|
readonly vercelScope?: string;
|
|
25
28
|
readonly workspaceRoot: string;
|
|
26
29
|
readonly deps?: Partial<VerifiedRemoteDevelopmentClientDeps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveVercelDeployment}from"./vercel-deployment.js";import{resolveDevelopmentOidcToken}from"#services/dev-client/request-headers.js";import{hasDevelopmentAuthorizationHeader,resolveRemoteDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{createDevelopmentCredentialGate}from"#services/dev-client/credential-gate.js";const defaultDeps={resolveVercelDeployment,resolveDevelopmentOidcToken};async function resolveVerifiedRemoteDevelopmentClient(e){let t={...defaultDeps,...e.deps},n=createDevelopmentCredentialGate(e.serverUrl),r;if(!hasDevelopmentAuthorizationHeader(e.headers)&&(r=await t.resolveVercelDeployment({workspaceRoot:e.workspaceRoot,host:new URL(e.serverUrl).host
|
|
1
|
+
import{resolveVercelDeployment}from"./vercel-deployment.js";import{resolveDevelopmentOidcToken}from"#services/dev-client/request-headers.js";import{hasDevelopmentAuthorizationHeader,resolveRemoteDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{createDevelopmentCredentialGate}from"#services/dev-client/credential-gate.js";const defaultDeps={resolveVercelDeployment,resolveDevelopmentOidcToken};async function resolveVerifiedRemoteDevelopmentClient(e){let t={...defaultDeps,...e.deps},n=createDevelopmentCredentialGate(e.serverUrl),r;if(!hasDevelopmentAuthorizationHeader(e.headers)&&(r=await t.resolveVercelDeployment({workspaceRoot:e.workspaceRoot,host:new URL(e.serverUrl).host,...e.projectSource===void 0?{scope:e.vercelScope}:{source:e.projectSource},signal:e.signal}),r.kind===`resolved`)){let{ownerId:e,projectId:i}=r.target.deployment;n.authorize({target:r.target,resolveToken:()=>t.resolveDevelopmentOidcToken({ownerId:e,projectId:i})})}return{deploymentResolution:r,options:resolveRemoteDevelopmentClientOptions({credentials:n,headers:e.headers,serverUrl:e.serverUrl}),lastOidcTokenFailure:n.lastTokenFailure}}export{resolveVerifiedRemoteDevelopmentClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";import{isLoopbackHostname}from"#shared/network-address.js";import{
|
|
1
|
+
import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";import{isLoopbackHostname}from"#shared/network-address.js";import{existsSync}from"node:fs";import{join}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{spawn}from"node:child_process";import{readDevelopmentRuntimeArtifactsRevision}from"#services/dev-client/runtime-artifacts.js";const DEFAULT_EVE_SERVER_TIMEOUT_MS=18e4,ANSI_ESCAPE_PATTERN=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`),SERVER_URL_CANDIDATE_PATTERN=/https?:\/\/[^\s"'<>]+/g;function normalizeOrigin(e){return new URL(e).origin}function isNodeErrorWithCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function delay(e){return new Promise(t=>setTimeout(t,e))}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function resolveEveCacheDirectory(e){return join(e,`.eve`)}function resolveEveDevServerRegistryPath(e,t){return join(resolveEveCacheDirectory(e),`${t.slug}-dev-server.json`)}function resolveEveDevServerLockPath(e,t){return join(resolveEveCacheDirectory(e),`${t.slug}-dev-server.lock`)}function resolveDevServerTimeout(e,t){if(e!==void 0){if(!Number.isFinite(e)||e<=0)throw Error(`eve ${t.label} development server timeout must be a positive number.`);return e}}function normalizeDevServerRegistry(e){if(isRecord(e)&&typeof e.appRoot==`string`&&typeof e.origin==`string`&&typeof e.updatedAt==`string`&&(e.pid===null||typeof e.pid==`number`))try{return{appRoot:e.appRoot,origin:normalizeOrigin(e.origin),pid:e.pid,updatedAt:e.updatedAt}}catch{return}}async function readUsableEveDevServerRegistry(e,t){try{let n=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e,t),`utf8`)));return n===void 0||n.appRoot!==e||await readDevelopmentRuntimeArtifactsRevision({serverUrl:n.origin,timeoutMs:1e3})===void 0?void 0:n.origin}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t,n){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e,t),`${JSON.stringify({appRoot:e,origin:n.origin,pid:n.process?.pid??null,updatedAt:new Date().toISOString()},null,2)}\n`)}async function removeStaleEveDevServerLock(e){try{let t=await stat(e);Date.now()-t.mtimeMs>3e4&&await rm(e,{force:!0})}catch(e){if(!isNodeErrorWithCode(e,`ENOENT`))throw e}}async function acquireEveDevServerLock(e,t,n){let r=resolveEveCacheDirectory(e),i=resolveEveDevServerLockPath(e,t),a=Date.now()+n;for(await mkdir(r,{recursive:!0});;)try{let e=await open(i,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(i,{force:!0})}}catch(r){if(!isNodeErrorWithCode(r,`EEXIST`))throw r;if(await readUsableEveDevServerRegistry(e,t)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(i),Date.now()>a)throw Error(`Timed out after ${n}ms waiting for another ${t.label} process to start eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}function parseLocalServerOrigin(e){let t=URL.parse(e);if(!(t===null||t.protocol!==`http:`&&t.protocol!==`https:`||!isLoopbackHostname(t.hostname)||t.port.length===0))return t.origin}function findLocalServerOrigin(e){for(let t of e.matchAll(SERVER_URL_CANDIDATE_PATTERN)){let e=parseLocalServerOrigin(t[0]);if(e!==void 0)return e}}function formatEveDevOutputLine(e,t){let n=e.replace(/\r$/,``),r=n.replace(ANSI_ESCAPE_PATTERN,``).trim();if(r.length===0||/^☰eve\b/.test(r)||r===`CONFIGURATION_FIELD_CONFLICT`||r.startsWith(`[CONFIGURATION_FIELD_CONFLICT]`))return;let i=t===void 0?`[eve:dev]`:`[eve:dev:${t}]`,a=/server listening at\s+(https?:\/\/[^\s]+)/i.exec(n);return a===null?`${i} ${n}`:`${i} server listening at ${a[1]}`}function createEveDevOutputWriter(e){let t=``,writeLine=t=>{let n=formatEveDevOutputLine(t,e.logLabel);n!==void 0&&e.stream.write(`${n}\n`)};return{flush(){t.length!==0&&(writeLine(t),t=``)},write(e){t+=e.toString(`utf8`);let n=t.split(`
|
|
2
2
|
`);t=n.pop()??``;for(let e of n)writeLine(e)}}}function startServerProcess(e){let t=e.timeoutMs??18e4;return new Promise((n,r)=>{let i=spawn(e.command,e.args,{cwd:e.cwd,env:{...process.env,...e.env},stdio:[`ignore`,`pipe`,`pipe`]}),a=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stderr}),o=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stdout}),s=setTimeout(()=>{i.kill(),r(Error(`Timed out after ${t}ms waiting for eve to print its server URL.`))},t),cleanup=()=>{clearTimeout(s),i.off(`error`,handleError),i.off(`exit`,handleEarlyExit)},flushOutput=()=>{o.flush(),a.flush()},handleError=e=>{flushOutput(),cleanup(),r(e)},handleEarlyExit=(e,t)=>{flushOutput(),cleanup(),r(Error(`eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},handleOutput=e=>{let t=findLocalServerOrigin(e.toString(`utf8`));t!==void 0&&(cleanup(),n({origin:t,process:i}))};i.once(`error`,handleError),i.once(`exit`,handleEarlyExit),i.stdout.on(`data`,e=>{o.write(e),handleOutput(e)}),i.stderr.on(`data`,e=>{a.write(e),handleOutput(e)})})}function installProcessShutdown(e){let t=e.process;if(t===void 0)return e;let close=()=>{t.killed||t.kill()};return process.once(`beforeExit`,close),process.once(`exit`,close),e}function startEveDevServer(e){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`,...e.workspaceAgentName===void 0?[]:[`--agent`,e.workspaceAgentName]],command:process.execPath,cwd:e.appRoot,logLabel:e.logLabel,timeoutMs:e.timeoutMs}).then(installProcessShutdown)}function startEveProductionServer(e){let t=new URL(e.origin),n=t.port,r=join(e.appRoot,`.output`,`server`,`index.mjs`);if(!existsSync(r))throw Error(`eve production output is missing at ${r}. Run eve build from ${e.appRoot} before starting ${e.host.label}.`);return startServerProcess({args:[r],command:process.execPath,cwd:e.appRoot,env:{HOST:t.hostname,NITRO_HOST:t.hostname,NITRO_PORT:n,PORT:n}}).then(installProcessShutdown)}async function resolveSharedEveDevServer(e){let t=e.timeoutMs??18e4,n=await readUsableEveDevServerRegistry(e.appRoot,e.host);if(n!==void 0)return{origin:n};let r=await acquireEveDevServerLock(e.appRoot,e.host,t);try{let n=await readUsableEveDevServerRegistry(e.appRoot,e.host);if(n!==void 0)return{origin:n};let r=await startEveDevServer({appRoot:e.appRoot,logLabel:e.logLabel,timeoutMs:t,workspaceAgentName:e.workspaceAgentName});return await writeEveDevServerRegistry(e.appRoot,e.host,r),r}finally{await r()}}export{DEFAULT_EVE_SERVER_TIMEOUT_MS,resolveDevServerTimeout,resolveSharedEveDevServer,startEveProductionServer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inputTextKey,readAnswerText}from"#internal/input-text.js";import{resolveTextToResponse}from"#channel/resolve-text.js";import{getProxyInputRequests}from"#harness/proxy-input-requests.js";import{resolveInputOutcome}from"#harness/input-request-resolution.js";import{SESSION_LIMIT_STOP_OPTION_ID}from"#harness/hitl/budget-request.js";const CONSUMED_MESSAGE_KEYS=new Set([`context`,`message`,inputTextKey]);function routeDeliverPayload(e){let t=getProxyInputRequests(e.state),routable=(t,n)=>n!==void 0&&e.allowRoute?.(t,n)!==!1,n=resolveMessageAgainstQuestions({enabled:e.resolveMessage===!0,entries:t,payload:e.payload,routable}),[r]=n.responses,i=[...e.payload.inputResponses??[],...n.responses],a=new Map,o=[],s,bucketFor=e=>{let t=JSON.stringify([e.childContinuationToken,e.childSessionInbox?.sessionId??``,e.remote?.sessionId??``,e.event.sequence,e.event.stepIndex,e.event.turnId,e.inputSource??null]),n=a.get(t);if(n!==void 0)return n;let r={childContinuationToken:e.childContinuationToken,remote:e.remote,event:e.event,parentRequestIds:[],responses:[],routes:[],...e.childSessionInbox!==void 0&&{childSessionInbox:e.childSessionInbox},...e.workflowAsk!==void 0&&{workflowAsk:e.workflowAsk}};return a.set(t,r),r},c=new Set;for(let e of i){let n=t.get(e.requestId);if(n===void 0||!routable(e.requestId,n)){o.push(e);continue}if(c.has(e.requestId))continue;c.add(e.requestId),n.kind===`session-limit`&&e.optionId===SESSION_LIMIT_STOP_OPTION_ID&&(s={kind:`cancel-turn`});let r=bucketFor(n);r.parentRequestIds.push(e.requestId),r.responses.push(e),r.routes.push(n)}let l=[...a.values()].map(({workflowAsk:n,remote:i,childContinuationToken:a,childSessionInbox:o,event:s,parentRequestIds:c,responses:l,routes:u})=>{let d=new Set(c),f=new Set(d);for(let e of u)if(e.batch!==void 0&&batchResolves({batch:e.batch,childContinuationToken:a,entries:t,responseIds:d}))for(let t of e.batch.requestIds)f.add(t);return{childContinuationToken:a,payload:{inputResponses:l},resolved:{event:s,resolutions:resolveRetiredRequests({entries:t,responses:l,retireRequestIds:f})},...o!==void 0&&{childSessionInbox:o},...r!==void 0&&l.includes(r)&&{message:e.payload.message},...n!==void 0&&{workflowAsk:n},...i!==void 0&&{remote:i},...u[0]?.inputSource!==void 0&&{inputSource:u[0].inputSource}}}),u={};for(let[t,r]of Object.entries(e.payload))t!==`inputResponses`&&r!==void 0&&(n.consumed&&CONSUMED_MESSAGE_KEYS.has(t)||(u[t]=r));return o.length>0&&(u.inputResponses=o),{forChildren:l,forSelf:Object.keys(u).length>0?u:void 0,parentAction:s}}function resolveRetiredRequests(e){let t=new Map(e.responses.map(e=>[e.requestId,e])),n=[];for(let r of e.retireRequestIds){let i=e.entries.get(r);i!==void 0&&n.push(toInputResolution(r,i,t.get(r)))}return n}function toInputResolution(e,t,n){let r=resolveInputOutcome(t.kind,n),i={kind:t.kind,outcome:r,requestId:e};return n===void 0?i:{...i,response:n}}function resolveMessageAgainstQuestions(e){let t={consumed:!1,responses:[]};if(!e.enabled||(e.payload.inputResponses?.length??0)>0
|
|
1
|
+
import{inputTextKey,readAnswerText}from"#internal/input-text.js";import{firstOpenInput}from"#harness/open-input-request.js";import{resolveTextToResponse}from"#channel/resolve-text.js";import{storedProjection}from"#harness/session-machine/view.js";import{getProxyInputRequests}from"#harness/proxy-input-requests.js";import{resolveInputOutcome}from"#harness/input-request-resolution.js";import{SESSION_LIMIT_STOP_OPTION_ID}from"#harness/hitl/budget-request.js";const CONSUMED_MESSAGE_KEYS=new Set([`context`,`message`,inputTextKey]);function routeDeliverPayload(e){let t=getProxyInputRequests(e.state),routable=(t,n)=>n!==void 0&&e.allowRoute?.(t,n)!==!1,n=resolveMessageAgainstQuestions({enabled:e.resolveMessage===!0,entries:t,payload:e.payload,routable,state:e.state}),[r]=n.responses,i=[...e.payload.inputResponses??[],...n.responses],a=new Map,o=[],s,bucketFor=e=>{let t=JSON.stringify([e.childContinuationToken,e.childSessionInbox?.sessionId??``,e.remote?.sessionId??``,e.event.sequence,e.event.stepIndex,e.event.turnId,e.inputSource??null]),n=a.get(t);if(n!==void 0)return n;let r={childContinuationToken:e.childContinuationToken,remote:e.remote,event:e.event,parentRequestIds:[],responses:[],routes:[],...e.childSessionInbox!==void 0&&{childSessionInbox:e.childSessionInbox},...e.workflowAsk!==void 0&&{workflowAsk:e.workflowAsk}};return a.set(t,r),r},c=new Set;for(let e of i){let n=t.get(e.requestId);if(n===void 0||!routable(e.requestId,n)){o.push(e);continue}if(c.has(e.requestId))continue;c.add(e.requestId),n.kind===`session-limit`&&e.optionId===SESSION_LIMIT_STOP_OPTION_ID&&(s={kind:`cancel-turn`});let r=bucketFor(n);r.parentRequestIds.push(e.requestId),r.responses.push(e),r.routes.push(n)}let l=[...a.values()].map(({workflowAsk:n,remote:i,childContinuationToken:a,childSessionInbox:o,event:s,parentRequestIds:c,responses:l,routes:u})=>{let d=new Set(c),f=new Set(d);for(let e of u)if(e.batch!==void 0&&batchResolves({batch:e.batch,childContinuationToken:a,entries:t,responseIds:d}))for(let t of e.batch.requestIds)f.add(t);return{childContinuationToken:a,payload:{inputResponses:l},resolved:{event:s,resolutions:resolveRetiredRequests({entries:t,responses:l,retireRequestIds:f})},...o!==void 0&&{childSessionInbox:o},...r!==void 0&&l.includes(r)&&{message:e.payload.message},...n!==void 0&&{workflowAsk:n},...i!==void 0&&{remote:i},...u[0]?.inputSource!==void 0&&{inputSource:u[0].inputSource}}}),u={};for(let[t,r]of Object.entries(e.payload))t!==`inputResponses`&&r!==void 0&&(n.consumed&&CONSUMED_MESSAGE_KEYS.has(t)||(u[t]=r));return o.length>0&&(u.inputResponses=o),{forChildren:l,forSelf:Object.keys(u).length>0?u:void 0,parentAction:s}}function resolveRetiredRequests(e){let t=new Map(e.responses.map(e=>[e.requestId,e])),n=[];for(let r of e.retireRequestIds){let i=e.entries.get(r);i!==void 0&&n.push(toInputResolution(r,i,t.get(r)))}return n}function toInputResolution(e,t,n){let r=resolveInputOutcome(t.kind,n),i={kind:t.kind,outcome:r,requestId:e};return n===void 0?i:{...i,response:n}}function resolveMessageAgainstQuestions(e){let t={consumed:!1,responses:[]};if(!e.enabled||(e.payload.inputResponses?.length??0)>0)return t;let n=readAnswerText(e.payload);if(n===void 0)return t;let answered=t=>{let n=e.entries.get(t);return n!==void 0&&!e.routable(t,n)},r=firstOpenInput(storedProjection(e.state),answered)?.request.requestId??[...e.entries.keys()].find(e=>!answered(e)),i=r===void 0?void 0:e.entries.get(r);if(r===void 0||i?.kind!==`question`)return t;let a=i.workflowAsk?.question??i.question,o=a===void 0?void 0:resolveTextToResponse(n,{requestId:r,...a});return o===void 0?t:{consumed:!0,responses:[o]}}function batchResolves(e){return e.batch.approvalRequestIds.length===0||e.batch.approvalRequestIds.every(t=>{let n=e.entries.get(t);return n===void 0||!sameBatch(n,e)||e.responseIds.has(t)})}function sameBatch(e,t){return e.childContinuationToken===t.childContinuationToken&&e.batch?.requestIds.length===t.batch.requestIds.length&&e.batch.requestIds.every((e,n)=>e===t.batch.requestIds[n])}export{routeDeliverPayload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function executeAskQuestionTool(e,t){"use workflow";return toAskQuestionOutput(await t.ask(toAskQuestionRequest(e)))}function toAskQuestionRequest(e){let t=e.options?.map(e=>({description:e.description,id:e.label,label:e.label}));return{allowFreeform:!0,display:t===void 0?`text`:`select`,prompt:e.question,...t!==void 0&&{options:t}}}function toAskQuestionOutput(e){switch(e.status){case`answered`:return{answer:e.optionId??e.text??``,status:`answered`};case`cancelled`:return{interrupted:!0};case`unavailable`:return{status:`unavailable`}}}executeAskQuestionTool.workflowId=`workflow//eve@0.
|
|
1
|
+
async function executeAskQuestionTool(e,t){"use workflow";return toAskQuestionOutput(await t.ask(toAskQuestionRequest(e)))}function toAskQuestionRequest(e){let t=e.options?.map(e=>({description:e.description,id:e.label,label:e.label}));return{allowFreeform:!0,display:t===void 0?`text`:`select`,prompt:e.question,...t!==void 0&&{options:t}}}function toAskQuestionOutput(e){switch(e.status){case`answered`:return{answer:e.optionId??e.text??``,status:`answered`};case`cancelled`:return{interrupted:!0};case`unavailable`:return{status:`unavailable`}}}executeAskQuestionTool.workflowId=`workflow//eve@0.73.0//executeAskQuestionTool`;export{executeAskQuestionTool,toAskQuestionOutput,toAskQuestionRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e,t){"use workflow";let n=new Promise(e=>t.abortSignal.addEventListener(`abort`,()=>e(`interrupted`),{once:!0})),r=sleep(Math.ceil(e.seconds*1e3)).then(()=>`elapsed`);return await Promise.race([r,n])===`elapsed`?{waitedSeconds:e.seconds}:{interrupted:!0}}executeSleepTool.workflowId=`workflow//eve@0.
|
|
1
|
+
import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e,t){"use workflow";let n=new Promise(e=>t.abortSignal.addEventListener(`abort`,()=>e(`interrupted`),{once:!0})),r=sleep(Math.ceil(e.seconds*1e3)).then(()=>`elapsed`);return await Promise.race([r,n])===`elapsed`?{waitedSeconds:e.seconds}:{interrupted:!0}}executeSleepTool.workflowId=`workflow//eve@0.73.0//executeSleepTool`;export{executeSleepTool};
|
|
@@ -32,6 +32,7 @@ export declare function withInvokeToolSpan(input: {
|
|
|
32
32
|
readonly auth: SessionAuthContext;
|
|
33
33
|
readonly callId: string;
|
|
34
34
|
readonly origin: InvokeToolTraceOrigin | undefined;
|
|
35
|
+
/** The call's own run id, never a tool session's: traces see each call as one run. */
|
|
35
36
|
readonly sessionId: string;
|
|
36
37
|
readonly toolName: string;
|
|
37
38
|
}, run: (observer: InvokeToolObserver) => Promise<InvokeToolResult>): Promise<InvokeToolResult>;
|
|
@@ -195,6 +195,33 @@ chatSdkChannel({
|
|
|
195
195
|
});
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
+
### Sign-ins
|
|
199
|
+
|
|
200
|
+
When a tool needs a connection the person hasn't authorized, eve shows a sign-in prompt with the connection's link, code, or instructions. In a direct message it posts the prompt in the thread and edits it once the sign-in completes.
|
|
201
|
+
|
|
202
|
+
Outside a direct message, the prompt is a credential, so eve sends it only to the person signing in. It uses the adapter's native ephemeral message where there is one and otherwise opens a direct message with them. The thread gets a status without the link, which eve edits once the sign-in completes.
|
|
203
|
+
|
|
204
|
+
To find that person, eve matches the turn's `auth` principal to the author of the message you passed to `send`. Private delivery therefore needs both:
|
|
205
|
+
|
|
206
|
+
- per-person `auth` on each `send`, so a principal names one person; and
|
|
207
|
+
- the handler's `Thread` object as `thread`, rather than a thread id string, so eve sees who wrote the message.
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
bot.onSubscribedMessage(async (thread, message) => {
|
|
211
|
+
await send(message.text, {
|
|
212
|
+
thread,
|
|
213
|
+
auth: {
|
|
214
|
+
authenticator: "slack",
|
|
215
|
+
principalType: "user",
|
|
216
|
+
principalId: message.author.userId,
|
|
217
|
+
attributes: {},
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Without both, including with the default `auth: null`, the thread only gets a notice to continue in a direct message, and the prompt isn't shown anywhere. The same happens when several people send as one principal (such as tenant auth), or when the adapter has neither ephemerals nor `openDM`.
|
|
224
|
+
|
|
198
225
|
### Proactive sessions
|
|
199
226
|
|
|
200
227
|
Start a session without an inbound webhook through `to(channel, target).send(message, { auth })` from a schedule `run` handler, or `ctx.to(channel, target).send(message, { auth })` from another channel. The target is a serialized Chat SDK thread, or `{ threadId, adapterName }` when you only have a provider-native thread id:
|
package/docs/channels/custom.mdx
CHANGED
|
@@ -67,11 +67,14 @@ Each route receives these operation surfaces:
|
|
|
67
67
|
- `attachSession(sessionId)` creates an I/O-free handle pinned to one durable session ID.
|
|
68
68
|
- `to(channel, target).send(message, options)` hands work to another authored channel.
|
|
69
69
|
- `params`, `waitUntil`, and `requestIp` provide request metadata and lifetime control.
|
|
70
|
-
- `describe()` returns the agent's name, description,
|
|
71
|
-
- `invokeTool(name, input, { auth })` runs one of those tools as `auth`, outside any conversation: no model, turn, or workflow run.
|
|
70
|
+
- `describe()` returns the agent's name, description, the compiled tools a caller can run outside a turn, with their JSON schemas, and the compiled skills, each with its `name` and `description`, sorted by name. It reads the compiled manifest only, never a skill file, and carries no other paths, config, or inspection detail, so a channel can publish it to its callers. Tools that need a turn (framework tools, workflow and provider tools, tools without `execute`) and tools and skills added by dynamic resolvers or subagents are left out.
|
|
71
|
+
- `invokeTool(name, input, { auth, key })` runs one of those tools as `auth`, outside any conversation: no model, turn, or workflow run. Authored state starts from its initial value and is not kept. Without `key`, each call gets its own session, and a sandbox the tool opens is deleted when the call ends. With `key` (1 to 512 characters), calls from the same `auth` principal with the same key share a session id and a sandbox, which is kept between calls; this needs Vercel Sandbox or just-bash, and an authenticated `auth` (a keyed call from the anonymous principal is `denied`); see [MCP tool sessions](./mcp#tool-sessions). When a trusted forwarder asserted `auth`, pass the principal your route verified as `forwardedBy`: it is part of the session, so one user reached through two forwarders gets two sessions. It resolves to `completed` with the tool's output, or to `invalid-input`, `denied`, `failed`, `approval-required` when the tool's approval policy asks a person (the tool did not run), or `authorization-required` with the connections the tool needs a sign-in to.
|
|
72
72
|
|
|
73
73
|
A direct call doesn't go through the AI SDK, so AI SDK telemetry integrations never see it. Conversation tool calls do: an integration that an `agent/instrumentation/*.ts` module registers with `registerTelemetry()` from `ai` receives `onToolExecutionStart` and `onToolExecutionEnd` for each of them. A direct call is traced by eve itself instead. It gets an `execute_tool` span under the caller's trace and emits `tool.call.started` and `tool.call.completed` to instrumentation. Over MCP, the caller's trace comes from the request's `_meta` trace context (see [Trace context](./mcp#trace-context)).
|
|
74
74
|
|
|
75
|
+
- `listSkillFiles(skill)` resolves to the skill's regular files, each with its `path` under the skill root and its `size` in bytes, sorted by path. It rejects a skill the agent does not have.
|
|
76
|
+
- `readSkill(skill, path?)` resolves to one skill file's raw bytes as a `Uint8Array`; decode text yourself, for example with `new TextDecoder().decode(bytes)`. `path` is relative to the skill root, such as `references/api.md`, and defaults to the skill's `SKILL.md`. It rejects absolute paths, paths with `.`, `..`, or empty segments, files the skill does not list, and files over 512 KiB.
|
|
77
|
+
|
|
75
78
|
Event handlers receive `(eventData, channel, ctx)`. `ctx.session.id` identifies
|
|
76
79
|
the exact session, while `channel.continuation` exposes the current address and
|
|
77
80
|
`alias()` when this channel needs to add another address. `session.failed`
|
|
@@ -94,6 +94,28 @@ Typing fires on `turn.started` and `actions.requested`, but only when a bot toke
|
|
|
94
94
|
|
|
95
95
|
HITL renders as Discord components. Confirmations and options become buttons, `display: "select"` becomes a string select, and freeform input becomes a button that opens a modal. When the user responds, the parked session (paused awaiting input) resumes.
|
|
96
96
|
|
|
97
|
+
A press, select, or modal submission answers as the Discord user who made it, with the same `defaultDiscordAuth` principal a command from them gets by default. Approval response policies compare against that principal. Approvals are requester-only by default, so only the person whose command asked can approve. `onInputResponse(ctx, interaction)` decides the answer's `auth`: return `{ auth }` to accept it, or `null` (or throw) to drop it and keep the request pending. `ctx.defaultAuth` is the presser's `defaultDiscordAuth`; it identifies them but doesn't authorize them by itself.
|
|
98
|
+
|
|
99
|
+
If you customize `onCommand`, eve drops every press and submission until you also set `onInputResponse`, and logs a warning saying so. The default Discord principal wouldn't match the principals your `onCommand` returns, so a requester-only approval would refuse the requester. It would also let someone your `onCommand` turns away answer open approvals. Give both hooks the same mapping and gating:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { discordChannel } from "eve/channels/discord";
|
|
103
|
+
|
|
104
|
+
const auth = (interaction: { user: { id: string } }) => ({
|
|
105
|
+
auth: {
|
|
106
|
+
principalId: `user:${interaction.user.id}`,
|
|
107
|
+
principalType: "user" as const,
|
|
108
|
+
authenticator: "discord",
|
|
109
|
+
attributes: {},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export default discordChannel({
|
|
114
|
+
onCommand: (_ctx, interaction) => auth(interaction),
|
|
115
|
+
onInputResponse: (_ctx, interaction) => auth(interaction),
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
97
119
|
### Proactive sessions
|
|
98
120
|
|
|
99
121
|
Start a session without an inbound interaction through `to(discord, target).send(message, { auth })` from a schedule `run` handler, or `ctx.to(discord, target).send(message, { auth })` from another channel. The proactive target shape is `{ channelId, conversationId?, initialMessage? }`. Either path needs a bot token, supplied by Connect or `DISCORD_BOT_TOKEN`.
|