@burtson-labs/agent-core 1.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +88 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/activation.d.ts +60 -0
- package/dist/mcp/activation.d.ts.map +1 -0
- package/dist/mcp/activation.js +139 -0
- package/dist/mcp/activation.js.map +1 -0
- package/dist/mcp/clientPool.d.ts +202 -0
- package/dist/mcp/clientPool.d.ts.map +1 -0
- package/dist/mcp/clientPool.js +469 -0
- package/dist/mcp/clientPool.js.map +1 -0
- package/dist/mcp/index.d.ts +18 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +28 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +43 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +130 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/toolAdapter.d.ts +57 -0
- package/dist/mcp/toolAdapter.d.ts.map +1 -0
- package/dist/mcp/toolAdapter.js +223 -0
- package/dist/mcp/toolAdapter.js.map +1 -0
- package/dist/mcp/types.d.ts +122 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +15 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/providers/deterministic-provider.d.ts +21 -0
- package/dist/providers/deterministic-provider.d.ts.map +1 -0
- package/dist/providers/deterministic-provider.js +80 -0
- package/dist/providers/deterministic-provider.js.map +1 -0
- package/dist/providers/provider-client.d.ts +12 -0
- package/dist/providers/provider-client.d.ts.map +1 -0
- package/dist/providers/provider-client.js +11 -0
- package/dist/providers/provider-client.js.map +1 -0
- package/dist/runtime/AgentRuntime.d.ts +67 -0
- package/dist/runtime/AgentRuntime.d.ts.map +1 -0
- package/dist/runtime/AgentRuntime.js +382 -0
- package/dist/runtime/AgentRuntime.js.map +1 -0
- package/dist/security/secretPatterns.d.ts +76 -0
- package/dist/security/secretPatterns.d.ts.map +1 -0
- package/dist/security/secretPatterns.js +290 -0
- package/dist/security/secretPatterns.js.map +1 -0
- package/dist/tools/ask-user-tool.d.ts +19 -0
- package/dist/tools/ask-user-tool.d.ts.map +1 -0
- package/dist/tools/ask-user-tool.js +148 -0
- package/dist/tools/ask-user-tool.js.map +1 -0
- package/dist/tools/compactMessages.d.ts +52 -0
- package/dist/tools/compactMessages.d.ts.map +1 -0
- package/dist/tools/compactMessages.js +158 -0
- package/dist/tools/compactMessages.js.map +1 -0
- package/dist/tools/core-tools.d.ts +29 -0
- package/dist/tools/core-tools.d.ts.map +1 -0
- package/dist/tools/core-tools.js +2214 -0
- package/dist/tools/core-tools.js.map +1 -0
- package/dist/tools/git-tools.d.ts +32 -0
- package/dist/tools/git-tools.d.ts.map +1 -0
- package/dist/tools/git-tools.js +330 -0
- package/dist/tools/git-tools.js.map +1 -0
- package/dist/tools/index.d.ts +15 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +31 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/language-adapters.d.ts +48 -0
- package/dist/tools/language-adapters.d.ts.map +1 -0
- package/dist/tools/language-adapters.js +299 -0
- package/dist/tools/language-adapters.js.map +1 -0
- package/dist/tools/loop/compactionTrigger.d.ts +47 -0
- package/dist/tools/loop/compactionTrigger.d.ts.map +1 -0
- package/dist/tools/loop/compactionTrigger.js +32 -0
- package/dist/tools/loop/compactionTrigger.js.map +1 -0
- package/dist/tools/loop/finalAnswerNudges.d.ts +68 -0
- package/dist/tools/loop/finalAnswerNudges.d.ts.map +1 -0
- package/dist/tools/loop/finalAnswerNudges.js +87 -0
- package/dist/tools/loop/finalAnswerNudges.js.map +1 -0
- package/dist/tools/loop/goalAnchor.d.ts +72 -0
- package/dist/tools/loop/goalAnchor.d.ts.map +1 -0
- package/dist/tools/loop/goalAnchor.js +76 -0
- package/dist/tools/loop/goalAnchor.js.map +1 -0
- package/dist/tools/loop/llmStream.d.ts +70 -0
- package/dist/tools/loop/llmStream.d.ts.map +1 -0
- package/dist/tools/loop/llmStream.js +181 -0
- package/dist/tools/loop/llmStream.js.map +1 -0
- package/dist/tools/loop/parallelExecute.d.ts +57 -0
- package/dist/tools/loop/parallelExecute.d.ts.map +1 -0
- package/dist/tools/loop/parallelExecute.js +54 -0
- package/dist/tools/loop/parallelExecute.js.map +1 -0
- package/dist/tools/loop/singleToolExecute.d.ts +71 -0
- package/dist/tools/loop/singleToolExecute.d.ts.map +1 -0
- package/dist/tools/loop/singleToolExecute.js +139 -0
- package/dist/tools/loop/singleToolExecute.js.map +1 -0
- package/dist/tools/loop/toolCallNormalize.d.ts +57 -0
- package/dist/tools/loop/toolCallNormalize.d.ts.map +1 -0
- package/dist/tools/loop/toolCallNormalize.js +99 -0
- package/dist/tools/loop/toolCallNormalize.js.map +1 -0
- package/dist/tools/loop/turnSetup.d.ts +43 -0
- package/dist/tools/loop/turnSetup.d.ts.map +1 -0
- package/dist/tools/loop/turnSetup.js +48 -0
- package/dist/tools/loop/turnSetup.js.map +1 -0
- package/dist/tools/ocr.d.ts +52 -0
- package/dist/tools/ocr.d.ts.map +1 -0
- package/dist/tools/ocr.js +238 -0
- package/dist/tools/ocr.js.map +1 -0
- package/dist/tools/post-edit-checks.d.ts +46 -0
- package/dist/tools/post-edit-checks.d.ts.map +1 -0
- package/dist/tools/post-edit-checks.js +236 -0
- package/dist/tools/post-edit-checks.js.map +1 -0
- package/dist/tools/skill-loader.d.ts +94 -0
- package/dist/tools/skill-loader.d.ts.map +1 -0
- package/dist/tools/skill-loader.js +422 -0
- package/dist/tools/skill-loader.js.map +1 -0
- package/dist/tools/skill-registry.d.ts +44 -0
- package/dist/tools/skill-registry.d.ts.map +1 -0
- package/dist/tools/skill-registry.js +118 -0
- package/dist/tools/skill-registry.js.map +1 -0
- package/dist/tools/skill-types.d.ts +38 -0
- package/dist/tools/skill-types.d.ts.map +1 -0
- package/dist/tools/skill-types.js +10 -0
- package/dist/tools/skill-types.js.map +1 -0
- package/dist/tools/skills/code-review-skill.d.ts +9 -0
- package/dist/tools/skills/code-review-skill.d.ts.map +1 -0
- package/dist/tools/skills/code-review-skill.js +66 -0
- package/dist/tools/skills/code-review-skill.js.map +1 -0
- package/dist/tools/skills/core-skill.d.ts +13 -0
- package/dist/tools/skills/core-skill.d.ts.map +1 -0
- package/dist/tools/skills/core-skill.js +23 -0
- package/dist/tools/skills/core-skill.js.map +1 -0
- package/dist/tools/skills/git-skill.d.ts +10 -0
- package/dist/tools/skills/git-skill.d.ts.map +1 -0
- package/dist/tools/skills/git-skill.js +30 -0
- package/dist/tools/skills/git-skill.js.map +1 -0
- package/dist/tools/skills/index.d.ts +17 -0
- package/dist/tools/skills/index.d.ts.map +1 -0
- package/dist/tools/skills/index.js +49 -0
- package/dist/tools/skills/index.js.map +1 -0
- package/dist/tools/skills/interaction-skill.d.ts +14 -0
- package/dist/tools/skills/interaction-skill.d.ts.map +1 -0
- package/dist/tools/skills/interaction-skill.js +24 -0
- package/dist/tools/skills/interaction-skill.js.map +1 -0
- package/dist/tools/skills/mail-search-skill.d.ts +25 -0
- package/dist/tools/skills/mail-search-skill.d.ts.map +1 -0
- package/dist/tools/skills/mail-search-skill.js +343 -0
- package/dist/tools/skills/mail-search-skill.js.map +1 -0
- package/dist/tools/skills/plan-skill.d.ts +10 -0
- package/dist/tools/skills/plan-skill.d.ts.map +1 -0
- package/dist/tools/skills/plan-skill.js +126 -0
- package/dist/tools/skills/plan-skill.js.map +1 -0
- package/dist/tools/skills/semantic-search-skill.d.ts +22 -0
- package/dist/tools/skills/semantic-search-skill.d.ts.map +1 -0
- package/dist/tools/skills/semantic-search-skill.js +244 -0
- package/dist/tools/skills/semantic-search-skill.js.map +1 -0
- package/dist/tools/skills/test-gen-skill.d.ts +9 -0
- package/dist/tools/skills/test-gen-skill.d.ts.map +1 -0
- package/dist/tools/skills/test-gen-skill.js +123 -0
- package/dist/tools/skills/test-gen-skill.js.map +1 -0
- package/dist/tools/tool-registry.d.ts +60 -0
- package/dist/tools/tool-registry.d.ts.map +1 -0
- package/dist/tools/tool-registry.js +200 -0
- package/dist/tools/tool-registry.js.map +1 -0
- package/dist/tools/tool-types.d.ts +281 -0
- package/dist/tools/tool-types.d.ts.map +1 -0
- package/dist/tools/tool-types.js +10 -0
- package/dist/tools/tool-types.js.map +1 -0
- package/dist/tools/tool-use-loop.d.ts +231 -0
- package/dist/tools/tool-use-loop.d.ts.map +1 -0
- package/dist/tools/tool-use-loop.js +2057 -0
- package/dist/tools/tool-use-loop.js.map +1 -0
- package/dist/tools/tool-use-parser.d.ts +78 -0
- package/dist/tools/tool-use-parser.d.ts.map +1 -0
- package/dist/tools/tool-use-parser.js +427 -0
- package/dist/tools/tool-use-parser.js.map +1 -0
- package/dist/tools/toolAvailabilityDetector.d.ts +48 -0
- package/dist/tools/toolAvailabilityDetector.d.ts.map +1 -0
- package/dist/tools/toolAvailabilityDetector.js +156 -0
- package/dist/tools/toolAvailabilityDetector.js.map +1 -0
- package/dist/tools/unified-patch.d.ts +87 -0
- package/dist/tools/unified-patch.d.ts.map +1 -0
- package/dist/tools/unified-patch.js +217 -0
- package/dist/tools/unified-patch.js.map +1 -0
- package/dist/types/agent.d.ts +69 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +54 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/tasks.d.ts +22 -0
- package/dist/types/tasks.d.ts.map +1 -0
- package/dist/types/tasks.js +3 -0
- package/dist/types/tasks.js.map +1 -0
- package/dist/utils/event-emitter.d.ts +13 -0
- package/dist/utils/event-emitter.d.ts.map +1 -0
- package/dist/utils/event-emitter.js +54 -0
- package/dist/utils/event-emitter.js.map +1 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for acceptance of support, warranty, indemnity, or other liability
|
|
168
|
+
obligations and/or rights consistent with this License. However, in
|
|
169
|
+
accepting such obligations, You may act only on Your own behalf
|
|
170
|
+
and on Your sole responsibility, not on behalf of any other Contributor,
|
|
171
|
+
and only if You agree to indemnify, defend, and hold each Contributor
|
|
172
|
+
harmless for any liability incurred by, or claims asserted against,
|
|
173
|
+
such Contributor by reason of your accepting any such warranty or
|
|
174
|
+
additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Burtson Labs
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.burtson.ai/logos/burtson-labs-logo-alt.png" />
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://cdn.burtson.ai/logos/burtson-labs-logo.png" />
|
|
5
|
+
<img src="https://cdn.burtson.ai/logos/burtson-labs-logo-alt.png" alt="Burtson Labs" width="150" />
|
|
6
|
+
</picture>
|
|
7
|
+
|
|
8
|
+
# @burtson-labs/agent-core
|
|
9
|
+
|
|
10
|
+
**Core reasoning and planning engine for the Bandit Agent Framework.**
|
|
11
|
+
|
|
12
|
+
Owns the `ToolUseLoop` — the iteration controller that drives every Bandit agent run, parent or subagent, in both the VS Code extension and the CLI host.
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## <img src="https://api.iconify.design/lucide/package.svg?color=%23a60ee5&width=22" align="absmiddle"> Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @burtson-labs/agent-core
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## <img src="https://api.iconify.design/lucide/puzzle.svg?color=%23a60ee5&width=22" align="absmiddle"> What's inside
|
|
24
|
+
|
|
25
|
+
| Path | Purpose |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `src/tools/tool-use-loop.ts` | The loop itself. Orchestrates LLM call → response parsing → detector pass → tool execution → repeat. |
|
|
28
|
+
| `src/tools/tool-use-parser.ts` | Extracts `<tool_call>` envelopes (XML, fenced, bare-JSON, pythonic fallbacks). |
|
|
29
|
+
| `src/tools/tool-registry.ts` | Tool registration + native-schema generation for Ollama's `tools` field. |
|
|
30
|
+
| `src/tools/core-tools.ts` | Built-in tools: `read_file`, `apply_edit`, `apply_patch`, `run_command`, `git_*`, etc. |
|
|
31
|
+
| `src/tools/compactMessages.ts` | Greedy compaction of stale tool-result messages when the message-token budget bites. |
|
|
32
|
+
| `src/tools/post-edit-checks.ts` | Auto type-check after TS/TSX edits. |
|
|
33
|
+
|
|
34
|
+
## <img src="https://api.iconify.design/lucide/flask-conical.svg?color=%23a60ee5&width=22" align="absmiddle"> Running tests
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pnpm --filter @burtson-labs/agent-core test
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The suite is split across **synthetic contract tests** (one file per detector cluster) and **real-trace replay tests** (turn logs from `.bandit/turns/` replayed through a fresh loop):
|
|
41
|
+
|
|
42
|
+
| Concern | File |
|
|
43
|
+
|---|---|
|
|
44
|
+
| Constructor options merged into runtime | [test/constructorOptionsContract.test.ts](test/constructorOptionsContract.test.ts) |
|
|
45
|
+
| "Claim without doing" detectors (false-completion, partial-completion, announce-then-stall) | [test/claimWithoutDoingDetectors.test.ts](test/claimWithoutDoingDetectors.test.ts) |
|
|
46
|
+
| "Structured output instead of tool" detectors (code-fence, JSON-todo auto-promote) | [test/structuredOutputDetectors.test.ts](test/structuredOutputDetectors.test.ts) |
|
|
47
|
+
| Loop detectors (prose-loop, todo-churn) | [test/loopDetectors.test.ts](test/loopDetectors.test.ts) |
|
|
48
|
+
| Malformed/empty recovery (empty-retry, thinking-off-recovery, parse-retry) | [test/malformedEmptyDetectors.test.ts](test/malformedEmptyDetectors.test.ts) |
|
|
49
|
+
| Hallucinated `<tool_result>` recovery | [test/hallucinationDetectors.test.ts](test/hallucinationDetectors.test.ts) |
|
|
50
|
+
| Subagent coordination (fired-and-forgotten) | [test/subagentCoordinationDetectors.test.ts](test/subagentCoordinationDetectors.test.ts) |
|
|
51
|
+
| Tool execution edge cases (dedup, cap, repeat-breaker, not-found, error, todo-progress) | [test/toolExecutionDetectors.test.ts](test/toolExecutionDetectors.test.ts) |
|
|
52
|
+
| Cancellation contract | [test/cancellationContract.test.ts](test/cancellationContract.test.ts) |
|
|
53
|
+
| Compaction + goal-anchor contract | [test/compactionContract.test.ts](test/compactionContract.test.ts) |
|
|
54
|
+
| Real-trace replay | [test/turnReplay.test.ts](test/turnReplay.test.ts) |
|
|
55
|
+
|
|
56
|
+
### Adding a regression fixture from a real failure trace
|
|
57
|
+
|
|
58
|
+
When you see a weird agent behavior in a real run, drop the turn-log fixture into the test suite so a future loop change can't silently regress it. **See [test/fixtures/turns/README.md](test/fixtures/turns/README.md)** for the full guide — replay-completeness limits, naming conventions, what to assert, and a copy-paste test template.
|
|
59
|
+
|
|
60
|
+
## <img src="https://api.iconify.design/lucide/book-open.svg?color=%23a60ee5&width=22" align="absmiddle"> Conventions
|
|
61
|
+
|
|
62
|
+
- **Every detector is one-shot per turn.** Each `tool_loop:*_nudge` event fires at most once before the loop terminates or the model recovers. Adding a new detector means adding the gate flag + a contract test.
|
|
63
|
+
- **Constructor options must flow through to runtime.** `ToolUseLoopOptions` set at construction time apply to every `runWithMessages` call. The merge happens in `runWithMessages` — see `effectiveOptions = { ...defaultOptions, ...perCall }`. New options need a corresponding entry in [test/constructorOptionsContract.test.ts](test/constructorOptionsContract.test.ts) (the file's exhaustiveness check fails build if you forget).
|
|
64
|
+
- **Helpers go in `test/_helpers.ts`; the replay harness in `test/_replay.ts`.** Both file names start with `_` so they're excluded from vitest's `test/**/*.test.ts` glob.
|
|
65
|
+
|
|
66
|
+
## <img src="https://api.iconify.design/lucide/network.svg?color=%23a60ee5&width=22" align="absmiddle"> Position in the framework
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
[host: VS Code extension or CLI]
|
|
70
|
+
│
|
|
71
|
+
▼
|
|
72
|
+
┌──────────────┐
|
|
73
|
+
│ ToolUseLoop │ ← this package
|
|
74
|
+
└──────┬───────┘
|
|
75
|
+
│
|
|
76
|
+
┌─────┴─────┐
|
|
77
|
+
▼ ▼
|
|
78
|
+
[tool registry] [chat function]
|
|
79
|
+
│ │
|
|
80
|
+
▼ ▼
|
|
81
|
+
[host-kit tools] [Ollama / Bandit cloud / etc.]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The loop is host-agnostic. Hosts wire up the chat function (with their own watchdogs / streaming / auth) and supply a tool registry; the loop owns iteration, retry/fallback policy, compaction, output-budget serialization, and the detector contract.
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
[Apache License 2.0](../../LICENSE) — Copyright 2026 Burtson Labs.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AgentRuntime, AgentRuntimeOptions } from "./runtime/AgentRuntime";
|
|
2
|
+
import type { ProviderClient } from "./providers/provider-client";
|
|
3
|
+
export * from "./types/agent";
|
|
4
|
+
export * from "./types/tasks";
|
|
5
|
+
export { validateAgentPlan } from "./types/agent";
|
|
6
|
+
export { ProviderClient, ProviderChatOptions, collectFromStream } from "./providers/provider-client";
|
|
7
|
+
export { DeterministicProviderClient, DeterministicProviderConfig } from "./providers/deterministic-provider";
|
|
8
|
+
export { AgentRuntime, AgentRuntimeOptions, AgentTelemetry, AgentLogger, PlanOptions, ExecuteOptions, StepExecutor, StepExecutorContext, StepExecutorOutput } from "./runtime/AgentRuntime";
|
|
9
|
+
export interface CreateAgentRuntimeOptions extends Partial<Omit<AgentRuntimeOptions, "provider">> {
|
|
10
|
+
provider?: ProviderClient;
|
|
11
|
+
}
|
|
12
|
+
export declare const createAgentRuntime: (options?: CreateAgentRuntimeOptions) => AgentRuntime;
|
|
13
|
+
export * from './tools';
|
|
14
|
+
export * from './mcp';
|
|
15
|
+
export { redactSecrets, redactSecretsString, BUILTIN_SECRET_PATTERNS, type SecretPattern, type RedactionResult } from './security/secretPatterns';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,yBAA0B,SAAQ,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;IAC/F,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAS,yBAA8B,KAAG,YAO5E,CAAC;AAGF,cAAc,SAAS,CAAC;AAKxB,cAAc,OAAO,CAAC;AAKtB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.BUILTIN_SECRET_PATTERNS = exports.redactSecretsString = exports.redactSecrets = exports.createAgentRuntime = exports.AgentRuntime = exports.DeterministicProviderClient = exports.collectFromStream = exports.validateAgentPlan = void 0;
|
|
18
|
+
const AgentRuntime_1 = require("./runtime/AgentRuntime");
|
|
19
|
+
const deterministic_provider_1 = require("./providers/deterministic-provider");
|
|
20
|
+
__exportStar(require("./types/agent"), exports);
|
|
21
|
+
__exportStar(require("./types/tasks"), exports);
|
|
22
|
+
var agent_1 = require("./types/agent");
|
|
23
|
+
Object.defineProperty(exports, "validateAgentPlan", { enumerable: true, get: function () { return agent_1.validateAgentPlan; } });
|
|
24
|
+
var provider_client_1 = require("./providers/provider-client");
|
|
25
|
+
Object.defineProperty(exports, "collectFromStream", { enumerable: true, get: function () { return provider_client_1.collectFromStream; } });
|
|
26
|
+
var deterministic_provider_2 = require("./providers/deterministic-provider");
|
|
27
|
+
Object.defineProperty(exports, "DeterministicProviderClient", { enumerable: true, get: function () { return deterministic_provider_2.DeterministicProviderClient; } });
|
|
28
|
+
var AgentRuntime_2 = require("./runtime/AgentRuntime");
|
|
29
|
+
Object.defineProperty(exports, "AgentRuntime", { enumerable: true, get: function () { return AgentRuntime_2.AgentRuntime; } });
|
|
30
|
+
const createAgentRuntime = (options = {}) => {
|
|
31
|
+
const { provider: providerOverride, ...rest } = options;
|
|
32
|
+
const provider = providerOverride ?? new deterministic_provider_1.DeterministicProviderClient();
|
|
33
|
+
return new AgentRuntime_1.AgentRuntime({
|
|
34
|
+
provider,
|
|
35
|
+
...rest
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.createAgentRuntime = createAgentRuntime;
|
|
39
|
+
// Tool system
|
|
40
|
+
__exportStar(require("./tools"), exports);
|
|
41
|
+
// MCP — Model Context Protocol client (Phase 1: groundwork). See
|
|
42
|
+
// docs/integration-playlist/mcp-roadmap.md. Off by default — hosts
|
|
43
|
+
// that don't construct an McpClientPool get zero behavior change.
|
|
44
|
+
__exportStar(require("./mcp"), exports);
|
|
45
|
+
// Secret-leak protection. Redacts API keys, tokens, and
|
|
46
|
+
// private keys from tool output before they hit the model context,
|
|
47
|
+
// the terminal, or the on-disk session log.
|
|
48
|
+
var secretPatterns_1 = require("./security/secretPatterns");
|
|
49
|
+
Object.defineProperty(exports, "redactSecrets", { enumerable: true, get: function () { return secretPatterns_1.redactSecrets; } });
|
|
50
|
+
Object.defineProperty(exports, "redactSecretsString", { enumerable: true, get: function () { return secretPatterns_1.redactSecretsString; } });
|
|
51
|
+
Object.defineProperty(exports, "BUILTIN_SECRET_PATTERNS", { enumerable: true, get: function () { return secretPatterns_1.BUILTIN_SECRET_PATTERNS; } });
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAA2E;AAC3E,+EAAiF;AAGjF,gDAA8B;AAC9B,gDAA8B;AAC9B,uCAAkD;AAAzC,0GAAA,iBAAiB,OAAA;AAE1B,+DAIqC;AADnC,oHAAA,iBAAiB,OAAA;AAGnB,6EAG4C;AAF1C,qIAAA,2BAA2B,OAAA;AAI7B,uDAUgC;AAT9B,4GAAA,YAAY,OAAA;AAeP,MAAM,kBAAkB,GAAG,CAAC,UAAqC,EAAE,EAAgB,EAAE;IAC1F,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,QAAQ,GAAG,gBAAgB,IAAI,IAAI,oDAA2B,EAAE,CAAC;IACvE,OAAO,IAAI,2BAAY,CAAC;QACtB,QAAQ;QACR,GAAI,IAA8C;KACnD,CAAC,CAAC;AACL,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B;AAEF,cAAc;AACd,0CAAwB;AAExB,iEAAiE;AACjE,mEAAmE;AACnE,kEAAkE;AAClE,wCAAsB;AAEtB,wDAAwD;AACxD,mEAAmE;AACnE,4CAA4C;AAC5C,4DAMmC;AALjC,+GAAA,aAAa,OAAA;AACb,qHAAA,mBAAmB,OAAA;AACnB,yHAAA,uBAAuB,OAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP server activation — decides which servers should contribute
|
|
3
|
+
* tools to the current turn's registry.
|
|
4
|
+
*
|
|
5
|
+
* - "always" (default): every prompt registers the server's tools.
|
|
6
|
+
* Backwards compatible with the - behavior.
|
|
7
|
+
* - "on-mention": tools register only when the user's prompt
|
|
8
|
+
* mentions one of the server's trigger keywords. Lets users
|
|
9
|
+
* configure many servers without every tool definition landing
|
|
10
|
+
* in every system prompt.
|
|
11
|
+
*
|
|
12
|
+
* The matcher is intentionally simple — case-insensitive substring
|
|
13
|
+
* search across name + triggers + auto-derived defaults for well-
|
|
14
|
+
* known providers. Cheap (~microseconds per server) and easy to
|
|
15
|
+
* reason about; users who want fancier matching can drop the server
|
|
16
|
+
* to "always" and pay the prompt cost.
|
|
17
|
+
*/
|
|
18
|
+
import type { McpServerConfig } from './types';
|
|
19
|
+
/**
|
|
20
|
+
* Identify the well-known provider this server's name implies (if
|
|
21
|
+
* any). Used both to pick default triggers AND by the UI to render
|
|
22
|
+
* a brand icon. Returns null when no provider hint is found — the
|
|
23
|
+
* server gets only its own name as a trigger.
|
|
24
|
+
*/
|
|
25
|
+
export declare function inferProviderHint(serverName: string): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Compute the effective trigger set for one server. Always includes
|
|
28
|
+
* the server's own name; merges in explicit triggers from config and
|
|
29
|
+
* auto-derived defaults for well-known providers.
|
|
30
|
+
*/
|
|
31
|
+
export declare function effectiveTriggers(serverName: string, config: McpServerConfig): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Decide whether a server should contribute tools for this prompt.
|
|
34
|
+
*
|
|
35
|
+
* - activation === "always" (default) → true regardless of prompt.
|
|
36
|
+
* - activation === "on-mention" → true iff at least one trigger
|
|
37
|
+
* appears as a substring in the prompt (case-insensitive).
|
|
38
|
+
* - disabled === true → false (server is off entirely).
|
|
39
|
+
*
|
|
40
|
+
* The prompt is matched against trigger words with simple substring
|
|
41
|
+
* containment — so "post a message in slack" matches the "slack"
|
|
42
|
+
* trigger; "slacking off" also matches but that's an acceptable
|
|
43
|
+
* false positive for a one-line matcher (the cost of a wasted tool
|
|
44
|
+
* registration on a misread prompt is bounded — Bandit just sends
|
|
45
|
+
* a few extra tool defs that the model ignores).
|
|
46
|
+
*/
|
|
47
|
+
export declare function shouldActivateServer(serverName: string, config: McpServerConfig, prompt: string | undefined): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Pure trigger-match check — does this prompt mention the server's
|
|
50
|
+
* name, any of its derived triggers, OR a universal MCP-intent
|
|
51
|
+
* keyword? Returns true even for servers configured with
|
|
52
|
+
* `activation: "always"`, where shouldActivateServer would
|
|
53
|
+
* unconditionally return true. Used by host enumeration logic to
|
|
54
|
+
* gate the FIRST-TIME spawn of an `always`-mode server: when we have
|
|
55
|
+
* no cached tool list, we only want to spawn (and fire the trust
|
|
56
|
+
* gate) when the user clearly intends to use that server — not on
|
|
57
|
+
* every "hi". See getAllMcpAgentTools.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isServerMentioned(serverName: string, config: McpServerConfig, prompt: string | undefined): boolean;
|
|
60
|
+
//# sourceMappingURL=activation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../src/mcp/activation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA4B/C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMnE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,EAAE,CASvF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAQT;AAeD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAMT"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP server activation — decides which servers should contribute
|
|
4
|
+
* tools to the current turn's registry.
|
|
5
|
+
*
|
|
6
|
+
* - "always" (default): every prompt registers the server's tools.
|
|
7
|
+
* Backwards compatible with the - behavior.
|
|
8
|
+
* - "on-mention": tools register only when the user's prompt
|
|
9
|
+
* mentions one of the server's trigger keywords. Lets users
|
|
10
|
+
* configure many servers without every tool definition landing
|
|
11
|
+
* in every system prompt.
|
|
12
|
+
*
|
|
13
|
+
* The matcher is intentionally simple — case-insensitive substring
|
|
14
|
+
* search across name + triggers + auto-derived defaults for well-
|
|
15
|
+
* known providers. Cheap (~microseconds per server) and easy to
|
|
16
|
+
* reason about; users who want fancier matching can drop the server
|
|
17
|
+
* to "always" and pay the prompt cost.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.inferProviderHint = inferProviderHint;
|
|
21
|
+
exports.effectiveTriggers = effectiveTriggers;
|
|
22
|
+
exports.shouldActivateServer = shouldActivateServer;
|
|
23
|
+
exports.isServerMentioned = isServerMentioned;
|
|
24
|
+
/**
|
|
25
|
+
* Default trigger keywords for popular MCP servers. Auto-applied
|
|
26
|
+
* when the user's config doesn't specify explicit triggers and the
|
|
27
|
+
* server name (or one of these keys) is in the registered name.
|
|
28
|
+
*
|
|
29
|
+
* The match is two-way: "slack" in the server name → use these
|
|
30
|
+
* triggers, AND a server's own name is always a trigger so users
|
|
31
|
+
* who name their server something custom still get a sensible
|
|
32
|
+
* baseline ("my-slack-bot" matches if the prompt mentions
|
|
33
|
+
* "my-slack-bot" or "slack").
|
|
34
|
+
*/
|
|
35
|
+
const DEFAULT_TRIGGERS_FOR_PROVIDER = {
|
|
36
|
+
slack: ['slack', 'channel', 'workspace', 'dm', 'message'],
|
|
37
|
+
github: ['github', 'repo', 'repository', 'pr', 'pull request', 'issue', 'commit'],
|
|
38
|
+
gmail: ['gmail', 'email', 'inbox', 'mail'],
|
|
39
|
+
gdrive: ['drive', 'gdrive', 'docs', 'spreadsheet', 'document', 'folder'],
|
|
40
|
+
google: ['google'],
|
|
41
|
+
calendar: ['calendar', 'meeting', 'schedule', 'event', 'appointment'],
|
|
42
|
+
outlook: ['outlook', 'email', 'inbox', 'mail'],
|
|
43
|
+
teams: ['teams', 'channel', 'meeting'],
|
|
44
|
+
microsoft: ['microsoft', 'office', 'sharepoint', 'onedrive'],
|
|
45
|
+
filesystem: ['file', 'folder', 'directory'],
|
|
46
|
+
postgres: ['postgres', 'sql', 'database', 'query'],
|
|
47
|
+
mongo: ['mongo', 'mongodb', 'database', 'query']
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Identify the well-known provider this server's name implies (if
|
|
51
|
+
* any). Used both to pick default triggers AND by the UI to render
|
|
52
|
+
* a brand icon. Returns null when no provider hint is found — the
|
|
53
|
+
* server gets only its own name as a trigger.
|
|
54
|
+
*/
|
|
55
|
+
function inferProviderHint(serverName) {
|
|
56
|
+
const lower = serverName.toLowerCase();
|
|
57
|
+
for (const key of Object.keys(DEFAULT_TRIGGERS_FOR_PROVIDER)) {
|
|
58
|
+
if (lower.includes(key))
|
|
59
|
+
return key;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Compute the effective trigger set for one server. Always includes
|
|
65
|
+
* the server's own name; merges in explicit triggers from config and
|
|
66
|
+
* auto-derived defaults for well-known providers.
|
|
67
|
+
*/
|
|
68
|
+
function effectiveTriggers(serverName, config) {
|
|
69
|
+
const set = new Set();
|
|
70
|
+
set.add(serverName.toLowerCase());
|
|
71
|
+
for (const t of config.triggers ?? [])
|
|
72
|
+
set.add(t.toLowerCase());
|
|
73
|
+
const provider = inferProviderHint(serverName);
|
|
74
|
+
if (provider) {
|
|
75
|
+
for (const t of DEFAULT_TRIGGERS_FOR_PROVIDER[provider])
|
|
76
|
+
set.add(t);
|
|
77
|
+
}
|
|
78
|
+
return [...set];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Decide whether a server should contribute tools for this prompt.
|
|
82
|
+
*
|
|
83
|
+
* - activation === "always" (default) → true regardless of prompt.
|
|
84
|
+
* - activation === "on-mention" → true iff at least one trigger
|
|
85
|
+
* appears as a substring in the prompt (case-insensitive).
|
|
86
|
+
* - disabled === true → false (server is off entirely).
|
|
87
|
+
*
|
|
88
|
+
* The prompt is matched against trigger words with simple substring
|
|
89
|
+
* containment — so "post a message in slack" matches the "slack"
|
|
90
|
+
* trigger; "slacking off" also matches but that's an acceptable
|
|
91
|
+
* false positive for a one-line matcher (the cost of a wasted tool
|
|
92
|
+
* registration on a misread prompt is bounded — Bandit just sends
|
|
93
|
+
* a few extra tool defs that the model ignores).
|
|
94
|
+
*/
|
|
95
|
+
function shouldActivateServer(serverName, config, prompt) {
|
|
96
|
+
if (config.disabled)
|
|
97
|
+
return false;
|
|
98
|
+
const mode = config.activation ?? 'always';
|
|
99
|
+
if (mode === 'always')
|
|
100
|
+
return true;
|
|
101
|
+
if (!prompt)
|
|
102
|
+
return false;
|
|
103
|
+
const haystack = prompt.toLowerCase();
|
|
104
|
+
const triggers = effectiveTriggers(serverName, config);
|
|
105
|
+
return triggers.some((t) => haystack.includes(t));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Universal MCP intent keywords — when the user explicitly says "mcp"
|
|
109
|
+
* or "model context protocol", they're asking to use MCP tooling
|
|
110
|
+
* generally, not naming a specific server. Treat that as a mention
|
|
111
|
+
* of every configured server so the first-time-spawn gate doesn't
|
|
112
|
+
* skip enumeration just because the user didn't memorize the server
|
|
113
|
+
* name. (Custom-named servers like "burtson-labs" have no other
|
|
114
|
+
* trigger words; without this you'd have to type "burtson-labs" to
|
|
115
|
+
* unlock its tools, which defeats the point of a generic "use mcp"
|
|
116
|
+
* request.)
|
|
117
|
+
*/
|
|
118
|
+
const MCP_INTENT_KEYWORDS = ['mcp', 'model context protocol'];
|
|
119
|
+
/**
|
|
120
|
+
* Pure trigger-match check — does this prompt mention the server's
|
|
121
|
+
* name, any of its derived triggers, OR a universal MCP-intent
|
|
122
|
+
* keyword? Returns true even for servers configured with
|
|
123
|
+
* `activation: "always"`, where shouldActivateServer would
|
|
124
|
+
* unconditionally return true. Used by host enumeration logic to
|
|
125
|
+
* gate the FIRST-TIME spawn of an `always`-mode server: when we have
|
|
126
|
+
* no cached tool list, we only want to spawn (and fire the trust
|
|
127
|
+
* gate) when the user clearly intends to use that server — not on
|
|
128
|
+
* every "hi". See getAllMcpAgentTools.
|
|
129
|
+
*/
|
|
130
|
+
function isServerMentioned(serverName, config, prompt) {
|
|
131
|
+
if (!prompt)
|
|
132
|
+
return false;
|
|
133
|
+
const haystack = prompt.toLowerCase();
|
|
134
|
+
if (MCP_INTENT_KEYWORDS.some((k) => haystack.includes(k)))
|
|
135
|
+
return true;
|
|
136
|
+
const triggers = effectiveTriggers(serverName, config);
|
|
137
|
+
return triggers.some((t) => haystack.includes(t));
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=activation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation.js","sourceRoot":"","sources":["../../src/mcp/activation.ts"],"names":[],"mappings":"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"}
|