@bunshin-cc/bunshin 0.13.1 → 0.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.
Files changed (2) hide show
  1. package/dist/bin.js +16 -4
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -3575,6 +3575,16 @@ var init_adopt = __esm({
3575
3575
  }
3576
3576
  });
3577
3577
 
3578
+ // ../core/src/v2/dream.ts
3579
+ var init_dream = __esm({
3580
+ "../core/src/v2/dream.ts"() {
3581
+ "use strict";
3582
+ init_merge();
3583
+ init_guidelines();
3584
+ init_reconcile();
3585
+ }
3586
+ });
3587
+
3578
3588
  // ../core/src/v2/index.ts
3579
3589
  var init_v2 = __esm({
3580
3590
  "../core/src/v2/index.ts"() {
@@ -3602,6 +3612,7 @@ var init_v2 = __esm({
3602
3612
  init_scopes();
3603
3613
  init_generalize();
3604
3614
  init_adopt();
3615
+ init_dream();
3605
3616
  }
3606
3617
  });
3607
3618
 
@@ -11555,7 +11566,8 @@ async function runOnce(c, args, out, err) {
11555
11566
  if (!job) break;
11556
11567
  const started = Date.now();
11557
11568
  const scratch = fs31.mkdtempSync(path27.join(os7.tmpdir(), "bunshin-job-"));
11558
- const res = await askJson(config, { system: job.system, user: job.prompt, schema: job.schema, enforceSchema: false, timeoutMs: 15 * 6e4, maxTokens: 16e3, cwd: scratch }).finally(
11569
+ let usage;
11570
+ const res = await askJson(config, { system: job.system, user: job.prompt, schema: job.schema, enforceSchema: false, timeoutMs: 15 * 6e4, maxTokens: 16e3, cwd: scratch, onUsage: (u) => usage = u }).finally(
11559
11571
  () => fs31.rmSync(scratch, { recursive: true, force: true })
11560
11572
  );
11561
11573
  const model = config.backend === "codex-cli" ? config.codexModel ?? "codex default" : config.backend === "pi-cli" ? config.piModel ?? "pi default" : config.model;
@@ -11567,7 +11579,7 @@ async function runOnce(c, args, out, err) {
11567
11579
  if (r2.body.status === "retry" && /no LLM backend|not found|ENOENT/.test(res.error)) break;
11568
11580
  continue;
11569
11581
  }
11570
- const r = await call(c, "POST", `/jobs/${job.id}/answer`, { answer: res.value, model, runner: c.name }, 12e4);
11582
+ const r = await call(c, "POST", `/jobs/${job.id}/answer`, { answer: res.value, model, runner: c.name, ...usage ? { usage } : {} }, 12e4);
11571
11583
  out(`${job.id} ${job.kind}: ${r.body.status}${r.body.error ? ` (${r.body.error})` : ""} in ${Math.round((Date.now() - started) / 1e3)}s via ${res.backend}
11572
11584
  `);
11573
11585
  if (r.body.status === "done" || r.body.status === "stale") done++;
@@ -11583,7 +11595,7 @@ function effortOf(job) {
11583
11595
  const tokens = Math.round(chars / 4);
11584
11596
  const minutes = Math.max(2, Math.round(2 + tokens / 15e3));
11585
11597
  const proposals = (job.prompt.match(/^### g_\w+/gm) ?? []).length;
11586
- const what = job.kind === "reflect" ? "read every [USER] message and each failed or denied result first; most sessions teach nothing new, and at most 4 lessons are kept" : job.kind === "merge" ? `${proposals} proposal${proposals === 1 ? "" : "s"} against one document: decide each, edit only what the applied ones need` : job.kind === "generalize" ? `${(job.prompt.match(/^<document /gm) ?? []).length} documents from sibling scopes: write once at the parent what at least two of them share, and trim it out of them; "nothing_shared" is a normal answer` : `${proposals} proposed new document${proposals === 1 ? "" : "s"}: combine, fold into existing ones, or reject`;
11598
+ const what = job.kind === "reflect" ? "read every [USER] message and each failed or denied result first; most sessions teach nothing new, and at most 4 lessons are kept" : job.kind === "merge" ? `${proposals} proposal${proposals === 1 ? "" : "s"} against one document: decide each, edit only what the applied ones need` : job.kind === "dream" ? `${proposals} proposal${proposals === 1 ? "" : "s"} that would wait for a person: integrate (as is, reworded, or into the document it belongs in), reject, or leave it for a person; check each against its session, and add rather than overwrite` : job.kind === "generalize" ? `${(job.prompt.match(/^<document /gm) ?? []).length} documents from sibling scopes: write once at the parent what at least two of them share, and trim it out of them; "nothing_shared" is a normal answer` : `${proposals} proposed new document${proposals === 1 ? "" : "s"}: combine, fold into existing ones, or reject`;
11587
11599
  return `${chars.toLocaleString("en")} chars (~${tokens.toLocaleString("en")} tokens); about ${minutes} min. ${what}.`;
11588
11600
  }
11589
11601
  function jobIndex(text2) {
@@ -12071,7 +12083,7 @@ var init_runner = __esm({
12071
12083
  init_trust();
12072
12084
  init_version();
12073
12085
  DEFAULT_API = "https://api.bunshin.cc";
12074
- KINDS2 = ["reflect", "merge", "create", "generalize"];
12086
+ KINDS2 = ["reflect", "merge", "create", "generalize", "dream"];
12075
12087
  str5 = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
12076
12088
  LAUNCHD_LABEL = "cc.bunshin.runner";
12077
12089
  CRON_MARK = "# bunshin-runner";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunshin-cc/bunshin",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "Shared memory for company AI agents. Connect Codex, Claude Code, or Pi to Bunshin.",
5
5
  "type": "module",
6
6
  "bin": {