@medicine-wheel/honcho 0.15.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.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @medicine-wheel/honcho
2
+
3
+ The wheel's projection into [Honcho](https://honcho.dev) — memory that reasons. The wheel stays canonical (what was recorded, and how it relates); Honcho holds what the accumulated history has come to mean about each peer, and keeps revising it as new records arrive.
4
+
5
+ Zero dependencies beyond `fetch`, `/v3` only.
6
+
7
+ The published `@honcho-ai/sdk` also speaks `/v3` and works against a 3.x server — verified on 2026-09-19 against the deployed 3.0.11, where a live `peer.chat` answered. An earlier note here claimed otherwise and was wrong. This package exists because the wheel's packages ship to npm (a vendor SDK here becomes a runtime dependency on all of them, for a river that only needs get-or-create and append), and because the part that carries weight is `projectBeat` / `projectCeremony` / `projectDiaryEntry` / `honchoIdFor` / `memoryProjectionNode` — the wheel's own ontology, which no SDK has.
8
+
9
+ ## The river: automatic, on write
10
+
11
+ A wheel server started with `HONCHO_URL` set projects **every stored beat, ceremony and diary entry** into Honcho the moment it is written, in the background. No agent in the loop, nothing to call, nothing filtered. The wheel's own answer to its caller is unchanged: a projection never delays a response, and a Honcho that is down is one line on stderr, never an error to the writer.
12
+
13
+ ```
14
+ POST /api/ceremonies → one message from the peer `medicine-wheel`, in the ceremony's session
15
+ POST /api/narrative/beats → one message from the speaker, witnesses seated, in the session of its first ceremony
16
+ POST /api/diary → one message in the participant's voice, in the ceremony's (or episode's) session
17
+ ```
18
+
19
+ `GET /api/health` reports it: `"honcho": { "enabled": true, "url": …, "workspace": … }`, or `{ "enabled": false }`.
20
+
21
+ The MCP server writes through these routes when `MW_API_URL` is set, so beats and ceremonies logged by an agent flow too. Honcho's deriver then reasons over each session in the background and the peer representations grow on their own.
22
+
23
+ ## Putting it into production
24
+
25
+ On the host that runs the wheel (eury: the chronicle wheel on `:8040`; Honcho on `:8133`):
26
+
27
+ ```bash
28
+ # 1. the wheel — one variable, then restart the server (a running process holds its old build)
29
+ HONCHO_URL=http://localhost:8133 # https://honcho.<tailnet>.ts.net from another host
30
+ HONCHO_WORKSPACE_ID=medicine-wheel # default; set it to share a workspace with Miadi (miadi-dev)
31
+ # HONCHO_API_KEY is unset while Honcho's auth is off
32
+
33
+ # 2. prove the river runs
34
+ curl -s http://127.0.0.1:8040/api/health | jq .honcho # {"enabled":true,...}
35
+ curl -s -X POST http://127.0.0.1:8040/api/narrative/beats -H 'content-type: application/json' \
36
+ -d '{"direction":"east","title":"River check","description":"first projected beat","learnings":[]}'
37
+ curl -s -X POST http://localhost:8133/v3/workspaces/medicine-wheel/sessions/list | jq '.items[].id' # medicine-wheel
38
+ curl -s -X POST http://localhost:8133/v3/workspaces/medicine-wheel/sessions/medicine-wheel/messages/list | jq '.items[-1].content'
39
+
40
+ # 3. later, once the deriver has reasoned
41
+ curl -s -X POST http://localhost:8133/v3/workspaces/medicine-wheel/peers/medicine-wheel/representation -H 'content-type: application/json' -d '{}'
42
+ ```
43
+
44
+ Docker: the entrypoint passes `HONCHO_URL`, `HONCHO_WORKSPACE_ID` and `HONCHO_API_KEY` through and prints the target at start.
45
+
46
+ ## The door: the same three moves by hand
47
+
48
+ ```ts
49
+ import { createHonchoClient, honchoFromEnv, honchoIdFor, project, projectBeat, memoryProjectionNode } from '@medicine-wheel/honcho';
50
+
51
+ const honcho = createHonchoClient(honchoFromEnv() ?? { baseUrl: 'http://localhost:8133', workspace: 'medicine-wheel' });
52
+
53
+ // project — a beat becomes a message from its speaker, in the session of its ceremony
54
+ await project(honcho, projectBeat(beat));
55
+
56
+ // recall — what Honcho has come to understand about the speaker
57
+ const who = await honcho.peers.representation(honchoIdFor(beat.speaker!));
58
+ const why = await honcho.peers.chat(honchoIdFor(beat.speaker!), 'What keeps this person from finishing a project?');
59
+
60
+ // project back — a derived conclusion returns to the wheel as a knowledge node
61
+ const node = memoryProjectionNode({
62
+ source: 'honcho', peerId: honchoIdFor(beat.speaker!), kind: 'pattern', status: 'inferred',
63
+ sourceEventIds: [beat.id], content: why, generatedAt: new Date().toISOString(), derivedBy: 'dialectic',
64
+ });
65
+ await wheel.nodes.create(node); // @medicine-wheel/client
66
+ ```
67
+
68
+ Through MCP: `honcho_status`, `honcho_project` (a beat or ceremony by id), `honcho_recall` (representation, or a question), `honcho_project_back` (a memory projection into the wheel).
69
+
70
+ ## Configuration
71
+
72
+ | Variable | Meaning |
73
+ | --- | --- |
74
+ | `HONCHO_URL` | The Honcho API. Unset: the river is off and the tools answer `unconfigured` |
75
+ | `HONCHO_WORKSPACE_ID` | Workspace; default `medicine-wheel` |
76
+ | `HONCHO_API_KEY` | Bearer token; unset for a self-hosted instance with auth off |
77
+
78
+ ## Ids and sessions
79
+
80
+ Honcho names resources with `^[a-zA-Z0-9_-]+$`; wheel ids carry colons. `honchoIdFor` is the deterministic bridge (`node:human:1726:abc` → `node-human-1726-abc`, `Éloïse` → `Eloise`), and every peer, session and message carries the original as `metadata.wheel_id`, so a Honcho record can always be traced back (Honcho's `filters` body: `{"metadata": {"wheel_id": "…"}}`).
81
+
82
+ A beat lands in the session of its first ceremony, else its cycle, else the wheel's standing session `medicine-wheel`. A ceremony log lands in its own session; a diary entry in its ceremony's, else its chronicle episode's. A ceremony and everything said in it share one session, which is what lets Honcho reason over them together.
@@ -0,0 +1,269 @@
1
+ /**
2
+ * @medicine-wheel/honcho — the wheel's projection into Honcho.
3
+ *
4
+ * The wheel is canonical: beats, ceremonies, nodes, edges, provenance. Honcho
5
+ * (https://honcho.dev, self-hosted at miadisabelle/mia-honcho) is memory that
6
+ * reasons: it takes messages, works over them in the background, and keeps an
7
+ * evolving representation of every peer it observes. This package is the door
8
+ * between the two, in three moves:
9
+ *
10
+ * 1. **Project** — a beat or a ceremony becomes one Honcho message in a session
11
+ * keyed by the ceremony (or cycle) it belongs to. Everything on the wheel is
12
+ * projected as is; nothing is filtered or gated here.
13
+ * 2. **Recall** — before a speaker speaks again, ask Honcho what it has come to
14
+ * understand about them (representation, a fast read) or ask it a question
15
+ * (dialectic chat, a reasoned answer).
16
+ * 3. **Project back** — a derived conclusion returns to the wheel as a
17
+ * `knowledge` node carrying `metadata.kind: "memory_projection"`, with the
18
+ * source ids, the status (`inferred` | `confirmed` | `rejected`) and who
19
+ * derived it, so the wheel stays inspectable.
20
+ *
21
+ * Honcho names its resources with `^[a-zA-Z0-9_-]+$`; wheel ids carry colons
22
+ * (`node:human:…`, `ceremony:…`). {@link honchoIdFor} is the deterministic
23
+ * bridge, and the original wheel id always travels in metadata as `wheel_id`.
24
+ *
25
+ * Zero dependencies beyond `fetch`, and `/v3` only.
26
+ *
27
+ * An earlier version of this comment said the published `@honcho-ai/sdk` speaks
28
+ * `/v2` and a 3.x server 404s it. That was not true. Checked on 2026-09-19
29
+ * against the deployed 3.0.11: both 2.2.0 and 2.5.0 call `/v3/workspaces/...`,
30
+ * and a live `peer.chat` through the SDK answers. The SDK is a working option.
31
+ *
32
+ * What this package is for instead: the wheel's packages ship to npm, so a
33
+ * vendor SDK here is a runtime dependency on every one of them, for a river
34
+ * that needs get-or-create and append and nothing else. And the useful part is
35
+ * not the transport — it is {@link projectBeat}, {@link projectCeremony},
36
+ * {@link projectDiaryEntry}, {@link honchoIdFor} and
37
+ * {@link memoryProjectionNode}, which are the wheel's own ontology and have no
38
+ * equivalent in any SDK.
39
+ */
40
+ import type { CeremonyLog, NarrativeBeat, NodeType, DirectionName } from '@medicine-wheel/ontology-core';
41
+ export type { CeremonyLog, NarrativeBeat };
42
+ export declare class HonchoClientError extends Error {
43
+ /** 502 when Honcho could not be reached; 503 when no URL was configured; else Honcho's own status. */
44
+ readonly status: number;
45
+ readonly url: string;
46
+ /** Honcho's response body when it refused, truncated. */
47
+ readonly body?: string | undefined;
48
+ constructor(message: string,
49
+ /** 502 when Honcho could not be reached; 503 when no URL was configured; else Honcho's own status. */
50
+ status: number, url: string,
51
+ /** Honcho's response body when it refused, truncated. */
52
+ body?: string | undefined);
53
+ }
54
+ /** Honcho's `RESOURCE_NAME_PATTERN` (src/schemas/api.py). */
55
+ export declare const HONCHO_ID_PATTERN: RegExp;
56
+ /**
57
+ * A wheel id (or a plain name) as a Honcho resource id. Deterministic, so the
58
+ * same node always lands on the same peer: `node:human:1726:abc` →
59
+ * `node-human-1726-abc`, `Guillaume Isabelle` → `Guillaume-Isabelle`,
60
+ * `Éloïse` → `Eloise`. Anything outside the pattern becomes `-`; runs collapse;
61
+ * the result is never empty and never longer than Honcho's 512.
62
+ */
63
+ export declare function honchoIdFor(wheelId: string): string;
64
+ export interface HonchoConfig {
65
+ /** `HONCHO_URL` — e.g. `http://localhost:8133` or `https://honcho.<tailnet>.ts.net`. */
66
+ baseUrl: string;
67
+ /** `HONCHO_WORKSPACE_ID` — default `medicine-wheel`. */
68
+ workspace: string;
69
+ /** `HONCHO_API_KEY` — sent as a bearer when set. A self-hosted Honcho with auth off needs none. */
70
+ apiKey?: string;
71
+ }
72
+ export declare const DEFAULT_WORKSPACE = "medicine-wheel";
73
+ /** Reads `HONCHO_URL`, `HONCHO_WORKSPACE_ID`, `HONCHO_API_KEY`. `null` when no URL is set. */
74
+ export declare function honchoFromEnv(env?: Record<string, string | undefined>): HonchoConfig | null;
75
+ export interface HonchoMessage {
76
+ content: string;
77
+ peer_id: string;
78
+ metadata?: Record<string, unknown>;
79
+ /** ISO timestamp; Honcho stamps now when absent. */
80
+ created_at?: string;
81
+ }
82
+ export interface SessionPeerConfig {
83
+ /** Whether Honcho builds a representation of this peer from this session. Session-scoped. */
84
+ observe_me?: boolean;
85
+ /** Whether this peer builds its own perspective of the others. */
86
+ observe_others?: boolean;
87
+ }
88
+ export interface HonchoPeer {
89
+ id: string;
90
+ workspace_id?: string;
91
+ metadata?: Record<string, unknown>;
92
+ [k: string]: unknown;
93
+ }
94
+ export interface HonchoSession {
95
+ id: string;
96
+ workspace_id?: string;
97
+ metadata?: Record<string, unknown>;
98
+ [k: string]: unknown;
99
+ }
100
+ export interface HonchoStoredMessage extends HonchoMessage {
101
+ id: string;
102
+ session_id: string;
103
+ workspace_id?: string;
104
+ }
105
+ export interface SessionContext {
106
+ id: string;
107
+ messages: HonchoStoredMessage[];
108
+ summary?: {
109
+ content: string;
110
+ [k: string]: unknown;
111
+ } | null;
112
+ peer_representation?: string | null;
113
+ peer_card?: string[] | null;
114
+ }
115
+ export interface RepresentationOptions {
116
+ /** Read what `peer` understands about this other peer, instead of Honcho's global view. */
117
+ target?: string;
118
+ session_id?: string;
119
+ search_query?: string;
120
+ max_conclusions?: number;
121
+ }
122
+ export interface ChatOptions {
123
+ session_id?: string;
124
+ target?: string;
125
+ /** `minimal` | `low` | `medium` | `high` | `max` — pick the lowest that answers. */
126
+ reasoning_level?: string;
127
+ }
128
+ export interface HonchoClientOptions extends HonchoConfig {
129
+ fetch?: typeof fetch;
130
+ timeoutMs?: number;
131
+ }
132
+ export interface HonchoClient {
133
+ readonly baseUrl: string;
134
+ readonly workspace: string;
135
+ health(): Promise<unknown>;
136
+ workspaces: {
137
+ /** Get-or-create the configured workspace. */
138
+ ensure(metadata?: Record<string, unknown>): Promise<Record<string, unknown>>;
139
+ };
140
+ peers: {
141
+ /** Get-or-create. Honcho returns the existing peer untouched when the id exists. */
142
+ ensure(id: string, metadata?: Record<string, unknown>): Promise<HonchoPeer>;
143
+ list(opts?: {
144
+ filters?: Record<string, unknown>;
145
+ page?: number;
146
+ size?: number;
147
+ }): Promise<HonchoPeer[]>;
148
+ /** What Honcho has come to understand about a peer. A fast read. */
149
+ representation(id: string, opts?: RepresentationOptions): Promise<string>;
150
+ /** Ask Honcho a question about a peer. Live reasoning: seconds, not milliseconds. */
151
+ chat(id: string, query: string, opts?: ChatOptions): Promise<string>;
152
+ };
153
+ sessions: {
154
+ ensure(id: string, opts?: {
155
+ peers?: Record<string, SessionPeerConfig>;
156
+ metadata?: Record<string, unknown>;
157
+ }): Promise<HonchoSession>;
158
+ list(opts?: {
159
+ filters?: Record<string, unknown>;
160
+ page?: number;
161
+ size?: number;
162
+ }): Promise<HonchoSession[]>;
163
+ /** Seat peers in an existing session (idempotent for already-seated peers). */
164
+ addPeers(id: string, peers: Record<string, SessionPeerConfig>): Promise<HonchoSession>;
165
+ /** Append messages. Honcho takes at most 100 per call; more are sent in order, in chunks. */
166
+ addMessages(id: string, messages: HonchoMessage[]): Promise<HonchoStoredMessage[]>;
167
+ context(id: string, opts?: {
168
+ peer_target?: string;
169
+ tokens?: number;
170
+ summary?: boolean;
171
+ }): Promise<SessionContext>;
172
+ };
173
+ /** Semantic search across the workspace's messages. */
174
+ search(query: string, opts?: {
175
+ limit?: number;
176
+ filters?: Record<string, unknown>;
177
+ }): Promise<HonchoStoredMessage[]>;
178
+ }
179
+ export declare function createHonchoClient(options: HonchoClientOptions): HonchoClient;
180
+ /** The peer the wheel itself speaks as — ceremony logs, beats with no speaker. */
181
+ export declare const WHEEL_PEER = "medicine-wheel";
182
+ /** One wheel record, ready to land in Honcho. */
183
+ export interface Projection {
184
+ /** Honcho session id — the ceremony (or cycle) the record belongs to. */
185
+ session_id: string;
186
+ /** Peers to seat, with their observation config. */
187
+ peers: Record<string, SessionPeerConfig>;
188
+ /** Peer metadata to write on ensure (carries `wheel_id`). */
189
+ peer_metadata: Record<string, Record<string, unknown>>;
190
+ session_metadata: Record<string, unknown>;
191
+ messages: HonchoMessage[];
192
+ }
193
+ /**
194
+ * Which Honcho session a beat lands in: its first ceremony, else its cycle,
195
+ * else the wheel's own standing session. A ceremony's beats and the ceremony
196
+ * log therefore share one session, which is what lets Honcho reason over them
197
+ * together.
198
+ */
199
+ export declare function sessionIdForBeat(beat: Pick<NarrativeBeat, 'ceremonies' | 'cycle_id'>): string;
200
+ export declare function sessionIdForCeremony(ceremony: Pick<CeremonyLog, 'id'>): string;
201
+ /** A beat as one Honcho message from its speaker, witnessed by its witnesses. */
202
+ export declare function projectBeat(beat: NarrativeBeat): Projection;
203
+ /** A ceremony log as one message spoken by the wheel, with every participant seated. */
204
+ export declare function projectCeremony(ceremony: CeremonyLog): Projection;
205
+ /**
206
+ * The shape of a ceremonial diary entry this package reads — structural, so
207
+ * `@medicine-wheel/storage-provider`'s `DiaryEntryRecord` satisfies it without
208
+ * this package depending on the provider.
209
+ */
210
+ export interface DiaryEntryLike {
211
+ id: string;
212
+ timestamp: string;
213
+ /** The participant whose voice this entry carries. */
214
+ participant: string;
215
+ agent?: string;
216
+ phase: string;
217
+ entryType: string;
218
+ content: string;
219
+ metadata?: {
220
+ ceremony_id?: unknown;
221
+ tags?: unknown;
222
+ [k: string]: unknown;
223
+ };
224
+ /** `chronicle:<episode-folder>` when the entry writes into an episode. */
225
+ chronicle?: string;
226
+ }
227
+ /** Where a diary entry lands: its ceremony, else its chronicle episode, else the wheel's standing session. */
228
+ export declare function sessionIdForDiaryEntry(entry: Pick<DiaryEntryLike, 'metadata' | 'chronicle'>): string;
229
+ /** A diary entry as one message in the participant's voice. */
230
+ export declare function projectDiaryEntry(entry: DiaryEntryLike): Projection;
231
+ export interface Projected {
232
+ session_id: string;
233
+ peers: string[];
234
+ messages: number;
235
+ }
236
+ /** Land a projection: ensure the workspace, peers and session, then append the messages. */
237
+ export declare function project(client: HonchoClient, projection: Projection): Promise<Projected>;
238
+ export type MemoryProjectionKind = 'pattern' | 'summary' | 'open_question' | 'preference';
239
+ export type MemoryProjectionStatus = 'inferred' | 'confirmed' | 'rejected';
240
+ /** A conclusion derived in Honcho, returning to the wheel with its provenance. */
241
+ export interface MemoryProjection {
242
+ source: 'honcho';
243
+ /** Wheel ids (beats, ceremonies) or Honcho message ids the conclusion rests on. */
244
+ sourceEventIds: string[];
245
+ /** The Honcho peer the conclusion is about. */
246
+ peerId: string;
247
+ kind: MemoryProjectionKind;
248
+ content: string;
249
+ status: MemoryProjectionStatus;
250
+ generatedAt: string;
251
+ /** The model or agent that derived it. */
252
+ derivedBy?: string;
253
+ }
254
+ export declare const MEMORY_PROJECTION_KIND = "memory_projection";
255
+ /** The `knowledge` node a memory projection becomes on the wheel. `NodeType` stays closed; the kind rides metadata. */
256
+ export interface MemoryProjectionNode {
257
+ id: string;
258
+ name: string;
259
+ type: NodeType;
260
+ direction: DirectionName;
261
+ description: string;
262
+ metadata: Record<string, unknown> & {
263
+ kind: typeof MEMORY_PROJECTION_KIND;
264
+ };
265
+ created_at: string;
266
+ updated_at: string;
267
+ }
268
+ export declare function memoryProjectionNode(p: MemoryProjection, id?: string): MemoryProjectionNode;
269
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEzG,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;AAI3C,qBAAa,iBAAkB,SAAQ,KAAK;IAGxC,sGAAsG;aACtF,MAAM,EAAE,MAAM;aACd,GAAG,EAAE,MAAM;IAC3B,yDAAyD;aACzC,IAAI,CAAC,EAAE,MAAM;gBAL7B,OAAO,EAAE,MAAM;IACf,sGAAsG;IACtF,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM;IAC3B,yDAAyD;IACzC,IAAI,CAAC,EAAE,MAAM,YAAA;CAKhC;AAID,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB,QAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKnD;AAID,MAAM,WAAW,YAAY;IAC3B,wFAAwF;IACxF,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAElD,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,GAAG,GAAE,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C3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAE1D,uHAAuH;AACvH,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,aAAa,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,sBAAsB,CAAA;KAAE,CAAC;IAC5E,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,gBAAgB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAwB3F"}
package/dist/index.js ADDED
@@ -0,0 +1,350 @@
1
+ /**
2
+ * @medicine-wheel/honcho — the wheel's projection into Honcho.
3
+ *
4
+ * The wheel is canonical: beats, ceremonies, nodes, edges, provenance. Honcho
5
+ * (https://honcho.dev, self-hosted at miadisabelle/mia-honcho) is memory that
6
+ * reasons: it takes messages, works over them in the background, and keeps an
7
+ * evolving representation of every peer it observes. This package is the door
8
+ * between the two, in three moves:
9
+ *
10
+ * 1. **Project** — a beat or a ceremony becomes one Honcho message in a session
11
+ * keyed by the ceremony (or cycle) it belongs to. Everything on the wheel is
12
+ * projected as is; nothing is filtered or gated here.
13
+ * 2. **Recall** — before a speaker speaks again, ask Honcho what it has come to
14
+ * understand about them (representation, a fast read) or ask it a question
15
+ * (dialectic chat, a reasoned answer).
16
+ * 3. **Project back** — a derived conclusion returns to the wheel as a
17
+ * `knowledge` node carrying `metadata.kind: "memory_projection"`, with the
18
+ * source ids, the status (`inferred` | `confirmed` | `rejected`) and who
19
+ * derived it, so the wheel stays inspectable.
20
+ *
21
+ * Honcho names its resources with `^[a-zA-Z0-9_-]+$`; wheel ids carry colons
22
+ * (`node:human:…`, `ceremony:…`). {@link honchoIdFor} is the deterministic
23
+ * bridge, and the original wheel id always travels in metadata as `wheel_id`.
24
+ *
25
+ * Zero dependencies beyond `fetch`, and `/v3` only.
26
+ *
27
+ * An earlier version of this comment said the published `@honcho-ai/sdk` speaks
28
+ * `/v2` and a 3.x server 404s it. That was not true. Checked on 2026-09-19
29
+ * against the deployed 3.0.11: both 2.2.0 and 2.5.0 call `/v3/workspaces/...`,
30
+ * and a live `peer.chat` through the SDK answers. The SDK is a working option.
31
+ *
32
+ * What this package is for instead: the wheel's packages ship to npm, so a
33
+ * vendor SDK here is a runtime dependency on every one of them, for a river
34
+ * that needs get-or-create and append and nothing else. And the useful part is
35
+ * not the transport — it is {@link projectBeat}, {@link projectCeremony},
36
+ * {@link projectDiaryEntry}, {@link honchoIdFor} and
37
+ * {@link memoryProjectionNode}, which are the wheel's own ontology and have no
38
+ * equivalent in any SDK.
39
+ */
40
+ // ── errors ──────────────────────────────────────────────────────────────────
41
+ export class HonchoClientError extends Error {
42
+ status;
43
+ url;
44
+ body;
45
+ constructor(message,
46
+ /** 502 when Honcho could not be reached; 503 when no URL was configured; else Honcho's own status. */
47
+ status, url,
48
+ /** Honcho's response body when it refused, truncated. */
49
+ body) {
50
+ super(message);
51
+ this.status = status;
52
+ this.url = url;
53
+ this.body = body;
54
+ this.name = 'HonchoClientError';
55
+ }
56
+ }
57
+ // ── ids ─────────────────────────────────────────────────────────────────────
58
+ /** Honcho's `RESOURCE_NAME_PATTERN` (src/schemas/api.py). */
59
+ export const HONCHO_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;
60
+ /**
61
+ * A wheel id (or a plain name) as a Honcho resource id. Deterministic, so the
62
+ * same node always lands on the same peer: `node:human:1726:abc` →
63
+ * `node-human-1726-abc`, `Guillaume Isabelle` → `Guillaume-Isabelle`,
64
+ * `Éloïse` → `Eloise`. Anything outside the pattern becomes `-`; runs collapse;
65
+ * the result is never empty and never longer than Honcho's 512.
66
+ */
67
+ export function honchoIdFor(wheelId) {
68
+ const folded = wheelId.normalize('NFKD').replace(/[\u0300-\u036f]/g, '');
69
+ const swapped = folded.replace(/[^a-zA-Z0-9_-]+/g, '-').replace(/-{2,}/g, '-').replace(/^-+|-+$/g, '');
70
+ const out = swapped.slice(0, 512);
71
+ return out.length > 0 ? out : 'unnamed';
72
+ }
73
+ export const DEFAULT_WORKSPACE = 'medicine-wheel';
74
+ /** Reads `HONCHO_URL`, `HONCHO_WORKSPACE_ID`, `HONCHO_API_KEY`. `null` when no URL is set. */
75
+ export function honchoFromEnv(env = process.env) {
76
+ const baseUrl = env.HONCHO_URL?.trim();
77
+ if (!baseUrl)
78
+ return null;
79
+ return {
80
+ baseUrl,
81
+ workspace: env.HONCHO_WORKSPACE_ID?.trim() || DEFAULT_WORKSPACE,
82
+ apiKey: env.HONCHO_API_KEY?.trim() || undefined,
83
+ };
84
+ }
85
+ const MAX_BATCH = 100;
86
+ export function createHonchoClient(options) {
87
+ const baseUrl = options.baseUrl.replace(/\/+$/, '');
88
+ const workspace = options.workspace || DEFAULT_WORKSPACE;
89
+ // Resolved per call, not captured: a fetch swapped in later (a polyfill, a
90
+ // test stub) is honoured by a client built earlier.
91
+ const doFetch = (...args) => (options.fetch ?? globalThis.fetch)(...args);
92
+ const timeoutMs = options.timeoutMs ?? 30_000;
93
+ const ws = `/v3/workspaces/${encodeURIComponent(workspace)}`;
94
+ async function call(method, path, body, query) {
95
+ const url = new URL(baseUrl + path);
96
+ for (const [k, v] of Object.entries(query ?? {}))
97
+ if (v !== undefined)
98
+ url.searchParams.set(k, String(v));
99
+ const headers = { accept: 'application/json' };
100
+ if (body !== undefined)
101
+ headers['content-type'] = 'application/json';
102
+ if (options.apiKey)
103
+ headers.authorization = `Bearer ${options.apiKey}`;
104
+ const controller = new AbortController();
105
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
106
+ let res;
107
+ try {
108
+ res = await doFetch(url.toString(), { method, headers, body: body === undefined ? undefined : JSON.stringify(body), signal: controller.signal });
109
+ }
110
+ catch (err) {
111
+ throw new HonchoClientError(`honcho unreachable at ${baseUrl}: ${err instanceof Error ? err.message : String(err)}`, 502, url.toString());
112
+ }
113
+ finally {
114
+ clearTimeout(timer);
115
+ }
116
+ const text = await res.text();
117
+ if (!res.ok)
118
+ throw new HonchoClientError(`honcho ${res.status} on ${method} ${path}`, res.status, url.toString(), text.slice(0, 600));
119
+ if (!text)
120
+ return undefined;
121
+ try {
122
+ return JSON.parse(text);
123
+ }
124
+ catch {
125
+ return text;
126
+ }
127
+ }
128
+ const items = (page) => Array.isArray(page) ? page : page?.items ?? [];
129
+ return {
130
+ baseUrl,
131
+ workspace,
132
+ health: () => call('GET', '/health'),
133
+ workspaces: {
134
+ ensure: (metadata = {}) => call('POST', '/v3/workspaces', { id: workspace, metadata }),
135
+ },
136
+ peers: {
137
+ ensure: (id, metadata = {}) => call('POST', `${ws}/peers`, { id, metadata }),
138
+ list: async (opts = {}) => items(await call('POST', `${ws}/peers/list`, opts.filters ? { filters: opts.filters } : {}, { page: opts.page, size: opts.size })),
139
+ representation: async (id, opts = {}) => (await call('POST', `${ws}/peers/${encodeURIComponent(id)}/representation`, opts)).representation ?? '',
140
+ chat: async (id, query, opts = {}) => {
141
+ const out = await call('POST', `${ws}/peers/${encodeURIComponent(id)}/chat`, { query, stream: false, ...opts });
142
+ return typeof out === 'string' ? out : out?.content ?? '';
143
+ },
144
+ },
145
+ sessions: {
146
+ ensure: (id, opts = {}) => call('POST', `${ws}/sessions`, { id, metadata: opts.metadata ?? {}, ...(opts.peers ? { peers: opts.peers } : {}) }),
147
+ list: async (opts = {}) => items(await call('POST', `${ws}/sessions/list`, opts.filters ? { filters: opts.filters } : {}, { page: opts.page, size: opts.size })),
148
+ addPeers: (id, peers) => call('POST', `${ws}/sessions/${encodeURIComponent(id)}/peers`, peers),
149
+ addMessages: async (id, messages) => {
150
+ const stored = [];
151
+ for (let i = 0; i < messages.length; i += MAX_BATCH) {
152
+ const chunk = messages.slice(i, i + MAX_BATCH);
153
+ stored.push(...(await call('POST', `${ws}/sessions/${encodeURIComponent(id)}/messages`, { messages: chunk })));
154
+ }
155
+ return stored;
156
+ },
157
+ context: (id, opts = {}) => call('GET', `${ws}/sessions/${encodeURIComponent(id)}/context`, undefined, { peer_target: opts.peer_target, tokens: opts.tokens, summary: opts.summary }),
158
+ },
159
+ search: async (query, opts = {}) => items(await call('POST', `${ws}/search`, { query, limit: opts.limit ?? 10, ...(opts.filters ? { filters: opts.filters } : {}) })),
160
+ };
161
+ }
162
+ // ── projection: wheel → Honcho ──────────────────────────────────────────────
163
+ /** The peer the wheel itself speaks as — ceremony logs, beats with no speaker. */
164
+ export const WHEEL_PEER = 'medicine-wheel';
165
+ const seat = () => ({ observe_me: true, observe_others: false });
166
+ function peerEntry(wheelRef) {
167
+ return [honchoIdFor(wheelRef), { wheel_id: wheelRef }];
168
+ }
169
+ /**
170
+ * Which Honcho session a beat lands in: its first ceremony, else its cycle,
171
+ * else the wheel's own standing session. A ceremony's beats and the ceremony
172
+ * log therefore share one session, which is what lets Honcho reason over them
173
+ * together.
174
+ */
175
+ export function sessionIdForBeat(beat) {
176
+ if (beat.ceremonies?.length)
177
+ return honchoIdFor(beat.ceremonies[0]);
178
+ if (beat.cycle_id)
179
+ return honchoIdFor(beat.cycle_id);
180
+ return WHEEL_PEER;
181
+ }
182
+ export function sessionIdForCeremony(ceremony) {
183
+ return honchoIdFor(ceremony.id);
184
+ }
185
+ /**
186
+ * A labelled line for a list field, or nothing when it is empty.
187
+ *
188
+ * Tolerant of a non-array on purpose: these fields reach the wheel over REST,
189
+ * where `learnings: "one thing"` is a shape a caller can send and the store
190
+ * will keep. Projecting it as one item beats throwing on a record the wheel
191
+ * already holds.
192
+ */
193
+ function list(label, xs) {
194
+ const items = Array.isArray(xs) ? xs.map(String) : typeof xs === 'string' && xs ? [xs] : [];
195
+ return items.length ? `\n${label}: ${items.join(', ')}` : '';
196
+ }
197
+ /** A beat as one Honcho message from its speaker, witnessed by its witnesses. */
198
+ export function projectBeat(beat) {
199
+ const speaker = beat.speaker ? peerEntry(beat.speaker) : [WHEEL_PEER, { wheel_id: WHEEL_PEER }];
200
+ const peers = { [speaker[0]]: seat() };
201
+ const peer_metadata = { [speaker[0]]: speaker[1] };
202
+ for (const w of beat.witnesses ?? []) {
203
+ const [id, meta] = peerEntry(w);
204
+ peers[id] ??= seat();
205
+ peer_metadata[id] ??= meta;
206
+ }
207
+ const content = `[${beat.direction}] ${beat.title}\n${beat.description}` +
208
+ (beat.prose ? `\n\n${beat.prose}` : '') +
209
+ list('Learnings', beat.learnings) +
210
+ list('Relations honored', beat.relations_honored);
211
+ return {
212
+ session_id: sessionIdForBeat(beat),
213
+ peers,
214
+ peer_metadata,
215
+ session_metadata: { wheel_kind: beat.ceremonies?.length ? 'ceremony' : beat.cycle_id ? 'cycle' : 'wheel', wheel_id: beat.ceremonies?.[0] ?? beat.cycle_id ?? WHEEL_PEER },
216
+ messages: [{
217
+ content,
218
+ peer_id: speaker[0],
219
+ created_at: beat.timestamp,
220
+ metadata: {
221
+ wheel_kind: 'beat',
222
+ wheel_id: beat.id,
223
+ direction: beat.direction,
224
+ act: beat.act,
225
+ ceremonies: beat.ceremonies ?? [],
226
+ ...(beat.cycle_id ? { cycle_id: beat.cycle_id } : {}),
227
+ ...(beat.witnesses?.length ? { witnesses: beat.witnesses } : {}),
228
+ ...(beat.origin ? { origin: beat.origin } : {}),
229
+ },
230
+ }],
231
+ };
232
+ }
233
+ /** A ceremony log as one message spoken by the wheel, with every participant seated. */
234
+ export function projectCeremony(ceremony) {
235
+ const peers = { [WHEEL_PEER]: seat() };
236
+ const peer_metadata = { [WHEEL_PEER]: { wheel_id: WHEEL_PEER } };
237
+ for (const p of ceremony.participants ?? []) {
238
+ const [id, meta] = peerEntry(p);
239
+ peers[id] ??= seat();
240
+ peer_metadata[id] ??= meta;
241
+ }
242
+ const content = `Ceremony: ${ceremony.type} (${ceremony.direction})` +
243
+ list('Participants', ceremony.participants) +
244
+ list('Intentions', ceremony.intentions) +
245
+ list('Medicines', ceremony.medicines_used) +
246
+ list('Relations honored', ceremony.relations_honored) +
247
+ (ceremony.research_context ? `\nContext: ${ceremony.research_context}` : '') +
248
+ (ceremony.episode_path ? `\nEpisode: ${ceremony.episode_path}` : '');
249
+ return {
250
+ session_id: sessionIdForCeremony(ceremony),
251
+ peers,
252
+ peer_metadata,
253
+ session_metadata: {
254
+ wheel_kind: 'ceremony',
255
+ wheel_id: ceremony.id,
256
+ type: ceremony.type,
257
+ direction: ceremony.direction,
258
+ ...(ceremony.episode_path ? { episode_path: ceremony.episode_path } : {}),
259
+ ...(ceremony.episode_number !== undefined ? { episode_number: ceremony.episode_number } : {}),
260
+ },
261
+ messages: [{
262
+ content,
263
+ peer_id: WHEEL_PEER,
264
+ created_at: ceremony.timestamp,
265
+ metadata: {
266
+ wheel_kind: 'ceremony',
267
+ wheel_id: ceremony.id,
268
+ type: ceremony.type,
269
+ direction: ceremony.direction,
270
+ ...(ceremony.source ? { source: ceremony.source } : {}),
271
+ },
272
+ }],
273
+ };
274
+ }
275
+ /** Where a diary entry lands: its ceremony, else its chronicle episode, else the wheel's standing session. */
276
+ export function sessionIdForDiaryEntry(entry) {
277
+ const ceremony = entry.metadata?.ceremony_id;
278
+ if (typeof ceremony === 'string' && ceremony)
279
+ return honchoIdFor(ceremony);
280
+ if (entry.chronicle)
281
+ return honchoIdFor(entry.chronicle);
282
+ return WHEEL_PEER;
283
+ }
284
+ /** A diary entry as one message in the participant's voice. */
285
+ export function projectDiaryEntry(entry) {
286
+ const [peerId, meta] = peerEntry(entry.participant);
287
+ const ceremony = entry.metadata?.ceremony_id;
288
+ const wheelSession = typeof ceremony === 'string' && ceremony ? ceremony : entry.chronicle ?? WHEEL_PEER;
289
+ const tags = Array.isArray(entry.metadata?.tags) ? entry.metadata.tags.map(String) : undefined;
290
+ return {
291
+ session_id: sessionIdForDiaryEntry(entry),
292
+ peers: { [peerId]: seat() },
293
+ peer_metadata: { [peerId]: meta },
294
+ session_metadata: {
295
+ wheel_kind: typeof ceremony === 'string' && ceremony ? 'ceremony' : entry.chronicle ? 'chronicle' : 'wheel',
296
+ wheel_id: wheelSession,
297
+ },
298
+ messages: [{
299
+ content: `[${entry.phase} · ${entry.entryType}] ${entry.content}` + list('Tags', tags),
300
+ peer_id: peerId,
301
+ created_at: entry.timestamp,
302
+ metadata: {
303
+ wheel_kind: 'diary',
304
+ wheel_id: entry.id,
305
+ phase: entry.phase,
306
+ entry_type: entry.entryType,
307
+ ...(entry.agent ? { agent: entry.agent } : {}),
308
+ ...(entry.chronicle ? { chronicle: entry.chronicle } : {}),
309
+ },
310
+ }],
311
+ };
312
+ }
313
+ /** Land a projection: ensure the workspace, peers and session, then append the messages. */
314
+ export async function project(client, projection) {
315
+ await client.workspaces.ensure();
316
+ for (const [id, metadata] of Object.entries(projection.peer_metadata))
317
+ await client.peers.ensure(id, metadata);
318
+ await client.sessions.ensure(projection.session_id, { peers: projection.peers, metadata: projection.session_metadata });
319
+ // A session that already existed keeps its seating; add any newcomer.
320
+ await client.sessions.addPeers(projection.session_id, projection.peers);
321
+ const stored = await client.sessions.addMessages(projection.session_id, projection.messages);
322
+ return { session_id: projection.session_id, peers: Object.keys(projection.peers), messages: stored.length };
323
+ }
324
+ export const MEMORY_PROJECTION_KIND = 'memory_projection';
325
+ export function memoryProjectionNode(p, id) {
326
+ const now = new Date().toISOString();
327
+ const nodeId = id ?? `node:knowledge:${MEMORY_PROJECTION_KIND}:${honchoIdFor(p.peerId)}:${Date.parse(p.generatedAt) || Date.now()}`;
328
+ const head = p.content.split('\n')[0].slice(0, 80);
329
+ return {
330
+ id: nodeId,
331
+ name: `${p.kind}: ${head}`,
332
+ type: 'knowledge',
333
+ // West: what has been worked over and made into understanding.
334
+ direction: 'west',
335
+ description: p.content,
336
+ metadata: {
337
+ kind: MEMORY_PROJECTION_KIND,
338
+ source: p.source,
339
+ source_event_ids: p.sourceEventIds,
340
+ peer_id: p.peerId,
341
+ projection_kind: p.kind,
342
+ status: p.status,
343
+ generated_at: p.generatedAt,
344
+ ...(p.derivedBy ? { derived_by: p.derivedBy } : {}),
345
+ },
346
+ created_at: now,
347
+ updated_at: now,
348
+ };
349
+ }
350
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAMH,+EAA+E;AAE/E,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAIxB;IACA;IAEA;IANlB,YACE,OAAe;IACf,sGAAsG;IACtF,MAAc,EACd,GAAW;IAC3B,yDAAyD;IACzC,IAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QALC,WAAM,GAAN,MAAM,CAAQ;QACd,QAAG,GAAH,GAAG,CAAQ;QAEX,SAAI,GAAJ,IAAI,CAAS;QAG7B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,+EAA+E;AAE/E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACzE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACvG,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,C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
+ "name": "@medicine-wheel/honcho",
3
+ "version": "0.15.0",
4
+ "type": "module",
5
+ "description": "The wheel's projection into Honcho — beats and ceremonies become Honcho messages, a speaker's evolving representation is recalled, and a derived conclusion is written back as a knowledge node. The wheel stays canonical; Honcho holds what the history has come to mean.",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "sideEffects": false,
17
+ "files": [
18
+ "dist",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "dev": "tsc --watch",
24
+ "lint": "tsc --noEmit",
25
+ "clean": "rm -rf dist",
26
+ "prepublishOnly": "npm run clean && npm run build"
27
+ },
28
+ "keywords": [
29
+ "medicine-wheel",
30
+ "honcho",
31
+ "memory",
32
+ "projection",
33
+ "peer-representation"
34
+ ],
35
+ "author": "IAIP Collaborative - Shawinigan, QC",
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/jgwill/medicine-wheel.git",
40
+ "directory": "src/honcho"
41
+ },
42
+ "dependencies": {
43
+ "@medicine-wheel/ontology-core": "^0.15.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^20.10.0",
47
+ "typescript": "^5.3.0"
48
+ }
49
+ }