@tenphi/akno 0.1.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 (147) hide show
  1. package/LICENSE +83 -0
  2. package/README.md +46 -0
  3. package/dist/args.d.ts +18 -0
  4. package/dist/args.d.ts.map +1 -0
  5. package/dist/args.js +92 -0
  6. package/dist/args.js.map +1 -0
  7. package/dist/bin.d.ts +3 -0
  8. package/dist/bin.d.ts.map +1 -0
  9. package/dist/bin.js +142 -0
  10. package/dist/bin.js.map +1 -0
  11. package/dist/commands/adopt-cmd.d.ts +2 -0
  12. package/dist/commands/adopt-cmd.d.ts.map +1 -0
  13. package/dist/commands/adopt-cmd.js +61 -0
  14. package/dist/commands/adopt-cmd.js.map +1 -0
  15. package/dist/commands/answer-cmd.d.ts +2 -0
  16. package/dist/commands/answer-cmd.d.ts.map +1 -0
  17. package/dist/commands/answer-cmd.js +150 -0
  18. package/dist/commands/answer-cmd.js.map +1 -0
  19. package/dist/commands/bench-cmd.d.ts +4 -0
  20. package/dist/commands/bench-cmd.d.ts.map +1 -0
  21. package/dist/commands/bench-cmd.js +1542 -0
  22. package/dist/commands/bench-cmd.js.map +1 -0
  23. package/dist/commands/config-cmd.d.ts +7 -0
  24. package/dist/commands/config-cmd.d.ts.map +1 -0
  25. package/dist/commands/config-cmd.js +80 -0
  26. package/dist/commands/config-cmd.js.map +1 -0
  27. package/dist/commands/context-cmd.d.ts +2 -0
  28. package/dist/commands/context-cmd.d.ts.map +1 -0
  29. package/dist/commands/context-cmd.js +130 -0
  30. package/dist/commands/context-cmd.js.map +1 -0
  31. package/dist/commands/doctor-cmd.d.ts +2 -0
  32. package/dist/commands/doctor-cmd.d.ts.map +1 -0
  33. package/dist/commands/doctor-cmd.js +198 -0
  34. package/dist/commands/doctor-cmd.js.map +1 -0
  35. package/dist/commands/dream-cmd.d.ts +26 -0
  36. package/dist/commands/dream-cmd.d.ts.map +1 -0
  37. package/dist/commands/dream-cmd.js +1167 -0
  38. package/dist/commands/dream-cmd.js.map +1 -0
  39. package/dist/commands/dream-model-status.d.ts +5 -0
  40. package/dist/commands/dream-model-status.d.ts.map +1 -0
  41. package/dist/commands/dream-model-status.js +33 -0
  42. package/dist/commands/dream-model-status.js.map +1 -0
  43. package/dist/commands/dream-notifications.d.ts +24 -0
  44. package/dist/commands/dream-notifications.d.ts.map +1 -0
  45. package/dist/commands/dream-notifications.js +168 -0
  46. package/dist/commands/dream-notifications.js.map +1 -0
  47. package/dist/commands/dream-schedule.d.ts +55 -0
  48. package/dist/commands/dream-schedule.d.ts.map +1 -0
  49. package/dist/commands/dream-schedule.js +160 -0
  50. package/dist/commands/dream-schedule.js.map +1 -0
  51. package/dist/commands/folder-cmd.d.ts +2 -0
  52. package/dist/commands/folder-cmd.d.ts.map +1 -0
  53. package/dist/commands/folder-cmd.js +84 -0
  54. package/dist/commands/folder-cmd.js.map +1 -0
  55. package/dist/commands/graph-cmd.d.ts +2 -0
  56. package/dist/commands/graph-cmd.d.ts.map +1 -0
  57. package/dist/commands/graph-cmd.js +126 -0
  58. package/dist/commands/graph-cmd.js.map +1 -0
  59. package/dist/commands/inbox-cmd.d.ts +2 -0
  60. package/dist/commands/inbox-cmd.d.ts.map +1 -0
  61. package/dist/commands/inbox-cmd.js +69 -0
  62. package/dist/commands/inbox-cmd.js.map +1 -0
  63. package/dist/commands/index-cmd.d.ts +2 -0
  64. package/dist/commands/index-cmd.d.ts.map +1 -0
  65. package/dist/commands/index-cmd.js +102 -0
  66. package/dist/commands/index-cmd.js.map +1 -0
  67. package/dist/commands/ingest-cmd.d.ts +2 -0
  68. package/dist/commands/ingest-cmd.d.ts.map +1 -0
  69. package/dist/commands/ingest-cmd.js +167 -0
  70. package/dist/commands/ingest-cmd.js.map +1 -0
  71. package/dist/commands/init-cmd.d.ts +292 -0
  72. package/dist/commands/init-cmd.d.ts.map +1 -0
  73. package/dist/commands/init-cmd.js +476 -0
  74. package/dist/commands/init-cmd.js.map +1 -0
  75. package/dist/commands/init-prompts.d.ts +51 -0
  76. package/dist/commands/init-prompts.d.ts.map +1 -0
  77. package/dist/commands/init-prompts.js +192 -0
  78. package/dist/commands/init-prompts.js.map +1 -0
  79. package/dist/commands/list-cmd.d.ts +2 -0
  80. package/dist/commands/list-cmd.d.ts.map +1 -0
  81. package/dist/commands/list-cmd.js +77 -0
  82. package/dist/commands/list-cmd.js.map +1 -0
  83. package/dist/commands/maintenance-policy-output.d.ts +4 -0
  84. package/dist/commands/maintenance-policy-output.d.ts.map +1 -0
  85. package/dist/commands/maintenance-policy-output.js +72 -0
  86. package/dist/commands/maintenance-policy-output.js.map +1 -0
  87. package/dist/commands/mutate-cmd.d.ts +5 -0
  88. package/dist/commands/mutate-cmd.d.ts.map +1 -0
  89. package/dist/commands/mutate-cmd.js +224 -0
  90. package/dist/commands/mutate-cmd.js.map +1 -0
  91. package/dist/commands/plan-cmd.d.ts +9 -0
  92. package/dist/commands/plan-cmd.d.ts.map +1 -0
  93. package/dist/commands/plan-cmd.js +411 -0
  94. package/dist/commands/plan-cmd.js.map +1 -0
  95. package/dist/commands/read-cmd.d.ts +2 -0
  96. package/dist/commands/read-cmd.d.ts.map +1 -0
  97. package/dist/commands/read-cmd.js +89 -0
  98. package/dist/commands/read-cmd.js.map +1 -0
  99. package/dist/commands/recall-cmd.d.ts +2 -0
  100. package/dist/commands/recall-cmd.d.ts.map +1 -0
  101. package/dist/commands/recall-cmd.js +176 -0
  102. package/dist/commands/recall-cmd.js.map +1 -0
  103. package/dist/commands/redeploy-cmd.d.ts +43 -0
  104. package/dist/commands/redeploy-cmd.d.ts.map +1 -0
  105. package/dist/commands/redeploy-cmd.js +270 -0
  106. package/dist/commands/redeploy-cmd.js.map +1 -0
  107. package/dist/commands/rules-cmd.d.ts +2 -0
  108. package/dist/commands/rules-cmd.d.ts.map +1 -0
  109. package/dist/commands/rules-cmd.js +72 -0
  110. package/dist/commands/rules-cmd.js.map +1 -0
  111. package/dist/commands/serve-cmd.d.ts +23 -0
  112. package/dist/commands/serve-cmd.d.ts.map +1 -0
  113. package/dist/commands/serve-cmd.js +415 -0
  114. package/dist/commands/serve-cmd.js.map +1 -0
  115. package/dist/commands/timeline-cmd.d.ts +2 -0
  116. package/dist/commands/timeline-cmd.d.ts.map +1 -0
  117. package/dist/commands/timeline-cmd.js +67 -0
  118. package/dist/commands/timeline-cmd.js.map +1 -0
  119. package/dist/commands/write-cmd.d.ts +49 -0
  120. package/dist/commands/write-cmd.d.ts.map +1 -0
  121. package/dist/commands/write-cmd.js +269 -0
  122. package/dist/commands/write-cmd.js.map +1 -0
  123. package/dist/ops-handle.d.ts +67 -0
  124. package/dist/ops-handle.d.ts.map +1 -0
  125. package/dist/ops-handle.js +196 -0
  126. package/dist/ops-handle.js.map +1 -0
  127. package/dist/output.d.ts +28 -0
  128. package/dist/output.d.ts.map +1 -0
  129. package/dist/output.js +87 -0
  130. package/dist/output.js.map +1 -0
  131. package/dist/serve/http.d.ts +19 -0
  132. package/dist/serve/http.d.ts.map +1 -0
  133. package/dist/serve/http.js +135 -0
  134. package/dist/serve/http.js.map +1 -0
  135. package/dist/serve/mcp.d.ts +21 -0
  136. package/dist/serve/mcp.d.ts.map +1 -0
  137. package/dist/serve/mcp.js +79 -0
  138. package/dist/serve/mcp.js.map +1 -0
  139. package/dist/serve/socket.d.ts +15 -0
  140. package/dist/serve/socket.d.ts.map +1 -0
  141. package/dist/serve/socket.js +311 -0
  142. package/dist/serve/socket.js.map +1 -0
  143. package/dist/version.d.ts +2 -0
  144. package/dist/version.d.ts.map +1 -0
  145. package/dist/version.js +15 -0
  146. package/dist/version.js.map +1 -0
  147. package/package.json +40 -0
