@braidhq/server 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +134 -106
- package/dist/app.d.ts +7 -15
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +74 -45
- package/dist/app.js.map +1 -1
- package/dist/authMode.d.ts +39 -0
- package/dist/authMode.d.ts.map +1 -0
- package/dist/authMode.js +50 -0
- package/dist/authMode.js.map +1 -0
- package/dist/composeApp.d.ts +80 -0
- package/dist/composeApp.d.ts.map +1 -0
- package/dist/composeApp.js +137 -0
- package/dist/composeApp.js.map +1 -0
- package/dist/composeFsApp.d.ts +27 -0
- package/dist/composeFsApp.d.ts.map +1 -0
- package/dist/{composeFs.js → composeFsApp.js} +127 -126
- package/dist/composeFsApp.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/_shared/env.d.ts +10 -0
- package/dist/infrastructure/_shared/env.d.ts.map +1 -0
- package/dist/infrastructure/{env.js → _shared/env.js} +5 -6
- package/dist/infrastructure/_shared/env.js.map +1 -0
- package/dist/infrastructure/_shared/frontmatter.d.ts +13 -0
- package/dist/infrastructure/_shared/frontmatter.d.ts.map +1 -0
- package/dist/infrastructure/{fs → _shared}/frontmatter.js +5 -5
- package/dist/infrastructure/_shared/frontmatter.js.map +1 -0
- package/dist/infrastructure/_shared/jsonFileStore.d.ts.map +1 -0
- package/dist/infrastructure/_shared/jsonFileStore.js.map +1 -0
- package/dist/infrastructure/{fs → _shared}/paths.d.ts +17 -10
- package/dist/infrastructure/_shared/paths.d.ts.map +1 -0
- package/dist/infrastructure/{fs → _shared}/paths.js +27 -20
- package/dist/infrastructure/_shared/paths.js.map +1 -0
- package/dist/infrastructure/auth/AccessPolicy.d.ts +33 -58
- package/dist/infrastructure/auth/AccessPolicy.d.ts.map +1 -1
- package/dist/infrastructure/auth/AccessPolicy.js +35 -42
- package/dist/infrastructure/auth/AccessPolicy.js.map +1 -1
- package/dist/infrastructure/auth/SessionStore.d.ts +22 -12
- package/dist/infrastructure/auth/SessionStore.d.ts.map +1 -1
- package/dist/infrastructure/auth/SessionStore.js +20 -20
- package/dist/infrastructure/auth/SessionStore.js.map +1 -1
- package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts +14 -0
- package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts.map +1 -0
- package/dist/infrastructure/{fs → batch}/FsBatchPlanRepository.js +9 -7
- package/dist/infrastructure/batch/FsBatchPlanRepository.js.map +1 -0
- package/dist/infrastructure/history/GitWorkspaceHistory.d.ts.map +1 -0
- package/dist/infrastructure/{git → history}/GitWorkspaceHistory.js +31 -24
- package/dist/infrastructure/history/GitWorkspaceHistory.js.map +1 -0
- package/dist/infrastructure/history/commitMessage.d.ts.map +1 -0
- package/dist/infrastructure/history/commitMessage.js +90 -0
- package/dist/infrastructure/history/commitMessage.js.map +1 -0
- package/dist/infrastructure/hitl/FsClarificationRepository.d.ts +13 -0
- package/dist/infrastructure/hitl/FsClarificationRepository.d.ts.map +1 -0
- package/dist/infrastructure/hitl/FsClarificationRepository.js +40 -0
- package/dist/infrastructure/hitl/FsClarificationRepository.js.map +1 -0
- package/dist/infrastructure/hitl/FsProposalRepository.d.ts.map +1 -0
- package/dist/infrastructure/{fs → hitl}/FsProposalRepository.js +8 -8
- package/dist/infrastructure/hitl/FsProposalRepository.js.map +1 -0
- package/dist/infrastructure/hitl/StatusedJsonStore.d.ts +30 -0
- package/dist/infrastructure/hitl/StatusedJsonStore.d.ts.map +1 -0
- package/dist/infrastructure/{fs/FsStatusedJsonRepository.js → hitl/StatusedJsonStore.js} +3 -3
- package/dist/infrastructure/hitl/StatusedJsonStore.js.map +1 -0
- package/dist/infrastructure/model/FsModelSerializer.d.ts +94 -0
- package/dist/infrastructure/model/FsModelSerializer.d.ts.map +1 -0
- package/dist/infrastructure/{fs/FsGraphSerializer.js → model/FsModelSerializer.js} +11 -11
- package/dist/infrastructure/model/FsModelSerializer.js.map +1 -0
- package/dist/infrastructure/oauth/GoogleOAuth.d.ts +20 -38
- package/dist/infrastructure/oauth/GoogleOAuth.d.ts.map +1 -1
- package/dist/infrastructure/oauth/GoogleOAuth.js +21 -22
- package/dist/infrastructure/oauth/GoogleOAuth.js.map +1 -1
- package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts +29 -0
- package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts.map +1 -0
- package/dist/infrastructure/reactor/FsReactorCycleRepository.js +94 -0
- package/dist/infrastructure/reactor/FsReactorCycleRepository.js.map +1 -0
- package/dist/infrastructure/secrets/SecretStore.d.ts +11 -14
- package/dist/infrastructure/secrets/SecretStore.d.ts.map +1 -1
- package/dist/infrastructure/secrets/SecretStore.js +4 -4
- package/dist/infrastructure/secrets/SecretStore.js.map +1 -1
- package/dist/infrastructure/{fs → skill}/FsRunRepository.d.ts +5 -3
- package/dist/infrastructure/skill/FsRunRepository.d.ts.map +1 -0
- package/dist/infrastructure/{fs → skill}/FsRunRepository.js +11 -9
- package/dist/infrastructure/skill/FsRunRepository.js.map +1 -0
- package/dist/infrastructure/{fs → skill}/FsSkillRegistry.d.ts +4 -13
- package/dist/infrastructure/skill/FsSkillRegistry.d.ts.map +1 -0
- package/dist/infrastructure/{fs → skill}/FsSkillRegistry.js +28 -20
- package/dist/infrastructure/skill/FsSkillRegistry.js.map +1 -0
- package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts +52 -0
- package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts.map +1 -0
- package/dist/infrastructure/{agent → skill}/SubprocessSkillRunner.js +107 -55
- package/dist/infrastructure/skill/SubprocessSkillRunner.js.map +1 -0
- package/dist/infrastructure/skill/asyncQueue.d.ts +20 -0
- package/dist/infrastructure/skill/asyncQueue.d.ts.map +1 -0
- package/dist/infrastructure/{agent → skill}/asyncQueue.js +2 -3
- package/dist/infrastructure/{agent → skill}/asyncQueue.js.map +1 -1
- package/dist/infrastructure/skill/lineBuffer.d.ts +15 -0
- package/dist/infrastructure/skill/lineBuffer.d.ts.map +1 -0
- package/dist/infrastructure/{agent/streamJsonParser.js → skill/lineBuffer.js} +5 -17
- package/dist/infrastructure/skill/lineBuffer.js.map +1 -0
- package/dist/infrastructure/skill/orphanReaper.d.ts +20 -0
- package/dist/infrastructure/skill/orphanReaper.d.ts.map +1 -0
- package/dist/infrastructure/{orphanReaper.js → skill/orphanReaper.js} +7 -5
- package/dist/infrastructure/skill/orphanReaper.js.map +1 -0
- package/dist/infrastructure/skill/subprocessEventStream.d.ts +16 -0
- package/dist/infrastructure/skill/subprocessEventStream.d.ts.map +1 -0
- package/dist/infrastructure/skill/subprocessEventStream.js +29 -0
- package/dist/infrastructure/skill/subprocessEventStream.js.map +1 -0
- package/dist/infrastructure/source/FsSourceUnitDigest.d.ts +19 -0
- package/dist/infrastructure/source/FsSourceUnitDigest.d.ts.map +1 -0
- package/dist/infrastructure/{fs → source}/FsSourceUnitDigest.js +9 -9
- package/dist/infrastructure/source/FsSourceUnitDigest.js.map +1 -0
- package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts +31 -0
- package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts.map +1 -0
- package/dist/infrastructure/{fs/FsSourceUnitStateRepository.js → source/FsSourceUnitObservationRepository.js} +18 -17
- package/dist/infrastructure/source/FsSourceUnitObservationRepository.js.map +1 -0
- package/dist/infrastructure/source/unitScan.d.ts +11 -0
- package/dist/infrastructure/source/unitScan.d.ts.map +1 -0
- package/dist/infrastructure/{fs/intentScan.js → source/unitScan.js} +36 -27
- package/dist/infrastructure/source/unitScan.js.map +1 -0
- package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts +2 -2
- package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts.map +1 -1
- package/dist/infrastructure/users/UserDirectoryFromRegistry.js +3 -2
- package/dist/infrastructure/users/UserDirectoryFromRegistry.js.map +1 -1
- package/dist/infrastructure/users/UserRegistryFile.d.ts +4 -5
- package/dist/infrastructure/users/UserRegistryFile.d.ts.map +1 -1
- package/dist/infrastructure/users/UserRegistryFile.js +6 -8
- package/dist/infrastructure/users/UserRegistryFile.js.map +1 -1
- package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts +9 -6
- package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts.map +1 -1
- package/dist/infrastructure/users/ensureWorkspaceOwners.js +10 -7
- package/dist/infrastructure/users/ensureWorkspaceOwners.js.map +1 -1
- package/dist/infrastructure/workspace/FsWorkspaceRepository.d.ts.map +1 -0
- package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.js +7 -6
- package/dist/infrastructure/workspace/FsWorkspaceRepository.js.map +1 -0
- package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts +18 -0
- package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts.map +1 -0
- package/dist/infrastructure/{fs → workspace}/WorkspaceDiscovery.js +15 -11
- package/dist/infrastructure/workspace/WorkspaceDiscovery.js.map +1 -0
- package/dist/infrastructure/{fs → workspace}/WorkspaceRegistryFile.d.ts +10 -9
- package/dist/infrastructure/workspace/WorkspaceRegistryFile.d.ts.map +1 -0
- package/dist/infrastructure/{fs → workspace}/WorkspaceRegistryFile.js +15 -17
- package/dist/infrastructure/workspace/WorkspaceRegistryFile.js.map +1 -0
- package/dist/infrastructure/workspace/productManifestWriter.d.ts +24 -0
- package/dist/infrastructure/workspace/productManifestWriter.d.ts.map +1 -0
- package/dist/infrastructure/{fs → workspace}/productManifestWriter.js +14 -26
- package/dist/infrastructure/workspace/productManifestWriter.js.map +1 -0
- package/dist/middleware/auth.d.ts +27 -17
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +69 -53
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/cors.d.ts.map +1 -1
- package/dist/middleware/cors.js +4 -1
- package/dist/middleware/cors.js.map +1 -1
- package/dist/middleware/error.d.ts.map +1 -1
- package/dist/middleware/error.js +15 -13
- package/dist/middleware/error.js.map +1 -1
- package/dist/middleware/workspaceAccess.d.ts +23 -19
- package/dist/middleware/workspaceAccess.d.ts.map +1 -1
- package/dist/middleware/workspaceAccess.js +31 -26
- package/dist/middleware/workspaceAccess.js.map +1 -1
- package/dist/policy/CapabilityCheck.d.ts +5 -5
- package/dist/policy/PermissionRegistry.d.ts +11 -9
- package/dist/policy/PermissionRegistry.d.ts.map +1 -1
- package/dist/policy/PermissionRegistry.js +10 -8
- package/dist/policy/PermissionRegistry.js.map +1 -1
- package/dist/policy/ViewerContext.d.ts +13 -11
- package/dist/policy/ViewerContext.d.ts.map +1 -1
- package/dist/policy/checks.d.ts +9 -9
- package/dist/policy/checks.d.ts.map +1 -1
- package/dist/policy/checks.js +14 -11
- package/dist/policy/checks.js.map +1 -1
- package/dist/policy/defaultRegistry.d.ts +3 -4
- package/dist/policy/defaultRegistry.d.ts.map +1 -1
- package/dist/policy/defaultRegistry.js +3 -4
- package/dist/policy/defaultRegistry.js.map +1 -1
- package/dist/policy/index.d.ts +2 -2
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +1 -1
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/resolveViewer.d.ts +9 -9
- package/dist/policy/resolveViewer.js +9 -9
- package/dist/routes/_shared.d.ts +93 -153
- package/dist/routes/_shared.d.ts.map +1 -1
- package/dist/routes/_shared.js +9 -5
- package/dist/routes/_shared.js.map +1 -1
- package/dist/routes/admin.d.ts +1 -1
- package/dist/routes/admin.d.ts.map +1 -1
- package/dist/routes/admin.js +13 -12
- package/dist/routes/admin.js.map +1 -1
- package/dist/routes/auth.d.ts +12 -10
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/auth.js +32 -34
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/clarifications.d.ts +8 -0
- package/dist/routes/clarifications.d.ts.map +1 -0
- package/dist/routes/clarifications.js +246 -0
- package/dist/routes/clarifications.js.map +1 -0
- package/dist/routes/edges.d.ts.map +1 -1
- package/dist/routes/edges.js +2 -6
- package/dist/routes/edges.js.map +1 -1
- package/dist/routes/history.d.ts.map +1 -1
- package/dist/routes/history.js +12 -10
- package/dist/routes/history.js.map +1 -1
- package/dist/routes/nodes.d.ts.map +1 -1
- package/dist/routes/nodes.js +4 -8
- package/dist/routes/nodes.js.map +1 -1
- package/dist/routes/oauth.d.ts +6 -7
- package/dist/routes/oauth.d.ts.map +1 -1
- package/dist/routes/oauth.js +6 -7
- package/dist/routes/oauth.js.map +1 -1
- package/dist/routes/ontologies.d.ts +7 -0
- package/dist/routes/ontologies.d.ts.map +1 -0
- package/dist/routes/ontologies.js +29 -0
- package/dist/routes/ontologies.js.map +1 -0
- package/dist/routes/ontology.d.ts.map +1 -1
- package/dist/routes/ontology.js +2 -1
- package/dist/routes/ontology.js.map +1 -1
- package/dist/routes/proposals.d.ts +2 -2
- package/dist/routes/proposals.d.ts.map +1 -1
- package/dist/routes/proposals.js +35 -30
- package/dist/routes/proposals.js.map +1 -1
- package/dist/routes/reactorCycles.d.ts +7 -0
- package/dist/routes/reactorCycles.d.ts.map +1 -0
- package/dist/routes/reactorCycles.js +60 -0
- package/dist/routes/reactorCycles.js.map +1 -0
- package/dist/routes/runs.d.ts.map +1 -1
- package/dist/routes/runs.js +22 -19
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/skillInputOptions.d.ts +2 -2
- package/dist/routes/skillInputOptions.d.ts.map +1 -1
- package/dist/routes/skillInputOptions.js +53 -53
- package/dist/routes/skillInputOptions.js.map +1 -1
- package/dist/routes/skills.d.ts +19 -1
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +141 -7
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/sourceLoaders.d.ts.map +1 -1
- package/dist/routes/sourceLoaders.js +1 -0
- package/dist/routes/sourceLoaders.js.map +1 -1
- package/dist/routes/sourceUnitObservations.d.ts +20 -0
- package/dist/routes/sourceUnitObservations.d.ts.map +1 -0
- package/dist/routes/sourceUnitObservations.js +80 -0
- package/dist/routes/sourceUnitObservations.js.map +1 -0
- package/dist/routes/sourceWebhooks.d.ts +26 -0
- package/dist/routes/sourceWebhooks.d.ts.map +1 -0
- package/dist/routes/sourceWebhooks.js +301 -0
- package/dist/routes/sourceWebhooks.js.map +1 -0
- package/dist/routes/users.d.ts +0 -2
- package/dist/routes/users.d.ts.map +1 -1
- package/dist/routes/users.js +15 -33
- package/dist/routes/users.js.map +1 -1
- package/dist/routes/workspaceEvents.d.ts +5 -4
- package/dist/routes/workspaceEvents.d.ts.map +1 -1
- package/dist/routes/workspaceEvents.js +7 -6
- package/dist/routes/workspaceEvents.js.map +1 -1
- package/dist/routes/workspaceMembers.d.ts +1 -1
- package/dist/routes/workspaceMembers.d.ts.map +1 -1
- package/dist/routes/workspaceMembers.js +2 -2
- package/dist/routes/workspaceMembers.js.map +1 -1
- package/dist/routes/workspaces.d.ts +21 -10
- package/dist/routes/workspaces.d.ts.map +1 -1
- package/dist/routes/workspaces.js +95 -69
- package/dist/routes/workspaces.js.map +1 -1
- package/dist/server.js +6 -70
- package/dist/server.js.map +1 -1
- package/dist/serviceAccounts.d.ts +13 -0
- package/dist/serviceAccounts.d.ts.map +1 -0
- package/dist/serviceAccounts.js +26 -0
- package/dist/serviceAccounts.js.map +1 -0
- package/dist/startServer.d.ts +17 -0
- package/dist/startServer.d.ts.map +1 -0
- package/dist/startServer.js +81 -0
- package/dist/startServer.js.map +1 -0
- package/dist/startup.d.ts +28 -0
- package/dist/startup.d.ts.map +1 -0
- package/dist/startup.js +94 -0
- package/dist/startup.js.map +1 -0
- package/package.json +35 -40
- package/dist/composeFs.d.ts +0 -55
- package/dist/composeFs.d.ts.map +0 -1
- package/dist/composeFs.js.map +0 -1
- package/dist/composition.d.ts +0 -133
- package/dist/composition.d.ts.map +0 -1
- package/dist/composition.js +0 -113
- package/dist/composition.js.map +0 -1
- package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts +0 -75
- package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts.map +0 -1
- package/dist/infrastructure/agent/SubprocessSkillRunner.js.map +0 -1
- package/dist/infrastructure/agent/asyncQueue.d.ts +0 -22
- package/dist/infrastructure/agent/asyncQueue.d.ts.map +0 -1
- package/dist/infrastructure/agent/mcpConfig.d.ts +0 -38
- package/dist/infrastructure/agent/mcpConfig.d.ts.map +0 -1
- package/dist/infrastructure/agent/mcpConfig.js +0 -55
- package/dist/infrastructure/agent/mcpConfig.js.map +0 -1
- package/dist/infrastructure/agent/streamJsonParser.d.ts +0 -20
- package/dist/infrastructure/agent/streamJsonParser.d.ts.map +0 -1
- package/dist/infrastructure/agent/streamJsonParser.js.map +0 -1
- package/dist/infrastructure/agent/subprocessEventStream.d.ts +0 -26
- package/dist/infrastructure/agent/subprocessEventStream.d.ts.map +0 -1
- package/dist/infrastructure/agent/subprocessEventStream.js +0 -112
- package/dist/infrastructure/agent/subprocessEventStream.js.map +0 -1
- package/dist/infrastructure/auth/ensureApprovedEmails.d.ts +0 -16
- package/dist/infrastructure/auth/ensureApprovedEmails.d.ts.map +0 -1
- package/dist/infrastructure/auth/ensureApprovedEmails.js +0 -20
- package/dist/infrastructure/auth/ensureApprovedEmails.js.map +0 -1
- package/dist/infrastructure/env.d.ts +0 -11
- package/dist/infrastructure/env.d.ts.map +0 -1
- package/dist/infrastructure/env.js.map +0 -1
- package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts +0 -300
- package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsBatchPlanRepository.js.map +0 -1
- package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts +0 -13
- package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsClarifyTicketRepository.js +0 -39
- package/dist/infrastructure/fs/FsClarifyTicketRepository.js.map +0 -1
- package/dist/infrastructure/fs/FsDecisionRepository.d.ts +0 -13
- package/dist/infrastructure/fs/FsDecisionRepository.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsDecisionRepository.js +0 -56
- package/dist/infrastructure/fs/FsDecisionRepository.js.map +0 -1
- package/dist/infrastructure/fs/FsGraphSerializer.d.ts +0 -629
- package/dist/infrastructure/fs/FsGraphSerializer.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsGraphSerializer.js.map +0 -1
- package/dist/infrastructure/fs/FsProposalRepository.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsProposalRepository.js.map +0 -1
- package/dist/infrastructure/fs/FsRunRepository.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsRunRepository.js.map +0 -1
- package/dist/infrastructure/fs/FsSkillRegistry.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsSkillRegistry.js.map +0 -1
- package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts +0 -19
- package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsSourceUnitDigest.js.map +0 -1
- package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts +0 -30
- package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsSourceUnitStateRepository.js.map +0 -1
- package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts +0 -35
- package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsStatusedJsonRepository.js.map +0 -1
- package/dist/infrastructure/fs/FsWorkspaceRepository.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsWorkspaceRepository.js.map +0 -1
- package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts +0 -15
- package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts.map +0 -1
- package/dist/infrastructure/fs/WorkspaceDiscovery.js.map +0 -1
- package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts.map +0 -1
- package/dist/infrastructure/fs/WorkspaceRegistryFile.js.map +0 -1
- package/dist/infrastructure/fs/frontmatter.d.ts +0 -13
- package/dist/infrastructure/fs/frontmatter.d.ts.map +0 -1
- package/dist/infrastructure/fs/frontmatter.js.map +0 -1
- package/dist/infrastructure/fs/intentScan.d.ts +0 -9
- package/dist/infrastructure/fs/intentScan.d.ts.map +0 -1
- package/dist/infrastructure/fs/intentScan.js.map +0 -1
- package/dist/infrastructure/fs/jsonFileStore.d.ts.map +0 -1
- package/dist/infrastructure/fs/jsonFileStore.js.map +0 -1
- package/dist/infrastructure/fs/paths.d.ts.map +0 -1
- package/dist/infrastructure/fs/paths.js.map +0 -1
- package/dist/infrastructure/fs/productManifestWriter.d.ts +0 -22
- package/dist/infrastructure/fs/productManifestWriter.d.ts.map +0 -1
- package/dist/infrastructure/fs/productManifestWriter.js.map +0 -1
- package/dist/infrastructure/git/GitWorkspaceHistory.d.ts.map +0 -1
- package/dist/infrastructure/git/GitWorkspaceHistory.js.map +0 -1
- package/dist/infrastructure/git/commitMessage.d.ts.map +0 -1
- package/dist/infrastructure/git/commitMessage.js +0 -71
- package/dist/infrastructure/git/commitMessage.js.map +0 -1
- package/dist/infrastructure/orphanReaper.d.ts +0 -18
- package/dist/infrastructure/orphanReaper.d.ts.map +0 -1
- package/dist/infrastructure/orphanReaper.js.map +0 -1
- package/dist/infrastructure/users/ensureLocalUser.d.ts +0 -15
- package/dist/infrastructure/users/ensureLocalUser.d.ts.map +0 -1
- package/dist/infrastructure/users/ensureLocalUser.js +0 -38
- package/dist/infrastructure/users/ensureLocalUser.js.map +0 -1
- package/dist/middleware/requireAdmin.d.ts +0 -10
- package/dist/middleware/requireAdmin.d.ts.map +0 -1
- package/dist/middleware/requireAdmin.js +0 -24
- package/dist/middleware/requireAdmin.js.map +0 -1
- package/dist/middleware/userId.d.ts +0 -16
- package/dist/middleware/userId.d.ts.map +0 -1
- package/dist/middleware/userId.js +0 -27
- package/dist/middleware/userId.js.map +0 -1
- package/dist/policy/Capability.d.ts +0 -12
- package/dist/policy/Capability.d.ts.map +0 -1
- package/dist/policy/Capability.js +0 -31
- package/dist/policy/Capability.js.map +0 -1
- package/dist/routes/clarify.d.ts +0 -9
- package/dist/routes/clarify.d.ts.map +0 -1
- package/dist/routes/clarify.js +0 -274
- package/dist/routes/clarify.js.map +0 -1
- package/dist/routes/decisions.d.ts +0 -7
- package/dist/routes/decisions.d.ts.map +0 -1
- package/dist/routes/decisions.js +0 -68
- package/dist/routes/decisions.js.map +0 -1
- package/dist/routes/sourceUnitStates.d.ts +0 -7
- package/dist/routes/sourceUnitStates.d.ts.map +0 -1
- package/dist/routes/sourceUnitStates.js +0 -45
- package/dist/routes/sourceUnitStates.js.map +0 -1
- /package/dist/infrastructure/{fs → _shared}/jsonFileStore.d.ts +0 -0
- /package/dist/infrastructure/{fs → _shared}/jsonFileStore.js +0 -0
- /package/dist/infrastructure/{git → history}/GitWorkspaceHistory.d.ts +0 -0
- /package/dist/infrastructure/{git → history}/commitMessage.d.ts +0 -0
- /package/dist/infrastructure/{fs → hitl}/FsProposalRepository.d.ts +0 -0
- /package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.d.ts +0 -0
package/dist/routes/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { newUserId, NotFoundError } from '@braidhq/core';
|
|
1
|
+
import { newUserId, NotFoundError, ServiceUnavailableError, ValidationError } from '@braidhq/core';
|
|
2
2
|
import { Hono } from 'hono';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { createOAuthState, createPkceVerifier } from '../infrastructure/oauth/GoogleOAuth.js';
|
|
@@ -14,9 +14,10 @@ const CallbackQuery = z.object({
|
|
|
14
14
|
});
|
|
15
15
|
export function createAuthRouter(deps) {
|
|
16
16
|
const router = new Hono();
|
|
17
|
-
// In-memory pending flows.
|
|
18
|
-
// supported topology in v0.2
|
|
19
|
-
//
|
|
17
|
+
// In-memory pending flows.
|
|
18
|
+
// A single-process server is the only supported topology in v0.2.
|
|
19
|
+
// HA or multi-process would need a shared store,
|
|
20
|
+
// but that's well past current scope.
|
|
20
21
|
const pending = new Map();
|
|
21
22
|
function reapExpired() {
|
|
22
23
|
const cutoff = Date.now() - PENDING_TTL_MS;
|
|
@@ -26,18 +27,14 @@ export function createAuthRouter(deps) {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
router.get('/google/start', async (context) => {
|
|
29
|
-
if (!deps.googleOAuth)
|
|
30
|
-
|
|
31
|
-
title: 'Google sign-in unavailable',
|
|
32
|
-
detail: 'Server is missing BRAID_GOOGLE_CLIENT_ID / BRAID_GOOGLE_CLIENT_SECRET; ask the admin to configure them.',
|
|
33
|
-
}, 503);
|
|
34
|
-
}
|
|
30
|
+
if (!deps.googleOAuth)
|
|
31
|
+
throw new ServiceUnavailableError('Server is missing BRAID_GOOGLE_CLIENT_ID / BRAID_GOOGLE_CLIENT_SECRET. Ask the admin to configure them.');
|
|
35
32
|
reapExpired();
|
|
36
33
|
const parsed = StartQuery.safeParse({
|
|
37
34
|
returnTo: context.req.query('returnTo'),
|
|
38
35
|
});
|
|
39
36
|
if (!parsed.success)
|
|
40
|
-
|
|
37
|
+
throw new ValidationError('Invalid returnTo query parameter.');
|
|
41
38
|
const state = createOAuthState();
|
|
42
39
|
const codeVerifier = createPkceVerifier();
|
|
43
40
|
pending.set(state, {
|
|
@@ -50,7 +47,7 @@ export function createAuthRouter(deps) {
|
|
|
50
47
|
});
|
|
51
48
|
router.get('/google/callback', async (context) => {
|
|
52
49
|
if (!deps.googleOAuth)
|
|
53
|
-
|
|
50
|
+
throw new ServiceUnavailableError('Google sign-in is not configured on this server.');
|
|
54
51
|
const parsed = CallbackQuery.safeParse({
|
|
55
52
|
code: context.req.query('code'),
|
|
56
53
|
state: context.req.query('state'),
|
|
@@ -58,7 +55,7 @@ export function createAuthRouter(deps) {
|
|
|
58
55
|
error_description: context.req.query('error_description'),
|
|
59
56
|
});
|
|
60
57
|
if (!parsed.success)
|
|
61
|
-
|
|
58
|
+
throw new ValidationError('Invalid callback parameters.');
|
|
62
59
|
const { code, state, error, error_description: errorDescription } = parsed.data;
|
|
63
60
|
if (error || !code || !state)
|
|
64
61
|
return redirectWithError(context, deps.studioUrl, error_description_or_default(error, errorDescription));
|
|
@@ -76,9 +73,9 @@ export function createAuthRouter(deps) {
|
|
|
76
73
|
const decision = await deps.accessPolicy.decide(profile.email);
|
|
77
74
|
if (!decision.allow)
|
|
78
75
|
return redirectWithError(context, flow.returnTo, decision.reason ?? 'Not authorized.');
|
|
79
|
-
// Resolve
|
|
80
|
-
//
|
|
81
|
-
// for invited users
|
|
76
|
+
// Resolve or create the user record. Google `sub` survives an email change,
|
|
77
|
+
// so prefer it as the join key,
|
|
78
|
+
// falling back to email for invited users new to login.
|
|
82
79
|
const isAdmin = deps.accessPolicy.isAdmin(profile.email);
|
|
83
80
|
let user = await deps.userRegistry.getByGoogleSub(profile.sub);
|
|
84
81
|
if (!user) {
|
|
@@ -96,8 +93,8 @@ export function createAuthRouter(deps) {
|
|
|
96
93
|
}
|
|
97
94
|
else if (isAdmin && user.serverRole !== 'admin') {
|
|
98
95
|
// BRAID_ADMIN_EMAILS was edited after this user was created.
|
|
99
|
-
// Promote on next login so re-deploying with new admin
|
|
100
|
-
//
|
|
96
|
+
// Promote on next login, so re-deploying with a new admin list,
|
|
97
|
+
// never needs manual user-table surgery.
|
|
101
98
|
user = await deps.userRegistry.update(user.id, { serverRole: 'admin' });
|
|
102
99
|
}
|
|
103
100
|
const session = await deps.sessionStore.issue(user.id);
|
|
@@ -112,11 +109,12 @@ export function createAuthRouter(deps) {
|
|
|
112
109
|
return context.body(null, 204);
|
|
113
110
|
});
|
|
114
111
|
router.get('/whoami', async (context) => {
|
|
115
|
-
// `/auth/*` is in the auth middleware's
|
|
116
|
-
// Bearer header isn't validated upstream.
|
|
117
|
-
// to identify the caller,
|
|
118
|
-
//
|
|
119
|
-
//
|
|
112
|
+
// `/auth/*` is in the auth middleware's PUBLIC_PATH_PREFIXES,
|
|
113
|
+
// so the Bearer header isn't validated upstream.
|
|
114
|
+
// Whoami exists precisely to identify the caller,
|
|
115
|
+
// so resolve the Bearer token here directly,
|
|
116
|
+
// rather than trusting the auth middleware's local-user fallback.
|
|
117
|
+
// An absent or invalid token yields `{ user: null }`.
|
|
120
118
|
const header = context.req.header('Authorization');
|
|
121
119
|
const token = header?.startsWith('Bearer ') ? header.slice('Bearer '.length).trim() : null;
|
|
122
120
|
let userId;
|
|
@@ -124,10 +122,10 @@ export function createAuthRouter(deps) {
|
|
|
124
122
|
const session = await deps.sessionStore.resolve(token);
|
|
125
123
|
userId = session?.userId;
|
|
126
124
|
}
|
|
127
|
-
//
|
|
128
|
-
// context userId
|
|
129
|
-
// wouldn't have rejected the request anyway.
|
|
130
|
-
if (!userId && deps.
|
|
125
|
+
// A deployment without enforced auth doesn't issue tokens,
|
|
126
|
+
// so fall back to the context userId, keeping /whoami working there.
|
|
127
|
+
// authMiddleware wouldn't have rejected the request anyway.
|
|
128
|
+
if (!userId && !deps.requiresAuth)
|
|
131
129
|
userId = context.get('userId');
|
|
132
130
|
if (!userId)
|
|
133
131
|
return context.json({ user: null });
|
|
@@ -141,22 +139,22 @@ export function createAuthRouter(deps) {
|
|
|
141
139
|
throw err;
|
|
142
140
|
}
|
|
143
141
|
});
|
|
144
|
-
// Hint at the configured studio URL
|
|
145
|
-
// can decide whether to gate at all
|
|
146
|
-
// whether Google is
|
|
147
|
-
// button leads to a 503
|
|
142
|
+
// Hint at the configured studio URL and auth mode,
|
|
143
|
+
// so the Login page can decide whether to gate at all,
|
|
144
|
+
// single-tenant skips it, and whether Google is configured,
|
|
145
|
+
// since otherwise the Sign-in button leads to a 503.
|
|
148
146
|
router.get('/config', (context) => {
|
|
149
147
|
return context.json({
|
|
150
148
|
googleEnabled: deps.googleOAuth !== undefined,
|
|
151
149
|
studioUrl: deps.studioUrl,
|
|
152
|
-
requiresAuth:
|
|
150
|
+
requiresAuth: deps.requiresAuth,
|
|
153
151
|
});
|
|
154
152
|
});
|
|
155
153
|
return router;
|
|
156
154
|
}
|
|
157
155
|
function redirectWithError(context, target, reason) {
|
|
158
|
-
// Use a clearly named hash key
|
|
159
|
-
// error out and
|
|
156
|
+
// Use a clearly named hash key.
|
|
157
|
+
// The Studio side pulls the error out and shows it on the Login page.
|
|
160
158
|
const url = `${target}#auth-error=${encodeURIComponent(reason)}`;
|
|
161
159
|
return context.redirect(url, 302);
|
|
162
160
|
}
|
package/dist/routes/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAClG,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAA;AAQ7F,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AA8BrC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAA;AAEF,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAClC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnC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QACD,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,GAAG,YAAY,aAAa;gBAC9B,OAAO,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;YACrC,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,mDAAmD;IACnD,uDAAuD;IACvD,4DAA4D;IAC5D,qDAAqD;IACrD,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;QAChC,OAAO,OAAO,CAAC,IAAI,CAAC;YAClB,aAAa,EAAE,IAAI,CAAC,WAAW,KAAK,SAAS;YAC7C,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAgB,EAAE,MAAc,EAAE,MAAc;IACzE,gCAAgC;IAChC,sEAAsE;IACtE,MAAM,GAAG,GAAG,GAAG,MAAM,eAAe,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAA;IAChE,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AACnC,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAyB,EAAE,WAA+B;IAC9F,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QACvC,OAAO,WAAW,CAAA;IACpB,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAC3B,OAAO,KAAK,CAAA;IACd,OAAO,wBAAwB,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ClarificationRepository, HITLService } from '@braidhq/core';
|
|
2
|
+
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
3
|
+
export interface ClarificationRouterDeps {
|
|
4
|
+
hitlService: HITLService;
|
|
5
|
+
clarificationRepository: ClarificationRepository;
|
|
6
|
+
}
|
|
7
|
+
export declare function createClarificationRouter(deps: ClarificationRouterDeps): OpenAPIHono;
|
|
8
|
+
//# sourceMappingURL=clarifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clarifications.d.ts","sourceRoot":"","sources":["../../src/routes/clarifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGzE,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAiE/D,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,WAAW,CAAA;IACxB,uBAAuB,EAAE,uBAAuB,CAAA;CACjD;AAiHD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,uBAAuB,GAAG,WAAW,CA0FpF"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { newClarificationCandidateId } from '@braidhq/core';
|
|
2
|
+
import { Clarification, ClarificationCandidateId, ClarificationCreateBody, ClarificationId, ClarificationStatus, ProposalId, UserId } from '@braidhq/schema';
|
|
3
|
+
import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi';
|
|
4
|
+
import { getUserId } from '../middleware/auth.js';
|
|
5
|
+
import { getViewerContext, requirePermission } from '../middleware/workspaceAccess.js';
|
|
6
|
+
import { getWorkspaceId } from '../middleware/workspaceId.js';
|
|
7
|
+
import { NotFoundResponse, ValidationFailureResponse, WorkspaceIdParam } from './_shared.js';
|
|
8
|
+
import { assertEntityInWorkspace } from './helpers.js';
|
|
9
|
+
const ListQuery = z.object({
|
|
10
|
+
status: z.union([ClarificationStatus, z.array(ClarificationStatus)]).optional().openapi({ description: 'Filter by clarification status. Pass one or many.' }),
|
|
11
|
+
limit: z.coerce.number().int().positive().optional(),
|
|
12
|
+
offset: z.coerce.number().int().nonnegative().optional(),
|
|
13
|
+
showAll: z.coerce.boolean().optional().openapi({ description: 'Owner-only: bypass the personal-pending filter so every member\'s open questions are visible.' }),
|
|
14
|
+
});
|
|
15
|
+
// Reviewer-facing answer body.
|
|
16
|
+
// The selection is either an existing `candidateId`,
|
|
17
|
+
// or a freshly authored `customCandidate` (description only).
|
|
18
|
+
// The server appends it to the clarification and answers in one transaction.
|
|
19
|
+
// `note` is a free-text rationale saved on the answer commit.
|
|
20
|
+
// `userId` is accepted for backwards compat,
|
|
21
|
+
// the authoritative value is the request context set by middleware.
|
|
22
|
+
const AnswerBody = z
|
|
23
|
+
.object({
|
|
24
|
+
candidateId: ClarificationCandidateId.optional(),
|
|
25
|
+
customCandidate: z.object({ description: z.string().min(1) }).optional(),
|
|
26
|
+
userId: UserId.optional(),
|
|
27
|
+
note: z.string().min(1).optional(),
|
|
28
|
+
})
|
|
29
|
+
.refine(body => Boolean(body.candidateId) !== Boolean(body.customCandidate), { message: 'Provide exactly one of candidateId or customCandidate' })
|
|
30
|
+
.openapi('ClarificationAnswerBody');
|
|
31
|
+
const SkipBody = z.object({
|
|
32
|
+
reason: z.string().min(1),
|
|
33
|
+
userId: UserId.optional(),
|
|
34
|
+
}).openapi('ClarificationSkipBody');
|
|
35
|
+
// PATCH body for clarification state transitions.
|
|
36
|
+
// The only legal transition the skill drives is `answered` to `applied`.
|
|
37
|
+
// The proposalId is optional, present when a Proposal was produced,
|
|
38
|
+
// absent when the chosen candidate had no graph impact.
|
|
39
|
+
// The skill then records the clarification as applied without a linking proposal.
|
|
40
|
+
const ApplyBody = z.object({
|
|
41
|
+
status: z.literal('applied'),
|
|
42
|
+
proposalId: ProposalId.optional(),
|
|
43
|
+
userId: UserId.optional(),
|
|
44
|
+
}).openapi('ClarificationApplyBody');
|
|
45
|
+
// Skill-emitted candidates ship their own ids (`cc-1`, `cc-merge`).
|
|
46
|
+
// Human-authored ones via Studio's "New question" form omit them,
|
|
47
|
+
// letting the server mint via `newClarificationCandidateId`.
|
|
48
|
+
// This keeps the ID minting rule intact,
|
|
49
|
+
// no `crypto.randomUUID() as XxxId` in clients.
|
|
50
|
+
const CreateBody = ClarificationCreateBody.openapi('ClarificationCreateBody');
|
|
51
|
+
const ClarificationIdParam = WorkspaceIdParam.extend({
|
|
52
|
+
clarificationId: ClarificationId.openapi({ param: { name: 'clarificationId', in: 'path' } }),
|
|
53
|
+
});
|
|
54
|
+
const ClarificationListResponse = z.object({
|
|
55
|
+
items: z.array(Clarification),
|
|
56
|
+
}).openapi('ClarificationListResponse');
|
|
57
|
+
const createClarificationRoute = createRoute({
|
|
58
|
+
method: 'post',
|
|
59
|
+
path: '/',
|
|
60
|
+
operationId: 'createClarification',
|
|
61
|
+
summary: 'Create a clarification. Skills submit this when they cannot decide between candidate interpretations.',
|
|
62
|
+
tags: ['clarify'],
|
|
63
|
+
request: {
|
|
64
|
+
params: WorkspaceIdParam,
|
|
65
|
+
body: { content: { 'application/json': { schema: CreateBody } } },
|
|
66
|
+
},
|
|
67
|
+
responses: {
|
|
68
|
+
201: {
|
|
69
|
+
description: 'The saved clarification.',
|
|
70
|
+
content: { 'application/json': { schema: Clarification } },
|
|
71
|
+
},
|
|
72
|
+
400: ValidationFailureResponse,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
const listClarificationRoute = createRoute({
|
|
76
|
+
method: 'get',
|
|
77
|
+
path: '/',
|
|
78
|
+
operationId: 'listClarifications',
|
|
79
|
+
summary: 'List clarifications for a workspace, optionally filtered by status.',
|
|
80
|
+
tags: ['clarify'],
|
|
81
|
+
request: {
|
|
82
|
+
params: WorkspaceIdParam,
|
|
83
|
+
query: ListQuery,
|
|
84
|
+
},
|
|
85
|
+
responses: {
|
|
86
|
+
200: {
|
|
87
|
+
description: 'A page of matching clarifications.',
|
|
88
|
+
content: { 'application/json': { schema: ClarificationListResponse } },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
const getClarificationRoute = createRoute({
|
|
93
|
+
method: 'get',
|
|
94
|
+
path: '/{clarificationId}',
|
|
95
|
+
operationId: 'getClarification',
|
|
96
|
+
summary: 'Fetch a single clarification.',
|
|
97
|
+
tags: ['clarify'],
|
|
98
|
+
request: { params: ClarificationIdParam },
|
|
99
|
+
responses: {
|
|
100
|
+
200: {
|
|
101
|
+
description: 'The requested clarification.',
|
|
102
|
+
content: { 'application/json': { schema: Clarification } },
|
|
103
|
+
},
|
|
104
|
+
404: NotFoundResponse,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
const answerClarificationRoute = createRoute({
|
|
108
|
+
method: 'post',
|
|
109
|
+
path: '/{clarificationId}/answer',
|
|
110
|
+
operationId: 'answerClarification',
|
|
111
|
+
summary: 'Reviewer answers a clarification. Triggers `pending` to `answered` transition.',
|
|
112
|
+
tags: ['clarify'],
|
|
113
|
+
request: {
|
|
114
|
+
params: ClarificationIdParam,
|
|
115
|
+
body: { content: { 'application/json': { schema: AnswerBody } } },
|
|
116
|
+
},
|
|
117
|
+
responses: {
|
|
118
|
+
200: {
|
|
119
|
+
description: 'The updated clarification.',
|
|
120
|
+
content: { 'application/json': { schema: Clarification } },
|
|
121
|
+
},
|
|
122
|
+
404: NotFoundResponse,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
const applyClarificationRoute = createRoute({
|
|
126
|
+
method: 'patch',
|
|
127
|
+
path: '/{clarificationId}',
|
|
128
|
+
operationId: 'markClarificationApplied',
|
|
129
|
+
summary: 'Mark a clarification applied. Optionally link the materialised Proposal.',
|
|
130
|
+
description: 'Called by the ddd:clarify skill once it has wrapped the resolution into a Proposal (or determined there is no graph impact). Transitions `answered` to `applied`.',
|
|
131
|
+
tags: ['clarify'],
|
|
132
|
+
request: {
|
|
133
|
+
params: ClarificationIdParam,
|
|
134
|
+
body: { content: { 'application/json': { schema: ApplyBody } } },
|
|
135
|
+
},
|
|
136
|
+
responses: {
|
|
137
|
+
200: {
|
|
138
|
+
description: 'The updated clarification.',
|
|
139
|
+
content: { 'application/json': { schema: Clarification } },
|
|
140
|
+
},
|
|
141
|
+
404: NotFoundResponse,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
const skipClarificationRoute = createRoute({
|
|
145
|
+
method: 'post',
|
|
146
|
+
path: '/{clarificationId}/skip',
|
|
147
|
+
operationId: 'skipClarification',
|
|
148
|
+
summary: 'Skip a clarification with a reason. Triggers `pending` to `skipped` transition.',
|
|
149
|
+
tags: ['clarify'],
|
|
150
|
+
request: {
|
|
151
|
+
params: ClarificationIdParam,
|
|
152
|
+
body: { content: { 'application/json': { schema: SkipBody } } },
|
|
153
|
+
},
|
|
154
|
+
responses: {
|
|
155
|
+
200: {
|
|
156
|
+
description: 'The updated clarification.',
|
|
157
|
+
content: { 'application/json': { schema: Clarification } },
|
|
158
|
+
},
|
|
159
|
+
404: NotFoundResponse,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
export function createClarificationRouter(deps) {
|
|
163
|
+
const router = new OpenAPIHono();
|
|
164
|
+
// Answer, skip, and mark-applied are HITL decisions,
|
|
165
|
+
// Owner and Maintainer only.
|
|
166
|
+
// Guests never see the tab, but a direct curl still 403s here.
|
|
167
|
+
router.use('/:clarificationId/answer', requirePermission('clarification.write'));
|
|
168
|
+
router.use('/:clarificationId/skip', requirePermission('clarification.write'));
|
|
169
|
+
router.use('/:clarificationId', requirePermission('clarification.write'));
|
|
170
|
+
router.openapi(createClarificationRoute, async (context) => {
|
|
171
|
+
const workspaceId = getWorkspaceId(context);
|
|
172
|
+
const body = context.req.valid('json');
|
|
173
|
+
const submitterId = getUserId(context);
|
|
174
|
+
const candidates = body.candidates.map(c => ({
|
|
175
|
+
...c,
|
|
176
|
+
id: c.id ?? newClarificationCandidateId(),
|
|
177
|
+
}));
|
|
178
|
+
const clarification = await deps.hitlService.submitClarification({ ...body, workspaceId, candidates, submitterId });
|
|
179
|
+
return context.json(clarification.toData(), 201);
|
|
180
|
+
});
|
|
181
|
+
router.openapi(listClarificationRoute, async (context) => {
|
|
182
|
+
const workspaceId = getWorkspaceId(context);
|
|
183
|
+
const { status, limit, offset, showAll } = context.req.valid('query');
|
|
184
|
+
const statuses = status === undefined ? undefined : Array.isArray(status) ? status : [status];
|
|
185
|
+
const viewer = getViewerContext(context);
|
|
186
|
+
const isOwner = viewer?.effectiveRole === 'owner';
|
|
187
|
+
// No viewer is an open composition (in-memory), which applies no personal filter.
|
|
188
|
+
const viewerId = (!viewer || (showAll && isOwner)) ? undefined : getUserId(context);
|
|
189
|
+
// Owners also see service-owned (autonomous) pending, since only they can act on it.
|
|
190
|
+
const clarifications = await deps.clarificationRepository.list({
|
|
191
|
+
workspaceId,
|
|
192
|
+
statuses,
|
|
193
|
+
limit,
|
|
194
|
+
offset,
|
|
195
|
+
...(viewerId ? { viewerId, includeServiceOwned: isOwner } : {}),
|
|
196
|
+
});
|
|
197
|
+
return context.json({ items: clarifications.map(clarification => clarification.toData()) }, 200);
|
|
198
|
+
});
|
|
199
|
+
router.openapi(getClarificationRoute, async (context) => {
|
|
200
|
+
const workspaceId = getWorkspaceId(context);
|
|
201
|
+
const { clarificationId } = context.req.valid('param');
|
|
202
|
+
const clarification = await deps.clarificationRepository.load(clarificationId);
|
|
203
|
+
assertEntityInWorkspace(workspaceId, clarification.workspaceId, 'Clarification', clarificationId);
|
|
204
|
+
return context.json(clarification.toData(), 200);
|
|
205
|
+
});
|
|
206
|
+
router.openapi(answerClarificationRoute, async (context) => {
|
|
207
|
+
const workspaceId = getWorkspaceId(context);
|
|
208
|
+
const { clarificationId } = context.req.valid('param');
|
|
209
|
+
const body = context.req.valid('json');
|
|
210
|
+
const userId = body.userId ?? getUserId(context);
|
|
211
|
+
const clarification = await deps.clarificationRepository.load(clarificationId);
|
|
212
|
+
assertEntityInWorkspace(workspaceId, clarification.workspaceId, 'Clarification', clarificationId);
|
|
213
|
+
const selection = body.candidateId
|
|
214
|
+
? { kind: 'existing', candidateId: body.candidateId }
|
|
215
|
+
: { kind: 'custom', description: body.customCandidate.description };
|
|
216
|
+
const answered = await deps.hitlService.answerClarification({
|
|
217
|
+
clarificationId,
|
|
218
|
+
selection,
|
|
219
|
+
userId,
|
|
220
|
+
...(body.note ? { note: body.note } : {}),
|
|
221
|
+
});
|
|
222
|
+
return context.json(answered.toData(), 200);
|
|
223
|
+
});
|
|
224
|
+
router.openapi(applyClarificationRoute, async (context) => {
|
|
225
|
+
const workspaceId = getWorkspaceId(context);
|
|
226
|
+
const { clarificationId } = context.req.valid('param');
|
|
227
|
+
const { proposalId, userId: bodyUserId } = context.req.valid('json');
|
|
228
|
+
const userId = bodyUserId ?? getUserId(context);
|
|
229
|
+
const clarification = await deps.clarificationRepository.load(clarificationId);
|
|
230
|
+
assertEntityInWorkspace(workspaceId, clarification.workspaceId, 'Clarification', clarificationId);
|
|
231
|
+
const applied = await deps.hitlService.markClarificationApplied(clarificationId, userId, proposalId);
|
|
232
|
+
return context.json(applied.toData(), 200);
|
|
233
|
+
});
|
|
234
|
+
router.openapi(skipClarificationRoute, async (context) => {
|
|
235
|
+
const workspaceId = getWorkspaceId(context);
|
|
236
|
+
const { clarificationId } = context.req.valid('param');
|
|
237
|
+
const { reason, userId: bodyUserId } = context.req.valid('json');
|
|
238
|
+
const userId = bodyUserId ?? getUserId(context);
|
|
239
|
+
const clarification = await deps.clarificationRepository.load(clarificationId);
|
|
240
|
+
assertEntityInWorkspace(workspaceId, clarification.workspaceId, 'Clarification', clarificationId);
|
|
241
|
+
const skipped = await deps.hitlService.skipClarification(clarificationId, reason, userId);
|
|
242
|
+
return context.json(skipped.toData(), 200);
|
|
243
|
+
});
|
|
244
|
+
return router;
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=clarifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clarifications.js","sourceRoot":"","sources":["../../src/routes/clarifications.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,eAAe,EAAE,mBAAmB,EAAE,UAAU,E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F,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edges.d.ts","sourceRoot":"","sources":["../../src/routes/edges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"edges.d.ts","sourceRoot":"","sources":["../../src/routes/edges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAgB/D,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAqBD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAgBpE"}
|
package/dist/routes/edges.js
CHANGED
|
@@ -3,13 +3,11 @@ import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi';
|
|
|
3
3
|
import { getWorkspaceId } from '../middleware/workspaceId.js';
|
|
4
4
|
import { ValidationFailureResponse, WorkspaceIdParam } from './_shared.js';
|
|
5
5
|
const ListQuery = z.object({
|
|
6
|
-
type: z.union([EdgeTypeId, z.array(EdgeTypeId)]).optional().openapi({ description: 'Filter by edge type id
|
|
6
|
+
type: z.union([EdgeTypeId, z.array(EdgeTypeId)]).optional().openapi({ description: 'Filter by edge type id. Pass one or many.' }),
|
|
7
7
|
fromNodeId: NodeId.optional()
|
|
8
8
|
.openapi({ description: 'Filter to edges originating from this node.' }),
|
|
9
9
|
toNodeId: NodeId.optional()
|
|
10
10
|
.openapi({ description: 'Filter to edges terminating at this node.' }),
|
|
11
|
-
limit: z.coerce.number().int().positive().optional().openapi({ description: 'Maximum number of edges to return.' }),
|
|
12
|
-
offset: z.coerce.number().int().nonnegative().optional().openapi({ description: 'Number of edges to skip before returning.' }),
|
|
13
11
|
});
|
|
14
12
|
const EdgeListResponse = z.object({
|
|
15
13
|
items: z.array(GraphEdge),
|
|
@@ -36,14 +34,12 @@ export function createEdgesRouter(deps) {
|
|
|
36
34
|
const router = new OpenAPIHono();
|
|
37
35
|
router.openapi(listEdgesRoute, async (context) => {
|
|
38
36
|
const workspaceId = getWorkspaceId(context);
|
|
39
|
-
const { type, fromNodeId, toNodeId
|
|
37
|
+
const { type, fromNodeId, toNodeId } = context.req.valid('query');
|
|
40
38
|
const types = type === undefined ? undefined : Array.isArray(type) ? type : [type];
|
|
41
39
|
const edges = await deps.modelService.listEdges(workspaceId, {
|
|
42
40
|
types,
|
|
43
41
|
fromNodeId,
|
|
44
42
|
toNodeId,
|
|
45
|
-
limit,
|
|
46
|
-
offset,
|
|
47
43
|
});
|
|
48
44
|
return context.json({ items: edges }, 200);
|
|
49
45
|
});
|
package/dist/routes/edges.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edges.js","sourceRoot":"","sources":["../../src/routes/edges.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE1E,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,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file":"history.d.ts","sourceRoot":"","sources":["../../src/routes/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAInD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/routes/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAInD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AA6B3B,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,cAAc,CAAA;CAC/B;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAqEjE"}
|
package/dist/routes/history.js
CHANGED
|
@@ -3,11 +3,12 @@ import { CommitSha, UserId } from '@braidhq/schema';
|
|
|
3
3
|
import { zValidator } from '@hono/zod-validator';
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { getUserId } from '../middleware/
|
|
6
|
+
import { getUserId } from '../middleware/auth.js';
|
|
7
7
|
import { requirePermission } from '../middleware/workspaceAccess.js';
|
|
8
8
|
import { getWorkspaceId } from '../middleware/workspaceId.js';
|
|
9
|
-
// `userId` accepted for backwards compat
|
|
10
|
-
// comes from the request context
|
|
9
|
+
// `userId` accepted for backwards compat,
|
|
10
|
+
// the authoritative value comes from the request context,
|
|
11
|
+
// set by the auth middleware.
|
|
11
12
|
const RestoreBody = z.object({
|
|
12
13
|
userId: UserId.optional(),
|
|
13
14
|
});
|
|
@@ -20,14 +21,15 @@ const ListQuery = z.object({
|
|
|
20
21
|
since: CommitSha.optional(),
|
|
21
22
|
limit: z.coerce.number().int().positive().max(200).optional(),
|
|
22
23
|
});
|
|
23
|
-
const
|
|
24
|
+
const ModelDiffQuery = z.object({
|
|
24
25
|
from: CommitSha,
|
|
25
26
|
to: CommitSha,
|
|
26
27
|
});
|
|
27
28
|
export function createHistoryRouter(deps) {
|
|
28
29
|
const router = new Hono();
|
|
29
|
-
// Restore is destructive
|
|
30
|
-
//
|
|
30
|
+
// Restore is destructive, Owner only.
|
|
31
|
+
// Tag CRUD is workspace metadata management,
|
|
32
|
+
// Owner only as well to keep ACL coherent.
|
|
31
33
|
router.use('/:sha/restore', requirePermission('history.write'));
|
|
32
34
|
router.use('/tags', requirePermission('history.write'));
|
|
33
35
|
router.use('/tags/*', requirePermission('history.write'));
|
|
@@ -41,10 +43,10 @@ export function createHistoryRouter(deps) {
|
|
|
41
43
|
return context.json({ items });
|
|
42
44
|
});
|
|
43
45
|
// Must be registered before `/:sha` so `graph-diff` isn't matched as a sha.
|
|
44
|
-
router.get('/graph-diff', zValidator('query',
|
|
46
|
+
router.get('/graph-diff', zValidator('query', ModelDiffQuery), async (context) => {
|
|
45
47
|
const workspaceId = getWorkspaceId(context);
|
|
46
48
|
const { from, to } = context.req.valid('query');
|
|
47
|
-
const envelope = await deps.historyService.
|
|
49
|
+
const envelope = await deps.historyService.getModelDiff(workspaceId, from, to);
|
|
48
50
|
return context.json(envelope);
|
|
49
51
|
});
|
|
50
52
|
router.get('/tags', async (context) => {
|
|
@@ -62,7 +64,7 @@ export function createHistoryRouter(deps) {
|
|
|
62
64
|
const workspaceId = getWorkspaceId(context);
|
|
63
65
|
const name = context.req.param('name');
|
|
64
66
|
if (!name)
|
|
65
|
-
throw new NotFoundError('
|
|
67
|
+
throw new NotFoundError('Tag name is required');
|
|
66
68
|
await deps.historyService.deleteTag(workspaceId, name);
|
|
67
69
|
return context.body(null, 204);
|
|
68
70
|
});
|
|
@@ -79,7 +81,7 @@ export function createHistoryRouter(deps) {
|
|
|
79
81
|
const sha = CommitSha.parse(context.req.param('sha'));
|
|
80
82
|
const commit = await deps.historyService.getCommit(workspaceId, sha);
|
|
81
83
|
if (!commit)
|
|
82
|
-
throw new NotFoundError(`
|
|
84
|
+
throw new NotFoundError(`Commit ${sha} not found in workspace ${workspaceId}`);
|
|
83
85
|
const diff = await deps.historyService.getCommitDiff(workspaceId, sha);
|
|
84
86
|
return context.json({ ...commit, diff });
|
|
85
87
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/routes/history.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/routes/history.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAE7D,0CAA0C;AAC1C,0DAA0D;AAC1D,8BAA8B;AAC9B,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;CAC1B,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;IACvB,GAAG,EAAE,SAAS;IACd,IAAI,EAAE,CAA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src/routes/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAsB/D,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAwDD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAgCpE"}
|