veryfront 0.1.512 → 0.1.513

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.
Files changed (32) hide show
  1. package/README.md +46 -5
  2. package/esm/deno.d.ts +0 -4
  3. package/esm/deno.js +1 -5
  4. package/esm/src/agent/agent-service-config.d.ts +54 -0
  5. package/esm/src/agent/agent-service-config.d.ts.map +1 -1
  6. package/esm/src/agent/agent-service-config.js +24 -0
  7. package/esm/src/agent/agent-service-registration.d.ts +110 -0
  8. package/esm/src/agent/agent-service-registration.d.ts.map +1 -0
  9. package/esm/src/agent/agent-service-registration.js +228 -0
  10. package/esm/src/agent/agent-service-runtime.d.ts +3 -1
  11. package/esm/src/agent/agent-service-runtime.d.ts.map +1 -1
  12. package/esm/src/agent/agent-service-runtime.js +17 -2
  13. package/esm/src/agent/index.d.ts +1 -0
  14. package/esm/src/agent/index.d.ts.map +1 -1
  15. package/esm/src/agent/index.js +1 -0
  16. package/esm/src/agent/veryfront-cloud-agent-service.d.ts +1 -0
  17. package/esm/src/agent/veryfront-cloud-agent-service.d.ts.map +1 -1
  18. package/esm/src/agent/veryfront-cloud-agent-service.js +70 -8
  19. package/esm/src/oauth/providers/base.d.ts +10 -0
  20. package/esm/src/oauth/providers/base.d.ts.map +1 -1
  21. package/esm/src/oauth/providers/base.js +32 -1
  22. package/esm/src/utils/version-constant.d.ts +1 -1
  23. package/esm/src/utils/version-constant.js +1 -1
  24. package/package.json +1 -1
  25. package/src/deno.js +1 -5
  26. package/src/src/agent/agent-service-config.ts +23 -0
  27. package/src/src/agent/agent-service-registration.ts +320 -0
  28. package/src/src/agent/agent-service-runtime.ts +25 -2
  29. package/src/src/agent/index.ts +15 -0
  30. package/src/src/agent/veryfront-cloud-agent-service.ts +82 -8
  31. package/src/src/oauth/providers/base.ts +33 -1
  32. package/src/src/utils/version-constant.ts +1 -1
package/README.md CHANGED
@@ -12,24 +12,34 @@ It gives you agents, tools, workflows, and a complete React rendering stack in a
12
12
 
13
13
  Purpose-built for TypeScript and React, Veryfront gives you everything you need to build agentic full-stack applications out-of-the-box.
14
14
 
