@arcforge/core 2.0.169 → 2.0.171
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/package.json +12 -12
- package/src/tools/tools.ts +57 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcforge/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.171",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"test:coverage": "bun test --coverage"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@arcforge/air": "2.0.
|
|
18
|
-
"@arcforge/capsule": "2.0.
|
|
19
|
-
"@arcforge/cloud": "2.0.
|
|
20
|
-
"@arcforge/cognet": "2.0.
|
|
21
|
-
"@arcforge/engines": "2.0.
|
|
22
|
-
"@arcforge/err": "2.0.
|
|
23
|
-
"@arcforge/kernel": "2.0.
|
|
24
|
-
"@arcforge/link": "2.0.
|
|
25
|
-
"@arcforge/session": "2.0.
|
|
26
|
-
"@arcforge/types": "2.0.
|
|
27
|
-
"@arcforge/vstr": "2.0.
|
|
17
|
+
"@arcforge/air": "2.0.171",
|
|
18
|
+
"@arcforge/capsule": "2.0.171",
|
|
19
|
+
"@arcforge/cloud": "2.0.171",
|
|
20
|
+
"@arcforge/cognet": "2.0.171",
|
|
21
|
+
"@arcforge/engines": "2.0.171",
|
|
22
|
+
"@arcforge/err": "2.0.171",
|
|
23
|
+
"@arcforge/kernel": "2.0.171",
|
|
24
|
+
"@arcforge/link": "2.0.171",
|
|
25
|
+
"@arcforge/session": "2.0.171",
|
|
26
|
+
"@arcforge/types": "2.0.171",
|
|
27
|
+
"@arcforge/vstr": "2.0.171",
|
|
28
28
|
"crossws": "^0.3.5",
|
|
29
29
|
"h3": "^1.13.0",
|
|
30
30
|
"hookable": "^5.5.3",
|
package/src/tools/tools.ts
CHANGED
|
@@ -9,6 +9,18 @@ import type { MediateOpts } from "./mediate"
|
|
|
9
9
|
|
|
10
10
|
type ToolsOpts = {
|
|
11
11
|
mediation: MediateOpts
|
|
12
|
+
/**
|
|
13
|
+
* Two tools exporting the same name into one scope.
|
|
14
|
+
*
|
|
15
|
+
* Reported rather than resolved: which one the author meant is not
|
|
16
|
+
* something the runtime can know, and quietly renaming one — which is what
|
|
17
|
+
* wrapping a module's tools under their own name amounted to — changes how
|
|
18
|
+
* it is called for a reason the author never chose.
|
|
19
|
+
*
|
|
20
|
+
* Optional because the placement is correct either way; this only decides
|
|
21
|
+
* whether anyone is told. A surface that can warn supplies one.
|
|
22
|
+
*/
|
|
23
|
+
onClash?(input: { name: string; previous: string; next: string }): void
|
|
12
24
|
}
|
|
13
25
|
|
|
14
26
|
/**
|
|
@@ -114,17 +126,52 @@ export function Tools(opts: ToolsOpts) {
|
|
|
114
126
|
*/
|
|
115
127
|
globals(): Record<string, unknown> {
|
|
116
128
|
const globals: Record<string, unknown> = {}
|
|
129
|
+
/** Which tool placed each name, so a clash can name both sides. */
|
|
130
|
+
const placedBy = new Map<string, string>()
|
|
131
|
+
|
|
117
132
|
for (const tool of loaded.values()) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
/**
|
|
134
|
+
* EVERY tool is placed flat, whatever its origin.
|
|
135
|
+
*
|
|
136
|
+
* Placement used to follow origin: an agent's own tools flat,
|
|
137
|
+
* an installed module's wrapped under its own name. Two things
|
|
138
|
+
* were wrong with that.
|
|
139
|
+
*
|
|
140
|
+
* It DISAGREED WITH THE DECLARATIONS in practice. The generated
|
|
141
|
+
* `.d.ts` and the model's `<scope>` both spelled a module tool
|
|
142
|
+
* `subagents.subagents.request()`, and the runtime here did not
|
|
143
|
+
* always agree — so a model read its own types, called exactly
|
|
144
|
+
* what they promised, and got `undefined is not an object`.
|
|
145
|
+
* That is the one failure this whole surface exists to prevent.
|
|
146
|
+
*
|
|
147
|
+
* And it made placement CONDITIONAL on provenance, which is not
|
|
148
|
+
* the author's concern. `import { subagents }` should be
|
|
149
|
+
* `subagents.request()` whether that came from src/tools or a
|
|
150
|
+
* package — otherwise moving a tool into a module silently
|
|
151
|
+
* rewrites every call site, for a reason nobody chose.
|
|
152
|
+
*
|
|
153
|
+
* A module exporting `const fs = {…}` is already its own
|
|
154
|
+
* namespace; it needs no help being one. What the wrap actually
|
|
155
|
+
* guarded was a NAME CLASH between two tools, and that is the
|
|
156
|
+
* author's to resolve — so it is reported rather than silently
|
|
157
|
+
* worked around by changing how one of them is addressed.
|
|
158
|
+
*/
|
|
159
|
+
for (const [name, value] of Object.entries(tool.values)) {
|
|
160
|
+
const previous = placedBy.get(name)
|
|
161
|
+
if (previous !== undefined && previous !== tool.namespace) {
|
|
162
|
+
/**
|
|
163
|
+
* Last write wins, and SAYS SO.
|
|
164
|
+
*
|
|
165
|
+
* Refusing would brick an agent over a collision it can
|
|
166
|
+
* still mostly serve, and silence is how the previous
|
|
167
|
+
* behaviour hid: `Object.assign` overwrote and nothing
|
|
168
|
+
* anywhere recorded that a capability had been shadowed.
|
|
169
|
+
*/
|
|
170
|
+
opts.onClash?.({ name, previous, next: tool.namespace })
|
|
171
|
+
}
|
|
172
|
+
globals[name] = value
|
|
173
|
+
placedBy.set(name, tool.namespace)
|
|
174
|
+
}
|
|
128
175
|
}
|
|
129
176
|
return globals
|
|
130
177
|
},
|