@rcrsr/rill-agent-foundry 0.19.0 → 0.20.0
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/dist/index.d.ts +66 -2
- package/dist/index.js +50 -0
- package/package.json +7 -4
package/dist/index.d.ts
CHANGED
|
@@ -266,6 +266,17 @@ export interface HandlerDescription {
|
|
|
266
266
|
readonly description?: string | undefined;
|
|
267
267
|
readonly defaultValue?: unknown;
|
|
268
268
|
}>;
|
|
269
|
+
/**
|
|
270
|
+
* Handler return type annotation, formatted with the same grammar as
|
|
271
|
+
* parameter type strings (e.g. `stream(dict(content: string)):string`).
|
|
272
|
+
* Undefined when the handler closure has no `:T` annotation, or when the
|
|
273
|
+
* rill-build emitting the handler is too old to expose the field.
|
|
274
|
+
*/
|
|
275
|
+
readonly returnType?: string | undefined;
|
|
276
|
+
}
|
|
277
|
+
export interface InitContext {
|
|
278
|
+
readonly globalVars?: Record<string, string> | undefined;
|
|
279
|
+
readonly ahiResolver?: ((agentName: string, request: RunRequest) => Promise<RunResponse>) | undefined;
|
|
269
280
|
}
|
|
270
281
|
export interface RunRequest {
|
|
271
282
|
readonly params?: Record<string, unknown> | undefined;
|
|
@@ -275,13 +286,25 @@ export interface RunContext {
|
|
|
275
286
|
readonly sessionVars?: Record<string, string> | undefined;
|
|
276
287
|
readonly onLog?: ((message: string) => void) | undefined;
|
|
277
288
|
readonly onChunk?: ((chunk: unknown) => Promise<void>) | undefined;
|
|
289
|
+
readonly signal?: AbortSignal | undefined;
|
|
278
290
|
}
|
|
279
291
|
export interface RunResponse {
|
|
280
292
|
readonly state: "completed" | "error";
|
|
281
293
|
readonly result: unknown;
|
|
282
294
|
readonly streamed?: boolean | undefined;
|
|
283
295
|
}
|
|
296
|
+
export interface AgentHandler {
|
|
297
|
+
describe(): HandlerDescription | null;
|
|
298
|
+
init(context?: InitContext): Promise<void>;
|
|
299
|
+
execute(request?: RunRequest, context?: RunContext): Promise<RunResponse>;
|
|
300
|
+
dispose(): Promise<void>;
|
|
301
|
+
}
|
|
302
|
+
export interface AgentManifest {
|
|
303
|
+
readonly defaultAgent: string;
|
|
304
|
+
readonly agents: ReadonlyMap<string, AgentHandler>;
|
|
305
|
+
}
|
|
284
306
|
export interface AgentRouter {
|
|
307
|
+
readonly manifest: AgentManifest;
|
|
285
308
|
run(agentName: string, request: RunRequest, context?: RunContext): Promise<RunResponse>;
|
|
286
309
|
describe(agentName: string): HandlerDescription | null;
|
|
287
310
|
agents(): string[];
|
|
@@ -300,13 +323,13 @@ export declare function buildSyncResponse(result: RunResponse, responseId: strin
|
|
|
300
323
|
*
|
|
301
324
|
* When debug is true, the original message is passed through verbatim.
|
|
302
325
|
* When debug is false or absent, a generic message is returned based on
|
|
303
|
-
* the error code
|
|
326
|
+
* the error code (FOUNDRY_AGENT_DEBUG_ERRORS=false behavior).
|
|
304
327
|
*/
|
|
305
328
|
export declare function buildErrorResponse(code: string, message: string, debug?: boolean): ErrorResponse;
|
|
306
329
|
/**
|
|
307
330
|
* Generate Foundry tool definitions from the default agent's handler descriptions.
|
|
308
331
|
*
|
|
309
|
-
* Only the default agent's handlers are exposed
|
|
332
|
+
* Only the default agent's handlers are exposed.
|
|
310
333
|
* Returns an empty array when describe() returns null.
|
|
311
334
|
*/
|
|
312
335
|
export declare function generateToolDefinitions(router: AgentRouter): FoundryToolDefinition[];
|
|
@@ -394,5 +417,46 @@ export interface FoundryHarness {
|
|
|
394
417
|
* GET /metrics — FoundryMetrics JSON
|
|
395
418
|
*/
|
|
396
419
|
export declare function createFoundryHarness(router: AgentRouter, options?: FoundryHarnessOptions): FoundryHarness;
|
|
420
|
+
export interface RillHarnessLogger {
|
|
421
|
+
info(...args: unknown[]): void;
|
|
422
|
+
warn(...args: unknown[]): void;
|
|
423
|
+
error(...args: unknown[]): void;
|
|
424
|
+
}
|
|
425
|
+
export interface RillCompiledPackage {
|
|
426
|
+
readonly mount: string;
|
|
427
|
+
readonly buildOutput: {
|
|
428
|
+
readonly outputPath: string;
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
export interface RillServeContext {
|
|
432
|
+
readonly config: Record<string, unknown>;
|
|
433
|
+
readonly logger: RillHarnessLogger;
|
|
434
|
+
readonly packages: readonly RillCompiledPackage[];
|
|
435
|
+
readonly requestedMount: string | undefined;
|
|
436
|
+
readonly args: readonly string[];
|
|
437
|
+
readonly onShutdown: (handler: () => void | Promise<void>) => void;
|
|
438
|
+
readonly onSourceChange: (handler: () => void | Promise<void>) => void;
|
|
439
|
+
}
|
|
440
|
+
export interface RillPostBuildContext {
|
|
441
|
+
readonly outputDir: string;
|
|
442
|
+
readonly packages: readonly RillCompiledPackage[];
|
|
443
|
+
readonly logger: RillHarnessLogger;
|
|
444
|
+
}
|
|
445
|
+
export interface RillHarness {
|
|
446
|
+
readonly name: string;
|
|
447
|
+
readonly postBuild?: (ctx: RillPostBuildContext) => Promise<void>;
|
|
448
|
+
readonly serve?: (ctx: RillServeContext) => Promise<number>;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Default export consumed by the rill CLI (`rill install --replace`,
|
|
452
|
+
* `rill run`) when this package is declared as a bundle harness. `serve`
|
|
453
|
+
* assembles a router from the bundle's compiled packages and hosts it over the
|
|
454
|
+
* Foundry Responses harness on `config.port` (default 3000).
|
|
455
|
+
*/
|
|
456
|
+
declare const harness: RillHarness;
|
|
457
|
+
|
|
458
|
+
export {
|
|
459
|
+
harness as default,
|
|
460
|
+
};
|
|
397
461
|
|
|
398
462
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -526,6 +526,8 @@ import { DefaultAzureCredential } from "@azure/identity";
|
|
|
526
526
|
import { validateParams, routerErrorToStatus } from "@rcrsr/rill-agent";
|
|
527
527
|
|
|
528
528
|
// ../../shared/hono-kit/src/index.ts
|
|
529
|
+
import { existsSync } from "fs";
|
|
530
|
+
import path from "path";
|
|
529
531
|
import { Hono } from "hono";
|
|
530
532
|
import { serve } from "@hono/node-server";
|
|
531
533
|
function assertJsonObject(parsed) {
|
|
@@ -556,6 +558,34 @@ function createHarnessLifecycle(options) {
|
|
|
556
558
|
}
|
|
557
559
|
return { app, listen, close };
|
|
558
560
|
}
|
|
561
|
+
function compiledPackageEntries(ctx) {
|
|
562
|
+
return ctx.packages.map((p) => ({
|
|
563
|
+
name: p.mount,
|
|
564
|
+
dir: p.buildOutput.outputPath
|
|
565
|
+
}));
|
|
566
|
+
}
|
|
567
|
+
function readHarnessPort(config, fallback) {
|
|
568
|
+
const p = config["port"];
|
|
569
|
+
if (typeof p === "number" && Number.isInteger(p)) return p;
|
|
570
|
+
if (typeof p === "string" && /^\d+$/.test(p)) return Number(p);
|
|
571
|
+
return fallback;
|
|
572
|
+
}
|
|
573
|
+
function assertCompiledHandlers(ctx) {
|
|
574
|
+
for (const pkg of ctx.packages) {
|
|
575
|
+
const handlerPath = path.join(pkg.buildOutput.outputPath, "handler.js");
|
|
576
|
+
if (!existsSync(handlerPath)) {
|
|
577
|
+
throw new Error(`missing handler file: ${handlerPath}`);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
async function runRillServe(ctx, start) {
|
|
582
|
+
const handle = await start(compiledPackageEntries(ctx));
|
|
583
|
+
ctx.onShutdown(async () => {
|
|
584
|
+
await handle.close();
|
|
585
|
+
});
|
|
586
|
+
return new Promise(() => {
|
|
587
|
+
});
|
|
588
|
+
}
|
|
559
589
|
|
|
560
590
|
// src/harness.ts
|
|
561
591
|
var DEFAULT_PORT = 8088;
|
|
@@ -948,6 +978,25 @@ function createFoundryHarness(router, options) {
|
|
|
948
978
|
}
|
|
949
979
|
return { listen, close, app, metrics };
|
|
950
980
|
}
|
|
981
|
+
|
|
982
|
+
// src/index.ts
|
|
983
|
+
import { createRouter, assembleManifest } from "@rcrsr/rill-agent";
|
|
984
|
+
var HARNESS_NAME = "@rcrsr/rill-agent-foundry";
|
|
985
|
+
var harness = {
|
|
986
|
+
name: HARNESS_NAME,
|
|
987
|
+
postBuild: async (ctx) => {
|
|
988
|
+
assertCompiledHandlers(ctx);
|
|
989
|
+
},
|
|
990
|
+
serve: (ctx) => runRillServe(ctx, async (entries) => {
|
|
991
|
+
const router = await createRouter(await assembleManifest(entries));
|
|
992
|
+
const port = readHarnessPort(ctx.config, 3e3);
|
|
993
|
+
const server = createFoundryHarness(router, { port });
|
|
994
|
+
await server.listen();
|
|
995
|
+
ctx.logger.info(`[${HARNESS_NAME}] listening on :${port}`);
|
|
996
|
+
return server;
|
|
997
|
+
})
|
|
998
|
+
};
|
|
999
|
+
var index_default = harness;
|
|
951
1000
|
export {
|
|
952
1001
|
CapacityError,
|
|
953
1002
|
CredentialError,
|
|
@@ -959,6 +1008,7 @@ export {
|
|
|
959
1008
|
createFoundryHarness,
|
|
960
1009
|
createIdGenerator,
|
|
961
1010
|
createSessionManager,
|
|
1011
|
+
index_default as default,
|
|
962
1012
|
extractInput,
|
|
963
1013
|
generateId,
|
|
964
1014
|
generateToolDefinitions,
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rcrsr/rill-agent-foundry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "rill agent foundry — Azure-hosted harness factory",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Andre Bremer",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"rill": {
|
|
9
|
+
"role": "harness"
|
|
10
|
+
},
|
|
8
11
|
"main": "dist/index.js",
|
|
9
12
|
"types": "dist/index.d.ts",
|
|
10
13
|
"keywords": [
|
|
@@ -25,13 +28,13 @@
|
|
|
25
28
|
"@opentelemetry/resources": "^2.7.1",
|
|
26
29
|
"@opentelemetry/sdk-node": "^0.216.0",
|
|
27
30
|
"hono": "^4.12.16",
|
|
28
|
-
"@rcrsr/rill-agent": "~0.
|
|
31
|
+
"@rcrsr/rill-agent": "~0.20.0"
|
|
29
32
|
},
|
|
30
33
|
"devDependencies": {
|
|
31
34
|
"@opentelemetry/api": "^1.9.0",
|
|
32
35
|
"dts-bundle-generator": "^9.5.1",
|
|
33
36
|
"tsup": "^8.5.0",
|
|
34
|
-
"@rcrsr/rill-agent-hono-kit": "^0.
|
|
37
|
+
"@rcrsr/rill-agent-hono-kit": "^0.20.0"
|
|
35
38
|
},
|
|
36
39
|
"files": [
|
|
37
40
|
"dist"
|
|
@@ -52,7 +55,7 @@
|
|
|
52
55
|
"build": "tsup && dts-bundle-generator --config dts-bundle-generator.config.cjs && node -e \"const fs=require('fs');const walk=(d)=>fs.readdirSync(d,{withFileTypes:true}).flatMap(e=>e.isDirectory()?walk(d+'/'+e.name):[d+'/'+e.name]);const hits=walk('dist').filter(f=>fs.readFileSync(f,'utf8').includes('@rcrsr/rill-agent-hono-kit'));if(hits.length){console.error('hono-kit leak in dist:',hits);process.exit(1);}\"",
|
|
53
56
|
"test": "vitest run",
|
|
54
57
|
"typecheck": "tsc --noEmit",
|
|
55
|
-
"lint": "
|
|
58
|
+
"lint": "oxlint --config ../../../.oxlintrc.json src/ tests/",
|
|
56
59
|
"check": "pnpm run build && pnpm run test && pnpm run lint"
|
|
57
60
|
}
|
|
58
61
|
}
|