@bevel-software/platform-core-backend 0.25.2 → 0.26.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/agent-guide/access-control.md +234 -0
- package/agent-guide/conventions.md +27 -0
- package/agent-guide/directory-structure.md +145 -0
- package/agent-guide/finding-things.md +7 -0
- package/agent-guide/introduction.md +27 -0
- package/agent-guide/skills.md +47 -0
- package/agent-guide/tool-manuals.md +217 -0
- package/agent-guide/where-a-new-file-goes.md +36 -0
- package/dist/assets.d.ts +7 -0
- package/dist/assets.d.ts.map +1 -1
- package/dist/assets.js +9 -0
- package/dist/assets.js.map +1 -1
- package/dist/core/core-ports.d.ts +11 -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 +13 -2
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +9 -0
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +14 -4
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/access/access-control.interface.d.ts +9 -0
- package/dist/modules/access/access-control.interface.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +1 -0
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +16 -0
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/agent-guide/agent-guide.d.ts +139 -0
- package/dist/modules/agent-guide/agent-guide.d.ts.map +1 -0
- package/dist/modules/agent-guide/agent-guide.js +191 -0
- package/dist/modules/agent-guide/agent-guide.js.map +1 -0
- package/dist/modules/agent-guide/agent-guide.tools.d.ts +24 -0
- package/dist/modules/agent-guide/agent-guide.tools.d.ts.map +1 -0
- package/dist/modules/agent-guide/agent-guide.tools.js +100 -0
- package/dist/modules/agent-guide/agent-guide.tools.js.map +1 -0
- package/dist/modules/agent-guide/index.d.ts +4 -0
- package/dist/modules/agent-guide/index.d.ts.map +1 -0
- package/dist/modules/agent-guide/index.js +4 -0
- package/dist/modules/agent-guide/index.js.map +1 -0
- package/dist/modules/agent-instructions/agent-instructions.routes.d.ts +3 -2
- package/dist/modules/agent-instructions/agent-instructions.routes.d.ts.map +1 -1
- package/dist/modules/agent-instructions/agent-instructions.routes.js +3 -2
- package/dist/modules/agent-instructions/agent-instructions.routes.js.map +1 -1
- package/dist/modules/agent-instructions/compose.d.ts +9 -6
- package/dist/modules/agent-instructions/compose.d.ts.map +1 -1
- package/dist/modules/agent-instructions/compose.js +9 -6
- package/dist/modules/agent-instructions/compose.js.map +1 -1
- package/dist/modules/agent-instructions/index.d.ts +1 -1
- package/dist/modules/agent-instructions/index.d.ts.map +1 -1
- package/dist/modules/agent-instructions/index.js +1 -1
- package/dist/modules/agent-instructions/index.js.map +1 -1
- package/dist/modules/agent-instructions/shared-file-rules.d.ts +10 -50
- package/dist/modules/agent-instructions/shared-file-rules.d.ts.map +1 -1
- package/dist/modules/agent-instructions/shared-file-rules.js +32 -85
- package/dist/modules/agent-instructions/shared-file-rules.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +29 -2
- package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
- package/dist/modules/mcp/mcp.service.js +113 -16
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/tool-schema-guard.d.ts +105 -0
- package/dist/modules/mcp/tool-schema-guard.d.ts.map +1 -0
- package/dist/modules/mcp/tool-schema-guard.js +171 -0
- package/dist/modules/mcp/tool-schema-guard.js.map +1 -0
- package/dist/modules/plugins/plugins.tools.d.ts +36 -2
- package/dist/modules/plugins/plugins.tools.d.ts.map +1 -1
- package/dist/modules/plugins/plugins.tools.js +71 -14
- package/dist/modules/plugins/plugins.tools.js.map +1 -1
- package/dist/modules/settings/deployment-settings.service.d.ts +0 -7
- package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
- package/dist/modules/settings/deployment-settings.service.js +14 -53
- package/dist/modules/settings/deployment-settings.service.js.map +1 -1
- package/dist/modules/settings/setup.routes.d.ts.map +1 -1
- package/dist/modules/settings/setup.routes.js +3 -6
- package/dist/modules/settings/setup.routes.js.map +1 -1
- package/dist/modules/skills/skills.tools.d.ts.map +1 -1
- package/dist/modules/skills/skills.tools.js +58 -16
- package/dist/modules/skills/skills.tools.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts +23 -4
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.contract.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts +4 -0
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.js +14 -0
- package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts +7 -0
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.js +66 -36
- package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
- package/dist/modules/tool-registry/description-length.d.ts +14 -14
- package/dist/modules/tool-registry/description-length.d.ts.map +1 -1
- package/dist/modules/tool-registry/description-length.js +24 -26
- package/dist/modules/tool-registry/description-length.js.map +1 -1
- package/dist/modules/tool-registry/guide-first.d.ts +23 -0
- package/dist/modules/tool-registry/guide-first.d.ts.map +1 -0
- package/dist/modules/tool-registry/guide-first.js +32 -0
- package/dist/modules/tool-registry/guide-first.js.map +1 -0
- package/dist/modules/tool-registry/tool-registry.d.ts +6 -0
- package/dist/modules/tool-registry/tool-registry.d.ts.map +1 -1
- package/dist/modules/tool-registry/tool-registry.js +9 -2
- package/dist/modules/tool-registry/tool-registry.js.map +1 -1
- package/dist/modules/workflow/agent-tools/change-request-read-shape.d.ts +449 -0
- package/dist/modules/workflow/agent-tools/change-request-read-shape.d.ts.map +1 -0
- package/dist/modules/workflow/agent-tools/change-request-read-shape.js +481 -0
- package/dist/modules/workflow/agent-tools/change-request-read-shape.js.map +1 -0
- package/dist/modules/workflow/agent-tools/change-request-read.tools.d.ts +73 -0
- package/dist/modules/workflow/agent-tools/change-request-read.tools.d.ts.map +1 -0
- package/dist/modules/workflow/agent-tools/change-request-read.tools.js +582 -0
- package/dist/modules/workflow/agent-tools/change-request-read.tools.js.map +1 -0
- package/dist/modules/workflow/agent-tools/change-request-summary.d.ts +12 -1
- package/dist/modules/workflow/agent-tools/change-request-summary.d.ts.map +1 -1
- package/dist/modules/workflow/agent-tools/change-request-summary.js +5 -1
- package/dist/modules/workflow/agent-tools/change-request-summary.js.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.js +9 -0
- package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
- package/dist/modules/workflow/git/git.service.d.ts +210 -13
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +456 -91
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/git/merge-commit.d.ts +73 -0
- package/dist/modules/workflow/git/merge-commit.d.ts.map +1 -0
- package/dist/modules/workflow/git/merge-commit.js +89 -0
- package/dist/modules/workflow/git/merge-commit.js.map +1 -0
- package/dist/modules/workflow/git/pull-request.service.d.ts +94 -1
- package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/pull-request.service.js +332 -37
- package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts +35 -0
- package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.js +178 -12
- package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
- package/dist/modules/workflow/workflow.routes.d.ts +6 -2
- package/dist/modules/workflow/workflow.routes.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.routes.js +7 -2
- package/dist/modules/workflow/workflow.routes.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +4 -0
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +3 -0
- package/dist/modules/workflow/workflow.service.js.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.js +22 -27
- package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts +58 -52
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/template-files.step.js +209 -223
- package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.d.ts +5 -3
- package/dist/modules/workspace/startup/steps/template-source.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.js +5 -3
- package/dist/modules/workspace/startup/steps/template-source.js.map +1 -1
- package/dist/modules/workspace/workspace.tools.d.ts +10 -1
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.tools.js +211 -18
- package/dist/modules/workspace/workspace.tools.js.map +1 -1
- package/dist/shared/domain-errors.d.ts +11 -0
- package/dist/shared/domain-errors.d.ts.map +1 -1
- package/dist/shared/domain-errors.js +14 -0
- package/dist/shared/domain-errors.js.map +1 -1
- package/dist/shared/hidden-tools.d.ts +44 -0
- package/dist/shared/hidden-tools.d.ts.map +1 -0
- package/dist/shared/hidden-tools.js +13 -0
- package/dist/shared/hidden-tools.js.map +1 -0
- package/kb-template/.bevelignore +0 -5
- package/package.json +4 -3
- package/src/__tests__/kb-layout-config.test.ts +10 -100
- package/src/__tests__/packaged-assets-ship.test.ts +54 -0
- package/src/assets.ts +10 -0
- package/src/core/core-ports.ts +11 -0
- package/src/core/create-core-server.ts +13 -2
- package/src/core/create-core-services.ts +28 -4
- package/src/index.ts +2 -2
- package/src/modules/access/__tests__/access-control.atref-batch.test.ts +58 -0
- package/src/modules/access/__tests__/access-control.platform-restore.test.ts +8 -7
- package/src/modules/access/__tests__/access-personal-plugin.test.ts +1 -18
- package/src/modules/access/access-control.interface.ts +15 -0
- package/src/modules/access/access-control.service.ts +21 -0
- package/src/modules/agent-guide/__tests__/agent-guide.test.ts +328 -0
- package/src/modules/agent-guide/__tests__/agent-guide.tools.test.ts +189 -0
- package/src/modules/agent-guide/agent-guide.tools.ts +122 -0
- package/src/modules/agent-guide/agent-guide.ts +291 -0
- package/src/modules/agent-guide/index.ts +21 -0
- package/src/modules/agent-instructions/__tests__/shared-file-rules.test.ts +28 -121
- package/src/modules/agent-instructions/agent-instructions.routes.ts +3 -2
- package/src/modules/agent-instructions/compose.ts +9 -6
- package/src/modules/agent-instructions/index.ts +0 -3
- package/src/modules/agent-instructions/shared-file-rules.ts +31 -93
- package/src/modules/mcp/__tests__/fake-downstream-mcp-server.ts +14 -3
- package/src/modules/mcp/__tests__/mcp.e2e.test.ts +250 -0
- package/src/modules/mcp/__tests__/mcp.service.test.ts +31 -23
- package/src/modules/mcp/__tests__/tool-schema-guard.test.ts +266 -0
- package/src/modules/mcp/mcp.service.ts +137 -19
- package/src/modules/mcp/tool-schema-guard.ts +196 -0
- package/src/modules/plugins/__tests__/plugins.tools.test.ts +154 -4
- package/src/modules/plugins/plugins.tools.ts +75 -15
- package/src/modules/settings/__tests__/deployment-settings.service.test.ts +26 -55
- package/src/modules/settings/deployment-settings.service.ts +13 -54
- package/src/modules/settings/setup.routes.ts +3 -6
- package/src/modules/skills/__tests__/skills.tools.description.test.ts +91 -0
- package/src/modules/skills/skills.tools.ts +62 -16
- package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +57 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +73 -4
- package/src/modules/tool-manuals/tool-manuals.contract.ts +24 -4
- package/src/modules/tool-manuals/tool-manuals.service.ts +17 -0
- package/src/modules/tool-manuals/tool-manuals.tools.ts +74 -36
- package/src/modules/tool-registry/__tests__/own-tool-schemas.test.ts +160 -0
- package/src/modules/tool-registry/__tests__/tool-description-length.test.ts +61 -59
- package/src/modules/tool-registry/description-length.ts +24 -26
- package/src/modules/tool-registry/guide-first.ts +34 -0
- package/src/modules/tool-registry/tool-registry.ts +9 -2
- package/src/modules/workflow/__tests__/apply-failure.test.ts +6 -1
- package/src/modules/workflow/agent-tools/__tests__/change-request-read-shape.test.ts +705 -0
- package/src/modules/workflow/agent-tools/__tests__/change-request-read.tools.test.ts +1518 -0
- package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +23 -2
- package/src/modules/workflow/agent-tools/change-request-read-shape.ts +712 -0
- package/src/modules/workflow/agent-tools/change-request-read.tools.ts +724 -0
- package/src/modules/workflow/agent-tools/change-request-summary.ts +5 -1
- package/src/modules/workflow/agent-tools/workflow.tools.ts +8 -0
- package/src/modules/workflow/git/__tests__/git.service.appliedChange.test.ts +285 -0
- package/src/modules/workflow/git/__tests__/git.service.changedFilesForPr.test.ts +124 -0
- package/src/modules/workflow/git/__tests__/git.service.mergeChangeRequest.test.ts +334 -0
- package/src/modules/workflow/git/__tests__/pull-request.service.list-fetch.test.ts +72 -2
- package/src/modules/workflow/git/__tests__/pull-request.service.placeholder.test.ts +24 -2
- package/src/modules/workflow/git/__tests__/pull-request.service.test.ts +620 -1
- package/src/modules/workflow/git/git.service.ts +537 -94
- package/src/modules/workflow/git/merge-commit.ts +88 -0
- package/src/modules/workflow/git/pull-request.service.ts +380 -54
- package/src/modules/workflow/review-workflow/__tests__/approval-states.test.ts +7 -1
- package/src/modules/workflow/review-workflow/__tests__/merge-records-own-commit.test.ts +407 -0
- package/src/modules/workflow/review-workflow/review-workflow.service.ts +189 -11
- package/src/modules/workflow/workflow.routes.ts +7 -2
- package/src/modules/workflow/workflow.service.ts +7 -0
- package/src/modules/workspace/__tests__/escape-sequences.routes.test.ts +4 -3
- package/src/modules/workspace/__tests__/workspace.routes.move-platform-files.test.ts +21 -10
- package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +33 -55
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +255 -22
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +191 -489
- package/src/modules/workspace/startup/steps/seed-tree.ts +21 -27
- package/src/modules/workspace/startup/steps/template-files.step.ts +217 -249
- package/src/modules/workspace/startup/steps/template-source.ts +5 -3
- package/src/modules/workspace/workspace.tools.ts +226 -16
- package/src/shared/domain-errors.ts +15 -0
- package/src/shared/hidden-tools.ts +45 -0
- package/kb-template/AGENTS.md +0 -730
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
* where the text specific to the tool sits, after whatever shared preamble it
|
|
6
6
|
* carried. Agents reported `file_stat`, `read_file`, `write_file` and
|
|
7
7
|
* `write_files` arriving ending in "[truncated]". The rules those descriptions
|
|
8
|
-
* shared now live in one place (see `agent-instructions/shared-file-rules.ts
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* shared now live in one place (see `agent-instructions/shared-file-rules.ts`,
|
|
9
|
+
* served in the guide `get_agent_guide` returns) and each description OPENS
|
|
10
|
+
* with the one sentence sending the agent there (`guide-first.ts`), which is
|
|
11
|
+
* what makes the cap below reachable rather than aspirational.
|
|
11
12
|
*/
|
|
12
13
|
import { TOOL_PREFIX_CAP } from '@bevel-software/platform-shared';
|
|
13
14
|
import { PREFIXED_TOOLS } from '../agent-instructions/compose.js';
|
|
14
|
-
import {
|
|
15
|
+
import { GUIDE_FIRST_SENTENCE } from './guide-first.js';
|
|
15
16
|
/**
|
|
16
17
|
* The ceiling on what a client is handed for one tool, enforced by
|
|
17
18
|
* `__tests__/tool-description-length.test.ts`.
|
|
@@ -22,8 +23,10 @@ import { SHARED_RULES_POINTER_MAX, sharedRulesPointer } from '../agent-instructi
|
|
|
22
23
|
* could answer: no useful description of `move_file` fits in 500. What answers
|
|
23
24
|
* that one is the ORDER of the text, which is why the deployment's purpose line
|
|
24
25
|
* is prepended rather than appended (see `prefixToolDescription`) and why every
|
|
25
|
-
* description now
|
|
26
|
-
*
|
|
26
|
+
* description now opens with the guide-first sentence and then what the tool
|
|
27
|
+
* does, with the tool's own detail last: a cut at 500 keeps the sentence and
|
|
28
|
+
* the tool's first sentence (see `firstSentenceEnd`) and takes the detail,
|
|
29
|
+
* which the guide states in full anyway. The other cut is the
|
|
27
30
|
* four-figure one agents reported on `file_stat`, `read_file`, `write_file` and
|
|
28
31
|
* `write_files`, and 1,200 sits below it with room to spare.
|
|
29
32
|
*
|
|
@@ -55,9 +58,10 @@ export const TOOL_DESCRIPTION_CAP = 1_200;
|
|
|
55
58
|
export const CLIENT_SHORT_CUT = 500;
|
|
56
59
|
/**
|
|
57
60
|
* Where the tool's OWN opening sentence ends in the text a client is handed:
|
|
58
|
-
* the purpose prefix counted at its cap, as in {@link clientVisibleLength},
|
|
59
|
-
* the
|
|
60
|
-
*
|
|
61
|
+
* the purpose prefix counted at its cap, as in {@link clientVisibleLength},
|
|
62
|
+
* and the guide-first sentence every listed tool opens with counted as the
|
|
63
|
+
* text it is — a client that cuts at 500 must still reach the sentence saying
|
|
64
|
+
* what the tool does, past that one.
|
|
61
65
|
*
|
|
62
66
|
* A description with no sentence-ending punctuation counts whole — the honest
|
|
63
67
|
* answer for text that never finishes a sentence.
|
|
@@ -67,10 +71,15 @@ export function firstSentenceEnd(tool) {
|
|
|
67
71
|
const description = tool.description ?? '';
|
|
68
72
|
if (description === '')
|
|
69
73
|
return prefix;
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
// The opener and whatever whitespace follows it: `guideFirstDescription`
|
|
75
|
+
// joins with one space, and leaves a description that already opens with
|
|
76
|
+
// the sentence as it came — a newline after it is still the opener's.
|
|
77
|
+
const opener = description.startsWith(GUIDE_FIRST_SENTENCE)
|
|
78
|
+
? GUIDE_FIRST_SENTENCE.length + (description.slice(GUIDE_FIRST_SENTENCE.length).match(/^\s*/)?.[0].length ?? 0)
|
|
79
|
+
: 0;
|
|
80
|
+
const own = description.slice(opener);
|
|
72
81
|
const firstSentence = own.match(/^[\s\S]*?[.!?](?=\s|$)/)?.[0] ?? own;
|
|
73
|
-
return prefix + firstSentence.length;
|
|
82
|
+
return prefix + opener + firstSentence.length;
|
|
74
83
|
}
|
|
75
84
|
/**
|
|
76
85
|
* The length of the description as a CLIENT receives it — which for the four
|
|
@@ -80,12 +89,8 @@ export function firstSentenceEnd(tool) {
|
|
|
80
89
|
* the cap is what an admin may grow their text to without being told, so a
|
|
81
90
|
* description that only fits beside a short prefix does not really fit.
|
|
82
91
|
*
|
|
83
|
-
* The
|
|
84
|
-
*
|
|
85
|
-
* — the guide's file name — so a description measured beside the nine
|
|
86
|
-
* characters of `AGENTS.md` would pass here and arrive cut on a deployment
|
|
87
|
-
* that renamed its guide. Whatever pointer a description actually carries is
|
|
88
|
-
* discounted and charged at {@link SHARED_RULES_POINTER_MAX} instead.
|
|
92
|
+
* The guide-first sentence every listed tool opens with is already in the
|
|
93
|
+
* description the registry lists, so it is measured as the text it is.
|
|
89
94
|
*/
|
|
90
95
|
export function clientVisibleLength(tool) {
|
|
91
96
|
const own = tool.description?.length ?? 0;
|
|
@@ -95,14 +100,7 @@ export function clientVisibleLength(tool) {
|
|
|
95
100
|
// text the client got.
|
|
96
101
|
if (own === 0)
|
|
97
102
|
return PREFIXED_TOOLS.has(tool.name) ? TOOL_PREFIX_CAP : 0;
|
|
98
|
-
// The pointer at its worst case rather than at this layout's: swap the one
|
|
99
|
-
// it carries for the longest it could be. A description that does not end
|
|
100
|
-
// with it (`start_session`, the proxied tools) is charged nothing.
|
|
101
|
-
const pointer = sharedRulesPointer();
|
|
102
|
-
const atWorstPointer = tool.description.endsWith(pointer)
|
|
103
|
-
? own - pointer.length + SHARED_RULES_POINTER_MAX
|
|
104
|
-
: own;
|
|
105
103
|
// `+ 2` for the blank line `prefixToolDescription` puts between the two.
|
|
106
|
-
return PREFIXED_TOOLS.has(tool.name) ?
|
|
104
|
+
return PREFIXED_TOOLS.has(tool.name) ? own + TOOL_PREFIX_CAP + 2 : own;
|
|
107
105
|
}
|
|
108
106
|
//# sourceMappingURL=description-length.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"description-length.js","sourceRoot":"","sources":["../../../src/modules/tool-registry/description-length.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"description-length.js","sourceRoot":"","sources":["../../../src/modules/tool-registry/description-length.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAA4C;IAC3E,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;IAC3C,IAAI,WAAW,KAAK,EAAE;QAAE,OAAO,MAAM,CAAC;IACtC,yEAAyE;IACzE,yEAAyE;IACzE,sEAAsE;IACtE,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,oBAAoB,CAAC;QACzD,CAAC,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC,CAAC;IACN,MAAM,GAAG,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,GAAG,CAAC,KAAK,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;IACtE,OAAO,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;AAChD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAA4C;IAC9E,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC,CAAC;IAC1C,6EAA6E;IAC7E,6EAA6E;IAC7E,0EAA0E;IAC1E,uBAAuB;IACvB,IAAI,GAAG,KAAK,CAAC;QAAE,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,yEAAyE;IACzE,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UtcpTool } from './tool.contract.js';
|
|
2
|
+
/** The one tool that returns the platform's guide (see `modules/agent-guide`). */
|
|
3
|
+
export declare const GET_AGENT_GUIDE_TOOL = "get_agent_guide";
|
|
4
|
+
/**
|
|
5
|
+
* The sentence every tool of the platform's own OPENS with: what to do before
|
|
6
|
+
* anything else here. At the front, not the end, because clients cut a long
|
|
7
|
+
* description from the end and the one instruction that must survive is this
|
|
8
|
+
* one. The guide's own tool is the one that does not carry it — it IS what
|
|
9
|
+
* the sentence points at.
|
|
10
|
+
*/
|
|
11
|
+
export declare const GUIDE_FIRST_SENTENCE = "Call `get_agent_guide` first and read the platform's guide before anything else here.";
|
|
12
|
+
/**
|
|
13
|
+
* `description` as a client is handed it: the sentence ahead of it, once. A
|
|
14
|
+
* description that already opens with the sentence is returned as it is, and
|
|
15
|
+
* an absent or empty one becomes the sentence alone. The ONE place the
|
|
16
|
+
* sentence is put in front of a description — the registry for the tools it
|
|
17
|
+
* lists, the MCP service for the meta-tools it builds itself — so the two
|
|
18
|
+
* cannot drift apart on what "once" means.
|
|
19
|
+
*/
|
|
20
|
+
export declare function guideFirstDescription(description: string | undefined): string;
|
|
21
|
+
/** `tool` as the catalog lists it: the sentence ahead of its own description, except on the guide's own tool. */
|
|
22
|
+
export declare function withGuideFirst(tool: UtcpTool): UtcpTool;
|
|
23
|
+
//# sourceMappingURL=guide-first.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide-first.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-registry/guide-first.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,0FAAoG,CAAC;AAEtI;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAI7E;AAED,iHAAiH;AACjH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAIvD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** The one tool that returns the platform's guide (see `modules/agent-guide`). */
|
|
2
|
+
export const GET_AGENT_GUIDE_TOOL = 'get_agent_guide';
|
|
3
|
+
/**
|
|
4
|
+
* The sentence every tool of the platform's own OPENS with: what to do before
|
|
5
|
+
* anything else here. At the front, not the end, because clients cut a long
|
|
6
|
+
* description from the end and the one instruction that must survive is this
|
|
7
|
+
* one. The guide's own tool is the one that does not carry it — it IS what
|
|
8
|
+
* the sentence points at.
|
|
9
|
+
*/
|
|
10
|
+
export const GUIDE_FIRST_SENTENCE = `Call \`${GET_AGENT_GUIDE_TOOL}\` first and read the platform's guide before anything else here.`;
|
|
11
|
+
/**
|
|
12
|
+
* `description` as a client is handed it: the sentence ahead of it, once. A
|
|
13
|
+
* description that already opens with the sentence is returned as it is, and
|
|
14
|
+
* an absent or empty one becomes the sentence alone. The ONE place the
|
|
15
|
+
* sentence is put in front of a description — the registry for the tools it
|
|
16
|
+
* lists, the MCP service for the meta-tools it builds itself — so the two
|
|
17
|
+
* cannot drift apart on what "once" means.
|
|
18
|
+
*/
|
|
19
|
+
export function guideFirstDescription(description) {
|
|
20
|
+
const own = description ?? '';
|
|
21
|
+
if (own.startsWith(GUIDE_FIRST_SENTENCE))
|
|
22
|
+
return own;
|
|
23
|
+
return own ? `${GUIDE_FIRST_SENTENCE} ${own}` : GUIDE_FIRST_SENTENCE;
|
|
24
|
+
}
|
|
25
|
+
/** `tool` as the catalog lists it: the sentence ahead of its own description, except on the guide's own tool. */
|
|
26
|
+
export function withGuideFirst(tool) {
|
|
27
|
+
if (tool.name === GET_AGENT_GUIDE_TOOL)
|
|
28
|
+
return tool;
|
|
29
|
+
const description = guideFirstDescription(tool.description);
|
|
30
|
+
return description === tool.description ? tool : { ...tool, description };
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=guide-first.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide-first.js","sourceRoot":"","sources":["../../../src/modules/tool-registry/guide-first.ts"],"names":[],"mappings":"AAEA,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,oBAAoB,mEAAmE,CAAC;AAEtI;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAA+B;IACnE,MAAM,GAAG,GAAG,WAAW,IAAI,EAAE,CAAC;IAC9B,IAAI,GAAG,CAAC,UAAU,CAAC,oBAAoB,CAAC;QAAE,OAAO,GAAG,CAAC;IACrD,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,oBAAoB,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC;AACvE,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,cAAc,CAAC,IAAc;IAC3C,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAoB;QAAE,OAAO,IAAI,CAAC;IACpD,MAAM,WAAW,GAAG,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5D,OAAO,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,CAAC;AAC5E,CAAC"}
|
|
@@ -6,6 +6,12 @@ import type { IToolRegistry, ToolListProvider, ToolManualContext, ToolProvider,
|
|
|
6
6
|
* catalog only aggregates and lists them — the two manual endpoints serialize
|
|
7
7
|
* each list per request. Insertion order is preserved (static tools first, then
|
|
8
8
|
* provider-built ones); a duplicate static name within a surface throws.
|
|
9
|
+
*
|
|
10
|
+
* Every listed tool but the guide's own (`get_agent_guide`, which is what the
|
|
11
|
+
* sentence points at) opens with the one sentence saying what to do before
|
|
12
|
+
* any of them (`guide-first.ts`): applied here, at the one place both
|
|
13
|
+
* surfaces list from, so no module that registers a tool has to remember it
|
|
14
|
+
* and no surface can serve a tool without it.
|
|
9
15
|
*/
|
|
10
16
|
export declare class ToolRegistry implements IToolRegistry {
|
|
11
17
|
private readonly external;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-registry/tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACT,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-registry/tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAa,YAAW,aAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+B;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+B;IACxD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAsB;IACxD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAsB;IACxD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA0B;IAEhE,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,YAAY,GAAG,IAAI;IAKzD,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,YAAY,GAAG,IAAI;IAKzD,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAIjD,YAAY,CAAC,GAAG,GAAE,iBAAsB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAK9D,YAAY,CAAC,GAAG,GAAE,iBAAsB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAMpE,OAAO,CAAC,GAAG;CAMZ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withGuideFirst } from './guide-first.js';
|
|
1
2
|
/**
|
|
2
3
|
* The tool catalog. Modules call `registerExternalTool` / `registerInternalTool`
|
|
3
4
|
* (both, for a `both` tool) with a self-describing UTCP `Tool` def, or a
|
|
@@ -5,6 +6,12 @@
|
|
|
5
6
|
* catalog only aggregates and lists them — the two manual endpoints serialize
|
|
6
7
|
* each list per request. Insertion order is preserved (static tools first, then
|
|
7
8
|
* provider-built ones); a duplicate static name within a surface throws.
|
|
9
|
+
*
|
|
10
|
+
* Every listed tool but the guide's own (`get_agent_guide`, which is what the
|
|
11
|
+
* sentence points at) opens with the one sentence saying what to do before
|
|
12
|
+
* any of them (`guide-first.ts`): applied here, at the one place both
|
|
13
|
+
* surfaces list from, so no module that registers a tool has to remember it
|
|
14
|
+
* and no surface can serve a tool without it.
|
|
8
15
|
*/
|
|
9
16
|
export class ToolRegistry {
|
|
10
17
|
external = new Map();
|
|
@@ -29,12 +36,12 @@ export class ToolRegistry {
|
|
|
29
36
|
}
|
|
30
37
|
async listExternal(ctx = {}) {
|
|
31
38
|
const dynamic = await Promise.all(this.externalProviders.map((p) => p(ctx)));
|
|
32
|
-
return [...this.external.values(), ...dynamic];
|
|
39
|
+
return [...this.external.values(), ...dynamic].map(withGuideFirst);
|
|
33
40
|
}
|
|
34
41
|
async listInternal(ctx = {}) {
|
|
35
42
|
const dynamic = await Promise.all(this.internalProviders.map((p) => p(ctx)));
|
|
36
43
|
const lists = await Promise.all(this.internalListProviders.map((p) => p(ctx)));
|
|
37
|
-
return [...this.internal.values(), ...dynamic, ...lists.flat()];
|
|
44
|
+
return [...this.internal.values(), ...dynamic, ...lists.flat()].map(withGuideFirst);
|
|
38
45
|
}
|
|
39
46
|
add(into, tool, surface) {
|
|
40
47
|
if (into.has(tool.name)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../../../src/modules/tool-registry/tool-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../../../src/modules/tool-registry/tool-registry.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,YAAY;IACN,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvC,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvC,iBAAiB,GAAmB,EAAE,CAAC;IACvC,iBAAiB,GAAmB,EAAE,CAAC;IACvC,qBAAqB,GAAuB,EAAE,CAAC;IAEhE,oBAAoB,CAAC,IAA6B;QAChD,IAAI,OAAO,IAAI,KAAK,UAAU;YAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;YAC7D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,oBAAoB,CAAC,IAA6B;QAChD,IAAI,OAAO,IAAI,KAAK,UAAU;YAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;YAC7D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,qBAAqB,CAAC,QAA0B;QAC9C,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAyB,EAAE;QAC5C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC7E,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAyB,EAAE;QAC5C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC7E,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/E,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACtF,CAAC;IAEO,GAAG,CAAC,IAA2B,EAAE,IAAc,EAAE,OAAe;QACtE,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,aAAa,OAAO,gBAAgB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACpE,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF"}
|