@prplkane/roundtable 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/snapshot.js CHANGED
@@ -40,6 +40,13 @@ function researchSnapshot(research) {
40
40
  ...(integerWithin(research.searches, 0, 9) ? { searches: research.searches } : {}) };
41
41
  }
42
42
 
43
+ // Epoch milliseconds are easy to misread across time zones, so every deadline also carries an
44
+ // ISO timestamp and the whole seconds left, both taken when the snapshot is built.
45
+ export const clock = (name, at) => at == null ? {} : {
46
+ [`${name}AtIso`]: new Date(at).toISOString(),
47
+ [`secondsUntil${name[0].toUpperCase()}${name.slice(1)}`]: Math.max(0, Math.ceil((at - Date.now()) / 1000)),
48
+ };
49
+
43
50
  // One compact, read-only view for local clients. Raw provider output and launch tokens stay out.
44
51
  export function reviewSnapshot(d) {
45
52
  const state = d.debate?.state || d.rebuilt;
@@ -59,7 +66,7 @@ export function reviewSnapshot(d) {
59
66
  attemptedCritiqueRounds: rounds.slice(1).filter((r) => r?.length === state.seats.length).length,
60
67
  completedRounds: rounds.filter((r) => hasUsableRound([r], state.seats.length)).length,
61
68
  completedCritiqueRounds: rounds.slice(1).filter((r) => hasUsableRound([r], state.seats.length)).length },
62
- deadlineAt: state.deadlineAt, stopReason: state.stopReason || null,
69
+ deadlineAt: state.deadlineAt, ...clock('deadline', state.deadlineAt), stopReason: state.stopReason || null,
63
70
  ...(state.research ? { research: researchSnapshot(state.research) } : {}),
64
71
  ...(state.stopReason ? { explanation: stopExplanation(state.stopReason, state.stopContext) } : {}),
65
72
  actions: d.finished ? (!verdict || verdict.failed || verdict.skipped) && hasUsableRound(rounds, state.seats.length) ? ['verdict'] : []
@@ -67,11 +74,11 @@ export function reviewSnapshot(d) {
67
74
  // reopenCalls: the seats already agree, so empty answers end the discussion; any answer text
68
75
  // or message runs one more round at this many calls. Absent when answering cannot reopen.
69
76
  gate: gate ? { round: gate.round, mode: gate.mode, reason: gate.reason, stop: gate.stop, questions: groupQuestions(gate.questions),
70
- autoContinueAt: d.pending.autoContinueAt ?? null, timeoutBehavior: 'continue_without_answers',
77
+ autoContinueAt: d.pending.autoContinueAt ?? null, ...clock('autoContinue', d.pending.autoContinueAt), timeoutBehavior: 'continue_without_answers',
71
78
  ...(gate.reopenable ? { reopenCalls: (state.seats || []).length } : {}) } : null,
72
79
  nextAction: gate?.questions.length ? {
73
80
  type: 'ask_user',
74
- instruction: 'Ask gate.questions using your available user-input tool. If there is no form, ask in chat. Group overlapping questions without losing their IDs. Do not invent answers. Tell the user when the response window closes; unanswered questions remain unknown. Read status before submitting a reply because the review may have continued.',
81
+ instruction: 'Ask gate.questions using your available user-input tool. If there is no form, ask in chat. Group overlapping questions without losing their IDs. Do not invent answers. Tell the user when the response window closes (gate.secondsUntilAutoContinue); unanswered questions remain unknown. Read status before submitting a reply because the review may have continued. Mark each answer from: "user" only when it is the user\'s own reply; from: "assistant" when you supplied it yourself with the user\'s permission.',
75
82
  answerTemplate: { round: gate.round, answers: groupQuestions(gate.questions).map((q) => ({ id: q.id, text: '' })) },
76
83
  } : { type: gate || ['researching', 'running', 'verdict'].includes(status) ? 'wait'
77
84
  : status === 'done' && sections ? 'report_result' : 'report_incomplete',