experimental-ash 0.24.2 → 0.25.1
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/dist/docs/public/typescript-api.md +0 -12
- package/dist/src/channel/adapter.d.ts +5 -18
- package/dist/src/channel/adapter.js +2 -8
- package/dist/src/channel/cross-channel-receive.d.ts +10 -1
- package/dist/src/channel/cross-channel-receive.js +21 -3
- package/dist/src/channel/routes.d.ts +2 -1
- package/dist/src/channel/routes.js +6 -3
- package/dist/src/channel/schedule.js +2 -2
- package/dist/src/channel/types.d.ts +1 -1
- package/dist/src/chunks/{client-DLHAGI2g.js → client-BShLWzR6.js} +3 -3
- package/dist/src/chunks/compile-agent-CyP6FrL8.js +5 -0
- package/dist/src/chunks/dev-authored-source-watcher-DIWfVUsu.js +1 -0
- package/dist/src/chunks/host-BxT35q6K.js +70 -0
- package/dist/src/chunks/paths-B2hLA0Fn.js +85 -0
- package/dist/src/chunks/{token-D98SQdvs.js → token-BOkIxJeV.js} +1 -1
- package/dist/src/chunks/types-CjIyrcYo.js +1 -0
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/dev/environment.d.ts +0 -5
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/repl.d.ts +1 -1
- package/dist/src/cli/dev/repl.js +3 -3
- package/dist/src/cli/run.d.ts +0 -1
- package/dist/src/cli/run.js +2 -2
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/message-reducer.js +13 -25
- package/dist/src/client/message-response.d.ts +2 -1
- package/dist/src/client/open-stream.d.ts +3 -3
- package/dist/src/client/open-stream.js +1 -2
- package/dist/src/client/session.d.ts +2 -1
- package/dist/src/client/session.js +0 -3
- package/dist/src/client/types.d.ts +3 -2
- package/dist/src/compiler/artifacts.d.ts +7 -10
- package/dist/src/compiler/artifacts.js +3 -3
- package/dist/src/compiler/manifest.d.ts +6 -15
- package/dist/src/compiler/manifest.js +3 -3
- package/dist/src/compiler/normalize-agent-config.js +12 -10
- package/dist/src/compiler/normalize-manifest.js +3 -2
- package/dist/src/context/container.d.ts +1 -16
- package/dist/src/context/container.js +1 -24
- package/dist/src/context/hook-lifecycle.d.ts +2 -7
- package/dist/src/context/hook-lifecycle.js +0 -6
- package/dist/src/context/provider.d.ts +1 -11
- package/dist/src/context/providers/sandbox.js +4 -1
- package/dist/src/context/run-step.d.ts +2 -4
- package/dist/src/context/run-step.js +4 -17
- package/dist/src/context/seed-keys.d.ts +1 -1
- package/dist/src/discover/connections.d.ts +2 -1
- package/dist/src/discover/diagnostics.d.ts +0 -8
- package/dist/src/discover/diagnostics.js +4 -16
- package/dist/src/discover/discover-agent.d.ts +3 -13
- package/dist/src/discover/discover-agent.js +1 -11
- package/dist/src/discover/discover-subagent.d.ts +3 -2
- package/dist/src/discover/discover-subagent.js +1 -1
- package/dist/src/discover/filesystem.d.ts +0 -37
- package/dist/src/discover/filesystem.js +0 -115
- package/dist/src/discover/grammar.d.ts +10 -20
- package/dist/src/discover/grammar.js +11 -33
- package/dist/src/discover/lib.d.ts +3 -2
- package/dist/src/discover/manifest.d.ts +3 -3
- package/dist/src/discover/markdown.d.ts +2 -1
- package/dist/src/discover/sandbox.d.ts +2 -1
- package/dist/src/discover/schedules.d.ts +3 -2
- package/dist/src/discover/schedules.js +1 -1
- package/dist/src/discover/skills.d.ts +3 -2
- package/dist/src/discover/skills.js +1 -1
- package/dist/src/discover/slots.d.ts +3 -2
- package/dist/src/evals/cli/eval.d.ts +0 -6
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/evals/loaders/index.d.ts +2 -22
- package/dist/src/evals/loaders/index.js +1 -1
- package/dist/src/evals/reporters/index.d.ts +2 -14
- package/dist/src/evals/reporters/index.js +1 -1
- package/dist/src/evals/runner/discover.d.ts +0 -6
- package/dist/src/evals/runner/discover.js +1 -1
- package/dist/src/evals/runner/execute-case.d.ts +2 -1
- package/dist/src/evals/runner/execute-suite.d.ts +2 -1
- package/dist/src/evals/runner/reporters/braintrust.js +1 -1
- package/dist/src/evals/runner/resolve-git-metadata.d.ts +3 -3
- package/dist/src/evals/scorers/autoevals-client.d.ts +2 -2
- package/dist/src/execution/await-authorization-orchestrator.d.ts +0 -2
- package/dist/src/execution/await-authorization-orchestrator.js +11 -19
- package/dist/src/execution/connection-auth-steps.d.ts +1 -5
- package/dist/src/execution/connection-auth-steps.js +5 -9
- package/dist/src/execution/node-step.d.ts +1 -1
- package/dist/src/execution/skills/instructions.d.ts +2 -1
- package/dist/src/execution/subagent-hitl-proxy.d.ts +1 -1
- package/dist/src/execution/subagent-tool.d.ts +0 -8
- package/dist/src/execution/subagent-tool.js +9 -16
- package/dist/src/execution/tool-compaction.js +0 -2
- package/dist/src/execution/turn-workflow.d.ts +1 -1
- package/dist/src/execution/turn-workflow.js +2 -3
- package/dist/src/execution/web-fetch/tool.js +1 -1
- package/dist/src/execution/workflow-steps.d.ts +15 -1
- package/dist/src/execution/workflow-steps.js +8 -18
- package/dist/src/harness/action-result-helpers.d.ts +0 -12
- package/dist/src/harness/action-result-helpers.js +1 -1
- package/dist/src/harness/emission.d.ts +2 -2
- package/dist/src/harness/execute-tool.d.ts +2 -1
- package/dist/src/harness/input-requests.d.ts +2 -1
- package/dist/src/harness/prompt-cache.d.ts +1 -9
- package/dist/src/harness/prompt-cache.js +0 -12
- package/dist/src/harness/runtime-actions.d.ts +2 -11
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/harness/step-hooks.d.ts +3 -2
- package/dist/src/harness/step-hooks.js +3 -7
- package/dist/src/harness/tool-loop.js +0 -2
- package/dist/src/harness/types.d.ts +1 -1
- package/dist/src/internal/application/package.js +2 -2
- package/dist/src/internal/application/runtime-compiled-artifacts-source.js +0 -1
- package/dist/src/internal/attachments/errors.d.ts +8 -2
- package/dist/src/internal/attachments/url-refs.d.ts +0 -1
- package/dist/src/internal/attachments/url-refs.js +1 -1
- package/dist/src/internal/authored-definition/channel.d.ts +0 -5
- package/dist/src/internal/authored-definition/channel.js +1 -10
- package/dist/src/internal/authored-definition/sandbox.d.ts +2 -1
- package/dist/src/internal/authored-definition/schema-backed.d.ts +3 -2
- package/dist/src/internal/authored-module-loader.d.ts +0 -6
- package/dist/src/internal/authored-module-loader.js +0 -9
- package/dist/src/internal/authored-module.d.ts +0 -4
- package/dist/src/internal/authored-module.js +0 -10
- package/dist/src/internal/bundler/nitro-rolldown.d.ts +2 -10
- package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
- package/dist/src/{public → internal}/helpers/markdown.d.ts +2 -23
- package/dist/src/{public → internal}/helpers/markdown.js +1 -1
- package/dist/src/internal/logging.d.ts +2 -8
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.d.ts +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +2 -2
- package/dist/src/internal/nitro/routes/channel-dispatch.js +2 -2
- package/dist/src/internal/nitro/routes/runtime-artifacts.js +0 -1
- package/dist/src/internal/node-esm-compat-banner.d.ts +1 -1
- package/dist/src/internal/runtime-registry.d.ts +2 -1
- package/dist/src/{protocol → internal}/vercel-agent-summary.d.ts +1 -1
- package/dist/src/protocol/message.d.ts +0 -34
- package/dist/src/protocol/message.js +0 -30
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/index.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +1 -7
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/connections.d.ts +2 -6
- package/dist/src/public/channels/slack/hitl.d.ts +3 -2
- package/dist/src/public/channels/slack/inbound.d.ts +0 -35
- package/dist/src/public/definitions/channel.d.ts +2 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/defineChannel.d.ts +1 -1
- package/dist/src/public/definitions/defineChannel.js +1 -1
- package/dist/src/public/definitions/instructions.d.ts +0 -11
- package/dist/src/public/definitions/instructions.js +0 -5
- package/dist/src/public/definitions/tool.d.ts +3 -7
- package/dist/src/public/definitions/tool.js +1 -1
- package/dist/src/public/instructions/index.d.ts +1 -5
- package/dist/src/public/instructions/index.js +1 -3
- package/dist/src/public/tool-result-narrowing.d.ts +2 -1
- package/dist/src/react/use-ash-agent.d.ts +2 -1
- package/dist/src/react/use-ash-agent.js +1 -5
- package/dist/src/runtime/actions/types.d.ts +8 -50
- package/dist/src/runtime/actions/types.js +5 -21
- package/dist/src/runtime/agent/bootstrap-model-utils.d.ts +2 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/channels/registry.js +3 -8
- package/dist/src/runtime/compiled-artifacts-source.d.ts +4 -11
- package/dist/src/runtime/compiled-artifacts-source.js +3 -7
- package/dist/src/runtime/connections/authorization-tokens.d.ts +1 -14
- package/dist/src/runtime/connections/authorization-tokens.js +2 -28
- package/dist/src/runtime/connections/principal-context.d.ts +3 -2
- package/dist/src/runtime/connections/validate-authorization.d.ts +0 -11
- package/dist/src/runtime/connections/validate-authorization.js +0 -16
- package/dist/src/runtime/framework-channels/index.d.ts +0 -1
- package/dist/src/runtime/framework-channels/index.js +1 -1
- package/dist/src/runtime/framework-tools/connection-search.d.ts +0 -46
- package/dist/src/runtime/framework-tools/connection-search.js +3 -78
- package/dist/src/runtime/framework-tools/connection-tools.d.ts +3 -6
- package/dist/src/runtime/framework-tools/connection-tools.js +6 -13
- package/dist/src/runtime/framework-tools/index.d.ts +2 -1
- package/dist/src/runtime/framework-tools/index.js +2 -1
- package/dist/src/runtime/framework-tools/skill.d.ts +0 -13
- package/dist/src/runtime/framework-tools/skill.js +1 -1
- package/dist/src/runtime/governance/auth/token-claims.d.ts +1 -16
- package/dist/src/runtime/governance/auth/token-claims.js +3 -3
- package/dist/src/runtime/governance/auth/types.d.ts +0 -4
- package/dist/src/runtime/governance/network/ip-allow-list.d.ts +0 -17
- package/dist/src/runtime/governance/network/ip-allow-list.js +0 -39
- package/dist/src/runtime/hooks/registry.d.ts +7 -4
- package/dist/src/runtime/hooks/registry.js +4 -2
- package/dist/src/runtime/loaders/bundled-artifacts.d.ts +0 -5
- package/dist/src/runtime/loaders/bundled-artifacts.js +0 -7
- package/dist/src/runtime/loaders/compile-metadata.d.ts +3 -10
- package/dist/src/runtime/loaders/compile-metadata.js +6 -8
- package/dist/src/runtime/loaders/manifest.d.ts +2 -2
- package/dist/src/runtime/loaders/manifest.js +4 -5
- package/dist/src/runtime/loaders/module-map.d.ts +2 -2
- package/dist/src/runtime/loaders/module-map.js +3 -4
- package/dist/src/runtime/prompt/compose.d.ts +2 -1
- package/dist/src/runtime/resolve-agent-graph.d.ts +2 -15
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/sandbox/keys.d.ts +2 -1
- package/dist/src/runtime/sandbox/registry.d.ts +3 -3
- package/dist/src/runtime/schedules/resolve-schedule.d.ts +3 -12
- package/dist/src/runtime/schedules/resolve-schedule.js +1 -1
- package/dist/src/runtime/sessions/auth.d.ts +2 -13
- package/dist/src/runtime/sessions/auth.js +1 -11
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/runtime/sessions/runtime-session.d.ts +0 -6
- package/dist/src/runtime/sessions/runtime-session.js +0 -13
- package/dist/src/runtime/sessions/turn.d.ts +2 -2
- package/dist/src/runtime/subagents/registry.d.ts +2 -5
- package/dist/src/runtime/subagents/registry.js +0 -6
- package/dist/src/runtime/tools/registry.d.ts +2 -1
- package/dist/src/runtime/tools/registry.js +1 -4
- package/dist/src/runtime/types.d.ts +4 -3
- package/dist/src/runtime/workspace/seed-files.d.ts +2 -1
- package/dist/src/services/dev-client/request-headers.d.ts +37 -8
- package/dist/src/services/dev-client/request-headers.js +71 -46
- package/dist/src/services/dev-client/stream.d.ts +0 -19
- package/dist/src/services/dev-client/stream.js +0 -37
- package/dist/src/services/dev-client/url.d.ts +3 -7
- package/dist/src/services/dev-client/url.js +4 -10
- package/dist/src/services/dev-client.d.ts +0 -12
- package/dist/src/services/dev-client.js +6 -92
- package/dist/src/shared/agent-definition.d.ts +1 -1
- package/dist/src/shared/json.d.ts +0 -4
- package/dist/src/shared/json.js +0 -38
- package/dist/src/shared/skill-definition.d.ts +0 -2
- package/package.json +1 -6
- package/dist/src/chunks/dev-authored-source-watcher-CBID_Dwh.js +0 -1
- package/dist/src/chunks/host-zBy9FyyX.js +0 -70
- package/dist/src/chunks/package-HUaeub_D.js +0 -1
- package/dist/src/chunks/paths-CebY5GCi.js +0 -89
- package/dist/src/chunks/types-DDA2QUED.js +0 -1
- package/dist/src/compiler/resource-files.d.ts +0 -19
- package/dist/src/compiler/resource-files.js +0 -28
- package/dist/src/execution/subagent-invocation.d.ts +0 -19
- package/dist/src/execution/subagent-invocation.js +0 -17
- package/dist/src/execution/task-mode.d.ts +0 -9
- package/dist/src/execution/task-mode.js +0 -12
- package/dist/src/execution/types.d.ts +0 -20
- package/dist/src/execution/types.js +0 -1
- package/dist/src/internal/logical-paths.d.ts +0 -13
- package/dist/src/internal/logical-paths.js +0 -25
- package/dist/src/runtime/sessions/messages.d.ts +0 -140
- package/dist/src/runtime/sessions/messages.js +0 -170
- package/dist/src/runtime/standard-schema.d.ts +0 -27
- package/dist/src/runtime/standard-schema.js +0 -64
- package/dist/src/services/dev-client/live-stream.d.ts +0 -35
- package/dist/src/services/dev-client/live-stream.js +0 -157
- package/dist/src/services/dev-client/send-message.d.ts +0 -24
- package/dist/src/services/dev-client/send-message.js +0 -185
- package/dist/src/services/dev-client/session.d.ts +0 -54
- package/dist/src/services/dev-client/session.js +0 -52
- package/dist/src/services/host.d.ts +0 -14
- package/dist/src/services/host.js +0 -13
- /package/dist/src/{package-name.d.ts → internal/package-name.d.ts} +0 -0
- /package/dist/src/{package-name.js → internal/package-name.js} +0 -0
- /package/dist/src/{protocol → internal}/vercel-agent-summary.js +0 -0
- /package/dist/src/{run-mode.d.ts → shared/run-mode.d.ts} +0 -0
- /package/dist/src/{run-mode.js → shared/run-mode.js} +0 -0
|
@@ -14,7 +14,7 @@ export const runtimeToolCallActionRequestSchema = z
|
|
|
14
14
|
/**
|
|
15
15
|
* Zod schema for one runtime-owned subagent-call action request.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
const runtimeSubagentCallActionRequestSchema = z
|
|
18
18
|
.object({
|
|
19
19
|
callId: z.string(),
|
|
20
20
|
description: z.string(),
|
|
@@ -28,25 +28,17 @@ export const runtimeSubagentCallActionRequestSchema = z
|
|
|
28
28
|
/**
|
|
29
29
|
* Zod schema for one runtime-owned load-skill action request.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
const runtimeLoadSkillActionRequestSchema = z
|
|
32
32
|
.object({
|
|
33
33
|
callId: z.string(),
|
|
34
34
|
input: jsonObjectSchema,
|
|
35
35
|
kind: z.literal("load-skill"),
|
|
36
36
|
})
|
|
37
37
|
.strict();
|
|
38
|
-
/**
|
|
39
|
-
* Zod schema for one runtime action request.
|
|
40
|
-
*/
|
|
41
|
-
export const runtimeActionRequestSchema = z.discriminatedUnion("kind", [
|
|
42
|
-
runtimeLoadSkillActionRequestSchema,
|
|
43
|
-
runtimeSubagentCallActionRequestSchema,
|
|
44
|
-
runtimeToolCallActionRequestSchema,
|
|
45
|
-
]);
|
|
46
38
|
/**
|
|
47
39
|
* Zod schema for one runtime-owned authored tool-result action result.
|
|
48
40
|
*/
|
|
49
|
-
|
|
41
|
+
const runtimeToolResultActionResultSchema = z
|
|
50
42
|
.object({
|
|
51
43
|
callId: z.string(),
|
|
52
44
|
isError: z.boolean().optional(),
|
|
@@ -58,7 +50,7 @@ export const runtimeToolResultActionResultSchema = z
|
|
|
58
50
|
/**
|
|
59
51
|
* Zod schema for one runtime-owned subagent result action result.
|
|
60
52
|
*/
|
|
61
|
-
|
|
53
|
+
const runtimeSubagentResultActionResultSchema = z
|
|
62
54
|
.object({
|
|
63
55
|
callId: z.string(),
|
|
64
56
|
isError: z.boolean().optional(),
|
|
@@ -73,7 +65,7 @@ export const runtimeSubagentResultActionResultSchema = z
|
|
|
73
65
|
* The result still reports whether a skill became active during the turn; the
|
|
74
66
|
* action name reflects how the model requests those instructions.
|
|
75
67
|
*/
|
|
76
|
-
|
|
68
|
+
const runtimeLoadSkillActionResultSchema = z
|
|
77
69
|
.object({
|
|
78
70
|
callId: z.string(),
|
|
79
71
|
isError: z.boolean().optional(),
|
|
@@ -82,11 +74,3 @@ export const runtimeLoadSkillActionResultSchema = z
|
|
|
82
74
|
name: z.string().optional(),
|
|
83
75
|
})
|
|
84
76
|
.strict();
|
|
85
|
-
/**
|
|
86
|
-
* Zod schema for one runtime action result.
|
|
87
|
-
*/
|
|
88
|
-
export const runtimeActionResultSchema = z.discriminatedUnion("kind", [
|
|
89
|
-
runtimeLoadSkillActionResultSchema,
|
|
90
|
-
runtimeSubagentResultActionResultSchema,
|
|
91
|
-
runtimeToolResultActionResultSchema,
|
|
92
|
-
]);
|
|
@@ -2,7 +2,7 @@ import type { MockLanguageModelV3 } from "ai/test";
|
|
|
2
2
|
export type BootstrapGenerateOptions = Parameters<MockLanguageModelV3["doGenerate"]>[0];
|
|
3
3
|
export type BootstrapPrompt = BootstrapGenerateOptions["prompt"];
|
|
4
4
|
export type BootstrapGenerateResult = Awaited<ReturnType<MockLanguageModelV3["doGenerate"]>>;
|
|
5
|
-
|
|
5
|
+
type BootstrapStreamResult = Awaited<ReturnType<MockLanguageModelV3["doStream"]>>;
|
|
6
6
|
/**
|
|
7
7
|
* Builds a deterministic `doGenerate` result from a text response and token
|
|
8
8
|
* estimates. Shared by the real bootstrap model and the authored-model mock.
|
|
@@ -34,3 +34,4 @@ export declare function getLastUserPromptText(prompt: BootstrapPrompt): string |
|
|
|
34
34
|
* Joins all message content in the prompt into a single string.
|
|
35
35
|
*/
|
|
36
36
|
export declare function getPromptText(prompt: BootstrapPrompt): string;
|
|
37
|
+
export {};
|
|
@@ -2,8 +2,8 @@ import { MockLanguageModelV3 } from "ai/test";
|
|
|
2
2
|
import { z } from "#compiled/zod/index.js";
|
|
3
3
|
import { BOOTSTRAP_RUNTIME_MODEL_ID, BOOTSTRAP_RUNTIME_SYSTEM_PROMPT, } from "#runtime/agent/bootstrap.js";
|
|
4
4
|
import { createBootstrapGenerateResult, createBootstrapStreamResult, estimateTokenCount, getLastUserPromptText, getPromptContentText, getPromptText, } from "#runtime/agent/bootstrap-model-utils.js";
|
|
5
|
+
import { LOAD_SKILL_TOOL_NAME } from "#runtime/skills/fragment-context.js";
|
|
5
6
|
const MOCK_RUNTIME_MODEL_PROVIDER = "ash-runtime-mock";
|
|
6
|
-
const LOAD_SKILL_TOOL_NAME = "load_skill";
|
|
7
7
|
const LOAD_SKILL_TOOL_CALL_ID = "call_load_skill";
|
|
8
8
|
const GET_WEATHER_TOOL_CALL_ID = "call_get_weather";
|
|
9
9
|
const authoredRuntimeModelMocks = new Map();
|
|
@@ -24,7 +24,6 @@ const ADAPTER_NON_EVENT_FIELDS = new Set([
|
|
|
24
24
|
"kind",
|
|
25
25
|
"state",
|
|
26
26
|
"deliver",
|
|
27
|
-
"contextProviders",
|
|
28
27
|
"createAdapterContext",
|
|
29
28
|
"fetchFile",
|
|
30
29
|
]);
|
|
@@ -64,9 +63,8 @@ export function createRuntimeAdapterRegistry(input) {
|
|
|
64
63
|
throw new RuntimeRegistryError("adapter", `Channel adapter kind "${kind}" is reserved by the framework. ` +
|
|
65
64
|
`A route-declared adapter may share a framework kind only as a ` +
|
|
66
65
|
`pass-through with no \`deliver\` hook, event handlers, ` +
|
|
67
|
-
`\`attachments\` resolver, \`
|
|
68
|
-
|
|
69
|
-
`channel-specific behavior.`, { ...location, entryName: kind });
|
|
66
|
+
`\`attachments\` resolver, or \`createAdapterContext\` factory. ` +
|
|
67
|
+
`Use a custom \`kind\` to add channel-specific behavior.`, { ...location, entryName: kind });
|
|
70
68
|
}
|
|
71
69
|
// Additive pass-through — the framework adapter stays in place.
|
|
72
70
|
continue;
|
|
@@ -98,7 +96,7 @@ export function deserializeRuntimeAdapter(registry, data) {
|
|
|
98
96
|
}
|
|
99
97
|
function requireAdapterKind(adapter, location) {
|
|
100
98
|
const kind = getAdapterKind(adapter);
|
|
101
|
-
if (kind
|
|
99
|
+
if (typeof kind !== "string" || kind.length === 0) {
|
|
102
100
|
throw new RuntimeRegistryError("adapter", "Adapters must declare a non-empty `kind` field.", {
|
|
103
101
|
entryName: "unknown",
|
|
104
102
|
logicalPath: location?.logicalPath,
|
|
@@ -121,9 +119,6 @@ function carriesAdapterBehavior(adapter) {
|
|
|
121
119
|
if (adapter.createAdapterContext !== undefined) {
|
|
122
120
|
return true;
|
|
123
121
|
}
|
|
124
|
-
if (adapter.contextProviders !== undefined && adapter.contextProviders.length > 0) {
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
122
|
// Remaining keys on a ChannelAdapter object correspond to stream
|
|
128
123
|
// event handlers (keyed by event type, e.g. "input.requested").
|
|
129
124
|
for (const [key, value] of Object.entries(adapter)) {
|
|
@@ -17,18 +17,12 @@ export interface RuntimeDiskCompiledArtifactsSource {
|
|
|
17
17
|
readonly kind: "disk";
|
|
18
18
|
/**
|
|
19
19
|
* Native filesystem path to the package-owned authored-source module map
|
|
20
|
-
* loader.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* loader. When set, the runtime loads modules directly from authored
|
|
21
|
+
* source instead of the bundled-compiled module map. Omitted in deployed
|
|
22
|
+
* runtimes, where the module map must come from the compiled artifact
|
|
23
|
+
* emitted by the build.
|
|
23
24
|
*/
|
|
24
25
|
readonly moduleMapLoaderPath?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Optional module-map loader override for package-internal dev/build flows.
|
|
27
|
-
*
|
|
28
|
-
* Omitted in deployed runtimes, where the module map must come from the
|
|
29
|
-
* compiled artifact emitted by the build.
|
|
30
|
-
*/
|
|
31
|
-
readonly moduleMapLoadMode?: "authored-source";
|
|
32
26
|
}
|
|
33
27
|
/**
|
|
34
28
|
* Creates the bundled compiled-artifact source.
|
|
@@ -38,7 +32,6 @@ export declare function createBundledRuntimeCompiledArtifactsSource(): RuntimeBu
|
|
|
38
32
|
* Creates the disk-backed compiled-artifact source for one authored app root.
|
|
39
33
|
*/
|
|
40
34
|
export declare function createDiskRuntimeCompiledArtifactsSource(appRoot: string, options?: {
|
|
41
|
-
readonly moduleMapLoadMode?: RuntimeDiskCompiledArtifactsSource["moduleMapLoadMode"];
|
|
42
35
|
readonly moduleMapLoaderPath?: string;
|
|
43
36
|
}): RuntimeDiskCompiledArtifactsSource;
|
|
44
37
|
/**
|
|
@@ -10,12 +10,11 @@ export function createBundledRuntimeCompiledArtifactsSource() {
|
|
|
10
10
|
* Creates the disk-backed compiled-artifact source for one authored app root.
|
|
11
11
|
*/
|
|
12
12
|
export function createDiskRuntimeCompiledArtifactsSource(appRoot, options = {}) {
|
|
13
|
-
if (options.
|
|
13
|
+
if (options.moduleMapLoaderPath !== undefined) {
|
|
14
14
|
return {
|
|
15
15
|
appRoot,
|
|
16
16
|
kind: "disk",
|
|
17
17
|
moduleMapLoaderPath: options.moduleMapLoaderPath,
|
|
18
|
-
moduleMapLoadMode: options.moduleMapLoadMode,
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
20
|
return {
|
|
@@ -36,11 +35,8 @@ export function getRuntimeCompiledArtifactsCacheKey(source) {
|
|
|
36
35
|
if (source.kind !== "disk") {
|
|
37
36
|
return "bundled";
|
|
38
37
|
}
|
|
39
|
-
if (source.
|
|
40
|
-
|
|
41
|
-
return `disk:${source.appRoot}:${source.moduleMapLoadMode}:${source.moduleMapLoaderPath}`;
|
|
42
|
-
}
|
|
43
|
-
return `disk:${source.appRoot}:${source.moduleMapLoadMode}`;
|
|
38
|
+
if (source.moduleMapLoaderPath !== undefined) {
|
|
39
|
+
return `disk:${source.appRoot}:authored-source:${source.moduleMapLoaderPath}`;
|
|
44
40
|
}
|
|
45
41
|
return `disk:${source.appRoot}`;
|
|
46
42
|
}
|
|
@@ -15,10 +15,6 @@
|
|
|
15
15
|
import type { AshContext } from "#context/container.js";
|
|
16
16
|
import { ContextKey } from "#context/key.js";
|
|
17
17
|
import type { TokenResult } from "#runtime/connections/types.js";
|
|
18
|
-
/**
|
|
19
|
-
* Inner map of `principalKey` → {@link TokenResult} for one connection.
|
|
20
|
-
*/
|
|
21
|
-
export type PrincipalTokenCache = Readonly<Record<string, TokenResult>>;
|
|
22
18
|
/**
|
|
23
19
|
* Virtual context key mapping connection name to a per-principal
|
|
24
20
|
* {@link TokenResult} cache.
|
|
@@ -35,7 +31,7 @@ export declare const ConnectionAuthorizationTokensKey: ContextKey<Readonly<Recor
|
|
|
35
31
|
* (not expired). Expired entries are treated as a cache miss so
|
|
36
32
|
* callers re-run the authorization flow.
|
|
37
33
|
*/
|
|
38
|
-
export declare function readCachedToken(ctx: AshContext, connectionName: string, principalKey: string
|
|
34
|
+
export declare function readCachedToken(ctx: AshContext, connectionName: string, principalKey: string): TokenResult | undefined;
|
|
39
35
|
/**
|
|
40
36
|
* Persists a freshly resolved {@link TokenResult} on the cache under
|
|
41
37
|
* `(connectionName, principalKey)`. Existing entries for other
|
|
@@ -45,12 +41,3 @@ export declare function readCachedToken(ctx: AshContext, connectionName: string,
|
|
|
45
41
|
* into the durable step payload. See the module docblock.
|
|
46
42
|
*/
|
|
47
43
|
export declare function writeCachedToken(ctx: AshContext, connectionName: string, principalKey: string, token: TokenResult): void;
|
|
48
|
-
/**
|
|
49
|
-
* Removes the cached token for `(connectionName, principalKey)`.
|
|
50
|
-
* Called when a connection's token is rejected downstream (for
|
|
51
|
-
* example the server returns 401 with the cached bearer) so the next
|
|
52
|
-
* `getToken` call runs fresh.
|
|
53
|
-
*
|
|
54
|
-
* Other principals' tokens on the same connection are preserved.
|
|
55
|
-
*/
|
|
56
|
-
export declare function clearCachedToken(ctx: AshContext, connectionName: string, principalKey: string): void;
|
|
@@ -29,11 +29,11 @@ export const ConnectionAuthorizationTokensKey = new ContextKey("ash.connectionAu
|
|
|
29
29
|
* (not expired). Expired entries are treated as a cache miss so
|
|
30
30
|
* callers re-run the authorization flow.
|
|
31
31
|
*/
|
|
32
|
-
export function readCachedToken(ctx, connectionName, principalKey
|
|
32
|
+
export function readCachedToken(ctx, connectionName, principalKey) {
|
|
33
33
|
const entry = ctx.get(ConnectionAuthorizationTokensKey)?.[connectionName]?.[principalKey];
|
|
34
34
|
if (entry === undefined)
|
|
35
35
|
return undefined;
|
|
36
|
-
if (entry.expiresAt !== undefined && entry.expiresAt <= now) {
|
|
36
|
+
if (entry.expiresAt !== undefined && entry.expiresAt <= Date.now()) {
|
|
37
37
|
return undefined;
|
|
38
38
|
}
|
|
39
39
|
return entry;
|
|
@@ -54,32 +54,6 @@ export function writeCachedToken(ctx, connectionName, principalKey, token) {
|
|
|
54
54
|
[connectionName]: { ...perConnection, [principalKey]: token },
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Removes the cached token for `(connectionName, principalKey)`.
|
|
59
|
-
* Called when a connection's token is rejected downstream (for
|
|
60
|
-
* example the server returns 401 with the cached bearer) so the next
|
|
61
|
-
* `getToken` call runs fresh.
|
|
62
|
-
*
|
|
63
|
-
* Other principals' tokens on the same connection are preserved.
|
|
64
|
-
*/
|
|
65
|
-
export function clearCachedToken(ctx, connectionName, principalKey) {
|
|
66
|
-
const existing = ctx.get(ConnectionAuthorizationTokensKey);
|
|
67
|
-
const perConnection = existing?.[connectionName];
|
|
68
|
-
if (existing === undefined || perConnection === undefined)
|
|
69
|
-
return;
|
|
70
|
-
if (perConnection[principalKey] === undefined)
|
|
71
|
-
return;
|
|
72
|
-
const nextPerConnection = { ...perConnection };
|
|
73
|
-
delete nextPerConnection[principalKey];
|
|
74
|
-
const next = { ...existing };
|
|
75
|
-
if (Object.keys(nextPerConnection).length === 0) {
|
|
76
|
-
delete next[connectionName];
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
next[connectionName] = nextPerConnection;
|
|
80
|
-
}
|
|
81
|
-
asContainer(ctx).setVirtualContext(ConnectionAuthorizationTokensKey, next);
|
|
82
|
-
}
|
|
83
57
|
/**
|
|
84
58
|
* Runtime installs `ContextContainer` as the concrete `AshContext`;
|
|
85
59
|
* we reach through the interface here because `setVirtualContext` is
|
|
@@ -42,13 +42,13 @@ import type { ConnectionPrincipal } from "#runtime/connections/types.js";
|
|
|
42
42
|
/**
|
|
43
43
|
* Per-connection principal overrides keyed by connection name.
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
type ConnectionPrincipalOverrides = Readonly<Record<string, ConnectionPrincipal>>;
|
|
46
46
|
/**
|
|
47
47
|
* One frame on the principal-override stack. Frames are compared by
|
|
48
48
|
* object identity when popping so concurrent entries can
|
|
49
49
|
* deterministically remove the frame they pushed.
|
|
50
50
|
*/
|
|
51
|
-
|
|
51
|
+
interface ConnectionPrincipalOverrideFrame {
|
|
52
52
|
readonly overrides: ConnectionPrincipalOverrides;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -98,3 +98,4 @@ export declare function lookupConnectionPrincipalOverride(ctx: {
|
|
|
98
98
|
* of the stack.
|
|
99
99
|
*/
|
|
100
100
|
export declare function withConnectionPrincipalOverride<T>(ctx: ContextContainer, overrides: ConnectionPrincipalOverrides, fn: () => Promise<T>): Promise<T>;
|
|
101
|
+
export {};
|
|
@@ -12,17 +12,6 @@ import type { AuthorizationDefinition } from "#runtime/connections/types.js";
|
|
|
12
12
|
* to prefix with its own context.
|
|
13
13
|
*/
|
|
14
14
|
export declare function validateAuthorizationSpec(authorization: unknown, fieldName?: string): string | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Narrow convenience that asserts `auth` is structurally valid and mutates
|
|
17
|
-
* defaulted fields into place, otherwise throws an `Error` with the caller's
|
|
18
|
-
* `prefix` joined to the validation message.
|
|
19
|
-
*
|
|
20
|
-
* Most call sites want a richer error (e.g. `ResolveAgentError`
|
|
21
|
-
* with `logicalPath`/`sourceId`) and should call
|
|
22
|
-
* {@link validateAuthorizationSpec} directly and wrap themselves.
|
|
23
|
-
* This helper is for the simple prefix-and-throw case.
|
|
24
|
-
*/
|
|
25
|
-
export declare function assertAuthorizationSpec(authorization: unknown, prefix: string, fieldName?: string): asserts authorization is AuthorizationDefinition;
|
|
26
15
|
/**
|
|
27
16
|
* Validates and normalizes an authored auth definition into the runtime shape.
|
|
28
17
|
*
|
|
@@ -39,22 +39,6 @@ export function validateAuthorizationSpec(authorization, fieldName = "auth") {
|
|
|
39
39
|
}
|
|
40
40
|
return undefined;
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Narrow convenience that asserts `auth` is structurally valid and mutates
|
|
44
|
-
* defaulted fields into place, otherwise throws an `Error` with the caller's
|
|
45
|
-
* `prefix` joined to the validation message.
|
|
46
|
-
*
|
|
47
|
-
* Most call sites want a richer error (e.g. `ResolveAgentError`
|
|
48
|
-
* with `logicalPath`/`sourceId`) and should call
|
|
49
|
-
* {@link validateAuthorizationSpec} directly and wrap themselves.
|
|
50
|
-
* This helper is for the simple prefix-and-throw case.
|
|
51
|
-
*/
|
|
52
|
-
export function assertAuthorizationSpec(authorization, prefix, fieldName = "auth") {
|
|
53
|
-
const normalized = normalizeAuthorizationSpec(authorization, prefix, fieldName);
|
|
54
|
-
if (authorization !== null && typeof authorization === "object") {
|
|
55
|
-
Object.assign(authorization, normalized);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
42
|
/**
|
|
59
43
|
* Validates and normalizes an authored auth definition into the runtime shape.
|
|
60
44
|
*
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { ResolvedChannelDefinition } from "#runtime/types.js";
|
|
2
|
-
export declare const ASH_CHANNEL_NAME = "ash";
|
|
3
2
|
export declare function getFrameworkChannelDefinitions(): readonly ResolvedChannelDefinition[];
|
|
4
3
|
export declare function getAllFrameworkChannelNames(): ReadonlySet<string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { none, vercelOidc } from "#public/channels/auth.js";
|
|
2
2
|
import { ashChannel } from "#public/channels/ash.js";
|
|
3
3
|
import { getConnectionCallbackChannelDefinitions, getConnectionCallbackChannelNames, } from "#runtime/connections/callback-route.js";
|
|
4
|
-
|
|
4
|
+
const ASH_CHANNEL_NAME = "ash";
|
|
5
5
|
export function getFrameworkChannelDefinitions() {
|
|
6
6
|
const auth = resolveFrameworkAshAuth();
|
|
7
7
|
const compiled = ashChannel({ auth });
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { type AshContext } from "#context/container.js";
|
|
2
1
|
import { ContextKey } from "#context/key.js";
|
|
3
|
-
import { createConnectionAuthorizationRequiredEvent } from "#protocol/message.js";
|
|
4
|
-
import type { ConnectionAuthorizationChallenge } from "#public/connections/errors.js";
|
|
5
2
|
import { type ConnectionRegistry, type ConnectionToolMetadata } from "#runtime/connections/types.js";
|
|
6
3
|
import type { ResolvedToolDefinition } from "#runtime/types.js";
|
|
7
4
|
import { CONNECTION_AUTHORIZATION_PLACEHOLDER } from "#runtime/framework-tools/pending-connection-tool-calls.js";
|
|
@@ -24,24 +21,6 @@ export declare const ConnectionRegistryKey: ContextKey<ConnectionRegistry>;
|
|
|
24
21
|
export interface DiscoveredConnectionToolsState {
|
|
25
22
|
readonly byConnection: Readonly<Record<string, readonly ConnectionToolMetadata[]>>;
|
|
26
23
|
}
|
|
27
|
-
/**
|
|
28
|
-
* One connection that requires user authorization before its tools
|
|
29
|
-
* can be used.
|
|
30
|
-
*/
|
|
31
|
-
export interface PendingConnectionAuthorization {
|
|
32
|
-
readonly connectionName: string;
|
|
33
|
-
readonly description: string;
|
|
34
|
-
readonly authorization?: ConnectionAuthorizationChallenge;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Durable context key for connections awaiting user authorization.
|
|
38
|
-
*
|
|
39
|
-
* Written by `connection_search` when a connection throws
|
|
40
|
-
* {@link ConnectionAuthorizationRequiredError}. Read by the harness after
|
|
41
|
-
* the step completes to emit `connection.authorization_required`
|
|
42
|
-
* events and optionally suspend the workflow on a webhook.
|
|
43
|
-
*/
|
|
44
|
-
export declare const PendingConnectionAuthorizationsKey: ContextKey<readonly PendingConnectionAuthorization[]>;
|
|
45
24
|
/**
|
|
46
25
|
* Durable context key for discovered connection tools.
|
|
47
26
|
*
|
|
@@ -73,29 +52,4 @@ export declare function executeConnectionSearch(input: ConnectionSearchInput, me
|
|
|
73
52
|
}): Promise<ConnectionSearchResultItem[] | typeof CONNECTION_AUTHORIZATION_PLACEHOLDER>;
|
|
74
53
|
export declare function tokenize(text: string): string[];
|
|
75
54
|
export declare function scoreMatch(queryTokens: string[], tool: ConnectionToolMetadata): number;
|
|
76
|
-
/** Emit function passed to {@link drainPendingConnectionAuthorizations}. */
|
|
77
|
-
type ConnectionAuthorizationEmitFn = (event: ReturnType<typeof createConnectionAuthorizationRequiredEvent>) => Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Emits queued non-interactive authorization-required events and clears
|
|
80
|
-
* the drained entries.
|
|
81
|
-
*/
|
|
82
|
-
export declare function drainPendingConnectionAuthorizations(params: {
|
|
83
|
-
readonly ctx: AshContext;
|
|
84
|
-
readonly emit: ConnectionAuthorizationEmitFn;
|
|
85
|
-
readonly state: {
|
|
86
|
-
readonly sequence: number;
|
|
87
|
-
readonly stepIndex: number;
|
|
88
|
-
readonly turnId: string;
|
|
89
|
-
};
|
|
90
|
-
}): Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* Adds `pending` to {@link PendingConnectionAuthorizationsKey} if no
|
|
93
|
-
* entry for the same `connectionName` already exists on the context.
|
|
94
|
-
*
|
|
95
|
-
* Single source of truth for the dedup-by-name rule: called from
|
|
96
|
-
* `wrapConnectionToolExecute` (single connection per pending call) and
|
|
97
|
-
* from the fan-out loop inside {@link executeConnectionSearch} (many
|
|
98
|
-
* connections per search call).
|
|
99
|
-
*/
|
|
100
|
-
export declare function recordPendingAuthorization(ctx: AshContext, pending: PendingConnectionAuthorization): void;
|
|
101
55
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { loadContext } from "#context/container.js";
|
|
2
2
|
import { ContextKey } from "#context/key.js";
|
|
3
3
|
import { createLogger } from "#internal/logging.js";
|
|
4
|
-
import { createConnectionAuthorizationRequiredEvent } from "#protocol/message.js";
|
|
5
4
|
import { isConnectionAuthorizationFailedError, isConnectionAuthorizationRequiredError, } from "#public/connections/errors.js";
|
|
6
5
|
import { supportsInteractiveAuthorization, } from "#runtime/connections/types.js";
|
|
7
6
|
import { qualifiedConnectionToolName } from "#runtime/framework-tools/connection-tools.js";
|
|
@@ -15,15 +14,6 @@ const logger = createLogger("framework.connection-search");
|
|
|
15
14
|
* The `connectionProvider` reconstructs it each step.
|
|
16
15
|
*/
|
|
17
16
|
export const ConnectionRegistryKey = new ContextKey("ash.connectionRegistry");
|
|
18
|
-
/**
|
|
19
|
-
* Durable context key for connections awaiting user authorization.
|
|
20
|
-
*
|
|
21
|
-
* Written by `connection_search` when a connection throws
|
|
22
|
-
* {@link ConnectionAuthorizationRequiredError}. Read by the harness after
|
|
23
|
-
* the step completes to emit `connection.authorization_required`
|
|
24
|
-
* events and optionally suspend the workflow on a webhook.
|
|
25
|
-
*/
|
|
26
|
-
export const PendingConnectionAuthorizationsKey = new ContextKey("ash.pendingConnectionAuthorizations");
|
|
27
17
|
/**
|
|
28
18
|
* Durable context key for discovered connection tools.
|
|
29
19
|
*
|
|
@@ -70,7 +60,6 @@ export const CONNECTION_SEARCH_TOOL_DEFINITION = {
|
|
|
70
60
|
name: "connection_search",
|
|
71
61
|
onCompact({ ctx }) {
|
|
72
62
|
ctx.set(DiscoveredConnectionToolsKey, { byConnection: {} });
|
|
73
|
-
ctx.set(PendingConnectionAuthorizationsKey, []);
|
|
74
63
|
ctx.set(PendingConnectionToolCallsKey, []);
|
|
75
64
|
return {};
|
|
76
65
|
},
|
|
@@ -96,7 +85,7 @@ export async function executeConnectionSearch(input, meta) {
|
|
|
96
85
|
const discoveredByConnection = {
|
|
97
86
|
...previouslyDiscovered?.byConnection,
|
|
98
87
|
};
|
|
99
|
-
const
|
|
88
|
+
const authRequiredConnections = [];
|
|
100
89
|
for (const conn of targetConnections) {
|
|
101
90
|
let tools;
|
|
102
91
|
try {
|
|
@@ -105,10 +94,7 @@ export async function executeConnectionSearch(input, meta) {
|
|
|
105
94
|
}
|
|
106
95
|
catch (err) {
|
|
107
96
|
if (isConnectionAuthorizationRequiredError(err)) {
|
|
108
|
-
|
|
109
|
-
connectionName: conn.connectionName,
|
|
110
|
-
description: conn.description,
|
|
111
|
-
});
|
|
97
|
+
authRequiredConnections.push(conn.connectionName);
|
|
112
98
|
failedConnections.push({
|
|
113
99
|
connection: conn.connectionName,
|
|
114
100
|
description: conn.description,
|
|
@@ -169,17 +155,7 @@ export async function executeConnectionSearch(input, meta) {
|
|
|
169
155
|
// Persist discovered tools so they materialize as first-class
|
|
170
156
|
// AI SDK tools on the next step.
|
|
171
157
|
ctx.set(DiscoveredConnectionToolsKey, { byConnection: discoveredByConnection });
|
|
172
|
-
|
|
173
|
-
if (pendingAuthorizations.length > 0) {
|
|
174
|
-
for (const auth of pendingAuthorizations) {
|
|
175
|
-
recordPendingAuthorization(ctx, auth);
|
|
176
|
-
}
|
|
177
|
-
// Only connections with `startAuthorization` can suspend on a
|
|
178
|
-
// framework-owned webhook.
|
|
179
|
-
interactiveConnectionNames = pendingAuthorizations
|
|
180
|
-
.map((a) => a.connectionName)
|
|
181
|
-
.filter((name) => isInteractive(registry, name));
|
|
182
|
-
}
|
|
158
|
+
const interactiveConnectionNames = authRequiredConnections.filter((name) => isInteractive(registry, name));
|
|
183
159
|
// Suspend the entire tool call when at least one auth-required
|
|
184
160
|
// connection has the full interactive-OAuth surface. The
|
|
185
161
|
// connection-discover retry re-runs this search after tokens land,
|
|
@@ -240,60 +216,9 @@ export function scoreMatch(queryTokens, tool) {
|
|
|
240
216
|
}
|
|
241
217
|
return score;
|
|
242
218
|
}
|
|
243
|
-
/**
|
|
244
|
-
* Emits queued non-interactive authorization-required events and clears
|
|
245
|
-
* the drained entries.
|
|
246
|
-
*/
|
|
247
|
-
export async function drainPendingConnectionAuthorizations(params) {
|
|
248
|
-
const pending = params.ctx.get(PendingConnectionAuthorizationsKey);
|
|
249
|
-
if (pending === undefined || pending.length === 0) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const registry = params.ctx.get(ConnectionRegistryKey);
|
|
253
|
-
const drained = [];
|
|
254
|
-
const deferred = [];
|
|
255
|
-
for (const auth of pending) {
|
|
256
|
-
if (isInteractive(registry, auth.connectionName)) {
|
|
257
|
-
deferred.push(auth);
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
drained.push(auth);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
for (const auth of drained) {
|
|
264
|
-
const payload = {
|
|
265
|
-
connectionName: auth.connectionName,
|
|
266
|
-
description: auth.description,
|
|
267
|
-
sequence: params.state.sequence,
|
|
268
|
-
stepIndex: params.state.stepIndex,
|
|
269
|
-
turnId: params.state.turnId,
|
|
270
|
-
};
|
|
271
|
-
if (auth.authorization !== undefined) {
|
|
272
|
-
payload.authorization = auth.authorization;
|
|
273
|
-
}
|
|
274
|
-
await params.emit(createConnectionAuthorizationRequiredEvent(payload));
|
|
275
|
-
}
|
|
276
|
-
params.ctx.set(PendingConnectionAuthorizationsKey, deferred);
|
|
277
|
-
}
|
|
278
219
|
function isInteractive(registry, connectionName) {
|
|
279
220
|
if (registry === undefined)
|
|
280
221
|
return false;
|
|
281
222
|
const def = registry.getConnections().find((c) => c.connectionName === connectionName);
|
|
282
223
|
return supportsInteractiveAuthorization(def?.authorization);
|
|
283
224
|
}
|
|
284
|
-
/**
|
|
285
|
-
* Adds `pending` to {@link PendingConnectionAuthorizationsKey} if no
|
|
286
|
-
* entry for the same `connectionName` already exists on the context.
|
|
287
|
-
*
|
|
288
|
-
* Single source of truth for the dedup-by-name rule: called from
|
|
289
|
-
* `wrapConnectionToolExecute` (single connection per pending call) and
|
|
290
|
-
* from the fan-out loop inside {@link executeConnectionSearch} (many
|
|
291
|
-
* connections per search call).
|
|
292
|
-
*/
|
|
293
|
-
export function recordPendingAuthorization(ctx, pending) {
|
|
294
|
-
const existing = ctx.get(PendingConnectionAuthorizationsKey) ?? [];
|
|
295
|
-
if (existing.some((entry) => entry.connectionName === pending.connectionName)) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
ctx.set(PendingConnectionAuthorizationsKey, [...existing, pending]);
|
|
299
|
-
}
|
|
@@ -24,12 +24,9 @@ export declare function resolveConnectionToolsFromState(registry: ConnectionRegi
|
|
|
24
24
|
*/
|
|
25
25
|
type ToolExecuteFn = (args: unknown, options: unknown) => Promise<unknown>;
|
|
26
26
|
/**
|
|
27
|
-
* Wraps one connection tool's `execute` to
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* Interactive auth records a pending retry and returns a placeholder
|
|
32
|
-
* result; non-interactive auth returns a model-visible retryable error.
|
|
27
|
+
* Wraps one connection tool's `execute` to record a pending retry and
|
|
28
|
+
* return a placeholder when interactive auth is required. Non-interactive
|
|
29
|
+
* connections let the error propagate — the model sees the failure.
|
|
33
30
|
*/
|
|
34
31
|
export declare function wrapConnectionToolExecute(params: {
|
|
35
32
|
readonly connectionDefinition: ResolvedConnectionDefinition | undefined;
|
|
@@ -2,7 +2,7 @@ import { loadContext } from "#context/container.js";
|
|
|
2
2
|
import { isConnectionAuthorizationRequiredError } from "#public/connections/errors.js";
|
|
3
3
|
import { isObject } from "#shared/guards.js";
|
|
4
4
|
import { supportsInteractiveAuthorization, } from "#runtime/connections/types.js";
|
|
5
|
-
import {
|
|
5
|
+
import {} from "#runtime/framework-tools/connection-search.js";
|
|
6
6
|
import { appendPendingConnectionToolCalls, CONNECTION_AUTHORIZATION_PLACEHOLDER, PendingConnectionToolCallsKey, } from "#runtime/framework-tools/pending-connection-tool-calls.js";
|
|
7
7
|
/**
|
|
8
8
|
* Builds the qualified tool name for a connection tool.
|
|
@@ -59,12 +59,9 @@ export async function resolveConnectionToolsFromState(registry, discovered, inpu
|
|
|
59
59
|
return result;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* Wraps one connection tool's `execute` to
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* Interactive auth records a pending retry and returns a placeholder
|
|
67
|
-
* result; non-interactive auth returns a model-visible retryable error.
|
|
62
|
+
* Wraps one connection tool's `execute` to record a pending retry and
|
|
63
|
+
* return a placeholder when interactive auth is required. Non-interactive
|
|
64
|
+
* connections let the error propagate — the model sees the failure.
|
|
68
65
|
*/
|
|
69
66
|
export function wrapConnectionToolExecute(params) {
|
|
70
67
|
const { connectionDefinition, connectionName, originalExecute, toolName } = params;
|
|
@@ -80,12 +77,8 @@ export function wrapConnectionToolExecute(params) {
|
|
|
80
77
|
}
|
|
81
78
|
const toolCallId = readToolCallId(options);
|
|
82
79
|
const isInteractive = supportsInteractiveAuthorization(connectionDefinition?.authorization);
|
|
83
|
-
const ctx = loadContext();
|
|
84
|
-
recordPendingAuthorization(ctx, {
|
|
85
|
-
connectionName,
|
|
86
|
-
description: connectionDefinition?.description ?? connectionName,
|
|
87
|
-
});
|
|
88
80
|
if (isInteractive && toolCallId !== undefined) {
|
|
81
|
+
const ctx = loadContext();
|
|
89
82
|
const existing = ctx.get(PendingConnectionToolCallsKey);
|
|
90
83
|
ctx.set(PendingConnectionToolCallsKey, appendPendingConnectionToolCalls(existing, [
|
|
91
84
|
{
|
|
@@ -98,7 +91,7 @@ export function wrapConnectionToolExecute(params) {
|
|
|
98
91
|
]));
|
|
99
92
|
return CONNECTION_AUTHORIZATION_PLACEHOLDER;
|
|
100
93
|
}
|
|
101
|
-
|
|
94
|
+
throw err;
|
|
102
95
|
}
|
|
103
96
|
};
|
|
104
97
|
}
|
|
@@ -14,7 +14,8 @@ interface FrameworkToolConfig {
|
|
|
14
14
|
export declare function getFrameworkToolDefinitions(config: FrameworkToolConfig): readonly ResolvedToolDefinition[];
|
|
15
15
|
/**
|
|
16
16
|
* Returns the names of every framework-provided tool the framework knows
|
|
17
|
-
* about, regardless of whether the current agent
|
|
17
|
+
* about, regardless of whether the current agent gates any of them on
|
|
18
|
+
* runtime configuration.
|
|
18
19
|
*
|
|
19
20
|
* Used by the graph resolver to validate `disableTool(name)` arguments —
|
|
20
21
|
* disabling a name that does not match any known framework tool is treated
|
|
@@ -40,7 +40,8 @@ export function getFrameworkToolDefinitions(config) {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Returns the names of every framework-provided tool the framework knows
|
|
43
|
-
* about, regardless of whether the current agent
|
|
43
|
+
* about, regardless of whether the current agent gates any of them on
|
|
44
|
+
* runtime configuration.
|
|
44
45
|
*
|
|
45
46
|
* Used by the graph resolver to validate `disableTool(name)` arguments —
|
|
46
47
|
* disabling a name that does not match any known framework tool is treated
|
|
@@ -1,15 +1,2 @@
|
|
|
1
1
|
import type { ResolvedToolDefinition } from "#runtime/types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Typed input accepted by {@link executeLoadSkillTool}.
|
|
4
|
-
*/
|
|
5
|
-
export interface LoadSkillInput {
|
|
6
|
-
readonly skill: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Executes the `load_skill` tool.
|
|
10
|
-
*
|
|
11
|
-
* Reads the requested skill's `SKILL.md` from the active sandbox and
|
|
12
|
-
* returns it as the tool result.
|
|
13
|
-
*/
|
|
14
|
-
export declare function executeLoadSkillTool(args: LoadSkillInput): Promise<unknown>;
|
|
15
2
|
export declare const SKILL_TOOL_DEFINITION: ResolvedToolDefinition;
|