@axlsdk/axl 0.2.0 → 0.4.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/README.md +31 -60
- package/dist/index.cjs +61 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +61 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1075,6 +1075,7 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1075
1075
|
private executions;
|
|
1076
1076
|
private pendingDecisionResolvers;
|
|
1077
1077
|
private abortControllers;
|
|
1078
|
+
private registeredEvals;
|
|
1078
1079
|
private mcpManager?;
|
|
1079
1080
|
private memoryManager?;
|
|
1080
1081
|
private spanManager;
|
|
@@ -1112,6 +1113,33 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1112
1113
|
getAgents(): Agent[];
|
|
1113
1114
|
/** Get a registered standalone agent by name. */
|
|
1114
1115
|
getAgent(name: string): Agent | undefined;
|
|
1116
|
+
/**
|
|
1117
|
+
* Register an eval config for Studio introspection and execution.
|
|
1118
|
+
* The config should be the result of `defineEval()` from `@axlsdk/eval`.
|
|
1119
|
+
* An optional `executeWorkflow` function can override the default behavior
|
|
1120
|
+
* of calling `runtime.execute()`.
|
|
1121
|
+
*/
|
|
1122
|
+
registerEval(name: string, config: unknown, executeWorkflow?: (input: unknown) => Promise<{
|
|
1123
|
+
output: unknown;
|
|
1124
|
+
cost?: number;
|
|
1125
|
+
}>): void;
|
|
1126
|
+
/** Get metadata about all registered evals. */
|
|
1127
|
+
getRegisteredEvals(): Array<{
|
|
1128
|
+
name: string;
|
|
1129
|
+
workflow: string;
|
|
1130
|
+
dataset: string;
|
|
1131
|
+
scorers: string[];
|
|
1132
|
+
}>;
|
|
1133
|
+
/** Get a registered eval config by name. */
|
|
1134
|
+
getRegisteredEval(name: string): {
|
|
1135
|
+
config: unknown;
|
|
1136
|
+
executeWorkflow?: (input: unknown) => Promise<{
|
|
1137
|
+
output: unknown;
|
|
1138
|
+
cost?: number;
|
|
1139
|
+
}>;
|
|
1140
|
+
} | undefined;
|
|
1141
|
+
/** Run a registered eval by name. */
|
|
1142
|
+
runRegisteredEval(name: string): Promise<unknown>;
|
|
1115
1143
|
/** Get all execution info (running + completed). */
|
|
1116
1144
|
getExecutions(): ExecutionInfo[];
|
|
1117
1145
|
/** Register a custom provider instance. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1075,6 +1075,7 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1075
1075
|
private executions;
|
|
1076
1076
|
private pendingDecisionResolvers;
|
|
1077
1077
|
private abortControllers;
|
|
1078
|
+
private registeredEvals;
|
|
1078
1079
|
private mcpManager?;
|
|
1079
1080
|
private memoryManager?;
|
|
1080
1081
|
private spanManager;
|
|
@@ -1112,6 +1113,33 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1112
1113
|
getAgents(): Agent[];
|
|
1113
1114
|
/** Get a registered standalone agent by name. */
|
|
1114
1115
|
getAgent(name: string): Agent | undefined;
|
|
1116
|
+
/**
|
|
1117
|
+
* Register an eval config for Studio introspection and execution.
|
|
1118
|
+
* The config should be the result of `defineEval()` from `@axlsdk/eval`.
|
|
1119
|
+
* An optional `executeWorkflow` function can override the default behavior
|
|
1120
|
+
* of calling `runtime.execute()`.
|
|
1121
|
+
*/
|
|
1122
|
+
registerEval(name: string, config: unknown, executeWorkflow?: (input: unknown) => Promise<{
|
|
1123
|
+
output: unknown;
|
|
1124
|
+
cost?: number;
|
|
1125
|
+
}>): void;
|
|
1126
|
+
/** Get metadata about all registered evals. */
|
|
1127
|
+
getRegisteredEvals(): Array<{
|
|
1128
|
+
name: string;
|
|
1129
|
+
workflow: string;
|
|
1130
|
+
dataset: string;
|
|
1131
|
+
scorers: string[];
|
|
1132
|
+
}>;
|
|
1133
|
+
/** Get a registered eval config by name. */
|
|
1134
|
+
getRegisteredEval(name: string): {
|
|
1135
|
+
config: unknown;
|
|
1136
|
+
executeWorkflow?: (input: unknown) => Promise<{
|
|
1137
|
+
output: unknown;
|
|
1138
|
+
cost?: number;
|
|
1139
|
+
}>;
|
|
1140
|
+
} | undefined;
|
|
1141
|
+
/** Run a registered eval by name. */
|
|
1142
|
+
runRegisteredEval(name: string): Promise<unknown>;
|
|
1115
1143
|
/** Get all execution info (running + completed). */
|
|
1116
1144
|
getExecutions(): ExecutionInfo[];
|
|
1117
1145
|
/** Register a custom provider instance. */
|
package/dist/index.js
CHANGED
|
@@ -1746,6 +1746,15 @@ function zodToJsonSchema(schema) {
|
|
|
1746
1746
|
function estimateTokens(text) {
|
|
1747
1747
|
return Math.ceil(text.length / 4);
|
|
1748
1748
|
}
|
|
1749
|
+
function stripMarkdownFences(text) {
|
|
1750
|
+
const trimmed = text.trim();
|
|
1751
|
+
if (trimmed.startsWith("```")) {
|
|
1752
|
+
const withoutOpening = trimmed.replace(/^```\w*\s*\n?/, "");
|
|
1753
|
+
const withoutClosing = withoutOpening.replace(/\n?```\s*$/, "");
|
|
1754
|
+
return withoutClosing.trim();
|
|
1755
|
+
}
|
|
1756
|
+
return trimmed;
|
|
1757
|
+
}
|
|
1749
1758
|
function estimateMessagesTokens(messages) {
|
|
1750
1759
|
let total = 0;
|
|
1751
1760
|
for (const msg of messages) {
|
|
@@ -2439,7 +2448,7 @@ Please fix and try again.`;
|
|
|
2439
2448
|
}
|
|
2440
2449
|
if (options?.schema) {
|
|
2441
2450
|
try {
|
|
2442
|
-
const parsed = JSON.parse(content);
|
|
2451
|
+
const parsed = JSON.parse(stripMarkdownFences(content));
|
|
2443
2452
|
const validated = options.schema.parse(parsed);
|
|
2444
2453
|
return validated;
|
|
2445
2454
|
} catch (err) {
|
|
@@ -4577,6 +4586,7 @@ var AxlRuntime = class extends EventEmitter2 {
|
|
|
4577
4586
|
executions = /* @__PURE__ */ new Map();
|
|
4578
4587
|
pendingDecisionResolvers = /* @__PURE__ */ new Map();
|
|
4579
4588
|
abortControllers = /* @__PURE__ */ new Map();
|
|
4589
|
+
registeredEvals = /* @__PURE__ */ new Map();
|
|
4580
4590
|
mcpManager;
|
|
4581
4591
|
memoryManager;
|
|
4582
4592
|
spanManager = new NoopSpanManager();
|
|
@@ -4672,6 +4682,52 @@ var AxlRuntime = class extends EventEmitter2 {
|
|
|
4672
4682
|
getAgent(name) {
|
|
4673
4683
|
return this.agents.get(name);
|
|
4674
4684
|
}
|
|
4685
|
+
/**
|
|
4686
|
+
* Register an eval config for Studio introspection and execution.
|
|
4687
|
+
* The config should be the result of `defineEval()` from `@axlsdk/eval`.
|
|
4688
|
+
* An optional `executeWorkflow` function can override the default behavior
|
|
4689
|
+
* of calling `runtime.execute()`.
|
|
4690
|
+
*/
|
|
4691
|
+
registerEval(name, config, executeWorkflow) {
|
|
4692
|
+
this.registeredEvals.set(name, { config, executeWorkflow });
|
|
4693
|
+
}
|
|
4694
|
+
/** Get metadata about all registered evals. */
|
|
4695
|
+
getRegisteredEvals() {
|
|
4696
|
+
const result = [];
|
|
4697
|
+
for (const [name, { config }] of this.registeredEvals) {
|
|
4698
|
+
const cfg = config;
|
|
4699
|
+
result.push({
|
|
4700
|
+
name,
|
|
4701
|
+
workflow: cfg.workflow ?? "unknown",
|
|
4702
|
+
dataset: cfg.dataset?.name ?? "unknown",
|
|
4703
|
+
scorers: (cfg.scorers ?? []).map((s) => s.name ?? "unknown")
|
|
4704
|
+
});
|
|
4705
|
+
}
|
|
4706
|
+
return result;
|
|
4707
|
+
}
|
|
4708
|
+
/** Get a registered eval config by name. */
|
|
4709
|
+
getRegisteredEval(name) {
|
|
4710
|
+
return this.registeredEvals.get(name);
|
|
4711
|
+
}
|
|
4712
|
+
/** Run a registered eval by name. */
|
|
4713
|
+
async runRegisteredEval(name) {
|
|
4714
|
+
const entry = this.registeredEvals.get(name);
|
|
4715
|
+
if (!entry) throw new Error(`Eval "${name}" is not registered`);
|
|
4716
|
+
if (entry.executeWorkflow) {
|
|
4717
|
+
let runEvalFn;
|
|
4718
|
+
try {
|
|
4719
|
+
({ runEval: runEvalFn } = await import("@axlsdk/eval"));
|
|
4720
|
+
} catch {
|
|
4721
|
+
throw new Error(
|
|
4722
|
+
"axl-eval is required for AxlRuntime.runRegisteredEval(). Install it with: npm install @axlsdk/eval"
|
|
4723
|
+
);
|
|
4724
|
+
}
|
|
4725
|
+
return runEvalFn(entry.config, entry.executeWorkflow);
|
|
4726
|
+
}
|
|
4727
|
+
return this.eval(
|
|
4728
|
+
entry.config
|
|
4729
|
+
);
|
|
4730
|
+
}
|
|
4675
4731
|
/** Get all execution info (running + completed). */
|
|
4676
4732
|
getExecutions() {
|
|
4677
4733
|
return [...this.executions.values()];
|
|
@@ -5055,10 +5111,10 @@ var AxlRuntime = class extends EventEmitter2 {
|
|
|
5055
5111
|
async eval(config) {
|
|
5056
5112
|
let runEval;
|
|
5057
5113
|
try {
|
|
5058
|
-
({ runEval } = await import("
|
|
5114
|
+
({ runEval } = await import("@axlsdk/eval"));
|
|
5059
5115
|
} catch {
|
|
5060
5116
|
throw new Error(
|
|
5061
|
-
"axl-eval is required for AxlRuntime.eval(). Install it with: npm install
|
|
5117
|
+
"axl-eval is required for AxlRuntime.eval(). Install it with: npm install @axlsdk/eval"
|
|
5062
5118
|
);
|
|
5063
5119
|
}
|
|
5064
5120
|
const executeWorkflow = async (input) => {
|
|
@@ -5085,10 +5141,10 @@ var AxlRuntime = class extends EventEmitter2 {
|
|
|
5085
5141
|
async evalCompare(baseline, candidate) {
|
|
5086
5142
|
let evalCompareFn;
|
|
5087
5143
|
try {
|
|
5088
|
-
({ evalCompare: evalCompareFn } = await import("
|
|
5144
|
+
({ evalCompare: evalCompareFn } = await import("@axlsdk/eval"));
|
|
5089
5145
|
} catch {
|
|
5090
5146
|
throw new Error(
|
|
5091
|
-
"axl-eval is required for AxlRuntime.evalCompare(). Install it with: npm install
|
|
5147
|
+
"axl-eval is required for AxlRuntime.evalCompare(). Install it with: npm install @axlsdk/eval"
|
|
5092
5148
|
);
|
|
5093
5149
|
}
|
|
5094
5150
|
return evalCompareFn(baseline, candidate);
|