harness-dispatch 0.7.9 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1170 -1
- package/README.md +52 -6
- package/config.default.yaml +49 -5
- package/dist/auth.d.ts +29 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +58 -5
- package/dist/auth.js.map +1 -1
- package/dist/billing.d.ts +24 -0
- package/dist/billing.d.ts.map +1 -1
- package/dist/billing.js +24 -0
- package/dist/billing.js.map +1 -1
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +529 -31
- package/dist/bin.js.map +1 -1
- package/dist/breaker-store.d.ts +25 -1
- package/dist/breaker-store.d.ts.map +1 -1
- package/dist/breaker-store.js +193 -25
- package/dist/breaker-store.js.map +1 -1
- package/dist/circuit-breaker.d.ts +9 -1
- package/dist/circuit-breaker.d.ts.map +1 -1
- package/dist/circuit-breaker.js +15 -1
- package/dist/circuit-breaker.js.map +1 -1
- package/dist/client-register.d.ts +157 -0
- package/dist/client-register.d.ts.map +1 -0
- package/dist/client-register.js +389 -0
- package/dist/client-register.js.map +1 -0
- package/dist/config/validation.d.ts +41 -0
- package/dist/config/validation.d.ts.map +1 -1
- package/dist/config/validation.js +215 -1
- package/dist/config/validation.js.map +1 -1
- package/dist/config.d.ts +4 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +143 -6
- package/dist/config.js.map +1 -1
- package/dist/configure-yaml.d.ts +2 -0
- package/dist/configure-yaml.d.ts.map +1 -1
- package/dist/configure-yaml.js +69 -3
- package/dist/configure-yaml.js.map +1 -1
- package/dist/dispatch-log.d.ts +14 -0
- package/dist/dispatch-log.d.ts.map +1 -1
- package/dist/dispatch-log.js +3 -0
- package/dist/dispatch-log.js.map +1 -1
- package/dist/dispatchers/generic-cli.d.ts.map +1 -1
- package/dist/dispatchers/generic-cli.js +92 -15
- package/dist/dispatchers/generic-cli.js.map +1 -1
- package/dist/dispatchers/openai-compatible.d.ts +20 -4
- package/dist/dispatchers/openai-compatible.d.ts.map +1 -1
- package/dist/dispatchers/openai-compatible.js +167 -19
- package/dist/dispatchers/openai-compatible.js.map +1 -1
- package/dist/dispatchers/shared/harness-login.d.ts +25 -0
- package/dist/dispatchers/shared/harness-login.d.ts.map +1 -0
- package/dist/dispatchers/shared/harness-login.js +68 -0
- package/dist/dispatchers/shared/harness-login.js.map +1 -0
- package/dist/dispatchers/shared/stream-subprocess.d.ts.map +1 -1
- package/dist/dispatchers/shared/stream-subprocess.js +70 -4
- package/dist/dispatchers/shared/stream-subprocess.js.map +1 -1
- package/dist/file-lock.d.ts +29 -1
- package/dist/file-lock.d.ts.map +1 -1
- package/dist/file-lock.js +22 -1
- package/dist/file-lock.js.map +1 -1
- package/dist/http/answer-stream.d.ts +52 -0
- package/dist/http/answer-stream.d.ts.map +1 -0
- package/dist/http/answer-stream.js +47 -0
- package/dist/http/answer-stream.js.map +1 -0
- package/dist/http/parse.d.ts.map +1 -1
- package/dist/http/parse.js +41 -0
- package/dist/http/parse.js.map +1 -1
- package/dist/http/server.d.ts +2 -0
- package/dist/http/server.d.ts.map +1 -1
- package/dist/http/server.js +281 -23
- package/dist/http/server.js.map +1 -1
- package/dist/jobs/context.d.ts +0 -7
- package/dist/jobs/context.d.ts.map +1 -1
- package/dist/jobs/context.js +95 -7
- package/dist/jobs/context.js.map +1 -1
- package/dist/jobs/store.d.ts.map +1 -1
- package/dist/jobs/store.js +45 -4
- package/dist/jobs/store.js.map +1 -1
- package/dist/jobs/types.d.ts +8 -1
- package/dist/jobs/types.d.ts.map +1 -1
- package/dist/jobs.d.ts +39 -0
- package/dist/jobs.d.ts.map +1 -1
- package/dist/jobs.js +207 -15
- package/dist/jobs.js.map +1 -1
- package/dist/leaderboard.d.ts.map +1 -1
- package/dist/leaderboard.js +39 -27
- package/dist/leaderboard.js.map +1 -1
- package/dist/mcp/config-hot-reload.d.ts +14 -3
- package/dist/mcp/config-hot-reload.d.ts.map +1 -1
- package/dist/mcp/config-hot-reload.js +33 -5
- package/dist/mcp/config-hot-reload.js.map +1 -1
- package/dist/mcp/dispatcher-factory.d.ts.map +1 -1
- package/dist/mcp/dispatcher-factory.js +14 -3
- package/dist/mcp/dispatcher-factory.js.map +1 -1
- package/dist/mcp/near-miss-guard.d.ts +45 -0
- package/dist/mcp/near-miss-guard.d.ts.map +1 -0
- package/dist/mcp/near-miss-guard.js +98 -0
- package/dist/mcp/near-miss-guard.js.map +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +36 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tool-schemas.d.ts +1 -1
- package/dist/mcp/tool-schemas.d.ts.map +1 -1
- package/dist/mcp/tool-schemas.js +27 -7
- package/dist/mcp/tool-schemas.js.map +1 -1
- package/dist/mcp/tools.d.ts +33 -4
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +85 -8
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp-clients.d.ts +72 -0
- package/dist/mcp-clients.d.ts.map +1 -0
- package/dist/mcp-clients.js +121 -0
- package/dist/mcp-clients.js.map +1 -0
- package/dist/near-miss.d.ts +63 -0
- package/dist/near-miss.d.ts.map +1 -0
- package/dist/near-miss.js +132 -0
- package/dist/near-miss.js.map +1 -0
- package/dist/quota.d.ts +31 -1
- package/dist/quota.d.ts.map +1 -1
- package/dist/quota.js +84 -8
- package/dist/quota.js.map +1 -1
- package/dist/route-policy.d.ts +12 -1
- package/dist/route-policy.d.ts.map +1 -1
- package/dist/route-policy.js +74 -2
- package/dist/route-policy.js.map +1 -1
- package/dist/router.d.ts +61 -2
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +160 -29
- package/dist/router.js.map +1 -1
- package/dist/safety.d.ts.map +1 -1
- package/dist/safety.js +37 -1
- package/dist/safety.js.map +1 -1
- package/dist/state-dir.d.ts +10 -0
- package/dist/state-dir.d.ts.map +1 -1
- package/dist/state-dir.js +12 -0
- package/dist/state-dir.js.map +1 -1
- package/dist/status.d.ts +30 -21
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +152 -8
- package/dist/status.js.map +1 -1
- package/dist/types.d.ts +49 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/working-dir.d.ts.map +1 -1
- package/dist/working-dir.js +16 -0
- package/dist/working-dir.js.map +1 -1
- package/dist/workspace-resolve.d.ts.map +1 -1
- package/dist/workspace-resolve.js +196 -15
- package/dist/workspace-resolve.js.map +1 -1
- package/dist/workspaces.d.ts +98 -0
- package/dist/workspaces.d.ts.map +1 -1
- package/dist/workspaces.js +609 -20
- package/dist/workspaces.js.map +1 -1
- package/package.json +1 -1
|
@@ -49,9 +49,20 @@ export declare function bootstrapRuntime(opts: {
|
|
|
49
49
|
/**
|
|
50
50
|
* Reload helper — pairs with a RuntimeHolder for in-place swap.
|
|
51
51
|
*
|
|
52
|
-
* If the config file's mtime
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* If the config file's mtime is UNCHANGED since we last reloaded, the call is
|
|
53
|
+
* a cheap no-op. Any difference — forwards or backwards — counts as a change:
|
|
54
|
+
* this said "has not moved" while testing "has not increased", so a config
|
|
55
|
+
* restored from a backup or extracted from an archive never reloaded.
|
|
56
|
+
* Circuit-breaker state from the previous router is preserved for every
|
|
57
|
+
* service that still exists in the new config.
|
|
58
|
+
*
|
|
59
|
+
* TWO SITUATIONS IN WHICH THIS DOES NOTHING, both by construction and both
|
|
60
|
+
* worth knowing before relying on it:
|
|
61
|
+
* - No `configPath` — i.e. every auto-detect install with no config file.
|
|
62
|
+
* There is no file to watch, so nothing reloads.
|
|
63
|
+
* - A config that is DELETED or renamed away. `statMtime` answers 0, which
|
|
64
|
+
* is treated as "unchanged" so a transient read failure does not tear down
|
|
65
|
+
* a working router. The server keeps serving the last good config.
|
|
55
66
|
*/
|
|
56
67
|
export declare class ConfigHotReloader {
|
|
57
68
|
private readonly holder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-hot-reload.d.ts","sourceRoot":"","sources":["../../src/mcp/config-hot-reload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE/E,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,WAAW,EAAE,aAAa,CAAC;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,gBAAgB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,+EAA+E;AAC/E,qBAAa,aAAa;IACxB,KAAK,EAAE,YAAY,CAAC;gBACR,KAAK,EAAE,YAAY;IAG/B,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;CAGlC;AAYD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC,GAAG,OAAO,CAAC,YAAY,CAAC,CAoBxB;AAkBD
|
|
1
|
+
{"version":3,"file":"config-hot-reload.d.ts","sourceRoot":"","sources":["../../src/mcp/config-hot-reload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CA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|
+
* If the config file's mtime is UNCHANGED since we last reloaded, the call is
|
|
87
|
+
* a cheap no-op. Any difference — forwards or backwards — counts as a change:
|
|
88
|
+
* this said "has not moved" while testing "has not increased", so a config
|
|
89
|
+
* restored from a backup or extracted from an archive never reloaded.
|
|
90
|
+
* Circuit-breaker state from the previous router is preserved for every
|
|
91
|
+
* service that still exists in the new config.
|
|
92
|
+
*
|
|
93
|
+
* TWO SITUATIONS IN WHICH THIS DOES NOTHING, both by construction and both
|
|
94
|
+
* worth knowing before relying on it:
|
|
95
|
+
* - No `configPath` — i.e. every auto-detect install with no config file.
|
|
96
|
+
* There is no file to watch, so nothing reloads.
|
|
97
|
+
* - A config that is DELETED or renamed away. `statMtime` answers 0, which
|
|
98
|
+
* is treated as "unchanged" so a transient read failure does not tear down
|
|
99
|
+
* a working router. The server keeps serving the last good config.
|
|
89
100
|
*/
|
|
90
101
|
export class ConfigHotReloader {
|
|
91
102
|
holder;
|
|
@@ -104,13 +115,20 @@ export class ConfigHotReloader {
|
|
|
104
115
|
const mtimeMs = await statMtime(this.configPath);
|
|
105
116
|
if (mtimeMs === 0)
|
|
106
117
|
return false;
|
|
107
|
-
|
|
118
|
+
// `!==`, not `<=`.
|
|
119
|
+
//
|
|
120
|
+
// Comparing "newer than" meant a config whose mtime went BACKWARDS was
|
|
121
|
+
// invisible forever: restored from a backup, copied with `cp -p`,
|
|
122
|
+
// extracted from an archive, or renamed in from an older temp file. Each
|
|
123
|
+
// is an ordinary way to change a config, and each left the server routing
|
|
124
|
+
// on the previous one with nothing said. Any difference is a change.
|
|
125
|
+
if (mtimeMs === this.holder.state.mtimeMs)
|
|
108
126
|
return false;
|
|
109
127
|
return this.mutex.run(async () => {
|
|
110
128
|
// Re-check after acquiring the lock — another caller may have already
|
|
111
129
|
// reloaded, in which case we bail without redoing the work.
|
|
112
130
|
const current = this.holder.state.mtimeMs;
|
|
113
|
-
if (mtimeMs
|
|
131
|
+
if (mtimeMs === current)
|
|
114
132
|
return false;
|
|
115
133
|
let next;
|
|
116
134
|
try {
|
|
@@ -135,6 +153,12 @@ export class ConfigHotReloader {
|
|
|
135
153
|
// re-checks on a timer and a broken file would otherwise print on
|
|
136
154
|
// every poll until it was fixed.
|
|
137
155
|
const message = err instanceof Error ? err.message : String(err);
|
|
156
|
+
// Also onto the config that is still in effect, so `status` can say the
|
|
157
|
+
// file on disk is not the one being routed on. stderr is invisible to
|
|
158
|
+
// every MCP client and every HTTP caller — which is most of the ways
|
|
159
|
+
// this server is used, and the comment above claimed status coverage
|
|
160
|
+
// this code did not have.
|
|
161
|
+
this.holder.state.config.reloadError = message;
|
|
138
162
|
if (message !== this.lastReloadError) {
|
|
139
163
|
this.lastReloadError = message;
|
|
140
164
|
process.stderr.write(`harness-dispatch: config reload FAILED, still running the previously loaded ` +
|
|
@@ -143,6 +167,10 @@ export class ConfigHotReloader {
|
|
|
143
167
|
return false;
|
|
144
168
|
}
|
|
145
169
|
this.lastReloadError = undefined;
|
|
170
|
+
// The freshly loaded config carries no error, but clear it off the old
|
|
171
|
+
// one too — a caller holding the previous object must not keep reporting
|
|
172
|
+
// a failure that has since been fixed.
|
|
173
|
+
delete this.holder.state.config.reloadError;
|
|
146
174
|
// Preserve circuit-breaker state for services that still exist.
|
|
147
175
|
const oldRouter = this.holder.state.router;
|
|
148
176
|
const oldBreakerStatus = oldRouter.circuitBreakerStatus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-hot-reload.js","sourceRoot":"","sources":["../../src/mcp/config-hot-reload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,M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AAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"dispatcher-factory.d.ts","sourceRoot":"","sources":["../../src/mcp/dispatcher-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,CA6B9E;AAED,0DAA0D;AAC1D,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAEvD,kDAAkD;AAClD,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACzC,UAAU,CAGZ;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CAQpE"}
|
|
@@ -41,10 +41,21 @@ export function collectApiKeyEnvVars(config) {
|
|
|
41
41
|
// (recorded during interpolation) is the only place that mapping survives,
|
|
42
42
|
// and without it a configured Groq/Gemini key stayed visible to every
|
|
43
43
|
// spawned CLI.
|
|
44
|
+
// EVERY reference in the string, not a whole-string match.
|
|
45
|
+
//
|
|
46
|
+
// `${VAR}` is supported anywhere in a value — `base_url: https://${HOST}/v1`
|
|
47
|
+
// is a documented shape — and `envRefs` stores the ORIGINAL string as its
|
|
48
|
+
// key. Anchoring to `^...$` therefore matched only values that are nothing
|
|
49
|
+
// but a reference, so a key embedded in a larger string was never collected
|
|
50
|
+
// and stayed visible to every spawned CLI. That is precisely the leak this
|
|
51
|
+
// sanitizer was written for, one string shape over.
|
|
52
|
+
const REF_RE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
44
53
|
for (const ref of config.envRefs?.values() ?? []) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
for (const match of ref.matchAll(REF_RE)) {
|
|
55
|
+
const name = match[1];
|
|
56
|
+
if (name)
|
|
57
|
+
vars.add(name);
|
|
58
|
+
}
|
|
48
59
|
}
|
|
49
60
|
return vars;
|
|
50
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher-factory.js","sourceRoot":"","sources":["../../src/mcp/dispatcher-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACvD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrD,IAAI,MAAM,EAAE,YAAY;YAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjD,IAAI,GAAG,CAAC,QAAQ,EAAE,YAAY;YAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACtE,CAAC;IACD,yEAAyE;IACzE,wEAAwE;IACxE,2EAA2E;IAC3E,sEAAsE;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;QACjD,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,IAAI;gBAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAKD,kDAAkD;AAClD,MAAM,UAAU,cAAc,CAC5B,GAAkB,EAClB,oBAA0C;IAE1C,IAAI,GAAG,CAAC,IAAI,KAAK,mBAAmB;QAAE,OAAO,IAAI,0BAA0B,CAAC,GAAG,CAAC,CAAC;IACjF,OAAO,IAAI,oBAAoB,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;AAC7D,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,gBAAgB,CAAC,MAAoB;IACnD,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,MAAM,aAAa,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACnD,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1D,IAAI,CAAC,GAAG,CAAC,OAAO;YAAE,SAAS;QAC3B,GAAG,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catch a near-miss TOP-LEVEL key on the MCP surface, before the SDK drops it.
|
|
3
|
+
*
|
|
4
|
+
* THE DEFECT. `safteyProfile: "read_only"` was accepted in silence and the
|
|
5
|
+
* dispatch then ran at the `workspace_edit` default — an acceptance pass
|
|
6
|
+
* measured it writing a file into the project. Asking for read-only by way of
|
|
7
|
+
* a typo got you write access, with nothing said on any surface. The HTTP
|
|
8
|
+
* surface has rejected the same input all along (`http/parse.ts` runs exactly
|
|
9
|
+
* the check below), so the two surfaces gave opposite answers to one input,
|
|
10
|
+
* which is the class the parity suite exists to end.
|
|
11
|
+
*
|
|
12
|
+
* WHY IT NEEDED THIS AND NOT A SCHEMA CHANGE. The SDK validates arguments
|
|
13
|
+
* against `z.object(inputShape)` before any handler runs, and zod STRIPS
|
|
14
|
+
* unknown keys rather than reporting them — so by the time our code sees the
|
|
15
|
+
* arguments, the misspelled key is already gone. `hints` is `.strict()`, which
|
|
16
|
+
* is why the nested form is caught; the outer object cannot be, because MCP
|
|
17
|
+
* carries `_meta` there and rejecting that would break legitimate callers. The
|
|
18
|
+
* named traps in `tool-schemas.ts` close the predictable snake_case slips, but
|
|
19
|
+
* a plain typo is not enumerable — generating every one-edit spelling of every
|
|
20
|
+
* hint name would put dozens of `z.never()` fields into the advertised schema.
|
|
21
|
+
*
|
|
22
|
+
* WHY WRAPPING setRequestHandler RATHER THAN REPLACING THE ROUTE. The obvious
|
|
23
|
+
* alternative — register our own `CallToolRequestSchema` handler — means
|
|
24
|
+
* reimplementing the SDK's routing: tool lookup, enable checks, task support,
|
|
25
|
+
* input and OUTPUT schema validation, and the `extra` argument that carries
|
|
26
|
+
* the progress token our fanout tap writes to. Replacing all of that to add
|
|
27
|
+
* one check would be trading a silent safety hole for a much larger surface of
|
|
28
|
+
* things to get wrong. This wraps the handler the SDK installs, inspects the
|
|
29
|
+
* raw arguments, and delegates: routing is untouched.
|
|
30
|
+
*
|
|
31
|
+
* Ordering matters. `McpServer` installs its CallTool handler lazily on the
|
|
32
|
+
* first `registerTool`, and calls `assertCanSetRequestHandler` first — so a
|
|
33
|
+
* handler registered ahead of it would make that assertion throw. This must be
|
|
34
|
+
* installed BEFORE `registerTools`, and it is a no-op until the SDK registers.
|
|
35
|
+
*/
|
|
36
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
37
|
+
/** The near-miss message for the first offending key, or undefined. */
|
|
38
|
+
export declare function nearMissInArguments(args: unknown, toolName?: string): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Wrap the CallTool handler the SDK is about to install.
|
|
41
|
+
*
|
|
42
|
+
* Call BEFORE `registerTools`. Returns nothing; the server is patched in place.
|
|
43
|
+
*/
|
|
44
|
+
export declare function installNearMissGuard(server: McpServer): void;
|
|
45
|
+
//# sourceMappingURL=near-miss-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"near-miss-guard.d.ts","sourceRoot":"","sources":["../../src/mcp/near-miss-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAYzE,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiBxF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsC5D"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catch a near-miss TOP-LEVEL key on the MCP surface, before the SDK drops it.
|
|
3
|
+
*
|
|
4
|
+
* THE DEFECT. `safteyProfile: "read_only"` was accepted in silence and the
|
|
5
|
+
* dispatch then ran at the `workspace_edit` default — an acceptance pass
|
|
6
|
+
* measured it writing a file into the project. Asking for read-only by way of
|
|
7
|
+
* a typo got you write access, with nothing said on any surface. The HTTP
|
|
8
|
+
* surface has rejected the same input all along (`http/parse.ts` runs exactly
|
|
9
|
+
* the check below), so the two surfaces gave opposite answers to one input,
|
|
10
|
+
* which is the class the parity suite exists to end.
|
|
11
|
+
*
|
|
12
|
+
* WHY IT NEEDED THIS AND NOT A SCHEMA CHANGE. The SDK validates arguments
|
|
13
|
+
* against `z.object(inputShape)` before any handler runs, and zod STRIPS
|
|
14
|
+
* unknown keys rather than reporting them — so by the time our code sees the
|
|
15
|
+
* arguments, the misspelled key is already gone. `hints` is `.strict()`, which
|
|
16
|
+
* is why the nested form is caught; the outer object cannot be, because MCP
|
|
17
|
+
* carries `_meta` there and rejecting that would break legitimate callers. The
|
|
18
|
+
* named traps in `tool-schemas.ts` close the predictable snake_case slips, but
|
|
19
|
+
* a plain typo is not enumerable — generating every one-edit spelling of every
|
|
20
|
+
* hint name would put dozens of `z.never()` fields into the advertised schema.
|
|
21
|
+
*
|
|
22
|
+
* WHY WRAPPING setRequestHandler RATHER THAN REPLACING THE ROUTE. The obvious
|
|
23
|
+
* alternative — register our own `CallToolRequestSchema` handler — means
|
|
24
|
+
* reimplementing the SDK's routing: tool lookup, enable checks, task support,
|
|
25
|
+
* input and OUTPUT schema validation, and the `extra` argument that carries
|
|
26
|
+
* the progress token our fanout tap writes to. Replacing all of that to add
|
|
27
|
+
* one check would be trading a silent safety hole for a much larger surface of
|
|
28
|
+
* things to get wrong. This wraps the handler the SDK installs, inspects the
|
|
29
|
+
* raw arguments, and delegates: routing is untouched.
|
|
30
|
+
*
|
|
31
|
+
* Ordering matters. `McpServer` installs its CallTool handler lazily on the
|
|
32
|
+
* first `registerTool`, and calls `assertCanSetRequestHandler` first — so a
|
|
33
|
+
* handler registered ahead of it would make that assertion throw. This must be
|
|
34
|
+
* installed BEFORE `registerTools`, and it is a no-op until the SDK registers.
|
|
35
|
+
*/
|
|
36
|
+
import { CallToolRequestSchema, McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
37
|
+
import { nearMissHintKey, nearMissMessage } from "../near-miss.js";
|
|
38
|
+
/** The method string the SDK keys its CallTool handler by. */
|
|
39
|
+
const CALL_TOOL_METHOD = "tools/call";
|
|
40
|
+
/** The near-miss message for the first offending key, or undefined. */
|
|
41
|
+
export function nearMissInArguments(args, toolName) {
|
|
42
|
+
if (args === null || typeof args !== "object" || Array.isArray(args))
|
|
43
|
+
return undefined;
|
|
44
|
+
for (const key of Object.keys(args)) {
|
|
45
|
+
const meant = nearMissHintKey(key);
|
|
46
|
+
if (meant !== undefined) {
|
|
47
|
+
// The TOOL is passed on, because the advice differs by it: on a tool
|
|
48
|
+
// that takes no hints, the corrected spelling is not a field either, and
|
|
49
|
+
// a message telling the caller to fix the spelling sends them to a key
|
|
50
|
+
// that is silently ignored — the class this guard exists to close,
|
|
51
|
+
// reopened one step later. Measured by an acceptance pass.
|
|
52
|
+
return nearMissMessage(key, meant, {
|
|
53
|
+
surface: "mcp",
|
|
54
|
+
...(toolName !== undefined ? { toolName } : {}),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Wrap the CallTool handler the SDK is about to install.
|
|
62
|
+
*
|
|
63
|
+
* Call BEFORE `registerTools`. Returns nothing; the server is patched in place.
|
|
64
|
+
*/
|
|
65
|
+
export function installNearMissGuard(server) {
|
|
66
|
+
const inner = server.server;
|
|
67
|
+
// Installing after `registerTools` is inert — the SDK's handler is already
|
|
68
|
+
// in place and this would wrap nothing — and the failure mode of getting the
|
|
69
|
+
// order wrong is a SILENT safety hole rather than an error. An acceptance
|
|
70
|
+
// pass confirmed the late install accepts a near miss with no complaint.
|
|
71
|
+
// There is one call site and its comment states the requirement, so this is
|
|
72
|
+
// a guard against a future edit, not a live bug; it costs one line and turns
|
|
73
|
+
// "safety check quietly absent" into a startup failure.
|
|
74
|
+
if (inner.assertCanSetRequestHandler !== undefined) {
|
|
75
|
+
inner.assertCanSetRequestHandler(CALL_TOOL_METHOD);
|
|
76
|
+
}
|
|
77
|
+
const original = inner.setRequestHandler.bind(inner);
|
|
78
|
+
// The cast is confined to this one line. The SDK types `setRequestHandler`
|
|
79
|
+
// against the specific schema it is given, and this wrapper is deliberately
|
|
80
|
+
// schema-agnostic: everything other than CallTool is passed straight through.
|
|
81
|
+
inner.setRequestHandler = ((schema, handler, ...rest) => {
|
|
82
|
+
if (schema !== CallToolRequestSchema) {
|
|
83
|
+
return original(schema, handler, ...rest);
|
|
84
|
+
}
|
|
85
|
+
const guarded = async (request, extra) => {
|
|
86
|
+
const params = request?.params;
|
|
87
|
+
const message = nearMissInArguments(params?.arguments, typeof params?.name === "string" ? params.name : undefined);
|
|
88
|
+
// InvalidParams, so it reaches the caller as a protocol error naming the
|
|
89
|
+
// key rather than as a tool result they might not read. The HTTP surface
|
|
90
|
+
// answers 400 for the same input.
|
|
91
|
+
if (message !== undefined)
|
|
92
|
+
throw new McpError(ErrorCode.InvalidParams, message);
|
|
93
|
+
return handler(request, extra);
|
|
94
|
+
};
|
|
95
|
+
return original(schema, guarded, ...rest);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=near-miss-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"near-miss-guard.js","sourceRoot":"","sources":["../../src/mcp/near-miss-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEnE,8DAA8D;AAC9D,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAMtC,uEAAuE;AACvE,MAAM,UAAU,mBAAmB,CAAC,IAAa,EAAE,QAAiB;IAClE,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IACvF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAA+B,CAAC,EAAE,CAAC;QAC/D,MAAM,KAAK,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,SAAS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QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAC3D,CAAC;YACF,yEAAyE;YACzE,yEAAyE;YACzE,kCAAkC;YAClC,IAAI,OAAO,KAAK,SAAS;gBAAE,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YAChF,OAAO,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC;QACF,OAAQ,QAAoD,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACzF,CAAC,CAAY,CAAC;AAChB,CAAC"}
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAoB,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAoB,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAwC5F,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,iBAAiB,GAC1B,SAAS,CAYX;AAED,gFAAgF;AAChF,wBAAsB,cAAc,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgBlF;AAMD,MAAM,WAAW,SAAS;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAgCD,wBAAsB,cAAc,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CAUnF"}
|
package/dist/mcp/server.js
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
10
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
11
|
import { bootstrapRuntime, ConfigHotReloader, RuntimeHolder } from "./config-hot-reload.js";
|
|
12
|
+
import { orphanStrandedSlotQueue } from "../jobs.js";
|
|
13
|
+
import { installNearMissGuard } from "./near-miss-guard.js";
|
|
12
14
|
import { registerTools } from "./tools.js";
|
|
13
15
|
import { registerResources } from "./resources.js";
|
|
14
16
|
import { initObservability } from "../observability/index.js";
|
|
@@ -49,6 +51,10 @@ const SERVER_INSTRUCTIONS = "This server turns the machine's installed coding ha
|
|
|
49
51
|
*/
|
|
50
52
|
export function buildMcpServerInstance(holder, reloader) {
|
|
51
53
|
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, { instructions: SERVER_INSTRUCTIONS });
|
|
54
|
+
// BEFORE registerTools: the SDK installs its CallTool handler on the first
|
|
55
|
+
// tool registration, and this wraps that handler as it goes in. See
|
|
56
|
+
// near-miss-guard.ts for why the check cannot live in the schema.
|
|
57
|
+
installNearMissGuard(server);
|
|
52
58
|
registerTools(server, { holder, reloader });
|
|
53
59
|
registerResources(server, { holder, reloader });
|
|
54
60
|
return server;
|
|
@@ -70,10 +76,40 @@ export async function buildMcpServer(opts = {}) {
|
|
|
70
76
|
const server = buildMcpServerInstance(holder, reloader);
|
|
71
77
|
return { server, holder, reloader };
|
|
72
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Report jobs stranded in the slot queue by a server that exited, rather than
|
|
81
|
+
* silently running them.
|
|
82
|
+
*
|
|
83
|
+
* A slot-queued job is exempt from orphan detection — nothing heartbeats for
|
|
84
|
+
* it, so the staleness rule would misreport every job that waits more than 90
|
|
85
|
+
* seconds. But the only things that drained the queue were a runner exiting
|
|
86
|
+
* and a new dispatch arriving, so a server that died with jobs queued left
|
|
87
|
+
* them reading `queued` forever, where a RUNNING job in the same situation is
|
|
88
|
+
* reported orphaned within 90s.
|
|
89
|
+
*
|
|
90
|
+
* The first attempt at this drained the queue here instead, which was worse
|
|
91
|
+
* than the gap it closed. An acceptance pass demonstrated the consequence:
|
|
92
|
+
* kill a server with a job queued, restart it, and that job runs to
|
|
93
|
+
* completion — in its original workingDir, at whatever safety profile the
|
|
94
|
+
* manifest recorded, up to `workspace_edit` or `full_auto`, with nobody
|
|
95
|
+
* watching and no confirmation. Bounded only by the 7-day retention window.
|
|
96
|
+
* Starting an editor is not an action anyone associates with "run yesterday's
|
|
97
|
+
* abandoned agent job against my repository".
|
|
98
|
+
*
|
|
99
|
+
* So: any job still slot-queued when a server starts belongs to a session that
|
|
100
|
+
* is gone — this process has not queued anything yet — and it is marked
|
|
101
|
+
* orphaned. That answers the question the caller was actually asking ("is this
|
|
102
|
+
* ever going to run?") without executing anything on their behalf. The job
|
|
103
|
+
* keeps its id and artifacts, and `retry_job` re-runs it deliberately.
|
|
104
|
+
*/
|
|
105
|
+
function reportStrandedQueue() {
|
|
106
|
+
void orphanStrandedSlotQueue().catch(() => undefined);
|
|
107
|
+
}
|
|
73
108
|
export async function startMcpServer(opts = {}) {
|
|
74
109
|
const { server } = await buildMcpServer(opts);
|
|
75
110
|
const transport = new StdioServerTransport();
|
|
76
111
|
await server.connect(transport);
|
|
112
|
+
reportStrandedQueue();
|
|
77
113
|
return {
|
|
78
114
|
async close() {
|
|
79
115
|
await server.close();
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
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AE,MAAM,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,mBAAmB,EAAE,CAAC;IACtB,OAAO;QACL,KAAK,CAAC,KAAK;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The MCP input contract: what the
|
|
2
|
+
* The MCP input contract: what the six tools accept, and what they refuse.
|
|
3
3
|
*
|
|
4
4
|
* Split out of tools.ts, which had grown to 1040 lines mixing the contract
|
|
5
5
|
* with the handlers that run after it. This half earns its own file rather
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-schemas.d.ts","sourceRoot":"","sources":["../../src/mcp/tool-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,aAAgB,CAAC;AAY5C,eAAO,MAAM,cAAc;;;;;EAAiD,CAAC;AAC7E,eAAO,MAAM,mBAAmB;;;;EAAuD,CAAC;AACxF,eAAO,MAAM,qBAAqB;;;;;EAA8D,CAAC;AACjG,eAAO,MAAM,iBAAiB;;;;;EAAqE,CAAC;AAEpG,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"tool-schemas.d.ts","sourceRoot":"","sources":["../../src/mcp/tool-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,aAAgB,CAAC;AAY5C,eAAO,MAAM,cAAc;;;;;EAAiD,CAAC;AAC7E,eAAO,MAAM,mBAAmB;;;;EAAuD,CAAC;AACxF,eAAO,MAAM,qBAAqB;;;;;EAA8D,CAAC;AACjG,eAAO,MAAM,iBAAiB;;;;;EAAqE,CAAC;AAEpG,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiHM,CAAC;AAErC,eAAO,MAAM,qBAAqB,QAG0B,CAAC;AAE7D,0IAA0I;AAC1I,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC;;;;;;;;GAQG;AACH,mEAAmE;AACnE,eAAO,MAAM,SAAS,QAA0B,CAAC;AAEjD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAkEnC,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;CA6BjC,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0GrB,CAAC;AAEX,eAAO,MAAM,mBAAmB;;CAUtB,CAAC;AAEX,eAAO,MAAM,eAAe;;CAc3B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;CAatB,CAAC;AAEX;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;CA0BtB,CAAC;AAEX,kFAAkF;AAClF,eAAO,MAAM,kBAAkB;;;CAiBrB,CAAC"}
|
package/dist/mcp/tool-schemas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The MCP input contract: what the
|
|
2
|
+
* The MCP input contract: what the six tools accept, and what they refuse.
|
|
3
3
|
*
|
|
4
4
|
* Split out of tools.ts, which had grown to 1040 lines mixing the contract
|
|
5
5
|
* with the handlers that run after it. This half earns its own file rather
|
|
@@ -81,7 +81,9 @@ export const publicHintsSchema = z
|
|
|
81
81
|
.optional()
|
|
82
82
|
.describe("Kind of work: 'execute' (write/modify code, run commands), 'plan' " +
|
|
83
83
|
"(architecture/design, no edits), 'review' (critique code, no edits), 'local' " +
|
|
84
|
-
"(trivial/mechanical —
|
|
84
|
+
"(trivial/mechanical — picks a local endpoint wherever it sits, ahead of the " +
|
|
85
|
+
"usual tier order, and falls back to normal routing when you have none). " +
|
|
86
|
+
"ALWAYS set this: when " +
|
|
85
87
|
"omitted, per-task capability weighting and model escalation are disabled and " +
|
|
86
88
|
"routing quality degrades."),
|
|
87
89
|
preferLargeContext: z
|
|
@@ -289,12 +291,23 @@ export const dispatchInputShape = {
|
|
|
289
291
|
...misplacedTopLevelKeys,
|
|
290
292
|
models: z
|
|
291
293
|
.array(z.string().refine(noNul, NO_NUL_MESSAGE))
|
|
294
|
+
// An EXPLICIT empty array is a caller mistake, and the most expensive one
|
|
295
|
+
// this field can carry: it fell through to the same branch as "omitted"
|
|
296
|
+
// and fanned out to every eligible route — measured at eight arms on one
|
|
297
|
+
// machine, one per configured route. A caller who wrote `models: []` built
|
|
298
|
+
// a list and it came out empty; they did not ask for everything. Omitting
|
|
299
|
+
// the field is how you ask for that, and it stays a deliberate keystroke
|
|
300
|
+
// rather than the result of a filter matching nothing.
|
|
301
|
+
.min(1, "models: [] selects no routes. Omit `models` entirely to fan out to every " +
|
|
302
|
+
"eligible route (expensive — one dispatch per route), or name at least one. " +
|
|
303
|
+
"An empty list is usually a filter that matched nothing.")
|
|
292
304
|
.optional()
|
|
293
305
|
.describe("Route ids or model names to fan out to (fanout mode only). This is the ONLY " +
|
|
294
306
|
"field that narrows which routes fanout hits — `hints.model` is ignored " +
|
|
295
307
|
"entirely in fanout mode (not used for selection, not forwarded to any " +
|
|
296
|
-
"dispatch); it only does anything in single mode.
|
|
297
|
-
"
|
|
308
|
+
"dispatch); it only does anything in single mode. An empty array is " +
|
|
309
|
+
"REFUSED rather than treated as 'all routes' — omit the field for that. " +
|
|
310
|
+
"Get valid ids from the `usage` tool."),
|
|
298
311
|
service: z
|
|
299
312
|
.string()
|
|
300
313
|
.optional()
|
|
@@ -379,8 +392,11 @@ export const workspaceInputShape = {
|
|
|
379
392
|
.boolean()
|
|
380
393
|
.optional()
|
|
381
394
|
.describe("Override a refusal. On 'apply': apply even when the target project has " +
|
|
382
|
-
"uncommitted changes
|
|
383
|
-
"
|
|
395
|
+
"uncommitted changes (a check only possible IN A GIT REPOSITORY — outside " +
|
|
396
|
+
"one, apply still refuses a file the patch touches that changed since the " +
|
|
397
|
+
"dispatch, but cannot see unrelated edits) — off by default because the " +
|
|
398
|
+
"patch was built against a clean base, so applying over newer work can " +
|
|
399
|
+
"conflict with or overwrite it. " +
|
|
384
400
|
"On 'discard': delete the workspace even when it holds changes your project " +
|
|
385
401
|
"does not have — off by default because discard is irreversible and the " +
|
|
386
402
|
"workspace may be the only copy."),
|
|
@@ -396,6 +412,10 @@ export const retryJobInputShape = {
|
|
|
396
412
|
.optional()
|
|
397
413
|
.describe("Route the retry somewhere else (e.g. the original hit its usage limit). " +
|
|
398
414
|
"Omit to reuse the original route, or to let the router pick again if it " +
|
|
399
|
-
"had none. Get valid ids from `usage`."
|
|
415
|
+
"had none. Get valid ids from `usage`. Retargeting leaves behind the " +
|
|
416
|
+
"original's model when the new route does not declare it — a model name " +
|
|
417
|
+
"belongs to the route it was picked for — and reports it as " +
|
|
418
|
+
"`droppedModel`; pass a fresh `hints.model` on `dispatch` to choose one " +
|
|
419
|
+
"for this route."),
|
|
400
420
|
};
|
|
401
421
|
//# sourceMappingURL=tool-schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-schemas.js","sourceRoot":"","sources":["../../src/mcp/tool-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM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AAC;SAChE,QAAQ,CAAC,wEAAwE,CAAC;IACrF,MAAM,EAAE,CAAC;SACN,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;SAClC,QAAQ,CACP,8EAA8E;QAC5E,0EAA0E;QAC1E,0EAA0E,CAC7E;IACH,KAAK,EAAE,CAAC;SACL,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CACP,yEAAyE;QACvE,2EAA2E;QAC3E,2EAA2E;QAC3E,yEAAyE;QACzE,wEAAwE;QACxE,iCAAiC;QACjC,6EAA6E;QAC7E,yEAAyE;QACzE,iCAAiC,CACpC;CACK,CAAC;AAEX,kFAAkF;AAClF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,KAAK,CAAC,SAAS,EAAE,8CAA8C,CAAC;SAChE,QAAQ,CAAC,wDAAwD,CAAC;IACrE,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,0EAA0E;QACxE,0EAA0E;QAC1E,sEAAsE;QACtE,yEAAyE;QACzE,6DAA6D;QAC7D,yEAAyE;QACzE,iBAAiB,CACpB;CACK,CAAC"}
|
package/dist/mcp/tools.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP tool registry for harness-dispatch.
|
|
3
3
|
*
|
|
4
|
-
* The public MCP surface is
|
|
5
|
-
* `dispatch` starts routed work (single or fanout) and only ever starts
|
|
6
|
-
* `job_status` checks or lists it
|
|
7
|
-
*
|
|
4
|
+
* The public MCP surface is six tools, each doing exactly one thing:
|
|
5
|
+
* `dispatch` starts routed work (single or fanout) and only ever starts;
|
|
6
|
+
* `job_status` checks or lists it; `cancel_job` stops one; `retry_job` runs a
|
|
7
|
+
* finished one again; `workspace` inspects, keeps or discards isolated work;
|
|
8
|
+
* `usage` reads route/quota state.
|
|
9
|
+
*
|
|
10
|
+
* The count was corrected from three to six a release ago and this list was
|
|
11
|
+
* not — the same defect one line further down, which is why it is spelled out
|
|
12
|
+
* in full here rather than summarised.
|
|
13
|
+
*
|
|
14
|
+
* Every dispatch is job-backed from the first moment — dispatch races an inline
|
|
8
15
|
* grace window against the background run, so a fast task returns its full
|
|
9
16
|
* result in-call and a slow one degrades to a pollable jobId with NOTHING
|
|
10
17
|
* lost to a timeout; job_status is how that jobId gets checked on later.
|
|
@@ -174,5 +181,27 @@ export type InvokeResult = {
|
|
|
174
181
|
kind: "json";
|
|
175
182
|
data: unknown;
|
|
176
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* Near-miss top-level keys are caught by `mcp/near-miss-guard.ts`, not here.
|
|
186
|
+
*
|
|
187
|
+
* This is where the gap used to be documented. The MCP SDK validates against
|
|
188
|
+
* `z.object(dispatchInputShape)` before any code in this file runs, and zod
|
|
189
|
+
* STRIPS unknown keys — so by the time a handler sees the arguments, a
|
|
190
|
+
* misspelled key is already gone, and nothing in the registered-tool path can
|
|
191
|
+
* see what the caller actually sent. `hints` is `.strict()`, which is why the
|
|
192
|
+
* nested form was always rejected; the outer object cannot be, because MCP
|
|
193
|
+
* carries `_meta` there.
|
|
194
|
+
*
|
|
195
|
+
* An acceptance pass measured what that cost: `safteyProfile: "read_only"` was
|
|
196
|
+
* accepted in silence and the dispatch ran at the `workspace_edit` default,
|
|
197
|
+
* writing a file. Asking for read-only by way of a typo got you write access,
|
|
198
|
+
* while the HTTP surface refused the same input — one input, two opposite
|
|
199
|
+
* answers, which is the class the parity suite exists to end.
|
|
200
|
+
*
|
|
201
|
+
* The guard wraps the CallTool handler the SDK installs and inspects the raw
|
|
202
|
+
* arguments before delegating, so the SDK's routing, validation and `extra`
|
|
203
|
+
* plumbing are untouched. Both surfaces now run the same check from
|
|
204
|
+
* `near-miss.ts`, and `surface-parity.test.ts` asserts it on both.
|
|
205
|
+
*/
|
|
177
206
|
export declare function invokeTool(name: string, args: unknown, deps: ToolDeps): Promise<InvokeResult>;
|
|
178
207
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/mcp/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAkB,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAKV,SAAS,EACT,QAAQ,EACR,eAAe,EACf,YAAY,EACb,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AAKpB,OAAO,EAKL,kBAAkB,EAElB,mBAAmB,EAOpB,MAAM,mBAAmB,CAAC;AAW3B;;;;;;;;;;GAUG;AAGH,eAAO,MAAM,UAAU,sFAAuF,CAAC;AAE/G,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IA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