@hmharness/kernel 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +7 -1
- package/dist/provider.js +2 -2
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
package/dist/mcp.d.ts
CHANGED
|
@@ -5,11 +5,13 @@ export type McpServerConfig = {
|
|
|
5
5
|
args?: string[];
|
|
6
6
|
env?: Record<string, string>;
|
|
7
7
|
trusted?: boolean;
|
|
8
|
+
trustedTools?: string[];
|
|
8
9
|
} | {
|
|
9
10
|
type: 'http';
|
|
10
11
|
url: string;
|
|
11
12
|
headers?: Record<string, string>;
|
|
12
13
|
trusted?: boolean;
|
|
14
|
+
trustedTools?: string[];
|
|
13
15
|
};
|
|
14
16
|
export declare class McpClient {
|
|
15
17
|
readonly serverName: string;
|
package/dist/mcp.js
CHANGED
|
@@ -253,14 +253,20 @@ export async function mcpServerTools(serverName, config) {
|
|
|
253
253
|
await client.connect();
|
|
254
254
|
const remote = await client.listTools();
|
|
255
255
|
const trusted = 'trusted' in config && config.trusted === true;
|
|
256
|
+
// Exemption granularity: `trusted: true` exempts the WHOLE server (dangerous,
|
|
257
|
+
// meant for servers you own). `trustedTools: ['search', ...]` exempts only
|
|
258
|
+
// the named REMOTE tool names - read-only lookups stay frictionless while
|
|
259
|
+
// every mutating tool on the same server still hits the approval gate.
|
|
260
|
+
const trustedTools = 'trustedTools' in config && Array.isArray(config.trustedTools) ? config.trustedTools : [];
|
|
256
261
|
const tools = remote.map((t) => {
|
|
257
262
|
const localName = `mcp_${sanitizeToolName(serverName)}_${sanitizeToolName(t.name)}`.slice(0, 60);
|
|
258
263
|
const remoteName = t.name;
|
|
264
|
+
const exempt = trusted || trustedTools.includes(remoteName);
|
|
259
265
|
return {
|
|
260
266
|
name: localName,
|
|
261
267
|
description: `[mcp:${serverName}] ${t.description ?? t.name}`.slice(0, 400),
|
|
262
268
|
parameters: normalizeSchema(t.inputSchema),
|
|
263
|
-
needsApproval:
|
|
269
|
+
needsApproval: exempt ? undefined : () => true,
|
|
264
270
|
async execute(args) {
|
|
265
271
|
return client.callTool(remoteName, args);
|
|
266
272
|
},
|
package/dist/provider.js
CHANGED
|
@@ -17,7 +17,7 @@ export async function chat(cfg, messages, tools, opts = {}) {
|
|
|
17
17
|
let lastError = '';
|
|
18
18
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
19
19
|
const ctrl = new AbortController();
|
|
20
|
-
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 120_000);
|
|
20
|
+
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? cfg.timeoutMs ?? 120_000);
|
|
21
21
|
try {
|
|
22
22
|
const res = await fetch(endpoint(cfg.baseUrl), {
|
|
23
23
|
method: 'POST',
|
|
@@ -191,7 +191,7 @@ export async function chatVision(cfg, prompt, imageDataUrl, opts = {}) {
|
|
|
191
191
|
let vAuth = cfg.authHeader ?? 'bearer';
|
|
192
192
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
193
193
|
const ctrl = new AbortController();
|
|
194
|
-
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 120_000);
|
|
194
|
+
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? cfg.timeoutMs ?? 120_000);
|
|
195
195
|
try {
|
|
196
196
|
const vHeaders = vAuth === 'bearer'
|
|
197
197
|
? { 'Content-Type': 'application/json', Authorization: `Bearer ${cfg.apiKey}` }
|
package/dist/types.d.ts
CHANGED
|
@@ -60,6 +60,10 @@ export interface ProviderConfig {
|
|
|
60
60
|
* for freellmapi). Omit for standard Authorization: Bearer; on 401 the
|
|
61
61
|
* provider renegotiates with X-Api-Key automatically. */
|
|
62
62
|
authHeader?: string;
|
|
63
|
+
/** Per-request timeout override (ms). Slow reasoning models (free-tier
|
|
64
|
+
* tokenrouter took 84s on an evolve-sized prompt vs the 120s default)
|
|
65
|
+
* set e.g. 240000 on the evolve/bench routes. */
|
|
66
|
+
timeoutMs?: number;
|
|
63
67
|
}
|
|
64
68
|
/** User-level configuration (HMH_HOME/config.json). */
|
|
65
69
|
export interface HmhConfig {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/kernel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "hmharness kernel: tool registry, provider adapters, the agent loop, session log, config. Zero runtime dependencies (Node >=22 native fetch).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|