conversationalist 0.0.9 → 0.0.11
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 +148 -30
- package/dist/adapters/anthropic/index.d.ts.map +1 -1
- package/dist/adapters/anthropic/index.js +255 -2
- package/dist/adapters/anthropic/index.js.map +8 -4
- package/dist/adapters/gemini/index.d.ts.map +1 -1
- package/dist/adapters/gemini/index.js +255 -3
- package/dist/adapters/gemini/index.js.map +8 -4
- package/dist/adapters/openai/index.d.ts.map +1 -1
- package/dist/adapters/openai/index.js +247 -3
- package/dist/adapters/openai/index.js.map +8 -4
- package/dist/context.d.ts +6 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/conversation/append.d.ts +5 -0
- package/dist/conversation/append.d.ts.map +1 -1
- package/dist/conversation/create.d.ts +9 -0
- package/dist/conversation/create.d.ts.map +1 -1
- package/dist/conversation/index.d.ts +8 -3
- package/dist/conversation/index.d.ts.map +1 -1
- package/dist/conversation/integrity.d.ts +16 -0
- package/dist/conversation/integrity.d.ts.map +1 -0
- package/dist/conversation/modify.d.ts +8 -2
- package/dist/conversation/modify.d.ts.map +1 -1
- package/dist/conversation/serialization.d.ts +0 -17
- package/dist/conversation/serialization.d.ts.map +1 -1
- package/dist/conversation/system-messages.d.ts.map +1 -1
- package/dist/conversation/tool-interactions.d.ts +45 -0
- package/dist/conversation/tool-interactions.d.ts.map +1 -0
- package/dist/conversation/transform.d.ts.map +1 -1
- package/dist/conversation/validation.d.ts +8 -0
- package/dist/conversation/validation.d.ts.map +1 -0
- package/dist/errors.d.ts +6 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/export/index.js +249 -12
- package/dist/export/index.js.map +10 -6
- package/dist/guards.d.ts +13 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/history.d.ts +21 -8
- package/dist/history.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2212 -259
- package/dist/index.js.map +26 -13
- package/dist/markdown/index.js +2169 -253
- package/dist/markdown/index.js.map +23 -12
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +38 -22
- package/dist/schemas/index.js.map +3 -3
- package/dist/schemas.d.ts +17 -37
- package/dist/schemas.d.ts.map +1 -1
- package/dist/streaming.d.ts.map +1 -1
- package/dist/types.d.ts +0 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/index.d.ts +0 -1
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/markdown.d.ts.map +1 -1
- package/dist/utilities/tool-calls.d.ts +2 -6
- package/dist/utilities/tool-calls.d.ts.map +1 -1
- package/dist/utilities/tool-results.d.ts.map +1 -1
- package/dist/utilities/transient.d.ts.map +1 -1
- package/dist/utilities.d.ts +0 -1
- package/dist/utilities.d.ts.map +1 -1
- package/dist/versioning/index.d.ts +0 -1
- package/dist/versioning/index.d.ts.map +1 -1
- package/dist/versioning/index.js +1 -52
- package/dist/versioning/index.js.map +4 -5
- package/dist/with-conversation.d.ts +4 -1
- package/dist/with-conversation.d.ts.map +1 -1
- package/package.json +7 -4
- package/dist/conversation.d.ts +0 -109
- package/dist/conversation.d.ts.map +0 -1
package/dist/schemas/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { conversationSchema, conversationShape, jsonValueSchema, messageInputSchema,
|
|
1
|
+
export { conversationSchema, conversationShape, jsonValueSchema, messageInputSchema, messageRoleSchema, messageSchema, multiModalContentSchema, tokenUsageSchema, toolCallSchema, toolResultSchema, } from '../schemas';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/schemas/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// src/schemas.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
var isPlainObject = (value) => {
|
|
4
|
+
if (!value || typeof value !== "object")
|
|
5
|
+
return false;
|
|
6
|
+
const prototype = Reflect.getPrototypeOf(value);
|
|
7
|
+
return prototype === Object.prototype || prototype === null;
|
|
8
|
+
};
|
|
3
9
|
function toMultiModalContent(value) {
|
|
4
10
|
const result = { type: value.type };
|
|
5
11
|
if (value.text !== undefined)
|
|
@@ -10,14 +16,28 @@ function toMultiModalContent(value) {
|
|
|
10
16
|
result.mimeType = value.mimeType;
|
|
11
17
|
return result;
|
|
12
18
|
}
|
|
13
|
-
var jsonValueSchema = z.lazy(() =>
|
|
14
|
-
z.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
var jsonValueSchema = z.lazy(() => {
|
|
20
|
+
const jsonObjectSchema = z.preprocess((value, ctx) => {
|
|
21
|
+
if (!isPlainObject(value)) {
|
|
22
|
+
ctx.addIssue({
|
|
23
|
+
code: z.ZodIssueCode.custom,
|
|
24
|
+
message: "expected a plain object"
|
|
25
|
+
});
|
|
26
|
+
return z.NEVER;
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}, z.record(z.string(), jsonValueSchema));
|
|
30
|
+
return z.union([
|
|
31
|
+
z.string(),
|
|
32
|
+
z.number().refine((value) => Number.isFinite(value), {
|
|
33
|
+
message: "expected a finite number"
|
|
34
|
+
}),
|
|
35
|
+
z.boolean(),
|
|
36
|
+
z.null(),
|
|
37
|
+
z.array(jsonValueSchema),
|
|
38
|
+
jsonObjectSchema
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
21
41
|
var multiModalContentSchema = z.discriminatedUnion("type", [
|
|
22
42
|
z.object({
|
|
23
43
|
type: z.literal("text"),
|
|
@@ -43,16 +63,12 @@ var toolCallSchema = z.object({
|
|
|
43
63
|
id: z.string(),
|
|
44
64
|
name: z.string(),
|
|
45
65
|
arguments: jsonValueSchema
|
|
46
|
-
});
|
|
66
|
+
}).strict();
|
|
47
67
|
var toolResultSchema = z.object({
|
|
48
68
|
callId: z.string(),
|
|
49
69
|
outcome: z.enum(["success", "error"]),
|
|
50
|
-
content: jsonValueSchema
|
|
51
|
-
|
|
52
|
-
toolName: z.string().optional(),
|
|
53
|
-
result: jsonValueSchema.optional(),
|
|
54
|
-
error: z.string().optional()
|
|
55
|
-
});
|
|
70
|
+
content: jsonValueSchema
|
|
71
|
+
}).strict();
|
|
56
72
|
var tokenUsageSchema = z.object({
|
|
57
73
|
prompt: z.number().int().min(0),
|
|
58
74
|
completion: z.number().int().min(0),
|
|
@@ -67,8 +83,8 @@ var messageInputSchema = z.object({
|
|
|
67
83
|
toolResult: toolResultSchema.optional(),
|
|
68
84
|
tokenUsage: tokenUsageSchema.optional(),
|
|
69
85
|
goalCompleted: z.boolean().optional()
|
|
70
|
-
});
|
|
71
|
-
var
|
|
86
|
+
}).strict();
|
|
87
|
+
var messageSchema = z.object({
|
|
72
88
|
id: z.string(),
|
|
73
89
|
role: messageRoleSchema,
|
|
74
90
|
content: z.union([z.string(), z.array(multiModalContentSchema)]),
|
|
@@ -80,7 +96,7 @@ var messageJSONSchema = z.object({
|
|
|
80
96
|
toolResult: toolResultSchema.optional(),
|
|
81
97
|
tokenUsage: tokenUsageSchema.optional(),
|
|
82
98
|
goalCompleted: z.boolean().optional()
|
|
83
|
-
}).
|
|
99
|
+
}).strict();
|
|
84
100
|
var conversationStatusSchema = z.enum([
|
|
85
101
|
"active",
|
|
86
102
|
"archived",
|
|
@@ -93,22 +109,22 @@ var conversationShape = {
|
|
|
93
109
|
status: conversationStatusSchema,
|
|
94
110
|
metadata: z.record(z.string(), jsonValueSchema),
|
|
95
111
|
ids: z.array(z.string()),
|
|
96
|
-
messages: z.record(z.string(),
|
|
112
|
+
messages: z.record(z.string(), messageSchema),
|
|
97
113
|
createdAt: z.string(),
|
|
98
114
|
updatedAt: z.string()
|
|
99
115
|
};
|
|
100
|
-
var conversationSchema = z.object(conversationShape);
|
|
116
|
+
var conversationSchema = z.object(conversationShape).strict();
|
|
101
117
|
export {
|
|
102
118
|
toolResultSchema,
|
|
103
119
|
toolCallSchema,
|
|
104
120
|
tokenUsageSchema,
|
|
105
121
|
multiModalContentSchema,
|
|
122
|
+
messageSchema,
|
|
106
123
|
messageRoleSchema,
|
|
107
|
-
messageJSONSchema,
|
|
108
124
|
messageInputSchema,
|
|
109
125
|
jsonValueSchema,
|
|
110
126
|
conversationShape,
|
|
111
127
|
conversationSchema
|
|
112
128
|
};
|
|
113
129
|
|
|
114
|
-
//# debugId=
|
|
130
|
+
//# debugId=4C03BFF9D6443A9164756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/schemas.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { MultiModalContent } from '@lasercat/homogenaize';\nimport { z } from 'zod';\n\nimport type {\n Conversation,\n ConversationStatus,\n JSONValue,\n Message,\n MessageInput,\n MessageRole,\n TokenUsage,\n ToolCall,\n ToolResult,\n} from './types';\n\ntype RawMultiModalContent = {\n type: 'text' | 'image';\n text?: string | undefined;\n url?: string | undefined;\n mimeType?: string | undefined;\n};\n\nfunction toMultiModalContent(value: RawMultiModalContent): MultiModalContent {\n const result: MultiModalContent = { type: value.type };\n if (value.text !== undefined) result.text = value.text;\n if (value.url !== undefined) result.url = value.url;\n if (value.mimeType !== undefined) result.mimeType = value.mimeType;\n return result;\n}\n\n/**\n * Zod schema for JSON-serializable values.\n */\nexport const jsonValueSchema: z.ZodType<JSONValue> = z.lazy(()
|
|
5
|
+
"import type { MultiModalContent } from '@lasercat/homogenaize';\nimport { z } from 'zod';\n\nimport type {\n Conversation,\n ConversationStatus,\n JSONValue,\n Message,\n MessageInput,\n MessageRole,\n TokenUsage,\n ToolCall,\n ToolResult,\n} from './types';\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (!value || typeof value !== 'object') return false;\n const prototype = Reflect.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n};\n\ntype RawMultiModalContent = {\n type: 'text' | 'image';\n text?: string | undefined;\n url?: string | undefined;\n mimeType?: string | undefined;\n};\n\nfunction toMultiModalContent(value: RawMultiModalContent): MultiModalContent {\n const result: MultiModalContent = { type: value.type };\n if (value.text !== undefined) result.text = value.text;\n if (value.url !== undefined) result.url = value.url;\n if (value.mimeType !== undefined) result.mimeType = value.mimeType;\n return result;\n}\n\n/**\n * Zod schema for JSON-serializable values.\n */\nexport const jsonValueSchema: z.ZodType<JSONValue> = z.lazy(() => {\n const jsonObjectSchema = z.preprocess(\n (value, ctx) => {\n if (!isPlainObject(value)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'expected a plain object',\n });\n return z.NEVER;\n }\n return value;\n },\n z.record(z.string(), jsonValueSchema),\n );\n\n return z.union([\n z.string(),\n z.number().refine((value) => Number.isFinite(value), {\n message: 'expected a finite number',\n }),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n jsonObjectSchema,\n ]);\n}) satisfies z.ZodType<JSONValue>;\n\n/**\n * Zod schema for multi-modal content parts (text or image).\n */\nexport const multiModalContentSchema = z\n .discriminatedUnion('type', [\n z.object({\n type: z.literal('text'),\n text: z.string(),\n }),\n z.object({\n type: z.literal('image'),\n url: z.string().url(),\n mimeType: z.string().optional(),\n text: z.string().optional(),\n }),\n ])\n .transform(toMultiModalContent) satisfies z.ZodType<MultiModalContent>;\n\n/**\n * Zod schema for valid message roles.\n */\nexport const messageRoleSchema = z.enum([\n 'user',\n 'assistant',\n 'system',\n 'developer',\n 'tool-use',\n 'tool-result',\n 'snapshot',\n]) satisfies z.ZodType<MessageRole>;\n\n/**\n * Zod schema for tool call metadata.\n */\nexport const toolCallSchema = z\n .object({\n id: z.string(),\n name: z.string(),\n arguments: jsonValueSchema,\n })\n .strict() satisfies z.ZodType<ToolCall>;\n\n/**\n * Zod schema for tool result metadata.\n */\nexport const toolResultSchema = z\n .object({\n callId: z.string(),\n outcome: z.enum(['success', 'error']),\n content: jsonValueSchema,\n })\n .strict() satisfies z.ZodType<ToolResult>;\n\n/**\n * Zod schema for token usage accounting.\n */\nexport const tokenUsageSchema = z.object({\n prompt: z.number().int().min(0),\n completion: z.number().int().min(0),\n total: z.number().int().min(0),\n}) satisfies z.ZodType<TokenUsage>;\n\n/**\n * Zod schema for message input payloads.\n */\nexport const messageInputSchema = z\n .object({\n role: messageRoleSchema,\n content: z.union([z.string(), z.array(multiModalContentSchema)]),\n metadata: z.record(z.string(), jsonValueSchema).optional(),\n hidden: z.boolean().optional(),\n toolCall: toolCallSchema.optional(),\n toolResult: toolResultSchema.optional(),\n tokenUsage: tokenUsageSchema.optional(),\n goalCompleted: z.boolean().optional(),\n })\n .strict() satisfies z.ZodType<MessageInput>;\n\n/**\n * Zod schema for messages.\n */\nexport const messageSchema = z\n .object({\n id: z.string(),\n role: messageRoleSchema,\n content: z.union([z.string(), z.array(multiModalContentSchema)]),\n position: z.number().int().min(0),\n createdAt: z.string(),\n metadata: z.record(z.string(), jsonValueSchema),\n hidden: z.boolean(),\n toolCall: toolCallSchema.optional(),\n toolResult: toolResultSchema.optional(),\n tokenUsage: tokenUsageSchema.optional(),\n goalCompleted: z.boolean().optional(),\n })\n .strict() satisfies z.ZodType<Message>;\n\n/**\n * Zod schema for conversation status values.\n */\nexport const conversationStatusSchema = z.enum([\n 'active',\n 'archived',\n 'deleted',\n]) satisfies z.ZodType<ConversationStatus>;\n\n/**\n * Raw conversation shape for storage systems that need direct access to fields.\n */\nexport const conversationShape = {\n schemaVersion: z.number().int().min(1),\n id: z.string(),\n title: z.string().optional(),\n status: conversationStatusSchema,\n metadata: z.record(z.string(), jsonValueSchema),\n ids: z.array(z.string()),\n messages: z.record(z.string(), messageSchema),\n createdAt: z.string(),\n updatedAt: z.string(),\n} as const;\n\n/**\n * Zod schema for serialized conversations.\n */\nexport const conversationSchema = z\n .object(conversationShape)\n .strict() satisfies z.ZodType<Conversation>;\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AACA;
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AACA;AAcA,IAAM,gBAAgB,CAAC,UAAqD;AAAA,EAC1E,IAAI,CAAC,SAAS,OAAO,UAAU;AAAA,IAAU,OAAO;AAAA,EAChD,MAAM,YAAY,QAAQ,eAAe,KAAK;AAAA,EAC9C,OAAO,cAAc,OAAO,aAAa,cAAc;AAAA;AAUzD,SAAS,mBAAmB,CAAC,OAAgD;AAAA,EAC3E,MAAM,SAA4B,EAAE,MAAM,MAAM,KAAK;AAAA,EACrD,IAAI,MAAM,SAAS;AAAA,IAAW,OAAO,OAAO,MAAM;AAAA,EAClD,IAAI,MAAM,QAAQ;AAAA,IAAW,OAAO,MAAM,MAAM;AAAA,EAChD,IAAI,MAAM,aAAa;AAAA,IAAW,OAAO,WAAW,MAAM;AAAA,EAC1D,OAAO;AAAA;AAMF,IAAM,kBAAwC,EAAE,KAAK,MAAM;AAAA,EAChE,MAAM,mBAAmB,EAAE,WACzB,CAAC,OAAO,QAAQ;AAAA,IACd,IAAI,CAAC,cAAc,KAAK,GAAG;AAAA,MACzB,IAAI,SAAS;AAAA,QACX,MAAM,EAAE,aAAa;AAAA,QACrB,SAAS;AAAA,MACX,CAAC;AAAA,MACD,OAAO,EAAE;AAAA,IACX;AAAA,IACA,OAAO;AAAA,KAET,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe,CAC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AAQ;AAAA,EACR,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe;AAAA,EAC9C,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EACvB,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa;AAAA,EAC5C,WAAW,EAAE,OAAO;AAAA,EACpB,WAAW,EAAE,OAAO;AACtB;AAKO,IAAM,qBAAqB,EAC/B,OAAO,iBAAiB,EACxB,OAAO;",
|
|
8
|
+
"debugId": "4C03BFF9D6443A9164756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare const toolCallSchema: z.ZodObject<{
|
|
|
44
44
|
id: z.ZodString;
|
|
45
45
|
name: z.ZodString;
|
|
46
46
|
arguments: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
47
|
-
}, z.core.$
|
|
47
|
+
}, z.core.$strict>;
|
|
48
48
|
/**
|
|
49
49
|
* Zod schema for tool result metadata.
|
|
50
50
|
*/
|
|
@@ -55,11 +55,7 @@ export declare const toolResultSchema: z.ZodObject<{
|
|
|
55
55
|
error: "error";
|
|
56
56
|
}>;
|
|
57
57
|
content: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
58
|
-
|
|
59
|
-
toolName: z.ZodOptional<z.ZodString>;
|
|
60
|
-
result: z.ZodOptional<z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>>;
|
|
61
|
-
error: z.ZodOptional<z.ZodString>;
|
|
62
|
-
}, z.core.$strip>;
|
|
58
|
+
}, z.core.$strict>;
|
|
63
59
|
/**
|
|
64
60
|
* Zod schema for token usage accounting.
|
|
65
61
|
*/
|
|
@@ -104,7 +100,7 @@ export declare const messageInputSchema: z.ZodObject<{
|
|
|
104
100
|
id: z.ZodString;
|
|
105
101
|
name: z.ZodString;
|
|
106
102
|
arguments: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
107
|
-
}, z.core.$
|
|
103
|
+
}, z.core.$strict>>;
|
|
108
104
|
toolResult: z.ZodOptional<z.ZodObject<{
|
|
109
105
|
callId: z.ZodString;
|
|
110
106
|
outcome: z.ZodEnum<{
|
|
@@ -112,22 +108,18 @@ export declare const messageInputSchema: z.ZodObject<{
|
|
|
112
108
|
error: "error";
|
|
113
109
|
}>;
|
|
114
110
|
content: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
115
|
-
|
|
116
|
-
toolName: z.ZodOptional<z.ZodString>;
|
|
117
|
-
result: z.ZodOptional<z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>>;
|
|
118
|
-
error: z.ZodOptional<z.ZodString>;
|
|
119
|
-
}, z.core.$strip>>;
|
|
111
|
+
}, z.core.$strict>>;
|
|
120
112
|
tokenUsage: z.ZodOptional<z.ZodObject<{
|
|
121
113
|
prompt: z.ZodNumber;
|
|
122
114
|
completion: z.ZodNumber;
|
|
123
115
|
total: z.ZodNumber;
|
|
124
116
|
}, z.core.$strip>>;
|
|
125
117
|
goalCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
126
|
-
}, z.core.$
|
|
118
|
+
}, z.core.$strict>;
|
|
127
119
|
/**
|
|
128
|
-
* Zod schema for
|
|
120
|
+
* Zod schema for messages.
|
|
129
121
|
*/
|
|
130
|
-
export declare const
|
|
122
|
+
export declare const messageSchema: z.ZodObject<{
|
|
131
123
|
id: z.ZodString;
|
|
132
124
|
role: z.ZodEnum<{
|
|
133
125
|
user: "user";
|
|
@@ -163,7 +155,7 @@ export declare const messageJSONSchema: z.ZodObject<{
|
|
|
163
155
|
id: z.ZodString;
|
|
164
156
|
name: z.ZodString;
|
|
165
157
|
arguments: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
166
|
-
}, z.core.$
|
|
158
|
+
}, z.core.$strict>>;
|
|
167
159
|
toolResult: z.ZodOptional<z.ZodObject<{
|
|
168
160
|
callId: z.ZodString;
|
|
169
161
|
outcome: z.ZodEnum<{
|
|
@@ -171,18 +163,14 @@ export declare const messageJSONSchema: z.ZodObject<{
|
|
|
171
163
|
error: "error";
|
|
172
164
|
}>;
|
|
173
165
|
content: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
174
|
-
|
|
175
|
-
toolName: z.ZodOptional<z.ZodString>;
|
|
176
|
-
result: z.ZodOptional<z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>>;
|
|
177
|
-
error: z.ZodOptional<z.ZodString>;
|
|
178
|
-
}, z.core.$strip>>;
|
|
166
|
+
}, z.core.$strict>>;
|
|
179
167
|
tokenUsage: z.ZodOptional<z.ZodObject<{
|
|
180
168
|
prompt: z.ZodNumber;
|
|
181
169
|
completion: z.ZodNumber;
|
|
182
170
|
total: z.ZodNumber;
|
|
183
171
|
}, z.core.$strip>>;
|
|
184
172
|
goalCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
185
|
-
}, z.core.$
|
|
173
|
+
}, z.core.$strict>;
|
|
186
174
|
/**
|
|
187
175
|
* Zod schema for conversation status values.
|
|
188
176
|
*/
|
|
@@ -241,7 +229,7 @@ export declare const conversationShape: {
|
|
|
241
229
|
id: z.ZodString;
|
|
242
230
|
name: z.ZodString;
|
|
243
231
|
arguments: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
244
|
-
}, z.core.$
|
|
232
|
+
}, z.core.$strict>>;
|
|
245
233
|
toolResult: z.ZodOptional<z.ZodObject<{
|
|
246
234
|
callId: z.ZodString;
|
|
247
235
|
outcome: z.ZodEnum<{
|
|
@@ -249,18 +237,14 @@ export declare const conversationShape: {
|
|
|
249
237
|
error: "error";
|
|
250
238
|
}>;
|
|
251
239
|
content: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
252
|
-
|
|
253
|
-
toolName: z.ZodOptional<z.ZodString>;
|
|
254
|
-
result: z.ZodOptional<z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>>;
|
|
255
|
-
error: z.ZodOptional<z.ZodString>;
|
|
256
|
-
}, z.core.$strip>>;
|
|
240
|
+
}, z.core.$strict>>;
|
|
257
241
|
tokenUsage: z.ZodOptional<z.ZodObject<{
|
|
258
242
|
prompt: z.ZodNumber;
|
|
259
243
|
completion: z.ZodNumber;
|
|
260
244
|
total: z.ZodNumber;
|
|
261
245
|
}, z.core.$strip>>;
|
|
262
246
|
goalCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
263
|
-
}, z.core.$
|
|
247
|
+
}, z.core.$strict>>;
|
|
264
248
|
readonly createdAt: z.ZodString;
|
|
265
249
|
readonly updatedAt: z.ZodString;
|
|
266
250
|
};
|
|
@@ -314,7 +298,7 @@ export declare const conversationSchema: z.ZodObject<{
|
|
|
314
298
|
id: z.ZodString;
|
|
315
299
|
name: z.ZodString;
|
|
316
300
|
arguments: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
317
|
-
}, z.core.$
|
|
301
|
+
}, z.core.$strict>>;
|
|
318
302
|
toolResult: z.ZodOptional<z.ZodObject<{
|
|
319
303
|
callId: z.ZodString;
|
|
320
304
|
outcome: z.ZodEnum<{
|
|
@@ -322,19 +306,15 @@ export declare const conversationSchema: z.ZodObject<{
|
|
|
322
306
|
error: "error";
|
|
323
307
|
}>;
|
|
324
308
|
content: z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>;
|
|
325
|
-
|
|
326
|
-
toolName: z.ZodOptional<z.ZodString>;
|
|
327
|
-
result: z.ZodOptional<z.ZodType<JSONValue, unknown, z.core.$ZodTypeInternals<JSONValue, unknown>>>;
|
|
328
|
-
error: z.ZodOptional<z.ZodString>;
|
|
329
|
-
}, z.core.$strip>>;
|
|
309
|
+
}, z.core.$strict>>;
|
|
330
310
|
tokenUsage: z.ZodOptional<z.ZodObject<{
|
|
331
311
|
prompt: z.ZodNumber;
|
|
332
312
|
completion: z.ZodNumber;
|
|
333
313
|
total: z.ZodNumber;
|
|
334
314
|
}, z.core.$strip>>;
|
|
335
315
|
goalCompleted: z.ZodOptional<z.ZodBoolean>;
|
|
336
|
-
}, z.core.$
|
|
316
|
+
}, z.core.$strict>>;
|
|
337
317
|
createdAt: z.ZodString;
|
|
338
318
|
updatedAt: z.ZodString;
|
|
339
|
-
}, z.core.$
|
|
319
|
+
}, z.core.$strict>;
|
|
340
320
|
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAGV,SAAS,EAOV,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAGV,SAAS,EAOV,MAAM,SAAS,CAAC;AAuBjB;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAyBhB,CAAC;AAElC;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;GAaoC,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;EAQK,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,cAAc;;;;kBAMc,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;kBAMc,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;iBAIK,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAWc,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAcc,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;EAIK,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAUpB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAEc,CAAC"}
|
package/dist/streaming.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../src/streaming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../src/streaming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,EACL,KAAK,uBAAuB,EAG7B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAEV,YAAY,EACZ,SAAS,EACT,OAAO,EACP,UAAU,EACX,MAAM,SAAS,CAAC;AA4CjB;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE5D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,GAAG,SAAS,CAEnF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,WAAW,GAAG,MAAM,EAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EACpC,WAAW,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAC7C;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CA+BnD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,EACrC,WAAW,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAC7C,YAAY,CA6Bd;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACtC,EACD,WAAW,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAC7C,YAAY,CA4Cd;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAC7C,YAAY,CAgCd"}
|
package/dist/types.d.ts
CHANGED
|
@@ -30,10 +30,6 @@ export interface ToolResult {
|
|
|
30
30
|
callId: string;
|
|
31
31
|
outcome: 'success' | 'error';
|
|
32
32
|
content: JSONValue;
|
|
33
|
-
toolCallId?: string | undefined;
|
|
34
|
-
toolName?: string | undefined;
|
|
35
|
-
result?: JSONValue | undefined;
|
|
36
|
-
error?: string | undefined;
|
|
37
33
|
}
|
|
38
34
|
/**
|
|
39
35
|
* Token usage accounting for a message.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,WAAW,GACX,UAAU,GACV,aAAa,GACb,UAAU,CAAC;AAEf;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,OAAO,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAA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,WAAW,mBAAmB;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,mBAAmB,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,mBAAmB,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type { ToMarkdownOptions } from '../types';
|
|
2
1
|
export { normalizeContent, toMultiModalArray } from './content';
|
|
3
2
|
export { createMessage, isAssistantMessage, messageHasImages, messageParts, messageText, messageToJSON, messageToString, } from './message';
|
|
4
3
|
export type { ToolCallPair } from './tool-calls';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAKhE,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,GAChB,MAAM,WAAW,CAAC;AAGnB,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/utilities/markdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/utilities/markdown.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,YAAY,EAIZ,WAAW,EAEX,iBAAiB,EAGlB,MAAM,UAAU,CAAC;AAQlB;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAQnD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAQrD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAEtD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEvE;AAgKD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAUR;AAwFD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AASD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAqB3D"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Message, ToolCall, ToolResult } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a paired tool call with its optional result.
|
|
4
4
|
*/
|
|
5
5
|
export interface ToolCallPair {
|
|
6
6
|
/** The tool call */
|
|
7
|
-
call:
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
arguments: JSONValue;
|
|
11
|
-
};
|
|
7
|
+
call: ToolCall;
|
|
12
8
|
/** The corresponding result, if available */
|
|
13
9
|
result?: ToolResult | undefined;
|
|
14
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-calls.d.ts","sourceRoot":"","sources":["../../src/utilities/tool-calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tool-calls.d.ts","sourceRoot":"","sources":["../../src/utilities/tool-calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oBAAoB;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,6CAA6C;IAC7C,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACnE,YAAY,EAAE,CA6BhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-results.d.ts","sourceRoot":"","sources":["../../src/utilities/tool-results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAEjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,GAClB,UAAU,
|
|
1
|
+
{"version":3,"file":"tool-results.d.ts","sourceRoot":"","sources":["../../src/utilities/tool-results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAEjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,GAClB,UAAU,CAEZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transient.d.ts","sourceRoot":"","sources":["../../src/utilities/transient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transient.d.ts","sourceRoot":"","sources":["../../src/utilities/transient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,YAAY,EAAE,SAAS,EAAW,MAAM,UAAU,CAAC;AAKnF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAQ3B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,YAAY,CAwC/E"}
|
package/dist/utilities.d.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* - './utilities/transient' for transient metadata handling
|
|
10
10
|
* - './utilities/type-helpers' for type guard helpers
|
|
11
11
|
*/
|
|
12
|
-
export type { ToMarkdownOptions } from './types';
|
|
13
12
|
export { normalizeContent, toMultiModalArray } from './utilities/content';
|
|
14
13
|
export { createMessage, isAssistantMessage, messageHasImages, messageParts, messageText, messageToJSON, messageToString, } from './utilities/message';
|
|
15
14
|
export type { ToolCallPair } from './utilities/tool-calls';
|
package/dist/utilities.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAK1E,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/versioning/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/versioning/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/versioning/index.js
CHANGED
|
@@ -1,58 +1,7 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
2
|
var CURRENT_SCHEMA_VERSION = 3;
|
|
3
|
-
// src/conversation/serialization.ts
|
|
4
|
-
function migrateConversation(json) {
|
|
5
|
-
if (typeof json !== "object" || json === null || Array.isArray(json)) {
|
|
6
|
-
return {
|
|
7
|
-
schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
8
|
-
id: "",
|
|
9
|
-
status: "active",
|
|
10
|
-
metadata: {},
|
|
11
|
-
ids: [],
|
|
12
|
-
messages: {},
|
|
13
|
-
createdAt: new Date().toISOString(),
|
|
14
|
-
updatedAt: new Date().toISOString()
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const data = json;
|
|
18
|
-
const rawMessages = data.messages;
|
|
19
|
-
let messages = {};
|
|
20
|
-
let ids = [];
|
|
21
|
-
const rawIds = data.ids;
|
|
22
|
-
const isStringArray = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
23
|
-
if (Array.isArray(rawMessages)) {
|
|
24
|
-
const rawMessageArray = rawMessages;
|
|
25
|
-
ids = rawMessageArray.map((message) => message.id);
|
|
26
|
-
messages = Object.fromEntries(rawMessageArray.map((message) => [message.id, message]));
|
|
27
|
-
} else if (rawMessages && typeof rawMessages === "object") {
|
|
28
|
-
messages = { ...rawMessages };
|
|
29
|
-
if (isStringArray(rawIds) && rawIds.length > 0) {
|
|
30
|
-
ids = [...rawIds];
|
|
31
|
-
} else {
|
|
32
|
-
ids = Object.values(messages).sort((a, b) => a.position - b.position).map((message) => message.id);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (ids.length > 0) {
|
|
36
|
-
ids = ids.filter((id) => (id in messages));
|
|
37
|
-
const missing = Object.keys(messages).filter((id) => !ids.includes(id));
|
|
38
|
-
if (missing.length > 0) {
|
|
39
|
-
const sortedMissing = missing.sort((a, b) => (messages[a]?.position ?? 0) - (messages[b]?.position ?? 0));
|
|
40
|
-
ids = [...ids, ...sortedMissing];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (!("schemaVersion" in json)) {
|
|
44
|
-
return {
|
|
45
|
-
...data,
|
|
46
|
-
schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
47
|
-
ids,
|
|
48
|
-
messages
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return { ...data, ids, messages };
|
|
52
|
-
}
|
|
53
3
|
export {
|
|
54
|
-
migrateConversation,
|
|
55
4
|
CURRENT_SCHEMA_VERSION
|
|
56
5
|
};
|
|
57
6
|
|
|
58
|
-
//# debugId=
|
|
7
|
+
//# debugId=9390544FC93DBFE664756E2164756E21
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/types.ts"
|
|
3
|
+
"sources": ["../../src/types.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { MultiModalContent } from '@lasercat/homogenaize';\n\n/**\n * Current schema version for serialized conversation data.\n * Increment when making breaking changes to the schema.\n */\nexport const CURRENT_SCHEMA_VERSION = 3;\n\n/**\n * JSON-serializable value types.\n */\nexport type JSONPrimitive = string | number | boolean | null;\nexport type JSONValue = JSONPrimitive | JSONValue[] | { [key: string]: JSONValue };\n\n/**\n * Supported message roles in a conversation.\n */\nexport type MessageRole =\n | 'user'\n | 'assistant'\n | 'system'\n | 'developer'\n | 'tool-use'\n | 'tool-result'\n | 'snapshot';\n\n/**\n * Tool call metadata for tool-use messages.\n */\nexport interface ToolCall {\n id: string;\n name: string;\n arguments: JSONValue;\n}\n\n/**\n * Tool execution result metadata for tool-result messages.\n */\nexport interface ToolResult {\n callId: string;\n outcome: 'success' | 'error';\n content: JSONValue;\n
|
|
6
|
-
"import { createInvalidPositionError, createSerializationError } from '../errors';\nimport type { Conversation, Message } from '../types';\nimport { CURRENT_SCHEMA_VERSION } from '../types';\nimport { createMessage, toReadonly } from '../utilities';\nimport { toIdRecord } from '../utilities/message-store';\nimport { assertToolReference, registerToolUse, type ToolUseIndex } from './tool-tracking';\n\n/**\n * Migrates a serialized conversation object to the current schema version.\n * Handles data from older versions that may not have a schemaVersion field.\n *\n * @param json - The conversation data to migrate (may be from an older version)\n * @returns A Conversation with the current schema version\n *\n * @example\n * ```ts\n * // Old data without schemaVersion\n * const old = { id: 'conv-1', status: 'active', ... };\n * const migrated = migrateConversation(old);\n * // migrated.schemaVersion === CURRENT_SCHEMA_VERSION\n * ```\n */\nexport function migrateConversation(json: unknown): Conversation {\n // Handle non-object input\n if (typeof json !== 'object' || json === null || Array.isArray(json)) {\n return {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n id: '',\n status: 'active',\n metadata: {},\n ids: [],\n messages: {},\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n };\n }\n\n const data = json as Conversation & { messages?: unknown };\n const rawMessages = data.messages;\n\n let messages: Record<string, Message> = {};\n let ids: string[] = [];\n const rawIds = (data as { ids?: unknown }).ids;\n const isStringArray = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every((item) => typeof item === 'string');\n\n if (Array.isArray(rawMessages)) {\n const rawMessageArray = rawMessages as Message[];\n ids = rawMessageArray.map((message) => message.id);\n messages = Object.fromEntries(\n rawMessageArray.map((message) => [message.id, message]),\n );\n } else if (rawMessages && typeof rawMessages === 'object') {\n messages = { ...(rawMessages as Record<string, Message>) };\n if (isStringArray(rawIds) && rawIds.length > 0) {\n ids = [...rawIds];\n } else {\n ids = Object.values(messages)\n .sort((a, b) => a.position - b.position)\n .map((message) => message.id);\n }\n }\n\n if (ids.length > 0) {\n ids = ids.filter((id) => id in messages);\n const missing = Object.keys(messages).filter((id) => !ids.includes(id));\n if (missing.length > 0) {\n const sortedMissing = missing.sort(\n (a, b) => (messages[a]?.position ?? 0) - (messages[b]?.position ?? 0),\n );\n ids = [...ids, ...sortedMissing];\n }\n }\n\n // If no schemaVersion, assume pre-versioning data (version 0) and add it\n if (!('schemaVersion' in json)) {\n return {\n ...data,\n schemaVersion: CURRENT_SCHEMA_VERSION,\n ids,\n messages,\n };\n }\n\n // Future: add migration logic between versions here\n return { ...data, ids, messages };\n}\n\n/**\n * Reconstructs a conversation from a JSON object.\n * Automatically migrates data from older schema versions.\n * Validates message positions are contiguous and tool results reference valid calls.\n * Throws a serialization error if validation fails.\n *\n * @param json - The conversation JSON to deserialize (may be from an older version)\n * @returns A Conversation object\n * @throws {SerializationError} If validation fails\n */\nexport function deserializeConversation(json: unknown): Conversation {\n // Migrate to current schema version\n const migrated = migrateConversation(json);\n\n try {\n const orderedMessages = migrated.ids.map((id, index) => {\n const message = migrated.messages[id];\n if (!message) {\n throw createSerializationError(`missing message for id ${id}`);\n }\n if (message.position !== index) {\n throw createInvalidPositionError(index, message.position);\n }\n return message;\n });\n\n orderedMessages.reduce<{ toolUses: ToolUseIndex }>(\n (state, message) => {\n if (message.role === 'tool-use' && message.toolCall) {\n return {\n toolUses: registerToolUse(state.toolUses, message.toolCall),\n };\n }\n\n if (message.role === 'tool-result' && message.toolResult) {\n assertToolReference(state.toolUses, message.toolResult.callId);\n }\n\n return state;\n },\n { toolUses: new Map<string, { name: string }>() },\n );\n\n const messageInstances: Message[] = orderedMessages.map((m) => createMessage(m));\n const conv: Conversation = {\n schemaVersion: migrated.schemaVersion,\n id: migrated.id,\n title: migrated.title,\n status: migrated.status,\n metadata: { ...migrated.metadata },\n ids: orderedMessages.map((message) => message.id),\n messages: toIdRecord(messageInstances),\n createdAt: migrated.createdAt,\n updatedAt: migrated.updatedAt,\n };\n return toReadonly(conv);\n } catch (error) {\n throw createSerializationError(\n `failed to deserialize conversation: ${\n error instanceof Error ? error.message : String(error)\n }`,\n error as Error,\n );\n }\n}\n"
|
|
5
|
+
"import type { MultiModalContent } from '@lasercat/homogenaize';\n\n/**\n * Current schema version for serialized conversation data.\n * Increment when making breaking changes to the schema.\n */\nexport const CURRENT_SCHEMA_VERSION = 3;\n\n/**\n * JSON-serializable value types.\n */\nexport type JSONPrimitive = string | number | boolean | null;\nexport type JSONValue = JSONPrimitive | JSONValue[] | { [key: string]: JSONValue };\n\n/**\n * Supported message roles in a conversation.\n */\nexport type MessageRole =\n | 'user'\n | 'assistant'\n | 'system'\n | 'developer'\n | 'tool-use'\n | 'tool-result'\n | 'snapshot';\n\n/**\n * Tool call metadata for tool-use messages.\n */\nexport interface ToolCall {\n id: string;\n name: string;\n arguments: JSONValue;\n}\n\n/**\n * Tool execution result metadata for tool-result messages.\n */\nexport interface ToolResult {\n callId: string;\n outcome: 'success' | 'error';\n content: JSONValue;\n}\n\n/**\n * Token usage accounting for a message.\n */\nexport interface TokenUsage {\n prompt: number;\n completion: number;\n total: number;\n}\n\n/**\n * Mutable input shape for creating a message.\n */\nexport interface MessageInput {\n role: MessageRole;\n content: string | MultiModalContent[];\n metadata?: Record<string, JSONValue> | undefined;\n hidden?: boolean | undefined;\n toolCall?: ToolCall | undefined;\n toolResult?: ToolResult | undefined;\n tokenUsage?: TokenUsage | undefined;\n /** Indicates if this message represents goal completion (assistant only) */\n goalCompleted?: boolean | undefined;\n}\n\n/**\n * Immutable message shape exposed by the library.\n */\nexport interface Message {\n id: string;\n role: MessageRole;\n content: string | ReadonlyArray<MultiModalContent>;\n position: number;\n createdAt: string;\n metadata: Readonly<Record<string, JSONValue>>;\n hidden: boolean;\n toolCall?: Readonly<ToolCall> | undefined;\n toolResult?: Readonly<ToolResult> | undefined;\n tokenUsage?: Readonly<TokenUsage> | undefined;\n}\n\n/**\n * Assistant-only message shape with optional goal completion metadata.\n */\nexport interface AssistantMessage extends Message {\n role: 'assistant';\n /** Indicates if this message represents goal completion */\n goalCompleted?: boolean | undefined;\n}\n\n/**\n * Status values for a conversation lifecycle.\n */\nexport type ConversationStatus = 'active' | 'archived' | 'deleted';\n\n/**\n * Immutable conversation state.\n */\nexport interface Conversation {\n schemaVersion: number;\n id: string;\n title?: string | undefined;\n status: ConversationStatus;\n metadata: Readonly<Record<string, JSONValue>>;\n ids: ReadonlyArray<string>;\n messages: Readonly<Record<string, Message>>;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * A function that estimates the number of tokens in a message.\n */\nexport type TokenEstimator = (message: Message) => number;\n\n/**\n * A plugin that can transform a MessageInput before it is appended.\n */\nexport type MessagePlugin = (input: MessageInput) => MessageInput;\n\n/**\n * Serialized form of a single node in the conversation history tree.\n */\nexport interface HistoryNodeSnapshot {\n conversation: Conversation;\n children: HistoryNodeSnapshot[];\n}\n\n/**\n * Serialized form of the entire conversation history.\n */\nexport interface ConversationHistorySnapshot {\n root: HistoryNodeSnapshot;\n currentPath: number[];\n}\n\n/**\n * Base options for all export operations.\n */\nexport interface ExportOptions {\n /**\n * When true, strips transient metadata (keys starting with '_').\n * @default false\n */\n stripTransient?: boolean;\n\n /**\n * When false, hidden messages are omitted from export output.\n * @default true\n */\n includeHidden?: boolean;\n\n /**\n * When true, hidden message content is replaced with a redacted placeholder.\n * Only applies when includeHidden is true.\n * @default false\n */\n redactHiddenContent?: boolean;\n\n /**\n * Placeholder used when redacting tool or hidden content.\n * @default \"[REDACTED]\"\n */\n redactedPlaceholder?: string;\n\n /**\n * When true, redacts tool call arguments with '[REDACTED]'.\n * @default false\n */\n redactToolArguments?: boolean;\n\n /**\n * When true, redacts tool result content with '[REDACTED]'.\n * @default false\n */\n redactToolResults?: boolean;\n}\n\n/**\n * Options for exporting to markdown format.\n */\nexport interface ToMarkdownOptions extends ExportOptions {\n /**\n * When true, includes YAML frontmatter with full metadata for lossless round-trip.\n * Headers include message ID: `### Role (msg-id)`\n * @default false\n */\n includeMetadata?: boolean;\n}\n"
|
|
7
6
|
],
|
|
8
|
-
"mappings": ";AAMO,IAAM,yBAAyB
|
|
9
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAMO,IAAM,yBAAyB;",
|
|
8
|
+
"debugId": "9390544FC93DBFE664756E2164756E21",
|
|
10
9
|
"names": []
|
|
11
10
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MultiModalContent } from '@lasercat/homogenaize';
|
|
2
|
+
import type { RedactMessageOptions } from './conversation/index';
|
|
2
3
|
import type { Conversation, JSONValue, Message, MessageInput, TokenUsage } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* A mutable draft wrapper around a conversation.
|
|
@@ -61,7 +62,7 @@ export interface ConversationDraft {
|
|
|
61
62
|
* @param position - The message position to redact.
|
|
62
63
|
* @param placeholder - Replacement text (default: '[REDACTED]').
|
|
63
64
|
*/
|
|
64
|
-
redactMessageAtPosition: (position: number,
|
|
65
|
+
redactMessageAtPosition: (position: number, placeholderOrOptions?: string | RedactMessageOptions) => ConversationDraft;
|
|
65
66
|
/**
|
|
66
67
|
* Appends a streaming message placeholder.
|
|
67
68
|
* Returns the draft and the new message ID for subsequent updates.
|
|
@@ -99,6 +100,7 @@ export interface ConversationDraft {
|
|
|
99
100
|
*/
|
|
100
101
|
truncateFromPosition: (position: number, options?: {
|
|
101
102
|
preserveSystemMessages?: boolean;
|
|
103
|
+
preserveToolPairs?: boolean;
|
|
102
104
|
}) => ConversationDraft;
|
|
103
105
|
/**
|
|
104
106
|
* Truncates the conversation to fit within a token limit.
|
|
@@ -110,6 +112,7 @@ export interface ConversationDraft {
|
|
|
110
112
|
estimateTokens?: (message: Message) => number;
|
|
111
113
|
preserveSystemMessages?: boolean;
|
|
112
114
|
preserveLastN?: number;
|
|
115
|
+
preserveToolPairs?: boolean;
|
|
113
116
|
}) => ConversationDraft;
|
|
114
117
|
}
|
|
115
118
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-conversation.d.ts","sourceRoot":"","sources":["../src/with-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"with-conversation.d.ts","sourceRoot":"","sources":["../src/with-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAkBjE,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE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