@cloudflare/ai-chat 0.8.5 → 0.8.6

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/README.md CHANGED
@@ -22,7 +22,7 @@ export class ChatAgent extends AIChatAgent {
22
22
  const workersai = createWorkersAI({ binding: this.env.AI });
23
23
 
24
24
  const result = streamText({
25
- model: workersai("@cf/moonshotai/kimi-k2.6"),
25
+ model: workersai("@cf/moonshotai/kimi-k2.7-code"),
26
26
  messages: await convertToModelMessages(this.messages)
27
27
  });
28
28
 
@@ -110,7 +110,7 @@ export class ChatAgent extends AIChatAgent {
110
110
  const workersai = createWorkersAI({ binding: this.env.AI });
111
111
 
112
112
  const result = streamText({
113
- model: workersai("@cf/moonshotai/kimi-k2.6"),
113
+ model: workersai("@cf/moonshotai/kimi-k2.7-code"),
114
114
  messages: await convertToModelMessages(this.messages),
115
115
  tools: {
116
116
  getWeather: tool({
@@ -409,7 +409,7 @@ export class ChatAgent extends AIChatAgent {
409
409
  const workersai = createWorkersAI({ binding: this.env.AI });
410
410
 
411
411
  const result = streamText({
412
- model: workersai("@cf/moonshotai/kimi-k2.6"),
412
+ model: workersai("@cf/moonshotai/kimi-k2.7-code"),
413
413
  messages: pruneMessages({
414
414
  messages: await convertToModelMessages(this.messages),
415
415
  reasoning: "before-last-message",
package/dist/index.js CHANGED
@@ -3114,9 +3114,17 @@ var AIChatAgent = class AIChatAgent extends Agent {
3114
3114
  }
3115
3115
  }
3116
3116
  let eventToSend = data;
3117
- if (continuation && data.type === "start" && "messageId" in data) {
3118
- const { messageId: _, ...rest } = data;
3119
- eventToSend = rest;
3117
+ if (data.type === "start") {
3118
+ if (continuation && "messageId" in data) {
3119
+ const { messageId: _, ...rest } = data;
3120
+ eventToSend = rest;
3121
+ } else if (!continuation) {
3122
+ const startData = data;
3123
+ if (startData.messageId == null) eventToSend = {
3124
+ ...startData,
3125
+ messageId: message.id
3126
+ };
3127
+ }
3120
3128
  }
3121
3129
  if (data.type === "finish" && "finishReason" in data) {
3122
3130
  const { finishReason, ...rest } = data;