simple-agents-wasm 0.5.1 → 0.5.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/package.json
CHANGED
|
@@ -38,7 +38,7 @@ export interface InitOutput {
|
|
|
38
38
|
readonly wasmclient_streamEvents: (a: number, b: number, c: number, d: any, e: any, f: number) => any;
|
|
39
39
|
readonly wasm_bindgen__convert__closures_____invoke__h327a4c82efcf6931: (a: number, b: number, c: any) => [number, number];
|
|
40
40
|
readonly wasm_bindgen__convert__closures_____invoke__h67e61867e7d8792e: (a: number, b: number, c: any, d: any) => void;
|
|
41
|
-
readonly
|
|
41
|
+
readonly wasm_bindgen__convert__closures_____invoke__h118a9f0d02b7a2c3: (a: number, b: number, c: any) => void;
|
|
42
42
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
43
43
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
44
44
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
@@ -414,8 +414,8 @@ function __wbg_get_imports() {
|
|
|
414
414
|
return ret;
|
|
415
415
|
},
|
|
416
416
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
417
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
418
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
417
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 64, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
418
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h118a9f0d02b7a2c3);
|
|
419
419
|
return ret;
|
|
420
420
|
},
|
|
421
421
|
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
@@ -454,8 +454,8 @@ function __wbg_get_imports() {
|
|
|
454
454
|
};
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
function
|
|
458
|
-
wasm.
|
|
457
|
+
function wasm_bindgen__convert__closures_____invoke__h118a9f0d02b7a2c3(arg0, arg1, arg2) {
|
|
458
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h118a9f0d02b7a2c3(arg0, arg1, arg2);
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
function wasm_bindgen__convert__closures_____invoke__h327a4c82efcf6931(arg0, arg1, arg2) {
|
|
Binary file
|
|
@@ -11,7 +11,7 @@ export const wasmclient_runYamlString: (a: number, b: number, c: number, d: any,
|
|
|
11
11
|
export const wasmclient_streamEvents: (a: number, b: number, c: number, d: any, e: any, f: number) => any;
|
|
12
12
|
export const wasm_bindgen__convert__closures_____invoke__h327a4c82efcf6931: (a: number, b: number, c: any) => [number, number];
|
|
13
13
|
export const wasm_bindgen__convert__closures_____invoke__h67e61867e7d8792e: (a: number, b: number, c: any, d: any) => void;
|
|
14
|
-
export const
|
|
14
|
+
export const wasm_bindgen__convert__closures_____invoke__h118a9f0d02b7a2c3: (a: number, b: number, c: any) => void;
|
|
15
15
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
16
16
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
17
17
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/rust/Cargo.toml
CHANGED
package/rust/src/lib.rs
CHANGED
|
@@ -110,7 +110,8 @@ struct GraphWorkflowNode {
|
|
|
110
110
|
|
|
111
111
|
#[derive(Deserialize, Clone)]
|
|
112
112
|
struct GraphNodeConfig {
|
|
113
|
-
|
|
113
|
+
user_input_prompt: Option<String>,
|
|
114
|
+
node_system_prompt: Option<String>,
|
|
114
115
|
payload: Option<JsonValue>,
|
|
115
116
|
output_schema: Option<JsonValue>,
|
|
116
117
|
}
|
|
@@ -127,7 +128,6 @@ struct GraphLlmCall {
|
|
|
127
128
|
model: Option<String>,
|
|
128
129
|
temperature: Option<f64>,
|
|
129
130
|
messages_path: Option<String>,
|
|
130
|
-
append_prompt_as_user: Option<bool>,
|
|
131
131
|
stream: Option<bool>,
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -156,7 +156,8 @@ struct WorkflowStep {
|
|
|
156
156
|
step_type: String,
|
|
157
157
|
key: Option<String>,
|
|
158
158
|
value: Option<JsonValue>,
|
|
159
|
-
|
|
159
|
+
user_input_prompt: Option<String>,
|
|
160
|
+
node_system_prompt: Option<String>,
|
|
160
161
|
condition: Option<WorkflowCondition>,
|
|
161
162
|
then: Option<String>,
|
|
162
163
|
r#else: Option<String>,
|
|
@@ -1581,10 +1582,17 @@ impl WasmClient {
|
|
|
1581
1582
|
))
|
|
1582
1583
|
})?;
|
|
1583
1584
|
|
|
1584
|
-
let
|
|
1585
|
+
let user_input_prompt = interpolate_graph_prompt(
|
|
1585
1586
|
node.config
|
|
1586
1587
|
.as_ref()
|
|
1587
|
-
.and_then(|config| config.
|
|
1588
|
+
.and_then(|config| config.user_input_prompt.as_deref())
|
|
1589
|
+
.unwrap_or_default(),
|
|
1590
|
+
&graph_context,
|
|
1591
|
+
);
|
|
1592
|
+
let node_system_prompt = interpolate_graph_prompt(
|
|
1593
|
+
node.config
|
|
1594
|
+
.as_ref()
|
|
1595
|
+
.and_then(|config| config.node_system_prompt.as_deref())
|
|
1588
1596
|
.unwrap_or_default(),
|
|
1589
1597
|
&graph_context,
|
|
1590
1598
|
);
|
|
@@ -1596,10 +1604,22 @@ impl WasmClient {
|
|
|
1596
1604
|
serde_json::from_value::<Vec<MessageInput>>(value.clone()).ok()
|
|
1597
1605
|
})
|
|
1598
1606
|
.unwrap_or_default();
|
|
1599
|
-
if
|
|
1607
|
+
if !node_system_prompt.trim().is_empty() {
|
|
1608
|
+
history.insert(
|
|
1609
|
+
0,
|
|
1610
|
+
MessageInput {
|
|
1611
|
+
role: "system".to_string(),
|
|
1612
|
+
content: JsonValue::String(node_system_prompt.clone()),
|
|
1613
|
+
name: None,
|
|
1614
|
+
tool_call_id: None,
|
|
1615
|
+
tool_calls: None,
|
|
1616
|
+
},
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
if !user_input_prompt.trim().is_empty() {
|
|
1600
1620
|
history.push(MessageInput {
|
|
1601
1621
|
role: "user".to_string(),
|
|
1602
|
-
content: JsonValue::String(
|
|
1622
|
+
content: JsonValue::String(user_input_prompt),
|
|
1603
1623
|
name: None,
|
|
1604
1624
|
tool_call_id: None,
|
|
1605
1625
|
tool_calls: None,
|
|
@@ -1610,7 +1630,20 @@ impl WasmClient {
|
|
|
1610
1630
|
.map_err(|_| js_error("failed to serialize graph llm messages"))?,
|
|
1611
1631
|
)?
|
|
1612
1632
|
} else {
|
|
1613
|
-
|
|
1633
|
+
if user_input_prompt.trim().is_empty() {
|
|
1634
|
+
return Err(config_error(format!(
|
|
1635
|
+
"llm_call node '{}' requires config.user_input_prompt when messages_path is not provided",
|
|
1636
|
+
node.id
|
|
1637
|
+
)));
|
|
1638
|
+
}
|
|
1639
|
+
if node_system_prompt.trim().is_empty() {
|
|
1640
|
+
JsValue::from_str(&user_input_prompt)
|
|
1641
|
+
} else {
|
|
1642
|
+
json_value_to_js_plain(&json!([
|
|
1643
|
+
{"role":"system","content": node_system_prompt},
|
|
1644
|
+
{"role":"user","content": user_input_prompt}
|
|
1645
|
+
]))?
|
|
1646
|
+
}
|
|
1614
1647
|
};
|
|
1615
1648
|
|
|
1616
1649
|
let opts = json!({ "temperature": llm.temperature });
|
|
@@ -2030,13 +2063,33 @@ impl WasmClient {
|
|
|
2030
2063
|
step.id
|
|
2031
2064
|
))
|
|
2032
2065
|
})?;
|
|
2033
|
-
let
|
|
2034
|
-
|
|
2066
|
+
let user_input_prompt = interpolate_string(
|
|
2067
|
+
step.user_input_prompt.as_deref().unwrap_or_default(),
|
|
2068
|
+
&context,
|
|
2069
|
+
);
|
|
2070
|
+
let node_system_prompt = interpolate_string(
|
|
2071
|
+
step.node_system_prompt.as_deref().unwrap_or_default(),
|
|
2072
|
+
&context,
|
|
2073
|
+
);
|
|
2074
|
+
if user_input_prompt.trim().is_empty() {
|
|
2075
|
+
return Err(config_error(format!(
|
|
2076
|
+
"llm_call step '{}' requires user_input_prompt",
|
|
2077
|
+
step.id
|
|
2078
|
+
)));
|
|
2079
|
+
}
|
|
2080
|
+
let prompt_input = if node_system_prompt.trim().is_empty() {
|
|
2081
|
+
JsValue::from_str(&user_input_prompt)
|
|
2082
|
+
} else {
|
|
2083
|
+
json_value_to_js_plain(&json!([
|
|
2084
|
+
{"role": "system", "content": node_system_prompt},
|
|
2085
|
+
{"role": "user", "content": user_input_prompt}
|
|
2086
|
+
]))?
|
|
2087
|
+
};
|
|
2035
2088
|
let opts = json!({ "temperature": step.temperature });
|
|
2036
2089
|
let completion_js = self
|
|
2037
2090
|
.complete(
|
|
2038
2091
|
model,
|
|
2039
|
-
|
|
2092
|
+
prompt_input,
|
|
2040
2093
|
Some(json_value_to_js_plain(&opts)?),
|
|
2041
2094
|
)
|
|
2042
2095
|
.await?;
|