@braidhq/server 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +71 -0
- package/dist/app.js.map +1 -0
- package/dist/composeFs.d.ts +20 -0
- package/dist/composeFs.d.ts.map +1 -0
- package/dist/composeFs.js +134 -0
- package/dist/composeFs.js.map +1 -0
- package/dist/composition.d.ts +49 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +43 -0
- package/dist/composition.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/agent/ClaudeCodeAgentBinding.d.ts +8 -0
- package/dist/infrastructure/agent/ClaudeCodeAgentBinding.d.ts.map +1 -0
- package/dist/infrastructure/agent/ClaudeCodeAgentBinding.js +62 -0
- package/dist/infrastructure/agent/ClaudeCodeAgentBinding.js.map +1 -0
- package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts +54 -0
- package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts.map +1 -0
- package/dist/infrastructure/agent/SubprocessSkillRunner.js +240 -0
- package/dist/infrastructure/agent/SubprocessSkillRunner.js.map +1 -0
- package/dist/infrastructure/agent/asyncQueue.d.ts +22 -0
- package/dist/infrastructure/agent/asyncQueue.d.ts.map +1 -0
- package/dist/infrastructure/agent/asyncQueue.js +43 -0
- package/dist/infrastructure/agent/asyncQueue.js.map +1 -0
- package/dist/infrastructure/agent/mcpConfig.d.ts +18 -0
- package/dist/infrastructure/agent/mcpConfig.d.ts.map +1 -0
- package/dist/infrastructure/agent/mcpConfig.js +47 -0
- package/dist/infrastructure/agent/mcpConfig.js.map +1 -0
- package/dist/infrastructure/agent/streamJsonParser.d.ts +20 -0
- package/dist/infrastructure/agent/streamJsonParser.d.ts.map +1 -0
- package/dist/infrastructure/agent/streamJsonParser.js +44 -0
- package/dist/infrastructure/agent/streamJsonParser.js.map +1 -0
- package/dist/infrastructure/agent/subprocessEventStream.d.ts +26 -0
- package/dist/infrastructure/agent/subprocessEventStream.d.ts.map +1 -0
- package/dist/infrastructure/agent/subprocessEventStream.js +112 -0
- package/dist/infrastructure/agent/subprocessEventStream.js.map +1 -0
- package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts +13 -0
- package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsClarifyTicketRepository.js +33 -0
- package/dist/infrastructure/fs/FsClarifyTicketRepository.js.map +1 -0
- package/dist/infrastructure/fs/FsDecisionRepository.d.ts +13 -0
- package/dist/infrastructure/fs/FsDecisionRepository.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsDecisionRepository.js +56 -0
- package/dist/infrastructure/fs/FsDecisionRepository.js.map +1 -0
- package/dist/infrastructure/fs/FsProposalRepository.d.ts +14 -0
- package/dist/infrastructure/fs/FsProposalRepository.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsProposalRepository.js +40 -0
- package/dist/infrastructure/fs/FsProposalRepository.js.map +1 -0
- package/dist/infrastructure/fs/FsRunRepository.d.ts +21 -0
- package/dist/infrastructure/fs/FsRunRepository.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsRunRepository.js +88 -0
- package/dist/infrastructure/fs/FsRunRepository.js.map +1 -0
- package/dist/infrastructure/fs/FsSkillRegistry.d.ts +34 -0
- package/dist/infrastructure/fs/FsSkillRegistry.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsSkillRegistry.js +143 -0
- package/dist/infrastructure/fs/FsSkillRegistry.js.map +1 -0
- package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts +35 -0
- package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsStatusedJsonRepository.js +79 -0
- package/dist/infrastructure/fs/FsStatusedJsonRepository.js.map +1 -0
- package/dist/infrastructure/fs/FsWorkspaceRepository.d.ts +21 -0
- package/dist/infrastructure/fs/FsWorkspaceRepository.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsWorkspaceRepository.js +87 -0
- package/dist/infrastructure/fs/FsWorkspaceRepository.js.map +1 -0
- package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts +17 -0
- package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts.map +1 -0
- package/dist/infrastructure/fs/WorkspaceRegistryFile.js +58 -0
- package/dist/infrastructure/fs/WorkspaceRegistryFile.js.map +1 -0
- package/dist/infrastructure/fs/frontmatter.d.ts +13 -0
- package/dist/infrastructure/fs/frontmatter.d.ts.map +1 -0
- package/dist/infrastructure/fs/frontmatter.js +46 -0
- package/dist/infrastructure/fs/frontmatter.js.map +1 -0
- package/dist/infrastructure/fs/jsonFileStore.d.ts +5 -0
- package/dist/infrastructure/fs/jsonFileStore.d.ts.map +1 -0
- package/dist/infrastructure/fs/jsonFileStore.js +29 -0
- package/dist/infrastructure/fs/jsonFileStore.js.map +1 -0
- package/dist/infrastructure/fs/paths.d.ts +22 -0
- package/dist/infrastructure/fs/paths.d.ts.map +1 -0
- package/dist/infrastructure/fs/paths.js +46 -0
- package/dist/infrastructure/fs/paths.js.map +1 -0
- package/dist/infrastructure/fs/productManifestWriter.d.ts +22 -0
- package/dist/infrastructure/fs/productManifestWriter.d.ts.map +1 -0
- package/dist/infrastructure/fs/productManifestWriter.js +75 -0
- package/dist/infrastructure/fs/productManifestWriter.js.map +1 -0
- package/dist/infrastructure/oauth/GoogleOAuth.d.ts +60 -0
- package/dist/infrastructure/oauth/GoogleOAuth.d.ts.map +1 -0
- package/dist/infrastructure/oauth/GoogleOAuth.js +114 -0
- package/dist/infrastructure/oauth/GoogleOAuth.js.map +1 -0
- package/dist/infrastructure/orphanReaper.d.ts +18 -0
- package/dist/infrastructure/orphanReaper.d.ts.map +1 -0
- package/dist/infrastructure/orphanReaper.js +42 -0
- package/dist/infrastructure/orphanReaper.js.map +1 -0
- package/dist/infrastructure/secrets/SecretStore.d.ts +36 -0
- package/dist/infrastructure/secrets/SecretStore.d.ts.map +1 -0
- package/dist/infrastructure/secrets/SecretStore.js +44 -0
- package/dist/infrastructure/secrets/SecretStore.js.map +1 -0
- package/dist/middleware/cors.d.ts +11 -0
- package/dist/middleware/cors.d.ts.map +1 -0
- package/dist/middleware/cors.js +30 -0
- package/dist/middleware/cors.js.map +1 -0
- package/dist/middleware/error.d.ts +3 -0
- package/dist/middleware/error.d.ts.map +1 -0
- package/dist/middleware/error.js +52 -0
- package/dist/middleware/error.js.map +1 -0
- package/dist/middleware/workspaceId.d.ts +10 -0
- package/dist/middleware/workspaceId.d.ts.map +1 -0
- package/dist/middleware/workspaceId.js +9 -0
- package/dist/middleware/workspaceId.js.map +1 -0
- package/dist/routes/clarify.d.ts +8 -0
- package/dist/routes/clarify.d.ts.map +1 -0
- package/dist/routes/clarify.js +84 -0
- package/dist/routes/clarify.js.map +1 -0
- package/dist/routes/decisions.d.ts +7 -0
- package/dist/routes/decisions.d.ts.map +1 -0
- package/dist/routes/decisions.js +30 -0
- package/dist/routes/decisions.js.map +1 -0
- package/dist/routes/edges.d.ts +7 -0
- package/dist/routes/edges.d.ts.map +1 -0
- package/dist/routes/edges.js +30 -0
- package/dist/routes/edges.js.map +1 -0
- package/dist/routes/health.d.ts +3 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +10 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/helpers.d.ts +5 -0
- package/dist/routes/helpers.d.ts.map +1 -0
- package/dist/routes/helpers.js +14 -0
- package/dist/routes/helpers.js.map +1 -0
- package/dist/routes/model.d.ts +7 -0
- package/dist/routes/model.d.ts.map +1 -0
- package/dist/routes/model.js +12 -0
- package/dist/routes/model.js.map +1 -0
- package/dist/routes/nodes.d.ts +7 -0
- package/dist/routes/nodes.d.ts.map +1 -0
- package/dist/routes/nodes.js +47 -0
- package/dist/routes/nodes.js.map +1 -0
- package/dist/routes/oauth.d.ts +20 -0
- package/dist/routes/oauth.d.ts.map +1 -0
- package/dist/routes/oauth.js +107 -0
- package/dist/routes/oauth.js.map +1 -0
- package/dist/routes/ontology.d.ts +8 -0
- package/dist/routes/ontology.d.ts.map +1 -0
- package/dist/routes/ontology.js +21 -0
- package/dist/routes/ontology.js.map +1 -0
- package/dist/routes/proposals.d.ts +10 -0
- package/dist/routes/proposals.d.ts.map +1 -0
- package/dist/routes/proposals.js +80 -0
- package/dist/routes/proposals.js.map +1 -0
- package/dist/routes/runs.d.ts +9 -0
- package/dist/routes/runs.d.ts.map +1 -0
- package/dist/routes/runs.js +73 -0
- package/dist/routes/runs.js.map +1 -0
- package/dist/routes/skills.d.ts +9 -0
- package/dist/routes/skills.d.ts.map +1 -0
- package/dist/routes/skills.js +42 -0
- package/dist/routes/skills.js.map +1 -0
- package/dist/routes/workspaceEvents.d.ts +14 -0
- package/dist/routes/workspaceEvents.d.ts.map +1 -0
- package/dist/routes/workspaceEvents.js +37 -0
- package/dist/routes/workspaceEvents.js.map +1 -0
- package/dist/routes/workspaces.d.ts +8 -0
- package/dist/routes/workspaces.d.ts.map +1 -0
- package/dist/routes/workspaces.js +167 -0
- package/dist/routes/workspaces.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +33 -0
- package/dist/server.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mroops0111
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppDependencies } from './composition.js';
|
|
2
|
+
import { Hono } from 'hono';
|
|
3
|
+
export interface AppOptions {
|
|
4
|
+
readonly corsOrigins?: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
export declare function createApp(deps: AppDependencies, options?: AppOptions): Hono;
|
|
7
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAkB3B,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACzC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,GAAE,UAAe,GAAG,IAAI,CA6D/E"}
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { corsMiddleware } from './middleware/cors.js';
|
|
3
|
+
import { errorHandler } from './middleware/error.js';
|
|
4
|
+
import { workspaceIdMiddleware } from './middleware/workspaceId.js';
|
|
5
|
+
import { createClarifyRouter } from './routes/clarify.js';
|
|
6
|
+
import { createDecisionsRouter } from './routes/decisions.js';
|
|
7
|
+
import { createEdgesRouter } from './routes/edges.js';
|
|
8
|
+
import { healthRouter } from './routes/health.js';
|
|
9
|
+
import { createModelRouter } from './routes/model.js';
|
|
10
|
+
import { createNodesRouter } from './routes/nodes.js';
|
|
11
|
+
import { createOAuthRouter } from './routes/oauth.js';
|
|
12
|
+
import { createOntologyRouter } from './routes/ontology.js';
|
|
13
|
+
import { createProposalsRouter } from './routes/proposals.js';
|
|
14
|
+
import { createRunsRouter } from './routes/runs.js';
|
|
15
|
+
import { createSkillsRouter } from './routes/skills.js';
|
|
16
|
+
import { createWorkspaceEventsRouter } from './routes/workspaceEvents.js';
|
|
17
|
+
import { createWorkspacesRouter } from './routes/workspaces.js';
|
|
18
|
+
export function createApp(deps, options = {}) {
|
|
19
|
+
const app = new Hono();
|
|
20
|
+
app.use('*', options.corsOrigins
|
|
21
|
+
? corsMiddleware({ allowedOrigins: options.corsOrigins })
|
|
22
|
+
: corsMiddleware());
|
|
23
|
+
app.onError(errorHandler);
|
|
24
|
+
app.route('/health', healthRouter);
|
|
25
|
+
app.route('/workspaces', createWorkspacesRouter({
|
|
26
|
+
workspaceService: deps.workspaceService,
|
|
27
|
+
sourceLoaderRunner: deps.sourceLoaderRunner,
|
|
28
|
+
}));
|
|
29
|
+
app.route('/workspaces', createWorkspaceEventsRouter({ eventBus: deps.eventBus }));
|
|
30
|
+
const workspaceScoped = new Hono();
|
|
31
|
+
workspaceScoped.use('*', workspaceIdMiddleware);
|
|
32
|
+
workspaceScoped.route('/model', createModelRouter({ modelService: deps.modelService }));
|
|
33
|
+
workspaceScoped.route('/nodes', createNodesRouter({ modelService: deps.modelService }));
|
|
34
|
+
workspaceScoped.route('/edges', createEdgesRouter({ modelService: deps.modelService }));
|
|
35
|
+
workspaceScoped.route('/proposals', createProposalsRouter({
|
|
36
|
+
hitlService: deps.hitlService,
|
|
37
|
+
proposalRepository: deps.proposalRepository,
|
|
38
|
+
modelRepository: deps.modelRepository,
|
|
39
|
+
validationService: deps.validationService,
|
|
40
|
+
}));
|
|
41
|
+
workspaceScoped.route('/clarify', createClarifyRouter({
|
|
42
|
+
hitlService: deps.hitlService,
|
|
43
|
+
clarifyRepository: deps.clarifyRepository,
|
|
44
|
+
}));
|
|
45
|
+
workspaceScoped.route('/decisions', createDecisionsRouter({ decisionRepository: deps.decisionRepository }));
|
|
46
|
+
workspaceScoped.route('/ontology', createOntologyRouter({
|
|
47
|
+
workspaceRepository: deps.workspaceRepository,
|
|
48
|
+
pluginRegistry: deps.pluginRegistry,
|
|
49
|
+
}));
|
|
50
|
+
if (deps.skillRegistry && deps.skillRunner) {
|
|
51
|
+
workspaceScoped.route('/skills', createSkillsRouter({
|
|
52
|
+
skillRegistry: deps.skillRegistry,
|
|
53
|
+
skillRunner: deps.skillRunner,
|
|
54
|
+
workspaceRepository: deps.workspaceRepository,
|
|
55
|
+
}));
|
|
56
|
+
workspaceScoped.route('/runs', createRunsRouter({
|
|
57
|
+
runRepository: deps.runRepository,
|
|
58
|
+
skillRunner: deps.skillRunner,
|
|
59
|
+
workspaceRepository: deps.workspaceRepository,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
app.route('/workspaces/:workspaceId', workspaceScoped);
|
|
63
|
+
if (deps.secretStore) {
|
|
64
|
+
app.route('/oauth', createOAuthRouter({
|
|
65
|
+
secretStore: deps.secretStore,
|
|
66
|
+
...(deps.googleOAuth ? { google: deps.googleOAuth } : {}),
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
return app;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.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1,20 @@
|
|
|
1
|
+
import type { AgentEffort } from '@braidhq/schema';
|
|
2
|
+
import type { AppDependencies } from './composition.js';
|
|
3
|
+
export interface ComposeFsOptions {
|
|
4
|
+
/** Where to persist registered workspace paths. Default `$BRAID_HOME` or `~/.braid`. */
|
|
5
|
+
readonly braidHome?: string;
|
|
6
|
+
/** URL the server reports to spawned subprocesses for REST callbacks. */
|
|
7
|
+
readonly apiUrl?: string;
|
|
8
|
+
/** Coding-agent model selection (default `opus`). */
|
|
9
|
+
readonly agentModel?: string;
|
|
10
|
+
/** Coding-agent effort tier (default `high`). */
|
|
11
|
+
readonly agentEffort?: AgentEffort;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Production composition root: real filesystem persistence for workspaces /
|
|
15
|
+
* proposals / clarify / decisions, built-in skills loaded from `@braidhq/core`,
|
|
16
|
+
* Claude Code subprocess agent. Model storage uses Kuzu (embedded, zero-infra)
|
|
17
|
+
* per workspace at `<workspace>/.braid/model.kuzu`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function composeFsApp(options?: ComposeFsOptions): AppDependencies;
|
|
20
|
+
//# sourceMappingURL=composeFs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFs.d.ts","sourceRoot":"","sources":["../src/composeFs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,WAAW,EAAmC,MAAM,iBAAiB,CAAA;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AA+BvD,MAAM,WAAW,gBAAgB;IAC/B,wFAAwF;IACxF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,qDAAqD;IACrD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,gBAAqB,GAAG,eAAe,CA4H5E"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import { builtinSkillsRoot, EvidenceValidator, InMemoryWorkspaceEventBus, NotFoundError, OntologyTypeValidator, OrphanEdgeValidator, PluginRegistry, StructuralValidator, } from '@braidhq/core';
|
|
5
|
+
import { dddOntology } from '@braidhq/ontology-ddd';
|
|
6
|
+
import { GoogleDriveLoader } from '@braidhq/source-loader-gdrive';
|
|
7
|
+
import { GitLoader } from '@braidhq/source-loader-git';
|
|
8
|
+
import { KuzuModelRepository } from '@braidhq/storage-kuzu';
|
|
9
|
+
import { composeApp } from './composition.js';
|
|
10
|
+
import { ClaudeCodeAgentBinding } from './infrastructure/agent/ClaudeCodeAgentBinding.js';
|
|
11
|
+
import { SubprocessSkillRunner } from './infrastructure/agent/SubprocessSkillRunner.js';
|
|
12
|
+
import { FsClarifyTicketRepository } from './infrastructure/fs/FsClarifyTicketRepository.js';
|
|
13
|
+
import { FsDecisionRepository } from './infrastructure/fs/FsDecisionRepository.js';
|
|
14
|
+
import { FsProposalRepository } from './infrastructure/fs/FsProposalRepository.js';
|
|
15
|
+
import { FsRunRepository } from './infrastructure/fs/FsRunRepository.js';
|
|
16
|
+
import { FsSkillRegistry } from './infrastructure/fs/FsSkillRegistry.js';
|
|
17
|
+
import { FsWorkspaceRepository } from './infrastructure/fs/FsWorkspaceRepository.js';
|
|
18
|
+
import { WorkspaceRegistryFile } from './infrastructure/fs/WorkspaceRegistryFile.js';
|
|
19
|
+
import { GoogleOAuth } from './infrastructure/oauth/GoogleOAuth.js';
|
|
20
|
+
import { FsSecretStore } from './infrastructure/secrets/SecretStore.js';
|
|
21
|
+
/**
|
|
22
|
+
* Production composition root: real filesystem persistence for workspaces /
|
|
23
|
+
* proposals / clarify / decisions, built-in skills loaded from `@braidhq/core`,
|
|
24
|
+
* Claude Code subprocess agent. Model storage uses Kuzu (embedded, zero-infra)
|
|
25
|
+
* per workspace at `<workspace>/.braid/model.kuzu`.
|
|
26
|
+
*/
|
|
27
|
+
export function composeFsApp(options = {}) {
|
|
28
|
+
const braidHome = options.braidHome ?? process.env.BRAID_HOME ?? join(homedir(), '.braid');
|
|
29
|
+
const apiUrl = options.apiUrl ?? 'http://localhost:4321';
|
|
30
|
+
const secretStore = new FsSecretStore(join(braidHome, 'secrets'));
|
|
31
|
+
const googleClientId = process.env.BRAID_GOOGLE_CLIENT_ID;
|
|
32
|
+
const googleClientSecret = process.env.BRAID_GOOGLE_CLIENT_SECRET;
|
|
33
|
+
const googleRedirect = process.env.BRAID_GOOGLE_REDIRECT_URI ?? `${apiUrl}/oauth/google/callback`;
|
|
34
|
+
const googleOAuth = googleClientId && googleClientSecret
|
|
35
|
+
? new GoogleOAuth({ clientId: googleClientId, clientSecret: googleClientSecret, redirectUri: googleRedirect })
|
|
36
|
+
: undefined;
|
|
37
|
+
const registry = new WorkspaceRegistryFile(join(braidHome, 'workspaces.json'));
|
|
38
|
+
const workspaceRepository = new FsWorkspaceRepository({ registry });
|
|
39
|
+
const workspaceRoots = async () => {
|
|
40
|
+
const workspaces = await workspaceRepository.list();
|
|
41
|
+
return new Map(workspaces.map(ws => [ws.id, ws.rootPath]));
|
|
42
|
+
};
|
|
43
|
+
const proposalRepository = new FsProposalRepository({ workspaceRoots });
|
|
44
|
+
const clarifyRepository = new FsClarifyTicketRepository({ workspaceRoots });
|
|
45
|
+
const decisionRepository = new FsDecisionRepository({ workspaceRoots });
|
|
46
|
+
const modelRepository = new KuzuModelRepository({
|
|
47
|
+
resolveDbPath: async (workspaceId) => {
|
|
48
|
+
const roots = await workspaceRoots();
|
|
49
|
+
const root = roots.get(workspaceId);
|
|
50
|
+
if (!root)
|
|
51
|
+
throw new NotFoundError(`Workspace "${workspaceId}" not registered`);
|
|
52
|
+
return join(root, '.braid', 'model.kuzu');
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const agentBinding = new ClaudeCodeAgentBinding({
|
|
56
|
+
id: 'claude-default',
|
|
57
|
+
kind: 'claude-code',
|
|
58
|
+
model: options.agentModel ?? 'opus',
|
|
59
|
+
effort: options.agentEffort ?? 'high',
|
|
60
|
+
extraArgs: [],
|
|
61
|
+
env: {},
|
|
62
|
+
});
|
|
63
|
+
const runRepository = new FsRunRepository();
|
|
64
|
+
const pluginRegistry = new PluginRegistry();
|
|
65
|
+
pluginRegistry.register(dddOntology);
|
|
66
|
+
pluginRegistry.register(new EvidenceValidator());
|
|
67
|
+
pluginRegistry.register(new OrphanEdgeValidator());
|
|
68
|
+
pluginRegistry.register(new OntologyTypeValidator(dddOntology));
|
|
69
|
+
pluginRegistry.register(new StructuralValidator(dddOntology));
|
|
70
|
+
pluginRegistry.register(new GitLoader());
|
|
71
|
+
if (googleOAuth) {
|
|
72
|
+
// GoogleDriveLoader requires OAuth to be configured. We resolve the
|
|
73
|
+
// access token per (workspaceId, sourceId): read stored tokens from
|
|
74
|
+
// the secret store, refresh if expired, persist the rotated access
|
|
75
|
+
// token, hand the bearer to the loader.
|
|
76
|
+
const oauth = googleOAuth;
|
|
77
|
+
pluginRegistry.register(new GoogleDriveLoader({
|
|
78
|
+
resolveAccessToken: async ({ workspaceId, sourceId }) => {
|
|
79
|
+
const key = `${workspaceId}--${sourceId}`;
|
|
80
|
+
const stored = await secretStore.read('oauth-google', key);
|
|
81
|
+
if (!stored) {
|
|
82
|
+
throw new NotFoundError(`Google Drive source "${sourceId}" on workspace "${workspaceId}" is not connected. `
|
|
83
|
+
+ `Authorise via POST /oauth/google/start.`);
|
|
84
|
+
}
|
|
85
|
+
// 60-second skew so we don't hand out a token about to expire mid-request.
|
|
86
|
+
const stillValidUntil = new Date(stored.expiresAt).getTime() - 60_000;
|
|
87
|
+
if (Date.now() < stillValidUntil)
|
|
88
|
+
return stored.accessToken;
|
|
89
|
+
const refreshed = await oauth.refreshAccessToken(stored.refreshToken);
|
|
90
|
+
await secretStore.write('oauth-google', key, {
|
|
91
|
+
...stored,
|
|
92
|
+
accessToken: refreshed.accessToken,
|
|
93
|
+
expiresAt: refreshed.expiresAt,
|
|
94
|
+
});
|
|
95
|
+
return refreshed.accessToken;
|
|
96
|
+
},
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
// Built after pluginRegistry is populated so plugin-shipped SKILL.md
|
|
100
|
+
// files mount under the `plugin` skill origin alongside builtins.
|
|
101
|
+
const skillRegistry = new FsSkillRegistry({
|
|
102
|
+
builtinSkillsRoot: builtinSkillsRoot,
|
|
103
|
+
pluginRegistry,
|
|
104
|
+
});
|
|
105
|
+
const eventBus = new InMemoryWorkspaceEventBus();
|
|
106
|
+
const skillRunner = new SubprocessSkillRunner({
|
|
107
|
+
skillRegistry,
|
|
108
|
+
agentBinding,
|
|
109
|
+
apiUrl,
|
|
110
|
+
runRepository,
|
|
111
|
+
eventBus,
|
|
112
|
+
referenceDirs: [
|
|
113
|
+
{ name: 'shared', path: join(builtinSkillsRoot, 'shared') },
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
const deps = composeApp({
|
|
117
|
+
workspaceRepository,
|
|
118
|
+
proposalRepository,
|
|
119
|
+
clarifyRepository,
|
|
120
|
+
decisionRepository,
|
|
121
|
+
modelRepository,
|
|
122
|
+
skillRegistry,
|
|
123
|
+
skillRunner,
|
|
124
|
+
runRepository,
|
|
125
|
+
pluginRegistry,
|
|
126
|
+
eventBus,
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
...deps,
|
|
130
|
+
secretStore,
|
|
131
|
+
...(googleOAuth ? { googleOAuth } : {}),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=composeFs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFs.js","sourceRoot":"","sources":["../src/composeFs.ts"],"names":[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CAAC,CAAA;IAEF,MAAM,QAAQ,GAAG,IAAI,yBAAyB,EAAE,CAAA;IAChD,MAAM,WAAW,GAAG,IAAI,qBAAqB,CAAC;QAC5C,aAAa;QACb,YAAY;QACZ,MAAM;QACN,aAAa;QACb,QAAQ;QACR,aAAa,EAAE;YACb,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAiB,EAAE;SAC5E;KACF,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,UAAU,CAAC;QACtB,mBAAmB;QACnB,kBAAkB;QAClB,iBAAiB;QACjB,kBAAkB;QAClB,eAAe;QACf,aAAa;QACb,WAAW;QACX,aAAa;QACb,cAAc;QACd,QAAQ;KACT,CAAC,CAAA;IACF,OAAO;QACL,GAAG,IAAI;QACP,WAAW;QACX,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ClarifyTicketRepository, Clock, DecisionRepository, ModelRepository, ProposalRepository, RunRepository, SkillRegistry, SkillRunner, WorkspaceEventBus, WorkspaceRepository } from '@braidhq/core';
|
|
2
|
+
import type { GoogleOAuth } from './infrastructure/oauth/GoogleOAuth.js';
|
|
3
|
+
import type { SecretStore } from './infrastructure/secrets/SecretStore.js';
|
|
4
|
+
import { HITLService, ModelService, PluginRegistry, SourceLoaderRunner, ValidationService, WorkspaceService } from '@braidhq/core';
|
|
5
|
+
export interface AppDependencies {
|
|
6
|
+
workspaceService: WorkspaceService;
|
|
7
|
+
hitlService: HITLService;
|
|
8
|
+
modelService: ModelService;
|
|
9
|
+
validationService: ValidationService;
|
|
10
|
+
sourceLoaderRunner: SourceLoaderRunner;
|
|
11
|
+
eventBus: WorkspaceEventBus;
|
|
12
|
+
pluginRegistry: PluginRegistry;
|
|
13
|
+
proposalRepository: ProposalRepository;
|
|
14
|
+
clarifyRepository: ClarifyTicketRepository;
|
|
15
|
+
decisionRepository: DecisionRepository;
|
|
16
|
+
modelRepository: ModelRepository;
|
|
17
|
+
workspaceRepository: WorkspaceRepository;
|
|
18
|
+
skillRegistry: SkillRegistry | undefined;
|
|
19
|
+
skillRunner: SkillRunner | undefined;
|
|
20
|
+
runRepository: RunRepository;
|
|
21
|
+
/** OAuth secret storage (file-based; pluggable for hosted deployments). */
|
|
22
|
+
secretStore?: SecretStore;
|
|
23
|
+
/**
|
|
24
|
+
* Google OAuth client. Undefined when env vars aren't set; routes
|
|
25
|
+
* respond with 503 in that case.
|
|
26
|
+
*/
|
|
27
|
+
googleOAuth?: GoogleOAuth;
|
|
28
|
+
clock: Clock;
|
|
29
|
+
}
|
|
30
|
+
export interface ComposeOptions {
|
|
31
|
+
clock?: Clock;
|
|
32
|
+
proposalRepository?: ProposalRepository;
|
|
33
|
+
clarifyRepository?: ClarifyTicketRepository;
|
|
34
|
+
decisionRepository?: DecisionRepository;
|
|
35
|
+
modelRepository?: ModelRepository;
|
|
36
|
+
workspaceRepository?: WorkspaceRepository;
|
|
37
|
+
pluginRegistry?: PluginRegistry;
|
|
38
|
+
skillRegistry?: SkillRegistry;
|
|
39
|
+
skillRunner?: SkillRunner;
|
|
40
|
+
runRepository?: RunRepository;
|
|
41
|
+
/**
|
|
42
|
+
* Pre-created event bus. Pass the same instance you wired into
|
|
43
|
+
* `SubprocessSkillRunner` so subscribers see runner events. Defaults
|
|
44
|
+
* to a fresh `InMemoryWorkspaceEventBus` for tests / in-memory boot.
|
|
45
|
+
*/
|
|
46
|
+
eventBus?: WorkspaceEventBus;
|
|
47
|
+
}
|
|
48
|
+
export declare function composeApp(options?: ComposeOptions): AppDependencies;
|
|
49
|
+
//# sourceMappingURL=composition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AAAA,OAAO,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,kBAAkB,CAAA;IACvC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC7B;AAED,wBAAgB,UAAU,CAAC,OAAO,GAAE,cAAmB,GAAG,eAAe,CA0CxE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { HITLService, InMemoryClarifyTicketRepository, InMemoryDecisionRepository, InMemoryModelRepository, InMemoryProposalRepository, InMemoryWorkspaceEventBus, InMemoryWorkspaceRepository, ModelService, noopRunRepository, PluginRegistry, SourceLoaderRunner, SystemClock, ValidationService, WorkspaceService, } from '@braidhq/core';
|
|
2
|
+
export function composeApp(options = {}) {
|
|
3
|
+
const clock = options.clock ?? new SystemClock();
|
|
4
|
+
const proposalRepository = options.proposalRepository ?? new InMemoryProposalRepository();
|
|
5
|
+
const clarifyRepository = options.clarifyRepository ?? new InMemoryClarifyTicketRepository();
|
|
6
|
+
const decisionRepository = options.decisionRepository ?? new InMemoryDecisionRepository();
|
|
7
|
+
const modelRepository = options.modelRepository ?? new InMemoryModelRepository();
|
|
8
|
+
const workspaceRepository = options.workspaceRepository ?? new InMemoryWorkspaceRepository();
|
|
9
|
+
const pluginRegistry = options.pluginRegistry ?? new PluginRegistry();
|
|
10
|
+
const eventBus = options.eventBus ?? new InMemoryWorkspaceEventBus();
|
|
11
|
+
const workspaceService = new WorkspaceService({ workspaceRepository });
|
|
12
|
+
const modelService = new ModelService({ modelRepository });
|
|
13
|
+
const validationService = new ValidationService({ pluginRegistry });
|
|
14
|
+
const sourceLoaderRunner = new SourceLoaderRunner({ pluginRegistry, clock, eventBus });
|
|
15
|
+
const hitlService = new HITLService({
|
|
16
|
+
proposalRepository,
|
|
17
|
+
clarifyRepository,
|
|
18
|
+
decisionRepository,
|
|
19
|
+
modelRepository,
|
|
20
|
+
validationService,
|
|
21
|
+
clock,
|
|
22
|
+
eventBus,
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
workspaceService,
|
|
26
|
+
hitlService,
|
|
27
|
+
modelService,
|
|
28
|
+
validationService,
|
|
29
|
+
sourceLoaderRunner,
|
|
30
|
+
eventBus,
|
|
31
|
+
pluginRegistry,
|
|
32
|
+
proposalRepository,
|
|
33
|
+
clarifyRepository,
|
|
34
|
+
decisionRepository,
|
|
35
|
+
modelRepository,
|
|
36
|
+
workspaceRepository,
|
|
37
|
+
skillRegistry: options.skillRegistry,
|
|
38
|
+
skillRunner: options.skillRunner,
|
|
39
|
+
runRepository: options.runRepository ?? noopRunRepository,
|
|
40
|
+
clock,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.js","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,0BAA0B,EAC1B,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,2BAA2B,EAC3B,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAA;AA+CtB,MAAM,UAAU,UAAU,CAAC,UAA0B,EAAE;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,WAAW,EAAE,CAAA;IAChD,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,IAAI,0BAA0B,EAAE,CAAA;IACzF,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,IAAI,+BAA+B,EAAE,CAAA;IAC5F,MAAM,kBAAkB,G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version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AgentBinding, AgentSpawnInput, SpawnInvocation } from '@braidhq/core';
|
|
2
|
+
import type { AgentBindingDescriptor } from '@braidhq/schema';
|
|
3
|
+
export declare class ClaudeCodeAgentBinding implements AgentBinding {
|
|
4
|
+
readonly descriptor: AgentBindingDescriptor;
|
|
5
|
+
constructor(descriptor: AgentBindingDescriptor);
|
|
6
|
+
resolveSpawn(input: AgentSpawnInput): SpawnInvocation;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ClaudeCodeAgentBinding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaudeCodeAgentBinding.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/agent/ClaudeCodeAgentBinding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACnF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAG7D,qBAAa,sBAAuB,YAAW,YAAY;IAC7C,QAAQ,CAAC,UAAU,EAAE,sBAAsB;gBAAlC,UAAU,EAAE,sBAAsB;IAMvD,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,eAAe;CA6CtD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
export class ClaudeCodeAgentBinding {
|
|
3
|
+
descriptor;
|
|
4
|
+
constructor(descriptor) {
|
|
5
|
+
this.descriptor = descriptor;
|
|
6
|
+
if (descriptor.kind !== 'claude-code') {
|
|
7
|
+
throw new Error(`ClaudeCodeAgentBinding expects kind="claude-code", got "${descriptor.kind}"`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
resolveSpawn(input) {
|
|
11
|
+
// When resuming, the prompt is just the user's follow-up text — claude
|
|
12
|
+
// already holds the conversation context and the original slash command.
|
|
13
|
+
const promptArg = input.resumeSessionId
|
|
14
|
+
? input.args
|
|
15
|
+
: `/${input.manifest.frontmatter.name} ${input.args}`;
|
|
16
|
+
const baseArgs = [
|
|
17
|
+
'-p',
|
|
18
|
+
promptArg,
|
|
19
|
+
'--output-format',
|
|
20
|
+
'stream-json',
|
|
21
|
+
'--verbose',
|
|
22
|
+
'--dangerously-skip-permissions',
|
|
23
|
+
'--model',
|
|
24
|
+
this.descriptor.model,
|
|
25
|
+
];
|
|
26
|
+
if (input.resumeSessionId) {
|
|
27
|
+
baseArgs.push('--resume', input.resumeSessionId);
|
|
28
|
+
}
|
|
29
|
+
if (this.descriptor.effort) {
|
|
30
|
+
baseArgs.push('--effort', this.descriptor.effort);
|
|
31
|
+
}
|
|
32
|
+
if (input.mcpConfigFile) {
|
|
33
|
+
baseArgs.push('--mcp-config', input.mcpConfigFile);
|
|
34
|
+
}
|
|
35
|
+
for (const dir of input.workspace.resolveAddDirs()) {
|
|
36
|
+
baseArgs.push('--add-dir', dir);
|
|
37
|
+
}
|
|
38
|
+
for (const extra of this.descriptor.extraArgs) {
|
|
39
|
+
baseArgs.push(extra);
|
|
40
|
+
}
|
|
41
|
+
const env = {
|
|
42
|
+
...filterEnv(process.env),
|
|
43
|
+
...this.descriptor.env,
|
|
44
|
+
BRAID_WORKSPACE: input.workspace.rootPath,
|
|
45
|
+
BRAID_WORKSPACE_ID: input.workspace.id,
|
|
46
|
+
BRAID_API_URL: input.apiUrl,
|
|
47
|
+
};
|
|
48
|
+
const invocation = input.mcpConfigFile
|
|
49
|
+
? { bin: 'claude', args: baseArgs, env, mcpConfigFile: input.mcpConfigFile }
|
|
50
|
+
: { bin: 'claude', args: baseArgs, env };
|
|
51
|
+
return invocation;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function filterEnv(source) {
|
|
55
|
+
const result = {};
|
|
56
|
+
for (const [key, value] of Object.entries(source)) {
|
|
57
|
+
if (typeof value === 'string')
|
|
58
|
+
result[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=ClaudeCodeAgentBinding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaudeCodeAgentBinding.js","sourceRoot":"","sources":["../../../src/infrastructure/agent/ClaudeCodeAgentBinding.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,MAAM,OAAO,sBAAsB;IACZ;IAArB,YAAqB,UAAkC;QAAlC,eAAU,GAAV,UAAU,CAAwB;QACrD,IAAI,UAAU,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,2DAA2D,UAAU,CAAC,IAAI,GAAG,CAAC,CAAA;QAChG,CAAC;IACH,CAAC;IAED,YAAY,CAAC,KAAsB;QACjC,uEAAuE;QACvE,yEAAyE;QACzE,MAAM,SAAS,GAAG,KAAK,CAAC,eAAe;YACrC,CAAC,CAAC,KAAK,CAAC,IAAI;YACZ,CAAC,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAA;QACvD,MAAM,QAAQ,GAAa;YACzB,IAAI;YACJ,SAAS;YACT,iBAAiB;YACjB,aAAa;YACb,WAAW;YACX,gCAAgC;YAChC,SAAS;YACT,IAAI,CAAC,UAAU,CAAC,KAA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,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AAED,SAAS,SAAS,CAAC,MAAyB;IAC1C,MAAM,MAAM,GAA2B,EAAE,CAAA;IACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAC3B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACvB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AgentBinding, RunRepository, SkillEventListener, SkillRegistry, SkillRunner, SkillRunOptions, SkillRunSubscription, Workspace, WorkspaceEventBus } from '@braidhq/core';
|
|
2
|
+
import type { AbsolutePath, SkillId, SkillRunId } from '@braidhq/schema';
|
|
3
|
+
import type { ChildProcess, SpawnOptions } from 'node:child_process';
|
|
4
|
+
export type SpawnFn = (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
|
|
5
|
+
/**
|
|
6
|
+
* Additional directories to expose under the session's `.claude/skills/`
|
|
7
|
+
* tree. Typically used for non-skill reference content (e.g. `shared/`
|
|
8
|
+
* that builtin SKILL.md files reference via `.claude/skills/shared/...`).
|
|
9
|
+
*/
|
|
10
|
+
export interface SkillReferenceDir {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly path: AbsolutePath;
|
|
13
|
+
}
|
|
14
|
+
export interface SubprocessSkillRunnerDeps {
|
|
15
|
+
readonly skillRegistry: SkillRegistry;
|
|
16
|
+
readonly agentBinding: AgentBinding;
|
|
17
|
+
readonly apiUrl: string;
|
|
18
|
+
/** Required: runs persist their event log here as the source of truth for replays. */
|
|
19
|
+
readonly runRepository: RunRepository;
|
|
20
|
+
readonly spawn?: SpawnFn;
|
|
21
|
+
readonly clock?: () => string;
|
|
22
|
+
/** Extra directories symlinked alongside skills (e.g. shared reference docs). */
|
|
23
|
+
readonly referenceDirs?: readonly SkillReferenceDir[];
|
|
24
|
+
/** Delete the per-run session directory after the run. Default `true`. */
|
|
25
|
+
readonly cleanupSession?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Optional pub/sub for workspace-scoped notifications. Used by Studio
|
|
28
|
+
* to invalidate run / proposal lists in real time without polling.
|
|
29
|
+
* Tests can leave this undefined.
|
|
30
|
+
*/
|
|
31
|
+
readonly eventBus?: WorkspaceEventBus;
|
|
32
|
+
}
|
|
33
|
+
export declare class SubprocessSkillRunner implements SkillRunner {
|
|
34
|
+
private readonly deps;
|
|
35
|
+
private readonly running;
|
|
36
|
+
/** sessionId → cwd for resuming. claude needs the same cwd between turns. */
|
|
37
|
+
private readonly sessionDirs;
|
|
38
|
+
private readonly subscribers;
|
|
39
|
+
/** How many events have been emitted (and persisted) per run so far. */
|
|
40
|
+
private readonly positions;
|
|
41
|
+
constructor(deps: SubprocessSkillRunnerDeps);
|
|
42
|
+
start(workspace: Workspace, skillId: SkillId, args: string, options?: SkillRunOptions): Promise<SkillRunId>;
|
|
43
|
+
subscribe(runId: SkillRunId, listener: SkillEventListener): SkillRunSubscription;
|
|
44
|
+
isActive(runId: SkillRunId): boolean;
|
|
45
|
+
cancel(runId: SkillRunId): Promise<void>;
|
|
46
|
+
forgetSession(sessionId: string): Promise<void>;
|
|
47
|
+
private drain;
|
|
48
|
+
private emit;
|
|
49
|
+
private resolveSessionDir;
|
|
50
|
+
private recoverSessionDir;
|
|
51
|
+
private buildSessionDir;
|
|
52
|
+
private now;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=SubprocessSkillRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubprocessSkillRunner.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/agent/SubprocessSkillRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,eAAe,EACf,oBAAo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