fascicle 0.16.4 → 0.16.5

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.16.5 — 2026-10-21
4
+
5
+ ### Fixed
6
+
7
+ - **A `claude_cli` session that isn't logged in says so.** A `claude -p` with no session to call with writes its reason to stdout, as a message in the model's place with the `authentication_failed` error code and an error result that reads "Not logged in · Please run /login", and it leaves stderr empty. The adapter read only stderr, so the call failed as `claude_cli_error: claude CLI exited with code 1:` with nothing after the colon. It reads the stream's error code as well now and throws `provider_auth_error` in the CLI's own words, `claude CLI reported an auth failure: Not logged in · Please run /login`, and any other failed exit with nothing on stderr carries the text of the CLI's error result. The error's `refresh_command` is `claude auth login`, since the CLI reads `claude login` as a prompt and opens a session.
8
+
9
+ ### Internal
10
+
11
+ - The `claude_cli` examples and their READMEs say `claude auth login` where they said `claude login`.
12
+
3
13
  ## v0.16.4 — 2026-10-21
4
14
 
5
15
  ### Added
package/dist/AGENTS.md CHANGED
@@ -3,7 +3,7 @@
3
3
  This file is for a coding agent (Claude Code, Codex, Cursor, or another) that's
4
4
  working in a project which uses the published `fascicle` package. A person who
5
5
  is learning Fascicle will usually import it from their `CLAUDE.md`, as
