@dommaker/harness 0.19.0 → 1.0.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 +14 -0
- package/bin/harness.js +136 -557
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +2 -13
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts +90 -0
- package/dist/cli/commands/definitions.d.ts.map +1 -0
- package/dist/cli/commands/definitions.js +519 -0
- package/dist/cli/commands/definitions.js.map +1 -0
- package/dist/cli/commands/knowledge.js.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +3 -25
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +3 -93
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +4 -4
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/context/index.d.ts +1 -5
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -5
- package/dist/context/index.js.map +1 -1
- package/dist/context/knowledge-injector.d.ts +3 -3
- package/dist/context/knowledge-injector.d.ts.map +1 -1
- package/dist/context/knowledge-injector.js +1 -1
- package/dist/context/session-manager.d.ts +1 -12
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +0 -63
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +1 -39
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/types.js +2 -15
- package/dist/context/types.js.map +1 -1
- package/dist/core/constraints/agent-prompt-renderer.d.ts +1 -1
- package/dist/core/constraints/agent-prompt-renderer.js +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +17 -2
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +84 -2
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/checker.d.ts +3 -17
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +7 -47
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/definitions.d.ts +0 -7
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +1 -8
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts +0 -2
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/index.d.ts +1 -1
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +2 -3
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/interceptor.d.ts.map +1 -1
- package/dist/core/constraints/interceptor.js +1 -5
- package/dist/core/constraints/interceptor.js.map +1 -1
- package/dist/core/effective-constraints.d.ts.map +1 -1
- package/dist/core/effective-constraints.js +0 -1
- package/dist/core/effective-constraints.js.map +1 -1
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +1 -8
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/dashboard/stats.d.ts.map +1 -1
- package/dist/dashboard/stats.js.map +1 -1
- package/dist/dashboard/types.d.ts +2 -2
- package/dist/dashboard/types.d.ts.map +1 -1
- package/dist/failure/constraint-handler.d.ts.map +1 -1
- package/dist/failure/constraint-handler.js +0 -2
- package/dist/failure/constraint-handler.js.map +1 -1
- package/dist/gates/acceptance.d.ts +9 -1
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +21 -0
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/checker-gate.d.ts +23 -0
- package/dist/gates/checker-gate.d.ts.map +1 -0
- package/dist/gates/checker-gate.js +53 -0
- package/dist/gates/checker-gate.js.map +1 -0
- package/dist/gates/command.d.ts +9 -2
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +10 -0
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/contract.d.ts +8 -2
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +9 -0
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/decision.d.ts +17 -0
- package/dist/gates/decision.d.ts.map +1 -0
- package/dist/gates/decision.js +25 -0
- package/dist/gates/decision.js.map +1 -0
- package/dist/gates/definitions.d.ts +63 -0
- package/dist/gates/definitions.d.ts.map +1 -0
- package/dist/gates/definitions.js +160 -0
- package/dist/gates/definitions.js.map +1 -0
- package/dist/gates/effective-gates.d.ts +30 -0
- package/dist/gates/effective-gates.d.ts.map +1 -0
- package/dist/gates/effective-gates.js +85 -0
- package/dist/gates/effective-gates.js.map +1 -0
- package/dist/gates/index.d.ts +25 -1
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js +37 -1
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/performance.d.ts +8 -2
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +9 -0
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/registry.d.ts +32 -0
- package/dist/gates/registry.d.ts.map +1 -0
- package/dist/gates/registry.js +90 -0
- package/dist/gates/registry.js.map +1 -0
- package/dist/gates/review.d.ts +8 -2
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +9 -0
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/runner.d.ts +30 -0
- package/dist/gates/runner.d.ts.map +1 -0
- package/dist/gates/runner.js +38 -0
- package/dist/gates/runner.js.map +1 -0
- package/dist/gates/security.d.ts +8 -2
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +9 -0
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +41 -1
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +0 -2
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/hooks/config.d.ts +26 -0
- package/dist/hooks/config.d.ts.map +1 -0
- package/dist/hooks/config.js +30 -0
- package/dist/hooks/config.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/registry.d.ts +18 -1
- package/dist/hooks/registry.d.ts.map +1 -1
- package/dist/hooks/registry.js +45 -0
- package/dist/hooks/registry.js.map +1 -1
- package/dist/hooks/types.d.ts +20 -0
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -20
- package/dist/index.js.map +1 -1
- package/dist/knowledge/import.d.ts +2 -2
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lifecycle-hooks.d.ts +2 -2
- package/dist/knowledge/lifecycle-hooks.d.ts.map +1 -1
- package/dist/knowledge/types.d.ts +5 -7
- package/dist/knowledge/types.d.ts.map +1 -1
- package/dist/knowledge/types.js +1 -1
- package/dist/knowledge/types.js.map +1 -1
- package/dist/monitoring/constraint-doctor.d.ts +4 -22
- package/dist/monitoring/constraint-doctor.d.ts.map +1 -1
- package/dist/monitoring/constraint-doctor.js +7 -94
- package/dist/monitoring/constraint-doctor.js.map +1 -1
- package/dist/presets/standard.d.ts +1 -1
- package/dist/presets/standard.d.ts.map +1 -1
- package/dist/presets/standard.js +1 -2
- package/dist/presets/standard.js.map +1 -1
- package/dist/spec/annotation-checker.d.ts.map +1 -1
- package/dist/spec/annotation-checker.js +6 -26
- package/dist/spec/annotation-checker.js.map +1 -1
- package/dist/tools/index.d.ts +0 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/types/constraint.d.ts +1 -12
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js +0 -3
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/project-config.d.ts +0 -2
- package/dist/types/project-config.d.ts.map +1 -1
- package/dist/utils/file-walk.d.ts +2 -2
- package/dist/utils/file-walk.js +2 -2
- package/package.json +6 -1
- package/src/CONTEXT.md +14 -0
- package/src/__tests__/checker-extra.test.ts +2 -59
- package/src/__tests__/constraint-doctor.test.ts +1 -140
- package/src/__tests__/constraint-handler.test.ts +0 -4
- package/src/__tests__/project-config-loader-extra.test.ts +0 -20
- package/src/__tests__/project-config-loader.test.ts +0 -1
- package/src/cli/commands/CONTEXT.md +15 -7
- package/src/cli/commands/__tests__/check-drift.test.ts +0 -3
- package/src/cli/commands/__tests__/check-skip-output.test.ts +0 -5
- package/src/cli/commands/__tests__/check.test.ts +7 -75
- package/src/cli/commands/__tests__/registry.test.ts +201 -0
- package/src/cli/commands/check.ts +2 -14
- package/src/cli/commands/definitions.ts +593 -0
- package/src/cli/commands/knowledge.ts +3 -3
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +4 -110
- package/src/cli/commands/sync-docs/index.ts +8 -5
- package/src/context/CONTEXT.md +2 -7
- package/src/context/__tests__/session-manager.test.ts +0 -91
- package/src/context/index.ts +1 -5
- package/src/context/knowledge-injector.ts +3 -3
- package/src/context/session-manager.ts +0 -74
- package/src/context/types.ts +2 -63
- package/src/core/constraints/__tests__/interceptor.test.ts +0 -2
- package/src/core/constraints/agent-prompt-renderer.ts +1 -1
- package/src/core/constraints/capabilities-parser.ts +95 -2
- package/src/core/constraints/checker.ts +8 -53
- package/src/core/constraints/definitions.ts +0 -8
- package/src/core/constraints/doc-freshness/runner.ts +1 -2
- package/src/core/constraints/index.ts +1 -2
- package/src/core/constraints/interceptor.ts +1 -6
- package/src/core/effective-constraints.ts +0 -1
- package/src/core/project-config-loader.ts +1 -7
- package/src/dashboard/stats.ts +2 -2
- package/src/dashboard/types.ts +2 -2
- package/src/failure/constraint-handler.ts +0 -2
- package/src/gates/CONTEXT.md +16 -13
- package/src/gates/__tests__/checker-gate.test.ts +45 -0
- package/src/gates/__tests__/contract.test.ts +73 -0
- package/src/gates/__tests__/effective-gates.test.ts +82 -0
- package/src/gates/__tests__/gate-interface.test.ts +202 -0
- package/src/gates/__tests__/registry.test.ts +87 -0
- package/src/gates/__tests__/runner.test.ts +81 -0
- package/src/gates/acceptance.ts +24 -1
- package/src/gates/checker-gate.ts +54 -0
- package/src/gates/command.ts +13 -2
- package/src/gates/contract.ts +12 -2
- package/src/gates/decision.ts +27 -0
- package/src/gates/definitions.ts +207 -0
- package/src/gates/effective-gates.ts +106 -0
- package/src/gates/index.ts +38 -0
- package/src/gates/performance.ts +12 -2
- package/src/gates/registry.ts +107 -0
- package/src/gates/review.ts +12 -2
- package/src/gates/runner.ts +57 -0
- package/src/gates/security.ts +12 -2
- package/src/gates/types.ts +48 -1
- package/src/hooks/CONTEXT.md +12 -2
- package/src/hooks/__tests__/bootstrap.test.ts +0 -1
- package/src/hooks/__tests__/config.test.ts +19 -0
- package/src/hooks/__tests__/pipeline.test.ts +79 -0
- package/src/hooks/__tests__/registry.test.ts +67 -0
- package/src/hooks/bootstrap.ts +0 -2
- package/src/hooks/config.ts +29 -0
- package/src/hooks/index.ts +2 -1
- package/src/hooks/registry.ts +60 -1
- package/src/hooks/types.ts +21 -0
- package/src/index.ts +5 -22
- package/src/knowledge/import.ts +3 -3
- package/src/knowledge/ingest.ts +4 -4
- package/src/knowledge/lifecycle-hooks.ts +3 -3
- package/src/knowledge/types.ts +5 -8
- package/src/monitoring/constraint-doctor.ts +7 -106
- package/src/presets/__tests__/standard.test.ts +0 -2
- package/src/presets/standard.ts +1 -2
- package/src/spec/__tests__/annotation-checker.test.ts +9 -3
- package/src/spec/annotation-checker.ts +7 -29
- package/src/tools/CONTEXT.md +7 -14
- package/src/tools/index.ts +0 -4
- package/src/types/constraint.ts +1 -14
- package/src/types/project-config.ts +0 -3
- package/src/utils/file-walk.ts +2 -2
- package/dist/architecture/constraint-engine.d.ts +0 -67
- package/dist/architecture/constraint-engine.d.ts.map +0 -1
- package/dist/architecture/constraint-engine.js +0 -295
- package/dist/architecture/constraint-engine.js.map +0 -1
- package/dist/architecture/cross-project-checker.d.ts +0 -54
- package/dist/architecture/cross-project-checker.d.ts.map +0 -1
- package/dist/architecture/cross-project-checker.js +0 -467
- package/dist/architecture/cross-project-checker.js.map +0 -1
- package/dist/cli/commands/index.d.ts +0 -30
- package/dist/cli/commands/index.d.ts.map +0 -1
- package/dist/cli/commands/index.js +0 -91
- package/dist/cli/commands/index.js.map +0 -1
- package/dist/context/file-budget.d.ts +0 -40
- package/dist/context/file-budget.d.ts.map +0 -1
- package/dist/context/file-budget.js +0 -147
- package/dist/context/file-budget.js.map +0 -1
- package/dist/context/progressive-loader.d.ts +0 -109
- package/dist/context/progressive-loader.d.ts.map +0 -1
- package/dist/context/progressive-loader.js +0 -166
- package/dist/context/progressive-loader.js.map +0 -1
- package/dist/context/token-pipeline.d.ts +0 -55
- package/dist/context/token-pipeline.d.ts.map +0 -1
- package/dist/context/token-pipeline.js +0 -220
- package/dist/context/token-pipeline.js.map +0 -1
- package/dist/context/tool-output-budget.d.ts +0 -59
- package/dist/context/tool-output-budget.d.ts.map +0 -1
- package/dist/context/tool-output-budget.js +0 -177
- package/dist/context/tool-output-budget.js.map +0 -1
- package/dist/core/constraints/default-executors.d.ts +0 -10
- package/dist/core/constraints/default-executors.d.ts.map +0 -1
- package/dist/core/constraints/default-executors.js +0 -120
- package/dist/core/constraints/default-executors.js.map +0 -1
- package/dist/llm/adapter.d.ts +0 -36
- package/dist/llm/adapter.d.ts.map +0 -1
- package/dist/llm/adapter.js +0 -118
- package/dist/llm/adapter.js.map +0 -1
- package/dist/llm/index.d.ts +0 -3
- package/dist/llm/index.d.ts.map +0 -1
- package/dist/llm/index.js +0 -19
- package/dist/llm/index.js.map +0 -1
- package/dist/llm/types.d.ts +0 -62
- package/dist/llm/types.d.ts.map +0 -1
- package/dist/llm/types.js +0 -8
- package/dist/llm/types.js.map +0 -1
- package/dist/tools/core/index.d.ts +0 -13
- package/dist/tools/core/index.d.ts.map +0 -1
- package/dist/tools/core/index.js +0 -198
- package/dist/tools/core/index.js.map +0 -1
- package/dist/tools/loader.d.ts +0 -21
- package/dist/tools/loader.d.ts.map +0 -1
- package/dist/tools/loader.js +0 -199
- package/dist/tools/loader.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -59
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/registry.js +0 -115
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/types.d.ts +0 -38
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/types.js +0 -6
- package/dist/tools/types.js.map +0 -1
- package/src/__tests__/architecture-engine.test.ts +0 -619
- package/src/__tests__/context/progressive-loader.test.ts +0 -131
- package/src/__tests__/cross-project-checker.test.ts +0 -318
- package/src/architecture/CONTEXT.md +0 -22
- package/src/architecture/constraint-engine.ts +0 -351
- package/src/architecture/cross-project-checker.ts +0 -545
- package/src/cli/commands/index.ts +0 -30
- package/src/context/__tests__/file-budget.test.ts +0 -142
- package/src/context/__tests__/progressive-loader.test.ts +0 -264
- package/src/context/__tests__/token-pipeline.test.ts +0 -178
- package/src/context/__tests__/tool-output-budget.test.ts +0 -95
- package/src/context/file-budget.ts +0 -142
- package/src/context/progressive-loader.ts +0 -260
- package/src/context/token-pipeline.ts +0 -265
- package/src/context/tool-output-budget.ts +0 -178
- package/src/core/constraints/__tests__/default-executors.test.ts +0 -57
- package/src/core/constraints/default-executors.ts +0 -92
- package/src/llm/CONTEXT.md +0 -21
- package/src/llm/__tests__/adapter.test.ts +0 -172
- package/src/llm/adapter.ts +0 -149
- package/src/llm/index.ts +0 -2
- package/src/llm/types.ts +0 -81
- package/src/tools/__tests__/loader.test.ts +0 -252
- package/src/tools/__tests__/registry.test.ts +0 -157
- package/src/tools/core/__tests__/core.test.ts +0 -122
- package/src/tools/core/index.ts +0 -201
- package/src/tools/loader.ts +0 -216
- package/src/tools/registry.ts +0 -128
- package/src/tools/types.ts +0 -46
package/dist/tools/loader.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.parseToolYaml = parseToolYaml;
|
|
37
|
-
exports.loadToolsFromDir = loadToolsFromDir;
|
|
38
|
-
exports.loadRegistry = loadRegistry;
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const yaml = __importStar(require("js-yaml"));
|
|
42
|
-
// Maps the type strings found in tool YAMLs to JSON Schema types
|
|
43
|
-
const TYPE_MAP = {
|
|
44
|
-
string: 'string',
|
|
45
|
-
path: 'string',
|
|
46
|
-
integer: 'integer',
|
|
47
|
-
number: 'number',
|
|
48
|
-
boolean: 'boolean',
|
|
49
|
-
array: 'array',
|
|
50
|
-
object: 'object',
|
|
51
|
-
};
|
|
52
|
-
function buildJsonSchema(params) {
|
|
53
|
-
const properties = {};
|
|
54
|
-
const required = [];
|
|
55
|
-
for (const [key, def] of Object.entries(params)) {
|
|
56
|
-
const prop = {};
|
|
57
|
-
const schemaType = TYPE_MAP[def.type ?? 'string'] ?? 'string';
|
|
58
|
-
prop.type = schemaType;
|
|
59
|
-
if (def.description)
|
|
60
|
-
prop.description = def.description;
|
|
61
|
-
if (def.default !== undefined)
|
|
62
|
-
prop.default = def.default;
|
|
63
|
-
if (def.items)
|
|
64
|
-
prop.items = def.items;
|
|
65
|
-
if (def.enum)
|
|
66
|
-
prop.enum = def.enum;
|
|
67
|
-
properties[key] = prop;
|
|
68
|
-
if (def.required)
|
|
69
|
-
required.push(key);
|
|
70
|
-
}
|
|
71
|
-
const schema = {
|
|
72
|
-
type: 'object',
|
|
73
|
-
properties,
|
|
74
|
-
};
|
|
75
|
-
if (required.length > 0)
|
|
76
|
-
schema.required = required;
|
|
77
|
-
return schema;
|
|
78
|
-
}
|
|
79
|
-
function normalizeInputs(raw) {
|
|
80
|
-
// Pattern A: `input` is a map (core/ext tools)
|
|
81
|
-
if (raw.input && typeof raw.input === 'object' && !Array.isArray(raw.input)) {
|
|
82
|
-
return raw.input;
|
|
83
|
-
}
|
|
84
|
-
// Pattern B: `inputs` is a list (some std tools)
|
|
85
|
-
if (Array.isArray(raw.inputs)) {
|
|
86
|
-
const result = {};
|
|
87
|
-
for (const item of raw.inputs) {
|
|
88
|
-
if (item.name) {
|
|
89
|
-
result[item.name] = {
|
|
90
|
-
type: item.type,
|
|
91
|
-
required: item.required,
|
|
92
|
-
description: item.description,
|
|
93
|
-
default: item.default,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
// Pattern C: `inputs` is a map (some std tools)
|
|
100
|
-
if (raw.inputs && typeof raw.inputs === 'object' && !Array.isArray(raw.inputs)) {
|
|
101
|
-
return raw.inputs;
|
|
102
|
-
}
|
|
103
|
-
return {};
|
|
104
|
-
}
|
|
105
|
-
function deriveToolId(filePath, definitionsDir) {
|
|
106
|
-
// Convert file path to ID: definitions/std/quick/implement.yml → std/quick/implement
|
|
107
|
-
const relative = path.relative(definitionsDir, filePath);
|
|
108
|
-
const withoutExt = relative.replace(/\.yml$/, '').replace(/\.yaml$/, '');
|
|
109
|
-
return withoutExt;
|
|
110
|
-
}
|
|
111
|
-
function detectCategory(filePath, definitionsDir) {
|
|
112
|
-
const relative = path.relative(definitionsDir, filePath);
|
|
113
|
-
const topDir = relative.split(path.sep)[0];
|
|
114
|
-
if (topDir === 'core')
|
|
115
|
-
return 'core';
|
|
116
|
-
if (topDir === 'ext')
|
|
117
|
-
return 'ext';
|
|
118
|
-
return 'std';
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Parse a single YAML file into a ToolDefinition.
|
|
122
|
-
*/
|
|
123
|
-
function parseToolYaml(yamlContent, filePath, definitionsDir) {
|
|
124
|
-
const raw = yaml.load(yamlContent);
|
|
125
|
-
const id = raw.id || deriveToolId(filePath, definitionsDir);
|
|
126
|
-
const name = raw.name || id;
|
|
127
|
-
const description = raw.description || '';
|
|
128
|
-
const category = detectCategory(filePath, definitionsDir);
|
|
129
|
-
const params = normalizeInputs(raw);
|
|
130
|
-
const parameters = buildJsonSchema(params);
|
|
131
|
-
const def = {
|
|
132
|
-
id,
|
|
133
|
-
name,
|
|
134
|
-
description,
|
|
135
|
-
category,
|
|
136
|
-
parameters,
|
|
137
|
-
};
|
|
138
|
-
return def;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Scan a directory recursively for .yml/.yaml files and return all file paths.
|
|
142
|
-
*/
|
|
143
|
-
function findYamlFiles(dir) {
|
|
144
|
-
const results = [];
|
|
145
|
-
if (!fs.existsSync(dir))
|
|
146
|
-
return results;
|
|
147
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
148
|
-
for (const entry of entries) {
|
|
149
|
-
const fullPath = path.join(dir, entry.name);
|
|
150
|
-
if (entry.isDirectory()) {
|
|
151
|
-
results.push(...findYamlFiles(fullPath));
|
|
152
|
-
}
|
|
153
|
-
else if (entry.isFile() && (entry.name.endsWith('.yml') || entry.name.endsWith('.yaml'))) {
|
|
154
|
-
results.push(fullPath);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return results;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Load all tool definitions from the definitions directory (core/, std/, ext/).
|
|
161
|
-
*/
|
|
162
|
-
function loadToolsFromDir(definitionsDir) {
|
|
163
|
-
const tools = [];
|
|
164
|
-
for (const category of ['core', 'std', 'ext']) {
|
|
165
|
-
const categoryDir = path.join(definitionsDir, category);
|
|
166
|
-
const yamlFiles = findYamlFiles(categoryDir);
|
|
167
|
-
for (const filePath of yamlFiles) {
|
|
168
|
-
try {
|
|
169
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
170
|
-
const tool = parseToolYaml(content, filePath, definitionsDir);
|
|
171
|
-
tools.push(tool);
|
|
172
|
-
}
|
|
173
|
-
catch (err) {
|
|
174
|
-
// Skip files that fail to parse
|
|
175
|
-
console.warn(`[harness] Failed to load tool YAML: ${filePath}`, err);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return tools;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Load the registry.json and fix absolute paths to relative (from definitions dir).
|
|
183
|
-
* Filters out workflow entries, keeping only tool entries.
|
|
184
|
-
*/
|
|
185
|
-
function loadRegistry(registryPath) {
|
|
186
|
-
const content = fs.readFileSync(registryPath, 'utf-8');
|
|
187
|
-
const registry = JSON.parse(content);
|
|
188
|
-
const definitionsDir = path.dirname(registryPath);
|
|
189
|
-
if (!Array.isArray(registry.tools))
|
|
190
|
-
return [];
|
|
191
|
-
return registry.tools
|
|
192
|
-
.filter((entry) => entry.type === 'tool')
|
|
193
|
-
.map((entry) => ({
|
|
194
|
-
...entry,
|
|
195
|
-
// Fix absolute paths to relative (from definitions dir); keep already-relative paths as-is
|
|
196
|
-
path: path.isAbsolute(entry.path) ? path.relative(definitionsDir, entry.path) : entry.path,
|
|
197
|
-
}));
|
|
198
|
-
}
|
|
199
|
-
//# sourceMappingURL=loader.js.map
|
package/dist/tools/loader.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/tools/loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8HA,sCAmBC;AAwBD,4CAoBC;AAMD,oCAoBC;AAvND,uCAAyB;AACzB,2CAA6B;AAC7B,8CAAgC;AAGhC,iEAAiE;AACjE,MAAM,QAAQ,GAA2B;IACvC,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACjB,CAAC;AAwCF,SAAS,eAAe,CAAC,MAAyI;IAChK,MAAM,UAAU,GAA4B,EAAE,CAAC;IAC/C,MAAM,Q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Y,CAAC,YAAoB;IAO/C,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAElD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE9C,OAAO,QAAQ,CAAC,KAAK;SAClB,MAAM,CAAC,CAAC,KAAwB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;SAC3D,GAAG,CAAC,CAAC,KAA0F,EAAE,EAAE,CAAC,CAAC;QACpG,GAAG,KAAK;QACR,2FAA2F;QAC3F,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;KAC3F,CAAC,CAAC,CAAC;AACR,CAAC"}
|
package/dist/tools/registry.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 工具注册表
|
|
3
|
-
*
|
|
4
|
-
* 工具注册/发现/执行
|
|
5
|
-
*/
|
|
6
|
-
import type { ToolDefinition, ToolCategory, ToolResult } from './types';
|
|
7
|
-
export declare class ToolRegistry {
|
|
8
|
-
private tools;
|
|
9
|
-
constructor();
|
|
10
|
-
/**
|
|
11
|
-
* 注册工具
|
|
12
|
-
*/
|
|
13
|
-
register(tool: ToolDefinition): void;
|
|
14
|
-
/**
|
|
15
|
-
* 批量注册
|
|
16
|
-
*/
|
|
17
|
-
registerAll(tools: ToolDefinition[]): void;
|
|
18
|
-
/**
|
|
19
|
-
* 获取工具
|
|
20
|
-
*/
|
|
21
|
-
get(id: string): ToolDefinition | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* 获取所有工具
|
|
24
|
-
*/
|
|
25
|
-
getAll(): ToolDefinition[];
|
|
26
|
-
/**
|
|
27
|
-
* 按分类获取
|
|
28
|
-
*/
|
|
29
|
-
getByCategory(category: ToolCategory): ToolDefinition[];
|
|
30
|
-
/**
|
|
31
|
-
* 搜索工具(名称/描述模糊匹配)
|
|
32
|
-
*/
|
|
33
|
-
search(query: string): ToolDefinition[];
|
|
34
|
-
/**
|
|
35
|
-
* 执行工具
|
|
36
|
-
*/
|
|
37
|
-
execute(id: string, params: Record<string, unknown>): Promise<ToolResult>;
|
|
38
|
-
/**
|
|
39
|
-
* 移除工具
|
|
40
|
-
*/
|
|
41
|
-
remove(id: string): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* 工具数量
|
|
44
|
-
*/
|
|
45
|
-
size(): number;
|
|
46
|
-
/**
|
|
47
|
-
* 检查工具是否存在
|
|
48
|
-
*/
|
|
49
|
-
has(id: string): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* 导出为 tool definitions(用于 LLM function calling)
|
|
52
|
-
*/
|
|
53
|
-
toToolDefinitions(): Array<{
|
|
54
|
-
name: string;
|
|
55
|
-
description: string;
|
|
56
|
-
parameters: Record<string, unknown>;
|
|
57
|
-
}>;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAExE,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAA8B;;IAM3C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAIpC;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI;IAM1C;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI3C;;OAEG;IACH,MAAM,IAAI,cAAc,EAAE;IAI1B;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG,cAAc,EAAE;IAIvD;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE;IASvC;;OAEG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IA6B/E;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI3B;;OAEG;IACH,IAAI,IAAI,MAAM;IAId;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIxB;;OAEG;IACH,iBAAiB,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CAOvG"}
|
package/dist/tools/registry.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* 工具注册表
|
|
4
|
-
*
|
|
5
|
-
* 工具注册/发现/执行
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.ToolRegistry = void 0;
|
|
9
|
-
class ToolRegistry {
|
|
10
|
-
tools;
|
|
11
|
-
constructor() {
|
|
12
|
-
this.tools = new Map();
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* 注册工具
|
|
16
|
-
*/
|
|
17
|
-
register(tool) {
|
|
18
|
-
this.tools.set(tool.id, tool);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 批量注册
|
|
22
|
-
*/
|
|
23
|
-
registerAll(tools) {
|
|
24
|
-
for (const tool of tools) {
|
|
25
|
-
this.register(tool);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 获取工具
|
|
30
|
-
*/
|
|
31
|
-
get(id) {
|
|
32
|
-
return this.tools.get(id);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 获取所有工具
|
|
36
|
-
*/
|
|
37
|
-
getAll() {
|
|
38
|
-
return Array.from(this.tools.values());
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* 按分类获取
|
|
42
|
-
*/
|
|
43
|
-
getByCategory(category) {
|
|
44
|
-
return this.getAll().filter(t => t.category === category);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* 搜索工具(名称/描述模糊匹配)
|
|
48
|
-
*/
|
|
49
|
-
search(query) {
|
|
50
|
-
const lower = query.toLowerCase();
|
|
51
|
-
return this.getAll().filter(t => t.name.toLowerCase().includes(lower) ||
|
|
52
|
-
t.description.toLowerCase().includes(lower) ||
|
|
53
|
-
t.id.toLowerCase().includes(lower));
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* 执行工具
|
|
57
|
-
*/
|
|
58
|
-
async execute(id, params) {
|
|
59
|
-
const tool = this.tools.get(id);
|
|
60
|
-
if (!tool) {
|
|
61
|
-
return {
|
|
62
|
-
success: false,
|
|
63
|
-
output: '',
|
|
64
|
-
error: `工具未找到: ${id}`,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
if (!tool.handler) {
|
|
68
|
-
return {
|
|
69
|
-
success: false,
|
|
70
|
-
output: '',
|
|
71
|
-
error: `工具 ${id} 未注册处理函数`,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
return await tool.handler(params);
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
return {
|
|
79
|
-
success: false,
|
|
80
|
-
output: '',
|
|
81
|
-
error: `工具执行失败: ${error instanceof Error ? error.message : String(error)}`,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* 移除工具
|
|
87
|
-
*/
|
|
88
|
-
remove(id) {
|
|
89
|
-
return this.tools.delete(id);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* 工具数量
|
|
93
|
-
*/
|
|
94
|
-
size() {
|
|
95
|
-
return this.tools.size;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* 检查工具是否存在
|
|
99
|
-
*/
|
|
100
|
-
has(id) {
|
|
101
|
-
return this.tools.has(id);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 导出为 tool definitions(用于 LLM function calling)
|
|
105
|
-
*/
|
|
106
|
-
toToolDefinitions() {
|
|
107
|
-
return this.getAll().map(t => ({
|
|
108
|
-
name: t.id,
|
|
109
|
-
description: t.description,
|
|
110
|
-
parameters: t.parameters,
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
exports.ToolRegistry = ToolRegistry;
|
|
115
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH,MAAa,YAAY;IACf,KAAK,CAA8B;IAE3C;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,IAAoB;QAC3B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,KAAuB;QACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC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EAAE,EAAE;gBACV,KAAK,EAAE,MAAM,EAAE,UAAU;aAC1B,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,EAAE;gBACV,KAAK,EAAE,WAAW,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aAC3E,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC7B,IAAI,EAAE,CAAC,CAAC,EAAE;YACV,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,UAAU,EAAE,CAAC,CAAC,UAAU;SACzB,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAvHD,oCAuHC"}
|
package/dist/tools/types.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 工具注册表类型定义
|
|
3
|
-
*/
|
|
4
|
-
export type ToolCategory = 'core' | 'std' | 'ext';
|
|
5
|
-
export interface ToolDefinition {
|
|
6
|
-
/** 工具唯一 ID */
|
|
7
|
-
id: string;
|
|
8
|
-
/** 工具名称 */
|
|
9
|
-
name: string;
|
|
10
|
-
/** 工具描述 */
|
|
11
|
-
description: string;
|
|
12
|
-
/** 工具分类 */
|
|
13
|
-
category: ToolCategory;
|
|
14
|
-
/** 参数 schema (JSON Schema) */
|
|
15
|
-
parameters: Record<string, unknown>;
|
|
16
|
-
/** 所需 sandbox 级别 */
|
|
17
|
-
sandboxLevel?: 1 | 2 | 3 | 4;
|
|
18
|
-
/** 是否需要确认 */
|
|
19
|
-
requiresConfirmation?: boolean;
|
|
20
|
-
/** 速率限制(每分钟) */
|
|
21
|
-
rateLimit?: number;
|
|
22
|
-
/** 工具处理函数 */
|
|
23
|
-
handler?: ToolHandler;
|
|
24
|
-
}
|
|
25
|
-
export type ToolHandler = (params: Record<string, unknown>) => Promise<ToolResult>;
|
|
26
|
-
export interface ToolResult {
|
|
27
|
-
success: boolean;
|
|
28
|
-
output: string;
|
|
29
|
-
error?: string;
|
|
30
|
-
metadata?: Record<string, unknown>;
|
|
31
|
-
}
|
|
32
|
-
export interface ToolRegistryConfig {
|
|
33
|
-
/** 自动注册核心工具 */
|
|
34
|
-
autoRegisterCore?: boolean;
|
|
35
|
-
/** 工具搜索路径 */
|
|
36
|
-
searchPaths?: string[];
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,WAAW;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW;IACX,QAAQ,EAAE,YAAY,CAAC;IACvB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,oBAAoB;IACpB,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,aAAa;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa;IACb,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAEnF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAID,MAAM,WAAW,kBAAkB;IACjC,eAAe;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
|
package/dist/tools/types.js
DELETED
package/dist/tools/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|