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