@eigenpal/automations 0.20.72 → 0.20.73
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/CHANGELOG.md +6 -0
- package/README.md +158 -11
- package/dist/compiler.d.ts +1 -1
- package/dist/compiler.js +2 -0
- package/dist/definition.d.ts +6 -6
- package/dist/evaluation.js +8 -1
- package/dist/index.js +19 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @eigenpal/automations
|
|
2
2
|
|
|
3
|
+
## 0.20.73
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 095515e: Allow immutable filesystem variants after evaluator and pass registration, preserve inferred evaluator and output types, and reject async/generator evaluation callbacks early. Document callback capabilities, limits and authoring checks.
|
|
8
|
+
|
|
3
9
|
## 0.20.71
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -38,6 +38,14 @@ Open [`examples/agents`](examples/agents/README.md) for a standalone IDE project
|
|
|
38
38
|
functional and filesystem agents, typed tools, evaluations, and all four directory-backed
|
|
39
39
|
shared resource kinds. Its README includes local setup, type checks and Git installation steps.
|
|
40
40
|
|
|
41
|
+
Read the [agent authoring documentation](https://docs.eigenpal.com/sdks/automations)
|
|
42
|
+
for guides and the [SDK overview](https://docs.eigenpal.com/sdks/overview) to choose
|
|
43
|
+
between the authoring package and API clients. This README is a package reference. Start with [Define an agent](#define-an-agent),
|
|
44
|
+
then [Callback environment and authoring checks](#callback-environment-and-authoring-checks),
|
|
45
|
+
[Shared resources](#shared-resources), and [Define evaluations](#define-evaluations).
|
|
46
|
+
The exported TypeScript declarations provide property documentation and inferred types
|
|
47
|
+
in your IDE.
|
|
48
|
+
|
|
41
49
|
## Compilation boundary
|
|
42
50
|
|
|
43
51
|
```ts
|
|
@@ -327,7 +335,7 @@ Filesystem agents gain the same tools and receive the original resource director
|
|
|
327
335
|
|
|
328
336
|
```ts
|
|
329
337
|
import checks from '../../resources/skills/invoice-checks/resource.ts';
|
|
330
|
-
//
|
|
338
|
+
// Add filesystem capabilities at any point, including after evaluation configuration:
|
|
331
339
|
// createAgent({ ... }).withFilesystem({ skills: { checks } });
|
|
332
340
|
```
|
|
333
341
|
|
|
@@ -429,7 +437,7 @@ const invoice = createAgent({
|
|
|
429
437
|
files: { 'invoice.txt': 'Supplier: Example Ltd; tax ID: EX123; subtotal: 100; tax rate: 0.2' },
|
|
430
438
|
});
|
|
431
439
|
|
|
432
|
-
//
|
|
440
|
+
// Evaluators infer the output schema; filesystem capabilities remain composable.
|
|
433
441
|
const evaluated = invoice
|
|
434
442
|
.defineEvaluator(
|
|
435
443
|
'fields',
|
|
@@ -480,23 +488,25 @@ expected fields in the dataset to avoid an evaluation error.
|
|
|
480
488
|
Pass callbacks only see registered score names. Misspelled output properties and
|
|
481
489
|
score names fail TypeScript checking. Use a Zod output schema for full inference;
|
|
482
490
|
raw JSON Schema and absent output schemas intentionally infer `unknown` and
|
|
483
|
-
require narrowing.
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
491
|
+
require narrowing. Tools, schemas and guards belong to `createAgent`. Register evaluators, then
|
|
492
|
+
finish with one pass decision. `.withFilesystem(options)` remains available at
|
|
493
|
+
every stage and preserves all schemas, tools, evaluators and the pass rule. It
|
|
494
|
+
returns a new definition; the original is unchanged. Either pass branch returns
|
|
495
|
+
a complete agent definition that can be compiled.
|
|
487
496
|
|
|
488
497
|
### Authoring phases
|
|
489
498
|
|
|
490
499
|
All methods return new immutable definitions. The original base agent is reusable.
|
|
491
500
|
|
|
492
|
-
1. `createAgent`
|
|
493
|
-
2.
|
|
501
|
+
1. `createAgent` defines tools, schemas, resources and guards.
|
|
502
|
+
2. `.defineEvaluator(name, evaluate)` adds typed evaluation logic. Register up
|
|
494
503
|
to 32 uniquely named evaluators. Names must be stable string literals, begin
|
|
495
504
|
with a letter and contain only letters, digits, `_` or `-`, up to 64 characters.
|
|
496
505
|
Prototype-related names are reserved. Runtime strings and unions are rejected
|
|
497
506
|
by TypeScript because they cannot establish a reliable score registry.
|
|
498
507
|
3. One terminal `.defineEvalPass(predicateOrWeightedScore)` closes registration.
|
|
499
|
-
Its result has no
|
|
508
|
+
Its result has no evaluator-registration or pass methods. `.withFilesystem`
|
|
509
|
+
remains available and preserves the completed evaluation configuration.
|
|
500
510
|
An unfinished evaluator chain cannot be compiled or released.
|
|
501
511
|
|
|
502
512
|
Agents with no evaluation configuration require no pass rule. Evaluation-enabled
|
|
@@ -572,5 +582,142 @@ available in either form. Weighting is never silently applied to predicates.
|
|
|
572
582
|
|
|
573
583
|
A predicate receives the complete readonly score map and must synchronously
|
|
574
584
|
return `boolean`. Use ordinary `&&`, `||`, comparisons and arithmetic for custom
|
|
575
|
-
logic. A second pass definition
|
|
576
|
-
|
|
585
|
+
logic. A second pass definition or additional evaluator after the pass is a type
|
|
586
|
+
error and unavailable at runtime. Filesystem capabilities can still be composed:
|
|
587
|
+
|
|
588
|
+
```ts
|
|
589
|
+
const reviewer = evaluated.defineEvalPass(({ fields }) => fields === 1);
|
|
590
|
+
export const functionalReviewer = reviewer;
|
|
591
|
+
export const filesystemReviewer = reviewer.withFilesystem({ cwd: null });
|
|
592
|
+
// Both reuse the same evaluators and pass callback; reviewer is unchanged.
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### Callback environment and authoring checks
|
|
596
|
+
|
|
597
|
+
Custom tool `execute` callbacks, custom evaluators, exact-diff and judge selectors,
|
|
598
|
+
and pass callbacks all use the same bounded QuickJS environment, with or without
|
|
599
|
+
`.withFilesystem()`. They can use synchronous JavaScript, local helper modules and
|
|
600
|
+
JSON data. Node APIs, network access, host files and arbitrary npm imports are
|
|
601
|
+
unavailable. Installing packages in a sandbox enables its built-in shell/Python
|
|
602
|
+
tools; it does not grant those packages or capabilities to TypeScript callbacks.
|
|
603
|
+
|
|
604
|
+
Use `lib: ["ES2022"]` and `types: []` in an authoring TypeScript project to flag
|
|
605
|
+
unsupported ambient Node/browser APIs in the IDE; the example project includes
|
|
606
|
+
this configuration. The compiler checks allowed imports, and declarations reject
|
|
607
|
+
async/generator callbacks without invoking them. These checks do not prove purity
|
|
608
|
+
or termination. A synchronous function returning a Promise indirectly, dynamic
|
|
609
|
+
global access, or bypassing types with `any` still requires runtime validation.
|
|
610
|
+
Runtime isolation and execution limits enforce the boundary.
|
|
611
|
+
|
|
612
|
+
#### What runs where
|
|
613
|
+
|
|
614
|
+
Defining an agent builds a declaration. The platform captures its TypeScript source
|
|
615
|
+
and relative helper modules, bundles them, and validates the declaration in an
|
|
616
|
+
isolated compiler. The compiler does not proactively call callback bodies on sample inputs.
|
|
617
|
+
At execution time the relevant callback runs in a fresh QuickJS context. Do not
|
|
618
|
+
use module variables as persistent state between tool calls or runs.
|
|
619
|
+
|
|
620
|
+
- `createTool({ execute })`: receives schema-validated tool arguments and returns
|
|
621
|
+
an object matching `outputSchema`. It runs when the model invokes that tool.
|
|
622
|
+
- `.defineEvaluator(name, callback)`: receives readonly `{ actual, expected }`
|
|
623
|
+
and returns a finite number from 0 to 1. `expected` may be missing or partial.
|
|
624
|
+
It runs during evaluation, not ordinary agent inference.
|
|
625
|
+
- `exactDiff({ select })`: receives a partial output and returns selected JSON
|
|
626
|
+
data. The platform invokes it separately for actual and expected outputs, then
|
|
627
|
+
compares those projections. Handle optional fields explicitly.
|
|
628
|
+
- `llmJudge({ prompt, select })`: the selector receives readonly
|
|
629
|
+
`{ actual, expected }` and returns JSON data for the judge. The platform makes
|
|
630
|
+
the model request outside the callback. The selector itself cannot call a model.
|
|
631
|
+
- `.defineEvalPass(callback)`: receives the readonly registered evaluator scores
|
|
632
|
+
and returns a boolean. It runs after evaluation scores are available.
|
|
633
|
+
|
|
634
|
+
These contracts are identical for normal and filesystem agents. Both reuse the
|
|
635
|
+
same QuickJS engine as workflow script steps; agent callbacks have their own
|
|
636
|
+
input/output contracts and limits rather than arbitrary workflow-step options.
|
|
637
|
+
|
|
638
|
+
#### Supported callback code
|
|
639
|
+
|
|
640
|
+
Use synchronous JavaScript calculations: strings, finite numbers, booleans,
|
|
641
|
+
arrays, plain objects, loops, `Math` calculations, regular expressions and JSON
|
|
642
|
+
operations. Local helper functions and constants are bundled with the definition:
|
|
643
|
+
|
|
644
|
+
```ts
|
|
645
|
+
// math.ts
|
|
646
|
+
export const taxRate = 0.2;
|
|
647
|
+
export function totalWithTax(subtotal: number) {
|
|
648
|
+
return subtotal * (1 + taxRate);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// agent.ts
|
|
652
|
+
import { createTool } from '@eigenpal/automations';
|
|
653
|
+
import { z } from 'zod';
|
|
654
|
+
import { totalWithTax } from './math.ts';
|
|
655
|
+
|
|
656
|
+
const calculateTotal = createTool({
|
|
657
|
+
description: 'Calculate the total including tax.',
|
|
658
|
+
inputSchema: z.object({ subtotal: z.number().nonnegative() }),
|
|
659
|
+
outputSchema: z.object({ total: z.number() }),
|
|
660
|
+
execute: ({ subtotal }) => ({ total: totalWithTax(subtotal) }),
|
|
661
|
+
});
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
Use `@eigenpal/automations`, Zod and captured relative modules as source imports.
|
|
665
|
+
These imports do not install arbitrary dependencies into QuickJS. Zod describes
|
|
666
|
+
schemas; its transforms, coercion and custom refinements are not supported by the
|
|
667
|
+
JSON Schema contract described above.
|
|
668
|
+
|
|
669
|
+
Keep values crossing the callback boundary JSON-compatible. Convert internal
|
|
670
|
+
collections to arrays/objects before returning; do not return functions, symbols,
|
|
671
|
+
`bigint`, cyclic objects or non-finite numbers. Evaluation selectors reject missing
|
|
672
|
+
selected values. Tool results must satisfy their declared object schema.
|
|
673
|
+
|
|
674
|
+
#### Unsupported callback code
|
|
675
|
+
|
|
676
|
+
These examples do not become valid by adding `.withFilesystem()`:
|
|
677
|
+
|
|
678
|
+
```ts
|
|
679
|
+
import fs from 'node:fs'; // No Node built-ins.
|
|
680
|
+
import decimal from 'decimal.js'; // No arbitrary npm runtime imports.
|
|
681
|
+
// await import('./helper.ts'); // No dynamic imports or require().
|
|
682
|
+
|
|
683
|
+
// execute: async ({ url }) => fetch(url) // No async, fetch or network access.
|
|
684
|
+
// execute: () => process.env.API_KEY // No environment or host credentials.
|
|
685
|
+
// execute: () => fs.readFileSync(...) // No filesystem access.
|
|
686
|
+
// execute: () => setTimeout(...) // No host timers/event loop integration.
|
|
687
|
+
// execute: () => document.title // No browser DOM.
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
A callback cannot use E2B APIs, spawn a process, access a database, read an attached
|
|
691
|
+
resource file directly, or obtain an SDK client to start another agent. The SDK
|
|
692
|
+
does not currently expose a general callback context with those capabilities.
|
|
693
|
+
Built-in resource browse/read/template tools are platform operations that the
|
|
694
|
+
agent can invoke, not functions injected into custom callbacks.
|
|
695
|
+
|
|
696
|
+
For scripts that need files, Python or installed npm libraries, opt into
|
|
697
|
+
`.withFilesystem({ packages: ... })` and let the agent use its sandbox shell/script
|
|
698
|
+
tools. Those scripts run inside the filesystem sandbox. Packages installed there
|
|
699
|
+
are still unavailable to `execute`, selectors and evaluator callbacks. The SDK
|
|
700
|
+
does not currently offer a second `execute` mode for sandbox scripts or Python.
|
|
701
|
+
|
|
702
|
+
Declaration compilation disables wall-clock time and random sources. Runtime
|
|
703
|
+
callbacks are not guaranteed deterministic: do not use `Date` or `Math.random`
|
|
704
|
+
for reproducible decisions. Prefer explicit input values. No purity annotation
|
|
705
|
+
can turn unavailable host APIs into supported capabilities.
|
|
706
|
+
|
|
707
|
+
#### Limits and diagnostics
|
|
708
|
+
|
|
709
|
+
Custom tool and evaluation callback invocations currently have at most 2 seconds
|
|
710
|
+
and 64 MiB of QuickJS memory, with a 512 KiB stack. Deployment script limits may
|
|
711
|
+
be tighter, and an agent's remaining time can further shorten tool execution.
|
|
712
|
+
Tool results and evaluation outputs are limited to 128 KiB; evaluation arguments
|
|
713
|
+
are limited to 256 KiB. These are platform limits, not configurable per callback
|
|
714
|
+
through this SDK. `SCRIPT_ENABLED=false` disables this script runtime too.
|
|
715
|
+
|
|
716
|
+
TypeScript checks callback argument/return types and, in the example authoring
|
|
717
|
+
project, flags missing Node/browser globals. Compilation rejects unsupported
|
|
718
|
+
imports and async/generator declarations with environment guidance. Runtime checks
|
|
719
|
+
reject returned Promises, invalid scores, schema mismatches and exceeded limits.
|
|
720
|
+
For security, arbitrary callback exception text is not exposed as a diagnostic.
|
|
721
|
+
A synchronous function can still refer to an unavailable global indirectly or
|
|
722
|
+
return a Promise through an untyped helper; those cases can fail only when invoked.
|
|
723
|
+
Test tools and evaluations with representative inputs before releasing an agent.
|
package/dist/compiler.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentCore, CompiledAgent, DefinitionSchema, JsonSchema } from './definition.js';
|
|
2
2
|
import { type AgentEvaluation } from './evaluation.js';
|
|
3
3
|
export declare function compileSchema(schema: DefinitionSchema, field: string): JsonSchema;
|
|
4
|
-
type CompilableAgent = Omit<AgentCore, 'evaluation'> & {
|
|
4
|
+
type CompilableAgent = Omit<AgentCore, 'evaluation' | 'withFilesystem'> & {
|
|
5
5
|
readonly evaluation?: AgentEvaluation<never, never>;
|
|
6
6
|
readonly defineEvalPass?: never;
|
|
7
7
|
};
|
package/dist/compiler.js
CHANGED
|
@@ -107,6 +107,8 @@ export function compileAgent(definition) {
|
|
|
107
107
|
validateWeightedPass(evaluation.pass, names);
|
|
108
108
|
else if (evaluation.pass.kind !== 'callback' || typeof evaluation.pass.evaluate !== 'function')
|
|
109
109
|
throw new Error('Invalid evaluation pass');
|
|
110
|
+
if (evaluation.pass.kind === 'callback')
|
|
111
|
+
assertSynchronousTool(evaluation.pass.evaluate, 'evaluation.pass');
|
|
110
112
|
}
|
|
111
113
|
const compiledEvaluation = evaluation
|
|
112
114
|
? {
|
package/dist/definition.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export interface AgentOptions<I = DefinitionSchema, O = DefinitionSchema> extend
|
|
|
69
69
|
tools?: Record<string, ToolDefinition<never, unknown>>;
|
|
70
70
|
}
|
|
71
71
|
export interface AgentCore<I = DefinitionSchema | undefined, O = DefinitionSchema | undefined> extends AutomationDefinition<'agent', I, O> {
|
|
72
|
+
/** Opt into a sandbox without changing schemas, tools, evaluators or the pass rule. Returns a new definition at the same authoring stage; replaces previous filesystem settings. */
|
|
73
|
+
withFilesystem(options?: FilesystemOptions): this;
|
|
72
74
|
readonly config: DeepReadonly<AgentConfig>;
|
|
73
75
|
readonly resources?: Readonly<Record<string, ResourceDeclaration>>;
|
|
74
76
|
readonly tools?: Readonly<Record<string, ToolDefinition<never, unknown>>>;
|
|
@@ -77,16 +79,14 @@ export interface AgentCore<I = DefinitionSchema | undefined, O = DefinitionSchem
|
|
|
77
79
|
type IsUnion<T, Whole = T> = T extends Whole ? ([Whole] extends [T] ? false : true) : never;
|
|
78
80
|
type EvaluatorName<N extends string> = string extends N ? never : true extends IsUnion<N> ? never : N;
|
|
79
81
|
export interface AgentDefinition<I = DefinitionSchema | undefined, O = DefinitionSchema | undefined> extends AgentCore<I, O> {
|
|
80
|
-
/**
|
|
81
|
-
withFilesystem(options?: FilesystemOptions): AgentDefinition<I, O>;
|
|
82
|
-
/** Register a named score from 0 to 1. Closes agent configuration; output types flow into the callback/selector. */
|
|
82
|
+
/** Register a named score from 0 to 1. Output types flow into the callback/selector; filesystem capability remains composable. */
|
|
83
83
|
defineEvaluator<const N extends string>(name: N & EvaluatorName<N>, evaluate: EvaluatorInput<InferSchema<O>>): AgentEvaluators<I, O, Record<N, number>>;
|
|
84
84
|
}
|
|
85
|
-
/** Evaluation registration
|
|
85
|
+
/** Evaluation registration preserves filesystem composition; pass closes evaluation registration. */
|
|
86
86
|
export interface AgentEvaluators<I, O, S extends Record<string, number>> extends AgentCore<I, O> {
|
|
87
|
-
/** Register a named score from 0 to 1.
|
|
87
|
+
/** Register a named score from 0 to 1. Output types flow into the callback/selector; filesystem capability remains composable. */
|
|
88
88
|
defineEvaluator<const N extends string>(name: N & EvaluatorName<N> & (N extends keyof S ? never : N), evaluate: EvaluatorInput<InferSchema<O>>): AgentEvaluators<I, O, S & Record<N, number>>;
|
|
89
|
-
/** Finish evaluation registration with one typed predicate or weightedScore decision.
|
|
89
|
+
/** Finish evaluation registration with one typed predicate or weightedScore decision. Filesystem capability can still be extended. */
|
|
90
90
|
defineEvalPass<const W extends Record<string, number>>(pass: ((scores: Readonly<S>) => boolean) | (WeightedPass<W> & {
|
|
91
91
|
readonly weights: Partial<S> & Record<Exclude<keyof W, keyof S>, never>;
|
|
92
92
|
})): AgentCore<I, O>;
|
package/dist/evaluation.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { assertSynchronousTool } from './capabilities.js';
|
|
2
3
|
const exactOptionsSchema = z
|
|
3
4
|
.strictObject({
|
|
4
5
|
rules: z
|
|
@@ -35,6 +36,7 @@ const exactOptionsSchema = z
|
|
|
35
36
|
export function exactDiff(options) {
|
|
36
37
|
if (typeof options.select !== 'function')
|
|
37
38
|
throw new Error('exactDiff requires select');
|
|
39
|
+
assertSynchronousTool(options.select, 'exactDiff.select');
|
|
38
40
|
return Object.freeze({
|
|
39
41
|
kind: 'exact-diff',
|
|
40
42
|
select: options.select,
|
|
@@ -51,6 +53,7 @@ export function llmJudge(options) {
|
|
|
51
53
|
throw new Error('llmJudge requires a prompt between 10 and 131072 characters');
|
|
52
54
|
if (typeof options.select !== 'function')
|
|
53
55
|
throw new Error('llmJudge requires select');
|
|
56
|
+
assertSynchronousTool(options.select, 'llmJudge.select');
|
|
54
57
|
if (options.model !== undefined && !options.model.trim())
|
|
55
58
|
throw new Error('llmJudge model cannot be empty');
|
|
56
59
|
return Object.freeze({ kind: 'llm-judge', ...options });
|
|
@@ -91,18 +94,22 @@ export function validateEvaluatorName(name) {
|
|
|
91
94
|
throw new Error('Invalid evaluator name');
|
|
92
95
|
}
|
|
93
96
|
export function normalizeEvaluator(input) {
|
|
94
|
-
if (typeof input === 'function')
|
|
97
|
+
if (typeof input === 'function') {
|
|
98
|
+
assertSynchronousTool(input, 'evaluator.evaluate');
|
|
95
99
|
return Object.freeze({ kind: 'custom', evaluate: input });
|
|
100
|
+
}
|
|
96
101
|
if (!input || typeof input !== 'object')
|
|
97
102
|
throw new Error('Invalid evaluator');
|
|
98
103
|
switch (input.kind) {
|
|
99
104
|
case 'custom':
|
|
100
105
|
if (typeof input.evaluate !== 'function')
|
|
101
106
|
throw new Error('Custom evaluator requires a callback');
|
|
107
|
+
assertSynchronousTool(input.evaluate, 'evaluator.evaluate');
|
|
102
108
|
return Object.freeze({ kind: 'custom', evaluate: input.evaluate });
|
|
103
109
|
case 'exact-diff':
|
|
104
110
|
if (typeof input.select !== 'function')
|
|
105
111
|
throw new Error('exactDiff requires select');
|
|
112
|
+
assertSynchronousTool(input.select, 'exactDiff.select');
|
|
106
113
|
return Object.freeze({
|
|
107
114
|
kind: 'exact-diff',
|
|
108
115
|
select: input.select,
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertSynchronousTool } from './capabilities.js';
|
|
1
2
|
import { agentConfigSchema, filesystemOptionsSchema } from './config.js';
|
|
2
3
|
import { freezeEvaluationData, normalizeEvaluator, validateEvaluatorName, validateWeightedPass, } from './evaluation.js';
|
|
3
4
|
import { resourceDeclarationMapSchema as resourceMapSchema } from './resources.js';
|
|
@@ -29,6 +30,8 @@ export function createAgent(options) {
|
|
|
29
30
|
else if (descriptor?.kind !== 'callback' ||
|
|
30
31
|
typeof descriptor.evaluate !== 'function')
|
|
31
32
|
throw new Error('Invalid evaluation pass');
|
|
33
|
+
if (descriptor.kind === 'callback')
|
|
34
|
+
assertSynchronousTool(descriptor.evaluate, 'evaluation.pass');
|
|
32
35
|
return build(config, evaluators, freezeEvaluationData({ ...descriptor }), attached);
|
|
33
36
|
};
|
|
34
37
|
const freeze = (value) => {
|
|
@@ -54,28 +57,26 @@ export function createAgent(options) {
|
|
|
54
57
|
}),
|
|
55
58
|
}
|
|
56
59
|
: {}),
|
|
60
|
+
withFilesystem(options = {}) {
|
|
61
|
+
const { skills, ...settings } = options;
|
|
62
|
+
const workspace = filesystemOptionsSchema.parse(settings);
|
|
63
|
+
const parsedSkills = resourceMapSchema.parse(skills ?? {});
|
|
64
|
+
if (Object.values(parsedSkills).some((resource) => resource.kind !== 'skill'))
|
|
65
|
+
throw new Error('Use resources for knowledge, rules and templates');
|
|
66
|
+
if (Object.keys(parsedSkills).some((name) => Object.hasOwn(portable, name)))
|
|
67
|
+
throw new Error('Duplicate resource name');
|
|
68
|
+
const { workspace: _previous, ...base } = config;
|
|
69
|
+
return build({
|
|
70
|
+
...base,
|
|
71
|
+
filesystem: true,
|
|
72
|
+
...(Object.keys(workspace).length ? { workspace } : {}),
|
|
73
|
+
}, evaluators, pass, { ...portable, ...parsedSkills });
|
|
74
|
+
},
|
|
57
75
|
...(pass
|
|
58
76
|
? {}
|
|
59
77
|
: names.length
|
|
60
78
|
? { defineEvaluator: addEvaluator, defineEvalPass }
|
|
61
|
-
: {
|
|
62
|
-
defineEvaluator: addEvaluator,
|
|
63
|
-
withFilesystem(options = {}) {
|
|
64
|
-
const { skills, ...settings } = options;
|
|
65
|
-
const workspace = filesystemOptionsSchema.parse(settings);
|
|
66
|
-
const parsedSkills = resourceMapSchema.parse(skills ?? {});
|
|
67
|
-
if (Object.values(parsedSkills).some((resource) => resource.kind !== 'skill'))
|
|
68
|
-
throw new Error('Use resources for knowledge, rules and templates');
|
|
69
|
-
if (Object.keys(parsedSkills).some((name) => Object.hasOwn(portable, name)))
|
|
70
|
-
throw new Error('Duplicate resource name');
|
|
71
|
-
const { workspace: _previous, ...base } = config;
|
|
72
|
-
return build({
|
|
73
|
-
...base,
|
|
74
|
-
filesystem: true,
|
|
75
|
-
...(Object.keys(workspace).length ? { workspace } : {}),
|
|
76
|
-
}, {}, undefined, { ...portable, ...parsedSkills });
|
|
77
|
-
},
|
|
78
|
-
}),
|
|
79
|
+
: { defineEvaluator: addEvaluator }),
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
82
|
return build(parsed);
|