simple-agents-wasm 0.2.30 → 0.2.31

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.js CHANGED
@@ -179,6 +179,35 @@ function interpolatePathTemplate(template, context) {
179
179
  });
180
180
  }
181
181
 
182
+ function interpolatePathValue(value, context) {
183
+ if (typeof value === "string") {
184
+ return value.replace(/{{\s*([^}]+)\s*}}/g, (_, token) => {
185
+ const resolved = getPathValue(context, token);
186
+ if (resolved === null || resolved === undefined) {
187
+ return "";
188
+ }
189
+ if (typeof resolved === "string") {
190
+ return resolved;
191
+ }
192
+ return JSON.stringify(resolved);
193
+ });
194
+ }
195
+
196
+ if (Array.isArray(value)) {
197
+ return value.map((entry) => interpolatePathValue(entry, context));
198
+ }
199
+
200
+ if (value !== null && value !== undefined && typeof value === "object") {
201
+ const output = {};
202
+ for (const [key, nested] of Object.entries(value)) {
203
+ output[key] = interpolatePathValue(nested, context);
204
+ }
205
+ return output;
206
+ }
207
+
208
+ return value;
209
+ }
210
+
182
211
  function maybeParseJson(text) {
183
212
  if (typeof text !== "string") {
184
213
  return text;
@@ -881,7 +910,7 @@ class BrowserJsClient {
881
910
  const workerOutput = await fn(
882
911
  {
883
912
  handler,
884
- payload: node.config?.payload ?? null,
913
+ payload: interpolatePathValue(node.config?.payload ?? null, graphContext),
885
914
  nodeId: node.id
886
915
  },
887
916
  graphContext
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-agents-wasm",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "description": "Browser-compatible SimpleAgents client for OpenAI-compatible providers",
5
5
  "type": "module",
6
6
  "main": "index.js",
Binary file
package/rust/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "simple-agents-wasm-rust"
3
- version = "0.2.30"
3
+ version = "0.2.31"
4
4
  edition = "2021"
5
5
  license = "MIT OR Apache-2.0"
6
6
 
package/rust/src/lib.rs CHANGED
@@ -538,6 +538,24 @@ fn interpolate_graph_prompt(input: &str, context: &JsonValue) -> String {
538
538
  output
539
539
  }
540
540
 
541
+ fn interpolate_graph_json(value: &JsonValue, context: &JsonValue) -> JsonValue {
542
+ match value {
543
+ JsonValue::String(s) => JsonValue::String(interpolate_graph_prompt(s, context)),
544
+ JsonValue::Array(items) => JsonValue::Array(
545
+ items
546
+ .iter()
547
+ .map(|item| interpolate_graph_json(item, context))
548
+ .collect(),
549
+ ),
550
+ JsonValue::Object(map) => JsonValue::Object(
551
+ map.iter()
552
+ .map(|(key, value)| (key.clone(), interpolate_graph_json(value, context)))
553
+ .collect(),
554
+ ),
555
+ _ => value.clone(),
556
+ }
557
+ }
558
+
541
559
  fn parse_json_from_text(value: &str) -> JsonValue {
542
560
  if let Ok(parsed) = serde_json::from_str::<JsonValue>(value) {
543
561
  return parsed;
@@ -1500,7 +1518,8 @@ impl WasmClient {
1500
1518
  "payload": node
1501
1519
  .config
1502
1520
  .as_ref()
1503
- .and_then(|config| config.payload.clone())
1521
+ .and_then(|config| config.payload.as_ref())
1522
+ .map(|payload| interpolate_graph_json(payload, &graph_context))
1504
1523
  .unwrap_or(JsonValue::Null),
1505
1524
  "nodeId": node.id.clone()
1506
1525
  });