fix(copilot): mark internal hook injections as agent-initiated
Apply the internal initiator marker to automated continuation, recovery, babysitter, stop-hook, and hook-message injections so Copilot attribution consistently sets x-initiator=agent for system-generated prompts.
This commit is contained in:
@@ -2,18 +2,26 @@ declare const require: (name: string) => any
|
||||
const { describe, expect, test } = require("bun:test")
|
||||
|
||||
import { injectContinuation } from "./continuation-injection"
|
||||
import { OMO_INTERNAL_INITIATOR_MARKER } from "../../shared/internal-initiator-marker"
|
||||
|
||||
describe("injectContinuation", () => {
|
||||
test("inherits tools from resolved message info when reinjecting", async () => {
|
||||
// given
|
||||
let capturedTools: Record<string, boolean> | undefined
|
||||
let capturedText: string | undefined
|
||||
const ctx = {
|
||||
directory: "/tmp/test",
|
||||
client: {
|
||||
session: {
|
||||
todo: async () => ({ data: [{ id: "1", content: "todo", status: "pending", priority: "high" }] }),
|
||||
promptAsync: async (input: { body: { tools?: Record<string, boolean> } }) => {
|
||||
promptAsync: async (input: {
|
||||
body: {
|
||||
tools?: Record<string, boolean>
|
||||
parts?: Array<{ type: string; text: string }>
|
||||
}
|
||||
}) => {
|
||||
capturedTools = input.body.tools
|
||||
capturedText = input.body.parts?.[0]?.text
|
||||
return {}
|
||||
},
|
||||
},
|
||||
@@ -37,5 +45,6 @@ describe("injectContinuation", () => {
|
||||
|
||||
// then
|
||||
expect(capturedTools).toEqual({ question: false, bash: true })
|
||||
expect(capturedText).toContain(OMO_INTERNAL_INITIATOR_MARKER)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
|
||||
import type { BackgroundManager } from "../../features/background-agent"
|
||||
import { normalizeSDKResponse, resolveInheritedPromptTools } from "../../shared"
|
||||
import {
|
||||
createInternalAgentTextPart,
|
||||
normalizeSDKResponse,
|
||||
resolveInheritedPromptTools,
|
||||
} from "../../shared"
|
||||
import {
|
||||
findNearestMessageWithFields,
|
||||
findNearestMessageWithFieldsFromSDK,
|
||||
@@ -151,7 +155,7 @@ ${todoList}`
|
||||
agent: agentName,
|
||||
...(model !== undefined ? { model } : {}),
|
||||
...(inheritedTools ? { tools: inheritedTools } : {}),
|
||||
parts: [{ type: "text", text: prompt }],
|
||||
parts: [createInternalAgentTextPart(prompt)],
|
||||
},
|
||||
query: { directory: ctx.directory },
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user