volute 0.45.2 → 0.46.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 (62) hide show
  1. package/README.md +3 -3
  2. package/dist/{activity-events-BUR2RYTJ.js → activity-events-NF6VWTJQ.js} +1 -1
  3. package/dist/{auth-FLAEXXZK.js → auth-CCFAU4GQ.js} +2 -2
  4. package/dist/{chat-76MRWWQX.js → chat-ZIQQS25U.js} +1 -1
  5. package/dist/chunk-4YU7HF4L.js +237 -0
  6. package/dist/{chunk-OP4JG2BS.js → chunk-5ZQZDDIK.js} +6 -2
  7. package/dist/{chunk-FR6S2KNN.js → chunk-BJZ4PV7R.js} +1 -1
  8. package/dist/{chunk-NYC5U6K7.js → chunk-E3DA4HYV.js} +4 -4
  9. package/dist/{chunk-YT7PEESJ.js → chunk-JO5IO4FH.js} +245 -124
  10. package/dist/{chunk-7ZUB63PS.js → chunk-KGIXX4NM.js} +1 -1
  11. package/dist/{chunk-EJVPTVTI.js → chunk-KQSFTPIM.js} +1 -1
  12. package/dist/{chunk-T6HYVHPG.js → chunk-OV7ZQ2GH.js} +1 -1
  13. package/dist/{clock-K43IMROX.js → chunk-PJ45FQPT.js} +21 -16
  14. package/dist/{chunk-UYLGEDVD.js → chunk-YXSUMLTC.js} +44 -267
  15. package/dist/{chunk-7C44R625.js → chunk-ZNMCCHCP.js} +47 -1
  16. package/dist/cli.js +11 -11
  17. package/dist/clock-RHS2JEDL.js +16 -0
  18. package/dist/{cloud-sync-3OJOPZRT.js → cloud-sync-46RS4SDA.js} +9 -8
  19. package/dist/{conversations-JZTD6KLR.js → conversations-CJOOCGNW.js} +2 -2
  20. package/dist/{daemon-restart-TIHKVVVA.js → daemon-restart-VFEI57UO.js} +1 -1
  21. package/dist/daemon.js +249 -170
  22. package/dist/{delete-BFMIGAIB.js → delete-HPLC7ETU.js} +1 -1
  23. package/dist/{delivery-manager-VDVKVA46.js → delivery-manager-JINZRG2W.js} +9 -8
  24. package/dist/{echo-text-6JJOPUD4.js → echo-text-VQPB5L2X.js} +10 -9
  25. package/dist/{export-GGIVO76O.js → export-LY723I3Z.js} +3 -3
  26. package/dist/{extensions-JONTW2HF.js → extensions-ZELQLTSR.js} +9 -8
  27. package/dist/{message-delivery-3C65ZI6L.js → message-delivery-R7JSQGYX.js} +11 -8
  28. package/dist/{mind-DWB6XYCH.js → mind-LHKS55DI.js} +9 -9
  29. package/dist/{mind-activity-tracker-POBLU3LC.js → mind-activity-tracker-3QRNJVR4.js} +2 -2
  30. package/dist/{mind-service-3F4I46CI.js → mind-service-NB2JMWQZ.js} +11 -8
  31. package/dist/mind-sleep-74TGOQBC.js +83 -0
  32. package/dist/{package-A7KXT67Q.js → package-DOD6CPO6.js} +2 -1
  33. package/dist/{scheduler-P6DXLLXI.js → scheduler-WVKII3LA.js} +9 -8
  34. package/dist/{seed-HCP5NYKH.js → seed-CNYIHPOH.js} +1 -1
  35. package/dist/{seed-cmd-ILOGNIFB.js → seed-cmd-AVNUNLZV.js} +2 -2
  36. package/dist/{seed-create-OURS2LS4.js → seed-create-ANXGYSCC.js} +3 -3
  37. package/dist/{seed-sprout-ELDFDAN6.js → seed-sprout-NIUFTX32.js} +5 -3
  38. package/dist/{send-AAIOPJAV.js → send-SPE6DVNJ.js} +6 -0
  39. package/dist/{setup-DQM5VPY4.js → setup-QT2A25SY.js} +1 -1
  40. package/dist/skills/orientation/SKILL.md +1 -1
  41. package/dist/skills/volute-mind/SKILL.md +8 -8
  42. package/dist/skills/volute-mind/references/sleep.md +8 -1
  43. package/dist/{skills-BKINFL7W.js → skills-AKCFA7BN.js} +1 -1
  44. package/dist/{sleep-manager-HCUH4PM4.js → sleep-manager-G6TXSDP7.js} +9 -8
  45. package/dist/{spirit-DBTIW7P4.js → spirit-RPBLLUQ5.js} +2 -2
  46. package/dist/{sprout-W3KC7UGK.js → sprout-SMX42ZBP.js} +1 -1
  47. package/dist/{system-chat-XOALE2RD.js → system-chat-NDAW6YP7.js} +9 -8
  48. package/dist/{turn-tracker-2W6Q2NSR.js → turn-tracker-FOIBNUUA.js} +2 -1
  49. package/dist/{up-FTK7CTO3.js → up-PS6PFS75.js} +1 -1
  50. package/dist/{version-notify-3XMAIQTE.js → version-notify-C5CH7CVP.js} +15 -10
  51. package/dist/web-assets/assets/{index-Bc2m8gRC.js → index-CU6XWICM.js} +3 -3
  52. package/dist/web-assets/index.html +1 -1
  53. package/package.json +2 -1
  54. package/templates/_base/home/VOLUTE.md +6 -2
  55. package/templates/_base/src/lib/context-breakdown.ts +57 -67
  56. package/templates/_base/src/lib/volute-server.ts +2 -2
  57. package/templates/claude/src/agent.ts +78 -42
  58. package/templates/claude/src/lib/session-reaper.ts +31 -0
  59. package/templates/codex/src/agent.ts +62 -40
  60. package/templates/pi/src/agent.ts +55 -38
  61. package/dist/mind-sleep-YMBR3I35.js +0 -47
  62. /package/dist/{chunk-QNQMSWZE.js → chunk-K6T43YBD.js} +0 -0
