{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst level = Type.Union([Type.Literal('host'), Type.Literal('workspace'), Type.Literal('session')]);\nconst scope = Type.Object({ id: Type.String(), level });\nconst nullableString = Type.Union([Type.String(), Type.Null()]);\nconst owner = Type.Object({\n  kind: Type.Union([Type.Literal('host'), Type.Literal('package'), Type.Literal('unknown')]),\n  packageName: nullableString,\n  origin: Type.Union([Type.Literal('po'), Type.Literal('personal'), Type.Literal('unknown')]),\n});\nconst kind = Type.Union([Type.Literal('data'), Type.Literal('component')]);\nconst placement = Type.Union([Type.Literal('verified'), Type.Literal('unverified')]);\nconst web = Type.Object({\n  version: Type.Literal(1),\n  slots: Type.Array(\n    Type.Object({\n      name: Type.String(),\n      scope: level,\n      description: Type.Optional(Type.String()),\n      parent: Type.Optional(Type.String()),\n      kind,\n    }),\n  ),\n  fills: Type.Array(Type.Object({ id: Type.String(), slot: nullableString, scope: level, placement })),\n  diagnostics: Type.Array(Type.String()),\n});\nconst base = { scope, scopes: Type.Array(scope), diagnostics: Type.Array(Type.String()) };\nconst services = Type.Object({\n  ...base,\n  packages: Type.Array(Type.Object({ scope, owner, web: Type.Union([web, Type.Null()]) })),\n  clientPackages: Type.Optional(Type.Array(Type.Object({ scope, owner, web: Type.Union([web, Type.Null()]) }))),\n  services: Type.Array(\n    Type.Object({\n      id: Type.String(),\n      name: Type.String(),\n      scope,\n      visibleFrom: scope,\n      owner,\n      public: Type.Boolean(),\n      description: nullableString,\n    }),\n  ),\n  consumers: Type.Array(Type.Object({ id: Type.String(), name: Type.String(), scope, owner })),\n  edges: Type.Array(\n    Type.Object({\n      consumer: Type.String(),\n      service: nullableString,\n      name: Type.String(),\n      status: Type.Union([Type.Literal('resolved'), Type.Literal('waiting')]),\n    }),\n  ),\n});\nconst slots = Type.Object({\n  ...base,\n  slots: Type.Array(\n    Type.Object({\n      id: Type.String(),\n      name: Type.String(),\n      scope,\n      owner,\n      description: nullableString,\n      parent: nullableString,\n      kind,\n    }),\n  ),\n  fills: Type.Array(Type.Object({ id: Type.String(), slot: nullableString, scope, owner, placement })),\n});\nexport const brainSimulationSchema = Type.Object({ enabled: Type.Boolean() }, { additionalProperties: false });\n\nexport const apiContracts = defineApiContract({\n  version: 1,\n  sockets: [],\n  dynamic: [],\n  http: [\n    ...(['workspace', 'session'] as const).flatMap((scope) => [\n      {\n        id: `brain.${scope}.simulation`,\n        scope,\n        basePath: 'brain',\n        path: '/simulation',\n        method: 'GET' as const,\n        authentication: 'owner' as const,\n        description: 'Read this exact scope simulation toggle.',\n        responses: jsonApiResponses(brainSimulationSchema),\n      },\n      {\n        id: `brain.${scope}.setSimulation`,\n        scope,\n        basePath: 'brain',\n        path: '/simulation',\n        method: 'PUT' as const,\n        authentication: 'owner' as const,\n        description: 'Set this exact scope simulation toggle without persistence or inheritance.',\n        body: { required: true, contentType: 'application/json' as const, schema: brainSimulationSchema },\n        responses: jsonApiResponses(brainSimulationSchema),\n      },\n    ]),\n    ...(['host', 'workspace', 'session'] as const).flatMap((scope) => [\n      {\n        id: `brain.${scope}.services`,\n        scope,\n        basePath: 'brain',\n        path: '/services',\n        method: 'GET' as const,\n        authentication: 'owner' as const,\n        description: 'Read this exact scope and its ancestry service graph.',\n        responses: jsonApiResponses(services),\n      },\n      {\n        id: `brain.${scope}.slots`,\n        scope,\n        basePath: 'brain',\n        path: '/slots',\n        method: 'GET' as const,\n        authentication: 'owner' as const,\n        description:\n          'Read host slots and metadata from this exact admitted browser mount and its ancestry, with explicit coverage diagnostics for older hosts.',\n        responses: jsonApiResponses(slots),\n      },\n    ]),\n  ],\n});\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAM,QAAQ,KAAK,MAAM;CAAC,KAAK,QAAQ,MAAM;CAAG,KAAK,QAAQ,WAAW;CAAG,KAAK,QAAQ,SAAS;AAAC,CAAC;AACn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