Skip to content

Commit 6287631

Browse files
karkarlCopilot
andcommitted
Merge origin/main into karkarl-reactor-version-update
Resolve docs/CHAT_VISUAL_DESIGN.md by keeping both the tail-navigation and main's question-dock/working-claw paragraphs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2 parents 746560b + ef1df54 commit 6287631

210 files changed

Lines changed: 19814 additions & 1303 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/native-gateway-from-source/SKILL.md‎

Lines changed: 247 additions & 2 deletions
Large diffs are not rendered by default.

‎.agents/skills/openclaw-proof-validation/SKILL.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ If the validation host is macOS, read [PARALLELS.md](PARALLELS.md) for the optio
2020

2121
## Required validation
2222

23+
First follow [execution-target routing](../../../docs/TEST_COVERAGE.md#choose-the-local-execution-target):
24+
app-only proof defaults to the isolated fixture Gateway; native-Gateway E2E
25+
defaults to [named side-by-side patches](../native-gateway-from-source/SKILL.md#default-multi-instance-native-gateway-testing)
26+
on an authorized, capable Windows client host, locally or in future cloud lanes.
27+
Use separate VMs for OS/clean-image isolation or unavailable host capabilities,
28+
not one VM per Gateway. Preserve required real MXC/WSL proof and explicit
29+
authority for existing shared Gateways.
30+
2331
Select the changed contract before running checks. Use the
2432
[read-only validation plan](../../../docs/TEST_COVERAGE.md#explain-the-validation-plan)
2533
to distinguish hosted lanes, mandatory local code-change closeout, and custom
@@ -59,6 +67,12 @@ Gateway pairing/provider proof. An interactive `ready` result is not a passed
5967
scenario.
6068

6169
For live app proof outside that fixture, select the Gateway before launching.
70+
For an isolated build that needs a real native Gateway, the default is the
71+
[task-owned build and named-patch workflow](../native-gateway-from-source/SKILL.md#prepare-an-isolated-test-build):
72+
build Companion in its own worktree, prepare a uniquely named Gateway patch in
73+
a task-owned work root, and launch with that patch and separate app data.
74+
The launcher's shared `npm-latest` / `packaged` defaults are not per-test
75+
instances; `-Isolated` alone does not create a unique Gateway.
6276
The [local launcher](../../../run-app-local.ps1) has these distinct effects:
6377

6478
| Option | Actual boundary |

‎.agents/skills/openclaw-testing/SKILL.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ stale. Rebuild and rerun against the new exact tree.
4343

4444
## Use the proportional ladder
4545

46+
Choose the [execution target](../../../docs/TEST_COVERAGE.md#choose-the-local-execution-target)
47+
before any authorized runtime proof. Fixture-covered app behavior stays on the
48+
deterministic fixture. Isolated test builds that need a real native Gateway
49+
default to the [task-owned build and named-patch workflow](../native-gateway-from-source/SKILL.md#prepare-an-isolated-test-build),
50+
including single-instance tests. Build Companion in its own worktree, prepare a
51+
unique patch with a task-owned work root, and select it explicitly with isolated
52+
app data. The launcher's `-Isolated` switch alone does not isolate a Gateway
53+
build or allocate a unique instance. Use separate VMs for OS/clean-image
54+
isolation or missing host capabilities; keep required real WSL/MXC proof.
55+
4656
Start at the smallest boundary that can fail for the intended regression. Move
4757
up when the change crosses another owner, transport, persistence boundary,
4858
architecture, or distribution format. Code changes still end with the required
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"use strict";
2+
3+
const MAX_LOG_BYTES = 32 * 1024 * 1024;
4+
const MAX_RESULT_CHARS = 16000;
5+
const REQUEST_TIMEOUT_MS = 60000;
6+
const UUID = /^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/;
7+
const ENDPOINTS = new Set([
8+
"https://api.githubcopilot.com", "https://api.individual.githubcopilot.com",
9+
"https://api.business.githubcopilot.com", "https://api.enterprise.githubcopilot.com",
10+
]);
11+
12+
// Same endpoint discovery and SSE transport as GitHub CLI's agent-task view.
13+
// Never derive authority from prompts, tool output, reasoning, or a branch file.
14+
async function readTaskResult(copilot, task, candidateHash) {
15+
if (!task.sessions?.length) return null;
16+
if (task.state !== "completed" || task.session_count !== 1 || task.sessions.length !== 1)
17+
throw new Error("Task result requires one completed session; reconcile manually");
18+
const session = task.sessions[0];
19+
if (!UUID.test(session.id) || session.task_id !== task.id || session.state !== "completed"
20+
|| !Number.isSafeInteger(task.repository?.id) || session.repository?.id !== task.repository.id)
21+
throw new Error("Task result session identity mismatch");
22+
const { data } = await copilot.request("POST /graphql", {
23+
query: "query { viewer { copilotEndpoints { api } } }",
24+
});
25+
const endpoint = data?.data?.viewer?.copilotEndpoints?.api;
26+
if (!ENDPOINTS.has(endpoint)) throw new Error("Unapproved Copilot result endpoint");
27+
// CAPI requires Bearer, whereas Octokit's auth hook rewrites it to token.
28+
// Obtain only this dedicated client's credential, after endpoint validation.
29+
const auth = await copilot.auth();
30+
if (auth.type !== "token" || !auth.token) throw new Error("Copilot result requires user token authentication");
31+
const response = await fetch(`${endpoint}/agents/sessions/${session.id}/logs`, {
32+
headers: { Authorization: `Bearer ${auth.token}`,
33+
"Copilot-Integration-Id": "copilot-4-cli", "X-GitHub-Api-Version": "2026-01-09" },
34+
redirect: "error", signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
35+
});
36+
if (!response.ok) throw new Error(`Copilot session log request failed: HTTP ${response.status}`);
37+
const chunks = [];
38+
let bytes = 0;
39+
for await (const chunk of response.body) {
40+
bytes += chunk.length;
41+
if (bytes > MAX_LOG_BYTES) throw new Error("Copilot session log exceeds size budget");
42+
chunks.push(Buffer.from(chunk));
43+
}
44+
let pending = null, final = null;
45+
for (const line of Buffer.concat(chunks).toString("utf8").split("\n")) {
46+
if (!line.trim()) continue;
47+
if (!line.startsWith("data: ")) throw new Error("Unexpected Copilot session log format");
48+
if (line.slice(6).trim() === "[DONE]") continue;
49+
let entry;
50+
try { entry = JSON.parse(line.slice(6)); }
51+
catch { throw new Error("Malformed Copilot session log event"); }
52+
if (entry.object !== "chat.completion.chunk") continue;
53+
if (typeof entry.id !== "string" || !entry.id) throw new Error("Missing Copilot result message identity");
54+
if (Array.isArray(entry.choices) && entry.choices.length === 0) continue;
55+
final = null;
56+
for (const choice of entry.choices ?? []) {
57+
const delta = choice.delta ?? {};
58+
if (delta.tool_calls?.length || (delta.role && delta.role !== "assistant")
59+
|| (choice.finish_reason && choice.finish_reason !== "stop")) {
60+
pending = null;
61+
continue;
62+
}
63+
// CAPI sometimes omits indexes, including in GitHub CLI's log fixtures.
64+
if ((choice.index ?? 0) !== 0 || (choice.index == null && entry.choices.length !== 1))
65+
throw new Error("Ambiguous Copilot result choice");
66+
if (delta.role === "assistant" && pending?.id !== entry.id) pending = { id: entry.id, text: "" };
67+
if (!pending || pending.id !== entry.id) continue;
68+
if (typeof delta.content === "string") pending.text += delta.content;
69+
if (pending.text.length > MAX_RESULT_CHARS) throw new Error("Copilot final answer exceeds size budget");
70+
if (choice.finish_reason === "stop") { final = pending.text.trim(); pending = null; }
71+
}
72+
}
73+
if (!final) return null;
74+
const markers = final.match(/<!-- upstream-gateway-disposition:v1:[\s\S]*?-->/g) ?? [];
75+
const match = markers.length === 1 && markers[0].match(new RegExp(
76+
"^<!-- upstream-gateway-disposition:v1:" + candidateHash
77+
+ ":(supported|intentionally-unsupported|existing-work|confirmed-gap) -->$"));
78+
if (!match || final.replace(markers[0], "").trim().length < 80) return null;
79+
return { sessionId: session.id, disposition: match[1], text: final };
80+
}
81+
82+
module.exports = { readTaskResult };

0 commit comments

Comments
 (0)