@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,94 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdir, readdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import { NotFoundError } from '@braidhq/core';
|
|
6
|
+
import { ReactorCycle as ReactorCycleSchema } from '@braidhq/schema';
|
|
7
|
+
import { reactorCycleFilePath, reactorCyclesDir } from '../_shared/paths.js';
|
|
8
|
+
/**
|
|
9
|
+
* Filesystem-backed `ReactorCycleRepository`. One JSON file per cycle,
|
|
10
|
+
* at `artifacts/reactor-cycles/<cycleId>.json`.
|
|
11
|
+
* Each save is an atomic rename,
|
|
12
|
+
* so the Studio Activity page never reads a half-written file.
|
|
13
|
+
*
|
|
14
|
+
* The file body is exactly the `ReactorCycle` shape, no wrapper or envelope.
|
|
15
|
+
* A future SQLite or Postgres impl maps one file to one row keyed by `cycleId`,
|
|
16
|
+
* with `(workspaceId, startedAt)` indexed for the list query.
|
|
17
|
+
*/
|
|
18
|
+
export class FsReactorCycleRepository {
|
|
19
|
+
options;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
}
|
|
23
|
+
async save(cycle) {
|
|
24
|
+
const root = await this.resolveRoot(cycle.workspaceId);
|
|
25
|
+
const file = reactorCycleFilePath(root, cycle.id);
|
|
26
|
+
await mkdir(reactorCyclesDir(root), { recursive: true });
|
|
27
|
+
// Random suffix so concurrent saves in the same ms don't collide.
|
|
28
|
+
const tmp = `${file}.tmp-${process.pid}-${randomUUID()}`;
|
|
29
|
+
await writeFile(tmp, `${JSON.stringify(cycle, null, 2)}\n`, 'utf-8');
|
|
30
|
+
await rename(tmp, file);
|
|
31
|
+
}
|
|
32
|
+
async load(workspaceId, cycleId) {
|
|
33
|
+
const root = await this.resolveRoot(workspaceId);
|
|
34
|
+
const file = reactorCycleFilePath(root, cycleId);
|
|
35
|
+
try {
|
|
36
|
+
const raw = await readFile(file, 'utf-8');
|
|
37
|
+
const parsed = ReactorCycleSchema.parse(JSON.parse(raw));
|
|
38
|
+
// The directory layout is per-workspace already,
|
|
39
|
+
// but double-check the body matches, guarding the case,
|
|
40
|
+
// where an operator copy-pasted in a file from another workspace.
|
|
41
|
+
if (parsed.workspaceId !== workspaceId)
|
|
42
|
+
return undefined;
|
|
43
|
+
return parsed;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error.code === 'ENOENT')
|
|
47
|
+
return undefined;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async listByWorkspace(workspaceId) {
|
|
52
|
+
const root = await this.resolveRoot(workspaceId);
|
|
53
|
+
const dir = reactorCyclesDir(root);
|
|
54
|
+
const entries = await safeReaddir(dir);
|
|
55
|
+
const cycles = [];
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
if (!entry.isFile() || !entry.name.endsWith('.json'))
|
|
58
|
+
continue;
|
|
59
|
+
if (entry.name.includes('.tmp-'))
|
|
60
|
+
continue;
|
|
61
|
+
const raw = await readFile(join(dir, entry.name), 'utf-8');
|
|
62
|
+
try {
|
|
63
|
+
const parsed = ReactorCycleSchema.parse(JSON.parse(raw));
|
|
64
|
+
if (parsed.workspaceId === workspaceId)
|
|
65
|
+
cycles.push(parsed);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Skip files that fail validation, truncated half-writes,
|
|
69
|
+
// or manual edits gone wrong.
|
|
70
|
+
// Raising them as errors here would,
|
|
71
|
+
// in turn, block the Activity page from rendering recent cycles.
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return cycles.sort((a, b) => b.startedAt.localeCompare(a.startedAt));
|
|
75
|
+
}
|
|
76
|
+
async resolveRoot(workspaceId) {
|
|
77
|
+
const roots = await this.options.workspaceRoots();
|
|
78
|
+
const root = roots.get(workspaceId);
|
|
79
|
+
if (!root)
|
|
80
|
+
throw new NotFoundError(`Workspace "${workspaceId}" has no registered root path`);
|
|
81
|
+
return root;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function safeReaddir(dir) {
|
|
85
|
+
try {
|
|
86
|
+
return await readdir(dir, { withFileTypes: true });
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error.code === 'ENOENT')
|
|
90
|
+
return [];
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=FsReactorCycleRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsReactorCycleRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/reactor/FsReactorCycleRepository.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;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KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;gBACxD,IAAI,MAAM,CAAC,WAAW,KAAK,WAAW;oBACpC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACvB,CAAC;YACD,MAAM,CAAC;gBACL,0DAA0D;gBAC1D,8BAA8B;gBAC9B,qCAAqC;gBACrC,iEAAiE;YACnE,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACtE,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,WAAwB;QAChD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;QACjD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACnC,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,aAAa,CAAC,cAAc,WAAW,+BAA+B,CAAC,CAAA;QACnF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,KAAK,UAAU,WAAW,CAAC,GAAW;IACpC,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,KAAK,EAAE,CAAC;QACb,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YACpD,OAAO,EAAE,CAAA;QACX,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-scope JSON secret storage on the local filesystem.
|
|
3
|
-
* `(namespace, key)` under `<root>/<namespace>/<key>.json`.
|
|
4
|
-
* written with mode 0600 so only the running user can read them
|
|
5
|
-
* containing directory is mode 0700.
|
|
2
|
+
* Per-scope JSON secret storage on the local filesystem.
|
|
3
|
+
* One file per `(namespace, key)` under `<root>/<namespace>/<key>.json`.
|
|
4
|
+
* Files are written with mode 0600 so only the running user can read them,
|
|
5
|
+
* the containing directory is mode 0700.
|
|
6
6
|
*
|
|
7
|
-
* This is NOT an encrypted-at-rest store.
|
|
8
|
-
* single-user Braid installs (the OSS target).
|
|
9
|
-
* would swap this for a vault adapter
|
|
10
|
-
*
|
|
7
|
+
* This is NOT an encrypted-at-rest store.
|
|
8
|
+
* It suits local, single-user Braid installs (the OSS target).
|
|
9
|
+
* A hosted SaaS deployment would swap this for a vault adapter,
|
|
10
|
+
* such as AWS Secrets Manager or Vault, behind the same interface.
|
|
11
11
|
*
|
|
12
|
-
* Layout
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* <workspaceId>--<sourceId>.json # one set of tokens per source
|
|
16
|
-
* oauth-github/
|
|
17
|
-
* <workspaceId>--<sourceId>.json
|
|
12
|
+
* Layout, one tokens file per source under a per-provider namespace,
|
|
13
|
+
* so Google tokens live at `<root>/oauth-google/<workspaceId>--<sourceId>.json`,
|
|
14
|
+
* and GitHub tokens at `<root>/oauth-github/<workspaceId>--<sourceId>.json`.
|
|
18
15
|
*/
|
|
19
16
|
export interface SecretRecord {
|
|
20
17
|
readonly value: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretStore.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/secrets/SecretStore.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"SecretStore.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/secrets/SecretStore.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IACnE,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACxE,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1D;AAED,qBAAa,aAAc,YAAW,WAAW;IACnC,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,MAAM;IAEnC,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAc/D,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAWpE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3D,OAAO,CAAC,OAAO;CAGhB"}
|
|
@@ -23,8 +23,8 @@ export class FsSecretStore {
|
|
|
23
23
|
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
24
24
|
const record = { value, updatedAt: new Date().toISOString() };
|
|
25
25
|
await writeFile(path, JSON.stringify(record, null, 2), { encoding: 'utf-8', mode: 0o600 });
|
|
26
|
-
// mkdir's mode arg is ignored on some platforms
|
|
27
|
-
// dir
|
|
26
|
+
// mkdir's mode arg is ignored on some platforms,
|
|
27
|
+
// so chmod the dir and file explicitly to keep perms stable across reboots and restores.
|
|
28
28
|
await chmod(dirname(path), 0o700);
|
|
29
29
|
await chmod(path, 0o600);
|
|
30
30
|
}
|
|
@@ -36,8 +36,8 @@ export class FsSecretStore {
|
|
|
36
36
|
return join(this.root, sanitize(namespace), `${sanitize(key)}.json`);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
// Conservative
|
|
40
|
-
//
|
|
39
|
+
// Conservative allowlist of ASCII letters, digits, `-`, `_`, and `.`.
|
|
40
|
+
// Anything else becomes `_` so a hostile workspaceId can't escape the dir.
|
|
41
41
|
function sanitize(input) {
|
|
42
42
|
return input.replace(/[^\w.-]/g, '_');
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretStore.js","sourceRoot":"","sources":["../../../src/infrastructure/secrets/SecretStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"SecretStore.js","sourceRoot":"","sources":["../../../src/infrastructure/secrets/SecretStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AA4BzC,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE7C,KAAK,CAAC,IAAI,CAAI,SAAiB,EAAE,GAAW;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QACzC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;YACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAiB,CAAA;YAC9C,OAAO,MAAM,CAAC,KAAU,CAAA;QAC1B,CAAC;QACD,OAAO,KAA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;AAED,sEAAsE;AACtE,2EAA2E;AAC3E,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;AACvC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RunRepository, Workspace } from '@braidhq/core';
|
|
2
|
-
import type { AbsolutePath, RunRecord, SkillEvent, SkillRunId } from '@braidhq/schema';
|
|
2
|
+
import type { AbsolutePath, RunRecord, SessionMetadata, SkillEvent, SkillRunId } from '@braidhq/schema';
|
|
3
3
|
/**
|
|
4
4
|
* File-system adapter for skill-run recording.
|
|
5
5
|
*
|
|
@@ -7,15 +7,20 @@ import type { AbsolutePath, RunRecord, SkillEvent, SkillRunId } from '@braidhq/s
|
|
|
7
7
|
* ├── index.jsonl (append-only summary, last-wins per runId)
|
|
8
8
|
* └── <runId>.jsonl (full SkillEvent stream for one run)
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* The index is append-only because every write of one workspace goes,
|
|
11
|
+
* today, through a single server process.
|
|
12
|
+
* Should that ever change,
|
|
13
|
+
* we would swap to atomic `mv tmp final` rewrites, or hand it to sqlite.
|
|
13
14
|
*/
|
|
14
15
|
export declare class FsRunRepository implements RunRepository {
|
|
15
16
|
saveRecord(workspace: Workspace, record: RunRecord): Promise<void>;
|
|
16
17
|
appendEvent(workspace: Workspace, runId: SkillRunId, event: SkillEvent): Promise<void>;
|
|
17
18
|
listRecords(workspace: Workspace): Promise<readonly RunRecord[]>;
|
|
18
19
|
readEvents(workspace: Workspace, runId: SkillRunId): AsyncIterable<SkillEvent>;
|
|
20
|
+
deleteRecords(workspace: Workspace, runIds: readonly SkillRunId[]): Promise<void>;
|
|
21
|
+
saveSessionMetadata(workspace: Workspace, metadata: SessionMetadata): Promise<void>;
|
|
22
|
+
listSessionMetadata(workspace: Workspace): Promise<readonly SessionMetadata[]>;
|
|
19
23
|
}
|
|
24
|
+
/** Re-exported so callers don't need to thread AbsolutePath types around. */
|
|
20
25
|
export type { AbsolutePath };
|
|
21
26
|
//# sourceMappingURL=FsRunRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsRunRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/skill/FsRunRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAQvG;;;;;;;;;;;GAWG;AACH,qBAAa,eAAgB,YAAW,aAAa;IAC7C,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlE,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtF,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC;IAyB9D,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;IAkBhF,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCjF,mBAAmB,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnF,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;CAsBrF;AA6BD,6EAA6E;AAC7E,YAAY,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
2
|
+
import { appendFile, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import { createInterface } from 'node:readline/promises';
|
|
5
|
+
import { RunRecord as RunRecordSchema, SessionMetadata as SessionMetadataSchema, SkillEvent as SkillEventSchema } from '@braidhq/schema';
|
|
6
|
+
import { runEventsPath, runIndexPath, runsDir, runSessionsMetadataPath } from '../_shared/paths.js';
|
|
7
|
+
/**
|
|
8
|
+
* File-system adapter for skill-run recording.
|
|
9
|
+
*
|
|
10
|
+
* <workspaceRoot>/artifacts/runs/
|
|
11
|
+
* ├── index.jsonl (append-only summary, last-wins per runId)
|
|
12
|
+
* └── <runId>.jsonl (full SkillEvent stream for one run)
|
|
13
|
+
*
|
|
14
|
+
* The index is append-only because every write of one workspace goes,
|
|
15
|
+
* today, through a single server process.
|
|
16
|
+
* Should that ever change,
|
|
17
|
+
* we would swap to atomic `mv tmp final` rewrites, or hand it to sqlite.
|
|
18
|
+
*/
|
|
19
|
+
export class FsRunRepository {
|
|
20
|
+
async saveRecord(workspace, record) {
|
|
21
|
+
const root = workspace.rootPath;
|
|
22
|
+
await mkdir(runsDir(root), { recursive: true });
|
|
23
|
+
const line = `${JSON.stringify(record)}\n`;
|
|
24
|
+
await appendFile(runIndexPath(root), line, 'utf-8');
|
|
25
|
+
}
|
|
26
|
+
async appendEvent(workspace, runId, event) {
|
|
27
|
+
const root = workspace.rootPath;
|
|
28
|
+
await mkdir(runsDir(root), { recursive: true });
|
|
29
|
+
const line = `${JSON.stringify(event)}\n`;
|
|
30
|
+
await appendFile(runEventsPath(root, runId), line, 'utf-8');
|
|
31
|
+
}
|
|
32
|
+
async listRecords(workspace) {
|
|
33
|
+
const root = workspace.rootPath;
|
|
34
|
+
const path = runIndexPath(root);
|
|
35
|
+
let raw;
|
|
36
|
+
try {
|
|
37
|
+
raw = await readFile(path, 'utf-8');
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error.code === 'ENOENT')
|
|
41
|
+
return [];
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
// Last-write-wins per runId so progress updates collapse to a single entry.
|
|
45
|
+
const byId = new Map();
|
|
46
|
+
for (const line of raw.split('\n')) {
|
|
47
|
+
if (line.length === 0)
|
|
48
|
+
continue;
|
|
49
|
+
const parsed = safeParseRecord(line);
|
|
50
|
+
if (parsed)
|
|
51
|
+
byId.set(parsed.runId, parsed);
|
|
52
|
+
}
|
|
53
|
+
// Reverse-chronological by startedAt so the newest conversation lands at top.
|
|
54
|
+
return Array.from(byId.values()).sort((a, b) => b.startedAt.localeCompare(a.startedAt));
|
|
55
|
+
}
|
|
56
|
+
async *readEvents(workspace, runId) {
|
|
57
|
+
const path = runEventsPath(workspace.rootPath, runId);
|
|
58
|
+
const stream = createReadStream(path, { encoding: 'utf-8' });
|
|
59
|
+
const reader = createInterface({ input: stream, crlfDelay: Number.POSITIVE_INFINITY });
|
|
60
|
+
try {
|
|
61
|
+
for await (const line of reader) {
|
|
62
|
+
if (line.length === 0)
|
|
63
|
+
continue;
|
|
64
|
+
const parsed = safeParseEvent(line);
|
|
65
|
+
if (parsed)
|
|
66
|
+
yield parsed;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
stream.destroy();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async deleteRecords(workspace, runIds) {
|
|
74
|
+
if (runIds.length === 0)
|
|
75
|
+
return;
|
|
76
|
+
const root = workspace.rootPath;
|
|
77
|
+
const indexPath = runIndexPath(root);
|
|
78
|
+
const targets = new Set(runIds);
|
|
79
|
+
let raw;
|
|
80
|
+
try {
|
|
81
|
+
raw = await readFile(indexPath, 'utf-8');
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error.code === 'ENOENT')
|
|
85
|
+
return;
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
// Rewrite the index excluding every line that names a target run.
|
|
89
|
+
// Last-wins reader semantics mean we must drop ALL occurrences,
|
|
90
|
+
// not just the latest one.
|
|
91
|
+
// An earlier entry left behind would,
|
|
92
|
+
// otherwise resurrect the run when `listRecords()` next runs.
|
|
93
|
+
const kept = [];
|
|
94
|
+
for (const line of raw.split('\n')) {
|
|
95
|
+
if (line.length === 0)
|
|
96
|
+
continue;
|
|
97
|
+
const parsed = safeParseRecord(line);
|
|
98
|
+
if (parsed && targets.has(parsed.runId))
|
|
99
|
+
continue;
|
|
100
|
+
kept.push(line);
|
|
101
|
+
}
|
|
102
|
+
const tmp = `${indexPath}.tmp-${process.pid}-${Date.now()}`;
|
|
103
|
+
await writeFile(tmp, kept.length === 0 ? '' : `${kept.join('\n')}\n`, 'utf-8');
|
|
104
|
+
await rename(tmp, indexPath);
|
|
105
|
+
// Per-runId event files get best-effort removal.
|
|
106
|
+
// A missing file is fine, the run errored before any event landed.
|
|
107
|
+
await Promise.all(runIds.map(id => rm(runEventsPath(root, id), { force: true })));
|
|
108
|
+
}
|
|
109
|
+
async saveSessionMetadata(workspace, metadata) {
|
|
110
|
+
const root = workspace.rootPath;
|
|
111
|
+
await mkdir(runsDir(root), { recursive: true });
|
|
112
|
+
const line = `${JSON.stringify(metadata)}\n`;
|
|
113
|
+
await appendFile(runSessionsMetadataPath(root), line, 'utf-8');
|
|
114
|
+
}
|
|
115
|
+
async listSessionMetadata(workspace) {
|
|
116
|
+
const root = workspace.rootPath;
|
|
117
|
+
let raw;
|
|
118
|
+
try {
|
|
119
|
+
raw = await readFile(runSessionsMetadataPath(root), 'utf-8');
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (error.code === 'ENOENT')
|
|
123
|
+
return [];
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
// Last-write-wins per sessionId, matching the index semantics.
|
|
127
|
+
const byId = new Map();
|
|
128
|
+
for (const line of raw.split('\n')) {
|
|
129
|
+
if (line.length === 0)
|
|
130
|
+
continue;
|
|
131
|
+
const parsed = safeParseSessionMetadata(line);
|
|
132
|
+
if (parsed)
|
|
133
|
+
byId.set(parsed.sessionId, parsed);
|
|
134
|
+
}
|
|
135
|
+
return Array.from(byId.values());
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function safeParseRecord(line) {
|
|
139
|
+
try {
|
|
140
|
+
return RunRecordSchema.parse(JSON.parse(line));
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function safeParseEvent(line) {
|
|
147
|
+
try {
|
|
148
|
+
return SkillEventSchema.parse(JSON.parse(line));
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function safeParseSessionMetadata(line) {
|
|
155
|
+
try {
|
|
156
|
+
return SessionMetadataSchema.parse(JSON.parse(line));
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=FsRunRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsRunRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/skill/FsRunRepository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,eAAe,IAAI,qBAAqB,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACxI,OAAO,EAAE,aAAa,EAAE,YAAY,EAA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IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;gBACnB,SAAQ;YACV,MAAM,MAAM,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAA;YAC7C,IAAI,MAAM;gBACR,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IAClC,CAAC;CACF;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,IAAI,CAAC;QACH,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IAChD,CAAC;IACD,MAAM,CAAC;QACL,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,CAAC;QACH,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IACjD,CAAC;IACD,MAAM,CAAC;QACL,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAY;IAC5C,IAAI,CAAC;QACH,OAAO,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IACtD,CAAC;IACD,MAAM,CAAC;QACL,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -3,11 +3,10 @@ import { type PluginRegistry, SkillManifest, type SkillRegistry, type Workspace
|
|
|
3
3
|
export interface FsSkillRegistryOptions {
|
|
4
4
|
readonly builtinSkillsRoot: AbsolutePath;
|
|
5
5
|
/**
|
|
6
|
-
* Optional plugin registry. When provided, skills
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* extension origins are discovered.
|
|
6
|
+
* Optional plugin registry. When provided, plugin-declared skills mount,
|
|
7
|
+
* between builtins and workspace skills, under the `plugin` origin.
|
|
8
|
+
* Without it, as in unit tests that compose no registry, only builtin,
|
|
9
|
+
* workspace, and extension origins are discovered.
|
|
11
10
|
*/
|
|
12
11
|
readonly pluginRegistry?: PluginRegistry;
|
|
13
12
|
}
|
|
@@ -18,14 +17,6 @@ export declare class FsSkillRegistry implements SkillRegistry {
|
|
|
18
17
|
find(workspace: Workspace, skillId: SkillId): Promise<SkillManifest | undefined>;
|
|
19
18
|
get(workspace: Workspace, skillId: SkillId): Promise<SkillManifest>;
|
|
20
19
|
private scanSkillsRoot;
|
|
21
|
-
/**
|
|
22
|
-
* Resolve every PluginSkillRef in the registry to a parsed
|
|
23
|
-
* SkillManifest. Each ref's `directory` is converted to an absolute
|
|
24
|
-
* fs path (URL via fileURLToPath), then `SKILL.md` is read and
|
|
25
|
-
* parsed. Missing files at a plugin-declared path are an error,
|
|
26
|
-
* not a silent skip: a plugin that ships a broken ref deserves a
|
|
27
|
-
* loud startup failure, not a mysteriously-absent skill.
|
|
28
|
-
*/
|
|
29
20
|
private scanPluginSkills;
|
|
30
21
|
private scanExtensionRoot;
|
|
31
22
|
private readSkillFrontmatter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsSkillRegistry.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/skill/FsSkillRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoB,OAAO,EAAe,MAAM,iBAAiB,CAAA;AAK3F,OAAO,EAAiB,KAAK,cAAc,EAAE,aAAa,EAAE,KAAK,aAAa,EAA0B,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAU7I,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,iBAAiB,EAAE,YAAY,CAAA;IACxC;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAA;CACzC;AAED,qBAAa,eAAgB,YAAW,aAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,sBAAsB;IAEtD,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC;IA4B7D,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAKhF,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;YAO3D,cAAc;YA+Bd,gBAAgB;YAuBhB,iBAAiB;YAwBjB,oBAAoB;YA4BpB,WAAW;CAc1B"}
|
|
@@ -2,10 +2,10 @@ import { Buffer } from 'node:buffer';
|
|
|
2
2
|
import { readdir, readFile, stat } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { NotFoundError, SkillManifest } from '@braidhq/core';
|
|
5
|
+
import { NotFoundError, SkillManifest, validateSkillStructure } from '@braidhq/core';
|
|
6
6
|
import { AbsolutePath as AbsolutePathSchema, SkillFrontmatter as SkillFrontmatterSchema, SkillId as SkillIdSchema } from '@braidhq/schema';
|
|
7
|
-
import { parseMarkdownFrontmatter } from '
|
|
8
|
-
import { workspaceSkillExtensionsDir, workspaceSkillsDir } from '
|
|
7
|
+
import { parseMarkdownFrontmatter } from '../_shared/frontmatter.js';
|
|
8
|
+
import { workspaceSkillExtensionsDir, workspaceSkillsDir } from '../_shared/paths.js';
|
|
9
9
|
export class FsSkillRegistry {
|
|
10
10
|
options;
|
|
11
11
|
constructor(options) {
|
|
@@ -16,9 +16,9 @@ export class FsSkillRegistry {
|
|
|
16
16
|
const pluginSkills = await this.scanPluginSkills();
|
|
17
17
|
const workspaceSkills = await this.scanSkillsRoot(AbsolutePathSchema.parse(workspaceSkillsDir(workspace.rootPath)), 'workspace');
|
|
18
18
|
const extensions = await this.scanExtensionRoot(AbsolutePathSchema.parse(workspaceSkillExtensionsDir(workspace.rootPath)));
|
|
19
|
-
// Precedence
|
|
20
|
-
// Extensions don't override
|
|
21
|
-
//
|
|
19
|
+
// Precedence, later wins: builtin < plugin < workspace.
|
|
20
|
+
// Extensions don't override. They attach an EXTEND.md path,
|
|
21
|
+
// and the agent binding points claude at that file at run time.
|
|
22
22
|
const manifests = new Map();
|
|
23
23
|
for (const manifest of builtins)
|
|
24
24
|
manifests.set(manifest.id, manifest);
|
|
@@ -55,8 +55,12 @@ export class FsSkillRegistry {
|
|
|
55
55
|
const frontmatter = await this.readSkillFrontmatter(skillFile);
|
|
56
56
|
if (!frontmatter)
|
|
57
57
|
continue;
|
|
58
|
+
// The directory is the bare verb. Namespace it by origin,
|
|
59
|
+
// builtins under `braid`, workspace skills under `workspace`,
|
|
60
|
+
// so the id matches the plugin the agent binding stages it as.
|
|
61
|
+
const namespace = origin === 'builtin' ? 'braid' : 'workspace';
|
|
58
62
|
manifests.push(new SkillManifest({
|
|
59
|
-
id: SkillIdSchema.parse(entry.name),
|
|
63
|
+
id: SkillIdSchema.parse(`${namespace}:${entry.name}`),
|
|
60
64
|
origin,
|
|
61
65
|
path: skillFile,
|
|
62
66
|
frontmatter,
|
|
@@ -64,14 +68,13 @@ export class FsSkillRegistry {
|
|
|
64
68
|
}
|
|
65
69
|
return manifests;
|
|
66
70
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
*/
|
|
71
|
+
// Resolve every PluginSkillRef in the registry to a parsed SkillManifest.
|
|
72
|
+
// Each ref's `directory` is resolved to an absolute path via fileURLToPath,
|
|
73
|
+
// then its `SKILL.md` is read and parsed.
|
|
74
|
+
// A file missing at such a path,
|
|
75
|
+
// counts as an error, never a silent skip.
|
|
76
|
+
// A plugin shipping a broken ref,
|
|
77
|
+
// earns a loud startup failure, not a mysteriously absent skill.
|
|
75
78
|
async scanPluginSkills() {
|
|
76
79
|
const registry = this.options.pluginRegistry;
|
|
77
80
|
if (!registry)
|
|
@@ -89,6 +92,7 @@ export class FsSkillRegistry {
|
|
|
89
92
|
origin: 'plugin',
|
|
90
93
|
path: skillFile,
|
|
91
94
|
frontmatter,
|
|
95
|
+
pluginId: ref.contributedBy,
|
|
92
96
|
}));
|
|
93
97
|
}
|
|
94
98
|
return manifests;
|
|
@@ -102,7 +106,11 @@ export class FsSkillRegistry {
|
|
|
102
106
|
const extendPath = AbsolutePathSchema.parse(join(root, entry.name, 'EXTEND.md'));
|
|
103
107
|
try {
|
|
104
108
|
await stat(extendPath);
|
|
105
|
-
|
|
109
|
+
// The extension dir is `<namespace>-<verb>`, filesystem-safe.
|
|
110
|
+
// The first hyphen maps back to the id's `:` separator,
|
|
111
|
+
// so `ddd-extract` targets `ddd:extract` and `braid:generate-doc`
|
|
112
|
+
// targets `braid:generate-doc`.
|
|
113
|
+
const skillId = SkillIdSchema.parse(entry.name.replace('-', ':'));
|
|
106
114
|
results.push({ id: skillId, path: extendPath });
|
|
107
115
|
}
|
|
108
116
|
catch (error) {
|
|
@@ -122,8 +130,20 @@ export class FsSkillRegistry {
|
|
|
122
130
|
return undefined;
|
|
123
131
|
throw error;
|
|
124
132
|
}
|
|
125
|
-
const { frontmatter } = parseMarkdownFrontmatter(content);
|
|
126
|
-
|
|
133
|
+
const { frontmatter: raw, body } = parseMarkdownFrontmatter(content);
|
|
134
|
+
const frontmatter = SkillFrontmatterSchema.parse(raw);
|
|
135
|
+
// Structural contract: SKILL.md must declare the required H2 sections,
|
|
136
|
+
// per its `braid.category`.
|
|
137
|
+
// The validator is hard-fail.
|
|
138
|
+
// A broken skill never lands silently in the workspace list.
|
|
139
|
+
// Were `## Procedure` absent, the skill would burn an entire run,
|
|
140
|
+
// before the agent ever noticed the missing section.
|
|
141
|
+
const validation = validateSkillStructure({ body, frontmatter });
|
|
142
|
+
if (!validation.ok) {
|
|
143
|
+
const issues = validation.issues.map(issue => `- ${issue.message}`).join('\n');
|
|
144
|
+
throw new Error(`SKILL.md at ${skillFile} fails the structure contract:\n${issues}`);
|
|
145
|
+
}
|
|
146
|
+
return frontmatter;
|
|
127
147
|
}
|
|
128
148
|
async readDirSafe(directory) {
|
|
129
149
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsSkillRegistry.js","sourceRoot":"","sources":["../../../src/infrastructure/skill/FsSkillRegistry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,aAAa,EAAuB,aAAa,EAAsB,sBAAsB,EAAkB,MAAM,eAAe,CAAA;AAC7I,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,gBAAgB,IAAI,sBAAsB,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1I,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAkBrF,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;IAAG,CAAC;IAEhE,KAAK,CAAC,IAAI,CAAC,SAAoB;QAC7B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAA;QACrF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAA;QAClD,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,cAAc,CAC/C,kBAAkB,CAAC,KAAK,CAAC,kBAAkB,CAAC,SAAS,CAAC,QAAQ,C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ventListener, SkillRegistry, SkillRunner, SkillRunOptions, SkillRunSubscription, Workspace, WorkspaceEventBus } from '@braidhq/core';
|
|
2
|
-
import type { AbsolutePath, SkillId, SkillRunId } from '@braidhq/schema';
|
|
2
|
+
import type { AbsolutePath, AgentBindingDescriptor, SkillId, SkillRunId } from '@braidhq/schema';
|
|
3
3
|
import type { ChildProcess, SpawnOptions } from 'node:child_process';
|
|
4
4
|
export type SpawnFn = (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
|
|
5
5
|
/**
|
|
6
|
-
* Additional directories to expose under the session's `.claude/skills/`
|
|
7
|
-
*
|
|
8
|
-
* that builtin SKILL.md files reference
|
|
6
|
+
* Additional directories to expose under the session's `.claude/skills/` tree.
|
|
7
|
+
* Typically non-skill reference content,
|
|
8
|
+
* e.g. a `shared/` dir that builtin SKILL.md files reference.
|
|
9
9
|
*/
|
|
10
10
|
export interface SkillReferenceDir {
|
|
11
11
|
readonly name: string;
|
|
@@ -13,30 +13,25 @@ export interface SkillReferenceDir {
|
|
|
13
13
|
}
|
|
14
14
|
export interface SubprocessSkillRunnerDeps {
|
|
15
15
|
readonly skillRegistry: SkillRegistry;
|
|
16
|
-
readonly
|
|
16
|
+
readonly buildAgentBinding: (descriptor: AgentBindingDescriptor) => AgentBinding;
|
|
17
|
+
readonly defaultAgent: AgentBindingDescriptor;
|
|
17
18
|
readonly apiUrl: string;
|
|
18
|
-
/** Required: runs persist their event log here as the source of truth for replays. */
|
|
19
19
|
readonly runRepository: RunRepository;
|
|
20
20
|
readonly spawn?: SpawnFn;
|
|
21
21
|
readonly clock?: () => string;
|
|
22
|
-
/** Extra directories symlinked alongside skills (e.g. shared reference docs). */
|
|
23
22
|
readonly referenceDirs?: readonly SkillReferenceDir[];
|
|
24
|
-
/** Delete the per-run session directory after the run. Default `true`. */
|
|
25
23
|
readonly cleanupSession?: boolean;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*/
|
|
24
|
+
readonly coreGateway?: {
|
|
25
|
+
readonly specUrl: string;
|
|
26
|
+
readonly uvxBin?: string;
|
|
27
|
+
};
|
|
31
28
|
readonly eventBus?: WorkspaceEventBus;
|
|
32
29
|
}
|
|
33
30
|
export declare class SubprocessSkillRunner implements SkillRunner {
|
|
34
31
|
private readonly deps;
|
|
35
32
|
private readonly running;
|
|
36
|
-
/** sessionId → cwd for resuming. claude needs the same cwd between turns. */
|
|
37
33
|
private readonly sessionDirs;
|
|
38
34
|
private readonly subscribers;
|
|
39
|
-
/** How many events have been emitted (and persisted) per run so far. */
|
|
40
35
|
private readonly positions;
|
|
41
36
|
constructor(deps: SubprocessSkillRunnerDeps);
|
|
42
37
|
start(workspace: Workspace, skillId: SkillId, args: string, options?: SkillRunOptions): Promise<SkillRunId>;
|
|
@@ -49,6 +44,9 @@ export declare class SubprocessSkillRunner implements SkillRunner {
|
|
|
49
44
|
private resolveSessionDir;
|
|
50
45
|
private recoverSessionDir;
|
|
51
46
|
private buildSessionDir;
|
|
47
|
+
private skillBundleDir;
|
|
48
|
+
private skillBundleDirsFor;
|
|
49
|
+
private bindingFor;
|
|
52
50
|
private now;
|
|
53
51
|
}
|
|
54
52
|
//# sourceMappingURL=SubprocessSkillRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubprocessSkillRunner.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/skill/SubprocessSkillRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAElB,aAAa,EACb,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAA8D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5J,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AASpE,MAA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