Skip to content

Commit a7f3888

Browse files
committed
fix(desktop): load hardened bridge runtime
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1fc19188-72f7-45c9-9cb3-fc3aad38a17c
1 parent 28ec145 commit a7f3888

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

packages/core/src/copilot-bridge.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ function responsesBody(input: RequestInit["body"]) {
390390
parallel_tool_calls: false,
391391
input: decoded.input.map((item) => {
392392
if (!isRecord(item) || item.type !== undefined || typeof item.role !== "string") return item
393+
if (item.role === "developer") return { type: "message", ...item, role: "system" }
393394
return { type: "message", ...item }
394395
}),
395396
})

packages/core/src/outbound-audit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { appendFileSync, chmodSync, mkdirSync } from "node:fs"
22
import { dirname, join } from "node:path"
3-
import { Global } from "./global"
3+
import { xdgState } from "xdg-basedir"
44
import type { Audit, AuditEvent } from "./outbound"
55

6-
export function create(file = join(Global.Path.state, "security", "outbound.jsonl")): Audit {
6+
export function create(file = join(xdgState!, "opencode", "security", "outbound.jsonl")): Audit {
77
mkdirSync(dirname(file), { recursive: true, mode: 0o700 })
88
chmodSync(dirname(file), 0o700)
99
return (event: AuditEvent) => {
@@ -15,4 +15,4 @@ export function create(file = join(Global.Path.state, "security", "outbound.json
1515
}
1616
}
1717

18-
export * as OutboundAudit from "./outbound-audit"
18+
export * as OutboundAudit from "./outbound-audit.ts"

packages/core/src/outbound.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ let installed = false
4040

4141
export class Denied extends Error {
4242
override readonly name = "OutboundPolicyDenied"
43+
readonly reason: AuditReason
4344

44-
constructor(readonly reason: AuditReason) {
45+
constructor(reason: AuditReason) {
4546
super(`Outbound request denied by workplace policy (${reason})`)
47+
this.reason = reason
4648
}
4749
}
4850

@@ -204,4 +206,4 @@ function redirectRequest(
204206
})
205207
}
206208

207-
export * as Outbound from "./outbound"
209+
export * as Outbound from "./outbound.ts"

packages/core/test/copilot-bridge.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,19 @@ describe("CopilotBridge transport", () => {
110110
store: true,
111111
previous_response_id: "untrusted",
112112
conversation: "untrusted",
113-
input: [{ role: "user", content: [{ type: "input_text", text: "hello" }] }],
113+
input: [
114+
{ role: "developer", content: "system instructions" },
115+
{ role: "user", content: [{ type: "input_text", text: "hello" }] },
116+
],
114117
}),
115118
})
116119
expect(body).toEqual({
117120
store: false,
118121
parallel_tool_calls: false,
119-
input: [{ type: "message", role: "user", content: [{ type: "input_text", text: "hello" }] }],
122+
input: [
123+
{ type: "message", role: "system", content: "system instructions" },
124+
{ type: "message", role: "user", content: [{ type: "input_text", text: "hello" }] },
125+
],
120126
})
121127
})
122128

0 commit comments

Comments
 (0)