agency-lang 0.0.76 → 0.0.77

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.
@@ -553,6 +553,7 @@ export class TypeScriptGenerator extends BaseGenerator {
553
553
  value: "string",
554
554
  };
555
555
  const zodSchema = mapTypeToZodSchema(_variableType, this.typeAliases);
556
+ const clientConfig = prompt.config ? this.processNode(prompt.config) : "{}";
556
557
  // Build prompt construction code
557
558
  const promptCode = this.buildPromptString({
558
559
  segments: prompt.segments,
@@ -578,7 +579,6 @@ export class TypeScriptGenerator extends BaseGenerator {
578
579
  }
579
580
  return `{ name: "${toolName}", params: __${toolName}ToolParams, execute: ${toolName}, isBuiltin: false }`;
580
581
  });
581
- const clientConfig = prompt.config ? this.processNode(prompt.config) : "{}";
582
582
  let threadExpr;
583
583
  if (this.parallelThreadVars[variableName]) {
584
584
  threadExpr = `__threads.get(${this.parallelThreadVars[variableName]})`;
@@ -191,9 +191,19 @@ export async function runPrompt(args) {
191
191
  2. use messages passed in as argument (add onto message thread)
192
192
  3. create an empty message thread just for this prompt
193
193
  */
194
- let messages = args.interruptData?.messages
195
- ? MessageThread.fromJSON(args.interruptData.messages)
196
- : args.messages || new MessageThread();
194
+ let messages;
195
+ if (args.interruptData?.messages) {
196
+ messages = MessageThread.fromJSON(args.interruptData.messages);
197
+ }
198
+ else if (clientConfig.messages) {
199
+ messages = MessageThread.fromJSON(clientConfig.messages);
200
+ }
201
+ else if (args.messages) {
202
+ messages = args.messages;
203
+ }
204
+ else {
205
+ messages = new MessageThread();
206
+ }
197
207
  // Restore state after interrupt
198
208
  let toolCalls = [];
199
209
  if (args.interruptData === undefined) {
@@ -14,5 +14,5 @@ export declare class MessageThread {
14
14
  newChild(): MessageThread;
15
15
  newSubthreadChild(): MessageThread;
16
16
  toJSON(): MessageThreadJSON;
17
- static fromJSON(json: MessageThreadJSON | MessageThread | smoltalk.MessageJSON[]): MessageThread;
17
+ static fromJSON(json: MessageThreadJSON | MessageThread | smoltalk.MessageJSON[] | smoltalk.Message[]): MessageThread;
18
18
  }
@@ -41,7 +41,19 @@ export class MessageThread {
41
41
  if (json instanceof MessageThread)
42
42
  return json;
43
43
  const thread = new MessageThread();
44
- thread.messages = (Array.isArray(json) ? json : json.messages || []).map((m) => smoltalk.messageFromJSON(m));
44
+ let _messages = [];
45
+ if (Array.isArray(json)) {
46
+ _messages = json;
47
+ }
48
+ else if ("messages" in json) {
49
+ _messages = json.messages;
50
+ }
51
+ else {
52
+ throw new Error("Invalid input for MessageThread.fromJSON");
53
+ }
54
+ const messagesToJSON = _messages.map((m) => "toJSON" in m ? m.toJSON() : m);
55
+ const smoltalkMessages = messagesToJSON.map((m) => smoltalk.messageFromJSON(m));
56
+ thread.setMessages(smoltalkMessages);
45
57
  return thread;
46
58
  }
47
59
  }
@@ -11,6 +11,10 @@ export function extractResponse(rawValue, schema) {
11
11
  }
12
12
  return direct.data;
13
13
  }
14
+ // 1.5 Look for { type: "object", properties: { response: { ... } } } pattern
15
+ if (rawValue.type === "object" && rawValue.properties) {
16
+ return extractResponse(rawValue.properties, schema);
17
+ }
14
18
  // 2. String → try JSON.parse, then recurse
15
19
  if (typeof rawValue === "string") {
16
20
  const stripped = rawValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agency-lang",
3
- "version": "0.0.76",
3
+ "version": "0.0.77",
4
4
  "description": "The Agency language",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -66,7 +66,7 @@
66
66
  "nanoid": "^5.1.6",
67
67
  "ora": "^9.3.0",
68
68
  "prompts": "^2.4.2",
69
- "smoltalk": "^0.0.61",
69
+ "smoltalk": "^0.0.62",
70
70
  "tarsec": "^0.1.8",
71
71
  "termcolors": "github:egonSchiele/termcolors",
72
72
  "typestache": "^0.4.4",