@xoxoai/checkmate 0.6.6 → 0.7.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/checkmate.js +13375 -0
- package/package.json +14 -100
- package/plugin/.claude-plugin/plugin.json +10 -0
- package/plugin/bin/checkmate.ts +3 -0
- package/plugin/contracts/finding.schema.json +78 -0
- package/plugin/contracts/gap.schema.json +56 -0
- package/plugin/contracts/plan-candidate.schema.json +103 -0
- package/plugin/contracts/plan-delta.schema.json +63 -0
- package/plugin/contracts/plan-patch.schema.json +116 -0
- package/plugin/contracts/plan-request.schema.json +108 -0
- package/plugin/contracts/plan.schema.json +313 -0
- package/plugin/contracts/profile.schema.json +154 -0
- package/plugin/contracts/response.schema.json +25 -0
- package/plugin/contracts/result.schema.json +410 -0
- package/plugin/dist/checkmate.js +13012 -0
- package/plugin/package.json +4 -0
- package/plugin/references/browser.md +35 -0
- package/plugin/references/http.md +30 -0
- package/plugin/references/workflow.md +122 -0
- package/plugin/skills/execute/SKILL.md +92 -0
- package/plugin/skills/plan/SKILL.md +94 -0
- package/plugin/skills/report/SKILL.md +28 -0
- package/plugin/skills/revise/SKILL.md +43 -0
- package/plugin/skills/setup/SKILL.md +82 -0
- package/plugin/skills/status/SKILL.md +20 -0
- package/plugin/skills/ui/SKILL.md +26 -0
- package/plugin/src/actor.ts +21 -0
- package/plugin/src/cli.ts +1133 -0
- package/plugin/src/contracts.ts +342 -0
- package/plugin/src/index.ts +52 -0
- package/plugin/src/plans.ts +1028 -0
- package/plugin/src/render.ts +544 -0
- package/plugin/src/runs.ts +868 -0
- package/plugin/src/store.ts +384 -0
- package/plugin/src/targets.ts +205 -0
- package/plugin/src/types.ts +319 -0
- package/plugin/src/ui/assets/client.js +501 -0
- package/plugin/src/ui/assets/favicon.svg +1 -0
- package/plugin/src/ui/assets/fonts/inter-OFL.txt +93 -0
- package/plugin/src/ui/assets/fonts/inter.woff2 +0 -0
- package/plugin/src/ui/assets/fonts/jetbrains-mono-OFL.txt +93 -0
- package/plugin/src/ui/assets/fonts/jetbrains-mono.woff2 +0 -0
- package/plugin/src/ui/assets/fonts/space-grotesk-OFL.txt +93 -0
- package/plugin/src/ui/assets/fonts/space-grotesk.woff2 +0 -0
- package/plugin/src/ui/assets/style.css +1926 -0
- package/plugin/src/ui/edit.ts +305 -0
- package/plugin/src/ui/forms.ts +209 -0
- package/plugin/src/ui/html.ts +130 -0
- package/plugin/src/ui/layout.ts +198 -0
- package/plugin/src/ui/lists.ts +645 -0
- package/plugin/src/ui/plan.ts +577 -0
- package/plugin/src/ui/run.ts +489 -0
- package/plugin/src/ui/server.ts +684 -0
- package/plugin/src/validators.d.ts +13 -0
- package/plugin/src/validators.js +1 -0
- package/plugin/src/views.ts +839 -0
- package/LICENSE +0 -21
- package/README.md +0 -294
- package/bin/checkmate.js +0 -13
- package/dist/ai/client.d.ts +0 -64
- package/dist/ai/client.d.ts.map +0 -1
- package/dist/ai/client.js +0 -313
- package/dist/ai/client.js.map +0 -1
- package/dist/ai/message-handler.d.ts +0 -9
- package/dist/ai/message-handler.d.ts.map +0 -1
- package/dist/ai/message-handler.js +0 -50
- package/dist/ai/message-handler.js.map +0 -1
- package/dist/ai/message-history.d.ts +0 -17
- package/dist/ai/message-history.d.ts.map +0 -1
- package/dist/ai/message-history.js +0 -45
- package/dist/ai/message-history.js.map +0 -1
- package/dist/ai/prompts.d.ts +0 -4
- package/dist/ai/prompts.d.ts.map +0 -1
- package/dist/ai/prompts.js +0 -24
- package/dist/ai/prompts.js.map +0 -1
- package/dist/ai/rate-limit-policy.d.ts +0 -9
- package/dist/ai/rate-limit-policy.d.ts.map +0 -1
- package/dist/ai/rate-limit-policy.js +0 -34
- package/dist/ai/rate-limit-policy.js.map +0 -1
- package/dist/ai/tool-response-handler.d.ts +0 -16
- package/dist/ai/tool-response-handler.d.ts.map +0 -1
- package/dist/ai/tool-response-handler.js +0 -85
- package/dist/ai/tool-response-handler.js.map +0 -1
- package/dist/ai/turn-processor.d.ts +0 -34
- package/dist/ai/turn-processor.d.ts.map +0 -1
- package/dist/ai/turn-processor.js +0 -107
- package/dist/ai/turn-processor.js.map +0 -1
- package/dist/api/allocate-run-identity.d.ts +0 -8
- package/dist/api/allocate-run-identity.d.ts.map +0 -1
- package/dist/api/allocate-run-identity.js +0 -10
- package/dist/api/allocate-run-identity.js.map +0 -1
- package/dist/api/execute-prepared-run.d.ts +0 -22
- package/dist/api/execute-prepared-run.d.ts.map +0 -1
- package/dist/api/execute-prepared-run.js +0 -184
- package/dist/api/execute-prepared-run.js.map +0 -1
- package/dist/api/index.d.ts +0 -25
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -69
- package/dist/api/index.js.map +0 -1
- package/dist/api/prepare-run.d.ts +0 -44
- package/dist/api/prepare-run.d.ts.map +0 -1
- package/dist/api/prepare-run.js +0 -261
- package/dist/api/prepare-run.js.map +0 -1
- package/dist/cli/diagnostic-relay.d.ts +0 -6
- package/dist/cli/diagnostic-relay.d.ts.map +0 -1
- package/dist/cli/diagnostic-relay.js +0 -6
- package/dist/cli/diagnostic-relay.js.map +0 -1
- package/dist/cli/main.d.ts +0 -21
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js +0 -166
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/protocol.d.ts +0 -57
- package/dist/cli/protocol.d.ts.map +0 -1
- package/dist/cli/protocol.js +0 -116
- package/dist/cli/protocol.js.map +0 -1
- package/dist/cli/reconcile-result.d.ts +0 -13
- package/dist/cli/reconcile-result.d.ts.map +0 -1
- package/dist/cli/reconcile-result.js +0 -300
- package/dist/cli/reconcile-result.js.map +0 -1
- package/dist/cli/run-parent.d.ts +0 -37
- package/dist/cli/run-parent.d.ts.map +0 -1
- package/dist/cli/run-parent.js +0 -491
- package/dist/cli/run-parent.js.map +0 -1
- package/dist/cli/signals.d.ts +0 -36
- package/dist/cli/signals.d.ts.map +0 -1
- package/dist/cli/signals.js +0 -85
- package/dist/cli/signals.js.map +0 -1
- package/dist/cli/static-commands.d.ts +0 -11
- package/dist/cli/static-commands.d.ts.map +0 -1
- package/dist/cli/static-commands.js +0 -83
- package/dist/cli/static-commands.js.map +0 -1
- package/dist/cli/worker-stream-guard.d.ts +0 -20
- package/dist/cli/worker-stream-guard.d.ts.map +0 -1
- package/dist/cli/worker-stream-guard.js +0 -41
- package/dist/cli/worker-stream-guard.js.map +0 -1
- package/dist/cli/worker.d.ts +0 -3
- package/dist/cli/worker.d.ts.map +0 -1
- package/dist/cli/worker.js +0 -111
- package/dist/cli/worker.js.map +0 -1
- package/dist/config/ingestion.d.ts +0 -58
- package/dist/config/ingestion.d.ts.map +0 -1
- package/dist/config/ingestion.js +0 -283
- package/dist/config/ingestion.js.map +0 -1
- package/dist/config/manifest.d.ts +0 -20
- package/dist/config/manifest.d.ts.map +0 -1
- package/dist/config/manifest.js +0 -91
- package/dist/config/manifest.js.map +0 -1
- package/dist/config/model-egress.d.ts +0 -10
- package/dist/config/model-egress.d.ts.map +0 -1
- package/dist/config/model-egress.js +0 -62
- package/dist/config/model-egress.js.map +0 -1
- package/dist/config/package-resolution.d.ts +0 -4
- package/dist/config/package-resolution.d.ts.map +0 -1
- package/dist/config/package-resolution.js +0 -24
- package/dist/config/package-resolution.js.map +0 -1
- package/dist/config/policy.d.ts +0 -44
- package/dist/config/policy.d.ts.map +0 -1
- package/dist/config/policy.js +0 -141
- package/dist/config/policy.js.map +0 -1
- package/dist/config/record.d.ts +0 -4
- package/dist/config/record.d.ts.map +0 -1
- package/dist/config/record.js +0 -10
- package/dist/config/record.js.map +0 -1
- package/dist/config/secrets.d.ts +0 -11
- package/dist/config/secrets.d.ts.map +0 -1
- package/dist/config/secrets.js +0 -42
- package/dist/config/secrets.js.map +0 -1
- package/dist/contracts/diagnostics.d.ts +0 -4
- package/dist/contracts/diagnostics.d.ts.map +0 -1
- package/dist/contracts/diagnostics.js +0 -31
- package/dist/contracts/diagnostics.js.map +0 -1
- package/dist/contracts/serialize.d.ts +0 -2
- package/dist/contracts/serialize.d.ts.map +0 -1
- package/dist/contracts/serialize.js +0 -90
- package/dist/contracts/serialize.js.map +0 -1
- package/dist/contracts/types.d.ts +0 -316
- package/dist/contracts/types.d.ts.map +0 -1
- package/dist/contracts/types.js +0 -74
- package/dist/contracts/types.js.map +0 -1
- package/dist/contracts/validator.d.ts +0 -8
- package/dist/contracts/validator.d.ts.map +0 -1
- package/dist/contracts/validator.js +0 -71
- package/dist/contracts/validator.js.map +0 -1
- package/dist/driver.d.ts +0 -97
- package/dist/driver.d.ts.map +0 -1
- package/dist/driver.js +0 -24
- package/dist/driver.js.map +0 -1
- package/dist/drivers/descriptor.d.ts +0 -15
- package/dist/drivers/descriptor.d.ts.map +0 -1
- package/dist/drivers/descriptor.js +0 -122
- package/dist/drivers/descriptor.js.map +0 -1
- package/dist/drivers/loader.d.ts +0 -18
- package/dist/drivers/loader.d.ts.map +0 -1
- package/dist/drivers/loader.js +0 -97
- package/dist/drivers/loader.js.map +0 -1
- package/dist/drivers/web/checkmate-driver.json +0 -47
- package/dist/drivers/web/index.d.ts +0 -6
- package/dist/drivers/web/index.d.ts.map +0 -1
- package/dist/drivers/web/index.js +0 -27
- package/dist/drivers/web/index.js.map +0 -1
- package/dist/drivers/web/session.d.ts +0 -25
- package/dist/drivers/web/session.d.ts.map +0 -1
- package/dist/drivers/web/session.js +0 -132
- package/dist/drivers/web/session.js.map +0 -1
- package/dist/drivers/web/tools/network-request-recorder.d.ts +0 -46
- package/dist/drivers/web/tools/network-request-recorder.d.ts.map +0 -1
- package/dist/drivers/web/tools/network-request-recorder.js +0 -164
- package/dist/drivers/web/tools/network-request-recorder.js.map +0 -1
- package/dist/drivers/web/tools/screenshot-service.d.ts +0 -10
- package/dist/drivers/web/tools/screenshot-service.d.ts.map +0 -1
- package/dist/drivers/web/tools/screenshot-service.js +0 -23
- package/dist/drivers/web/tools/screenshot-service.js.map +0 -1
- package/dist/drivers/web/tools/snapshot-filter/index.d.ts +0 -4
- package/dist/drivers/web/tools/snapshot-filter/index.d.ts.map +0 -1
- package/dist/drivers/web/tools/snapshot-filter/index.js +0 -4
- package/dist/drivers/web/tools/snapshot-filter/index.js.map +0 -1
- package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.d.ts +0 -15
- package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.d.ts.map +0 -1
- package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.js +0 -99
- package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.js.map +0 -1
- package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.d.ts +0 -5
- package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.d.ts.map +0 -1
- package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.js +0 -56
- package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.js.map +0 -1
- package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.d.ts +0 -3
- package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.d.ts.map +0 -1
- package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.js +0 -85
- package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.js.map +0 -1
- package/dist/drivers/web/tools/snapshot-service.d.ts +0 -31
- package/dist/drivers/web/tools/snapshot-service.d.ts.map +0 -1
- package/dist/drivers/web/tools/snapshot-service.js +0 -96
- package/dist/drivers/web/tools/snapshot-service.js.map +0 -1
- package/dist/drivers/web/tools/tool.d.ts +0 -76
- package/dist/drivers/web/tools/tool.d.ts.map +0 -1
- package/dist/drivers/web/tools/tool.js +0 -562
- package/dist/drivers/web/tools/tool.js.map +0 -1
- package/dist/drivers/web/tools/transient-state-tracker.d.ts +0 -26
- package/dist/drivers/web/tools/transient-state-tracker.d.ts.map +0 -1
- package/dist/drivers/web/tools/transient-state-tracker.js +0 -301
- package/dist/drivers/web/tools/transient-state-tracker.js.map +0 -1
- package/dist/drivers/web/tools/types.d.ts +0 -11
- package/dist/drivers/web/tools/types.d.ts.map +0 -1
- package/dist/drivers/web/tools/types.js +0 -2
- package/dist/drivers/web/tools/types.js.map +0 -1
- package/dist/evidence/atomic-file.d.ts +0 -23
- package/dist/evidence/atomic-file.d.ts.map +0 -1
- package/dist/evidence/atomic-file.js +0 -104
- package/dist/evidence/atomic-file.js.map +0 -1
- package/dist/evidence/layout.d.ts +0 -30
- package/dist/evidence/layout.d.ts.map +0 -1
- package/dist/evidence/layout.js +0 -152
- package/dist/evidence/layout.js.map +0 -1
- package/dist/evidence/retention.d.ts +0 -5
- package/dist/evidence/retention.d.ts.map +0 -1
- package/dist/evidence/retention.js +0 -10
- package/dist/evidence/retention.js.map +0 -1
- package/dist/evidence/store.d.ts +0 -101
- package/dist/evidence/store.d.ts.map +0 -1
- package/dist/evidence/store.js +0 -375
- package/dist/evidence/store.js.map +0 -1
- package/dist/evidence/terminal-finalizer.d.ts +0 -19
- package/dist/evidence/terminal-finalizer.d.ts.map +0 -1
- package/dist/evidence/terminal-finalizer.js +0 -56
- package/dist/evidence/terminal-finalizer.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -12
- package/dist/index.js.map +0 -1
- package/dist/logging/invocation-logger.d.ts +0 -4
- package/dist/logging/invocation-logger.d.ts.map +0 -1
- package/dist/logging/invocation-logger.js +0 -25
- package/dist/logging/invocation-logger.js.map +0 -1
- package/dist/logging/level-logger.d.ts +0 -11
- package/dist/logging/level-logger.d.ts.map +0 -1
- package/dist/logging/level-logger.js +0 -82
- package/dist/logging/level-logger.js.map +0 -1
- package/dist/logging/types.d.ts +0 -8
- package/dist/logging/types.d.ts.map +0 -1
- package/dist/logging/types.js +0 -7
- package/dist/logging/types.js.map +0 -1
- package/dist/redaction/diagnostic-sanitizer.d.ts +0 -7
- package/dist/redaction/diagnostic-sanitizer.d.ts.map +0 -1
- package/dist/redaction/diagnostic-sanitizer.js +0 -42
- package/dist/redaction/diagnostic-sanitizer.js.map +0 -1
- package/dist/redaction/redactor.d.ts +0 -40
- package/dist/redaction/redactor.d.ts.map +0 -1
- package/dist/redaction/redactor.js +0 -176
- package/dist/redaction/redactor.js.map +0 -1
- package/dist/redaction/scrub.d.ts +0 -29
- package/dist/redaction/scrub.d.ts.map +0 -1
- package/dist/redaction/scrub.js +0 -54
- package/dist/redaction/scrub.js.map +0 -1
- package/dist/runtime/config.d.ts +0 -16
- package/dist/runtime/config.d.ts.map +0 -1
- package/dist/runtime/config.js +0 -2
- package/dist/runtime/config.js.map +0 -1
- package/dist/runtime/driver-boundary.d.ts +0 -16
- package/dist/runtime/driver-boundary.d.ts.map +0 -1
- package/dist/runtime/driver-boundary.js +0 -71
- package/dist/runtime/driver-boundary.js.map +0 -1
- package/dist/runtime/driver-session.d.ts +0 -9
- package/dist/runtime/driver-session.d.ts.map +0 -1
- package/dist/runtime/driver-session.js +0 -64
- package/dist/runtime/driver-session.js.map +0 -1
- package/dist/runtime/internal-step-evidence.d.ts +0 -30
- package/dist/runtime/internal-step-evidence.d.ts.map +0 -1
- package/dist/runtime/internal-step-evidence.js +0 -82
- package/dist/runtime/internal-step-evidence.js.map +0 -1
- package/dist/runtime/result-adapter.d.ts +0 -9
- package/dist/runtime/result-adapter.d.ts.map +0 -1
- package/dist/runtime/result-adapter.js +0 -77
- package/dist/runtime/result-adapter.js.map +0 -1
- package/dist/runtime/runner.d.ts +0 -43
- package/dist/runtime/runner.d.ts.map +0 -1
- package/dist/runtime/runner.js +0 -72
- package/dist/runtime/runner.js.map +0 -1
- package/dist/runtime/scenario-control.d.ts +0 -40
- package/dist/runtime/scenario-control.d.ts.map +0 -1
- package/dist/runtime/scenario-control.js +0 -94
- package/dist/runtime/scenario-control.js.map +0 -1
- package/dist/runtime/scenario-runner.d.ts +0 -41
- package/dist/runtime/scenario-runner.d.ts.map +0 -1
- package/dist/runtime/scenario-runner.js +0 -274
- package/dist/runtime/scenario-runner.js.map +0 -1
- package/dist/runtime/scenario-state.d.ts +0 -55
- package/dist/runtime/scenario-state.d.ts.map +0 -1
- package/dist/runtime/scenario-state.js +0 -128
- package/dist/runtime/scenario-state.js.map +0 -1
- package/dist/runtime/step-execution.d.ts +0 -27
- package/dist/runtime/step-execution.d.ts.map +0 -1
- package/dist/runtime/step-execution.js +0 -143
- package/dist/runtime/step-execution.js.map +0 -1
- package/dist/runtime/text.d.ts +0 -10
- package/dist/runtime/text.d.ts.map +0 -1
- package/dist/runtime/text.js +0 -25
- package/dist/runtime/text.js.map +0 -1
- package/dist/runtime/types.d.ts +0 -53
- package/dist/runtime/types.d.ts.map +0 -1
- package/dist/runtime/types.js +0 -2
- package/dist/runtime/types.js.map +0 -1
- package/dist/runtime/usage-tracker.d.ts +0 -37
- package/dist/runtime/usage-tracker.d.ts.map +0 -1
- package/dist/runtime/usage-tracker.js +0 -110
- package/dist/runtime/usage-tracker.js.map +0 -1
- package/dist/tools/define-agent-tool.d.ts +0 -20
- package/dist/tools/define-agent-tool.d.ts.map +0 -1
- package/dist/tools/define-agent-tool.js +0 -30
- package/dist/tools/define-agent-tool.js.map +0 -1
- package/dist/tools/dispatcher.d.ts +0 -19
- package/dist/tools/dispatcher.d.ts.map +0 -1
- package/dist/tools/dispatcher.js +0 -91
- package/dist/tools/dispatcher.js.map +0 -1
- package/dist/tools/loop-detector.d.ts +0 -27
- package/dist/tools/loop-detector.d.ts.map +0 -1
- package/dist/tools/loop-detector.js +0 -76
- package/dist/tools/loop-detector.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -19
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/registry.js +0 -54
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/step/result-tool.d.ts +0 -7
- package/dist/tools/step/result-tool.d.ts.map +0 -1
- package/dist/tools/step/result-tool.js +0 -34
- package/dist/tools/step/result-tool.js.map +0 -1
- package/dist/tools/tool-contract.d.ts +0 -3
- package/dist/tools/tool-contract.d.ts.map +0 -1
- package/dist/tools/tool-contract.js +0 -2
- package/dist/tools/tool-contract.js.map +0 -1
- package/dist/tools/types.d.ts +0 -210
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/types.js +0 -4
- package/dist/tools/types.js.map +0 -1
- package/docs/CLI.md +0 -59
- package/docs/CONFIGURATION.md +0 -105
- package/docs/DRIVERS.md +0 -79
- package/docs/EVIDENCE.md +0 -64
- package/schemas/checkmate-config.v1.json +0 -176
- package/schemas/describe-result.v1.json +0 -414
- package/schemas/driver-descriptor.v1.json +0 -66
- package/schemas/run-request.v1.json +0 -67
- package/schemas/run-result.v1.json +0 -333
- package/schemas/validation-result.v1.json +0 -86
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4';
|
|
2
|
-
/**
|
|
3
|
-
* Creates an internal runner tool, which may return a step assertion.
|
|
4
|
-
* Driver authors use defineDriverTool from '@xoxoai/checkmate/driver' instead.
|
|
5
|
-
*/
|
|
6
|
-
export function defineAgentTool(toolConfig) {
|
|
7
|
-
const jsonSchema = z.toJSONSchema(toolConfig.schema);
|
|
8
|
-
delete jsonSchema.$schema;
|
|
9
|
-
const definition = {
|
|
10
|
-
name: toolConfig.name,
|
|
11
|
-
description: toolConfig.description,
|
|
12
|
-
parameters: jsonSchema,
|
|
13
|
-
strict: toolConfig.strict ?? true,
|
|
14
|
-
};
|
|
15
|
-
return {
|
|
16
|
-
definition,
|
|
17
|
-
execute: async (args, context) => {
|
|
18
|
-
const parsed = toolConfig.schema.safeParse(args);
|
|
19
|
-
if (!parsed.success) {
|
|
20
|
-
return JSON.stringify({ error: `Invalid args for '${toolConfig.name}': ${parsed.error.message}` });
|
|
21
|
-
}
|
|
22
|
-
return toolConfig.handler(parsed.data, context);
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Internal shorthand for defineAgentTool; not part of the public driver API.
|
|
28
|
-
*/
|
|
29
|
-
export const defineTool = defineAgentTool;
|
|
30
|
-
//# sourceMappingURL=define-agent-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-agent-tool.js","sourceRoot":"","sources":["../../src/tools/define-agent-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAW1B;;;GAGG;AACH,MAAM,UAAU,eAAe,CAA4B,UAA+B;IACzF,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,CAA4B,CAAA;IAC/E,OAAO,UAAU,CAAC,OAAO,CAAA;IAEzB,MAAM,UAAU,GAAwB;QACvC,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,IAAI;KACjC,CAAA;IAED,OAAO;QACN,UAAU;QACV,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,OAAyB,EAAE,EAAE;YAC3D,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;YAChD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACrB,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,qBAAqB,UAAU,CAAC,IAAI,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YACnG,CAAC;YAED,OAAO,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAChD,CAAC;KACD,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { RuntimeLogger } from '../logging/types.js';
|
|
2
|
-
import { LoopDetector } from './loop-detector.js';
|
|
3
|
-
import { ToolRegistry } from './registry.js';
|
|
4
|
-
import { AgentToolContext, ToolCall, ToolResponse } from './types.js';
|
|
5
|
-
export declare class ToolDispatcher {
|
|
6
|
-
private readonly toolRegistry;
|
|
7
|
-
private readonly loopDetector;
|
|
8
|
-
private readonly runtimeLogger;
|
|
9
|
-
private readonly debug;
|
|
10
|
-
constructor(toolRegistry: ToolRegistry, loopDetector: LoopDetector, runtimeLogger: RuntimeLogger, debug?: boolean);
|
|
11
|
-
getToolRegistry(): ToolRegistry;
|
|
12
|
-
dispatch(toolCall: ToolCall, context: AgentToolContext): Promise<ToolResponse | null>;
|
|
13
|
-
private formatAllowedToolNames;
|
|
14
|
-
private normalizeToolResponse;
|
|
15
|
-
}
|
|
16
|
-
export declare class ToolDispatchError extends Error {
|
|
17
|
-
constructor(message: string, options?: ErrorOptions);
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/tools/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAsC,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzG,qBAAa,cAAc;IAEzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAHL,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,KAAK,UAAQ;IAG/B,eAAe,IAAI,YAAY;IAIzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IA6C3F,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,qBAAqB;CAkB7B;AAED,qBAAa,iBAAkB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAInD"}
|
package/dist/tools/dispatcher.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { scrub } from '../redaction/scrub.js';
|
|
2
|
-
export class ToolDispatcher {
|
|
3
|
-
toolRegistry;
|
|
4
|
-
loopDetector;
|
|
5
|
-
runtimeLogger;
|
|
6
|
-
debug;
|
|
7
|
-
constructor(toolRegistry, loopDetector, runtimeLogger, debug = false) {
|
|
8
|
-
this.toolRegistry = toolRegistry;
|
|
9
|
-
this.loopDetector = loopDetector;
|
|
10
|
-
this.runtimeLogger = runtimeLogger;
|
|
11
|
-
this.debug = debug;
|
|
12
|
-
}
|
|
13
|
-
getToolRegistry() {
|
|
14
|
-
return this.toolRegistry;
|
|
15
|
-
}
|
|
16
|
-
async dispatch(toolCall, context) {
|
|
17
|
-
this.loopDetector.recordToolCall(toolCall);
|
|
18
|
-
this.runtimeLogger.info(`executing tool: ${toolCall.name}:\n${JSON.stringify(toolCall.arguments ?? {}, null, 2)}`);
|
|
19
|
-
const tool = this.toolRegistry.resolve(toolCall.name);
|
|
20
|
-
if (!tool) {
|
|
21
|
-
throw new ToolDispatchError([
|
|
22
|
-
`Invalid tool name: ${toolCall.name}`,
|
|
23
|
-
`arguments: ${preview(toolCall.arguments, 1_000)}`,
|
|
24
|
-
`registered_tools: ${this.toolRegistry.getRegisteredToolNames().join(', ') || '(none)'}`,
|
|
25
|
-
`allowed_tools: ${this.formatAllowedToolNames()}`,
|
|
26
|
-
].join('\n'));
|
|
27
|
-
}
|
|
28
|
-
let result;
|
|
29
|
-
try {
|
|
30
|
-
result = await tool.execute(toolCall.arguments, context);
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
throw new ToolDispatchError([
|
|
34
|
-
`Tool execution failed: ${toolCall.name}`,
|
|
35
|
-
`arguments: ${preview(toolCall.arguments, 1_000)}`,
|
|
36
|
-
`original_error: ${error instanceof Error ? error.message : String(error)}`,
|
|
37
|
-
].join('\n'), { cause: error });
|
|
38
|
-
}
|
|
39
|
-
const response = this.normalizeToolResponse(toolCall.name, result);
|
|
40
|
-
if (response === null && this.debug) {
|
|
41
|
-
this.runtimeLogger.debug([
|
|
42
|
-
'tool completed without model response:',
|
|
43
|
-
`tool: ${toolCall.name}`,
|
|
44
|
-
`arguments: ${preview(toolCall.arguments ?? {}, 1_000)}`,
|
|
45
|
-
].join('\n'));
|
|
46
|
-
}
|
|
47
|
-
return response;
|
|
48
|
-
}
|
|
49
|
-
formatAllowedToolNames() {
|
|
50
|
-
const allowedNames = this.toolRegistry.getAllowedToolNames();
|
|
51
|
-
return allowedNames === '*' ? '(all registered tools allowed)' : allowedNames.join(', ') || '(none)';
|
|
52
|
-
}
|
|
53
|
-
normalizeToolResponse(toolName, result) {
|
|
54
|
-
if (result === undefined) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
if (typeof result === 'string') {
|
|
58
|
-
return { name: toolName, response: result, status: inferToolResponseStatus(result) };
|
|
59
|
-
}
|
|
60
|
-
const normalizedResult = (result ?? { response: '' });
|
|
61
|
-
return {
|
|
62
|
-
name: toolName,
|
|
63
|
-
response: normalizedResult.response,
|
|
64
|
-
snapshot: normalizedResult.snapshot ?? null,
|
|
65
|
-
status: normalizedResult.status ?? 'success',
|
|
66
|
-
...(normalizedResult.assertion ? { assertion: normalizedResult.assertion } : {}),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export class ToolDispatchError extends Error {
|
|
71
|
-
constructor(message, options) {
|
|
72
|
-
super(message, options);
|
|
73
|
-
this.name = 'ToolDispatchError';
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function preview(value, maxLength) {
|
|
77
|
-
const text = typeof value === 'string' ? value : JSON.stringify(value, null, 2);
|
|
78
|
-
const safeText = scrub(text ?? String(value));
|
|
79
|
-
return safeText.length <= maxLength ? safeText : `${safeText.slice(0, maxLength - 3)}...`;
|
|
80
|
-
}
|
|
81
|
-
function inferToolResponseStatus(response) {
|
|
82
|
-
const normalizedResponse = response.trim().toLowerCase();
|
|
83
|
-
if (normalizedResponse.startsWith('failed') ||
|
|
84
|
-
normalizedResponse.startsWith('error') ||
|
|
85
|
-
normalizedResponse.startsWith('tool call error') ||
|
|
86
|
-
normalizedResponse.startsWith('{"error"')) {
|
|
87
|
-
return 'error';
|
|
88
|
-
}
|
|
89
|
-
return 'success';
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=dispatcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/tools/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAK7C,MAAM,OAAO,cAAc;IAER;IACA;IACA;IACA;IAJlB,YACkB,YAA0B,EAC1B,YAA0B,EAC1B,aAA4B,EAC5B,QAAQ,KAAK;QAHb,iBAAY,GAAZ,YAAY,CAAc;QAC1B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,kBAAa,GAAb,aAAa,CAAe;QAC5B,UAAK,GAAL,KAAK,CAAQ;IAC5B,CAAC;IAEJ,eAAe;QACd,OAAO,IAAI,CAAC,YAAY,CAAA;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAkB,EAAE,OAAyB;QAC3D,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAA;QAC1C,IAAI,CAAC,aAAa,CAAC,IAAI,CACtB,mBAAmB,QAAQ,CAAC,IAAI,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CACzF,CAAA;QAED,MAAM,IAAI,GAAG,IAAI,CAAC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E,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IAChC,CAAC;CACD;AAED,SAAS,OAAO,CAAC,KAAc,EAAE,SAAiB;IACjD,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC/E,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC7C,OAAO,QAAQ,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,CAAA;AAC1F,CAAC;AAED,SAAS,uBAAuB,CAAC,QAAgB;IAChD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACxD,IACC,kBAAkB,CAAC,UAAU,CAAC,QAAQ,CAAC;QACvC,kBAAkB,CAAC,UAAU,CAAC,OAAO,CAAC;QACtC,kBAAkB,CAAC,UAAU,CAAC,iBAAiB,CAAC;QAChD,kBAAkB,CAAC,UAAU,CAAC,UAAU,CAAC,EACxC,CAAC;QACF,OAAO,OAAO,CAAA;IACf,CAAC;IAED,OAAO,SAAS,CAAA;AACjB,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ToolCall } from './tool-contract.js';
|
|
2
|
-
export type LoopDetectionResult = {
|
|
3
|
-
loopDetected: boolean;
|
|
4
|
-
patternLength: number;
|
|
5
|
-
repetitions: number;
|
|
6
|
-
pattern: string[];
|
|
7
|
-
};
|
|
8
|
-
export declare class LoopDetectedError extends Error {
|
|
9
|
-
readonly loopResult: LoopDetectionResult;
|
|
10
|
-
static readonly STATUS = "TOOL_CALL_LOOP";
|
|
11
|
-
readonly status: string;
|
|
12
|
-
constructor(loopResult: LoopDetectionResult);
|
|
13
|
-
}
|
|
14
|
-
export declare class LoopDetector {
|
|
15
|
-
private readonly maxRepetitions;
|
|
16
|
-
private toolCallHistory;
|
|
17
|
-
constructor(maxRepetitions: number);
|
|
18
|
-
reset(): void;
|
|
19
|
-
recordToolCall(toolCall: ToolCall): void;
|
|
20
|
-
detectLoop(): void;
|
|
21
|
-
private checkPatternRepetition;
|
|
22
|
-
private patternsMatch;
|
|
23
|
-
private createToolSignature;
|
|
24
|
-
getHistory(): string[];
|
|
25
|
-
getHistoryLength(): number;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=loop-detector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loop-detector.d.ts","sourceRoot":"","sources":["../../src/tools/loop-detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,MAAM,MAAM,mBAAmB,GAAG;IACjC,YAAY,EAAE,OAAO,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA;AAED,qBAAa,iBAAkB,SAAQ,KAAK;aAIf,UAAU,EAAE,mBAAmB;IAH3D,MAAM,CAAC,QAAQ,CAAC,MAAM,oBAAmB;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBAEK,UAAU,EAAE,mBAAmB;CAO3D;AAED,qBAAa,YAAY;IAGZ,OAAO,CAAC,QAAQ,CAAC,cAAc;IAF3C,OAAO,CAAC,eAAe,CAAe;gBAET,cAAc,EAAE,MAAM;IAEnD,KAAK,IAAI,IAAI;IAIb,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAKxC,UAAU;IAWV,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;IAY3B,UAAU,IAAI,MAAM,EAAE;IAItB,gBAAgB,IAAI,MAAM;CAG1B"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export class LoopDetectedError extends Error {
|
|
2
|
-
loopResult;
|
|
3
|
-
static STATUS = 'TOOL_CALL_LOOP';
|
|
4
|
-
status;
|
|
5
|
-
constructor(loopResult) {
|
|
6
|
-
super(`detected tool call loop pattern [${loopResult.pattern.join(' -> ')}] repeated ${loopResult.repetitions} times`);
|
|
7
|
-
this.loopResult = loopResult;
|
|
8
|
-
this.name = 'LoopDetectedError';
|
|
9
|
-
this.status = LoopDetectedError.STATUS;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export class LoopDetector {
|
|
13
|
-
maxRepetitions;
|
|
14
|
-
toolCallHistory = [];
|
|
15
|
-
constructor(maxRepetitions) {
|
|
16
|
-
this.maxRepetitions = maxRepetitions;
|
|
17
|
-
}
|
|
18
|
-
reset() {
|
|
19
|
-
this.toolCallHistory = [];
|
|
20
|
-
}
|
|
21
|
-
recordToolCall(toolCall) {
|
|
22
|
-
this.toolCallHistory.push(this.createToolSignature(toolCall));
|
|
23
|
-
this.detectLoop();
|
|
24
|
-
}
|
|
25
|
-
detectLoop() {
|
|
26
|
-
const history = this.toolCallHistory;
|
|
27
|
-
for (let patternLength = 1; patternLength <= Math.floor(history.length / 2); patternLength++) {
|
|
28
|
-
const result = this.checkPatternRepetition(patternLength);
|
|
29
|
-
if (result.loopDetected) {
|
|
30
|
-
this.reset();
|
|
31
|
-
throw new LoopDetectedError(result);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
checkPatternRepetition(patternLength) {
|
|
36
|
-
const history = this.toolCallHistory;
|
|
37
|
-
if (history.length < patternLength * this.maxRepetitions) {
|
|
38
|
-
return { loopDetected: false, patternLength: 0, repetitions: 0, pattern: [] };
|
|
39
|
-
}
|
|
40
|
-
const pattern = history.slice(-patternLength);
|
|
41
|
-
let repetitions = 1;
|
|
42
|
-
for (let index = history.length - patternLength * 2; index >= 0; index -= patternLength) {
|
|
43
|
-
const slice = history.slice(index, index + patternLength);
|
|
44
|
-
if (this.patternsMatch(pattern, slice)) {
|
|
45
|
-
repetitions++;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (repetitions >= this.maxRepetitions) {
|
|
52
|
-
return { loopDetected: true, patternLength, repetitions, pattern };
|
|
53
|
-
}
|
|
54
|
-
return { loopDetected: false, patternLength: 0, repetitions: 0, pattern: [] };
|
|
55
|
-
}
|
|
56
|
-
patternsMatch(pattern1, pattern2) {
|
|
57
|
-
return pattern1.length === pattern2.length && pattern1.every((item, index) => item === pattern2[index]);
|
|
58
|
-
}
|
|
59
|
-
createToolSignature(toolCall) {
|
|
60
|
-
const args = typeof toolCall.arguments === 'object' && toolCall.arguments !== null
|
|
61
|
-
? toolCall.arguments
|
|
62
|
-
: {};
|
|
63
|
-
const sortedArgs = Object.keys(args)
|
|
64
|
-
.sort()
|
|
65
|
-
.map((key) => `${key}:${JSON.stringify(args[key])}`)
|
|
66
|
-
.join(',');
|
|
67
|
-
return `${toolCall.name}(${sortedArgs})`;
|
|
68
|
-
}
|
|
69
|
-
getHistory() {
|
|
70
|
-
return [...this.toolCallHistory];
|
|
71
|
-
}
|
|
72
|
-
getHistoryLength() {
|
|
73
|
-
return this.toolCallHistory.length;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=loop-detector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loop-detector.js","sourceRoot":"","sources":["../../src/tools/loop-detector.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAIf;IAH5B,MAAM,CAAU,MAAM,GAAG,gBAAgB,CAAA;IAChC,MAAM,CAAQ;IAEvB,YAA4B,UAA+B;QAC1D,KAAK,CACJ,oCAAo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pE,CAAC,CAAE,QAAQ,CAAC,SAAqC;YACjD,CAAC,CAAC,EAAE,CAAA;QACN,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;aAClC,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aACnD,IAAI,CAAC,GAAG,CAAC,CAAA;QACX,OAAO,GAAG,QAAQ,CAAC,IAAI,IAAI,UAAU,GAAG,CAAA;IACzC,CAAC;IAED,UAAU;QACT,OAAO,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,CAAA;IACjC,CAAC;IAED,gBAAgB;QACf,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAA;IACnC,CAAC;CACD"}
|
package/dist/tools/registry.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ChatCompletionFunctionTool } from 'openai/resources/chat/completions';
|
|
2
|
-
import { AgentTool } from './types.js';
|
|
3
|
-
export type { ToolResponse } from './types.js';
|
|
4
|
-
export declare class ToolRegistry {
|
|
5
|
-
private readonly tools;
|
|
6
|
-
private readonly toolsByName;
|
|
7
|
-
private readonly allowedNames;
|
|
8
|
-
constructor(input: {
|
|
9
|
-
allowedTools: '*' | readonly string[];
|
|
10
|
-
});
|
|
11
|
-
register(tool: AgentTool | AgentTool[]): void;
|
|
12
|
-
resolve(toolName: string): AgentTool | undefined;
|
|
13
|
-
getRegisteredToolNames(): string[];
|
|
14
|
-
getTools(): Promise<ChatCompletionFunctionTool[]>;
|
|
15
|
-
getAllowedToolNames(): '*' | readonly string[];
|
|
16
|
-
private isAllowed;
|
|
17
|
-
private toOpenAiTool;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AAE9E,OAAO,EAAE,SAAS,EAAe,MAAM,YAAY,CAAA;AAEnD,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,qBAAa,YAAY;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+B;IAC3D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAyB;gBAE1C,KAAK,EAAE;QAAE,YAAY,EAAE,GAAG,GAAG,SAAS,MAAM,EAAE,CAAA;KAAE;IAI5D,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI;IAc7C,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAKhD,sBAAsB,IAAI,MAAM,EAAE;IAI5B,QAAQ,IAAI,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAMvD,mBAAmB,IAAI,GAAG,GAAG,SAAS,MAAM,EAAE;IAI9C,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,YAAY;CAWpB"}
|
package/dist/tools/registry.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { StepResultTool } from './step/result-tool.js';
|
|
2
|
-
import { getToolName } from './types.js';
|
|
3
|
-
export class ToolRegistry {
|
|
4
|
-
tools = [];
|
|
5
|
-
toolsByName = new Map();
|
|
6
|
-
allowedNames;
|
|
7
|
-
constructor(input) {
|
|
8
|
-
this.allowedNames = input.allowedTools === '*' ? '*' : [...input.allowedTools];
|
|
9
|
-
}
|
|
10
|
-
register(tool) {
|
|
11
|
-
const tools = Array.isArray(tool) ? tool : [tool];
|
|
12
|
-
for (const registeredTool of tools) {
|
|
13
|
-
const toolName = getToolName(registeredTool);
|
|
14
|
-
if (this.toolsByName.has(toolName)) {
|
|
15
|
-
throw new Error(`Duplicate tool registration for '${toolName}'`);
|
|
16
|
-
}
|
|
17
|
-
this.tools.push(registeredTool);
|
|
18
|
-
this.toolsByName.set(toolName, registeredTool);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
resolve(toolName) {
|
|
22
|
-
if (!this.isAllowed(toolName))
|
|
23
|
-
return undefined;
|
|
24
|
-
return this.toolsByName.get(toolName);
|
|
25
|
-
}
|
|
26
|
-
getRegisteredToolNames() {
|
|
27
|
-
return this.tools.map((tool) => getToolName(tool));
|
|
28
|
-
}
|
|
29
|
-
async getTools() {
|
|
30
|
-
const definitions = this.tools.map((tool) => this.toOpenAiTool(tool));
|
|
31
|
-
return definitions.filter((tool) => this.isAllowed(tool.function.name));
|
|
32
|
-
}
|
|
33
|
-
getAllowedToolNames() {
|
|
34
|
-
return this.allowedNames === '*' ? '*' : [...this.allowedNames];
|
|
35
|
-
}
|
|
36
|
-
isAllowed(toolName) {
|
|
37
|
-
return (toolName === StepResultTool.TOOL_FAIL_TEST_STEP ||
|
|
38
|
-
toolName === StepResultTool.TOOL_PASS_TEST_STEP ||
|
|
39
|
-
this.allowedNames === '*' ||
|
|
40
|
-
this.allowedNames.includes(toolName));
|
|
41
|
-
}
|
|
42
|
-
toOpenAiTool(tool) {
|
|
43
|
-
return {
|
|
44
|
-
type: 'function',
|
|
45
|
-
function: {
|
|
46
|
-
name: tool.definition.name,
|
|
47
|
-
description: tool.definition.description,
|
|
48
|
-
parameters: tool.definition.parameters,
|
|
49
|
-
strict: tool.definition.strict,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAa,WAAW,EAAE,MAAM,YAAY,CAAA;AAInD,MAAM,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,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;QAErE,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;IACxE,CAAC;IAED,mBAAmB;QAClB,OAAO,IAAI,CAAC,YAAY,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAA;IAChE,CAAC;IAEO,SAAS,CAAC,QAAgB;QACjC,OAAO,CACN,QAAQ,KAAK,cAAc,CAAC,mBAAmB;YAC/C,QAAQ,KAAK,cAAc,CAAC,mBAAmB;YAC/C,IAAI,CAAC,YAAY,KAAK,GAAG;YACzB,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACpC,CAAA;IACF,CAAC;IAEO,YAAY,CAAC,IAAe;QACnC,OAAO;YACN,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE;gBACT,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI;gBAC1B,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW;gBACxC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU;gBACtC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;aAC9B;SACD,CAAA;IACF,CAAC;CACD"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AgentTool } from '../types.js';
|
|
2
|
-
export declare const StepResultTool: {
|
|
3
|
-
readonly TOOL_FAIL_TEST_STEP: "fail_test_step";
|
|
4
|
-
readonly TOOL_PASS_TEST_STEP: "pass_test_step";
|
|
5
|
-
};
|
|
6
|
-
export declare function createStepResultTools(): AgentTool[];
|
|
7
|
-
//# sourceMappingURL=result-tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/step/result-tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,eAAO,MAAM,cAAc;;;CAGjB,CAAA;AAQV,wBAAgB,qBAAqB,IAAI,SAAS,EAAE,CAqBnD"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4';
|
|
2
|
-
import { defineAgentTool } from '../define-agent-tool.js';
|
|
3
|
-
export const StepResultTool = {
|
|
4
|
-
TOOL_FAIL_TEST_STEP: 'fail_test_step',
|
|
5
|
-
TOOL_PASS_TEST_STEP: 'pass_test_step',
|
|
6
|
-
};
|
|
7
|
-
const stepResultSchema = z
|
|
8
|
-
.object({
|
|
9
|
-
actualResult: z.string().describe('The actual result of the test step'),
|
|
10
|
-
})
|
|
11
|
-
.strict();
|
|
12
|
-
export function createStepResultTools() {
|
|
13
|
-
return [
|
|
14
|
-
defineAgentTool({
|
|
15
|
-
name: StepResultTool.TOOL_FAIL_TEST_STEP,
|
|
16
|
-
description: 'Fail the test step with the actual result',
|
|
17
|
-
schema: stepResultSchema,
|
|
18
|
-
handler: ({ actualResult }) => ({
|
|
19
|
-
response: actualResult,
|
|
20
|
-
assertion: { passed: false, actual: actualResult },
|
|
21
|
-
}),
|
|
22
|
-
}),
|
|
23
|
-
defineAgentTool({
|
|
24
|
-
name: StepResultTool.TOOL_PASS_TEST_STEP,
|
|
25
|
-
description: 'Pass the test step with the actual result',
|
|
26
|
-
schema: stepResultSchema,
|
|
27
|
-
handler: ({ actualResult }) => ({
|
|
28
|
-
response: actualResult,
|
|
29
|
-
assertion: { passed: true, actual: actualResult },
|
|
30
|
-
}),
|
|
31
|
-
}),
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=result-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-tool.js","sourceRoot":"","sources":["../../../src/tools/step/result-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAGzD,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,mBAAmB,EAAE,gBAAgB;IACrC,mBAAmB,EAAE,gBAAgB;CAC5B,CAAA;AAEV,MAAM,gBAAgB,GAAG,CAAC;KACxB,MAAM,CAAC;IACP,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;CACvE,CAAC;KACD,MAAM,EAAE,CAAA;AAEV,MAAM,UAAU,qBAAqB;IACpC,OAAO;QACN,eAAe,CAAC;YACf,IAAI,EAAE,cAAc,CAAC,mBAAmB;YACxC,WAAW,EAAE,2CAA2C;YACxD,MAAM,EAAE,gBAAgB;YACxB,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC/B,QAAQ,EAAE,YAAY;gBACtB,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE;aAClD,CAAC;SACF,CAAC;QACF,eAAe,CAAC;YACf,IAAI,EAAE,cAAc,CAAC,mBAAmB;YACxC,WAAW,EAAE,2CAA2C;YACxD,MAAM,EAAE,gBAAgB;YACxB,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC/B,QAAQ,EAAE,YAAY;gBACtB,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE;aACjD,CAAC;SACF,CAAC;KACF,CAAA;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-contract.d.ts","sourceRoot":"","sources":["../../src/tools/tool-contract.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,aAAa,EACb,YAAY,GACZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-contract.js","sourceRoot":"","sources":["../../src/tools/tool-contract.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/tools/types.d.ts
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { Step, StepAssertion } from '../runtime/types.js';
|
|
2
|
-
import type { StepControl } from '../runtime/scenario-control.js';
|
|
3
|
-
/**
|
|
4
|
-
* Normalized tool call emitted by the model.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const call: ToolCall = {
|
|
9
|
-
* name: 'browser_click_or_hover',
|
|
10
|
-
* arguments: { ref: 'e123', hover: false },
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export type ToolCall = {
|
|
15
|
-
/**
|
|
16
|
-
* Tool name requested by the model.
|
|
17
|
-
*/
|
|
18
|
-
name: string;
|
|
19
|
-
/**
|
|
20
|
-
* Parsed tool arguments.
|
|
21
|
-
*/
|
|
22
|
-
arguments?: unknown;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Serializable tool definition used by Checkmate.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* const definition: AgentToolDefinition = {
|
|
30
|
-
* name: 'check_api_health',
|
|
31
|
-
* description: 'Check whether the API is healthy',
|
|
32
|
-
* parameters: { type: 'object', properties: { url: { type: 'string' } } },
|
|
33
|
-
* strict: true,
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export type AgentToolDefinition = {
|
|
38
|
-
/**
|
|
39
|
-
* Stable tool name.
|
|
40
|
-
*/
|
|
41
|
-
name: string;
|
|
42
|
-
/**
|
|
43
|
-
* Short tool description shown to the model.
|
|
44
|
-
*/
|
|
45
|
-
description: string;
|
|
46
|
-
/**
|
|
47
|
-
* JSON schema for the tool parameters.
|
|
48
|
-
*/
|
|
49
|
-
parameters: Record<string, unknown>;
|
|
50
|
-
/**
|
|
51
|
-
* Whether the tool arguments should be validated strictly.
|
|
52
|
-
*/
|
|
53
|
-
strict: boolean;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Structured tool response returned to the model.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* const response: AgentToolResponse = {
|
|
61
|
-
* response: 'Clicked the Submit button.',
|
|
62
|
-
* status: 'success',
|
|
63
|
-
* }
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export type AgentToolResponse = {
|
|
67
|
-
/**
|
|
68
|
-
* Human-readable result returned to the model.
|
|
69
|
-
*/
|
|
70
|
-
response: string;
|
|
71
|
-
/**
|
|
72
|
-
* Optional fresh snapshot to append after tool execution.
|
|
73
|
-
*/
|
|
74
|
-
snapshot?: string | null;
|
|
75
|
-
/**
|
|
76
|
-
* Outcome status used in tool execution summaries.
|
|
77
|
-
*/
|
|
78
|
-
status?: 'success' | 'error';
|
|
79
|
-
/**
|
|
80
|
-
* Ends the step with this assertion instead of running another model turn.
|
|
81
|
-
*/
|
|
82
|
-
assertion?: StepAssertion;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Any valid value a tool can return.
|
|
86
|
-
*
|
|
87
|
-
* Tools may return a structured response, a plain string, or nothing.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```ts
|
|
91
|
-
* const result: AgentToolResult = {
|
|
92
|
-
* response: 'API health is good',
|
|
93
|
-
* status: 'success',
|
|
94
|
-
* }
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
export type AgentToolResult = AgentToolResponse | string | void;
|
|
98
|
-
/**
|
|
99
|
-
* Context passed to every tool execution.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```ts
|
|
103
|
-
* const handler = async (_args: unknown, context: AgentToolContext) => {
|
|
104
|
-
* return `Working on: ${context.step.action}`
|
|
105
|
-
* }
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
export type AgentToolContext = {
|
|
109
|
-
/**
|
|
110
|
-
* Step currently being executed.
|
|
111
|
-
*/
|
|
112
|
-
step: Step;
|
|
113
|
-
/**
|
|
114
|
-
* Model turn the tool is being dispatched on, starting at `1`, when known.
|
|
115
|
-
*/
|
|
116
|
-
turn?: number;
|
|
117
|
-
signal?: AbortSignal;
|
|
118
|
-
control?: StepControl;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Internal tool contract used by the runner loop, including assertion-bearing tools.
|
|
122
|
-
*
|
|
123
|
-
* Driver authors use DriverTool and defineDriverTool from '@xoxoai/checkmate/driver'.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```ts
|
|
127
|
-
* const tool: AgentTool = defineTool({
|
|
128
|
-
* name: 'check_api_health',
|
|
129
|
-
* description: 'Check whether the API is healthy',
|
|
130
|
-
* schema: z.object({ url: z.string() }).strict(),
|
|
131
|
-
* handler: async ({ url }) => `API health is good for ${url}`,
|
|
132
|
-
* })
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
export type AgentTool = {
|
|
136
|
-
driverId?: string;
|
|
137
|
-
/**
|
|
138
|
-
* Tool definition exposed to the model.
|
|
139
|
-
*/
|
|
140
|
-
definition: AgentToolDefinition;
|
|
141
|
-
/**
|
|
142
|
-
* Tool implementation.
|
|
143
|
-
*/
|
|
144
|
-
execute: (args: unknown, context: AgentToolContext) => Promise<AgentToolResult> | AgentToolResult;
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Normalized tool response recorded by the runner loop.
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```ts
|
|
151
|
-
* const response: ToolResponse = {
|
|
152
|
-
* name: 'browser_navigate',
|
|
153
|
-
* response: 'Navigated to https://example.com',
|
|
154
|
-
* snapshot: null,
|
|
155
|
-
* status: 'success',
|
|
156
|
-
* }
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
export type ToolResponse = {
|
|
160
|
-
/**
|
|
161
|
-
* Tool that produced the response.
|
|
162
|
-
*/
|
|
163
|
-
name?: string;
|
|
164
|
-
/**
|
|
165
|
-
* Human-readable result returned to the model.
|
|
166
|
-
*/
|
|
167
|
-
response: string;
|
|
168
|
-
/**
|
|
169
|
-
* Fresh page snapshot captured after the tool ran.
|
|
170
|
-
*/
|
|
171
|
-
snapshot?: string | null;
|
|
172
|
-
/**
|
|
173
|
-
* Outcome status used in tool execution summaries.
|
|
174
|
-
*/
|
|
175
|
-
status: 'success' | 'error';
|
|
176
|
-
/**
|
|
177
|
-
* Assertion that ends the step, when the tool produced one.
|
|
178
|
-
*/
|
|
179
|
-
assertion?: StepAssertion;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* One tool execution observed during the runner loop.
|
|
183
|
-
*
|
|
184
|
-
* Driver hooks receive the public DriverToolExecution shape instead.
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```ts
|
|
188
|
-
* const execution: ToolExecution = {
|
|
189
|
-
* toolCallId: 'call_1',
|
|
190
|
-
* toolCall: { name: 'browser_navigate', arguments: { url: 'https://example.com' } },
|
|
191
|
-
* toolResponse: { response: 'Navigated to example.com', status: 'success' },
|
|
192
|
-
* }
|
|
193
|
-
* ```
|
|
194
|
-
*/
|
|
195
|
-
export type ToolExecution = {
|
|
196
|
-
/**
|
|
197
|
-
* Provider-issued id for the tool call.
|
|
198
|
-
*/
|
|
199
|
-
toolCallId: string;
|
|
200
|
-
/**
|
|
201
|
-
* Normalized tool call request.
|
|
202
|
-
*/
|
|
203
|
-
toolCall: ToolCall;
|
|
204
|
-
/**
|
|
205
|
-
* Normalized tool response returned by Checkmate.
|
|
206
|
-
*/
|
|
207
|
-
toolResponse: ToolResponse;
|
|
208
|
-
};
|
|
209
|
-
export declare function getToolName(tool: AgentTool): string;
|
|
210
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAEnC;;OAEG;IACH,MAAM,EAAE,OAAO,CAAA;CACf,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAExB;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAA;IAE5B;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;CACzB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAAA;AAE/D;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,MAAM,CAAC,EAAE,WAAW,CAAA;IAEpB,OAAO,CAAC,EAAE,WAAW,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,SAAS,GAAG;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,UAAU,EAAE,mBAAmB,CAAA;IAE/B;;OAEG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;CACjG,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAExB;;OAEG;IACH,MAAM,EAAE,SAAS,GAAG,OAAO,CAAA;IAE3B;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;CACzB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAA;IAElB;;OAEG;IACH,YAAY,EAAE,YAAY,CAAA;CAC1B,CAAA;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAEnD"}
|
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":"AA0OA,MAAM,UAAU,WAAW,CAAC,IAAe;IAC1C,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAA;AAC5B,CAAC"}
|