Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,35 @@ export default {
resolveTransportTurnState: buildTransportTurnState,
})

if (typeof api.registerGatewayMethod === "function") api.registerGatewayMethod(
"taas.completion.deliver",
async ({ params, respond }) => {
const pp = (params ?? {}) as Record<string, unknown>
const sessionId = safeString(pp.sessionId)
const operationId = safeString(pp.operationId)
const output = safeString(pp.output)
if (!sessionId || !operationId || !output) {
respond(false, undefined, { code: "invalid_request", message: "sessionId, operationId, and output are required" })
return
}
const eventText = [
"[Requester bridge background completion]",
`operation_id=${operationId}`,
"The exact session-bound Claude Code continuation completed. Send the following completion update to the user in normal assistant voice:",
output,
].join("\n")
const queued = api.runtime.system.enqueueSystemEvent(eventText, { sessionKey: sessionId })
if (queued) api.runtime.system.requestHeartbeat({
source: "other",
intent: "immediate",
reason: "taas_completion_delivery",
sessionKey: sessionId,
})
respond(true, { ok: Boolean(queued), sessionId, operationId })
},
{ scope: "operator.write" }
)

if (typeof api.registerGatewayMethod === "function") api.registerGatewayMethod(
"taas.autorouter.lastRoute",
async ({ params, respond }) => {
Expand Down
2 changes: 1 addition & 1 deletion test/requester-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function loadPlugin(env: Record<string, string | undefined> = {}) {

function captureProvider(plugin: any) {
let provider: any
plugin.register({ registerProvider(candidate: any) { provider = candidate } })
plugin.register({ registerProvider(candidate: any) { provider = candidate }, runtime: { system: { enqueueSystemEvent: () => true, requestHeartbeat: () => {} } } })
return provider
}

Expand Down
Loading