mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-16 03:31:44 +01:00
feat(prp): declare the contract for provider-started turns (#21422)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip Runner runs Claude Code through the ACPX sidecar. > - Claude can start a shell command in the background and end its turn. When the command finishes, Claude Code starts a cycle of its own to continue. Today the Runner stops Claude at the end of the turn, so the command stops and the run fails with `native_finalization_missing`. > - A stack of pull requests lets the Runner accept that cycle as a new turn of the same run, when a controller asks for it. > - The Runner, its sidecar and the controller speak two protocols with schemas: PRP between the controller and the Runner, and the sidecar protocol between `paperclip-runnerd` and the ACPX sidecar. > - A turn that the provider starts needs new fields and one new command in those protocols. > - This pull request declares them and generates the readers again. It changes no behavior. > - The benefit is that the next two pull requests show behavior only, with the contract already in review. ## Linked Issues or Issue Description No public issue exists. The issue is described here. This pull request is one part of a change that was first opened as one large pull request (#21316). The parts, in stack order after #21311: 1. #21419: sidecar preparation (a refactor). 2. #21420: converter for raw ACP session updates. 3. #21421: cycle stream at the adapter. 4. #21422: contract for provider-started turns. 5. #21423: `paperclip-runnerd` waits for a provider-started turn. 6. #21316: the sidecar adopts a cycle. This is part 4. Its base branch is `feat/claude-provider-cycle-stream`. After each part, a production run does the same as today, because no controller sends the opt-in. Refs #19912 (design). **What existing behavior does this improve?** Nothing in production. The protocol schemas. **Subsystem affected** Paperclip Runner: `protocol/` and the generated TypeScript and Rust contract code. **Current behavior** - PRP has no way to say that a turn was started by the provider, or that the Runner waits for such a turn. - The sidecar protocol has no command to arm the sidecar and no event for a turn that the provider starts. **Proposed behavior** - PRP (`schemas/provider-turn.schema.json`, new): `providerStartedTurns` (boolean) in the payload of `turn.start`, `origin: "provider"` on `turn.started`, and `awaitingProviderTurn: true` on `turn.completed`. `command-v3` and `event-v3` refer to it. - Sidecar protocol (`provider-schemas/acpx-sidecar.schema.json`): the command `session.provider_turn` with `{ turnId, armed }`, the event `runtime.turn_started` with `{ origin: "provider" }`, and the payload of the diagnostic for a lost provider. The schema enforces that payload for a `runtime.diagnostic` with the code `ACPX_PROVIDER_PROCESS_LOST`. Diagnostics with other codes keep their open payload. - `paperclip-runnerd` decodes `runtime.turn_started` and refuses it. No sidecar sends it yet. The Runner of today refuses an unknown event too. - No controller, Runner or sidecar uses the new fields in this pull request. **Reason and benefit** The repository rule for Runner contracts says that new fields must be in the schema with generated readers. A separate pull request lets a reviewer read the contract alone. ## What Changed - `protocol/schemas/provider-turn.schema.json` (new), `command-v3.schema.json`, `event-v3.schema.json`, `protocol/provider-schemas/acpx-sidecar.schema.json`, `protocol/manifest.json`. - `scripts/generate-acpx-sidecar-contract.mjs` and `scripts/generate-protocol-schema-module.mjs`. - Generated: `src/drivers/acpx/generated-sidecar-contract.ts`, `src/protocol/generated/schema-bundle.ts`, `src/protocol/generated/standalone-validators.ts`, `runner/crates/runner-core/src/generated_acpx_sidecar_contract.rs`. - `runner/crates/runner-core/src/acpx_event_payload.rs` (3 lines): the Rust `match` on the event type must name the new event to compile. - `test/protocol-contract.test.mjs`. - The contract digests of the pack change (`prp.acpx-sidecar`, `prp.command-v3`, `prp.event-v3`, `rust`, and the new `prp.provider-turn`). No stored file refers to these digests. No provider `commandDigest` and no profile version changes. ## Verification At the head of this branch, from `packages/paperclip-runner`: - `npx tsc --noEmit -p tsconfig.json`, `npx tsc --noEmit -p tsconfig.test.json`, `pnpm run typecheck:typescript`, `pnpm run build:typescript`, `node --test test/acpx-sidecar-contract.test.mjs test/protocol-contract.test.mjs`, the server check `node scripts/verify-runner-vendor-dependencies.mjs`, `node --test scripts/__tests__/runner-release-crate-cache.test.mjs`, `cargo fmt --check` and `cargo build -p paperclip-runner-core --bins` (no new warning): all passed. The contract tests: 32 passed. - The sidecar suite and the tracker tests: 141 passed. Not run: the full suite. CI supplies that coverage. ## Risks - **The pack contract digest changes.** Older image packs are not used again. - **The opt-in field is accepted by the schema but has no effect yet.** A controller that sends it before part 5 gets the behavior of today. - **State saved by the previous release:** this pull request changes no persisted shape. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Fable 5.2 (`claude-fable-5-2`) in Claude Code planned the change and the split, reviewed the diff, and ran a part of the verification again. - Claude Opus 5.5 (`claude-opus-5-5`), as a Claude Code subagent with tool use (shell, file edits, local test runs), wrote the change and the tests and cut this slice from the full change. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6d8ebc4a85
commit
1332ab987f
14 files changed
+312
-6
No files matched your search
@@ -35,7 +35,7 @@
|
||||
{
|
||||
"path": "schemas/command-v3.schema.json",
|
||||
"id": "https://paperclip.dev/schemas/prp/v3/command.schema.json",
|
||||
"sha256": "3c8a2d55bfcd1151885ed74bfb4fe2994b9b56f4794d02e446606253d2e8870d"
|
||||
"sha256": "0757002c91143e89b12efd46d80c981a00a739109adf22992038398c4f84e7c7"
|
||||
},
|
||||
{
|
||||
"path": "schemas/command.schema.json",
|
||||
@@ -60,7 +60,7 @@
|
||||
{
|
||||
"path": "schemas/event-v3.schema.json",
|
||||
"id": "https://paperclip.dev/schemas/prp/v3/event.schema.json",
|
||||
"sha256": "dcd842c34d0b6cccffde3d28de9f5c68790699962eb30d19ffc54f2fc30e24d8"
|
||||
"sha256": "d661ba8facbbec1389509f17bb6322958d100af98838b98a654e0a7cba15053f"
|
||||
},
|
||||
{
|
||||
"path": "schemas/event.schema.json",
|
||||
@@ -97,6 +97,11 @@
|
||||
"id": "https://paperclip.dev/schemas/prp/v1/provider-failure.schema.json",
|
||||
"sha256": "d8bc6a9a165d48c125aa0b2193f6dc212450156086f17ef852f93a3a4c260dd0"
|
||||
},
|
||||
{
|
||||
"path": "schemas/provider-turn.schema.json",
|
||||
"id": "https://paperclip.dev/schemas/prp/v3/provider-turn.schema.json",
|
||||
"sha256": "5112079cb5ba37b81728437d686cff22317b77cbbd039e1891a53cd37971e06c"
|
||||
},
|
||||
{
|
||||
"path": "schemas/question-adapter-fixture.schema.json",
|
||||
"id": "https://paperclip.dev/schemas/prp/v1/question-adapter-fixture.schema.json",
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"session.goal.get",
|
||||
"session.goal.set",
|
||||
"session.goal.clear",
|
||||
"session.provider_turn",
|
||||
"session.suspend",
|
||||
"session.close"
|
||||
]
|
||||
@@ -51,6 +52,7 @@
|
||||
"runtime.permission_requested",
|
||||
"runtime.input_requested",
|
||||
"runtime.tool_called",
|
||||
"runtime.turn_started",
|
||||
"runtime.turn_terminal",
|
||||
"runtime.process",
|
||||
"runtime.diagnostic",
|
||||
@@ -82,6 +84,10 @@
|
||||
"if": { "properties": { "command": { "const": "turn.steer" } } },
|
||||
"then": { "properties": { "params": { "$ref": "#/$defs/turnControl" } } }
|
||||
},
|
||||
{
|
||||
"if": { "properties": { "command": { "const": "session.provider_turn" } } },
|
||||
"then": { "properties": { "params": { "$ref": "#/$defs/providerTurnArming" } } }
|
||||
},
|
||||
{
|
||||
"if": { "properties": { "command": { "const": "session.open" } } },
|
||||
"then": { "properties": { "params": { "allOf": [{ "$ref": "#/$defs/sessionOpenParams" }, { "$ref": "#/$defs/sessionOpenThinkingLevel" }, { "$ref": "#/$defs/sessionOpenClaudeEffort" }] } } }
|
||||
@@ -261,9 +267,54 @@
|
||||
"payload": { "$ref": "#/$defs/richEvent" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": { "properties": { "eventType": { "const": "runtime.turn_started" } } },
|
||||
"then": {
|
||||
"properties": {
|
||||
"runId": { "type": "string" },
|
||||
"turnId": { "type": "string" },
|
||||
"payload": { "$ref": "#/$defs/providerTurnStarted" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": { "properties": { "eventType": { "const": "runtime.diagnostic" }, "payload": {
|
||||
"type": "object",
|
||||
"properties": { "code": { "const": "ACPX_PROVIDER_PROCESS_LOST" } },
|
||||
"required": ["code"]
|
||||
} } },
|
||||
"then": { "properties": { "payload": { "$ref": "#/$defs/providerTurnLost" } } }
|
||||
}
|
||||
]
|
||||
},
|
||||
"providerTurnArming": {
|
||||
"description": "runnerd arms or disarms adoption of Claude's next own cycle. Arming names the completed terminal that reported live background tasks; the sidecar adopts a cycle only while armed and replies whether it is armed.",
|
||||
"type": "object",
|
||||
"required": ["turnId", "armed"],
|
||||
"properties": {
|
||||
"turnId": { "type": "string", "maxLength": 240, "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$" },
|
||||
"armed": { "type": "boolean" }
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"providerTurnLost": {
|
||||
"description": "runtime.diagnostic payload the sidecar sends when the provider exits while runnerd is armed for a provider-started turn. runnerd stops awaiting and releases the run.terminal it held back.",
|
||||
"type": "object",
|
||||
"required": ["code", "message"],
|
||||
"properties": {
|
||||
"code": { "const": "ACPX_PROVIDER_PROCESS_LOST" },
|
||||
"message": { "type": "string", "maxLength": 8192 }
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"providerTurnStarted": {
|
||||
"description": "Claude began its own cycle with no prompt in flight. runnerd admits it only while it awaits a provider-started turn.",
|
||||
"type": "object",
|
||||
"required": ["origin"],
|
||||
"properties": { "origin": { "const": "provider" } },
|
||||
"additionalProperties": false
|
||||
},
|
||||
"backgroundTasks": {
|
||||
"description": "Claude's live background tasks, carried on a completed runtime.turn_terminal payload and on a session.snapshot result taken with no active turn. The sidecar sends it only when it knows the count. An absent value means unknown, and runnerd then restarts the provider as before. runnerd keeps the provider between turns only for exactly {\"live\": 0}.",
|
||||
"type": "object",
|
||||
|
||||
@@ -518,6 +518,30 @@
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "turn.start"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"providerStartedTurns": {
|
||||
"$ref": "https://paperclip.dev/schemas/prp/v3/provider-turn.schema.json#/$defs/controllerOptIn"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
],
|
||||
"additionalProperties": true
|
||||
|
||||
@@ -739,6 +739,54 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"eventType": {
|
||||
"const": "turn.started"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"origin": {
|
||||
"$ref": "https://paperclip.dev/schemas/prp/v3/provider-turn.schema.json#/$defs/origin"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"eventType": {
|
||||
"const": "turn.completed"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"awaitingProviderTurn": {
|
||||
"$ref": "https://paperclip.dev/schemas/prp/v3/provider-turn.schema.json#/$defs/awaitingProviderTurn"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
],
|
||||
"additionalProperties": true
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://paperclip.dev/schemas/prp/v3/provider-turn.schema.json",
|
||||
"title": "PRP provider-started turn markers",
|
||||
"description": "Marks a turn the provider started without a controller turn.start, a completed turn after which the Runner keeps the provider to await one, and the controller's per-turn opt-in on turn.start. Without the opt-in the Runner never awaits, never suppresses run.terminal and never surfaces a provider-started turn.",
|
||||
"$defs": {
|
||||
"origin": {
|
||||
"const": "provider"
|
||||
},
|
||||
"awaitingProviderTurn": {
|
||||
"const": true
|
||||
},
|
||||
"controllerOptIn": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,9 @@ pub fn decode_acpx_event(
|
||||
admit_acpx_event_payload_size(event)?;
|
||||
|
||||
match event.event_type {
|
||||
GeneratedAcpxSidecarEventType::RuntimeTurnStarted => Err(LocalRunnerError::invalid(
|
||||
"ACPX provider turn start requires an awaited continuation",
|
||||
)),
|
||||
GeneratedAcpxSidecarEventType::RuntimeRichEvent => decode_rich_event(&event.payload),
|
||||
GeneratedAcpxSidecarEventType::RuntimeEvent => decode_runtime_event(&event.payload),
|
||||
GeneratedAcpxSidecarEventType::RuntimePermissionRequested => {
|
||||
|
||||
+6
@@ -3,6 +3,8 @@
|
||||
pub const GENERATED_ACPX_SIDECAR_PROTOCOL_VERSION: u64 = 2;
|
||||
pub const GENERATED_ACPX_TURN_DISPATCH_JOURNAL_FILE: &str = "paperclip-turn-dispatch.jsonl";
|
||||
pub const GENERATED_ACPX_TURN_DISPATCH_SCHEMA: &str = "paperclip.acpx-turn-dispatch.v1";
|
||||
pub const GENERATED_ACPX_PROVIDER_TURN_ORIGIN: &str = "provider";
|
||||
pub const GENERATED_ACPX_PROVIDER_TURN_LOST_CODE: &str = "ACPX_PROVIDER_PROCESS_LOST";
|
||||
pub const GENERATED_ACPX_BACKGROUND_TASKS_MAX_LIVE: u64 = 9007199254740991;
|
||||
|
||||
pub fn read_generated_acpx_background_tasks(value: &serde_json::Value) -> Option<u64> {
|
||||
@@ -55,6 +57,7 @@ pub enum GeneratedAcpxSidecarCommand {
|
||||
SessionGoalGet,
|
||||
SessionGoalSet,
|
||||
SessionGoalClear,
|
||||
SessionProviderTurn,
|
||||
SessionSuspend,
|
||||
SessionClose,
|
||||
}
|
||||
@@ -76,6 +79,7 @@ impl GeneratedAcpxSidecarCommand {
|
||||
Self::SessionGoalGet => "session.goal.get",
|
||||
Self::SessionGoalSet => "session.goal.set",
|
||||
Self::SessionGoalClear => "session.goal.clear",
|
||||
Self::SessionProviderTurn => "session.provider_turn",
|
||||
Self::SessionSuspend => "session.suspend",
|
||||
Self::SessionClose => "session.close",
|
||||
}
|
||||
@@ -94,6 +98,8 @@ pub enum GeneratedAcpxSidecarEventType {
|
||||
RuntimeInputRequested,
|
||||
#[serde(rename = "runtime.tool_called")]
|
||||
RuntimeToolCalled,
|
||||
#[serde(rename = "runtime.turn_started")]
|
||||
RuntimeTurnStarted,
|
||||
#[serde(rename = "runtime.turn_terminal")]
|
||||
RuntimeTurnTerminal,
|
||||
#[serde(rename = "runtime.process")]
|
||||
|
||||
@@ -24,6 +24,14 @@ if (providerPolicySchema?.additionalProperties !== false || !providerPolicySchem
|
||||
throw new Error("ACPX sidecar providerPolicy must be a closed object schema");
|
||||
}
|
||||
const providerPolicyFields = Object.keys(providerPolicySchema.properties);
|
||||
const providerTurnOrigin = schema.$defs.providerTurnStarted?.properties?.origin?.const;
|
||||
const providerTurnLostCode = schema.$defs.providerTurnLost?.properties?.code?.const;
|
||||
if (typeof providerTurnLostCode !== "string" || schema.$defs.providerTurnLost?.additionalProperties !== false) {
|
||||
throw new Error("ACPX provider-turn loss diagnostic must be a closed object with a constant code");
|
||||
}
|
||||
if (typeof providerTurnOrigin !== "string" || schema.$defs.providerTurnStarted?.additionalProperties !== false) {
|
||||
throw new Error("ACPX provider-started turn payload must be a closed object with a constant origin");
|
||||
}
|
||||
// Mutation wins for compound provider kinds so create-target attestation and
|
||||
// the normalized readOnly flag cannot disagree across the sidecar boundary.
|
||||
const toolOperationPrecedence = [
|
||||
@@ -69,8 +77,8 @@ const rustVariant = (value) =>
|
||||
.map((part) => part[0].toUpperCase() + part.slice(1))
|
||||
.join("");
|
||||
|
||||
const typescript = `// Generated by scripts/generate-acpx-sidecar-contract.mjs. Do not edit.\n\nexport const GENERATED_ACPX_SIDECAR_PROTOCOL_VERSION = ${protocolVersion} as const;\nexport const GENERATED_ACPX_TURN_DISPATCH_JOURNAL_FILE = ${quote(turnDispatchJournalFile)};\nexport const GENERATED_ACPX_TURN_DISPATCH_SCHEMA = ${quote(turnDispatchSchema)};\nexport const GENERATED_ACPX_SIDECAR_COMMANDS = [\n${commands.map((value) => ` ${quote(value)},`).join("\n")}\n] as const;\nexport type GeneratedAcpxSidecarCommand =\n (typeof GENERATED_ACPX_SIDECAR_COMMANDS)[number];\n\nexport const GENERATED_ACPX_SIDECAR_EVENT_TYPES = [\n${events.map((value) => ` ${quote(value)},`).join("\n")}\n] as const;\nexport type GeneratedAcpxSidecarEventType =\n (typeof GENERATED_ACPX_SIDECAR_EVENT_TYPES)[number];\n\nexport const GENERATED_ACPX_SIDECAR_OPEN_PARAMS = [\n${openParams.map((value) => ` ${quote(value)},`).join("\n")}\n] as const;\n\nexport const GENERATED_ACPX_SIDECAR_PROVIDER_POLICY_FIELDS = [\n${providerPolicyFields.map((value) => ` ${quote(value)},`).join("\n")}\n] as const;\n\nexport const GENERATED_ACPX_BACKGROUND_TASKS_MAX_LIVE = ${backgroundLiveMaximum};\n\nexport type GeneratedAcpxBackgroundTasks = { live: number };\n\nexport function readGeneratedAcpxBackgroundTasks(value: unknown): GeneratedAcpxBackgroundTasks | null {\n if (value === null || typeof value !== "object" || Array.isArray(value)) return null;\n const keys = Object.keys(value);\n const live = (value as Record<string, unknown>).live;\n if (keys.length !== 1 || keys[0] !== "live" || typeof live !== "number" || !Number.isInteger(live)) return null;\n return live >= 0 && live <= GENERATED_ACPX_BACKGROUND_TASKS_MAX_LIVE ? { live } : null;\n}\n\nexport type GeneratedAcpxToolOperation =\n | "read"\n | "search"\n | "list"\n | "edit"\n | "execute"\n | "unknown";\n\nexport const GENERATED_ACPX_TOOL_OPERATION_PRECEDENCE = [\n${toolOperationPrecedence.map(([operation, tokens]) => ` { operation: ${quote(operation)}, tokens: [${tokens.map(quote).join(", ")}] },`).join("\n")}\n] as const;\n\nexport function classifyGeneratedAcpxToolOperation(\n toolKind: unknown,\n toolTitle: unknown,\n): GeneratedAcpxToolOperation {\n const candidate =\n typeof toolKind === "string" && toolKind\n ? toolKind\n : typeof toolTitle === "string"\n ? toolTitle\n : "";\n const normalized = candidate.slice(0, 240).toLowerCase();\n for (const { operation, tokens } of GENERATED_ACPX_TOOL_OPERATION_PRECEDENCE) {\n if (tokens.some((token) => normalized.includes(token))) return operation;\n }\n return normalized ? "execute" : "unknown";\n}\n`;
|
||||
const rust = `// Generated by scripts/generate-acpx-sidecar-contract.mjs. Do not edit.\n\npub const GENERATED_ACPX_SIDECAR_PROTOCOL_VERSION: u64 = ${protocolVersion};\npub const GENERATED_ACPX_TURN_DISPATCH_JOURNAL_FILE: &str = ${quote(turnDispatchJournalFile)};\npub const GENERATED_ACPX_TURN_DISPATCH_SCHEMA: &str = ${quote(turnDispatchSchema)};\npub const GENERATED_ACPX_BACKGROUND_TASKS_MAX_LIVE: u64 = ${backgroundLiveMaximum};\n\npub fn read_generated_acpx_background_tasks(value: &serde_json::Value) -> Option<u64> {\n let tasks = value.as_object()?;\n if tasks.len() != 1 {\n return None;\n }\n tasks\n .get("live")?\n .as_u64()\n .filter(|live| *live <= GENERATED_ACPX_BACKGROUND_TASKS_MAX_LIVE)\n}\n\npub const GENERATED_ACPX_TOOL_OPERATION_PRECEDENCE: &[(&str, &[&str])] = &[\n${toolOperationPrecedence.map(([operation, tokens]) => ` (${quote(operation)}, &[${tokens.map(quote).join(", ")}]),`).join("\n")}\n];\n\npub fn classify_generated_acpx_tool_operation(kind: &str, title: &str) -> &'static str {\n let kind = kind.to_ascii_lowercase();\n let title = title.to_ascii_lowercase();\n let candidate = if kind.is_empty() { &title } else { &kind };\n for (operation, tokens) in GENERATED_ACPX_TOOL_OPERATION_PRECEDENCE {\n if tokens.iter().any(|token| candidate.contains(token)) {\n return operation;\n }\n }\n if candidate.is_empty() {\n "unknown"\n } else {\n "execute"\n }\n}\n\n#[derive(Clone, Copy, Debug, PartialEq, Eq)]\npub enum GeneratedAcpxSidecarCommand {\n${commands.map((value) => ` ${rustVariant(value)},`).join("\n")}\n}\n\nimpl GeneratedAcpxSidecarCommand {\n pub const fn as_str(self) -> &'static str {\n match self {\n${commands.map((value) => ` Self::${rustVariant(value)} => ${quote(value)},`).join("\n")}\n }\n }\n}\n\n#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Deserialize)]\npub enum GeneratedAcpxSidecarEventType {\n${events.map((value) => ` #[serde(rename = ${quote(value)})]\n ${rustVariant(value)},`).join("\n")}\n}\n`;
|
||||
const typescript = `// Generated by scripts/generate-acpx-sidecar-contract.mjs. Do not edit.\n\nexport const GENERATED_ACPX_SIDECAR_PROTOCOL_VERSION = ${protocolVersion} as const;\nexport const GENERATED_ACPX_TURN_DISPATCH_JOURNAL_FILE = ${quote(turnDispatchJournalFile)};\nexport const GENERATED_ACPX_TURN_DISPATCH_SCHEMA = ${quote(turnDispatchSchema)};\nexport const GENERATED_ACPX_PROVIDER_TURN_ORIGIN = ${quote(providerTurnOrigin)};\nexport const GENERATED_ACPX_PROVIDER_TURN_LOST_CODE = ${quote(providerTurnLostCode)};\nexport const GENERATED_ACPX_SIDECAR_COMMANDS = [\n${commands.map((value) => ` ${quote(value)},`).join("\n")}\n] as const;\nexport type GeneratedAcpxSidecarCommand =\n (typeof GENERATED_ACPX_SIDECAR_COMMANDS)[number];\n\nexport const GENERATED_ACPX_SIDECAR_EVENT_TYPES = [\n${events.map((value) => ` ${quote(value)},`).join("\n")}\n] as const;\nexport type GeneratedAcpxSidecarEventType =\n (typeof GENERATED_ACPX_SIDECAR_EVENT_TYPES)[number];\n\nexport const GENERATED_ACPX_SIDECAR_OPEN_PARAMS = [\n${openParams.map((value) => ` ${quote(value)},`).join("\n")}\n] as const;\n\nexport const GENERATED_ACPX_SIDECAR_PROVIDER_POLICY_FIELDS = [\n${providerPolicyFields.map((value) => ` ${quote(value)},`).join("\n")}\n] as const;\n\nexport const GENERATED_ACPX_BACKGROUND_TASKS_MAX_LIVE = ${backgroundLiveMaximum};\n\nexport type GeneratedAcpxBackgroundTasks = { live: number };\n\nexport function readGeneratedAcpxBackgroundTasks(value: unknown): GeneratedAcpxBackgroundTasks | null {\n if (value === null || typeof value !== "object" || Array.isArray(value)) return null;\n const keys = Object.keys(value);\n const live = (value as Record<string, unknown>).live;\n if (keys.length !== 1 || keys[0] !== "live" || typeof live !== "number" || !Number.isInteger(live)) return null;\n return live >= 0 && live <= GENERATED_ACPX_BACKGROUND_TASKS_MAX_LIVE ? { live } : null;\n}\n\nexport type GeneratedAcpxToolOperation =\n | "read"\n | "search"\n | "list"\n | "edit"\n | "execute"\n | "unknown";\n\nexport const GENERATED_ACPX_TOOL_OPERATION_PRECEDENCE = [\n${toolOperationPrecedence.map(([operation, tokens]) => ` { operation: ${quote(operation)}, tokens: [${tokens.map(quote).join(", ")}] },`).join("\n")}\n] as const;\n\nexport function classifyGeneratedAcpxToolOperation(\n toolKind: unknown,\n toolTitle: unknown,\n): GeneratedAcpxToolOperation {\n const candidate =\n typeof toolKind === "string" && toolKind\n ? toolKind\n : typeof toolTitle === "string"\n ? toolTitle\n : "";\n const normalized = candidate.slice(0, 240).toLowerCase();\n for (const { operation, tokens } of GENERATED_ACPX_TOOL_OPERATION_PRECEDENCE) {\n if (tokens.some((token) => normalized.includes(token))) return operation;\n }\n return normalized ? "execute" : "unknown";\n}\n`;
|
||||
const rust = `// Generated by scripts/generate-acpx-sidecar-contract.mjs. Do not edit.\n\npub const GENERATED_ACPX_SIDECAR_PROTOCOL_VERSION: u64 = ${protocolVersion};\npub const GENERATED_ACPX_TURN_DISPATCH_JOURNAL_FILE: &str = ${quote(turnDispatchJournalFile)};\npub const GENERATED_ACPX_TURN_DISPATCH_SCHEMA: &str = ${quote(turnDispatchSchema)};\npub const GENERATED_ACPX_PROVIDER_TURN_ORIGIN: &str = ${quote(providerTurnOrigin)};\npub const GENERATED_ACPX_PROVIDER_TURN_LOST_CODE: &str = ${quote(providerTurnLostCode)};\npub const GENERATED_ACPX_BACKGROUND_TASKS_MAX_LIVE: u64 = ${backgroundLiveMaximum};\n\npub fn read_generated_acpx_background_tasks(value: &serde_json::Value) -> Option<u64> {\n let tasks = value.as_object()?;\n if tasks.len() != 1 {\n return None;\n }\n tasks\n .get("live")?\n .as_u64()\n .filter(|live| *live <= GENERATED_ACPX_BACKGROUND_TASKS_MAX_LIVE)\n}\n\npub const GENERATED_ACPX_TOOL_OPERATION_PRECEDENCE: &[(&str, &[&str])] = &[\n${toolOperationPrecedence.map(([operation, tokens]) => ` (${quote(operation)}, &[${tokens.map(quote).join(", ")}]),`).join("\n")}\n];\n\npub fn classify_generated_acpx_tool_operation(kind: &str, title: &str) -> &'static str {\n let kind = kind.to_ascii_lowercase();\n let title = title.to_ascii_lowercase();\n let candidate = if kind.is_empty() { &title } else { &kind };\n for (operation, tokens) in GENERATED_ACPX_TOOL_OPERATION_PRECEDENCE {\n if tokens.iter().any(|token| candidate.contains(token)) {\n return operation;\n }\n }\n if candidate.is_empty() {\n "unknown"\n } else {\n "execute"\n }\n}\n\n#[derive(Clone, Copy, Debug, PartialEq, Eq)]\npub enum GeneratedAcpxSidecarCommand {\n${commands.map((value) => ` ${rustVariant(value)},`).join("\n")}\n}\n\nimpl GeneratedAcpxSidecarCommand {\n pub const fn as_str(self) -> &'static str {\n match self {\n${commands.map((value) => ` Self::${rustVariant(value)} => ${quote(value)},`).join("\n")}\n }\n }\n}\n\n#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Deserialize)]\npub enum GeneratedAcpxSidecarEventType {\n${events.map((value) => ` #[serde(rename = ${quote(value)})]\n ${rustVariant(value)},`).join("\n")}\n}\n`;
|
||||
|
||||
// Classification must inspect the same complete provider value in both
|
||||
// languages. Display-field truncation happens only after operation selection.
|
||||
|
||||
@@ -38,6 +38,7 @@ const schemaNames = [
|
||||
"event-v2",
|
||||
"event-v3",
|
||||
"session-goal",
|
||||
"provider-turn",
|
||||
"fixture",
|
||||
];
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
export const GENERATED_ACPX_SIDECAR_PROTOCOL_VERSION = 2 as const;
|
||||
export const GENERATED_ACPX_TURN_DISPATCH_JOURNAL_FILE = "paperclip-turn-dispatch.jsonl";
|
||||
export const GENERATED_ACPX_TURN_DISPATCH_SCHEMA = "paperclip.acpx-turn-dispatch.v1";
|
||||
export const GENERATED_ACPX_PROVIDER_TURN_ORIGIN = "provider";
|
||||
export const GENERATED_ACPX_PROVIDER_TURN_LOST_CODE = "ACPX_PROVIDER_PROCESS_LOST";
|
||||
export const GENERATED_ACPX_SIDECAR_COMMANDS = [
|
||||
"initialize",
|
||||
"session.open",
|
||||
@@ -18,6 +20,7 @@ export const GENERATED_ACPX_SIDECAR_COMMANDS = [
|
||||
"session.goal.get",
|
||||
"session.goal.set",
|
||||
"session.goal.clear",
|
||||
"session.provider_turn",
|
||||
"session.suspend",
|
||||
"session.close",
|
||||
] as const;
|
||||
@@ -30,6 +33,7 @@ export const GENERATED_ACPX_SIDECAR_EVENT_TYPES = [
|
||||
"runtime.permission_requested",
|
||||
"runtime.input_requested",
|
||||
"runtime.tool_called",
|
||||
"runtime.turn_started",
|
||||
"runtime.turn_terminal",
|
||||
"runtime.process",
|
||||
"runtime.diagnostic",
|
||||
|
||||
@@ -1200,6 +1200,30 @@ export const commandV3Schema = {
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "turn.start"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"providerStartedTurns": {
|
||||
"$ref": "https://paperclip.dev/schemas/prp/v3/provider-turn.schema.json#/$defs/controllerOptIn"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
],
|
||||
"additionalProperties": true
|
||||
@@ -6806,6 +6830,54 @@ export const eventV3Schema = {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"eventType": {
|
||||
"const": "turn.started"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"origin": {
|
||||
"$ref": "https://paperclip.dev/schemas/prp/v3/provider-turn.schema.json#/$defs/origin"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"eventType": {
|
||||
"const": "turn.completed"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"awaitingProviderTurn": {
|
||||
"$ref": "https://paperclip.dev/schemas/prp/v3/provider-turn.schema.json#/$defs/awaitingProviderTurn"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
],
|
||||
"additionalProperties": true
|
||||
@@ -6974,6 +7046,24 @@ export const sessionGoalSchema = {
|
||||
}
|
||||
} as const;
|
||||
|
||||
export const providerTurnSchema = {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://paperclip.dev/schemas/prp/v3/provider-turn.schema.json",
|
||||
"title": "PRP provider-started turn markers",
|
||||
"description": "Marks a turn the provider started without a controller turn.start, a completed turn after which the Runner keeps the provider to await one, and the controller's per-turn opt-in on turn.start. Without the opt-in the Runner never awaits, never suppresses run.terminal and never surfaces a provider-started turn.",
|
||||
"$defs": {
|
||||
"origin": {
|
||||
"const": "provider"
|
||||
},
|
||||
"awaitingProviderTurn": {
|
||||
"const": true
|
||||
},
|
||||
"controllerOptIn": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
} as const;
|
||||
|
||||
export const fixtureSchema = {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://paperclip.dev/schemas/prp/v1/fixture.schema.json",
|
||||
@@ -7103,5 +7193,6 @@ export const prpSchemaBundle = {
|
||||
"event-v2": eventV2Schema,
|
||||
"event-v3": eventV3Schema,
|
||||
"session-goal": sessionGoalSchema,
|
||||
"provider-turn": providerTurnSchema,
|
||||
"fixture": fixtureSchema,
|
||||
} as const;
|
||||
@@ -4,4 +4,4 @@
|
||||
import equalModule from "ajv/dist/runtime/equal.js";
|
||||
import ucs2LengthModule from "ajv/dist/runtime/ucs2length.js";
|
||||
|
||||
"use strict";export const authCredentialsValidator: unknown = validate20;const schema31 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://paperclip.dev/schemas/prp/v1/auth-credentials.schema.json","title":"PRP credential update notification","description":"Content-free evidence of changed credentials for the harness-auth binding in this normalized session. Credential-store detection does not prove an OAuth refresh succeeded.","type":"object","required":["schema","provider","bindingId","revision","detection"],"properties":{"schema":{"const":"paperclip.auth.credentials.updated.v1"},"provider":{"type":"string","minLength":1,"maxLength":160,"pattern":"^[A-Za-z0-9][A-Za-z0-9._:-]*$"},"bindingId":{"type":"string","minLength":1,"maxLength":160,"pattern":"^[A-Za-z0-9][A-Za-z0-9._:-]*$"},"revision":{"type":"integer","minimum":1,"maximum":9007199254740991},"detection":{"enum":["credential_store","native_hook"]}},"additionalProperties":false};const func1 = typeof ucs2LengthModule === "function" ? ucs2LengthModule : ucs2LengthModule.default;const pattern4 = new RegExp("^[A-Za-z0-9][A-Za-z0-9._:-]*$", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://paperclip.dev/schemas/prp/v1/auth-credentials.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema"},message:"must have required property '"+"schema"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.provider === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "provider"},message:"must have required property '"+"provider"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.bindingId === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "bindingId"},message:"must have required property '"+"bindingId"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.revision === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.detection === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "detection"},message:"must have required property '"+"detection"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}for(const key0 in data){if(!(((((key0 === "schema") || (key0 === "provider")) || (key0 === "bindingId")) || (key0 === "revision")) || (key0 === "detection"))){const err5 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.schema !== undefined){if("paperclip.auth.credentials.updated.v1" !== data.schema){const err6 = {instancePath:instancePath+"/schema",schemaPath:"#/properties/schema/const",keyword:"const",params:{allowedValue: "paperclip.auth.credentials.updated.v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.provider !== undefined){let data1 = data.provider;if(typeof data1 === "string"){if(func1(data1) > 160){const err7 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/maxLength",keyword:"maxLength",params:{limit: 160},message:"must NOT have more than 160 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func1(data1) < 1){const err8 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(!pattern4.test(data1)){const err9 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9][A-Za-z0-9._:-]*$"},message:"must match pattern \""+"^[A-Za-z0-9][A-Za-z0-9._:-]*$"+"\""};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}else {const err10 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data.bindingId !== undefined){let data2 = data.binLine truncated
|
||||
"use strict";export const authCredentialsValidator: unknown = validate20;const schema31 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://paperclip.dev/schemas/prp/v1/auth-credentials.schema.json","title":"PRP credential update notification","description":"Content-free evidence of changed credentials for the harness-auth binding in this normalized session. Credential-store detection does not prove an OAuth refresh succeeded.","type":"object","required":["schema","provider","bindingId","revision","detection"],"properties":{"schema":{"const":"paperclip.auth.credentials.updated.v1"},"provider":{"type":"string","minLength":1,"maxLength":160,"pattern":"^[A-Za-z0-9][A-Za-z0-9._:-]*$"},"bindingId":{"type":"string","minLength":1,"maxLength":160,"pattern":"^[A-Za-z0-9][A-Za-z0-9._:-]*$"},"revision":{"type":"integer","minimum":1,"maximum":9007199254740991},"detection":{"enum":["credential_store","native_hook"]}},"additionalProperties":false};const func1 = typeof ucs2LengthModule === "function" ? ucs2LengthModule : ucs2LengthModule.default;const pattern4 = new RegExp("^[A-Za-z0-9][A-Za-z0-9._:-]*$", "u");function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://paperclip.dev/schemas/prp/v1/auth-credentials.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema"},message:"must have required property '"+"schema"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.provider === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "provider"},message:"must have required property '"+"provider"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.bindingId === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "bindingId"},message:"must have required property '"+"bindingId"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.revision === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.detection === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "detection"},message:"must have required property '"+"detection"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}for(const key0 in data){if(!(((((key0 === "schema") || (key0 === "provider")) || (key0 === "bindingId")) || (key0 === "revision")) || (key0 === "detection"))){const err5 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.schema !== undefined){if("paperclip.auth.credentials.updated.v1" !== data.schema){const err6 = {instancePath:instancePath+"/schema",schemaPath:"#/properties/schema/const",keyword:"const",params:{allowedValue: "paperclip.auth.credentials.updated.v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.provider !== undefined){let data1 = data.provider;if(typeof data1 === "string"){if(func1(data1) > 160){const err7 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/maxLength",keyword:"maxLength",params:{limit: 160},message:"must NOT have more than 160 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func1(data1) < 1){const err8 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(!pattern4.test(data1)){const err9 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9][A-Za-z0-9._:-]*$"},message:"must match pattern \""+"^[A-Za-z0-9][A-Za-z0-9._:-]*$"+"\""};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}else {const err10 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data.bindingId !== undefined){let data2 = data.binLine truncated
|
||||
@@ -289,3 +289,34 @@ test("a terminal's background task report matches the shared accepted and reject
|
||||
assert.equal(validate(terminal({ status: "completed", backgroundTasks: value })), false, name);
|
||||
}
|
||||
});
|
||||
|
||||
test("provider-started turn frames are closed and the provider-lost diagnostic is enforced only for its code", () => {
|
||||
const event = (eventType, payload, extra = {}) => ({ ...messages[2], eventType, payload, ...extra });
|
||||
assert.equal(validate(event("runtime.turn_started", { origin: "provider" }, { turnId: "provider-1" })), true, JSON.stringify(validate.errors));
|
||||
assert.equal(validate(event("runtime.turn_started", { origin: "controller" })), false);
|
||||
assert.equal(validate(event("runtime.turn_started", { origin: "provider", extra: true })), false);
|
||||
assert.equal(validate(event("runtime.turn_started", { origin: "provider" }, { turnId: null })), false);
|
||||
const diagnostic = (payload) => event("runtime.diagnostic", payload, { turnId: null });
|
||||
assert.equal(validate(diagnostic({ code: "ACPX_PROVIDER_PROCESS_LOST", message: "The provider exited." })), true, JSON.stringify(validate.errors));
|
||||
assert.equal(validate(diagnostic({ code: "ACPX_PROVIDER_PROCESS_LOST", message: "x".repeat(8_192) })), true, JSON.stringify(validate.errors));
|
||||
for (const payload of [
|
||||
{ code: "ACPX_PROVIDER_PROCESS_LOST" },
|
||||
{ code: "ACPX_PROVIDER_PROCESS_LOST", message: "x".repeat(8_193) },
|
||||
{ code: "ACPX_PROVIDER_PROCESS_LOST", message: 7 },
|
||||
{ code: "ACPX_PROVIDER_PROCESS_LOST", message: "The provider exited.", detail: "extra" },
|
||||
]) {
|
||||
assert.equal(validate(diagnostic(payload)), false, JSON.stringify(payload));
|
||||
}
|
||||
for (const payload of [
|
||||
{ code: "sidecar_input_failed", message: "Bad input." },
|
||||
{ code: "sidecar_shutdown_requested", message: "x".repeat(9_000) },
|
||||
{ code: "malformed_frame" },
|
||||
{ code: "acpx_terminal_usage_unavailable", message: "Unavailable.", detail: "extra" },
|
||||
]) {
|
||||
assert.equal(validate(diagnostic(payload)), true, JSON.stringify(payload));
|
||||
}
|
||||
const command = (params) => ({ ...messages[0], command: "session.provider_turn", params });
|
||||
assert.equal(validate(command({ turnId: "turn-1", armed: true })), true, JSON.stringify(validate.errors));
|
||||
assert.equal(validate(command({ turnId: "turn-1" })), false);
|
||||
assert.equal(validate(command({ turnId: "turn-1", armed: true, extra: 1 })), false);
|
||||
});
|
||||
@@ -27,7 +27,7 @@ async function fixture(relativePath) {
|
||||
|
||||
test("all schema IDs are unique and all external references resolve", async () => {
|
||||
const schemas = await loadSchemaCatalog(resolve(protocolRoot, "schemas"));
|
||||
assert.equal(schemas.length, 30);
|
||||
assert.equal(schemas.length, 31);
|
||||
assert.doesNotThrow(() => compileProtocolValidators(schemas));
|
||||
});
|
||||
|
||||
@@ -65,6 +65,23 @@ test("runtime activity is a closed Runner notification in every supported event
|
||||
}
|
||||
});
|
||||
|
||||
test("PRP v3 marks a provider-started turn and a completed turn that awaits one with closed values", async () => {
|
||||
const validators = compileProtocolValidators(await loadSchemaCatalog(resolve(protocolRoot, "schemas")));
|
||||
const happy = await fixture("replay/happy-path.json");
|
||||
const event = (eventType, payload) => ({ ...happy.events[0], schema: "paperclip.prp.event.v3", schemaVersion: 3, eventType, priority: 0,
|
||||
sourceKind: "runner", payload: { provider: "acpx", providerTurnId: "provider-1", ...payload } });
|
||||
assert.equal(validators.eventV3(event("turn.started", { status: "inProgress", origin: "provider" })), true);
|
||||
assert.equal(validators.eventV3(event("turn.started", { status: "inProgress" })), true);
|
||||
assert.equal(validators.eventV3(event("turn.started", { status: "inProgress", origin: "controller" })), false);
|
||||
assert.equal(validators.eventV3(event("turn.completed", { status: "completed", awaitingProviderTurn: true })), true);
|
||||
assert.equal(validators.eventV3(event("turn.completed", { status: "completed" })), true);
|
||||
assert.equal(validators.eventV3(event("turn.completed", { status: "completed", awaitingProviderTurn: false })), false);
|
||||
const command = (payload) => ({ ...happy.commands[0], schema: "paperclip.prp.command.v3", type: "turn.start", payload });
|
||||
assert.equal(validators.commandV3(command({ turnId: "turn-1", text: "Work.", providerStartedTurns: true })), true);
|
||||
assert.equal(validators.commandV3(command({ turnId: "turn-1", text: "Work." })), true);
|
||||
assert.equal(validators.commandV3(command({ turnId: "turn-1", text: "Work.", providerStartedTurns: "yes" })), false);
|
||||
});
|
||||
|
||||
test("unknown additive fields remain compatible with PRP v1", async () => {
|
||||
const value = await fixture("replay/unknown-optional-fields.json");
|
||||
assert.equal(value.futureFixtureHint.producerVersion, "1.1-preview");
|
||||
|
||||
Reference in new issue
Block a user