6
- [lesson 0](https://github.com/robmclarty/fascicle/blob/v0.16.4/docs/learn/00-set-up.md) shows. Every shape, rule, and error message below
6
+ [lesson 0](https://github.com/robmclarty/fascicle/blob/v0.16.5/docs/learn/00-set-up.md) shows. Every shape, rule, and error message below
7
7
  was checked against `fascicle` 0.16.3, and against 0.15.0 where the two differ,
8
8
  and a rule that a later release changes says what changed.
9
9
 
@@ -345,11 +345,11 @@ describe('the calculator', () => {
345
345
 
346
346
  ## Where to Look Next
347
347
 
348
- - [blueprint.md](https://github.com/robmclarty/fascicle/blob/v0.16.4/docs/blueprint.md) for the layout of a growing app.
349
- - [leaf-arm-spine.md](https://github.com/robmclarty/fascicle/blob/v0.16.4/docs/leaf-arm-spine.md) for choosing a primitive at each
348
+ - [blueprint.md](https://github.com/robmclarty/fascicle/blob/v0.16.5/docs/blueprint.md) for the layout of a growing app.
349
+ - [leaf-arm-spine.md](https://github.com/robmclarty/fascicle/blob/v0.16.5/docs/leaf-arm-spine.md) for choosing a primitive at each
350
350
  layer.
351
- - [composition.md](https://github.com/robmclarty/fascicle/blob/v0.16.4/docs/composition.md) for one line on every composer.
352
- - [cookbook.md](https://github.com/robmclarty/fascicle/blob/v0.16.4/docs/cookbook.md) for worked patterns, including tool loops with
351
+ - [composition.md](https://github.com/robmclarty/fascicle/blob/v0.16.5/docs/composition.md) for one line on every composer.
352
+ - [cookbook.md](https://github.com/robmclarty/fascicle/blob/v0.16.5/docs/cookbook.md) for worked patterns, including tool loops with
353
353
  `define_tool`.
354
- - [testing.md](https://github.com/robmclarty/fascicle/blob/v0.16.4/docs/testing.md) for the stand-in engines.
355
- - [troubleshooting.md](https://github.com/robmclarty/fascicle/blob/v0.16.4/docs/troubleshooting.md) for errors and their causes.
354
+ - [testing.md](https://github.com/robmclarty/fascicle/blob/v0.16.5/docs/testing.md) for the stand-in engines.
355
+ - [troubleshooting.md](https://github.com/robmclarty/fascicle/blob/v0.16.5/docs/troubleshooting.md) for errors and their causes.
@@ -3514,13 +3514,20 @@ function gate(raw, recognize) {
3514
3514
  }
3515
3515
  /**
3516
3516
  * Normalize an `assistant` event: its `message` must be an object and its
3517
- * `content` an array, whose recognized parts are kept and the rest dropped.
3517
+ * `content` an array, whose recognized parts are kept and the rest dropped. An
3518
+ * `error` code, when present, must be a string.
3518
3519
  */
3519
3520
  function as_assistant_event(raw) {
3520
3521
  const message = raw["message"];
3521
- if (!is_record(message)) return void 0;
3522
+ if (!is_record(message) || !opt_string(raw, "error")) return void 0;
3522
3523
  const content = collect_parts(message["content"], as_assistant_part);
3523
- return content === void 0 ? void 0 : {
3524
+ if (content === void 0) return void 0;
3525
+ const error = raw["error"];
3526
+ return typeof error === "string" ? {
3527
+ type: "assistant",
3528
+ message: { content },
3529
+ error
3530
+ } : {
3524
3531
  type: "assistant",
3525
3532
  message: { content }
3526
3533
  };
@@ -3701,6 +3708,7 @@ async function handle_assistant(state, event, chunks, dispatch) {
3701
3708
  flush_turn(state);
3702
3709
  state.current_step_index += 1;
3703
3710
  }
3711
+ if (event.error !== void 0) state.api_error = event.error;
3704
3712
  for (const part of event.message.content) {
3705
3713
  if (part.type === "text") {
3706
3714
  state.turn_text += part.text;
@@ -3887,6 +3895,7 @@ function snapshot(state) {
3887
3895
  if (state.total_cost_usd !== void 0) base.total_cost_usd = state.total_cost_usd;
3888
3896
  if (state.duration_ms !== void 0) base.duration_ms = state.duration_ms;
3889
3897
  if (state.duration_api_ms !== void 0) base.duration_api_ms = state.duration_api_ms;
3898
+ if (state.api_error !== void 0) base.api_error = state.api_error;
3890
3899
  return base;
3891
3900
  }
3892
3901
  //#endregion
@@ -4659,27 +4668,35 @@ function compile_schema(schema) {
4659
4668
  return JSON.stringify(to_json_schema(schema, { strip_meta: true }));
4660
4669
  }
4661
4670
  /**
4662
- * Turn a closed CLI subprocess's exit code, signal, and stderr into an
4663
- * `Error`.
4671
+ * Turn a closed CLI subprocess's exit code, signal, stderr, and what its
4672
+ * stream reported into an `Error`.
4673
+ *
4674
+ * Checks for an auth failure first, then for a claude binary that bwrap
4675
+ * started but couldn't find inside its sandbox, then for a missing sandbox
4676
+ * binary, then falls back to a generic exit-code error. The stderr snippet
4677
+ * attached to each error is truncated to 512 bytes.
4664
4678
  *
4665
- * Checks stderr for an auth failure first, then for a claude binary that
4666
- * bwrap started but couldn't find inside its sandbox, then for a missing
4667
- * sandbox binary, then falls back to a generic exit-code error. The stderr
4668
- * snippet attached to each error is truncated to 512 bytes.
4679
+ * A logged-out CLI says so on stdout and leaves stderr empty: it writes an
4680
+ * assistant message with the `authentication_failed` error code and an error
4681
+ * result that reads "Not logged in · Please run /login". So the auth check
4682
+ * reads the stream's error code as well as stderr, and when stderr is empty,
4683
+ * an error result's text stands in for it in the message.
4669
4684
  *
4670
4685
  * The bwrap check has to come before the sandbox check: bwrap's own
4671
4686
  * "execvp <binary>: No such file or directory" names bwrap and says the file
4672
4687
  * is missing, so the sandbox check would blame bwrap for the claude binary.
4673
4688
  */
4674
- function classify_close_error(code, signal, stderr) {
4689
+ function classify_close_error(code, signal, stderr, parsed) {
4675
4690
  const snippet = stderr.slice(0, 512);
4676
- if (stderr_is_auth_failure(stderr)) return new provider_auth_error(PROVIDER_NAME, `claude CLI reported an auth failure: ${snippet}`, { refresh_command: "claude login" });
4691
+ const reported = parsed?.is_error === true ? parsed.final_text.slice(0, 512) : "";
4692
+ const detail = snippet.length > 0 ? snippet : reported;
4693
+ if (stderr_is_auth_failure(stderr) || parsed?.api_error === "authentication_failed") return new provider_auth_error(PROVIDER_NAME, `claude CLI reported an auth failure: ${detail}`, { refresh_command: "claude auth login" });
4677
4694
  const sandboxed_binary = BWRAP_EXEC_MISSING.exec(stderr)?.[1];
4678
4695
  if (sandboxed_binary !== void 0) return new claude_cli_error("binary_not_found", `bwrap ran but found no claude binary at '${sandboxed_binary}' inside its sandbox, which binds only /usr, /bin, /lib, /lib64, and additional_write_paths: ${snippet}`, { stderr_snippet: snippet });
4679
4696
  if (/bwrap|greywall|sandbox/i.test(stderr) && /not found|no such file|enoent/i.test(stderr)) return new claude_cli_error("sandbox_unavailable", `sandbox binary unavailable: ${snippet}`, { stderr_snippet: snippet });
4680
4697
  const status = typeof code === "number" ? code : void 0;
4681
4698
  const signal_part = signal !== null ? ` (signal ${signal})` : "";
4682
- const message = `claude CLI exited with code ${String(code)}${signal_part}: ${snippet}`;
4699
+ const message = `claude CLI exited with code ${String(code)}${signal_part}: ${detail}`;
4683
4700
  const metadata = { stderr_snippet: snippet };
4684
4701
  if (status !== void 0) metadata.status = status;
4685
4702
  return new claude_cli_error("subprocess_exit", message, metadata);
@@ -4731,7 +4748,7 @@ async function run_cli(spawn_runtime, args) {
4731
4748
  throw err;
4732
4749
  }
4733
4750
  const parsed = snapshot(state);
4734
- if (close_outcome.code !== 0) throw classify_close_error(close_outcome.code, close_outcome.signal, close_outcome.stderr);
4751
+ if (close_outcome.code !== 0) throw classify_close_error(close_outcome.code, close_outcome.signal, close_outcome.stderr, parsed);
4735
4752
  if (!parsed.received_result) throw new claude_cli_error("no_result_event", "claude CLI closed without emitting a terminal result event", { stderr_snippet: close_outcome.stderr.slice(0, 512) });
4736
4753
  return {
4737
4754
  parsed,
@@ -7403,4 +7420,4 @@ function create_engine(config) {
7403
7420
  //#endregion
7404
7421
  export { create_engine as t };
7405
7422
 
7406
- //# sourceMappingURL=engine-D1QMcyIG.js.map
7423
+ //# sourceMappingURL=engine-B6rIIM4J.js.map