[
  {
    "type": "function",
    "name": "read_connection",
    "description": "Read assigned goal IDs, canWrite, canReadIdeas, canProposeGoals and expiry for this connection.",
    "parameters": {
      "type": "object",
      "properties": {},
      "additionalProperties": false
    }
  },
  {
    "type": "function",
    "name": "propose_goal_changes",
    "description": "Submit 1–20 goal creates/updates for owner review. Requires canProposeGoals. Use goal.revision from current reads for updates. Send returned reviewUrl to the owner; no goals change until the owner approves in the app. Preserve identical operationId and payload on retry.",
    "parameters": {
      "type": "object",
      "properties": {
        "proposal": {
          "type": "object",
          "properties": {
            "operationId": {
              "type": "string",
              "format": "uuid"
            },
            "summary": {
              "type": "string",
              "minLength": 1,
              "maxLength": 2000
            },
            "operations": {
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "create"
                      },
                      "goal": {
                        "type": "object",
                        "properties": {
                          "title": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 500
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "active",
                              "completed",
                              "deferred"
                            ],
                            "default": "active"
                          },
                          "order": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 1000000,
                            "default": 0
                          },
                          "specification": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "description": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 4000
                                  },
                                  "details": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 1000
                                    },
                                    "maxItems": 20
                                  }
                                },
                                "required": [
                                  "description",
                                  "details"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "default": null
                          }
                        },
                        "required": [
                          "title"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "type",
                      "goal"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "update"
                      },
                      "goalId": {
                        "type": "string",
                        "pattern": "^[a-f\\d]{24}$",
                        "description": "Goal ID from list"
                      },
                      "revision": {
                        "type": "string",
                        "pattern": "^[a-f\\d]{64}$"
                      },
                      "changes": {
                        "type": "object",
                        "properties": {
                          "title": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 500
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "active",
                              "completed",
                              "deferred"
                            ]
                          },
                          "order": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 1000000
                          },
                          "specification": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "description": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 4000
                                  },
                                  "details": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 1000
                                    },
                                    "maxItems": 20
                                  }
                                },
                                "required": [
                                  "description",
                                  "details"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "type",
                      "goalId",
                      "revision",
                      "changes"
                    ],
                    "additionalProperties": false
                  }
                ]
              },
              "minItems": 1,
              "maxItems": 20
            }
          },
          "required": [
            "operationId",
            "summary",
            "operations"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "proposal"
      ],
      "additionalProperties": false
    }
  },
  {
    "type": "function",
    "name": "read_goal_proposal",
    "description": "Read this connection’s proposal status after owner review. Pending means goals have not changed.",
    "parameters": {
      "type": "object",
      "properties": {
        "proposalId": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{24}$"
        }
      },
      "required": [
        "proposalId"
      ],
      "additionalProperties": false
    }
  },
  {
    "type": "function",
    "name": "list_goals",
    "description": "List assigned goals. Follow nextCursor.",
    "parameters": {
      "type": "object",
      "properties": {
        "after": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{24}$"
        }
      },
      "additionalProperties": false
    }
  },
  {
    "type": "function",
    "name": "list_ideas",
    "description": "Read shared ideas if list_goals reports capabilities.readIdeas. Includes unlinked ideas and ideas attached to selected unencrypted goals. Follow nextCursor; this does not allow editing ideas.",
    "parameters": {
      "type": "object",
      "properties": {
        "after": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{24}$"
        }
      },
      "additionalProperties": false
    }
  },
  {
    "type": "function",
    "name": "read_goal_workspace",
    "description": "Read assigned goal context and latest handoff before coaching or writing.",
    "parameters": {
      "type": "object",
      "properties": {
        "goalId": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{24}$"
        }
      },
      "required": [
        "goalId"
      ],
      "additionalProperties": false
    }
  },
  {
    "type": "function",
    "name": "update_goal_workspace",
    "description": "Save an authorized workspace command. Preserve the identical command after a lost response; reconcile version conflicts. Requires write access.",
    "parameters": {
      "type": "object",
      "properties": {
        "goalId": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{24}$"
        },
        "operationId": {
          "type": "string",
          "format": "uuid"
        },
        "version": {
          "type": "integer",
          "minimum": 0
        },
        "operation": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "create_item"
                },
                "item": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "title": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "description": {
                      "type": "string",
                      "maxLength": 4000,
                      "default": ""
                    },
                    "successCriteria": {
                      "type": "string",
                      "maxLength": 2000,
                      "default": ""
                    },
                    "priority": {
                      "type": "string",
                      "enum": [
                        "low",
                        "normal",
                        "high"
                      ],
                      "default": "normal"
                    },
                    "dependsOn": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "maxItems": 20,
                      "default": []
                    }
                  },
                  "required": [
                    "id",
                    "title"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "type",
                "item"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "update_item"
                },
                "itemId": {
                  "type": "string",
                  "format": "uuid"
                },
                "changes": {
                  "type": "object",
                  "properties": {
                    "title": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "description": {
                      "type": "string",
                      "maxLength": 4000
                    },
                    "successCriteria": {
                      "type": "string",
                      "maxLength": 2000
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "planned",
                        "in_progress",
                        "blocked",
                        "done",
                        "cancelled"
                      ]
                    },
                    "priority": {
                      "type": "string",
                      "enum": [
                        "low",
                        "normal",
                        "high"
                      ]
                    },
                    "blocker": {
                      "type": "string",
                      "maxLength": 2000
                    },
                    "dependsOn": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "maxItems": 20
                    }
                  },
                  "additionalProperties": false
                }
              },
              "required": [
                "type",
                "itemId",
                "changes"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "add_note"
                },
                "itemId": {
                  "type": "string",
                  "format": "uuid"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "note",
                    "evidence"
                  ]
                },
                "text": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4000
                }
              },
              "required": [
                "type",
                "itemId",
                "kind",
                "text"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "handoff"
                },
                "summary": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4000
                },
                "nextAction": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 2000
                }
              },
              "required": [
                "type",
                "summary",
                "nextAction"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "set_criteria"
                },
                "successCriteria": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4000
                }
              },
              "required": [
                "type",
                "successCriteria"
              ],
              "additionalProperties": false
            }
          ]
        }
      },
      "required": [
        "goalId",
        "operationId",
        "version",
        "operation"
      ],
      "additionalProperties": false
    }
  }
]
