[
  {
    "name": "bb_workflow_run",
    "description": "Execute a workflow script that orchestrates multiple subagents deterministically. Workflows run in the background — this tool returns immediately with a run ID and a `previewDirective`. After a successful call, emit that directive exactly once on its own line (not in a code fence) so BB renders live progress in chat. A completion notification is sent to the origin thread. Use `bb workflows status <run-id>` for a compact summary. For detailed history, redirect a bounded JSONL page from `bb workflows history <run-id> --cursor <call-index> --limit <1-100>` into `$BB_THREAD_STORAGE`, then inspect the file with normal filesystem tools.",
    "inputSchema": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "properties": {
        "script": {
          "type": "string",
          "minLength": 1,
          "description": "Self-contained workflow script. Must begin with `export const meta = { name, description, phases }` (pure literal, no computed values) followed by the script body using agent()/parallel()/pipeline()/phase()."
        },
        "source": {
          "type": "string",
          "minLength": 1,
          "description": "Alias for `script`. Do not provide both `source` and `script`."
        },
        "scriptPath": {
          "type": "string",
          "minLength": 1,
          "description": "Path to a workflow script file on the origin environment's host. Relative paths start at the workspace root and all paths must remain inside that workspace."
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "description": "Name of a saved workflow from the current workspace's .bb/workflows/ directory. Resolves to a self-contained script."
        },
        "args": {
          "default": null,
          "description": "Optional input value exposed to the script as the global `args`, verbatim. Pass arrays/objects as actual JSON values, NOT as a JSON-encoded string — a stringified list breaks `args.filter`/`args.map` in the script. Use for parameterized named workflows (e.g. a research question).",
          "$ref": "#/$defs/__schema0"
        },
        "resumeRunId": {
          "default": null,
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ],
          "description": "Run ID of a prior BB workflow to resume from. Calls in the causally safe, longest unchanged prefix return cached results; the first edited, new, or concurrent call and everything after it run live. The prior run must be terminal and from the same project and environment."
        }
      },
      "additionalProperties": false,
      "$defs": {
        "__schema0": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            },
            {
              "type": "boolean"
            },
            {
              "type": "null"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/__schema0"
              }
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "$ref": "#/$defs/__schema0"
              }
            }
          ]
        }
      }
    }
  },
  {
    "name": "bb_workflow_result",
    "description": "Use this tool to return your final response in the requested structured format. You MUST call this tool exactly once at the end of your response with {\"value\": ...} to provide the structured output.",
    "inputSchema": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "properties": {
        "value": {
          "description": "The final value matching the requested JSON Schema.",
          "$ref": "#/$defs/__schema0"
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false,
      "$defs": {
        "__schema0": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            },
            {
              "type": "boolean"
            },
            {
              "type": "null"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/__schema0"
              }
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "$ref": "#/$defs/__schema0"
              }
            }
          ]
        }
      }
    }
  }
]