5.13 History ​

Contract 2.0.0 · package sha256 a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e · generated from examples/section-5/5.13-history.ts by services/onsite-scripter/scripts/build-contract-docs.mjs; edit the source, not this file.

Imports: values (has, validate, the Holo*Error classes, the pure helpers) from @holostep-configurators/runtime-client, types from @holostep-configurators/runtime-client/contract, /math and /testing names from those entries; boot from the runtime module the root's loadRuntimeAtFloor resolves to. A type your page defines is your app's: declare it there, never import it from the package.

ts
import type { Reason, Session, SessionState } from '@holostep-configurators/runtime-client/contract';
declare const session: Session;
declare const signal: AbortSignal;
declare const fabricGroup: string;                                       // the GroupNode's nodeId
declare function replan(state: SessionState, reason: Reason): Promise<void>;
export async function assistantTurn(): Promise<void> {
  const turn = session.history.group({ label: 'Assistant', actor: 'assistant' });
  try {
    const r = await session.select(fabricGroup, 'velvet-blue', { expectGroup: turn, expectRevision: session.revision });   // actor comes from the group
    if (r.outcome === 'refused') await replan(session.state(), r.reason);   // 'conflict': the shopper clicked; 'busy': a write is pending
  } finally {
    turn.commit();                                                           // also after a refusal: an open group takes the app's next writes until its timeout
  }
}

Back to the examples · llms.txt