{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tradingai.local/schemas/extension-v1.schema.json",
  "title": "TradingAI Marketplace Extension Manifest v1",
  "description": "Shape schema for supported Marketplace manifests. Runtime validators remain authoritative for semantic and safety checks.",
  "oneOf": [
    {
      "$ref": "#/$defs/wasmManifest"
    },
    {
      "$ref": "#/$defs/interactiveWasmManifest"
    },
    {
      "$ref": "#/$defs/webAppManifest"
    },
    {
      "$ref": "#/$defs/resourceManifest"
    },
    {
      "$ref": "#/$defs/managedModelManifest"
    }
  ],
  "$defs": {
    "extensionId": {
      "type": "string",
      "minLength": 12,
      "maxLength": 128,
      "pattern": "^tradingai\\.[a-z0-9](?:[a-z0-9._-]{0,126}[a-z0-9])?$"
    },
    "namespacedId": {
      "type": "string",
      "minLength": 3,
      "maxLength": 128,
      "pattern": "^tradingai\\.[a-z0-9](?:[a-z0-9._-]{0,126}[a-z0-9])?\\.[A-Za-z0-9._-]+$"
    },
    "commonProperties": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/extensionId"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "apiVersion": {
          "const": 1
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "publisher": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "capabilities": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "tradingRead",
              "languageModel",
              "alertsWrite",
              "chartWrite"
            ]
          }
        },
        "metadata": {
          "type": "object"
        }
      }
    },
    "staticSdui": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "type",
            "text"
          ],
          "properties": {
            "type": {
              "const": "label"
            },
            "key": {
              "type": "string",
              "maxLength": 128
            },
            "text": {
              "type": "string",
              "maxLength": 4096
            },
            "maxLines": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "fontSize": {
              "type": "number",
              "minimum": 1,
              "maximum": 128
            },
            "fontWeight": {
              "type": "string",
              "maxLength": 32
            },
            "color": {
              "type": "string",
              "maxLength": 16
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "const": "box"
            },
            "key": {
              "type": "string",
              "maxLength": 128
            },
            "width": {
              "type": "number",
              "minimum": 0,
              "maximum": 4096
            },
            "height": {
              "type": "number",
              "minimum": 0,
              "maximum": 4096
            },
            "padding": {
              "type": "number",
              "minimum": 0,
              "maximum": 256
            },
            "margin": {
              "type": "number",
              "minimum": 0,
              "maximum": 256
            },
            "color": {
              "type": "string",
              "maxLength": 16
            },
            "borderRadius": {
              "type": "number",
              "minimum": 0,
              "maximum": 256
            },
            "child": {
              "$ref": "#/$defs/staticSdui"
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": [
            "type",
            "children"
          ],
          "properties": {
            "type": {
              "enum": [
                "row",
                "column"
              ]
            },
            "key": {
              "type": "string",
              "maxLength": 128
            },
            "spacing": {
              "type": "number",
              "minimum": 0,
              "maximum": 256
            },
            "mainAxisAlignment": {
              "type": "string",
              "maxLength": 32
            },
            "crossAxisAlignment": {
              "type": "string",
              "maxLength": 32
            },
            "children": {
              "type": "array",
              "maxItems": 128,
              "items": {
                "$ref": "#/$defs/staticSdui"
              }
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "viewContainer": {
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/namespacedId"
        },
        "title": {
          "type": "string",
          "maxLength": 4096
        },
        "icon": {
          "type": "string",
          "maxLength": 128
        },
        "order": {
          "type": "integer",
          "minimum": -100000,
          "maximum": 100000
        }
      },
      "additionalProperties": false
    },
    "viewContainerMap": {
      "type": "object",
      "properties": {
        "sidebar": {
          "type": "array",
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/viewContainer"
          }
        },
        "panel": {
          "type": "array",
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/viewContainer"
          }
        },
        "auxiliaryBar": {
          "type": "array",
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/viewContainer"
          }
        }
      },
      "additionalProperties": false
    },
    "resourceView": {
      "allOf": [
        {
          "type": "object",
          "required": [
            "id"
          ],
          "properties": {
            "id": {
              "$ref": "#/$defs/namespacedId"
            },
            "name": {
              "type": "string",
              "maxLength": 4096
            },
            "order": {
              "type": "integer",
              "minimum": -100000,
              "maximum": 100000
            },
            "when": {
              "type": "string",
              "maxLength": 128
            },
            "sdui": {
              "$ref": "#/$defs/staticSdui"
            },
            "quoteSymbol": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "candleTimeframe": {
              "enum": [
                "1m",
                "5m",
                "15m",
                "1H",
                "4H",
                "1D"
              ]
            },
            "candleLimit": {
              "type": "integer",
              "minimum": 1,
              "maximum": 256
            },
            "guestOutput": {
              "const": true
            }
          },
          "additionalProperties": false,
          "dependentRequired": {
            "candleTimeframe": [
              "quoteSymbol",
              "candleLimit"
            ],
            "candleLimit": [
              "quoteSymbol",
              "candleTimeframe"
            ],
            "guestOutput": [
              "quoteSymbol"
            ]
          }
        },
        {
          "oneOf": [
            {
              "required": [
                "sdui"
              ],
              "not": {
                "required": [
                  "quoteSymbol"
                ]
              }
            },
            {
              "required": [
                "quoteSymbol"
              ],
              "not": {
                "required": [
                  "sdui"
                ]
              }
            }
          ]
        }
      ]
    },
    "viewMap": {
      "type": "object",
      "patternProperties": {
        "^tradingai\\.[a-z0-9](?:[a-z0-9._-]{0,126}[a-z0-9])?$": {
          "type": "array",
          "maxItems": 32,
          "items": {
            "$ref": "#/$defs/resourceView"
          }
        }
      },
      "additionalProperties": false
    },
    "interactiveWasmView": {
      "type": "object",
      "required": [
        "id",
        "name",
        "interactive"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^.*\\S.*$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^.*\\S.*$"
        },
        "interactive": {
          "const": true
        }
      },
      "additionalProperties": false
    },
    "interactiveWasmViewMap": {
      "type": "object",
      "minProperties": 1,
      "propertyNames": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128,
        "pattern": "^.*\\S.*$"
      },
      "additionalProperties": {
        "type": "array",
        "minItems": 1,
        "maxItems": 32,
        "items": {
          "$ref": "#/$defs/interactiveWasmView"
        }
      }
    },
    "interactiveWasmViewContainer": {
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^.*\\S.*$"
        },
        "title": {
          "type": "string",
          "maxLength": 4096
        },
        "icon": {
          "type": "string",
          "maxLength": 128
        },
        "order": {
          "type": "integer",
          "minimum": -100000,
          "maximum": 100000
        }
      },
      "additionalProperties": false
    },
    "interactiveWasmViewContainerMap": {
      "type": "object",
      "properties": {
        "sidebar": {
          "type": "array",
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/interactiveWasmViewContainer"
          }
        },
        "panel": {
          "type": "array",
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/interactiveWasmViewContainer"
          }
        },
        "auxiliaryBar": {
          "type": "array",
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/interactiveWasmViewContainer"
          }
        }
      },
      "additionalProperties": false
    },
    "interactiveWasmContributions": {
      "type": "object",
      "required": [
        "views"
      ],
      "properties": {
        "views": {
          "$ref": "#/$defs/interactiveWasmViewMap"
        },
        "viewContainers": {
          "$ref": "#/$defs/interactiveWasmViewContainerMap"
        }
      },
      "additionalProperties": false
    },
    "watchlistPreset": {
      "type": "object",
      "required": [
        "id",
        "name",
        "symbols"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/namespacedId"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "description": {
          "type": "string",
          "maxLength": 1024
        },
        "symbols": {
          "type": "array",
          "minItems": 1,
          "maxItems": 100,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z0-9^._:/-]{1,64}$"
          }
        }
      },
      "additionalProperties": false
    },
    "researchLink": {
      "type": "object",
      "required": [
        "id",
        "title",
        "url",
        "scope"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/namespacedId"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "description": {
          "type": "string",
          "maxLength": 1024
        },
        "url": {
          "type": "string",
          "format": "uri",
          "minLength": 9,
          "maxLength": 2048,
          "pattern": "^https://"
        },
        "scope": {
          "enum": [
            "general",
            "symbol"
          ]
        },
        "symbol": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "scope": {
                "const": "general"
              }
            },
            "required": [
              "scope"
            ]
          },
          "then": {
            "not": {
              "required": [
                "symbol"
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "scope": {
                "const": "symbol"
              }
            },
            "required": [
              "scope"
            ]
          },
          "then": {
            "required": [
              "symbol"
            ]
          }
        }
      ],
      "additionalProperties": false
    },
    "scannerPreset": {
      "type": "object",
      "required": [
        "id",
        "name",
        "kind",
        "symbols",
        "styles",
        "cadenceMinutes"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/namespacedId"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "description": {
          "type": "string",
          "maxLength": 1024
        },
        "kind": {
          "const": "smc_watch"
        },
        "symbols": {
          "type": "array",
          "minItems": 1,
          "maxItems": 25,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._-]{1,16}:[A-Za-z0-9^._/-]{1,32}$"
          }
        },
        "styles": {
          "type": "array",
          "minItems": 1,
          "maxItems": 4,
          "uniqueItems": true,
          "items": {
            "enum": [
              "S",
              "D",
              "W",
              "P"
            ]
          }
        },
        "cadenceMinutes": {
          "type": "object",
          "minProperties": 1,
          "maxProperties": 4,
          "properties": {
            "S": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1440
            },
            "D": {
              "type": "integer",
              "minimum": 5,
              "maximum": 1440
            },
            "W": {
              "type": "integer",
              "minimum": 15,
              "maximum": 1440
            },
            "P": {
              "type": "integer",
              "minimum": 60,
              "maximum": 1440
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "indicatorPreset": {
      "type": "object",
      "required": [
        "id",
        "name",
        "kind",
        "indicator",
        "parameters"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/namespacedId"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "description": {
          "type": "string",
          "maxLength": 1024
        },
        "kind": {
          "const": "technical_indicator"
        },
        "indicator": {
          "enum": [
            "sma",
            "ema",
            "rsi",
            "macd"
          ]
        },
        "parameters": {
          "type": "object"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "indicator": {
                "enum": [
                  "sma",
                  "ema",
                  "rsi"
                ]
              }
            },
            "required": [
              "indicator"
            ]
          },
          "then": {
            "properties": {
              "parameters": {
                "type": "object",
                "required": [
                  "period"
                ],
                "properties": {
                  "period": {
                    "type": "integer",
                    "minimum": 2,
                    "maximum": 500
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "indicator": {
                "const": "macd"
              }
            },
            "required": [
              "indicator"
            ]
          },
          "then": {
            "properties": {
              "parameters": {
                "type": "object",
                "required": [
                  "fastPeriod",
                  "slowPeriod",
                  "signalPeriod"
                ],
                "properties": {
                  "fastPeriod": {
                    "type": "integer",
                    "minimum": 2,
                    "maximum": 100
                  },
                  "slowPeriod": {
                    "type": "integer",
                    "minimum": 3,
                    "maximum": 500
                  },
                  "signalPeriod": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      ],
      "additionalProperties": false
    },
    "automationTemplate": {
      "type": "object",
      "required": [
        "id",
        "name",
        "task",
        "minimumIntervalMinutes"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/namespacedId"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "description": {
          "type": "string",
          "maxLength": 1024
        },
        "task": {
          "enum": [
            "morning_briefing",
            "today_briefing",
            "screener_review",
            "visual_pattern_review"
          ]
        },
        "minimumIntervalMinutes": {
          "type": "integer",
          "minimum": 5,
          "maximum": 10080
        }
      },
      "additionalProperties": false
    },
    "alertTemplate": {
      "type": "object",
      "required": [
        "id",
        "title",
        "condition",
        "expirationSeconds"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/namespacedId"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "description": {
          "type": "string",
          "maxLength": 1024
        },
        "condition": {
          "enum": [
            "crossing",
            "crossingUp",
            "crossingDown",
            "greaterThan",
            "lessThan",
            "enteringChannel",
            "exitingChannel",
            "insideChannel",
            "outsideChannel",
            "movingUp",
            "movingDown",
            "movingUpPercents",
            "movingDownPercents",
            "movingUpOrDown"
          ]
        },
        "expirationSeconds": {
          "type": "integer",
          "minimum": 60,
          "maximum": 2592000
        }
      },
      "additionalProperties": false
    },
    "chartAnnotation": {
      "type": "object",
      "required": [
        "id",
        "title",
        "kind",
        "color",
        "lineWidth"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/namespacedId"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "description": {
          "type": "string",
          "maxLength": 1024
        },
        "kind": {
          "enum": [
            "horizontalLine",
            "trendLine"
          ]
        },
        "color": {
          "type": "string",
          "pattern": "^#[0-9A-Fa-f]{6}$"
        },
        "lineWidth": {
          "type": "integer",
          "minimum": 1,
          "maximum": 5
        }
      },
      "additionalProperties": false
    },
    "resourceContributions": {
      "type": "object",
      "properties": {
        "views": {
          "$ref": "#/$defs/viewMap"
        },
        "viewContainers": {
          "$ref": "#/$defs/viewContainerMap"
        },
        "watchlistPresets": {
          "type": "array",
          "minItems": 1,
          "maxItems": 16,
          "items": {
            "$ref": "#/$defs/watchlistPreset"
          }
        },
        "researchLinks": {
          "type": "array",
          "minItems": 1,
          "maxItems": 16,
          "items": {
            "$ref": "#/$defs/researchLink"
          }
        },
        "scannerPresets": {
          "type": "array",
          "minItems": 1,
          "maxItems": 16,
          "items": {
            "$ref": "#/$defs/scannerPreset"
          }
        },
        "indicatorPresets": {
          "type": "array",
          "minItems": 1,
          "maxItems": 16,
          "items": {
            "$ref": "#/$defs/indicatorPreset"
          }
        },
        "automationTemplates": {
          "type": "array",
          "minItems": 1,
          "maxItems": 16,
          "items": {
            "$ref": "#/$defs/automationTemplate"
          }
        },
        "alertTemplates": {
          "type": "array",
          "minItems": 1,
          "maxItems": 32,
          "items": {
            "$ref": "#/$defs/alertTemplate"
          }
        },
        "chartAnnotations": {
          "type": "array",
          "minItems": 1,
          "maxItems": 32,
          "items": {
            "$ref": "#/$defs/chartAnnotation"
          }
        }
      },
      "additionalProperties": false
    },
    "wasmContributions": {
      "type": "object",
      "properties": {
        "views": {
          "$ref": "#/$defs/viewMap"
        },
        "viewContainers": {
          "$ref": "#/$defs/viewContainerMap"
        }
      },
      "additionalProperties": false
    },
    "commonRequired": {
      "type": "object",
      "required": [
        "id",
        "name",
        "version",
        "apiVersion",
        "description",
        "publisher",
        "runtime",
        "contributes"
      ]
    },
    "wasmManifest": {
      "type": "object",
      "required": [
        "id",
        "name",
        "version",
        "apiVersion",
        "description",
        "publisher",
        "runtime",
        "entry_point",
        "contributes"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/extensionId"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "apiVersion": {
          "const": 1
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "publisher": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "runtime": {
          "const": "wasm"
        },
        "entry_point": {
          "const": "main.wasm"
        },
        "capabilities": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "const": "tradingRead"
          }
        },
        "contributes": {
          "$ref": "#/$defs/wasmContributions"
        },
        "metadata": {
          "type": "object"
        }
      },
      "additionalProperties": false
    },
    "interactiveWasmManifest": {
      "type": "object",
      "required": [
        "id",
        "name",
        "version",
        "apiVersion",
        "description",
        "publisher",
        "runtime",
        "minHostVersion",
        "contributes"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/extensionId"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "apiVersion": {
          "const": 2
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "publisher": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "runtime": {
          "const": "wasm"
        },
        "entry_point": {
          "const": "main.wasm"
        },
        "minHostVersion": {
          "type": "string",
          "pattern": "^(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)(?:-(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$"
        },
        "capabilities": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "tradingRead",
              "chartWrite",
              "alertsWrite",
              "languageModel",
              "network",
              "secrets",
              "fileSystemRead",
              "openExternal"
            ]
          }
        },
        "contributes": {
          "$ref": "#/$defs/interactiveWasmContributions"
        },
        "metadata": {
          "type": "object"
        }
      },
      "additionalProperties": false
    },
    "webAppContribution": {
      "type": "object",
      "required": [
        "containerId",
        "viewId",
        "title"
      ],
      "properties": {
        "containerId": {
          "$ref": "#/$defs/extensionId"
        },
        "viewId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 138,
          "pattern": "^tradingai\\.[a-z0-9](?:[a-z0-9._-]{0,126}[a-z0-9])?\\.workspace$"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120,
          "pattern": "^.*\\S.*$"
        }
      },
      "additionalProperties": false
    },
    "webAppFiles": {
      "type": "object",
      "minProperties": 2,
      "maxProperties": 255,
      "propertyNames": {
        "type": "string",
        "minLength": 1,
        "maxLength": 256,
        "pattern": "^(?!manifest\\.json$)(?!/)(?!.*(?:^|/)(?:\\.|\\.\\.)(?:/|$))(?:[A-Za-z0-9._-]+/){0,15}[A-Za-z0-9._-]+\\.(?:html|css|js|json|svg|png|jpg|jpeg|webp|woff2|txt)$"
      },
      "patternProperties": {
        ".*": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "additionalProperties": false,
      "allOf": [
        {
          "required": [
            "index.html"
          ]
        }
      ]
    },
    "webAppMetadata": {
      "type": "object",
      "required": [
        "protocol",
        "entry",
        "files",
        "networkOrigins"
      ],
      "properties": {
        "protocol": {
          "const": "tradingai-webapp-v1"
        },
        "entry": {
          "const": "index.html"
        },
        "files": {
          "$ref": "#/$defs/webAppFiles"
        },
        "networkOrigins": {
          "type": "array",
          "maxItems": 32,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "maxLength": 512,
            "pattern": "^https://(?:(?=.{1,253}(?::|$))(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|\\[(?:(?:[0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|(?:[0-9a-f]{1,4}:){1,7}:|(?:[0-9a-f]{1,4}:){1,6}:[0-9a-f]{1,4}|(?:[0-9a-f]{1,4}:){1,5}(?::[0-9a-f]{1,4}){1,2}|(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,3}|(?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,4}|(?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,5}|[0-9a-f]{1,4}:(?:(?::[0-9a-f]{1,4}){1,6})|:(?:(?::[0-9a-f]{1,4}){1,7}|:))\\])(?::(?:[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$",
            "allOf": [
              {
                "not": {
                  "pattern": "^https://(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)*(?:localhost|local|internal|lan|home|home\\.arpa|test|invalid|onion)(?::[0-9]+)?$"
                }
              },
              {
                "not": {
                  "pattern": "^https://(?:0|10|127|169\\.254|172\\.(?:1[6-9]|2[0-9]|3[01])|192\\.(?:0|168)|198\\.(?:18|19|51)|203\\.0\\.113|100\\.(?:6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])|22[4-9]|23[0-9]|24[0-9]|25[0-5])(?:\\.[0-9]{1,3}){0,3}(?::[0-9]+)?$"
                }
              },
              {
                "not": {
                  "pattern": "^https://\\[(?:::|::1|::ffff:|(?:fc|fd)[0-9a-f]{0,2}:|fe[89ab][0-9a-f]:|ff[0-9a-f]{2}:|2001:(?:db8|0db8):|2001:(?:0{0,3}[0-9a-f]|0{0,2}[1-9a-f][0-9a-f]|0?1[0-9a-f]{2}):)[0-9a-f:]*\\](?::[0-9]+)?$"
                }
              },
              {
                "not": {
                  "pattern": "^https://\\[(?:(?:0{1,4}:){7}0{1,4}|(?:0{1,4}:){7}0{0,3}1)\\](?::[0-9]+)?$"
                }
              }
            ]
          }
        }
      },
      "additionalProperties": false
    },
    "webAppManifest": {
      "type": "object",
      "required": [
        "id",
        "name",
        "version",
        "apiVersion",
        "description",
        "publisher",
        "runtime",
        "trust",
        "minHostVersion",
        "capabilities",
        "contributes",
        "metadata"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/extensionId"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "apiVersion": {
          "const": 3
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "publisher": {
          "const": "TradingAI Official"
        },
        "runtime": {
          "const": "webApp"
        },
        "trust": {
          "const": "verified"
        },
        "minHostVersion": {
          "type": "string",
          "maxLength": 128,
          "pattern": "^(?:(?:(?:[4-9]|[1-9][0-9]+)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)|3\\.(?:[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)|3\\.0\\.(?:[1-9][0-9]*))(?:-(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?|3\\.0\\.0)(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$"
        },
        "capabilities": {
          "type": "array",
          "minItems": 5,
          "maxItems": 5,
          "uniqueItems": true,
          "items": {
            "enum": [
              "browser",
              "network",
              "openExternal",
              "secrets",
              "languageModel"
            ]
          },
          "allOf": [
            {"contains": {"const": "browser"}},
            {"contains": {"const": "network"}},
            {"contains": {"const": "openExternal"}},
            {"contains": {"const": "secrets"}},
            {"contains": {"const": "languageModel"}}
          ]
        },
        "contributes": {
          "type": "object",
          "required": [
            "webApp"
          ],
          "properties": {
            "webApp": {
              "$ref": "#/$defs/webAppContribution"
            }
          },
          "additionalProperties": false
        },
        "metadata": {
          "type": "object",
          "required": [
            "webApp"
          ],
          "properties": {
            "webApp": {
              "$ref": "#/$defs/webAppMetadata"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "resourceManifest": {
      "type": "object",
      "required": [
        "id",
        "name",
        "version",
        "apiVersion",
        "description",
        "publisher",
        "runtime",
        "contributes"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/extensionId"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "apiVersion": {
          "const": 1
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "publisher": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "runtime": {
          "const": "resource"
        },
        "capabilities": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "tradingRead",
              "languageModel",
              "alertsWrite",
              "chartWrite"
            ]
          }
        },
        "contributes": {
          "$ref": "#/$defs/resourceContributions"
        },
        "metadata": {
          "type": "object"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "contributes": {
                "anyOf": [
                  {
                    "required": [
                      "scannerPresets"
                    ]
                  },
                  {
                    "required": [
                      "indicatorPresets"
                    ]
                  }
                ]
              }
            }
          },
          "then": {
            "required": [
              "capabilities"
            ],
            "properties": {
              "capabilities": {
                "contains": {
                  "const": "tradingRead"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "contributes": {
                "required": [
                  "automationTemplates"
                ]
              }
            }
          },
          "then": {
            "required": [
              "capabilities"
            ],
            "properties": {
              "capabilities": {
                "minItems": 2,
                "allOf": [
                  {
                    "contains": {
                      "const": "tradingRead"
                    }
                  },
                  {
                    "contains": {
                      "const": "languageModel"
                    }
                  }
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "capabilities": {
                "contains": {
                  "const": "languageModel"
                }
              }
            }
          },
          "then": {
            "properties": {
              "contributes": {
                "required": [
                  "automationTemplates"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "contributes": {
                "required": [
                  "alertTemplates"
                ]
              }
            }
          },
          "then": {
            "required": [
              "capabilities"
            ],
            "properties": {
              "capabilities": {
                "contains": {
                  "const": "alertsWrite"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "capabilities": {
                "contains": {
                  "const": "alertsWrite"
                }
              }
            }
          },
          "then": {
            "properties": {
              "contributes": {
                "required": [
                  "alertTemplates"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "contributes": {
                "required": [
                  "chartAnnotations"
                ]
              }
            }
          },
          "then": {
            "required": [
              "capabilities"
            ],
            "properties": {
              "capabilities": {
                "contains": {
                  "const": "chartWrite"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "capabilities": {
                "contains": {
                  "const": "chartWrite"
                }
              }
            }
          },
          "then": {
            "properties": {
              "contributes": {
                "required": [
                  "chartAnnotations"
                ]
              }
            }
          }
        },
        {
          "properties": {
            "contributes": {
              "properties": {
                "views": {
                  "additionalProperties": {
                    "items": {
                      "not": {
                        "anyOf": [
                          {
                            "required": [
                              "candleTimeframe"
                            ]
                          },
                          {
                            "required": [
                              "candleLimit"
                            ]
                          },
                          {
                            "required": [
                              "guestOutput"
                            ]
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ],
      "additionalProperties": false
    },
    "managedModelManifest": {
      "type": "object",
      "required": [
        "id",
        "name",
        "version",
        "apiVersion",
        "description",
        "publisher",
        "runtime",
        "trust",
        "minHostVersion",
        "capabilities",
        "contributes",
        "metadata"
      ],
      "properties": {
        "id": {
          "const": "tradingai.time_series_forecast"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "version": {
          "type": "string",
          "pattern": "^(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$"
        },
        "apiVersion": {
          "const": 1
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "publisher": {
          "const": "TradingAI Official"
        },
        "runtime": {
          "const": "managedModel"
        },
        "trust": {
          "const": "verified"
        },
        "minHostVersion": {
          "type": "string",
          "pattern": "^(?:[3-9]|[1-9][0-9]+)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)(?:\\+[0-9A-Za-z.-]+)?$"
        },
        "capabilities": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "uniqueItems": true,
          "items": {
            "enum": [
              "shell",
              "network",
              "tradingRead",
              "chartWrite"
            ]
          },
          "allOf": [
            {"contains": {"const": "shell"}},
            {"contains": {"const": "network"}},
            {"contains": {"const": "tradingRead"}},
            {"contains": {"const": "chartWrite"}}
          ]
        },
        "contributes": {
          "type": "object",
          "required": ["forecastProvider"],
          "properties": {
            "forecastProvider": {
              "type": "object",
              "required": ["protocol", "title"],
              "properties": {
                "protocol": {"const": "timesfm-http-v1"},
                "title": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 120,
                  "pattern": "^.*\\S.*$"
                }
              },
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        "metadata": {
          "type": "object",
          "required": ["managedModel"],
          "additionalProperties": false,
          "properties": {
            "managedModel": {
              "type": "object",
              "required": [
                "protocol",
                "pythonVersion",
                "timesfmVersion",
                "numpyVersion",
                "modelRepository",
                "modelRevision",
                "prepareEntryPoint",
                "serviceEntryPoint",
                "files",
                "requiresNonCommercialResearch"
              ],
              "properties": {
                "protocol": {"const": "timesfm-http-v1"},
                "pythonVersion": {
                  "type": "string",
                  "pattern": "^3\\.11\\.(?:0|[1-9][0-9]*)$"
                },
                "timesfmVersion": {
                  "type": "string",
                  "pattern": "^3\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)$"
                },
                "numpyVersion": {
                  "type": "string",
                  "pattern": "^(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)$"
                },
                "modelRepository": {"const": "google/timesfm-3.0-pytorch"},
                "modelRevision": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{40}$"
                },
                "prepareEntryPoint": {
                  "const": "tools/timesfm_forecast/prepare.py"
                },
                "serviceEntryPoint": {
                  "const": "tools/timesfm_forecast/server.py"
                },
                "files": {
                  "type": "object",
                  "minProperties": 2,
                  "maxProperties": 255,
                  "propertyNames": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1024,
                    "pattern": "^(?!manifest\\.json$)(?!/)(?!.*(?:^|/)(?:\\.|\\.\\.)(?:/|$))(?!.*\\\\)[A-Za-z0-9._/-]+$"
                  },
                  "patternProperties": {
                    ".*": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{64}$"
                    }
                  },
                  "additionalProperties": false
                },
                "requiresNonCommercialResearch": {"const": true}
              },
              "additionalProperties": false,
              "allOf": [
                {
                  "properties": {
                    "files": {
                      "required": [
                        "tools/timesfm_forecast/prepare.py",
                        "tools/timesfm_forecast/server.py"
                      ]
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "additionalProperties": false
    }
  }
}
