@artinet/fleet 0.1.1 → 0.1.5

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.
@@ -801,7 +801,7 @@ export declare const CreateAgentRequestSchema: import("zod/v4").ZodObject<{
801
801
  instructions: import("zod/v4").ZodString;
802
802
  services: import("zod/v4").ZodDefault<import("zod/v4").ZodArray<import("zod/v4").ZodUnion<readonly [import("zod/v4").ZodUnion<readonly [import("zod/v4").ZodObject<{
803
803
  id: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
804
- url: import("zod/v4").ZodString;
804
+ url: import("zod/v4").ZodURL;
805
805
  headers: import("zod/v4").ZodOptional<import("zod/v4").ZodRecord<import("zod/v4").ZodString, import("zod/v4").ZodString>>;
806
806
  authToken: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
807
807
  parameters: import("zod/v4").ZodOptional<import("zod/v4").ZodRecord<import("zod/v4").ZodString, import("zod/v4").ZodUnknown>>;
@@ -916,7 +916,7 @@ export declare const CreateAgentRequestSchema: import("zod/v4").ZodObject<{
916
916
  }, import("zod/v4/core").$strip>;
917
917
  }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
918
918
  id: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
919
- url: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
919
+ url: import("zod/v4").ZodOptional<import("zod/v4").ZodURL>;
920
920
  headers: import("zod/v4").ZodOptional<import("zod/v4").ZodOptional<import("zod/v4").ZodRecord<import("zod/v4").ZodString, import("zod/v4").ZodString>>>;
921
921
  authToken: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
922
922
  parameters: import("zod/v4").ZodOptional<import("zod/v4").ZodRecord<import("zod/v4").ZodString, import("zod/v4").ZodUnknown>>;
@@ -1031,7 +1031,7 @@ export declare const CreateAgentRequestSchema: import("zod/v4").ZodObject<{
1031
1031
  }, import("zod/v4/core").$strip>;
1032
1032
  }, import("zod/v4/core").$strip>]>, import("zod/v4").ZodUnion<readonly [import("zod/v4").ZodObject<{
1033
1033
  id: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
1034
- url: import("zod/v4").ZodString;
1034
+ url: import("zod/v4").ZodURL;
1035
1035
  headers: import("zod/v4").ZodOptional<import("zod/v4").ZodRecord<import("zod/v4").ZodString, import("zod/v4").ZodString>>;
1036
1036
  authToken: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
1037
1037
  parameters: import("zod/v4").ZodOptional<import("zod/v4").ZodRecord<import("zod/v4").ZodString, import("zod/v4").ZodUnknown>>;
@@ -1168,7 +1168,7 @@ export declare const CreateAgentRequestSchema: import("zod/v4").ZodObject<{
1168
1168
  }, import("zod/v4/core").$strip>;
1169
1169
  }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
1170
1170
  id: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
1171
- url: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
1171
+ url: import("zod/v4").ZodOptional<import("zod/v4").ZodURL>;
1172
1172
  headers: import("zod/v4").ZodOptional<import("zod/v4").ZodOptional<import("zod/v4").ZodRecord<import("zod/v4").ZodString, import("zod/v4").ZodString>>>;
1173
1173
  authToken: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
1174
1174
  parameters: import("zod/v4").ZodOptional<import("zod/v4").ZodRecord<import("zod/v4").ZodString, import("zod/v4").ZodUnknown>>;
@@ -170,7 +170,7 @@ export declare const TestRequestSchema: z.ZodObject<{
170
170
  instructions: z.ZodString;
171
171
  services: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
172
172
  id: z.ZodOptional<z.ZodString>;
173
- url: z.ZodString;
173
+ url: z.ZodURL;
174
174
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
175
175
  authToken: z.ZodOptional<z.ZodString>;
176
176
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -285,7 +285,7 @@ export declare const TestRequestSchema: z.ZodObject<{
285
285
  }, z.core.$strip>;
286
286
  }, z.core.$strip>, z.ZodObject<{
287
287
  id: z.ZodOptional<z.ZodString>;
288
- url: z.ZodOptional<z.ZodString>;
288
+ url: z.ZodOptional<z.ZodURL>;
289
289
  headers: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
290
290
  authToken: z.ZodOptional<z.ZodString>;
291
291
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -400,7 +400,7 @@ export declare const TestRequestSchema: z.ZodObject<{
400
400
  }, z.core.$strip>;
401
401
  }, z.core.$strip>]>, z.ZodUnion<readonly [z.ZodObject<{
402
402
  id: z.ZodOptional<z.ZodString>;
403
- url: z.ZodString;
403
+ url: z.ZodURL;
404
404
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
405
405
  authToken: z.ZodOptional<z.ZodString>;
406
406
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -537,7 +537,7 @@ export declare const TestRequestSchema: z.ZodObject<{
537
537
  }, z.core.$strip>;
538
538
  }, z.core.$strip>, z.ZodObject<{
539
539
  id: z.ZodOptional<z.ZodString>;
540
- url: z.ZodOptional<z.ZodString>;
540
+ url: z.ZodOptional<z.ZodURL>;
541
541
  headers: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
542
542
  authToken: z.ZodOptional<z.ZodString>;
543
543
  parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -35,7 +35,9 @@ export async function handle(req, res, _next, context, request = RequestAgent, i
35
35
  }
36
36
  export const factory = (request = RequestAgent, intercepts) => async (req, res, next, context) => await handle(req, res, next, context, request, intercepts);
37
37
  export async function request({ request: req, response: res, next, context, handler = handle, user, }) {
38
- const agentId = req?.params?.[AGENT_FIELD_NAME];
38
+ const agentId = Array.isArray(req?.params?.[AGENT_FIELD_NAME])
39
+ ? req?.params?.[AGENT_FIELD_NAME][0]
40
+ : req?.params?.[AGENT_FIELD_NAME];
39
41
  if (!agentId) {
40
42
  return next(INVALID_REQUEST({ message: `${AGENT_FIELD_NAME} is required` }));
41
43
  }
@@ -9,18 +9,77 @@ import { Settings as FleetSettings } from "../../settings.js";
9
9
  import * as agent from "./agent-request.js";
10
10
  import * as testing from "./test-request.js";
11
11
  import * as deployment from "./deploy-request.js";
12
+ /**
13
+ * Extended settings for the Express Fleet server.
14
+ *
15
+ * Combines base {@link FleetSettings} with Express-specific handlers for
16
+ * authentication, user resolution, and request processing.
17
+ *
18
+ * @see {@link https://expressjs.com/en/guide/using-middleware.html Express Middleware}
19
+ */
12
20
  export type Settings = FleetSettings & {
21
+ /** Extracts the user ID from an incoming request. Used for multi-tenant agent isolation. */
13
22
  user?: (req: express.Request) => Promise<string>;
23
+ /** Handler for agent retrieval requests. Generated via {@link agent.factory}. */
14
24
  retrieve?: agent.handler;
25
+ /** Handler for agent deployment requests. Generated via {@link deployment.factory}. */
15
26
  deploy?: deployment.handler;
27
+ /** Handler for agent test/evaluation requests. Generated via {@link testing.factory}. */
16
28
  evaluate?: testing.handler;
29
+ /**
30
+ * Authentication middleware applied to protected routes.
31
+ * @see {@link https://expressjs.com/en/guide/writing-middleware.html Writing Middleware}
32
+ */
17
33
  auth?: (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<void>;
18
34
  };
35
+ /**
36
+ * Options for configuring the Fleet server instance.
37
+ *
38
+ * Allows injection of a pre-configured Express app for integration with
39
+ * existing servers or custom middleware stacks.
40
+ */
19
41
  export interface Options {
42
+ /** Pre-configured Express application. Defaults to a new `express()` instance. */
20
43
  app?: express.Application;
44
+ /** Apply auth middleware to agent retrieval routes. Defaults to `false`. */
21
45
  authOnRetrieve?: boolean;
46
+ /** Expose the test endpoint for agent evaluation. Defaults to `true`. */
22
47
  enableTesting?: boolean;
23
48
  }
49
+ /**
50
+ * Creates and configures a Fleet server instance using Express.
51
+ *
52
+ * This function implements the **Factory Pattern** combined with **Dependency Injection**
53
+ * to provide a flexible, testable, and configurable server setup. The pattern allows
54
+ * consumers to override defaults while maintaining sensible out-of-the-box behavior.
55
+ *
56
+ * @param settings - Partial configuration merged with defaults. Supports custom
57
+ * handlers for `get`, `set`, `test`, and middleware composition.
58
+ * @param options - Server instantiation options
59
+ * @param options.app - Pre-configured Express application instance. Useful for
60
+ * adding custom middleware or integrating with existing servers.
61
+ * @param options.authOnRetrieve - When `true`, applies auth middleware to agent
62
+ * retrieval routes. Defaults to `false` for development convenience.
63
+ * @param options.enableTesting - When `true`, exposes the test endpoint for
64
+ * agent evaluation. Disable in production if not needed.
65
+ *
66
+ * @returns Object containing:
67
+ * - `app`: The configured Express application
68
+ * - `launch`: Function to start the HTTP server on a specified port
69
+ * - `ship`: Async function to deploy agents and return a launchable server
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * // Basic usage with defaults
74
+ * const { app, launch } = fleet();
75
+ * launch(3000);
76
+ *
77
+ * // With custom configuration
78
+ * const { ship } = fleet({ userId: 'admin' }, { authOnRetrieve: true });
79
+ * const server = await ship([agentConfig]);
80
+ * server.launch(8080);
81
+ * ```
82
+ */
24
83
  export declare function fleet(settings?: Partial<Settings>, { app, authOnRetrieve, enableTesting, }?: Options): {
25
84
  app: express.Application;
26
85
  launch: (port: number) => Server;
@@ -40,6 +40,40 @@ const createRequestContext = (context) => {
40
40
  timestamp: undefined,
41
41
  };
42
42
  };
43
+ /**
44
+ * Creates and configures a Fleet server instance using Express.
45
+ *
46
+ * This function implements the **Factory Pattern** combined with **Dependency Injection**
47
+ * to provide a flexible, testable, and configurable server setup. The pattern allows
48
+ * consumers to override defaults while maintaining sensible out-of-the-box behavior.
49
+ *
50
+ * @param settings - Partial configuration merged with defaults. Supports custom
51
+ * handlers for `get`, `set`, `test`, and middleware composition.
52
+ * @param options - Server instantiation options
53
+ * @param options.app - Pre-configured Express application instance. Useful for
54
+ * adding custom middleware or integrating with existing servers.
55
+ * @param options.authOnRetrieve - When `true`, applies auth middleware to agent
56
+ * retrieval routes. Defaults to `false` for development convenience.
57
+ * @param options.enableTesting - When `true`, exposes the test endpoint for
58
+ * agent evaluation. Disable in production if not needed.
59
+ *
60
+ * @returns Object containing:
61
+ * - `app`: The configured Express application
62
+ * - `launch`: Function to start the HTTP server on a specified port
63
+ * - `ship`: Async function to deploy agents and return a launchable server
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // Basic usage with defaults
68
+ * const { app, launch } = fleet();
69
+ * launch(3000);
70
+ *
71
+ * // With custom configuration
72
+ * const { ship } = fleet({ userId: 'admin' }, { authOnRetrieve: true });
73
+ * const server = await ship([agentConfig]);
74
+ * server.launch(8080);
75
+ * ```
76
+ */
43
77
  export function fleet(settings = DEFAULTS, { app = express(), authOnRetrieve = false, enableTesting = true, } = {}) {
44
78
  const context = createContext(settings);
45
79
  const { basePath, agentPath, fallbackPath, deploymentPath, testPath, auth, user, evaluate, deploy, retrieve, set, } = context;
@@ -9,18 +9,86 @@ import { Settings as FleetSettings } from "../../settings.js";
9
9
  import * as agent from "./agent-request.js";
10
10
  import * as testing from "./test-request.js";
11
11
  import * as deployment from "./deploy-request.js";
12
+ /**
13
+ * Extended settings for the Hono Fleet server.
14
+ *
15
+ * Combines base {@link FleetSettings} with Hono-specific handlers for
16
+ * authentication, user resolution, and request processing.
17
+ *
18
+ * @see {@link https://hono.dev/docs/guides/middleware Hono Middleware Guide}
19
+ */
12
20
  export type Settings = FleetSettings & {
21
+ /** Extracts the user ID from the Hono context. Used for multi-tenant agent isolation. */
13
22
  user?: (ctx: hono.Context) => Promise<string>;
23
+ /** Handler for agent retrieval requests. Generated via {@link agent.factory}. */
14
24
  retrieve?: agent.handler;
25
+ /** Handler for agent deployment requests. Generated via {@link deployment.factory}. */
15
26
  deploy?: deployment.handler;
27
+ /** Handler for agent test/evaluation requests. Generated via {@link testing.factory}. */
16
28
  evaluate?: testing.handler;
29
+ /**
30
+ * Authentication middleware applied to protected routes.
31
+ * @see {@link https://hono.dev/docs/guides/middleware#middleware-argument Middleware Guide}
32
+ */
17
33
  auth?: (ctx: hono.Context, next: hono.Next) => Promise<void>;
18
34
  };
35
+ /**
36
+ * Options for configuring the Fleet server instance.
37
+ *
38
+ * Allows injection of a pre-configured Hono app for integration with
39
+ * existing servers or edge runtime deployments.
40
+ */
19
41
  export interface Options {
42
+ /** Pre-configured Hono application. Defaults to a new `Hono()` instance. */
20
43
  app?: hono.Hono;
44
+ /** Apply auth middleware to agent retrieval routes. Defaults to `false`. */
21
45
  authOnRetrieve?: boolean;
46
+ /** Expose the test endpoint for agent evaluation. Defaults to `true`. */
22
47
  enableTesting?: boolean;
23
48
  }
49
+ /**
50
+ * Creates and configures a Fleet server instance using Hono.
51
+ *
52
+ * This function implements the **Factory Pattern** combined with **Dependency Injection**
53
+ * to provide a flexible, testable, and configurable server setup. Hono is chosen for its
54
+ * ultrafast performance, edge-runtime compatibility, and minimal footprint.
55
+ *
56
+ * @see {@link https://hono.dev/docs/ Hono Documentation}
57
+ * @see {@link https://hono.dev/docs/concepts/routers Hono Routers}
58
+ * @see {@link https://hono.dev/docs/guides/middleware Hono Middleware Guide}
59
+ *
60
+ * ## Security Considerations
61
+ *
62
+ * - Authentication middleware is applied conditionally via `auth` setting
63
+ * - `authOnRetrieve` flag controls whether agent retrieval requires authentication
64
+ * - Consider enabling `authOnRetrieve` in production environments
65
+ *
66
+ * @param settings - Partial configuration merged with defaults. Supports custom
67
+ * handlers for `get`, `set`, `test`, and middleware composition.
68
+ * @param options - Server instantiation options
69
+ * @param options.app - Pre-configured Hono application instance. Useful for
70
+ * adding custom middleware or integrating with existing servers.
71
+ * @param options.authOnRetrieve - When `true`, applies auth middleware to agent
72
+ * retrieval routes. Defaults to `false` for development convenience.
73
+ * @param options.enableTesting - When `true`, exposes the test endpoint for
74
+ * agent evaluation. Disable in production if not needed.
75
+ *
76
+ * @returns Object containing:
77
+ * - `app`: The configured Hono application
78
+ * - `launch`: Function to start the HTTP server on a specified port
79
+ * - `ship`: Async function to deploy agents and return a launchable server
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * // Basic usage with defaults
84
+ * const { app, launch } = fleet();
85
+ * launch(3000);
86
+ *
87
+ * // With custom configuration and edge deployment
88
+ * const { app } = fleet({ userId: 'admin' }, { authOnRetrieve: true });
89
+ * export default app; // For Cloudflare Workers
90
+ * ```
91
+ */
24
92
  export declare function fleet(settings?: Partial<Settings>, { app, authOnRetrieve, enableTesting, }?: Options): {
25
93
  app: hono.Hono;
26
94
  launch: (port: number) => ServerType;
@@ -42,6 +42,49 @@ const createRequestContext = (context) => {
42
42
  timestamp: undefined,
43
43
  };
44
44
  };
45
+ /**
46
+ * Creates and configures a Fleet server instance using Hono.
47
+ *
48
+ * This function implements the **Factory Pattern** combined with **Dependency Injection**
49
+ * to provide a flexible, testable, and configurable server setup. Hono is chosen for its
50
+ * ultrafast performance, edge-runtime compatibility, and minimal footprint.
51
+ *
52
+ * @see {@link https://hono.dev/docs/ Hono Documentation}
53
+ * @see {@link https://hono.dev/docs/concepts/routers Hono Routers}
54
+ * @see {@link https://hono.dev/docs/guides/middleware Hono Middleware Guide}
55
+ *
56
+ * ## Security Considerations
57
+ *
58
+ * - Authentication middleware is applied conditionally via `auth` setting
59
+ * - `authOnRetrieve` flag controls whether agent retrieval requires authentication
60
+ * - Consider enabling `authOnRetrieve` in production environments
61
+ *
62
+ * @param settings - Partial configuration merged with defaults. Supports custom
63
+ * handlers for `get`, `set`, `test`, and middleware composition.
64
+ * @param options - Server instantiation options
65
+ * @param options.app - Pre-configured Hono application instance. Useful for
66
+ * adding custom middleware or integrating with existing servers.
67
+ * @param options.authOnRetrieve - When `true`, applies auth middleware to agent
68
+ * retrieval routes. Defaults to `false` for development convenience.
69
+ * @param options.enableTesting - When `true`, exposes the test endpoint for
70
+ * agent evaluation. Disable in production if not needed.
71
+ *
72
+ * @returns Object containing:
73
+ * - `app`: The configured Hono application
74
+ * - `launch`: Function to start the HTTP server on a specified port
75
+ * - `ship`: Async function to deploy agents and return a launchable server
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Basic usage with defaults
80
+ * const { app, launch } = fleet();
81
+ * launch(3000);
82
+ *
83
+ * // With custom configuration and edge deployment
84
+ * const { app } = fleet({ userId: 'admin' }, { authOnRetrieve: true });
85
+ * export default app; // For Cloudflare Workers
86
+ * ```
87
+ */
45
88
  export function fleet(settings = DEFAULTS, { app = new hono.Hono(), authOnRetrieve = false, enableTesting = true, } = {}) {
46
89
  const context = createContext(settings);
47
90
  const { basePath, agentPath, fallbackPath, deploymentPath, testPath, auth, user, evaluate, deploy, retrieve, set, } = context;
@@ -6,16 +6,37 @@ import { RequestAgentRoute, TestAgentRoute } from "./routes/index.js";
6
6
  import { CreateAgentRoute } from "./routes/create/index.js";
7
7
  import { Configuration } from "./types.js";
8
8
  import { Middleware } from "./routes/intercept.js";
9
+ /**
10
+ * Route path configuration parameters for the Fleet server.
11
+ *
12
+ * Extends {@link Configuration} with customizable URL paths for each endpoint,
13
+ * allowing flexible integration with existing API structures.
14
+ */
9
15
  export interface Params extends Configuration {
16
+ /** Base path prefix for all Fleet routes. Defaults to `/`. */
10
17
  basePath?: string;
18
+ /** Fallback path for agent requests. Defaults to `/.well-known/agent`. */
11
19
  fallbackPath?: string;
20
+ /** Path for agent deployment requests. Defaults to `/deploy`. */
12
21
  deploymentPath?: string;
22
+ /** Path for agent test/evaluation requests. Defaults to `/test`. */
13
23
  testPath?: string;
14
- /**Middleware addons are currently only supported on the Request Agent route */
24
+ /** Middleware addons are currently only supported on the Request Agent route. */
15
25
  middleware?: Middleware;
16
26
  }
27
+ /**
28
+ * Complete settings combining route paths with handler implementations.
29
+ *
30
+ * Defines the core operations for agent management:
31
+ * - `get`: Retrieve and execute agent requests
32
+ * - `set`: Deploy new agents or update existing ones
33
+ * - `test`: Evaluate agent behavior (optional)
34
+ */
17
35
  export interface Settings extends Params {
36
+ /** Implementation for retrieving and processing agent requests. */
18
37
  get: RequestAgentRoute["implementation"];
38
+ /** Implementation for deploying or updating agents. */
19
39
  set: CreateAgentRoute["implementation"];
40
+ /** Implementation for testing/evaluating agents. Optional. */
20
41
  test?: TestAgentRoute["implementation"];
21
42
  }
package/dist/ship.d.ts CHANGED
@@ -3,4 +3,48 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { CreateAgentRoute } from "./routes/create/index.js";
6
- export declare function ship<T extends CreateAgentRoute["request"]>(fleetUrl: string | undefined, request: T): Promise<CreateAgentRoute["response"]>;
6
+ /**
7
+ * Deploys an agent configuration to a remote Fleet server.
8
+ *
9
+ * This function serves as a client for agent deployment,
10
+ * implementing schema validation on both request and response to ensure type safety
11
+ * and data integrity across network boundaries.
12
+ *
13
+ * @see {@link https://zod.dev/ Zod Schema Validation}
14
+ *
15
+ * Schema validation will throw if the request or response doesn't match the expected
16
+ * structure. Network errors from `fetch` will propagate as-is.
17
+ *
18
+ * @template T - The agent request type, constrained to `CreateAgentRoute["request"]`
19
+ *
20
+ * @param fleetUrl - Base URL of the Fleet server. Defaults to `http://localhost:3000`
21
+ * for local development. In production, use environment variables.
22
+ * @param request - Agent configuration to deploy. Must conform to {@link armada.CreateAgentRequestSchema}.
23
+ * @param headers - Optional custom HTTP headers to include with the request. Useful for authentication tokens, correlation IDs, or distributed tracing headers.
24
+ *
25
+ * @returns Promise resolving to the deployment response, validated against {@link API.CreateAgentResponseSchema}.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Deploy to local development server
30
+ * const result = await ship("http://localhost:3000", {
31
+ * config: {
32
+ * schemaVersion: "0.1.0",
33
+ * uri: "my-agent",
34
+ * name: "My Agent",
35
+ * description: "A helpful assistant",
36
+ * modelId: "gpt-4",
37
+ * instructions: "You are a helpful assistant.",
38
+ * version: "1.0.0",
39
+ * },
40
+ * });
41
+ *
42
+ * // Deploy with authentication header
43
+ * const authResult = await ship(
44
+ * process.env.FLEET_URL!,
45
+ * agentConfig,
46
+ * { Authorization: `Bearer ${token}` }
47
+ * );
48
+ * ```
49
+ */
50
+ export declare function ship<T extends CreateAgentRoute["request"]>(fleetUrl: string | undefined, request: T, headers?: Record<string, string>): Promise<CreateAgentRoute["response"]>;
package/dist/ship.js CHANGED
@@ -5,13 +5,58 @@
5
5
  import * as sdk from "@artinet/sdk";
6
6
  import * as armada from "@artinet/armada";
7
7
  import { API } from "@artinet/types";
8
- export async function ship(fleetUrl = "http://localhost:3000", request) {
8
+ /**
9
+ * Deploys an agent configuration to a remote Fleet server.
10
+ *
11
+ * This function serves as a client for agent deployment,
12
+ * implementing schema validation on both request and response to ensure type safety
13
+ * and data integrity across network boundaries.
14
+ *
15
+ * @see {@link https://zod.dev/ Zod Schema Validation}
16
+ *
17
+ * Schema validation will throw if the request or response doesn't match the expected
18
+ * structure. Network errors from `fetch` will propagate as-is.
19
+ *
20
+ * @template T - The agent request type, constrained to `CreateAgentRoute["request"]`
21
+ *
22
+ * @param fleetUrl - Base URL of the Fleet server. Defaults to `http://localhost:3000`
23
+ * for local development. In production, use environment variables.
24
+ * @param request - Agent configuration to deploy. Must conform to {@link armada.CreateAgentRequestSchema}.
25
+ * @param headers - Optional custom HTTP headers to include with the request. Useful for authentication tokens, correlation IDs, or distributed tracing headers.
26
+ *
27
+ * @returns Promise resolving to the deployment response, validated against {@link API.CreateAgentResponseSchema}.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * // Deploy to local development server
32
+ * const result = await ship("http://localhost:3000", {
33
+ * config: {
34
+ * schemaVersion: "0.1.0",
35
+ * uri: "my-agent",
36
+ * name: "My Agent",
37
+ * description: "A helpful assistant",
38
+ * modelId: "gpt-4",
39
+ * instructions: "You are a helpful assistant.",
40
+ * version: "1.0.0",
41
+ * },
42
+ * });
43
+ *
44
+ * // Deploy with authentication header
45
+ * const authResult = await ship(
46
+ * process.env.FLEET_URL!,
47
+ * agentConfig,
48
+ * { Authorization: `Bearer ${token}` }
49
+ * );
50
+ * ```
51
+ */
52
+ export async function ship(fleetUrl = "http://localhost:3000", request, headers = {}) {
9
53
  const requestBody = await sdk.validateSchema(armada.CreateAgentRequestSchema, request);
10
54
  sdk.logger.debug(`deployAgent request:`, { requestBody });
11
55
  const response = await fetch(`${fleetUrl}/deploy`, {
12
56
  method: "POST",
13
57
  headers: {
14
58
  "Content-Type": "application/json",
59
+ ...headers,
15
60
  },
16
61
  body: JSON.stringify(requestBody),
17
62
  });
package/dist/types.d.ts CHANGED
@@ -4,8 +4,45 @@
4
4
  */
5
5
  import { RequestAgentRoute, TestAgentRoute } from "./routes/index.js";
6
6
  import { CreateAgentRoute } from "./routes/create/index.js";
7
+ /**
8
+ * Combined context type for all route handlers.
9
+ *
10
+ * Represents the intersection of context requirements across agent request,
11
+ * creation, and testing routes. Used internally for handler type safety.
12
+ */
7
13
  export type Config = RequestAgentRoute["context"] & CreateAgentRoute["context"] & TestAgentRoute["context"];
14
+ /**
15
+ * Configuration type without agent-specific identifiers.
16
+ *
17
+ * Omits `agentId` from {@link Config} for use in settings and initialization
18
+ * where the agent ID is not yet known.
19
+ */
8
20
  export type Configuration = Omit<Config, "agentId">;
21
+ /**
22
+ * Discriminated union for operation results.
23
+ *
24
+ * Provides a type-safe way to represent three possible outcomes:
25
+ * - `success`: Operation completed with a result
26
+ * - `error`: Operation failed with an error
27
+ * - `stream`: Operation returns an async iterable stream
28
+ *
29
+ * @see {@link https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions Discriminated Unions}
30
+ *
31
+ * @template Result - Type of successful result. Defaults to `unknown`.
32
+ * @template Error - Type of error payload. Defaults to `unknown`.
33
+ * @template Stream - Type of streamed items. Defaults to `unknown`.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * function handle(result: ResultOrError<User, ApiError, Chunk>) {
38
+ * switch (result.type) {
39
+ * case "success": return result.result; // User
40
+ * case "error": throw result.error; // ApiError
41
+ * case "stream": return result.stream; // AsyncIterable<Chunk>
42
+ * }
43
+ * }
44
+ * ```
45
+ */
9
46
  export type ResultOrError<Result = unknown, Error = unknown, Stream = unknown> = {
10
47
  type: "success";
11
48
  result: Result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artinet/fleet",
3
- "version": "0.1.1",
3
+ "version": "0.1.5",
4
4
  "description": "A an agentic orchestration server for on premise deployment.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -62,53 +62,52 @@
62
62
  ],
63
63
  "rootDir": ".",
64
64
  "dependencies": {
65
- "@artinet/armada": "^0.1.0",
66
- "@artinet/sdk": "^0.6.0",
67
- "@artinet/types": "^0.0.9",
65
+ "@artinet/armada": "^0.1.4",
66
+ "@artinet/sdk": "^0.6.4",
67
+ "@artinet/types": "^0.1.4",
68
68
  "@sindresorhus/slugify": "^3.0.0",
69
- "agent-def": "^0.1.0",
70
- "orc8": "^0.1.0",
69
+ "agent-def": "^0.1.4",
70
+ "orc8": "^0.1.4",
71
71
  "zod": "^3.25"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@a2a-js/sdk": "^0.3.7",
75
75
  "@modelcontextprotocol/sdk": "^1.24.3",
76
76
  "@opentelemetry/api": "^1.9.0",
77
+ "drizzle-orm": "^0.45.1",
77
78
  "express": "^5.2.1",
78
79
  "hono": "^4.11.3",
79
80
  "openai": "^6.15.0",
80
- "pino": "^10.1.0",
81
- "drizzle-orm": "^0.45.1"
81
+ "pino": "^10.1.0"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@a2a-js/sdk": "^0.3.7",
85
- "@artinet/loader": "^0.0.1",
86
- "@eslint/js": "^9.25.1",
85
+ "@eslint/js": "^9.39.2",
87
86
  "@modelcontextprotocol/sdk": "^1.24.3",
88
87
  "@types/better-sqlite3": "^7.6.13",
89
- "@types/express": "^5.0.0",
88
+ "@types/express": "^5.0.6",
90
89
  "@types/jest": "^29.5.14",
91
- "@types/node": "^22.19.3",
90
+ "@types/node": "^25.0.9",
92
91
  "@types/supertest": "^6.0.3",
93
92
  "autocannon": "^8.0.0",
94
93
  "better-sqlite3": "^12.5.0",
95
94
  "drizzle-orm": "^0.45.1",
96
- "eslint": "^9.25.1",
95
+ "eslint": "^9.39.2",
97
96
  "express": "^5.2.1",
98
- "globals": "^16.0.0",
99
- "hono": "^4.11.3",
100
- "jest": "^29.7.0",
101
- "pino": "^10.1.0",
97
+ "globals": "^17.0.0",
98
+ "hono": "^4.11.4",
99
+ "jest": "29.7.0",
100
+ "pino": "^10.2.0",
102
101
  "pm2": "^6.0.14",
103
- "rimraf": "^5.0.5",
102
+ "rimraf": "^6.1.2",
104
103
  "supertest": "latest",
105
- "ts-jest": "^29.3.2",
104
+ "ts-jest": "^29.4.6",
106
105
  "ts-node": "^10.9.2",
107
- "typescript": "^5.8.3",
108
- "typescript-eslint": "^8.31.1",
106
+ "typescript": "^5.9.3",
107
+ "typescript-eslint": "^8.53.0",
109
108
  "undici": "^5.29.0"
110
109
  },
111
110
  "engines": {
112
- "node": ">=18.9.1"
111
+ "node": ">=20.0.0"
113
112
  }
114
113
  }