15
- - [**Agents**](https://veryfront.com/docs/code/guides/agents) — Build autonomous agents with model routing, system prompts, hosted execution helpers, and tool calling. Agents reason about goals and iterate until they reach a final answer.
15
+ - [**Agents**](https://veryfront.com/docs/code/guides/agents) — Build autonomous agents with model routing, system prompts, hosted execution, and tool calling. Agents reason about goals and iterate until they reach a final answer. Supports AG-UI streaming, multi-agent composition, and hosted child-run orchestration.
16
16
 
17
17
  - [**Tools**](https://veryfront.com/docs/code/guides/tools) — Define Zod-validated functions that agents can call. Tools are auto-discovered from the file system with no registration needed.
18
18
 
19
- - [**Workflows**](https://veryfront.com/docs/code/guides/workflows) — Orchestrate multi-step AI pipelines with branching, parallelism, and human-in-the-loop approval gates.
19
+ - [**Workflows**](https://veryfront.com/docs/code/guides/workflows) — Orchestrate multi-step AI pipelines with branching, parallelism, human-in-the-loop approval gates, and durable crash recovery via Redis checkpoints.
20
+
21
+ - [**Skills**](https://veryfront.com/docs/code/guides/skills) — Project-level agent capabilities defined as `SKILL.md` files following the agentskills.io specification. Skills provide prompt augmentation, tool allowlists, and script execution.
20
22
 
21
23
  - [**Jobs & Cron Jobs**](https://veryfront.com/docs/code/guides/jobs) — Run durable project-scoped background work now or on a schedule through the Veryfront platform.
22
24
 
23
- - [**Multi-Agent**](https://veryfront.com/docs/code/guides/multi-agent) — Compose agents that delegate to each other as tools for complex, coordinated tasks.
25
+ - [**Tasks**](https://veryfront.com/docs/code/guides/tasks) — File-based background task definitions discovered automatically and executable via the jobs system.
26
+
27
+ - [**Multi-Agent**](https://veryfront.com/docs/code/guides/multi-agent) — Compose agents that delegate to each other as tools for complex, coordinated tasks. AG-UI control-plane for hosted agent orchestration.
28
+
29
+ - [**Memory & Streaming**](https://veryfront.com/docs/code/guides/memory-and-streaming) — Give agents conversation history and streaming responses. Built-in chat UI components for React with AG-UI protocol support.
24
30
 
25
- - [**Memory & Streaming**](https://veryfront.com/docs/code/guides/memory-and-streaming) — Give agents conversation history and streaming responses. Built-in chat UI components for React.
31
+ - [**MCP Server**](https://veryfront.com/docs/code/guides/mcp-server) — Expose tools, prompts, and resources via the Model Context Protocol. Includes SSE transport, session management, and elicitation support.
26
32
 
27
- - [**MCP Server**](https://veryfront.com/docs/code/guides/mcp-server) — Expose tools, prompts, and resources via the Model Context Protocol.
33
+ - [**Sandbox**](https://veryfront.com/docs/code/guides/sandbox) — Ephemeral compute environments for isolated code execution with shell tools and agent service integration.
34
+
35
+ - [**Integrations**](https://veryfront.com/docs/code/guides/integrations) — Pre-built connectors with OAuth flows, remote tools, and metadata for third-party services.
28
36
 
29
37
  - [**Pages & Routing**](https://veryfront.com/docs/code/guides/pages-and-routing) — File-based routing with React Server Components, layouts, and server-side rendering.
30
38
 
31
39
  - [**Data Fetching & API Routes**](https://veryfront.com/docs/code/guides/data-fetching) — Server-side data loading, API route handlers, and [middleware](https://veryfront.com/docs/code/guides/middleware) with built-in [OAuth](https://veryfront.com/docs/code/guides/oauth) support.
32
40
 
41
+ - [**Extensions**](./docs/guides/extensions.md) — Contract-based plugin system with 12 first-party packages for LLM providers, bundling, CSS, tracing, caching, and more.
42
+
33
43
  ## Get Started
34
44
 
35
45
  The **recommended** way to get started with Veryfront:
@@ -60,6 +70,37 @@ brew install veryfront/tap/veryfront
60
70
 
61
71
  Follow the [Quickstart guide](https://veryfront.com/docs/code/guides/quickstart) for step-by-step setup, or explore our [templates](https://veryfront.com/docs/code/guides/quickstart#templates) to start building your first application with Veryfront. For the full documentation, visit [veryfront.com/docs/code](https://veryfront.com/docs/code).
62
72
 
73
+ ## Project Structure
74
+
75
+ ```
76
+ veryfront/
77
+ ├── src/ # Framework core modules
78
+ │ ├── agent/ # Agent runtime, AG-UI, hosted execution
79
+ │ ├── tool/ # Tool definitions and registry
80
+ │ ├── workflow/ # Durable DAG workflows with crash recovery
81
+ │ ├── mcp/ # Model Context Protocol server
82
+ │ ├── skill/ # Agent skills system (SKILL.md)
83
+ │ ├── chat/ # Chat UI components and streaming
84
+ │ ├── discovery/ # Auto-discovery of tools, agents, workflows
85
+ │ ├── sandbox/ # Ephemeral compute environments
86
+ │ ├── jobs/ # Background jobs client
87
+ │ ├── task/ # Task definitions and runner
88
+ │ ├── channels/ # Control-plane agent routing
89
+ │ ├── integrations/ # Third-party connector metadata
90
+ │ ├── provider/ # AI model provider adapters
91
+ │ ├── rendering/ # SSR/RSC engine
92
+ │ ├── server/ # HTTP servers (dev + production)
93
+ │ ├── routing/ # File-based routing
94
+ │ ├── security/ # Rate limiting, CORS, CSP, validation
95
+ │ └── ... # See src/README.md for full list
96
+ ├── cli/ # CLI and TUI dashboard
97
+ ├── extensions/ # First-party extension packages
98
+ ├── docs/ # Architecture diagrams and guides
99
+ ├── tests/ # Integration and E2E tests
100
+ ├── benchmarks/ # Performance benchmarks
101
+ └── scripts/ # Development and build scripts
102
+ ```
103
+
63
104
  ## Examples
64
105
 
65
106
  You can find standalone, runnable examples in the [veryfront-examples](https://github.com/veryfront/veryfront-examples) repo.
package/esm/deno.d.ts CHANGED
@@ -259,12 +259,8 @@ declare namespace _default {
259
259
  "@opentelemetry/sdk-node": string;
260
260
  "@opentelemetry/sdk-trace-base": string;
261
261
  "@mdx-js/mdx": string;
262
- "@babel/parser": string;
263
262
  "gray-matter": string;
264
263
  zod: string;
265
- mdast: string;
266
- hast: string;
267
- unist: string;
268
264
  unified: string;
269
265
  "class-variance-authority": string;
270
266
  "tailwind-merge": string;
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.512",
3
+ "version": "0.1.513",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -284,12 +284,8 @@ export default {
284
284
  "@opentelemetry/sdk-node": "npm:@opentelemetry/sdk-node@0.217.0",
285
285
  "@opentelemetry/sdk-trace-base": "npm:@opentelemetry/sdk-trace-base@2.7.1",
286
286
  "@mdx-js/mdx": "npm:@mdx-js/mdx@3.1.1",
287
- "@babel/parser": "npm:@babel/parser@7.29.2",
288
287
  "gray-matter": "npm:gray-matter@4.0.3",
289
288
  "zod": "npm:zod@4.3.6",
290
- "mdast": "npm:@types/mdast@4.0.3",
291
- "hast": "npm:@types/hast@3.0.3",
292
- "unist": "npm:@types/unist@3.0.2",
293
289
  "unified": "npm:unified@11.0.5",
294
290
  "class-variance-authority": "npm:class-variance-authority@0.7.1",
295
291
  "tailwind-merge": "npm:tailwind-merge@3.5.0",
@@ -1,6 +1,19 @@
1
1
  import { z } from "zod";
2
2
  export declare const agentServiceConfigSchema: z.ZodPipe<z.ZodObject<{
3
3
  VERYFRONT_API_URL: z.ZodDefault<z.ZodString>;
4
+ VERYFRONT_API_TOKEN: z.ZodOptional<z.ZodString>;
5
+ VERYFRONT_PROJECT_ID: z.ZodOptional<z.ZodString>;
6
+ VERYFRONT_AGENT_SERVICE_URL: z.ZodOptional<z.ZodString>;
7
+ VERYFRONT_AGENT_SERVICE_KEY: z.ZodOptional<z.ZodString>;
8
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
9
+ true: "true";
10
+ false: "false";
11
+ auto: "auto";
12
+ enabled: "enabled";
13
+ disabled: "disabled";
14
+ }>>, z.ZodTransform<"auto" | "enabled" | "disabled", "true" | "false" | "auto" | "enabled" | "disabled">>;
15
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
16
+ VERYFRONT_AGENT_SERVICE_REGION: z.ZodOptional<z.ZodString>;
4
17
  NODE_ENV: z.ZodDefault<z.ZodEnum<{
5
18
  development: "development";
6
19
  production: "production";
@@ -17,6 +30,13 @@ export declare const agentServiceConfigSchema: z.ZodPipe<z.ZodObject<{
17
30
  }, z.core.$strip>, z.ZodTransform<{
18
31
  VERYFRONT_API_URL: string;
19
32
  VERYFRONT_MCP_URL: string;
33
+ VERYFRONT_API_TOKEN: string | undefined;
34
+ VERYFRONT_PROJECT_ID: string | undefined;
35
+ VERYFRONT_AGENT_SERVICE_URL: string | undefined;
36
+ VERYFRONT_AGENT_SERVICE_KEY: string | undefined;
37
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: "auto" | "enabled" | "disabled";
38
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: number;
39
+ VERYFRONT_AGENT_SERVICE_REGION: string | undefined;
20
40
  VERYFRONT_STUDIO_MCP_URL: string;
21
41
  VERYFRONT_ENABLE_DURABLE_INVOKE_AGENT: boolean;
22
42
  VERYFRONT_ENABLE_DURABLE_TASK: boolean;
@@ -28,6 +48,8 @@ export declare const agentServiceConfigSchema: z.ZodPipe<z.ZodObject<{
28
48
  OTEL_EXPORTER_OTLP_ENDPOINT: string | undefined;
29
49
  }, {
30
50
  VERYFRONT_API_URL: string;
51
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: "auto" | "enabled" | "disabled";
52
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: number;
31
53
  NODE_ENV: "development" | "production" | "test";
32
54
  PORT: number;
33
55
  VERYFRONT_STUDIO_MCP_URL: string;
@@ -35,6 +57,11 @@ export declare const agentServiceConfigSchema: z.ZodPipe<z.ZodObject<{
35
57
  VERYFRONT_ENABLE_DURABLE_TASK: boolean;
36
58
  ALLOWED_ORIGINS: string;
37
59
  OTEL_ENABLED: boolean;
60
+ VERYFRONT_API_TOKEN?: string | undefined;
61
+ VERYFRONT_PROJECT_ID?: string | undefined;
62
+ VERYFRONT_AGENT_SERVICE_URL?: string | undefined;
63
+ VERYFRONT_AGENT_SERVICE_KEY?: string | undefined;
64
+ VERYFRONT_AGENT_SERVICE_REGION?: string | undefined;
38
65
  OAUTH_PUBLIC_KEY?: string | undefined;
39
66
  OTEL_EXPORTER_OTLP_ENDPOINT?: string | undefined;
40
67
  }>>;
@@ -42,6 +69,19 @@ export type AgentServiceConfig = z.infer<typeof agentServiceConfigSchema>;
42
69
  export type AgentServiceConfigInput = z.input<typeof agentServiceConfigSchema>;
43
70
  export declare const hostedAgentServiceConfigSchema: z.ZodPipe<z.ZodObject<{
44
71
  VERYFRONT_API_URL: z.ZodDefault<z.ZodString>;
72
+ VERYFRONT_API_TOKEN: z.ZodOptional<z.ZodString>;
73
+ VERYFRONT_PROJECT_ID: z.ZodOptional<z.ZodString>;
74
+ VERYFRONT_AGENT_SERVICE_URL: z.ZodOptional<z.ZodString>;
75
+ VERYFRONT_AGENT_SERVICE_KEY: z.ZodOptional<z.ZodString>;
76
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
77
+ true: "true";
78
+ false: "false";
79
+ auto: "auto";
80
+ enabled: "enabled";
81
+ disabled: "disabled";
82
+ }>>, z.ZodTransform<"auto" | "enabled" | "disabled", "true" | "false" | "auto" | "enabled" | "disabled">>;
83
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
84
+ VERYFRONT_AGENT_SERVICE_REGION: z.ZodOptional<z.ZodString>;
45
85
  NODE_ENV: z.ZodDefault<z.ZodEnum<{
46
86
  development: "development";
47
87
  production: "production";
@@ -58,6 +98,13 @@ export declare const hostedAgentServiceConfigSchema: z.ZodPipe<z.ZodObject<{
58
98
  }, z.core.$strip>, z.ZodTransform<{
59
99
  VERYFRONT_API_URL: string;
60
100
  VERYFRONT_MCP_URL: string;
101
+ VERYFRONT_API_TOKEN: string | undefined;
102
+ VERYFRONT_PROJECT_ID: string | undefined;
103
+ VERYFRONT_AGENT_SERVICE_URL: string | undefined;
104
+ VERYFRONT_AGENT_SERVICE_KEY: string | undefined;
105
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: "auto" | "enabled" | "disabled";
106
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: number;
107
+ VERYFRONT_AGENT_SERVICE_REGION: string | undefined;
61
108
  VERYFRONT_STUDIO_MCP_URL: string;
62
109
  VERYFRONT_ENABLE_DURABLE_INVOKE_AGENT: boolean;
63
110
  VERYFRONT_ENABLE_DURABLE_TASK: boolean;
@@ -69,6 +116,8 @@ export declare const hostedAgentServiceConfigSchema: z.ZodPipe<z.ZodObject<{
69
116
  OTEL_EXPORTER_OTLP_ENDPOINT: string | undefined;
70
117
  }, {
71
118
  VERYFRONT_API_URL: string;
119
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: "auto" | "enabled" | "disabled";
120
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: number;
72
121
  NODE_ENV: "development" | "production" | "test";
73
122
  PORT: number;
74
123
  VERYFRONT_STUDIO_MCP_URL: string;
@@ -76,6 +125,11 @@ export declare const hostedAgentServiceConfigSchema: z.ZodPipe<z.ZodObject<{
76
125
  VERYFRONT_ENABLE_DURABLE_TASK: boolean;
77
126
  ALLOWED_ORIGINS: string;
78
127
  OTEL_ENABLED: boolean;
128
+ VERYFRONT_API_TOKEN?: string | undefined;
129
+ VERYFRONT_PROJECT_ID?: string | undefined;
130
+ VERYFRONT_AGENT_SERVICE_URL?: string | undefined;
131
+ VERYFRONT_AGENT_SERVICE_KEY?: string | undefined;
132
+ VERYFRONT_AGENT_SERVICE_REGION?: string | undefined;
79
133
  OAUTH_PUBLIC_KEY?: string | undefined;
80
134
  OTEL_EXPORTER_OTLP_ENDPOINT?: string | undefined;
81
135
  }>>;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-service-config.d.ts","sourceRoot":"","sources":["../../../src/src/agent/agent-service-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuBlC,CAAC;AAEJ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,w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splitAllowedOrigins(value) {
6
6
  return value.split(",").map((origin) => origin.trim());
7
7
  }
8
8
  const booleanFlagSchema = z.string().default("false").transform(parseBooleanFlag);
9
+ const agentServiceRegistrationModeInputSchema = z
10
+ .enum(["auto", "enabled", "disabled", "true", "false"])
11
+ .default("auto")
12
+ .transform((value) => {
13
+ if (value === "true")
14
+ return "enabled";
15
+ if (value === "false")
16
+ return "disabled";
17
+ return value;
18
+ });
9
19
  export const agentServiceConfigSchema = z.object({
10
20
  VERYFRONT_API_URL: z.string().url().default("https://api.veryfront.com"),
21
+ VERYFRONT_API_TOKEN: z.string().min(1).optional(),
22
+ VERYFRONT_PROJECT_ID: z.string().min(1).optional(),
23
+ VERYFRONT_AGENT_SERVICE_URL: z.string().url().optional(),
24
+ VERYFRONT_AGENT_SERVICE_KEY: z.string().min(1).max(128).optional(),
25
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: agentServiceRegistrationModeInputSchema,
26
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: z.coerce.number().positive().default(30_000),
27
+ VERYFRONT_AGENT_SERVICE_REGION: z.string().min(1).max(128).optional(),
11
28
  NODE_ENV: z.enum(["development", "test", "production"]).default("development"),
12
29
  PORT: z.coerce.number().default(3001),
13
30
  OAUTH_PUBLIC_KEY: z.string().optional(),
@@ -20,6 +37,13 @@ export const agentServiceConfigSchema = z.object({
20
37
  }).transform((env) => ({
21
38
  VERYFRONT_API_URL: env.VERYFRONT_API_URL,
22
39
  VERYFRONT_MCP_URL: `${env.VERYFRONT_API_URL}/mcp`,
40
+ VERYFRONT_API_TOKEN: env.VERYFRONT_API_TOKEN,
41
+ VERYFRONT_PROJECT_ID: env.VERYFRONT_PROJECT_ID,
42
+ VERYFRONT_AGENT_SERVICE_URL: env.VERYFRONT_AGENT_SERVICE_URL,
43
+ VERYFRONT_AGENT_SERVICE_KEY: env.VERYFRONT_AGENT_SERVICE_KEY,
44
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: env.VERYFRONT_AGENT_SERVICE_REGISTRATION,
45
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: env.VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS,
46
+ VERYFRONT_AGENT_SERVICE_REGION: env.VERYFRONT_AGENT_SERVICE_REGION,
23
47
  VERYFRONT_STUDIO_MCP_URL: env.VERYFRONT_STUDIO_MCP_URL,
24
48
  VERYFRONT_ENABLE_DURABLE_INVOKE_AGENT: env.VERYFRONT_ENABLE_DURABLE_INVOKE_AGENT,
25
49
  VERYFRONT_ENABLE_DURABLE_TASK: env.VERYFRONT_ENABLE_DURABLE_TASK,
@@ -0,0 +1,110 @@
1
+ import { z } from "zod";
2
+ export declare const agentServiceRegistrationModeSchema: z.ZodEnum<{
3
+ auto: "auto";
4
+ enabled: "enabled";
5
+ disabled: "disabled";
6
+ }>;
7
+ export declare const agentServiceRegistrationConfigSchema: z.ZodObject<{
8
+ VERYFRONT_API_URL: z.ZodString;
9
+ VERYFRONT_API_TOKEN: z.ZodOptional<z.ZodString>;
10
+ VERYFRONT_PROJECT_ID: z.ZodOptional<z.ZodString>;
11
+ VERYFRONT_AGENT_SERVICE_URL: z.ZodOptional<z.ZodString>;
12
+ VERYFRONT_AGENT_SERVICE_KEY: z.ZodOptional<z.ZodString>;
13
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: z.ZodEnum<{
14
+ auto: "auto";
15
+ enabled: "enabled";
16
+ disabled: "disabled";
17
+ }>;
18
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: z.ZodNumber;
19
+ VERYFRONT_AGENT_SERVICE_REGION: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>;
21
+ export declare const resolvedAgentServiceRegistrationInputSchema: z.ZodObject<{
22
+ apiUrl: z.ZodString;
23
+ authToken: z.ZodString;
24
+ serviceName: z.ZodString;
25
+ serviceKey: z.ZodString;
26
+ scopeKind: z.ZodEnum<{
27
+ global: "global";
28
+ project: "project";
29
+ }>;
30
+ projectId: z.ZodOptional<z.ZodString>;
31
+ agentId: z.ZodOptional<z.ZodString>;
32
+ baseUrl: z.ZodString;
33
+ invokeUrl: z.ZodString;
34
+ version: z.ZodOptional<z.ZodString>;
35
+ runtime: z.ZodOptional<z.ZodString>;
36
+ region: z.ZodOptional<z.ZodString>;
37
+ heartbeatIntervalMs: z.ZodNumber;
38
+ }, z.core.$strip>;
39
+ declare const agentPushRuntimeServiceRestSchema: z.ZodObject<{
40
+ id: z.ZodString;
41
+ service_name: z.ZodString;
42
+ service_key: z.ZodString;
43
+ scope_kind: z.ZodEnum<{
44
+ global: "global";
45
+ project: "project";
46
+ }>;
47
+ scope_key: z.ZodString;
48
+ project_id: z.ZodNullable<z.ZodString>;
49
+ agent_id: z.ZodNullable<z.ZodString>;
50
+ base_url: z.ZodString;
51
+ invoke_url: z.ZodString;
52
+ status: z.ZodEnum<{
53
+ disabled: "disabled";
54
+ active: "active";
55
+ }>;
56
+ capabilities: z.ZodNullable<z.ZodUnknown>;
57
+ metadata: z.ZodNullable<z.ZodUnknown>;
58
+ version: z.ZodNullable<z.ZodString>;
59
+ runtime: z.ZodNullable<z.ZodString>;
60
+ region: z.ZodNullable<z.ZodString>;
61
+ last_heartbeat_at: z.ZodNullable<z.ZodString>;
62
+ created_at: z.ZodString;
63
+ updated_at: z.ZodString;
64
+ }, z.core.$strip>;
65
+ declare const registerAgentPushRuntimeServiceRequestSchema: z.ZodObject<{
66
+ service_name: z.ZodString;
67
+ service_key: z.ZodString;
68
+ scope_kind: z.ZodEnum<{
69
+ global: "global";
70
+ project: "project";
71
+ }>;
72
+ project_id: z.ZodOptional<z.ZodString>;
73
+ agent_id: z.ZodOptional<z.ZodString>;
74
+ base_url: z.ZodString;
75
+ invoke_url: z.ZodString;
76
+ version: z.ZodOptional<z.ZodString>;
77
+ runtime: z.ZodOptional<z.ZodString>;
78
+ region: z.ZodOptional<z.ZodString>;
79
+ }, z.core.$strip>;
80
+ export type AgentServiceRegistrationMode = z.infer<typeof agentServiceRegistrationModeSchema>;
81
+ export type AgentServiceRegistrationConfig = z.infer<typeof agentServiceRegistrationConfigSchema>;
82
+ export type ResolvedAgentServiceRegistrationInput = z.infer<typeof resolvedAgentServiceRegistrationInputSchema>;
83
+ export type AgentPushRuntimeServiceRest = z.infer<typeof agentPushRuntimeServiceRestSchema>;
84
+ export type RegisterAgentPushRuntimeServiceRequest = z.infer<typeof registerAgentPushRuntimeServiceRequestSchema>;
85
+ export type AgentServiceRegistrationLogger = {
86
+ info?: (message: string, metadata?: Record<string, unknown>) => void;
87
+ warn?: (message: string, metadata?: Record<string, unknown>) => void;
88
+ error?: (message: string, metadata?: Record<string, unknown>) => void;
89
+ };
90
+ export type ResolveAgentServiceRegistrationInputOptions = {
91
+ config: AgentServiceRegistrationConfig;
92
+ serviceName: string;
93
+ agentId?: string;
94
+ version?: string;
95
+ runtime?: string;
96
+ };
97
+ export type AgentServiceRegistrationLifecycle = {
98
+ serviceId: string;
99
+ service: AgentPushRuntimeServiceRest;
100
+ heartbeat: () => Promise<void>;
101
+ stop: () => void;
102
+ };
103
+ export type CreateAgentServiceRegistrationLifecycleOptions = ResolvedAgentServiceRegistrationInput & {
104
+ fetch?: typeof globalThis.fetch;
105
+ logger?: AgentServiceRegistrationLogger;
106
+ };
107
+ export declare function resolveAgentServiceRegistrationInput(options: ResolveAgentServiceRegistrationInputOptions): Promise<ResolvedAgentServiceRegistrationInput | null>;
108
+ export declare function createAgentServiceRegistrationLifecycle(options: CreateAgentServiceRegistrationLifecycleOptions): Promise<AgentServiceRegistrationLifecycle>;
109
+ export {};
110
+ //# sourceMappingURL=agent-service-registration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-service-registration.d.ts","sourceRoot":"","sources":["../../../src/src/agent/agent-service-registration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kCAAkC;;;;EAI7C,CAAC;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AC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,2BAA2B,CAAC;IACrC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,8CAA8C,GACtD,qCAAqC,GACrC;IACA,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,MAAM,CAAC,EAAE,8BAA8B,CAAC;CACzC,CAAC;AA0DJ,wBAAsB,oCAAoC,CACxD,OAAO,EAAE,2CAA2C,GACnD,OAAO,CAAC,qCAAqC,GAAG,IAAI,CAAC,CA6CvD;AA4DD,wBAAsB,uCAAuC,CAC3D,OAAO,EAAE,8CAA8C,GACtD,OAAO,CAAC,iCAAiC,CAAC,CA0C5C"}
@@ -0,0 +1,228 @@
1
+ import * as dntShim from "../../_dnt.shims.js";
2
+ import { z } from "zod";
3
+ export const agentServiceRegistrationModeSchema = z.enum([
4
+ "auto",
5
+ "enabled",
6
+ "disabled",
7
+ ]);
8
+ export const agentServiceRegistrationConfigSchema = z.object({
9
+ VERYFRONT_API_URL: z.string().url(),
10
+ VERYFRONT_API_TOKEN: z.string().min(1).optional(),
11
+ VERYFRONT_PROJECT_ID: z.string().min(1).optional(),
12
+ VERYFRONT_AGENT_SERVICE_URL: z.string().url().optional(),
13
+ VERYFRONT_AGENT_SERVICE_KEY: z.string().min(1).max(128).optional(),
14
+ VERYFRONT_AGENT_SERVICE_REGISTRATION: agentServiceRegistrationModeSchema,
15
+ VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS: z.number().positive(),
16
+ VERYFRONT_AGENT_SERVICE_REGION: z.string().min(1).max(128).optional(),
17
+ });
18
+ export const resolvedAgentServiceRegistrationInputSchema = z.object({
19
+ apiUrl: z.string().url(),
20
+ authToken: z.string().min(1),
21
+ serviceName: z.string().min(1).max(128),
22
+ serviceKey: z.string().min(1).max(128),
23
+ scopeKind: z.enum(["global", "project"]),
24
+ projectId: z.string().min(1).optional(),
25
+ agentId: z.string().min(1).max(128).optional(),
26
+ baseUrl: z.string().url(),
27
+ invokeUrl: z.string().url(),
28
+ version: z.string().min(1).max(128).optional(),
29
+ runtime: z.string().min(1).max(128).optional(),
30
+ region: z.string().min(1).max(128).optional(),
31
+ heartbeatIntervalMs: z.number().positive(),
32
+ });
33
+ const agentPushRuntimeServiceRestSchema = z.object({
34
+ id: z.string().uuid(),
35
+ service_name: z.string(),
36
+ service_key: z.string(),
37
+ scope_kind: z.enum(["global", "project"]),
38
+ scope_key: z.string(),
39
+ project_id: z.string().nullable(),
40
+ agent_id: z.string().nullable(),
41
+ base_url: z.string().url(),
42
+ invoke_url: z.string().url(),
43
+ status: z.enum(["active", "disabled"]),
44
+ capabilities: z.unknown().nullable(),
45
+ metadata: z.unknown().nullable(),
46
+ version: z.string().nullable(),
47
+ runtime: z.string().nullable(),
48
+ region: z.string().nullable(),
49
+ last_heartbeat_at: z.string().nullable(),
50
+ created_at: z.string(),
51
+ updated_at: z.string(),
52
+ });
53
+ const agentPushRuntimeServiceResponseSchema = z.object({
54
+ service: agentPushRuntimeServiceRestSchema,
55
+ });
56
+ const registerAgentPushRuntimeServiceRequestSchema = z.object({
57
+ service_name: z.string().min(1).max(128),
58
+ service_key: z.string().min(1).max(128),
59
+ scope_kind: z.enum(["global", "project"]),
60
+ project_id: z.string().optional(),
61
+ agent_id: z.string().optional(),
62
+ base_url: z.string().url(),
63
+ invoke_url: z.string().url(),
64
+ version: z.string().optional(),
65
+ runtime: z.string().optional(),
66
+ region: z.string().optional(),
67
+ });
68
+ function normalizeBaseUrl(value) {
69
+ const url = new URL(value);
70
+ url.pathname = url.pathname.replace(/\/+$/, "");
71
+ url.search = "";
72
+ url.hash = "";
73
+ return url.toString().replace(/\/$/, "");
74
+ }
75
+ function defaultInvokeUrl(baseUrl) {
76
+ return new URL("/api/runs", baseUrl).toString();
77
+ }
78
+ function getRegistrationEndpoint(apiUrl) {
79
+ return new URL("/agent-runtimes/push-services", apiUrl).toString();
80
+ }
81
+ function getHeartbeatEndpoint(apiUrl, serviceId) {
82
+ return new URL(`/agent-runtimes/push-services/${serviceId}/heartbeat`, apiUrl).toString();
83
+ }
84
+ function getErrorMessage(error) {
85
+ return error instanceof Error ? error.message : String(error);
86
+ }
87
+ async function stableServiceKey(input) {
88
+ const keySource = [
89
+ input.serviceName,
90
+ input.agentId ?? "default",
91
+ input.scopeKind,
92
+ input.projectId ?? "global",
93
+ input.baseUrl,
94
+ ].join("|");
95
+ const digest = await dntShim.crypto.subtle.digest("SHA-256", new TextEncoder().encode(keySource));
96
+ const hash = Array.from(new Uint8Array(digest))
97
+ .map((byte) => byte.toString(16).padStart(2, "0"))
98
+ .join("")
99
+ .slice(0, 32);
100
+ return `${input.serviceName}:${hash}`.slice(0, 128);
101
+ }
102
+ function requireExplicitRegistrationValue(value, envName) {
103
+ if (!value) {
104
+ throw new Error(`${envName} is required when VERYFRONT_AGENT_SERVICE_REGISTRATION=enabled`);
105
+ }
106
+ return value;
107
+ }
108
+ export async function resolveAgentServiceRegistrationInput(options) {
109
+ const config = agentServiceRegistrationConfigSchema.parse(options.config);
110
+ const enabled = config.VERYFRONT_AGENT_SERVICE_REGISTRATION === "enabled";
111
+ const token = enabled
112
+ ? requireExplicitRegistrationValue(config.VERYFRONT_API_TOKEN, "VERYFRONT_API_TOKEN")
113
+ : config.VERYFRONT_API_TOKEN;
114
+ const serviceUrl = enabled
115
+ ? requireExplicitRegistrationValue(config.VERYFRONT_AGENT_SERVICE_URL, "VERYFRONT_AGENT_SERVICE_URL")
116
+ : config.VERYFRONT_AGENT_SERVICE_URL;
117
+ if (config.VERYFRONT_AGENT_SERVICE_REGISTRATION === "disabled") {
118
+ return null;
119
+ }
120
+ if (!token || !serviceUrl) {
121
+ return null;
122
+ }
123
+ const scopeKind = config.VERYFRONT_PROJECT_ID ? "project" : "global";
124
+ const baseUrl = normalizeBaseUrl(serviceUrl);
125
+ const serviceKey = config.VERYFRONT_AGENT_SERVICE_KEY ?? await stableServiceKey({
126
+ serviceName: options.serviceName,
127
+ agentId: options.agentId,
128
+ baseUrl,
129
+ scopeKind,
130
+ projectId: config.VERYFRONT_PROJECT_ID,
131
+ });
132
+ return resolvedAgentServiceRegistrationInputSchema.parse({
133
+ apiUrl: config.VERYFRONT_API_URL,
134
+ authToken: token,
135
+ serviceName: options.serviceName,
136
+ serviceKey,
137
+ scopeKind,
138
+ projectId: config.VERYFRONT_PROJECT_ID,
139
+ agentId: options.agentId,
140
+ baseUrl,
141
+ invokeUrl: defaultInvokeUrl(baseUrl),
142
+ version: options.version,
143
+ runtime: options.runtime,
144
+ region: config.VERYFRONT_AGENT_SERVICE_REGION,
145
+ heartbeatIntervalMs: config.VERYFRONT_AGENT_SERVICE_HEARTBEAT_INTERVAL_MS,
146
+ });
147
+ }
148
+ async function readAgentPushRuntimeServiceResponse(response) {
149
+ if (!response.ok) {
150
+ throw new Error(`Agent runtime registration request failed with HTTP ${response.status}`);
151
+ }
152
+ const parsed = agentPushRuntimeServiceResponseSchema.parse(await response.json());
153
+ return parsed.service;
154
+ }
155
+ function createHeaders(authToken) {
156
+ const headers = new Headers();
157
+ headers.set("Authorization", `Bearer ${authToken}`);
158
+ headers.set("Content-Type", "application/json");
159
+ return headers;
160
+ }
161
+ function buildRegistrationRequest(input) {
162
+ return registerAgentPushRuntimeServiceRequestSchema.parse({
163
+ service_name: input.serviceName,
164
+ service_key: input.serviceKey,
165
+ scope_kind: input.scopeKind,
166
+ project_id: input.projectId,
167
+ agent_id: input.agentId,
168
+ base_url: input.baseUrl,
169
+ invoke_url: input.invokeUrl,
170
+ version: input.version,
171
+ runtime: input.runtime,
172
+ region: input.region,
173
+ });
174
+ }
175
+ async function registerAgentPushRuntimeService(input, fetchImpl) {
176
+ const response = await fetchImpl(getRegistrationEndpoint(input.apiUrl), {
177
+ method: "POST",
178
+ headers: createHeaders(input.authToken),
179
+ body: JSON.stringify(buildRegistrationRequest(input)),
180
+ });
181
+ return await readAgentPushRuntimeServiceResponse(response);
182
+ }
183
+ async function heartbeatAgentPushRuntimeService(input, fetchImpl) {
184
+ const response = await fetchImpl(getHeartbeatEndpoint(input.apiUrl, input.serviceId), {
185
+ method: "POST",
186
+ headers: createHeaders(input.authToken),
187
+ });
188
+ return await readAgentPushRuntimeServiceResponse(response);
189
+ }
190
+ export async function createAgentServiceRegistrationLifecycle(options) {
191
+ const fetchImpl = options.fetch ?? globalThis.fetch;
192
+ const input = resolvedAgentServiceRegistrationInputSchema.parse(options);
193
+ const service = await registerAgentPushRuntimeService(input, fetchImpl);
194
+ let stopped = false;
195
+ const heartbeat = async () => {
196
+ if (stopped) {
197
+ return;
198
+ }
199
+ await heartbeatAgentPushRuntimeService({
200
+ apiUrl: input.apiUrl,
201
+ authToken: input.authToken,
202
+ serviceId: service.id,
203
+ }, fetchImpl);
204
+ };
205
+ const interval = dntShim.setInterval(() => {
206
+ void heartbeat().catch((error) => {
207
+ options.logger?.warn?.("Agent service heartbeat failed", {
208
+ serviceId: service.id,
209
+ error: getErrorMessage(error),
210
+ });
211
+ });
212
+ }, input.heartbeatIntervalMs);
213
+ options.logger?.info?.("Agent service registered with control plane", {
214
+ serviceId: service.id,
215
+ serviceName: service.service_name,
216
+ scopeKind: service.scope_kind,
217
+ projectId: service.project_id,
218
+ });
219
+ return {
220
+ serviceId: service.id,
221
+ service,
222
+ heartbeat,
223
+ stop: () => {
224
+ stopped = true;
225
+ clearInterval(interval);
226
+ },
227
+ };
228
+ }
@@ -5,7 +5,7 @@ import { type AgentServiceAuth, type AgentServiceAuthConfig } from "./agent-serv
5
5
  import type { ParsedHostedChatRequest } from "./hosted-chat-request-parser.js";
6
6
  import type { AgUiResumeValue } from "./ag-ui-tool-shared.js";
7
7
  import type { RuntimeAgentMarkdownDefinition } from "./runtime-agent-definition.js";
8
- import { type AgentServiceServer, type NodeAgentServiceServer } from "./agent-service-server.js";
8
+ import { type AgentServiceServer, type AgentServiceServerLifecycle, type NodeAgentServiceServer } from "./agent-service-server.js";
9
9
  import type { VeryfrontServiceServerLogger } from "../server/service-server.js";
10
10
  export type HostedAgentServiceRuntimeConfig = AgentServiceAuthConfig & {
11
11
  PORT: number;
@@ -49,12 +49,14 @@ export type StartNodeHostedAgentServiceOptions<TExecution extends object, TConfi
49
49
  bindAddress?: string;
50
50
  hardShutdownTimeoutMs?: number;
51
51
  signals?: readonly NodeJS.Signals[];
52
+ lifecycle?: AgentServiceServerLifecycle;
52
53
  };
53
54
  export type StartNodeAgentServiceOptions<TExecution extends object, TConfig extends AgentServiceRuntimeConfig = AgentServiceRuntimeConfig> = StartNodeHostedAgentServiceOptions<TExecution, TConfig>;
54
55
  export type StartAgentServiceRuntimeOptions<TExecution extends object, TConfig extends AgentServiceRuntimeConfig = AgentServiceRuntimeConfig> = CreateAgentServiceRuntimeOptions<TExecution, TConfig> & {
55
56
  bindAddress?: string;
56
57
  hardShutdownTimeoutMs?: number;
57
58
  signals?: readonly NodeJS.Signals[];
59
+ lifecycle?: AgentServiceServerLifecycle;
58
60
  };
59
61
  export type StartNodeHostedAgentServiceResult<TExecution extends object, TConfig extends HostedAgentServiceRuntimeConfig = HostedAgentServiceRuntimeConfig> = HostedAgentServiceRuntimeBundle<TExecution, TConfig> & {
60
62
  nodeServer: NodeAgentServiceServer;