@hexis-ai/engram-sdk 0.5.0 → 0.6.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/dist/client.d.ts +23 -1
- package/dist/client.js +21 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +58 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ScoredSession, SearchOptions, Session, SessionStep } from "@hexis-ai/engram-core";
|
|
2
2
|
import { type RefCandidate } from "./extract";
|
|
3
|
-
import type { AliasInfo, AliasUpsert, EventBatch, IdentityInfo, IdentityUpsert, PersonCreate, PersonInfo, PersonMap, PersonUpdate, SessionEvent, SessionInit } from "./types";
|
|
3
|
+
import type { AliasInfo, AliasUpsert, EventBatch, IdentityInfo, IdentityUpsert, MessageContentBlock, PersonCreate, PersonInfo, PersonMap, PersonUpdate, SessionEvent, SessionInit } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* Envelope returned by session endpoints. The persons map is deduped
|
|
6
6
|
* across whatever sessions the response carries so display info isn't
|
|
@@ -190,6 +190,28 @@ export declare class EngramSession {
|
|
|
190
190
|
* resolved by the host (engram-server does not resolve platform identities). */
|
|
191
191
|
addParticipant(personId: string): void;
|
|
192
192
|
setTitle(title: string): void;
|
|
193
|
+
/**
|
|
194
|
+
* Append a turn to the session. `content` is an Anthropic-shaped
|
|
195
|
+
* block array — the same shape monet stores in
|
|
196
|
+
* `conversation_messages.trace`, with `text` + `tool_use` +
|
|
197
|
+
* `tool_result` blocks. Re-emitting with the same `message_id` is
|
|
198
|
+
* intentional: the host may want to refresh content (e.g. after
|
|
199
|
+
* summarisation rewrites the user-visible text).
|
|
200
|
+
*/
|
|
201
|
+
recordMessage(input: {
|
|
202
|
+
role: string;
|
|
203
|
+
content: MessageContentBlock[];
|
|
204
|
+
message_id?: string;
|
|
205
|
+
model?: string;
|
|
206
|
+
tokens?: {
|
|
207
|
+
input: number;
|
|
208
|
+
output: number;
|
|
209
|
+
};
|
|
210
|
+
/** When omitted, the SDK stamps `at` to the wall-clock moment of
|
|
211
|
+
* enqueue — appropriate for live agent emission. Pass an explicit
|
|
212
|
+
* ISO string to mirror an existing host record's timestamp. */
|
|
213
|
+
at?: string;
|
|
214
|
+
}): void;
|
|
193
215
|
/** Mark the session ended and flush buffered events. */
|
|
194
216
|
end(): Promise<void>;
|
|
195
217
|
/**
|
package/dist/client.js
CHANGED
|
@@ -199,6 +199,27 @@ export class EngramSession {
|
|
|
199
199
|
};
|
|
200
200
|
this.enqueue(ev);
|
|
201
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Append a turn to the session. `content` is an Anthropic-shaped
|
|
204
|
+
* block array — the same shape monet stores in
|
|
205
|
+
* `conversation_messages.trace`, with `text` + `tool_use` +
|
|
206
|
+
* `tool_result` blocks. Re-emitting with the same `message_id` is
|
|
207
|
+
* intentional: the host may want to refresh content (e.g. after
|
|
208
|
+
* summarisation rewrites the user-visible text).
|
|
209
|
+
*/
|
|
210
|
+
recordMessage(input) {
|
|
211
|
+
const ev = {
|
|
212
|
+
type: "message",
|
|
213
|
+
seq: this.seq++,
|
|
214
|
+
at: input.at ?? new Date().toISOString(),
|
|
215
|
+
role: input.role,
|
|
216
|
+
content: input.content,
|
|
217
|
+
...(input.message_id !== undefined ? { message_id: input.message_id } : {}),
|
|
218
|
+
...(input.model !== undefined ? { model: input.model } : {}),
|
|
219
|
+
...(input.tokens !== undefined ? { tokens: input.tokens } : {}),
|
|
220
|
+
};
|
|
221
|
+
this.enqueue(ev);
|
|
222
|
+
}
|
|
202
223
|
/** Mark the session ended and flush buffered events. */
|
|
203
224
|
async end() {
|
|
204
225
|
if (this.ended)
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export { extractReferences, encodeResourceId, type RefCandidate, type ReferenceS
|
|
|
3
3
|
export { parseToolName, type ParsedToolName } from "./tool-name";
|
|
4
4
|
export { fetchIdToken, cloudRunIdTokenAuth } from "./id-token";
|
|
5
5
|
export { EngramAdmin, createAdminClient, type AdminClientOptions, type CreateWorkspaceInput, type CreateWorkspaceResult, type Workspace as AdminWorkspace, type ApiKey as AdminApiKey, type IssuedKey as AdminIssuedKey, } from "./admin";
|
|
6
|
-
export type { SessionInit, SessionAck, SessionEvent, StepEvent, ParticipantEvent, TitleEvent, EndEvent, EventBatch, PersonInfo, PersonCreate, PersonUpdate, PersonMap, AliasInfo, AliasUpsert, IdentityInfo, IdentityUpsert, } from "./types";
|
|
6
|
+
export type { SessionInit, SessionAck, SessionEvent, StepEvent, ParticipantEvent, TitleEvent, EndEvent, MessageContentBlock, MessageEvent, EventBatch, PersonInfo, PersonCreate, PersonUpdate, PersonMap, AliasInfo, AliasUpsert, IdentityInfo, IdentityUpsert, } from "./types";
|
package/dist/types.d.ts
CHANGED
|
@@ -54,7 +54,64 @@ export interface EndEvent {
|
|
|
54
54
|
seq: number;
|
|
55
55
|
at: string;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* One block within a message's content. Modelled after Anthropic's
|
|
59
|
+
* Messages API content blocks so SDK callers can pass agent runtime
|
|
60
|
+
* output through with zero translation. The discriminated union covers
|
|
61
|
+
* the standard block types; unknown `type` values pass through
|
|
62
|
+
* untouched so future Anthropic / vendor blocks don't require an SDK
|
|
63
|
+
* upgrade to ingest.
|
|
64
|
+
*/
|
|
65
|
+
export type MessageContentBlock = {
|
|
66
|
+
type: "text";
|
|
67
|
+
text: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: "tool_use";
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
input: unknown;
|
|
73
|
+
} | {
|
|
74
|
+
type: "tool_result";
|
|
75
|
+
tool_use_id: string;
|
|
76
|
+
content: unknown;
|
|
77
|
+
is_error?: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
type: "thinking";
|
|
80
|
+
thinking: string;
|
|
81
|
+
} | {
|
|
82
|
+
type: string;
|
|
83
|
+
[k: string]: unknown;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* One turn in a session — the canonical record of what someone or the
|
|
87
|
+
* agent actually said/did. Carries the full Anthropic-shaped content
|
|
88
|
+
* (text + tool_use + tool_result + thinking + …) so engram is lossless
|
|
89
|
+
* relative to monet's PG transcript.
|
|
90
|
+
*
|
|
91
|
+
* `role` is intentionally `string` rather than `user|assistant` because
|
|
92
|
+
* monet-style channel-originated turns use richer role labels (`system`,
|
|
93
|
+
* `resume`, identity refs like `slack:U…`). Tighten to a union on the
|
|
94
|
+
* read side if a consumer needs it; the wire stays permissive.
|
|
95
|
+
*/
|
|
96
|
+
export interface MessageEvent {
|
|
97
|
+
type: "message";
|
|
98
|
+
seq: number;
|
|
99
|
+
at: string;
|
|
100
|
+
/** Stable host-side id (monet's `conversation_messages` row id). The
|
|
101
|
+
* same logical message can be re-emitted idempotently if the host
|
|
102
|
+
* needs to update content (e.g. summarisation rewrite). */
|
|
103
|
+
message_id?: string;
|
|
104
|
+
role: string;
|
|
105
|
+
content: MessageContentBlock[];
|
|
106
|
+
/** Model + usage metadata captured at write time. Optional because
|
|
107
|
+
* inbound channel messages (slack, calendar) don't have these. */
|
|
108
|
+
model?: string;
|
|
109
|
+
tokens?: {
|
|
110
|
+
input: number;
|
|
111
|
+
output: number;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export type SessionEvent = StepEvent | ParticipantEvent | TitleEvent | EndEvent | MessageEvent;
|
|
58
115
|
export interface EventBatch {
|
|
59
116
|
events: SessionEvent[];
|
|
60
117
|
}
|