simple-agents-wasm 0.3.5 → 0.3.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": "simple-agents-wasm",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Browser-compatible SimpleAgents client for OpenAI-compatible providers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"index.d.ts",
|
|
19
19
|
"workflow_stream_printer.mjs",
|
|
20
20
|
"workflow_stream_printer.d.ts",
|
|
21
|
+
"workflow_event.d.ts",
|
|
21
22
|
"runtime",
|
|
22
23
|
"README.md",
|
|
23
24
|
"pkg",
|
|
@@ -34,6 +35,9 @@
|
|
|
34
35
|
"types": "./workflow_stream_printer.d.ts",
|
|
35
36
|
"import": "./workflow_stream_printer.mjs",
|
|
36
37
|
"default": "./workflow_stream_printer.mjs"
|
|
38
|
+
},
|
|
39
|
+
"./workflow_event": {
|
|
40
|
+
"types": "./workflow_event.d.ts"
|
|
37
41
|
}
|
|
38
42
|
},
|
|
39
43
|
"engines": {
|
|
Binary file
|
package/rust/Cargo.toml
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event names emitted by the Rust YAML workflow runner (stream callbacks).
|
|
3
|
+
* Source of truth: crates/simple-agents-workflow/src/yaml_runner/ (execute.rs,
|
|
4
|
+
* client_executor.rs, node_execution.rs).
|
|
5
|
+
* The runner may add new types without a semver bump; treat as open-ended.
|
|
6
|
+
*/
|
|
7
|
+
export type WorkflowRunnerEventType =
|
|
8
|
+
| 'workflow_started'
|
|
9
|
+
| 'workflow_completed'
|
|
10
|
+
| 'node_started'
|
|
11
|
+
| 'node_completed'
|
|
12
|
+
| 'resolved_llm_input'
|
|
13
|
+
| 'node_stream_delta'
|
|
14
|
+
| 'node_stream_thinking_delta'
|
|
15
|
+
| 'node_stream_output_delta'
|
|
16
|
+
| 'node_tool_call_requested'
|
|
17
|
+
| 'node_tool_call_completed'
|
|
18
|
+
| 'node_tool_call_failed'
|
|
19
|
+
| 'node_tool_roundtrip_completed'
|
|
20
|
+
| 'node_healed'
|
|
21
|
+
| (string & {})
|
|
22
|
+
|
|
23
|
+
export interface WorkflowRunnerEvent {
|
|
24
|
+
event_type: WorkflowRunnerEventType
|
|
25
|
+
node_id?: string
|
|
26
|
+
step_id?: string
|
|
27
|
+
node_kind?: string
|
|
28
|
+
streamable?: boolean
|
|
29
|
+
message?: string
|
|
30
|
+
delta?: string
|
|
31
|
+
token_kind?: string
|
|
32
|
+
is_terminal_node_token?: boolean
|
|
33
|
+
elapsed_ms?: number
|
|
34
|
+
metadata?: Record<string, unknown>
|
|
35
|
+
}
|
|
@@ -10,3 +10,16 @@ export interface WorkflowStreamPrinterOptions {
|
|
|
10
10
|
export function createWorkflowStreamPrinter(
|
|
11
11
|
options?: WorkflowStreamPrinterOptions,
|
|
12
12
|
): (event: Record<string, unknown>) => void;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Ready-made `onEvent` callback that prints streamed tokens inline and silences
|
|
16
|
+
* lifecycle events. A simpler alternative to {@link createWorkflowStreamPrinter}
|
|
17
|
+
* (no step headers, no state).
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { defaultOnEvent } from 'simple-agents-wasm/workflow_stream_printer';
|
|
22
|
+
* await client.runWorkflow(yaml, input, { onEvent: defaultOnEvent });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function defaultOnEvent(event: Record<string, unknown>): void;
|
|
@@ -85,3 +85,31 @@ export function createWorkflowStreamPrinter(options = {}) {
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Ready-made `onEvent` callback that prints streamed tokens inline and silences
|
|
91
|
+
* lifecycle events. A simpler alternative to {@link createWorkflowStreamPrinter}
|
|
92
|
+
* (no step headers, no state).
|
|
93
|
+
*
|
|
94
|
+
* Usage:
|
|
95
|
+
* ```js
|
|
96
|
+
* import { defaultOnEvent } from 'simple-agents-wasm/workflow_stream_printer';
|
|
97
|
+
* await client.runWorkflow(yaml, input, { onEvent: defaultOnEvent });
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @param {Record<string, unknown>} event
|
|
101
|
+
*/
|
|
102
|
+
export function defaultOnEvent(event) {
|
|
103
|
+
const eventType = event?.event_type;
|
|
104
|
+
if (typeof eventType !== "string") return;
|
|
105
|
+
if (
|
|
106
|
+
eventType === "node_stream_delta" ||
|
|
107
|
+
eventType === "node_stream_thinking_delta" ||
|
|
108
|
+
eventType === "node_stream_output_delta"
|
|
109
|
+
) {
|
|
110
|
+
const delta = event.delta;
|
|
111
|
+
if (typeof delta === "string") {
|
|
112
|
+
writeChunk(delta);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|