@jjh32456/dsh-longlive 0.0.0-stage → 1.6.4
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 +1525 -0
- package/LICENSE +21 -0
- package/QUICKSTART.md +342 -0
- package/README.en.md +43 -0
- package/README.md +149 -2
- package/SPEC.md +204 -0
- package/cordis.patch.yml +81 -0
- package/docs/ARCHITECTURE.md +127 -0
- package/docs/AUTO-RECALL-WIRING.md +84 -0
- package/docs/AUTO-RECALL.md +123 -0
- package/docs/CONCEPTS.md +143 -0
- package/docs/CONFIG.md +547 -0
- package/docs/DEV.md +279 -0
- package/docs/ERRORS.md +259 -0
- package/docs/FAQ.md +186 -0
- package/docs/FEATURES.md +325 -0
- package/docs/METRICS.md +244 -0
- package/docs/MIGRATION-1.6.0.md +218 -0
- package/docs/OPERATIONS.md +433 -0
- package/docs/PANEL-INTEGRATION.md +183 -0
- package/docs/PRESENCE-BUS-WIRING.md +491 -0
- package/docs/PRESENCE-BUS.md +694 -0
- package/docs/QUICKSTART.md +149 -0
- package/docs/README.en.md +44 -0
- package/docs/RESIDENT-WATCHER.md +90 -0
- package/docs/SESSION-WATCH.md +214 -0
- package/docs/SURGERY.md +186 -0
- package/docs/TOOLS.md +184 -0
- package/docs/TROUBLESHOOTING.md +329 -0
- package/icon.svg +11 -0
- package/lib/client.js +436 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +209 -4
- package/runbook.md +314 -0
- package/scripts/auto-truncate-run.ps1 +711 -0
- package/scripts/install-resident-watcher.ps1 +15 -0
- package/scripts/install-session-watch.ps1 +332 -0
- package/scripts/install-surgery-task.ps1 +171 -0
- package/scripts/lib/auto-truncate-run.ps1 +512 -0
- package/scripts/lib/session-watch-fixture.mjs +207 -0
- package/scripts/longlive-doctor.mjs +513 -0
- package/scripts/mark-core-cards.mjs +289 -0
- package/scripts/metrics-read.mjs +79 -0
- package/scripts/metrics-sample.mjs +215 -0
- package/scripts/pack.mjs +392 -0
- package/scripts/resident-watcher-status.ps1 +15 -0
- package/scripts/resident-watcher.ps1 +643 -0
- package/scripts/router-proposals.mjs +386 -0
- package/scripts/session-watch-drill.mjs +553 -0
- package/scripts/session-watch-status.ps1 +146 -0
- package/scripts/session-watch.mjs +1367 -0
- package/scripts/surgery-inspect.mjs +122 -0
- package/scripts/surgery-run.cmd +34 -0
- package/scripts/truncate-cli.mjs +273 -0
- package/scripts/unattended-surgery.ps1 +1016 -0
- package/scripts/uninstall-resident-watcher.ps1 +15 -0
- package/scripts/uninstall-session-watch.ps1 +192 -0
- package/scripts/watch-loop.ps1 +916 -0
- package/src/auto-truncate.js +891 -0
- package/src/backup.js +146 -0
- package/src/bus/bus.mjs +1446 -0
- package/src/codec.js +269 -0
- package/src/compaction/cut-engine.js +44 -0
- package/src/compaction/engine-core.js +1070 -0
- package/src/compaction/entry.js +228 -0
- package/src/compaction.js +230 -0
- package/src/conclusion.js +346 -0
- package/src/config.js +392 -0
- package/src/d6/runtime.js +517 -0
- package/src/d6/surface.js +181 -0
- package/src/deps.js +187 -0
- package/src/engine-status.js +141 -0
- package/src/features.js +606 -0
- package/src/heartbeat.js +252 -0
- package/src/home.js +16 -0
- package/src/host-version.js +280 -0
- package/src/identity/card-marker.js +281 -0
- package/src/identity/handover.js +606 -0
- package/src/identity/index.js +329 -0
- package/src/identity/inject-position.js +131 -0
- package/src/identity/writeback.js +344 -0
- package/src/identity.js +118 -0
- package/src/index.js +474 -0
- package/src/live-target.js +212 -0
- package/src/live.js +1468 -0
- package/src/memory/cards.js +425 -0
- package/src/memory/consolidate.js +670 -0
- package/src/memory/filter-runner.js +555 -0
- package/src/memory/filter.js +1031 -0
- package/src/memory/forget.js +386 -0
- package/src/memory/frontmatter.js +454 -0
- package/src/memory/index.js +287 -0
- package/src/memory/maintenance.js +734 -0
- package/src/memory/manifest.js +245 -0
- package/src/memory/paths.js +229 -0
- package/src/memory/procedure.js +963 -0
- package/src/memory/provenance.js +119 -0
- package/src/memory/recall.js +219 -0
- package/src/memory/reinforce.js +145 -0
- package/src/memory/state.js +279 -0
- package/src/metrics/classify.mjs +187 -0
- package/src/metrics/estimate.mjs +108 -0
- package/src/metrics/index.mjs +184 -0
- package/src/metrics/measure.mjs +462 -0
- package/src/metrics/store.mjs +234 -0
- package/src/original.js +294 -0
- package/src/policy-profile.js +448 -0
- package/src/recall/cards.mjs +195 -0
- package/src/recall/embedding.mjs +698 -0
- package/src/recall/index.js +405 -0
- package/src/recall/inject-order.mjs +267 -0
- package/src/recall/privacy.mjs +119 -0
- package/src/recall/recall-core.mjs +657 -0
- package/src/router/aliases.json +31 -0
- package/src/router/background/agent-runner.mjs +239 -0
- package/src/router/background/anchor.mjs +323 -0
- package/src/router/background/audit.mjs +337 -0
- package/src/router/background/budget-ledger.mjs +648 -0
- package/src/router/background/host-sim.mjs +451 -0
- package/src/router/background/index.mjs +81 -0
- package/src/router/background/memory.mjs +63 -0
- package/src/router/background/mock-llm.mjs +203 -0
- package/src/router/background/queue.mjs +224 -0
- package/src/router/background/retry.mjs +255 -0
- package/src/router/background/router.mjs +1459 -0
- package/src/router/background/stream.mjs +276 -0
- package/src/router/background/tool-policy.mjs +255 -0
- package/src/router/design-headings.json +221 -0
- package/src/router/face/config.mjs +155 -0
- package/src/router/face/context.mjs +284 -0
- package/src/router/face/face.mjs +466 -0
- package/src/router/face/identity.mjs +130 -0
- package/src/router/face/index.mjs +65 -0
- package/src/router/face/journal.mjs +119 -0
- package/src/router/face/llm.mjs +252 -0
- package/src/router/face/outbox.mjs +153 -0
- package/src/router/face/paths.mjs +54 -0
- package/src/router/fixtures/M1.json +16 -0
- package/src/router/fixtures/M2.json +16 -0
- package/src/router/fixtures/M3.json +20 -0
- package/src/router/fixtures/M4.json +20 -0
- package/src/router/fixtures/M5.json +45 -0
- package/src/router/fixtures/M6.json +53 -0
- package/src/router/fixtures/M7.json +46 -0
- package/src/router/fixtures/S1.json +20 -0
- package/src/router/fixtures/S2.json +23 -0
- package/src/router/fixtures/S3.json +20 -0
- package/src/router/fixtures/S4.json +34 -0
- package/src/router/fixtures/S5.json +43 -0
- package/src/router/fixtures/S6.json +47 -0
- package/src/router/fixtures/T1.json +23 -0
- package/src/router/fixtures/T2.json +16 -0
- package/src/router/fixtures/T3.json +19 -0
- package/src/router/fixtures/T4.json +16 -0
- package/src/router/fixtures/X1.json +17 -0
- package/src/router/fixtures/X2.json +20 -0
- package/src/router/gen-design-headings.mjs +107 -0
- package/src/router/judge.mjs +986 -0
- package/src/router/policies/generic.json +114 -0
- package/src/router/policies/owner-rulings-2026-11-03.json +62 -0
- package/src/router/route.js +1679 -0
- package/src/router/router.mjs +531 -0
- package/src/router/routing-rules.json +1001 -0
- package/src/router/run-sim.mjs +530 -0
- package/src/router/runtime.js +558 -0
- package/src/router/service/apply.mjs +1218 -0
- package/src/router/service/board.mjs +632 -0
- package/src/router/service/caller.mjs +131 -0
- package/src/router/service/config.mjs +361 -0
- package/src/router/service/context.mjs +314 -0
- package/src/router/service/hint.mjs +654 -0
- package/src/router/service/lease.mjs +494 -0
- package/src/router/service/live.mjs +251 -0
- package/src/router/service/lock.mjs +550 -0
- package/src/router/service/merge.mjs +255 -0
- package/src/router/service/model-resolve.mjs +350 -0
- package/src/router/service/paths.mjs +180 -0
- package/src/router/service/proposals.mjs +1461 -0
- package/src/router/service/queue.mjs +477 -0
- package/src/router/service/reconcile.mjs +253 -0
- package/src/router/service/service.mjs +2963 -0
- package/src/router/service/sources.mjs +352 -0
- package/src/router/service/status.mjs +514 -0
- package/src/router/service/store.mjs +476 -0
- package/src/router/service/ticklock.mjs +239 -0
- package/src/router/service/tokens.mjs +95 -0
- package/src/router/service/tools.mjs +248 -0
- package/src/router/service/wake.mjs +544 -0
- package/src/router/service/wal.mjs +685 -0
- package/src/router/shadow.mjs +820 -0
- package/src/surgery-recovery.js +1909 -0
- package/src/tool-output.js +396 -0
- package/src/tools.js +2887 -0
- package/src/truncate-visible.js +2258 -0
- package/src/truncate.js +999 -0
- package/src/ui/flags.js +259 -0
- package/src/ui/routes.js +281 -0
- package/src/version.js +99 -0
- package/test/auto-recall.test.mjs +474 -0
- package/test/auto-truncate.test.mjs +931 -0
- package/test/autobind.test.mjs +385 -0
- package/test/bus.test.mjs +1572 -0
- package/test/cli-guard.test.mjs +198 -0
- package/test/conclusion.test.mjs +408 -0
- package/test/config-schema.test.mjs +204 -0
- package/test/d6-output.test.mjs +194 -0
- package/test/d6.test.mjs +395 -0
- package/test/deps.test.mjs +342 -0
- package/test/doctor-setup.test.mjs +297 -0
- package/test/embedding-recall.test.mjs +347 -0
- package/test/feature-flags.test.mjs +568 -0
- package/test/filter-shadow.test.mjs +170 -0
- package/test/fixtures/baseline-0.8.0-registration.json +556 -0
- package/test/fixtures/d6-header-tools.json +1 -0
- package/test/fixtures/lock-child.mjs +67 -0
- package/test/fixtures/pre-step-container.mjs +100 -0
- package/test/fixtures/privacy-memory/topics/pii-unmarked.md +9 -0
- package/test/fixtures/privacy-memory/topics/secret-local-only.md +11 -0
- package/test/fixtures/profile-session-longlive-config.json +20 -0
- package/test/fixtures/proposal-cas-child.mjs +66 -0
- package/test/host-engine-status.test.mjs +307 -0
- package/test/hot-truncate.test.mjs +1081 -0
- package/test/identity-card-marker.test.mjs +307 -0
- package/test/identity-router/run.mjs +721 -0
- package/test/integration-pre-step.test.mjs +553 -0
- package/test/live.test.mjs +1020 -0
- package/test/maintenance-schedule.test.mjs +538 -0
- package/test/memory.test.mjs +2828 -0
- package/test/metrics.test.mjs +478 -0
- package/test/orchestrator.test.mjs +266 -0
- package/test/p1_probe.mjs +97 -0
- package/test/packaging.test.mjs +182 -0
- package/test/portability.test.mjs +343 -0
- package/test/rc4-regressions.test.mjs +562 -0
- package/test/rc5-regressions.test.mjs +197 -0
- package/test/rc6-chinese.test.mjs +394 -0
- package/test/router-1100/apply-off.test.mjs +175 -0
- package/test/router-1100/budget-reconcile.test.mjs +215 -0
- package/test/router-1100/config-context.test.mjs +211 -0
- package/test/router-1100/helpers.mjs +129 -0
- package/test/router-1100/hint-envelope.test.mjs +150 -0
- package/test/router-1100/lock-crossproc.test.mjs +206 -0
- package/test/router-1100/proposal-cas-crossproc.test.mjs +184 -0
- package/test/router-1100/router-apply.test.mjs +372 -0
- package/test/router-1100/router-fixb.test.mjs +602 -0
- package/test/router-1100/router-proposals.test.mjs +405 -0
- package/test/router-1100/router-queue-lease-wal.test.mjs +355 -0
- package/test/router-1100/router-security-cr.test.mjs +333 -0
- package/test/router-1100/service-lifecycle.test.mjs +220 -0
- package/test/router-1100/tools-contract.test.mjs +164 -0
- package/test/router-1100/turn-reflect-tick.test.mjs +89 -0
- package/test/router-1100/v6-contract.test.mjs +158 -0
- package/test/router-1100/v6b-contract.test.mjs +293 -0
- package/test/router-1100/v6c-contract.test.mjs +249 -0
- package/test/router-1100/wal-rotation.test.mjs +375 -0
- package/test/router-1100/wp1-config.test.mjs +170 -0
- package/test/router-1100/wp1-default-off.test.mjs +77 -0
- package/test/router-1100/wp1-model-status.test.mjs +90 -0
- package/test/router-1100/wp1-status.test.mjs +220 -0
- package/test/router-1100/wp1-tools.test.mjs +146 -0
- package/test/router-1100/wp5-cli.test.mjs +240 -0
- package/test/router-1100/wp5-model-auto.test.mjs +418 -0
- package/test/router-1100/wp6-merge.test.mjs +386 -0
- package/test/router-1100/wp6-wake.test.mjs +502 -0
- package/test/router-background/audit.test.mjs +37 -0
- package/test/router-background/budget-ledger.test.mjs +330 -0
- package/test/router-background/cross-process.test.mjs +222 -0
- package/test/router-background/fixtures/cross-child.mjs +85 -0
- package/test/router-background/fixtures/real-shapes.mjs +239 -0
- package/test/router-background/router.test.mjs +1044 -0
- package/test/router-background/stream-retry.test.mjs +358 -0
- package/test/router-background/tool-agent.test.mjs +384 -0
- package/test/router-face/bridge.test.mjs +169 -0
- package/test/router-face/face.test.mjs +316 -0
- package/test/router-failclosed.test.mjs +466 -0
- package/test/router-identity.test.mjs +384 -0
- package/test/router-l1-l2.contract.test.mjs +1075 -0
- package/test/router-memory-tools.test.mjs +262 -0
- package/test/router-policy.test.mjs +225 -0
- package/test/router-runtime.test.mjs +438 -0
- package/test/router-shadow.test.mjs +287 -0
- package/test/router.test.mjs +903 -0
- package/test/run-rc.mjs +299 -0
- package/test/run.mjs +2469 -0
- package/test/safety-defaults.test.mjs +179 -0
- package/test/seeded-load.test.mjs +436 -0
- package/test/session-original.test.mjs +338 -0
- package/test/surgery-recovery.test.mjs +936 -0
- package/test/t7_drive.mjs +151 -0
- package/test/tool-output.test.mjs +393 -0
- package/test/tool-schema.test.mjs +177 -0
- package/test/tools_contract.test.mjs +716 -0
- package/test/truncate-visible.test.mjs +1150 -0
- package/test/ui-flags.test.mjs +477 -0
- package/test/v4-hardening.test.mjs +427 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// Host-contract gate for tool `parameters`.
|
|
2
|
+
//
|
|
3
|
+
// 1.5.0 shipped D6's `tool_search` with a full JSON Schema object as
|
|
4
|
+
// `parameters`. Host 0.2.2-rc.1's `defineTool` expects a bare property map
|
|
5
|
+
// (argument name -> value schema) and throws while building the tool:
|
|
6
|
+
//
|
|
7
|
+
// JsonSchemaError: unsupported JSON schema:
|
|
8
|
+
// parameters.type must be a value schema object
|
|
9
|
+
//
|
|
10
|
+
// That is a startup failure for the whole host (EXIT 1), so it must be caught
|
|
11
|
+
// here. The validator below mirrors the host's author-schema compiler:
|
|
12
|
+
// `_host022/lib/types/schema.js:240` compilePropertyMap(spec, 'parameters')
|
|
13
|
+
// `_host022/lib/types/schema.js:76-83` every property must be a value schema
|
|
14
|
+
// `_host022/lib/types/schema.js:127-205` the value-schema DSL
|
|
15
|
+
// It is intentionally local: plain-node suites must not require the host
|
|
16
|
+
// package, and the test drives the real `registerTools()` seam instead.
|
|
17
|
+
|
|
18
|
+
import assert from 'node:assert/strict';
|
|
19
|
+
import test from 'node:test';
|
|
20
|
+
|
|
21
|
+
import { TOOL_SEARCH_SPEC } from '../src/d6/runtime.js';
|
|
22
|
+
import { createRouterTools } from '../src/router/service/tools.mjs';
|
|
23
|
+
import { TOOLS, registerTools } from '../src/tools.js';
|
|
24
|
+
|
|
25
|
+
const VALUE_TYPES = new Set([
|
|
26
|
+
'string',
|
|
27
|
+
'number',
|
|
28
|
+
'integer',
|
|
29
|
+
'boolean',
|
|
30
|
+
'null',
|
|
31
|
+
'array',
|
|
32
|
+
'object',
|
|
33
|
+
'json',
|
|
34
|
+
]);
|
|
35
|
+
const ANNOTATION_KEYS = ['description', 'title', 'default', 'examples'];
|
|
36
|
+
|
|
37
|
+
function isPlainRecord(value) {
|
|
38
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function assertAllowedKeys(schema, path, allowed) {
|
|
42
|
+
for (const key of Object.keys(schema)) {
|
|
43
|
+
assert.ok(allowed.includes(key), `${path}.${key} is not supported by the host value schema DSL`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Compile one value schema the way `_host022/lib/types/schema.js` would. */
|
|
48
|
+
function assertValueSchema(schema, path, { allowRequired = false } = {}) {
|
|
49
|
+
assert.ok(isPlainRecord(schema), `${path} must be a value schema object`);
|
|
50
|
+
if (Object.hasOwn(schema, 'required')) {
|
|
51
|
+
assert.equal(allowRequired, true, `${path}.required is only allowed on a property`);
|
|
52
|
+
assert.equal(schema.required, true, `${path}.required must be true when present`);
|
|
53
|
+
}
|
|
54
|
+
const authorKeys = [...ANNOTATION_KEYS, ...(allowRequired ? ['required'] : [])];
|
|
55
|
+
|
|
56
|
+
if (Object.hasOwn(schema, 'oneOf')) {
|
|
57
|
+
assert.ok(!Object.hasOwn(schema, 'type'), `${path} cannot declare both type and oneOf`);
|
|
58
|
+
assertAllowedKeys(schema, path, [...authorKeys, 'oneOf']);
|
|
59
|
+
assert.ok(
|
|
60
|
+
Array.isArray(schema.oneOf) && schema.oneOf.length >= 2,
|
|
61
|
+
`${path}.oneOf must be an array of at least two value schemas`,
|
|
62
|
+
);
|
|
63
|
+
schema.oneOf.forEach((branch, index) => {
|
|
64
|
+
assertValueSchema(branch, `${path}.oneOf[${index}]`, { allowRequired: false });
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
assert.ok(Object.hasOwn(schema, 'type'), `${path} must declare type or oneOf`);
|
|
70
|
+
const { type } = schema;
|
|
71
|
+
assert.ok(
|
|
72
|
+
typeof type === 'string' && VALUE_TYPES.has(type),
|
|
73
|
+
`${path}.type must be string/number/integer/boolean/null/array/object/json`,
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
if (type === 'object') {
|
|
77
|
+
assertAllowedKeys(schema, path, [...authorKeys, 'type', 'properties', 'additionalProperties']);
|
|
78
|
+
assert.equal(
|
|
79
|
+
typeof schema.additionalProperties,
|
|
80
|
+
'boolean',
|
|
81
|
+
`${path}.additionalProperties must be explicitly true or false`,
|
|
82
|
+
);
|
|
83
|
+
if (Object.hasOwn(schema, 'properties')) {
|
|
84
|
+
const properties = schema.properties;
|
|
85
|
+
assert.ok(isPlainRecord(properties), `${path}.properties must be a map of value schemas`);
|
|
86
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
87
|
+
assertValueSchema(value, `${path}.properties.${name}`, { allowRequired: true });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (type === 'array') {
|
|
94
|
+
assertAllowedKeys(schema, path, [...authorKeys, 'type', 'items']);
|
|
95
|
+
if (Object.hasOwn(schema, 'items')) {
|
|
96
|
+
assertValueSchema(schema.items, `${path}.items`, { allowRequired: false });
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
assertAllowedKeys(schema, path, [...authorKeys, 'type', 'enum', 'const']);
|
|
102
|
+
if (Object.hasOwn(schema, 'enum')) {
|
|
103
|
+
assert.ok(
|
|
104
|
+
Array.isArray(schema.enum) && schema.enum.length > 0,
|
|
105
|
+
`${path}.enum must be a non-empty array of scalar values`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The host receives `parameters` and runs `compilePropertyMap` on it. A
|
|
112
|
+
* top-level `type`/`properties`/`additionalProperties` means the caller passed
|
|
113
|
+
* a wrapped JSON Schema instead of that map.
|
|
114
|
+
*/
|
|
115
|
+
function assertBareParameterMap(parameters, label) {
|
|
116
|
+
assert.ok(
|
|
117
|
+
isPlainRecord(parameters),
|
|
118
|
+
`${label}: parameters must be an object map of argument name -> value schema`,
|
|
119
|
+
);
|
|
120
|
+
for (const wrapperKey of ['type', 'properties', 'required', 'additionalProperties', '$schema']) {
|
|
121
|
+
assert.ok(
|
|
122
|
+
!Object.hasOwn(parameters, wrapperKey),
|
|
123
|
+
`${label}: parameters must not have a top-level "${wrapperKey}" ` +
|
|
124
|
+
'(the host expects a bare property map, not a JSON Schema object)',
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
for (const [name, schema] of Object.entries(parameters)) {
|
|
128
|
+
assertValueSchema(schema, `${label}.${name}`, { allowRequired: true });
|
|
129
|
+
}
|
|
130
|
+
return parameters;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
test('every default tool hands defineTool a bare parameter map', () => {
|
|
134
|
+
for (const tool of TOOLS) {
|
|
135
|
+
assertBareParameterMap(tool.parameters, tool.name);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('D6 tool_search parameters are a bare map, not a wrapped JSON Schema', () => {
|
|
140
|
+
const parameters = assertBareParameterMap(TOOL_SEARCH_SPEC.parameters, 'tool_search');
|
|
141
|
+
assert.deepEqual(Object.keys(parameters), ['names', 'query', 'limit']);
|
|
142
|
+
assert.equal(parameters.names.type, 'array');
|
|
143
|
+
assert.equal(parameters.names.items.type, 'string');
|
|
144
|
+
assert.equal(parameters.query.type, 'string');
|
|
145
|
+
assert.equal(parameters.limit.type, 'integer');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('registerTools passes the host validator for every registered tool family', async () => {
|
|
149
|
+
const routerTools = createRouterTools({
|
|
150
|
+
status: () => ({ ok: true }),
|
|
151
|
+
config: { proposalEnabled: true },
|
|
152
|
+
});
|
|
153
|
+
const d6Tools = [{ ...TOOL_SEARCH_SPEC, invoke: async () => ({}) }];
|
|
154
|
+
// This is exactly the host seam: registerTools() calls defineTool() once per
|
|
155
|
+
// tool, and defineTool() is what throws in 0.2.2-rc.1.
|
|
156
|
+
const defineTool = (definition) => {
|
|
157
|
+
assertBareParameterMap(definition.parameters, definition.name);
|
|
158
|
+
return definition;
|
|
159
|
+
};
|
|
160
|
+
const captured = [];
|
|
161
|
+
const ctx = {
|
|
162
|
+
tools: {
|
|
163
|
+
register(definition) {
|
|
164
|
+
captured.push(definition);
|
|
165
|
+
return () => {};
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const count = await registerTools(ctx, { defineTool, routerTools, d6Tools });
|
|
171
|
+
|
|
172
|
+
assert.equal(count, TOOLS.length + routerTools.length + 1);
|
|
173
|
+
assert.equal(captured.length, count);
|
|
174
|
+
assert.equal(captured.at(-1)?.name, 'tool_search');
|
|
175
|
+
const names = captured.map((definition) => definition.name);
|
|
176
|
+
assert.equal(new Set(names).size, names.length, 'registered tool names must be unique');
|
|
177
|
+
});
|