@modelprofile.com/flexharness 10.12.0 → 10.14.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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.codesandbox.d.ts +39 -0
- package/dist_ts/classes.codesandbox.js +539 -0
- package/dist_ts/classes.flexharness.d.ts +17 -0
- package/dist_ts/classes.flexharness.js +222 -8
- package/dist_ts/classes.toolcatalog.d.ts +90 -0
- package/dist_ts/classes.toolcatalog.js +1398 -0
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +2 -1
- package/dist_ts/interfaces.d.ts +237 -3
- package/dist_ts/interfaces.js +50 -1
- package/dist_ts/plugins.d.ts +66 -1
- package/dist_ts/plugins.js +19 -1
- package/dist_ts/utils.harnessoptions.d.ts +7 -1
- package/dist_ts/utils.harnessoptions.js +48 -2
- package/dist_ts/utils.json.js +3 -1
- package/dist_ts/utils.schemadeclarations.d.ts +53 -0
- package/dist_ts/utils.schemadeclarations.js +315 -0
- package/dist_ts/utils.tooloutput.d.ts +2 -0
- package/dist_ts/utils.tooloutput.js +11 -1
- package/dist_ts_compaction/plugins.d.ts +3 -3
- package/dist_ts_compaction/plugins.js +3 -3
- package/dist_ts_compaction/smartagent.compaction.d.ts +10 -1
- package/dist_ts_compaction/smartagent.compaction.js +79 -38
- package/package.json +17 -4
- package/readme.md +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.codesandbox.ts +565 -0
- package/ts/classes.flexharness.ts +242 -7
- package/ts/classes.toolcatalog.ts +1512 -0
- package/ts/index.ts +1 -0
- package/ts/interfaces.ts +285 -3
- package/ts/plugins.ts +86 -0
- package/ts/readme.md +1 -1
- package/ts/utils.harnessoptions.ts +55 -0
- package/ts/utils.json.ts +2 -0
- package/ts/utils.schemadeclarations.ts +322 -0
- package/ts/utils.tooloutput.ts +9 -0
- package/ts_compaction/plugins.ts +3 -3
- package/ts_compaction/smartagent.compaction.ts +90 -34
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import { type IFlexCatalogProposal, type IFlexCatalogProposalContext, type IFlexCodeModeLimits, type TFlexCatalogCallDecision, type IFlexCatalogDescribeInput, type IFlexCatalogDescribeResult, type IFlexCatalogMethod, type IFlexCatalogRunContext, type IFlexCatalogSearchInput, type IFlexCatalogToolDefinition, type IFlexToolCatalog, type IFlexToolCatalogOptions, type TFlexCatalogCallError } from './interfaces.js';
|
|
3
|
+
interface IPreparedCall {
|
|
4
|
+
readonly success: true;
|
|
5
|
+
readonly method: string;
|
|
6
|
+
readonly params: unknown;
|
|
7
|
+
/** The method's `onCall` decision for the call; `run` without the hook. */
|
|
8
|
+
decide(context: IFlexCatalogRunContext<any>): Promise<TFlexCatalogCallDecision>;
|
|
9
|
+
run(context: IFlexCatalogRunContext<any>): ReturnType<IFlexCatalogMethod['run']>;
|
|
10
|
+
}
|
|
11
|
+
interface IFailedCall {
|
|
12
|
+
readonly success: false;
|
|
13
|
+
readonly error: TFlexCatalogCallError;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A tool catalog prepared for the model: search, TypeScript declarations, parameter validation and
|
|
17
|
+
* dispatch. FlexHarness builds one for every catalog a tool provider returns; it is public so a
|
|
18
|
+
* host can check what its catalog shows the model, and measure it, without running a session.
|
|
19
|
+
*/
|
|
20
|
+
export declare class FlexToolCatalog<TScope = unknown> {
|
|
21
|
+
private readonly core;
|
|
22
|
+
private readonly admitted;
|
|
23
|
+
/** The limits of `run_code`; absent while code mode is off. */
|
|
24
|
+
readonly codeMode: Readonly<IFlexCodeModeLimits> | undefined;
|
|
25
|
+
private namespaceTree?;
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Prepares `catalog`. Preparing the same object again returns the cached preparation, so a host
|
|
29
|
+
* that returns one catalog object for every run pays for it once.
|
|
30
|
+
*/
|
|
31
|
+
static create<TScope = unknown>(catalog: IFlexToolCatalog<TScope>, options?: IFlexToolCatalogOptions): Promise<FlexToolCatalog<TScope>>;
|
|
32
|
+
/** Every method path this catalog offers, sorted. */
|
|
33
|
+
get methods(): string[];
|
|
34
|
+
/** Every named type, sorted. */
|
|
35
|
+
get types(): string[];
|
|
36
|
+
/** The same catalog offering only `paths`. */
|
|
37
|
+
restrict(paths: Iterable<string>): FlexToolCatalog<TScope>;
|
|
38
|
+
has(path: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The built-in tools as the model sees them: the three catalog tools, and `run_code` in code
|
|
41
|
+
* mode. Their text depends only on the catalog and its options.
|
|
42
|
+
*/
|
|
43
|
+
toolDefinitions(): Record<string, IFlexCatalogToolDefinition>;
|
|
44
|
+
private codeToolDefinition;
|
|
45
|
+
/** Hands proposed calls to the catalog's `onProposals` and returns what the model sees for them. */
|
|
46
|
+
propose(proposals: readonly IFlexCatalogProposal[], context: IFlexCatalogProposalContext<TScope>): Promise<unknown>;
|
|
47
|
+
/** Search results or a namespace listing as text. */
|
|
48
|
+
search(input?: IFlexCatalogSearchInput): string;
|
|
49
|
+
/**
|
|
50
|
+
* The declarations of `input.methods` and `input.types`. Method declarations bring the named
|
|
51
|
+
* types they use, minus `declaredTypes`, which a session already has.
|
|
52
|
+
*/
|
|
53
|
+
describe(input: IFlexCatalogDescribeInput, options?: {
|
|
54
|
+
declaredTypes?: Iterable<string>;
|
|
55
|
+
maxBytes?: number;
|
|
56
|
+
}): IFlexCatalogDescribeResult;
|
|
57
|
+
/** The named types `describe_tools` results in `messages` declared. */
|
|
58
|
+
declaredTypesIn(messages: readonly plugins.ModelMessage[] | undefined): Set<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Resolves and validates a call. A failure is the error `execute` reports to the model; success
|
|
61
|
+
* returns the run with the validated parameters. A schema validator that throws rejects.
|
|
62
|
+
*/
|
|
63
|
+
prepareCall(method: unknown, params: unknown): Promise<IPreparedCall | IFailedCall>;
|
|
64
|
+
/** The real method and params of an `execute` input, when it names a method of this catalog. */
|
|
65
|
+
callTarget(input: unknown): {
|
|
66
|
+
method: string;
|
|
67
|
+
params: unknown;
|
|
68
|
+
} | undefined;
|
|
69
|
+
private isAdmitted;
|
|
70
|
+
private tree;
|
|
71
|
+
private topLevelLine;
|
|
72
|
+
private page;
|
|
73
|
+
private describeTypescript;
|
|
74
|
+
private describeJson;
|
|
75
|
+
/** Issues the method's JSON Schema finds in `value`. */
|
|
76
|
+
private validateStructure;
|
|
77
|
+
/** Issues reported by a zod, Standard Schema or AI SDK validator. */
|
|
78
|
+
private foreignIssues;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* While a run has a catalog, its tool names are reserved (`run_code` in code mode too), and a
|
|
82
|
+
* method path must differ from every tool name.
|
|
83
|
+
*/
|
|
84
|
+
export declare const assertNoCatalogCollisions: (catalog: FlexToolCatalog<unknown>, tools: Readonly<Record<string, unknown>>) => void;
|
|
85
|
+
/**
|
|
86
|
+
* The AI SDK schema of a built-in catalog tool: the definition's JSON Schema, validated with it, so a
|
|
87
|
+
* malformed call goes back to the model like any other invalid tool input.
|
|
88
|
+
*/
|
|
89
|
+
export declare const catalogToolInputSchema: <TInput>(definition: IFlexCatalogToolDefinition) => plugins.Schema<TInput>;
|
|
90
|
+
export {};
|