@keb-org/consol 0.0.0-stage → 0.1.1
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.
- package/LICENSE +21 -0
- package/README.md +265 -2
- package/dist/consol.d.ts +36 -0
- package/dist/errors.d.ts +29 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +815 -0
- package/dist/index.mjs +5 -0
- package/dist/stdio.d.ts +120 -0
- package/dist/transport.d.ts +38 -0
- package/dist/types.d.ts +395 -0
- package/dist/vault.d.ts +180 -0
- package/package.json +58 -4
package/dist/vault.d.ts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { type EngineOptions } from "./stdio";
|
|
2
|
+
import { type CallOptions } from "./transport";
|
|
3
|
+
import type { ConsolidationDisposition, PairDisposition, ReadResult, RecallResult, Reply, ReflectResult, RememberResult, RemoveResult, Scope, SourceDisposition } from "./types";
|
|
4
|
+
export { sliceUtf8 } from "./types";
|
|
5
|
+
export declare const CLIENT_INFO: {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
/** Local vault: the SDK spawns `consol stdio` for it. */
|
|
10
|
+
export interface VaultOptions extends EngineOptions {
|
|
11
|
+
/** Local directory, or `s3://bucket[/prefix]/<name>` (needs `db`; AWS_* from the environment). */
|
|
12
|
+
path: string;
|
|
13
|
+
/** Default agent of every call; a call's own `agent` argument overrides it. */
|
|
14
|
+
agent: string;
|
|
15
|
+
}
|
|
16
|
+
/** Hosted vault: POSTs to a backend that runs `Consol.handle`. Backends create vaults, clients only open. */
|
|
17
|
+
export interface HostedOptions {
|
|
18
|
+
url: string;
|
|
19
|
+
/** Sent with every request: the backend developer's own auth. */
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
/** The backend's name for the vault. */
|
|
22
|
+
vault: string;
|
|
23
|
+
agent: string;
|
|
24
|
+
/** Default per-call deadline in ms (300000); 0 disables it. */
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Binds one recoverable write to inspected work; a write never completes the work. */
|
|
28
|
+
export interface ReflectionContext {
|
|
29
|
+
work_id: string;
|
|
30
|
+
basis_hash: string;
|
|
31
|
+
action_key: string;
|
|
32
|
+
}
|
|
33
|
+
/** Decision input source reference; unlike results it never carries `review_version`. */
|
|
34
|
+
export interface InspectedSource {
|
|
35
|
+
id: string;
|
|
36
|
+
owner: string;
|
|
37
|
+
content_version: string;
|
|
38
|
+
}
|
|
39
|
+
/** Body byte range (UTF-8, frontmatter excluded) that a decision cites as evidence. */
|
|
40
|
+
export interface InspectedSpan {
|
|
41
|
+
source: InspectedSource;
|
|
42
|
+
byte_range: [number, number];
|
|
43
|
+
}
|
|
44
|
+
/** Required for completed pair decisions so validity periods are compared, not assumed. */
|
|
45
|
+
export interface TemporalAssessment {
|
|
46
|
+
validity: "overlap" | "disjoint" | "empty" | "unknown";
|
|
47
|
+
reason: string;
|
|
48
|
+
evidence: InspectedSpan[];
|
|
49
|
+
correction_reason?: string;
|
|
50
|
+
}
|
|
51
|
+
/** Names the authored link a `linked` pair decision relies on. */
|
|
52
|
+
export interface PairAssertion {
|
|
53
|
+
owner: InspectedSource;
|
|
54
|
+
src: string;
|
|
55
|
+
dst: string;
|
|
56
|
+
relation: "derives" | "causes" | "contradicts" | "questions";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One explicit outcome for `reflect({ decisions })`; the tool schema defines each kind's required
|
|
60
|
+
* evidence. `retry_after_ms` is an epoch-ms timestamp within the next day, only for `retryable_error`.
|
|
61
|
+
* Hub and promotion decisions are experimental.
|
|
62
|
+
*/
|
|
63
|
+
export type Decision = {
|
|
64
|
+
kind: "source";
|
|
65
|
+
work_id: string;
|
|
66
|
+
basis_hash: string;
|
|
67
|
+
disposition: SourceDisposition;
|
|
68
|
+
reason: string;
|
|
69
|
+
outputs?: InspectedSource[];
|
|
70
|
+
action_keys?: string[];
|
|
71
|
+
retry_after_ms?: number;
|
|
72
|
+
} | {
|
|
73
|
+
kind: "pair";
|
|
74
|
+
work_id: string;
|
|
75
|
+
basis_hash: string;
|
|
76
|
+
disposition: PairDisposition;
|
|
77
|
+
reason: string;
|
|
78
|
+
temporal?: TemporalAssessment;
|
|
79
|
+
assertion?: PairAssertion;
|
|
80
|
+
action_keys?: string[];
|
|
81
|
+
retry_after_ms?: number;
|
|
82
|
+
} | {
|
|
83
|
+
kind: "hub" | "promotion";
|
|
84
|
+
work_id: string;
|
|
85
|
+
basis_hash: string;
|
|
86
|
+
disposition: ConsolidationDisposition;
|
|
87
|
+
reason: string;
|
|
88
|
+
outputs?: InspectedSource[];
|
|
89
|
+
evidence?: InspectedSpan[];
|
|
90
|
+
action_keys?: string[];
|
|
91
|
+
retry_after_ms?: number;
|
|
92
|
+
} | {
|
|
93
|
+
kind: "abandon_write";
|
|
94
|
+
work_id: string;
|
|
95
|
+
basis_hash: string;
|
|
96
|
+
action_key: string;
|
|
97
|
+
inspected: InspectedSource | null;
|
|
98
|
+
reason: string;
|
|
99
|
+
};
|
|
100
|
+
/** Flat wire args for recall. */
|
|
101
|
+
export interface RecallArgs {
|
|
102
|
+
query: string;
|
|
103
|
+
agent?: string;
|
|
104
|
+
include_history?: boolean;
|
|
105
|
+
limit?: number;
|
|
106
|
+
}
|
|
107
|
+
/** Flat wire args for read. */
|
|
108
|
+
export interface ReadArgs {
|
|
109
|
+
id: string;
|
|
110
|
+
agent?: string;
|
|
111
|
+
continuation?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Flat wire args for remember. Omitted or null metadata preserves the stored value; "" or [] clears
|
|
115
|
+
* it. Without `expected_version` the write is create-only.
|
|
116
|
+
*/
|
|
117
|
+
export interface RememberArgs {
|
|
118
|
+
id: string;
|
|
119
|
+
agent?: string;
|
|
120
|
+
/** Markdown body only, never frontmatter. */
|
|
121
|
+
content?: string | null;
|
|
122
|
+
expected_version?: string;
|
|
123
|
+
entities?: string[] | null;
|
|
124
|
+
facets?: string[] | null;
|
|
125
|
+
scope?: Scope | null;
|
|
126
|
+
summary?: string | null;
|
|
127
|
+
team?: string | null;
|
|
128
|
+
/** `YYYY-MM-DD` or RFC 3339 with `Z`/offset; "" clears the bound. */
|
|
129
|
+
valid_from?: string | null;
|
|
130
|
+
valid_to?: string | null;
|
|
131
|
+
reflection?: ReflectionContext;
|
|
132
|
+
}
|
|
133
|
+
/** Flat wire args for remove (archives the note; its body stays readable). */
|
|
134
|
+
export interface RemoveArgs {
|
|
135
|
+
id: string;
|
|
136
|
+
expected_version: string;
|
|
137
|
+
agent?: string;
|
|
138
|
+
reflection?: ReflectionContext;
|
|
139
|
+
}
|
|
140
|
+
/** Resume a pending reflection-bound write with the same context and tool. */
|
|
141
|
+
export interface ResumeArgs {
|
|
142
|
+
resume: true;
|
|
143
|
+
reflection: ReflectionContext;
|
|
144
|
+
agent?: string;
|
|
145
|
+
}
|
|
146
|
+
/** Flat wire args for reflect. */
|
|
147
|
+
export interface ReflectArgs {
|
|
148
|
+
agent?: string;
|
|
149
|
+
ids?: string[];
|
|
150
|
+
work_ids?: string[];
|
|
151
|
+
limit?: number;
|
|
152
|
+
decisions?: Decision[];
|
|
153
|
+
}
|
|
154
|
+
/** One vault behind a transport (a local child or a hosted backend). Build it with createVault or openVault; close() is final. */
|
|
155
|
+
export declare class Vault {
|
|
156
|
+
private readonly transport;
|
|
157
|
+
private readonly vault;
|
|
158
|
+
private readonly agent;
|
|
159
|
+
private constructor();
|
|
160
|
+
/** Server version of the last reply; null before the first. */
|
|
161
|
+
get serverVersion(): string | null;
|
|
162
|
+
/** Final and idempotent; concurrent calls share one completion. Later calls fail with `closed`. */
|
|
163
|
+
close(): Promise<void>;
|
|
164
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
165
|
+
/** Raw call for LLM loops: tool errors come back as the reply's `error`, never thrown. */
|
|
166
|
+
callTool(name: string, args: Record<string, unknown>, options?: CallOptions): Promise<Reply>;
|
|
167
|
+
/** Leads, not proof: read a note before relying on it or editing it. */
|
|
168
|
+
recall(args: RecallArgs, options?: CallOptions): Promise<RecallResult>;
|
|
169
|
+
read(args: ReadArgs, options?: CallOptions): Promise<ReadResult>;
|
|
170
|
+
remember(args: RememberArgs | ResumeArgs, options?: CallOptions): Promise<RememberResult>;
|
|
171
|
+
remove(args: RemoveArgs | ResumeArgs, options?: CallOptions): Promise<RemoveResult>;
|
|
172
|
+
reflect(args?: ReflectArgs, options?: CallOptions): Promise<ReflectResult>;
|
|
173
|
+
}
|
|
174
|
+
/** Creates the vault and starts its child; fails with `vault_exists` when a vault marker exists. */
|
|
175
|
+
export declare function createVault(options: VaultOptions): Promise<Vault>;
|
|
176
|
+
/**
|
|
177
|
+
* Local: starts the child of an existing vault (`vault_not_found` when no marker exists). Hosted
|
|
178
|
+
* (`url`): no round trip here, a missing vault is `vault_not_found` on the first call.
|
|
179
|
+
*/
|
|
180
|
+
export declare function openVault(options: VaultOptions | HostedOptions): Promise<Vault>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keb-org/consol",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Consol memory engine SDK: a local vault, a hosted vault client, and the Consol backend class",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"memory",
|
|
8
|
+
"agents",
|
|
9
|
+
"llm",
|
|
10
|
+
"markdown"
|
|
11
|
+
],
|
|
12
|
+
"author": "Khas",
|
|
13
|
+
"homepage": "https://github.com/keb-org/consol/tree/main/bindings/js#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/keb-org/consol/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/keb-org/consol.git",
|
|
20
|
+
"directory": "bindings/js"
|
|
21
|
+
},
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"module": "dist/index.mjs",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.mjs",
|
|
29
|
+
"require": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && bun build src/index.ts --outfile dist/index.js --target node --format cjs && cp src/index.mjs dist/index.mjs && tsc --emitDeclarationOnly --pretty false",
|
|
41
|
+
"typecheck": "tsc --noEmit --pretty false",
|
|
42
|
+
"test": "bun run build && bun test/pure.ts && node test/http.ts && node test/sdk.ts && tsc --noEmit --pretty false -p test",
|
|
43
|
+
"test:offline": "bun run build && bun test/pure.ts && node test/http.ts && tsc --noEmit --pretty false -p test",
|
|
44
|
+
"test:consumers": "bun run build && bash consumers/run.sh"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"typescript": "5.3.3",
|
|
48
|
+
"@types/node": "20.11.0"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"optionalDependencies": {
|
|
54
|
+
"@keb-org/consol-win32-x64": "0.1.1",
|
|
55
|
+
"@keb-org/consol-darwin-arm64": "0.1.1",
|
|
56
|
+
"@keb-org/consol-darwin-x64": "0.1.1",
|
|
57
|
+
"@keb-org/consol-linux-x64": "0.1.1",
|
|
58
|
+
"@keb-org/consol-linux-arm64": "0.1.1"
|
|
59
|
+
}
|
|
60
|
+
}
|