@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
package/dist/output.js ADDED
@@ -0,0 +1,87 @@
1
+ import { styleText } from 'node:util';
2
+ function wrap(format) {
3
+ return (text) => styleText(format, text, { stream: process.stdout });
4
+ }
5
+ export const style = {
6
+ bold: wrap('bold'),
7
+ dim: wrap('dim'),
8
+ red: wrap('red'),
9
+ green: wrap('green'),
10
+ yellow: wrap('yellow'),
11
+ blue: wrap('blue'),
12
+ cyan: wrap('cyan'),
13
+ grey: wrap('gray'),
14
+ };
15
+ export function heading(text) {
16
+ process.stdout.write(`\n${style.bold(text)}\n`);
17
+ }
18
+ export function line(text = '') {
19
+ process.stdout.write(`${text}\n`);
20
+ }
21
+ export function json(value) {
22
+ process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
23
+ }
24
+ export function fail(message) {
25
+ process.stderr.write(`${styleText('red', 'error', { stream: process.stderr })} ${message}\n`);
26
+ }
27
+ export function warn(message) {
28
+ process.stderr.write(`${styleText('yellow', 'warning', { stream: process.stderr })} ${message}\n`);
29
+ }
30
+ /** Aligned key/value block. `-` in the value column reads better than empty. */
31
+ export function kv(entries, indent = ' ') {
32
+ const width = Math.max(...entries.map(([key]) => key.length));
33
+ for (const [key, value] of entries) {
34
+ line(`${indent}${style.grey(key.padEnd(width))} ${value ?? '-'}`);
35
+ }
36
+ }
37
+ /**
38
+ * A status is not decoration — `empty` and `unavailable` mean different things
39
+ * to the caller, and the colour is there so a human scanning output does not have
40
+ * to read the word to notice which one happened.
41
+ */
42
+ export function statusLabel(status) {
43
+ switch (status) {
44
+ case 'ok':
45
+ return style.green('ok');
46
+ case 'empty':
47
+ case 'degraded':
48
+ return style.yellow(status);
49
+ case 'unavailable':
50
+ return style.red('unavailable');
51
+ case 'failed':
52
+ return style.red('failed');
53
+ default:
54
+ return status;
55
+ }
56
+ }
57
+ /** In-place progress on a TTY; one line per phase otherwise, so logs stay readable. */
58
+ export function progressWriter() {
59
+ let lastPhase = '';
60
+ const dim = (text) => styleText('gray', text, { stream: process.stderr });
61
+ return (phase, done, total, detail) => {
62
+ if (!process.stderr.isTTY) {
63
+ if (phase !== lastPhase) {
64
+ lastPhase = phase;
65
+ process.stderr.write(`${phase}: ${total}\n`);
66
+ }
67
+ return;
68
+ }
69
+ const label = detail ? ` ${truncate(detail, 46)}` : '';
70
+ const bar = total > 0 ? `${done}/${total}` : `${done}`;
71
+ process.stderr.write(`\r\u001b[2K${dim(phase.padEnd(10))} ${bar}${dim(label)}`);
72
+ if (phase === 'done')
73
+ process.stderr.write('\r\u001b[2K');
74
+ };
75
+ }
76
+ export function truncate(text, max) {
77
+ const collapsed = text.replace(/\s+/g, ' ').trim();
78
+ return collapsed.length <= max ? collapsed : `${collapsed.slice(0, max - 1)}…`;
79
+ }
80
+ export function ms(value) {
81
+ if (value < 1)
82
+ return `${value.toFixed(2)}ms`;
83
+ if (value < 1000)
84
+ return `${value.toFixed(0)}ms`;
85
+ return `${(value / 1000).toFixed(1)}s`;
86
+ }
87
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAYtC,SAAS,IAAI,CAAC,MAAc;IAC1B,OAAO,CAAC,IAAY,EAAU,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC;IAChB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;A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AAC,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAChF,IAAI,KAAK,KAAK,MAAM;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,GAAW;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACnD,OAAO,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,EAAE,CAAC,KAAa;IAC9B,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACjD,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACzC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { Akno } from '@tenphi/akno-core';
2
+ export interface HttpServer {
3
+ readonly address: string;
4
+ close(): Promise<void>;
5
+ }
6
+ /**
7
+ * For agents in containers or on another host: Akno runs on the host and
8
+ * the agent reaches it over the network, so the knowledge base and the index never
9
+ * need to be mounted into a sandbox — which also keeps the single-writer property
10
+ * that makes WAL concurrency safe.
11
+ *
12
+ * Binds loopback unless told otherwise, and says so loudly if not: this door has
13
+ * no authentication of its own and is meant to sit behind one.
14
+ */
15
+ export declare function serveHttp(akno: Akno, address: string, options?: {
16
+ allow?: string[];
17
+ log?: (message: string) => void;
18
+ }): Promise<HttpServer>;
19
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/serve/http.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAG9C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GAClE,OAAO,CAAC,UAAU,CAAC,CAyBrB"}
@@ -0,0 +1,135 @@
1
+ import http from 'node:http';
2
+ import { AknoError, OPS, PROTOCOL_VERSION, isOpName } from '@tenphi/akno-protocol';
3
+ import { AKNO_VERSION } from "../version.js";
4
+ /**
5
+ * For agents in containers or on another host: Akno runs on the host and
6
+ * the agent reaches it over the network, so the knowledge base and the index never
7
+ * need to be mounted into a sandbox — which also keeps the single-writer property
8
+ * that makes WAL concurrency safe.
9
+ *
10
+ * Binds loopback unless told otherwise, and says so loudly if not: this door has
11
+ * no authentication of its own and is meant to sit behind one.
12
+ */
13
+ export async function serveHttp(akno, address, options = {}) {
14
+ const [host, portText] = splitAddress(address);
15
+ const port = Number(portText);
16
+ if (!Number.isInteger(port) || port <= 0) {
17
+ throw new AknoError('invalid', `not a valid host:port — ${address}`);
18
+ }
19
+ const server = http.createServer((request, response) => {
20
+ void route(request, response, akno, options);
21
+ });
22
+ await new Promise((resolve, reject) => {
23
+ server.once('error', reject);
24
+ server.listen(port, host, () => {
25
+ server.off('error', reject);
26
+ resolve();
27
+ });
28
+ });
29
+ return {
30
+ address: `${host}:${port}`,
31
+ async close() {
32
+ await new Promise((resolve) => server.close(() => resolve()));
33
+ },
34
+ };
35
+ }
36
+ async function route(request, response, akno, options) {
37
+ const url = new URL(request.url ?? '/', 'http://localhost');
38
+ if (url.pathname === '/hello') {
39
+ const hello = {
40
+ hello: 'akno',
41
+ protocol: PROTOCOL_VERSION,
42
+ version: AKNO_VERSION,
43
+ writable: akno.writable,
44
+ akno_path: akno.config.aknoPath,
45
+ ops: options.allow ?? Object.keys(OPS),
46
+ };
47
+ send(response, 200, hello);
48
+ return;
49
+ }
50
+ if (url.pathname === '/health') {
51
+ send(response, 200, { ok: true, writable: akno.writable });
52
+ return;
53
+ }
54
+ const match = /^\/op\/([a-z_]+)$/.exec(url.pathname);
55
+ if (!match || request.method !== 'POST') {
56
+ send(response, 404, { ok: false, error: { code: 'not_found', message: 'POST /op/<name>' } });
57
+ return;
58
+ }
59
+ const op = match[1];
60
+ try {
61
+ if (!isOpName(op))
62
+ throw new AknoError('invalid', `unknown op: ${op}`);
63
+ if (options.allow && !options.allow.includes(op)) {
64
+ throw new AknoError('forbidden', `${op} is not allowed on this door`);
65
+ }
66
+ const input = await readJson(request);
67
+ // A header rather than a field in the body: `actor` is about the caller, not the op, and putting
68
+ // it in the JSON would collide the day an op wants a field of that name.
69
+ const declared = request.headers['x-akno-actor'];
70
+ const actor = declared === 'user' || declared === 'agent' || declared === 'akno' ? declared : undefined;
71
+ const started = performance.now();
72
+ const result = await akno.call(op, input, actor ? { actor } : {});
73
+ options.log?.(`${op} ${(performance.now() - started).toFixed(1)}ms`);
74
+ send(response, 200, { ok: true, result });
75
+ }
76
+ catch (err) {
77
+ const error = AknoError.from(err);
78
+ options.log?.(`${op} ${error.code}: ${error.message}`);
79
+ send(response, statusFor(error.code), { ok: false, error: error.toJSON() });
80
+ }
81
+ }
82
+ /** HTTP status codes chosen so a proxy or a dashboard reads them correctly. */
83
+ function statusFor(code) {
84
+ switch (code) {
85
+ case 'invalid':
86
+ return 400;
87
+ case 'forbidden':
88
+ return 403;
89
+ case 'not_found':
90
+ return 404;
91
+ case 'read_only':
92
+ case 'busy':
93
+ return 409;
94
+ case 'not_implemented':
95
+ return 501;
96
+ case 'unavailable':
97
+ return 503;
98
+ default:
99
+ return 500;
100
+ }
101
+ }
102
+ function send(response, status, body) {
103
+ const payload = JSON.stringify(body);
104
+ response.writeHead(status, {
105
+ 'content-type': 'application/json',
106
+ 'content-length': Buffer.byteLength(payload),
107
+ });
108
+ response.end(payload);
109
+ }
110
+ async function readJson(request) {
111
+ const chunks = [];
112
+ let bytes = 0;
113
+ for await (const chunk of request) {
114
+ bytes += chunk.length;
115
+ // A 4 MB cap: `remember` takes a transcript, not a corpus.
116
+ if (bytes > 4 * 1024 * 1024)
117
+ throw new AknoError('invalid', 'request body too large');
118
+ chunks.push(chunk);
119
+ }
120
+ if (chunks.length === 0)
121
+ return {};
122
+ try {
123
+ return JSON.parse(Buffer.concat(chunks).toString('utf8'));
124
+ }
125
+ catch {
126
+ throw new AknoError('invalid', 'request body is not valid JSON');
127
+ }
128
+ }
129
+ function splitAddress(address) {
130
+ const index = address.lastIndexOf(':');
131
+ if (index === -1)
132
+ return ['127.0.0.1', address];
133
+ return [address.slice(0, index) || '127.0.0.1', address.slice(index + 1)];
134
+ }
135
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/serve/http.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAc,MAAM,uBAAuB,CAAC;AAE/F,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAO7C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAU,EACV,O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AAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,SAAS,CAAC,SAAS,EAAE,gCAAgC,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAChD,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type OpName } from '@tenphi/akno-protocol';
2
+ import type { OpInput, OpResult } from '@tenphi/akno-protocol';
3
+ /**
4
+ * The stdio MCP door, for third-party agents that speak it:
5
+ *
6
+ * { "mcpServers": { "memory": { "command": "akno", "args": ["serve", "--mcp"] } } }
7
+ *
8
+ * Every tool is generated from the op registry, so an op cannot exist over the
9
+ * socket and be missing here. Trust is a parameter: `server.mcp_allow` in config
10
+ * decides which ops this door exposes, and denying `forget` to a sandboxed agent
11
+ * needs no second code path.
12
+ */
13
+ export declare function serveMcp(akno: {
14
+ call<N extends OpName>(op: N, input: OpInput<N>): Promise<OpResult<N>>;
15
+ }, options?: {
16
+ allow?: string[];
17
+ log?: (message: string) => void;
18
+ }): Promise<{
19
+ close(): Promise<void>;
20
+ }>;
21
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/serve/mcp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmC,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG/D;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAG5B,IAAI,EAAE;IAAE,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;CAAE,EAChF,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GAClE,OAAO,CAAC;IAAE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAuErC"}
@@ -0,0 +1,79 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { AknoError, MCP_SERVER_NAME, OPS } from '@tenphi/akno-protocol';
4
+ import { AKNO_VERSION } from "../version.js";
5
+ /**
6
+ * The stdio MCP door, for third-party agents that speak it:
7
+ *
8
+ * { "mcpServers": { "memory": { "command": "akno", "args": ["serve", "--mcp"] } } }
9
+ *
10
+ * Every tool is generated from the op registry, so an op cannot exist over the
11
+ * socket and be missing here. Trust is a parameter: `server.mcp_allow` in config
12
+ * decides which ops this door exposes, and denying `forget` to a sandboxed agent
13
+ * needs no second code path.
14
+ */
15
+ export async function serveMcp(
16
+ // Ops, not an `Akno`: this door is equally happy in front of an in-process index or of a
17
+ // socket connection to the service that holds the write handle. Nothing here needs more.
18
+ akno, options = {}) {
19
+ const server = new McpServer({ name: MCP_SERVER_NAME, version: AKNO_VERSION }, {
20
+ // Named "memory" and described as memory, deliberately. A model reasons better about a
21
+ // faculty it has than about a product it has been integrated with, and the brand is not
22
+ // a fact it can use: what it needs is that recall is where knowledge of this user lives,
23
+ // and what the status fields mean.
24
+ instructions: 'This is the user’s long-term memory, stored as a Markdown knowledge base. Use `answer` for a direct ' +
25
+ 'factual response grounded entirely in memory, or `recall` when evidence must be inspected, compared, ' +
26
+ 'or quoted. Do not call both by default: answer already performs bounded recall and returns compact ' +
27
+ 'related identities. Recall’s typed page and document results carry source addresses, so a claim you ' +
28
+ 'take from them can be cited and a claim you cannot find in them should not be made. Read `status` on ' +
29
+ 'every result: "empty" means the knowledge base ' +
30
+ 'genuinely has nothing and you may say so; "degraded" means part of the search stack was ' +
31
+ 'missing, so absence is not proven; "unavailable" means the index could not be read. In ' +
32
+ 'question mode, `coverage` tells you which parts of the question the results actually cover — ' +
33
+ 'do not answer the parts marked false. Values returned under `superseded` are historical, not ' +
34
+ 'current.',
35
+ });
36
+ const allowed = (options.allow ?? Object.keys(OPS));
37
+ for (const name of allowed) {
38
+ const definition = OPS[name];
39
+ if (!definition)
40
+ continue;
41
+ server.registerTool(name, {
42
+ title: name,
43
+ description: definition.implemented
44
+ ? definition.description
45
+ : `${definition.description} NOT AVAILABLE in this build — calling it returns not_implemented.`,
46
+ inputSchema: definition.input,
47
+ }, async (input) => {
48
+ try {
49
+ const started = performance.now();
50
+ const result = await akno.call(name, input);
51
+ options.log?.(`mcp ${name} ${(performance.now() - started).toFixed(1)}ms`);
52
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
53
+ }
54
+ catch (err) {
55
+ const error = AknoError.from(err);
56
+ options.log?.(`mcp ${name} ${error.code}: ${error.message}`);
57
+ // An error returned as content rather than thrown lets the agent read
58
+ // the code and react — the whole point of `degraded` vs `empty`.
59
+ return {
60
+ isError: true,
61
+ content: [
62
+ {
63
+ type: 'text',
64
+ text: JSON.stringify({ status: 'error', ...error.toJSON() }, null, 2),
65
+ },
66
+ ],
67
+ };
68
+ }
69
+ });
70
+ }
71
+ const transport = new StdioServerTransport();
72
+ await server.connect(transport);
73
+ return {
74
+ async close() {
75
+ await server.close();
76
+ },
77
+ };
78
+ }
79
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/serve/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,EAAe,MAAM,uBAAuB,CAAC;AAErF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ;AAC5B,yFAAyF;AACzF,yFAAyF;AACzF,IAAgF,EAChF,UAAiE,EAAE;IAEnE,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,EAChD;QACE,uFAAuF;QACvF,wFAAwF;QACxF,yFAAyF;QACzF,mCAAmC;QACnC,YAAY,EACV,sGAAsG;YACtG,uGAAuG;YACvG,qGAAqG;YACrG,sGAAsG;YACtG,uGAAuG;YACvG,iDAAiD;YACjD,0FAA0F;YAC1F,yFAAyF;YACzF,+FAA+F;YAC/F,+FAA+F;YAC/F,UAAU;KACb,CACF,CAAC;IAEF,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAa,CAAC;IAEhE,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,UAAU;YAAE,SAAS;QAE1B,MAAM,CAAC,YAAY,CACjB,IAAI,EACJ;YACE,KAAK,EAAE,IAAI;YACX,WAAW,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S,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,OAAO;QACL,KAAK,CAAC,KAAK;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type Akno } from '@tenphi/akno-core';
2
+ export interface SocketServer {
3
+ readonly path: string;
4
+ close(): Promise<void>;
5
+ }
6
+ /**
7
+ * The default door: no port, filesystem permissions are the auth, and it is
8
+ * the fastest. Newline-delimited JSON over a unix socket, framed by the protocol
9
+ * package so this file and the client cannot disagree about the wire.
10
+ */
11
+ export declare function serveSocket(akno: Akno, socketPath: string, options?: {
12
+ allow?: string[];
13
+ log?: (message: string) => void;
14
+ }): Promise<SocketServer>;
15
+ //# sourceMappingURL=socket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/serve/socket.ts"],"names":[],"mappings":"AAgBA,OAAO,EAGL,KAAK,IAAI,EAIV,MAAM,mBAAmB,CAAC;AAG3B,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GAClE,OAAO,CAAC,YAAY,CAAC,CA4EvB"}