@agent-native/core 0.231.0 → 0.232.0-nightly-20261118182504
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/dist/a2a/call-hooks.d.ts +135 -0
- package/dist/a2a/call-hooks.js +164 -0
- package/dist/a2a/client.d.ts +5 -0
- package/dist/a2a/client.js +22 -0
- package/dist/a2a/foreground-call-scope.d.ts +6 -0
- package/dist/a2a/foreground-call-scope.js +26 -0
- package/dist/a2a/handlers.js +119 -2
- package/dist/a2a/index.d.ts +3 -0
- package/dist/a2a/index.js +2 -0
- package/dist/a2a/invoke.js +17 -0
- package/dist/a2a/server.js +3 -0
- package/dist/action.js +3 -1
- package/dist/agent/durable-background.d.ts +6 -0
- package/dist/agent/durable-background.js +6 -0
- package/dist/agent/durable-turn-grant.d.ts +53 -0
- package/dist/agent/durable-turn-grant.js +83 -0
- package/dist/agent/production-agent.js +54 -2
- package/dist/app-config/agent.d.ts +1 -0
- package/dist/app-config/agent.js +7 -0
- package/dist/app-config/schema.d.ts +1 -0
- package/dist/cli/doctor.d.ts +1 -0
- package/dist/cli/doctor.js +10 -4
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.js +9 -15
- package/dist/client/sharing/useShareButtonController.d.ts +5 -0
- package/dist/client/sharing/useShareButtonController.js +2 -1
- package/dist/client/use-chat-threads.js +3 -0
- package/dist/client/use-db-sync.js +22 -0
- package/dist/collab/routes.d.ts +1 -1
- package/dist/deploy/build.d.ts +4 -1
- package/dist/deploy/build.js +25 -15
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/framework-package-versions.json +7 -7
- package/dist/guards/index.d.ts +1 -1
- package/dist/guards/index.js +1 -1
- package/dist/guards/no-env-credentials.d.ts +15 -1
- package/dist/guards/no-env-credentials.js +27 -0
- package/dist/integrations/internal-token.d.ts +15 -0
- package/dist/integrations/internal-token.js +19 -0
- package/dist/mcp/build-server.js +18 -2
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/turn-grant-admitters.d.ts +61 -0
- package/dist/mcp/turn-grant-admitters.js +83 -0
- package/dist/mcp/turn-grant-store.d.ts +5 -0
- package/dist/mcp/turn-grant-store.js +19 -0
- package/dist/org/index.d.ts +2 -2
- package/dist/org/workspace-app-access.js +30 -11
- package/dist/provider-api/actions/custom-provider-registration.d.ts +16 -16
- package/dist/provider-api/actions/provider-api.d.ts +8 -8
- package/dist/provider-api/call-gates.d.ts +71 -2
- package/dist/provider-api/call-gates.js +157 -3
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/provider-api/index.d.ts +1 -1
- package/dist/provider-api/index.js +1 -1
- package/dist/provider-api/interactive-scope.d.ts +2 -1
- package/dist/provider-api/interactive-scope.js +17 -4
- package/dist/server/agent-chat-plugin.js +9 -2
- package/dist/server/agent-run-context.d.ts +1 -1
- package/dist/server/agent-run-context.js +34 -3
- package/dist/server/entry-server.js +3 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/shared/build-id.d.ts +14 -0
- package/dist/shared/build-id.js +21 -0
- package/dist/vite/client.d.ts +16 -0
- package/dist/vite/client.js +6 -3
- package/dist/vitest-config.js +1 -0
- package/dist/workspace-connections/workspace-credential-actions.d.ts +1 -0
- package/dist/workspace-connections/workspace-credential-actions.js +1 -0
- package/dist/workspace-connections/workspace-credentials.d.ts +4 -0
- package/dist/workspace-connections/workspace-credentials.js +40 -4
- package/docs/content/template-design-agent.mdx +0 -1
- package/docs/content/template-design-developers.mdx +6 -9
- package/docs/workspace-credential-drafts.md +28 -0
- package/package.json +5 -4
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A action call hooks: deployment-owned additions to direct A2A action
|
|
3
|
+
* calls (`actions/invoke`).
|
|
4
|
+
*
|
|
5
|
+
* A hook can attach extra JSON-RPC params to an outgoing call (for example a
|
|
6
|
+
* signed proof that the call comes from a live user turn) and, on the
|
|
7
|
+
* receiving app, refuse an incoming call or admit it as foreground work that
|
|
8
|
+
* runs inside a provider-interactive scope. With no hook registered the client
|
|
9
|
+
* and the handler behave exactly as without this module.
|
|
10
|
+
*/
|
|
11
|
+
/** The peer an outgoing call was resolved to, when it came through agent discovery. */
|
|
12
|
+
export interface A2AActionCallTarget {
|
|
13
|
+
kind: "discovered" | "url";
|
|
14
|
+
id?: string;
|
|
15
|
+
url: string;
|
|
16
|
+
/** Where discovery found the agent, e.g. "workspace". */
|
|
17
|
+
source?: string;
|
|
18
|
+
}
|
|
19
|
+
/** One outgoing `actions/invoke` call, as a hook sees it before it is sent. */
|
|
20
|
+
export interface A2AOutgoingActionCall {
|
|
21
|
+
/** The URL the caller passed. */
|
|
22
|
+
url: string;
|
|
23
|
+
/** The normalized audience of the endpoint the call is sent to. */
|
|
24
|
+
audience: string;
|
|
25
|
+
action: string;
|
|
26
|
+
input: Record<string, unknown>;
|
|
27
|
+
/** The user the caller asked to sign the call as, when it named one. */
|
|
28
|
+
userEmail?: string;
|
|
29
|
+
orgId?: string;
|
|
30
|
+
target?: A2AActionCallTarget;
|
|
31
|
+
}
|
|
32
|
+
export interface A2AOutgoingActionCallAdditions {
|
|
33
|
+
/**
|
|
34
|
+
* Extra JSON-RPC params sent with the call. They may not reuse a key the
|
|
35
|
+
* call already sends (`action`, `input`, `metadata`) or one another hook
|
|
36
|
+
* added.
|
|
37
|
+
*/
|
|
38
|
+
params?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/** The verified caller of an incoming call. */
|
|
41
|
+
export interface A2AIncomingActionCaller {
|
|
42
|
+
email: string;
|
|
43
|
+
/** "user", "organization" or "org-member", when the token said which. */
|
|
44
|
+
identityAssurance?: string;
|
|
45
|
+
/** The organization the caller's token was verified against. */
|
|
46
|
+
orgId?: string;
|
|
47
|
+
/** The audiences the caller's token was verified for. */
|
|
48
|
+
audiences: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
/** One incoming `actions/invoke` call, after its identity is verified. */
|
|
51
|
+
export interface A2AIncomingActionCall {
|
|
52
|
+
action: string;
|
|
53
|
+
input: Record<string, unknown>;
|
|
54
|
+
/** The call's JSON-RPC params as received, including any a peer hook added. */
|
|
55
|
+
params: Readonly<Record<string, unknown>>;
|
|
56
|
+
caller: A2AIncomingActionCaller;
|
|
57
|
+
/** Whether the verified caller is a member of `orgId`. */
|
|
58
|
+
isOrgMember(orgId: string): Promise<boolean>;
|
|
59
|
+
}
|
|
60
|
+
export type A2AIncomingActionCallDecision = {
|
|
61
|
+
status: "refused";
|
|
62
|
+
message: string;
|
|
63
|
+
reason?: string;
|
|
64
|
+
} | {
|
|
65
|
+
status: "admitted";
|
|
66
|
+
/** Run the action as foreground work for the caller until `expiresAt`. */
|
|
67
|
+
foreground?: {
|
|
68
|
+
expiresAt: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Run the action in this organization instead of the caller's personal
|
|
72
|
+
* scope. It must match the verified organization when the token carried
|
|
73
|
+
* one; otherwise the caller must be a member of it.
|
|
74
|
+
*/
|
|
75
|
+
orgId?: string;
|
|
76
|
+
};
|
|
77
|
+
export interface A2AActionCallHook {
|
|
78
|
+
/** Stable id; registering a different hook under the same id throws. */
|
|
79
|
+
id: string;
|
|
80
|
+
outgoing?(call: A2AOutgoingActionCall): A2AOutgoingActionCallAdditions | undefined | Promise<A2AOutgoingActionCallAdditions | undefined>;
|
|
81
|
+
/** Return undefined to leave the call as it is. */
|
|
82
|
+
incoming?(call: A2AIncomingActionCall): A2AIncomingActionCallDecision | undefined | Promise<A2AIncomingActionCallDecision | undefined>;
|
|
83
|
+
}
|
|
84
|
+
/** JSON-RPC `error.data.kind` of a call a hook refused. */
|
|
85
|
+
export declare const A2A_CALL_REFUSED_KIND = "agent-native/a2a-call-refused";
|
|
86
|
+
/** A peer refused an A2A action call through one of its call hooks. */
|
|
87
|
+
export declare class A2ACallRefusedError extends Error {
|
|
88
|
+
readonly code: number;
|
|
89
|
+
readonly hookId: string | undefined;
|
|
90
|
+
readonly reason: string | undefined;
|
|
91
|
+
constructor(message: string, options: {
|
|
92
|
+
code: number;
|
|
93
|
+
hookId?: string;
|
|
94
|
+
reason?: string;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/** A call hook threw, or returned something the call cannot carry. */
|
|
98
|
+
/** How long one deployment hook may hold an A2A action call. */
|
|
99
|
+
export declare const A2A_CALL_HOOK_TIMEOUT_MS = 5000;
|
|
100
|
+
export declare class A2ACallHookError extends Error {
|
|
101
|
+
readonly hookId: string;
|
|
102
|
+
constructor(hookId: string, message: string, options?: {
|
|
103
|
+
cause?: unknown;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Register an A2A action call hook. Every registered hook runs, in
|
|
108
|
+
* registration order. Registering the same hook object again is a no-op.
|
|
109
|
+
* Returns a function that removes it.
|
|
110
|
+
*/
|
|
111
|
+
export declare function registerA2AActionCallHook(hook: A2AActionCallHook): () => void;
|
|
112
|
+
export declare function listA2AActionCallHooks(): readonly A2AActionCallHook[];
|
|
113
|
+
export declare function hasA2AActionCallHooks(): boolean;
|
|
114
|
+
export declare function clearA2AActionCallHooksForTests(): void;
|
|
115
|
+
/** Collect the extra params every hook adds to an outgoing call. */
|
|
116
|
+
export declare function collectOutgoingA2AActionCallParams(call: A2AOutgoingActionCall): Promise<Record<string, unknown>>;
|
|
117
|
+
export type A2AIncomingActionCallOutcome = {
|
|
118
|
+
status: "refused";
|
|
119
|
+
hookId: string;
|
|
120
|
+
message: string;
|
|
121
|
+
reason?: string;
|
|
122
|
+
} | {
|
|
123
|
+
status: "admitted";
|
|
124
|
+
foreground?: {
|
|
125
|
+
expiresAt: number;
|
|
126
|
+
};
|
|
127
|
+
orgId?: string;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Ask every hook about an incoming call. The first refusal wins. Admissions
|
|
131
|
+
* combine: the earliest foreground expiry, and one organization at most.
|
|
132
|
+
* Undefined when no hook had an opinion. A hook that throws throws
|
|
133
|
+
* {@link A2ACallHookError}.
|
|
134
|
+
*/
|
|
135
|
+
export declare function decideIncomingA2AActionCall(call: A2AIncomingActionCall): Promise<A2AIncomingActionCallOutcome | undefined>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A action call hooks: deployment-owned additions to direct A2A action
|
|
3
|
+
* calls (`actions/invoke`).
|
|
4
|
+
*
|
|
5
|
+
* A hook can attach extra JSON-RPC params to an outgoing call (for example a
|
|
6
|
+
* signed proof that the call comes from a live user turn) and, on the
|
|
7
|
+
* receiving app, refuse an incoming call or admit it as foreground work that
|
|
8
|
+
* runs inside a provider-interactive scope. With no hook registered the client
|
|
9
|
+
* and the handler behave exactly as without this module.
|
|
10
|
+
*/
|
|
11
|
+
/** JSON-RPC `error.data.kind` of a call a hook refused. */
|
|
12
|
+
export const A2A_CALL_REFUSED_KIND = "agent-native/a2a-call-refused";
|
|
13
|
+
/** A peer refused an A2A action call through one of its call hooks. */
|
|
14
|
+
export class A2ACallRefusedError extends Error {
|
|
15
|
+
code;
|
|
16
|
+
hookId;
|
|
17
|
+
reason;
|
|
18
|
+
constructor(message, options) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "A2ACallRefusedError";
|
|
21
|
+
this.code = options.code;
|
|
22
|
+
this.hookId = options.hookId;
|
|
23
|
+
this.reason = options.reason;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** A call hook threw, or returned something the call cannot carry. */
|
|
27
|
+
/** How long one deployment hook may hold an A2A action call. */
|
|
28
|
+
export const A2A_CALL_HOOK_TIMEOUT_MS = 5_000;
|
|
29
|
+
async function runHookBounded(hookId, direction, run) {
|
|
30
|
+
let timer;
|
|
31
|
+
try {
|
|
32
|
+
return await Promise.race([
|
|
33
|
+
Promise.resolve().then(run),
|
|
34
|
+
new Promise((_, reject) => {
|
|
35
|
+
timer = setTimeout(() => reject(new A2ACallHookError(hookId, `${direction} hook did not answer within ${A2A_CALL_HOOK_TIMEOUT_MS} ms`)), A2A_CALL_HOOK_TIMEOUT_MS);
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
catch (cause) {
|
|
40
|
+
if (cause instanceof A2ACallHookError && cause.hookId === hookId)
|
|
41
|
+
throw cause;
|
|
42
|
+
throw new A2ACallHookError(hookId, `${direction} hook failed`, { cause });
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
clearTimeout(timer);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class A2ACallHookError extends Error {
|
|
49
|
+
hookId;
|
|
50
|
+
constructor(hookId, message, options) {
|
|
51
|
+
super(`A2A call hook "${hookId}": ${message}`, options);
|
|
52
|
+
this.name = "A2ACallHookError";
|
|
53
|
+
this.hookId = hookId;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const globals = globalThis;
|
|
57
|
+
const registry = (globals.__agentNativeA2AActionCallHooks ??= { hooks: [] });
|
|
58
|
+
/**
|
|
59
|
+
* Register an A2A action call hook. Every registered hook runs, in
|
|
60
|
+
* registration order. Registering the same hook object again is a no-op.
|
|
61
|
+
* Returns a function that removes it.
|
|
62
|
+
*/
|
|
63
|
+
export function registerA2AActionCallHook(hook) {
|
|
64
|
+
if (!hook.id)
|
|
65
|
+
throw new Error("An A2A action call hook needs an id.");
|
|
66
|
+
const existing = registry.hooks.find((entry) => entry.id === hook.id);
|
|
67
|
+
if (existing && existing !== hook) {
|
|
68
|
+
throw new Error(`A2A action call hook "${hook.id}" is already registered by another module.`);
|
|
69
|
+
}
|
|
70
|
+
if (!existing)
|
|
71
|
+
registry.hooks.push(hook);
|
|
72
|
+
return () => {
|
|
73
|
+
const index = registry.hooks.indexOf(hook);
|
|
74
|
+
if (index >= 0)
|
|
75
|
+
registry.hooks.splice(index, 1);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function listA2AActionCallHooks() {
|
|
79
|
+
return [...registry.hooks];
|
|
80
|
+
}
|
|
81
|
+
export function hasA2AActionCallHooks() {
|
|
82
|
+
return registry.hooks.length > 0;
|
|
83
|
+
}
|
|
84
|
+
export function clearA2AActionCallHooksForTests() {
|
|
85
|
+
registry.hooks.length = 0;
|
|
86
|
+
}
|
|
87
|
+
const RESERVED_OUTGOING_PARAMS = new Set(["action", "input", "metadata"]);
|
|
88
|
+
/** Collect the extra params every hook adds to an outgoing call. */
|
|
89
|
+
export async function collectOutgoingA2AActionCallParams(call) {
|
|
90
|
+
const params = {};
|
|
91
|
+
for (const hook of listA2AActionCallHooks()) {
|
|
92
|
+
if (!hook.outgoing)
|
|
93
|
+
continue;
|
|
94
|
+
let additions;
|
|
95
|
+
const outgoing = hook.outgoing;
|
|
96
|
+
additions = await runHookBounded(hook.id, "outgoing", () => outgoing(call));
|
|
97
|
+
for (const [key, value] of Object.entries(additions?.params ?? {})) {
|
|
98
|
+
if (value === undefined)
|
|
99
|
+
continue;
|
|
100
|
+
if (RESERVED_OUTGOING_PARAMS.has(key) || Object.hasOwn(params, key)) {
|
|
101
|
+
throw new A2ACallHookError(hook.id, `param "${key}" is already set`);
|
|
102
|
+
}
|
|
103
|
+
params[key] = value;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return params;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Ask every hook about an incoming call. The first refusal wins. Admissions
|
|
110
|
+
* combine: the earliest foreground expiry, and one organization at most.
|
|
111
|
+
* Undefined when no hook had an opinion. A hook that throws throws
|
|
112
|
+
* {@link A2ACallHookError}.
|
|
113
|
+
*/
|
|
114
|
+
export async function decideIncomingA2AActionCall(call) {
|
|
115
|
+
let admitted = { status: "admitted" };
|
|
116
|
+
let decided = false;
|
|
117
|
+
for (const hook of listA2AActionCallHooks()) {
|
|
118
|
+
if (!hook.incoming)
|
|
119
|
+
continue;
|
|
120
|
+
let decision;
|
|
121
|
+
const incoming = hook.incoming;
|
|
122
|
+
decision = await runHookBounded(hook.id, "incoming", () => incoming(call));
|
|
123
|
+
if (decision === undefined)
|
|
124
|
+
continue;
|
|
125
|
+
decided = true;
|
|
126
|
+
if (decision.status === "refused") {
|
|
127
|
+
return {
|
|
128
|
+
status: "refused",
|
|
129
|
+
hookId: hook.id,
|
|
130
|
+
message: decision.message,
|
|
131
|
+
...(decision.reason ? { reason: decision.reason } : {}),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// Hooks are deployment code that may not be type-checked against this union.
|
|
135
|
+
const status = decision.status;
|
|
136
|
+
if (status !== "admitted") {
|
|
137
|
+
throw new A2ACallHookError(hook.id, "returned an unknown decision");
|
|
138
|
+
}
|
|
139
|
+
if (decision.foreground) {
|
|
140
|
+
const { expiresAt } = decision.foreground;
|
|
141
|
+
if (!Number.isSafeInteger(expiresAt)) {
|
|
142
|
+
throw new A2ACallHookError(hook.id, "foreground expiry is invalid");
|
|
143
|
+
}
|
|
144
|
+
admitted = {
|
|
145
|
+
...admitted,
|
|
146
|
+
foreground: {
|
|
147
|
+
expiresAt: Math.min(admitted.foreground?.expiresAt ?? expiresAt, expiresAt),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (decision.orgId !== undefined) {
|
|
152
|
+
if (admitted.orgId !== undefined && admitted.orgId !== decision.orgId) {
|
|
153
|
+
return {
|
|
154
|
+
status: "refused",
|
|
155
|
+
hookId: hook.id,
|
|
156
|
+
message: "A2A call hooks named different organizations",
|
|
157
|
+
reason: "org-conflict",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
admitted = { ...admitted, orgId: decision.orgId };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return decided ? admitted : undefined;
|
|
164
|
+
}
|
package/dist/a2a/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type A2AActionCallTarget } from "./call-hooks.js";
|
|
1
2
|
import type { A2ACorrelationMetadata, A2ASourceContextReference, A2AReadOnlyActionResult, AgentCard, A2AProtocolVersion, FilePart, Message, Task } from "./types.js";
|
|
2
3
|
export declare const MAX_A2A_CALLER_RESPONSE_CHARS = 32768;
|
|
3
4
|
export declare function clearA2ACardCache(): void;
|
|
@@ -115,6 +116,8 @@ export declare class A2AClient {
|
|
|
115
116
|
}): Promise<Task>;
|
|
116
117
|
invokeAction(action: string, input?: Record<string, unknown>, opts?: {
|
|
117
118
|
metadata?: A2ACorrelationMetadata;
|
|
119
|
+
/** Extra JSON-RPC params, e.g. from an A2A action call hook. */
|
|
120
|
+
params?: Record<string, unknown>;
|
|
118
121
|
}): Promise<A2AReadOnlyActionResult>;
|
|
119
122
|
sendAndWait(message: Message, opts?: {
|
|
120
123
|
contextId?: string;
|
|
@@ -185,4 +188,6 @@ export declare function callAction(url: string, action: string, input?: Record<s
|
|
|
185
188
|
agentCardUrl?: string;
|
|
186
189
|
protocolVersion?: A2AProtocolVersion;
|
|
187
190
|
a2aVersion?: A2AProtocolVersion;
|
|
191
|
+
/** The discovered peer, passed to A2A action call hooks. */
|
|
192
|
+
invocationTarget?: A2AActionCallTarget;
|
|
188
193
|
}): Promise<A2AReadOnlyActionResult>;
|
package/dist/a2a/client.js
CHANGED
|
@@ -7,6 +7,7 @@ import { resolveVercelDeploymentProtectionHeaders } from "../server/deployment-p
|
|
|
7
7
|
import { getRequestContext } from "../server/request-context.js";
|
|
8
8
|
import { SYNTHETIC_TRAFFIC_BETA_E2E, SYNTHETIC_TRAFFIC_HEADER, } from "../shared/test-traffic.js";
|
|
9
9
|
import { canonicalA2AAudience } from "./audience.js";
|
|
10
|
+
import { A2A_CALL_REFUSED_KIND, A2ACallRefusedError, collectOutgoingA2AActionCallParams, hasA2AActionCallHooks, } from "./call-hooks.js";
|
|
10
11
|
import { sanitizeA2ACorrelationMetadata } from "./correlation.js";
|
|
11
12
|
import { A2A_ORG_MEMBER_DELEGATION_TYPE } from "./organization-identity.js";
|
|
12
13
|
import { RemoteAgentCredentialRejectedError } from "./remote-agent-auth.js";
|
|
@@ -485,11 +486,20 @@ export class A2AClient {
|
|
|
485
486
|
async invokeAction(action, input = {}, opts) {
|
|
486
487
|
const metadata = sanitizeA2ACorrelationMetadata(opts?.metadata);
|
|
487
488
|
const response = await this.rpc("actions/invoke", {
|
|
489
|
+
...opts?.params,
|
|
488
490
|
action,
|
|
489
491
|
input,
|
|
490
492
|
...(Object.keys(metadata).length > 0 ? { metadata } : {}),
|
|
491
493
|
});
|
|
492
494
|
if (response.error) {
|
|
495
|
+
const data = response.error.data;
|
|
496
|
+
if (data?.kind === A2A_CALL_REFUSED_KIND) {
|
|
497
|
+
throw new A2ACallRefusedError(`A2A error (${response.error.code}): ${response.error.message}`, {
|
|
498
|
+
code: response.error.code,
|
|
499
|
+
...(typeof data.hookId === "string" ? { hookId: data.hookId } : {}),
|
|
500
|
+
...(typeof data.reason === "string" ? { reason: data.reason } : {}),
|
|
501
|
+
});
|
|
502
|
+
}
|
|
493
503
|
throw new Error(`A2A error (${response.error.code}): ${response.error.message}`);
|
|
494
504
|
}
|
|
495
505
|
return response.result;
|
|
@@ -1535,8 +1545,20 @@ export async function callAction(url, action, input = {}, opts) {
|
|
|
1535
1545
|
.slice(1)
|
|
1536
1546
|
.filter((token) => token !== undefined));
|
|
1537
1547
|
}
|
|
1548
|
+
const hookParams = hasA2AActionCallHooks()
|
|
1549
|
+
? await collectOutgoingA2AActionCallParams({
|
|
1550
|
+
url,
|
|
1551
|
+
audience: invocationAudience,
|
|
1552
|
+
action: actionName,
|
|
1553
|
+
input,
|
|
1554
|
+
...(opts?.userEmail !== undefined ? { userEmail: opts.userEmail } : {}),
|
|
1555
|
+
...(opts?.orgId !== undefined ? { orgId: opts.orgId } : {}),
|
|
1556
|
+
...(opts?.invocationTarget ? { target: opts.invocationTarget } : {}),
|
|
1557
|
+
})
|
|
1558
|
+
: {};
|
|
1538
1559
|
return client.invokeAction(actionName, input, {
|
|
1539
1560
|
metadata: sanitizeA2ACorrelationMetadata(opts?.correlation),
|
|
1561
|
+
...(Object.keys(hookParams).length > 0 ? { params: hookParams } : {}),
|
|
1540
1562
|
});
|
|
1541
1563
|
}
|
|
1542
1564
|
async function buildA2AApiKeyAttempts(opts, audience) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True inside an incoming A2A action call that a call hook admitted as
|
|
3
|
+
* foreground work, until the call settles or its admission expires.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isA2AForegroundCall(): boolean;
|
|
6
|
+
export declare function runAsA2AForegroundCall<T>(expiresAt: number, work: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getAsyncLocalStorageCtor } from "../shared/optional-node-builtins.js";
|
|
2
|
+
const ScopeStorage = getAsyncLocalStorageCtor();
|
|
3
|
+
const foregroundCall = ScopeStorage
|
|
4
|
+
? new ScopeStorage()
|
|
5
|
+
: undefined;
|
|
6
|
+
/**
|
|
7
|
+
* True inside an incoming A2A action call that a call hook admitted as
|
|
8
|
+
* foreground work, until the call settles or its admission expires.
|
|
9
|
+
*/
|
|
10
|
+
export function isA2AForegroundCall() {
|
|
11
|
+
const call = foregroundCall?.getStore();
|
|
12
|
+
return call !== undefined && call.active && Date.now() < call.expiresAt;
|
|
13
|
+
}
|
|
14
|
+
export async function runAsA2AForegroundCall(expiresAt, work) {
|
|
15
|
+
if (!foregroundCall)
|
|
16
|
+
return work();
|
|
17
|
+
const call = { active: true, expiresAt };
|
|
18
|
+
return foregroundCall.run(call, async () => {
|
|
19
|
+
try {
|
|
20
|
+
return await work();
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
call.active = false;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
package/dist/a2a/handlers.js
CHANGED
|
@@ -18,8 +18,10 @@ import { fireInternalDispatch } from "../server/self-dispatch.js";
|
|
|
18
18
|
import { agentChat } from "../shared/agent-chat.js";
|
|
19
19
|
import { track } from "../tracking/registry.js";
|
|
20
20
|
import { hasConfiguredA2ASecret, isA2AProductionRuntime, } from "./auth-policy.js";
|
|
21
|
+
import { A2A_CALL_REFUSED_KIND, decideIncomingA2AActionCall, hasA2AActionCallHooks, } from "./call-hooks.js";
|
|
21
22
|
import { callAction } from "./client.js";
|
|
22
23
|
import { sanitizeA2ACorrelationMetadata } from "./correlation.js";
|
|
24
|
+
import { runAsA2AForegroundCall } from "./foreground-call-scope.js";
|
|
23
25
|
import { assertA2APersistablePayload } from "./persistence-safety.js";
|
|
24
26
|
import { createTask, createOrReuseTask, cancelA2ATask, getTask, getTaskOwnership, updateTask, claimA2ATaskForProcessing, a2aTaskLeaseThreadId, getA2ATaskDispatchState, failStuckA2ATask, failStuckQueuedA2ATask, settleProcessingA2ATask, resetStuckA2ATaskForRetry, touchQueuedA2ATaskDispatch, touchProcessingA2ATask, pauseProcessingA2ATask, MAX_A2A_IDEMPOTENCY_KEY_CHARS, A2A_TASK_CLAIM_LOST_ERROR_CODE, A2ATaskCanceledError, A2A_PERSONAL_OWNER_SCOPE, A2A_ORG_ID_OWNER_SCOPE_PREFIX, } from "./task-store.js";
|
|
25
27
|
const A2A_PROCESS_TASK_PATH = "/_agent-native/a2a/_process-task";
|
|
@@ -1291,12 +1293,22 @@ async function handleInvokeReadOnlyAction(params, event, config) {
|
|
|
1291
1293
|
: {}),
|
|
1292
1294
|
}, { userId: verifiedEmail });
|
|
1293
1295
|
};
|
|
1296
|
+
let foreground;
|
|
1297
|
+
if (hasA2AActionCallHooks()) {
|
|
1298
|
+
const admission = await admitIncomingA2AActionCall(params, action, input, verifiedEmail, event);
|
|
1299
|
+
if ("error" in admission)
|
|
1300
|
+
return admission.error;
|
|
1301
|
+
foreground = admission.foreground;
|
|
1302
|
+
}
|
|
1294
1303
|
try {
|
|
1295
|
-
const
|
|
1304
|
+
const execute = () => config.executeReadOnlyAction({
|
|
1296
1305
|
action,
|
|
1297
1306
|
input: input,
|
|
1298
1307
|
invocationId,
|
|
1299
|
-
})
|
|
1308
|
+
});
|
|
1309
|
+
const result = await withA2ARequestContext(undefined, event, () => foreground
|
|
1310
|
+
? runForegroundA2AActionCall(foreground.expiresAt, event, execute)
|
|
1311
|
+
: execute());
|
|
1300
1312
|
emitTracking(result.status);
|
|
1301
1313
|
return jsonRpcResult(0, { action, ...result });
|
|
1302
1314
|
}
|
|
@@ -1306,6 +1318,111 @@ async function handleInvokeReadOnlyAction(params, event, config) {
|
|
|
1306
1318
|
return jsonRpcError(0, -32000, "Direct action invocation failed");
|
|
1307
1319
|
}
|
|
1308
1320
|
}
|
|
1321
|
+
function refusedA2AActionCall(message, reason, hookId) {
|
|
1322
|
+
return {
|
|
1323
|
+
jsonrpc: "2.0",
|
|
1324
|
+
id: 0,
|
|
1325
|
+
error: {
|
|
1326
|
+
code: -32001,
|
|
1327
|
+
message,
|
|
1328
|
+
data: {
|
|
1329
|
+
kind: A2A_CALL_REFUSED_KIND,
|
|
1330
|
+
...(hookId ? { hookId } : {}),
|
|
1331
|
+
...(reason ? { reason } : {}),
|
|
1332
|
+
},
|
|
1333
|
+
},
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Ask the deployment's call hooks about a verified direct action call. An
|
|
1338
|
+
* admitted organization is bound only when the caller's token carried it or
|
|
1339
|
+
* the caller is a member of it.
|
|
1340
|
+
*/
|
|
1341
|
+
async function admitIncomingA2AActionCall(params, action, input, verifiedEmail, event) {
|
|
1342
|
+
const verifiedOrgId = typeof event.context.__a2aVerifiedOrgId === "string"
|
|
1343
|
+
? event.context.__a2aVerifiedOrgId
|
|
1344
|
+
: undefined;
|
|
1345
|
+
const identityAssurance = event.context.__a2aIdentityAssurance;
|
|
1346
|
+
const audiences = event.context.__a2aVerifiedAudiences;
|
|
1347
|
+
const isOrgMember = async (orgId) => {
|
|
1348
|
+
const { isOrgMemberForA2A } = await import("../org/membership.js");
|
|
1349
|
+
return isOrgMemberForA2A(orgId, verifiedEmail, event);
|
|
1350
|
+
};
|
|
1351
|
+
let outcome;
|
|
1352
|
+
try {
|
|
1353
|
+
outcome = await decideIncomingA2AActionCall({
|
|
1354
|
+
action,
|
|
1355
|
+
input,
|
|
1356
|
+
params: Object.freeze({ ...params }),
|
|
1357
|
+
caller: {
|
|
1358
|
+
email: verifiedEmail,
|
|
1359
|
+
...(typeof identityAssurance === "string" ? { identityAssurance } : {}),
|
|
1360
|
+
...(verifiedOrgId ? { orgId: verifiedOrgId } : {}),
|
|
1361
|
+
audiences: Array.isArray(audiences)
|
|
1362
|
+
? audiences.filter((value) => typeof value === "string")
|
|
1363
|
+
: [],
|
|
1364
|
+
},
|
|
1365
|
+
isOrgMember,
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
catch (error) {
|
|
1369
|
+
console.error(`[a2a] Call hook failed for direct action ${action}:`, error);
|
|
1370
|
+
return { error: jsonRpcError(0, -32000, "A2A call hook failed") };
|
|
1371
|
+
}
|
|
1372
|
+
if (outcome === undefined)
|
|
1373
|
+
return { foreground: undefined };
|
|
1374
|
+
if (outcome.status === "refused") {
|
|
1375
|
+
return {
|
|
1376
|
+
error: refusedA2AActionCall(outcome.message, outcome.reason, outcome.hookId),
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
if (outcome.orgId !== undefined && outcome.orgId !== verifiedOrgId) {
|
|
1380
|
+
if (verifiedOrgId) {
|
|
1381
|
+
return {
|
|
1382
|
+
error: refusedA2AActionCall("A2A call organization does not match the verified organization", "org-mismatch"),
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
let member;
|
|
1386
|
+
try {
|
|
1387
|
+
member = await isOrgMember(outcome.orgId);
|
|
1388
|
+
}
|
|
1389
|
+
catch (error) {
|
|
1390
|
+
console.error("[a2a] Organization membership check failed:", error);
|
|
1391
|
+
return {
|
|
1392
|
+
error: jsonRpcError(0, -32003, "Organization membership check is temporarily unavailable"),
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
if (!member) {
|
|
1396
|
+
return {
|
|
1397
|
+
error: refusedA2AActionCall("A2A caller is not a member of the requested organization", "org-not-member"),
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
event.context.__a2aVerifiedOrgId = outcome.orgId;
|
|
1401
|
+
}
|
|
1402
|
+
if (outcome.foreground && outcome.foreground.expiresAt <= Date.now()) {
|
|
1403
|
+
return {
|
|
1404
|
+
error: refusedA2AActionCall("A2A foreground admission has expired", "foreground-expired"),
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
// A timer cannot run longer than this; a longer window would abort at once.
|
|
1408
|
+
if (outcome.foreground &&
|
|
1409
|
+
outcome.foreground.expiresAt - Date.now() > MAX_TIMER_DELAY_MS) {
|
|
1410
|
+
return {
|
|
1411
|
+
error: refusedA2AActionCall("A2A foreground admission is longer than the server can hold", "foreground-too-long"),
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
return { foreground: outcome.foreground };
|
|
1415
|
+
}
|
|
1416
|
+
const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
|
|
1417
|
+
/** Run an admitted call as foreground work, revoked at expiry or when the request aborts. */
|
|
1418
|
+
function runForegroundA2AActionCall(expiresAt, event, work) {
|
|
1419
|
+
const expiry = AbortSignal.timeout(Math.max(0, expiresAt - Date.now()));
|
|
1420
|
+
const requestSignal = event.req.signal;
|
|
1421
|
+
const signal = requestSignal instanceof AbortSignal
|
|
1422
|
+
? AbortSignal.any([requestSignal, expiry])
|
|
1423
|
+
: expiry;
|
|
1424
|
+
return runAsA2AForegroundCall(expiresAt, () => runWithProviderInteractiveScope(true, work, { signal }));
|
|
1425
|
+
}
|
|
1309
1426
|
export async function handleJsonRpcH3(body, event, config) {
|
|
1310
1427
|
if (!body || body.jsonrpc !== "2.0" || !body.method) {
|
|
1311
1428
|
setResponseStatus(event, 400);
|
package/dist/a2a/index.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export { A2A_AGENT_ACTIVITY_KIND, A2A_AGENT_ACTIVITY_VERSION, MAX_A2A_ACTIVITY_R
|
|
|
5
5
|
export { A2AClient, A2AJsonRpcResponseError, A2AMissingJsonRpcResponseError, A2ANoJsonRpcInterfaceError, A2AProtocolError, assertCredentialedA2AUrl, callAction, callAgent, clearA2ACardCache, getGlobalA2ASecret, signA2AOrgMemberDelegationToken, signA2AOrganizationToken, signA2AToken, } from "./client.js";
|
|
6
6
|
export type { A2AProtocolErrorCode } from "./client.js";
|
|
7
7
|
export { workspacePrivateOrigins } from "./workspace-private-origins.js";
|
|
8
|
+
export { A2A_CALL_REFUSED_KIND, A2ACallHookError, A2ACallRefusedError, listA2AActionCallHooks, registerA2AActionCallHook, } from "./call-hooks.js";
|
|
9
|
+
export type { A2AActionCallHook, A2AActionCallTarget, A2AIncomingActionCall, A2AIncomingActionCallDecision, A2AIncomingActionCaller, A2AOutgoingActionCall, A2AOutgoingActionCallAdditions, } from "./call-hooks.js";
|
|
10
|
+
export { isA2AForegroundCall } from "./foreground-call-scope.js";
|
|
8
11
|
export { clearRemoteAgentTokenCache, RemoteAgentAuthError, RemoteAgentCredentialRejectedError, resolveRemoteAgentToken, } from "./remote-agent-auth.js";
|
|
9
12
|
export type { RemoteAgentAuthErrorCode, RemoteAgentCredentialContext, } from "./remote-agent-auth.js";
|
|
10
13
|
export { canonicalA2AAudience } from "./audience.js";
|
package/dist/a2a/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export { generateAgentCard } from "./agent-card.js";
|
|
|
3
3
|
export { A2A_AGENT_ACTIVITY_KIND, A2A_AGENT_ACTIVITY_VERSION, MAX_A2A_ACTIVITY_REASONING_CHARS, MAX_A2A_ACTIVITY_REASONING_SEGMENTS, MAX_A2A_ACTIVITY_RESPONSE_CHARS, MAX_A2A_ACTIVITY_TOOL_CALLS, MAX_A2A_ACTIVITY_TOTAL_CHARS, MAX_A2A_ACTIVITY_TOOL_ID_CHARS, MAX_A2A_ACTIVITY_TOOL_INPUT_CHARS, MAX_A2A_ACTIVITY_TOOL_NAME_CHARS, MAX_A2A_ACTIVITY_TOOL_PAYLOAD_CHARS, MAX_A2A_ACTIVITY_TOOL_RESULT_CHARS, applyA2AAgentActivityEvent, buildA2AAgentActivityPart, buildA2AAgentActivitySnapshot, createA2AAgentActivityState, parseA2AAgentActivityPart, } from "./activity.js";
|
|
4
4
|
export { A2AClient, A2AJsonRpcResponseError, A2AMissingJsonRpcResponseError, A2ANoJsonRpcInterfaceError, A2AProtocolError, assertCredentialedA2AUrl, callAction, callAgent, clearA2ACardCache, getGlobalA2ASecret, signA2AOrgMemberDelegationToken, signA2AOrganizationToken, signA2AToken, } from "./client.js";
|
|
5
5
|
export { workspacePrivateOrigins } from "./workspace-private-origins.js";
|
|
6
|
+
export { A2A_CALL_REFUSED_KIND, A2ACallHookError, A2ACallRefusedError, listA2AActionCallHooks, registerA2AActionCallHook, } from "./call-hooks.js";
|
|
7
|
+
export { isA2AForegroundCall } from "./foreground-call-scope.js";
|
|
6
8
|
export { clearRemoteAgentTokenCache, RemoteAgentAuthError, RemoteAgentCredentialRejectedError, resolveRemoteAgentToken, } from "./remote-agent-auth.js";
|
|
7
9
|
export { canonicalA2AAudience } from "./audience.js";
|
|
8
10
|
export { A2APersistencePayloadError } from "./persistence-safety.js";
|
package/dist/a2a/invoke.js
CHANGED
|
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { discoverAgents as defaultDiscoverAgents, findAgent as defaultFindAgent, } from "../server/agent-discovery.js";
|
|
3
3
|
import { getRequestContext, getRequestOrgId, getRequestUserEmail, runWithRequestContext, } from "../server/request-context.js";
|
|
4
4
|
import { ANTHROPIC_MANAGED_AGENTS_METADATA_KEY, createAnthropicManagedAgentsHandler, } from "./anthropic-managed-agents.js";
|
|
5
|
+
import { hasA2AActionCallHooks, } from "./call-hooks.js";
|
|
5
6
|
import { callAction as defaultCallAction, callAgent as defaultCallAgent, } from "./client.js";
|
|
6
7
|
import { resolveRemoteAgentToken } from "./remote-agent-auth.js";
|
|
7
8
|
export class AgentInvocationError extends Error {
|
|
@@ -18,6 +19,7 @@ export class AgentInvocationError extends Error {
|
|
|
18
19
|
}
|
|
19
20
|
const invocationAuthByTarget = new WeakMap();
|
|
20
21
|
const invocationProviderKindByTarget = new WeakMap();
|
|
22
|
+
const invocationSourceByTarget = new WeakMap();
|
|
21
23
|
export async function resolveAgentInvocationTarget(target, options = {}) {
|
|
22
24
|
const cleanTarget = target.trim();
|
|
23
25
|
if (!cleanTarget) {
|
|
@@ -85,6 +87,8 @@ export async function resolveAgentInvocationTarget(target, options = {}) {
|
|
|
85
87
|
invocationAuthByTarget.set(resolvedTarget, agent.auth);
|
|
86
88
|
if (agent.kind)
|
|
87
89
|
invocationProviderKindByTarget.set(resolvedTarget, agent.kind);
|
|
90
|
+
if (agent.source)
|
|
91
|
+
invocationSourceByTarget.set(resolvedTarget, agent.source);
|
|
88
92
|
return resolvedTarget;
|
|
89
93
|
}
|
|
90
94
|
export async function invokeAgent(options) {
|
|
@@ -183,6 +187,15 @@ export async function invokeAgent(options) {
|
|
|
183
187
|
responseText,
|
|
184
188
|
};
|
|
185
189
|
}
|
|
190
|
+
function actionCallTarget(target) {
|
|
191
|
+
const source = invocationSourceByTarget.get(target);
|
|
192
|
+
return {
|
|
193
|
+
kind: target.kind,
|
|
194
|
+
...(target.id !== undefined ? { id: target.id } : {}),
|
|
195
|
+
url: target.url,
|
|
196
|
+
...(source ? { source } : {}),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
186
199
|
export async function invokeAgentAction(options) {
|
|
187
200
|
const action = options.action.trim();
|
|
188
201
|
if (!action) {
|
|
@@ -215,11 +228,15 @@ export async function invokeAgentAction(options) {
|
|
|
215
228
|
orgDomain: options.orgDomain,
|
|
216
229
|
orgSecret: options.orgSecret,
|
|
217
230
|
}),
|
|
231
|
+
...(options.orgId !== undefined ? { orgId: options.orgId } : {}),
|
|
218
232
|
requestTimeoutMs: options.requestTimeoutMs,
|
|
219
233
|
correlation: options.correlation,
|
|
220
234
|
...((options.cardUrl ?? target.cardUrl)
|
|
221
235
|
? { cardUrl: options.cardUrl ?? target.cardUrl }
|
|
222
236
|
: {}),
|
|
237
|
+
...(hasA2AActionCallHooks()
|
|
238
|
+
? { invocationTarget: actionCallTarget(target) }
|
|
239
|
+
: {}),
|
|
223
240
|
});
|
|
224
241
|
return { target, action, result };
|
|
225
242
|
}
|
package/dist/a2a/server.js
CHANGED
|
@@ -906,6 +906,9 @@ export function mountA2A(nitroApp, config, routePrefix = "/_agent-native") {
|
|
|
906
906
|
}
|
|
907
907
|
if (verifiedAudienceBound) {
|
|
908
908
|
event.context.__a2aAudienceVerified = true;
|
|
909
|
+
const expected = expectedJwtAudience(event, { routePrefix });
|
|
910
|
+
event.context.__a2aVerifiedAudiences =
|
|
911
|
+
typeof expected === "string" ? [expected] : (expected ?? []);
|
|
909
912
|
}
|
|
910
913
|
if (verifiedOrgDomain) {
|
|
911
914
|
event.context.__a2aOrgDomain = verifiedOrgDomain;
|
package/dist/action.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isA2AForegroundCall } from "./a2a/foreground-call-scope.js";
|
|
1
2
|
import { copyActionArguments, snapshotActionArguments, } from "./action-arguments-identity.js";
|
|
2
3
|
import { actionCallIsRetrySafe, actionCallReadOnly, actionOutputEffect, classifyActionCall, isMcpReadOnlyTool, } from "./action-call-classification.js";
|
|
3
4
|
import { ACTION_EXECUTION_KEY, actionExecutionStorage, endInvocationEvidence, holdInvocationEvidence, noteObservedWrite, currentInvocationEvidence, runOutsideActionInvocation, takeVouchedEvidence, withoutWriteObservation, } from "./action-frame.js";
|
|
@@ -607,7 +608,8 @@ export function defineAction(options) {
|
|
|
607
608
|
(isProviderInteractiveScope() ||
|
|
608
609
|
isDurableProviderInteractiveScope())) ||
|
|
609
610
|
(ctx?.caller === "mcp" &&
|
|
610
|
-
currentInvocationEvidence()?.providerInteractive === true)
|
|
611
|
+
currentInvocationEvidence()?.providerInteractive === true) ||
|
|
612
|
+
(ctx?.caller === "a2a" && isA2AForegroundCall()), () => options.run(args, ctx));
|
|
611
613
|
};
|
|
612
614
|
const accessCheckedRun = typeof options.authorize === "function" || options.access
|
|
613
615
|
? wrapRunWithAccess(handlerRun, options.access, options.authorize)
|
|
@@ -57,6 +57,12 @@ export declare const AGENT_CHAT_BACKGROUND_SETUP_CLEANUP_FIELD = "__agentChatBac
|
|
|
57
57
|
export declare const AGENT_CHAT_BROWSER_SESSION_ID_FIELD = "__agentNativeBrowserSessionId";
|
|
58
58
|
/** Captured turn origin; durable workers do not restore loopback trust from this payload. */
|
|
59
59
|
export declare const AGENT_CHAT_REQUEST_CONTEXT_FIELD = "__agentChatRequestContext";
|
|
60
|
+
/**
|
|
61
|
+
* Signed proof, minted only by the foreground handler, that the turn a durable
|
|
62
|
+
* run continues was started interactively by its owner. A client can submit
|
|
63
|
+
* this field too, so the foreground handler always overwrites it.
|
|
64
|
+
*/
|
|
65
|
+
export declare const AGENT_CHAT_TURN_GRANT_FIELD = "__agentChatTurnGrant";
|
|
60
66
|
export declare function isHostedRuntimeForDurableBackground(): boolean;
|
|
61
67
|
export declare function isNetlifyHostedRuntimeForDurableBackground(): boolean;
|
|
62
68
|
export declare function isInBackgroundFunctionRuntime(): boolean;
|