simple-agents-wasm 0.3.0 → 0.3.2
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/index.d.ts +43 -3
- package/package.json +15 -1
- package/pkg/simple_agents_wasm.d.ts +2 -2
- package/pkg/simple_agents_wasm.js +7 -7
- package/pkg/simple_agents_wasm_bg.wasm +0 -0
- package/pkg/simple_agents_wasm_bg.wasm.d.ts +2 -2
- package/rust/Cargo.toml +1 -1
- package/workflow_stream_printer.d.ts +12 -0
- package/workflow_stream_printer.mjs +87 -0
package/index.d.ts
CHANGED
|
@@ -100,10 +100,43 @@ export interface ClientConfig {
|
|
|
100
100
|
headers?: Record<string, string>;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
/** Matches Rust `YamlWorkflowTelemetryConfig` JSON (snake_case). */
|
|
104
|
+
export interface WorkflowTelemetryConfig {
|
|
105
|
+
enabled?: boolean;
|
|
106
|
+
nerdstats?: boolean;
|
|
107
|
+
sample_rate?: number;
|
|
108
|
+
payload_mode?: "full_payload" | "redacted_payload";
|
|
109
|
+
retention_days?: number;
|
|
110
|
+
multi_tenant?: boolean;
|
|
111
|
+
tool_trace_mode?: "full" | "redacted" | "off";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface WorkflowTraceContext {
|
|
115
|
+
trace_id?: string;
|
|
116
|
+
span_id?: string;
|
|
117
|
+
parent_span_id?: string;
|
|
118
|
+
traceparent?: string;
|
|
119
|
+
tracestate?: string;
|
|
120
|
+
baggage?: Record<string, string>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface WorkflowTraceTenant {
|
|
124
|
+
workspace_id?: string;
|
|
125
|
+
user_id?: string;
|
|
126
|
+
conversation_id?: string;
|
|
127
|
+
request_id?: string;
|
|
128
|
+
run_id?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface WorkflowTraceConfig {
|
|
132
|
+
context?: WorkflowTraceContext;
|
|
133
|
+
tenant?: WorkflowTraceTenant;
|
|
134
|
+
}
|
|
135
|
+
|
|
103
136
|
export interface WorkflowRunOptions {
|
|
104
|
-
telemetry?: Record<string, unknown>;
|
|
105
|
-
trace?: Record<string, unknown>;
|
|
106
137
|
model?: string;
|
|
138
|
+
telemetry?: WorkflowTelemetryConfig;
|
|
139
|
+
trace?: WorkflowTraceConfig;
|
|
107
140
|
onEvent?: (event: Record<string, unknown>) => void;
|
|
108
141
|
functions?: Record<
|
|
109
142
|
string,
|
|
@@ -114,6 +147,12 @@ export interface WorkflowRunOptions {
|
|
|
114
147
|
>;
|
|
115
148
|
}
|
|
116
149
|
|
|
150
|
+
/** Common workflow `input` fields; extra keys are allowed for workflow-specific payloads. */
|
|
151
|
+
export interface WorkflowInputFields {
|
|
152
|
+
email_text?: string;
|
|
153
|
+
[key: string]: unknown;
|
|
154
|
+
}
|
|
155
|
+
|
|
117
156
|
export interface WorkflowRunEvent {
|
|
118
157
|
stepId: string;
|
|
119
158
|
stepType: string;
|
|
@@ -132,6 +171,7 @@ export interface WorkflowExecutionFlags {
|
|
|
132
171
|
healing?: boolean;
|
|
133
172
|
workflow_streaming?: boolean;
|
|
134
173
|
node_llm_streaming?: boolean;
|
|
174
|
+
split_stream_deltas?: boolean;
|
|
135
175
|
}
|
|
136
176
|
|
|
137
177
|
export interface WorkflowExecutionRequest {
|
|
@@ -139,7 +179,7 @@ export interface WorkflowExecutionRequest {
|
|
|
139
179
|
messages: MessageInput[];
|
|
140
180
|
context?: Record<string, unknown>;
|
|
141
181
|
media?: Record<string, unknown>;
|
|
142
|
-
input?:
|
|
182
|
+
input?: WorkflowInputFields;
|
|
143
183
|
execution?: WorkflowExecutionFlags;
|
|
144
184
|
workflow_options?: WorkflowRunOptions;
|
|
145
185
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-agents-wasm",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Browser-compatible SimpleAgents client for OpenAI-compatible providers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -16,12 +16,26 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"index.js",
|
|
18
18
|
"index.d.ts",
|
|
19
|
+
"workflow_stream_printer.mjs",
|
|
20
|
+
"workflow_stream_printer.d.ts",
|
|
19
21
|
"runtime",
|
|
20
22
|
"README.md",
|
|
21
23
|
"pkg",
|
|
22
24
|
"rust/Cargo.toml",
|
|
23
25
|
"rust/src"
|
|
24
26
|
],
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./index.d.ts",
|
|
30
|
+
"import": "./index.js",
|
|
31
|
+
"default": "./index.js"
|
|
32
|
+
},
|
|
33
|
+
"./workflow_stream_printer": {
|
|
34
|
+
"types": "./workflow_stream_printer.d.ts",
|
|
35
|
+
"import": "./workflow_stream_printer.mjs",
|
|
36
|
+
"default": "./workflow_stream_printer.mjs"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
25
39
|
"engines": {
|
|
26
40
|
"node": ">=18"
|
|
27
41
|
},
|
|
@@ -27,8 +27,8 @@ export interface InitOutput {
|
|
|
27
27
|
readonly wasmclient_runWorkflowYaml: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
28
28
|
readonly wasmclient_runWorkflowYamlString: (a: number, b: number, c: number, d: any, e: number) => any;
|
|
29
29
|
readonly wasmclient_streamEvents: (a: number, b: number, c: number, d: any, e: any, f: number) => any;
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
30
|
+
readonly wasm_bindgen__convert__closures_____invoke__h9f53f643b01d7c8e: (a: number, b: number, c: any) => [number, number];
|
|
31
|
+
readonly wasm_bindgen__convert__closures_____invoke__h05acb8c479b21d4b: (a: number, b: number, c: any, d: any) => void;
|
|
32
32
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
33
33
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
34
34
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
@@ -314,7 +314,7 @@ function __wbg_get_imports() {
|
|
|
314
314
|
const a = state0.a;
|
|
315
315
|
state0.a = 0;
|
|
316
316
|
try {
|
|
317
|
-
return
|
|
317
|
+
return wasm_bindgen__convert__closures_____invoke__h05acb8c479b21d4b(a, state0.b, arg0, arg1);
|
|
318
318
|
} finally {
|
|
319
319
|
state0.a = a;
|
|
320
320
|
}
|
|
@@ -394,8 +394,8 @@ function __wbg_get_imports() {
|
|
|
394
394
|
return ret;
|
|
395
395
|
},
|
|
396
396
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
397
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
398
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
397
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 146, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
398
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h9f53f643b01d7c8e);
|
|
399
399
|
return ret;
|
|
400
400
|
},
|
|
401
401
|
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
@@ -434,15 +434,15 @@ function __wbg_get_imports() {
|
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
-
function
|
|
438
|
-
const ret = wasm.
|
|
437
|
+
function wasm_bindgen__convert__closures_____invoke__h9f53f643b01d7c8e(arg0, arg1, arg2) {
|
|
438
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h9f53f643b01d7c8e(arg0, arg1, arg2);
|
|
439
439
|
if (ret[1]) {
|
|
440
440
|
throw takeFromExternrefTable0(ret[0]);
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
function
|
|
445
|
-
wasm.
|
|
444
|
+
function wasm_bindgen__convert__closures_____invoke__h05acb8c479b21d4b(arg0, arg1, arg2, arg3) {
|
|
445
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h05acb8c479b21d4b(arg0, arg1, arg2, arg3);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
const WasmClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
Binary file
|
|
@@ -9,8 +9,8 @@ export const wasmclient_new: (a: number, b: number, c: any) => [number, number,
|
|
|
9
9
|
export const wasmclient_runWorkflowYaml: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
10
10
|
export const wasmclient_runWorkflowYamlString: (a: number, b: number, c: number, d: any, e: number) => any;
|
|
11
11
|
export const wasmclient_streamEvents: (a: number, b: number, c: number, d: any, e: any, f: number) => any;
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
12
|
+
export const wasm_bindgen__convert__closures_____invoke__h9f53f643b01d7c8e: (a: number, b: number, c: any) => [number, number];
|
|
13
|
+
export const wasm_bindgen__convert__closures_____invoke__h05acb8c479b21d4b: (a: number, b: number, c: any, d: any) => void;
|
|
14
14
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
15
15
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
16
16
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/rust/Cargo.toml
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface WorkflowStreamPrinterOptions {
|
|
2
|
+
/** When true, print thinking vs output deltas instead of merged `node_stream_delta`. */
|
|
3
|
+
splitThinking?: boolean;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Build a default `onEvent` callback for {@link Client.streamWorkflow} (Node-friendly streaming;
|
|
8
|
+
* in browsers without `process.stdout`, falls back to `console.log` per chunk).
|
|
9
|
+
*/
|
|
10
|
+
export function createWorkflowStreamPrinter(
|
|
11
|
+
options?: WorkflowStreamPrinterOptions,
|
|
12
|
+
): (event: Record<string, unknown>) => void;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} WorkflowStreamPrinterOptions
|
|
3
|
+
* @property {boolean} [splitThinking] When true, print `node_stream_thinking_delta` and
|
|
4
|
+
* `node_stream_output_delta`; otherwise print `node_stream_delta`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Default `onEvent` handler for {@link Client.streamWorkflow} that prints stream tokens to stdout.
|
|
9
|
+
* @param {WorkflowStreamPrinterOptions} [options]
|
|
10
|
+
* @returns {(event: Record<string, unknown>) => void}
|
|
11
|
+
*/
|
|
12
|
+
function writeChunk(chunk) {
|
|
13
|
+
if (typeof process !== "undefined" && process.stdout?.write) {
|
|
14
|
+
process.stdout.write(chunk);
|
|
15
|
+
} else if (typeof chunk === "string" && chunk.length > 0) {
|
|
16
|
+
console.log(chunk);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function writeLine() {
|
|
21
|
+
if (typeof process !== "undefined" && process.stdout?.write) {
|
|
22
|
+
process.stdout.write("\n");
|
|
23
|
+
} else {
|
|
24
|
+
console.log();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createWorkflowStreamPrinter(options = {}) {
|
|
29
|
+
const splitThinking = options.splitThinking === true;
|
|
30
|
+
/** @type {{ currentNode: string | null, lineOpen: boolean, lastTokenLabel: string | null }} */
|
|
31
|
+
const state = { currentNode: null, lineOpen: false, lastTokenLabel: null };
|
|
32
|
+
|
|
33
|
+
return (event) => {
|
|
34
|
+
const eventType = event?.event_type;
|
|
35
|
+
if (typeof eventType !== "string") return;
|
|
36
|
+
|
|
37
|
+
let isStream = eventType === "node_stream_delta";
|
|
38
|
+
if (splitThinking) {
|
|
39
|
+
isStream =
|
|
40
|
+
eventType === "node_stream_thinking_delta" ||
|
|
41
|
+
eventType === "node_stream_output_delta";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const delta = typeof event.delta === "string" ? event.delta : "";
|
|
45
|
+
if (isStream && delta !== "") {
|
|
46
|
+
let displayId =
|
|
47
|
+
typeof event.node_id === "string"
|
|
48
|
+
? event.node_id
|
|
49
|
+
: typeof event.step_id === "string"
|
|
50
|
+
? event.step_id
|
|
51
|
+
: "?";
|
|
52
|
+
|
|
53
|
+
if (state.currentNode !== displayId) {
|
|
54
|
+
if (state.lineOpen) writeLine();
|
|
55
|
+
writeChunk(`\nStep: ${displayId}\nStreaming: `);
|
|
56
|
+
state.currentNode = displayId;
|
|
57
|
+
state.lineOpen = true;
|
|
58
|
+
state.lastTokenLabel = null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (splitThinking) {
|
|
62
|
+
const parts = [];
|
|
63
|
+
if (typeof event.token_kind === "string" && event.token_kind.trim()) {
|
|
64
|
+
parts.push(event.token_kind.trim());
|
|
65
|
+
}
|
|
66
|
+
if (event.is_terminal_node_token === true) {
|
|
67
|
+
parts.push("terminal");
|
|
68
|
+
}
|
|
69
|
+
const tokenLabel = parts.length ? `[${parts.join(" ")}] ` : "";
|
|
70
|
+
if (tokenLabel && tokenLabel !== state.lastTokenLabel) {
|
|
71
|
+
if (state.lineOpen) writeLine();
|
|
72
|
+
writeChunk(`${tokenLabel}${displayId}: `);
|
|
73
|
+
state.lastTokenLabel = tokenLabel;
|
|
74
|
+
state.lineOpen = true;
|
|
75
|
+
}
|
|
76
|
+
writeChunk(delta);
|
|
77
|
+
} else {
|
|
78
|
+
writeChunk(delta);
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (eventType === "workflow_started" || eventType === "workflow_completed") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|