@alveus-ai/std 0.1.34 → 0.1.36
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/composition/errors.d.ts +20 -0
- package/dist/composition/errors.d.ts.map +1 -0
- package/dist/composition/errors.js +24 -0
- package/dist/composition/errors.js.map +1 -0
- package/dist/composition/index.d.ts +6 -0
- package/dist/composition/index.d.ts.map +1 -0
- package/dist/composition/index.js +6 -0
- package/dist/composition/index.js.map +1 -0
- package/dist/composition/map.d.ts +34 -0
- package/dist/composition/map.d.ts.map +1 -0
- package/dist/composition/map.js +75 -0
- package/dist/composition/map.js.map +1 -0
- package/dist/composition/pipeline.d.ts +23 -0
- package/dist/composition/pipeline.d.ts.map +1 -0
- package/dist/composition/pipeline.js +39 -0
- package/dist/composition/pipeline.js.map +1 -0
- package/dist/composition/router.d.ts +22 -0
- package/dist/composition/router.d.ts.map +1 -0
- package/dist/composition/router.js +32 -0
- package/dist/composition/router.js.map +1 -0
- package/dist/composition/select.d.ts +46 -0
- package/dist/composition/select.d.ts.map +1 -0
- package/dist/composition/select.js +148 -0
- package/dist/composition/select.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface CompositionItemFailure {
|
|
2
|
+
index: number;
|
|
3
|
+
key?: string;
|
|
4
|
+
agent?: string;
|
|
5
|
+
message: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
retryable?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class CompositionFailure extends Error {
|
|
10
|
+
readonly failures: CompositionItemFailure[];
|
|
11
|
+
constructor(message: string, failures: CompositionItemFailure[]);
|
|
12
|
+
}
|
|
13
|
+
export declare class CompositionLimitError extends Error {
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class CompositionConfigurationError extends Error {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
export declare function isPromiseLike(value: unknown): value is PromiseLike<unknown>;
|
|
20
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/composition/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;gBAEhC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE;CAKhE;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,6BAA8B,SAAQ,KAAK;gBAC1C,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,CAE3E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class CompositionFailure extends Error {
|
|
2
|
+
failures;
|
|
3
|
+
constructor(message, failures) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = 'CompositionFailure';
|
|
6
|
+
this.failures = failures;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class CompositionLimitError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'CompositionLimitError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class CompositionConfigurationError extends Error {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'CompositionConfigurationError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function isPromiseLike(value) {
|
|
22
|
+
return value !== null && typeof value === 'object' && typeof value.then === 'function';
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/composition/errors.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,QAAQ,CAA2B;IAE5C,YAAY,OAAe,EAAE,QAAkC;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAQ,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC;AAClG,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { mapAgent, type MapOptions, type MapReport } from './map.js';
|
|
2
|
+
export { pipelineAgent, type PipelineStage, type PipelineOptions } from './pipeline.js';
|
|
3
|
+
export { routerAgent, type Route, type RouterOptions } from './router.js';
|
|
4
|
+
export { selectAgent, type SelectCandidate, type SelectMode, type SelectOptions, type SelectResult, } from './select.js';
|
|
5
|
+
export { CompositionFailure, CompositionLimitError, CompositionConfigurationError, type CompositionItemFailure, } from './errors.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,6BAA6B,EAC7B,KAAK,sBAAsB,GAC5B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { mapAgent } from './map.js';
|
|
2
|
+
export { pipelineAgent } from './pipeline.js';
|
|
3
|
+
export { routerAgent } from './router.js';
|
|
4
|
+
export { selectAgent, } from './select.js';
|
|
5
|
+
export { CompositionFailure, CompositionLimitError, CompositionConfigurationError, } from './errors.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/composition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmC,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,aAAa,EAA4C,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAC1E,OAAO,EACL,WAAW,GAKZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,6BAA6B,GAE9B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ExecutionContext, CompositionPolicy, Agent, VirtualAgent } from '@alveus-ai/core';
|
|
2
|
+
import { type CompositionItemFailure } from './errors.js';
|
|
3
|
+
type AgentRef = Agent<any, any, any, any> | VirtualAgent<any, any> | string;
|
|
4
|
+
export interface MapOptions<TItem = any, TChildInput = any> extends CompositionPolicy {
|
|
5
|
+
/**
|
|
6
|
+
* Transform each item into the agent's input.
|
|
7
|
+
* Must be synchronous and deterministic.
|
|
8
|
+
* Defaults to passing the item directly.
|
|
9
|
+
*/
|
|
10
|
+
inputFn?: (item: TItem, index: number) => TChildInput;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum number of items. Defaults to 500.
|
|
13
|
+
*/
|
|
14
|
+
maxItems?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface MapReport<TOutput = any> {
|
|
17
|
+
results: (TOutput | undefined)[];
|
|
18
|
+
failures: CompositionItemFailure[];
|
|
19
|
+
succeeded: number;
|
|
20
|
+
failed: number;
|
|
21
|
+
total: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fan-out: spawn one child per item, collect results in order.
|
|
25
|
+
*
|
|
26
|
+
* Respects `concurrency` to limit parallel children.
|
|
27
|
+
* `failureMode` controls error handling:
|
|
28
|
+
* - `fail-fast` (default): cancel remaining on first error, throw CompositionFailure
|
|
29
|
+
* - `collect-errors`: return MapReport with all results and failures
|
|
30
|
+
* - `skip`: return MapReport; failed items have undefined results
|
|
31
|
+
*/
|
|
32
|
+
export declare function mapAgent<TItem, TOutput = any>(ctx: ExecutionContext, agent: AgentRef, items: TItem[], opts?: MapOptions<TItem>): Promise<MapReport<TOutput>>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/composition/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAEjB,KAAK,EACL,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,aAAa,CAAC;AAErB,KAAK,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AAK5E,MAAM,WAAW,UAAU,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,GAAG,GAAG,CAAE,SAAQ,iBAAiB;IACnF;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC;IAEtD;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS,CAAC,OAAO,GAAG,GAAG;IACtC,OAAO,EAAE,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,CAAC;IACjC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,EACjD,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,QAAQ,EACf,KAAK,EAAE,KAAK,EAAE,EACd,IAAI,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,GACvB,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CA0E7B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { CompositionFailure, CompositionLimitError, } from './errors.js';
|
|
2
|
+
const DEFAULT_MAX_ITEMS = 500;
|
|
3
|
+
const ABSOLUTE_MAX_ITEMS = 500;
|
|
4
|
+
/**
|
|
5
|
+
* Fan-out: spawn one child per item, collect results in order.
|
|
6
|
+
*
|
|
7
|
+
* Respects `concurrency` to limit parallel children.
|
|
8
|
+
* `failureMode` controls error handling:
|
|
9
|
+
* - `fail-fast` (default): cancel remaining on first error, throw CompositionFailure
|
|
10
|
+
* - `collect-errors`: return MapReport with all results and failures
|
|
11
|
+
* - `skip`: return MapReport; failed items have undefined results
|
|
12
|
+
*/
|
|
13
|
+
export async function mapAgent(ctx, agent, items, opts) {
|
|
14
|
+
if (items.length === 0) {
|
|
15
|
+
return { results: [], failures: [], succeeded: 0, failed: 0, total: 0 };
|
|
16
|
+
}
|
|
17
|
+
const maxItems = Math.min(opts?.maxItems ?? DEFAULT_MAX_ITEMS, ABSOLUTE_MAX_ITEMS);
|
|
18
|
+
if (items.length > maxItems) {
|
|
19
|
+
throw new CompositionLimitError(`mapAgent currently supports up to ${maxItems} items per execution. ` +
|
|
20
|
+
`Split this workload into pages or use a durable pool.`);
|
|
21
|
+
}
|
|
22
|
+
const concurrency = opts?.concurrency ?? items.length;
|
|
23
|
+
const failureMode = opts?.failureMode ?? 'fail-fast';
|
|
24
|
+
const inputFn = opts?.inputFn ?? ((item) => item);
|
|
25
|
+
const spawnOpts = {
|
|
26
|
+
...(opts?.timeout != null ? { timeout: opts.timeout } : {}),
|
|
27
|
+
...(opts?.cancellation ? { cancellation: opts.cancellation } : {}),
|
|
28
|
+
};
|
|
29
|
+
const results = new Array(items.length).fill(undefined);
|
|
30
|
+
const failures = [];
|
|
31
|
+
let cursor = 0;
|
|
32
|
+
while (cursor < items.length) {
|
|
33
|
+
const batchEnd = Math.min(cursor + concurrency, items.length);
|
|
34
|
+
const batch = [];
|
|
35
|
+
for (let i = cursor; i < batchEnd; i++) {
|
|
36
|
+
const input = inputFn(items[i], i);
|
|
37
|
+
const handle = await ctx.spawn(agent, input, {
|
|
38
|
+
...spawnOpts,
|
|
39
|
+
idempotencyKey: `map-${i}`,
|
|
40
|
+
});
|
|
41
|
+
batch.push({ handle, index: i });
|
|
42
|
+
}
|
|
43
|
+
const settled = await Promise.allSettled(batch.map(async ({ handle, index }) => {
|
|
44
|
+
const result = await handle.result();
|
|
45
|
+
return { result, index };
|
|
46
|
+
}));
|
|
47
|
+
for (const entry of settled) {
|
|
48
|
+
if (entry.status === 'fulfilled') {
|
|
49
|
+
results[entry.value.index] = entry.value.result;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const batchIdx = settled.indexOf(entry);
|
|
53
|
+
const index = batch[batchIdx].index;
|
|
54
|
+
const error = entry.reason;
|
|
55
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
56
|
+
failures.push({ index, message, type: error?.name });
|
|
57
|
+
if (failureMode === 'fail-fast') {
|
|
58
|
+
for (const { handle } of batch) {
|
|
59
|
+
try {
|
|
60
|
+
await handle.cancel();
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// already completed or cancelled
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
throw new CompositionFailure(`mapAgent failed at index ${index}: ${message}`, failures);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
cursor = batchEnd;
|
|
71
|
+
}
|
|
72
|
+
const succeeded = items.length - failures.length;
|
|
73
|
+
return { results, failures, succeeded, failed: failures.length, total: items.length };
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../src/composition/map.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,aAAa,CAAC;AAIrB,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAwB/B;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC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,CAAC,CAAC,KAAK,CAAC;gBACpC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;gBAC3B,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAEvE,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBAErD,IAAI,WAAW,KAAK,WAAW,EAAE,CAAC;oBAChC,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;wBAC/B,IAAI,CAAC;4BACH,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;wBACxB,CAAC;wBAAC,MAAM,CAAC;4BACP,iCAAiC;wBACnC,CAAC;oBACH,CAAC;oBACD,MAAM,IAAI,kBAAkB,CAAC,4BAA4B,KAAK,KAAK,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;gBAC1F,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,GAAG,QAAQ,CAAC;IACpB,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ExecutionContext, CompositionPolicy, Agent, VirtualAgent } from '@alveus-ai/core';
|
|
2
|
+
type AgentRef = Agent<any, any, any, any> | VirtualAgent<any, any> | string;
|
|
3
|
+
export interface PipelineStage {
|
|
4
|
+
agent: AgentRef;
|
|
5
|
+
/**
|
|
6
|
+
* Transform the previous stage's output into this stage's input.
|
|
7
|
+
* Must be synchronous and deterministic.
|
|
8
|
+
* Receives (previousOutput, originalInput, stageIndex).
|
|
9
|
+
* Defaults to passing previousOutput directly.
|
|
10
|
+
*/
|
|
11
|
+
transformInput?: (previousOutput: any, originalInput: any, index: number) => any;
|
|
12
|
+
}
|
|
13
|
+
export interface PipelineOptions extends CompositionPolicy {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Sequential composition: chain N agents where each stage's output
|
|
17
|
+
* feeds the next stage's input.
|
|
18
|
+
*
|
|
19
|
+
* Returns the final stage's output.
|
|
20
|
+
*/
|
|
21
|
+
export declare function pipelineAgent<TOutput = any>(ctx: ExecutionContext, stages: PipelineStage[], input: any, opts?: PipelineOptions): Promise<TOutput>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/composition/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGhG,KAAK,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AAE5E,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,QAAQ,CAAC;IAChB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC;CAClF;AAED,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;CAAG;AAE7D;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAG,GAAG,EAC/C,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,aAAa,EAAE,EACvB,KAAK,EAAE,GAAG,EACV,IAAI,CAAC,EAAE,eAAe,GACrB,OAAO,CAAC,OAAO,CAAC,CAqClB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CompositionConfigurationError, isPromiseLike } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sequential composition: chain N agents where each stage's output
|
|
4
|
+
* feeds the next stage's input.
|
|
5
|
+
*
|
|
6
|
+
* Returns the final stage's output.
|
|
7
|
+
*/
|
|
8
|
+
export async function pipelineAgent(ctx, stages, input, opts) {
|
|
9
|
+
if (stages.length === 0) {
|
|
10
|
+
return input;
|
|
11
|
+
}
|
|
12
|
+
const spawnOpts = {
|
|
13
|
+
...(opts?.timeout != null ? { timeout: opts.timeout } : {}),
|
|
14
|
+
...(opts?.cancellation ? { cancellation: opts.cancellation } : {}),
|
|
15
|
+
};
|
|
16
|
+
let current = input;
|
|
17
|
+
for (let i = 0; i < stages.length; i++) {
|
|
18
|
+
const stage = stages[i];
|
|
19
|
+
let stageInput;
|
|
20
|
+
if (stage.transformInput) {
|
|
21
|
+
stageInput = stage.transformInput(current, input, i);
|
|
22
|
+
if (isPromiseLike(stageInput)) {
|
|
23
|
+
throw new CompositionConfigurationError(`pipelineAgent transformInput must be synchronous. ` +
|
|
24
|
+
`Stage ${i} returned a Promise. ` +
|
|
25
|
+
`Use an intermediate agent for async transformations.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
stageInput = current;
|
|
30
|
+
}
|
|
31
|
+
const handle = await ctx.spawn(stage.agent, stageInput, {
|
|
32
|
+
...spawnOpts,
|
|
33
|
+
idempotencyKey: `pipeline-${i}`,
|
|
34
|
+
});
|
|
35
|
+
current = await handle.result();
|
|
36
|
+
}
|
|
37
|
+
return current;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/composition/pipeline.ts"],"names":[],"mappings":"AACA,O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Z,cAAc,EAAE,YAAY,CAAC,EAAE;SAChC,CAAC,CAAC;QACH,OAAO,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,OAAO,OAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ExecutionContext, CompositionPolicy, Agent, VirtualAgent } from '@alveus-ai/core';
|
|
2
|
+
type AgentRef = Agent<any, any, any, any> | VirtualAgent<any, any> | string;
|
|
3
|
+
export interface Route<TInput = any> {
|
|
4
|
+
/** Sync predicate — return true to select this route. Must not be async. */
|
|
5
|
+
when: (input: TInput) => boolean;
|
|
6
|
+
agent: AgentRef;
|
|
7
|
+
label?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RouterOptions extends CompositionPolicy {
|
|
10
|
+
/** Agent to use when no route matches. If omitted, throws on no match. */
|
|
11
|
+
defaultAgent?: AgentRef;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Conditional dispatch: evaluates route predicates in order and
|
|
15
|
+
* spawns the first matching agent.
|
|
16
|
+
*
|
|
17
|
+
* Predicates must be synchronous and deterministic.
|
|
18
|
+
* For async or LLM-based routing, use a routing agent instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare function routerAgent<TInput = any, TOutput = any>(ctx: ExecutionContext, routes: Route<TInput>[], input: TInput, opts?: RouterOptions): Promise<TOutput>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/composition/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGhG,KAAK,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AAE5E,MAAM,WAAW,KAAK,CAAC,MAAM,GAAG,GAAG;IACjC,4EAA4E;IAC5E,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACjC,KAAK,EAAE,QAAQ,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,0EAA0E;IAC1E,YAAY,CAAC,EAAE,QAAQ,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,MAAM,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG,EAC3D,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EACvB,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,aAAa,GACnB,OAAO,CAAC,OAAO,CAAC,CA+BlB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CompositionConfigurationError, isPromiseLike } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Conditional dispatch: evaluates route predicates in order and
|
|
4
|
+
* spawns the first matching agent.
|
|
5
|
+
*
|
|
6
|
+
* Predicates must be synchronous and deterministic.
|
|
7
|
+
* For async or LLM-based routing, use a routing agent instead.
|
|
8
|
+
*/
|
|
9
|
+
export async function routerAgent(ctx, routes, input, opts) {
|
|
10
|
+
const spawnOpts = {
|
|
11
|
+
...(opts?.timeout != null ? { timeout: opts.timeout } : {}),
|
|
12
|
+
...(opts?.cancellation ? { cancellation: opts.cancellation } : {}),
|
|
13
|
+
};
|
|
14
|
+
for (const route of routes) {
|
|
15
|
+
const match = route.when(input);
|
|
16
|
+
if (isPromiseLike(match)) {
|
|
17
|
+
throw new CompositionConfigurationError(`routerAgent predicates must be synchronous. ` +
|
|
18
|
+
`Route "${route.label ?? '(unlabeled)'}" returned a Promise. ` +
|
|
19
|
+
`Use a routing agent for async or LLM-based routing.`);
|
|
20
|
+
}
|
|
21
|
+
if (match) {
|
|
22
|
+
const handle = await ctx.spawn(route.agent, input, spawnOpts);
|
|
23
|
+
return handle.result();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (opts?.defaultAgent) {
|
|
27
|
+
const handle = await ctx.spawn(opts.defaultAgent, input, spawnOpts);
|
|
28
|
+
return handle.result();
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`No route matched and no default agent provided. Routes evaluated: ${routes.map((r) => r.label ?? '(unlabeled)').join(', ')}`);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/composition/router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAgB3E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAqB,EACrB,MAAuB,EACvB,KAAa,EACb,IAAoB;IAEpB,MAAM,SAAS,GAAG;QAChB,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnE,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,6BAA6B,CACrC,8CAA8C;gBAC5C,UAAU,KAAK,CAAC,KAAK,IAAI,aAAa,wBAAwB;gBAC9D,qDAAqD,CACxD,CAAC;QACJ,CAAC;QAED,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAkB,KAAK,CAAC,KAAe,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;YACzF,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAED,IAAI,IAAI,EAAE,YAAY,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAkB,IAAI,CAAC,YAAsB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAC/F,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;IAED,MAAM,IAAI,KAAK,CACb,qEAAqE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC9H,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ExecutionContext, CompositionPolicy, Agent, VirtualAgent } from '@alveus-ai/core';
|
|
2
|
+
type AgentRef = Agent<any, any, any, any> | VirtualAgent<any, any> | string;
|
|
3
|
+
export interface SelectCandidate {
|
|
4
|
+
agent: AgentRef;
|
|
5
|
+
label?: string;
|
|
6
|
+
}
|
|
7
|
+
export type SelectMode = {
|
|
8
|
+
kind: 'first-success';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'first-settled';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'quorum';
|
|
13
|
+
n: number;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'judge';
|
|
16
|
+
judgeAgent: AgentRef;
|
|
17
|
+
};
|
|
18
|
+
export interface SelectOptions extends CompositionPolicy {
|
|
19
|
+
/**
|
|
20
|
+
* Selection mode:
|
|
21
|
+
* - `first-success` (default): first candidate to succeed wins; cancel the rest
|
|
22
|
+
* - `first-settled`: first candidate to settle (success or failure) wins
|
|
23
|
+
* - `quorum`: wait for N successful completions; cancel the rest
|
|
24
|
+
* - `judge`: await all, then call a judge agent to pick
|
|
25
|
+
*/
|
|
26
|
+
mode?: SelectMode;
|
|
27
|
+
}
|
|
28
|
+
export interface SelectResult<TOutput = any> {
|
|
29
|
+
winner: TOutput;
|
|
30
|
+
winnerIndex: number | number[];
|
|
31
|
+
all?: (TOutput | null)[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Competitive selection: spawn N agents in parallel, return based on mode.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const { winner } = await selectAgent(ctx, [
|
|
39
|
+
* { agent: fastModel, label: 'gpt-4o-mini' },
|
|
40
|
+
* { agent: smartModel, label: 'claude-opus' },
|
|
41
|
+
* ], { prompt: '...' });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function selectAgent<TOutput = any>(ctx: ExecutionContext, candidates: SelectCandidate[], input: any, opts?: SelectOptions): Promise<SelectResult<TOutput>>;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/composition/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAEjB,KAAK,EACL,YAAY,EACb,MAAM,iBAAiB,CAAC;AAGzB,KAAK,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AAE5E,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,QAAQ,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE5C,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,YAAY,CAAC,OAAO,GAAG,GAAG;IACzC,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,GAAG,CAAC,EAAE,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAAC,OAAO,GAAG,GAAG,EAC7C,GAAG,EAAE,gBAAgB,EACrB,UAAU,EAAE,eAAe,EAAE,EAC7B,KAAK,EAAE,GAAG,EACV,IAAI,CAAC,EAAE,aAAa,GACnB,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAiChC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { CompositionFailure } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Competitive selection: spawn N agents in parallel, return based on mode.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const { winner } = await selectAgent(ctx, [
|
|
8
|
+
* { agent: fastModel, label: 'gpt-4o-mini' },
|
|
9
|
+
* { agent: smartModel, label: 'claude-opus' },
|
|
10
|
+
* ], { prompt: '...' });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export async function selectAgent(ctx, candidates, input, opts) {
|
|
14
|
+
if (candidates.length === 0) {
|
|
15
|
+
throw new Error('selectAgent requires at least one candidate');
|
|
16
|
+
}
|
|
17
|
+
const mode = opts?.mode ?? { kind: 'first-success' };
|
|
18
|
+
const spawnOpts = {
|
|
19
|
+
...(opts?.timeout != null ? { timeout: opts.timeout } : {}),
|
|
20
|
+
...(opts?.cancellation ? { cancellation: opts.cancellation } : {}),
|
|
21
|
+
};
|
|
22
|
+
const handles = [];
|
|
23
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
24
|
+
const handle = await ctx.spawn(candidates[i].agent, input, {
|
|
25
|
+
...spawnOpts,
|
|
26
|
+
idempotencyKey: `select-${i}`,
|
|
27
|
+
});
|
|
28
|
+
handles.push(handle);
|
|
29
|
+
}
|
|
30
|
+
if (mode.kind === 'first-success') {
|
|
31
|
+
return selectFirstSuccess(handles);
|
|
32
|
+
}
|
|
33
|
+
if (mode.kind === 'first-settled') {
|
|
34
|
+
return selectFirstSettled(handles);
|
|
35
|
+
}
|
|
36
|
+
if (mode.kind === 'quorum') {
|
|
37
|
+
return selectQuorum(handles, mode.n);
|
|
38
|
+
}
|
|
39
|
+
return selectJudge(ctx, handles, candidates, input, mode.judgeAgent);
|
|
40
|
+
}
|
|
41
|
+
async function cancelRemaining(handles, exclude) {
|
|
42
|
+
for (let i = 0; i < handles.length; i++) {
|
|
43
|
+
if (!exclude.has(i)) {
|
|
44
|
+
try {
|
|
45
|
+
await handles[i].cancel();
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// already completed or cancelled
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function selectFirstSuccess(handles) {
|
|
54
|
+
const pending = handles.map(async (handle, i) => {
|
|
55
|
+
const result = await handle.result();
|
|
56
|
+
return { result, index: i };
|
|
57
|
+
});
|
|
58
|
+
const remaining = [...pending];
|
|
59
|
+
const errors = [];
|
|
60
|
+
while (remaining.length > 0) {
|
|
61
|
+
const settled = await Promise.race(remaining.map((p, ri) => p.then((v) => ({ status: 'fulfilled', value: v, ri }), (e) => ({ status: 'rejected', reason: e, ri }))));
|
|
62
|
+
remaining.splice(settled.ri, 1);
|
|
63
|
+
if (settled.status === 'fulfilled') {
|
|
64
|
+
await cancelRemaining(handles, new Set([settled.value.index]));
|
|
65
|
+
return { winner: settled.value.result, winnerIndex: settled.value.index };
|
|
66
|
+
}
|
|
67
|
+
errors.push({ index: errors.length, error: settled.reason });
|
|
68
|
+
}
|
|
69
|
+
throw new CompositionFailure('All candidates failed', errors.map((e) => ({
|
|
70
|
+
index: e.index,
|
|
71
|
+
message: e.error instanceof Error ? e.error.message : String(e.error),
|
|
72
|
+
})));
|
|
73
|
+
}
|
|
74
|
+
async function selectFirstSettled(handles) {
|
|
75
|
+
const promises = handles.map(async (handle, i) => {
|
|
76
|
+
const result = await handle.result();
|
|
77
|
+
return { result, index: i };
|
|
78
|
+
});
|
|
79
|
+
const winner = await Promise.race(promises);
|
|
80
|
+
await cancelRemaining(handles, new Set([winner.index]));
|
|
81
|
+
return { winner: winner.result, winnerIndex: winner.index };
|
|
82
|
+
}
|
|
83
|
+
async function selectQuorum(handles, n) {
|
|
84
|
+
if (n > handles.length) {
|
|
85
|
+
throw new Error(`Quorum size ${n} exceeds candidate count ${handles.length}`);
|
|
86
|
+
}
|
|
87
|
+
const all = new Array(handles.length).fill(null);
|
|
88
|
+
const successIndices = [];
|
|
89
|
+
let failedCount = 0;
|
|
90
|
+
const pending = handles.map(async (handle, i) => {
|
|
91
|
+
const result = await handle.result();
|
|
92
|
+
return { result, index: i };
|
|
93
|
+
});
|
|
94
|
+
const remaining = [...pending];
|
|
95
|
+
while (remaining.length > 0) {
|
|
96
|
+
const settled = await Promise.race(remaining.map((p, ri) => p.then((v) => ({ status: 'fulfilled', value: v, ri }), (e) => ({ status: 'rejected', reason: e, ri }))));
|
|
97
|
+
remaining.splice(settled.ri, 1);
|
|
98
|
+
if (settled.status === 'fulfilled') {
|
|
99
|
+
all[settled.value.index] = settled.value.result;
|
|
100
|
+
successIndices.push(settled.value.index);
|
|
101
|
+
if (successIndices.length >= n) {
|
|
102
|
+
await cancelRemaining(handles, new Set(successIndices));
|
|
103
|
+
return { winner: all[successIndices[0]], winnerIndex: successIndices, all };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
failedCount++;
|
|
108
|
+
const successesStillPossible = successIndices.length + remaining.length;
|
|
109
|
+
if (successesStillPossible < n) {
|
|
110
|
+
await cancelRemaining(handles, new Set(successIndices));
|
|
111
|
+
throw new CompositionFailure(`Quorum of ${n} impossible: ${successIndices.length} succeeded, ${failedCount} failed, ${remaining.length} remaining`, [{ index: failedCount - 1, message: 'Quorum became impossible' }]);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
throw new CompositionFailure(`Quorum of ${n} not reached: only ${successIndices.length} succeeded`, [{ index: 0, message: `Only ${successIndices.length} of ${n} required succeeded` }]);
|
|
116
|
+
}
|
|
117
|
+
async function selectJudge(ctx, handles, candidates, originalInput, judgeAgent) {
|
|
118
|
+
const all = [];
|
|
119
|
+
const failureMetadata = [];
|
|
120
|
+
for (let i = 0; i < handles.length; i++) {
|
|
121
|
+
try {
|
|
122
|
+
all.push(await handles[i].result());
|
|
123
|
+
failureMetadata.push({ index: i, error: null });
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
all.push(null);
|
|
127
|
+
failureMetadata.push({
|
|
128
|
+
index: i,
|
|
129
|
+
error: e instanceof Error ? e.message : String(e),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const judgeInput = {
|
|
134
|
+
originalInput,
|
|
135
|
+
candidates: all.map((result, i) => ({
|
|
136
|
+
index: i,
|
|
137
|
+
label: candidates[i].label ?? `candidate-${i}`,
|
|
138
|
+
result,
|
|
139
|
+
failed: failureMetadata[i].error !== null,
|
|
140
|
+
error: failureMetadata[i].error,
|
|
141
|
+
})),
|
|
142
|
+
};
|
|
143
|
+
const judgeHandle = await ctx.spawn(judgeAgent, judgeInput);
|
|
144
|
+
const verdict = (await judgeHandle.result());
|
|
145
|
+
const winnerIndex = typeof verdict?.winnerIndex === 'number' ? verdict.winnerIndex : 0;
|
|
146
|
+
return { winner: all[winnerIndex], winnerIndex, all };
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/composition/select.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAgCjD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAqB,EACrB,UAA6B,EAC7B,KAAU,EACV,IAAoB;IAEpB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,IAAI,GAAe,IAAI,EAAE,IAAI,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;IACjE,MAAM,SAAS,GAAG;QAChB,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnE,CAAC;IAEF,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAe,UAAU,CAAC,CAAC,CAAC,CAAC,KAAe,EAAE,KAAK,EAAE;YACjF,GAAG,SAAS;YACZ,cAAc,EAAE,UAAU,CAAC,EAAE;SAC9B,CAAC,CAAC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,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;aAClD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,aAAa;QACb,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAClC,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,aAAa,CAAC,EAAE;YAC9C,MAAM;YACN,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI;YACzC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK;SAChC,CAAC,CAAC;KACJ,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,UAAoB,EAAE,UAAU,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,CAAC,MAAM,WAAW,CAAC,MAAM,EAAE,CAA4B,CAAC;IAExE,MAAM,WAAW,GAAG,OAAO,OAAO,EAAE,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvF,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,WAAW,CAAE,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;AACzD,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,8 @@ export * from './agents/index.js';
|
|
|
23
23
|
export * from './memory/index.js';
|
|
24
24
|
// Re-export all patterns
|
|
25
25
|
export * from './patterns/index.js';
|
|
26
|
+
// Re-export all composition utilities
|
|
27
|
+
export * from './composition/index.js';
|
|
26
28
|
// Re-export all utilities
|
|
27
29
|
export * from './utils/index.js';
|
|
28
30
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uBAAuB;AACvB,cAAc,mBAAmB,CAAC;AAElC,iCAAiC;AACjC,cAAc,mBAAmB,CAAC;AAElC,yBAAyB;AACzB,cAAc,qBAAqB,CAAC;AAEpC,0BAA0B;AAC1B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uBAAuB;AACvB,cAAc,mBAAmB,CAAC;AAElC,iCAAiC;AACjC,cAAc,mBAAmB,CAAC;AAElC,yBAAyB;AACzB,cAAc,qBAAqB,CAAC;AAEpC,sCAAsC;AACtC,cAAc,wBAAwB,CAAC;AAEvC,0BAA0B;AAC1B,cAAc,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alveus-ai/std",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
4
4
|
"description": "Standard library of reusable agents and utilities for Alveus",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"types": "./dist/patterns/index.d.ts",
|
|
23
23
|
"import": "./dist/patterns/index.js"
|
|
24
24
|
},
|
|
25
|
+
"./composition": {
|
|
26
|
+
"types": "./dist/composition/index.d.ts",
|
|
27
|
+
"import": "./dist/composition/index.js"
|
|
28
|
+
},
|
|
25
29
|
"./utils": {
|
|
26
30
|
"types": "./dist/utils/index.d.ts",
|
|
27
31
|
"import": "./dist/utils/index.js"
|