Explorer

html-ui.commit-release

As of snapshot H1ryuUovIX. See the latest

description
Build the release of host.js and commit it to the main of host-release through the MCP of your own definy server (definy_commit_parts, signed with its key): runtime-script (definy.cloudflare-service-runtime-script), app-wasm-base64 (handler compiled with core.compile-to-wasm) and host-script (definy.node-host-script). Send it to the public server with definy_push afterwards (docs/local-server.md)
type
Fn(
  mcp_url: String,
  mcp_token: Secret,
  handler: Code<Record{
    fetch: Fn(request: @"a1pi7OnUxY7Cb5hF-I2zLNV5-vq9vdg6OhS7Oj-0h1c") -> @definy.service-io,
    scheduled: Fn(time_ms: Number) -> @definy.service-io
  }>
) -> @wasi.io
expression
fn(mcp_url$0, mcp_token$1, handler$2) =>
  #get_parts<@wasi.io>({
    ids: $2.part_ids,
    then: fn(parts$3) =>
      #outgoing_request<@wasi.io>({
        request: {
          method: "POST",
          url: $0,
          headers: [
            {name: "Content-Type", value: "application/json"},
            {name: "Accept", value: "application/json, text/event-stream"}
          ],
          secret_headers: [{name: "Authorization", prefix: "Bearer ", secret: $1}],
          body: @core.string-to-bytes(
            value: @definy.json-to-string(
              value: #object<@definy.json>([
                {key: "jsonrpc", value: #string<@definy.json>("2.0")},
                {key: "id", value: #number<@definy.json>(1)},
                {key: "method", value: #string<@definy.json>("tools/call")},
                {
                  key: "params",
                  value: #object<@definy.json>([
                    {key: "name", value: #string<@definy.json>("definy_commit_parts")},
                    {
                      key: "arguments",
                      value: #object<@definy.json>([
                        {key: "project", value: #string<@definy.json>("host-release")},
                        {key: "branch", value: #string<@definy.json>("main")},
                        {key: "message", value: #string<@definy.json>("Build the release (html-ui.build-release)")},
                        {
                          key: "changes",
                          value: #array<@definy.json>([
                            @html-ui.release-change(part: "host-release.runtime-script", value: @definy.cloudflare-service-runtime-script),
                            @html-ui.release-change(
                              part: "host-release.app-wasm-base64",
                              value: @std.bytes-to-base64(bytes: @core.compile-to-wasm(expr: $2.expression, parts: $3))
                            ),
                            @html-ui.release-change(part: "host-release.host-script", value: @definy.node-host-script)
                          ])
                        }
                      ])
                    }
                  ])
                }
              ])
            )
          )
        },
        then: fn(result$4) =>
          match $4 {
            #error(message$5) =>
              #done<@wasi.io>(@core.string-concat(left: "The MCP request failed: ", right: $5)),
            #ok(response$6) =>
              #done<@wasi.io>(@std.string-join(items: ["HTTP ", @std.number-to-string(value: $6.status), ": ", $6.text], separator: ""))
          }
      })
  })
visibility
public
html-ui.commit-release (project html-ui, branch main, snapshot H1ryuUovIXcTVEe5d12w2Sh0pl2WqjPHS4U8D1Wo118)
id: cHr0ydO74uS21RuTcSq1yFPVkjl_9t79E4ElLmtJ5CE
content hash: G_3oE9ABgDPh3N2K6mO95PPEr9LydixtZcMxkSopYPg