@tenphi/akno-protocol 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 (67) hide show
  1. package/LICENSE +83 -0
  2. package/README.md +26 -0
  3. package/dist/common.d.ts +1553 -0
  4. package/dist/common.d.ts.map +1 -0
  5. package/dist/common.js +309 -0
  6. package/dist/common.js.map +1 -0
  7. package/dist/errors.d.ts +24 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +69 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +16 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +16 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/ops/answer.d.ts +207 -0
  16. package/dist/ops/answer.d.ts.map +1 -0
  17. package/dist/ops/answer.js +90 -0
  18. package/dist/ops/answer.js.map +1 -0
  19. package/dist/ops/context.d.ts +845 -0
  20. package/dist/ops/context.d.ts.map +1 -0
  21. package/dist/ops/context.js +82 -0
  22. package/dist/ops/context.js.map +1 -0
  23. package/dist/ops/folder.d.ts +85 -0
  24. package/dist/ops/folder.d.ts.map +1 -0
  25. package/dist/ops/folder.js +56 -0
  26. package/dist/ops/folder.js.map +1 -0
  27. package/dist/ops/graph.d.ts +352 -0
  28. package/dist/ops/graph.d.ts.map +1 -0
  29. package/dist/ops/graph.js +63 -0
  30. package/dist/ops/graph.js.map +1 -0
  31. package/dist/ops/list.d.ts +136 -0
  32. package/dist/ops/list.d.ts.map +1 -0
  33. package/dist/ops/list.js +57 -0
  34. package/dist/ops/list.js.map +1 -0
  35. package/dist/ops/mutate.d.ts +432 -0
  36. package/dist/ops/mutate.d.ts.map +1 -0
  37. package/dist/ops/mutate.js +234 -0
  38. package/dist/ops/mutate.js.map +1 -0
  39. package/dist/ops/read.d.ts +242 -0
  40. package/dist/ops/read.d.ts.map +1 -0
  41. package/dist/ops/read.js +65 -0
  42. package/dist/ops/read.js.map +1 -0
  43. package/dist/ops/recall.d.ts +531 -0
  44. package/dist/ops/recall.d.ts.map +1 -0
  45. package/dist/ops/recall.js +59 -0
  46. package/dist/ops/recall.js.map +1 -0
  47. package/dist/ops/timeline.d.ts +264 -0
  48. package/dist/ops/timeline.d.ts.map +1 -0
  49. package/dist/ops/timeline.js +68 -0
  50. package/dist/ops/timeline.js.map +1 -0
  51. package/dist/ops/write.d.ts +182 -0
  52. package/dist/ops/write.d.ts.map +1 -0
  53. package/dist/ops/write.js +114 -0
  54. package/dist/ops/write.js.map +1 -0
  55. package/dist/registry.d.ts +2657 -0
  56. package/dist/registry.d.ts.map +1 -0
  57. package/dist/registry.js +191 -0
  58. package/dist/registry.js.map +1 -0
  59. package/dist/version.d.ts +14 -0
  60. package/dist/version.d.ts.map +1 -0
  61. package/dist/version.js +14 -0
  62. package/dist/version.js.map +1 -0
  63. package/dist/wire.d.ts +112 -0
  64. package/dist/wire.d.ts.map +1 -0
  65. package/dist/wire.js +102 -0
  66. package/dist/wire.js.map +1 -0
  67. package/package.json +38 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,QAAQ;;;;;EAA0D,CAAC;AAChF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB;;;EAAgC,CAAC;AAChE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,eAAO,MAAM,eAAe;;;;EAA4C,CAAC;AACzE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC9D,eAAO,MAAM,cAAc;;;;;;;;;;iBAGzB,CAAC;AACH,MAAM,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dist/common.js ADDED
