@koi-language/koi 1.0.4 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koi-language/koi",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Koi - Agent-first language. Calm orchestration.",
5
5
  "type": "module",
6
6
  "main": "src/runtime/index.js",
package/src/cli/koi.js CHANGED
@@ -505,7 +505,8 @@ Agent Greeter : Worker {
505
505
  - Add a motivational message or fun fact
506
506
  - Be brief (2-3 sentences)
507
507
 
508
- Return JSON: { "greeting": "your greeting here", "emoji": "an appropriate emoji" }
508
+ Use the return action with your greeting data:
509
+ { "greeting": "your greeting here", "emoji": "an appropriate emoji" }
509
510
  """
510
511
  }
511
512
  }
@@ -136,6 +136,30 @@ export class IncrementalJSONParser {
136
136
  actions.push(...objects);
137
137
  }
138
138
 
139
+ // If no "actions" array was found, the LLM returned raw JSON
140
+ // Wrap it in a return action so it can be executed properly
141
+ if (this.actionsStartIndex === -1 && this.buffer.length > 0) {
142
+ try {
143
+ const rawJSON = JSON.parse(this.buffer.trim());
144
+ // Check if it's not already an action (has actionType or intent)
145
+ if (!rawJSON.actionType && !rawJSON.actions) {
146
+ if (process.env.KOI_DEBUG_LLM) {
147
+ console.error(`[IncrementalParser] ⚠️ No "actions" array found - wrapping raw JSON in return action`);
148
+ }
149
+ return [{
150
+ actionType: 'direct',
151
+ intent: 'return',
152
+ data: rawJSON
153
+ }];
154
+ }
155
+ } catch (e) {
156
+ // Not valid JSON, return whatever objects we found
157
+ if (process.env.KOI_DEBUG_LLM) {
158
+ console.error(`[IncrementalParser] ⚠️ Failed to parse raw response as JSON: ${e.message}`);
159
+ }
160
+ }
161
+ }
162
+
139
163
  return actions;
140
164
  }
141
165