@braidhq/server 0.0.1 → 0.1.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 +136 -0
- package/dist/app.d.ts +19 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +121 -3
- package/dist/app.js.map +1 -1
- package/dist/composeFs.d.ts +41 -6
- package/dist/composeFs.d.ts.map +1 -1
- package/dist/composeFs.js +234 -52
- package/dist/composeFs.js.map +1 -1
- package/dist/composition.d.ts +86 -2
- package/dist/composition.d.ts.map +1 -1
- package/dist/composition.js +71 -1
- package/dist/composition.js.map +1 -1
- package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts +21 -0
- package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts.map +1 -1
- package/dist/infrastructure/agent/SubprocessSkillRunner.js +35 -3
- package/dist/infrastructure/agent/SubprocessSkillRunner.js.map +1 -1
- package/dist/infrastructure/agent/mcpConfig.d.ts +25 -5
- package/dist/infrastructure/agent/mcpConfig.d.ts.map +1 -1
- package/dist/infrastructure/agent/mcpConfig.js +22 -14
- package/dist/infrastructure/agent/mcpConfig.js.map +1 -1
- package/dist/infrastructure/auth/AccessPolicy.d.ts +112 -0
- package/dist/infrastructure/auth/AccessPolicy.d.ts.map +1 -0
- package/dist/infrastructure/auth/AccessPolicy.js +184 -0
- package/dist/infrastructure/auth/AccessPolicy.js.map +1 -0
- package/dist/infrastructure/auth/SessionStore.d.ts +40 -0
- package/dist/infrastructure/auth/SessionStore.d.ts.map +1 -0
- package/dist/infrastructure/auth/SessionStore.js +107 -0
- package/dist/infrastructure/auth/SessionStore.js.map +1 -0
- package/dist/infrastructure/auth/ensureApprovedEmails.d.ts +16 -0
- package/dist/infrastructure/auth/ensureApprovedEmails.d.ts.map +1 -0
- package/dist/infrastructure/auth/ensureApprovedEmails.js +20 -0
- package/dist/infrastructure/auth/ensureApprovedEmails.js.map +1 -0
- package/dist/infrastructure/env.d.ts +11 -0
- package/dist/infrastructure/env.d.ts.map +1 -0
- package/dist/infrastructure/env.js +20 -0
- package/dist/infrastructure/env.js.map +1 -0
- package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts +300 -0
- package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsBatchPlanRepository.js +42 -0
- package/dist/infrastructure/fs/FsBatchPlanRepository.js.map +1 -0
- package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts.map +1 -1
- package/dist/infrastructure/fs/FsClarifyTicketRepository.js +7 -1
- package/dist/infrastructure/fs/FsClarifyTicketRepository.js.map +1 -1
- package/dist/infrastructure/fs/FsGraphSerializer.d.ts +629 -0
- package/dist/infrastructure/fs/FsGraphSerializer.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsGraphSerializer.js +60 -0
- package/dist/infrastructure/fs/FsGraphSerializer.js.map +1 -0
- package/dist/infrastructure/fs/FsProposalRepository.d.ts.map +1 -1
- package/dist/infrastructure/fs/FsProposalRepository.js +8 -0
- package/dist/infrastructure/fs/FsProposalRepository.js.map +1 -1
- package/dist/infrastructure/fs/FsRunRepository.d.ts +4 -1
- package/dist/infrastructure/fs/FsRunRepository.d.ts.map +1 -1
- package/dist/infrastructure/fs/FsRunRepository.js +75 -3
- package/dist/infrastructure/fs/FsRunRepository.js.map +1 -1
- package/dist/infrastructure/fs/FsSkillRegistry.d.ts.map +1 -1
- package/dist/infrastructure/fs/FsSkillRegistry.js +15 -3
- package/dist/infrastructure/fs/FsSkillRegistry.js.map +1 -1
- package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts +19 -0
- package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsSourceUnitDigest.js +58 -0
- package/dist/infrastructure/fs/FsSourceUnitDigest.js.map +1 -0
- package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts +30 -0
- package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts.map +1 -0
- package/dist/infrastructure/fs/FsSourceUnitStateRepository.js +87 -0
- package/dist/infrastructure/fs/FsSourceUnitStateRepository.js.map +1 -0
- package/dist/infrastructure/fs/FsWorkspaceRepository.d.ts.map +1 -1
- package/dist/infrastructure/fs/FsWorkspaceRepository.js +12 -3
- package/dist/infrastructure/fs/FsWorkspaceRepository.js.map +1 -1
- package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts +15 -0
- package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts.map +1 -0
- package/dist/infrastructure/fs/WorkspaceDiscovery.js +46 -0
- package/dist/infrastructure/fs/WorkspaceDiscovery.js.map +1 -0
- package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts +26 -2
- package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts.map +1 -1
- package/dist/infrastructure/fs/WorkspaceRegistryFile.js +109 -5
- package/dist/infrastructure/fs/WorkspaceRegistryFile.js.map +1 -1
- package/dist/infrastructure/fs/intentScan.d.ts +9 -0
- package/dist/infrastructure/fs/intentScan.d.ts.map +1 -0
- package/dist/infrastructure/fs/intentScan.js +135 -0
- package/dist/infrastructure/fs/intentScan.js.map +1 -0
- package/dist/infrastructure/fs/paths.d.ts +14 -0
- package/dist/infrastructure/fs/paths.d.ts.map +1 -1
- package/dist/infrastructure/fs/paths.js +43 -0
- package/dist/infrastructure/fs/paths.js.map +1 -1
- package/dist/infrastructure/fs/productManifestWriter.d.ts +1 -1
- package/dist/infrastructure/fs/productManifestWriter.d.ts.map +1 -1
- package/dist/infrastructure/fs/productManifestWriter.js +1 -3
- package/dist/infrastructure/fs/productManifestWriter.js.map +1 -1
- package/dist/infrastructure/git/GitWorkspaceHistory.d.ts +18 -0
- package/dist/infrastructure/git/GitWorkspaceHistory.d.ts.map +1 -0
- package/dist/infrastructure/git/GitWorkspaceHistory.js +303 -0
- package/dist/infrastructure/git/GitWorkspaceHistory.js.map +1 -0
- package/dist/infrastructure/git/commitMessage.d.ts +4 -0
- package/dist/infrastructure/git/commitMessage.d.ts.map +1 -0
- package/dist/infrastructure/git/commitMessage.js +71 -0
- package/dist/infrastructure/git/commitMessage.js.map +1 -0
- package/dist/infrastructure/oauth/GoogleOAuth.d.ts +48 -1
- package/dist/infrastructure/oauth/GoogleOAuth.d.ts.map +1 -1
- package/dist/infrastructure/oauth/GoogleOAuth.js +68 -0
- package/dist/infrastructure/oauth/GoogleOAuth.js.map +1 -1
- 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 +23 -0
- package/dist/infrastructure/users/UserRegistryFile.d.ts.map +1 -0
- package/dist/infrastructure/users/UserRegistryFile.js +91 -0
- package/dist/infrastructure/users/UserRegistryFile.js.map +1 -0
- package/dist/infrastructure/users/ensureLocalUser.d.ts +15 -0
- package/dist/infrastructure/users/ensureLocalUser.d.ts.map +1 -0
- package/dist/infrastructure/users/ensureLocalUser.js +38 -0
- package/dist/infrastructure/users/ensureLocalUser.js.map +1 -0
- package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts +9 -0
- package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts.map +1 -0
- package/dist/infrastructure/users/ensureWorkspaceOwners.js +22 -0
- package/dist/infrastructure/users/ensureWorkspaceOwners.js.map +1 -0
- package/dist/middleware/auth.d.ts +29 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +81 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/cors.js +1 -1
- package/dist/middleware/cors.js.map +1 -1
- package/dist/middleware/requireAdmin.d.ts +10 -0
- package/dist/middleware/requireAdmin.d.ts.map +1 -0
- package/dist/middleware/requireAdmin.js +24 -0
- package/dist/middleware/requireAdmin.js.map +1 -0
- package/dist/middleware/userId.d.ts +16 -0
- package/dist/middleware/userId.d.ts.map +1 -0
- package/dist/middleware/userId.js +27 -0
- package/dist/middleware/userId.js.map +1 -0
- package/dist/middleware/workspaceAccess.d.ts +47 -0
- package/dist/middleware/workspaceAccess.d.ts.map +1 -0
- package/dist/middleware/workspaceAccess.js +86 -0
- package/dist/middleware/workspaceAccess.js.map +1 -0
- package/dist/policy/Capability.d.ts +12 -0
- package/dist/policy/Capability.d.ts.map +1 -0
- package/dist/policy/Capability.js +31 -0
- package/dist/policy/Capability.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 +23 -0
- package/dist/policy/PermissionRegistry.d.ts.map +1 -0
- package/dist/policy/PermissionRegistry.js +27 -0
- package/dist/policy/PermissionRegistry.js.map +1 -0
- package/dist/policy/ViewerContext.d.ts +27 -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 +52 -0
- package/dist/policy/checks.js.map +1 -0
- package/dist/policy/defaultRegistry.d.ts +10 -0
- package/dist/policy/defaultRegistry.d.ts.map +1 -0
- package/dist/policy/defaultRegistry.js +16 -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 +198 -0
- package/dist/routes/_shared.d.ts.map +1 -0
- package/dist/routes/_shared.js +29 -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 +227 -0
- package/dist/routes/admin.js.map +1 -0
- package/dist/routes/auth.d.ts +33 -0
- package/dist/routes/auth.d.ts.map +1 -0
- package/dist/routes/auth.js +170 -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/clarify.d.ts +4 -3
- package/dist/routes/clarify.d.ts.map +1 -1
- package/dist/routes/clarify.js +247 -57
- package/dist/routes/clarify.js.map +1 -1
- package/dist/routes/decisions.d.ts +2 -2
- package/dist/routes/decisions.d.ts.map +1 -1
- package/dist/routes/decisions.js +50 -12
- package/dist/routes/decisions.js.map +1 -1
- package/dist/routes/edges.d.ts +2 -2
- package/dist/routes/edges.d.ts.map +1 -1
- package/dist/routes/edges.js +35 -13
- 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 +88 -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 +75 -19
- package/dist/routes/nodes.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 +4 -3
- package/dist/routes/proposals.d.ts.map +1 -1
- package/dist/routes/proposals.js +170 -41
- package/dist/routes/proposals.js.map +1 -1
- package/dist/routes/runs.d.ts.map +1 -1
- package/dist/routes/runs.js +52 -1
- 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 +161 -0
- package/dist/routes/skillInputOptions.js.map +1 -0
- package/dist/routes/skills.d.ts +2 -2
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +89 -19
- 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 +29 -0
- package/dist/routes/sourceLoaders.js.map +1 -0
- package/dist/routes/sourceUnitStates.d.ts +7 -0
- package/dist/routes/sourceUnitStates.d.ts.map +1 -0
- package/dist/routes/sourceUnitStates.js +45 -0
- package/dist/routes/sourceUnitStates.js.map +1 -0
- package/dist/routes/users.d.ts +9 -0
- package/dist/routes/users.d.ts.map +1 -0
- package/dist/routes/users.js +127 -0
- package/dist/routes/users.js.map +1 -0
- 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 +19 -1
- package/dist/routes/workspaces.d.ts.map +1 -1
- package/dist/routes/workspaces.js +161 -45
- package/dist/routes/workspaces.js.map +1 -1
- package/dist/server.js +69 -25
- package/dist/server.js.map +1 -1
- package/package.json +48 -31
- package/LICENSE +0 -21
- 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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { UserId } from '@braidhq/schema';
|
|
2
|
+
export interface IssuedSession {
|
|
3
|
+
readonly token: string;
|
|
4
|
+
readonly userId: UserId;
|
|
5
|
+
readonly expiresAt?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ResolvedSession {
|
|
8
|
+
readonly userId: UserId;
|
|
9
|
+
readonly expiresAt?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Hashed session tokens persisted to `${BRAID_HOME}/sessions.json`.
|
|
13
|
+
*
|
|
14
|
+
* Token format: 32 random bytes encoded as `base64url` (43 chars). The
|
|
15
|
+
* plain text is returned exactly once at issuance time; the server
|
|
16
|
+
* stores SHA-256 of it. A leaked sessions.json therefore cannot be
|
|
17
|
+
* replayed as a Bearer header.
|
|
18
|
+
*
|
|
19
|
+
* No rotation, no rolling expiry, no per-device tracking: this is the
|
|
20
|
+
* minimum useful surface for v0.2. Phase D / future remote-server work
|
|
21
|
+
* can revisit if needed.
|
|
22
|
+
*/
|
|
23
|
+
export declare class SessionStore {
|
|
24
|
+
private readonly filePath;
|
|
25
|
+
constructor(filePath: string);
|
|
26
|
+
issue(userId: UserId, options?: {
|
|
27
|
+
ttlSeconds?: number;
|
|
28
|
+
}): Promise<IssuedSession>;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve a Bearer token to its session. Updates `lastUsedAt` as a
|
|
31
|
+
* side effect; not strictly required for correctness but useful for
|
|
32
|
+
* the future "active sessions" admin view.
|
|
33
|
+
*/
|
|
34
|
+
resolve(token: string): Promise<ResolvedSession | null>;
|
|
35
|
+
revoke(token: string): Promise<void>;
|
|
36
|
+
revokeAllForUser(userId: UserId): Promise<void>;
|
|
37
|
+
private read;
|
|
38
|
+
private write;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=SessionStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionStore.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/auth/SessionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AA4B7C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,MAAM;IAEvC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IAa1F;;;;OAIG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAevD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASpC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAQvC,IAAI;YAeJ,KAAK;CAIpB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
2
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
4
|
+
import { ValidationError } from '@braidhq/core';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
const SessionRow = z.object({
|
|
7
|
+
/**
|
|
8
|
+
* SHA-256 hex of the actual token. The plaintext is shown to the
|
|
9
|
+
* client exactly once at issuance time; the server only ever sees
|
|
10
|
+
* the hash thereafter. Constant-time compare is unnecessary for a
|
|
11
|
+
* pre-image lookup on hex strings, which is what `findByToken` does.
|
|
12
|
+
*/
|
|
13
|
+
tokenHash: z.string().length(64),
|
|
14
|
+
userId: z.string().min(1),
|
|
15
|
+
createdAt: z.string().datetime({ offset: true }),
|
|
16
|
+
expiresAt: z.string().datetime({ offset: true }).optional(),
|
|
17
|
+
lastUsedAt: z.string().datetime({ offset: true }).optional(),
|
|
18
|
+
});
|
|
19
|
+
const StoreContent = z.object({
|
|
20
|
+
sessions: z.array(SessionRow).default([]),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Hashed session tokens persisted to `${BRAID_HOME}/sessions.json`.
|
|
24
|
+
*
|
|
25
|
+
* Token format: 32 random bytes encoded as `base64url` (43 chars). The
|
|
26
|
+
* plain text is returned exactly once at issuance time; the server
|
|
27
|
+
* stores SHA-256 of it. A leaked sessions.json therefore cannot be
|
|
28
|
+
* replayed as a Bearer header.
|
|
29
|
+
*
|
|
30
|
+
* No rotation, no rolling expiry, no per-device tracking: this is the
|
|
31
|
+
* minimum useful surface for v0.2. Phase D / future remote-server work
|
|
32
|
+
* can revisit if needed.
|
|
33
|
+
*/
|
|
34
|
+
export class SessionStore {
|
|
35
|
+
filePath;
|
|
36
|
+
constructor(filePath) {
|
|
37
|
+
this.filePath = filePath;
|
|
38
|
+
}
|
|
39
|
+
async issue(userId, options = {}) {
|
|
40
|
+
const content = await this.read();
|
|
41
|
+
const token = randomBytes(32).toString('base64url');
|
|
42
|
+
const tokenHash = sha256Hex(token);
|
|
43
|
+
const createdAt = new Date().toISOString();
|
|
44
|
+
const expiresAt = options.ttlSeconds
|
|
45
|
+
? new Date(Date.now() + options.ttlSeconds * 1000).toISOString()
|
|
46
|
+
: undefined;
|
|
47
|
+
content.sessions.push({ tokenHash, userId, createdAt, ...(expiresAt ? { expiresAt } : {}) });
|
|
48
|
+
await this.write(content);
|
|
49
|
+
return { token, userId, ...(expiresAt ? { expiresAt } : {}) };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Resolve a Bearer token to its session. Updates `lastUsedAt` as a
|
|
53
|
+
* side effect; not strictly required for correctness but useful for
|
|
54
|
+
* the future "active sessions" admin view.
|
|
55
|
+
*/
|
|
56
|
+
async resolve(token) {
|
|
57
|
+
if (!token || token.length === 0)
|
|
58
|
+
return null;
|
|
59
|
+
const tokenHash = sha256Hex(token);
|
|
60
|
+
const content = await this.read();
|
|
61
|
+
const row = content.sessions.find(s => s.tokenHash === tokenHash);
|
|
62
|
+
if (!row)
|
|
63
|
+
return null;
|
|
64
|
+
if (row.expiresAt && Date.parse(row.expiresAt) < Date.now())
|
|
65
|
+
return null;
|
|
66
|
+
row.lastUsedAt = new Date().toISOString();
|
|
67
|
+
await this.write(content);
|
|
68
|
+
return { userId: row.userId, ...(row.expiresAt ? { expiresAt: row.expiresAt } : {}) };
|
|
69
|
+
}
|
|
70
|
+
async revoke(token) {
|
|
71
|
+
const tokenHash = sha256Hex(token);
|
|
72
|
+
const content = await this.read();
|
|
73
|
+
const filtered = content.sessions.filter(s => s.tokenHash !== tokenHash);
|
|
74
|
+
if (filtered.length === content.sessions.length)
|
|
75
|
+
return;
|
|
76
|
+
await this.write({ sessions: filtered });
|
|
77
|
+
}
|
|
78
|
+
async revokeAllForUser(userId) {
|
|
79
|
+
const content = await this.read();
|
|
80
|
+
const filtered = content.sessions.filter(s => s.userId !== userId);
|
|
81
|
+
if (filtered.length === content.sessions.length)
|
|
82
|
+
return;
|
|
83
|
+
await this.write({ sessions: filtered });
|
|
84
|
+
}
|
|
85
|
+
async read() {
|
|
86
|
+
try {
|
|
87
|
+
const raw = await readFile(this.filePath, 'utf-8');
|
|
88
|
+
const parsed = StoreContent.safeParse(JSON.parse(raw));
|
|
89
|
+
if (!parsed.success)
|
|
90
|
+
throw new ValidationError(`Invalid session store at "${this.filePath}": ${parsed.error.message}`);
|
|
91
|
+
return parsed.data;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error.code === 'ENOENT')
|
|
95
|
+
return { sessions: [] };
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async write(content) {
|
|
100
|
+
await mkdir(dirname(this.filePath), { recursive: true });
|
|
101
|
+
await writeFile(this.filePath, `${JSON.stringify(content, null, 2)}\n`, 'utf-8');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function sha256Hex(input) {
|
|
105
|
+
return createHash('sha256').update(input).digest('hex');
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=SessionStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionStore.js","sourceRoot":"","sources":["../../../src/infrastructure/auth/SessionStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAChD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC3D,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,C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EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACxD,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClF,CAAC;CACF;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { UserRegistryFile } from '../users/UserRegistryFile.js';
|
|
2
|
+
import type { AccessPolicy } from './AccessPolicy.js';
|
|
3
|
+
/**
|
|
4
|
+
* Back-fills `approvedEmails` from existing users.json entries.
|
|
5
|
+
*
|
|
6
|
+
* Without this, accounts created before the approvedEmails feature
|
|
7
|
+
* existed (or while the invite-was-consumed bug was live) would be
|
|
8
|
+
* stuck behind Gate-1 even though they hold a valid user record. Every
|
|
9
|
+
* email we see in the registry must be persistently approved going
|
|
10
|
+
* forward; this is the one-shot reconciliation.
|
|
11
|
+
*
|
|
12
|
+
* Idempotent: AccessPolicy.approveEmail no-ops when the email is
|
|
13
|
+
* already there, so re-running on every boot is cheap.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ensureApprovedEmails(userRegistry: UserRegistryFile, accessPolicy: AccessPolicy): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=ensureApprovedEmails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureApprovedEmails.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/auth/ensureApprovedEmails.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Back-fills `approvedEmails` from existing users.json entries.
|
|
3
|
+
*
|
|
4
|
+
* Without this, accounts created before the approvedEmails feature
|
|
5
|
+
* existed (or while the invite-was-consumed bug was live) would be
|
|
6
|
+
* stuck behind Gate-1 even though they hold a valid user record. Every
|
|
7
|
+
* email we see in the registry must be persistently approved going
|
|
8
|
+
* forward; this is the one-shot reconciliation.
|
|
9
|
+
*
|
|
10
|
+
* Idempotent: AccessPolicy.approveEmail no-ops when the email is
|
|
11
|
+
* already there, so re-running on every boot is cheap.
|
|
12
|
+
*/
|
|
13
|
+
export async function ensureApprovedEmails(userRegistry, accessPolicy) {
|
|
14
|
+
const users = await userRegistry.list();
|
|
15
|
+
for (const user of users) {
|
|
16
|
+
if (user.email)
|
|
17
|
+
await accessPolicy.approveEmail(user.email);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ensureApprovedEmails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureApprovedEmails.js","sourceRoot":"","sources":["../../../src/infrastructure/auth/ensureApprovedEmails.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,YAA8B,EAC9B,YAA0B;IAE1B,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAA;IACvC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,KAAK;YACZ,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a boolean env var. Canonical form is `true` / `false`; we also
|
|
3
|
+
* accept the common YAML / shell idioms (`yes` / `no`, `on` / `off`,
|
|
4
|
+
* `1` / `0`) so existing `.env` files don't break on the rename.
|
|
5
|
+
*
|
|
6
|
+
* Returns `defaultValue` when the variable is unset or the literal is
|
|
7
|
+
* unrecognised (silent fall-through — we don't want a typo in env to
|
|
8
|
+
* crash the server boot).
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseBoolEnv(value: string | undefined, defaultValue: boolean): boolean;
|
|
11
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/infrastructure/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAStF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a boolean env var. Canonical form is `true` / `false`; we also
|
|
3
|
+
* accept the common YAML / shell idioms (`yes` / `no`, `on` / `off`,
|
|
4
|
+
* `1` / `0`) so existing `.env` files don't break on the rename.
|
|
5
|
+
*
|
|
6
|
+
* Returns `defaultValue` when the variable is unset or the literal is
|
|
7
|
+
* unrecognised (silent fall-through — we don't want a typo in env to
|
|
8
|
+
* crash the server boot).
|
|
9
|
+
*/
|
|
10
|
+
export function parseBoolEnv(value, defaultValue) {
|
|
11
|
+
if (value === undefined)
|
|
12
|
+
return defaultValue;
|
|
13
|
+
const lower = value.trim().toLowerCase();
|
|
14
|
+
if (lower === 'true' || lower === '1' || lower === 'yes' || lower === 'on')
|
|
15
|
+
return true;
|
|
16
|
+
if (lower === 'false' || lower === '0' || lower === 'no' || lower === 'off')
|
|
17
|
+
return false;
|
|
18
|
+
return defaultValue;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/infrastructure/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,KAAyB,EAAE,YAAqB;IAC3E,IAAI,KAAK,KAAK,SAAS;QACrB,OAAO,YAAY,CAAA;IACrB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACxC,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI;QACxE,OAAO,IAAI,CAAA;IACb,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK;QACzE,OAAO,KAAK,CAAA;IACd,OAAO,YAAY,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import type { BatchPlanRepository, Workspace } from '@braidhq/core';
|
|
2
|
+
import { BatchPlan } from '@braidhq/core';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export declare const BATCH_PLAN_VERSION = 1;
|
|
5
|
+
export declare const BatchPlanFile: z.ZodObject<{
|
|
6
|
+
version: z.ZodNumber;
|
|
7
|
+
plan: z.ZodObject<{
|
|
8
|
+
id: z.ZodBranded<z.ZodString, "BatchPlanId">;
|
|
9
|
+
workspaceId: z.ZodBranded<z.ZodString, "WorkspaceId">;
|
|
10
|
+
createdAt: z.ZodString;
|
|
11
|
+
updatedAt: z.ZodString;
|
|
12
|
+
mode: z.ZodEnum<["intent", "derive"]>;
|
|
13
|
+
status: z.ZodEnum<["idle", "deriving", "running", "completed", "failed", "stopped", "archived"]>;
|
|
14
|
+
autoApply: z.ZodBoolean;
|
|
15
|
+
baselineTag: z.ZodOptional<z.ZodString>;
|
|
16
|
+
units: z.ZodArray<z.ZodObject<{
|
|
17
|
+
id: z.ZodBranded<z.ZodString, "PlanUnitId">;
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
description: z.ZodString;
|
|
20
|
+
sourceId: z.ZodOptional<z.ZodBranded<z.ZodString, "SourceId">>;
|
|
21
|
+
scopeHint: z.ZodOptional<z.ZodString>;
|
|
22
|
+
status: z.ZodEnum<["pending", "running", "completed", "failed", "skipped"]>;
|
|
23
|
+
skillRunId: z.ZodOptional<z.ZodBranded<z.ZodString, "SkillRunId">>;
|
|
24
|
+
startedAt: z.ZodOptional<z.ZodString>;
|
|
25
|
+
completedAt: z.ZodOptional<z.ZodString>;
|
|
26
|
+
proposalIds: z.ZodDefault<z.ZodArray<z.ZodBranded<z.ZodString, "ProposalId">, "many">>;
|
|
27
|
+
clarifyTicketIds: z.ZodDefault<z.ZodArray<z.ZodBranded<z.ZodString, "ClarifyTicketId">, "many">>;
|
|
28
|
+
error: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
description: string;
|
|
31
|
+
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
|
32
|
+
id: string & z.BRAND<"PlanUnitId">;
|
|
33
|
+
name: string;
|
|
34
|
+
proposalIds: (string & z.BRAND<"ProposalId">)[];
|
|
35
|
+
clarifyTicketIds: (string & z.BRAND<"ClarifyTicketId">)[];
|
|
36
|
+
sourceId?: (string & z.BRAND<"SourceId">) | undefined;
|
|
37
|
+
scopeHint?: string | undefined;
|
|
38
|
+
skillRunId?: (string & z.BRAND<"SkillRunId">) | undefined;
|
|
39
|
+
startedAt?: string | undefined;
|
|
40
|
+
completedAt?: string | undefined;
|
|
41
|
+
error?: string | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
description: string;
|
|
44
|
+
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
sourceId?: string | undefined;
|
|
48
|
+
scopeHint?: string | undefined;
|
|
49
|
+
skillRunId?: string | undefined;
|
|
50
|
+
startedAt?: string | undefined;
|
|
51
|
+
completedAt?: string | undefined;
|
|
52
|
+
proposalIds?: string[] | undefined;
|
|
53
|
+
clarifyTicketIds?: string[] | undefined;
|
|
54
|
+
error?: string | undefined;
|
|
55
|
+
}>, "many">;
|
|
56
|
+
running: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
unitId: z.ZodBranded<z.ZodString, "PlanUnitId">;
|
|
58
|
+
skillRunId: z.ZodBranded<z.ZodString, "SkillRunId">;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
skillRunId: string & z.BRAND<"SkillRunId">;
|
|
61
|
+
unitId: string & z.BRAND<"PlanUnitId">;
|
|
62
|
+
}, {
|
|
63
|
+
skillRunId: string;
|
|
64
|
+
unitId: string;
|
|
65
|
+
}>>;
|
|
66
|
+
error: z.ZodOptional<z.ZodString>;
|
|
67
|
+
checkpointPhases: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
68
|
+
status: z.ZodEnum<["running", "completed", "failed"]>;
|
|
69
|
+
unitIds: z.ZodArray<z.ZodBranded<z.ZodString, "PlanUnitId">, "many">;
|
|
70
|
+
startedAt: z.ZodOptional<z.ZodString>;
|
|
71
|
+
completedAt: z.ZodOptional<z.ZodString>;
|
|
72
|
+
skillRunId: z.ZodOptional<z.ZodBranded<z.ZodString, "SkillRunId">>;
|
|
73
|
+
error: z.ZodOptional<z.ZodString>;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
status: "running" | "completed" | "failed";
|
|
76
|
+
unitIds: (string & z.BRAND<"PlanUnitId">)[];
|
|
77
|
+
skillRunId?: (string & z.BRAND<"SkillRunId">) | undefined;
|
|
78
|
+
startedAt?: string | undefined;
|
|
79
|
+
completedAt?: string | undefined;
|
|
80
|
+
error?: string | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
status: "running" | "completed" | "failed";
|
|
83
|
+
unitIds: string[];
|
|
84
|
+
skillRunId?: string | undefined;
|
|
85
|
+
startedAt?: string | undefined;
|
|
86
|
+
completedAt?: string | undefined;
|
|
87
|
+
error?: string | undefined;
|
|
88
|
+
}>, "many">>;
|
|
89
|
+
batchPolicy: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
perUnitSkillId: z.ZodBranded<z.ZodString, "SkillId">;
|
|
91
|
+
perUnitLabel: z.ZodOptional<z.ZodString>;
|
|
92
|
+
checkpointSkillId: z.ZodOptional<z.ZodBranded<z.ZodString, "SkillId">>;
|
|
93
|
+
checkpointLabel: z.ZodOptional<z.ZodString>;
|
|
94
|
+
checkpointChunkSize: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
checkpointRunAtEnd: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
perUnitSkillId: string & z.BRAND<"SkillId">;
|
|
98
|
+
perUnitLabel?: string | undefined;
|
|
99
|
+
checkpointSkillId?: (string & z.BRAND<"SkillId">) | undefined;
|
|
100
|
+
checkpointLabel?: string | undefined;
|
|
101
|
+
checkpointChunkSize?: number | undefined;
|
|
102
|
+
checkpointRunAtEnd?: boolean | undefined;
|
|
103
|
+
}, {
|
|
104
|
+
perUnitSkillId: string;
|
|
105
|
+
perUnitLabel?: string | undefined;
|
|
106
|
+
checkpointSkillId?: string | undefined;
|
|
107
|
+
checkpointLabel?: string | undefined;
|
|
108
|
+
checkpointChunkSize?: number | undefined;
|
|
109
|
+
checkpointRunAtEnd?: boolean | undefined;
|
|
110
|
+
}>>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
status: "running" | "completed" | "failed" | "idle" | "deriving" | "stopped" | "archived";
|
|
113
|
+
id: string & z.BRAND<"BatchPlanId">;
|
|
114
|
+
workspaceId: string & z.BRAND<"WorkspaceId">;
|
|
115
|
+
createdAt: string;
|
|
116
|
+
updatedAt: string;
|
|
117
|
+
mode: "intent" | "derive";
|
|
118
|
+
autoApply: boolean;
|
|
119
|
+
units: {
|
|
120
|
+
description: string;
|
|
121
|
+
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
|
122
|
+
id: string & z.BRAND<"PlanUnitId">;
|
|
123
|
+
name: string;
|
|
124
|
+
proposalIds: (string & z.BRAND<"ProposalId">)[];
|
|
125
|
+
clarifyTicketIds: (string & z.BRAND<"ClarifyTicketId">)[];
|
|
126
|
+
sourceId?: (string & z.BRAND<"SourceId">) | undefined;
|
|
127
|
+
scopeHint?: string | undefined;
|
|
128
|
+
skillRunId?: (string & z.BRAND<"SkillRunId">) | undefined;
|
|
129
|
+
startedAt?: string | undefined;
|
|
130
|
+
completedAt?: string | undefined;
|
|
131
|
+
error?: string | undefined;
|
|
132
|
+
}[];
|
|
133
|
+
checkpointPhases: {
|
|
134
|
+
status: "running" | "completed" | "failed";
|
|
135
|
+
unitIds: (string & z.BRAND<"PlanUnitId">)[];
|
|
136
|
+
skillRunId?: (string & z.BRAND<"SkillRunId">) | undefined;
|
|
137
|
+
startedAt?: string | undefined;
|
|
138
|
+
completedAt?: string | undefined;
|
|
139
|
+
error?: string | undefined;
|
|
140
|
+
}[];
|
|
141
|
+
running?: {
|
|
142
|
+
skillRunId: string & z.BRAND<"SkillRunId">;
|
|
143
|
+
unitId: string & z.BRAND<"PlanUnitId">;
|
|
144
|
+
} | undefined;
|
|
145
|
+
error?: string | undefined;
|
|
146
|
+
baselineTag?: string | undefined;
|
|
147
|
+
batchPolicy?: {
|
|
148
|
+
perUnitSkillId: string & z.BRAND<"SkillId">;
|
|
149
|
+
perUnitLabel?: string | undefined;
|
|
150
|
+
checkpointSkillId?: (string & z.BRAND<"SkillId">) | undefined;
|
|
151
|
+
checkpointLabel?: string | undefined;
|
|
152
|
+
checkpointChunkSize?: number | undefined;
|
|
153
|
+
checkpointRunAtEnd?: boolean | undefined;
|
|
154
|
+
} | undefined;
|
|
155
|
+
}, {
|
|
156
|
+
status: "running" | "completed" | "failed" | "idle" | "deriving" | "stopped" | "archived";
|
|
157
|
+
id: string;
|
|
158
|
+
workspaceId: string;
|
|
159
|
+
createdAt: string;
|
|
160
|
+
updatedAt: string;
|
|
161
|
+
mode: "intent" | "derive";
|
|
162
|
+
autoApply: boolean;
|
|
163
|
+
units: {
|
|
164
|
+
description: string;
|
|
165
|
+
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
|
166
|
+
id: string;
|
|
167
|
+
name: string;
|
|
168
|
+
sourceId?: string | undefined;
|
|
169
|
+
scopeHint?: string | undefined;
|
|
170
|
+
skillRunId?: string | undefined;
|
|
171
|
+
startedAt?: string | undefined;
|
|
172
|
+
completedAt?: string | undefined;
|
|
173
|
+
proposalIds?: string[] | undefined;
|
|
174
|
+
clarifyTicketIds?: string[] | undefined;
|
|
175
|
+
error?: string | undefined;
|
|
176
|
+
}[];
|
|
177
|
+
running?: {
|
|
178
|
+
skillRunId: string;
|
|
179
|
+
unitId: string;
|
|
180
|
+
} | undefined;
|
|
181
|
+
error?: string | undefined;
|
|
182
|
+
baselineTag?: string | undefined;
|
|
183
|
+
checkpointPhases?: {
|
|
184
|
+
status: "running" | "completed" | "failed";
|
|
185
|
+
unitIds: string[];
|
|
186
|
+
skillRunId?: string | undefined;
|
|
187
|
+
startedAt?: string | undefined;
|
|
188
|
+
completedAt?: string | undefined;
|
|
189
|
+
error?: string | undefined;
|
|
190
|
+
}[] | undefined;
|
|
191
|
+
batchPolicy?: {
|
|
192
|
+
perUnitSkillId: string;
|
|
193
|
+
perUnitLabel?: string | undefined;
|
|
194
|
+
checkpointSkillId?: string | undefined;
|
|
195
|
+
checkpointLabel?: string | undefined;
|
|
196
|
+
checkpointChunkSize?: number | undefined;
|
|
197
|
+
checkpointRunAtEnd?: boolean | undefined;
|
|
198
|
+
} | undefined;
|
|
199
|
+
}>;
|
|
200
|
+
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
version: number;
|
|
202
|
+
plan: {
|
|
203
|
+
status: "running" | "completed" | "failed" | "idle" | "deriving" | "stopped" | "archived";
|
|
204
|
+
id: string & z.BRAND<"BatchPlanId">;
|
|
205
|
+
workspaceId: string & z.BRAND<"WorkspaceId">;
|
|
206
|
+
createdAt: string;
|
|
207
|
+
updatedAt: string;
|
|
208
|
+
mode: "intent" | "derive";
|
|
209
|
+
autoApply: boolean;
|
|
210
|
+
units: {
|
|
211
|
+
description: string;
|
|
212
|
+
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
|
213
|
+
id: string & z.BRAND<"PlanUnitId">;
|
|
214
|
+
name: string;
|
|
215
|
+
proposalIds: (string & z.BRAND<"ProposalId">)[];
|
|
216
|
+
clarifyTicketIds: (string & z.BRAND<"ClarifyTicketId">)[];
|
|
217
|
+
sourceId?: (string & z.BRAND<"SourceId">) | undefined;
|
|
218
|
+
scopeHint?: string | undefined;
|
|
219
|
+
skillRunId?: (string & z.BRAND<"SkillRunId">) | undefined;
|
|
220
|
+
startedAt?: string | undefined;
|
|
221
|
+
completedAt?: string | undefined;
|
|
222
|
+
error?: string | undefined;
|
|
223
|
+
}[];
|
|
224
|
+
checkpointPhases: {
|
|
225
|
+
status: "running" | "completed" | "failed";
|
|
226
|
+
unitIds: (string & z.BRAND<"PlanUnitId">)[];
|
|
227
|
+
skillRunId?: (string & z.BRAND<"SkillRunId">) | undefined;
|
|
228
|
+
startedAt?: string | undefined;
|
|
229
|
+
completedAt?: string | undefined;
|
|
230
|
+
error?: string | undefined;
|
|
231
|
+
}[];
|
|
232
|
+
running?: {
|
|
233
|
+
skillRunId: string & z.BRAND<"SkillRunId">;
|
|
234
|
+
unitId: string & z.BRAND<"PlanUnitId">;
|
|
235
|
+
} | undefined;
|
|
236
|
+
error?: string | undefined;
|
|
237
|
+
baselineTag?: string | undefined;
|
|
238
|
+
batchPolicy?: {
|
|
239
|
+
perUnitSkillId: string & z.BRAND<"SkillId">;
|
|
240
|
+
perUnitLabel?: string | undefined;
|
|
241
|
+
checkpointSkillId?: (string & z.BRAND<"SkillId">) | undefined;
|
|
242
|
+
checkpointLabel?: string | undefined;
|
|
243
|
+
checkpointChunkSize?: number | undefined;
|
|
244
|
+
checkpointRunAtEnd?: boolean | undefined;
|
|
245
|
+
} | undefined;
|
|
246
|
+
};
|
|
247
|
+
}, {
|
|
248
|
+
version: number;
|
|
249
|
+
plan: {
|
|
250
|
+
status: "running" | "completed" | "failed" | "idle" | "deriving" | "stopped" | "archived";
|
|
251
|
+
id: string;
|
|
252
|
+
workspaceId: string;
|
|
253
|
+
createdAt: string;
|
|
254
|
+
updatedAt: string;
|
|
255
|
+
mode: "intent" | "derive";
|
|
256
|
+
autoApply: boolean;
|
|
257
|
+
units: {
|
|
258
|
+
description: string;
|
|
259
|
+
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
|
260
|
+
id: string;
|
|
261
|
+
name: string;
|
|
262
|
+
sourceId?: string | undefined;
|
|
263
|
+
scopeHint?: string | undefined;
|
|
264
|
+
skillRunId?: string | undefined;
|
|
265
|
+
startedAt?: string | undefined;
|
|
266
|
+
completedAt?: string | undefined;
|
|
267
|
+
proposalIds?: string[] | undefined;
|
|
268
|
+
clarifyTicketIds?: string[] | undefined;
|
|
269
|
+
error?: string | undefined;
|
|
270
|
+
}[];
|
|
271
|
+
running?: {
|
|
272
|
+
skillRunId: string;
|
|
273
|
+
unitId: string;
|
|
274
|
+
} | undefined;
|
|
275
|
+
error?: string | undefined;
|
|
276
|
+
baselineTag?: string | undefined;
|
|
277
|
+
checkpointPhases?: {
|
|
278
|
+
status: "running" | "completed" | "failed";
|
|
279
|
+
unitIds: string[];
|
|
280
|
+
skillRunId?: string | undefined;
|
|
281
|
+
startedAt?: string | undefined;
|
|
282
|
+
completedAt?: string | undefined;
|
|
283
|
+
error?: string | undefined;
|
|
284
|
+
}[] | undefined;
|
|
285
|
+
batchPolicy?: {
|
|
286
|
+
perUnitSkillId: string;
|
|
287
|
+
perUnitLabel?: string | undefined;
|
|
288
|
+
checkpointSkillId?: string | undefined;
|
|
289
|
+
checkpointLabel?: string | undefined;
|
|
290
|
+
checkpointChunkSize?: number | undefined;
|
|
291
|
+
checkpointRunAtEnd?: boolean | undefined;
|
|
292
|
+
} | undefined;
|
|
293
|
+
};
|
|
294
|
+
}>;
|
|
295
|
+
export declare class FsBatchPlanRepository implements BatchPlanRepository {
|
|
296
|
+
load(workspace: Workspace): Promise<BatchPlan | null>;
|
|
297
|
+
save(workspace: Workspace, plan: BatchPlan): Promise<void>;
|
|
298
|
+
clear(workspace: Workspace): Promise<void>;
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=FsBatchPlanRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsBatchPlanRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/fs/FsBatchPlanRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGnE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,kBAAkB,IAAI,CAAA;AAEnC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGxB,CAAA;AAEF,qBAAa,qBAAsB,YAAW,mBAAmB;IACzD,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAmBrD,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1D,KAAK,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAGjD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { BatchPlan } from '@braidhq/core';
|
|
4
|
+
import { BatchPlan as BatchPlanData } from '@braidhq/schema';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { batchPlanPath, workspaceArtifactsDir } from './paths.js';
|
|
7
|
+
export const BATCH_PLAN_VERSION = 1;
|
|
8
|
+
export const BatchPlanFile = z.object({
|
|
9
|
+
version: z.number().int(),
|
|
10
|
+
plan: BatchPlanData,
|
|
11
|
+
});
|
|
12
|
+
export class FsBatchPlanRepository {
|
|
13
|
+
async load(workspace) {
|
|
14
|
+
let raw;
|
|
15
|
+
try {
|
|
16
|
+
raw = await readFile(batchPlanPath(workspace.rootPath), 'utf-8');
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error.code === 'ENOENT')
|
|
20
|
+
return null;
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
const parsed = BatchPlanFile.parse(JSON.parse(raw));
|
|
24
|
+
if (parsed.version !== BATCH_PLAN_VERSION) {
|
|
25
|
+
throw new Error(`batch-plan.json version mismatch in ${workspace.rootPath}: expected ${BATCH_PLAN_VERSION}, got ${parsed.version}`);
|
|
26
|
+
}
|
|
27
|
+
return new BatchPlan(parsed.plan);
|
|
28
|
+
}
|
|
29
|
+
async save(workspace, plan) {
|
|
30
|
+
const path = batchPlanPath(workspace.rootPath);
|
|
31
|
+
await mkdir(workspaceArtifactsDir(workspace.rootPath), { recursive: true });
|
|
32
|
+
const payload = { version: BATCH_PLAN_VERSION, plan: plan.toData() };
|
|
33
|
+
// Atomic write so a crashed server can't leave a half-file mid-run.
|
|
34
|
+
const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
|
|
35
|
+
await writeFile(tmp, `${JSON.stringify(payload, null, 2)}\n`, 'utf-8');
|
|
36
|
+
await rename(tmp, path);
|
|
37
|
+
}
|
|
38
|
+
async clear(workspace) {
|
|
39
|
+
await rm(batchPlanPath(workspace.rootPath), { force: true });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=FsBatchPlanRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsBatchPlanRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/fs/FsBatchPlanRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACzB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAA;AAEF,MAAM,OAAO,qBAAqB;IAChC,KAAK,CAAC,IAAI,CAAC,SAAoB;QAC7B,IAAI,GAAW,CAAA;QACf,IAAI,CAAC;YACH,GAAG,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAA;QAClE,CAAC;QACD,OAAO,KAAK,EAAE,CAAC;YACb,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;gBACp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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FsClarifyTicketRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/fs/FsClarifyTicketRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,WAAW,EACZ,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,KAAK,uBAAuB,EAAY,MAAM,eAAe,CAAA;AAKrF,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAA;CAC/E;AAED,qBAAa,yBAA0B,YAAW,uBAAuB;IACvE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2F;gBAEpG,OAAO,EAAE,gCAAgC;IAgB/C,IAAI,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"FsClarifyTicketRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/fs/FsClarifyTicketRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,WAAW,EACZ,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,KAAK,uBAAuB,EAAY,MAAM,eAAe,CAAA;AAKrF,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAA;CAC/E;AAED,qBAAa,yBAA0B,YAAW,uBAAuB;IACvE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2F;gBAEpG,OAAO,EAAE,gCAAgC;IAgB/C,IAAI,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAgB5D,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAI9D,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3C"}
|
|
@@ -17,10 +17,16 @@ export class FsClarifyTicketRepository {
|
|
|
17
17
|
}, options.workspaceRoots);
|
|
18
18
|
}
|
|
19
19
|
async list(filter) {
|
|
20
|
-
|
|
20
|
+
let tickets = await this.base.list({
|
|
21
21
|
...(filter?.workspaceId !== undefined ? { workspaceId: filter.workspaceId } : {}),
|
|
22
22
|
...(filter?.statuses !== undefined ? { statuses: filter.statuses } : {}),
|
|
23
23
|
});
|
|
24
|
+
// Phase E personal/shared filter: pending tickets only owner sees;
|
|
25
|
+
// answered / applied / skipped stay workspace-shared.
|
|
26
|
+
if (filter?.viewerId !== undefined) {
|
|
27
|
+
const viewerId = filter.viewerId;
|
|
28
|
+
tickets = tickets.filter(ticket => ticket.status !== 'pending' || ticket.ownerId === undefined || ticket.ownerId === viewerId);
|
|
29
|
+
}
|
|
24
30
|
return paginate(tickets, filter?.limit, filter?.offset);
|
|
25
31
|
}
|
|
26
32
|
load(clarifyTicketId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FsClarifyTicketRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/fs/FsClarifyTicketRepository.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAgC,QAAQ,EAAE,MAAM,eAAe,CAAA;AACrF,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAMzD,MAAM,OAAO,yBAAyB;IACnB,IAAI,CAA2F;IAEhH,YAAY,OAAyC;QACnD,IAAI,CAAC,IAAI,GAAG,IAAI,wBAAwB,CACtC;YACE,UAAU,EAAE,eAAe;YAC3B,QAAQ,E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