@kmmao/happy-wire 0.2.2 → 0.2.4
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 +22 -3
- package/dist/index.d.cts +543 -2
- package/dist/index.d.mts +543 -2
- package/dist/index.mjs +21 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -46,6 +46,15 @@ const sessionTurnEndStatusSchema = z.enum([
|
|
|
46
46
|
"failed",
|
|
47
47
|
"cancelled"
|
|
48
48
|
]);
|
|
49
|
+
const sessionModelUsageSchema = z.object({
|
|
50
|
+
inputTokens: z.number(),
|
|
51
|
+
outputTokens: z.number(),
|
|
52
|
+
cacheReadInputTokens: z.number(),
|
|
53
|
+
cacheCreationInputTokens: z.number(),
|
|
54
|
+
costUSD: z.number(),
|
|
55
|
+
contextWindow: z.number(),
|
|
56
|
+
maxOutputTokens: z.number()
|
|
57
|
+
});
|
|
49
58
|
const sessionTurnEndEventSchema = z.object({
|
|
50
59
|
t: z.literal("turn-end"),
|
|
51
60
|
status: sessionTurnEndStatusSchema,
|
|
@@ -56,7 +65,10 @@ const sessionTurnEndEventSchema = z.object({
|
|
|
56
65
|
cache_creation_input_tokens: z.number().optional(),
|
|
57
66
|
cache_read_input_tokens: z.number().optional()
|
|
58
67
|
}).optional(),
|
|
59
|
-
durationMs: z.number().optional()
|
|
68
|
+
durationMs: z.number().optional(),
|
|
69
|
+
totalCostUsd: z.number().optional(),
|
|
70
|
+
numTurns: z.number().optional(),
|
|
71
|
+
modelUsage: z.record(z.string(), sessionModelUsageSchema).optional()
|
|
60
72
|
});
|
|
61
73
|
const sessionStopEventSchema = z.object({
|
|
62
74
|
t: z.literal("stop")
|
|
@@ -108,6 +120,10 @@ const sessionToolProgressEventSchema = z.object({
|
|
|
108
120
|
elapsedSeconds: z.number(),
|
|
109
121
|
taskId: z.string().optional()
|
|
110
122
|
});
|
|
123
|
+
const sessionPromptSuggestionEventSchema = z.object({
|
|
124
|
+
t: z.literal("prompt-suggestion"),
|
|
125
|
+
suggestion: z.string()
|
|
126
|
+
});
|
|
111
127
|
const sessionEventSchema = z.discriminatedUnion("t", [
|
|
112
128
|
sessionTextEventSchema,
|
|
113
129
|
sessionServiceMessageEventSchema,
|
|
@@ -122,7 +138,8 @@ const sessionEventSchema = z.discriminatedUnion("t", [
|
|
|
122
138
|
sessionTaskStartEventSchema,
|
|
123
139
|
sessionTaskProgressEventSchema,
|
|
124
140
|
sessionTaskEndEventSchema,
|
|
125
|
-
sessionToolProgressEventSchema
|
|
141
|
+
sessionToolProgressEventSchema,
|
|
142
|
+
sessionPromptSuggestionEventSchema
|
|
126
143
|
]);
|
|
127
144
|
const sessionEnvelopeSchema = z.object({
|
|
128
145
|
id: z.string(),
|
|
@@ -141,7 +158,7 @@ const sessionEnvelopeSchema = z.object({
|
|
|
141
158
|
path: ["role"]
|
|
142
159
|
});
|
|
143
160
|
}
|
|
144
|
-
if ((envelope.ev.t === "start" || envelope.ev.t === "stop" || envelope.ev.t === "usage-update" || envelope.ev.t === "task-start" || envelope.ev.t === "task-progress" || envelope.ev.t === "task-end" || envelope.ev.t === "tool-progress") && envelope.role !== "agent") {
|
|
161
|
+
if ((envelope.ev.t === "start" || envelope.ev.t === "stop" || envelope.ev.t === "usage-update" || envelope.ev.t === "task-start" || envelope.ev.t === "task-progress" || envelope.ev.t === "task-end" || envelope.ev.t === "tool-progress" || envelope.ev.t === "prompt-suggestion") && envelope.role !== "agent") {
|
|
145
162
|
ctx.addIssue({
|
|
146
163
|
code: z.ZodIssueCode.custom,
|
|
147
164
|
message: `${envelope.ev.t} events must use role "agent"`,
|
|
@@ -261,4 +278,4 @@ const ApiUpdateMachineStateSchema = UpdateMachineBodySchema;
|
|
|
261
278
|
const UpdateBodySchema = UpdateNewMessageBodySchema;
|
|
262
279
|
const UpdateSchema = CoreUpdateContainerSchema;
|
|
263
280
|
|
|
264
|
-
export { AgentMessageSchema, ApiMessageSchema, ApiUpdateMachineStateSchema, ApiUpdateNewMessageSchema, ApiUpdateSessionStateSchema, CoreUpdateBodySchema, CoreUpdateContainerSchema, LegacyMessageContentSchema, MessageContentSchema, MessageMetaSchema, SessionMessageContentSchema, SessionMessageSchema, SessionProtocolMessageSchema, UpdateBodySchema, UpdateMachineBodySchema, UpdateNewMessageBodySchema, UpdateSchema, UpdateSessionBodySchema, UserMessageSchema, VersionedEncryptedValueSchema, VersionedMachineEncryptedValueSchema, VersionedNullableEncryptedValueSchema, createEnvelope, sessionEnvelopeSchema, sessionEventSchema, sessionFileEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTaskEndEventSchema, sessionTaskProgressEventSchema, sessionTaskStartEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionToolProgressEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, sessionUsageUpdateEventSchema };
|
|
281
|
+
export { AgentMessageSchema, ApiMessageSchema, ApiUpdateMachineStateSchema, ApiUpdateNewMessageSchema, ApiUpdateSessionStateSchema, CoreUpdateBodySchema, CoreUpdateContainerSchema, LegacyMessageContentSchema, MessageContentSchema, MessageMetaSchema, SessionMessageContentSchema, SessionMessageSchema, SessionProtocolMessageSchema, UpdateBodySchema, UpdateMachineBodySchema, UpdateNewMessageBodySchema, UpdateSchema, UpdateSessionBodySchema, UserMessageSchema, VersionedEncryptedValueSchema, VersionedMachineEncryptedValueSchema, VersionedNullableEncryptedValueSchema, createEnvelope, sessionEnvelopeSchema, sessionEventSchema, sessionFileEventSchema, sessionModelUsageSchema, sessionPromptSuggestionEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTaskEndEventSchema, sessionTaskProgressEventSchema, sessionTaskStartEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionToolProgressEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, sessionUsageUpdateEventSchema };
|