@@ -0,0 +1,309 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * What a page contributes to memory. This is deliberately separate from who may
4
+ * edit it: a canonical page can be owner-maintained or fully synthesized, while
5
+ * a source page remains evidence either way.
6
+ */
7
+ export const PageRole = z.enum(['knowledge', 'source', 'inference', 'ignored']);
8
+ /** Automatic write authority carried by a page's `akno` frontmatter block. */
9
+ export const RememberManagement = z.enum(['deny', 'integrate']);
10
+ export const DreamManagement = z.enum(['none', 'hygiene', 'synthesize']);
11
+ export const PageManagement = z.object({
12
+ remember: RememberManagement.optional(),
13
+ dream: DreamManagement.optional(),
14
+ });
15
+ /**
16
+ * One op, three expansion modes — because looking something up and
17
+ * answering a question are different retrieval problems, but must not be
18
+ * different ops. Inferred from the query unless passed explicitly.
19
+ */
20
+ export const RecallMode = z.enum(['lookup', 'question', 'explore']);
21
+ /** How much of a page body a card carries back. */
22
+ export const Depth = z.enum(['summary', 'lines', 'full']);
23
+ /**
24
+ * Absence has a reason. Three distinct outcomes, never one silent empty
25
+ * result: `empty` proved nothing matched, `degraded` means a model was missing
26
+ * and the search was weaker, `unavailable` means the index could not be read.
27
+ */
28
+ export const ResultStatus = z.enum(['ok', 'empty', 'degraded', 'unavailable']);
29
+ /**
30
+ * Every line Akno returns carries the file and line it came from. `confidence`
31
+ * is present when a fact was derived from this line — how sure the deriver is
32
+ * that the line states a well-formed durable claim, not how sure it is the claim
33
+ * is true.
34
+ */
35
+ export const Line = z.object({
36
+ n: z.number().int().positive(),
37
+ text: z.string(),
38
+ confidence: z.number().min(0).max(1).optional(),
39
+ /**
40
+ * The live fact this line produced, when it produced one — the handle `forget`
41
+ * takes to retract it.
42
+ *
43
+ * Without this, `forget({fact})` was documented and unreachable: it is the op's
44
+ * primary form, and no read path returned an id to give it. Retracting therefore
45
+ * meant deleting a whole page, which is a much larger claim than "this one
46
+ * sentence is wrong". It rides on the line because that is exactly what forget
47
+ * removes — the sentence, not a database row that would be re-derived tomorrow.
48
+ */
49
+ fact: z.string().optional(),
50
+ });
51
+ /**
52
+ * A replaced value comes back labelled, not as a second competing current
53
+ * answer. Two live readings of one attribute is the most common way a prose
54
+ * knowledge base starts lying.
55
+ */
56
+ export const SupersededClaim = z.object({
57
+ claim: z.string(),
58
+ valid_to: z.string(),
59
+ });
60
+ /**
61
+ * Whether document evidence can still be checked against its original bytes.
62
+ *
63
+ * Extracted text is a useful surviving copy, but it is not the original. Keeping
64
+ * that distinction in the result lets a caller use remembered evidence without
65
+ * implying that the source file is still present.
66
+ */
67
+ export const DocumentAvailability = z.object({
68
+ status: z.enum(['available', 'degraded', 'unavailable']),
69
+ available_from: z.array(z.enum(['original', 'indexed_text', 'rendition'])),
70
+ missing_originals: z.array(z.string()),
71
+ available_renditions: z.array(z.string()),
72
+ /** Earliest time an original in this document group was observed missing. */
73
+ missing_since: z.string().optional(),
74
+ });
75
+ export const GraphRelation = z.enum([
76
+ 'canonical_record',
77
+ 'links_to',
78
+ 'mentions',
79
+ 'about',
80
+ 'has_attribute',
81
+ 'related_entity',
82
+ 'owns_document',
83
+ 'participates_in',
84
+ ]);
85
+ export const GraphNodeKind = z.enum(['entity', 'page', 'document', 'fact', 'event']);
86
+ /** Compact identity only. Read the referenced page or document for content. */
87
+ export const GraphNodeRef = z.object({
88
+ id: z.string(),
89
+ kind: GraphNodeKind,
90
+ slug: z.string().optional(),
91
+ label: z.string().optional(),
92
+ role: PageRole.optional(),
93
+ entity: z.string().optional(),
94
+ entity_type: z.enum(['person', 'organization', 'place', 'product', 'event', 'concept', 'other']).optional(),
95
+ document: z.string().optional(),
96
+ fact: z.string().optional(),
97
+ event: z.string().optional(),
98
+ date: z.string().optional(),
99
+ line_start: z.number().int().positive().optional(),
100
+ line_end: z.number().int().positive().optional(),
101
+ availability: DocumentAvailability.shape.status.optional(),
102
+ });
103
+ /** A locator, never a copied claim or excerpt. */
104
+ export const GraphEvidenceLocator = z.object({
105
+ kind: z.enum(['page_line', 'fact_line', 'frontmatter', 'document']),
106
+ slug: z.string().optional(),
107
+ document: z.string().optional(),
108
+ event: z.string().optional(),
109
+ fact: z.string().optional(),
110
+ line_start: z.number().int().positive().optional(),
111
+ line_end: z.number().int().positive().optional(),
112
+ field: z.string().optional(),
113
+ });
114
+ /** Why one recall candidate entered the fused candidate set. */
115
+ export const RecallMatchArm = z.enum(['lexical', 'vector', 'graph']);
116
+ /** Compact, self-contained graph explanation attached only to a returned card. */
117
+ export const RecallGraphPath = z.object({
118
+ seed: GraphNodeRef,
119
+ target: GraphNodeRef,
120
+ nodes: z.array(GraphNodeRef).min(2).max(4),
121
+ relations: z.array(GraphRelation).min(1).max(3),
122
+ hops: z.number().int().positive().max(3),
123
+ confidence: z.number().min(0).max(1),
124
+ evidence: z.array(GraphEvidenceLocator).min(1).max(3),
125
+ });
126
+ /** An attachment that matched, and where inside it. */
127
+ export const DocumentRef = z.object({
128
+ id: z.string(),
129
+ rel_path: z.string().optional(),
130
+ mime: z.string().optional(),
131
+ label: z.string().optional(),
132
+ pages: z.number().int().nonnegative().optional(),
133
+ /**
134
+ * Files this document is made of, when more than one — `passport.pdf` plus
135
+ * `passport-2.pdf` is one document in two files. `pages` and `matched_page` both
136
+ * count through the whole of it, so a page number is one a reader can look up.
137
+ */
138
+ parts: z.number().int().positive().optional(),
139
+ matched_page: z.number().int().positive().optional(),
140
+ /** What the document is, in a sentence. A stored document has a summary of its own. */
141
+ summary: z.string().optional(),
142
+ /**
143
+ * The matching text from inside the document, capped by `recall.source_quote_lines`.
144
+ *
145
+ * A document is evidence, not a claim, so it comes back as a quote window rather
146
+ * than in full — and as a quote attributed to the document and its page, never as a line
147
+ * citation on the Markdown page, which has no such line.
148
+ */
149
+ quote: z.string().optional(),
150
+ availability: DocumentAvailability.optional(),
151
+ });
152
+ /** How searchable text was obtained from a standalone document. */
153
+ export const DocumentTextSource = z.object({
154
+ kind: z.enum(['original_text', 'ocr_text', 'model_description', 'none']),
155
+ via: z.enum(['plain', 'textutil', 'text-layer', 'ocr', 'vision', 'none']),
156
+ confidence: z.number().min(0).max(1).nullable().optional(),
157
+ });
158
+ export const DocumentPartRef = z.object({
159
+ id: z.string(),
160
+ path: z.string(),
161
+ pages: z.number().int().nonnegative().nullable().optional(),
162
+ });
163
+ /**
164
+ * Recall returns page cards, not chunks — a chunk boundary is an indexing
165
+ * artifact and means nothing to a reader.
166
+ */
167
+ export const Card = z.object({
168
+ slug: z.string(),
169
+ title: z.string(),
170
+ role: PageRole,
171
+ summary: z.string().nullable(),
172
+ /** `Car insurance 2026 › Policy` — the heading path of the best-matching chunk. */
173
+ breadcrumb: z.string().optional(),
174
+ updated: z.string().optional(),
175
+ score: z.number(),
176
+ /**
177
+ * An **absolute** relevance in 0..1, when one is available: a cross-encoder's
178
+ * judgement, or cosine similarity from the embedding arm. Absent on a lexical-only
179
+ * search, where nothing produces a comparable number.
180
+ *
181
+ * `score` ranks within one result set and cannot be compared to a fixed threshold —
182
+ * the best hit of a bad set still ranks first. This is the field to threshold on.
183
+ */
184
+ relevance: z.number().min(0).max(1).optional(),
185
+ lines: z.array(Line),
186
+ superseded: z.array(SupersededClaim).optional(),
187
+ links: z.array(z.string()).optional(),
188
+ documents: z.array(DocumentRef).optional(),
189
+ /** Set when the role capped what this card could contribute. */
190
+ truncated: z.boolean().optional(),
191
+ /** Candidate-generation arms that found this page. Scores across these arms are fused by rank. */
192
+ matched_by: z.array(RecallMatchArm).optional(),
193
+ /** Bounded graph paths that contributed this returned page, with locators but no copied claims. */
194
+ graph_paths: z.array(RecallGraphPath).optional(),
195
+ });
196
+ /** The page variant in the authoritative mixed recall result list. */
197
+ export const PageCard = Card.extend({ type: z.literal('page') });
198
+ /** Searchable evidence that has not been filed beneath a Markdown page. */
199
+ export const DocumentCard = z.object({
200
+ type: z.literal('document'),
201
+ id: z.string(),
202
+ path: z.string(),
203
+ label: z.string(),
204
+ mime: z.string().nullable(),
205
+ summary: z.string().optional(),
206
+ quote: z.string().optional(),
207
+ matched_page: z.number().int().positive().optional(),
208
+ parts: z.array(DocumentPartRef).optional(),
209
+ source: DocumentTextSource,
210
+ availability: DocumentAvailability.optional(),
211
+ ownership: z.object({
212
+ status: z.literal('orphan'),
213
+ }),
214
+ suggested_actions: z
215
+ .array(z.object({
216
+ op: z.literal('adopt'),
217
+ args: z.object({ documentId: z.string() }),
218
+ }))
219
+ .optional(),
220
+ score: z.number(),
221
+ relevance: z.number().min(0).max(1).optional(),
222
+ matched_by: z.array(RecallMatchArm).optional(),
223
+ graph_paths: z.array(RecallGraphPath).optional(),
224
+ });
225
+ export const RecallResult = z.discriminatedUnion('type', [PageCard, DocumentCard]);
226
+ export function isPageCard(result) {
227
+ return result.type === 'page';
228
+ }
229
+ export function isDocumentCard(result) {
230
+ return result.type === 'document';
231
+ }
232
+ /**
233
+ * Named, machine-readable reasons a result is `degraded`. A rule that quietly
234
+ * excludes half a knowledge base is worse than no rule — default to visible.
235
+ */
236
+ export const DegradedReason = z.enum([
237
+ 'no_embedding_model',
238
+ 'no_reranker',
239
+ 'no_derive_model',
240
+ 'no_expansion_model',
241
+ 'embedding_failed',
242
+ 'rerank_failed',
243
+ 'derive_failed',
244
+ 'expansion_failed',
245
+ 'no_vector_index',
246
+ 'partial_index',
247
+ /** The file yielded no text — nothing to read back, and no model involved either way. */
248
+ 'no_document_text',
249
+ /** The original bytes are gone; recall is using a retained extraction or rendition. */
250
+ 'document_source_missing',
251
+ /** Recall could not read the optional structural graph candidate arm. */
252
+ 'no_graph_index',
253
+ /** Canonical entity names are not completely available for exact seeding. */
254
+ 'no_entity_index',
255
+ /** One or more query names were ambiguous and Akno abstained. */
256
+ 'entity_resolution_failed',
257
+ /** Base index rows and their rebuildable graph projection are out of step. */
258
+ 'partial_graph_index',
259
+ /** A path, seed, or per-node fan-out safety cap stopped traversal. */
260
+ 'graph_traversal_limited',
261
+ /** Related evidence exists, but no model role is available to produce a grounded answer. */
262
+ 'no_answer_model',
263
+ /** The answer-generation request failed or returned an invalid draft. */
264
+ 'answer_failed',
265
+ /** Independent support verification failed or could not run. */
266
+ 'answer_verification_failed',
267
+ /** The answer hit a configured generation or output safety cap. */
268
+ 'answer_truncated',
269
+ ]);
270
+ /** Every op's response carries these, so a caller can branch uniformly. */
271
+ export const ResultEnvelope = z.object({
272
+ status: ResultStatus,
273
+ degraded: z.array(DegradedReason).optional(),
274
+ /** Human-readable note attached to a non-`ok` status. */
275
+ note: z.string().optional(),
276
+ });
277
+ /** What the reranker was allowed to remove, kept visible so fewer results never looks accidental. */
278
+ export const RecallQualification = z.object({
279
+ model: z.enum(['llm', 'native']),
280
+ /** Content-free runtime identity and cost receipt for the qualification request. */
281
+ model_id: z.string().optional(),
282
+ latency_ms: z.number().nonnegative().optional(),
283
+ input_tokens: z.number().int().nonnegative().nullable().optional(),
284
+ output_tokens: z.number().int().nonnegative().nullable().optional(),
285
+ total_tokens: z.number().int().nonnegative().nullable().optional(),
286
+ applied: z.boolean(),
287
+ judged: z.number().int().nonnegative(),
288
+ rejected: z.number().int().nonnegative(),
289
+ /** Candidates outside the bounded rerank window. Omitted when qualification is applied. */
290
+ unjudged: z.number().int().nonnegative(),
291
+ basis: z.enum(['llm_grade', 'native_auto', 'native_manual', 'disabled', 'calibration_failed']),
292
+ /** Native raw-score boundary; null for LLM grades or when calibration failed. */
293
+ threshold: z.number().nullable(),
294
+ });
295
+ export const SlugFilter = z.object({
296
+ folder: z.string().optional(),
297
+ type: z.string().optional(),
298
+ tags: z.array(z.string()).optional(),
299
+ role: PageRole.optional(),
300
+ /** Restrict evidence to Markdown pages, stored documents, or both. */
301
+ source: z.enum(['page', 'document', 'both']).optional(),
302
+ /** Orphans have no page role; `orphan` therefore selects document evidence only. */
303
+ ownership: z.enum(['orphan', 'owned', 'any']).optional(),
304
+ });
305
+ /** `YYYY`, `YYYY-MM` or `YYYY-MM-DD` — the granularities a ledger is filtered by. */
306
+ export const DatePrefix = z
307
+ .string()
308
+ .regex(/^\d{4}(-\d{2}(-\d{2})?)?$/, 'expected YYYY, YYYY-MM or YYYY-MM-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,qFAAqF;AACrF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,EAAE;KACR,KAAK,CAAC,2BAA2B,EAAE,sCAAsC,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Failure is a *result*, not an exception, everywhere a caller could reasonably
3
+ * continue. `recall` distinguishing "nothing matched" from "the index is
4
+ * unavailable" is the whole point — an agent can honestly say "not
5
+ * recorded" only when the layer proved it.
6
+ */
7
+ export declare const ERROR_CODES: readonly ["empty", "degraded", "unavailable", "busy", "interrupted", "requires_approval", "conflict", "invalid", "forbidden", "not_found", "read_only", "not_implemented", "internal"];
8
+ export type ErrorCode = (typeof ERROR_CODES)[number];
9
+ /**
10
+ * Thrown across a door boundary and reconstructed on the far side, so a client
11
+ * sees the same error shape whether it called in-process or over a socket.
12
+ */
13
+ export declare class AknoError extends Error {
14
+ readonly code: ErrorCode;
15
+ readonly details: Record<string, unknown> | undefined;
16
+ constructor(code: ErrorCode, message: string, details?: Record<string, unknown>);
17
+ toJSON(): {
18
+ code: ErrorCode;
19
+ message: string;
20
+ details?: Record<string, unknown>;
21
+ };
22
+ static from(value: unknown): AknoError;
23
+ }
24
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,WAAW,wLA2Bd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;gBAE1C,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAO/E,MAAM,IAAI;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;IAMjF,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS;CAKvC"}
package/dist/errors.js ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Failure is a *result*, not an exception, everywhere a caller could reasonably
3
+ * continue. `recall` distinguishing "nothing matched" from "the index is
4
+ * unavailable" is the whole point — an agent can honestly say "not
5
+ * recorded" only when the layer proved it.
6
+ */
7
+ export const ERROR_CODES = [
8
+ /** The op ran; the knowledge base genuinely has nothing. Not an error. */
9
+ 'empty',
10
+ /** A model was unavailable, so a weaker path ran. The result is real but thinner. */
11
+ 'degraded',
12
+ /** The index could not be read. Say "let me check again", never "not recorded". */
13
+ 'unavailable',
14
+ /** The requested lifecycle is already active. Retry later or inspect the supplied run id. */
15
+ 'busy',
16
+ /** A durable lifecycle record was recovered after its process ended before finalization. */
17
+ 'interrupted',
18
+ /** A gate blocked a write. Carries a proposal_id the user can approve. */
19
+ 'requires_approval',
20
+ /** Two live claims on one attribute. Surfaced before the write commits. */
21
+ 'conflict',
22
+ /** Bad input — schema violation, unknown slug, malformed id. */
23
+ 'invalid',
24
+ /** The caller's permissions do not include this op on this subtree. */
25
+ 'forbidden',
26
+ /** Named thing does not exist. */
27
+ 'not_found',
28
+ /** Another process holds the write handle; this one is read-only. */
29
+ 'read_only',
30
+ /** Reached in this cut only: the op's schema is final, the body is not. */
31
+ 'not_implemented',
32
+ /** Everything else. */
33
+ 'internal',
34
+ ];
35
+ /**
36
+ * Thrown across a door boundary and reconstructed on the far side, so a client
37
+ * sees the same error shape whether it called in-process or over a socket.
38
+ */
39
+ export class AknoError extends Error {
40
+ code;
41
+ details;
42
+ constructor(code, message, details) {
43
+ super(message);
44
+ this.name = 'AknoError';
45
+ this.code = code;
46
+ this.details = details;
47
+ }
48
+ toJSON() {
49
+ return this.details
50
+ ? { code: this.code, message: this.message, details: this.details }
51
+ : { code: this.code, message: this.message };
52
+ }
53
+ static from(value) {
54
+ if (value instanceof AknoError)
55
+ return value;
56
+ if (isWireError(value))
57
+ return new AknoError(value.code, value.message, value.details);
58
+ return new AknoError('internal', value instanceof Error ? value.message : String(value));
59
+ }
60
+ }
61
+ function isWireError(value) {
62
+ if (typeof value !== 'object' || value === null)
63
+ return false;
64
+ const candidate = value;
65
+ return (typeof candidate.message === 'string' &&
66
+ typeof candidate.code === 'string' &&
67
+ ERROR_CODES.includes(candidate.code));
68
+ }
69
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,0EAA0E;IAC1E,OAAO;IACP,qFAAqF;IACrF,UAAU;IACV,mFAAmF;IACnF,aAAa;IACb,6FAA6F;IAC7F,MAAM;IACN,4FAA4F;IAC5F,aAAa;IACb,0EAA0E;IAC1E,mBAAmB;IACnB,2EAA2E;IAC3E,UAAU;IACV,gEAAgE;IAChE,SAAS;IACT,uEAAuE;IACvE,WAAW;IACX,kCAAkC;IAClC,WAAW;IACX,qEAAqE;IACrE,WAAW;IACX,2EAA2E;IAC3E,iBAAiB;IACjB,uBAAuB;IACvB,UAAU;CACF,CAAC;AAIX;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,IAAI,CAAY;IAChB,OAAO,CAAsC;IAEtD,YAAY,IAAe,EAAE,OAAe,EAAE,OAAiC;QAC7E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO;YACjB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;YACnE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,KAAc;QACxB,IAAI,KAAK,YAAY,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7C,IAAI,WAAW,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACvF,OAAO,IAAI,SAAS,CAAC,UAAU,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3F,CAAC;CACF;AAED,SAAS,WAAW,CAClB,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,SAAS,GAAG,KAA8C,CAAC;IACjE,OAAO,CACL,OAAO,SAAS,CAAC,OAAO,KAAK,QAAQ;QACrC,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QACjC,WAAiC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAC5D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ export * from './version.ts';
2
+ export * from './errors.ts';
3
+ export * from './common.ts';
4
+ export * from './registry.ts';
5
+ export * from './wire.ts';
6
+ export * from './ops/recall.ts';
7
+ export * from './ops/answer.ts';
8
+ export * from './ops/read.ts';
9
+ export * from './ops/list.ts';
10
+ export * from './ops/timeline.ts';
11
+ export * from './ops/context.ts';
12
+ export * from './ops/graph.ts';
13
+ export * from './ops/write.ts';
14
+ export * from './ops/folder.ts';
15
+ export * from './ops/mutate.ts';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAE1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ export * from "./version.js";
2
+ export * from "./errors.js";
3
+ export * from "./common.js";
4
+ export * from "./registry.js";
5
+ export * from "./wire.js";
6
+ export * from "./ops/recall.js";
7
+ export * from "./ops/answer.js";
8
+ export * from "./ops/read.js";
9
+ export * from "./ops/list.js";
10
+ export * from "./ops/timeline.js";
11
+ export * from "./ops/context.js";
12
+ export * from "./ops/graph.js";
13
+ export * from "./ops/write.js";
14
+ export * from "./ops/folder.js";
15
+ export * from "./ops/mutate.js";
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAE1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}