@axlsdk/axl 0.13.5 → 0.13.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
@@ -303,6 +303,8 @@ const result = await runtime.execute('my-workflow', { query: 'Hello' });
303
303
  const stream = runtime.stream('my-workflow', { query: 'Hello' });
304
304
  for await (const event of stream) {
305
305
  if (event.type === 'token') process.stdout.write(event.data);
306
+ if (event.type === 'error') console.error('Stream error:', event.message);
307
+ if (event.type === 'done') console.log('Result:', event.data);
306
308
  }
307
309
 
308
310
  // Sessions
package/dist/index.cjs CHANGED
@@ -2838,7 +2838,7 @@ ${JSON.stringify(jsonSchema, null, 2)}`;
2838
2838
  });
2839
2839
  continue;
2840
2840
  }
2841
- this.onToolCall?.({ name: toolName, args: toolArgs2 });
2841
+ this.onToolCall?.({ name: toolName, args: toolArgs2, callId: toolCall.id });
2842
2842
  const toolStart2 = Date.now();
2843
2843
  const executeOverride = async () => {
2844
2844
  let toolResult3;
@@ -2871,7 +2871,7 @@ ${JSON.stringify(jsonSchema, null, 2)}`;
2871
2871
  agent: agent2._name,
2872
2872
  tool: toolName,
2873
2873
  duration: Date.now() - toolStart2,
2874
- data: { args: toolArgs2, result: toolResult2 }
2874
+ data: { args: toolArgs2, result: toolResult2, callId: toolCall.id }
2875
2875
  });
2876
2876
  currentMessages.push({
2877
2877
  role: "tool",
@@ -2902,7 +2902,7 @@ ${JSON.stringify(jsonSchema, null, 2)}`;
2902
2902
  });
2903
2903
  continue;
2904
2904
  }
2905
- this.onToolCall?.({ name: toolName, args: toolArgs });
2905
+ this.onToolCall?.({ name: toolName, args: toolArgs, callId: toolCall.id });
2906
2906
  const toolStart = Date.now();
2907
2907
  if (tool2 && tool2.requireApproval) {
2908
2908
  const approvalFn = async () => {
@@ -3031,7 +3031,7 @@ ${JSON.stringify(jsonSchema, null, 2)}`;
3031
3031
  agent: agent2._name,
3032
3032
  tool: traceName,
3033
3033
  duration: Date.now() - toolStart,
3034
- data: { args: toolArgs, result: toolResult }
3034
+ data: { args: toolArgs, result: toolResult, callId: toolCall.id }
3035
3035
  });
3036
3036
  currentMessages.push({
3037
3037
  role: "tool",
@@ -4742,6 +4742,8 @@ var AxlStream = class _AxlStream extends import_node_stream.Readable {
4742
4742
  this.bus.on("__reject", (error) => rejectPromise(error));
4743
4743
  this.bus.on("error", () => {
4744
4744
  });
4745
+ this.promise.catch(() => {
4746
+ });
4745
4747
  }
4746
4748
  static STREAM_EVENTS = /* @__PURE__ */ new Set([
4747
4749
  "token",
@@ -4887,9 +4889,16 @@ var AxlStream = class _AxlStream extends import_node_stream.Readable {
4887
4889
  _error(error) {
4888
4890
  if (this.finished) return;
4889
4891
  this.finished = true;
4890
- const errorEvent = { type: "error", error };
4892
+ const errorEvent = { type: "error", message: error.message };
4891
4893
  this.bus.emit("error", errorEvent);
4894
+ this.push(errorEvent);
4892
4895
  this.push(null);
4896
+ const waiter = this.waiters.shift();
4897
+ if (waiter) {
4898
+ waiter({ value: errorEvent, done: false });
4899
+ } else {
4900
+ this.eventQueue.push(errorEvent);
4901
+ }
4893
4902
  for (const w of this.waiters) {
4894
4903
  w({ value: void 0, done: true });
4895
4904
  }
@@ -5742,6 +5751,7 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
5742
5751
  execInfo.status = "completed";
5743
5752
  execInfo.completedAt = Date.now();
5744
5753
  execInfo.duration = execInfo.completedAt - execInfo.startedAt;
5754
+ execInfo.result = output;
5745
5755
  ctx.log("workflow_end", {
5746
5756
  workflow: name,
5747
5757
  status: "completed",
@@ -5854,7 +5864,8 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
5854
5864
  axlStream._push({
5855
5865
  type: "tool_result",
5856
5866
  name: event.tool ?? "",
5857
- result: event.data?.result
5867
+ result: event.data?.result,
5868
+ callId: event.data?.callId
5858
5869
  });
5859
5870
  }
5860
5871
  axlStream._push({ type: "step", step: event.step, data: event });
@@ -5863,7 +5874,12 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
5863
5874
  axlStream._push({ type: "token", data: token });
5864
5875
  },
5865
5876
  onToolCall: (call) => {
5866
- axlStream._push({ type: "tool_call", name: call.name, args: call.args });
5877
+ axlStream._push({
5878
+ type: "tool_call",
5879
+ name: call.name,
5880
+ args: call.args,
5881
+ callId: call.callId
5882
+ });
5867
5883
  },
5868
5884
  onAgentStart: (info) => {
5869
5885
  axlStream._push({ type: "agent_start", agent: info.agent, model: info.model });
@@ -5897,6 +5913,7 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
5897
5913
  execInfo.status = "completed";
5898
5914
  execInfo.completedAt = Date.now();
5899
5915
  execInfo.duration = execInfo.completedAt - execInfo.startedAt;
5916
+ execInfo.result = result;
5900
5917
  wfCtx.log("workflow_end", {
5901
5918
  workflow: name,
5902
5919
  status: "completed",