@bevel-software/platform-core-backend 0.8.0 → 0.9.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/dist/core/core-ports.d.ts +7 -0
- package/dist/core/core-ports.d.ts.map +1 -1
- package/dist/core/core-ports.js.map +1 -1
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +24 -11
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +7 -2
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +39 -18
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/modules/access/access.routes.d.ts +3 -1
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +4 -2
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/access/render-roles-yaml.d.ts +22 -0
- package/dist/modules/access/render-roles-yaml.d.ts.map +1 -0
- package/dist/modules/access/render-roles-yaml.js +56 -0
- package/dist/modules/access/render-roles-yaml.js.map +1 -0
- package/dist/modules/access/roles-admin.service.d.ts +15 -1
- package/dist/modules/access/roles-admin.service.d.ts.map +1 -1
- package/dist/modules/access/roles-admin.service.js +30 -15
- package/dist/modules/access/roles-admin.service.js.map +1 -1
- package/dist/modules/settings/setup.routes.d.ts +10 -1
- package/dist/modules/settings/setup.routes.d.ts.map +1 -1
- package/dist/modules/settings/setup.routes.js +111 -6
- package/dist/modules/settings/setup.routes.js.map +1 -1
- package/dist/modules/workspace/startup/kb-git.d.ts +23 -0
- package/dist/modules/workspace/startup/kb-git.d.ts.map +1 -0
- package/dist/modules/workspace/startup/kb-git.js +86 -0
- package/dist/modules/workspace/startup/kb-git.js.map +1 -0
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts +74 -0
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -0
- package/dist/modules/workspace/startup/kb-startup-runner.js +528 -0
- package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -0
- package/dist/modules/workspace/startup/on-server-start.d.ts +105 -0
- package/dist/modules/workspace/startup/on-server-start.d.ts.map +1 -0
- package/dist/modules/workspace/startup/on-server-start.js +21 -0
- package/dist/modules/workspace/startup/on-server-start.js.map +1 -0
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts +46 -0
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts.map +1 -0
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js +492 -0
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js.map +1 -0
- package/dist/modules/workspace/startup/steps/roles-yaml.step.d.ts +23 -0
- package/dist/modules/workspace/startup/steps/roles-yaml.step.d.ts.map +1 -0
- package/dist/modules/workspace/startup/steps/roles-yaml.step.js +69 -0
- package/dist/modules/workspace/startup/steps/roles-yaml.step.js.map +1 -0
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts +17 -0
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -0
- package/dist/modules/workspace/startup/steps/seed-tree.js +109 -0
- package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -0
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts +103 -0
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -0
- package/dist/modules/workspace/startup/steps/template-files.step.js +337 -0
- package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -0
- package/dist/modules/workspace/workspace.service.d.ts +0 -35
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +2 -101
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/kb-template/gitignore.template +16 -0
- package/package.json +3 -3
- package/src/core/core-ports.ts +7 -0
- package/src/core/create-core-server.ts +30 -11
- package/src/core/create-core-services.ts +43 -22
- package/src/modules/access/__tests__/roles-admin.service.test.ts +24 -2
- package/src/modules/access/access.routes.ts +3 -0
- package/src/modules/access/render-roles-yaml.ts +65 -0
- package/src/modules/access/roles-admin.service.ts +32 -14
- package/src/modules/settings/__tests__/setup.routes.test.ts +124 -3
- package/src/modules/settings/setup.routes.ts +112 -5
- package/src/modules/workspace/__tests__/workspace.service.test.ts +5 -94
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +495 -0
- package/src/modules/workspace/startup/kb-git.ts +94 -0
- package/src/modules/workspace/startup/kb-startup-runner.ts +597 -0
- package/src/modules/workspace/startup/on-server-start.ts +97 -0
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +636 -0
- package/src/modules/workspace/{plugins-migration.ts → startup/steps/groups-to-plugins.step.ts} +342 -260
- package/src/modules/workspace/startup/steps/roles-yaml.step.ts +71 -0
- package/src/modules/workspace/startup/steps/seed-tree.ts +115 -0
- package/src/modules/workspace/startup/steps/template-files.step.ts +360 -0
- package/src/modules/workspace/workspace.service.ts +2 -106
- package/src/modules/workspace/__tests__/kb-seed.service.test.ts +0 -512
- package/src/modules/workspace/__tests__/plugins-migration.test.ts +0 -427
- package/src/modules/workspace/kb-seed.interface.ts +0 -36
- package/src/modules/workspace/kb-seed.service.ts +0 -584
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The KB startup contract: every migration and scaffolding concern runs here,
|
|
3
|
+
* at the deployment's quiet moments, and nowhere else.
|
|
4
|
+
*
|
|
5
|
+
* There are exactly two occasions, both provably quiet (no user holds a lock,
|
|
6
|
+
* no edit is mid-flight): SERVER BOOT, before routes mount; and FIRST-TIME
|
|
7
|
+
* SETUP COMPLETION, when the branch model is configured through the setup
|
|
8
|
+
* screen — the app is gated shut until exactly that moment. Any later re-run
|
|
9
|
+
* would race live sessions on the very working clones it maintains, which is
|
|
10
|
+
* why there is no retry tick, no lazy per-branch trigger, and no maintenance
|
|
11
|
+
* on runtime branch opens, ever. A failed boot is retried by the container's
|
|
12
|
+
* restart policy — each attempt at boot time, on quiet trees.
|
|
13
|
+
*
|
|
14
|
+
* Failure model, fully fail-closed: the server either completes the phase or
|
|
15
|
+
* does not serve. An UNHANDLED throw from a step stops the boot — the same
|
|
16
|
+
* contract a DB migration has. A failure the author knows is survivable must
|
|
17
|
+
* be DECLARED via the result. `KB_SAFE_BOOT=1` is the break-glass demotion
|
|
18
|
+
* (see the runner).
|
|
19
|
+
*/
|
|
20
|
+
export interface OnServerStart {
|
|
21
|
+
/** Shown in logs and error messages: "groups-to-plugins", "template-files", … */
|
|
22
|
+
readonly name: string;
|
|
23
|
+
run(ctx: ServerStartContext): Promise<StepResult>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What the runner should do next. Every declared outcome asserts "the tree is
|
|
27
|
+
* in a state later steps can safely run against".
|
|
28
|
+
*/
|
|
29
|
+
export type StepResult =
|
|
30
|
+
/** Fully done; declared ops apply. "Nothing to do" is `ok` with no ops. */
|
|
31
|
+
{
|
|
32
|
+
outcome: 'ok';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Incomplete but VALID: declared ops still apply; the remainder is named
|
|
36
|
+
* and logged. The migration's refused conversions are exactly this.
|
|
37
|
+
*/
|
|
38
|
+
| {
|
|
39
|
+
outcome: 'partial';
|
|
40
|
+
reason: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Did not complete: declared ops are discarded UNAPPLIED — the tree is
|
|
44
|
+
* untouched by construction, not by revert — and later steps continue.
|
|
45
|
+
*/
|
|
46
|
+
| {
|
|
47
|
+
outcome: 'skipped';
|
|
48
|
+
reason: string;
|
|
49
|
+
}
|
|
50
|
+
/** Serving would be worse than being down. The deliberate kill switch. */
|
|
51
|
+
| {
|
|
52
|
+
outcome: 'stopBoot';
|
|
53
|
+
message: string;
|
|
54
|
+
};
|
|
55
|
+
export interface ServerStartContext {
|
|
56
|
+
/** The resolved template directory this build ships. */
|
|
57
|
+
readonly templateDir: string;
|
|
58
|
+
/** Handles are lazy — the clone happens on first `repoDir()`. */
|
|
59
|
+
defaultBranch(): Promise<KbBranch>;
|
|
60
|
+
protectedBranches(): Promise<KbBranch[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Every branch on the remote, drafts included — and WRITABLE like any
|
|
63
|
+
* other: with maintenance applied uniformly at the quiet moment, migrating
|
|
64
|
+
* a draft alongside its target is what keeps its change-request diff down
|
|
65
|
+
* to the user's own changes. (The lazy era's read-only rule guarded
|
|
66
|
+
* against ASYMMETRIC application; uniform application inverts it — a
|
|
67
|
+
* stale draft against a migrated target diffs by the whole rename.)
|
|
68
|
+
*/
|
|
69
|
+
allBranches(): Promise<KbBranch[]>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One branch's working copy, with buffered writes. Steps never touch the
|
|
73
|
+
* disk: they READ via `repoDir()` and DECLARE operations, which the runner —
|
|
74
|
+
* the only writer — applies when the step returns `ok`/`partial` (so the next
|
|
75
|
+
* step sees the real, updated tree) and discards on `skipped`. The applier
|
|
76
|
+
* enforces the write layer's containment contract once — repo-relative
|
|
77
|
+
* paths, no escapes, no symlinks — instead of every step getting raw fs
|
|
78
|
+
* right.
|
|
79
|
+
*/
|
|
80
|
+
export interface KbBranch {
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly isProtected: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Absolute path of the checked-out clone; clone-if-absent happens here.
|
|
85
|
+
* This is the READ seam: writing through the returned path is a contract
|
|
86
|
+
* violation by the step — steps are first-party trusted code, and the
|
|
87
|
+
* buffered-ops contract is a convention the runner enforces structurally,
|
|
88
|
+
* not a sandbox it defends.
|
|
89
|
+
*/
|
|
90
|
+
repoDir(): Promise<string>;
|
|
91
|
+
/** Declare a file's full content at a repo-relative path. */
|
|
92
|
+
write(path: string, content: string | Uint8Array): void;
|
|
93
|
+
/** Declare a relocation — file or whole directory (the Groups→Plugins rename is one op). */
|
|
94
|
+
move(from: string, to: string): void;
|
|
95
|
+
/** Declare a file's removal. */
|
|
96
|
+
remove(path: string): void;
|
|
97
|
+
/**
|
|
98
|
+
* One honest line per logical change — the branch's commit message is built
|
|
99
|
+
* from these. Notes ride WITH the step's ops: kept when the step's outcome
|
|
100
|
+
* applies them (`ok`/`partial`), discarded together with them on `skipped` —
|
|
101
|
+
* a skipped step must not caption a commit made of other steps' changes.
|
|
102
|
+
*/
|
|
103
|
+
note(line: string): void;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=on-server-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-server-start.d.ts","sourceRoot":"","sources":["../../../../src/modules/workspace/startup/on-server-start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU;AACpB,2EAA2E;AACzE;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE;AACnB;;;GAGG;GACD;IAAE,OAAO,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACxC;;;GAGG;GACD;IAAE,OAAO,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACxC,0EAA0E;GACxE;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,iEAAiE;IACjE,aAAa,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,iBAAiB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACzC;;;;;;;OAOG;IACH,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B;;;;;;OAMG;IACH,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3B,6DAA6D;IAC7D,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IACxD,4FAA4F;IAC5F,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,gCAAgC;IAChC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The KB startup contract: every migration and scaffolding concern runs here,
|
|
3
|
+
* at the deployment's quiet moments, and nowhere else.
|
|
4
|
+
*
|
|
5
|
+
* There are exactly two occasions, both provably quiet (no user holds a lock,
|
|
6
|
+
* no edit is mid-flight): SERVER BOOT, before routes mount; and FIRST-TIME
|
|
7
|
+
* SETUP COMPLETION, when the branch model is configured through the setup
|
|
8
|
+
* screen — the app is gated shut until exactly that moment. Any later re-run
|
|
9
|
+
* would race live sessions on the very working clones it maintains, which is
|
|
10
|
+
* why there is no retry tick, no lazy per-branch trigger, and no maintenance
|
|
11
|
+
* on runtime branch opens, ever. A failed boot is retried by the container's
|
|
12
|
+
* restart policy — each attempt at boot time, on quiet trees.
|
|
13
|
+
*
|
|
14
|
+
* Failure model, fully fail-closed: the server either completes the phase or
|
|
15
|
+
* does not serve. An UNHANDLED throw from a step stops the boot — the same
|
|
16
|
+
* contract a DB migration has. A failure the author knows is survivable must
|
|
17
|
+
* be DECLARED via the result. `KB_SAFE_BOOT=1` is the break-glass demotion
|
|
18
|
+
* (see the runner).
|
|
19
|
+
*/
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=on-server-start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-server-start.js","sourceRoot":"","sources":["../../../../src/modules/workspace/startup/on-server-start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { OnServerStart, ServerStartContext, StepResult } from '../on-server-start.js';
|
|
2
|
+
/**
|
|
3
|
+
* One-way migration of a knowledge base from `Groups/` to the Agent Plugins
|
|
4
|
+
* layout under `Plugins/` (https://agent-plugins.org, v1.0.0), as an
|
|
5
|
+
* {@link OnServerStart} step. (It began life as an in-place module run from
|
|
6
|
+
* the lazy top-up; that path is gone, and this is the only form.) Steps
|
|
7
|
+
* never write: every change is DECLARED on the branch handle
|
|
8
|
+
* (`move`/`write`/`remove`) and the runner applies it, while every read goes
|
|
9
|
+
* against the real, pre-step tree via `repoDir()`.
|
|
10
|
+
*
|
|
11
|
+
* Idempotent: a KB already on the new layout is untouched, and a half-finished
|
|
12
|
+
* run is completed by the next one.
|
|
13
|
+
*
|
|
14
|
+
* What moves — and what CONVERTS:
|
|
15
|
+
*
|
|
16
|
+
* Groups/GTM/access.md → Plugins/GTM/access.md (stays put)
|
|
17
|
+
* Groups/GTM/deploy/SKILL.md → Plugins/GTM/skills/deploy/SKILL.md
|
|
18
|
+
* Groups/GTM/web-search.tool → Plugins/GTM/software.bevel.hexis/tools/web-search.tool
|
|
19
|
+
* Groups/GTM/notion.tool (mcp) → an entry in Plugins/GTM/mcp.json, and the
|
|
20
|
+
* `.tool` file is DELETED — mcp.json is
|
|
21
|
+
* authoritative for MCP servers now.
|
|
22
|
+
* Plugins/GTM/plugin.json (written)
|
|
23
|
+
*
|
|
24
|
+
* The mcp.json entry is keyed by the `.tool`'s manual id: that id is the
|
|
25
|
+
* namespace vault secrets bind to (`<id>_<VAR>`), so keeping it is what keeps
|
|
26
|
+
* every configured secret and completed OAuth grant bound. What mcp.json
|
|
27
|
+
* cannot carry — auth headers with `${VAR}` references, variable declarations,
|
|
28
|
+
* the local-only flag — moves into `plugin.json`'s
|
|
29
|
+
* `extensions["software.bevel.hexis"].mcpServers[<id>]` block, the reverse-DNS
|
|
30
|
+
* namespace the spec reserves for client-specific data. `http`/`inline`
|
|
31
|
+
* manuals still MOVE as `.tool` files: nothing but this platform can run them.
|
|
32
|
+
*
|
|
33
|
+
* Scope: EVERY branch, drafts included and writable (`ctx.allBranches()`) —
|
|
34
|
+
* maintenance applied uniformly at the quiet moment is what keeps a draft's
|
|
35
|
+
* change-request diff down to the user's own changes; a stale draft against a
|
|
36
|
+
* migrated target would diff by the whole rename.
|
|
37
|
+
*
|
|
38
|
+
* Outcomes: a per-manual NOT-converted refusal makes the step `partial` with
|
|
39
|
+
* the reasons (the declared ops for everything else still apply); a branch
|
|
40
|
+
* carrying BOTH roots contributes nothing but a note; everything else is `ok`.
|
|
41
|
+
*/
|
|
42
|
+
export declare class GroupsToPluginsStep implements OnServerStart {
|
|
43
|
+
readonly name = "groups-to-plugins";
|
|
44
|
+
run(ctx: ServerStartContext): Promise<StepResult>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=groups-to-plugins.step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups-to-plugins.step.d.ts","sourceRoot":"","sources":["../../../../../src/modules/workspace/startup/steps/groups-to-plugins.step.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAY,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAErG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IACvD,QAAQ,CAAC,IAAI,uBAAuB;IAE9B,GAAG,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;CAOxD"}
|