@bevel-software/platform-core-backend 0.29.0 → 0.30.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/__tests__/test-repositories.d.ts +3 -0
- package/dist/__tests__/test-repositories.d.ts.map +1 -0
- package/dist/__tests__/test-repositories.js +18 -0
- package/dist/__tests__/test-repositories.js.map +1 -0
- package/dist/core/create-core-server.js +1 -1
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +3 -0
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +32 -4
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/core/lifecycle.d.ts +8 -0
- package/dist/core/lifecycle.d.ts.map +1 -1
- package/dist/core/lifecycle.js +4 -0
- package/dist/core/lifecycle.js.map +1 -1
- package/dist/modules/access/access-control.interface.d.ts +20 -0
- package/dist/modules/access/access-control.interface.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +32 -1
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +138 -16
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +20 -6
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/agent-instructions/shared-file-rules.d.ts +1 -1
- package/dist/modules/agent-instructions/shared-file-rules.js +1 -1
- package/dist/modules/diff/diff.service.d.ts.map +1 -1
- package/dist/modules/diff/diff.service.js +7 -1
- package/dist/modules/diff/diff.service.js.map +1 -1
- package/dist/modules/kb-fs/git-dir.d.ts +21 -0
- package/dist/modules/kb-fs/git-dir.d.ts.map +1 -0
- package/dist/modules/kb-fs/git-dir.js +58 -0
- package/dist/modules/kb-fs/git-dir.js.map +1 -0
- package/dist/modules/kb-fs/index.d.ts +2 -0
- package/dist/modules/kb-fs/index.d.ts.map +1 -1
- package/dist/modules/kb-fs/index.js +2 -1
- package/dist/modules/kb-fs/index.js.map +1 -1
- package/dist/modules/kb-fs/ref-files.d.ts +63 -0
- package/dist/modules/kb-fs/ref-files.d.ts.map +1 -0
- package/dist/modules/kb-fs/ref-files.js +249 -0
- package/dist/modules/kb-fs/ref-files.js.map +1 -0
- package/dist/modules/plugins/teams.routes.d.ts +4 -0
- package/dist/modules/plugins/teams.routes.d.ts.map +1 -1
- package/dist/modules/plugins/teams.routes.js +9 -1
- package/dist/modules/plugins/teams.routes.js.map +1 -1
- package/dist/modules/tool-auth/internal-token.service.d.ts +1 -1
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts +1 -2
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts.map +1 -1
- package/dist/modules/tool-auth/tool-auth.middleware.js +1 -2
- package/dist/modules/tool-auth/tool-auth.middleware.js.map +1 -1
- package/dist/modules/tool-helpers/tool-handler.d.ts +2 -2
- package/dist/modules/tool-helpers/tool.contract.d.ts +2 -2
- package/dist/modules/workflow/git/git.service.d.ts +29 -0
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +177 -24
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/workflow-hooks.d.ts +1 -1
- package/dist/modules/workspace/agent-access.gate.d.ts +2 -2
- package/dist/modules/workspace/agent-access.gate.js +2 -2
- package/dist/modules/workspace/bounded-matcher.d.ts +79 -0
- package/dist/modules/workspace/bounded-matcher.d.ts.map +1 -0
- package/dist/modules/workspace/bounded-matcher.js +261 -0
- package/dist/modules/workspace/bounded-matcher.js.map +1 -0
- package/dist/modules/workspace/fetch-instant.d.ts +9 -0
- package/dist/modules/workspace/fetch-instant.d.ts.map +1 -0
- package/dist/modules/workspace/fetch-instant.js +13 -0
- package/dist/modules/workspace/fetch-instant.js.map +1 -0
- package/dist/modules/workspace/index.d.ts +7 -0
- package/dist/modules/workspace/index.d.ts.map +1 -1
- package/dist/modules/workspace/index.js +6 -0
- package/dist/modules/workspace/index.js.map +1 -1
- package/dist/modules/workspace/kb-repository.contract.d.ts +124 -0
- package/dist/modules/workspace/kb-repository.contract.d.ts.map +1 -0
- package/dist/modules/workspace/kb-repository.contract.js +19 -0
- package/dist/modules/workspace/kb-repository.contract.js.map +1 -0
- package/dist/modules/workspace/kb-repository.d.ts +236 -0
- package/dist/modules/workspace/kb-repository.d.ts.map +1 -0
- package/dist/modules/workspace/kb-repository.js +811 -0
- package/dist/modules/workspace/kb-repository.js.map +1 -0
- package/dist/modules/workspace/pattern-matcher.contract.d.ts +50 -0
- package/dist/modules/workspace/pattern-matcher.contract.d.ts.map +1 -0
- package/dist/modules/workspace/pattern-matcher.contract.js +27 -0
- package/dist/modules/workspace/pattern-matcher.contract.js.map +1 -0
- package/dist/modules/workspace/routine-write-policy.d.ts +0 -7
- package/dist/modules/workspace/routine-write-policy.d.ts.map +1 -1
- package/dist/modules/workspace/routine-write-policy.js +0 -5
- package/dist/modules/workspace/routine-write-policy.js.map +1 -1
- package/dist/modules/workspace/set-aside-clone.d.ts +40 -0
- package/dist/modules/workspace/set-aside-clone.d.ts.map +1 -1
- package/dist/modules/workspace/set-aside-clone.js +139 -0
- package/dist/modules/workspace/set-aside-clone.js.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts +99 -0
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.js +407 -29
- package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +68 -32
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +240 -161
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/modules/workspace/workspace.tools.d.ts +13 -4
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.tools.js +162 -336
- package/dist/modules/workspace/workspace.tools.js.map +1 -1
- package/dist/test-setup.js +4 -0
- package/dist/test-setup.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/test-repositories.ts +22 -0
- package/src/__tests__/workspace-service.ts +69 -0
- package/src/core/__tests__/lifecycle.test.ts +16 -0
- package/src/core/create-core-server.ts +1 -1
- package/src/core/create-core-services.ts +36 -3
- package/src/core/lifecycle.ts +10 -0
- package/src/modules/access/__tests__/access-control.atref-cache.test.ts +144 -4
- package/src/modules/access/__tests__/access-control.group-read.test.ts +73 -0
- package/src/modules/access/__tests__/access.routes.group-grant.test.ts +66 -0
- package/src/modules/access/__tests__/access.routes.unknown-email.test.ts +2 -0
- package/src/modules/access/access-control.interface.ts +22 -0
- package/src/modules/access/access-control.service.ts +142 -14
- package/src/modules/access/access.routes.ts +22 -6
- package/src/modules/agent-instructions/shared-file-rules.ts +1 -1
- package/src/modules/diff/__tests__/diff.service.seed-atomicity.test.ts +2 -1
- package/src/modules/diff/__tests__/diff.service.test.ts +2 -1
- package/src/modules/diff/__tests__/diff.service.worktree.test.ts +76 -0
- package/src/modules/diff/diff.service.ts +6 -4
- package/src/modules/kb-fs/__tests__/git-dir.test.ts +77 -0
- package/src/modules/kb-fs/__tests__/ref-files.test.ts +338 -0
- package/src/modules/kb-fs/git-dir.ts +53 -0
- package/src/modules/kb-fs/index.ts +2 -0
- package/src/modules/kb-fs/ref-files.ts +279 -0
- package/src/modules/plugins/__tests__/teams.routes.test.ts +55 -0
- package/src/modules/plugins/teams.routes.ts +14 -1
- package/src/modules/settings/__tests__/setup.routes.layout-phase.test.ts +2 -2
- package/src/modules/settings/__tests__/setup.routes.managed-phase.test.ts +2 -2
- package/src/modules/tool-auth/internal-token.service.ts +1 -1
- package/src/modules/tool-auth/tool-auth.middleware.ts +1 -2
- package/src/modules/tool-helpers/__tests__/branch-declaration.test.ts +2 -2
- package/src/modules/tool-helpers/tool-handler.ts +2 -2
- package/src/modules/tool-helpers/tool.contract.ts +2 -2
- package/src/modules/tool-registry/__tests__/tool-description-length.test.ts +6 -1
- package/src/modules/workflow/git/__tests__/git.service.changedPathsMemo.test.ts +175 -0
- package/src/modules/workflow/git/__tests__/git.service.worktrees.test.ts +284 -0
- package/src/modules/workflow/git/git.service.ts +184 -22
- package/src/modules/workflow/workflow-hooks.ts +1 -1
- package/src/modules/workspace/__tests__/agent-downloads.test.ts +2 -2
- package/src/modules/workspace/__tests__/bounded-matcher.test.ts +213 -0
- package/src/modules/workspace/__tests__/git-internals.security.test.ts +22 -7
- package/src/modules/workspace/__tests__/kb-repository.test.ts +481 -0
- package/src/modules/workspace/__tests__/rest-tool-arguments.test.ts +14 -0
- package/src/modules/workspace/__tests__/routine-write-policy.test.ts +0 -11
- package/src/modules/workspace/__tests__/workspace-paths-inside-the-repo.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.routes.folder-zip-access.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.routes.folders.test.ts +4 -3
- package/src/modules/workspace/__tests__/workspace.service.any-workspace-credentials.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.service.ensure-remotes-fetched.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.service.forget-clone-races.test.ts +12 -5
- package/src/modules/workspace/__tests__/workspace.service.list-cloned.test.ts +6 -6
- package/src/modules/workspace/__tests__/workspace.service.move-never-overwrites.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.replaced-repository.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.test.ts +24 -23
- package/src/modules/workspace/__tests__/workspace.service.unknown-branch.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.worktrees.test.ts +620 -0
- package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +15 -1
- package/src/modules/workspace/__tests__/workspace.tools.branch-errors.test.ts +71 -5
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +153 -298
- package/src/modules/workspace/agent-access.gate.ts +2 -2
- package/src/modules/workspace/bounded-matcher.ts +328 -0
- package/src/modules/workspace/fetch-instant.ts +13 -0
- package/src/modules/workspace/index.ts +12 -0
- package/src/modules/workspace/kb-repository.contract.ts +124 -0
- package/src/modules/workspace/kb-repository.ts +844 -0
- package/src/modules/workspace/pattern-matcher.contract.ts +69 -0
- package/src/modules/workspace/routine-write-policy.ts +0 -15
- package/src/modules/workspace/set-aside-clone.ts +140 -0
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.degraded.test.ts +3 -2
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +12 -10
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.worktrees.test.ts +613 -0
- package/src/modules/workspace/startup/kb-startup-runner.ts +422 -29
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +4 -3
- package/src/modules/workspace/workspace.service.ts +247 -169
- package/src/modules/workspace/workspace.tools.ts +179 -365
- package/src/test-setup.ts +5 -0
|
@@ -27,7 +27,9 @@ import { RoutineWritePolicyService } from '../routine-write-policy.js';
|
|
|
27
27
|
import { SpillStore } from '../spill-store.js';
|
|
28
28
|
import { DocExtractService } from '../file-readers/doc-extract.service.js';
|
|
29
29
|
import { registerWorkspaceTools } from '../workspace.tools.js';
|
|
30
|
+
import { WorkerPatternMatcher } from '../bounded-matcher.js';
|
|
30
31
|
import { WorkspaceService } from '../workspace.service.js';
|
|
32
|
+
import { newWorkspaceService } from '../../../__tests__/workspace-service.js';
|
|
31
33
|
|
|
32
34
|
const execFileAsync = promisify(execFile);
|
|
33
35
|
const KB_DIR = 'knowledge-base';
|
|
@@ -69,6 +71,7 @@ describe('workspace tools — a branch that cannot be opened', () => {
|
|
|
69
71
|
let workspaces: WorkspaceService | null = null;
|
|
70
72
|
let spillRoot = '';
|
|
71
73
|
let docCacheDir = '';
|
|
74
|
+
let patternMatcher: WorkerPatternMatcher | undefined;
|
|
72
75
|
|
|
73
76
|
afterEach(async () => {
|
|
74
77
|
if (httpServer) {
|
|
@@ -78,6 +81,8 @@ describe('workspace tools — a branch that cannot be opened', () => {
|
|
|
78
81
|
await new Promise<void>((r) => httpServer!.close(() => r()));
|
|
79
82
|
}
|
|
80
83
|
httpServer = undefined;
|
|
84
|
+
await patternMatcher?.close();
|
|
85
|
+
patternMatcher = undefined;
|
|
81
86
|
workspaces = null;
|
|
82
87
|
for (const dir of [root, spillRoot, docCacheDir]) {
|
|
83
88
|
if (dir) await rm(dir, { recursive: true, force: true });
|
|
@@ -96,7 +101,13 @@ describe('workspace tools — a branch that cannot be opened', () => {
|
|
|
96
101
|
let internalTools: { name: string; inputs: unknown }[] = [];
|
|
97
102
|
|
|
98
103
|
async function start(
|
|
99
|
-
opts: {
|
|
104
|
+
opts: {
|
|
105
|
+
repoUrl?: 'origin' | 'unreachable';
|
|
106
|
+
scope?: 'read' | 'write';
|
|
107
|
+
source?: 'internal' | 'external';
|
|
108
|
+
/** More files committed at the repository's root — `knowledge-base/<name>` to the tools. */
|
|
109
|
+
files?: Record<string, string>;
|
|
110
|
+
} = {},
|
|
100
111
|
): Promise<string> {
|
|
101
112
|
root = await mkdtemp(join(tmpdir(), 'ws-tools-branch-'));
|
|
102
113
|
spillRoot = await mkdtemp(join(tmpdir(), 'ws-tools-spill-'));
|
|
@@ -112,13 +123,16 @@ describe('workspace tools — a branch that cannot be opened', () => {
|
|
|
112
123
|
await runGit(seed, ['remote', 'add', 'origin', upstream]);
|
|
113
124
|
await mkdir(join(seed, KB_DIR));
|
|
114
125
|
await writeFile(join(seed, KB_DIR, 'a.md'), 'hello\n', 'utf-8');
|
|
126
|
+
for (const [name, content] of Object.entries(opts.files ?? {})) {
|
|
127
|
+
await writeFile(join(seed, name), content, 'utf-8');
|
|
128
|
+
}
|
|
115
129
|
await runGit(seed, ['add', '.']);
|
|
116
130
|
await runGit(seed, ['commit', '-m', 'init']);
|
|
117
131
|
await runGit(seed, ['checkout', '-b', 'alice/draft']);
|
|
118
132
|
await runGit(seed, ['commit', '--allow-empty', '-m', 'draft']);
|
|
119
133
|
await runGit(seed, ['push', 'origin', 'target-company-state', 'alice/draft']);
|
|
120
134
|
|
|
121
|
-
workspaces =
|
|
135
|
+
workspaces = newWorkspaceService(
|
|
122
136
|
workspacesRoot,
|
|
123
137
|
opts.repoUrl === 'unreachable' ? join(root, 'no-such-repo.git') : upstream,
|
|
124
138
|
testKbContext({ kbDirName: KB_DIR }),
|
|
@@ -185,6 +199,15 @@ describe('workspace tools — a branch that cannot be opened', () => {
|
|
|
185
199
|
},
|
|
186
200
|
new RoutineWritePolicyService(),
|
|
187
201
|
{} as never,
|
|
202
|
+
// Skill check, change gate, uploads, guide, downloads, starter packs, disk: not this file's business.
|
|
203
|
+
undefined,
|
|
204
|
+
undefined,
|
|
205
|
+
undefined,
|
|
206
|
+
undefined,
|
|
207
|
+
undefined,
|
|
208
|
+
undefined,
|
|
209
|
+
undefined,
|
|
210
|
+
(patternMatcher = new WorkerPatternMatcher()),
|
|
188
211
|
);
|
|
189
212
|
app.use('/api', router);
|
|
190
213
|
internalTools = (await registry.listInternal()) as unknown as { name: string; inputs: unknown }[];
|
|
@@ -435,9 +458,7 @@ describe('workspace tools — a branch that cannot be opened', () => {
|
|
|
435
458
|
const base = await start({ source: 'internal', scope: 'write' });
|
|
436
459
|
const takesBranch = internalTools
|
|
437
460
|
.map((t) => ({ name: t.name, body: (t.inputs as { properties?: { body?: { required?: string[] } } }).properties?.body }))
|
|
438
|
-
.filter(({ body }) => (body?.required ?? []).includes('branch'))
|
|
439
|
-
// Resolves its own branch, and validates it itself first.
|
|
440
|
-
.filter(({ name }) => name !== 'execute_command');
|
|
461
|
+
.filter(({ body }) => (body?.required ?? []).includes('branch'));
|
|
441
462
|
|
|
442
463
|
for (const { name: tool, body } of takesBranch) {
|
|
443
464
|
// Every other argument the tool requires, so the call matches the tool
|
|
@@ -470,6 +491,51 @@ describe('workspace tools — a branch that cannot be opened', () => {
|
|
|
470
491
|
expect((body.entries as { name: string }[]).map((e) => e.name)).toContain(KB_DIR);
|
|
471
492
|
});
|
|
472
493
|
|
|
494
|
+
/**
|
|
495
|
+
* Not about branches, but this file holds the real chain harness: a grep
|
|
496
|
+
* called from inside `call_tool_chain` reaches the same route, so the same
|
|
497
|
+
* bound stops a catastrophic pattern there — the chain answers the worded
|
|
498
|
+
* 400 rather than waiting out its own timeout on a held event loop.
|
|
499
|
+
*/
|
|
500
|
+
it('stops a too-expensive grep pattern from inside call_tool_chain, and a control pattern still matches', async () => {
|
|
501
|
+
const line = `${'a'.repeat(39)}!`;
|
|
502
|
+
const base = await start({ files: { 'redos.md': `${line}\n` } });
|
|
503
|
+
const client = await CodeModeUtcpClient.create(process.cwd(), {
|
|
504
|
+
variables: { bevel_API_URL: base, bevel_CONNECTION_KEY: 'internal-token' },
|
|
505
|
+
} as never);
|
|
506
|
+
try {
|
|
507
|
+
await client.registerManual(
|
|
508
|
+
new HttpCallTemplateSerializer().validateDict({
|
|
509
|
+
name: 'bevel',
|
|
510
|
+
call_template_type: 'http',
|
|
511
|
+
http_method: 'GET',
|
|
512
|
+
url: '${API_URL}/api/agent/internal/utcp',
|
|
513
|
+
content_type: 'application/json',
|
|
514
|
+
headers: { Authorization: 'Bearer ${CONNECTION_KEY}' },
|
|
515
|
+
}),
|
|
516
|
+
);
|
|
517
|
+
const { result } = await client.callToolChain(
|
|
518
|
+
`const grep = (pattern) => bevel.grep({ body: { branch: 'alice/draft', pattern, path: 'knowledge-base/redos.md' } });
|
|
519
|
+
let expensive;
|
|
520
|
+
const started = Date.now();
|
|
521
|
+
try { expensive = { ok: grep('^(a+)+$') }; } catch (err) { expensive = { failed: err.message }; }
|
|
522
|
+
const took = Date.now() - started;
|
|
523
|
+
return { expensive, took, control: grep('^a+!$') };`,
|
|
524
|
+
30_000,
|
|
525
|
+
);
|
|
526
|
+
// The search is stopped at the ticket's 5 s budget: timed around the call
|
|
527
|
+
// itself, inside the chain, so the chain runtime's own start-up (which
|
|
528
|
+
// varies by machine) is not what this measures.
|
|
529
|
+
expect(result.took).toBeLessThan(5_000 + 2_000);
|
|
530
|
+
expect(result.expensive.ok).toBeUndefined();
|
|
531
|
+
expect(result.expensive.failed).toContain('HTTP 400');
|
|
532
|
+
expect(result.expensive.failed).toContain('Pattern too expensive');
|
|
533
|
+
expect(result.control.matches).toEqual([{ path: `${KB_DIR}/redos.md`, line: 1, text: line }]);
|
|
534
|
+
} finally {
|
|
535
|
+
await client.close();
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
|
|
473
539
|
it('500s an unreachable remote rather than blaming the branch', async () => {
|
|
474
540
|
const base = await start({ repoUrl: 'unreachable' });
|
|
475
541
|
|