@z3rno/sdk 0.4.0 → 0.5.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/index.cjs +230 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +250 -1
- package/dist/index.d.ts +250 -1
- package/dist/index.js +225 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -989,6 +989,120 @@ declare const RefineJobStatusResponse: z.ZodObject<{
|
|
|
989
989
|
job_metadata?: Record<string, unknown> | undefined;
|
|
990
990
|
}>;
|
|
991
991
|
type RefineJobStatusResponse = z.infer<typeof RefineJobStatusResponse>;
|
|
992
|
+
/** Conversation metadata. */
|
|
993
|
+
declare const ConversationResponse: z.ZodObject<{
|
|
994
|
+
id: z.ZodString;
|
|
995
|
+
agent_id: z.ZodString;
|
|
996
|
+
user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
997
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
998
|
+
summary_cadence: z.ZodNumber;
|
|
999
|
+
turn_count: z.ZodNumber;
|
|
1000
|
+
last_summary_turn: z.ZodNumber;
|
|
1001
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1002
|
+
created_at: z.ZodString;
|
|
1003
|
+
updated_at: z.ZodString;
|
|
1004
|
+
}, "strip", z.ZodTypeAny, {
|
|
1005
|
+
metadata: Record<string, unknown>;
|
|
1006
|
+
id: string;
|
|
1007
|
+
agent_id: string;
|
|
1008
|
+
created_at: string;
|
|
1009
|
+
updated_at: string;
|
|
1010
|
+
summary_cadence: number;
|
|
1011
|
+
turn_count: number;
|
|
1012
|
+
last_summary_turn: number;
|
|
1013
|
+
user_id?: string | null | undefined;
|
|
1014
|
+
title?: string | null | undefined;
|
|
1015
|
+
}, {
|
|
1016
|
+
id: string;
|
|
1017
|
+
agent_id: string;
|
|
1018
|
+
created_at: string;
|
|
1019
|
+
updated_at: string;
|
|
1020
|
+
summary_cadence: number;
|
|
1021
|
+
turn_count: number;
|
|
1022
|
+
last_summary_turn: number;
|
|
1023
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1024
|
+
user_id?: string | null | undefined;
|
|
1025
|
+
title?: string | null | undefined;
|
|
1026
|
+
}>;
|
|
1027
|
+
type ConversationResponse = z.infer<typeof ConversationResponse>;
|
|
1028
|
+
/** Result of POST /v1/conversations/{id}/turns. */
|
|
1029
|
+
declare const TurnAddResponse: z.ZodObject<{
|
|
1030
|
+
turn_index: z.ZodNumber;
|
|
1031
|
+
needs_summary: z.ZodBoolean;
|
|
1032
|
+
}, "strip", z.ZodTypeAny, {
|
|
1033
|
+
turn_index: number;
|
|
1034
|
+
needs_summary: boolean;
|
|
1035
|
+
}, {
|
|
1036
|
+
turn_index: number;
|
|
1037
|
+
needs_summary: boolean;
|
|
1038
|
+
}>;
|
|
1039
|
+
type TurnAddResponse = z.infer<typeof TurnAddResponse>;
|
|
1040
|
+
/** One turn within a conversation. */
|
|
1041
|
+
declare const TurnResponse: z.ZodObject<{
|
|
1042
|
+
memory_id: z.ZodString;
|
|
1043
|
+
turn_index: z.ZodNumber;
|
|
1044
|
+
turn_role: z.ZodString;
|
|
1045
|
+
content: z.ZodString;
|
|
1046
|
+
created_at: z.ZodString;
|
|
1047
|
+
}, "strip", z.ZodTypeAny, {
|
|
1048
|
+
content: string;
|
|
1049
|
+
created_at: string;
|
|
1050
|
+
memory_id: string;
|
|
1051
|
+
turn_index: number;
|
|
1052
|
+
turn_role: string;
|
|
1053
|
+
}, {
|
|
1054
|
+
content: string;
|
|
1055
|
+
created_at: string;
|
|
1056
|
+
memory_id: string;
|
|
1057
|
+
turn_index: number;
|
|
1058
|
+
turn_role: string;
|
|
1059
|
+
}>;
|
|
1060
|
+
type TurnResponse = z.infer<typeof TurnResponse>;
|
|
1061
|
+
/** Paginated turn list. */
|
|
1062
|
+
declare const TurnListResponse: z.ZodObject<{
|
|
1063
|
+
turns: z.ZodArray<z.ZodObject<{
|
|
1064
|
+
memory_id: z.ZodString;
|
|
1065
|
+
turn_index: z.ZodNumber;
|
|
1066
|
+
turn_role: z.ZodString;
|
|
1067
|
+
content: z.ZodString;
|
|
1068
|
+
created_at: z.ZodString;
|
|
1069
|
+
}, "strip", z.ZodTypeAny, {
|
|
1070
|
+
content: string;
|
|
1071
|
+
created_at: string;
|
|
1072
|
+
memory_id: string;
|
|
1073
|
+
turn_index: number;
|
|
1074
|
+
turn_role: string;
|
|
1075
|
+
}, {
|
|
1076
|
+
content: string;
|
|
1077
|
+
created_at: string;
|
|
1078
|
+
memory_id: string;
|
|
1079
|
+
turn_index: number;
|
|
1080
|
+
turn_role: string;
|
|
1081
|
+
}>, "many">;
|
|
1082
|
+
total: z.ZodNumber;
|
|
1083
|
+
conversation_id: z.ZodString;
|
|
1084
|
+
}, "strip", z.ZodTypeAny, {
|
|
1085
|
+
total: number;
|
|
1086
|
+
turns: {
|
|
1087
|
+
content: string;
|
|
1088
|
+
created_at: string;
|
|
1089
|
+
memory_id: string;
|
|
1090
|
+
turn_index: number;
|
|
1091
|
+
turn_role: string;
|
|
1092
|
+
}[];
|
|
1093
|
+
conversation_id: string;
|
|
1094
|
+
}, {
|
|
1095
|
+
total: number;
|
|
1096
|
+
turns: {
|
|
1097
|
+
content: string;
|
|
1098
|
+
created_at: string;
|
|
1099
|
+
memory_id: string;
|
|
1100
|
+
turn_index: number;
|
|
1101
|
+
turn_role: string;
|
|
1102
|
+
}[];
|
|
1103
|
+
conversation_id: string;
|
|
1104
|
+
}>;
|
|
1105
|
+
type TurnListResponse = z.infer<typeof TurnListResponse>;
|
|
992
1106
|
|
|
993
1107
|
/**
|
|
994
1108
|
* Z3rno TypeScript SDK client.
|
|
@@ -1197,6 +1311,11 @@ declare class Z3rnoClient {
|
|
|
1197
1311
|
* `sentence-transformers` on the server side.
|
|
1198
1312
|
*/
|
|
1199
1313
|
rerank?: boolean;
|
|
1314
|
+
/**
|
|
1315
|
+
* Phase G slice 2: scope recall to a single conversation. Older
|
|
1316
|
+
* servers ignore the field.
|
|
1317
|
+
*/
|
|
1318
|
+
conversationId?: string;
|
|
1200
1319
|
}): Promise<RecallResponse>;
|
|
1201
1320
|
/**
|
|
1202
1321
|
* Forgets (deletes) one or more memories.
|
|
@@ -1418,6 +1537,33 @@ declare class Z3rnoClient {
|
|
|
1418
1537
|
datasetId?: string;
|
|
1419
1538
|
}): Promise<RefineJobResponse>;
|
|
1420
1539
|
getRefineStatus(jobId: string): Promise<RefineJobStatusResponse>;
|
|
1540
|
+
/**
|
|
1541
|
+
* Open a new conversation. Returns the conversation row including
|
|
1542
|
+
* the assigned `id`, which subsequent `recall`s and `addTurn`s
|
|
1543
|
+
* reference. The `summaryCadence` controls how often the server
|
|
1544
|
+
* flags the conversation for summarization.
|
|
1545
|
+
*/
|
|
1546
|
+
createConversation(params: {
|
|
1547
|
+
agentId: string;
|
|
1548
|
+
userId?: string;
|
|
1549
|
+
title?: string;
|
|
1550
|
+
summaryCadence?: number;
|
|
1551
|
+
metadata?: Record<string, unknown>;
|
|
1552
|
+
}): Promise<ConversationResponse>;
|
|
1553
|
+
getConversation(conversationId: string): Promise<ConversationResponse>;
|
|
1554
|
+
/**
|
|
1555
|
+
* Stamp an existing Memo as the next turn of the conversation.
|
|
1556
|
+
* Returns the assigned `turn_index` plus `needs_summary` — when
|
|
1557
|
+
* `true`, the conversation has crossed its cadence threshold.
|
|
1558
|
+
*/
|
|
1559
|
+
addTurn(conversationId: string, params: {
|
|
1560
|
+
memoryId: string;
|
|
1561
|
+
turnRole: string;
|
|
1562
|
+
}): Promise<TurnAddResponse>;
|
|
1563
|
+
listTurns(conversationId: string, params?: {
|
|
1564
|
+
afterTurn?: number;
|
|
1565
|
+
limit?: number;
|
|
1566
|
+
}): Promise<TurnListResponse>;
|
|
1421
1567
|
private request;
|
|
1422
1568
|
private sleep;
|
|
1423
1569
|
private handleResponse;
|
|
@@ -1622,4 +1768,107 @@ declare class Z3rnoConnectionError extends Z3rnoError {
|
|
|
1622
1768
|
constructor(message: string);
|
|
1623
1769
|
}
|
|
1624
1770
|
|
|
1625
|
-
|
|
1771
|
+
/**
|
|
1772
|
+
* Vercel AI SDK adapter for Z3rno (Phase G slice 3).
|
|
1773
|
+
*
|
|
1774
|
+
* Vercel AI SDK accepts a plain `CoreMessage[]` history; this adapter
|
|
1775
|
+
* loads + persists that history through Z3rno conversations. Drop the
|
|
1776
|
+
* `messages` accessor straight into `streamText` / `generateText`,
|
|
1777
|
+
* call `appendUserMessage` / `appendAssistantMessage` after each turn,
|
|
1778
|
+
* and Z3rno handles ordering + recall.
|
|
1779
|
+
*
|
|
1780
|
+
* Zero hard dependency on the `ai` package — we duck-type on the
|
|
1781
|
+
* minimal `CoreMessage` shape (`{ role, content }`).
|
|
1782
|
+
*/
|
|
1783
|
+
|
|
1784
|
+
type Z3rnoMessageRole = "user" | "assistant" | "system" | "tool";
|
|
1785
|
+
/** Subset of Vercel `ai` `CoreMessage` the adapter needs. */
|
|
1786
|
+
interface CoreMessage {
|
|
1787
|
+
role: Z3rnoMessageRole;
|
|
1788
|
+
content: string;
|
|
1789
|
+
}
|
|
1790
|
+
interface Z3rnoVercelMemoryOptions {
|
|
1791
|
+
client: Z3rnoClient;
|
|
1792
|
+
agentId: string;
|
|
1793
|
+
/** When set, recall + persisted turns are scoped to this Z3rno conversation. */
|
|
1794
|
+
conversationId?: string;
|
|
1795
|
+
/** Max history slice to load. Default 50. */
|
|
1796
|
+
topK?: number;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Lightweight history adapter you can hand straight to Vercel AI SDK
|
|
1800
|
+
* helpers. `await mem.messages()` returns a CoreMessage[] ready to
|
|
1801
|
+
* pass to `streamText({ messages: ... })`. After each turn, call
|
|
1802
|
+
* `appendUserMessage` / `appendAssistantMessage` so future recalls
|
|
1803
|
+
* see the latest state.
|
|
1804
|
+
*/
|
|
1805
|
+
declare class Z3rnoVercelMemory {
|
|
1806
|
+
private readonly client;
|
|
1807
|
+
private readonly agentId;
|
|
1808
|
+
private readonly conversationId;
|
|
1809
|
+
private readonly topK;
|
|
1810
|
+
constructor(options: Z3rnoVercelMemoryOptions);
|
|
1811
|
+
messages(): Promise<CoreMessage[]>;
|
|
1812
|
+
appendUserMessage(content: string): Promise<void>;
|
|
1813
|
+
appendAssistantMessage(content: string): Promise<void>;
|
|
1814
|
+
appendToolMessage(content: string): Promise<void>;
|
|
1815
|
+
private append;
|
|
1816
|
+
private normaliseRole;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* Mastra adapter for Z3rno (Phase G slice 3).
|
|
1821
|
+
*
|
|
1822
|
+
* Mastra exposes a `MastraMemory`-shaped interface — see
|
|
1823
|
+
* https://mastra.ai/docs/agents/memory. This adapter implements
|
|
1824
|
+
* the same surface (`getMessages` / `addMessage` / `clear`) using
|
|
1825
|
+
* Z3rno conversations as the backing store.
|
|
1826
|
+
*
|
|
1827
|
+
* Zero hard dependency on the `@mastra/core` package — we provide
|
|
1828
|
+
* the typed surface and Mastra's runtime accepts any conforming
|
|
1829
|
+
* object.
|
|
1830
|
+
*/
|
|
1831
|
+
|
|
1832
|
+
type MastraRole = "user" | "assistant" | "system" | "tool";
|
|
1833
|
+
interface MastraMessage {
|
|
1834
|
+
role: MastraRole;
|
|
1835
|
+
content: string;
|
|
1836
|
+
threadId?: string;
|
|
1837
|
+
resourceId?: string;
|
|
1838
|
+
}
|
|
1839
|
+
interface Z3rnoMastraMemoryOptions {
|
|
1840
|
+
client: Z3rnoClient;
|
|
1841
|
+
agentId: string;
|
|
1842
|
+
/** Mastra's thread is Z3rno's conversation; supply or look up by threadId. */
|
|
1843
|
+
conversationId?: string;
|
|
1844
|
+
topK?: number;
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Mastra-compatible memory backed by Z3rno conversations. Plug into
|
|
1848
|
+
* a Mastra `Agent`:
|
|
1849
|
+
*
|
|
1850
|
+
* const memory = new Z3rnoMastraMemory({ client, agentId, conversationId });
|
|
1851
|
+
* const agent = new Agent({ name: "support", memory });
|
|
1852
|
+
*/
|
|
1853
|
+
declare class Z3rnoMastraMemory {
|
|
1854
|
+
private readonly client;
|
|
1855
|
+
private readonly agentId;
|
|
1856
|
+
private readonly conversationId;
|
|
1857
|
+
private readonly topK;
|
|
1858
|
+
constructor(options: Z3rnoMastraMemoryOptions);
|
|
1859
|
+
/** Mastra contract: return ordered prior messages for the thread. */
|
|
1860
|
+
getMessages(_args?: {
|
|
1861
|
+
limit?: number;
|
|
1862
|
+
}): Promise<MastraMessage[]>;
|
|
1863
|
+
/** Mastra contract: persist one message. */
|
|
1864
|
+
addMessage(message: MastraMessage): Promise<void>;
|
|
1865
|
+
/**
|
|
1866
|
+
* Mastra `clear()` — deliberate no-op. Z3rno keeps the source of
|
|
1867
|
+
* truth and recall is already scoped per conversation; flushing
|
|
1868
|
+
* the thread would risk losing audit-relevant history.
|
|
1869
|
+
*/
|
|
1870
|
+
clear(): Promise<void>;
|
|
1871
|
+
private normaliseRole;
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
export { AuditEntry, AuditPageResponse, AuthenticationError, BatchStoreResponse, ConversationResponse, type CoreMessage, DistillJobResponse, DistillJobStatusResponse, EndSessionResponse, ForgetResponse, IngestJobResponse, IngestJobStatusResponse, type MastraMessage, type MastraRole, MemoryHistoryResponse, MemoryResponse, MemoryType, MemoryVersion, NotFoundError, RateLimitError, RecallResponse, RecallResultItem, RefineJobResponse, RefineJobStatusResponse, RelationshipType, RetrievalStrategy, ServerError, SessionResponse, StoreMemoryRequest, TurnAddResponse, TurnListResponse, TurnResponse, ValidationError, Z3rnoClient, type Z3rnoClientConfig, Z3rnoConnectionError, Z3rnoError, Z3rnoMastraMemory, type Z3rnoMastraMemoryOptions, type Z3rnoMessageRole, Z3rnoTimeoutError, Z3rnoVercelMemory, type Z3rnoVercelMemoryOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -989,6 +989,120 @@ declare const RefineJobStatusResponse: z.ZodObject<{
|
|
|
989
989
|
job_metadata?: Record<string, unknown> | undefined;
|
|
990
990
|
}>;
|
|
991
991
|
type RefineJobStatusResponse = z.infer<typeof RefineJobStatusResponse>;
|
|
992
|
+
/** Conversation metadata. */
|
|
993
|
+
declare const ConversationResponse: z.ZodObject<{
|
|
994
|
+
id: z.ZodString;
|
|
995
|
+
agent_id: z.ZodString;
|
|
996
|
+
user_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
997
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
998
|
+
summary_cadence: z.ZodNumber;
|
|
999
|
+
turn_count: z.ZodNumber;
|
|
1000
|
+
last_summary_turn: z.ZodNumber;
|
|
1001
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1002
|
+
created_at: z.ZodString;
|
|
1003
|
+
updated_at: z.ZodString;
|
|
1004
|
+
}, "strip", z.ZodTypeAny, {
|
|
1005
|
+
metadata: Record<string, unknown>;
|
|
1006
|
+
id: string;
|
|
1007
|
+
agent_id: string;
|
|
1008
|
+
created_at: string;
|
|
1009
|
+
updated_at: string;
|
|
1010
|
+
summary_cadence: number;
|
|
1011
|
+
turn_count: number;
|
|
1012
|
+
last_summary_turn: number;
|
|
1013
|
+
user_id?: string | null | undefined;
|
|
1014
|
+
title?: string | null | undefined;
|
|
1015
|
+
}, {
|
|
1016
|
+
id: string;
|
|
1017
|
+
agent_id: string;
|
|
1018
|
+
created_at: string;
|
|
1019
|
+
updated_at: string;
|
|
1020
|
+
summary_cadence: number;
|
|
1021
|
+
turn_count: number;
|
|
1022
|
+
last_summary_turn: number;
|
|
1023
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1024
|
+
user_id?: string | null | undefined;
|
|
1025
|
+
title?: string | null | undefined;
|
|
1026
|
+
}>;
|
|
1027
|
+
type ConversationResponse = z.infer<typeof ConversationResponse>;
|
|
1028
|
+
/** Result of POST /v1/conversations/{id}/turns. */
|
|
1029
|
+
declare const TurnAddResponse: z.ZodObject<{
|
|
1030
|
+
turn_index: z.ZodNumber;
|
|
1031
|
+
needs_summary: z.ZodBoolean;
|
|
1032
|
+
}, "strip", z.ZodTypeAny, {
|
|
1033
|
+
turn_index: number;
|
|
1034
|
+
needs_summary: boolean;
|
|
1035
|
+
}, {
|
|
1036
|
+
turn_index: number;
|
|
1037
|
+
needs_summary: boolean;
|
|
1038
|
+
}>;
|
|
1039
|
+
type TurnAddResponse = z.infer<typeof TurnAddResponse>;
|
|
1040
|
+
/** One turn within a conversation. */
|
|
1041
|
+
declare const TurnResponse: z.ZodObject<{
|
|
1042
|
+
memory_id: z.ZodString;
|
|
1043
|
+
turn_index: z.ZodNumber;
|
|
1044
|
+
turn_role: z.ZodString;
|
|
1045
|
+
content: z.ZodString;
|
|
1046
|
+
created_at: z.ZodString;
|
|
1047
|
+
}, "strip", z.ZodTypeAny, {
|
|
1048
|
+
content: string;
|
|
1049
|
+
created_at: string;
|
|
1050
|
+
memory_id: string;
|
|
1051
|
+
turn_index: number;
|
|
1052
|
+
turn_role: string;
|
|
1053
|
+
}, {
|
|
1054
|
+
content: string;
|
|
1055
|
+
created_at: string;
|
|
1056
|
+
memory_id: string;
|
|
1057
|
+
turn_index: number;
|
|
1058
|
+
turn_role: string;
|
|
1059
|
+
}>;
|
|
1060
|
+
type TurnResponse = z.infer<typeof TurnResponse>;
|
|
1061
|
+
/** Paginated turn list. */
|
|
1062
|
+
declare const TurnListResponse: z.ZodObject<{
|
|
1063
|
+
turns: z.ZodArray<z.ZodObject<{
|
|
1064
|
+
memory_id: z.ZodString;
|
|
1065
|
+
turn_index: z.ZodNumber;
|
|
1066
|
+
turn_role: z.ZodString;
|
|
1067
|
+
content: z.ZodString;
|
|
1068
|
+
created_at: z.ZodString;
|
|
1069
|
+
}, "strip", z.ZodTypeAny, {
|
|
1070
|
+
content: string;
|
|
1071
|
+
created_at: string;
|
|
1072
|
+
memory_id: string;
|
|
1073
|
+
turn_index: number;
|
|
1074
|
+
turn_role: string;
|
|
1075
|
+
}, {
|
|
1076
|
+
content: string;
|
|
1077
|
+
created_at: string;
|
|
1078
|
+
memory_id: string;
|
|
1079
|
+
turn_index: number;
|
|
1080
|
+
turn_role: string;
|
|
1081
|
+
}>, "many">;
|
|
1082
|
+
total: z.ZodNumber;
|
|
1083
|
+
conversation_id: z.ZodString;
|
|
1084
|
+
}, "strip", z.ZodTypeAny, {
|
|
1085
|
+
total: number;
|
|
1086
|
+
turns: {
|
|
1087
|
+
content: string;
|
|
1088
|
+
created_at: string;
|
|
1089
|
+
memory_id: string;
|
|
1090
|
+
turn_index: number;
|
|
1091
|
+
turn_role: string;
|
|
1092
|
+
}[];
|
|
1093
|
+
conversation_id: string;
|
|
1094
|
+
}, {
|
|
1095
|
+
total: number;
|
|
1096
|
+
turns: {
|
|
1097
|
+
content: string;
|
|
1098
|
+
created_at: string;
|
|
1099
|
+
memory_id: string;
|
|
1100
|
+
turn_index: number;
|
|
1101
|
+
turn_role: string;
|
|
1102
|
+
}[];
|
|
1103
|
+
conversation_id: string;
|
|
1104
|
+
}>;
|
|
1105
|
+
type TurnListResponse = z.infer<typeof TurnListResponse>;
|
|
992
1106
|
|
|
993
1107
|
/**
|
|
994
1108
|
* Z3rno TypeScript SDK client.
|
|
@@ -1197,6 +1311,11 @@ declare class Z3rnoClient {
|
|
|
1197
1311
|
* `sentence-transformers` on the server side.
|
|
1198
1312
|
*/
|
|
1199
1313
|
rerank?: boolean;
|
|
1314
|
+
/**
|
|
1315
|
+
* Phase G slice 2: scope recall to a single conversation. Older
|
|
1316
|
+
* servers ignore the field.
|
|
1317
|
+
*/
|
|
1318
|
+
conversationId?: string;
|
|
1200
1319
|
}): Promise<RecallResponse>;
|
|
1201
1320
|
/**
|
|
1202
1321
|
* Forgets (deletes) one or more memories.
|
|
@@ -1418,6 +1537,33 @@ declare class Z3rnoClient {
|
|
|
1418
1537
|
datasetId?: string;
|
|
1419
1538
|
}): Promise<RefineJobResponse>;
|
|
1420
1539
|
getRefineStatus(jobId: string): Promise<RefineJobStatusResponse>;
|
|
1540
|
+
/**
|
|
1541
|
+
* Open a new conversation. Returns the conversation row including
|
|
1542
|
+
* the assigned `id`, which subsequent `recall`s and `addTurn`s
|
|
1543
|
+
* reference. The `summaryCadence` controls how often the server
|
|
1544
|
+
* flags the conversation for summarization.
|
|
1545
|
+
*/
|
|
1546
|
+
createConversation(params: {
|
|
1547
|
+
agentId: string;
|
|
1548
|
+
userId?: string;
|
|
1549
|
+
title?: string;
|
|
1550
|
+
summaryCadence?: number;
|
|
1551
|
+
metadata?: Record<string, unknown>;
|
|
1552
|
+
}): Promise<ConversationResponse>;
|
|
1553
|
+
getConversation(conversationId: string): Promise<ConversationResponse>;
|
|
1554
|
+
/**
|
|
1555
|
+
* Stamp an existing Memo as the next turn of the conversation.
|
|
1556
|
+
* Returns the assigned `turn_index` plus `needs_summary` — when
|
|
1557
|
+
* `true`, the conversation has crossed its cadence threshold.
|
|
1558
|
+
*/
|
|
1559
|
+
addTurn(conversationId: string, params: {
|
|
1560
|
+
memoryId: string;
|
|
1561
|
+
turnRole: string;
|
|
1562
|
+
}): Promise<TurnAddResponse>;
|
|
1563
|
+
listTurns(conversationId: string, params?: {
|
|
1564
|
+
afterTurn?: number;
|
|
1565
|
+
limit?: number;
|
|
1566
|
+
}): Promise<TurnListResponse>;
|
|
1421
1567
|
private request;
|
|
1422
1568
|
private sleep;
|
|
1423
1569
|
private handleResponse;
|
|
@@ -1622,4 +1768,107 @@ declare class Z3rnoConnectionError extends Z3rnoError {
|
|
|
1622
1768
|
constructor(message: string);
|
|
1623
1769
|
}
|
|
1624
1770
|
|
|
1625
|
-
|
|
1771
|
+
/**
|
|
1772
|
+
* Vercel AI SDK adapter for Z3rno (Phase G slice 3).
|
|
1773
|
+
*
|
|
1774
|
+
* Vercel AI SDK accepts a plain `CoreMessage[]` history; this adapter
|
|
1775
|
+
* loads + persists that history through Z3rno conversations. Drop the
|
|
1776
|
+
* `messages` accessor straight into `streamText` / `generateText`,
|
|
1777
|
+
* call `appendUserMessage` / `appendAssistantMessage` after each turn,
|
|
1778
|
+
* and Z3rno handles ordering + recall.
|
|
1779
|
+
*
|
|
1780
|
+
* Zero hard dependency on the `ai` package — we duck-type on the
|
|
1781
|
+
* minimal `CoreMessage` shape (`{ role, content }`).
|
|
1782
|
+
*/
|
|
1783
|
+
|
|
1784
|
+
type Z3rnoMessageRole = "user" | "assistant" | "system" | "tool";
|
|
1785
|
+
/** Subset of Vercel `ai` `CoreMessage` the adapter needs. */
|
|
1786
|
+
interface CoreMessage {
|
|
1787
|
+
role: Z3rnoMessageRole;
|
|
1788
|
+
content: string;
|
|
1789
|
+
}
|
|
1790
|
+
interface Z3rnoVercelMemoryOptions {
|
|
1791
|
+
client: Z3rnoClient;
|
|
1792
|
+
agentId: string;
|
|
1793
|
+
/** When set, recall + persisted turns are scoped to this Z3rno conversation. */
|
|
1794
|
+
conversationId?: string;
|
|
1795
|
+
/** Max history slice to load. Default 50. */
|
|
1796
|
+
topK?: number;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Lightweight history adapter you can hand straight to Vercel AI SDK
|
|
1800
|
+
* helpers. `await mem.messages()` returns a CoreMessage[] ready to
|
|
1801
|
+
* pass to `streamText({ messages: ... })`. After each turn, call
|
|
1802
|
+
* `appendUserMessage` / `appendAssistantMessage` so future recalls
|
|
1803
|
+
* see the latest state.
|
|
1804
|
+
*/
|
|
1805
|
+
declare class Z3rnoVercelMemory {
|
|
1806
|
+
private readonly client;
|
|
1807
|
+
private readonly agentId;
|
|
1808
|
+
private readonly conversationId;
|
|
1809
|
+
private readonly topK;
|
|
1810
|
+
constructor(options: Z3rnoVercelMemoryOptions);
|
|
1811
|
+
messages(): Promise<CoreMessage[]>;
|
|
1812
|
+
appendUserMessage(content: string): Promise<void>;
|
|
1813
|
+
appendAssistantMessage(content: string): Promise<void>;
|
|
1814
|
+
appendToolMessage(content: string): Promise<void>;
|
|
1815
|
+
private append;
|
|
1816
|
+
private normaliseRole;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* Mastra adapter for Z3rno (Phase G slice 3).
|
|
1821
|
+
*
|
|
1822
|
+
* Mastra exposes a `MastraMemory`-shaped interface — see
|
|
1823
|
+
* https://mastra.ai/docs/agents/memory. This adapter implements
|
|
1824
|
+
* the same surface (`getMessages` / `addMessage` / `clear`) using
|
|
1825
|
+
* Z3rno conversations as the backing store.
|
|
1826
|
+
*
|
|
1827
|
+
* Zero hard dependency on the `@mastra/core` package — we provide
|
|
1828
|
+
* the typed surface and Mastra's runtime accepts any conforming
|
|
1829
|
+
* object.
|
|
1830
|
+
*/
|
|
1831
|
+
|
|
1832
|
+
type MastraRole = "user" | "assistant" | "system" | "tool";
|
|
1833
|
+
interface MastraMessage {
|
|
1834
|
+
role: MastraRole;
|
|
1835
|
+
content: string;
|
|
1836
|
+
threadId?: string;
|
|
1837
|
+
resourceId?: string;
|
|
1838
|
+
}
|
|
1839
|
+
interface Z3rnoMastraMemoryOptions {
|
|
1840
|
+
client: Z3rnoClient;
|
|
1841
|
+
agentId: string;
|
|
1842
|
+
/** Mastra's thread is Z3rno's conversation; supply or look up by threadId. */
|
|
1843
|
+
conversationId?: string;
|
|
1844
|
+
topK?: number;
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Mastra-compatible memory backed by Z3rno conversations. Plug into
|
|
1848
|
+
* a Mastra `Agent`:
|
|
1849
|
+
*
|
|
1850
|
+
* const memory = new Z3rnoMastraMemory({ client, agentId, conversationId });
|
|
1851
|
+
* const agent = new Agent({ name: "support", memory });
|
|
1852
|
+
*/
|
|
1853
|
+
declare class Z3rnoMastraMemory {
|
|
1854
|
+
private readonly client;
|
|
1855
|
+
private readonly agentId;
|
|
1856
|
+
private readonly conversationId;
|
|
1857
|
+
private readonly topK;
|
|
1858
|
+
constructor(options: Z3rnoMastraMemoryOptions);
|
|
1859
|
+
/** Mastra contract: return ordered prior messages for the thread. */
|
|
1860
|
+
getMessages(_args?: {
|
|
1861
|
+
limit?: number;
|
|
1862
|
+
}): Promise<MastraMessage[]>;
|
|
1863
|
+
/** Mastra contract: persist one message. */
|
|
1864
|
+
addMessage(message: MastraMessage): Promise<void>;
|
|
1865
|
+
/**
|
|
1866
|
+
* Mastra `clear()` — deliberate no-op. Z3rno keeps the source of
|
|
1867
|
+
* truth and recall is already scoped per conversation; flushing
|
|
1868
|
+
* the thread would risk losing audit-relevant history.
|
|
1869
|
+
*/
|
|
1870
|
+
clear(): Promise<void>;
|
|
1871
|
+
private normaliseRole;
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
export { AuditEntry, AuditPageResponse, AuthenticationError, BatchStoreResponse, ConversationResponse, type CoreMessage, DistillJobResponse, DistillJobStatusResponse, EndSessionResponse, ForgetResponse, IngestJobResponse, IngestJobStatusResponse, type MastraMessage, type MastraRole, MemoryHistoryResponse, MemoryResponse, MemoryType, MemoryVersion, NotFoundError, RateLimitError, RecallResponse, RecallResultItem, RefineJobResponse, RefineJobStatusResponse, RelationshipType, RetrievalStrategy, ServerError, SessionResponse, StoreMemoryRequest, TurnAddResponse, TurnListResponse, TurnResponse, ValidationError, Z3rnoClient, type Z3rnoClientConfig, Z3rnoConnectionError, Z3rnoError, Z3rnoMastraMemory, type Z3rnoMastraMemoryOptions, type Z3rnoMessageRole, Z3rnoTimeoutError, Z3rnoVercelMemory, type Z3rnoVercelMemoryOptions };
|