Files
oh-my-opencode/src/hooks/session-recovery/resume.test.ts
T
Maxim Harizanov 850fb0378e 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.
2026-02-19 13:17:02 +02:00

53 lines
1.7 KiB
TypeScript

declare const require: (name: string) => any
const { describe, expect, test } = require("bun:test")
import { extractResumeConfig, resumeSession } from "./resume"
import { OMO_INTERNAL_INITIATOR_MARKER } from "../../shared/internal-initiator-marker"
import type { MessageData } from "./types"
describe("session-recovery resume", () => {
test("extractResumeConfig carries tools from last user message", () => {
// given
const userMessage: MessageData = {
info: {
agent: "Hephaestus",
model: { providerID: "openai", modelID: "gpt-5.3-codex" },
tools: { question: false, bash: true },
},
}
// when
const config = extractResumeConfig(userMessage, "ses_resume_tools")
// then
expect(config.tools).toEqual({ question: false, bash: true })
})
test("resumeSession sends inherited tools with continuation prompt", async () => {
// given
let promptBody: Record<string, unknown> | undefined
const client = {
session: {
promptAsync: async (input: { body: Record<string, unknown> }) => {
promptBody = input.body
return {}
},
},
}
// when
const ok = await resumeSession(client as never, {
sessionID: "ses_resume_prompt",
agent: "Hephaestus",
model: { providerID: "openai", modelID: "gpt-5.3-codex" },
tools: { question: false, bash: true },
})
// then
expect(ok).toBe(true)
expect(promptBody?.tools).toEqual({ question: false, bash: true })
expect(Array.isArray(promptBody?.parts)).toBe(true)
const firstPart = (promptBody?.parts as Array<{ text?: string }>)?.[0]
expect(firstPart?.text).toContain(OMO_INTERNAL_INITIATOR_MARKER)
})
})