Explorer

html-ui.rpc

description
type
Fn(
  config: @html-ui.config,
  method: String,
  request: String,
  then: Fn(response: @html-ui.response) -> @definy.service-io
) -> @definy.service-io
expression
fn(config$0, method$1, request$2, then$3) =>
  let arguments$4 = match @definy.parse-json(text: $2) {
      #ok(value$5) =>
        $5,
      #error(_) =>
        #null<@definy.json>
    };
  @definy.service-io-then-respond(
    io: match @std.string-starts-with(value: $1, prefix: "definy_") {
      true =>
        match @definy.mcp-find-tool(tools: @definy.mcp-tools, name: $1, index: 0) {
          #some(tool$6) =>
            $6.handler(arguments: $4, request: $0.request),
          #none(_) =>
            @definy.mcp-text-error(text: @core.string-concat(left: "No tool: ", right: $1))
        },
      false =>
        match @definy.handle-rpc(method: $1, request: $0.request) {
          #some(handler$8) =>
            $8(request: $4),
          #none(_) =>
            @definy.mcp-text-error(text: @core.string-concat(left: "No RPC method: ", right: $1))
        }
    },
    respond: fn(response$7) =>
      $3(response: @html-ui.service-response(response: $7))
  )
visibility
public
html-ui.rpc (project html-ui, branch main, snapshot Daaw3vbJhY15cDW6JsA4JuXvffjj_qFyxoZQMUM8hvQ)
id: PrEClZOcEqjdyK47DQWxOmaLajZ6af7vsIuJqHWXJhc
content hash: dLJaxZBsF3edjjggudpcRoosVCwd_L6fXaOyHIHil24