@@ -16,6 +16,7 @@ import {
16
16
  countSkillDescriptionTokens,
17
17
  countSystemPromptTokens,
18
18
  findPiSessionFile,
19
+ getCachedContextInfo,
19
20
  processPiSession,
20
21
  readSdkInstructions,
21
22
  readSkillDescriptions,
@@ -36,7 +37,7 @@ import type {
36
37
  VoluteContentPart,
37
38
  VoluteEvent,
38
39
  } from "./lib/types.js";
39
- import type { ContextInfo, ContextMessages } from "./lib/volute-server.js";
40
+ import type { ContextInfo, ContextMessages, SessionContextInfo } from "./lib/volute-server.js";
40
41
 
41
42
  type PiAgentSession = Awaited<ReturnType<typeof createAgentSession>>["session"];
42
43
 
@@ -63,8 +64,8 @@ export function createMind(options: {
63
64
  subagents?: Record<string, SubagentConfig>;
64
65
  }): {
65
66
  resolve: HandlerResolver;
66
- getContextInfo: () => ContextInfo;
67
- getContextMessages: () => ContextMessages;
67
+ getContextInfo: () => Promise<ContextInfo>;
68
+ getContextMessages: () => Promise<ContextMessages>;
68
69
  } {
69
70
  const sessions = new Map<string, PiSession>();
70
71
  const prompts = loadPrompts();
@@ -538,50 +539,66 @@ export function createMind(options: {
538
539
  const claudeMdTokens = countSdkInstructionTokens(options.cwd);
539
540
  const skillDescTokens = countSkillDescriptionTokens([resolvePath(options.cwd, ".pi/skills")]);
540
541
 
541
- function processSession(sessionName: string) {
542
- const jsonlPath = findPiSessionFile(piSessionsDir, sessionName);
543
- return jsonlPath
544
- ? processPiSession(jsonlPath, systemPromptTokens, claudeMdTokens, skillDescTokens)
545
- : null;
546
- }
547
-
548
- function getContextInfo(): ContextInfo {
549
- return {
550
- sessions: Array.from(sessions.values()).map((s) => {
551
- try {
552
- const result = processSession(s.name);
553
- return {
554
- name: s.name,
555
- contextTokens: result?.parsed?.contextTokens ?? s.contextTokens,
556
- contextWindow: maxContextTokens,
557
- breakdown: result?.parsed?.breakdown,
558
- };
559
- } catch (err) {
560
- log("mind", `failed to get context breakdown for session "${s.name}":`, err);
561
- return { name: s.name, contextTokens: s.contextTokens, contextWindow: maxContextTokens };
562
- }
563
- }),
564
- systemPrompt: systemPromptTokens,
565
- };
542
+ async function getContextInfo(): Promise<ContextInfo> {
543
+ const infos: SessionContextInfo[] = [];
544
+ for (const s of sessions.values()) {
545
+ try {
546
+ const jsonlPath = findPiSessionFile(piSessionsDir, s.name);
547
+ // Cache the computed breakdown by file identity: polls between turns are free.
548
+ const parsed = jsonlPath
549
+ ? await getCachedContextInfo(
550
+ jsonlPath,
551
+ async () =>
552
+ (
553
+ await processPiSession(
554
+ jsonlPath,
555
+ systemPromptTokens,
556
+ claudeMdTokens,
557
+ skillDescTokens,
558
+ )
559
+ ).parsed,
560
+ )
561
+ : null;
562
+ infos.push({
563
+ name: s.name,
564
+ contextTokens: parsed?.contextTokens ?? s.contextTokens,
565
+ contextWindow: maxContextTokens,
566
+ breakdown: parsed?.breakdown,
567
+ });
568
+ } catch (err) {
569
+ log("mind", `failed to get context breakdown for session "${s.name}":`, err);
570
+ infos.push({
571
+ name: s.name,
572
+ contextTokens: s.contextTokens,
573
+ contextWindow: maxContextTokens,
574
+ });
575
+ }
576
+ }
577
+ return { sessions: infos, systemPrompt: systemPromptTokens };
566
578
  }
567
579
 
568
- function getContextMessages(): ContextMessages {
580
+ async function getContextMessages(): Promise<ContextMessages> {
569
581
  const skillsDir = resolvePath(options.cwd, ".pi/skills");
582
+ const sessionMessages: ContextMessages["sessions"] = [];
583
+ for (const s of sessions.values()) {
584
+ try {
585
+ const jsonlPath = findPiSessionFile(piSessionsDir, s.name);
586
+ const result = jsonlPath
587
+ ? await processPiSession(jsonlPath, systemPromptTokens, claudeMdTokens, skillDescTokens)
588
+ : null;
589
+ sessionMessages.push({ name: s.name, messages: result?.messages ?? [] });
590
+ } catch (err) {
591
+ log("mind", `failed to extract messages for session "${s.name}":`, err);
592
+ sessionMessages.push({ name: s.name, messages: [] });
593
+ }
594
+ }
570
595
  return {
571
596
  preamble: {
572
597
  systemPrompt: options.systemPrompt,
573
598
  sdkInstructions: readSdkInstructions(options.cwd),
574
599
  skillDescriptions: readSkillDescriptions([skillsDir]),
575
600
  },
576
- sessions: Array.from(sessions.values()).map((s) => {
577
- try {
578
- const result = processSession(s.name);
579
- return { name: s.name, messages: result?.messages ?? [] };
580
- } catch (err) {
581
- log("mind", `failed to extract messages for session "${s.name}":`, err);
582
- return { name: s.name, messages: [] };
583
- }
584
- }),
601
+ sessions: sessionMessages,
585
602
  };
586
603
  }
587
604
 
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- resolveMindName
4
- } from "./chunk-BTY4WNFE.js";
5
- import {
6
- daemonFetch
7
- } from "./chunk-RBNMDAKB.js";
8
- import {
9
- command
10
- } from "./chunk-TXSA4Q3V.js";
11
- import "./chunk-O7IGP7ZW.js";
12
- import "./chunk-K3NQKI34.js";
13
-
14
- // packages/cli/src/commands/mind-sleep.ts
15
- var cmd = command({
16
- name: "volute clock sleep",
17
- description: "Put a mind to sleep",
18
- args: [{ name: "name", description: "Mind to sleep (or use --mind / VOLUTE_MIND)" }],
19
- flags: {
20
- mind: { type: "string", description: "Mind name" },
21
- "wake-at": { type: "string", description: "Schedule wake time" }
22
- },
23
- run: async ({ args, flags }) => {
24
- const name = args.name || resolveMindName(flags);
25
- if (!name) {
26
- console.error("Provide a mind name as argument, --mind flag, or VOLUTE_MIND env var");
27
- process.exit(1);
28
- }
29
- const body = {};
30
- if (flags["wake-at"]) body.wakeAt = flags["wake-at"];
31
- const res = await daemonFetch(`/api/minds/${encodeURIComponent(name)}/sleep`, {
32
- method: "POST",
33
- headers: { "Content-Type": "application/json" },
34
- body: JSON.stringify(body)
35
- });
36
- const data = await res.json();
37
- if (!res.ok) {
38
- console.error(data.error || "Failed to put mind to sleep");
39
- process.exit(1);
40
- }
41
- console.log(`${name} is going to sleep`);
42
- }
43
- });
44
- var run = cmd.execute;
45
- export {
46
- run
47
- };
File without changes