@@ -0,0 +1,269 @@
1
+ import fs from 'node:fs';
2
+ import fsp from 'node:fs/promises';
3
+ import { openOptionsFrom, parse } from "../args.js";
4
+ import { heading, json, kv, line, statusLabel, style, truncate } from "../output.js";
5
+ import { resolveOps } from "../ops-handle.js";
6
+ const WRITE_HELP = `akno write [options]
7
+
8
+ Create, append, patch or replace a page. Exactly one body option.
9
+
10
+ --slug <slug> The page. Omit with --event for a ledger-only event.
11
+ --content <text> Replace the whole body (or create the page).
12
+ --append <text> Add to the end of the body.
13
+ --section <heading> With --append: add at the end of that section instead. Errors
14
+ when the page has no such heading, or more than one.
15
+ --replace <find> With --with: replace one unique occurrence.
16
+ --with <text>
17
+ --patch <-|file> A unified diff. Context must match exactly.
18
+ --event <YYYY-MM-DD=summary>
19
+ Also append a timeline line, in the same change.
20
+ --title / --type / --tag <t,...> / --link <slug,...>
21
+ Frontmatter for a page being created.
22
+ --attach <path[=label]>
23
+ Attach a file, repeatable. It is copied in beside the page,
24
+ named after it, and its text is extracted and indexed — so a
25
+ PDF you attach is searchable by its own contents.
26
+ --actor <who> user | agent. The user is never gated; default agent.
27
+ --resolve-conflict <token>
28
+ Proceed past a conflict you have already asked about.
29
+ --dry-run Report what would happen; touch nothing.
30
+ --json`;
31
+ export async function writeCommand(argv) {
32
+ const { values } = parse(argv, {
33
+ slug: { type: 'string' },
34
+ content: { type: 'string' },
35
+ append: { type: 'string' },
36
+ section: { type: 'string' },
37
+ replace: { type: 'string' },
38
+ with: { type: 'string' },
39
+ patch: { type: 'string' },
40
+ event: { type: 'string' },
41
+ title: { type: 'string' },
42
+ type: { type: 'string' },
43
+ tag: { type: 'string' },
44
+ link: { type: 'string' },
45
+ attach: { type: 'string', multiple: true },
46
+ actor: { type: 'string' },
47
+ 'resolve-conflict': { type: 'string' },
48
+ 'dry-run': { type: 'boolean', default: false },
49
+ });
50
+ if (values.help) {
51
+ line(WRITE_HELP);
52
+ return 0;
53
+ }
54
+ const event = values.event ? parseEvent(values.event) : null;
55
+ if (values.event && !event) {
56
+ line(style.red('--event wants YYYY-MM-DD=summary'));
57
+ return 1;
58
+ }
59
+ if (values.replace !== undefined && values.with === undefined) {
60
+ line(style.red('--replace needs --with'));
61
+ return 1;
62
+ }
63
+ // `--patch -` reads stdin, because a diff is rarely something you type.
64
+ const patch = values.patch === '-'
65
+ ? await readStdin()
66
+ : values.patch
67
+ ? await fsp.readFile(values.patch, 'utf8').catch(() => values.patch)
68
+ : undefined;
69
+ const handle = await resolveOps(values, openOptionsFrom(values), {
70
+ write: true,
71
+ ...(values.actor === 'user' || values.actor === 'agent' ? { actor: values.actor } : {}),
72
+ });
73
+ try {
74
+ const result = await handle.ops.write({
75
+ ...(values.slug ? { slug: values.slug } : {}),
76
+ ...(values.content !== undefined ? { content: values.content } : {}),
77
+ ...(values.append !== undefined ? { append: values.append } : {}),
78
+ ...(values.section ? { section: values.section } : {}),
79
+ ...(patch !== undefined ? { patch } : {}),
80
+ ...(values.replace !== undefined ? { replace: { find: values.replace, with: values.with } } : {}),
81
+ ...(event ? { event } : {}),
82
+ ...(values.title ? { title: values.title } : {}),
83
+ ...(values.type ? { type: values.type } : {}),
84
+ ...(values.tag ? { tags: values.tag.split(',').map((t) => t.trim()) } : {}),
85
+ ...(values.link ? { links: values.link.split(',').map((l) => l.trim()) } : {}),
86
+ ...(values.attach?.length ? { documents: values.attach.map(parseAttachment) } : {}),
87
+ ...(values['resolve-conflict'] ? { resolve_conflict: values['resolve-conflict'] } : {}),
88
+ ...(values['dry-run'] ? { dry_run: true } : {}),
89
+ });
90
+ if (values.json) {
91
+ json(result);
92
+ return result.outcome === 'ok' || result.outcome === 'noop' ? 0 : 2;
93
+ }
94
+ return printWriteOutcome(result);
95
+ }
96
+ finally {
97
+ await handle.close();
98
+ }
99
+ }
100
+ /**
101
+ * `conflict`, `requires_approval` and `requires_folder` are not failures — they are the layer
102
+ * doing its job, and they must reach the caller as distinguishable results. Exit code 2 marks
103
+ * "needs a decision", separate from 1.
104
+ *
105
+ * The three are not the same kind of thing, and the output says which. A conflict and an
106
+ * approval want a person; `requires_folder` wants a sentence from whoever is writing, and
107
+ * printing it under a heading that says "approval" is how a caller learns to wait for
108
+ * somebody who is never coming.
109
+ */
110
+ export function printWriteOutcome(result) {
111
+ if (result.outcome === 'conflict' && result.conflict) {
112
+ const conflict = result.conflict;
113
+ heading(style.yellow('conflict — nothing was written'));
114
+ kv([
115
+ ['page', `${conflict.slug}:${conflict.line}`],
116
+ ['on file', truncate(conflict.existing, 90)],
117
+ ['incoming', truncate(conflict.incoming, 90)],
118
+ ]);
119
+ line(`\n ${style.grey('ask the user which is current, then:')}`);
120
+ line(` ${style.bold(`akno write … --resolve-conflict ${conflict.token}`)}`);
121
+ return 2;
122
+ }
123
+ if (result.outcome === 'requires_approval' && result.approval) {
124
+ heading(style.yellow('needs approval — nothing was written'));
125
+ kv([
126
+ ['reason', result.approval.reason],
127
+ ['proposal', result.approval.proposal_id],
128
+ ]);
129
+ if (result.approval.nearest.length > 0) {
130
+ line(` ${style.grey('could go instead')} ${result.approval.nearest.join(', ')}`);
131
+ }
132
+ line(`\n ${style.bold(`akno approve ${result.approval.proposal_id}`)} ${style.grey('or')} ${style.bold(`akno decline ${result.approval.proposal_id}`)}`);
133
+ return 2;
134
+ }
135
+ if (result.outcome === 'requires_folder' && result.requires_folder) {
136
+ const required = result.requires_folder;
137
+ heading(style.yellow(`'${required.folder}' is not declared — nothing was written`));
138
+ if (required.nearest.length > 0) {
139
+ line(` ${style.grey('could go instead')} ${required.nearest.join(', ')}`);
140
+ }
141
+ line(`\n ${style.grey('say what belongs there, then repeat the write:')}`);
142
+ line(` ${style.bold(`akno folder ${required.folder} --description "…"`)}`);
143
+ return 2;
144
+ }
145
+ if (result.outcome === 'noop') {
146
+ line(`${statusLabel('ok')} ${style.grey(result.note ?? 'nothing changed')}`);
147
+ return 0;
148
+ }
149
+ line(`${statusLabel(result.status)} ${style.grey(result.change_id ? `change ${result.change_id}` : 'dry run')}`);
150
+ for (const target of result.wrote ?? []) {
151
+ const where = target.line ? `${target.slug}:${target.line}` : target.slug;
152
+ line(` ${style.green(target.action.padEnd(9))} ${where}`);
153
+ }
154
+ for (const document of result.documents ?? []) {
155
+ // Which extractor produced the text is not a detail: a vision model's description of
156
+ // a photograph is not the same claim as a PDF's own text layer.
157
+ line(` ${style.green('stored'.padEnd(9))} ${document.rel_path} ${document.text_from ? style.grey(`(text: ${document.text_from})`) : ''}`);
158
+ }
159
+ if (result.facts && result.facts.added > 0) {
160
+ line(style.grey(` ${result.facts.added} fact(s) derived from the new lines`));
161
+ }
162
+ if (result.note)
163
+ line(style.grey(` ${result.note}`));
164
+ return 0;
165
+ }
166
+ /**
167
+ * `path` or `path=label`. Split at the last `=` and only when the left side is a file
168
+ * that exists, because a path may legitimately contain one and a wrong guess would
169
+ * silently attach the wrong thing — or nothing.
170
+ */
171
+ function parseAttachment(raw) {
172
+ const at = raw.lastIndexOf('=');
173
+ if (at > 0) {
174
+ const candidate = raw.slice(0, at);
175
+ if (fs.existsSync(candidate))
176
+ return { path: candidate, label: raw.slice(at + 1) };
177
+ }
178
+ return { path: raw };
179
+ }
180
+ function parseEvent(raw) {
181
+ const match = /^(\d{4}-\d{2}-\d{2})[=:]\s*(.+)$/.exec(raw.trim());
182
+ return match ? { date: match[1], summary: match[2] } : null;
183
+ }
184
+ async function readStdin() {
185
+ const chunks = [];
186
+ for await (const chunk of process.stdin)
187
+ chunks.push(chunk);
188
+ return Buffer.concat(chunks).toString('utf8');
189
+ }
190
+ const REMEMBER_HELP = `akno remember [text | -] [options]
191
+
192
+ Hand over a transcript or notes and let Akno decide what is worth keeping and
193
+ where it goes. Use this instead of write when you do not want to choose slugs or
194
+ phrasing yourself. Reads stdin with '-'.
195
+
196
+ --dry-run Show what it would keep and where, without writing.
197
+ --actor <who> user | agent.
198
+ --json`;
199
+ export async function rememberCommand(argv) {
200
+ const { values, positionals } = parse(argv, {
201
+ 'dry-run': { type: 'boolean', default: false },
202
+ actor: { type: 'string' },
203
+ });
204
+ if (values.help || positionals.length === 0) {
205
+ line(REMEMBER_HELP);
206
+ return values.help ? 0 : 1;
207
+ }
208
+ const text = positionals[0] === '-' ? await readStdin() : positionals.join(' ');
209
+ const handle = await resolveOps(values, openOptionsFrom(values), {
210
+ write: true,
211
+ ...(values.actor === 'user' || values.actor === 'agent' ? { actor: values.actor } : {}),
212
+ });
213
+ try {
214
+ const result = await handle.ops.remember({
215
+ text,
216
+ ...(values['dry-run'] ? { dry_run: true } : {}),
217
+ });
218
+ if (values.json) {
219
+ json(result);
220
+ return 0;
221
+ }
222
+ // The outcome only when it says something the status does not: a successful remember
223
+ // printed "ok ok", which reads like a bug because it is one.
224
+ const outcome = result.outcome === 'ok' ? '' : ` ${style.grey(result.outcome)}`;
225
+ line(`${statusLabel(result.status)}${outcome}`);
226
+ if (result.note)
227
+ line(style.grey(` ${result.note}`));
228
+ if (result.fallback) {
229
+ line(style.grey(` fallback ${result.fallback.slug}: ${result.fallback.status === 'used'
230
+ ? 'selected'
231
+ : `unavailable (${result.fallback.reason?.replaceAll('_', ' ') ?? 'unknown reason'})`}`));
232
+ }
233
+ if (result.considered?.length) {
234
+ heading('Considered');
235
+ for (const entry of result.considered) {
236
+ const mark = entry.written
237
+ ? style.green('wrote')
238
+ : entry.kept
239
+ ? style.yellow('held')
240
+ : entry.destination === 'no_writable_destination'
241
+ ? style.yellow('held')
242
+ : style.yellow('ask ');
243
+ const where = entry.slug
244
+ ? `${entry.slug} ${style.grey(`(${entry.score})`)}${entry.destination === 'configured_fallback' ? style.grey(' · configured fallback') : ''}`
245
+ : entry.destination === 'no_writable_destination'
246
+ ? style.grey('no authorized writable destination')
247
+ : style.grey('no page scored high enough');
248
+ line(` ${mark} ${truncate(entry.claim, 76)}`);
249
+ line(` ${style.grey('→')} ${where}`);
250
+ }
251
+ }
252
+ if (result.wrote?.length) {
253
+ heading('Wrote');
254
+ for (const target of result.wrote) {
255
+ line(` ${style.green(target.action.padEnd(9))} ${target.line ? `${target.slug}:${target.line}` : target.slug}`);
256
+ }
257
+ }
258
+ for (const approval of result.approvals ?? []) {
259
+ line(`\n${style.yellow('needs approval')} ${approval.reason}`);
260
+ line(` ${style.grey('nearest')} ${approval.nearest.join(', ')}`);
261
+ line(` ${style.bold(`akno approve ${approval.proposal_id}`)}`);
262
+ }
263
+ return (result.approvals?.length ?? 0) > 0 ? 2 : 0;
264
+ }
265
+ finally {
266
+ await handle.close();
267
+ }
268
+ }
269
+ //# sourceMappingURL=write-cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-cmd.js","sourceRoot":"","sources":["../../src/commands/write-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;SAwBV,CAAC;AAEV,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAc;IAC/C,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAiBrB,IAAI,EAAE;QACP,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC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AAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAC3G,CAAC;YACJ,CAAC;QACH,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;YAC9C,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAC/D,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACnE,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,gBAAgB,QAAQ,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { type Akno, type MaintenanceStatus } from '@tenphi/akno-core';
2
+ import type { CommandName, AknoOps, OpInput, OpName, OpResult } from '@tenphi/akno-protocol';
3
+ export interface OpsHandle {
4
+ /**
5
+ * The named ops, plus the dynamic `call` both sides implement — a door that dispatches by
6
+ * name (MCP, HTTP) needs it, and dropping it here would force such a door to re-resolve the
7
+ * service itself and duplicate the fallback rules.
8
+ */
9
+ ops: AknoOps & {
10
+ call<N extends OpName>(op: N, input: OpInput<N>): Promise<OpResult<N>>;
11
+ };
12
+ /** Set when the ops run in-process, for commands that need more than the ops. */
13
+ akno: Akno | null;
14
+ via: 'socket' | 'in-process';
15
+ close(): Promise<void>;
16
+ }
17
+ export interface MaintenanceWaitUpdate {
18
+ elapsedMs: number;
19
+ via: 'socket' | 'in-process';
20
+ status: MaintenanceStatus | null;
21
+ }
22
+ /**
23
+ * Spawning a process per memory call costs 33ms against 0.04ms for a
24
+ * long-lived handle — an 800× difference, none of it the database. So a read
25
+ * command prefers a running service and only falls back to in-process, where the
26
+ * 33ms does not matter because there is nothing else in the process anyway.
27
+ *
28
+ * Falling back rather than failing also means the CLI works before the user has
29
+ * ever run `akno serve`, which is the first thing they will try.
30
+ *
31
+ * **Writes route the same way, and must.** They used to call `open()` directly, which meant every
32
+ * one of them failed `read_only` whenever the service was running — the arrangement the docs
33
+ * recommend. `akno remember` from a terminal, on a machine set up as documented, could not write.
34
+ */
35
+ export declare function resolveOps(values: {
36
+ connect?: boolean;
37
+ json?: boolean;
38
+ }, openOptions: {
39
+ aknoPath?: string;
40
+ stateDir?: string;
41
+ }, options?: {
42
+ write?: boolean;
43
+ actor?: 'user' | 'agent' | 'akno';
44
+ }): Promise<OpsHandle>;
45
+ /**
46
+ * Runs operator work — including `index`, `inbox`, `dream`, gates, journal reads, and plans — through the
47
+ * running service when there
48
+ * is one, and in-process when there is not.
49
+ *
50
+ * Exactly one process may hold the write handle, so with a service running these have to go
51
+ * *through* it. They used to open the index directly and be refused, each in its own way: the
52
+ * nightly cycle failed with "another process holds the write handle", `index` warned and
53
+ * exited, and `inbox` reported an empty inbox it had never been able to read.
54
+ */
55
+ export declare function runMaintenance<T>(command: CommandName, input: Record<string, unknown>, values: {
56
+ connect?: boolean;
57
+ json?: boolean;
58
+ }, openOptions: {
59
+ aknoPath?: string;
60
+ stateDir?: string;
61
+ }, inProcess: (akno: Akno) => Promise<T>, options?: {
62
+ writable?: boolean;
63
+ /** Periodic, content-free queue snapshots for long-running operator commands. */
64
+ onWait?: (update: MaintenanceWaitUpdate) => void;
65
+ waitEveryMs?: number;
66
+ }): Promise<T>;
67
+ //# sourceMappingURL=ops-handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ops-handle.d.ts","sourceRoot":"","sources":["../src/ops-handle.ts"],"names":[],"mappings":"AAGA,OAAO,EAA+B,KAAK,IAAI,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG7F,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,GAAG,EAAE,OAAO,GAAG;QAAE,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC;IAC1F,iFAAiF;IACjF,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,GAAG,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC7B,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,EAC7C,WAAW,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;CAAO,GACnE,OAAO,CAAC,SAAS,CAAC,CA2CpB;AAmED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,EAC7C,WAAW,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EACrD,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EACrC,OAAO,GAAE;IACP,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;CACjB,GACL,OAAO,CAAC,CAAC,CAAC,CA+CZ"}
@@ -0,0 +1,196 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { connect, defaultSocketPath } from '@tenphi/akno-client';
4
+ import { AknoError, loadConfig, open } from '@tenphi/akno-core';
5
+ import { style } from "./output.js";
6
+ /**
7
+ * Spawning a process per memory call costs 33ms against 0.04ms for a
8
+ * long-lived handle — an 800× difference, none of it the database. So a read
9
+ * command prefers a running service and only falls back to in-process, where the
10
+ * 33ms does not matter because there is nothing else in the process anyway.
11
+ *
12
+ * Falling back rather than failing also means the CLI works before the user has
13
+ * ever run `akno serve`, which is the first thing they will try.
14
+ *
15
+ * **Writes route the same way, and must.** They used to call `open()` directly, which meant every
16
+ * one of them failed `read_only` whenever the service was running — the arrangement the docs
17
+ * recommend. `akno remember` from a terminal, on a machine set up as documented, could not write.
18
+ */
19
+ export async function resolveOps(values, openOptions, options = {}) {
20
+ const target = serviceTarget(values, openOptions);
21
+ const socketPath = target.socketPath;
22
+ if (values.connect || fs.existsSync(socketPath)) {
23
+ try {
24
+ const client = await connectToTarget(target, {
25
+ // Stated per connection, because the alternative is a write from a person at a terminal
26
+ // being gated as though an agent had asked — and a gated proposal being unanswerable
27
+ // through the door the service is meant to be reached by.
28
+ ...(options.actor ? { actor: options.actor } : {}),
29
+ });
30
+ return {
31
+ ops: client,
32
+ akno: null,
33
+ via: 'socket',
34
+ close: () => client.close(),
35
+ };
36
+ }
37
+ catch (err) {
38
+ const error = AknoError.from(err);
39
+ if (values.connect || error.code !== 'unavailable')
40
+ throw error;
41
+ // A stale socket file from a crashed service is common enough that
42
+ // failing here would be a bad default.
43
+ if (!values.json) {
44
+ process.stderr.write(style.grey(`no service on ${socketPath}; opening the index in-process\n`));
45
+ }
46
+ }
47
+ }
48
+ // A read takes no write handle: a one-shot must never pull it out from under a service that is
49
+ // about to start, and it does not need it. A write has no choice — with no service there is
50
+ // nobody else to do it.
51
+ const akno = await open({
52
+ ...openOptions,
53
+ writable: options.write === true,
54
+ ...(options.actor ? { actor: options.actor } : {}),
55
+ });
56
+ return {
57
+ ops: akno,
58
+ akno,
59
+ via: 'in-process',
60
+ close: () => akno.close(),
61
+ };
62
+ }
63
+ function serviceTarget(values, openOptions) {
64
+ try {
65
+ const config = loadConfig(openOptions);
66
+ return { socketPath: config.socketPath, expectedAknoPath: config.aknoPath };
67
+ }
68
+ catch (error) {
69
+ // `--connect` without a memory/config override is an explicit request for the conventional
70
+ // service door. Every implicit or targeted call must retain the configuration error instead
71
+ // of using that door and accidentally operating on whichever knowledge base is already live.
72
+ if (values.connect && !hasExplicitMemoryTarget(openOptions)) {
73
+ return { socketPath: defaultSocketPath(), expectedAknoPath: null };
74
+ }
75
+ throw error;
76
+ }
77
+ }
78
+ function hasExplicitMemoryTarget(openOptions) {
79
+ return Boolean(openOptions.aknoPath ||
80
+ openOptions.stateDir ||
81
+ process.env.AKNO_CONFIG ||
82
+ process.env.AKNO_PATH ||
83
+ process.env.AKNO_STATE_DIR);
84
+ }
85
+ async function connectToTarget(target, options = {}) {
86
+ const client = await connect({ socket: target.socketPath, ...options });
87
+ try {
88
+ if (target.expectedAknoPath &&
89
+ pathIdentity(client.hello.akno_path) !== pathIdentity(target.expectedAknoPath)) {
90
+ throw new AknoError('conflict', `the service on ${target.socketPath} is for ${client.hello.akno_path}, not ` +
91
+ `${target.expectedAknoPath}; use a matching --state-dir for the requested knowledge base`, { reason: 'service_target_mismatch' });
92
+ }
93
+ return client;
94
+ }
95
+ catch (error) {
96
+ await client.close().catch(() => { });
97
+ throw error;
98
+ }
99
+ }
100
+ function pathIdentity(value) {
101
+ try {
102
+ return fs.realpathSync.native(value);
103
+ }
104
+ catch {
105
+ return path.resolve(value);
106
+ }
107
+ }
108
+ /**
109
+ * Runs operator work — including `index`, `inbox`, `dream`, gates, journal reads, and plans — through the
110
+ * running service when there
111
+ * is one, and in-process when there is not.
112
+ *
113
+ * Exactly one process may hold the write handle, so with a service running these have to go
114
+ * *through* it. They used to open the index directly and be refused, each in its own way: the
115
+ * nightly cycle failed with "another process holds the write handle", `index` warned and
116
+ * exited, and `inbox` reported an empty inbox it had never been able to read.
117
+ */
118
+ export async function runMaintenance(command, input, values, openOptions, inProcess, options = {}) {
119
+ const target = serviceTarget(values, openOptions);
120
+ const socketPath = target.socketPath;
121
+ if (values.connect || fs.existsSync(socketPath)) {
122
+ try {
123
+ const client = await connectToTarget(target);
124
+ try {
125
+ if (!values.json) {
126
+ process.stderr.write(style.grey(`via the service on ${socketPath}\n`));
127
+ }
128
+ return await withWaitUpdates(client.command(command, input), 'socket', async () => (await client.command('plan', { action: 'status' })), options);
129
+ }
130
+ finally {
131
+ await client.close();
132
+ }
133
+ }
134
+ catch (err) {
135
+ const error = AknoError.from(err);
136
+ // A command error came from a healthy service and must reach its caller intact. Falling
137
+ // back here used to turn a precise refusal into a second, misleading in-process attempt.
138
+ if (error.code !== 'unavailable')
139
+ throw error;
140
+ // `--connect` means the caller wants the service or nothing; otherwise a stale socket
141
+ // file from a crashed service must not stop a one-off pass.
142
+ if (values.connect)
143
+ throw error;
144
+ if (!values.json) {
145
+ process.stderr.write(style.grey(`no service on ${socketPath}; running in-process\n`));
146
+ }
147
+ }
148
+ }
149
+ // Proposal, change, and plan reads only inspect state; taking the write handle for them would block a service
150
+ // from starting while somebody lists their pending approvals.
151
+ const akno = await open({ ...openOptions, ...(options.writable === false ? { writable: false } : {}) });
152
+ try {
153
+ return await withWaitUpdates(inProcess(akno), 'in-process', async () => akno.maintenanceStatus(), options);
154
+ }
155
+ finally {
156
+ await akno.close();
157
+ }
158
+ }
159
+ async function withWaitUpdates(work, via, readStatus, options) {
160
+ if (!options.onWait)
161
+ return work;
162
+ const started = performance.now();
163
+ const every = Math.max(1_000, options.waitEveryMs ?? 5_000);
164
+ let stopped = false;
165
+ let timer = null;
166
+ let polling = false;
167
+ const emit = async () => {
168
+ if (stopped || polling)
169
+ return;
170
+ polling = true;
171
+ let status = null;
172
+ try {
173
+ status = await readStatus();
174
+ }
175
+ catch {
176
+ // Progress is observational. Losing one snapshot must never fail or cancel the work.
177
+ }
178
+ finally {
179
+ polling = false;
180
+ }
181
+ if (!stopped) {
182
+ options.onWait?.({ elapsedMs: Math.round(performance.now() - started), via, status });
183
+ timer = setTimeout(() => void emit(), every);
184
+ }
185
+ };
186
+ timer = setTimeout(() => void emit(), every);
187
+ try {
188
+ return await work;
189
+ }
190
+ finally {
191
+ stopped = true;
192
+ if (timer)
193
+ clearTimeout(timer);
194
+ }
195
+ }
196
+ //# sourceMappingURL=ops-handle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ops-handle.js","sourceRoot":"","sources":["../src/ops-handle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OA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C,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;YACtF,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IAC7C,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ export declare const style: {
2
+ bold: (text: string) => string;
3
+ dim: (text: string) => string;
4
+ red: (text: string) => string;
5
+ green: (text: string) => string;
6
+ yellow: (text: string) => string;
7
+ blue: (text: string) => string;
8
+ cyan: (text: string) => string;
9
+ grey: (text: string) => string;
10
+ };
11
+ export declare function heading(text: string): void;
12
+ export declare function line(text?: string): void;
13
+ export declare function json(value: unknown): void;
14
+ export declare function fail(message: string): void;
15
+ export declare function warn(message: string): void;
16
+ /** Aligned key/value block. `-` in the value column reads better than empty. */
17
+ export declare function kv(entries: [string, string | number | null | undefined][], indent?: string): void;
18
+ /**
19
+ * A status is not decoration — `empty` and `unavailable` mean different things
20
+ * to the caller, and the colour is there so a human scanning output does not have
21
+ * to read the word to notice which one happened.
22
+ */
23
+ export declare function statusLabel(status: string): string;
24
+ /** In-place progress on a TTY; one line per phase otherwise, so logs stay readable. */
25
+ export declare function progressWriter(): (phase: string, done: number, total: number, detail?: string) => void;
26
+ export declare function truncate(text: string, max: number): string;
27
+ export declare function ms(value: number): string;
28
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,KAAK;iBAJoB,MAAM,KAAK,MAAM;gBAAjB,MAAM,KAAK,MAAM;gBAAjB,MAAM,KAAK,MAAM;kBAAjB,MAAM,KAAK,MAAM;mBAAjB,MAAM,KAAK,MAAM;iBAAjB,MAAM,KAAK,MAAM;iBAAjB,MAAM,KAAK,MAAM;iBAAjB,MAAM,KAAK,MAAM;CAatD,CAAC;AAEF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,IAAI,CAAC,IAAI,SAAK,GAAG,IAAI,CAEpC;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAEzC;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,gFAAgF;AAChF,wBAAgB,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EAAE,MAAM,SAAO,GAAG,IAAI,CAK/F;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAclD;AAED,uFAAuF;AACvF,wBAAgB,cAAc,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAgBtG;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIxC"}