@kmmao/happy-wire 0.2.1 → 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 +46 -2
- package/dist/index.d.cts +1307 -231
- package/dist/index.d.mts +1307 -231
- package/dist/index.mjs +43 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -72,6 +72,42 @@ const sessionUsageUpdateEventSchema = z.object({
|
|
|
72
72
|
}),
|
|
73
73
|
durationMs: z.number().optional()
|
|
74
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()
|
|
110
|
+
});
|
|
75
111
|
const sessionEventSchema = z.discriminatedUnion("t", [
|
|
76
112
|
sessionTextEventSchema,
|
|
77
113
|
sessionServiceMessageEventSchema,
|
|
@@ -82,7 +118,11 @@ const sessionEventSchema = z.discriminatedUnion("t", [
|
|
|
82
118
|
sessionStartEventSchema,
|
|
83
119
|
sessionTurnEndEventSchema,
|
|
84
120
|
sessionStopEventSchema,
|
|
85
|
-
sessionUsageUpdateEventSchema
|
|
121
|
+
sessionUsageUpdateEventSchema,
|
|
122
|
+
sessionTaskStartEventSchema,
|
|
123
|
+
sessionTaskProgressEventSchema,
|
|
124
|
+
sessionTaskEndEventSchema,
|
|
125
|
+
sessionToolProgressEventSchema
|
|
86
126
|
]);
|
|
87
127
|
const sessionEnvelopeSchema = z.object({
|
|
88
128
|
id: z.string(),
|
|
@@ -101,7 +141,7 @@ const sessionEnvelopeSchema = z.object({
|
|
|
101
141
|
path: ["role"]
|
|
102
142
|
});
|
|
103
143
|
}
|
|
104
|
-
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") {
|
|
105
145
|
ctx.addIssue({
|
|
106
146
|
code: z.ZodIssueCode.custom,
|
|
107
147
|
message: `${envelope.ev.t} events must use role "agent"`,
|
|
@@ -221,4 +261,4 @@ const ApiUpdateMachineStateSchema = UpdateMachineBodySchema;
|
|
|
221
261
|
const UpdateBodySchema = UpdateNewMessageBodySchema;
|
|
222
262
|
const UpdateSchema = CoreUpdateContainerSchema;
|
|
223
263
|
|
|
224
|
-
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 };
|