{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/kagura-ai-com/json-schema/kagura-ai-com-workspace-connector-create-request-schema.json",
  "title": "WorkspaceConnectorCreateRequest",
  "description": "Request body for provisioning an ai-worker connector.",
  "x-generated": "2026-11-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/kagura-ai-com-openapi.json#/components/schemas/WorkspaceConnectorCreateRequest",
  "properties": {
    "connector_type": {
      "type": "string",
      "enum": [
        "slack",
        "discord",
        "teams"
      ],
      "title": "Connector Type",
      "description": "Connector backend to provision"
    },
    "resource_id": {
      "type": "string",
      "maxLength": 255,
      "minLength": 1,
      "title": "Resource Id",
      "description": "Workspace-scoped resource slug for ingested chat events"
    },
    "display_name": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "title": "Display Name"
    },
    "oauth_tokens": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Oauth Tokens",
      "description": "OAuth token bundle; stored Fernet-encrypted"
    },
    "pii_guardrail_config": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Pii Guardrail Config",
      "description": "PII guardrail config for ai-worker pre-compile"
    },
    "litellm_virtual_key_id": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "title": "Litellm Virtual Key Id"
    },
    "virtual_key_valid_until": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Virtual Key Valid Until"
    },
    "quota_events_per_hour": {
      "type": "integer",
      "maximum": 10000.0,
      "minimum": 1.0,
      "title": "Quota Events Per Hour",
      "default": 1000
    },
    "context_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Context Id",
      "description": "Existing write-target context"
    },
    "auto_create_context_name": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ],
      "title": "Auto Create Context Name",
      "description": "Create a fresh private context with this name"
    },
    "llm_config": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Llm Config",
      "description": "BYO LLM bundle; Fernet-encrypted"
    },
    "channel_ids": {
      "anyOf": [
        {
          "items": {},
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Channel Ids",
      "description": "Ingest channel selection"
    },
    "locale": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 10
        },
        {
          "type": "null"
        }
      ],
      "title": "Locale",
      "description": "Worker pre-compile locale. Must map to the worker Locale contract ('en' | 'ja'); common BCP-47 forms are normalized (ja-JP → ja). See models.worker_runtime.WORKER_LOCALES (#1377)."
    },
    "external_team_id": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "title": "External Team Id",
      "description": "Platform team id (worker dispatch key)"
    },
    "app_key": {
      "type": "string",
      "maxLength": 64,
      "minLength": 1,
      "pattern": "^[a-z0-9][a-z0-9_-]{0,63}$",
      "title": "App Key",
      "description": "Stable platform app identity selector",
      "default": "default"
    },
    "slack_install_handle": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "title": "Slack Install Handle",
      "description": "One-time handle from the Slack OAuth callback; resolved server-side to oauth_tokens + external_team_id (bot token never sent by client)"
    },
    "runtime": {
      "anyOf": [
        {
          "$ref": "#/$defs/WorkerRuntimeConfig"
        },
        {
          "type": "null"
        }
      ],
      "description": "Non-secret per-connector worker controls; omitted uses worker defaults"
    }
  },
  "type": "object",
  "required": [
    "connector_type",
    "resource_id"
  ],
  "$defs": {
    "WorkerRuntimeBufferConfig": {
      "properties": {
        "ttl_seconds": {
          "type": "integer",
          "maximum": 86400.0,
          "exclusiveMinimum": 0.0,
          "title": "Ttl Seconds",
          "default": 86400
        },
        "max_len": {
          "type": "integer",
          "maximum": 100000.0,
          "exclusiveMinimum": 0.0,
          "title": "Max Len",
          "default": 10000
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "WorkerRuntimeBufferConfig",
      "description": "Tenant-owned buffer limits; connection coordinates are intentionally absent."
    },
    "WorkerRuntimeConfig": {
      "properties": {
        "buffer": {
          "$ref": "#/$defs/WorkerRuntimeBufferConfig"
        },
        "flush": {
          "$ref": "#/$defs/WorkerRuntimeFlushConfig"
        },
        "supervisor": {
          "$ref": "#/$defs/WorkerRuntimeSupervisorConfig"
        },
        "lifecycle": {
          "$ref": "#/$defs/WorkerRuntimeLifecycleConfig"
        },
        "continuity": {
          "$ref": "#/$defs/WorkerRuntimeContinuityConfig"
        },
        "vision_enabled": {
          "type": "boolean",
          "title": "Vision Enabled",
          "default": true
        },
        "team_scope_filter_enabled": {
          "type": "boolean",
          "title": "Team Scope Filter Enabled",
          "default": false
        },
        "channel_allowlist_enabled": {
          "type": "boolean",
          "title": "Channel Allowlist Enabled",
          "default": false
        },
        "mention_answer_enabled": {
          "type": "boolean",
          "title": "Mention Answer Enabled",
          "default": false
        },
        "answer_relevance_threshold": {
          "type": "number",
          "maximum": 1.0,
          "minimum": 0.0,
          "title": "Answer Relevance Threshold",
          "default": 0.35
        },
        "answer_timeout_sec": {
          "type": "number",
          "maximum": 300.0,
          "exclusiveMinimum": 0.0,
          "title": "Answer Timeout Sec",
          "default": 8.0
        },
        "memory_link_template": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 1024
            },
            {
              "type": "null"
            }
          ],
          "title": "Memory Link Template"
        },
        "entity_extraction_enabled": {
          "type": "boolean",
          "title": "Entity Extraction Enabled",
          "default": false
        },
        "entity_max": {
          "type": "integer",
          "maximum": 50.0,
          "exclusiveMinimum": 0.0,
          "title": "Entity Max",
          "default": 8
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "WorkerRuntimeConfig",
      "description": "Complete non-secret, installation-scoped worker runtime contract."
    },
    "WorkerRuntimeContinuityConfig": {
      "properties": {
        "time_window_minutes": {
          "type": "integer",
          "maximum": 10080.0,
          "minimum": 0.0,
          "title": "Time Window Minutes",
          "default": 30
        },
        "semantic_threshold": {
          "type": "number",
          "maximum": 1.0,
          "minimum": 0.0,
          "title": "Semantic Threshold",
          "default": 0.6
        },
        "semantic_check_enabled": {
          "type": "boolean",
          "title": "Semantic Check Enabled",
          "default": false
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "WorkerRuntimeContinuityConfig",
      "description": "Per-connector topic-continuity thresholds."
    },
    "WorkerRuntimeFlushConfig": {
      "properties": {
        "silence_seconds": {
          "type": "integer",
          "maximum": 604800.0,
          "minimum": 0.0,
          "title": "Silence Seconds",
          "default": 300
        },
        "volume_tokens": {
          "type": "integer",
          "maximum": 1000000.0,
          "exclusiveMinimum": 0.0,
          "title": "Volume Tokens",
          "default": 2000
        },
        "max_tracked_topics": {
          "type": "integer",
          "maximum": 100000.0,
          "exclusiveMinimum": 0.0,
          "title": "Max Tracked Topics",
          "default": 10000
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "WorkerRuntimeFlushConfig",
      "description": "Per-connector topic flush thresholds."
    },
    "WorkerRuntimeLifecycleConfig": {
      "properties": {
        "deletion_mode": {
          "type": "string",
          "enum": [
            "forget",
            "redact"
          ],
          "title": "Deletion Mode",
          "default": "redact"
        },
        "redacted_summary": {
          "type": "string",
          "maxLength": 512,
          "minLength": 1,
          "title": "Redacted Summary",
          "default": "[redacted on user request]"
        },
        "dormant_summary": {
          "type": "string",
          "maxLength": 512,
          "minLength": 1,
          "title": "Dormant Summary",
          "default": "[dormant] (channel archived)"
        },
        "edited_summary": {
          "type": "string",
          "maxLength": 512,
          "minLength": 1,
          "title": "Edited Summary",
          "default": "[stale] (source message edited)"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "WorkerRuntimeLifecycleConfig",
      "description": "Connector lifecycle propagation behavior."
    },
    "WorkerRuntimeSupervisorConfig": {
      "properties": {
        "tick_seconds": {
          "type": "number",
          "maximum": 3600.0,
          "minimum": 0.1,
          "title": "Tick Seconds",
          "default": 1.0
        },
        "shutdown_flush_timeout_seconds": {
          "type": "number",
          "maximum": 600.0,
          "exclusiveMinimum": 0.0,
          "title": "Shutdown Flush Timeout Seconds",
          "default": 25.0
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "WorkerRuntimeSupervisorConfig",
      "description": "Per-connector supervisor cadence and shutdown budget."
    }
  }
}