fascicle 0.8.13 → 0.9.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/CHANGELOG.md +39 -0
- package/README.md +2 -0
- package/dist/{adapters-DdUx-_b3.js → adapters-Dbx3M8m-.js} +3 -2
- package/dist/{adapters-DdUx-_b3.js.map → adapters-Dbx3M8m-.js.map} +1 -1
- package/dist/adapters.d.ts +1 -1
- package/dist/adapters.js +1 -1
- package/dist/{core-BhmclJzj.js → core-CYpxskeT.js} +3 -2
- package/dist/core-CYpxskeT.js.map +1 -0
- package/dist/{index-C3NcdaSY.d.ts → index-CJRUqgsV.d.ts} +10 -2
- package/dist/{index-CEj6hY9z.d.ts → index-JhJahQNi.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +40 -33
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +1 -1
- package/dist/mcp.js.map +1 -1
- package/dist/stdio.d.ts +1 -1
- package/dist/stdio.js +2 -2
- package/dist/stdio.js.map +1 -1
- package/dist/ui.d.ts +48 -0
- package/dist/ui.js +175 -0
- package/dist/ui.js.map +1 -0
- package/package.json +46 -39
- package/dist/core-BhmclJzj.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as timeout_error, C as describe, D as describe_cycle_error, E as aborted_error, O as resume_validation_error, S as sequence, T as run, _ as retry, a as trajectory_event_schema, b as branch, c as scope, d as suspend, f as checkpoint, g as fallback, h as timeout, i as span_start_event_schema, j as flow_schema_default, k as suspended_error, l as stash, m as loop, n as emit_event_schema, o as STEP_KINDS, p as compose, r as span_end_event_schema, s as is_step_kind, t as custom_event_schema, u as use, v as pipe, w as step, x as parallel, y as map } from "./core-
|
|
2
|
-
import { a as http_logger, n as tee_logger, o as filesystem_logger } from "./adapters-
|
|
1
|
+
import { A as timeout_error, C as describe, D as describe_cycle_error, E as aborted_error, O as resume_validation_error, S as sequence, T as run, _ as retry, a as trajectory_event_schema, b as branch, c as scope, d as suspend, f as checkpoint, g as fallback, h as timeout, i as span_start_event_schema, j as flow_schema_default, k as suspended_error, l as stash, m as loop, n as emit_event_schema, o as STEP_KINDS, p as compose, r as span_end_event_schema, s as is_step_kind, t as custom_event_schema, u as use, v as pipe, w as step, x as parallel, y as map } from "./core-CYpxskeT.js";
|
|
2
|
+
import { a as http_logger, n as tee_logger, o as filesystem_logger } from "./adapters-Dbx3M8m-.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { mkdir, open, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
@@ -7,7 +7,7 @@ import { dirname, join, resolve } from "node:path";
|
|
|
7
7
|
import { createReadStream, existsSync, mkdtempSync, statSync, watch, writeFileSync } from "node:fs";
|
|
8
8
|
import { tmpdir } from "node:os";
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
10
|
-
import { NoObjectGeneratedError, Output, generateText,
|
|
10
|
+
import { NoObjectGeneratedError, Output, generateText, isStepCount, streamText, tool } from "ai";
|
|
11
11
|
import { createServer } from "node:http";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import { parseArgs } from "node:util";
|
|
@@ -1023,14 +1023,14 @@ function regression_compare(current, baseline, options = {}) {
|
|
|
1023
1023
|
function compute_per_case(current, baseline, score_threshold, cost_threshold) {
|
|
1024
1024
|
const by_id_current = index_by_case_id(current.cases);
|
|
1025
1025
|
const by_id_baseline = index_by_case_id(baseline.cases);
|
|
1026
|
-
const all_ids = new Set([...by_id_current.keys(), ...by_id_baseline.keys()]);
|
|
1026
|
+
const all_ids = /* @__PURE__ */ new Set([...by_id_current.keys(), ...by_id_baseline.keys()]);
|
|
1027
1027
|
const out = [];
|
|
1028
1028
|
for (const id of all_ids) {
|
|
1029
1029
|
const c = by_id_current.get(id);
|
|
1030
1030
|
const b = by_id_baseline.get(id);
|
|
1031
1031
|
const score_deltas = {};
|
|
1032
1032
|
let any_score_regression = false;
|
|
1033
|
-
const judge_names = new Set([...Object.keys(c?.scores ?? {}), ...Object.keys(b?.scores ?? {})]);
|
|
1033
|
+
const judge_names = /* @__PURE__ */ new Set([...Object.keys(c?.scores ?? {}), ...Object.keys(b?.scores ?? {})]);
|
|
1034
1034
|
for (const name of judge_names) {
|
|
1035
1035
|
const delta = score_value(c?.scores[name]) - score_value(b?.scores[name]);
|
|
1036
1036
|
score_deltas[name] = delta;
|
|
@@ -1065,7 +1065,7 @@ function index_by_case_id(cases) {
|
|
|
1065
1065
|
return m;
|
|
1066
1066
|
}
|
|
1067
1067
|
function collect_judge_names(a, b) {
|
|
1068
|
-
return [
|
|
1068
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(a.summary.mean_scores), ...Object.keys(b.summary.mean_scores)])].toSorted();
|
|
1069
1069
|
}
|
|
1070
1070
|
async function read_baseline(path) {
|
|
1071
1071
|
const text = await readFile(path, "utf8");
|
|
@@ -1085,7 +1085,7 @@ function validate_report(value, path) {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
//#endregion
|
|
1087
1087
|
//#region src/engine/pricing.ts
|
|
1088
|
-
const FREE_PROVIDERS = new Set(["ollama", "lmstudio"]);
|
|
1088
|
+
const FREE_PROVIDERS = /* @__PURE__ */ new Set(["ollama", "lmstudio"]);
|
|
1089
1089
|
const DEFAULT_PRICING = Object.freeze({
|
|
1090
1090
|
"anthropic:claude-opus-4-8": {
|
|
1091
1091
|
input_per_million: 5,
|
|
@@ -1530,7 +1530,7 @@ function translate_anthropic_effort(effort) {
|
|
|
1530
1530
|
function normalize_anthropic_usage(raw) {
|
|
1531
1531
|
return default_normalize_usage(raw);
|
|
1532
1532
|
}
|
|
1533
|
-
const SUPPORTED$7 = new Set([
|
|
1533
|
+
const SUPPORTED$7 = /* @__PURE__ */ new Set([
|
|
1534
1534
|
"text",
|
|
1535
1535
|
"tools",
|
|
1536
1536
|
"schema",
|
|
@@ -1578,7 +1578,7 @@ function translate_openai_effort(effort) {
|
|
|
1578
1578
|
function normalize_openai_usage(raw) {
|
|
1579
1579
|
return default_normalize_usage(raw);
|
|
1580
1580
|
}
|
|
1581
|
-
const SUPPORTED$6 = new Set([
|
|
1581
|
+
const SUPPORTED$6 = /* @__PURE__ */ new Set([
|
|
1582
1582
|
"text",
|
|
1583
1583
|
"tools",
|
|
1584
1584
|
"schema",
|
|
@@ -1628,7 +1628,7 @@ function translate_google_effort(effort) {
|
|
|
1628
1628
|
function normalize_google_usage(raw) {
|
|
1629
1629
|
return default_normalize_usage(raw);
|
|
1630
1630
|
}
|
|
1631
|
-
const SUPPORTED$5 = new Set([
|
|
1631
|
+
const SUPPORTED$5 = /* @__PURE__ */ new Set([
|
|
1632
1632
|
"text",
|
|
1633
1633
|
"tools",
|
|
1634
1634
|
"schema",
|
|
@@ -1669,7 +1669,7 @@ function normalize_ollama_usage(raw) {
|
|
|
1669
1669
|
delete base.reasoning_tokens;
|
|
1670
1670
|
return base;
|
|
1671
1671
|
}
|
|
1672
|
-
const SUPPORTED$4 = new Set([
|
|
1672
|
+
const SUPPORTED$4 = /* @__PURE__ */ new Set([
|
|
1673
1673
|
"text",
|
|
1674
1674
|
"tools",
|
|
1675
1675
|
"schema",
|
|
@@ -1705,7 +1705,7 @@ function normalize_lmstudio_usage(raw) {
|
|
|
1705
1705
|
delete base.reasoning_tokens;
|
|
1706
1706
|
return base;
|
|
1707
1707
|
}
|
|
1708
|
-
const SUPPORTED$3 = new Set([
|
|
1708
|
+
const SUPPORTED$3 = /* @__PURE__ */ new Set([
|
|
1709
1709
|
"text",
|
|
1710
1710
|
"tools",
|
|
1711
1711
|
"schema",
|
|
@@ -1721,7 +1721,8 @@ const create_lmstudio_adapter = (init) => {
|
|
|
1721
1721
|
async build_model(model_id) {
|
|
1722
1722
|
return (await load_optional_peer("@ai-sdk/openai-compatible")).createOpenAICompatible({
|
|
1723
1723
|
name: "lmstudio",
|
|
1724
|
-
baseURL: base_url
|
|
1724
|
+
baseURL: base_url,
|
|
1725
|
+
includeUsage: true
|
|
1725
1726
|
})(model_id);
|
|
1726
1727
|
},
|
|
1727
1728
|
translate_effort: translate_lmstudio_effort,
|
|
@@ -1744,7 +1745,7 @@ function translate_openrouter_effort(effort) {
|
|
|
1744
1745
|
function normalize_openrouter_usage(raw) {
|
|
1745
1746
|
return default_normalize_usage(raw);
|
|
1746
1747
|
}
|
|
1747
|
-
const SUPPORTED$2 = new Set([
|
|
1748
|
+
const SUPPORTED$2 = /* @__PURE__ */ new Set([
|
|
1748
1749
|
"text",
|
|
1749
1750
|
"tools",
|
|
1750
1751
|
"schema",
|
|
@@ -1803,7 +1804,7 @@ function translate_bedrock_effort(effort) {
|
|
|
1803
1804
|
function normalize_bedrock_usage(raw) {
|
|
1804
1805
|
return default_normalize_usage(raw);
|
|
1805
1806
|
}
|
|
1806
|
-
const SUPPORTED$1 = new Set([
|
|
1807
|
+
const SUPPORTED$1 = /* @__PURE__ */ new Set([
|
|
1807
1808
|
"text",
|
|
1808
1809
|
"tools",
|
|
1809
1810
|
"schema",
|
|
@@ -3166,7 +3167,7 @@ function create_option_ignored_dedup(trajectory) {
|
|
|
3166
3167
|
* dispose, supports }` — no `build_model`, `translate_effort`, or
|
|
3167
3168
|
* `normalize_usage` members.
|
|
3168
3169
|
*/
|
|
3169
|
-
const SUPPORTED = new Set([
|
|
3170
|
+
const SUPPORTED = /* @__PURE__ */ new Set([
|
|
3170
3171
|
"text",
|
|
3171
3172
|
"tools",
|
|
3172
3173
|
"schema",
|
|
@@ -3458,7 +3459,7 @@ function create_claude_cli_adapter(init) {
|
|
|
3458
3459
|
* a frozen Map; runtime provider registration beyond the built-in set is
|
|
3459
3460
|
* deferred (spec §5.9).
|
|
3460
3461
|
*/
|
|
3461
|
-
const BUILTIN_PROVIDERS = new Map([
|
|
3462
|
+
const BUILTIN_PROVIDERS = /* @__PURE__ */ new Map([
|
|
3462
3463
|
["anthropic", create_anthropic_adapter],
|
|
3463
3464
|
["openai", create_openai_adapter],
|
|
3464
3465
|
["google", create_google_adapter],
|
|
@@ -4116,12 +4117,13 @@ async function run_tool_loop(config) {
|
|
|
4116
4117
|
}
|
|
4117
4118
|
const would_exceed_after = step_index + 1 >= config.max_steps;
|
|
4118
4119
|
const tool_results_to_feed = [];
|
|
4120
|
+
let terminal_fired = false;
|
|
4119
4121
|
for (const raw_call of effective_calls) {
|
|
4120
4122
|
throw_if_aborted_in_flight(config.abort, step_index, {
|
|
4121
4123
|
id: raw_call.id,
|
|
4122
4124
|
name: raw_call.name
|
|
4123
4125
|
});
|
|
4124
|
-
if (would_exceed_after) {
|
|
4126
|
+
if (would_exceed_after && tool_map.get(raw_call.name)?.ends_turn !== true) {
|
|
4125
4127
|
const record = {
|
|
4126
4128
|
id: raw_call.id,
|
|
4127
4129
|
name: raw_call.name,
|
|
@@ -4311,6 +4313,7 @@ async function run_tool_loop(config) {
|
|
|
4311
4313
|
};
|
|
4312
4314
|
step_tool_records.push(record);
|
|
4313
4315
|
tool_calls_all.push(record);
|
|
4316
|
+
if (tool.ends_turn === true) terminal_fired = true;
|
|
4314
4317
|
tool_results_to_feed.push(build_tool_result_message(raw_call.id, tool.name, output ?? ""));
|
|
4315
4318
|
record_tool_call(config.trajectory, {
|
|
4316
4319
|
step_index,
|
|
@@ -4349,7 +4352,7 @@ async function run_tool_loop(config) {
|
|
|
4349
4352
|
...r.error !== void 0 ? { error: r.error } : { output: r.output }
|
|
4350
4353
|
});
|
|
4351
4354
|
for (const m of tool_results_to_feed) config.messages.push(m);
|
|
4352
|
-
const turn_finish_reason = would_exceed_after ? "max_steps" : salvage !== void 0 ? "tool_calls" : turn.finish_reason;
|
|
4355
|
+
const turn_finish_reason = terminal_fired ? "tool_calls" : would_exceed_after ? "max_steps" : salvage !== void 0 ? "tool_calls" : turn.finish_reason;
|
|
4353
4356
|
const step_record = {
|
|
4354
4357
|
index: step_index,
|
|
4355
4358
|
text: turn.text,
|
|
@@ -4365,6 +4368,11 @@ async function run_tool_loop(config) {
|
|
|
4365
4368
|
usage: turn.usage,
|
|
4366
4369
|
finish_reason: turn_finish_reason
|
|
4367
4370
|
});
|
|
4371
|
+
if (terminal_fired) {
|
|
4372
|
+
finish_reason = "stop";
|
|
4373
|
+
text = turn.text;
|
|
4374
|
+
break;
|
|
4375
|
+
}
|
|
4368
4376
|
if (would_exceed_after) {
|
|
4369
4377
|
max_steps_reached = true;
|
|
4370
4378
|
finish_reason = "max_steps";
|
|
@@ -4535,8 +4543,9 @@ function to_sdk_messages(messages) {
|
|
|
4535
4543
|
* as potentially attacker-controlled: it warns on every call (and newer `ai`
|
|
4536
4544
|
* versions throw unless `allowSystemInMessages` is set). fascicle's system
|
|
4537
4545
|
* content is the developer's own prompt, and the SDK's own recommendation is to
|
|
4538
|
-
* deliver it through the top-level `
|
|
4539
|
-
* at its source rather than
|
|
4546
|
+
* deliver it through the top-level `instructions` option (v7's rename of the
|
|
4547
|
+
* former `system` option), which removes the warning at its source rather than
|
|
4548
|
+
* suppressing it.
|
|
4540
4549
|
*
|
|
4541
4550
|
* Only the *leading* run is hoisted (fascicle's only shape: one or more system
|
|
4542
4551
|
* messages, then the conversation). A system message that appears after a
|
|
@@ -4609,11 +4618,7 @@ function map_stream_part_to_chunk(part, step_index) {
|
|
|
4609
4618
|
}
|
|
4610
4619
|
}
|
|
4611
4620
|
function default_usage_from_sdk(usage) {
|
|
4612
|
-
|
|
4613
|
-
return {
|
|
4614
|
-
input_tokens: raw.input_tokens ?? 0,
|
|
4615
|
-
output_tokens: raw.output_tokens ?? 0
|
|
4616
|
-
};
|
|
4621
|
+
return default_normalize_usage(to_raw_provider_usage(usage));
|
|
4617
4622
|
}
|
|
4618
4623
|
async function collect_stream(params, step_index, dispatcher, on_first_chunk, internal_controller, adapter) {
|
|
4619
4624
|
const stream_result = streamText(params);
|
|
@@ -4622,7 +4627,7 @@ async function collect_stream(params, step_index, dispatcher, on_first_chunk, in
|
|
|
4622
4627
|
let finish_reason = "stop";
|
|
4623
4628
|
let raw_usage = {};
|
|
4624
4629
|
let first = true;
|
|
4625
|
-
for await (const part of stream_result.
|
|
4630
|
+
for await (const part of stream_result.stream) {
|
|
4626
4631
|
if (first) {
|
|
4627
4632
|
first = false;
|
|
4628
4633
|
on_first_chunk();
|
|
@@ -4679,7 +4684,7 @@ async function collect_non_stream(params, adapter) {
|
|
|
4679
4684
|
};
|
|
4680
4685
|
}
|
|
4681
4686
|
/**
|
|
4682
|
-
* When `
|
|
4687
|
+
* When `output` (structured output) is in play, `generateText` eagerly parses the
|
|
4683
4688
|
* model's text against the schema and throws `NoObjectGeneratedError` if it
|
|
4684
4689
|
* does not conform. That parse is the SDK's, not fascicle's: turning it into a
|
|
4685
4690
|
* thrown error would skip the engine's own schema-parse + repair loop (and the
|
|
@@ -4833,11 +4838,12 @@ async function generate(opts_in, engine) {
|
|
|
4833
4838
|
model,
|
|
4834
4839
|
messages: sdk_messages,
|
|
4835
4840
|
abortSignal: internal_controller.signal,
|
|
4836
|
-
stopWhen:
|
|
4841
|
+
stopWhen: isStepCount(1),
|
|
4842
|
+
maxRetries: 0
|
|
4837
4843
|
};
|
|
4838
|
-
if (hoisted_system !== void 0) base_params.
|
|
4844
|
+
if (hoisted_system !== void 0) base_params.instructions = hoisted_system;
|
|
4839
4845
|
if (sdk_tools !== void 0) base_params.tools = sdk_tools;
|
|
4840
|
-
if (output_spec !== void 0) base_params.
|
|
4846
|
+
if (output_spec !== void 0) base_params.output = output_spec;
|
|
4841
4847
|
if (provider_options !== void 0) base_params.providerOptions = provider_options;
|
|
4842
4848
|
if (opts.temperature !== void 0) base_params.temperature = opts.temperature;
|
|
4843
4849
|
if (opts.max_tokens !== void 0) base_params.maxOutputTokens = opts.max_tokens;
|
|
@@ -5181,7 +5187,7 @@ function model_call(cfg) {
|
|
|
5181
5187
|
if (cfg.max_tool_calls_per_step !== void 0) opts.max_tool_calls_per_step = cfg.max_tool_calls_per_step;
|
|
5182
5188
|
if (cfg.on_tool_approval !== void 0) opts.on_tool_approval = cfg.on_tool_approval;
|
|
5183
5189
|
if (ctx.streaming) opts.on_chunk = (chunk) => {
|
|
5184
|
-
ctx.
|
|
5190
|
+
ctx.trajectory.record({
|
|
5185
5191
|
kind: "model_chunk",
|
|
5186
5192
|
step_id,
|
|
5187
5193
|
chunk
|
|
@@ -5323,8 +5329,9 @@ function start_server(options) {
|
|
|
5323
5329
|
http_server.listen(port, host, () => {
|
|
5324
5330
|
http_server.removeListener("error", res_err);
|
|
5325
5331
|
const addr = http_server.address();
|
|
5332
|
+
const bound_port = addr !== null && typeof addr === "object" && "port" in addr ? addr.port : port;
|
|
5326
5333
|
res_ok({
|
|
5327
|
-
url: `http://${host}:${
|
|
5334
|
+
url: `http://${host}:${bound_port}`,
|
|
5328
5335
|
close: () => close_server(http_server)
|
|
5329
5336
|
});
|
|
5330
5337
|
});
|