@kmmao/happy-wire 0.2.0 → 0.2.2
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 +48 -3
- package/dist/index.d.cts +1358 -251
- package/dist/index.d.mts +1358 -251
- package/dist/index.mjs +45 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -69,7 +69,44 @@ const sessionUsageUpdateEventSchema = z.object({
|
|
|
69
69
|
output_tokens: z.number(),
|
|
70
70
|
cache_creation_input_tokens: z.number().optional(),
|
|
71
71
|
cache_read_input_tokens: z.number().optional()
|
|
72
|
-
})
|
|
72
|
+
}),
|
|
73
|
+
durationMs: z.number().optional()
|
|
74
|
+
});
|
|
75
|
+
const sessionTaskStartEventSchema = z.object({
|
|
76
|
+
t: z.literal("task-start"),
|
|
77
|
+
taskId: z.string(),
|
|
78
|
+
toolUseId: z.string().optional(),
|
|
79
|
+
description: z.string(),
|
|
80
|
+
taskType: z.string().optional()
|
|
81
|
+
});
|
|
82
|
+
const sessionTaskProgressEventSchema = z.object({
|
|
83
|
+
t: z.literal("task-progress"),
|
|
84
|
+
taskId: z.string(),
|
|
85
|
+
description: z.string(),
|
|
86
|
+
usage: z.object({
|
|
87
|
+
totalTokens: z.number(),
|
|
88
|
+
toolUses: z.number(),
|
|
89
|
+
durationMs: z.number()
|
|
90
|
+
}),
|
|
91
|
+
lastToolName: z.string().optional()
|
|
92
|
+
});
|
|
93
|
+
const sessionTaskEndEventSchema = z.object({
|
|
94
|
+
t: z.literal("task-end"),
|
|
95
|
+
taskId: z.string(),
|
|
96
|
+
status: z.enum(["completed", "failed", "stopped"]),
|
|
97
|
+
summary: z.string(),
|
|
98
|
+
usage: z.object({
|
|
99
|
+
totalTokens: z.number(),
|
|
100
|
+
toolUses: z.number(),
|
|
101
|
+
durationMs: z.number()
|
|
102
|
+
}).optional()
|
|
103
|
+
});
|
|
104
|
+
const sessionToolProgressEventSchema = z.object({
|
|
105
|
+
t: z.literal("tool-progress"),
|
|
106
|
+
toolUseId: z.string(),
|
|
107
|
+
toolName: z.string(),
|
|
108
|
+
elapsedSeconds: z.number(),
|
|
109
|
+
taskId: z.string().optional()
|
|
73
110
|
});
|
|
74
111
|
const sessionEventSchema = z.discriminatedUnion("t", [
|
|
75
112
|
sessionTextEventSchema,
|
|
@@ -81,7 +118,11 @@ const sessionEventSchema = z.discriminatedUnion("t", [
|
|
|
81
118
|
sessionStartEventSchema,
|
|
82
119
|
sessionTurnEndEventSchema,
|
|
83
120
|
sessionStopEventSchema,
|
|
84
|
-
sessionUsageUpdateEventSchema
|
|
121
|
+
sessionUsageUpdateEventSchema,
|
|
122
|
+
sessionTaskStartEventSchema,
|
|
123
|
+
sessionTaskProgressEventSchema,
|
|
124
|
+
sessionTaskEndEventSchema,
|
|
125
|
+
sessionToolProgressEventSchema
|
|
85
126
|
]);
|
|
86
127
|
const sessionEnvelopeSchema = z.object({
|
|
87
128
|
id: z.string(),
|
|
@@ -100,7 +141,7 @@ const sessionEnvelopeSchema = z.object({
|
|
|
100
141
|
path: ["role"]
|
|
101
142
|
});
|
|
102
143
|
}
|
|
103
|
-
if ((envelope.ev.t === "start" || envelope.ev.t === "stop" || envelope.ev.t === "usage-update") && envelope.role !== "agent") {
|
|
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") {
|
|
104
145
|
ctx.addIssue({
|
|
105
146
|
code: z.ZodIssueCode.custom,
|
|
106
147
|
message: `${envelope.ev.t} events must use role "agent"`,
|
|
@@ -220,4 +261,4 @@ const ApiUpdateMachineStateSchema = UpdateMachineBodySchema;
|
|
|
220
261
|
const UpdateBodySchema = UpdateNewMessageBodySchema;
|
|
221
262
|
const UpdateSchema = CoreUpdateContainerSchema;
|
|
222
263
|
|
|
223
|
-
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, sessionTextEventSchema, sessionToolCallEndEventSchema, sessionToolCallStartEventSchema, sessionTurnEndEventSchema, sessionTurnEndStatusSchema, sessionTurnStartEventSchema, sessionUsageUpdateEventSchema };
|
|
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 };
|