@kmmao/happy-wire 0.2.3 → 0.2.5
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 +21 -3
- package/dist/index.d.cts +512 -2
- package/dist/index.d.mts +512 -2
- package/dist/index.mjs +20 -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")
|
|
@@ -112,6 +124,9 @@ const sessionPromptSuggestionEventSchema = z.object({
|
|
|
112
124
|
t: z.literal("prompt-suggestion"),
|
|
113
125
|
suggestion: z.string()
|
|
114
126
|
});
|
|
127
|
+
const sessionNeedsContinueEventSchema = z.object({
|
|
128
|
+
t: z.literal("needs-continue")
|
|
129
|
+
});
|
|
115
130
|
const sessionEventSchema = z.discriminatedUnion("t", [
|
|
116
131
|
sessionTextEventSchema,
|
|
117
132
|
sessionServiceMessageEventSchema,
|
|
@@ -127,7 +142,8 @@ const sessionEventSchema = z.discriminatedUnion("t", [
|
|
|
127
142
|
sessionTaskProgressEventSchema,
|
|
128
143
|
sessionTaskEndEventSchema,
|
|
129
144
|
sessionToolProgressEventSchema,
|
|
130
|
-
sessionPromptSuggestionEventSchema
|
|
145
|
+
sessionPromptSuggestionEventSchema,
|
|
146
|
+
sessionNeedsContinueEventSchema
|
|
131
147
|
]);
|
|
132
148
|
const sessionEnvelopeSchema = z.object({
|
|
133
149
|
id: z.string(),
|
|
@@ -146,7 +162,7 @@ const sessionEnvelopeSchema = z.object({
|
|
|
146
162
|
path: ["role"]
|
|
147
163
|
});
|
|
148
164
|
}
|
|
149
|
-
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") {
|
|
165
|
+
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.ev.t === "needs-continue") && envelope.role !== "agent") {
|
|
150
166
|
ctx.addIssue({
|
|
151
167
|
code: z.ZodIssueCode.custom,
|
|
152
168
|
message: `${envelope.ev.t} events must use role "agent"`,
|
|
@@ -266,4 +282,4 @@ const ApiUpdateMachineStateSchema = UpdateMachineBodySchema;
|
|
|
266
282
|
const UpdateBodySchema = UpdateNewMessageBodySchema;
|
|
267
283
|
const UpdateSchema = CoreUpdateContainerSchema;
|
|
268
284
|
|
|
269
|
-
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, sessionPromptSuggestionEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTaskEndEventSchema, sessionTaskProgressEventSchema, sessionTaskStartEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionToolProgressEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, sessionUsageUpdateEventSchema };
|
|
285
|
+
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, sessionNeedsContinueEventSchema, sessionPromptSuggestionEventSchema, sessionRoleSchema, sessionServiceMessageEventSchema, sessionStartEventSchema, sessionStopEventSchema, sessionTaskEndEventSchema, sessionTaskProgressEventSchema, sessionTaskStartEventSchema, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionToolProgressEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, sessionUsageUpdateEventSchema };
|