|
| 1 | +// SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> |
| 3 | + |
| 4 | +/// PanLL Agent Coordination command wrappers — Tauri invoke bridge for the |
| 5 | +/// coordination view panel. |
| 6 | +/// |
| 7 | +/// All commands invoke BoJ cartridge endpoints for multi-agent topology |
| 8 | +/// and strategy management. Uses `Tea_Cmd.call` for async operations. |
| 9 | + |
| 10 | +@val external invoke: (string, 'a) => promise<string> = "__TAURI__.core.invoke" |
| 11 | + |
| 12 | +/// Fetch the current agent coordination topology. |
| 13 | +/// Returns JSON with nodes, edges, and active strategy. |
| 14 | +let topology = ( |
| 15 | + tagger: result<string, string> => 'msg, |
| 16 | +): Tea_Cmd.t<'msg> => { |
| 17 | + Tea_Cmd.call(callbacks => { |
| 18 | + invoke("agent_coord_topology", {}) |
| 19 | + ->Promise.then(result => { |
| 20 | + callbacks.enqueue(tagger(Ok(result))) |
| 21 | + Promise.resolve() |
| 22 | + }) |
| 23 | + ->Promise.catch(_err => { |
| 24 | + callbacks.enqueue(tagger(Error("Failed to fetch coordination topology"))) |
| 25 | + Promise.resolve() |
| 26 | + }) |
| 27 | + ->ignore |
| 28 | + }) |
| 29 | +} |
| 30 | + |
| 31 | +/// Set the coordination strategy for the agent system. |
| 32 | +/// Returns JSON confirming the strategy change. |
| 33 | +let setStrategy = ( |
| 34 | + strategyId: string, |
| 35 | + tagger: result<string, string> => 'msg, |
| 36 | +): Tea_Cmd.t<'msg> => { |
| 37 | + Tea_Cmd.call(callbacks => { |
| 38 | + invoke("agent_coord_set_strategy", {"strategy_id": strategyId}) |
| 39 | + ->Promise.then(result => { |
| 40 | + callbacks.enqueue(tagger(Ok(result))) |
| 41 | + Promise.resolve() |
| 42 | + }) |
| 43 | + ->Promise.catch(_err => { |
| 44 | + callbacks.enqueue(tagger(Error("Failed to set coordination strategy"))) |
| 45 | + Promise.resolve() |
| 46 | + }) |
| 47 | + ->ignore |
| 48 | + }) |
| 49 | +} |
0 commit comments