← All procedures

procedure.define

Define a new procedure from an aggregation

MCPCLIbrowser
Package
@procedures/client · README
Path
["procedure","define"]
CLI
mark procedure define --path <string[]> --aggregation <object>
MCP tool
procedure.define on the dev-tools server
As data
{"$proc":["procedure","define"],"input":{}}
Tags
core, meta, runs-refs

Try it in the Composer →

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY, allCoreProcedures } from "@procedures/client";

for (const procedure of allCoreProcedures) {
  if (!PROCEDURE_REGISTRY.has(procedure.path)) PROCEDURE_REGISTRY.register(procedure);
}

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["procedure","define"], { path: [], aggregation: {} });
console.log(JSON.stringify(result));

From the command line

$ mark procedure define --path <string[]> --aggregation <object>

As data, in a program

{
  "$proc": ["procedure", "define"],
  "input": { "path": [], "aggregation": {} }
}

Input

FieldTypeRequiredDefaultDescription
pathstring[]yesThe path of the new procedure, for example ["tools", "double"]
aggregationobjectyesThe body of the procedure: a call ({ $proc, input }) that runs, as client.exec runs it, each time the procedure is called
metadataobjectnoThe metadata of the procedure, for example { description, tags }
replacebooleannoReplace a procedure that procedure.define made at the same path (never a procedure of code)

Output

FieldTypeRequiredDefaultDescription
pathstring[]yesThe path of the defined procedure
replacedbooleanyesTrue when the call replaced a runtime-defined procedure
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "path": {
        "minItems": 1,
        "type": "array",
        "items": {
          "type": "string",
          "minLength": 1
        },
        "description": "The path of the new procedure, for example [\"tools\", \"double\"]"
      },
      "aggregation": {
        "type": "object",
        "properties": {
          "$proc": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "The path of the procedure that the body calls"
          },
          "input": {
            "description": "The input of that call. It reads the input of the new procedure as { $ref: \"input.<field>\" }."
          },
          "$name": {
            "description": "A name that a $ref can read",
            "type": "string"
          }
        },
        "required": [
          "$proc"
        ],
        "additionalProperties": {},
        "description": "The body of the procedure: a call ({ $proc, input }) that runs, as client.exec runs it, each time the procedure is called"
      },
      "metadata": {
        "description": "The metadata of the procedure, for example { description, tags }",
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {}
      },
      "replace": {
        "description": "Replace a procedure that procedure.define made at the same path (never a procedure of code)",
        "type": "boolean"
      }
    },
    "required": [
      "path",
      "aggregation"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "path": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "The path of the defined procedure"
      },
      "replaced": {
        "type": "boolean",
        "description": "True when the call replaced a runtime-defined procedure"
      }
    },
    "required": [
      "path",
      "replaced"
    ],
    "additionalProperties": {}
  }
}