@braidhq/server 0.0.1 → 0.2.0
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/README.md +164 -0
- package/dist/app.d.ts +12 -3
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +154 -9
- 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 +79 -0
- package/dist/composeApp.d.ts.map +1 -0
- package/dist/composeApp.js +136 -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/composeFsApp.js +309 -0
- 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/_shared/env.js +19 -0
- 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/_shared/paths.d.ts +43 -0
- package/dist/infrastructure/_shared/paths.d.ts.map +1 -0
- package/dist/infrastructure/_shared/paths.js +96 -0
- package/dist/infrastructure/_shared/paths.js.map +1 -0
- package/dist/infrastructure/auth/AccessPolicy.d.ts +87 -0
- package/dist/infrastructure/auth/AccessPolicy.d.ts.map +1 -0
- package/dist/infrastructure/auth/AccessPolicy.js +177 -0
- package/dist/infrastructure/auth/AccessPolicy.js.map +1 -0
- package/dist/infrastructure/auth/SessionStore.d.ts +50 -0
- package/dist/infrastructure/auth/SessionStore.d.ts.map +1 -0
- package/dist/infrastructure/auth/SessionStore.js +104 -0
- package/dist/infrastructure/auth/SessionStore.js.map +1 -0
- package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts +79 -0
- package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts.map +1 -0
- package/dist/infrastructure/batch/FsBatchPlanRepository.js +42 -0
- package/dist/infrastructure/batch/FsBatchPlanRepository.js.map +1 -0
- package/dist/infrastructure/history/GitWorkspaceHistory.d.ts +18 -0
- package/dist/infrastructure/history/GitWorkspaceHistory.d.ts.map +1 -0
- package/dist/infrastructure/history/GitWorkspaceHistory.js +310 -0
- package/dist/infrastructure/history/GitWorkspaceHistory.js.map +1 -0
- package/dist/infrastructure/history/commitMessage.d.ts +4 -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 +39 -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 +10 -3
- 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 +96 -0
- package/dist/infrastructure/model/FsModelSerializer.d.ts.map +1 -0
- package/dist/infrastructure/model/FsModelSerializer.js +60 -0
- package/dist/infrastructure/model/FsModelSerializer.js.map +1 -0
- package/dist/infrastructure/oauth/GoogleOAuth.d.ts +43 -14
- package/dist/infrastructure/oauth/GoogleOAuth.d.ts.map +1 -1
- package/dist/infrastructure/oauth/GoogleOAuth.js +78 -11
- 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 +9 -4
- package/dist/infrastructure/skill/FsRunRepository.d.ts.map +1 -0
- package/dist/infrastructure/skill/FsRunRepository.js +162 -0
- 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 +38 -18
- package/dist/infrastructure/skill/FsSkillRegistry.js.map +1 -0
- package/dist/infrastructure/{agent → skill}/SubprocessSkillRunner.d.ts +13 -15
- package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts.map +1 -0
- package/dist/infrastructure/{agent → skill}/SubprocessSkillRunner.js +124 -40
- 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/source/FsSourceUnitDigest.js +58 -0
- 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/source/FsSourceUnitObservationRepository.js +88 -0
- package/dist/infrastructure/source/FsSourceUnitObservationRepository.js.map +1 -0
- package/dist/infrastructure/source/intentScan.d.ts +13 -0
- package/dist/infrastructure/source/intentScan.d.ts.map +1 -0
- package/dist/infrastructure/source/intentScan.js +137 -0
- package/dist/infrastructure/source/intentScan.js.map +1 -0
- package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts +14 -0
- package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts.map +1 -0
- package/dist/infrastructure/users/UserDirectoryFromRegistry.js +21 -0
- package/dist/infrastructure/users/UserDirectoryFromRegistry.js.map +1 -0
- package/dist/infrastructure/users/UserRegistryFile.d.ts +22 -0
- package/dist/infrastructure/users/UserRegistryFile.d.ts.map +1 -0
- package/dist/infrastructure/users/UserRegistryFile.js +89 -0
- package/dist/infrastructure/users/UserRegistryFile.js.map +1 -0
- package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts +12 -0
- package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts.map +1 -0
- package/dist/infrastructure/users/ensureWorkspaceOwners.js +25 -0
- package/dist/infrastructure/users/ensureWorkspaceOwners.js.map +1 -0
- package/dist/infrastructure/workspace/FsWorkspaceRepository.d.ts.map +1 -0
- package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.js +15 -5
- 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/workspace/WorkspaceDiscovery.js +50 -0
- package/dist/infrastructure/workspace/WorkspaceDiscovery.js.map +1 -0
- package/dist/infrastructure/workspace/WorkspaceRegistryFile.d.ts +42 -0
- package/dist/infrastructure/workspace/WorkspaceRegistryFile.d.ts.map +1 -0
- package/dist/infrastructure/workspace/WorkspaceRegistryFile.js +160 -0
- 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 -28
- package/dist/infrastructure/workspace/productManifestWriter.js.map +1 -0
- package/dist/middleware/auth.d.ts +39 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +87 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/cors.d.ts.map +1 -1
- package/dist/middleware/cors.js +5 -2
- 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 +51 -0
- package/dist/middleware/workspaceAccess.d.ts.map +1 -0
- package/dist/middleware/workspaceAccess.js +91 -0
- package/dist/middleware/workspaceAccess.js.map +1 -0
- package/dist/policy/CapabilityCheck.d.ts +14 -0
- package/dist/policy/CapabilityCheck.d.ts.map +1 -0
- package/dist/policy/CapabilityCheck.js +2 -0
- package/dist/policy/CapabilityCheck.js.map +1 -0
- package/dist/policy/PermissionRegistry.d.ts +25 -0
- package/dist/policy/PermissionRegistry.d.ts.map +1 -0
- package/dist/policy/PermissionRegistry.js +29 -0
- package/dist/policy/PermissionRegistry.js.map +1 -0
- package/dist/policy/ViewerContext.d.ts +29 -0
- package/dist/policy/ViewerContext.d.ts.map +1 -0
- package/dist/policy/ViewerContext.js +2 -0
- package/dist/policy/ViewerContext.js.map +1 -0
- package/dist/policy/checks.d.ts +15 -0
- package/dist/policy/checks.d.ts.map +1 -0
- package/dist/policy/checks.js +55 -0
- package/dist/policy/checks.js.map +1 -0
- package/dist/policy/defaultRegistry.d.ts +9 -0
- package/dist/policy/defaultRegistry.d.ts.map +1 -0
- package/dist/policy/defaultRegistry.js +15 -0
- package/dist/policy/defaultRegistry.js.map +1 -0
- package/dist/policy/index.d.ts +8 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +5 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/resolveViewer.d.ts +16 -0
- package/dist/policy/resolveViewer.d.ts.map +1 -0
- package/dist/policy/resolveViewer.js +37 -0
- package/dist/policy/resolveViewer.js.map +1 -0
- package/dist/routes/_shared.d.ts +138 -0
- package/dist/routes/_shared.d.ts.map +1 -0
- package/dist/routes/_shared.js +33 -0
- package/dist/routes/_shared.js.map +1 -0
- package/dist/routes/admin.d.ts +13 -0
- package/dist/routes/admin.d.ts.map +1 -0
- package/dist/routes/admin.js +228 -0
- package/dist/routes/admin.js.map +1 -0
- package/dist/routes/auth.d.ts +35 -0
- package/dist/routes/auth.d.ts.map +1 -0
- package/dist/routes/auth.js +168 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/batch.d.ts +7 -0
- package/dist/routes/batch.d.ts.map +1 -0
- package/dist/routes/batch.js +47 -0
- package/dist/routes/batch.js.map +1 -0
- package/dist/routes/clarifications.d.ts +8 -0
- package/dist/routes/clarifications.d.ts.map +1 -0
- package/dist/routes/clarifications.js +243 -0
- package/dist/routes/clarifications.js.map +1 -0
- package/dist/routes/edges.d.ts +2 -2
- package/dist/routes/edges.d.ts.map +1 -1
- package/dist/routes/edges.js +34 -16
- package/dist/routes/edges.js.map +1 -1
- package/dist/routes/health.d.ts +2 -2
- package/dist/routes/health.d.ts.map +1 -1
- package/dist/routes/health.js +21 -3
- package/dist/routes/health.js.map +1 -1
- package/dist/routes/history.d.ts +7 -0
- package/dist/routes/history.d.ts.map +1 -0
- package/dist/routes/history.js +90 -0
- package/dist/routes/history.js.map +1 -0
- package/dist/routes/model.d.ts +2 -2
- package/dist/routes/model.d.ts.map +1 -1
- package/dist/routes/model.js +20 -4
- package/dist/routes/model.js.map +1 -1
- package/dist/routes/nodes.d.ts +2 -2
- package/dist/routes/nodes.d.ts.map +1 -1
- package/dist/routes/nodes.js +77 -25
- 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/ontology.d.ts +2 -2
- package/dist/routes/ontology.d.ts.map +1 -1
- package/dist/routes/ontology.js +22 -5
- package/dist/routes/ontology.js.map +1 -1
- package/dist/routes/proposals.d.ts +5 -4
- package/dist/routes/proposals.d.ts.map +1 -1
- package/dist/routes/proposals.js +176 -45
- 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 +66 -12
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/skillInputOptions.d.ts +10 -0
- package/dist/routes/skillInputOptions.d.ts.map +1 -0
- package/dist/routes/skillInputOptions.js +159 -0
- package/dist/routes/skillInputOptions.js.map +1 -0
- package/dist/routes/skills.d.ts +21 -3
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +223 -21
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/sourceLoaders.d.ts +7 -0
- package/dist/routes/sourceLoaders.d.ts.map +1 -0
- package/dist/routes/sourceLoaders.js +30 -0
- package/dist/routes/sourceLoaders.js.map +1 -0
- 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 +7 -0
- package/dist/routes/users.d.ts.map +1 -0
- package/dist/routes/users.js +109 -0
- package/dist/routes/users.js.map +1 -0
- 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 +11 -0
- package/dist/routes/workspaceMembers.d.ts.map +1 -0
- package/dist/routes/workspaceMembers.js +81 -0
- package/dist/routes/workspaceMembers.js.map +1 -0
- package/dist/routes/workspaces.d.ts +30 -1
- package/dist/routes/workspaces.d.ts.map +1 -1
- package/dist/routes/workspaces.js +207 -63
- package/dist/routes/workspaces.js.map +1 -1
- package/dist/server.js +9 -29
- package/dist/server.js.map +1 -1
- 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 +49 -32
- package/LICENSE +0 -21
- package/dist/composeFs.d.ts +0 -20
- package/dist/composeFs.d.ts.map +0 -1
- package/dist/composeFs.js +0 -134
- package/dist/composeFs.js.map +0 -1
- package/dist/composition.d.ts +0 -49
- package/dist/composition.d.ts.map +0 -1
- package/dist/composition.js +0 -43
- package/dist/composition.js.map +0 -1
- package/dist/infrastructure/agent/ClaudeCodeAgentBinding.d.ts +0 -8
- package/dist/infrastructure/agent/ClaudeCodeAgentBinding.d.ts.map +0 -1
- package/dist/infrastructure/agent/ClaudeCodeAgentBinding.js +0 -62
- package/dist/infrastructure/agent/ClaudeCodeAgentBinding.js.map +0 -1
- 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 -18
- package/dist/infrastructure/agent/mcpConfig.d.ts.map +0 -1
- package/dist/infrastructure/agent/mcpConfig.js +0 -47
- 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/fs/FsClarifyTicketRepository.d.ts +0 -13
- package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts.map +0 -1
- package/dist/infrastructure/fs/FsClarifyTicketRepository.js +0 -33
- 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/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 +0 -88
- 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/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/WorkspaceRegistryFile.d.ts +0 -17
- package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts.map +0 -1
- package/dist/infrastructure/fs/WorkspaceRegistryFile.js +0 -58
- 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/jsonFileStore.d.ts.map +0 -1
- package/dist/infrastructure/fs/jsonFileStore.js.map +0 -1
- package/dist/infrastructure/fs/paths.d.ts +0 -22
- package/dist/infrastructure/fs/paths.d.ts.map +0 -1
- package/dist/infrastructure/fs/paths.js +0 -46
- 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/orphanReaper.d.ts +0 -18
- package/dist/infrastructure/orphanReaper.d.ts.map +0 -1
- package/dist/infrastructure/orphanReaper.js.map +0 -1
- package/dist/routes/clarify.d.ts +0 -8
- package/dist/routes/clarify.d.ts.map +0 -1
- package/dist/routes/clarify.js +0 -84
- 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 -30
- package/dist/routes/decisions.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/{fs → hitl}/FsProposalRepository.d.ts +0 -0
- /package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.d.ts +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Clarification, paginate } from '@braidhq/core';
|
|
2
|
+
import { Clarification as ClarificationSchema } from '@braidhq/schema';
|
|
3
|
+
import { clarificationDir, CLARIFY_STATUSES } from '../_shared/paths.js';
|
|
4
|
+
import { StatusedJsonStore } from './StatusedJsonStore.js';
|
|
5
|
+
export class FsClarificationRepository {
|
|
6
|
+
base;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.base = new StatusedJsonStore({
|
|
9
|
+
entityName: 'Clarification',
|
|
10
|
+
statuses: CLARIFY_STATUSES,
|
|
11
|
+
dirFor: clarificationDir,
|
|
12
|
+
parse: raw => new Clarification(ClarificationSchema.parse(raw)),
|
|
13
|
+
serialize: entity => entity.toData(),
|
|
14
|
+
idOf: entity => entity.id,
|
|
15
|
+
statusOf: entity => entity.status,
|
|
16
|
+
workspaceIdOf: entity => entity.workspaceId,
|
|
17
|
+
}, options.workspaceRoots);
|
|
18
|
+
}
|
|
19
|
+
async list(filter) {
|
|
20
|
+
let tickets = await this.base.list({
|
|
21
|
+
...(filter?.workspaceId !== undefined ? { workspaceId: filter.workspaceId } : {}),
|
|
22
|
+
...(filter?.statuses !== undefined ? { statuses: filter.statuses } : {}),
|
|
23
|
+
});
|
|
24
|
+
// Pending tickets are personal, only the owner sees them.
|
|
25
|
+
// Answered, applied, and skipped tickets stay workspace-shared.
|
|
26
|
+
if (filter?.viewerId !== undefined) {
|
|
27
|
+
const viewerId = filter.viewerId;
|
|
28
|
+
tickets = tickets.filter(ticket => ticket.status !== 'pending' || ticket.owner === 'system' || ticket.owner === viewerId);
|
|
29
|
+
}
|
|
30
|
+
return paginate(tickets, filter?.limit, filter?.offset);
|
|
31
|
+
}
|
|
32
|
+
load(clarificationId) {
|
|
33
|
+
return this.base.load(clarificationId);
|
|
34
|
+
}
|
|
35
|
+
save(ticket) {
|
|
36
|
+
return this.base.save(ticket);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=FsClarificationRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsClarificationRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/hitl/FsClarificationRepository.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAgC,QAAQ,EAAE,MAAM,eAAe,CAAA;AACrF,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAM1D,MAAM,OAAO,yBAAyB;IACnB,IAAI,CAAoF;IAEzG,YAAY,OAAyC;QACnD,IAAI,CAAC,IAAI,GAAG,IAAI,iBAAi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AO,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACzD,CAAC;IAED,IAAI,CAAC,eAAgC;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,CAAC,MAAqB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsProposalRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/hitl/FsProposalRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5F,OAAO,EAAY,QAAQ,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAK3E,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAA;CAC/E;AAED,qBAAa,oBAAqB,YAAW,kBAAkB;IAC7D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2E;gBAEpF,OAAO,EAAE,2BAA2B;IAgB1C,IAAI,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAqBxD,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI/C,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { paginate, Proposal } from '@braidhq/core';
|
|
2
2
|
import { Proposal as ProposalSchema } from '@braidhq/schema';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { PROPOSAL_STATUSES, proposalsDir } from '../_shared/paths.js';
|
|
4
|
+
import { StatusedJsonStore } from './StatusedJsonStore.js';
|
|
5
5
|
export class FsProposalRepository {
|
|
6
6
|
base;
|
|
7
7
|
constructor(options) {
|
|
8
|
-
this.base = new
|
|
8
|
+
this.base = new StatusedJsonStore({
|
|
9
9
|
entityName: 'Proposal',
|
|
10
10
|
statuses: PROPOSAL_STATUSES,
|
|
11
11
|
dirFor: proposalsDir,
|
|
@@ -25,6 +25,13 @@ export class FsProposalRepository {
|
|
|
25
25
|
const skills = filter.generatedBy;
|
|
26
26
|
proposals = proposals.filter(proposal => skills.includes(proposal.generatedBy));
|
|
27
27
|
}
|
|
28
|
+
// Pending proposals are personal, only the owner sees them.
|
|
29
|
+
// Applied and rejected stay as workspace-shared audit history.
|
|
30
|
+
// Absent viewerId means no filter, for Owner Show All and legacy callers.
|
|
31
|
+
if (filter?.viewerId !== undefined) {
|
|
32
|
+
const viewerId = filter.viewerId;
|
|
33
|
+
proposals = proposals.filter(proposal => proposal.status !== 'pending' || proposal.owner === 'system' || proposal.owner === viewerId);
|
|
34
|
+
}
|
|
28
35
|
return paginate(proposals, filter?.limit, filter?.offset);
|
|
29
36
|
}
|
|
30
37
|
load(proposalId) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsProposalRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/hitl/FsProposalRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAA2B,MAAM,eAAe,CAAA;AAC3E,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAM1D,MAAM,OAAO,oB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,CAAC,CAAA;QACjF,CAAC;QACD,4DAA4D;QAC5D,+DAA+D;QAC/D,0EAA0E;QAC1E,IAAI,MAAM,EAAE,QAAQ,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;YAChC,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CACtC,QAAQ,CAAC,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAC5F,CAAA;QACH,CAAC;QACD,OAAO,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3D,CAAC;IAED,IAAI,CAAC,UAAsB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACnC,CAAC;IAED,IAAI,CAAC,QAAkB;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACjC,CAAC;IAED,MAAM,CAAC,UAAsB;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AbsolutePath, WorkspaceId } from '@braidhq/schema';
|
|
2
|
+
export interface StatusedJsonStoreConfig<TEntity, TStatus extends string, TId extends string> {
|
|
3
|
+
readonly entityName: string;
|
|
4
|
+
readonly statuses: readonly TStatus[];
|
|
5
|
+
readonly idOf: (entity: TEntity) => TId;
|
|
6
|
+
readonly statusOf: (entity: TEntity) => TStatus;
|
|
7
|
+
readonly workspaceIdOf: (entity: TEntity) => WorkspaceId;
|
|
8
|
+
readonly dirFor: (workspaceRoot: AbsolutePath, status: TStatus) => string;
|
|
9
|
+
readonly parse: (raw: unknown) => TEntity;
|
|
10
|
+
readonly serialize: (entity: TEntity) => unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface StatusedJsonListFilter<TStatus extends string> {
|
|
13
|
+
readonly workspaceId?: WorkspaceId;
|
|
14
|
+
readonly statuses?: readonly TStatus[];
|
|
15
|
+
}
|
|
16
|
+
export declare class StatusedJsonStore<TEntity, TStatus extends string, TId extends string> {
|
|
17
|
+
private readonly config;
|
|
18
|
+
private readonly workspaceRoots;
|
|
19
|
+
constructor(config: StatusedJsonStoreConfig<TEntity, TStatus, TId>, workspaceRoots: () => Promise<ReadonlyMap<WorkspaceId, AbsolutePath>>);
|
|
20
|
+
list(filter?: StatusedJsonListFilter<TStatus>): Promise<TEntity[]>;
|
|
21
|
+
load(id: TId): Promise<TEntity>;
|
|
22
|
+
save(entity: TEntity): Promise<void>;
|
|
23
|
+
remove(id: TId): Promise<void>;
|
|
24
|
+
locate(id: TId): Promise<{
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly status: TStatus;
|
|
27
|
+
} | undefined>;
|
|
28
|
+
private candidateRoots;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=StatusedJsonStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusedJsonStore.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/hitl/StatusedJsonStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMhE,MAAM,WAAW,uBAAuB,CAAC,OAAO,EAAE,OAAO,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM;IAI1F,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAA;IAGrC,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,GAAG,CAAA;IACvC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAA;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AAO,CAAA;KAAE,GAAG,SAAS,CAAC;YAkBjF,cAAc;CAS7B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { rm } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { NotFoundError } from '@braidhq/core';
|
|
4
|
-
import { listJsonFiles, moveFile, readJsonFile, writeJsonFile } from '
|
|
5
|
-
export class
|
|
4
|
+
import { listJsonFiles, moveFile, readJsonFile, writeJsonFile } from '../_shared/jsonFileStore.js';
|
|
5
|
+
export class StatusedJsonStore {
|
|
6
6
|
config;
|
|
7
7
|
workspaceRoots;
|
|
8
8
|
constructor(config, workspaceRoots) {
|
|
@@ -76,4 +76,4 @@ export class FsStatusedJsonRepository {
|
|
|
76
76
|
return root ? new Map([[workspaceId, root]]) : new Map();
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
//# sourceMappingURL=
|
|
79
|
+
//# sourceMappingURL=StatusedJsonStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusedJsonStore.js","sourceRoot":"","sources":["../../../src/infrastructure/hitl/StatusedJsonStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AA2BlG,MAAM,OAAO,iBAAiB;IAET;IACA;IAFnB,YACmB,MAAsD,EACtD,cAAqE;QADrE,WAAM,GAAN,MAAM,CAAgD;QACtD,mBAAc,GAAd,cAAc,CAAuD;IACrF,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,MAAwC;QACjD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;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MAAM,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAC1C,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;gBAC1E,IAAI,CAAC;oBACH,MAAM,YAAY,CAAC,aAAa,CAAC,CAAA;oBACjC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;gBACxC,CAAC;gBACD,OAAO,KAAK,EAAE,CAAC;oBACb,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;wBACpD,MAAM,KAAK,CAAA;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAEO,KAAK,CAAC,cAAc,CAC1B,WAAoC;QAEpC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;QACzC,IAAI,CAAC,WAAW;YACd,OAAO,KAAK,CAAA;QACd,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACnC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAA;IAC1D,CAAC;CACF"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { ModelSerializer, Workspace } from '@braidhq/core';
|
|
2
|
+
import type { ModelSnapshot } from '@braidhq/schema';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export declare const MODEL_JSON_VERSION = 1;
|
|
5
|
+
export declare const ModelJsonFile: z.ZodObject<{
|
|
6
|
+
version: z.ZodNumber;
|
|
7
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
8
|
+
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
|
9
|
+
type: z.core.$ZodBranded<z.ZodString, "NodeTypeId", "out">;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
description: z.ZodOptional<z.ZodString>;
|
|
12
|
+
status: z.ZodEnum<{
|
|
13
|
+
completed: "completed";
|
|
14
|
+
draft: "draft";
|
|
15
|
+
unclear: "unclear";
|
|
16
|
+
deprecated: "deprecated";
|
|
17
|
+
}>;
|
|
18
|
+
metadata: z.ZodObject<{
|
|
19
|
+
intentMissing: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
intentConflict: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
implementationMissing: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
sourceReferences: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
23
|
+
sourceId: z.core.$ZodBranded<z.ZodString, "SourceId", "out">;
|
|
24
|
+
location: z.ZodObject<{
|
|
25
|
+
uri: z.ZodString;
|
|
26
|
+
startLine: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
anchor: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>>>;
|
|
32
|
+
lastTouchedBy: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "SkillId", "out">>;
|
|
33
|
+
externalReferences: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
34
|
+
kind: z.core.$ZodBranded<z.ZodString, "ExternalReferenceKind", "out">;
|
|
35
|
+
url: z.ZodString;
|
|
36
|
+
label: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>>>;
|
|
38
|
+
driftIssues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
39
|
+
id: z.core.$ZodBranded<z.ZodString, "DriftIssueId", "out">;
|
|
40
|
+
description: z.ZodString;
|
|
41
|
+
severity: z.ZodEnum<{
|
|
42
|
+
error: "error";
|
|
43
|
+
warning: "warning";
|
|
44
|
+
info: "info";
|
|
45
|
+
}>;
|
|
46
|
+
sourceReferences: z.ZodArray<z.ZodObject<{
|
|
47
|
+
sourceId: z.core.$ZodBranded<z.ZodString, "SourceId", "out">;
|
|
48
|
+
location: z.ZodObject<{
|
|
49
|
+
uri: z.ZodString;
|
|
50
|
+
startLine: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
anchor: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
raisedAt: z.ZodString;
|
|
57
|
+
}, z.core.$strip>>>;
|
|
58
|
+
acknowledgedDrifts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
embedding: z.ZodOptional<z.ZodObject<{
|
|
61
|
+
vector: z.ZodArray<z.ZodNumber>;
|
|
62
|
+
modelId: z.ZodString;
|
|
63
|
+
createdAt: z.ZodString;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
67
|
+
id: z.core.$ZodBranded<z.ZodString, "EdgeId", "out">;
|
|
68
|
+
type: z.core.$ZodBranded<z.ZodString, "EdgeTypeId", "out">;
|
|
69
|
+
fromNodeId: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
|
70
|
+
toNodeId: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
|
71
|
+
metadata: z.ZodObject<{
|
|
72
|
+
sourceReferences: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
73
|
+
sourceId: z.core.$ZodBranded<z.ZodString, "SourceId", "out">;
|
|
74
|
+
location: z.ZodObject<{
|
|
75
|
+
uri: z.ZodString;
|
|
76
|
+
startLine: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
anchor: z.ZodOptional<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>>>;
|
|
82
|
+
lastTouchedBy: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "SkillId", "out">>;
|
|
83
|
+
externalReferences: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
84
|
+
kind: z.core.$ZodBranded<z.ZodString, "ExternalReferenceKind", "out">;
|
|
85
|
+
url: z.ZodString;
|
|
86
|
+
label: z.ZodOptional<z.ZodString>;
|
|
87
|
+
}, z.core.$strip>>>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
export declare class FsModelSerializer implements ModelSerializer {
|
|
92
|
+
write(workspace: Workspace, snapshot: ModelSnapshot): Promise<void>;
|
|
93
|
+
read(workspace: Workspace): Promise<ModelSnapshot | null>;
|
|
94
|
+
exists(workspace: Workspace): Promise<boolean>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=FsModelSerializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsModelSerializer.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/model/FsModelSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAIpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,kBAAkB,IAAI,CAAA;AAEnC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIxB,CAAA;AAEF,qBAAa,iBAAkB,YAAW,eAAe;IACjD,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAenE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAmBzD,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;CASrD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { GraphEdge, GraphNode } from '@braidhq/schema';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { graphJsonPath, workspaceArtifactsDir } from '../_shared/paths.js';
|
|
6
|
+
export const MODEL_JSON_VERSION = 1;
|
|
7
|
+
export const ModelJsonFile = z.object({
|
|
8
|
+
version: z.number().int(),
|
|
9
|
+
nodes: z.array(GraphNode),
|
|
10
|
+
edges: z.array(GraphEdge),
|
|
11
|
+
});
|
|
12
|
+
export class FsModelSerializer {
|
|
13
|
+
async write(workspace, snapshot) {
|
|
14
|
+
const path = graphJsonPath(workspace.rootPath);
|
|
15
|
+
await mkdir(workspaceArtifactsDir(workspace.rootPath), { recursive: true });
|
|
16
|
+
const payload = {
|
|
17
|
+
version: MODEL_JSON_VERSION,
|
|
18
|
+
nodes: [...snapshot.nodes].sort(byId),
|
|
19
|
+
edges: [...snapshot.edges].sort(byId),
|
|
20
|
+
};
|
|
21
|
+
// Atomic write. A crashed server must not leave a half-file behind,
|
|
22
|
+
// one that would mis-hydrate Kùzu on the next restart.
|
|
23
|
+
const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
|
|
24
|
+
await writeFile(tmp, `${JSON.stringify(payload, null, 2)}\n`, 'utf-8');
|
|
25
|
+
await rename(tmp, path);
|
|
26
|
+
}
|
|
27
|
+
async read(workspace) {
|
|
28
|
+
let raw;
|
|
29
|
+
try {
|
|
30
|
+
raw = await readFile(graphJsonPath(workspace.rootPath), 'utf-8');
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error.code === 'ENOENT')
|
|
34
|
+
return null;
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
const parsed = ModelJsonFile.parse(JSON.parse(raw));
|
|
38
|
+
if (parsed.version !== MODEL_JSON_VERSION) {
|
|
39
|
+
throw new Error(`model.json version mismatch in ${workspace.rootPath}: expected ${MODEL_JSON_VERSION}, got ${parsed.version}`);
|
|
40
|
+
}
|
|
41
|
+
return { nodes: parsed.nodes, edges: parsed.edges };
|
|
42
|
+
}
|
|
43
|
+
async exists(workspace) {
|
|
44
|
+
try {
|
|
45
|
+
await readFile(graphJsonPath(workspace.rootPath), 'utf-8');
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function byId(a, b) {
|
|
54
|
+
if (a.id < b.id)
|
|
55
|
+
return -1;
|
|
56
|
+
if (a.id > b.id)
|
|
57
|
+
return 1;
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=FsModelSerializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsModelSerializer.js","sourceRoot":"","sources":["../../../src/infrastructure/model/FsModelSerializer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE1E,MAAM,CAAC,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AAS,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAA;QAClE,CAAC;QACD,OAAO,KAAK,EAAE,CAAC;YACb,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;gBACpD,OAAO,IAAI,CAAA;YACb,MAAM,KAAK,CAAA;QACb,CAAC;QACD,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;QACnD,IAAI,MAAM,CAAC,OAAO,KAAK,kBAAkB,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CACb,kCAAkC,SAAS,CAAC,QAAQ,cAAc,kBAAkB,SAAS,MAAM,CAAC,OAAO,EAAE,CAC9G,CAAA;QACH,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAA;IACrD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAoB;QAC/B,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAA;YAC1D,OAAO,IAAI,CAAA;QACb,CAAC;QACD,MAAM,CAAC;YACL,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;CACF;AAED,SAAS,IAAI,CAA2B,CAAI,EAAE,CAAI;IAChD,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE;QACb,OAAO,CAAC,CAAC,CAAA;IACX,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE;QACb,OAAO,CAAC,CAAA;IACV,OAAO,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile fields Braid needs after Google authn.
|
|
3
|
+
* `sub` is the stable Google account id, used as the join key into `users.json`.
|
|
4
|
+
*/
|
|
5
|
+
export interface GoogleProfile {
|
|
6
|
+
readonly sub: string;
|
|
7
|
+
readonly email: string;
|
|
8
|
+
readonly displayName: string;
|
|
9
|
+
readonly emailVerified?: boolean;
|
|
10
|
+
}
|
|
1
11
|
export interface GoogleOAuthConfig {
|
|
2
|
-
/** OAuth client id from the user's GCP project. */
|
|
3
12
|
readonly clientId: string;
|
|
4
|
-
/** OAuth client secret. */
|
|
5
13
|
readonly clientSecret: string;
|
|
6
|
-
/** Absolute redirect URI registered in the GCP OAuth client. */
|
|
7
14
|
readonly redirectUri: string;
|
|
15
|
+
readonly loginRedirectUri?: string;
|
|
8
16
|
}
|
|
9
17
|
export interface AuthorizationUrlInput {
|
|
10
|
-
/** OAuth scope(s) requested. Braid passes Drive read-only. */
|
|
11
18
|
readonly scopes: readonly string[];
|
|
12
|
-
/** State token (CSRF + flow-restore). */
|
|
13
19
|
readonly state: string;
|
|
14
|
-
/** PKCE verifier; the URL embeds its SHA-256 challenge. */
|
|
15
20
|
readonly codeVerifier: string;
|
|
16
21
|
}
|
|
17
22
|
export interface TokenSet {
|
|
@@ -26,26 +31,50 @@ export interface RefreshedAccessToken {
|
|
|
26
31
|
readonly expiresAt: string;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
|
-
* Minimal Google OAuth 2.0 client for installed-app
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* surface auditable.
|
|
34
|
+
* Minimal Google OAuth 2.0 client for the installed-app or web flow.
|
|
35
|
+
* We skip `openid-client` and `google-auth-library`,
|
|
36
|
+
* because only four calls are needed (build URL, exchange code, refresh, revoke).
|
|
37
|
+
* Avoiding a heavyweight dependency keeps the server's install footprint small,
|
|
38
|
+
* and the auth surface auditable.
|
|
35
39
|
*/
|
|
36
40
|
export declare class GoogleOAuth {
|
|
37
41
|
private readonly config;
|
|
38
42
|
constructor(config: GoogleOAuthConfig);
|
|
39
43
|
/**
|
|
40
44
|
* Build the URL the user's browser is sent to. `state` and `codeVerifier`
|
|
41
|
-
* MUST be unique per flow
|
|
42
|
-
* the callback arrives.
|
|
45
|
+
* MUST be unique per flow,
|
|
46
|
+
* the caller stores them in pending-state until the callback arrives.
|
|
43
47
|
*/
|
|
44
48
|
buildAuthorizationUrl(input: AuthorizationUrlInput): string;
|
|
45
49
|
exchangeCode(input: {
|
|
46
50
|
code: string;
|
|
47
51
|
codeVerifier: string;
|
|
48
52
|
}): Promise<TokenSet>;
|
|
53
|
+
/**
|
|
54
|
+
* Login flow URL. Same client and redirect as the Drive flow,
|
|
55
|
+
* but with `openid email profile` scopes and no `prompt=consent`.
|
|
56
|
+
* Google suppresses the consent screen when the user has already approved those scopes,
|
|
57
|
+
* which is what login wants,
|
|
58
|
+
* unlike Drive where a refresh_token is required and `prompt=consent` is forced.
|
|
59
|
+
*/
|
|
60
|
+
buildLoginUrl(input: {
|
|
61
|
+
state: string;
|
|
62
|
+
codeVerifier: string;
|
|
63
|
+
}): string;
|
|
64
|
+
/** Path Google sends the login callback to. Routed under `/auth/google/callback`. */
|
|
65
|
+
loginRedirectUri(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Exchange an authorization code from the login flow for the user's profile.
|
|
68
|
+
* Does NOT require `refresh_token`, since login is one-shot.
|
|
69
|
+
* The Braid server issues its own session afterwards,
|
|
70
|
+
* so Google's tokens are discarded after this call.
|
|
71
|
+
* Uses the userinfo endpoint instead of decoding the id_token,
|
|
72
|
+
* so no JWT verifier is pulled in just to read 3 fields.
|
|
73
|
+
*/
|
|
74
|
+
loginWithCode(input: {
|
|
75
|
+
code: string;
|
|
76
|
+
codeVerifier: string;
|
|
77
|
+
}): Promise<GoogleProfile>;
|
|
49
78
|
refreshAccessToken(refreshToken: string): Promise<RefreshedAccessToken>;
|
|
50
79
|
}
|
|
51
80
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleOAuth.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/oauth/GoogleOAuth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version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qB,GAAG,MAAM;IAgBrD,YAAY,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IA2BpF;;;;;;OAMG;IACH,aAAa,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAerE,qFAAqF;IACrF,gBAAgB,IAAI,MAAM;IAI1B;;;;;;;OAOG;IACG,aAAa,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IA0CpF,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAsB9E;AA4BD;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createHash, randomBytes } from 'node:crypto';
|
|
2
2
|
const AUTH_ENDPOINT = 'https://accounts.google.com/o/oauth2/v2/auth';
|
|
3
3
|
const TOKEN_ENDPOINT = 'https://oauth2.googleapis.com/token';
|
|
4
|
+
const USERINFO_ENDPOINT = 'https://openidconnect.googleapis.com/v1/userinfo';
|
|
4
5
|
/**
|
|
5
|
-
* Minimal Google OAuth 2.0 client for installed-app
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* surface auditable.
|
|
6
|
+
* Minimal Google OAuth 2.0 client for the installed-app or web flow.
|
|
7
|
+
* We skip `openid-client` and `google-auth-library`,
|
|
8
|
+
* because only four calls are needed (build URL, exchange code, refresh, revoke).
|
|
9
|
+
* Avoiding a heavyweight dependency keeps the server's install footprint small,
|
|
10
|
+
* and the auth surface auditable.
|
|
11
11
|
*/
|
|
12
12
|
export class GoogleOAuth {
|
|
13
13
|
config;
|
|
@@ -16,8 +16,8 @@ export class GoogleOAuth {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Build the URL the user's browser is sent to. `state` and `codeVerifier`
|
|
19
|
-
* MUST be unique per flow
|
|
20
|
-
* the callback arrives.
|
|
19
|
+
* MUST be unique per flow,
|
|
20
|
+
* the caller stores them in pending-state until the callback arrives.
|
|
21
21
|
*/
|
|
22
22
|
buildAuthorizationUrl(input) {
|
|
23
23
|
const params = new URLSearchParams({
|
|
@@ -25,7 +25,7 @@ export class GoogleOAuth {
|
|
|
25
25
|
redirect_uri: this.config.redirectUri,
|
|
26
26
|
response_type: 'code',
|
|
27
27
|
scope: input.scopes.join(' '),
|
|
28
|
-
access_type: 'offline', //
|
|
28
|
+
access_type: 'offline', // yields refresh_token in the response
|
|
29
29
|
prompt: 'consent', // ensure refresh_token even on re-auth
|
|
30
30
|
include_granted_scopes: 'true',
|
|
31
31
|
state: input.state,
|
|
@@ -54,12 +54,79 @@ export class GoogleOAuth {
|
|
|
54
54
|
}
|
|
55
55
|
const payload = await response.json();
|
|
56
56
|
if (!payload.refresh_token) {
|
|
57
|
-
// Google only returns refresh_token on first consent.
|
|
58
|
-
// one, the caller can't store anything useful for next time.
|
|
57
|
+
// Google only returns refresh_token on first consent.
|
|
58
|
+
// Without one, the caller can't store anything useful for next time.
|
|
59
59
|
throw new Error('Google did not return a refresh_token. Add prompt=consent and ensure access_type=offline.');
|
|
60
60
|
}
|
|
61
61
|
return tokenSetFromPayload(payload);
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Login flow URL. Same client and redirect as the Drive flow,
|
|
65
|
+
* but with `openid email profile` scopes and no `prompt=consent`.
|
|
66
|
+
* Google suppresses the consent screen when the user has already approved those scopes,
|
|
67
|
+
* which is what login wants,
|
|
68
|
+
* unlike Drive where a refresh_token is required and `prompt=consent` is forced.
|
|
69
|
+
*/
|
|
70
|
+
buildLoginUrl(input) {
|
|
71
|
+
const params = new URLSearchParams({
|
|
72
|
+
client_id: this.config.clientId,
|
|
73
|
+
redirect_uri: this.loginRedirectUri(),
|
|
74
|
+
response_type: 'code',
|
|
75
|
+
scope: 'openid email profile',
|
|
76
|
+
access_type: 'online',
|
|
77
|
+
include_granted_scopes: 'true',
|
|
78
|
+
state: input.state,
|
|
79
|
+
code_challenge: pkceChallenge(input.codeVerifier),
|
|
80
|
+
code_challenge_method: 'S256',
|
|
81
|
+
});
|
|
82
|
+
return `${AUTH_ENDPOINT}?${params.toString()}`;
|
|
83
|
+
}
|
|
84
|
+
/** Path Google sends the login callback to. Routed under `/auth/google/callback`. */
|
|
85
|
+
loginRedirectUri() {
|
|
86
|
+
return this.config.loginRedirectUri ?? this.config.redirectUri;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Exchange an authorization code from the login flow for the user's profile.
|
|
90
|
+
* Does NOT require `refresh_token`, since login is one-shot.
|
|
91
|
+
* The Braid server issues its own session afterwards,
|
|
92
|
+
* so Google's tokens are discarded after this call.
|
|
93
|
+
* Uses the userinfo endpoint instead of decoding the id_token,
|
|
94
|
+
* so no JWT verifier is pulled in just to read 3 fields.
|
|
95
|
+
*/
|
|
96
|
+
async loginWithCode(input) {
|
|
97
|
+
const body = new URLSearchParams({
|
|
98
|
+
client_id: this.config.clientId,
|
|
99
|
+
client_secret: this.config.clientSecret,
|
|
100
|
+
redirect_uri: this.loginRedirectUri(),
|
|
101
|
+
grant_type: 'authorization_code',
|
|
102
|
+
code: input.code,
|
|
103
|
+
code_verifier: input.codeVerifier,
|
|
104
|
+
});
|
|
105
|
+
const tokenResponse = await fetch(TOKEN_ENDPOINT, {
|
|
106
|
+
method: 'POST',
|
|
107
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
108
|
+
body,
|
|
109
|
+
});
|
|
110
|
+
if (!tokenResponse.ok) {
|
|
111
|
+
const text = await tokenResponse.text().catch(() => '');
|
|
112
|
+
throw new Error(`Google login token exchange failed: ${tokenResponse.status} ${tokenResponse.statusText} ${text}`);
|
|
113
|
+
}
|
|
114
|
+
const { access_token } = await tokenResponse.json();
|
|
115
|
+
const userinfoResponse = await fetch(USERINFO_ENDPOINT, {
|
|
116
|
+
headers: { Authorization: `Bearer ${access_token}` },
|
|
117
|
+
});
|
|
118
|
+
if (!userinfoResponse.ok) {
|
|
119
|
+
const text = await userinfoResponse.text().catch(() => '');
|
|
120
|
+
throw new Error(`Google userinfo fetch failed: ${userinfoResponse.status} ${userinfoResponse.statusText} ${text}`);
|
|
121
|
+
}
|
|
122
|
+
const userinfo = await userinfoResponse.json();
|
|
123
|
+
return {
|
|
124
|
+
sub: userinfo.sub,
|
|
125
|
+
email: userinfo.email,
|
|
126
|
+
displayName: userinfo.name ?? userinfo.given_name ?? userinfo.email,
|
|
127
|
+
...(userinfo.email_verified !== undefined ? { emailVerified: userinfo.email_verified } : {}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
63
130
|
async refreshAccessToken(refreshToken) {
|
|
64
131
|
const body = new URLSearchParams({
|
|
65
132
|
client_id: this.config.clientId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleOAuth.js","sourceRoot":"","sources":["../../../src/infrastructure/oauth/GoogleOAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,aAAa,GAAG,8CAA8C,CAAA;AACpE,MAAM,cAAc,GAAG,qCAAqC,CAAA;
|
|
1
|
+
{"version":3,"file":"GoogleOAuth.js","sourceRoot":"","sources":["../../../src/infrastructure/oauth/GoogleOAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,aAAa,GAAG,8CAA8C,CAAA;AACpE,MAAM,cAAc,GAAG,qCAAqC,CAAA;AAC5D,MAAM,iBAAiB,GAA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AAU,CAAC,CAAC,WAAW,EAAE;SAC5D,CAAA;IACH,CAAC;CACF;AAUD,SAAS,mBAAmB,CAAC,CAAmB;IAC9C,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,YAAY;QAC3B,YAAY,EAAE,CAAC,CAAC,aAAc;QAC9B,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE;QACrD,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,SAAS,EAAE,CAAC,CAAC,UAAU;KACxB,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,GAAG,IAAI,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AAC9C,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReactorCycleRepository } from '@braidhq/core';
|
|
2
|
+
import type { AbsolutePath, ReactorCycle, ReactorCycleId, WorkspaceId } from '@braidhq/schema';
|
|
3
|
+
export interface FsReactorCycleRepositoryOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Lookup of workspaceId to workspaceRoot. Shared with the other Fs repositories,
|
|
6
|
+
* so this repo doesn't introduce a separate dependency on `WorkspaceService`.
|
|
7
|
+
* `composeFs.ts` builds a single closure once and passes it to every fs repo.
|
|
8
|
+
*/
|
|
9
|
+
readonly workspaceRoots: () => Promise<ReadonlyMap<WorkspaceId, AbsolutePath>>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Filesystem-backed `ReactorCycleRepository`. One JSON file per cycle,
|
|
13
|
+
* at `artifacts/reactor-cycles/<cycleId>.json`.
|
|
14
|
+
* Each save is an atomic rename,
|
|
15
|
+
* so the Studio Activity page never reads a half-written file.
|
|
16
|
+
*
|
|
17
|
+
* The file body is exactly the `ReactorCycle` shape, no wrapper or envelope.
|
|
18
|
+
* A future SQLite or Postgres impl maps one file to one row keyed by `cycleId`,
|
|
19
|
+
* with `(workspaceId, startedAt)` indexed for the list query.
|
|
20
|
+
*/
|
|
21
|
+
export declare class FsReactorCycleRepository implements ReactorCycleRepository {
|
|
22
|
+
private readonly options;
|
|
23
|
+
constructor(options: FsReactorCycleRepositoryOptions);
|
|
24
|
+
save(cycle: ReactorCycle): Promise<void>;
|
|
25
|
+
load(workspaceId: WorkspaceId, cycleId: ReactorCycleId): Promise<ReactorCycle | undefined>;
|
|
26
|
+
listByWorkspace(workspaceId: WorkspaceId): Promise<readonly ReactorCycle[]>;
|
|
27
|
+
private resolveRoot;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=FsReactorCycleRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsReactorCycleRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/reactor/FsReactorCycleRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAU9F,MAAM,WAAW,+BAA+B;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAA;CAC/E;AAED;;;;;;;;;GASG;AACH,qBAAa,wBAAyB,YAAW,sBAAsB;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,+BAA+B;IAE/D,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxC,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAoB1F,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC;YA0BnE,WAAW;CAO1B"}
|