@artinet/fleet 0.1.0-alpha.1 → 0.1.0-alpha.2
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/README.md +112 -24
- package/dist/{src/default.d.ts → default.d.ts} +3 -3
- package/dist/{src/default.js → default.js} +1 -1
- package/dist/{src/index.d.ts → index.d.ts} +2 -1
- package/dist/{src/index.js → index.js} +2 -1
- package/dist/{src/routes → routes}/create/index.d.ts +2 -2
- package/dist/{src/routes → routes}/request/implementation/invoke.d.ts +4 -0
- package/dist/{src/routes → routes}/request/implementation/invoke.js +4 -0
- package/dist/{src/routes → routes}/request/implementation/load.d.ts +4 -0
- package/dist/{src/routes → routes}/request/implementation/load.js +4 -0
- package/dist/{src/routes → routes}/request/implementation/request.d.ts +4 -0
- package/dist/{src/routes → routes}/request/implementation/request.js +20 -1
- package/dist/{src/routes → routes}/request/implementation/test-invoke.d.ts +4 -0
- package/dist/{src/routes → routes}/request/implementation/test-invoke.js +4 -0
- package/dist/{src/routes → routes}/request/interceptors/fetch-agent.d.ts +4 -0
- package/dist/{src/routes → routes}/request/interceptors/fetch-agent.js +4 -0
- package/dist/{src/routes → routes}/request/interceptors/get-agents.d.ts +4 -0
- package/dist/{src/routes → routes}/request/interceptors/get-agents.js +4 -0
- package/dist/{src/routes → routes}/request/request.d.ts +4 -0
- package/dist/{src/routes → routes}/request/request.js +4 -0
- package/dist/{src/routes → routes}/request/types/definitions.d.ts +4 -0
- package/dist/{src/routes → routes}/request/types/definitions.js +4 -0
- package/dist/{src/server → server}/express/agent-request.d.ts +4 -0
- package/dist/{src/server → server}/express/agent-request.js +4 -0
- package/dist/{src/server → server}/express/deploy-request.d.ts +4 -0
- package/dist/{src/server → server}/express/deploy-request.js +4 -0
- package/dist/{src/server → server}/express/rpc.d.ts +4 -0
- package/dist/{src/server → server}/express/rpc.js +4 -0
- package/dist/{src/server → server}/express/server.d.ts +5 -1
- package/dist/{src/server → server}/express/server.js +11 -3
- package/dist/{src/server → server}/express/test-request.d.ts +4 -0
- package/dist/{src/server → server}/express/test-request.js +4 -0
- package/dist/{src/server → server}/express/utils.d.ts +4 -0
- package/dist/{src/server → server}/express/utils.js +4 -0
- package/dist/server/hono/agent-request.d.ts +29 -0
- package/dist/server/hono/agent-request.js +52 -0
- package/dist/server/hono/deploy-request.d.ts +17 -0
- package/dist/server/hono/deploy-request.js +26 -0
- package/dist/server/hono/error-handler.d.ts +9 -0
- package/dist/server/hono/error-handler.js +41 -0
- package/dist/server/hono/fleet.d.ts +3 -0
- package/dist/server/hono/fleet.js +2 -0
- package/dist/server/hono/index.d.ts +4 -0
- package/dist/server/hono/index.js +4 -0
- package/dist/server/hono/rpc.d.ts +16 -0
- package/dist/server/hono/rpc.js +49 -0
- package/dist/server/hono/server.d.ts +30 -0
- package/dist/server/hono/server.js +120 -0
- package/dist/server/hono/test-request.d.ts +17 -0
- package/dist/server/hono/test-request.js +56 -0
- package/dist/server/hono/utils.d.ts +8 -0
- package/dist/server/hono/utils.js +12 -0
- package/dist/{src/server → server}/index.d.ts +1 -0
- package/dist/{src/server → server}/index.js +1 -0
- package/dist/{src/settings.d.ts → settings.d.ts} +4 -0
- package/dist/settings.js +5 -0
- package/dist/{src/ship.d.ts → ship.d.ts} +4 -0
- package/dist/{src/ship.js → ship.js} +6 -2
- package/dist/{src/storage.d.ts → storage/in-memory.d.ts} +4 -0
- package/dist/{src/storage.js → storage/in-memory.js} +4 -0
- package/dist/storage/sqlite.d.ts +1388 -0
- package/dist/storage/sqlite.js +80 -0
- package/dist/{src/types.d.ts → types.d.ts} +4 -0
- package/dist/types.js +5 -0
- package/package.json +30 -6
- package/dist/src/settings.js +0 -1
- package/dist/src/types.js +0 -1
- /package/dist/{src/routes → routes}/create/index.js +0 -0
- /package/dist/{src/routes → routes}/index.d.ts +0 -0
- /package/dist/{src/routes → routes}/index.js +0 -0
- /package/dist/{src/routes → routes}/request/implementation/index.d.ts +0 -0
- /package/dist/{src/routes → routes}/request/implementation/index.js +0 -0
- /package/dist/{src/routes → routes}/request/index.d.ts +0 -0
- /package/dist/{src/routes → routes}/request/index.js +0 -0
- /package/dist/{src/routes → routes}/request/interceptors/index.d.ts +0 -0
- /package/dist/{src/routes → routes}/request/interceptors/index.js +0 -0
- /package/dist/{src/routes → routes}/request/types/index.d.ts +0 -0
- /package/dist/{src/routes → routes}/request/types/index.js +0 -0
- /package/dist/{src/server → server}/express/fleet.d.ts +0 -0
- /package/dist/{src/server → server}/express/fleet.js +0 -0
- /package/dist/{src/server → server}/express/index.d.ts +0 -0
- /package/dist/{src/server → server}/express/index.js +0 -0
package/README.md
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://artinet.io"><img src="https://img.shields.io/badge/website-artinet.io-black" alt="Website"></a>
|
|
3
|
+
<a href="https://www.npmjs.com/package/@artinet/fleet"><img src="https://img.shields.io/npm/v/@artinet/fleet?color=black" alt="Downloads"></a>
|
|
4
|
+
<a><img src="https://img.shields.io/badge/License-Apache_2.0-black.svg" alt="License"></a>
|
|
5
|
+
<a href="https://snyk.io/test/npm/@artinet/fleet"><img src="https://snyk.io/test/npm/@artinet/fleet/badge.svg" alt="Known Vulnerabilities"></a>
|
|
6
|
+
</p>
|
|
7
|
+
<h1 align="center"><em>fleet</em></h1>
|
|
8
8
|
|
|
9
9
|
Deploy AI agents on any infrastructure.
|
|
10
10
|
|
|
11
11
|
Fleet is a lightweight server framework for hosting [A2A Protocol](https://github.com/google-a2a/A2A) agents with built-in orchestration, tool integration (MCP), and Agent2Agent communication.
|
|
12
12
|
|
|
13
|
-
> 🚧 **More servers coming soon** — Hono, Bun, and standalone adapters are on the roadmap.
|
|
14
|
-
|
|
15
13
|
## Installation
|
|
16
14
|
|
|
17
15
|
```bash
|
|
18
|
-
npm install @artinet/fleet
|
|
16
|
+
npm install @artinet/fleet openai @modelcontextprotocol/sdk @a2a-js/sdk
|
|
19
17
|
```
|
|
20
18
|
|
|
21
19
|
**Requirements:** Node.js ≥ 18.9.1
|
|
@@ -26,12 +24,32 @@ npm install @artinet/fleet express openai @modelcontextprotocol/sdk
|
|
|
26
24
|
|
|
27
25
|
Set an `OPENAI_API_KEY` in you environment variables, then start your Server.
|
|
28
26
|
|
|
27
|
+
**Express**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install express
|
|
31
|
+
```
|
|
32
|
+
|
|
29
33
|
```typescript
|
|
30
34
|
import { fleet } from "@artinet/fleet/express";
|
|
31
35
|
|
|
32
36
|
const { app } = fleet().launch(3000);
|
|
33
37
|
```
|
|
34
38
|
|
|
39
|
+
**Hono**:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install hono
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { fleet } from "@artinet/fleet/hono";
|
|
47
|
+
|
|
48
|
+
const { app } = fleet().launch(3000);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> 🚧 **More servers coming soon** — Bun adapters and edge support are on the roadmap.
|
|
52
|
+
|
|
35
53
|
That's it. You now have:
|
|
36
54
|
|
|
37
55
|
- `POST /deploy` — Deploy agents
|
|
@@ -152,6 +170,76 @@ for await (const update of client.sendStreamingMessage("Tell me a story")) {
|
|
|
152
170
|
}
|
|
153
171
|
```
|
|
154
172
|
|
|
173
|
+
### SQLite Storage
|
|
174
|
+
|
|
175
|
+
Set up a SQLite Database with [drizzle](https://www.npmjs.com/package/drizzle-orm):
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
npm install drizzle-orm better-sqlite3
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import { SQLiteStore, AgentsTable } from "@artinet/fleet/sqlite";
|
|
183
|
+
import { fleet } from "@artinet/fleet/hono";
|
|
184
|
+
/*Use any drizzle compatible Database*/
|
|
185
|
+
import Database from "better-sqlite3";
|
|
186
|
+
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
187
|
+
|
|
188
|
+
const sqlite = new Database("fleet.db");
|
|
189
|
+
const db = drizzle<AgentsTable>(sqlite);
|
|
190
|
+
|
|
191
|
+
fleet({
|
|
192
|
+
storage: new SQLiteStore(db),
|
|
193
|
+
}).launch(3000);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Logging
|
|
197
|
+
|
|
198
|
+
Settup a custom logger via the [@artinet/sdk](https://www.npmjs.com/package/@artinet/sdk):
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
npm install @artinet/sdk pino pino-pretty
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import { configure } from "@artinet/sdk";
|
|
206
|
+
import { configurePino } from "@artinet/sdk/pino";
|
|
207
|
+
import pino from "pino";
|
|
208
|
+
|
|
209
|
+
configure({
|
|
210
|
+
logger: configurePino(
|
|
211
|
+
pino({
|
|
212
|
+
level: "info",
|
|
213
|
+
transport: {
|
|
214
|
+
target: "pino-pretty",
|
|
215
|
+
options: { colorize: true },
|
|
216
|
+
},
|
|
217
|
+
})
|
|
218
|
+
),
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## [Docker Configuration](https://github.com/the-artinet-project/artinet/blob/main/fleet/dockerfile)
|
|
223
|
+
|
|
224
|
+
Build the docker image:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
docker build -t artinet-fleet .
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Copy the example and fill in your values:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
cp .env.example .env
|
|
234
|
+
# Edit .env with your API keys
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Run:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
docker run --env-file .env -v fleet-data:/data -p 3000:3000 -e PORT=3000 artinet-fleet
|
|
241
|
+
```
|
|
242
|
+
|
|
155
243
|
<!-- ## Custom Handlers
|
|
156
244
|
|
|
157
245
|
```typescript
|
|
@@ -190,17 +278,17 @@ const app = fleet(
|
|
|
190
278
|
app.listen(3000);
|
|
191
279
|
``` -->
|
|
192
280
|
|
|
193
|
-
##
|
|
281
|
+
## Settings
|
|
194
282
|
|
|
195
|
-
| Option | Type | Default
|
|
196
|
-
| ---------------------- | ------------ |
|
|
197
|
-
| `storage` | `IDataStore` | `InMemoryStore` | Agent storage backend (storage adapters coming soon) |
|
|
198
|
-
| `basePath` | `string` | `"/"`
|
|
199
|
-
| `agentPath` | `string` | `"/agentId"`
|
|
200
|
-
| `deploymentPath` | `string` | `"/deploy"`
|
|
201
|
-
| `testPath` | `string` | `"/test"`
|
|
202
|
-
| `inferenceProviderUrl` | `string` | `undefined`
|
|
203
|
-
| `load` | `function` | `loadAgent`
|
|
283
|
+
| Option | Type | Default | Description |
|
|
284
|
+
| ---------------------- | ------------ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
285
|
+
| `storage` | `IDataStore` | `InMemoryStore`, `SQLiteStore` | Agent storage backend (storage adapters coming soon) |
|
|
286
|
+
| `basePath` | `string` | `"/"` | Base path for all routes |
|
|
287
|
+
| `agentPath` | `string` | `"/agentId"` | Agent interaction path |
|
|
288
|
+
| `deploymentPath` | `string` | `"/deploy"` | Deployment endpoint |
|
|
289
|
+
| `testPath` | `string` | `"/test"` | Test endpoint |
|
|
290
|
+
| `inferenceProviderUrl` | `string` | `undefined` | An OpenAI API compatible endpoint |
|
|
291
|
+
| `load` | `function` | `loadAgent` | Returns an A2A Protocol compliant agent wrapped in the [`@artinet/sdk`](<(https://github.com/the-artinet-project/artinet-sdk)>) |
|
|
204
292
|
|
|
205
293
|
## API Reference
|
|
206
294
|
|
|
@@ -209,7 +297,7 @@ app.listen(3000);
|
|
|
209
297
|
| Method | Path | Description |
|
|
210
298
|
| ------ | ------------------------------------------ | -------------------- |
|
|
211
299
|
| POST | `/deploy` | Deploy a new agent |
|
|
212
|
-
| POST | `/test` | Test
|
|
300
|
+
| POST | `/test` | Test a new agent |
|
|
213
301
|
| GET | `/agentId/:id/.well-known/agent-card.json` | Get agent card |
|
|
214
302
|
| POST | `/agentId/:id` | JSON-RPC interaction |
|
|
215
303
|
|
|
@@ -228,14 +316,14 @@ app.listen(3000);
|
|
|
228
316
|
```
|
|
229
317
|
|
|
230
318
|
@artinet/fleet
|
|
231
|
-
├── /express # Express adapter
|
|
232
|
-
├── /hono #
|
|
319
|
+
├── /express # Express adapter
|
|
320
|
+
├── /hono # Hono adapter
|
|
233
321
|
└── /bun # Coming soon
|
|
234
322
|
|
|
235
323
|
Depends on:
|
|
236
324
|
├── @artinet/armada # Core business logic
|
|
237
325
|
├── @artinet/sdk # A2A protocol client/server
|
|
238
|
-
├── orc8 # Agent orchestration
|
|
326
|
+
├── orc8 # Agent/Tool orchestration
|
|
239
327
|
├── agent-def # Standardized Agent Definitions
|
|
240
328
|
├── openai # OpenAI API Client
|
|
241
329
|
└── @mcp # @modelcontextprotocol/sdk
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as armada from "@artinet/armada";
|
|
2
|
-
import { InMemoryStore } from "./storage.js";
|
|
2
|
+
import { InMemoryStore } from "./storage/in-memory.js";
|
|
3
3
|
export declare const DEFAULTS: {
|
|
4
4
|
basePath: string;
|
|
5
5
|
agentPath: string;
|
|
@@ -299,7 +299,7 @@ export declare const DEFAULTS: {
|
|
|
299
299
|
openWorldHint?: boolean | undefined;
|
|
300
300
|
} | undefined;
|
|
301
301
|
execution?: {
|
|
302
|
-
taskSupport?: "
|
|
302
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
303
303
|
} | undefined;
|
|
304
304
|
_meta?: Record<string, unknown> | undefined;
|
|
305
305
|
icons?: {
|
|
@@ -426,7 +426,7 @@ export declare const DEFAULTS: {
|
|
|
426
426
|
openWorldHint?: boolean | undefined;
|
|
427
427
|
} | undefined;
|
|
428
428
|
execution?: {
|
|
429
|
-
taskSupport?: "
|
|
429
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
430
430
|
} | undefined;
|
|
431
431
|
_meta?: Record<string, unknown> | undefined;
|
|
432
432
|
icons?: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as armada from "@artinet/armada";
|
|
2
2
|
import { RequestAgent, CreateAgent, TestAgent, loadAgent, invokeAgent, } from "./routes/index.js";
|
|
3
|
-
import { InMemoryStore } from "./storage.js";
|
|
3
|
+
import { InMemoryStore } from "./storage/in-memory.js";
|
|
4
4
|
export const DEFAULTS = {
|
|
5
5
|
basePath: "/",
|
|
6
6
|
agentPath: armada.RETRIEVE_DEPLOYMENT_PATH,
|
|
@@ -2,5 +2,6 @@ export * from "./server/index.js";
|
|
|
2
2
|
export * from "./routes/index.js";
|
|
3
3
|
export * from "./settings.js";
|
|
4
4
|
export * from "./types.js";
|
|
5
|
-
export * from "./storage.js";
|
|
6
5
|
export * from "./ship.js";
|
|
6
|
+
export * from "./storage/in-memory.js";
|
|
7
|
+
export * from "./storage/sqlite.js";
|
|
@@ -2,5 +2,6 @@ export * from "./server/index.js";
|
|
|
2
2
|
export * from "./routes/index.js";
|
|
3
3
|
export * from "./settings.js";
|
|
4
4
|
export * from "./types.js";
|
|
5
|
-
export * from "./storage.js";
|
|
6
5
|
export * from "./ship.js";
|
|
6
|
+
export * from "./storage/in-memory.js";
|
|
7
|
+
export * from "./storage/sqlite.js";
|
|
@@ -292,7 +292,7 @@ export declare const CreateAgent: armada.Implementation<{
|
|
|
292
292
|
openWorldHint?: boolean | undefined;
|
|
293
293
|
} | undefined;
|
|
294
294
|
execution?: {
|
|
295
|
-
taskSupport?: "
|
|
295
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
296
296
|
} | undefined;
|
|
297
297
|
_meta?: Record<string, unknown> | undefined;
|
|
298
298
|
icons?: {
|
|
@@ -419,7 +419,7 @@ export declare const CreateAgent: armada.Implementation<{
|
|
|
419
419
|
openWorldHint?: boolean | undefined;
|
|
420
420
|
} | undefined;
|
|
421
421
|
execution?: {
|
|
422
|
-
taskSupport?: "
|
|
422
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
423
423
|
} | undefined;
|
|
424
424
|
_meta?: Record<string, unknown> | undefined;
|
|
425
425
|
icons?: {
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import { AgentConfigurationSchema } from "agent-def";
|
|
2
6
|
import * as sdk from "@artinet/sdk";
|
|
7
|
+
async function load(context, target) {
|
|
8
|
+
/**Check the cache first */
|
|
9
|
+
if (context.agents?.[target.uri]) {
|
|
10
|
+
return context.agents?.[target.uri];
|
|
11
|
+
}
|
|
12
|
+
const agent = (await context.load(target, context));
|
|
13
|
+
/**Cache the agent for future requests */
|
|
14
|
+
if (agent) {
|
|
15
|
+
context.agents = {
|
|
16
|
+
...context.agents,
|
|
17
|
+
[target.uri]: agent,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return agent;
|
|
21
|
+
}
|
|
3
22
|
export const requestImplementation = async (request, context) => {
|
|
4
23
|
if (!context.target) {
|
|
5
24
|
throw sdk.INTERNAL_ERROR({
|
|
@@ -8,7 +27,7 @@ export const requestImplementation = async (request, context) => {
|
|
|
8
27
|
});
|
|
9
28
|
}
|
|
10
29
|
const agentConfig = await sdk.validateSchema(AgentConfigurationSchema, context.target);
|
|
11
|
-
const agent = await
|
|
30
|
+
const agent = await load(context, agentConfig);
|
|
12
31
|
if (!agent) {
|
|
13
32
|
throw sdk.INTERNAL_ERROR({
|
|
14
33
|
data: {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import { TestAgentRoute } from "../types/definitions.js";
|
|
2
6
|
import { Agent } from "../types/definitions.js";
|
|
3
7
|
export declare const testInvoke: (request: TestAgentRoute["request"], _agent: Agent) => Promise<TestAgentRoute["response"] | null>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import { RequestAgentRoute, TestAgentRoute } from "./types/definitions.js";
|
|
2
6
|
export declare const requestAgent: (request: RequestAgentRoute["request"], context: RequestAgentRoute["context"], requestFn?: RequestAgentRoute["implementation"]) => Promise<RequestAgentRoute["response"]>;
|
|
3
7
|
export declare const RequestAgent: RequestAgentRoute["implementation"];
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import express from "express";
|
|
2
6
|
import { CreateAgentRoute } from "../../routes/create/index.js";
|
|
3
7
|
export type handler = (req: express.Request, res: express.Response, next: express.NextFunction, context: CreateAgentRoute["context"], deploy?: CreateAgentRoute["implementation"]) => Promise<void>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import { CreateAgent, CreateAgentRequestSchema, } from "../../routes/create/index.js";
|
|
2
6
|
import { generateRequestId, generateRegistrationId } from "./utils.js";
|
|
3
7
|
import { logger, validateSchema } from "@artinet/sdk";
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import { Server } from "http";
|
|
2
6
|
import express from "express";
|
|
3
7
|
import { CreateAgentRoute } from "../../routes/create/index.js";
|
|
@@ -20,7 +24,7 @@ export interface Options {
|
|
|
20
24
|
export declare function fleet(settings?: Partial<Settings>, { app, authOnRetrieve, enableTesting, }?: Options): {
|
|
21
25
|
app: express.Application;
|
|
22
26
|
launch: (port: number) => Server;
|
|
23
|
-
ship: (agents: CreateAgentRoute["request"][]) => Promise<{
|
|
27
|
+
ship: (agents: CreateAgentRoute["request"][], userId?: string) => Promise<{
|
|
24
28
|
launch: (port?: number) => Server;
|
|
25
29
|
}>;
|
|
26
30
|
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import * as sdk from "@artinet/sdk";
|
|
2
6
|
import express from "express";
|
|
3
7
|
import { DEFAULTS } from "../../default.js";
|
|
@@ -27,8 +31,9 @@ const createRequestContext = (context) => {
|
|
|
27
31
|
found: undefined,
|
|
28
32
|
target: undefined,
|
|
29
33
|
defaultInstructions: undefined,
|
|
34
|
+
/**cache agents in memory so we don't have to load them from storage on every request */
|
|
35
|
+
// agents: undefined,
|
|
30
36
|
agentId: undefined,
|
|
31
|
-
agents: undefined,
|
|
32
37
|
requestId: undefined,
|
|
33
38
|
timestamp: undefined,
|
|
34
39
|
};
|
|
@@ -86,9 +91,12 @@ export function fleet(settings = DEFAULTS, { app = express(), authOnRetrieve = f
|
|
|
86
91
|
sdk.logger.info(`Fleet server running on http://localhost:${port}`);
|
|
87
92
|
});
|
|
88
93
|
};
|
|
89
|
-
const ship = async (agents) => {
|
|
94
|
+
const ship = async (agents, userId) => {
|
|
90
95
|
for (const agent of agents) {
|
|
91
|
-
const response = await set(agent,
|
|
96
|
+
const response = await set(agent, {
|
|
97
|
+
...createRequestContext(context),
|
|
98
|
+
userId: userId ?? (await user?.({})),
|
|
99
|
+
});
|
|
92
100
|
if (response.success) {
|
|
93
101
|
sdk.logger.info(`Agent shipped: ${response.agentId}`);
|
|
94
102
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
import express from "express";
|
|
2
6
|
import { TestAgentRoute } from "../../routes/request/index.js";
|
|
3
7
|
export type handler = (req: express.Request, res: express.Response, next: express.NextFunction, context: TestAgentRoute["context"], test?: TestAgentRoute["implementation"]) => Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 The Artinet Project
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import * as hono from "hono";
|
|
6
|
+
import { RequestAgentRoute, RequestContext } from "../../routes/request/index.js";
|
|
7
|
+
export declare const AGENT_FIELD_NAME = "agentId";
|
|
8
|
+
export type handler = (ctx: hono.Context, next: hono.Next, context: RequestContext, request?: RequestAgentRoute["implementation"]) => Promise<void>;
|
|
9
|
+
export declare function handle(ctx: hono.Context, _next: hono.Next, context: RequestContext, request?: RequestAgentRoute["implementation"]): Promise<void>;
|
|
10
|
+
export declare const factory: (request?: RequestAgentRoute["implementation"]) => handler;
|
|
11
|
+
/**
|
|
12
|
+
* Handler utilities for agent HTTP requests.
|
|
13
|
+
*
|
|
14
|
+
* Exports a reusable handler function for routing requests to agent instances,
|
|
15
|
+
* verifying agentId route param, and returning agent metadata
|
|
16
|
+
* or dispatching to JSON-RPC middleware as appropriate.
|
|
17
|
+
*
|
|
18
|
+
* Used by the deployment server to provide a standard agent endpoint interface.
|
|
19
|
+
*
|
|
20
|
+
* @module server/handlers/agent
|
|
21
|
+
*/
|
|
22
|
+
export interface Params {
|
|
23
|
+
ctx: hono.Context;
|
|
24
|
+
next: hono.Next;
|
|
25
|
+
context: Omit<RequestContext, "agentId">;
|
|
26
|
+
handler: handler;
|
|
27
|
+
user: (ctx: hono.Context) => Promise<string>;
|
|
28
|
+
}
|
|
29
|
+
export declare function request({ ctx, next, context, handler, user, }: Params): Promise<void>;
|