veryfront 0.1.217 → 0.1.219
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/esm/cli/commands/init/config-generator.d.ts +13 -1
- package/esm/cli/commands/init/config-generator.d.ts.map +1 -1
- package/esm/cli/commands/init/config-generator.js +15 -1
- package/esm/cli/commands/init/init-command.d.ts.map +1 -1
- package/esm/cli/commands/init/init-command.js +9 -2
- package/esm/deno.d.ts +1 -3
- package/esm/deno.js +6 -5
- package/esm/src/agent/ag-ui-detached-start.d.ts +84 -0
- package/esm/src/agent/ag-ui-detached-start.d.ts.map +1 -0
- package/esm/src/agent/ag-ui-detached-start.js +273 -0
- package/esm/src/agent/index.d.ts +1 -0
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +1 -0
- package/esm/src/extensions/interfaces/auth-provider.d.ts +30 -3
- package/esm/src/extensions/interfaces/auth-provider.d.ts.map +1 -1
- package/esm/src/extensions/interfaces/index.d.ts +2 -1
- package/esm/src/extensions/interfaces/index.d.ts.map +1 -1
- package/esm/src/extensions/interfaces/token-cache-store.d.ts +56 -0
- package/esm/src/extensions/interfaces/token-cache-store.d.ts.map +1 -0
- package/esm/src/extensions/interfaces/token-cache-store.js +12 -0
- package/esm/src/extensions/recommendations.d.ts.map +1 -1
- package/esm/src/extensions/recommendations.js +1 -0
- package/esm/src/integrations/_data.js +1 -1
- package/esm/src/integrations/schema.d.ts +1 -0
- package/esm/src/integrations/schema.d.ts.map +1 -1
- package/esm/src/integrations/schema.js +8 -0
- package/esm/src/proxy/cache/index.d.ts +1 -1
- package/esm/src/proxy/cache/index.d.ts.map +1 -1
- package/esm/src/proxy/cache/index.js +25 -15
- package/esm/src/proxy/cache/tracing-cache.d.ts +31 -0
- package/esm/src/proxy/cache/tracing-cache.d.ts.map +1 -0
- package/esm/src/proxy/cache/tracing-cache.js +44 -0
- package/esm/src/proxy/cache/types.d.ts +1 -1
- package/esm/src/proxy/cache/types.js +1 -1
- package/esm/src/proxy/handler.d.ts +7 -0
- package/esm/src/proxy/handler.d.ts.map +1 -1
- package/esm/src/proxy/handler.js +50 -29
- package/esm/src/server/runtime-handler/request-tracker.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/request-tracker.js +5 -6
- package/esm/src/server/runtime-handler/request-utils.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/request-utils.js +1 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +66 -35
- package/src/cli/commands/init/config-generator.ts +33 -0
- package/src/cli/commands/init/init-command.ts +9 -2
- package/src/deno.js +6 -5
- package/src/src/agent/ag-ui-detached-start.ts +397 -0
- package/src/src/agent/index.ts +8 -0
- package/src/src/extensions/interfaces/auth-provider.ts +35 -3
- package/src/src/extensions/interfaces/index.ts +10 -1
- package/src/src/extensions/interfaces/token-cache-store.ts +58 -0
- package/src/src/extensions/recommendations.ts +1 -0
- package/src/src/integrations/_data.ts +1 -1
- package/src/src/integrations/schema.ts +8 -0
- package/src/src/proxy/cache/index.ts +27 -15
- package/src/src/proxy/cache/tracing-cache.ts +77 -0
- package/src/src/proxy/cache/types.ts +1 -1
- package/src/src/proxy/handler.ts +57 -31
- package/src/src/server/runtime-handler/request-tracker.ts +5 -7
- package/src/src/server/runtime-handler/request-utils.ts +1 -0
- package/src/src/utils/version-constant.ts +1 -1
- package/esm/src/proxy/cache/redis-cache.d.ts +0 -25
- package/esm/src/proxy/cache/redis-cache.d.ts.map +0 -1
- package/esm/src/proxy/cache/redis-cache.js +0 -219
- package/src/src/proxy/cache/redis-cache.ts +0 -255
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface CreatePackageJsonOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Selected integrations whose `connector.json#npmDependencies` should be
|
|
4
|
+
* merged into the generated project's `package.json#dependencies`.
|
|
5
|
+
* First declaration wins on version collisions; framework pins
|
|
6
|
+
* (react, react-dom, veryfront, zod) always take precedence.
|
|
7
|
+
*/
|
|
8
|
+
integrations?: Array<{
|
|
9
|
+
name: string;
|
|
10
|
+
npmDependencies?: Record<string, string>;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createPackageJson(projectDir: string, projectName?: string, options?: CreatePackageJsonOptions): Promise<void>;
|
|
2
14
|
//# sourceMappingURL=config-generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-generator.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/config-generator.ts"],"names":[],"mappings":"AAOA,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"config-generator.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/config-generator.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C,CAAC,CAAC;CACJ;AAED,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,IAAI,CAAC,CA0Df"}
|
|
@@ -3,7 +3,7 @@ import { join } from "../../../src/platform/compat/path/index.js";
|
|
|
3
3
|
import { createFileSystem } from "../../../src/platform/index.js";
|
|
4
4
|
// Keep init scaffold aligned with current framework default React major/minor.
|
|
5
5
|
const DEFAULT_INIT_REACT_VERSION = "19.1.1";
|
|
6
|
-
export async function createPackageJson(projectDir, projectName) {
|
|
6
|
+
export async function createPackageJson(projectDir, projectName, options = {}) {
|
|
7
7
|
const fs = createFileSystem();
|
|
8
8
|
// Read any existing package.json (e.g. from template) to merge dependencies
|
|
9
9
|
let templateDeps = {};
|
|
@@ -12,6 +12,19 @@ export async function createPackageJson(projectDir, projectName) {
|
|
|
12
12
|
const existing = JSON.parse(await fs.readTextFile(pkgPath));
|
|
13
13
|
templateDeps = existing.dependencies ?? {};
|
|
14
14
|
}
|
|
15
|
+
// Merge per-integration deps. First declaration wins; collisions are logged.
|
|
16
|
+
const integrationDeps = {};
|
|
17
|
+
for (const integration of options.integrations ?? []) {
|
|
18
|
+
for (const [pkg, range] of Object.entries(integration.npmDependencies ?? {})) {
|
|
19
|
+
if (pkg in integrationDeps) {
|
|
20
|
+
if (integrationDeps[pkg] !== range) {
|
|
21
|
+
logger.warn(`[init] ${integration.name} requested ${pkg}@${range} but ${pkg}@${integrationDeps[pkg]} is already pinned by an earlier integration - keeping the earlier pin`);
|
|
22
|
+
}
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
integrationDeps[pkg] = range;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
15
28
|
const dirName = projectDir.split(/[/\\]/).pop();
|
|
16
29
|
const packageJson = {
|
|
17
30
|
name: projectName ?? dirName ?? "veryfront-project",
|
|
@@ -27,6 +40,7 @@ export async function createPackageJson(projectDir, projectName) {
|
|
|
27
40
|
},
|
|
28
41
|
dependencies: {
|
|
29
42
|
...templateDeps,
|
|
43
|
+
...integrationDeps,
|
|
30
44
|
react: `^${DEFAULT_INIT_REACT_VERSION}`,
|
|
31
45
|
"react-dom": `^${DEFAULT_INIT_REACT_VERSION}`,
|
|
32
46
|
veryfront: `^${VERSION}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/init-command.ts"],"names":[],"mappings":"AAAA;;;iCAGiC;AAUjC,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,YAAY,CAAC;AAmK5D;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"init-command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/init-command.ts"],"names":[],"mappings":"AAAA;;;iCAGiC;AAUjC,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,YAAY,CAAC;AAmK5D;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAkYrE"}
|
|
@@ -210,6 +210,7 @@ export async function initCommand(options) {
|
|
|
210
210
|
}
|
|
211
211
|
const allEnvVars = templateConfig?.envVars ? [...templateConfig.envVars] : [];
|
|
212
212
|
const featureTips = [];
|
|
213
|
+
let loadedIntegrations = [];
|
|
213
214
|
if (features.length) {
|
|
214
215
|
const { ordered, errors } = await resolveFeatures(features);
|
|
215
216
|
if (errors.length) {
|
|
@@ -242,7 +243,8 @@ export async function initCommand(options) {
|
|
|
242
243
|
const baseConfig = await loadIntegrationBaseConfig();
|
|
243
244
|
if (baseConfig?.envVars)
|
|
244
245
|
allEnvVars.push(...baseConfig.envVars);
|
|
245
|
-
const { integrations:
|
|
246
|
+
const { integrations: resolvedIntegrations, files: integrationFiles, errors: integrationErrors, } = await loadIntegrations(integrations);
|
|
247
|
+
loadedIntegrations = resolvedIntegrations;
|
|
246
248
|
if (integrationErrors.length) {
|
|
247
249
|
for (const error of integrationErrors)
|
|
248
250
|
logger.warn(error);
|
|
@@ -280,7 +282,12 @@ export async function initCommand(options) {
|
|
|
280
282
|
}
|
|
281
283
|
// Skip in quiet/TUI mode since local dev uses CDN and package.json can cause hydration issues
|
|
282
284
|
if (!options.quiet) {
|
|
283
|
-
await createPackageJson(projectDir, projectName
|
|
285
|
+
await createPackageJson(projectDir, projectName, {
|
|
286
|
+
integrations: loadedIntegrations.map((integration) => ({
|
|
287
|
+
name: integration.config.name,
|
|
288
|
+
npmDependencies: integration.config.npmDependencies,
|
|
289
|
+
})),
|
|
290
|
+
});
|
|
284
291
|
}
|
|
285
292
|
if (allEnvVars.length) {
|
|
286
293
|
const envResult = await promptForEnvVars(dedupeEnvVars(allEnvVars), {
|
package/esm/deno.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare namespace _default {
|
|
|
3
3
|
let version: string;
|
|
4
4
|
let license: string;
|
|
5
5
|
let nodeModulesDir: string;
|
|
6
|
+
let workspace: string[];
|
|
6
7
|
let exclude: string[];
|
|
7
8
|
let exports: {
|
|
8
9
|
".": string;
|
|
@@ -250,9 +251,6 @@ declare namespace _default {
|
|
|
250
251
|
"tailwindcss/plugin": string;
|
|
251
252
|
"tailwindcss/defaultTheme": string;
|
|
252
253
|
"tailwindcss/colors": string;
|
|
253
|
-
redis: string;
|
|
254
|
-
pg: string;
|
|
255
|
-
jose: string;
|
|
256
254
|
"@opentelemetry/api": string;
|
|
257
255
|
"@opentelemetry/core": string;
|
|
258
256
|
"@opentelemetry/context-async-hooks": string;
|
package/esm/deno.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.219",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"nodeModulesDir": "auto",
|
|
6
|
+
"workspace": [
|
|
7
|
+
"./extensions/ext-redis"
|
|
8
|
+
],
|
|
6
9
|
"exclude": [
|
|
7
10
|
"npm/",
|
|
8
11
|
"dist/",
|
|
@@ -12,7 +15,8 @@ export default {
|
|
|
12
15
|
"data/",
|
|
13
16
|
".deno_cache/",
|
|
14
17
|
"cli/templates/files/",
|
|
15
|
-
"cli/templates/integrations/"
|
|
18
|
+
"cli/templates/integrations/",
|
|
19
|
+
"extensions/"
|
|
16
20
|
],
|
|
17
21
|
"exports": {
|
|
18
22
|
".": "./src/index.ts",
|
|
@@ -260,9 +264,6 @@ export default {
|
|
|
260
264
|
"tailwindcss/plugin": "https://esm.sh/tailwindcss@4.2.2/plugin",
|
|
261
265
|
"tailwindcss/defaultTheme": "https://esm.sh/tailwindcss@4.2.2/defaultTheme",
|
|
262
266
|
"tailwindcss/colors": "https://esm.sh/tailwindcss@4.2.2/colors",
|
|
263
|
-
"redis": "npm:redis@5.11.0",
|
|
264
|
-
"pg": "npm:pg@8.13.1",
|
|
265
|
-
"jose": "npm:jose@5.9.6",
|
|
266
267
|
"@opentelemetry/api": "npm:@opentelemetry/api@1.9.0",
|
|
267
268
|
"@opentelemetry/core": "npm:@opentelemetry/core@2.6.0",
|
|
268
269
|
"@opentelemetry/context-async-hooks": "npm:@opentelemetry/context-async-hooks@2.6.0",
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type RunResumeSessionManager } from "./runtime/index.js";
|
|
3
|
+
import type { Agent } from "./types.js";
|
|
4
|
+
type AgUiResumeValue = {
|
|
5
|
+
result: unknown;
|
|
6
|
+
isError: boolean;
|
|
7
|
+
};
|
|
8
|
+
type AgUiContextValue = Record<string, unknown> | ((request: Request) => Record<string, unknown> | Promise<Record<string, unknown>>);
|
|
9
|
+
export declare const AgUiDetachedStartRequestSchema: z.ZodObject<{
|
|
10
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
role: z.ZodEnum<{
|
|
13
|
+
tool: "tool";
|
|
14
|
+
user: "user";
|
|
15
|
+
assistant: "assistant";
|
|
16
|
+
system: "system";
|
|
17
|
+
}>;
|
|
18
|
+
parts: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
19
|
+
type: z.ZodString;
|
|
20
|
+
}, z.core.$loose>>>;
|
|
21
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
22
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
description: z.ZodOptional<z.ZodString>;
|
|
27
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
28
|
+
}, z.core.$strip>>>;
|
|
29
|
+
context: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
30
|
+
type: z.ZodLiteral<"text">;
|
|
31
|
+
title: z.ZodOptional<z.ZodString>;
|
|
32
|
+
text: z.ZodString;
|
|
33
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<"json">;
|
|
35
|
+
title: z.ZodOptional<z.ZodString>;
|
|
36
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
37
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
38
|
+
type: z.ZodLiteral<"resource">;
|
|
39
|
+
title: z.ZodOptional<z.ZodString>;
|
|
40
|
+
uri: z.ZodString;
|
|
41
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
42
|
+
text: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>], "type">>>;
|
|
44
|
+
forwardedProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
45
|
+
model: z.ZodOptional<z.ZodString>;
|
|
46
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
threadId: z.ZodString;
|
|
48
|
+
runId: z.ZodString;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export declare const AgUiDetachedStartAcceptedSchema: z.ZodObject<{
|
|
51
|
+
accepted: z.ZodLiteral<true>;
|
|
52
|
+
duplicate: z.ZodBoolean;
|
|
53
|
+
runId: z.ZodString;
|
|
54
|
+
threadId: z.ZodString;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export type AgUiDetachedStartRequest = z.infer<typeof AgUiDetachedStartRequestSchema>;
|
|
57
|
+
export type AgUiDetachedStartAccepted = z.infer<typeof AgUiDetachedStartAcceptedSchema>;
|
|
58
|
+
export interface AgUiDetachedStartHandlerOptions {
|
|
59
|
+
agent: Agent;
|
|
60
|
+
sessionManager: RunResumeSessionManager<AgUiResumeValue>;
|
|
61
|
+
context?: AgUiContextValue;
|
|
62
|
+
onAccepted?: (input: {
|
|
63
|
+
request: AgUiDetachedStartRequest;
|
|
64
|
+
runId: string;
|
|
65
|
+
threadId: string;
|
|
66
|
+
}) => Promise<void> | void;
|
|
67
|
+
onDuplicate?: (input: {
|
|
68
|
+
request: AgUiDetachedStartRequest;
|
|
69
|
+
runId: string;
|
|
70
|
+
threadId: string;
|
|
71
|
+
}) => Promise<void> | void;
|
|
72
|
+
onFinish?: (input: {
|
|
73
|
+
runId: string;
|
|
74
|
+
threadId: string;
|
|
75
|
+
}) => Promise<void> | void;
|
|
76
|
+
onError?: (input: {
|
|
77
|
+
runId: string;
|
|
78
|
+
threadId: string;
|
|
79
|
+
error: unknown;
|
|
80
|
+
}) => Promise<void> | void;
|
|
81
|
+
}
|
|
82
|
+
export declare function createAgUiDetachedStartHandler(options: AgUiDetachedStartHandlerOptions): (requestOrCtx: unknown) => Promise<Response>;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=ag-ui-detached-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ag-ui-detached-start.d.ts","sourceRoot":"","sources":["../../../src/src/agent/ag-ui-detached-start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAW,MAAM,YAAY,CAAC;AAMjD,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,gBAAgB,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,M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G;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,+BAA+B,GACvC,CAAC,YAAY,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CA2G9C"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { INVALID_ARGUMENT } from "../errors/index.js";
|
|
3
|
+
import { SKILL_TOOL_IDS } from "../skill/types.js";
|
|
4
|
+
import { toolRegistry } from "../tool/index.js";
|
|
5
|
+
import { streamDataStreamEvents } from "./data-stream.js";
|
|
6
|
+
import { AgUiRequestSchema } from "./ag-ui-handler.js";
|
|
7
|
+
import { AgentRuntime, RunAlreadyExistsError, } from "./runtime/index.js";
|
|
8
|
+
const AGENT_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
9
|
+
const AG_UI_DETACHED_RUN_ID_SCHEMA = z.string().min(1).max(128).regex(AGENT_ID_PATTERN);
|
|
10
|
+
const MAX_TEXT_PART_LENGTH = 10_000;
|
|
11
|
+
function isRecord(value) {
|
|
12
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function normalizeToolArgs(part) {
|
|
15
|
+
if (isRecord(part.args))
|
|
16
|
+
return part.args;
|
|
17
|
+
if (isRecord(part.input))
|
|
18
|
+
return part.input;
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
function normalizeMessagePart(part) {
|
|
22
|
+
if (part.type === "text" && typeof part.text === "string" &&
|
|
23
|
+
part.text.length <= MAX_TEXT_PART_LENGTH) {
|
|
24
|
+
return { type: "text", text: part.text };
|
|
25
|
+
}
|
|
26
|
+
if (part.type === "tool_call" && typeof part.id === "string" && typeof part.name === "string") {
|
|
27
|
+
return {
|
|
28
|
+
type: "tool-call",
|
|
29
|
+
toolCallId: part.id,
|
|
30
|
+
toolName: part.name,
|
|
31
|
+
args: normalizeToolArgs(part),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (part.type === "tool-call" &&
|
|
35
|
+
typeof part.toolCallId === "string" &&
|
|
36
|
+
typeof part.toolName === "string") {
|
|
37
|
+
return {
|
|
38
|
+
type: "tool-call",
|
|
39
|
+
toolCallId: part.toolCallId,
|
|
40
|
+
toolName: part.toolName,
|
|
41
|
+
args: normalizeToolArgs(part),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (typeof part.type === "string" &&
|
|
45
|
+
part.type.startsWith("tool-") &&
|
|
46
|
+
part.type !== "tool-result" &&
|
|
47
|
+
typeof part.toolCallId === "string" &&
|
|
48
|
+
typeof part.toolName === "string") {
|
|
49
|
+
return {
|
|
50
|
+
type: part.type,
|
|
51
|
+
toolCallId: part.toolCallId,
|
|
52
|
+
toolName: part.toolName,
|
|
53
|
+
args: normalizeToolArgs(part),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (part.type === "tool_result" && typeof part.tool_call_id === "string") {
|
|
57
|
+
return {
|
|
58
|
+
type: "tool-result",
|
|
59
|
+
toolCallId: part.tool_call_id,
|
|
60
|
+
toolName: typeof part.tool_name === "string" ? part.tool_name : "unknown",
|
|
61
|
+
result: "output" in part ? part.output : undefined,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (part.type === "tool-result" && typeof part.toolCallId === "string") {
|
|
65
|
+
return {
|
|
66
|
+
type: "tool-result",
|
|
67
|
+
toolCallId: part.toolCallId,
|
|
68
|
+
toolName: typeof part.toolName === "string" ? part.toolName : "unknown",
|
|
69
|
+
result: "result" in part ? part.result : undefined,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function normalizeMessages(messages) {
|
|
75
|
+
return messages.map((message) => ({
|
|
76
|
+
id: message.id,
|
|
77
|
+
role: message.role,
|
|
78
|
+
parts: message.parts
|
|
79
|
+
.map((part) => normalizeMessagePart(part))
|
|
80
|
+
.filter((part) => part !== null),
|
|
81
|
+
...(message.createdAt ? { timestamp: Date.parse(message.createdAt) || undefined } : {}),
|
|
82
|
+
...(message.metadata ? { metadata: message.metadata } : {}),
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
function isRequest(obj) {
|
|
86
|
+
return (typeof obj === "object" &&
|
|
87
|
+
obj !== null &&
|
|
88
|
+
"json" in obj &&
|
|
89
|
+
typeof obj.json === "function" &&
|
|
90
|
+
"url" in obj &&
|
|
91
|
+
typeof obj.url === "string" &&
|
|
92
|
+
"method" in obj &&
|
|
93
|
+
typeof obj.method === "string");
|
|
94
|
+
}
|
|
95
|
+
function extractRequest(requestOrCtx) {
|
|
96
|
+
if (isRequest(requestOrCtx))
|
|
97
|
+
return requestOrCtx;
|
|
98
|
+
if (typeof requestOrCtx === "object" && requestOrCtx !== null && "request" in requestOrCtx) {
|
|
99
|
+
const candidate = requestOrCtx.request;
|
|
100
|
+
if (isRequest(candidate))
|
|
101
|
+
return candidate;
|
|
102
|
+
}
|
|
103
|
+
throw INVALID_ARGUMENT.create({
|
|
104
|
+
detail: "Invalid handler argument: expected Request or APIContext",
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function buildStreamContext(request, baseContext, threadId, runId) {
|
|
108
|
+
return {
|
|
109
|
+
...baseContext,
|
|
110
|
+
threadId,
|
|
111
|
+
runId,
|
|
112
|
+
agUi: {
|
|
113
|
+
context: request.context,
|
|
114
|
+
forwardedProps: request.forwardedProps,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function createInjectedAgUiTool(runId, tool, sessionManager) {
|
|
119
|
+
return {
|
|
120
|
+
id: tool.name,
|
|
121
|
+
type: "function",
|
|
122
|
+
description: tool.description ?? tool.name,
|
|
123
|
+
inputSchema: z.record(z.string(), z.unknown()),
|
|
124
|
+
inputSchemaJson: (tool.parameters ??
|
|
125
|
+
{ type: "object", properties: {}, additionalProperties: true }),
|
|
126
|
+
execute: async (_input, context) => {
|
|
127
|
+
const toolCallId = typeof context?.toolCallId === "string" ? context.toolCallId : null;
|
|
128
|
+
if (!toolCallId) {
|
|
129
|
+
throw new Error(`Missing toolCallId for injected tool "${tool.name}"`);
|
|
130
|
+
}
|
|
131
|
+
sessionManager.prepareForSignal(runId, toolCallId);
|
|
132
|
+
const submitted = await sessionManager.waitForSignal(runId, toolCallId);
|
|
133
|
+
if (submitted.isError) {
|
|
134
|
+
throw new Error(typeof submitted.result === "string"
|
|
135
|
+
? submitted.result
|
|
136
|
+
: JSON.stringify(submitted.result));
|
|
137
|
+
}
|
|
138
|
+
return submitted.result;
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function buildMergedTools(agent, request, sessionManager) {
|
|
143
|
+
const injectedTools = Object.fromEntries(request.tools.map((tool) => [
|
|
144
|
+
tool.name,
|
|
145
|
+
createInjectedAgUiTool(request.runId, tool, sessionManager),
|
|
146
|
+
]));
|
|
147
|
+
if (!agent.config.tools) {
|
|
148
|
+
return Object.keys(injectedTools).length > 0 ? injectedTools : undefined;
|
|
149
|
+
}
|
|
150
|
+
if (agent.config.tools === true) {
|
|
151
|
+
const merged = {};
|
|
152
|
+
for (const [toolId] of toolRegistry.getAll()) {
|
|
153
|
+
if (!agent.config.skills && SKILL_TOOL_IDS.has(toolId)) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
merged[toolId] = true;
|
|
157
|
+
}
|
|
158
|
+
return { ...merged, ...injectedTools };
|
|
159
|
+
}
|
|
160
|
+
return { ...agent.config.tools, ...injectedTools };
|
|
161
|
+
}
|
|
162
|
+
async function resolveContextValue(value, request) {
|
|
163
|
+
if (typeof value === "function") {
|
|
164
|
+
return await value(request);
|
|
165
|
+
}
|
|
166
|
+
return value ?? {};
|
|
167
|
+
}
|
|
168
|
+
function scheduleDetachedTask(requestOrCtx, task) {
|
|
169
|
+
if (typeof requestOrCtx === "object" &&
|
|
170
|
+
requestOrCtx !== null &&
|
|
171
|
+
"waitUntil" in requestOrCtx &&
|
|
172
|
+
typeof requestOrCtx.waitUntil === "function") {
|
|
173
|
+
(requestOrCtx.waitUntil)(task);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
void task;
|
|
177
|
+
}
|
|
178
|
+
async function drainRuntimeStream(stream) {
|
|
179
|
+
for await (const _event of streamDataStreamEvents(stream)) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
export const AgUiDetachedStartRequestSchema = AgUiRequestSchema.extend({
|
|
184
|
+
threadId: z.string().uuid(),
|
|
185
|
+
runId: AG_UI_DETACHED_RUN_ID_SCHEMA,
|
|
186
|
+
});
|
|
187
|
+
export const AgUiDetachedStartAcceptedSchema = z.object({
|
|
188
|
+
accepted: z.literal(true),
|
|
189
|
+
duplicate: z.boolean(),
|
|
190
|
+
runId: AG_UI_DETACHED_RUN_ID_SCHEMA,
|
|
191
|
+
threadId: z.string().uuid(),
|
|
192
|
+
});
|
|
193
|
+
export function createAgUiDetachedStartHandler(options) {
|
|
194
|
+
return async function POST(requestOrCtx) {
|
|
195
|
+
const request = extractRequest(requestOrCtx);
|
|
196
|
+
try {
|
|
197
|
+
const parsed = AgUiDetachedStartRequestSchema.parse(await request.json());
|
|
198
|
+
const context = await resolveContextValue(options.context, request);
|
|
199
|
+
try {
|
|
200
|
+
const abortSignal = options.sessionManager.startRun({
|
|
201
|
+
runId: parsed.runId,
|
|
202
|
+
threadId: parsed.threadId,
|
|
203
|
+
});
|
|
204
|
+
const runtime = new AgentRuntime(options.agent.id, {
|
|
205
|
+
...options.agent.config,
|
|
206
|
+
tools: buildMergedTools(options.agent, parsed, options.sessionManager),
|
|
207
|
+
});
|
|
208
|
+
const runtimeStream = await runtime.stream(normalizeMessages(parsed.messages), buildStreamContext(parsed, context, parsed.threadId, parsed.runId), undefined, parsed.model, parsed.maxOutputTokens, abortSignal);
|
|
209
|
+
await options.onAccepted?.({
|
|
210
|
+
request: parsed,
|
|
211
|
+
runId: parsed.runId,
|
|
212
|
+
threadId: parsed.threadId,
|
|
213
|
+
});
|
|
214
|
+
const detachedTask = (async () => {
|
|
215
|
+
try {
|
|
216
|
+
await drainRuntimeStream(runtimeStream);
|
|
217
|
+
options.sessionManager.completeRun(parsed.runId);
|
|
218
|
+
await options.onFinish?.({
|
|
219
|
+
runId: parsed.runId,
|
|
220
|
+
threadId: parsed.threadId,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
options.sessionManager.failRun(parsed.runId);
|
|
225
|
+
await options.onError?.({
|
|
226
|
+
runId: parsed.runId,
|
|
227
|
+
threadId: parsed.threadId,
|
|
228
|
+
error,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
})().catch(() => undefined);
|
|
232
|
+
scheduleDetachedTask(requestOrCtx, detachedTask);
|
|
233
|
+
return Response.json({
|
|
234
|
+
accepted: true,
|
|
235
|
+
duplicate: false,
|
|
236
|
+
runId: parsed.runId,
|
|
237
|
+
threadId: parsed.threadId,
|
|
238
|
+
}, { status: 202 });
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
if (error instanceof RunAlreadyExistsError) {
|
|
242
|
+
await options.onDuplicate?.({
|
|
243
|
+
request: parsed,
|
|
244
|
+
runId: parsed.runId,
|
|
245
|
+
threadId: parsed.threadId,
|
|
246
|
+
});
|
|
247
|
+
return Response.json({
|
|
248
|
+
accepted: true,
|
|
249
|
+
duplicate: true,
|
|
250
|
+
runId: parsed.runId,
|
|
251
|
+
threadId: parsed.threadId,
|
|
252
|
+
}, { status: 202 });
|
|
253
|
+
}
|
|
254
|
+
options.sessionManager.failRun(parsed.runId);
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
if (error instanceof z.ZodError) {
|
|
260
|
+
return Response.json({
|
|
261
|
+
error: "Invalid AG-UI detached start request",
|
|
262
|
+
details: error.issues.map((issue) => ({
|
|
263
|
+
path: issue.path,
|
|
264
|
+
message: issue.message,
|
|
265
|
+
})),
|
|
266
|
+
}, { status: 400 });
|
|
267
|
+
}
|
|
268
|
+
return Response.json({
|
|
269
|
+
error: error instanceof Error ? error.message : "Internal detached start failed",
|
|
270
|
+
}, { status: 500 });
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}
|
package/esm/src/agent/index.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export { type AgUiRuntimeContextItem, AgUiRuntimeContextItemSchema, type AgUiRun
|
|
|
88
88
|
export { type AgUiBrowserEncodedEvent, type AgUiBrowserEncoderState, type AgUiBrowserRunFinishedMetadata, type AgUiRuntimeStreamEvent, createAgUiBrowserEncoderState, finalizeAgUiBrowserEvents, mapRuntimeStreamEventToAgUiBrowserEvents, } from "./ag-ui-browser-encoder.js";
|
|
89
89
|
export { mergeToolCallInput, mergeToolInputDelta, parseDataStreamSseEvents, parseToolInputObject, streamDataStreamEvents, stripLeadingEmptyObjectPlaceholder, } from "./data-stream.js";
|
|
90
90
|
export { expandAllowedRemoteToolNames, getProviderNativeToolNames, type ProviderNativeToolInventoryOptions, } from "./provider-native-tool-inventory.js";
|
|
91
|
+
export { type AgUiDetachedStartAccepted, AgUiDetachedStartAcceptedSchema, type AgUiDetachedStartHandlerOptions, type AgUiDetachedStartRequest, AgUiDetachedStartRequestSchema, createAgUiDetachedStartHandler, } from "./ag-ui-detached-start.js";
|
|
91
92
|
export { type AgUiCancelHandlerOptions, type AgUiResumeHandlerOptions, type AgUiResumeSignal, AgUiResumeSignalSchema, createAgUiCancelHandler, createAgUiResumeHandler, } from "./ag-ui-run-control.js";
|
|
92
93
|
export { type AgUiContextItem, type AgUiHandlerConfigWithAgent, type AgUiHandlerOptions, type AgUiInjectedTool, type AgUiRequest, AgUiRequestSchema, createAgUiHandler, } from "./ag-ui-handler.js";
|
|
93
94
|
export { type HumanInputField, type HumanInputFieldInput, HumanInputFieldSchema, type HumanInputOption, HumanInputOptionSchema, type HumanInputPendingRequest, HumanInputPendingRequestSchema, type HumanInputRequest, type HumanInputRequestInput, HumanInputRequestSchema, type HumanInputResult, HumanInputResultSchema, HumanInputResumeError, InvalidHumanInputResultError, waitForHumanInput, type WaitForHumanInputOptions, } from "./human-input.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,OAAO,yBAAyB,CAAC;AAGjC,YAAY,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,OAAO,IAAI,YAAY,EACvB,WAAW,EACX,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,iBAAiB,EACtB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KAA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O,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,OAAO,yBAAyB,CAAC;AAGjC,YAAY,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,OAAO,IAAI,YAAY,EACvB,WAAW,EACX,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK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BAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC"}
|
package/esm/src/agent/index.js
CHANGED
|
@@ -87,6 +87,7 @@ export { AgUiRuntimeContextItemSchema, AgUiRuntimeInjectedToolSchema, AgUiRuntim
|
|
|
87
87
|
export { createAgUiBrowserEncoderState, finalizeAgUiBrowserEvents, mapRuntimeStreamEventToAgUiBrowserEvents, } from "./ag-ui-browser-encoder.js";
|
|
88
88
|
export { mergeToolCallInput, mergeToolInputDelta, parseDataStreamSseEvents, parseToolInputObject, streamDataStreamEvents, stripLeadingEmptyObjectPlaceholder, } from "./data-stream.js";
|
|
89
89
|
export { expandAllowedRemoteToolNames, getProviderNativeToolNames, } from "./provider-native-tool-inventory.js";
|
|
90
|
+
export { AgUiDetachedStartAcceptedSchema, AgUiDetachedStartRequestSchema, createAgUiDetachedStartHandler, } from "./ag-ui-detached-start.js";
|
|
90
91
|
export { AgUiResumeSignalSchema, createAgUiCancelHandler, createAgUiResumeHandler, } from "./ag-ui-run-control.js";
|
|
91
92
|
export { AgUiRequestSchema, createAgUiHandler, } from "./ag-ui-handler.js";
|
|
92
93
|
export { HumanInputFieldSchema, HumanInputOptionSchema, HumanInputPendingRequestSchema, HumanInputRequestSchema, HumanInputResultSchema, HumanInputResumeError, InvalidHumanInputResultError, waitForHumanInput, } from "./human-input.js";
|
|
@@ -32,18 +32,45 @@ export interface VerifyOptions {
|
|
|
32
32
|
/** Additional implementation-specific options. */
|
|
33
33
|
[key: string]: unknown;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The parsed, unverified header of a JWT.
|
|
37
|
+
*
|
|
38
|
+
* Returned by {@link AuthProvider.decode}. `alg` is the signing algorithm
|
|
39
|
+
* advertised by the token (e.g. `"HS256"`, `"RS256"`); additional fields
|
|
40
|
+
* such as `kid` or `typ` may be present.
|
|
41
|
+
*/
|
|
42
|
+
export interface TokenHeader {
|
|
43
|
+
/** Signing algorithm advertised by the token header. */
|
|
44
|
+
alg?: string;
|
|
45
|
+
/** Additional header fields. */
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
35
48
|
/**
|
|
36
49
|
* AuthProvider contract interface.
|
|
37
50
|
*
|
|
38
51
|
* Implementations sign, verify, and decode authentication tokens
|
|
39
|
-
* (e.g. JWTs) for request authentication
|
|
52
|
+
* (e.g. JWTs) for request authentication, and verify third-party tokens
|
|
53
|
+
* against a remote JWKS.
|
|
40
54
|
*/
|
|
41
55
|
export interface AuthProvider {
|
|
42
56
|
/** Sign a payload into a token string. */
|
|
43
57
|
sign(payload: TokenPayload, options?: SignOptions): Promise<string>;
|
|
44
58
|
/** Verify a token and return its decoded payload. Throws on invalid tokens. */
|
|
45
59
|
verify(token: string, options?: VerifyOptions): Promise<TokenPayload>;
|
|
46
|
-
/**
|
|
47
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Verify a token against a remote JSON Web Key Set.
|
|
62
|
+
*
|
|
63
|
+
* Fetches (and caches) the JWKS at `jwksUrl`, then verifies the token's
|
|
64
|
+
* signature and claims. Throws on invalid tokens, unreachable JWKS, or
|
|
65
|
+
* `kid`/algorithm mismatch.
|
|
66
|
+
*/
|
|
67
|
+
verifyWithJwks(token: string, jwksUrl: string, options?: VerifyOptions): Promise<TokenPayload>;
|
|
68
|
+
/**
|
|
69
|
+
* Decode a token's protected header without verifying its signature.
|
|
70
|
+
*
|
|
71
|
+
* Returns `undefined` on malformed input. Useful for inspecting `alg`
|
|
72
|
+
* before choosing a verification strategy.
|
|
73
|
+
*/
|
|
74
|
+
decode(token: string): TokenHeader | undefined;
|
|
48
75
|
}
|
|
49
76
|
//# sourceMappingURL=auth-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../../../../src/src/extensions/interfaces/auth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,mCAAmC;AACnC,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,kDAAkD;IAClD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED
|
|
1
|
+
{"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../../../../src/src/extensions/interfaces/auth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,mCAAmC;AACnC,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,kDAAkD;IAClD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpE,+EAA+E;IAC/E,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACtE;;;;;;OAMG;IACH,cAAc,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;CAChD"}
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
import "../../../_dnt.polyfills.js";
|
|
9
9
|
export type { BundleOptions, BundleOutput, Bundler, BundleResult, BundlerPlugin, BundlerPluginBuild, TransformOptions, TransformResult, } from "./bundler.js";
|
|
10
10
|
export type { CacheStore } from "./cache-store.js";
|
|
11
|
+
export type { TokenCacheEntry, TokenCacheStats, TokenCacheStore } from "./token-cache-store.js";
|
|
11
12
|
export type { CSSProcessOptions, CSSProcessor, CSSProcessResult } from "./css-processor.js";
|
|
12
13
|
export type { ContentTransformer, ContentTransformOptions, ContentTransformResult, } from "./content-transformer.js";
|
|
13
14
|
export type { DatabaseClient, QueryResult } from "./database-client.js";
|
|
14
|
-
export type { AuthProvider, SignOptions, TokenPayload, VerifyOptions } from "./auth-provider.js";
|
|
15
|
+
export type { AuthProvider, SignOptions, TokenHeader, TokenPayload, VerifyOptions, } from "./auth-provider.js";
|
|
15
16
|
export type { SpanData, TracingExporter } from "./tracing-exporter.js";
|
|
16
17
|
export type { AIModelProvider, ChatMessage, CompletionOptions, CompletionResult, ContentPart, StreamChunk, ToolDefinition, } from "./ai-model-provider.js";
|
|
17
18
|
export type { EmbeddingOptions, EmbeddingProvider, EmbeddingResult } from "./embedding-provider.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/extensions/interfaces/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,4BAA4B,CAAC;AAEpC,YAAY,EACV,aAAa,EACb,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,aAAa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