eve 0.34.0 → 0.35.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 +18 -0
- package/README.md +3 -3
- package/dist/src/chunks/{use-eve-agent-BNdcle_M.js → use-eve-agent-COmP-H8R.js} +6 -3
- package/dist/src/chunks/{use-eve-agent-FJkEMXYk.js → use-eve-agent-CnppTEFk.js} +6 -3
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/commands/trace-detail.d.ts +3 -2
- package/dist/src/cli/commands/trace-detail.js +1 -1
- package/dist/src/cli/dev/tui/traces/trace-conversation.d.ts +4 -6
- package/dist/src/cli/dev/tui/traces/trace-conversation.js +1 -2
- package/dist/src/client/agent-info-schema.d.ts +12 -4
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/compiled/.vendor-stamp.json +3 -3
- package/dist/src/compiled/@chat-adapter/slack/index.js +1 -1
- package/dist/src/compiled/@workflow/core/index.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world/env-config.d.ts +1 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +92 -35
- package/dist/src/compiled/@workflow/world/index.d.ts +3 -2
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +25 -23
- package/dist/src/compiled/@workflow/world/queue.d.ts +4 -0
- package/dist/src/compiled/@workflow/world/runs.d.ts +4 -0
- package/dist/src/compiled/@workflow/world/slot-identity.d.ts +53 -0
- package/dist/src/compiled/@workflow/world/spec-version.d.ts +36 -1
- package/dist/src/compiled/@workflow/world/steps.d.ts +4 -0
- package/dist/src/compiled/@workflow/world/ulid.d.ts +6 -0
- package/dist/src/compiled/@workflow/world-local/index.js +4 -4
- package/dist/src/compiled/@workflow/world-vercel/index.js +13 -17
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-6OqdYdi4.js → attribute-changes-BoH7JsWp.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/dist-DlFv0aHY.js +40 -0
- package/dist/src/compiled/_chunks/workflow/env-config-DxamfI7T.js +1 -0
- package/dist/src/compiled/_chunks/workflow/frames-CTpeJYEQ.js +3 -0
- package/dist/src/compiled/_chunks/workflow/{functions-CXb61C6h.js → functions-CeeNvKsq.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-BPQHjeY5.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-DQ5dOyjm.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-id-BdE0MZz9.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-CzdoBiqy.js +1 -0
- package/dist/src/compiled/_chunks/workflow/spec-version-DBUVfF_R.js +1 -0
- package/dist/src/compiled/_chunks/workflow/undici-CUIybhQ2.js +95 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-DK2lnH6U.js +15 -0
- package/dist/src/compiled/_chunks/workflow/{wrapper-CDq65xJV.js → wrapper-CMGju7QA.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/ws-transport-Csi6Cydc.js +1 -0
- package/dist/src/compiler/extension-compatibility.d.ts +10 -10
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +8 -8
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-extension.d.ts +3 -3
- package/dist/src/compiler/normalize-extension.js +1 -1
- package/dist/src/compiler/normalize-instructions.d.ts +1 -1
- package/dist/src/compiler/normalize-instructions.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -3
- package/dist/src/context/dynamic-instruction-lifecycle.d.ts +5 -1
- package/dist/src/context/dynamic-instruction-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +6 -2
- package/dist/src/context/keys.js +1 -1
- package/dist/src/discover/manifest.d.ts +1 -1
- package/dist/src/discover/manifest.js +1 -1
- package/dist/src/evals/index.d.ts +2 -2
- package/dist/src/evals/reporters/index.d.ts +1 -1
- package/dist/src/evals/runner/artifacts.js +1 -1
- package/dist/src/evals/runner/execute-eval.d.ts +5 -0
- package/dist/src/evals/runner/execute-eval.js +1 -1
- package/dist/src/evals/runner/execute-task.d.ts +3 -0
- package/dist/src/evals/runner/execute-task.js +1 -1
- package/dist/src/evals/runner/reporters/braintrust.js +1 -1
- package/dist/src/evals/runner/reporters/types.d.ts +28 -2
- package/dist/src/evals/runner/run-evals.js +1 -1
- package/dist/src/evals/session.d.ts +11 -2
- package/dist/src/evals/session.js +1 -1
- package/dist/src/evals/target.js +1 -1
- package/dist/src/evals/types.d.ts +10 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/session.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/execution/workflow-trace-context.d.ts +11 -0
- package/dist/src/execution/workflow-trace-context.js +1 -0
- package/dist/src/harness/ai-sdk-hook-bridge.d.ts +1 -1
- package/dist/src/harness/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/harness/channel-delivery-instrumentation.d.ts +1 -1
- package/dist/src/harness/channel-delivery-instrumentation.js +1 -1
- package/dist/src/harness/emission.d.ts +2 -2
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/instrumentation/config.js +1 -0
- package/dist/src/harness/{instrumentation-content.d.ts → instrumentation/content.d.ts} +1 -1
- package/dist/src/harness/{instrumentation-dispatch.d.ts → instrumentation/dispatch.d.ts} +1 -1
- package/dist/src/harness/{instrumentation-dispatch.js → instrumentation/dispatch.js} +1 -1
- package/dist/src/harness/{instrumentation-lifecycle.d.ts → instrumentation/lifecycle.d.ts} +3 -6
- package/dist/src/harness/{instrumentation-lifecycle.js → instrumentation/lifecycle.js} +1 -1
- package/dist/src/harness/{instrumentation-native-events.d.ts → instrumentation/native-events.d.ts} +1 -1
- package/dist/src/harness/{instrumentation-native-events.js → instrumentation/native-events.js} +1 -1
- package/dist/src/harness/{instrumentation-providers.d.ts → instrumentation/providers.d.ts} +1 -1
- package/dist/src/harness/{instrumentation-providers.js → instrumentation/providers.js} +1 -1
- package/dist/src/harness/{instrumentation-runtime.d.ts → instrumentation/runtime.d.ts} +4 -2
- package/dist/src/harness/{instrumentation-state.d.ts → instrumentation/state.d.ts} +1 -1
- package/dist/src/harness/parent-lineage.d.ts +1 -1
- package/dist/src/harness/prepare-trace-context.d.ts +16 -0
- package/dist/src/harness/prepare-trace-context.js +1 -0
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/types.d.ts +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +2 -2
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.d.ts +3 -3
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/helpers/markdown.js +1 -1
- package/dist/src/internal/instrumentation.d.ts +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +4 -3
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/channel-request-instrumentation.js +1 -1
- package/dist/src/internal/vercel/project-link.d.ts +1 -1
- package/dist/src/internal/vercel/project-link.js +1 -1
- package/dist/src/internal/vercel-agent-summary.d.ts +10 -9
- package/dist/src/internal/vercel-agent-summary.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/protocol/message.d.ts +15 -1
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/public/channels/github/auth.d.ts +30 -0
- package/dist/src/public/channels/github/auth.js +2 -2
- package/dist/src/public/channels/github/defaults.d.ts +4 -4
- package/dist/src/public/channels/github/defaults.js +1 -1
- package/dist/src/public/channels/github/dispatch.d.ts +3 -2
- package/dist/src/public/channels/github/dispatch.js +1 -1
- package/dist/src/public/channels/github/githubChannel.d.ts +7 -2
- package/dist/src/public/channels/github/githubChannel.js +1 -1
- package/dist/src/public/channels/github/index.d.ts +1 -1
- package/dist/src/public/definitions/instructions.d.ts +14 -4
- package/dist/src/public/definitions/instructions.js +1 -1
- package/dist/src/public/definitions/tool.d.ts +5 -8
- package/dist/src/public/instructions/index.d.ts +1 -2
- package/dist/src/public/instructions/index.js +1 -1
- package/dist/src/public/instrumentation/index.d.ts +4 -3
- package/dist/src/public/instrumentation/otel.d.ts +5 -4
- package/dist/src/public/instrumentation/provider.d.ts +2 -2
- package/dist/src/runtime/agent/bootstrap.d.ts +2 -0
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/runtime/prompt/compose.d.ts +1 -1
- package/dist/src/runtime/prompt/compose.js +3 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/types.d.ts +4 -3
- package/dist/src/setup/project-resolution.d.ts +3 -3
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/slack-connect-lifecycle.d.ts +0 -9
- package/dist/src/setup/slack-connect-lifecycle.js +1 -1
- package/dist/src/setup/slackbot.d.ts +2 -1
- package/dist/src/setup/slackbot.js +1 -1
- package/dist/src/shared/dynamic-tool-definition.d.ts +3 -4
- package/dist/src/shared/instructions-definition.d.ts +15 -11
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tracing/agent-action-instrumentation.d.ts +1 -1
- package/dist/src/tracing/agent-action-instrumentation.js +1 -1
- package/dist/src/tracing/agent-approval-instrumentation.d.ts +1 -1
- package/dist/src/tracing/agent-channel-delivery-instrumentation.d.ts +1 -1
- package/dist/src/tracing/agent-channel-delivery-instrumentation.js +1 -1
- package/dist/src/tracing/agent-otel-provider.d.ts +4 -2
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-session-context.d.ts +17 -0
- package/dist/src/tracing/agent-otel-session-context.js +1 -0
- package/dist/src/tracing/agent-otel-usage.d.ts +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.d.ts +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
- package/dist/src/tracing/agent-trace-state.d.ts +1 -1
- package/dist/src/tracing/install-instrumentation-runtime.d.ts +2 -2
- package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
- package/dist/src/tracing/local-instrumentation-runtime.d.ts +1 -1
- package/dist/src/tracing/local-instrumentation-runtime.js +1 -1
- package/dist/src/tracing/local-traces.d.ts +3 -3
- package/dist/src/tracing/local-traces.js +1 -1
- package/dist/src/tracing/otel-declaration.d.ts +2 -2
- package/dist/src/tracing/otel-declaration.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/README.md +18 -20
- package/docs/agent-config.md +5 -5
- package/docs/channels/eve.mdx +10 -56
- package/docs/channels/github.mdx +1 -1
- package/docs/channels/meta.json +1 -0
- package/docs/concepts/context-control.md +32 -56
- package/docs/concepts/default-harness.md +2 -2
- package/docs/concepts/execution-model-and-durability.mdx +4 -4
- package/docs/concepts/meta.json +3 -1
- package/docs/concepts/sessions-runs-and-streaming.md +22 -10
- package/docs/{guides → concepts}/state.md +3 -3
- package/docs/connections/mcp.mdx +6 -89
- package/docs/connections/meta.json +1 -0
- package/docs/connections/openapi.mdx +5 -69
- package/docs/connections/overview.mdx +29 -3
- package/docs/evals/meta.json +1 -0
- package/docs/evals/reporters.mdx +14 -4
- package/docs/extensions.md +1 -1
- package/docs/getting-started.mdx +175 -13
- package/docs/guides/auth-and-route-protection.md +3 -18
- package/docs/guides/client/meta.json +2 -1
- package/docs/guides/client/output-schema.mdx +2 -2
- package/docs/guides/client/overview.mdx +1 -1
- package/docs/guides/deployment/meta.json +1 -0
- package/docs/guides/deployment/overview.md +1 -1
- package/docs/guides/deployment/self-hosting.md +3 -3
- package/docs/guides/deployment/vercel.mdx +1 -1
- package/docs/guides/dev-tui.md +3 -13
- package/docs/guides/dynamic-capabilities.md +26 -4
- package/docs/guides/frontend/meta.json +2 -1
- package/docs/guides/frontend/nextjs.mdx +1 -10
- package/docs/guides/frontend/nuxt.mdx +1 -10
- package/docs/guides/frontend/overview.mdx +12 -3
- package/docs/guides/frontend/sveltekit.mdx +1 -10
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +39 -126
- package/docs/guides/frontend/use-eve-agent-vue.mdx +40 -139
- package/docs/guides/instrumentation.md +15 -15
- package/docs/guides/meta.json +1 -5
- package/docs/guides/remote-agents.md +9 -9
- package/docs/guides/session-context.md +34 -103
- package/docs/install-integrations.mdx +1 -1
- package/docs/instructions.mdx +45 -12
- package/docs/meta.json +24 -13
- package/docs/patterns/dynamic-scheduling.md +1 -1
- package/docs/patterns/meta.json +1 -0
- package/docs/patterns/multi-tenant-approvals.md +1 -1
- package/docs/patterns/multi-tenant-auth.md +1 -1
- package/docs/patterns/multi-tenant-memory.md +4 -3
- package/docs/{guides → protocols}/acp.md +1 -1
- package/docs/protocols/meta.json +5 -0
- package/docs/reference/cli.md +34 -34
- package/docs/reference/meta.json +1 -1
- package/docs/reference/typescript-api.md +4 -2
- package/docs/{subagents.mdx → subagents/index.mdx} +2 -2
- package/docs/subagents/meta.json +5 -0
- package/docs/{guides/dynamic-workflows.md → subagents/workflow-tool.md} +6 -6
- package/docs/tools/human-in-the-loop.md +1 -1
- package/docs/tools/meta.json +1 -0
- package/docs/tools/overview.mdx +1 -1
- package/docs/tutorial/connect-a-warehouse.mdx +1 -1
- package/docs/tutorial/meta.json +1 -0
- package/docs/tutorial/remember-definitions.mdx +2 -2
- package/docs/tutorial/ship-it.mdx +2 -2
- package/package.json +4 -4
- package/dist/src/compiled/_chunks/workflow/dist-C8PhDW9B.js +0 -1
- package/dist/src/compiled/_chunks/workflow/functions-xMPAeWFr.js +0 -1
- package/dist/src/compiled/_chunks/workflow/node-Smb57EnG.js +0 -40
- package/dist/src/compiled/_chunks/workflow/resume-hook-BrduAuFX.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-CX7_sJnW.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-tsb2HjWK.js +0 -1
- package/dist/src/compiled/_chunks/workflow/undici-BNc_0O4m.js +0 -95
- package/dist/src/compiled/_chunks/workflow/wait-until-BYKVqrwc.js +0 -15
- package/dist/src/harness/instrumentation-config.js +0 -1
- package/docs/installation.mdx +0 -66
- package/docs/project-structure.mdx +0 -53
- package/docs/reference/project-layout.md +0 -123
- /package/dist/src/harness/{instrumentation-config.d.ts → instrumentation/config.d.ts} +0 -0
- /package/dist/src/harness/{instrumentation-content.js → instrumentation/content.js} +0 -0
- /package/dist/src/harness/{instrumentation-runtime-context.d.ts → instrumentation/runtime-context.d.ts} +0 -0
- /package/dist/src/harness/{instrumentation-runtime-context.js → instrumentation/runtime-context.js} +0 -0
- /package/dist/src/harness/{instrumentation-runtime.js → instrumentation/runtime.js} +0 -0
- /package/dist/src/harness/{instrumentation-setup-context.d.ts → instrumentation/setup-context.d.ts} +0 -0
- /package/dist/src/harness/{instrumentation-setup-context.js → instrumentation/setup-context.js} +0 -0
- /package/dist/src/harness/{instrumentation-state.js → instrumentation/state.js} +0 -0
- /package/docs/{guides → protocols}/ucp.mdx +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile}from"node:fs/promises";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{basename,join}from"node:path";import{LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH}from"#internal/workflow/local-world-data-directory.js";import{turnWorkflowReference}from"#execution/workflow-runtime.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{DEVELOPMENT_WORKER_APP_ROOT_ENV,DEVELOPMENT_WORKFLOW_DELIVERY_HEADER,DEVELOPMENT_WORKFLOW_SECRET_ENV,DEVELOPMENT_WORKFLOW_STREAM_ROUTE,DEVELOPMENT_WORKFLOW_TRANSPORT_HEADER,DEVELOPMENT_WORKFLOW_WORLD_ROUTE,DEVELOPMENT_WORLD_OPERATIONS}from"#internal/workflow/development-world-protocol.js";import{timingSafeEqualStrings}from"#internal/nitro/dev-client-address.js";import{decodeDevelopmentWorldJson,decodeDevelopmentWorldValue,deserializeDevelopmentWorldError,encodeDevelopmentWorldValue}from"#internal/workflow/development-world-codec.js";import{getDevelopmentWorkflowGeneration,withDevelopmentWorkflowGeneration}from"#internal/workflow/development-generation-context.js";var MissingDevelopmentGenerationError=class extends Error{constructor(e,t){super(`Workflow run references missing development generation "${e}". Remove "${LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH}" to discard the app's active local Workflow runs.`,t===void 0?void 0:{cause:t}),this.name=`MissingDevelopmentGenerationError`}};async function call(e,t=[]){return decodeDevelopmentWorldValue(await(await fetchDevelopmentWorld(DEVELOPMENT_WORKFLOW_WORLD_ROUTE,{body:encodeDevelopmentWorldValue({arguments:t,operation:e}),method:`POST`})).text())}function createDevelopmentWorkflowWorld(){let e=buildForwardedOperations();return{specVersion:5,
|
|
1
|
+
import{readFile}from"node:fs/promises";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{basename,join}from"node:path";import{LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH}from"#internal/workflow/local-world-data-directory.js";import{turnWorkflowReference}from"#execution/workflow-runtime.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{DEVELOPMENT_WORKER_APP_ROOT_ENV,DEVELOPMENT_WORKFLOW_DELIVERY_HEADER,DEVELOPMENT_WORKFLOW_SECRET_ENV,DEVELOPMENT_WORKFLOW_STREAM_ROUTE,DEVELOPMENT_WORKFLOW_TRANSPORT_HEADER,DEVELOPMENT_WORKFLOW_WORLD_ROUTE,DEVELOPMENT_WORLD_OPERATIONS}from"#internal/workflow/development-world-protocol.js";import{timingSafeEqualStrings}from"#internal/nitro/dev-client-address.js";import{decodeDevelopmentWorldJson,decodeDevelopmentWorldValue,deserializeDevelopmentWorldError,encodeDevelopmentWorldValue}from"#internal/workflow/development-world-codec.js";import{getDevelopmentWorkflowGeneration,withDevelopmentWorkflowGeneration}from"#internal/workflow/development-generation-context.js";var MissingDevelopmentGenerationError=class extends Error{constructor(e,t){super(`Workflow run references missing development generation "${e}". Remove "${LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH}" to discard the app's active local Workflow runs.`,t===void 0?void 0:{cause:t}),this.name=`MissingDevelopmentGenerationError`}};async function call(e,t=[]){return decodeDevelopmentWorldValue(await(await fetchDevelopmentWorld(DEVELOPMENT_WORKFLOW_WORLD_ROUTE,{body:encodeDevelopmentWorldValue({arguments:t,operation:e}),method:`POST`})).text())}function createDevelopmentWorkflowWorld(){let e=buildForwardedOperations();return{specVersion:5,async getDeploymentId(){return getDevelopmentWorkflowGeneration()?.generationId??await call(`getDeploymentId`)},resolveLatestDeploymentId:e.topLevel.resolveLatestDeploymentId,queue:e.topLevel.queue,createQueueHandler,runs:e.groups.runs,steps:e.groups.steps,events:e.groups.events,hooks:e.groups.hooks,streams:{...e.groups.streams,get:async(e,t,n)=>{let r=new URL(resolveDevelopmentWorldBaseUrl());r.pathname=DEVELOPMENT_WORKFLOW_STREAM_ROUTE,r.searchParams.set(`runId`,e),r.searchParams.set(`name`,t),n!==void 0&&r.searchParams.set(`startIndex`,String(n));let i=await fetchDevelopmentWorld(r,{method:`GET`});if(i.body===null)throw Error(`Development Workflow stream response had no body.`);return i.body}},async start(){},async close(){}}}function buildForwardedOperations(){let e={},t={};for(let n of DEVELOPMENT_WORLD_OPERATIONS){let forward=async(...e)=>await call(n,e),r=n.indexOf(`.`);r===-1?t[n]=forward:(e[n.slice(0,r)]??={})[n.slice(r+1)]=forward}return{groups:e,topLevel:t}}function createQueueHandler(e,n){return async r=>{let i=readRequiredEnvironment(DEVELOPMENT_WORKFLOW_SECRET_ENV),a=r.headers.get(DEVELOPMENT_WORKFLOW_DELIVERY_HEADER);if(a===null||!timingSafeEqualStrings(a,i))return Response.json({error:`Workflow delivery is not trusted.`},{status:401});let c=r.headers.get(`x-vqs-queue-name`),l=r.headers.get(`x-vqs-message-id`),u=Number(r.headers.get(`x-vqs-message-attempt`));if(c===null||!c.startsWith(e)||l===null||!Number.isInteger(u)||u<1||r.body===null)return Response.json({error:`Workflow delivery is malformed.`},{status:400});let d=decodeDevelopmentWorldJson(await r.text());try{let e=readRequiredEnvironment(DEVELOPMENT_WORKER_APP_ROOT_ENV),r=await resolveDeliveryGenerationId(d),i=await withDevelopmentWorkflowGeneration({generationId:r,source:createDiskRuntimeCompiledArtifactsSource(await readGenerationRuntimeAppRoot(e,r),{durableReference:`development-generation`,moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:e})},async()=>await n(d,{attempt:u,messageId:l,queueName:c}));return Response.json(i===void 0?{ok:!0}:{timeoutSeconds:i.timeoutSeconds})}catch(e){return e instanceof MissingDevelopmentGenerationError?(console.error(`[eve:dev] ${e.message}`),Response.json({ok:!0})):Response.json(String(e),{status:500})}}}async function resolveDeliveryGenerationId(e){if(!isRecord(e))return await call(`resolveLatestDeploymentId`);let t=isRecord(e.runInput)?e.runInput:void 0;if(t!==void 0)return t.workflowName===turnWorkflowReference.workflowId&&typeof t.deploymentId==`string`?t.deploymentId:await call(`resolveLatestDeploymentId`);let n=typeof e.runId==`string`?e.runId:typeof e.workflowRunId==`string`?e.workflowRunId:void 0;if(n===void 0)return await call(`resolveLatestDeploymentId`);let r=await call(`runs.get`,[n,{resolveData:`none`}]);return r.workflowName===turnWorkflowReference.workflowId?r.deploymentId:await call(`resolveLatestDeploymentId`)}async function readGenerationRuntimeAppRoot(t,i){if(i.length===0||i===`.`||i===`..`||basename(i)!==i)throw Error(`Workflow run references invalid development generation "${i}".`);let a=join(t,`.eve`,`dev-runtime`,`snapshots`,i,`generation.json`),o;try{o=await readFile(a,`utf8`)}catch(e){throw isFileNotFoundError(e)?new MissingDevelopmentGenerationError(i,e):e}let s;try{s=JSON.parse(o)}catch(e){throw Error(`Development generation "${i}" has invalid metadata.`,{cause:e})}if(!isRecord(s)||typeof s.runtimeAppRoot!=`string`)throw Error(`Development generation "${i}" has invalid metadata.`);return s.runtimeAppRoot}function isFileNotFoundError(e){return e instanceof Error&&`code`in e&&e.code===`ENOENT`}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function fetchDevelopmentWorld(e,t){let n=e instanceof URL?e:new URL(e,resolveDevelopmentWorldBaseUrl()),r=new Headers(t.headers);r.set(DEVELOPMENT_WORKFLOW_TRANSPORT_HEADER,readRequiredEnvironment(DEVELOPMENT_WORKFLOW_SECRET_ENV));let i=await fetch(n,{...t,headers:r});if(!i.ok){let e=await i.text(),t=readDevelopmentWorldError(e);throw t===void 0?Error(`Development Workflow World request failed (${String(i.status)}): ${e}`):t}return i}function readDevelopmentWorldError(e){try{return deserializeDevelopmentWorldError(decodeDevelopmentWorldValue(e))}catch{return}}function resolveDevelopmentWorldBaseUrl(){return readRequiredEnvironment(`WORKFLOW_LOCAL_BASE_URL`)}function readRequiredEnvironment(e){let t=process.env[e];if(t===void 0||t.length===0)throw Error(`Development Workflow transport is missing ${e}.`);return t}export{MissingDevelopmentGenerationError,createDevelopmentWorkflowWorld};
|
|
@@ -9,7 +9,7 @@ export declare const EVE_STREAM_TAIL_INDEX_HEADER = "x-eve-stream-tail-index";
|
|
|
9
9
|
export declare const EVE_STREAM_VERSION_HEADER = "x-eve-stream-version";
|
|
10
10
|
export declare const EVE_MESSAGE_STREAM_CONTENT_TYPE = "application/x-ndjson; charset=utf-8";
|
|
11
11
|
export declare const EVE_MESSAGE_STREAM_FORMAT = "ndjson";
|
|
12
|
-
export declare const EVE_MESSAGE_STREAM_VERSION = "
|
|
12
|
+
export declare const EVE_MESSAGE_STREAM_VERSION = "22";
|
|
13
13
|
/**
|
|
14
14
|
* eve-owned finish reason for one completed assistant step.
|
|
15
15
|
*
|
|
@@ -90,6 +90,16 @@ export interface RuntimeIdentity {
|
|
|
90
90
|
readonly gitSha?: string;
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Portable trace coordinates for correlating an eve run with an external
|
|
95
|
+
* observability backend. The fields follow the W3C trace-context model while
|
|
96
|
+
* remaining owned by eve rather than exposing an OpenTelemetry type.
|
|
97
|
+
*/
|
|
98
|
+
export interface RuntimeTraceContext {
|
|
99
|
+
readonly traceId: string;
|
|
100
|
+
readonly spanId: string;
|
|
101
|
+
readonly traceFlags: number;
|
|
102
|
+
}
|
|
93
103
|
/**
|
|
94
104
|
* JSON request accepted by the canonical message route.
|
|
95
105
|
*
|
|
@@ -117,6 +127,7 @@ export interface SessionStartedStreamEvent {
|
|
|
117
127
|
data: {
|
|
118
128
|
invocation?: SubagentSessionInvocationMetadata;
|
|
119
129
|
runtime?: RuntimeIdentity;
|
|
130
|
+
trace?: RuntimeTraceContext;
|
|
120
131
|
};
|
|
121
132
|
type: "session.started";
|
|
122
133
|
}
|
|
@@ -126,6 +137,7 @@ export interface SessionStartedStreamEvent {
|
|
|
126
137
|
export interface TurnStartedStreamEvent {
|
|
127
138
|
data: {
|
|
128
139
|
sequence: number;
|
|
140
|
+
trace?: RuntimeTraceContext;
|
|
129
141
|
turnId: string;
|
|
130
142
|
};
|
|
131
143
|
type: "turn.started";
|
|
@@ -612,12 +624,14 @@ export declare function isTurnFailureEvent<TEvent extends UnstampedMessageStream
|
|
|
612
624
|
export declare function createSessionStartedEvent(input?: {
|
|
613
625
|
readonly invocation?: SubagentSessionInvocationMetadata;
|
|
614
626
|
readonly runtime?: RuntimeIdentity;
|
|
627
|
+
readonly trace?: RuntimeTraceContext;
|
|
615
628
|
}): SessionStartedStreamEvent;
|
|
616
629
|
/**
|
|
617
630
|
* Creates the `turn.started` event for one prepared runtime turn.
|
|
618
631
|
*/
|
|
619
632
|
export declare function createTurnStartedEvent(input: {
|
|
620
633
|
readonly sequence: number;
|
|
634
|
+
readonly trace?: RuntimeTraceContext;
|
|
621
635
|
readonly turnId: string;
|
|
622
636
|
}): TurnStartedStreamEvent;
|
|
623
637
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{deserializeUrlFilePart,hasInternalRefScheme,isSerializedUrlFilePart}from"#internal/attachments/url-refs.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";import{decodeSandboxRef,isSandboxRefUrl}from"#internal/attachments/sandbox-refs.js";import{createEventId}from"#protocol/event-id.js";const EVE_SESSION_ID_HEADER=`x-eve-session-id`,EVE_STREAM_FORMAT_HEADER=`x-eve-stream-format`,EVE_STREAM_TAIL_INDEX_HEADER=`x-eve-stream-tail-index`,EVE_STREAM_VERSION_HEADER=`x-eve-stream-version`,EVE_MESSAGE_STREAM_CONTENT_TYPE=`application/x-ndjson; charset=utf-8`,EVE_MESSAGE_STREAM_FORMAT=`ndjson`,EVE_MESSAGE_STREAM_VERSION=`
|
|
1
|
+
import{deserializeUrlFilePart,hasInternalRefScheme,isSerializedUrlFilePart}from"#internal/attachments/url-refs.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";import{decodeSandboxRef,isSandboxRefUrl}from"#internal/attachments/sandbox-refs.js";import{createEventId}from"#protocol/event-id.js";const EVE_SESSION_ID_HEADER=`x-eve-session-id`,EVE_STREAM_FORMAT_HEADER=`x-eve-stream-format`,EVE_STREAM_TAIL_INDEX_HEADER=`x-eve-stream-tail-index`,EVE_STREAM_VERSION_HEADER=`x-eve-stream-version`,EVE_MESSAGE_STREAM_CONTENT_TYPE=`application/x-ndjson; charset=utf-8`,EVE_MESSAGE_STREAM_FORMAT=`ndjson`,EVE_MESSAGE_STREAM_VERSION=`22`,textEncoder=new TextEncoder;function isCurrentTurnBoundaryEvent(e){return e.type===`session.completed`||e.type===`session.failed`||e.type===`session.waiting`}function isTurnFailureEvent(e){return e.type===`session.failed`||e.type===`step.failed`||e.type===`turn.failed`}function createSessionStartedEvent(e){let t={};return e?.invocation!==void 0&&(t.invocation=e.invocation),e?.runtime!==void 0&&(t.runtime=e.runtime),e?.trace!==void 0&&(t.trace=e.trace),{data:t,type:`session.started`}}function createTurnStartedEvent(e){let t={sequence:e.sequence,turnId:e.turnId};return e.trace!==void 0&&(t.trace=e.trace),{data:t,type:`turn.started`}}function createMessageReceivedEvent(e){return{data:{message:summarizeUserContent(e.message),parts:projectUserContentParts(e.message),sequence:e.sequence,turnId:e.turnId},type:`message.received`}}function summarizeUserContent(e){if(typeof e==`string`)return e;let t=[];for(let n of e)if(n.type===`text`)t.push(n.text);else if(n.type===`file`){let e=n.filename??n.mediaType;t.push(`[file: ${e} (${n.mediaType})]`)}else n.type===`image`&&t.push(`[image: ${n.mediaType??`image`}]`);return t.join(`
|
|
2
2
|
`)}function projectUserContentParts(e){if(typeof e==`string`)return[{text:e,type:`text`}];let t=[];for(let n of e)n.type===`text`?t.push({text:n.text,type:`text`}):n.type===`file`?t.push(projectFileLikePart(n.data,n.mediaType,n.filename)):n.type===`image`&&t.push(projectFileLikePart(n.image,n.mediaType??`application/octet-stream`,void 0));return t}function projectFileLikePart(e,t,n){if(isSandboxRefUrl(e)){let t=decodeSandboxRef(e);return createProjectedFilePart({filename:basenameOf(n??t.path),mediaType:t.mediaType,size:t.size})}let r=projectTaggedFileData(e,t,n);if(r!==void 0)return r;let i=byteLengthOf(e);return createProjectedFilePart(i===void 0?{filename:n,mediaType:t,...clientUrlFragment(e)}:{filename:n,mediaType:t,size:i})}function projectTaggedFileData(e,t,n){if(isTaggedFileData(e))switch(e.type){case`data`:{let r=byteLengthOf(e.data);return createProjectedFilePart(r===void 0?{filename:n,mediaType:t}:{filename:n,mediaType:t,size:r})}case`reference`:case`text`:return createProjectedFilePart({filename:n,mediaType:t});case`url`:return createProjectedFilePart({filename:n,mediaType:t,...clientUrlFragment(e.url)})}}function createProjectedFilePart(e){let t={mediaType:e.mediaType,type:`file`};return e.filename!==void 0&&(t.filename=e.filename),e.size!==void 0&&(t.size=e.size),e.url!==void 0&&(t.url=e.url),t}function isTaggedFileData(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`data`||t===`reference`||t===`text`||t===`url`}function byteLengthOf(e){if(e instanceof Uint8Array||e instanceof ArrayBuffer)return e.byteLength}function clientUrlFragment(r){if(isSerializedUrlFilePart(r))try{let t=deserializeUrlFilePart(r);return isClientResolvableUrl(t)?{url:t.href}:{}}catch{return{}}if(r instanceof URL)return isClientResolvableUrl(r)?{url:r.href}:{};if(typeof r!=`string`||hasInternalRefScheme(r))return{};if(r.startsWith(`data:`))return{url:r};try{let e=new URL(r);return isClientResolvableUrl(e)?{url:e.href}:{}}catch{return{}}}function isClientResolvableUrl(e){return e.protocol===`http:`||e.protocol===`https:`||e.protocol===`data:`}function basenameOf(e){let t=e.replaceAll(`\\`,`/`),n=t.slice(t.lastIndexOf(`/`)+1);return n.length>0?n:e}function createActionsRequestedEvent(e){return{data:{actions:e.actions,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`actions.requested`}}function createAuthorizationRequiredEvent(e){let t={description:e.description,name:e.name,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId};return e.authorization!==void 0&&(t.authorization=e.authorization),e.candidateId!==void 0&&(t.candidateId=e.candidateId),e.webhookUrl!==void 0&&(t.webhookUrl=e.webhookUrl),{data:t,type:`authorization.required`}}function createAuthorizationCompletedEvent(e){let t={name:e.name,outcome:e.outcome,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId};return e.authorization!==void 0&&(t.authorization=e.authorization),e.candidateId!==void 0&&(t.candidateId=e.candidateId),e.reason!==void 0&&(t.reason=e.reason),{data:t,type:`authorization.completed`}}function createApprovalCandidateEvent(e){return{data:e,type:`approval.candidate`}}function createApprovalSettledEvent(e){return{data:e,type:`approval.settled`}}function createInputRequestedEvent(e){return{data:{requests:e.requests,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`input.requested`}}function createActionResultEvent(e){let t=e.rejected===!0?{error:buildActionResultError(e.result),status:`rejected`}:normalizeActionResultOutcome(e.result);return{data:{error:t.error,result:e.result,sequence:e.sequence,status:t.status,stepIndex:e.stepIndex,turnId:e.turnId},type:`action.result`}}function createActionPartialEvent(e){return{data:{result:e.result,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`action.partial`}}function createSubagentCalledEvent(e){return{data:{callId:e.callId,childSessionId:e.childSessionId,sessionId:e.sessionId,sequence:e.sequence,name:e.name,remote:e.remote,toolName:e.toolName,turnId:e.turnId,workflowId:e.workflowId},type:`subagent.called`}}function createMessageAppendedEvent(e){return{data:{messageDelta:e.messageDelta,messageSoFar:e.messageSoFar,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`message.appended`}}function createReasoningAppendedEvent(e){return{data:{reasoningDelta:e.reasoningDelta,reasoningSoFar:e.reasoningSoFar,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`reasoning.appended`}}function createMessageCompletedEvent(e){return{data:{finishReason:e.finishReason??`stop`,message:e.message,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`message.completed`}}function createReasoningCompletedEvent(e){return{data:{reasoning:e.reasoning,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`reasoning.completed`}}function createResultCompletedEvent(e){return{data:{result:e.result,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`result.completed`}}function createStepStartedEvent(e){return{data:{modelId:e.modelId,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`step.started`}}function createStepCompletedEvent(e){let t={finishReason:e.finishReason,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId};return e.usage!==void 0&&(t.usage=e.usage),e.providerMetadata!==void 0&&(t.providerMetadata=e.providerMetadata),{data:t,type:`step.completed`}}function createStepFailedEvent(e){return{data:{code:e.code,details:e.details,message:e.message,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`step.failed`}}function createTurnCompletedEvent(e){return{data:{sequence:e.sequence,turnId:e.turnId},type:`turn.completed`}}function createTurnFailedEvent(e){return{data:{code:e.code,details:e.details,message:e.message,sequence:e.sequence,turnId:e.turnId},type:`turn.failed`}}function createTurnCancelledEvent(e){return{data:{sequence:e.sequence,turnId:e.turnId},type:`turn.cancelled`}}function createContextClearedEvent(e){return{data:{sequence:e.sequence,sessionId:e.sessionId,turnId:e.turnId},type:`context.cleared`}}function createCompactionRequestedEvent(e){return{data:{modelId:e.modelId,sequence:e.sequence,sessionId:e.sessionId,turnId:e.turnId,usageInputTokens:e.usageInputTokens??null},type:`compaction.requested`}}function createCompactionCompletedEvent(e){return{data:{modelId:e.modelId,sequence:e.sequence,sessionId:e.sessionId,turnId:e.turnId},type:`compaction.completed`}}function createSessionWaitingEvent(e=``){return{data:{continuationToken:toChannelLocalContinuationToken(e),wait:`next-user-message`},type:`session.waiting`}}function createSessionFailedEvent(e){return{data:{code:e.code,details:e.details,message:e.message,sessionId:e.sessionId},type:`session.failed`}}function createSessionCompletedEvent(){return{type:`session.completed`}}function stampMessageStreamEvent(e){return{...e,meta:{at:new Date().toISOString(),id:createEventId()}}}function encodeMessageStreamEvent(e){return textEncoder.encode(`${JSON.stringify(e)}\n`)}function normalizeActionResultOutcome(e){if(e.isError===!0)return{error:buildActionResultError(e),status:`failed`};let t=readActionResultOutputError(e.output);return t===void 0?{status:`completed`}:{error:t,status:`failed`}}function buildActionResultError(e){let t=readActionResultOutputError(e.output);return t===void 0?{code:`ACTION_RESULT_FAILED`,message:formatActionResultOutput(e.output)}:t}function readActionResultOutputError(e){let t=parseActionResultOutputRecord(e);if(t===void 0)return;let n=typeof t.code==`string`&&t.code.length>0?t.code:void 0,r=typeof t.message==`string`&&t.message.length>0?t.message:void 0;if(!(n===void 0||r===void 0))return{code:n,message:r}}function parseActionResultOutputRecord(e){if(typeof e==`object`&&e)return e;if(typeof e!=`string`)return;let t=e.trim();if(t.length!==0)try{let e=JSON.parse(t);if(typeof e==`object`&&e)return e}catch{return}}function formatActionResultOutput(e){if(typeof e==`string`)return e;let t=JSON.stringify(e);return typeof t==`string`&&t.length>0?t:`Action failed.`}export{EVE_MESSAGE_STREAM_CONTENT_TYPE,EVE_MESSAGE_STREAM_FORMAT,EVE_MESSAGE_STREAM_VERSION,EVE_SESSION_ID_HEADER,EVE_STREAM_FORMAT_HEADER,EVE_STREAM_TAIL_INDEX_HEADER,EVE_STREAM_VERSION_HEADER,createActionPartialEvent,createActionResultEvent,createActionsRequestedEvent,createApprovalCandidateEvent,createApprovalSettledEvent,createAuthorizationCompletedEvent,createAuthorizationRequiredEvent,createCompactionCompletedEvent,createCompactionRequestedEvent,createContextClearedEvent,createInputRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createResultCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepCompletedEvent,createStepFailedEvent,createStepStartedEvent,createSubagentCalledEvent,createTurnCancelledEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent,encodeMessageStreamEvent,isCurrentTurnBoundaryEvent,isTurnFailureEvent,stampMessageStreamEvent};
|
|
@@ -12,11 +12,29 @@ export type GitHubWebhookSecret = string | (() => string | Promise<string>);
|
|
|
12
12
|
* as Connect derive the installation token out-of-band and set this field.
|
|
13
13
|
*/
|
|
14
14
|
export type GitHubInstallationToken = string | (() => string | Promise<string>);
|
|
15
|
+
/**
|
|
16
|
+
* The name the channel answers to in `@mentions` (the GitHub App slug,
|
|
17
|
+
* without the `[bot]` suffix), supplied directly or resolved lazily.
|
|
18
|
+
*
|
|
19
|
+
* A lazy resolver runs on first use inside request handling, where
|
|
20
|
+
* credentials that only exist per request (such as the Vercel OIDC token
|
|
21
|
+
* behind Connect metadata lookups) are available; a fulfilled value is
|
|
22
|
+
* cached, and a rejection is retried on the next event instead of pinned.
|
|
23
|
+
*/
|
|
24
|
+
export type GitHubBotName = string | (() => string | Promise<string>);
|
|
15
25
|
/** Credentials used by the native GitHub channel. */
|
|
16
26
|
export interface GitHubChannelCredentials {
|
|
17
27
|
readonly appId?: GitHubAppId;
|
|
18
28
|
readonly privateKey?: GitHubPrivateKey;
|
|
19
29
|
readonly webhookSecret?: GitHubWebhookSecret;
|
|
30
|
+
/**
|
|
31
|
+
* The GitHub App's slug (its `@mention` handle, without the `[bot]`
|
|
32
|
+
* suffix), supplied directly or resolved lazily. Used as the channel's
|
|
33
|
+
* `botName` when the config does not set one, so integrations that broker
|
|
34
|
+
* credentials can make mention dispatch work with no explicit
|
|
35
|
+
* configuration.
|
|
36
|
+
*/
|
|
37
|
+
readonly appSlug?: GitHubBotName;
|
|
20
38
|
/**
|
|
21
39
|
* Pre-resolved GitHub installation access token. When supplied, eve uses
|
|
22
40
|
* it directly for authenticated GitHub API calls and skips the native
|
|
@@ -44,6 +62,18 @@ export declare function resolveGitHubAppId(appId?: GitHubAppId): Promise<string>
|
|
|
44
62
|
export declare function resolveGitHubPrivateKey(privateKey?: GitHubPrivateKey): Promise<string>;
|
|
45
63
|
/** Resolves a GitHub webhook secret, falling back to `GITHUB_WEBHOOK_SECRET`. */
|
|
46
64
|
export declare function resolveGitHubWebhookSecret(webhookSecret?: GitHubWebhookSecret): Promise<string>;
|
|
65
|
+
/** The channel's lazily resolved bot name, shared by dispatch and defaults. */
|
|
66
|
+
export type GitHubBotNameResolver = () => Promise<string | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* Creates the channel's `botName` resolver: explicit config first, then the
|
|
69
|
+
* credentials' `appSlug`, then `GITHUB_APP_SLUG`. A fulfilled name is cached
|
|
70
|
+
* for the channel's lifetime; a rejection is logged and retried on the next
|
|
71
|
+
* event, so one failed delivery cannot pin the channel to a missing name.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createGitHubBotNameResolver(input: {
|
|
74
|
+
readonly botName?: GitHubBotName;
|
|
75
|
+
readonly credentials?: GitHubChannelCredentials;
|
|
76
|
+
}): GitHubBotNameResolver;
|
|
47
77
|
/** Converts hosted-platform escaped newlines back into PEM newlines. */
|
|
48
78
|
export declare function normalizeGitHubPrivateKey(privateKey: string): string;
|
|
49
79
|
/** Creates a short-lived RS256 GitHub App JWT. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createSign}from"node:crypto";import{isObject}from"#shared/guards.js";const installationTokenCache=new Map;async function resolveGitHubAppId(e){let t=e??process.env.GITHUB_APP_ID;if(t===void 0||t===``)throw Error(`githubChannel: GITHUB_APP_ID is required.`);let n=typeof t==`function`?await t():t;return String(n)}async function resolveGitHubPrivateKey(e){let t=e??process.env.GITHUB_APP_PRIVATE_KEY;if(!t)throw Error(`githubChannel: GITHUB_APP_PRIVATE_KEY is required.`);return normalizeGitHubPrivateKey(typeof t==`function`?await t():t)}async function resolveGitHubWebhookSecret(e){let t=e??process.env.GITHUB_WEBHOOK_SECRET;if(!t)throw Error(`githubChannel: GITHUB_WEBHOOK_SECRET is required.`);return typeof t==`function`?await t():t}function normalizeGitHubPrivateKey(e){return e.replace(/\\n/gu,`
|
|
2
|
-
`)}async function createGitHubAppJwt(t){let n=await resolveGitHubAppId(t.appId),r=await resolveGitHubPrivateKey(t.privateKey),i=Math.floor((t.now?.getTime()??Date.now())/1e3),a={alg:`RS256`,typ:`JWT`},o={exp:i+600,iat:i-60,iss:n},s=`${base64UrlJson(a)}.${base64UrlJson(o)}`;return`${s}.${createSign(`RSA-SHA256`).update(s).sign(r,`base64url`)}`}async function resolveGitHubInstallationToken(e){let t=e.credentials?.installationToken;if(t!==void 0)return typeof t==`function`?await t():t;if(e.installationId===void 0)throw Error(`githubChannel: installationId is required for authenticated GitHub API calls.`);return createGitHubInstallationToken({api:e.api,appId:e.credentials?.appId,installationId:e.installationId,privateKey:e.credentials?.privateKey})}async function createGitHubInstallationToken(e){let
|
|
1
|
+
import{createSign}from"node:crypto";import{createLogger}from"#internal/logging.js";import{isObject}from"#shared/guards.js";const log=createLogger(`github.auth`),installationTokenCache=new Map;async function resolveGitHubAppId(e){let t=e??process.env.GITHUB_APP_ID;if(t===void 0||t===``)throw Error(`githubChannel: GITHUB_APP_ID is required.`);let n=typeof t==`function`?await t():t;return String(n)}async function resolveGitHubPrivateKey(e){let t=e??process.env.GITHUB_APP_PRIVATE_KEY;if(!t)throw Error(`githubChannel: GITHUB_APP_PRIVATE_KEY is required.`);return normalizeGitHubPrivateKey(typeof t==`function`?await t():t)}async function resolveGitHubWebhookSecret(e){let t=e??process.env.GITHUB_WEBHOOK_SECRET;if(!t)throw Error(`githubChannel: GITHUB_WEBHOOK_SECRET is required.`);return typeof t==`function`?await t():t}function createGitHubBotNameResolver(e){let t;return async()=>{if(t!==void 0)return t;let n=e.botName??e.credentials?.appSlug??process.env.GITHUB_APP_SLUG;if(n!==void 0){if(typeof n==`string`)return t=normalizeBotName(n),t;try{return t=normalizeBotName(await n()),t}catch(e){log.warn(`githubChannel: botName resolver failed; retrying on the next event`,{error:e});return}}}}function normalizeBotName(e){let t=e.trim();return t.length>0?t:void 0}function normalizeGitHubPrivateKey(e){return e.replace(/\\n/gu,`
|
|
2
|
+
`)}async function createGitHubAppJwt(t){let n=await resolveGitHubAppId(t.appId),r=await resolveGitHubPrivateKey(t.privateKey),i=Math.floor((t.now?.getTime()??Date.now())/1e3),a={alg:`RS256`,typ:`JWT`},o={exp:i+600,iat:i-60,iss:n},s=`${base64UrlJson(a)}.${base64UrlJson(o)}`;return`${s}.${createSign(`RSA-SHA256`).update(s).sign(r,`base64url`)}`}async function resolveGitHubInstallationToken(e){let t=e.credentials?.installationToken;if(t!==void 0)return typeof t==`function`?await t():t;if(e.installationId===void 0)throw Error(`githubChannel: installationId is required for authenticated GitHub API calls.`);return createGitHubInstallationToken({api:e.api,appId:e.credentials?.appId,installationId:e.installationId,privateKey:e.credentials?.privateKey})}async function createGitHubInstallationToken(e){let t=await resolveGitHubAppId(e.appId),r=e.api?.apiBaseUrl??`https://api.github.com`,a=`${r}:${t}:${e.installationId}`,o=installationTokenCache.get(a);if(o!==void 0&&Date.now()<o.expiresAtMs-6e4)return o.token;let s=await createGitHubAppJwt({appId:t,privateKey:e.privateKey}),c=await(e.api?.fetch??fetch)(`${r}/app/installations/${e.installationId}/access_tokens`,{headers:{accept:`application/vnd.github+json`,authorization:`Bearer ${s}`,"x-github-api-version":`2022-11-28`},method:`POST`}),l=await parseJsonBody(c);if(!c.ok)throw Error(`githubChannel: create installation token failed with HTTP ${c.status}.`);if(!isObject(l)||typeof l.token!=`string`)throw Error(`githubChannel: installation token response did not include a token.`);let u=parseExpiryMs(l.expires_at);return installationTokenCache.set(a,{expiresAtMs:u,token:l.token}),l.token}function clearGitHubInstallationTokenCache(){installationTokenCache.clear()}function seedGitHubInstallationTokenForTests(e){let t=e.apiBaseUrl??`https://api.github.com`,n=e.appId??`test-app`;installationTokenCache.set(`${t}:${n}:${e.installationId}`,{expiresAtMs:Date.now()+3600*1e3,token:e.token})}function base64UrlJson(e){return Buffer.from(JSON.stringify(e)).toString(`base64url`)}async function parseJsonBody(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function parseExpiryMs(e){if(typeof e==`string`){let t=Date.parse(e);if(Number.isFinite(t))return t}return Date.now()+3600*1e3}export{clearGitHubInstallationTokenCache,createGitHubAppJwt,createGitHubBotNameResolver,createGitHubInstallationToken,normalizeGitHubPrivateKey,resolveGitHubAppId,resolveGitHubInstallationToken,resolveGitHubPrivateKey,resolveGitHubWebhookSecret,seedGitHubInstallationTokenForTests};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SessionAuthContext } from "#channel/types.js";
|
|
2
2
|
import type { GitHubApiOptions } from "#public/channels/github/api.js";
|
|
3
|
-
import type { GitHubChannelCredentials } from "#public/channels/github/auth.js";
|
|
3
|
+
import type { GitHubBotNameResolver, GitHubChannelCredentials } from "#public/channels/github/auth.js";
|
|
4
4
|
import { type GitHubComment } from "#public/channels/github/inbound.js";
|
|
5
5
|
import type { GitHubChannelEvents, GitHubInboundContext, GitHubInboundResult, GitHubProgressConfig } from "#public/channels/github/githubChannel.js";
|
|
6
6
|
/**
|
|
@@ -12,14 +12,14 @@ import type { GitHubChannelEvents, GitHubInboundContext, GitHubInboundResult, Gi
|
|
|
12
12
|
export declare function defaultGitHubAuth(ctx: GitHubInboundContext): SessionAuthContext;
|
|
13
13
|
/** Options used by the built-in GitHub comment dispatch hook. */
|
|
14
14
|
export interface GitHubDefaultDispatchOptions {
|
|
15
|
-
readonly botName?:
|
|
15
|
+
readonly botName?: GitHubBotNameResolver;
|
|
16
16
|
}
|
|
17
17
|
/** Default comment hook: dispatch only when the comment `@mention`s the bot. */
|
|
18
|
-
export declare function defaultOnComment(ctx: GitHubInboundContext, comment: GitHubComment, options: GitHubDefaultDispatchOptions): GitHubInboundResult
|
|
18
|
+
export declare function defaultOnComment(ctx: GitHubInboundContext, comment: GitHubComment, options: GitHubDefaultDispatchOptions): Promise<GitHubInboundResult>;
|
|
19
19
|
/** Options used by built-in GitHub event handlers. */
|
|
20
20
|
export interface GitHubDefaultEventOptions {
|
|
21
21
|
readonly api?: GitHubApiOptions;
|
|
22
|
-
readonly botName?:
|
|
22
|
+
readonly botName?: GitHubBotNameResolver;
|
|
23
23
|
readonly credentials?: GitHubChannelCredentials;
|
|
24
24
|
readonly progress?: GitHubProgressConfig;
|
|
25
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createLogger,extractErrorId,formatErrorHint,logError}from"#internal/logging.js";import{checkoutGitHubRepository}from"#public/channels/github/checkout.js";import{shouldDispatchGitHubComment}from"#public/channels/github/inbound.js";import{splitGitHubCommentBody}from"#public/channels/github/limits.js";const log=createLogger(`github.defaults`);function defaultGitHubAuth(e){let{sender:t}=e;return{attributes:{conversation_kind:e.conversation.kind,delivery_id:e.delivery.id,installation_id:String(e.github.installationId??``),issue_number:String(e.conversation.issueNumber??``),pull_request_number:String(e.conversation.pullRequestNumber??``),repository:e.repository.fullName,repository_id:String(e.repository.id),user_login:t.login,user_type:t.type},authenticator:`github-webhook`,issuer:`github:${e.repository.owner}`,principalId:`github:${t.id}`,principalType:t.type===`Bot`?`service`:`user`,subject:t.login}}function defaultOnComment(e,t,n){return shouldDispatchGitHubComment({author:t.author,body:t.body,botName:n.botName})?{auth:defaultGitHubAuth(e)}:null}function createDefaultEvents(e={}){return{async"turn.started"(t,n,i){if(e.progress?.reactions!==!1)try{await n.thread.react(`eyes`)}catch(e){logError(log,`GitHub reaction failed — swallowed`,e)}await checkoutRepositoryForTurn(n,i,e)},async"message.completed"(e,t,n){e.finishReason===`tool-calls`||!e.message||await postCommentChunks(t,e.message)},async"input.requested"(t,n,r){if(t.requests.length===0)return;let i=t.requests.map(renderInputRequest),a=renderReplyInstruction(t.requests,e.botName);a!==void 0&&i.push(a),await postCommentChunks(n,i.join(`
|
|
1
|
+
import{createLogger,extractErrorId,formatErrorHint,logError}from"#internal/logging.js";import{checkoutGitHubRepository}from"#public/channels/github/checkout.js";import{shouldDispatchGitHubComment}from"#public/channels/github/inbound.js";import{splitGitHubCommentBody}from"#public/channels/github/limits.js";const log=createLogger(`github.defaults`);function defaultGitHubAuth(e){let{sender:t}=e;return{attributes:{conversation_kind:e.conversation.kind,delivery_id:e.delivery.id,installation_id:String(e.github.installationId??``),issue_number:String(e.conversation.issueNumber??``),pull_request_number:String(e.conversation.pullRequestNumber??``),repository:e.repository.fullName,repository_id:String(e.repository.id),user_login:t.login,user_type:t.type},authenticator:`github-webhook`,issuer:`github:${e.repository.owner}`,principalId:`github:${t.id}`,principalType:t.type===`Bot`?`service`:`user`,subject:t.login}}async function defaultOnComment(e,t,n){return shouldDispatchGitHubComment({author:t.author,body:t.body,botName:await n.botName?.()})?{auth:defaultGitHubAuth(e)}:null}function createDefaultEvents(e={}){return{async"turn.started"(t,n,i){if(e.progress?.reactions!==!1)try{await n.thread.react(`eyes`)}catch(e){logError(log,`GitHub reaction failed — swallowed`,e)}await checkoutRepositoryForTurn(n,i,e)},async"message.completed"(e,t,n){e.finishReason===`tool-calls`||!e.message||await postCommentChunks(t,e.message)},async"input.requested"(t,n,r){if(t.requests.length===0)return;let i=t.requests.map(renderInputRequest),a=renderReplyInstruction(t.requests,await e.botName?.());a!==void 0&&i.push(a),await postCommentChunks(n,i.join(`
|
|
2
2
|
|
|
3
3
|
`))},async"session.failed"(e,r){let i=formatErrorHint(e),a=extractErrorId(e.details);await postFailure(r,[`This session could not recover from an error${i}.`,``,`Start a new comment to continue.`,...a?[``,`Error id: ${a}`]:[]].join(`
|
|
4
4
|
`))},async"turn.failed"(e,r,i){let a=formatErrorHint(e),o=extractErrorId(e.details);await postFailure(r,[`I hit an error while handling your request${a}.`,``,`Please try again, rephrase, or reach out if it keeps failing.`,...o?[``,`Error id: ${o}`]:[]].join(`
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ChannelFrom } from "#channel/channel-operations.js";
|
|
2
|
+
import type { GitHubBotNameResolver } from "#public/channels/github/auth.js";
|
|
2
3
|
import { type GitHubCheckRunWebhookEvent, type GitHubCheckSuiteWebhookEvent, type GitHubIssueCommentEvent, type GitHubIssueWebhookEvent, type GitHubPullRequestReviewCommentEvent, type GitHubPullRequestWebhookEvent, type GitHubWorkflowRunWebhookEvent } from "#public/channels/github/inbound.js";
|
|
3
4
|
import { type GitHubChannelState } from "#public/channels/github/state.js";
|
|
4
5
|
import type { GitHubChannelConfig } from "#public/channels/github/githubChannel.js";
|
|
5
6
|
/** Dispatches a bot-directed issue or PR timeline comment into the runtime. */
|
|
6
7
|
export declare function dispatchIssueComment(input: {
|
|
7
|
-
readonly botName:
|
|
8
|
+
readonly botName: GitHubBotNameResolver;
|
|
8
9
|
readonly config: GitHubChannelConfig;
|
|
9
10
|
readonly event: GitHubIssueCommentEvent;
|
|
10
11
|
readonly handler: NonNullable<GitHubChannelConfig["onComment"]>;
|
|
@@ -12,7 +13,7 @@ export declare function dispatchIssueComment(input: {
|
|
|
12
13
|
}): Promise<void>;
|
|
13
14
|
/** Dispatches a bot-directed inline pull-request review comment. */
|
|
14
15
|
export declare function dispatchPullRequestReviewComment(input: {
|
|
15
|
-
readonly botName:
|
|
16
|
+
readonly botName: GitHubBotNameResolver;
|
|
16
17
|
readonly config: GitHubChannelConfig;
|
|
17
18
|
readonly event: GitHubPullRequestReviewCommentEvent;
|
|
18
19
|
readonly handler: NonNullable<GitHubChannelConfig["onComment"]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{extractGitHubCommentTrigger,formatGitHubContextBlock}from"#public/channels/github/inbound.js";import{buildGitHubBinding}from"#public/channels/github/binding.js";import{buildGitHubPullRequestContext,mergeGitHubContext}from"#public/channels/github/pr-context.js";import{continuationTokenFromState,stateFromCiEvent,stateFromIssueCommentEvent,stateFromIssueEvent,stateFromPullRequestEvent,stateFromPullRequestReviewCommentEvent}from"#public/channels/github/state.js";const log=createLogger(`github.dispatch`);async function dispatchIssueComment(e){if(isIgnoredInboundComment(e.event.comment.body,e.event.comment.author,
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{extractGitHubCommentTrigger,formatGitHubContextBlock}from"#public/channels/github/inbound.js";import{buildGitHubBinding}from"#public/channels/github/binding.js";import{buildGitHubPullRequestContext,mergeGitHubContext}from"#public/channels/github/pr-context.js";import{continuationTokenFromState,stateFromCiEvent,stateFromIssueCommentEvent,stateFromIssueEvent,stateFromPullRequestEvent,stateFromPullRequestReviewCommentEvent}from"#public/channels/github/state.js";const log=createLogger(`github.dispatch`);async function dispatchIssueComment(e){let t=await e.botName();if(isIgnoredInboundComment(e.event.comment.body,e.event.comment.author,t))return;let n=buildInboundContext(e.config,e.event);await dispatchCommentTurn({body:e.event.comment.body,botName:t,commentUrl:e.event.comment.htmlUrl,event:e.event,handlerResult:()=>e.handler(n,toGitHubComment(e.event.comment)),config:e.config,from:e.from,state:stateFromIssueCommentEvent(e.event)})}async function dispatchPullRequestReviewComment(e){let t=await e.botName();if(isIgnoredInboundComment(e.event.comment.body,e.event.comment.author,t))return;let n=buildInboundContext(e.config,e.event);await dispatchCommentTurn({body:e.event.comment.body,botName:t,commentUrl:e.event.comment.htmlUrl,event:e.event,handlerResult:()=>e.handler(n,toGitHubComment(e.event.comment)),config:e.config,from:e.from,state:stateFromPullRequestReviewCommentEvent(e.event)})}async function dispatchIssue(e){let t=buildInboundContext(e.config,e.event);await dispatchWebhookEventTurn({config:e.config,event:e.event,handlerResult:()=>e.handler(t,e.event.issue),message:formatIssueEventMessage(e.event),from:e.from,state:stateFromIssueEvent(e.event)})}async function dispatchPullRequest(e){let t=buildInboundContext(e.config,e.event);await dispatchWebhookEventTurn({config:e.config,event:e.event,handlerResult:()=>e.handler(t,e.event.pullRequest),message:formatPullRequestEventMessage(e.event),from:e.from,state:stateFromPullRequestEvent(e.event)})}async function dispatchCheckSuite(e){await dispatchCiEvent({...e,ci:e.event.checkSuite,handlerResult:t=>e.handler(t,e.event.checkSuite),label:`Check suite`})}async function dispatchCheckRun(e){await dispatchCiEvent({...e,ci:e.event.checkRun,handlerResult:t=>e.handler(t,e.event.checkRun),label:`Check run`})}async function dispatchWorkflowRun(e){await dispatchCiEvent({...e,ci:e.event.workflowRun,handlerResult:t=>e.handler(t,e.event.workflowRun),label:`Workflow run`})}async function dispatchCiEvent(e){let t=stateFromCiEvent(e.event),n=buildInboundContext(e.config,e.event);if(t.pullRequestNumber===null){await runInboundHandler({event:e.event,handlerResult:()=>e.handlerResult(n)})!=null&&log.warn(`GitHub CI event cannot dispatch without an associated pull request`,{deliveryId:e.event.delivery.id,event:e.event.kind});return}await dispatchWebhookEventTurn({config:e.config,event:e.event,handlerResult:()=>e.handlerResult(n),message:formatCiEventMessage(e.label,e.ci),from:e.from,state:t})}async function dispatchWebhookEventTurn(e){let t=await runInboundHandler({event:e.event,handlerResult:e.handlerResult});t!=null&&await sendGitHubTurn({auth:t.auth,event:e.event,message:e.message,context:mergeGitHubContext({github:await buildPullRequestContext(e.config,e.state,e.event.delivery.id),hook:t.context}),from:e.from,state:e.state})}async function dispatchCommentTurn(e){let t=await runInboundHandler({event:e.event,handlerResult:e.handlerResult});if(t==null)return;let r=extractGitHubCommentTrigger({body:e.body,botName:e.botName})?.message??e.body.trim();await sendGitHubTurn({auth:t.auth,commentUrl:e.commentUrl,event:e.event,message:r,context:mergeGitHubContext({github:await buildPullRequestContext(e.config,e.state,e.event.delivery.id),hook:t.context}),from:e.from,state:e.state})}async function runInboundHandler(e){try{return await e.handlerResult()}catch(n){logError(log,`GitHub inbound handler failed`,n,{deliveryId:e.event.delivery.id});return}}async function sendGitHubTurn(e){let n=formatGitHubContextBlock({deliveryId:e.event.delivery.id,commentUrl:e.commentUrl,headSha:e.state.headSha,issueNumber:e.state.issueNumber,pullRequestNumber:e.state.pullRequestNumber,repository:e.event.repository,sender:e.event.sender});try{await e.from(continuationTokenFromState(e.state)).send(e.message,{auth:e.auth,context:[n,...e.context??[]],state:e.state})}catch(n){logError(log,e.logMessage??`GitHub delivery failed`,n,{deliveryId:e.event.delivery.id})}}async function buildPullRequestContext(e,n,r){try{return await buildGitHubPullRequestContext({api:e.api,baseSha:n.baseSha,config:e.pullRequestContext,credentials:e.credentials,headSha:n.headSha,installationId:n.installationId??void 0,owner:n.owner,pullRequestNumber:n.pullRequestNumber,repo:n.repo})}catch(e){logError(log,`GitHub pull-request context failed — swallowed`,e,{deliveryId:r});return}}function buildInboundContext(e,t){let n=buildGitHubBinding({config:e,state:t.kind===`check_suite`||t.kind===`check_run`||t.kind===`workflow_run`?stateFromCiEvent(t):t.kind===`issue_comment`?stateFromIssueCommentEvent(t):t.kind===`issues`?stateFromIssueEvent(t):t.kind===`pull_request`?stateFromPullRequestEvent(t):stateFromPullRequestReviewCommentEvent(t)});return{conversation:t.conversation,delivery:t.delivery,github:n.github,repository:t.repository,sender:t.sender,thread:n.thread}}function toGitHubComment(e){return{author:e.author,body:e.body,htmlUrl:e.htmlUrl,id:e.id,raw:e.raw,url:e.url}}function formatIssueEventMessage(e){let t=readString(e.issue.raw.title);return`Issue ${e.issue.action}: #${e.issue.issueNumber}${t?` ${t}`:``}`}function formatPullRequestEventMessage(e){let t=readString(e.pullRequest.raw.title);return`Pull request ${e.pullRequest.action}: #${e.pullRequest.pullRequestNumber}${t?` ${t}`:``}`}function formatCiEventMessage(e,t){let n=t.conclusion??t.status;return`${e} ${t.action}: ${ciEventId(t)}${n?` (${n})`:``}`}function ciEventId(e){return`checkSuiteId`in e?e.checkSuiteId:`checkRunId`in e?e.checkRunId:e.workflowRunId}function isIgnoredInboundComment(e,t,n){if(e.includes(`<!-- eve:github:`)||t?.type===`Bot`)return!0;let r=n?`${n}[bot]`.toLowerCase():``;return r.length>0&&t?.login.toLowerCase()===r}function readString(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}export{dispatchCheckRun,dispatchCheckSuite,dispatchIssue,dispatchIssueComment,dispatchPullRequest,dispatchPullRequestReviewComment,dispatchWorkflowRun};
|
|
@@ -4,7 +4,7 @@ import type { ChannelContinuationOps } from "#public/definitions/channel.js";
|
|
|
4
4
|
import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
5
5
|
import { type GitHubHandle, type GitHubThread } from "#public/channels/github/binding.js";
|
|
6
6
|
import { type GitHubApiOptions } from "#public/channels/github/api.js";
|
|
7
|
-
import type
|
|
7
|
+
import { type GitHubBotName, type GitHubChannelCredentials } from "#public/channels/github/auth.js";
|
|
8
8
|
import { type GitHubCheckRunEvent, type GitHubCheckSuiteEvent, type GitHubComment, type GitHubConversationRef, type GitHubDelivery, type GitHubIssueEvent, type GitHubPullRequestEvent, type GitHubRepositoryRef, type GitHubUser, type GitHubWorkflowRunEvent } from "#public/channels/github/inbound.js";
|
|
9
9
|
import { type GitHubChannelState } from "#public/channels/github/state.js";
|
|
10
10
|
import type { GitHubPullRequestContextConfig } from "#public/channels/github/pr-context.js";
|
|
@@ -96,7 +96,12 @@ export interface GitHubChannelEvents {
|
|
|
96
96
|
/** Configuration for {@link githubChannel}. */
|
|
97
97
|
export interface GitHubChannelConfig {
|
|
98
98
|
readonly api?: GitHubApiOptions;
|
|
99
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The name the channel answers to in `@mentions`, supplied directly or
|
|
101
|
+
* resolved lazily on first use inside request handling. Falls back to the
|
|
102
|
+
* credentials' `appSlug`, then `GITHUB_APP_SLUG`.
|
|
103
|
+
*/
|
|
104
|
+
readonly botName?: GitHubBotName;
|
|
100
105
|
readonly credentials?: GitHubChannelCredentials;
|
|
101
106
|
readonly events?: GitHubChannelEvents;
|
|
102
107
|
readonly progress?: GitHubProgressConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{readNonEmptyString}from"#shared/guards.js";import{POST,defineChannel}from"#public/definitions/channel.js";import{getGitHubRepository}from"#public/channels/github/api.js";import{parseGitHubWebhookEvent}from"#public/channels/github/inbound.js";import{buildGitHubBinding}from"#public/channels/github/binding.js";import{continuationTokenFromState,conversationFromState,initialGitHubState,stateFromReceiveTarget}from"#public/channels/github/state.js";import{GITHUB_CHANNEL_DEFAULT_ROUTE}from"#public/channels/github/constants.js";import{createDefaultEvents,defaultOnComment}from"#public/channels/github/defaults.js";import{dispatchCheckRun,dispatchCheckSuite,dispatchIssue,dispatchIssueComment,dispatchPullRequest,dispatchPullRequestReviewComment,dispatchWorkflowRun}from"#public/channels/github/dispatch.js";import{verifyGitHubRequest}from"#public/channels/github/verify.js";const log=createLogger(`github.channel`);function githubChannel(e={}){let c=e.botName
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{readNonEmptyString}from"#shared/guards.js";import{POST,defineChannel}from"#public/definitions/channel.js";import{createGitHubBotNameResolver}from"#public/channels/github/auth.js";import{getGitHubRepository}from"#public/channels/github/api.js";import{parseGitHubWebhookEvent}from"#public/channels/github/inbound.js";import{buildGitHubBinding}from"#public/channels/github/binding.js";import{continuationTokenFromState,conversationFromState,initialGitHubState,stateFromReceiveTarget}from"#public/channels/github/state.js";import{GITHUB_CHANNEL_DEFAULT_ROUTE}from"#public/channels/github/constants.js";import{createDefaultEvents,defaultOnComment}from"#public/channels/github/defaults.js";import{dispatchCheckRun,dispatchCheckSuite,dispatchIssue,dispatchIssueComment,dispatchPullRequest,dispatchPullRequestReviewComment,dispatchWorkflowRun}from"#public/channels/github/dispatch.js";import{verifyGitHubRequest}from"#public/channels/github/verify.js";const log=createLogger(`github.channel`);function githubChannel(e={}){let c=createGitHubBotNameResolver({botName:e.botName,credentials:e.credentials}),u={botName:c},d={...createDefaultEvents({api:e.api,botName:c,credentials:e.credentials,progress:e.progress}),...e.events};return defineChannel({kindHint:`github`,turnPolicy:e.turnPolicy,state:initialGitHubState(),context(t,n){return rebuildGitHubContext(t,n,e)},routes:[POST(e.route??GITHUB_CHANNEL_DEFAULT_ROUTE,async(t,{from:n,waitUntil:r})=>{let i=await verifyInbound(t,e.credentials);if(i===null)return new Response(`unauthorized`,{status:401});let a=missingGitHubWebhookHeaders(t.headers),s;try{s=parseGitHubWebhookEvent({body:i,contentType:t.headers.get(`content-type`)??void 0,headers:t.headers})}catch(e){return log.warn(`inbound GitHub body is not valid JSON`,{error:e}),jsonOk({ignored:!0,ok:!0})}return s===null?(a.length>0&&log.warn(`GitHub webhook ignored because standard headers were missing`,{missingHeaders:a}),jsonOk({ignored:!0,ok:!0})):(a.length>0&&log.warn(`GitHub webhook missing standard headers; inferred metadata from payload`,{deliveryId:s.delivery.id,event:s.delivery.event,missingHeaders:a,repository:s.repository.fullName}),s.kind===`ping`?jsonOk({ok:!0}):s.kind===`issue_comment`&&s.action===`created`?(r(dispatchIssueComment({botName:c,config:e,event:s,handler:e.onComment??((e,t)=>defaultOnComment(e,t,u)),from:n})),jsonOk({ok:!0})):s.kind===`pull_request_review_comment`&&s.action===`created`?(r(dispatchPullRequestReviewComment({botName:c,config:e,event:s,handler:e.onComment??((e,t)=>defaultOnComment(e,t,u)),from:n})),jsonOk({ok:!0})):s.kind===`issues`&&e.onIssue!==void 0?(r(dispatchIssue({config:e,event:s,handler:e.onIssue,from:n})),jsonOk({ok:!0})):s.kind===`pull_request`&&e.onPullRequest!==void 0?(r(dispatchPullRequest({config:e,event:s,handler:e.onPullRequest,from:n})),jsonOk({ok:!0})):s.kind===`check_suite`&&e.onCheckSuite!==void 0?(r(dispatchCheckSuite({config:e,event:s,handler:e.onCheckSuite,from:n})),jsonOk({ok:!0})):s.kind===`check_run`&&e.onCheckRun!==void 0?(r(dispatchCheckRun({config:e,event:s,handler:e.onCheckRun,from:n})),jsonOk({ok:!0})):s.kind===`workflow_run`&&e.onWorkflowRun!==void 0?(r(dispatchWorkflowRun({config:e,event:s,handler:e.onWorkflowRun,from:n})),jsonOk({ok:!0})):jsonOk({ignored:!0,ok:!0}))})],async receive(n,{from:r}){let i=n.target,o=readNonEmptyString(i.owner),c=readNonEmptyString(i.repo);if(o===void 0||c===void 0)throw Error(`githubChannel().receive requires target.owner and target.repo.`);if([i.issueNumber!==void 0,i.pullRequestNumber!==void 0].filter(Boolean).length!==1)throw Error(`githubChannel().receive requires exactly one of issueNumber or pullRequestNumber.`);let l=stateFromReceiveTarget({target:i,owner:o,repo:c,repositoryId:i.repositoryId??(await getGitHubRepository({api:e.api,credentials:e.credentials,installationId:i.installationId,owner:o,repo:c})).id});if(i.initialMessage!==void 0){let{thread:t}=buildGitHubBinding({config:e,state:l});await t.post(i.initialMessage)}return r(continuationTokenFromState(l)).send(n.message,{auth:n.auth,state:l})},events:d})}function rebuildGitHubContext(e,t,n){let r=buildGitHubBinding({config:n,state:e});return{conversation:conversationFromState(e),github:r.github,repository:r.github.repository,state:e,thread:r.thread}}async function verifyInbound(e,t){try{return await verifyGitHubRequest(e,{webhookSecret:t?.webhookSecret,webhookVerifier:t?.webhookVerifier})}catch(e){return log.warn(`github inbound verification failed`,{error:e}),null}}function missingGitHubWebhookHeaders(e){return[`x-github-event`,`x-github-delivery`].filter(t=>{let n=e.get(t);return n===null||n.trim().length===0})}function jsonOk(e){return new Response(JSON.stringify(e),{headers:{"content-type":`application/json; charset=utf-8`},status:200})}export{githubChannel};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { GitHubApiError, type GitHubApiMethod, type GitHubApiOptions, type GitHubApiResponse, type GitHubJsonObject, type GitHubPostedComment, type GitHubReactionContent, } from "#public/channels/github/api.js";
|
|
2
2
|
export { type GitHubHandle, type GitHubThread } from "#public/channels/github/binding.js";
|
|
3
|
-
export { type GitHubAppId, type GitHubChannelCredentials, type GitHubInstallationToken, type GitHubPrivateKey, type GitHubWebhookSecret, } from "#public/channels/github/auth.js";
|
|
3
|
+
export { type GitHubAppId, type GitHubBotName, type GitHubChannelCredentials, type GitHubInstallationToken, type GitHubPrivateKey, type GitHubWebhookSecret, } from "#public/channels/github/auth.js";
|
|
4
4
|
export { defaultGitHubAuth } from "#public/channels/github/defaults.js";
|
|
5
5
|
export { type GitHubAppRef, type GitHubCheckRunEvent, type GitHubCheckSuiteEvent, type GitHubCiEvent, type GitHubCiPayload, type GitHubComment, type GitHubConversationKind, type GitHubConversationRef, type GitHubDelivery, type GitHubIssueAction, type GitHubIssueEvent, type GitHubPullRequestAction, type GitHubPullRequestEvent, type GitHubRepositoryRef, type GitHubUser, type GitHubWorkflowRunEvent, } from "#public/channels/github/inbound.js";
|
|
6
6
|
export { githubChannel, type GitHubChannel, type GitHubChannelConfig, type GitHubChannelEvents, type GitHubEventContext, type GitHubInboundContext, type GitHubInboundResult, type GitHubInboundResultOrPromise, type GitHubProgressConfig, type GitHubReceiveTarget, } from "#public/channels/github/githubChannel.js";
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
+
import { type DynamicResolveContext, type DynamicSentinel } from "#shared/dynamic-tool-definition.js";
|
|
1
2
|
import type { ExactDefinition } from "#public/definitions/exact.js";
|
|
2
3
|
import type { PublicInstructionsDefinition } from "#shared/instructions-definition.js";
|
|
3
4
|
export type InstructionsDefinition = Readonly<PublicInstructionsDefinition>;
|
|
4
5
|
/**
|
|
5
|
-
* Defines
|
|
6
|
-
* definition.
|
|
6
|
+
* Defines instructions in TypeScript from a `{ content, role? }`
|
|
7
|
+
* definition. Omitted `role` defaults to `"system"`.
|
|
7
8
|
*
|
|
8
9
|
* Use it to return instructions from a `defineDynamic` resolver in
|
|
9
|
-
* `agent/instructions
|
|
10
|
-
* `{ role: "system" }` message. For a fixed prompt with no resolver,
|
|
10
|
+
* `agent/instructions/`. For a fixed prompt with no resolver,
|
|
11
11
|
* author `instructions.md` instead. The result is branded so the dynamic
|
|
12
12
|
* instruction lifecycle can validate that a resolver return came through
|
|
13
13
|
* this helper.
|
|
14
14
|
*/
|
|
15
15
|
export declare function defineInstructions<TInstructions extends InstructionsDefinition>(definition: ExactDefinition<TInstructions, InstructionsDefinition>): TInstructions;
|
|
16
|
+
export type DynamicInstructionsResult = InstructionsDefinition | null;
|
|
17
|
+
export type DynamicInstructionsEvents = {
|
|
18
|
+
readonly [K in "session.started" | "turn.started"]?: (event: unknown, ctx: DynamicResolveContext) => DynamicInstructionsResult | Promise<DynamicInstructionsResult>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Defines a runtime instructions resolver for session and turn boundaries.
|
|
22
|
+
*/
|
|
23
|
+
export declare function defineDynamic<const TEvents extends DynamicInstructionsEvents>(definition: {
|
|
24
|
+
readonly events: ExactDefinition<TEvents, DynamicInstructionsEvents>;
|
|
25
|
+
}): DynamicSentinel<DynamicInstructionsResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{INSTRUCTIONS_BRAND}from"#shared/dynamic-tool-definition.js";function defineInstructions(e){return Object.assign(e,{[INSTRUCTIONS_BRAND]:!0}),e}export{defineInstructions};
|
|
1
|
+
import{DYNAMIC_SENTINEL_KIND,INSTRUCTIONS_BRAND}from"#shared/dynamic-tool-definition.js";import{stampDefinitionKey}from"#public/tool-result-narrowing.js";function defineInstructions(e){return Object.assign(e,{[INSTRUCTIONS_BRAND]:!0}),e}function defineDynamic(t){let n={kind:DYNAMIC_SENTINEL_KIND,events:t.events};return stampDefinitionKey(n,`dynamic-instructions:${Object.keys(t.events).join(`,`)}`),n}export{defineDynamic,defineInstructions};
|
|
@@ -157,7 +157,8 @@ export declare function defineTool<TReturn>(definition: {
|
|
|
157
157
|
export declare function defineTool<TInput = unknown, TOutput = unknown>(definition: ToolDefinition<TInput, TOutput>): ToolDefinition<TInput, TOutput>;
|
|
158
158
|
/**
|
|
159
159
|
* Defines a dynamic resolver evaluated at runtime from stream-event
|
|
160
|
-
* handlers. It is shared across
|
|
160
|
+
* handlers. It is shared across tools, skills, and agent definitions;
|
|
161
|
+
* the directory it is
|
|
161
162
|
* authored in (not this function) decides what each handler must return
|
|
162
163
|
* and which events are honored. The file's path-derived slug names the
|
|
163
164
|
* single-entry case; a `Record<string, ...>` return names entries
|
|
@@ -168,17 +169,13 @@ export declare function defineTool<TInput = unknown, TOutput = unknown>(definiti
|
|
|
168
169
|
* `Record<string, defineTool(...)>`, or `null`.
|
|
169
170
|
* - `agent/skills/`: return a single `defineSkill(...)`, a
|
|
170
171
|
* `Record<string, defineSkill(...)>`, or `null`.
|
|
171
|
-
* - `agent/instructions/`: return a single `defineInstructions({ markdown })`,
|
|
172
|
-
* which lowers to one `{ role: "system", content: markdown }` message,
|
|
173
|
-
* or `null`. (Maps are not meaningful here.)
|
|
174
172
|
* - `agent/subagents/<name>/agent.ts`: return `defineAgent(...)` to configure
|
|
175
173
|
* and expose the subagent, or `null` to omit it.
|
|
176
174
|
*
|
|
177
175
|
* Per-slot events: tools resolvers run at `session.started`,
|
|
178
|
-
* `turn.started`, and `step.started`.
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* handler keyed on `step.started` in those slots.
|
|
176
|
+
* `turn.started`, and `step.started`. Skills resolvers run only at
|
|
177
|
+
* `session.started` and `turn.started`; the runtime never invokes a
|
|
178
|
+
* handler keyed on `step.started` in that slot.
|
|
182
179
|
* Dynamic subagents run at `session.started` and `turn.started` only.
|
|
183
180
|
*
|
|
184
181
|
* ```ts
|
|
@@ -2,6 +2,5 @@
|
|
|
2
2
|
* Instructions prompt authoring helpers for `agent/instructions.ts`
|
|
3
3
|
* and `agent/instructions/*.ts` files.
|
|
4
4
|
*/
|
|
5
|
-
export { defineInstructions, type InstructionsDefinition, } from "#public/definitions/instructions.js";
|
|
6
|
-
export { defineDynamic } from "#public/definitions/tool.js";
|
|
5
|
+
export { defineDynamic, defineInstructions, type DynamicInstructionsEvents, type DynamicInstructionsResult, type InstructionsDefinition, } from "#public/definitions/instructions.js";
|
|
7
6
|
export type { DynamicResolveContext, DynamicSentinel } from "#shared/dynamic-tool-definition.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineDynamic
|
|
1
|
+
import{defineDynamic,defineInstructions}from"#public/definitions/instructions.js";export{defineDynamic,defineInstructions};
|
|
@@ -121,13 +121,14 @@ export interface InstrumentationDefinition {
|
|
|
121
121
|
readonly events?: InstrumentationEvents;
|
|
122
122
|
/**
|
|
123
123
|
* Whether to record full model inputs in telemetry spans. Defaults to
|
|
124
|
-
* `true` when
|
|
125
|
-
*
|
|
124
|
+
* `false`. Set `true` only when the destination is approved to receive
|
|
125
|
+
* input content.
|
|
126
126
|
*/
|
|
127
127
|
readonly recordInputs?: boolean;
|
|
128
128
|
/**
|
|
129
129
|
* Whether to record full model outputs in telemetry spans. Defaults to
|
|
130
|
-
* `true` when
|
|
130
|
+
* `false`. Set `true` only when the destination is approved to receive
|
|
131
|
+
* output content.
|
|
131
132
|
*/
|
|
132
133
|
readonly recordOutputs?: boolean;
|
|
133
134
|
/**
|
|
@@ -14,8 +14,8 @@ export type { SpanExporter, SpanProcessor } from "#compiled/@vercel/otel/index.j
|
|
|
14
14
|
/**
|
|
15
15
|
* Vercel Agent Runs, enabled by default in production.
|
|
16
16
|
*
|
|
17
|
-
* Export it from `agent/instrumentation/agent-runs.ts` to
|
|
18
|
-
* export `disableInstrumentation()` from that file to turn it off.
|
|
17
|
+
* Export it from `agent/instrumentation/agent-runs.ts` to configure content
|
|
18
|
+
* capture, or export `disableInstrumentation()` from that file to turn it off.
|
|
19
19
|
*/
|
|
20
20
|
export declare function agentRuns(options?: ContentOptions): OtelIntegration;
|
|
21
21
|
/**
|
|
@@ -25,7 +25,8 @@ export declare function agentRuns(options?: ContentOptions): OtelIntegration;
|
|
|
25
25
|
* backend, or export `disableInstrumentation()` from that file to turn it off.
|
|
26
26
|
* Omitting the file leaves eve's default in place.
|
|
27
27
|
*
|
|
28
|
-
* `EVE_TRACES_CONTENT=
|
|
29
|
-
*
|
|
28
|
+
* `EVE_TRACES_CONTENT=on` opts the default local spool into content capture.
|
|
29
|
+
* `off` overrides this destination and no other, so declining content locally
|
|
30
|
+
* leaves what a hosted backend receives alone.
|
|
30
31
|
*/
|
|
31
32
|
export declare function localTraces(options?: ContentOptions): OtelIntegration;
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Reachable only with `experimental.instrumentationProviders` on. With the flag
|
|
5
5
|
* off nothing discovers that directory, so these types compile but never run.
|
|
6
6
|
*/
|
|
7
|
-
import type { InstrumentationCapture, InstrumentationEvent } from "#harness/instrumentation
|
|
7
|
+
import type { InstrumentationCapture, InstrumentationEvent } from "#harness/instrumentation/lifecycle.js";
|
|
8
8
|
import type { JsonValue } from "#public/types/json.js";
|
|
9
9
|
export type { JsonValue } from "#public/types/json.js";
|
|
10
|
-
export type { InstrumentationActionCompletedEvent, InstrumentationActionFailedEvent, InstrumentationActionKind, InstrumentationActionOutcome, InstrumentationActionOutput, InstrumentationActionStartedEvent, InstrumentationAttemptScope, InstrumentationCapture, InstrumentationChannelDeliveryInput, InstrumentationChannelDeliveryOutcome, InstrumentationChannelDeliveryRef, InstrumentationChannelDeliveryStartedEvent, InstrumentationChannelDeliveryTerminalEvent, InstrumentationContentPart, InstrumentationEvent, InstrumentationInputKind, InstrumentationInputOption, InstrumentationInputOutcome, InstrumentationInputRequest, InstrumentationInputRequestedEvent, InstrumentationInputResolvedEvent, InstrumentationInputResponse, InstrumentationModelCallCompletedEvent, InstrumentationModelCallFailedEvent, InstrumentationModelCallStartedEvent, InstrumentationModelRef, InstrumentationOperationRef, InstrumentationParentLineage, InstrumentationSessionFailedEvent, InstrumentationSessionSettledEvent, InstrumentationSessionStartedEvent, InstrumentationSessionTransitionEvent, InstrumentationStepAttemptMetadataEvent, InstrumentationStepAttemptCompletedEvent, InstrumentationStepAttemptFailedEvent, InstrumentationStepAttemptStartedEvent, InstrumentationStepAttemptTerminalEvent, InstrumentationToolCallCompletedEvent, InstrumentationToolCallFailedEvent, InstrumentationToolCallStartedEvent, InstrumentationToolOutput, InstrumentationTraceContext, InstrumentationTurnFailedEvent, InstrumentationTurnSettledEvent, InstrumentationTurnStartedEvent, InstrumentationTurnTerminalEvent, InstrumentationUsage, } from "#harness/instrumentation
|
|
10
|
+
export type { InstrumentationActionCompletedEvent, InstrumentationActionFailedEvent, InstrumentationActionKind, InstrumentationActionOutcome, InstrumentationActionOutput, InstrumentationActionStartedEvent, InstrumentationAttemptScope, InstrumentationCapture, InstrumentationChannelDeliveryInput, InstrumentationChannelDeliveryOutcome, InstrumentationChannelDeliveryRef, InstrumentationChannelDeliveryStartedEvent, InstrumentationChannelDeliveryTerminalEvent, InstrumentationContentPart, InstrumentationEvent, InstrumentationInputKind, InstrumentationInputOption, InstrumentationInputOutcome, InstrumentationInputRequest, InstrumentationInputRequestedEvent, InstrumentationInputResolvedEvent, InstrumentationInputResponse, InstrumentationModelCallCompletedEvent, InstrumentationModelCallFailedEvent, InstrumentationModelCallStartedEvent, InstrumentationModelRef, InstrumentationOperationRef, InstrumentationParentLineage, InstrumentationSessionFailedEvent, InstrumentationSessionSettledEvent, InstrumentationSessionStartedEvent, InstrumentationSessionTransitionEvent, InstrumentationStepAttemptMetadataEvent, InstrumentationStepAttemptCompletedEvent, InstrumentationStepAttemptFailedEvent, InstrumentationStepAttemptStartedEvent, InstrumentationStepAttemptTerminalEvent, InstrumentationToolCallCompletedEvent, InstrumentationToolCallFailedEvent, InstrumentationToolCallStartedEvent, InstrumentationToolOutput, InstrumentationTraceContext, InstrumentationTurnFailedEvent, InstrumentationTurnSettledEvent, InstrumentationTurnStartedEvent, InstrumentationTurnTerminalEvent, InstrumentationUsage, } from "#harness/instrumentation/lifecycle.js";
|
|
11
11
|
/**
|
|
12
12
|
* Marks a value as having come from `defineInstrumentation` or a built-in
|
|
13
13
|
* factory.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ModelMessage } from "ai";
|
|
1
2
|
import type { PreparedRuntimeTool } from "#runtime/sessions/turn.js";
|
|
2
3
|
import type { ResolvedAgent, ResolvedAgentDefinition } from "#runtime/types.js";
|
|
3
4
|
import type { WorkspaceRuntimeSpec } from "#runtime/workspace/types.js";
|
|
@@ -26,6 +27,7 @@ interface RuntimeTurnAgentBase {
|
|
|
26
27
|
readonly availableSkills?: readonly AvailableSkillDescription[];
|
|
27
28
|
readonly id: string;
|
|
28
29
|
readonly instructions: readonly string[];
|
|
30
|
+
readonly initialMessages?: readonly ModelMessage[];
|
|
29
31
|
/**
|
|
30
32
|
* Optional model used only for compaction summaries.
|
|
31
33
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AGENT_TOOL_NAME,isImplicitAgentToolAvailable}from"#runtime/framework-tools/agent.js";import{composeRuntimeBasePrompt}from"#runtime/prompt/compose.js";const BOOTSTRAP_RUNTIME_MODEL_ID=`eve-bootstrap-model`,BOOTSTRAP_RUNTIME_SYSTEM_PROMPT=`You are the eve bootstrap agent. Be concise, stay grounded in the current conversation, and do not assume tools are available unless the runtime provides them.`;function createResolvedRuntimeTurnAgent(n){let r=n.agent,i=r.config,a=n.id??i?.name;if(a===void 0)throw Error(`Expected a path-derived agent id while resolving agent resources.`);let o=n.tools.some(e=>e.kind===`subagent`||e.kind===`remote`),s=isImplicitAgentToolAvailable({disabledFrameworkTools:r.disabledFrameworkTools,hasAuthoredAgentTool:n.tools.some(t=>t.name===AGENT_TOOL_NAME),nodeId:n.nodeId}),c={availableSkills:r.skills.map(e=>({description:e.description,name:e.name})),id:a,instructions:composeRuntimeBasePrompt({connections:r.connections,instructions:r.instructions,persistentSubagentSessions:i?.experimental?.subagentPersistentSessions===!0,subagentsAvailable:o||s,toolsAvailable:n.tools.length>0||s,workspaceSpec:r.workspaceSpec}),compactionModel:i?.compaction?.model,nodeId:n.nodeId,outputSchema:i?.outputSchema,reasoning:i?.reasoning,tools:[...n.tools],workspaceSpec:r.workspaceSpec};return i===void 0?{...c,configResolver:!0}:i.dynamicModel===void 0?{...c,model:i.model}:{...c,dynamicModel:i.dynamicModel}}export{BOOTSTRAP_RUNTIME_MODEL_ID,BOOTSTRAP_RUNTIME_SYSTEM_PROMPT,createResolvedRuntimeTurnAgent};
|
|
1
|
+
import{AGENT_TOOL_NAME,isImplicitAgentToolAvailable}from"#runtime/framework-tools/agent.js";import{composeRuntimeBasePrompt}from"#runtime/prompt/compose.js";const BOOTSTRAP_RUNTIME_MODEL_ID=`eve-bootstrap-model`,BOOTSTRAP_RUNTIME_SYSTEM_PROMPT=`You are the eve bootstrap agent. Be concise, stay grounded in the current conversation, and do not assume tools are available unless the runtime provides them.`;function createResolvedRuntimeTurnAgent(n){let r=n.agent,i=r.config,a=n.id??i?.name;if(a===void 0)throw Error(`Expected a path-derived agent id while resolving agent resources.`);let o=n.tools.some(e=>e.kind===`subagent`||e.kind===`remote`),s=isImplicitAgentToolAvailable({disabledFrameworkTools:r.disabledFrameworkTools,hasAuthoredAgentTool:n.tools.some(t=>t.name===AGENT_TOOL_NAME),nodeId:n.nodeId}),c={availableSkills:r.skills.map(e=>({description:e.description,name:e.name})),id:a,initialMessages:r.instructions.filter(e=>e.role===`user`&&e.content.trim().length>0).map(e=>({content:e.content.trim(),role:`user`})),instructions:composeRuntimeBasePrompt({connections:r.connections,instructions:r.instructions,persistentSubagentSessions:i?.experimental?.subagentPersistentSessions===!0,subagentsAvailable:o||s,toolsAvailable:n.tools.length>0||s,workspaceSpec:r.workspaceSpec}),compactionModel:i?.compaction?.model,nodeId:n.nodeId,outputSchema:i?.outputSchema,reasoning:i?.reasoning,tools:[...n.tools],workspaceSpec:r.workspaceSpec};return i===void 0?{...c,configResolver:!0}:i.dynamicModel===void 0?{...c,model:i.model}:{...c,dynamicModel:i.dynamicModel}}export{BOOTSTRAP_RUNTIME_MODEL_ID,BOOTSTRAP_RUNTIME_SYSTEM_PROMPT,createResolvedRuntimeTurnAgent};
|
|
@@ -6,7 +6,7 @@ import type { WorkspaceRuntimeSpec } from "#runtime/workspace/types.js";
|
|
|
6
6
|
*/
|
|
7
7
|
interface ComposeRuntimeBasePromptInput {
|
|
8
8
|
connections?: readonly ResolvedConnectionDefinition[];
|
|
9
|
-
instructions?: ResolvedInstructionsDefinition;
|
|
9
|
+
instructions?: readonly ResolvedInstructionsDefinition[];
|
|
10
10
|
/**
|
|
11
11
|
* Whether the agent opted into `experimental.subagentPersistentSessions`.
|
|
12
12
|
* Gates the agent-messaging prompt block that documents `agentId`
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import{formatAvailableSkillsSection}from"#execution/skills/instructions.js";import{createWorkspacePromptSection}from"#runtime/workspace/spec.js";import{formatConnectionsSection}from"#runtime/prompt/connections.js";function composeRuntimeBasePrompt(e){return[...createInstructionsPromptBlocks(e.instructions),...createWorkspacePromptBlocks(e.workspaceSpec),...e.toolsAvailable?[`Tool execution
|
|
2
|
-
A single tool or subagent call runs as one serial action. If you call multiple independent tools or subagents in one response, eve treats that batch as parallel work. Only batch work that is independent and does not rely on another call in the same response.`]:[],...e.subagentsAvailable&&e.persistentSubagentSessions?["Agent messaging\nAgents you have already delegated to stay available after they answer. eve injects the current `<agents>` list into the conversation as a note labeled `[Agents]`; it is added automatically by the framework, not written by the user, and never requires a reply. The list is only a record of those existing agents — their `agentId`, name, and latest status. It does not limit which subagent tools you can call: your tool list is the source of truth, and any subagent tool can always be called without `agentId` to start a new agent, including when the `<agents>` list is empty or absent. Pass `agentId` to the same subagent tool only to continue one of those existing agents' sessions."]:[],...createConnectionsPromptBlocks(e.connections),...createSkillsPromptBlocks(e.skills)]}function createInstructionsPromptBlocks(e){
|
|
2
|
+
A single tool or subagent call runs as one serial action. If you call multiple independent tools or subagents in one response, eve treats that batch as parallel work. Only batch work that is independent and does not rely on another call in the same response.`]:[],...e.subagentsAvailable&&e.persistentSubagentSessions?["Agent messaging\nAgents you have already delegated to stay available after they answer. eve injects the current `<agents>` list into the conversation as a note labeled `[Agents]`; it is added automatically by the framework, not written by the user, and never requires a reply. The list is only a record of those existing agents — their `agentId`, name, and latest status. It does not limit which subagent tools you can call: your tool list is the source of truth, and any subagent tool can always be called without `agentId` to start a new agent, including when the `<agents>` list is empty or absent. Pass `agentId` to the same subagent tool only to continue one of those existing agents' sessions."]:[],...createConnectionsPromptBlocks(e.connections),...createSkillsPromptBlocks(e.skills)]}function createInstructionsPromptBlocks(e){let t=(e??[]).filter(e=>e.role===`system`&&e.content.trim().length>0);if(t.length===0)return[];let n=t.length===1?t[0]:void 0;return[`Instructions (${n!==void 0&&!n.sourceId.startsWith(`ext:`)&&!n.sourceId.startsWith(`ext-override:`)?n.name:`instructions`})\n${t.map(e=>e.content).join(`
|
|
3
|
+
|
|
4
|
+
`).trim()}`]}function createWorkspacePromptBlocks(e){if(e===void 0)return[];let n=createWorkspacePromptSection(e);return n===void 0?[]:[n]}function createConnectionsPromptBlocks(e){return!e||e.length===0?[]:[formatConnectionsSection(e)]}function createSkillsPromptBlocks(t){if(!t||t.length===0)return[];let n=formatAvailableSkillsSection(t);return n===null?[]:[n]}export{composeRuntimeBasePrompt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ResolveAgentError,createResolvedModuleSourceRef}from"#runtime/resolve-helpers.js";import{resolveDynamicToolDefinition}from"#runtime/resolve-dynamic-tool.js";import{resolveChannelDefinition}from"#runtime/resolve-channel.js";import{resolveConnectionDefinition}from"#runtime/resolve-connection.js";import{resolveHookDefinition}from"#runtime/resolve-hook.js";import{resolveSandboxDefinition}from"#runtime/resolve-sandbox.js";import{resolveDynamicInstructionsDefinition}from"#runtime/resolve-dynamic-instructions.js";import{resolveDynamicSkillDefinition}from"#runtime/resolve-dynamic-skill.js";import{resolveToolDefinition}from"#runtime/resolve-tool.js";async function resolveAgent(e){let t=e.manifest.skills.map(e=>({...e,metadata:e.metadata===void 0?void 0:{...e.metadata}})),i=[],a=[];for(let t of e.manifest.channels){if(t.kind===`disabled`){a.push(t.name);continue}i.push(await resolveChannelDefinition(t,e.moduleMap,e.nodeId))}let o=await Promise.all(e.manifest.tools.map(t=>resolveToolDefinition(t,e.moduleMap,e.nodeId))),s=await Promise.all((e.manifest.dynamicInstructions??[]).map(t=>resolveDynamicInstructionsDefinition(t,e.moduleMap,e.nodeId))),c=await Promise.all((e.manifest.dynamicSkills??[]).map(t=>resolveDynamicSkillDefinition(t,e.moduleMap,e.nodeId))),l=await Promise.all(e.manifest.dynamicTools.map(t=>resolveDynamicToolDefinition(t,e.moduleMap,e.nodeId))),u=await Promise.all(e.manifest.hooks.map(t=>resolveHookDefinition(t,e.moduleMap,e.nodeId))),d=await Promise.all(e.manifest.connections.map(t=>resolveConnectionDefinition(t,e.moduleMap,e.nodeId))),f=e.manifest.sandbox===null?null:await resolveSandboxDefinition(e.manifest.sandbox,e.moduleMap,e.nodeId),p=
|
|
1
|
+
import{ResolveAgentError,createResolvedModuleSourceRef}from"#runtime/resolve-helpers.js";import{resolveDynamicToolDefinition}from"#runtime/resolve-dynamic-tool.js";import{resolveChannelDefinition}from"#runtime/resolve-channel.js";import{resolveConnectionDefinition}from"#runtime/resolve-connection.js";import{resolveHookDefinition}from"#runtime/resolve-hook.js";import{resolveSandboxDefinition}from"#runtime/resolve-sandbox.js";import{resolveDynamicInstructionsDefinition}from"#runtime/resolve-dynamic-instructions.js";import{resolveDynamicSkillDefinition}from"#runtime/resolve-dynamic-skill.js";import{resolveToolDefinition}from"#runtime/resolve-tool.js";async function resolveAgent(e){let t=e.manifest.skills.map(e=>({...e,metadata:e.metadata===void 0?void 0:{...e.metadata}})),i=[],a=[];for(let t of e.manifest.channels){if(t.kind===`disabled`){a.push(t.name);continue}i.push(await resolveChannelDefinition(t,e.moduleMap,e.nodeId))}let o=await Promise.all(e.manifest.tools.map(t=>resolveToolDefinition(t,e.moduleMap,e.nodeId))),s=await Promise.all((e.manifest.dynamicInstructions??[]).map(t=>resolveDynamicInstructionsDefinition(t,e.moduleMap,e.nodeId))),c=await Promise.all((e.manifest.dynamicSkills??[]).map(t=>resolveDynamicSkillDefinition(t,e.moduleMap,e.nodeId))),l=await Promise.all(e.manifest.dynamicTools.map(t=>resolveDynamicToolDefinition(t,e.moduleMap,e.nodeId))),u=await Promise.all(e.manifest.hooks.map(t=>resolveHookDefinition(t,e.moduleMap,e.nodeId))),d=await Promise.all(e.manifest.connections.map(t=>resolveConnectionDefinition(t,e.moduleMap,e.nodeId))),f=e.manifest.sandbox===null?null:await resolveSandboxDefinition(e.manifest.sandbox,e.moduleMap,e.nodeId),p=e.manifest.instructions.map(createResolvedInstructionsDefinition),m=e.manifest.workspaceResourceRoot,h={channels:i,connections:d,disabledFrameworkChannels:a,disabledFrameworkTools:[...e.manifest.disabledFrameworkTools],workflowTool:e.manifest.workflowTool===void 0?void 0:{maxSubagents:e.manifest.workflowTool.maxSubagents},webSearchProvider:e.manifest.webSearchProvider,dynamicInstructionsResolvers:s,dynamicSkillResolvers:c,dynamicToolResolvers:l,hooks:u,instructions:p,metadata:{agentRoot:e.manifest.agentRoot,appRoot:e.manifest.appRoot,diagnosticsSummary:e.manifest.diagnosticsSummary},sandbox:f,workspaceResourceRoot:m,skills:t,tools:o,workspaceSpec:{rootEntries:[...m.rootEntries]}};return`config`in e.manifest?{...h,config:createResolvedAgentConfig(e.manifest)}:h}function createResolvedInstructionsDefinition(e){return{content:e.content,name:e.name,logicalPath:e.logicalPath,role:e.role,sourceId:e.sourceId,sourceKind:e.sourceKind}}function createResolvedAgentConfig(e){let n={name:e.config.name};if(e.config.compaction!==void 0){let t={};e.config.compaction.model!==void 0&&(t.model=e.config.compaction.model.source===void 0?{contextWindowTokens:e.config.compaction.model.contextWindowTokens,id:e.config.compaction.model.id,maxOutputTokens:e.config.compaction.model.maxOutputTokens,providerOptions:e.config.compaction.model.providerOptions}:{contextWindowTokens:e.config.compaction.model.contextWindowTokens,id:e.config.compaction.model.id,maxOutputTokens:e.config.compaction.model.maxOutputTokens,providerOptions:e.config.compaction.model.providerOptions,source:{exportName:e.config.compaction.model.source.exportName,sourceKind:`module`,logicalPath:e.config.compaction.model.source.logicalPath,sourceId:e.config.compaction.model.source.sourceId}}),e.config.compaction.thresholdPercent!==void 0&&(t.thresholdPercent=e.config.compaction.thresholdPercent),n.compaction=t}if(e.config.experimental!==void 0&&(n.experimental={instrumentationProviders:e.config.experimental.instrumentationProviders,subagentPersistentSessions:e.config.experimental.subagentPersistentSessions,workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}}),e.config.outputSchema!==void 0&&(n.outputSchema=e.config.outputSchema),e.config.reasoning!==void 0&&(n.reasoning=e.config.reasoning),e.config.source!==void 0&&(n.source=createResolvedModuleSourceRef(e.config.source)),e.config.limits!==void 0&&(n.limits={maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,sessionTimeoutMs:e.config.limits.sessionTimeoutMs}),e.config.dynamicModel!==void 0)return{...n,dynamicModel:{...createResolvedModuleSourceRef(e.config.dynamicModel),eventNames:[...e.config.dynamicModel.eventNames]}};let r=e.config.model;return{...n,model:r.source===void 0?{id:r.id,contextWindowTokens:r.contextWindowTokens,maxOutputTokens:r.maxOutputTokens,providerOptions:r.providerOptions}:{contextWindowTokens:r.contextWindowTokens,id:r.id,maxOutputTokens:r.maxOutputTokens,providerOptions:r.providerOptions,source:{exportName:r.source.exportName,sourceKind:`module`,logicalPath:r.source.logicalPath,sourceId:r.source.sourceId}}}}export{ResolveAgentError,resolveAgent};
|
|
@@ -36,12 +36,13 @@ export type ResolvedModuleSourceRef = Readonly<ModuleSourceRef>;
|
|
|
36
36
|
* `instructions.{ts,...}`.
|
|
37
37
|
*
|
|
38
38
|
* Module-backed instructions sources are executed once at build time —
|
|
39
|
-
* the resulting
|
|
39
|
+
* the resulting content is captured here. Runtime never re-evaluates
|
|
40
40
|
* the module.
|
|
41
41
|
*/
|
|
42
42
|
export type ResolvedInstructionsDefinition = Readonly<SourceRef & {
|
|
43
|
+
content: string;
|
|
43
44
|
name: string;
|
|
44
|
-
|
|
45
|
+
role: "system" | "user";
|
|
45
46
|
} & (Omit<MarkdownSourceRef<undefined>, "definition"> | ModuleSourceRef)>;
|
|
46
47
|
/**
|
|
47
48
|
* Runtime-owned skill metadata resolved from markdown, TypeScript, or a skill
|
|
@@ -368,7 +369,7 @@ export interface ResolvedAgent {
|
|
|
368
369
|
* `instructions.{ts,...}`, or `undefined` when the agent does not
|
|
369
370
|
* declare one.
|
|
370
371
|
*/
|
|
371
|
-
readonly instructions
|
|
372
|
+
readonly instructions: readonly ResolvedInstructionsDefinition[];
|
|
372
373
|
/**
|
|
373
374
|
* Authored sandbox override for this agent, when one exists. `null`
|
|
374
375
|
* means the agent uses the framework default sandbox unchanged.
|