@voybio/ace-swarm 0.1.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 +109 -0
- package/LICENSE +186 -0
- package/README.md +229 -0
- package/assets/.agents/ACE/ACE-Init/AGENTS.md +210 -0
- package/assets/.agents/ACE/ACE-Init/instructions.md +118 -0
- package/assets/.agents/ACE/ACE_coders/AGENTS.md +154 -0
- package/assets/.agents/ACE/ACE_coders/INSTRUCTIONS.md +216 -0
- package/assets/.agents/ACE/AGENT_REGISTRY.md +70 -0
- package/assets/.agents/ACE/AGENT_REGISTRY_7.md +9 -0
- package/assets/.agents/ACE/DIRECTIVE_KERNEL.md +234 -0
- package/assets/.agents/ACE/UI/AGENTS.md +115 -0
- package/assets/.agents/ACE/UI/instructions.md +178 -0
- package/assets/.agents/ACE/VOS/ACE_VOS_MISSING_INFO_MATRIX.md +42 -0
- package/assets/.agents/ACE/VOS/AGENTS.md +72 -0
- package/assets/.agents/ACE/VOS/instructions.md +211 -0
- package/assets/.agents/ACE/agent-astgrep/AGENTS.md +123 -0
- package/assets/.agents/ACE/agent-astgrep/instructions.md +91 -0
- package/assets/.agents/ACE/agent-builder/AGENTS.md +172 -0
- package/assets/.agents/ACE/agent-builder/instructions.md +137 -0
- package/assets/.agents/ACE/agent-docs/AGENTS.md +159 -0
- package/assets/.agents/ACE/agent-docs/instructions.md +133 -0
- package/assets/.agents/ACE/agent-eval/AGENTS.md +46 -0
- package/assets/.agents/ACE/agent-eval/instructions.md +56 -0
- package/assets/.agents/ACE/agent-memory/AGENTS.md +49 -0
- package/assets/.agents/ACE/agent-memory/instructions.md +50 -0
- package/assets/.agents/ACE/agent-observability/AGENTS.md +46 -0
- package/assets/.agents/ACE/agent-observability/instructions.md +50 -0
- package/assets/.agents/ACE/agent-ops/AGENTS.md +201 -0
- package/assets/.agents/ACE/agent-ops/instructions.md +136 -0
- package/assets/.agents/ACE/agent-qa/AGENTS.md +189 -0
- package/assets/.agents/ACE/agent-qa/instructions.md +121 -0
- package/assets/.agents/ACE/agent-release/AGENTS.md +48 -0
- package/assets/.agents/ACE/agent-release/instructions.md +49 -0
- package/assets/.agents/ACE/agent-research/AGENTS.md +160 -0
- package/assets/.agents/ACE/agent-research/instructions.md +118 -0
- package/assets/.agents/ACE/agent-security/AGENTS.md +48 -0
- package/assets/.agents/ACE/agent-security/instructions.md +50 -0
- package/assets/.agents/ACE/agent-skeptic/AGENTS.md +178 -0
- package/assets/.agents/ACE/agent-skeptic/instructions.md +196 -0
- package/assets/.agents/ACE/agent-spec/AGENTS.md +169 -0
- package/assets/.agents/ACE/agent-spec/instructions.md +116 -0
- package/assets/.agents/ACE/orchestrator/AGENTS.md +365 -0
- package/assets/.agents/ACE/orchestrator/instructions.md +231 -0
- package/assets/.agents/skills/ace-orchestrator/SKILL.md +63 -0
- package/assets/.agents/skills/ace-orchestrator/references/engineering-bootstrap-playbook.md +360 -0
- package/assets/.agents/skills/astgrep-index/SKILL.md +58 -0
- package/assets/.agents/skills/codemunch/SKILL.md +65 -0
- package/assets/.agents/skills/codemunch/references/ast-driven-protocol.md +543 -0
- package/assets/.agents/skills/codesnipe/SKILL.md +64 -0
- package/assets/.agents/skills/codesnipe/references/dual-codebase-playbook.md +671 -0
- package/assets/.agents/skills/eval-harness/SKILL.md +203 -0
- package/assets/.agents/skills/handoff-lint/SKILL.md +164 -0
- package/assets/.agents/skills/incident-commander/SKILL.md +174 -0
- package/assets/.agents/skills/landing-review-watcher/SKILL.md +68 -0
- package/assets/.agents/skills/memory-curator/SKILL.md +179 -0
- package/assets/.agents/skills/problem-triage/SKILL.md +57 -0
- package/assets/.agents/skills/problem-triage/agents/openai.yaml +3 -0
- package/assets/.agents/skills/release-sentry/SKILL.md +189 -0
- package/assets/.agents/skills/risk-quant/SKILL.md +190 -0
- package/assets/.agents/skills/schema-forge/SKILL.md +174 -0
- package/assets/.agents/skills/skill-auditor/SKILL.md +52 -0
- package/assets/.agents/skills/state-auditor/SKILL.md +182 -0
- package/assets/.github/hooks/ace-copilot.json +68 -0
- package/assets/agent-state/ACE_WORKFLOW.md +131 -0
- package/assets/agent-state/ARTIFACT_MANIFEST.json +5 -0
- package/assets/agent-state/AST_GREP_COMMANDS.md +121 -0
- package/assets/agent-state/AST_GREP_INDEX.json +13 -0
- package/assets/agent-state/AST_GREP_INDEX.md +15 -0
- package/assets/agent-state/DECISIONS.md +7 -0
- package/assets/agent-state/EVIDENCE_LOG.md +7 -0
- package/assets/agent-state/HANDOFF.json +24 -0
- package/assets/agent-state/INTERFACE_REGISTRY.md +75 -0
- package/assets/agent-state/MODULES/gates/gate-autonomy.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-completeness.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-correctness.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-evaluation.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-operability.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-security.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-typescript-public-surface.json +7 -0
- package/assets/agent-state/MODULES/registry.json +41 -0
- package/assets/agent-state/MODULES/roles/capability-astgrep.json +49 -0
- package/assets/agent-state/MODULES/roles/capability-build.json +39 -0
- package/assets/agent-state/MODULES/roles/capability-docs.json +38 -0
- package/assets/agent-state/MODULES/roles/capability-eval.json +20 -0
- package/assets/agent-state/MODULES/roles/capability-memory.json +20 -0
- package/assets/agent-state/MODULES/roles/capability-observability.json +20 -0
- package/assets/agent-state/MODULES/roles/capability-ops.json +45 -0
- package/assets/agent-state/MODULES/roles/capability-qa.json +40 -0
- package/assets/agent-state/MODULES/roles/capability-release.json +21 -0
- package/assets/agent-state/MODULES/roles/capability-research.json +44 -0
- package/assets/agent-state/MODULES/roles/capability-security.json +21 -0
- package/assets/agent-state/MODULES/roles/capability-skeptic.json +48 -0
- package/assets/agent-state/MODULES/roles/capability-spec.json +42 -0
- package/assets/agent-state/MODULES/schemas/ACE_RUNTIME_PROFILE.schema.json +289 -0
- package/assets/agent-state/MODULES/schemas/ARTIFACT_MANIFEST.schema.json +185 -0
- package/assets/agent-state/MODULES/schemas/HANDOFF.agent-state.schema.json +124 -0
- package/assets/agent-state/MODULES/schemas/HANDOFF.schema.json +55 -0
- package/assets/agent-state/MODULES/schemas/RUNTIME_EXECUTOR_SESSION_REGISTRY.schema.json +290 -0
- package/assets/agent-state/MODULES/schemas/RUNTIME_TOOL_SPEC_REGISTRY.schema.json +144 -0
- package/assets/agent-state/MODULES/schemas/STATUS_EVENT.schema.json +84 -0
- package/assets/agent-state/MODULES/schemas/SWARM_HANDOFF.schema.json +138 -0
- package/assets/agent-state/MODULES/schemas/TRACKER_SNAPSHOT.schema.json +134 -0
- package/assets/agent-state/MODULES/schemas/VERICIFY_BRIDGE_SNAPSHOT.schema.json +157 -0
- package/assets/agent-state/MODULES/schemas/VERICIFY_PROCESS_POST_LOG.schema.json +93 -0
- package/assets/agent-state/MODULES/schemas/WORKSPACE_SESSION_REGISTRY.schema.json +133 -0
- package/assets/agent-state/PROVENANCE_LOG.md +28 -0
- package/assets/agent-state/QUALITY_GATES.md +15 -0
- package/assets/agent-state/RISKS.md +8 -0
- package/assets/agent-state/SCOPE.md +20 -0
- package/assets/agent-state/SKILL_CATALOG.md +48 -0
- package/assets/agent-state/STATUS.md +8 -0
- package/assets/agent-state/STATUS_EVENTS.ndjson +1 -0
- package/assets/agent-state/TASK.md +18 -0
- package/assets/agent-state/TEAL_CONFIG.md +117 -0
- package/assets/agent-state/handoff-registry.json +5 -0
- package/assets/agent-state/index-fingerprints.json +7 -0
- package/assets/agent-state/index.json +32 -0
- package/assets/agent-state/run-ledger.json +5 -0
- package/assets/agent-state/runtime-executor-sessions.json +5 -0
- package/assets/agent-state/runtime-tool-specs.json +5 -0
- package/assets/agent-state/runtime-workspaces.json +5 -0
- package/assets/agent-state/todo-state.json +7 -0
- package/assets/agent-state/tracker-snapshot.json +7 -0
- package/assets/agent-state/vericify/ace-bridge.json +60 -0
- package/assets/agent-state/vericify/process-posts.json +5 -0
- package/assets/instructions/ACE.instructions.md +187 -0
- package/assets/instructions/ACE_Coder.instructions.md +146 -0
- package/assets/instructions/ACE_UI.instructions.md +178 -0
- package/assets/instructions/ACE_VOS.instructions.md +211 -0
- package/assets/scripts/ace-hook-dispatch.mjs +538 -0
- package/assets/scripts/bootstrap-workspace.sh +27 -0
- package/assets/scripts/copilot-hook-dispatch.mjs +3 -0
- package/assets/scripts/eval-harness.sh +68 -0
- package/assets/scripts/render-mcp-configs.sh +396 -0
- package/assets/tasks/README.md +48 -0
- package/assets/tasks/SWARM_HANDOFF.example.json +53 -0
- package/assets/tasks/SWARM_HANDOFF.example_ui_to_coders.json +55 -0
- package/assets/tasks/SWARM_HANDOFF.example_vos_to_ui.json +55 -0
- package/assets/tasks/SWARM_HANDOFF.template.json +52 -0
- package/assets/tasks/cli_work_split.md +22 -0
- package/assets/tasks/lessons.md +17 -0
- package/assets/tasks/role_tasks.md +206 -0
- package/assets/tasks/todo.md +23 -0
- package/dist/ace-autonomy.d.ts +137 -0
- package/dist/ace-autonomy.js +472 -0
- package/dist/ace-context.d.ts +29 -0
- package/dist/ace-context.js +240 -0
- package/dist/ace-internal-tools.d.ts +8 -0
- package/dist/ace-internal-tools.js +76 -0
- package/dist/ace-server-instructions.d.ts +12 -0
- package/dist/ace-server-instructions.js +324 -0
- package/dist/agent-runtime/role-adapters.d.ts +29 -0
- package/dist/agent-runtime/role-adapters.js +573 -0
- package/dist/astgrep-index.d.ts +24 -0
- package/dist/astgrep-index.js +476 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +591 -0
- package/dist/git-ops.d.ts +53 -0
- package/dist/git-ops.js +238 -0
- package/dist/handoff-registry.d.ts +71 -0
- package/dist/handoff-registry.js +422 -0
- package/dist/helpers.d.ts +126 -0
- package/dist/helpers.js +1687 -0
- package/dist/index-store.d.ts +51 -0
- package/dist/index-store.js +328 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/internal-tool-runtime.d.ts +21 -0
- package/dist/internal-tool-runtime.js +136 -0
- package/dist/job-scheduler.d.ts +175 -0
- package/dist/job-scheduler.js +1217 -0
- package/dist/kanban.d.ts +27 -0
- package/dist/kanban.js +339 -0
- package/dist/local-model-runtime.d.ts +40 -0
- package/dist/local-model-runtime.js +174 -0
- package/dist/model-bridge.d.ts +54 -0
- package/dist/model-bridge.js +587 -0
- package/dist/orchestrator-supervisor.d.ts +100 -0
- package/dist/orchestrator-supervisor.js +399 -0
- package/dist/problem-triage.d.ts +23 -0
- package/dist/problem-triage.js +448 -0
- package/dist/prompts.d.ts +7 -0
- package/dist/prompts.js +628 -0
- package/dist/public-surface.d.ts +30 -0
- package/dist/public-surface.js +316 -0
- package/dist/resources.d.ts +7 -0
- package/dist/resources.js +545 -0
- package/dist/run-ledger.d.ts +36 -0
- package/dist/run-ledger.js +257 -0
- package/dist/runtime-command.d.ts +18 -0
- package/dist/runtime-command.js +76 -0
- package/dist/runtime-executor.d.ts +104 -0
- package/dist/runtime-executor.js +985 -0
- package/dist/runtime-profile.d.ts +116 -0
- package/dist/runtime-profile.js +532 -0
- package/dist/runtime-tool-specs.d.ts +68 -0
- package/dist/runtime-tool-specs.js +527 -0
- package/dist/safe-edit.d.ts +52 -0
- package/dist/safe-edit.js +255 -0
- package/dist/schemas.d.ts +44 -0
- package/dist/schemas.js +830 -0
- package/dist/semantic-cache.d.ts +147 -0
- package/dist/semantic-cache.js +552 -0
- package/dist/semantic-hash.d.ts +83 -0
- package/dist/semantic-hash.js +346 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.js +46 -0
- package/dist/shared.d.ts +136 -0
- package/dist/shared.js +269 -0
- package/dist/skill-auditor.d.ts +26 -0
- package/dist/skill-auditor.js +184 -0
- package/dist/skill-catalog.d.ts +60 -0
- package/dist/skill-catalog.js +305 -0
- package/dist/status-events.d.ts +40 -0
- package/dist/status-events.js +269 -0
- package/dist/store/ace-packed-store.d.ts +69 -0
- package/dist/store/ace-packed-store.js +434 -0
- package/dist/store/bootstrap-store.d.ts +46 -0
- package/dist/store/bootstrap-store.js +242 -0
- package/dist/store/catalog-builder.d.ts +21 -0
- package/dist/store/catalog-builder.js +68 -0
- package/dist/store/importer.d.ts +19 -0
- package/dist/store/importer.js +157 -0
- package/dist/store/knowledge-bake.d.ts +59 -0
- package/dist/store/knowledge-bake.js +339 -0
- package/dist/store/materializers/hook-context-materializer.d.ts +25 -0
- package/dist/store/materializers/hook-context-materializer.js +100 -0
- package/dist/store/materializers/host-file-materializer.d.ts +37 -0
- package/dist/store/materializers/host-file-materializer.js +271 -0
- package/dist/store/materializers/todo-syncer.d.ts +30 -0
- package/dist/store/materializers/todo-syncer.js +140 -0
- package/dist/store/materializers/vericify-projector.d.ts +38 -0
- package/dist/store/materializers/vericify-projector.js +239 -0
- package/dist/store/repositories/discovery-repository.d.ts +24 -0
- package/dist/store/repositories/discovery-repository.js +58 -0
- package/dist/store/repositories/handoff-repository.d.ts +31 -0
- package/dist/store/repositories/handoff-repository.js +67 -0
- package/dist/store/repositories/ledger-repository.d.ts +26 -0
- package/dist/store/repositories/ledger-repository.js +49 -0
- package/dist/store/repositories/runtime-kv-repository.d.ts +16 -0
- package/dist/store/repositories/runtime-kv-repository.js +36 -0
- package/dist/store/repositories/scheduler-repository.d.ts +50 -0
- package/dist/store/repositories/scheduler-repository.js +123 -0
- package/dist/store/repositories/session-repository.d.ts +33 -0
- package/dist/store/repositories/session-repository.js +82 -0
- package/dist/store/repositories/todo-repository.d.ts +31 -0
- package/dist/store/repositories/todo-repository.js +77 -0
- package/dist/store/repositories/tracker-repository.d.ts +25 -0
- package/dist/store/repositories/tracker-repository.js +43 -0
- package/dist/store/repositories/vericify-repository.d.ts +32 -0
- package/dist/store/repositories/vericify-repository.js +58 -0
- package/dist/store/skills-install.d.ts +28 -0
- package/dist/store/skills-install.js +86 -0
- package/dist/store/state-reader.d.ts +49 -0
- package/dist/store/state-reader.js +111 -0
- package/dist/store/store-artifacts.d.ts +12 -0
- package/dist/store/store-artifacts.js +138 -0
- package/dist/store/store-snapshot.d.ts +19 -0
- package/dist/store/store-snapshot.js +140 -0
- package/dist/store/topology-bake.d.ts +15 -0
- package/dist/store/topology-bake.js +215 -0
- package/dist/store/types.d.ts +155 -0
- package/dist/store/types.js +35 -0
- package/dist/store/workspace-snapshot.d.ts +26 -0
- package/dist/store/workspace-snapshot.js +107 -0
- package/dist/store/write-queue.d.ts +7 -0
- package/dist/store/write-queue.js +26 -0
- package/dist/todo-state.d.ts +41 -0
- package/dist/todo-state.js +399 -0
- package/dist/tools-agent.d.ts +7 -0
- package/dist/tools-agent.js +1542 -0
- package/dist/tools-discovery.d.ts +6 -0
- package/dist/tools-discovery.js +178 -0
- package/dist/tools-drift.d.ts +13 -0
- package/dist/tools-drift.js +357 -0
- package/dist/tools-files.d.ts +6 -0
- package/dist/tools-files.js +679 -0
- package/dist/tools-framework.d.ts +7 -0
- package/dist/tools-framework.js +1414 -0
- package/dist/tools-git.d.ts +6 -0
- package/dist/tools-git.js +183 -0
- package/dist/tools-handoff.d.ts +32 -0
- package/dist/tools-handoff.js +489 -0
- package/dist/tools-lifecycle.d.ts +6 -0
- package/dist/tools-lifecycle.js +205 -0
- package/dist/tools-memory.d.ts +6 -0
- package/dist/tools-memory.js +260 -0
- package/dist/tools-scheduler.d.ts +6 -0
- package/dist/tools-scheduler.js +228 -0
- package/dist/tools-skills.d.ts +3 -0
- package/dist/tools-skills.js +104 -0
- package/dist/tools-todo.d.ts +6 -0
- package/dist/tools-todo.js +154 -0
- package/dist/tools.d.ts +9 -0
- package/dist/tools.js +33 -0
- package/dist/tracker-adapters.d.ts +74 -0
- package/dist/tracker-adapters.js +776 -0
- package/dist/tracker-sync.d.ts +10 -0
- package/dist/tracker-sync.js +84 -0
- package/dist/tui/agent-runner.d.ts +137 -0
- package/dist/tui/agent-runner.js +466 -0
- package/dist/tui/agent-worker.d.ts +10 -0
- package/dist/tui/agent-worker.js +347 -0
- package/dist/tui/chat.d.ts +84 -0
- package/dist/tui/chat.js +368 -0
- package/dist/tui/commands.d.ts +57 -0
- package/dist/tui/commands.js +432 -0
- package/dist/tui/dashboard.d.ts +24 -0
- package/dist/tui/dashboard.js +110 -0
- package/dist/tui/index.d.ts +114 -0
- package/dist/tui/index.js +1059 -0
- package/dist/tui/input.d.ts +49 -0
- package/dist/tui/input.js +336 -0
- package/dist/tui/layout.d.ts +116 -0
- package/dist/tui/layout.js +367 -0
- package/dist/tui/ollama.d.ts +116 -0
- package/dist/tui/ollama.js +192 -0
- package/dist/tui/openai-compatible.d.ts +63 -0
- package/dist/tui/openai-compatible.js +370 -0
- package/dist/tui/provider-discovery.d.ts +59 -0
- package/dist/tui/provider-discovery.js +530 -0
- package/dist/tui/renderer.d.ts +166 -0
- package/dist/tui/renderer.js +304 -0
- package/dist/tui/tabs.d.ts +70 -0
- package/dist/tui/tabs.js +208 -0
- package/dist/tui/telemetry.d.ts +56 -0
- package/dist/tui/telemetry.js +106 -0
- package/dist/vericify-bridge.d.ts +146 -0
- package/dist/vericify-bridge.js +571 -0
- package/dist/vericify-context.d.ts +10 -0
- package/dist/vericify-context.js +72 -0
- package/dist/workspace-manager.d.ts +107 -0
- package/dist/workspace-manager.js +636 -0
- package/package.json +83 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type ArtifactSource } from "./helpers.js";
|
|
2
|
+
import { type ValidationResult } from "./schemas.js";
|
|
3
|
+
export declare const RUNTIME_TOOL_SPEC_REGISTRY_REL_PATH = "agent-state/runtime-tool-specs.json";
|
|
4
|
+
export declare const RUNTIME_TOOL_SPEC_SCHEMA_REL_PATH = "agent-state/MODULES/schemas/RUNTIME_TOOL_SPEC_REGISTRY.schema.json";
|
|
5
|
+
export declare const RUNTIME_TOOL_SPEC_SCHEMA_NAME = "runtime-tool-spec-registry@1.0.0";
|
|
6
|
+
type JsonSchemaScalar = string | number | boolean | null;
|
|
7
|
+
export type RuntimeToolSchemaType = "object" | "array" | "string" | "number" | "integer" | "boolean" | "null";
|
|
8
|
+
export interface RuntimeToolSchema {
|
|
9
|
+
type: RuntimeToolSchemaType;
|
|
10
|
+
description?: string;
|
|
11
|
+
enum?: JsonSchemaScalar[];
|
|
12
|
+
properties?: Record<string, RuntimeToolSchema>;
|
|
13
|
+
required?: string[];
|
|
14
|
+
additionalProperties?: boolean;
|
|
15
|
+
items?: RuntimeToolSchema;
|
|
16
|
+
}
|
|
17
|
+
export interface RuntimeToolExecutorConfig {
|
|
18
|
+
command: string;
|
|
19
|
+
cwd?: string;
|
|
20
|
+
timeout_ms?: number;
|
|
21
|
+
env?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface RuntimeToolSpec {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
input_schema: RuntimeToolSchema;
|
|
27
|
+
success_schema?: RuntimeToolSchema;
|
|
28
|
+
failure_schema?: RuntimeToolSchema;
|
|
29
|
+
executor: RuntimeToolExecutorConfig;
|
|
30
|
+
}
|
|
31
|
+
export interface RuntimeToolSpecRegistry {
|
|
32
|
+
version: 1;
|
|
33
|
+
updated_at: string;
|
|
34
|
+
tools: RuntimeToolSpec[];
|
|
35
|
+
}
|
|
36
|
+
export interface RuntimeToolSpecRegistryResult {
|
|
37
|
+
ok: boolean;
|
|
38
|
+
schema: typeof RUNTIME_TOOL_SPEC_SCHEMA_NAME;
|
|
39
|
+
path: string;
|
|
40
|
+
source: ArtifactSource;
|
|
41
|
+
registry?: RuntimeToolSpecRegistry;
|
|
42
|
+
errors?: string[];
|
|
43
|
+
}
|
|
44
|
+
export interface RuntimeToolExecutionContext {
|
|
45
|
+
session_id?: string;
|
|
46
|
+
workspace_path?: string;
|
|
47
|
+
turn_number?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface RuntimeToolExecutionResult {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
name: string;
|
|
52
|
+
summary: string;
|
|
53
|
+
request_path: string;
|
|
54
|
+
response_path: string;
|
|
55
|
+
exit_code?: number | null;
|
|
56
|
+
duration_ms?: number;
|
|
57
|
+
output?: unknown;
|
|
58
|
+
error?: unknown;
|
|
59
|
+
validation_errors?: string[];
|
|
60
|
+
}
|
|
61
|
+
export declare function validateRuntimeToolRegistryContent(raw: string): ValidationResult;
|
|
62
|
+
export declare function loadRuntimeToolRegistry(explicitPath?: string): RuntimeToolSpecRegistryResult;
|
|
63
|
+
export declare function readRuntimeToolRegistry(): RuntimeToolSpecRegistry;
|
|
64
|
+
export declare function listRuntimeToolSpecs(): RuntimeToolSpec[];
|
|
65
|
+
export declare function getRuntimeToolRegistryPath(): string;
|
|
66
|
+
export declare function executeRuntimeTool(name: string, input: unknown, context?: RuntimeToolExecutionContext): Promise<RuntimeToolExecutionResult>;
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=runtime-tool-specs.d.ts.map
|
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, mkdtempSync, rmSync, writeFileSync, } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { DEFAULTS_ROOT, resolveWorkspaceArtifactPath as resolveWorkspaceArtifactPathHelper, resolveWorkspaceRoot, } from "./helpers.js";
|
|
7
|
+
import { appendRunLedgerEntrySafe } from "./run-ledger.js";
|
|
8
|
+
import { runShellCommand } from "./runtime-command.js";
|
|
9
|
+
import { readRuntimeProfile } from "./runtime-profile.js";
|
|
10
|
+
import { validateRuntimeToolSpecRegistryPayload, } from "./schemas.js";
|
|
11
|
+
import { appendStatusEventSafe } from "./status-events.js";
|
|
12
|
+
import { openStore } from "./store/ace-packed-store.js";
|
|
13
|
+
import { getWorkspaceStorePath, readStoreBlobSync, storeExistsSync, toVirtualStorePath, } from "./store/store-snapshot.js";
|
|
14
|
+
import { operationalArtifactKey, } from "./store/store-artifacts.js";
|
|
15
|
+
import { withStoreWriteQueue } from "./store/write-queue.js";
|
|
16
|
+
export const RUNTIME_TOOL_SPEC_REGISTRY_REL_PATH = "agent-state/runtime-tool-specs.json";
|
|
17
|
+
export const RUNTIME_TOOL_SPEC_SCHEMA_REL_PATH = "agent-state/MODULES/schemas/RUNTIME_TOOL_SPEC_REGISTRY.schema.json";
|
|
18
|
+
export const RUNTIME_TOOL_SPEC_SCHEMA_NAME = "runtime-tool-spec-registry@1.0.0";
|
|
19
|
+
const DEFAULT_RUNTIME_TOOL_SPEC_REGISTRY_PATH = resolve(DEFAULTS_ROOT, RUNTIME_TOOL_SPEC_REGISTRY_REL_PATH);
|
|
20
|
+
const runtimeToolResponseSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
ok: z.boolean(),
|
|
23
|
+
summary: z.string().optional(),
|
|
24
|
+
output: z.unknown().optional(),
|
|
25
|
+
error: z.unknown().optional(),
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
function defaultRegistry() {
|
|
29
|
+
return {
|
|
30
|
+
version: 1,
|
|
31
|
+
updated_at: "1970-01-01T00:00:00.000Z",
|
|
32
|
+
tools: [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function normalizeSource(path) {
|
|
36
|
+
return path === DEFAULT_RUNTIME_TOOL_SPEC_REGISTRY_PATH || path.startsWith(DEFAULTS_ROOT)
|
|
37
|
+
? "package-defaults"
|
|
38
|
+
: "workspace";
|
|
39
|
+
}
|
|
40
|
+
function configuredRegistryRelativePath() {
|
|
41
|
+
const configured = readRuntimeProfile().tools?.registry_path;
|
|
42
|
+
return typeof configured === "string" && configured.trim().length > 0
|
|
43
|
+
? configured.trim()
|
|
44
|
+
: RUNTIME_TOOL_SPEC_REGISTRY_REL_PATH;
|
|
45
|
+
}
|
|
46
|
+
function resolveRuntimeToolRegistryTarget(explicitPath) {
|
|
47
|
+
const relativePath = explicitPath?.trim() || configuredRegistryRelativePath();
|
|
48
|
+
const workspaceRoot = resolveWorkspaceRoot();
|
|
49
|
+
const storePath = getWorkspaceStorePath(workspaceRoot);
|
|
50
|
+
const operationalKey = !relativePath.startsWith("/")
|
|
51
|
+
? operationalArtifactKey(relativePath)
|
|
52
|
+
: undefined;
|
|
53
|
+
const resolved = relativePath.startsWith("/")
|
|
54
|
+
? resolve(relativePath)
|
|
55
|
+
: resolveWorkspaceArtifactPathHelper(relativePath, "read");
|
|
56
|
+
const defaultWorkspacePath = resolveWorkspaceArtifactPathHelper(RUNTIME_TOOL_SPEC_REGISTRY_REL_PATH, "read");
|
|
57
|
+
if (existsSync(resolved)) {
|
|
58
|
+
return { path: resolved, source: normalizeSource(resolved), mode: "file" };
|
|
59
|
+
}
|
|
60
|
+
if (operationalKey && readStoreBlobSync(workspaceRoot, operationalKey)) {
|
|
61
|
+
return {
|
|
62
|
+
path: toVirtualStorePath(storePath, operationalKey),
|
|
63
|
+
source: "store",
|
|
64
|
+
mode: "store",
|
|
65
|
+
key: operationalKey,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const knowledgeKey = !relativePath.startsWith("/") && relativePath === RUNTIME_TOOL_SPEC_REGISTRY_REL_PATH
|
|
69
|
+
? "knowledge/agent-state/runtime-tool-specs.json"
|
|
70
|
+
: undefined;
|
|
71
|
+
if (knowledgeKey && readStoreBlobSync(workspaceRoot, knowledgeKey)) {
|
|
72
|
+
return {
|
|
73
|
+
path: toVirtualStorePath(storePath, knowledgeKey),
|
|
74
|
+
source: "store",
|
|
75
|
+
mode: "store",
|
|
76
|
+
key: knowledgeKey,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (resolved === defaultWorkspacePath) {
|
|
80
|
+
return {
|
|
81
|
+
path: DEFAULT_RUNTIME_TOOL_SPEC_REGISTRY_PATH,
|
|
82
|
+
source: "package-defaults",
|
|
83
|
+
mode: "file",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return { path: resolved, source: "workspace", mode: "file" };
|
|
87
|
+
}
|
|
88
|
+
function resolveWorkspaceArtifactPath(filePath) {
|
|
89
|
+
return resolveWorkspaceArtifactPathHelper(filePath, "write");
|
|
90
|
+
}
|
|
91
|
+
function buildTempToolPaths(callId) {
|
|
92
|
+
const tempDir = mkdtempSync(join(tmpdir(), `ace-runtime-tool-${callId}-`));
|
|
93
|
+
return {
|
|
94
|
+
tempDir,
|
|
95
|
+
requestPath: join(tempDir, "request.json"),
|
|
96
|
+
responsePath: join(tempDir, "response.json"),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function runtimeToolArtifactKey(callId, kind) {
|
|
100
|
+
return `state/runtime/tools/invocations/${callId}/${kind}.json`;
|
|
101
|
+
}
|
|
102
|
+
function runtimeToolArtifactVirtualPath(callId, kind) {
|
|
103
|
+
return toVirtualStorePath(getWorkspaceStorePath(resolveWorkspaceRoot()), runtimeToolArtifactKey(callId, kind));
|
|
104
|
+
}
|
|
105
|
+
async function persistToolInvocationArtifacts(callId, requestContent, responseContent) {
|
|
106
|
+
const workspaceRoot = resolveWorkspaceRoot();
|
|
107
|
+
if (!storeExistsSync(workspaceRoot)) {
|
|
108
|
+
const requestPath = resolveWorkspaceArtifactPath(`.ace-runtime/tools/${callId}.request.json`);
|
|
109
|
+
const responsePath = resolveWorkspaceArtifactPath(`.ace-runtime/tools/${callId}.response.json`);
|
|
110
|
+
mkdirSync(dirname(requestPath), { recursive: true });
|
|
111
|
+
writeFileSync(requestPath, requestContent, "utf-8");
|
|
112
|
+
writeFileSync(responsePath, responseContent, "utf-8");
|
|
113
|
+
return { requestPath, responsePath };
|
|
114
|
+
}
|
|
115
|
+
const storePath = getWorkspaceStorePath(workspaceRoot);
|
|
116
|
+
await withStoreWriteQueue(storePath, async () => {
|
|
117
|
+
const store = await openStore(storePath);
|
|
118
|
+
try {
|
|
119
|
+
await store.setBlob(runtimeToolArtifactKey(callId, "request"), requestContent);
|
|
120
|
+
await store.setBlob(runtimeToolArtifactKey(callId, "response"), responseContent);
|
|
121
|
+
await store.commit();
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
await store.close();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
requestPath: runtimeToolArtifactVirtualPath(callId, "request"),
|
|
129
|
+
responsePath: runtimeToolArtifactVirtualPath(callId, "response"),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function parseRuntimeToolRegistry(raw) {
|
|
133
|
+
let parsed;
|
|
134
|
+
try {
|
|
135
|
+
parsed = JSON.parse(raw);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
throw new Error(`Runtime tool registry contains invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
139
|
+
}
|
|
140
|
+
const validation = validateRuntimeToolSpecRegistryPayload(parsed);
|
|
141
|
+
if (!validation.ok) {
|
|
142
|
+
throw new Error(`Runtime tool registry failed validation (${validation.schema}): ${validation.errors.join("; ")}`);
|
|
143
|
+
}
|
|
144
|
+
return parsed;
|
|
145
|
+
}
|
|
146
|
+
function ensureToolSpec(spec, name) {
|
|
147
|
+
if (spec)
|
|
148
|
+
return spec;
|
|
149
|
+
throw new Error(`Unknown runtime tool spec: ${name}`);
|
|
150
|
+
}
|
|
151
|
+
function isPlainObject(value) {
|
|
152
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
153
|
+
}
|
|
154
|
+
function validateEnum(schema, value, path) {
|
|
155
|
+
if (!schema.enum || schema.enum.length === 0)
|
|
156
|
+
return [];
|
|
157
|
+
return schema.enum.some((entry) => Object.is(entry, value))
|
|
158
|
+
? []
|
|
159
|
+
: [`${path}: value must be one of ${schema.enum.map((entry) => JSON.stringify(entry)).join(", ")}`];
|
|
160
|
+
}
|
|
161
|
+
function validateValueAgainstSchema(schema, value, path) {
|
|
162
|
+
const enumErrors = validateEnum(schema, value, path);
|
|
163
|
+
if (enumErrors.length > 0)
|
|
164
|
+
return enumErrors;
|
|
165
|
+
switch (schema.type) {
|
|
166
|
+
case "object": {
|
|
167
|
+
if (!isPlainObject(value))
|
|
168
|
+
return [`${path}: expected object`];
|
|
169
|
+
const errors = [];
|
|
170
|
+
const properties = schema.properties ?? {};
|
|
171
|
+
const required = new Set(schema.required ?? []);
|
|
172
|
+
for (const key of required) {
|
|
173
|
+
if (!Object.prototype.hasOwnProperty.call(value, key)) {
|
|
174
|
+
errors.push(`${path}.${key}: required`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
for (const [key, childValue] of Object.entries(value)) {
|
|
178
|
+
const childSchema = properties[key];
|
|
179
|
+
if (!childSchema) {
|
|
180
|
+
if (schema.additionalProperties === false) {
|
|
181
|
+
errors.push(`${path}.${key}: additional properties are not allowed`);
|
|
182
|
+
}
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
errors.push(...validateValueAgainstSchema(childSchema, childValue, `${path}.${key}`));
|
|
186
|
+
}
|
|
187
|
+
return errors;
|
|
188
|
+
}
|
|
189
|
+
case "array": {
|
|
190
|
+
if (!Array.isArray(value))
|
|
191
|
+
return [`${path}: expected array`];
|
|
192
|
+
if (!schema.items)
|
|
193
|
+
return [];
|
|
194
|
+
return value.flatMap((entry, index) => validateValueAgainstSchema(schema.items, entry, `${path}[${index}]`));
|
|
195
|
+
}
|
|
196
|
+
case "string":
|
|
197
|
+
return typeof value === "string" ? [] : [`${path}: expected string`];
|
|
198
|
+
case "number":
|
|
199
|
+
return typeof value === "number" && Number.isFinite(value)
|
|
200
|
+
? []
|
|
201
|
+
: [`${path}: expected number`];
|
|
202
|
+
case "integer":
|
|
203
|
+
return typeof value === "number" && Number.isInteger(value)
|
|
204
|
+
? []
|
|
205
|
+
: [`${path}: expected integer`];
|
|
206
|
+
case "boolean":
|
|
207
|
+
return typeof value === "boolean" ? [] : [`${path}: expected boolean`];
|
|
208
|
+
case "null":
|
|
209
|
+
return value === null ? [] : [`${path}: expected null`];
|
|
210
|
+
default:
|
|
211
|
+
return [`${path}: unsupported schema type ${schema.type}`];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function emitRuntimeToolEvent(eventType, summary, payload) {
|
|
215
|
+
return appendStatusEventSafe({
|
|
216
|
+
source_module: "capability-framework",
|
|
217
|
+
event_type: eventType,
|
|
218
|
+
status: eventType === "RUNTIME_TOOL_EXECUTED" ? "done" : "fail",
|
|
219
|
+
summary,
|
|
220
|
+
payload,
|
|
221
|
+
}).then(() => undefined).catch(() => undefined);
|
|
222
|
+
}
|
|
223
|
+
export function validateRuntimeToolRegistryContent(raw) {
|
|
224
|
+
try {
|
|
225
|
+
parseRuntimeToolRegistry(raw);
|
|
226
|
+
return { ok: true, schema: RUNTIME_TOOL_SPEC_SCHEMA_NAME };
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
return {
|
|
230
|
+
ok: false,
|
|
231
|
+
schema: RUNTIME_TOOL_SPEC_SCHEMA_NAME,
|
|
232
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
export function loadRuntimeToolRegistry(explicitPath) {
|
|
237
|
+
const target = resolveRuntimeToolRegistryTarget(explicitPath);
|
|
238
|
+
if (target.mode === "file" && !existsSync(target.path)) {
|
|
239
|
+
return {
|
|
240
|
+
ok: false,
|
|
241
|
+
schema: RUNTIME_TOOL_SPEC_SCHEMA_NAME,
|
|
242
|
+
path: target.path,
|
|
243
|
+
source: target.source,
|
|
244
|
+
errors: [`Runtime tool registry file not found: ${target.path}`],
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
const raw = target.mode === "store"
|
|
248
|
+
? (target.key ? readStoreBlobSync(resolveWorkspaceRoot(), target.key) : undefined) ?? ""
|
|
249
|
+
: readFileSync(target.path, "utf-8");
|
|
250
|
+
try {
|
|
251
|
+
const registry = parseRuntimeToolRegistry(raw);
|
|
252
|
+
return {
|
|
253
|
+
ok: true,
|
|
254
|
+
schema: RUNTIME_TOOL_SPEC_SCHEMA_NAME,
|
|
255
|
+
path: target.path,
|
|
256
|
+
source: target.source,
|
|
257
|
+
registry,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
void emitRuntimeToolEvent("RUNTIME_TOOL_REGISTRY_INVALID", `Runtime tool registry validation failed for ${target.path}`, {
|
|
262
|
+
path: target.path,
|
|
263
|
+
source: target.source,
|
|
264
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
265
|
+
});
|
|
266
|
+
return {
|
|
267
|
+
ok: false,
|
|
268
|
+
schema: RUNTIME_TOOL_SPEC_SCHEMA_NAME,
|
|
269
|
+
path: target.path,
|
|
270
|
+
source: target.source,
|
|
271
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
export function readRuntimeToolRegistry() {
|
|
276
|
+
const result = loadRuntimeToolRegistry();
|
|
277
|
+
if (result.ok && result.registry)
|
|
278
|
+
return result.registry;
|
|
279
|
+
if (result.source === "package-defaults")
|
|
280
|
+
return defaultRegistry();
|
|
281
|
+
throw new Error(result.errors?.join("; ") ?? "Runtime tool registry is unavailable.");
|
|
282
|
+
}
|
|
283
|
+
export function listRuntimeToolSpecs() {
|
|
284
|
+
return [...readRuntimeToolRegistry().tools].sort((a, b) => a.name.localeCompare(b.name));
|
|
285
|
+
}
|
|
286
|
+
export function getRuntimeToolRegistryPath() {
|
|
287
|
+
return loadRuntimeToolRegistry().path;
|
|
288
|
+
}
|
|
289
|
+
export async function executeRuntimeTool(name, input, context = {}) {
|
|
290
|
+
const registry = readRuntimeToolRegistry();
|
|
291
|
+
const spec = ensureToolSpec(registry.tools.find((tool) => tool.name === name), name);
|
|
292
|
+
const inputErrors = validateValueAgainstSchema(spec.input_schema, input, "input");
|
|
293
|
+
const workspacePath = context.workspace_path && context.workspace_path.trim().length > 0
|
|
294
|
+
? resolve(context.workspace_path)
|
|
295
|
+
: resolveWorkspaceRoot();
|
|
296
|
+
const callId = randomUUID();
|
|
297
|
+
const tempPaths = buildTempToolPaths(callId);
|
|
298
|
+
let requestPath = runtimeToolArtifactVirtualPath(callId, "request");
|
|
299
|
+
let responsePath = runtimeToolArtifactVirtualPath(callId, "response");
|
|
300
|
+
if (inputErrors.length > 0) {
|
|
301
|
+
const validationRequest = JSON.stringify({
|
|
302
|
+
tool: {
|
|
303
|
+
name: spec.name,
|
|
304
|
+
description: spec.description,
|
|
305
|
+
},
|
|
306
|
+
input,
|
|
307
|
+
session_id: context.session_id,
|
|
308
|
+
turn_number: context.turn_number,
|
|
309
|
+
workspace_path: workspacePath,
|
|
310
|
+
timestamp: new Date().toISOString(),
|
|
311
|
+
}, null, 2);
|
|
312
|
+
const validationResponse = JSON.stringify({
|
|
313
|
+
ok: false,
|
|
314
|
+
summary: `Input validation failed for runtime tool '${name}'`,
|
|
315
|
+
error: {
|
|
316
|
+
message: "Input validation failed",
|
|
317
|
+
},
|
|
318
|
+
validation_errors: inputErrors,
|
|
319
|
+
}, null, 2);
|
|
320
|
+
({ requestPath, responsePath } = await persistToolInvocationArtifacts(callId, validationRequest, validationResponse));
|
|
321
|
+
rmSync(tempPaths.tempDir, { recursive: true, force: true });
|
|
322
|
+
const result = {
|
|
323
|
+
ok: false,
|
|
324
|
+
name,
|
|
325
|
+
summary: `Input validation failed for runtime tool '${name}'`,
|
|
326
|
+
request_path: requestPath,
|
|
327
|
+
response_path: responsePath,
|
|
328
|
+
error: {
|
|
329
|
+
message: "Input validation failed",
|
|
330
|
+
},
|
|
331
|
+
validation_errors: inputErrors,
|
|
332
|
+
};
|
|
333
|
+
await appendRunLedgerEntrySafe({
|
|
334
|
+
tool: "runtime-tool-specs",
|
|
335
|
+
category: "regression",
|
|
336
|
+
message: result.summary,
|
|
337
|
+
artifacts: [],
|
|
338
|
+
metadata: {
|
|
339
|
+
tool_name: name,
|
|
340
|
+
validation_errors: inputErrors,
|
|
341
|
+
},
|
|
342
|
+
}).catch(() => undefined);
|
|
343
|
+
await emitRuntimeToolEvent("RUNTIME_TOOL_FAILED", result.summary, {
|
|
344
|
+
tool_name: name,
|
|
345
|
+
validation_errors: inputErrors,
|
|
346
|
+
session_id: context.session_id,
|
|
347
|
+
turn_number: context.turn_number,
|
|
348
|
+
});
|
|
349
|
+
return result;
|
|
350
|
+
}
|
|
351
|
+
const payload = {
|
|
352
|
+
tool: {
|
|
353
|
+
name: spec.name,
|
|
354
|
+
description: spec.description,
|
|
355
|
+
},
|
|
356
|
+
input,
|
|
357
|
+
session_id: context.session_id,
|
|
358
|
+
turn_number: context.turn_number,
|
|
359
|
+
workspace_path: workspacePath,
|
|
360
|
+
timestamp: new Date().toISOString(),
|
|
361
|
+
};
|
|
362
|
+
const requestRaw = JSON.stringify(payload, null, 2);
|
|
363
|
+
writeFileSync(tempPaths.requestPath, requestRaw, "utf-8");
|
|
364
|
+
const cwdBase = spec.executor.cwd?.trim()
|
|
365
|
+
? resolve(spec.executor.cwd.startsWith("/")
|
|
366
|
+
? spec.executor.cwd
|
|
367
|
+
: resolve(workspacePath, spec.executor.cwd))
|
|
368
|
+
: workspacePath;
|
|
369
|
+
const shellResult = await runShellCommand(spec.executor.command, {
|
|
370
|
+
cwd: cwdBase,
|
|
371
|
+
env: {
|
|
372
|
+
...process.env,
|
|
373
|
+
...(spec.executor.env ?? {}),
|
|
374
|
+
ACE_RUNTIME_TOOL_NAME: spec.name,
|
|
375
|
+
ACE_RUNTIME_TOOL_REQUEST_FILE: tempPaths.requestPath,
|
|
376
|
+
ACE_RUNTIME_TOOL_RESPONSE_FILE: tempPaths.responsePath,
|
|
377
|
+
ACE_RUNTIME_SESSION_ID: context.session_id ?? "",
|
|
378
|
+
ACE_RUNTIME_TURN: context.turn_number ? String(context.turn_number) : "",
|
|
379
|
+
ACE_RUNTIME_WORKSPACE_PATH: workspacePath,
|
|
380
|
+
},
|
|
381
|
+
timeout_ms: spec.executor.timeout_ms ?? 60_000,
|
|
382
|
+
});
|
|
383
|
+
let responseRaw;
|
|
384
|
+
if (existsSync(tempPaths.responsePath)) {
|
|
385
|
+
responseRaw = readFileSync(tempPaths.responsePath, "utf-8");
|
|
386
|
+
}
|
|
387
|
+
if (!responseRaw) {
|
|
388
|
+
const summary = `Runtime tool '${name}' did not produce a response payload`;
|
|
389
|
+
({ requestPath, responsePath } = await persistToolInvocationArtifacts(callId, requestRaw, JSON.stringify({
|
|
390
|
+
ok: false,
|
|
391
|
+
summary,
|
|
392
|
+
error: {
|
|
393
|
+
message: summary,
|
|
394
|
+
stdout: shellResult.stdout,
|
|
395
|
+
stderr: shellResult.stderr,
|
|
396
|
+
},
|
|
397
|
+
}, null, 2)));
|
|
398
|
+
const result = {
|
|
399
|
+
ok: false,
|
|
400
|
+
name,
|
|
401
|
+
summary,
|
|
402
|
+
request_path: requestPath,
|
|
403
|
+
response_path: responsePath,
|
|
404
|
+
exit_code: shellResult.exit_code,
|
|
405
|
+
duration_ms: shellResult.duration_ms,
|
|
406
|
+
error: {
|
|
407
|
+
message: summary,
|
|
408
|
+
stdout: shellResult.stdout,
|
|
409
|
+
stderr: shellResult.stderr,
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
await appendRunLedgerEntrySafe({
|
|
413
|
+
tool: "runtime-tool-specs",
|
|
414
|
+
category: "regression",
|
|
415
|
+
message: summary,
|
|
416
|
+
artifacts: [requestPath],
|
|
417
|
+
metadata: {
|
|
418
|
+
tool_name: name,
|
|
419
|
+
exit_code: shellResult.exit_code,
|
|
420
|
+
timed_out: shellResult.timed_out,
|
|
421
|
+
},
|
|
422
|
+
}).catch(() => undefined);
|
|
423
|
+
await emitRuntimeToolEvent("RUNTIME_TOOL_FAILED", summary, {
|
|
424
|
+
tool_name: name,
|
|
425
|
+
exit_code: shellResult.exit_code,
|
|
426
|
+
timed_out: shellResult.timed_out,
|
|
427
|
+
session_id: context.session_id,
|
|
428
|
+
turn_number: context.turn_number,
|
|
429
|
+
});
|
|
430
|
+
rmSync(tempPaths.tempDir, { recursive: true, force: true });
|
|
431
|
+
return result;
|
|
432
|
+
}
|
|
433
|
+
let parsed;
|
|
434
|
+
try {
|
|
435
|
+
parsed = JSON.parse(responseRaw);
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
const summary = `Runtime tool '${name}' returned invalid JSON`;
|
|
439
|
+
({ requestPath, responsePath } = await persistToolInvocationArtifacts(callId, requestRaw, responseRaw));
|
|
440
|
+
await emitRuntimeToolEvent("RUNTIME_TOOL_FAILED", summary, {
|
|
441
|
+
tool_name: name,
|
|
442
|
+
error: error instanceof Error ? error.message : String(error),
|
|
443
|
+
});
|
|
444
|
+
rmSync(tempPaths.tempDir, { recursive: true, force: true });
|
|
445
|
+
return {
|
|
446
|
+
ok: false,
|
|
447
|
+
name,
|
|
448
|
+
summary,
|
|
449
|
+
request_path: requestPath,
|
|
450
|
+
response_path: responsePath,
|
|
451
|
+
exit_code: shellResult.exit_code,
|
|
452
|
+
duration_ms: shellResult.duration_ms,
|
|
453
|
+
error: {
|
|
454
|
+
message: error instanceof Error ? error.message : String(error),
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
const envelope = runtimeToolResponseSchema.safeParse(parsed);
|
|
459
|
+
if (!envelope.success) {
|
|
460
|
+
const summary = `Runtime tool '${name}' returned an invalid response envelope`;
|
|
461
|
+
({ requestPath, responsePath } = await persistToolInvocationArtifacts(callId, requestRaw, responseRaw));
|
|
462
|
+
rmSync(tempPaths.tempDir, { recursive: true, force: true });
|
|
463
|
+
return {
|
|
464
|
+
ok: false,
|
|
465
|
+
name,
|
|
466
|
+
summary,
|
|
467
|
+
request_path: requestPath,
|
|
468
|
+
response_path: responsePath,
|
|
469
|
+
exit_code: shellResult.exit_code,
|
|
470
|
+
duration_ms: shellResult.duration_ms,
|
|
471
|
+
error: {
|
|
472
|
+
message: envelope.error.issues.map((issue) => issue.message).join("; "),
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
const validationErrors = envelope.data.ok
|
|
477
|
+
? spec.success_schema
|
|
478
|
+
? validateValueAgainstSchema(spec.success_schema, envelope.data.output, "output")
|
|
479
|
+
: []
|
|
480
|
+
: spec.failure_schema
|
|
481
|
+
? validateValueAgainstSchema(spec.failure_schema, envelope.data.error, "error")
|
|
482
|
+
: [];
|
|
483
|
+
const success = envelope.data.ok && validationErrors.length === 0;
|
|
484
|
+
const summary = envelope.data.summary ??
|
|
485
|
+
(success ? `Runtime tool '${name}' executed successfully` : `Runtime tool '${name}' failed`);
|
|
486
|
+
({ requestPath, responsePath } = await persistToolInvocationArtifacts(callId, requestRaw, responseRaw));
|
|
487
|
+
rmSync(tempPaths.tempDir, { recursive: true, force: true });
|
|
488
|
+
const result = {
|
|
489
|
+
ok: success,
|
|
490
|
+
name,
|
|
491
|
+
summary,
|
|
492
|
+
request_path: requestPath,
|
|
493
|
+
response_path: responsePath,
|
|
494
|
+
exit_code: shellResult.exit_code,
|
|
495
|
+
duration_ms: shellResult.duration_ms,
|
|
496
|
+
output: envelope.data.ok ? envelope.data.output : undefined,
|
|
497
|
+
error: envelope.data.ok ? undefined : envelope.data.error,
|
|
498
|
+
validation_errors: validationErrors.length > 0 ? validationErrors : undefined,
|
|
499
|
+
};
|
|
500
|
+
await appendRunLedgerEntrySafe({
|
|
501
|
+
tool: "runtime-tool-specs",
|
|
502
|
+
category: success ? "info" : "regression",
|
|
503
|
+
message: summary,
|
|
504
|
+
artifacts: [requestPath, responsePath],
|
|
505
|
+
metadata: {
|
|
506
|
+
tool_name: name,
|
|
507
|
+
exit_code: shellResult.exit_code,
|
|
508
|
+
duration_ms: shellResult.duration_ms,
|
|
509
|
+
timed_out: shellResult.timed_out,
|
|
510
|
+
session_id: context.session_id,
|
|
511
|
+
turn_number: context.turn_number,
|
|
512
|
+
validation_errors: validationErrors,
|
|
513
|
+
},
|
|
514
|
+
}).catch(() => undefined);
|
|
515
|
+
await emitRuntimeToolEvent(success ? "RUNTIME_TOOL_EXECUTED" : "RUNTIME_TOOL_FAILED", summary, {
|
|
516
|
+
tool_name: name,
|
|
517
|
+
request_path: requestPath,
|
|
518
|
+
response_path: responsePath,
|
|
519
|
+
exit_code: shellResult.exit_code,
|
|
520
|
+
timed_out: shellResult.timed_out,
|
|
521
|
+
session_id: context.session_id,
|
|
522
|
+
turn_number: context.turn_number,
|
|
523
|
+
validation_errors: validationErrors,
|
|
524
|
+
});
|
|
525
|
+
return result;
|
|
526
|
+
}
|
|
527
|
+
//# sourceMappingURL=runtime-tool-specs.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe-edit module: copy → modify → validate → swap pattern.
|
|
3
|
+
* Prevents bricking by never leaving core files in a broken state.
|
|
4
|
+
*/
|
|
5
|
+
export interface SafeEditInput {
|
|
6
|
+
/** Workspace-relative path to edit. */
|
|
7
|
+
path: string;
|
|
8
|
+
/** New file content. */
|
|
9
|
+
content: string;
|
|
10
|
+
/** Shell command to validate the change (e.g., "npx tsc --noEmit"). */
|
|
11
|
+
validation_command?: string;
|
|
12
|
+
/** Shell command to run tests (e.g., "npm test"). */
|
|
13
|
+
test_command?: string;
|
|
14
|
+
/** Whether to keep a .ace-backup copy (default: true). */
|
|
15
|
+
backup?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface SafeEditResult {
|
|
18
|
+
ok: boolean;
|
|
19
|
+
original_path: string;
|
|
20
|
+
staging_path: string;
|
|
21
|
+
backup_path?: string;
|
|
22
|
+
original_hash: string;
|
|
23
|
+
new_hash: string;
|
|
24
|
+
validation_passed?: boolean;
|
|
25
|
+
validation_output?: string;
|
|
26
|
+
test_passed?: boolean;
|
|
27
|
+
test_output?: string;
|
|
28
|
+
error?: string;
|
|
29
|
+
restored?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface TestSuiteResult {
|
|
32
|
+
ok: boolean;
|
|
33
|
+
exit_code: number;
|
|
34
|
+
output: string;
|
|
35
|
+
command: string;
|
|
36
|
+
duration_ms: number;
|
|
37
|
+
}
|
|
38
|
+
export interface DiffResult {
|
|
39
|
+
has_diff: boolean;
|
|
40
|
+
original_lines: number;
|
|
41
|
+
new_lines: number;
|
|
42
|
+
added: number;
|
|
43
|
+
removed: number;
|
|
44
|
+
diff_summary: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function safeEditFile(input: SafeEditInput): SafeEditResult;
|
|
47
|
+
export declare function runTestSuite(command?: string): TestSuiteResult;
|
|
48
|
+
export declare function diffContents(original: string, updated: string): DiffResult;
|
|
49
|
+
export declare function diffFiles(pathA: string, pathB: string): DiffResult & {
|
|
50
|
+
error?: string;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=safe-edit.d.ts.map
|