mirror of
https://github.com/wassname/pi-plan.git
synced 2026-09-26 14:10:23 +08:00
Restore bindings before model availability checks, require explicit reconnect/restart recovery, detach inactive plans, remove the general Intercom actuator, and reject placeholder evidence without hashing the plan log. Preserve synchronous handoff-before-ack; document that the void SDK cannot confirm durable message delivery.
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
export function intercomFixture() {
|
|
let autoHello = true;
|
|
let registration: any;
|
|
const sent: any[] = [];
|
|
let connected = true;
|
|
const receive = (payload: any, fromSessionId = "peer") => registration.onEvent({ type: "message", fromSessionId, payload });
|
|
return {
|
|
sent, receive,
|
|
replyToHello: (value: boolean) => { autoHello = value; },
|
|
event: (event: any) => registration.onEvent(event),
|
|
connect: (value: boolean) => { connected = value; registration.onEvent({ type: "connection", connected: value, supported: true }); },
|
|
events: {
|
|
on: () => () => {},
|
|
emit: (name: string, value: any) => {
|
|
if (name !== "intercom:extension-register") return false;
|
|
registration = value;
|
|
value.onReady({
|
|
snapshot: () => ({ connected, supported: true }),
|
|
publish: (message: any) => {
|
|
sent.push(message);
|
|
if (message.kind === "hello" && autoHello) queueMicrotask(() => receive({ ...message, role: message.role === "worker" ? "supervisor" : "worker", ready: true }));
|
|
},
|
|
});
|
|
return true;
|
|
},
|
|
},
|
|
};
|
|
}
|