@kmmao/happy-wire 0.1.0 → 0.2.1

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.mjs CHANGED
@@ -61,6 +61,17 @@ const sessionTurnEndEventSchema = z.object({
61
61
  const sessionStopEventSchema = z.object({
62
62
  t: z.literal("stop")
63
63
  });
64
+ const sessionUsageUpdateEventSchema = z.object({
65
+ t: z.literal("usage-update"),
66
+ model: z.string().optional(),
67
+ usage: z.object({
68
+ input_tokens: z.number(),
69
+ output_tokens: z.number(),
70
+ cache_creation_input_tokens: z.number().optional(),
71
+ cache_read_input_tokens: z.number().optional()
72
+ }),
73
+ durationMs: z.number().optional()
74
+ });
64
75
  const sessionEventSchema = z.discriminatedUnion("t", [
65
76
  sessionTextEventSchema,
66
77
  sessionServiceMessageEventSchema,
@@ -70,7 +81,8 @@ const sessionEventSchema = z.discriminatedUnion("t", [
70
81
  sessionTurnStartEventSchema,
71
82
  sessionStartEventSchema,
72
83
  sessionTurnEndEventSchema,
73
- sessionStopEventSchema
84
+ sessionStopEventSchema,
85
+ sessionUsageUpdateEventSchema
74
86
  ]);
75
87
  const sessionEnvelopeSchema = z.object({
76
88
  id: z.string(),
@@ -89,7 +101,7 @@ const sessionEnvelopeSchema = z.object({
89
101
  path: ["role"]
90
102
  });
91
103
  }
92
- if ((envelope.ev.t === "start" || envelope.ev.t === "stop") && envelope.role !== "agent") {
104
+ if ((envelope.ev.t === "start" || envelope.ev.t === "stop" || envelope.ev.t === "usage-update") && envelope.role !== "agent") {
93
105
  ctx.addIssue({
94
106
  code: z.ZodIssueCode.custom,
95
107
  message: `${envelope.ev.t} events must use role "agent"`,
@@ -209,4 +221,4 @@ const ApiUpdateMachineStateSchema = UpdateMachineBodySchema;
209
221
  const UpdateBodySchema = UpdateNewMessageBodySchema;
210
222
  const UpdateSchema = CoreUpdateContainerSchema;
211
223
 
212
- 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 };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmmao/happy-wire",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Shared message wire types and Zod schemas for Happy clients and services",
5
5
  "author": "kmmao",
6
6
  "license": "MIT",