@loucompanion/forge-bridge 0.1.4-dev.8901ba056f68 → 0.1.4-dev.894bcbd53d64
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/README.md +142 -1
- package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
- package/dist/bridge/bridge-chat-provider-command.js +132 -0
- package/dist/bridge/bridge-chat.types.d.ts +10 -0
- package/dist/bridge/bridge-chat.types.js +16 -1
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +11 -0
- package/dist/bridge/bridge-state-io.js +50 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +87 -14
- package/dist/bridge/bridge.service.js +394 -338
- package/dist/bridge/bridge.types.d.ts +16 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.d.ts +3 -0
- package/dist/bridge/runner-host-capabilities.js +13 -0
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +20 -1
- package/dist/cleanup/cleanup.service.js +150 -169
- package/dist/cleanup/cleanup.types.d.ts +6 -0
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
- package/dist/cleanup/host-runtime-ledger.js +130 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +74 -12
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +149 -186
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +6 -0
- package/dist/cli/local-config.js +32 -4
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/attempt-node-runtime-launcher.js +9 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
- package/dist/runtime/attempt-process-supervisor.js +12 -6
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
- package/dist/runtime/dotnet-build-outputs.js +402 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-facts.d.ts +2 -1
- package/dist/runtime/host-load-admission.d.ts +18 -3
- package/dist/runtime/host-load-admission.js +19 -4
- package/dist/runtime/host-load-child-environment.d.ts +11 -6
- package/dist/runtime/host-load-child-environment.js +22 -11
- package/dist/runtime/host-load-governor-config.d.ts +19 -1
- package/dist/runtime/host-load-governor-config.js +37 -0
- package/dist/runtime/host-load-governor.d.ts +14 -0
- package/dist/runtime/host-load-governor.js +139 -26
- package/dist/runtime/host-load-ledger-lock.js +6 -4
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +34 -4
- package/dist/runtime/host-load-sampler.js +73 -7
- package/dist/runtime/host-load-step-class.d.ts +3 -1
- package/dist/runtime/host-load-step-class.js +60 -5
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +81 -0
- package/dist/runtime/host-load-token-ledger.d.ts +26 -0
- package/dist/runtime/host-load-token-ledger.js +93 -61
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-runtime-contract.d.ts +12 -0
- package/dist/runtime/host-runtime-contract.js +29 -1
- package/dist/runtime/host-runtime-lease.d.ts +59 -3
- package/dist/runtime/host-runtime-lease.js +212 -61
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +36 -0
- package/dist/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -0
- package/dist/sandbox/host-capacity-broker.d.ts +10 -2
- package/dist/sandbox/host-capacity-broker.js +27 -6
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +90 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.js +2 -6
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -7
- package/dist/session/managed-attempt-tools.js +94 -104
- package/dist/session/managed-build-coordinator.d.ts +16 -0
- package/dist/session/managed-build-coordinator.js +10 -0
- package/dist/session/managed-build-receipt.d.ts +5 -0
- package/dist/session/managed-build-receipt.js +8 -3
- package/dist/session/managed-command-host-load.d.ts +2 -0
- package/dist/session/managed-command-host-load.js +2 -1
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +7 -0
- package/dist/session/phase-completion.artifacts.js +96 -26
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +10 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +5 -0
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +4 -10
- package/dist/session/phase-completion.runtime.js +77 -209
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +208 -231
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +49 -93
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-process.js +10 -10
- package/dist/session/pre-publication-step-execution.d.ts +2 -1
- package/dist/session/pre-publication-step-execution.js +6 -5
- package/dist/session/pre-publication-validation.d.ts +30 -14
- package/dist/session/pre-publication-validation.js +207 -134
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +39 -430
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +72 -32
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +29 -1
- package/dist/session/provider-cli/provider-cli.service.d.ts +7 -1
- package/dist/session/provider-cli/provider-cli.service.js +78 -171
- package/dist/session/provider-cli/provider-cli.types.d.ts +26 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +22 -1
- package/dist/session/sandbox-host-capacity-gate.js +42 -14
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +6 -1
- package/dist/session/session.service.d.ts +9 -2
- package/dist/session/session.service.js +169 -66
- package/dist/session/session.types.js +4 -4
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +13 -1
- package/dist/shared/process/host-process-supervisor.js +66 -14
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.js +14 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/orphan-relink.d.ts +19 -0
- package/dist/worktree/orphan-relink.js +106 -0
- package/dist/worktree/wip-git.d.ts +33 -0
- package/dist/worktree/wip-git.js +122 -0
- package/dist/worktree/wip-refs.d.ts +62 -0
- package/dist/worktree/wip-refs.js +119 -0
- package/dist/worktree/wip-restore.d.ts +38 -0
- package/dist/worktree/wip-restore.js +190 -0
- package/dist/worktree/wip-snapshot.d.ts +50 -0
- package/dist/worktree/wip-snapshot.js +268 -0
- package/dist/worktree/worktree-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +34 -0
- package/dist/worktree/worktree-origin-sync.js +127 -0
- package/dist/worktree/worktree-wip-events.d.ts +18 -0
- package/dist/worktree/worktree-wip-events.js +98 -0
- package/dist/worktree/worktree-wip.d.ts +50 -0
- package/dist/worktree/worktree-wip.js +185 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +31 -5
- package/dist/worktree/worktree.service.js +120 -163
- package/dist/worktree/worktree.types.d.ts +31 -0
- package/package.json +2 -2
|
@@ -76,6 +76,7 @@ Complete the Draft cycle in order inside this same provider session:
|
|
|
76
76
|
5. Follow the returned draft-plan instruction, draft the requested final JSON shape for the current Draft kind, then call \`forge.complete_draft_work_order_plan(...)\`.
|
|
77
77
|
6. Follow the returned critic instruction, critique literalism, wrong-project scope, and decomposition quality, then call \`forge.complete_draft_critic(...)\`.
|
|
78
78
|
7. Follow the returned proposal instruction, then call \`forge.complete_draft_proposal(...)\` with the final Draft JSON payload in \`draft_json\`.
|
|
79
|
+
Every gate before the proposal needs a \`summary\` of what it checked or decided.
|
|
79
80
|
The final proposal tool writes \`draft.proposal.json\` under \`.forge/work-items/{workItemId}/artifacts/\`. Reporting Draft completion in prose is not enough.`;
|
|
80
81
|
}
|
|
81
82
|
export function completionPromptForDecomposeCycle(currentGate = "decompose_subject_intake") {
|
|
@@ -92,6 +93,7 @@ Required order:
|
|
|
92
93
|
5. Follow the returned dependency-graph instruction, validate keys/dependencies/order, then call \`forge.complete_decompose_dependency_graph(...)\`.
|
|
93
94
|
6. Follow the returned critic instruction, critique scope, DAG safety, manual reconciliation risk, and missing acceptance detail, then call \`forge.complete_decompose_critic(...)\`.
|
|
94
95
|
7. Follow the returned proposal instruction, then call \`forge.complete_decompose_proposal(...)\` with final JSON in \`proposal_json\`.
|
|
96
|
+
Every gate before the proposal needs a \`summary\` of what it checked or decided.
|
|
95
97
|
The final proposal tool writes \`decompose.proposal.json\` under \`.forge/work-items/{workItemId}/artifacts/\`. The proposal_json object must contain summary, optional blockedReason, and candidates. Work Order-to-Feature candidates may include \`estimated_qa_scope\`; Feature-to-Story candidates should include \`qa_scope\` with schema_version 1 plus scheduleIndex, waveIndex, expectedOutput, handoffSummary, and dependencyReason for dependency handoff. Set \`qa_scope.required_capabilities\` to \`["docker_engine"]\` when implementation or validation starts containers or needs a Docker daemon; repository-specific service and image versions do not belong in the runner capability name.`;
|
|
96
98
|
}
|
|
97
99
|
export function completionPromptForDebugCycle(currentGate = "debug_repro") {
|
|
@@ -144,6 +146,9 @@ export function completionToolNextInstructionForDraftGate(completedGate, status,
|
|
|
144
146
|
if (status === "blocked") {
|
|
145
147
|
return `Stay in ${completedGate}; record the blocker and retry the same Draft gate when unblocked.`;
|
|
146
148
|
}
|
|
149
|
+
if (status !== "pass") {
|
|
150
|
+
return `Stay in ${completedGate}; revise the work and call the same Draft gate again with status pass when it is complete.`;
|
|
151
|
+
}
|
|
147
152
|
if (!nextGate) {
|
|
148
153
|
return "Draft proposal accepted. Forge has the structured Work Order draft JSON needed to populate the form.";
|
|
149
154
|
}
|
|
@@ -216,7 +221,7 @@ export function completionToolNextInstructionForDebugGate(completedGate, status,
|
|
|
216
221
|
function qaGateInstruction(gate) {
|
|
217
222
|
switch (gate) {
|
|
218
223
|
case "qa_regression":
|
|
219
|
-
return "Run or explicitly skip applicable regression/build/lint/typecheck/e2e checks, then call forge.complete_qa_regression. For normal Story QA, prefer focused checks and runner-authored forge.start_managed_verification tier profiles; reserve dotnet_solution for shared infrastructure, Feature/PR integration, or an explicit plan requirement. Use forge.start_managed_command only for other commands expected to exceed two minutes, continue independent QA, then call forge.wait_managed_command and include its terminal managed_command_id in command evidence. If the wait returns command_continues=true, continue useful work or wait again after retry_after_ms; do not poll get_managed_command. Normalize negative assertions so an expected no-match exits 0. A reproduced failure outside the current diff and acceptance criteria may remain non-blocking only when the current item has independent passing evidence: preserve it as an out_of_scope_failure with candidate_bug_id, scope_evidence, acceptance_criteria_independent: true, and a failing focused repro command/exit code. Never classify an unexplained, in-scope, or infrastructure failure this way.";
|
|
224
|
+
return "Run or explicitly skip applicable regression/build/lint/typecheck/e2e checks, then call forge.complete_qa_regression. For normal Story QA, prefer focused checks and runner-authored forge.start_managed_verification .NET tier profiles (run_all_shards needs shard_count of at least 2 and no no_build); run Playwright e2e through forge.start_managed_command with the attempt's FORGE_PLAYWRIGHT_CONFIG and the spec files you need; reserve dotnet_solution for shared infrastructure, Feature/PR integration, or an explicit plan requirement. Use forge.start_managed_command only for other commands expected to exceed two minutes, continue independent QA, then call forge.wait_managed_command and include its terminal managed_command_id in command evidence. If the wait returns command_continues=true, continue useful work or wait again after retry_after_ms; do not poll get_managed_command. Normalize negative assertions so an expected no-match exits 0. A reproduced failure outside the current diff and acceptance criteria may remain non-blocking only when the current item has independent passing evidence: preserve it as an out_of_scope_failure with candidate_bug_id, scope_evidence, acceptance_criteria_independent: true, and a failing focused repro command/exit code. Never classify an unexplained, in-scope, or infrastructure failure this way.";
|
|
220
225
|
case "qa_api":
|
|
221
226
|
return "Run or explicitly skip applicable API/backend contract checks, then call forge.complete_qa_api.";
|
|
222
227
|
case "qa_manual_web":
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type CompletionToolCallResult, type CompletionToolRuntime, type CompletionToolRuntimeOptions, type CompletionToolServerConfig } from "./phase-completion.js";
|
|
2
2
|
import { type ManagedAttemptToolResult } from "./managed-attempt-tools.js";
|
|
3
3
|
export declare function prepareCompletionToolRuntime(options: CompletionToolRuntimeOptions): Promise<CompletionToolRuntime>;
|
|
4
|
-
export declare function buildCompletionToolServerArgs(config: CompletionToolServerConfig): readonly string[];
|
|
5
4
|
export declare function codexMcpConfigArgs(runtime: CompletionToolRuntime): readonly string[];
|
|
6
5
|
export declare function cursorMcpServerConfig(runtime: CompletionToolRuntime): unknown;
|
|
7
6
|
export declare function claudeMcpServerConfig(runtime: CompletionToolRuntime): unknown;
|
|
@@ -17,7 +16,7 @@ export declare class CompletionToolServerSession {
|
|
|
17
16
|
constructor(config: CompletionToolServerConfig);
|
|
18
17
|
get instructions(): string;
|
|
19
18
|
toolDefinitions(): readonly unknown[];
|
|
20
|
-
callTool(toolName: string,
|
|
19
|
+
callTool(toolName: string, rawInput: unknown): Promise<CompletionToolCallResult | ManagedAttemptToolResult>;
|
|
21
20
|
private callDecomposeGateTool;
|
|
22
21
|
private callDraftGateTool;
|
|
23
22
|
private callDebugGateTool;
|
|
@@ -38,12 +37,7 @@ export declare function completionToolRuntimeEnvironment(runtimeEnvironment?: Re
|
|
|
38
37
|
*/
|
|
39
38
|
export declare function assertManagedQaRegressionEvidence(input: unknown, receipts: readonly Readonly<Record<string, unknown>>[]): void;
|
|
40
39
|
export declare function runCompletionMcpServer(config: CompletionToolServerConfig): Promise<void>;
|
|
41
|
-
export declare function parseCompletionMcpArgs(argv: readonly string[]): {
|
|
42
|
-
readonly ok: true;
|
|
43
|
-
readonly config: CompletionToolServerConfig;
|
|
44
|
-
} | {
|
|
45
|
-
readonly ok: false;
|
|
46
|
-
readonly error: string;
|
|
47
|
-
};
|
|
48
40
|
export declare function completionRedactionEnv(secrets: readonly string[]): Readonly<Record<string, string>>;
|
|
49
|
-
export declare function completionToolRejectedResult(toolName: string, error: unknown): Readonly<Record<string, unknown>>;
|
|
41
|
+
export declare function completionToolRejectedResult(toolName: string, error: unknown, input?: unknown): Readonly<Record<string, unknown>>;
|
|
42
|
+
/** The input schema a completion tool advertises; also the shape its arguments are coerced to. */
|
|
43
|
+
export declare function completionToolInputSchema(name: string): unknown;
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
|
|
5
4
|
import { completionPhaseFromDispatch, completionPhaseOrder, completionRedactionSecretsEnv, completionToolNamesForDebugGate, completionToolNamesForDecomposeGate, completionToolNamesForDraftGate, completionToolNamesForPhase, completionToolNamesForQaGate, debugCompletionPhaseOrder, decomposeCompletionGateOrder, draftCompletionGateOrder, qaCompletionGateOrder, toolServerName, usesArchitectCycleCompletion, usesDebugCycleCompletion, usesDevelopCycleCompletion, usesQaCycleCompletion } from "./phase-completion.js";
|
|
6
|
-
import { CompletionPayloadValidationError, asDebugCompletionPhase, asJsonRpcMessage, asMutableRecord, asRecord, artifactOwnerRelativeRoot, decomposeGateFromToolName, draftGateFromToolName, errorMessage, forgeBridgeCliBinPath, isDebugCompletionPhase, isDecomposeDispatch,
|
|
5
|
+
import { CompletionPayloadValidationError, asDebugCompletionPhase, asJsonRpcMessage, asMutableRecord, asRecord, artifactOwnerRelativeRoot, decomposeGateFromToolName, draftGateFromToolName, errorMessage, forgeBridgeCliBinPath, isDebugCompletionPhase, isDecomposeDispatch, normalizedOwnerType, phaseFromToolName, qaGateFromToolName, requiredString, rpcError, tomlString, tomlStringArray, writeJsonRpc } from "./phase-completion.validation.js";
|
|
7
6
|
import { completionPromptForDebugCycle, completionPromptForDecomposeCycle, completionPromptForDevelopCycle, completionPromptForDraftCycle, completionPromptForPhase, completionPromptForQaCycle, completionToolNextInstruction, completionToolNextInstructionForDebugGate, completionToolNextInstructionForDecomposeGate, completionToolNextInstructionForDraftGate, completionToolNextInstructionForQaGate, nextDebugPhaseAfter, nextPhaseAfter } from "./phase-completion.prompts.js";
|
|
8
7
|
import { configuredNativeTestPostgresFallbackPath, nativeTestPostgresFallbackConfigEnvironment, } from "../runtime/native-test-postgres-fallback.js";
|
|
9
8
|
import { isHostLoadChildEnvironmentName } from "../runtime/host-load-child-environment.js";
|
|
9
|
+
import { isProviderUserConfigIsolated, providerUserConfigIsolationUnsupported } from "./provider-cli/provider-user-config-isolation.js";
|
|
10
10
|
import { toolDescription, toolInputSchema } from "./phase-completion.schemas.js";
|
|
11
|
+
import { coerceJsonStringArguments, emptyToolInputHint, isEmptyToolInput } from "./mcp-argument-coercion.js";
|
|
11
12
|
import { writeCompletionArtifact, writeDecomposeGateCompletionArtifact, writeDraftGateCompletionArtifact } from "./phase-completion.artifacts.js";
|
|
12
|
-
import {
|
|
13
|
+
import { buildCompletionToolServerArgs } from "./phase-completion.mcp-args.js";
|
|
14
|
+
import { callManagedAttemptTool, isManagedAttemptTool, managedAttemptToolDefinition, managedAttemptToolInputSchema, managedAttemptToolNames, runWithOwnerShutdown, } from "./managed-attempt-tools.js";
|
|
13
15
|
export async function prepareCompletionToolRuntime(options) {
|
|
14
16
|
const phase = options.phase ?? completionPhaseFromDispatch(options.dispatch);
|
|
15
17
|
const worktreePath = path.resolve(options.worktree.worktreePath);
|
|
16
18
|
const workItemId = options.dispatch.workItem.id;
|
|
17
19
|
const ownerType = normalizedOwnerType(options.dispatch.cycleRun.ownerType) ?? "work_item";
|
|
18
20
|
const ownerId = options.dispatch.cycleRun.ownerId ?? workItemId;
|
|
21
|
+
// A managed-tools-only server records no completion artifact, so it takes no cycle mode.
|
|
22
|
+
const cycles = !options.managedToolsOnly;
|
|
19
23
|
const mcpArgs = buildCompletionToolServerArgs({
|
|
20
24
|
worktreePath,
|
|
21
25
|
workItemId,
|
|
@@ -23,15 +27,17 @@ export async function prepareCompletionToolRuntime(options) {
|
|
|
23
27
|
ownerId,
|
|
24
28
|
phase,
|
|
25
29
|
producedBy: `${options.dispatch.execution.provider}-cli`,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
managedToolsOnly: options.managedToolsOnly,
|
|
31
|
+
developCycle: cycles && usesDevelopCycleCompletion(options.dispatch),
|
|
32
|
+
qaCycle: cycles && usesQaCycleCompletion(options.dispatch),
|
|
33
|
+
debugCycle: cycles && usesDebugCycleCompletion(options.dispatch),
|
|
34
|
+
architectCycle: cycles && usesArchitectCycleCompletion(options.dispatch),
|
|
35
|
+
draftCycle: cycles
|
|
36
|
+
&& (phase === "draft"
|
|
37
|
+
|| options.dispatch.execution.lane.trim().toLowerCase() === "draft"
|
|
38
|
+
|| options.dispatch.cycleRun.kind.trim().toLowerCase() === "draft")
|
|
33
39
|
&& !isDecomposeDispatch(options.dispatch),
|
|
34
|
-
decomposeCycle: isDecomposeDispatch(options.dispatch)
|
|
40
|
+
decomposeCycle: cycles && isDecomposeDispatch(options.dispatch)
|
|
35
41
|
});
|
|
36
42
|
const runtime = {
|
|
37
43
|
serverName: toolServerName,
|
|
@@ -41,50 +47,16 @@ export async function prepareCompletionToolRuntime(options) {
|
|
|
41
47
|
cleanup: async () => undefined
|
|
42
48
|
};
|
|
43
49
|
const provider = options.dispatch.execution.provider.trim().toLowerCase();
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
// Provider phases refuse these at entry (admitUserConfigIsolatedProvider, provider-cli.runtime.ts);
|
|
51
|
+
// this guards any other caller before the Claude MCP config is written.
|
|
52
|
+
if (!isProviderUserConfigIsolated(provider)) {
|
|
53
|
+
throw providerUserConfigIsolationUnsupported(options.dispatch.execution.provider);
|
|
46
54
|
}
|
|
47
55
|
if (provider === "claude") {
|
|
48
56
|
return await prepareClaudeCompletionToolRuntime(runtime);
|
|
49
57
|
}
|
|
50
58
|
return runtime;
|
|
51
59
|
}
|
|
52
|
-
export function buildCompletionToolServerArgs(config) {
|
|
53
|
-
const args = [
|
|
54
|
-
"mcp",
|
|
55
|
-
"--worktree",
|
|
56
|
-
path.resolve(config.worktreePath),
|
|
57
|
-
"--work-item-id",
|
|
58
|
-
config.workItemId,
|
|
59
|
-
"--phase",
|
|
60
|
-
config.phase,
|
|
61
|
-
"--produced-by",
|
|
62
|
-
config.producedBy ?? "forge-completion-tool"
|
|
63
|
-
];
|
|
64
|
-
if (config.ownerType || config.ownerId) {
|
|
65
|
-
args.push("--owner-type", normalizedOwnerType(config.ownerType) ?? "work_item");
|
|
66
|
-
args.push("--owner-id", config.ownerId ?? config.workItemId);
|
|
67
|
-
}
|
|
68
|
-
if (config.developCycle) {
|
|
69
|
-
args.push("--develop-cycle");
|
|
70
|
-
}
|
|
71
|
-
if (config.qaCycle) {
|
|
72
|
-
args.push("--qa-cycle");
|
|
73
|
-
}
|
|
74
|
-
if (config.debugCycle) {
|
|
75
|
-
args.push("--debug-cycle");
|
|
76
|
-
}
|
|
77
|
-
if (config.architectCycle) {
|
|
78
|
-
args.push("--architect-cycle");
|
|
79
|
-
}
|
|
80
|
-
if (config.draftCycle) {
|
|
81
|
-
args.push("--draft-cycle");
|
|
82
|
-
}
|
|
83
|
-
if (config.decomposeCycle) {
|
|
84
|
-
args.push("--decompose-cycle");
|
|
85
|
-
}
|
|
86
|
-
return args;
|
|
87
|
-
}
|
|
88
60
|
export function codexMcpConfigArgs(runtime) {
|
|
89
61
|
const prefix = `mcp_servers.${runtime.serverName}`;
|
|
90
62
|
const args = [
|
|
@@ -132,6 +104,10 @@ export function completionToolNamesForServer(config) {
|
|
|
132
104
|
? completionToolNamesForPhase("architect")
|
|
133
105
|
: completionToolNamesForPhase(config.phase);
|
|
134
106
|
}
|
|
107
|
+
const managedToolsOnlyInstructions = "Forge serves only its managed-attempt tools in this turn: "
|
|
108
|
+
+ "forge.start_managed_verification, forge.start_managed_command, forge.wait_managed_command, forge.get_managed_command, "
|
|
109
|
+
+ "forge.run_managed_command and forge.reset_generated_outputs. No completion tool is available; the phase's completion "
|
|
110
|
+
+ "artifacts are already recorded and must stay as they are.";
|
|
135
111
|
export class CompletionToolServerSession {
|
|
136
112
|
config;
|
|
137
113
|
currentPhase;
|
|
@@ -145,36 +121,46 @@ export class CompletionToolServerSession {
|
|
|
145
121
|
this.currentPhase = config.phase;
|
|
146
122
|
}
|
|
147
123
|
get instructions() {
|
|
148
|
-
return this.config.
|
|
149
|
-
?
|
|
150
|
-
: this.config.
|
|
151
|
-
?
|
|
152
|
-
: this.config.
|
|
153
|
-
?
|
|
154
|
-
: this.config.
|
|
155
|
-
?
|
|
156
|
-
: this.config.
|
|
157
|
-
?
|
|
158
|
-
:
|
|
124
|
+
return this.config.managedToolsOnly
|
|
125
|
+
? managedToolsOnlyInstructions
|
|
126
|
+
: this.config.decomposeCycle
|
|
127
|
+
? completionPromptForDecomposeCycle(this.currentDecomposeGate)
|
|
128
|
+
: this.config.draftCycle
|
|
129
|
+
? completionPromptForDraftCycle(this.currentDraftGate)
|
|
130
|
+
: this.config.debugCycle
|
|
131
|
+
? completionPromptForDebugCycle(asDebugCompletionPhase(this.currentPhase))
|
|
132
|
+
: this.config.qaCycle
|
|
133
|
+
? completionPromptForQaCycle(this.currentQaGate, artifactOwnerRelativeRoot(this.config.ownerType, this.config.ownerId, this.config.workItemId))
|
|
134
|
+
: this.config.developCycle
|
|
135
|
+
? completionPromptForDevelopCycle(this.currentPhase)
|
|
136
|
+
: completionPromptForPhase(this.currentPhase, artifactOwnerRelativeRoot(this.config.ownerType, this.config.ownerId, this.config.workItemId));
|
|
159
137
|
}
|
|
160
138
|
toolDefinitions() {
|
|
161
|
-
const completionTools =
|
|
139
|
+
const completionTools = this.config.managedToolsOnly
|
|
140
|
+
? []
|
|
141
|
+
: completionToolNamesForServer(this.config).map(toolDefinition);
|
|
162
142
|
return managedAttemptToolsAvailable()
|
|
163
143
|
? [...completionTools, ...managedAttemptToolNames.map(managedAttemptToolDefinition)]
|
|
164
144
|
: completionTools;
|
|
165
145
|
}
|
|
166
|
-
async callTool(toolName,
|
|
146
|
+
async callTool(toolName, rawInput) {
|
|
167
147
|
if (isManagedAttemptTool(toolName)) {
|
|
168
148
|
if (!managedAttemptToolsAvailable()) {
|
|
169
149
|
throw new Error("Forge managed-attempt tools require an active managed host runtime.");
|
|
170
150
|
}
|
|
171
|
-
const
|
|
151
|
+
const managedInput = coerceJsonStringArguments(rawInput, managedAttemptToolInputSchema(toolName));
|
|
152
|
+
const result = await callManagedAttemptTool(toolName, managedInput, this.config.worktreePath);
|
|
172
153
|
if (Array.isArray(result.structuredContent.command)) {
|
|
173
154
|
this.managedCommandReceipts.push(result.structuredContent);
|
|
174
155
|
}
|
|
175
156
|
return result;
|
|
176
157
|
}
|
|
158
|
+
if (this.config.managedToolsOnly) {
|
|
159
|
+
throw new Error(`${toolName} is not available in this turn: Forge serves only its managed-attempt tools during a pre-publication repair turn, and the phase's completion artifacts are already recorded. Fix the failing checks and stop; Bridge reruns validation.`);
|
|
160
|
+
}
|
|
177
161
|
const requestedPhase = phaseFromToolName(toolName);
|
|
162
|
+
// Clients sometimes send a declared array/object argument as its JSON text.
|
|
163
|
+
const input = coerceJsonStringArguments(rawInput, completionToolInputSchema(toolName));
|
|
178
164
|
if (this.completed) {
|
|
179
165
|
throw new Error("Forge completion cycle is already complete; no more completion calls are accepted.");
|
|
180
166
|
}
|
|
@@ -271,15 +257,26 @@ export class CompletionToolServerSession {
|
|
|
271
257
|
const completedGate = this.currentDraftGate;
|
|
272
258
|
const reference = await writeDraftGateCompletionArtifact(this.config, completedGate, toolName, input);
|
|
273
259
|
const status = reference.status.trim().toLowerCase();
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const
|
|
260
|
+
// Only a pass completes a Draft gate; needs_revision, needs_rework, and blocked keep the same
|
|
261
|
+
// gate selected so it is retried, never skipped.
|
|
262
|
+
const pass = status === "pass";
|
|
263
|
+
const nextGate = pass ? this.advanceAfterDraftGate(completedGate) : completedGate;
|
|
264
|
+
const nextPhase = pass ? (nextGate ? "draft" : "sign_off_ready") : "draft";
|
|
265
|
+
const nextInstruction = completionToolNextInstructionForDraftGate(completedGate, status, pass ? nextGate : null);
|
|
277
266
|
return {
|
|
278
267
|
content: [{ type: "text", text: `Forge recorded ${completedGate} artifact ${path.relative(reference.repoPath, reference.path)} (${reference.status}, ${reference.contentHash}). ${nextInstruction}` }],
|
|
279
268
|
structuredContent: {
|
|
280
269
|
...reference,
|
|
281
270
|
...acceptedArtifactReceipt(reference),
|
|
282
|
-
gate: {
|
|
271
|
+
gate: {
|
|
272
|
+
phase: "draft",
|
|
273
|
+
draftGate: completedGate,
|
|
274
|
+
status,
|
|
275
|
+
allowed: pass,
|
|
276
|
+
reason: !pass
|
|
277
|
+
? `${completedGate} artifact recorded with status ${status}; rework is required before continuing.`
|
|
278
|
+
: nextGate ? `${completedGate} artifact accepted; continue to ${nextGate}.` : `Draft proposal artifact accepted with status ${status}.`
|
|
279
|
+
},
|
|
283
280
|
nextPhase,
|
|
284
281
|
nextInstruction
|
|
285
282
|
}
|
|
@@ -476,7 +473,7 @@ export function completionToolRuntimeEnvironment(runtimeEnvironment, nativeTestP
|
|
|
476
473
|
env[name] = value.trim();
|
|
477
474
|
}
|
|
478
475
|
// Managed verification reads the operator's native test cluster only through
|
|
479
|
-
// this explicit path
|
|
476
|
+
// this explicit path; the file's `use` decides whether Docker comes first.
|
|
480
477
|
if (runtimeEnvironment && nativeTestPostgresFallbackPath) {
|
|
481
478
|
env[nativeTestPostgresFallbackConfigEnvironment] = nativeTestPostgresFallbackPath;
|
|
482
479
|
}
|
|
@@ -584,148 +581,12 @@ export async function runCompletionMcpServer(config) {
|
|
|
584
581
|
}
|
|
585
582
|
});
|
|
586
583
|
}
|
|
587
|
-
export function parseCompletionMcpArgs(argv) {
|
|
588
|
-
let worktreePath = null;
|
|
589
|
-
let workItemId = null;
|
|
590
|
-
let phase = "implementation";
|
|
591
|
-
let ownerType;
|
|
592
|
-
let ownerId;
|
|
593
|
-
let producedBy;
|
|
594
|
-
let developCycle = false;
|
|
595
|
-
let qaCycle = false;
|
|
596
|
-
let debugCycle = false;
|
|
597
|
-
let architectCycle = false;
|
|
598
|
-
let draftCycle = false;
|
|
599
|
-
let decomposeCycle = false;
|
|
600
|
-
for (let index = 1; index < argv.length; index += 1) {
|
|
601
|
-
const arg = argv[index];
|
|
602
|
-
if (arg === "--worktree") {
|
|
603
|
-
worktreePath = argv[++index] ?? null;
|
|
604
|
-
}
|
|
605
|
-
else if (arg === "--work-item-id") {
|
|
606
|
-
workItemId = argv[++index] ?? null;
|
|
607
|
-
}
|
|
608
|
-
else if (arg === "--owner-type") {
|
|
609
|
-
ownerType = normalizedOwnerType(argv[++index]);
|
|
610
|
-
if (!ownerType) {
|
|
611
|
-
return { ok: false, error: "mcp --owner-type must be work_item or story." };
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
else if (arg === "--owner-id") {
|
|
615
|
-
ownerId = argv[++index] ?? undefined;
|
|
616
|
-
}
|
|
617
|
-
else if (arg === "--phase") {
|
|
618
|
-
const rawPhase = argv[++index];
|
|
619
|
-
const parsedPhase = parseStrictCompletionPhase(rawPhase);
|
|
620
|
-
if (!parsedPhase) {
|
|
621
|
-
return { ok: false, error: "mcp --phase must be one of: implementation, self-review, validation, qa, architect, draft, decompose, ci-repair, comment-repair, debug-repro, debug-root-cause, debug-fix, debug-regression." };
|
|
622
|
-
}
|
|
623
|
-
phase = parsedPhase;
|
|
624
|
-
}
|
|
625
|
-
else if (arg === "--produced-by") {
|
|
626
|
-
producedBy = argv[++index] ?? undefined;
|
|
627
|
-
}
|
|
628
|
-
else if (arg === "--develop-cycle") {
|
|
629
|
-
developCycle = true;
|
|
630
|
-
}
|
|
631
|
-
else if (arg === "--qa-cycle") {
|
|
632
|
-
qaCycle = true;
|
|
633
|
-
}
|
|
634
|
-
else if (arg === "--debug-cycle") {
|
|
635
|
-
debugCycle = true;
|
|
636
|
-
}
|
|
637
|
-
else if (arg === "--architect-cycle") {
|
|
638
|
-
architectCycle = true;
|
|
639
|
-
}
|
|
640
|
-
else if (arg === "--draft-cycle") {
|
|
641
|
-
draftCycle = true;
|
|
642
|
-
}
|
|
643
|
-
else if (arg === "--decompose-cycle") {
|
|
644
|
-
decomposeCycle = true;
|
|
645
|
-
}
|
|
646
|
-
else {
|
|
647
|
-
return { ok: false, error: `Unknown mcp argument: ${arg}` };
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
if (!worktreePath?.trim() || !workItemId?.trim()) {
|
|
651
|
-
return { ok: false, error: "mcp requires --worktree and --work-item-id." };
|
|
652
|
-
}
|
|
653
|
-
if ([developCycle, qaCycle, debugCycle, architectCycle, draftCycle, decomposeCycle].filter(Boolean).length > 1) {
|
|
654
|
-
return { ok: false, error: "mcp accepts only one cycle mode." };
|
|
655
|
-
}
|
|
656
|
-
if (developCycle && !isDevelopCompletionPhase(phase)) {
|
|
657
|
-
return { ok: false, error: "mcp --develop-cycle requires --phase implementation, self-review, or validation." };
|
|
658
|
-
}
|
|
659
|
-
if (qaCycle && phase !== "qa") {
|
|
660
|
-
return { ok: false, error: "mcp --qa-cycle requires --phase qa." };
|
|
661
|
-
}
|
|
662
|
-
if (debugCycle && !isDebugCompletionPhase(phase)) {
|
|
663
|
-
return { ok: false, error: "mcp --debug-cycle requires --phase debug-repro, debug-root-cause, debug-fix, or debug-regression." };
|
|
664
|
-
}
|
|
665
|
-
if (architectCycle && phase !== "architect") {
|
|
666
|
-
return { ok: false, error: "mcp --architect-cycle requires --phase architect." };
|
|
667
|
-
}
|
|
668
|
-
if (draftCycle && phase !== "draft") {
|
|
669
|
-
return { ok: false, error: "mcp --draft-cycle requires --phase draft." };
|
|
670
|
-
}
|
|
671
|
-
if (decomposeCycle && phase !== "decompose") {
|
|
672
|
-
return { ok: false, error: "mcp --decompose-cycle requires --phase decompose." };
|
|
673
|
-
}
|
|
674
|
-
return {
|
|
675
|
-
ok: true,
|
|
676
|
-
config: {
|
|
677
|
-
worktreePath: path.resolve(worktreePath),
|
|
678
|
-
workItemId,
|
|
679
|
-
ownerType,
|
|
680
|
-
ownerId,
|
|
681
|
-
phase,
|
|
682
|
-
producedBy,
|
|
683
|
-
redactionSecrets: [
|
|
684
|
-
...parseCompletionRedactionSecrets(process.env[completionRedactionSecretsEnv]),
|
|
685
|
-
...attemptDatabaseCapabilitySecrets(process.env[attemptDatabaseCapabilityEnvironment]),
|
|
686
|
-
],
|
|
687
|
-
developCycle,
|
|
688
|
-
qaCycle,
|
|
689
|
-
debugCycle,
|
|
690
|
-
architectCycle,
|
|
691
|
-
draftCycle,
|
|
692
|
-
decomposeCycle
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
584
|
export function completionRedactionEnv(secrets) {
|
|
697
585
|
const filtered = secrets.filter((secret) => secret.length > 0);
|
|
698
586
|
return filtered.length > 0
|
|
699
587
|
? { [completionRedactionSecretsEnv]: JSON.stringify(filtered) }
|
|
700
588
|
: {};
|
|
701
589
|
}
|
|
702
|
-
async function prepareCursorCompletionToolRuntime(worktreePath, runtime) {
|
|
703
|
-
const cursorDir = path.join(worktreePath, ".cursor");
|
|
704
|
-
const configPath = path.join(cursorDir, "mcp.json");
|
|
705
|
-
const original = await fs.readFile(configPath, "utf8").then((content) => ({ existed: true, content }), () => ({ existed: false, content: "" }));
|
|
706
|
-
const existing = original.existed ? parseOptionalJsonObject(original.content, configPath) : {};
|
|
707
|
-
const servers = asMutableRecord(existing.mcpServers);
|
|
708
|
-
servers[runtime.serverName] = cursorMcpServerConfig(runtime);
|
|
709
|
-
const next = {
|
|
710
|
-
...existing,
|
|
711
|
-
mcpServers: servers
|
|
712
|
-
};
|
|
713
|
-
await fs.mkdir(cursorDir, { recursive: true });
|
|
714
|
-
await writeFileAtomic(configPath, `${JSON.stringify(next, null, 2)}\n`);
|
|
715
|
-
return {
|
|
716
|
-
...runtime,
|
|
717
|
-
cursorMcpConfigPath: configPath,
|
|
718
|
-
cleanup: async () => {
|
|
719
|
-
if (original.existed) {
|
|
720
|
-
await writeFileAtomic(configPath, original.content);
|
|
721
|
-
}
|
|
722
|
-
else {
|
|
723
|
-
await fs.rm(configPath, { force: true });
|
|
724
|
-
await fs.rmdir(cursorDir).catch(() => undefined);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
590
|
/**
|
|
730
591
|
* Claude Code takes MCP servers from `--mcp-config <file>`. The file lives in an attempt-owned
|
|
731
592
|
* temp directory (never the worktree) because its env block can carry redaction secrets, and
|
|
@@ -808,15 +669,18 @@ async function handleJsonRpcRequest(session, method, params) {
|
|
|
808
669
|
catch (error) {
|
|
809
670
|
if (isManagedAttemptTool(name))
|
|
810
671
|
throw error;
|
|
811
|
-
return completionToolRejectedResult(name, error);
|
|
672
|
+
return completionToolRejectedResult(name, error, args);
|
|
812
673
|
}
|
|
813
674
|
}
|
|
814
675
|
throw new Error(`Unsupported MCP method: ${method}`);
|
|
815
676
|
}
|
|
816
|
-
export function completionToolRejectedResult(toolName, error) {
|
|
677
|
+
export function completionToolRejectedResult(toolName, error, input) {
|
|
817
678
|
const issues = error instanceof CompletionPayloadValidationError
|
|
818
679
|
? [...error.issues]
|
|
819
680
|
: [errorMessage(error)];
|
|
681
|
+
if (input !== undefined && isEmptyToolInput(input)) {
|
|
682
|
+
issues.push(`${emptyToolInputHint} Keep long free text such as report_markdown short.`);
|
|
683
|
+
}
|
|
820
684
|
const repairInstruction = "Repair every listed issue and resubmit this same gate once. Do not inspect the artifact path: rejected calls never write or replace completion artifacts.";
|
|
821
685
|
return {
|
|
822
686
|
content: [{
|
|
@@ -844,10 +708,14 @@ function acceptedArtifactReceipt(reference) {
|
|
|
844
708
|
},
|
|
845
709
|
};
|
|
846
710
|
}
|
|
847
|
-
function toolDefinition(name
|
|
711
|
+
function toolDefinition(name) {
|
|
848
712
|
return {
|
|
849
713
|
name,
|
|
850
|
-
description: toolDescription(
|
|
851
|
-
inputSchema:
|
|
714
|
+
description: toolDescription(phaseFromToolName(name), qaGateFromToolName(name), decomposeGateFromToolName(name), draftGateFromToolName(name)),
|
|
715
|
+
inputSchema: completionToolInputSchema(name)
|
|
852
716
|
};
|
|
853
717
|
}
|
|
718
|
+
/** The input schema a completion tool advertises; also the shape its arguments are coerced to. */
|
|
719
|
+
export function completionToolInputSchema(name) {
|
|
720
|
+
return toolInputSchema(phaseFromToolName(name), qaGateFromToolName(name), decomposeGateFromToolName(name), draftGateFromToolName(name));
|
|
721
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function browserCheckSchema(required: readonly string[]): unknown;
|
|
2
|
+
export declare function qaSidecarsSchema(): unknown;
|
|
3
|
+
export declare function qaEvidenceWrapperSchema(): unknown;
|
|
4
|
+
/** QA evidence gates read only sidecars from the nested wrapper; the other evidence fields go at the top level. */
|
|
5
|
+
export declare function qaGateEvidenceWrapperSchema(): unknown;
|
|
6
|
+
export declare function findingEvidenceSchema(rule: string): unknown;
|
|
7
|
+
export declare function objectToolSchema(properties: Record<string, unknown>, required: readonly string[], description: string): unknown;
|
|
8
|
+
export declare function evidenceObjectSchema(required: readonly string[], properties: Record<string, unknown>): unknown;
|
|
9
|
+
export declare function qaScopeSchema(description: string): unknown;
|
|
10
|
+
export declare function commandEvidenceSchema(): unknown;
|
|
11
|
+
export declare function resolvedFindingSchema(): unknown;
|
|
12
|
+
export declare function acceptanceCriteriaSchema(): unknown;
|
|
13
|
+
export declare function reviewSectionSchema(): {
|
|
14
|
+
readonly type: "object";
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly additionalProperties: true;
|
|
17
|
+
readonly properties: Record<string, unknown>;
|
|
18
|
+
};
|
|
19
|
+
export declare function reviewSectionProperties(): Record<string, unknown>;
|