Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

[1/3] feat(eve): add `principalId` to `authorization` events (#4003)

Ben Pankowa4028360a8c1
diff --git a/.changeset/authorization-event-principal.md b/.changeset/authorization-event-principal.md
new file mode 100644
index 000000000..098f3d2a5
--- /dev/null
+++ b/.changeset/authorization-event-principal.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+`authorization.required` and `authorization.completed` events now include `principalId`, the session principal who started the sign-in, using the same value as `responderPrincipalId` on approval events. Candidate sign-in events also now include their `attemptId`.
diff --git a/docs/concepts/sessions-runs-and-streaming.md b/docs/concepts/sessions-runs-and-streaming.md
index 4fdf1c549..ee48bbafb 100644
--- a/docs/concepts/sessions-runs-and-streaming.md
+++ b/docs/concepts/sessions-runs-and-streaming.md
@@ -129,7 +129,7 @@ A call to a tool that runs as a task, such as an agent tool, `agentRouter()`, th
A turn doesn't end while tasks are working. When the model ends its text early, eve holds the turn and the stream emits `turn.waiting` for it; the turn continues once a result arrives or its caller writes. In a root session, that text completes as an ordinary `message.completed`. In a child session or a schedule's session, it reports `finishReason: "tool-calls"`, so channels post only the final reply. When the model calls `task_wait` and no result is ready yet, the stream also emits `turn.waiting`. Either way, the next `step.started` for the same `turnId` means the turn resumed, and `session.waiting` comes only after the turn ends. See [Tasks](/docs/tools/tasks#turns-wait-for-their-tasks).
-`step.failed` and `turn.failed` carry `{ code, message, details? }` for the failed fragment or turn, and `session.failed` is the terminal session-level variant. `turn.cancelled` is not a failure: the cancelled turn ends without any failure event, `session.waiting` follows, and the session accepts the next message normally. Whatever the turn streamed before cancellation stays on the stream. Durable history keeps the accepted user input and previously settled work, and discards incomplete assistant output. Tool calls the cancellation stopped stay in history, each answered as cancelled, so the model sees that the work started and stopped instead of a request left unanswered. When a turn requested an output schema, the finalized payload lands on `result.completed` as `data.result` before the turn boundary. `authorization.required` carries the sign-in challenge (`data.authorization` may include `url`, `userCode`, `expiresAt`, `instructions`), and `authorization.completed` carries `data.outcome` (`"authorized" | "declined" | "failed" | "timed-out"`).
+`step.failed` and `turn.failed` carry `{ code, message, details? }` for the failed fragment or turn, and `session.failed` is the terminal session-level variant. `turn.cancelled` is not a failure: the cancelled turn ends without any failure event, `session.waiting` follows, and the session accepts the next message normally. Whatever the turn streamed before cancellation stays on the stream. Durable history keeps the accepted user input and previously settled work, and discards incomplete assistant output. Tool calls the cancellation stopped stay in history, each answered as cancelled, so the model sees that the work started and stopped instead of a request left unanswered. When a turn requested an output schema, the finalized payload lands on `result.completed` as `data.result` before the turn boundary. `authorization.required` carries the sign-in challenge (`data.authorization` may include `url`, `userCode`, `expiresAt`, `instructions`), and `authorization.completed` carries `data.outcome` (`"authorized" | "declined" | "failed" | "timed-out"`). Both carry `data.principalId` when a session principal started the sign-in. It holds the same value as `responderPrincipalId` on approval events, so a channel can deliver the challenge privately to that person even after someone else starts a later turn.
A provider response ending with `content-filter` fails with `MODEL_CALL_FAILED`,
`details.semanticErrorId: "model-response-content-filtered"`, and
diff --git a/e2e/fixtures/agent-subagents/evals/remote-direct-authorization.eval.ts b/e2e/fixtures/agent-subagents/evals/remote-direct-authorization.eval.ts
index 7a815cb79..3a24cadac 100644
--- a/e2e/fixtures/agent-subagents/evals/remote-direct-authorization.eval.ts
+++ b/e2e/fixtures/agent-subagents/evals/remote-direct-authorization.eval.ts
@@ -1,8 +1,12 @@
import { defineEval } from "eve/evals";
import { DIRECT_AUTHORIZATION } from "../agent/lib/remote-direct-hitl-script.js";
+/** Alice's fixture principal; the remote hop itself runs as the `router-app` service. */
+const ALICE = "e2e-user";
+
export default defineEval({
- description: "Alice authorizes a tool called directly in her remote agent.",
+ description:
+ "Alice authorizes a tool called directly in her remote agent. The forwarded sign-in names Alice, not the service hop that reached the child.",
timeoutMs: 90_000,
async test(t) {
const session = await t.session();
@@ -22,10 +26,11 @@ export default defineEval({
data: {
name: "direct-release-authorization",
authorization: { userCode: "direct-release-code" },
+ principalId: ALICE,
},
});
turn.event("authorization.completed", {
- data: { name: "direct-release-authorization", outcome: "authorized" },
+ data: { name: "direct-release-authorization", outcome: "authorized", principalId: ALICE },
});
turn.messageIncludes("PARENT-DIRECT-COMPLETE: DIRECT-AUTHORIZATION-COMPLETE");
t.calledSubagent("remote-loopback", { status: "completed", count: 1 });
diff --git a/e2e/fixtures/agent-tools-hitl/evals/auth/authorization-principal-after-other-speaker.eval.ts b/e2e/fixtures/agent-tools-hitl/evals/auth/authorization-principal-after-other-speaker.eval.ts
new file mode 100644
index 000000000..e349bfc69
--- /dev/null
+++ b/e2e/fixtures/agent-tools-hitl/evals/auth/authorization-principal-after-other-speaker.eval.ts
@@ -0,0 +1,50 @@
+import { defineEval } from "eve/evals";
+
+const ALICE = "principal-binding-alice";
+const BOB = "principal-binding-bob";
+const as = (principalId: string) => ({ headers: { "x-eve-fixture-user": principalId } });
+
+/**
+ * Alice starts a sign-in, then Bob posts in the same session before Alice
+ * finishes. Bob is now the session's latest caller, so a channel that picks
+ * the recipient from the current caller would send Alice's challenge or
+ * completion status to Bob. Both events name Alice instead.
+ */
+export default defineEval({
+ description: "A sign-in stays bound to the person who started it after someone else speaks.",
+ async test(t) {
+ const started = await t.send(
+ 'Call the auth-probe tool exactly once with marker "principal-binding".',
+ as(ALICE),
+ );
+ const session = started.session;
+ started.event("authorization.required", { count: 1, data: { principalId: ALICE } });
+ started.event("session.waiting", { count: 1 });
+ const required = started.events.find((event) => event.type === "authorization.required");
+ if (
+ required?.type !== "authorization.required" ||
+ required.data.authorization?.url === undefined
+ )
+ throw new Error("Expected Alice's sign-in challenge URL.");
+
+ const bob = await session.send(
+ "Do not call any tools. Reply with exactly BOB-STATUS-OK.",
+ as(BOB),
+ );
+ bob.expectOk();
+ bob.messageIncludes("BOB-STATUS-OK");
+ bob.notEvent("authorization.required");
+ bob.notEvent("authorization.completed");
+
+ const callbackTurn = t.target.watchTurn(session.sessionId, {
+ startIndex: session.state?.streamIndex,
+ });
+ const callback = await fetch(new URL(required.data.authorization.url));
+ if (!callback.ok) throw new Error(`Fixture sign-in callback failed (${callback.status}).`);
+ const completed = await callbackTurn.result();
+ completed.event("authorization.completed", {
+ count: 1,
+ data: { attemptId: required.data.attemptId, outcome: "authorized", principalId: ALICE },
+ });
+ },
+});
diff --git a/e2e/fixtures/agent-tools-hitl/evals/hitl/authorized-response-oauth-nonblocking.eval.ts b/e2e/fixtures/agent-tools-hitl/evals/hitl/authorized-response-oauth-nonblocking.eval.ts
index 3d31683a4..db10ee98b 100644
--- a/e2e/fixtures/agent-tools-hitl/evals/hitl/authorized-response-oauth-nonblocking.eval.ts
+++ b/e2e/fixtures/agent-tools-hitl/evals/hitl/authorized-response-oauth-nonblocking.eval.ts
@@ -2,13 +2,18 @@ import { defineEval } from "eve/evals";
const MARKER = "authorized-response-oauth-nonblocking-K3T9";
const TOOL_NAME = "oauth-authorized-gate";
+const REQUESTER = "oauth-nonblocking-requester";
+const RESPONDER = "oauth-nonblocking-responder";
+const as = (principalId: string) => ({ headers: { "x-eve-fixture-user": principalId } });
export default defineEval({
tags: ["real-model"],
- description: "A message runs while candidate OAuth stays open, then OAuth settles the approval.",
+ description:
+ "A message runs while candidate OAuth stays open, then OAuth settles the approval. The sign-in names the responder, not the requester who speaks while it waits.",
async test(t) {
const { session: conversation } = await t.send(
`Call the \`${TOOL_NAME}\` tool with marker "${MARKER}".`,
+ as(REQUESTER),
);
const approval = conversation.requireInputRequest({
display: "confirmation",
@@ -16,12 +21,13 @@ export default defineEval({
});
const approvalTurn = await conversation.startRespond(
[{ optionId: "approve", requestId: approval.requestId }],
- { headers: { "x-eve-fixture-user": "oauth-nonblocking-responder" } },
+ as(RESPONDER),
);
const required = await approvalTurn.waitForEvent("authorization.required");
const message = await approvalTurn.session.send(
"Do not call tools. Reply with exactly CANDIDATE-OAUTH-OPEN-OK.",
+ as(REQUESTER),
);
message.expectOk();
message.messageIncludes("CANDIDATE-OAUTH-OPEN-OK");
@@ -36,6 +42,11 @@ export default defineEval({
) {
throw new Error("Expected candidate OAuth URL.");
}
+ if (required.data.principalId !== RESPONDER) {
+ throw new Error(
+ `Candidate sign-in named ${String(required.data.principalId)}, not the responder.`,
+ );
+ }
const callbackUrl = new URL(required.data.authorization.url);
const callbackTurn = t.target.watchTurn(approvalTurn.sessionId, {
startIndex: conversation.state?.streamIndex,
@@ -45,7 +56,10 @@ export default defineEval({
if (!callback.ok)
throw new Error(`Fixture OAuth callback failed (${String(callback.status)}).`);
const resumed = await callbackTurn.result();
- resumed.event("authorization.completed", { count: 1, data: { outcome: "authorized" } });
+ resumed.event("authorization.completed", {
+ count: 1,
+ data: { outcome: "authorized", principalId: RESPONDER },
+ });
resumed.event("approval.settled", {
count: 1,
data: { outcome: "approved", requestId: approval.requestId },
diff --git a/packages/eve/extension-contracts/compatibility/channel/v36.ts b/packages/eve/extension-contracts/compatibility/channel/v36.ts
new file mode 100644
index 000000000..b78f70d82
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/channel/v36.ts
@@ -0,0 +1,14 @@
+import { defineChannel } from "#public/channels/index.js";
+
+// Epoch 36 authorization events had no `principalId`; it is additive.
+export default defineChannel({
+ routes: [],
+ events: {
+ "authorization.required"(event) {
+ console.info("sign-in required", { name: event.name, url: event.authorization?.url });
+ },
+ "authorization.completed"(event) {
+ console.info("sign-in completed", { name: event.name, outcome: event.outcome });
+ },
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/connection/v32.ts b/packages/eve/extension-contracts/compatibility/connection/v32.ts
new file mode 100644
index 000000000..0c3b7ccd2
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/connection/v32.ts
@@ -0,0 +1,14 @@
+import { defineDynamic, defineMcpClientConnection } from "#public/connections/index.js";
+
+// Epoch 32 authorization events had no `principalId`; it is additive.
+export default defineDynamic({
+ events: {
+ "turn.started": (_event, ctx) =>
+ ctx.session.auth.current === null
+ ? null
+ : defineMcpClientConnection({
+ description: "Search the support knowledge base.",
+ url: "https://support.example.com/mcp",
+ }),
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/dynamicInstructions/v26.ts b/packages/eve/extension-contracts/compatibility/dynamicInstructions/v26.ts
new file mode 100644
index 000000000..772a239a6
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/dynamicInstructions/v26.ts
@@ -0,0 +1,9 @@
+import { defineDynamic, defineInstructions } from "#public/instructions/index.js";
+
+// Epoch 26 authorization events had no `principalId`; it is additive.
+export default defineDynamic({
+ events: {
+ "turn.started": (_event, ctx) =>
+ defineInstructions({ markdown: `Review evidence for session ${ctx.session.id}.` }),
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/dynamicSkill/v25.ts b/packages/eve/extension-contracts/compatibility/dynamicSkill/v25.ts
new file mode 100644
index 000000000..0d32e4469
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/dynamicSkill/v25.ts
@@ -0,0 +1,12 @@
+import { defineDynamic, defineSkill } from "#public/skills/index.js";
+
+// Epoch 25 authorization events had no `principalId`; it is additive.
+export default defineDynamic({
+ events: {
+ "turn.started": (_event, ctx) =>
+ defineSkill({
+ description: `Review evidence for session ${ctx.session.id}.`,
+ markdown: "# Evidence review\n\nCheck every claim against its source.",
+ }),
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/dynamicTool/v60.ts b/packages/eve/extension-contracts/compatibility/dynamicTool/v60.ts
new file mode 100644
index 000000000..bcbe173a0
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/dynamicTool/v60.ts
@@ -0,0 +1,13 @@
+import { defineDynamic, defineTool } from "#public/tools/index.js";
+
+// Epoch 60 authorization events had no `principalId`; it is additive.
+export default defineDynamic({
+ events: {
+ "turn.started": (_event, ctx) =>
+ defineTool({
+ description: "Return the active session identifier.",
+ inputSchema: { type: "object", properties: {} },
+ execute: () => ({ sessionId: ctx.session.id }),
+ }),
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/hook/v31.ts b/packages/eve/extension-contracts/compatibility/hook/v31.ts
new file mode 100644
index 000000000..e6d344a88
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/hook/v31.ts
@@ -0,0 +1,17 @@
+import { defineHook } from "#public/hooks/index.js";
+
+// Epoch 31 authorization events had no `principalId`; it is additive.
+export default defineHook({
+ events: {
+ "authorization.required"(event, ctx) {
+ console.info("sign-in required", {
+ attemptId: event.data.attemptId,
+ name: event.data.name,
+ sessionId: ctx.session.id,
+ });
+ },
+ "authorization.completed"(event) {
+ console.info("sign-in completed", { name: event.data.name, outcome: event.data.outcome });
+ },
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/schedule/v18.ts b/packages/eve/extension-contracts/compatibility/schedule/v18.ts
new file mode 100644
index 000000000..f3d5b8365
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/schedule/v18.ts
@@ -0,0 +1,22 @@
+import { defineChannel } from "#public/channels/index.js";
+import { defineSchedule } from "#public/schedules/index.js";
+
+// Epoch 18 authorization events had no `principalId`; it is additive.
+const updates = defineChannel({
+ routes: [],
+ events: {
+ "authorization.required"(event) {
+ console.info("sign-in required", { name: event.name });
+ },
+ },
+ receive(input, { from }) {
+ return from("daily-updates").send(input.message, { auth: input.auth });
+ },
+});
+
+export default defineSchedule({
+ cron: "0 9 * * *",
+ async run({ to, appAuth }) {
+ await to(updates, {}).send("Prepare the daily summary.", { auth: appAuth });
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/subagent/v23.ts b/packages/eve/extension-contracts/compatibility/subagent/v23.ts
new file mode 100644
index 000000000..f7937cb62
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/subagent/v23.ts
@@ -0,0 +1,14 @@
+import { defineAgent, defineDynamic } from "#public/index.js";
+
+// Epoch 23 authorization events had no `principalId`; it is additive.
+export default defineDynamic({
+ events: {
+ "turn.started": (_event, ctx) =>
+ ctx.session.auth.current === null
+ ? null
+ : defineAgent({
+ description: "Investigate the authenticated user request.",
+ model: "openai/gpt-5.6-sol",
+ }),
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/tool/v63.ts b/packages/eve/extension-contracts/compatibility/tool/v63.ts
new file mode 100644
index 000000000..36f3ece7d
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/tool/v63.ts
@@ -0,0 +1,18 @@
+import { z } from "zod";
+import { defineTool } from "#public/tools/index.js";
+
+// Epoch 63 authorization events had no `principalId`. Compiled epoch 63 tools
+// still park on sign-in through ctx.getToken; `principalId` is additive.
+export default defineTool({
+ description: "List the caller's open tickets.",
+ inputSchema: z.object({ project: z.string() }),
+ async execute({ project }, ctx) {
+ const { token } = await ctx.getToken({
+ principalType: "user",
+ async getToken() {
+ return { token: "ticket-token" };
+ },
+ });
+ return { authorized: token.length > 0, project };
+ },
+});
diff --git a/packages/eve/extension-contracts/reports/channel/v37.json b/packages/eve/extension-contracts/reports/channel/v37.json
new file mode 100644
index 000000000..c6bed0ff5
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/channel/v37.json
@@ -0,0 +1,21 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "channel",
+ "epoch": 37,
+ "sha256": "912cd731c677093c691165943c49d722c3dfaad48d372e45f7dc250cdc13e9c1",
+ "exports": [
+ "DELETE",
+ "GET",
+ "HEAD",
+ "OPTIONS",
+ "PATCH",
+ "POST",
+ "PUT",
+ "WS",
+ "createWebSocketUpgradeServer",
+ "defineChannel",
+ "disableRoute",
+ "isChannel",
+ "isDisabledRouteSentinel"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/connection/v33.json b/packages/eve/extension-contracts/reports/connection/v33.json
new file mode 100644
index 000000000..c0641d0ed
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/connection/v33.json
@@ -0,0 +1,16 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "connection",
+ "epoch": 33,
+ "sha256": "7d887bec62c02319218333e6cefd7416b9783ecde6066ef754dc4429fb7dadfc",
+ "exports": [
+ "ConnectionAuthorizationFailedError",
+ "ConnectionAuthorizationRequiredError",
+ "defineDynamic",
+ "defineInteractiveAuthorization",
+ "defineMcpClientConnection",
+ "defineOpenAPIConnection",
+ "isConnectionAuthorizationFailedError",
+ "isConnectionAuthorizationRequiredError"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/dynamicInstructions/v27.json b/packages/eve/extension-contracts/reports/dynamicInstructions/v27.json
new file mode 100644
index 000000000..729cc8d9c
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/dynamicInstructions/v27.json
@@ -0,0 +1,7 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "dynamicInstructions",
+ "epoch": 27,
+ "sha256": "23b88d414915eb4eb5602a86aa64c2d92e0bd46f28e1961c7458ad6bb35467ee",
+ "exports": ["defineDynamic"]
+}
diff --git a/packages/eve/extension-contracts/reports/dynamicSkill/v26.json b/packages/eve/extension-contracts/reports/dynamicSkill/v26.json
new file mode 100644
index 000000000..3888dc86b
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/dynamicSkill/v26.json
@@ -0,0 +1,7 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "dynamicSkill",
+ "epoch": 26,
+ "sha256": "e3587d51ea75e4a5d0ec74f9eb97daab0e63e332b3b5e3d20283ad6461dca89a",
+ "exports": ["defineDynamic"]
+}
diff --git a/packages/eve/extension-contracts/reports/dynamicTool/v61.json b/packages/eve/extension-contracts/reports/dynamicTool/v61.json
new file mode 100644
index 000000000..32ed3a7e3
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/dynamicTool/v61.json
@@ -0,0 +1,16 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "dynamicTool",
+ "epoch": 61,
+ "sha256": "d0623ad154b98686c393e428c9fca356b4c5595f018c130d4f92bf2c948ec8f4",
+ "exports": [
+ "DynamicToolEntry",
+ "DynamicToolEvents",
+ "DynamicToolResult",
+ "DynamicToolSet",
+ "auto",
+ "defineDurableCallback",
+ "defineDurableSchema",
+ "defineDynamic"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/hook/v32.json b/packages/eve/extension-contracts/reports/hook/v32.json
new file mode 100644
index 000000000..2fdd76476
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/hook/v32.json
@@ -0,0 +1,7 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "hook",
+ "epoch": 32,
+ "sha256": "2892a8e11cab1cfff6c7f6a5d93538c286db86996215bd6f9a200c77a60c7935",
+ "exports": ["defineHook"]
+}
diff --git a/packages/eve/extension-contracts/reports/schedule/v19.json b/packages/eve/extension-contracts/reports/schedule/v19.json
new file mode 100644
index 000000000..275ba627e
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/schedule/v19.json
@@ -0,0 +1,14 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "schedule",
+ "epoch": 19,
+ "sha256": "8f7363efd6803eb6694c16a741bac41bd377c5fb87d4310d07c5706329bd4aa8",
+ "exports": [
+ "ScheduleDefinition",
+ "ScheduleHandlerArgs",
+ "ScheduleRunHandler",
+ "ScheduleToFn",
+ "TypedReceiveTarget",
+ "defineSchedule"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/subagent/v24.json b/packages/eve/extension-contracts/reports/subagent/v24.json
new file mode 100644
index 000000000..4cf181aeb
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/subagent/v24.json
@@ -0,0 +1,23 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "subagent",
+ "epoch": 24,
+ "sha256": "c4f6404acc676d9f79cc74c79846109bdcfbb68a1b9bb8dc95134ed1e1a3f72c",
+ "exports": [
+ "AgentCompactionDefinition",
+ "AgentDefinition",
+ "AgentModelDefinition",
+ "AgentStaticModelDefinition",
+ "DefinedAgent",
+ "DynamicLocalSubagentDefinition",
+ "DynamicSubagentDefinition",
+ "RemoteAgentDefinition",
+ "RemoteAgentDefinitionInput",
+ "WorkspaceAgentDefinition",
+ "WorkspaceAgentTransport",
+ "defineAgent",
+ "defineDynamic",
+ "defineRemoteAgent",
+ "defineWorkspaceAgent"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/tool/v64.json b/packages/eve/extension-contracts/reports/tool/v64.json
new file mode 100644
index 000000000..f63fb8a0f
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/tool/v64.json
@@ -0,0 +1,28 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "tool",
+ "epoch": 64,
+ "sha256": "2327e493b288e0637cd2522e29617da73c1699a76ba44cccb8dd5202a69162ba",
+ "exports": [
+ "AgentRouterInput",
+ "AgentRouterTool",
+ "WorkflowStepToolContext",
+ "WorkflowTool",
+ "WorkflowToolDefinition",
+ "WorkflowToolInput",
+ "WorkflowToolOptions",
+ "agentRouter",
+ "defaultWebSearch",
+ "defineTool",
+ "defineWorkflowTool",
+ "disableTool",
+ "evaluate",
+ "isDisabledToolSentinel",
+ "isWebSearchToolDefinition",
+ "toolOutput",
+ "toolOutputPart",
+ "toolResultFrom",
+ "webSearch",
+ "workflow"
+ ]
+}
diff --git a/packages/eve/src/compiler/extension-compatibility.ts b/packages/eve/src/compiler/extension-compatibility.ts
index 1d3d6cacf..10d84c699 100644
--- a/packages/eve/src/compiler/extension-compatibility.ts
+++ b/packages/eve/src/compiler/extension-compatibility.ts
@@ -22,8 +22,8 @@ interface ExtensionCapabilityContract {
const EXTENSION_CAPABILITY_CONTRACTS = {
extension: { current: 1, supported: [1], dropped: {} },
tool: {
- current: 63,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 29, 30, 31, 32, 34, 35, 54, 55, 63],
+ current: 64,
+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 29, 30, 31, 32, 34, 35, 54, 55, 63, 64],
dropped: {
14: "TaskExec.delegated was removed; migrate to workflow-backed background tools",
15: "TaskExec replaces stageEffect with send",
@@ -69,10 +69,10 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
},
dynamicTool: {
- current: 60,
+ current: 61,
supported: [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 31, 32, 33, 52, 54,
- 60,
+ 60, 61,
],
dropped: {
21: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
@@ -111,8 +111,8 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
},
channel: {
- current: 36,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 29, 31, 36],
+ current: 37,
+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 29, 31, 36, 37],
dropped: {
12: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
19: "Continuation rekey was removed; channel extensions must use additive continuation.alias instead.",
@@ -133,8 +133,8 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
},
schedule: {
- current: 18,
- supported: [1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18],
+ current: 19,
+ supported: [1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 19],
dropped: {
5: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
16: 'Background task delivery was removed: sends no longer accept taskDeliveryPolicy and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.',
@@ -142,8 +142,8 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
},
subagent: {
- current: 23,
- supported: [3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 23],
+ current: 24,
+ supported: [3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 23, 24],
dropped: {
1: "Persistent subagent sessions are now the default and the experimental opt-in was removed",
2: "Persistent subagent sessions are now the default and the experimental opt-in was removed",
@@ -156,8 +156,10 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
},
connection: {
- current: 32,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 32],
+ current: 33,
+ supported: [
+ 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 32, 33,
+ ],
dropped: {
9: "Dynamic connection resolvers no longer receive conversation or channel continuation data",
10: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
@@ -171,8 +173,8 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
},
hook: {
- current: 31,
- supported: [20, 21, 22, 23, 25, 27, 31],
+ current: 32,
+ supported: [20, 21, 22, 23, 25, 27, 31, 32],
dropped: {
1: "Model identity moved from session.started runtime metadata to step.started call attribution.",
2: "Model identity moved from session.started runtime metadata to step.started call attribution.",
@@ -202,8 +204,8 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
skill: { current: 2, supported: [1, 2], dropped: {} },
dynamicSkill: {
- current: 25,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 25],
+ current: 26,
+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 25, 26],
dropped: {
13: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
22: "Run mode was removed; sessions always park and ConversationContext no longer carries mode.",
@@ -213,8 +215,8 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
instructions: { current: 2, supported: [1, 2], dropped: {} },
dynamicInstructions: {
- current: 26,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 26],
+ current: 27,
+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 26, 27],
dropped: {
14: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
23: "Run mode was removed; sessions always park and ConversationContext no longer carries mode.",
diff --git a/packages/eve/src/execution/authorization-callback-match.ts b/packages/eve/src/execution/authorization-callback-match.ts
index a9c51a0ae..ffc466856 100644
--- a/packages/eve/src/execution/authorization-callback-match.ts
+++ b/packages/eve/src/execution/authorization-callback-match.ts
@@ -1,11 +1,13 @@
import type { DeliverPayload } from "#channel/types.js";
-import type { AuthorizationResult, PendingAuthorizationState } from "#harness/authorization.js";
-import type { ConnectionAuthorizationChallenge } from "#connections/errors.js";
+import type {
+ AuthorizationChallenge,
+ AuthorizationResult,
+ PendingAuthorizationState,
+} from "#harness/authorization.js";
import type { AuthorizationCallback } from "#shared/connection-types.js";
export interface MatchedAuthorizationCallback {
- readonly authorization: ConnectionAuthorizationChallenge;
- readonly candidateId?: string;
+ readonly challenge: AuthorizationChallenge;
readonly result: { readonly name: string; readonly attemptId: string } & AuthorizationResult;
}
@@ -50,8 +52,7 @@ export function matchAuthorizationCallbacks(
matchedAttemptKeys.add(attemptKey);
matches.push({
- authorization: challenge.challenge,
- candidateId: challenge.candidateId,
+ challenge,
result: {
attemptId: attemptKey,
callback: callback.callback,
diff --git a/packages/eve/src/execution/session/entry-authorization.integration.test.ts b/packages/eve/src/execution/session/entry-authorization.integration.test.ts
index 5041524ea..bd9ec3861 100644
--- a/packages/eve/src/execution/session/entry-authorization.integration.test.ts
+++ b/packages/eve/src/execution/session/entry-authorization.integration.test.ts
@@ -246,9 +246,14 @@ describe("workflowEntry integration", () => {
const completed = filterEventsByType(callbackTurn, "authorization.completed");
expectSingleTurn(callbackTurn, "turn_2");
expect(completed).toHaveLength(1);
+ // The attempt stays bound to user-1 even though user-2 spoke last.
+ expect(filterEventsByType(firstTurn, "authorization.required")[0]?.data.principalId).toBe(
+ "user-1",
+ );
expect(completed[0]?.data).toMatchObject({
name: "weather",
outcome: "authorized",
+ principalId: "user-1",
});
// The granted authorization serves the next explicit tool request.
diff --git a/packages/eve/src/execution/session/turn-connection-approval.integration.test.ts b/packages/eve/src/execution/session/turn-connection-approval.integration.test.ts
index 2930ac7a3..60a5e4e33 100644
--- a/packages/eve/src/execution/session/turn-connection-approval.integration.test.ts
+++ b/packages/eve/src/execution/session/turn-connection-approval.integration.test.ts
@@ -12,7 +12,9 @@ import {
getApprovalAuditState,
markApprovalCandidateAuthorizationRequired,
} from "#harness/approval-candidates.js";
-import { setPendingAuthorization } from "#harness/authorization.js";
+import { CallbackBaseUrlKey, setPendingAuthorization } from "#harness/authorization.js";
+import { ConnectionAuthorizationRequiredError } from "#connections/errors.js";
+import { defineInteractiveAuthorization } from "#shared/connection-types.js";
import { getPendingInputBatches } from "#harness/pending-input-batches.js";
import type { HarnessSession } from "#harness/types.js";
import { defineOpenAPIConnection } from "#public/definitions/connections/openapi.js";
@@ -250,6 +252,7 @@ function setup(
ctx.set(BundleKey, bundle);
ctx.set(ChannelKey, adapter);
ctx.set(SessionIdKey, sessionId);
+ ctx.set(CallbackBaseUrlKey, "https://agent.example.com");
const session: HarnessSession = {
agent: { modelReference: { id: "test" }, system: "Save notes.", tools: [] },
compaction: { recentWindowSize: 10, threshold: 100_000 },
@@ -504,6 +507,80 @@ describe("turn connection approval restoration", () => {
]);
});
+ it("names the responder, not the requester, on a candidate's sign-in events", async () => {
+ const signIn = defineInteractiveAuthorization<{ readonly nonce: string }>({
+ async getToken() {
+ throw new ConnectionAuthorizationRequiredError("notes-approver");
+ },
+ async startAuthorization() {
+ return { challenge: { url: "https://idp.example/sign-in" }, resume: { nonce: "n1" } };
+ },
+ async completeAuthorization() {
+ return { token: "approver-token" };
+ },
+ });
+ const fixture = setup();
+ fixture.response.mockImplementation(((context: ApprovalResponseContext) =>
+ context.auth
+ .getToken(signIn, { authKey: "notes-approver" })
+ .then(() => ({ status: "allowed" as const }))) as never);
+ await fixture.step({
+ delivery: { kind: "deliver", payloads: [{ message: "Prepare Alice's note for Bob." }] },
+ });
+ const parked = await fixture.step();
+ const request = getPendingInputBatches(readDurableSession(parked.sessionState).state)[0]!
+ .requests[0]!;
+
+ const signInStart = fixture.events.length;
+ await fixture.step({
+ delivery: {
+ kind: "deliver",
+ auth: bob,
+ payloads: [{ inputResponses: [{ requestId: request.requestId, optionId: "approve" }] }],
+ },
+ });
+ // Ingesting the candidate, running its policy, and parking on sign-in are separate passes.
+ for (let result = await fixture.step(); result.action === "continue";) {
+ result = await fixture.step();
+ }
+ const candidate = fixture.events
+ .slice(signInStart)
+ .find((event) => event.type === "approval.candidate");
+ const required = fixture.events
+ .slice(signInStart)
+ .find((event) => event.type === "authorization.required");
+ expect(candidate?.data).toMatchObject({ responderPrincipalId: "bob" });
+ expect(required?.data).toMatchObject({
+ attemptId: expect.any(String),
+ candidateId: candidate?.data.candidateId,
+ principalId: "bob",
+ });
+
+ const completionStart = fixture.events.length;
+ await fixture.step({
+ delivery: {
+ kind: "deliver",
+ payloads: [
+ {
+ authorizationCallback: {
+ attemptId: required?.data.attemptId,
+ callback: { method: "GET", params: { code: "ok" } },
+ connectionName: required?.data.name,
+ },
+ },
+ ],
+ },
+ });
+ const completed = fixture.events
+ .slice(completionStart)
+ .find((event) => event.type === "authorization.completed");
+ expect(completed?.data).toMatchObject({
+ attemptId: required?.data.attemptId,
+ outcome: "authorized",
+ principalId: "bob",
+ });
+ });
+
it("restores the originating connection for a sign-in callback without a premature turn", async () => {
const fixture = setup();
await fixture.step({
diff --git a/packages/eve/src/execution/session/turn-step.ts b/packages/eve/src/execution/session/turn-step.ts
index 7f3c1c9e3..c41628b53 100644
--- a/packages/eve/src/execution/session/turn-step.ts
+++ b/packages/eve/src/execution/session/turn-step.ts
@@ -65,6 +65,7 @@ import {
createSessionStartedEvent,
createTurnStartedEvent,
} from "#protocol/message.js";
+import { authorizationEventFields } from "#harness/authorization-event-fields.js";
import {
CallbackBaseUrlKey,
clearPendingAuthorization,
@@ -472,7 +473,7 @@ async function runSessionStep(input: TurnStepInput): Promise<DurableStepResult>
if (firstCall && completedAuths) {
let emissionState = getHarnessEmissionState(schemaSession.state);
const startsTurn = completedAuths.some(
- ({ candidateId }) => candidateId === undefined,
+ ({ challenge }) => challenge.candidateId === undefined,
);
if (startsTurn && isHarnessBetweenTurns(schemaSession)) {
const turnInput = createTurnInputMessages(
@@ -517,13 +518,10 @@ async function runSessionStep(input: TurnStepInput): Promise<DurableStepResult>
}
schemaSession = setHarnessEmissionState(schemaSession, emissionState);
}
- for (const { authorization, result, candidateId } of completedAuths) {
+ for (const { challenge } of completedAuths) {
await handleEvent(
createAuthorizationCompletedEvent({
- attemptId: result.attemptId,
- authorization,
- candidateId,
- name: result.name,
+ ...authorizationEventFields(challenge),
outcome: "authorized",
sequence: emissionState.sequence,
stepIndex: emissionState.stepIndex,
diff --git a/packages/eve/src/execution/tool-auth.integration.test.ts b/packages/eve/src/execution/tool-auth.integration.test.ts
index 239d6fa72..ec537e1e8 100644
--- a/packages/eve/src/execution/tool-auth.integration.test.ts
+++ b/packages/eve/src/execution/tool-auth.integration.test.ts
@@ -1,6 +1,9 @@
import { describe, expect, it } from "vitest";
-import { buildApprovalResponseAuth } from "#execution/tool-auth.js";
+import {
+ buildApprovalResponseAuth,
+ handleApprovalResponsePolicyError,
+} from "#execution/tool-auth.js";
import { evictScopedToken, resolveScopedToken } from "#runtime/connections/scoped-authorization.js";
import { loadContext } from "#context/container.js";
import { AuthKey, SessionIdKey } from "#context/keys.js";
@@ -158,6 +161,44 @@ describe("approval response authorization", () => {
type: "user",
});
});
+
+ it("binds a responder's sign-in attempt to the responder instead of ambient auth", async () => {
+ const provider: AuthorizationDefinition = {
+ principalType: "user",
+ async getToken(): Promise<TokenResult> {
+ throw requiredError();
+ },
+ async startAuthorization() {
+ return { challenge: { url: "https://idp.example/auth" } };
+ },
+ async completeAuthorization(): Promise<TokenResult> {
+ return { token: "after-signin" };
+ },
+ };
+ const runtime = await createTestRuntime({ tools: [] });
+
+ const signal = await runtime.runAsSession({ sessionId: "session_responder_auth" }, async () => {
+ seedUserPrincipal();
+ loadContext().set(CallbackBaseUrlKey, "https://app.example");
+ try {
+ await buildApprovalResponseAuth({
+ responder: {
+ attributes: {},
+ authenticator: "test-idp",
+ principalId: "bound-U1",
+ principalType: "user",
+ },
+ scope: "candidate-1",
+ }).getToken(provider);
+ } catch (error) {
+ return await handleApprovalResponsePolicyError(error);
+ }
+ throw new Error("expected authorization to be required");
+ });
+
+ if (!isAuthorizationSignal(signal)) throw new Error("expected signal");
+ expect(signal.challenges[0]?.principalId).toBe("bound-U1");
+ });
});
describe("tool-hosted authorization", () => {
diff --git a/packages/eve/src/execution/tools/workflow/step.ts b/packages/eve/src/execution/tools/workflow/step.ts
index aea6aa756..abac0a8f9 100644
--- a/packages/eve/src/execution/tools/workflow/step.ts
+++ b/packages/eve/src/execution/tools/workflow/step.ts
@@ -1,4 +1,5 @@
import { createHook, getWorkflowMetadata } from "#compiled/@workflow/core/index.js";
+import { authorizationEventFields } from "#harness/authorization-event-fields.js";
import type { AuthorizationChallenge } from "#harness/authorization.js";
import type { AuthorizationCallback } from "#shared/connection-types.js";
import type { ToolContext } from "#tools/definition.js";
@@ -221,13 +222,11 @@ async function reportAuthorization(
outcome?: "authorized" | "failed",
): Promise<void> {
const eventInput = {
- attemptId: challenge.attemptId,
- name: challenge.name,
+ ...authorizationEventFields(challenge),
sequence: run.from.sequence,
stepIndex: run.from.stepIndex,
taskId: run.from.taskId,
turnId: run.from.turnId,
- authorization: challenge.challenge,
};
const event =
outcome === undefined
diff --git a/packages/eve/src/harness/authorization-event-fields.ts b/packages/eve/src/harness/authorization-event-fields.ts
new file mode 100644
index 000000000..7ab2ae588
--- /dev/null
+++ b/packages/eve/src/harness/authorization-event-fields.ts
@@ -0,0 +1,16 @@
+import type { AuthorizationChallenge } from "#harness/authorization.js";
+
+/**
+ * Fields every `authorization.*` event copies from its challenge. Emitters
+ * spread this and add only event-local fields, so a new challenge-derived
+ * field reaches every event at once.
+ */
+export function authorizationEventFields(challenge: AuthorizationChallenge) {
+ return {
+ attemptId: challenge.attemptId,
+ authorization: challenge.challenge,
+ candidateId: challenge.candidateId,
+ name: challenge.name,
+ principalId: challenge.principalId,
+ };
+}
diff --git a/packages/eve/src/harness/authorization.ts b/packages/eve/src/harness/authorization.ts
index 2a6f29c1a..8f0a7bb18 100644
--- a/packages/eve/src/harness/authorization.ts
+++ b/packages/eve/src/harness/authorization.ts
@@ -63,6 +63,8 @@ export interface AuthorizationChallenge {
readonly hookUrl: string;
/** Principal passed to `startAuthorization`; omitted from model-facing copies. */
readonly principal?: ConnectionPrincipal;
+ /** Session principal that started this attempt; projected onto authorization events. */
+ readonly principalId?: string;
/**
* Opaque resume value from the strategy's `startAuthorization`,
* journaled across the park. Absent for provider-owned flows.
diff --git a/packages/eve/src/harness/tool-loop.ts b/packages/eve/src/harness/tool-loop.ts
index 94fdfe0d8..9023acbce 100644
--- a/packages/eve/src/harness/tool-loop.ts
+++ b/packages/eve/src/harness/tool-loop.ts
@@ -161,6 +161,7 @@ import {
validateHarnessModelMessages,
} from "#harness/messages.js";
import { normalizeProviderToolHistory } from "#harness/provider-tool-history.js";
+import { authorizationEventFields } from "#harness/authorization-event-fields.js";
import {
getPendingAuthorization,
getSupersededAuthorizationChallenges,
@@ -739,10 +740,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
continue;
await emit(
createAuthorizationCompletedEvent({
- attemptId: challenge.attemptId,
- authorization: challenge.challenge,
- candidateId: challenge.candidateId,
- name: challenge.name,
+ ...authorizationEventFields(challenge),
outcome: "failed",
reason: "The approval response expired. Please submit a new response.",
sequence: emissionState.sequence,
@@ -832,11 +830,9 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
for (const challenge of coordinated.challenges) {
await emit(
createAuthorizationRequiredEvent({
- authorization: challenge.challenge,
- candidateId: challenge.candidateId,
+ ...authorizationEventFields(challenge),
description:
challenge.challenge.instructions ?? `Authorization required for ${challenge.name}`,
- name: challenge.name,
sequence: emissionState.sequence,
stepIndex: emissionState.stepIndex,
turnId: emissionState.turnId,
@@ -2768,9 +2764,7 @@ async function handleStepResult(input: {
)) {
await emit(
createAuthorizationCompletedEvent({
- attemptId: superseded.attemptId,
- authorization: superseded.challenge,
- name: superseded.name,
+ ...authorizationEventFields(superseded),
outcome: "failed",
reason: "Superseded by a newer authorization attempt.",
sequence: emissionState.sequence,
@@ -2782,9 +2776,7 @@ async function handleStepResult(input: {
for (const ch of challenges) {
await emit(
createAuthorizationRequiredEvent({
- attemptId: ch.attemptId,
- authorization: ch.challenge,
- name: ch.name,
+ ...authorizationEventFields(ch),
description: ch.challenge.instructions ?? `Authorization required for ${ch.name}`,
webhookUrl: ch.hookUrl,
sequence: emissionState.sequence,
diff --git a/packages/eve/src/protocol/message.ts b/packages/eve/src/protocol/message.ts
index b92ed2651..928b70760 100644
--- a/packages/eve/src/protocol/message.ts
+++ b/packages/eve/src/protocol/message.ts
@@ -684,6 +684,11 @@ export interface AuthorizationRequiredStreamEvent {
candidateId?: string;
description: string;
name: string;
+ /**
+ * Session principal that started this sign-in, matching `responderPrincipalId`
+ * on approval events. Channels use it to deliver the challenge privately.
+ */
+ principalId?: string;
sequence: number;
stepIndex: number;
/** The task that needs the sign-in, when it comes from a task's run. */
@@ -726,6 +731,8 @@ export interface AuthorizationCompletedStreamEvent {
authorization?: ConnectionAuthorizationChallenge;
name: string;
outcome: AuthorizationOutcome;
+ /** Session principal that started the matching sign-in. */
+ principalId?: string;
reason?: string;
sequence: number;
stepIndex: number;
@@ -1187,6 +1194,7 @@ export function createAuthorizationRequiredEvent(input: {
readonly candidateId?: string;
readonly description: string;
readonly name: string;
+ readonly principalId?: string;
readonly sequence: number;
readonly stepIndex: number;
readonly taskId?: string;
@@ -1209,6 +1217,9 @@ export function createAuthorizationRequiredEvent(input: {
if (input.candidateId !== undefined) {
data.candidateId = input.candidateId;
}
+ if (input.principalId !== undefined) {
+ data.principalId = input.principalId;
+ }
if (input.webhookUrl !== undefined) {
data.webhookUrl = input.webhookUrl;
}
@@ -1232,6 +1243,7 @@ export function createAuthorizationCompletedEvent(input: {
readonly candidateId?: string;
readonly name: string;
readonly outcome: AuthorizationOutcome;
+ readonly principalId?: string;
readonly reason?: string;
readonly sequence: number;
readonly stepIndex: number;
@@ -1254,6 +1266,9 @@ export function createAuthorizationCompletedEvent(input: {
if (input.candidateId !== undefined) {
data.candidateId = input.candidateId;
}
+ if (input.principalId !== undefined) {
+ data.principalId = input.principalId;
+ }
if (input.reason !== undefined) {
data.reason = input.reason;
}
diff --git a/packages/eve/src/runtime/connections/scoped-authorization.ts b/packages/eve/src/runtime/connections/scoped-authorization.ts
index 0cf0671e9..d541a9162 100644
--- a/packages/eve/src/runtime/connections/scoped-authorization.ts
+++ b/packages/eve/src/runtime/connections/scoped-authorization.ts
@@ -36,7 +36,7 @@ import {
resolveConnectionPrincipal,
resolveConnectionPrincipalFromAuth,
} from "#runtime/connections/principal.js";
-import type { SessionAuthContext } from "#context/keys.js";
+import { AuthKey, type SessionAuthContext } from "#context/keys.js";
import {
type AuthorizationDefinition,
type ConnectionAuthorizationContext,
@@ -325,6 +325,8 @@ async function startScopedAuthorization(
const interactive = authorization as InteractiveAuthorizationDefinition<JsonValue>;
const principal = resolveScopedPrincipal(input);
+ const principalId = (input.boundResponder ?? contextStorage.getStore()?.get(AuthKey))
+ ?.principalId;
const callbackUrl = resolveAuthorizationCallbackUrl({
authorization,
callbackUrl: attempt.hookUrl,
@@ -342,6 +344,7 @@ async function startScopedAuthorization(
instanceId: input.instanceId,
name: scope,
principal,
+ principalId,
resume,
},
]);
diff --git a/packages/eve/src/subagents/callback-route.ts b/packages/eve/src/subagents/callback-route.ts
index d099756bc..648e29012 100644
--- a/packages/eve/src/subagents/callback-route.ts
+++ b/packages/eve/src/subagents/callback-route.ts
@@ -84,6 +84,7 @@ const sessionAuthorizationCallbackSchema = z.object({
webhookUrl: z.string().optional(),
attemptId: z.string().optional(),
taskId: z.string().optional(),
+ principalId: z.string().optional(),
})
.passthrough(),
}),
@@ -98,6 +99,7 @@ const sessionAuthorizationCallbackSchema = z.object({
turnId: z.string(),
attemptId: z.string().optional(),
taskId: z.string().optional(),
+ principalId: z.string().optional(),
})
.passthrough(),
}),