@h-rig/contracts 0.0.6-alpha.103 → 0.0.6-alpha.119

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/dist/src/index.js CHANGED
@@ -1738,6 +1738,85 @@ function parseStopSentinel(text, expectedRunId) {
1738
1738
  const reason = body.match(/(?:^|\s)reason=(.+)$/)?.[1]?.trim() ?? null;
1739
1739
  return { reason };
1740
1740
  }
1741
+ var RIG_PAUSE_SENTINEL = "<<RIG_PAUSE";
1742
+ var RIG_RESUME_SENTINEL = "<<RIG_RESUME";
1743
+ var RIG_CONTROL_SENTINEL_END = ">>";
1744
+ function buildControlSentinel(marker, runId, requestedBy) {
1745
+ return `${marker} runId=${runId} requestedBy=${requestedBy}${RIG_CONTROL_SENTINEL_END}`;
1746
+ }
1747
+ function parseControlSentinel(marker, text, expectedRunId) {
1748
+ const start = text.indexOf(marker);
1749
+ if (start < 0)
1750
+ return null;
1751
+ const end = text.indexOf(RIG_CONTROL_SENTINEL_END, start);
1752
+ const body = text.slice(start + marker.length, end >= 0 ? end : undefined).trim();
1753
+ const runId = body.match(/(?:^|\s)runId=([^\s>]+)/)?.[1] ?? "";
1754
+ if (runId && runId !== expectedRunId)
1755
+ return null;
1756
+ const requestedBy = body.match(/(?:^|\s)requestedBy=([^\s>]+)/)?.[1] ?? null;
1757
+ return { requestedBy };
1758
+ }
1759
+ function buildPauseSentinel(runId, requestedBy = "rig") {
1760
+ return buildControlSentinel(RIG_PAUSE_SENTINEL, runId, requestedBy);
1761
+ }
1762
+ function parsePauseSentinel(text, expectedRunId) {
1763
+ return parseControlSentinel(RIG_PAUSE_SENTINEL, text, expectedRunId);
1764
+ }
1765
+ function buildResumeSentinel(runId, requestedBy = "rig") {
1766
+ return buildControlSentinel(RIG_RESUME_SENTINEL, runId, requestedBy);
1767
+ }
1768
+ function parseResumeSentinel(text, expectedRunId) {
1769
+ return parseControlSentinel(RIG_RESUME_SENTINEL, text, expectedRunId);
1770
+ }
1771
+ var RIG_INBOX_RESOLUTION_SENTINEL = "<<RIG_INBOX_RESOLUTION";
1772
+ function encodeInboxResolutionPayload(payload) {
1773
+ return encodeURIComponent(JSON.stringify(payload));
1774
+ }
1775
+ function decodeInboxResolutionPayload(payload) {
1776
+ try {
1777
+ const parsed = JSON.parse(decodeURIComponent(payload));
1778
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
1779
+ return null;
1780
+ const record = parsed;
1781
+ if (record.kind === "approval") {
1782
+ const requestId = typeof record.requestId === "string" ? record.requestId.trim() : "";
1783
+ const decision = record.decision === "approve" || record.decision === "reject" ? record.decision : null;
1784
+ const note = typeof record.note === "string" ? record.note : record.note === null ? null : undefined;
1785
+ if (!requestId || !decision)
1786
+ return null;
1787
+ return { kind: "approval", requestId, decision, ...note !== undefined ? { note } : {} };
1788
+ }
1789
+ if (record.kind === "input") {
1790
+ const requestId = typeof record.requestId === "string" ? record.requestId.trim() : "";
1791
+ const answers = record.answers && typeof record.answers === "object" && !Array.isArray(record.answers) ? Object.fromEntries(Object.entries(record.answers).filter((entry) => typeof entry[1] === "string")) : null;
1792
+ if (!requestId || !answers)
1793
+ return null;
1794
+ return { kind: "input", requestId, answers };
1795
+ }
1796
+ } catch {
1797
+ return null;
1798
+ }
1799
+ return null;
1800
+ }
1801
+ function buildInboxResolutionSentinel(runId, resolution, requestedBy = "rig") {
1802
+ return `${RIG_INBOX_RESOLUTION_SENTINEL} runId=${runId} requestedBy=${requestedBy} data=${encodeInboxResolutionPayload(resolution)}${RIG_CONTROL_SENTINEL_END}`;
1803
+ }
1804
+ function parseInboxResolutionSentinel(text, expectedRunId) {
1805
+ const start = text.indexOf(RIG_INBOX_RESOLUTION_SENTINEL);
1806
+ if (start < 0)
1807
+ return null;
1808
+ const end = text.indexOf(RIG_CONTROL_SENTINEL_END, start);
1809
+ const body = text.slice(start + RIG_INBOX_RESOLUTION_SENTINEL.length, end >= 0 ? end : undefined).trim();
1810
+ const runId = body.match(/(?:^|\s)runId=([^\s>]+)/)?.[1] ?? "";
1811
+ if (runId && runId !== expectedRunId)
1812
+ return null;
1813
+ const requestedBy = body.match(/(?:^|\s)requestedBy=([^\s>]+)/)?.[1] ?? null;
1814
+ const payload = body.match(/(?:^|\s)data=([^\s>]+)/)?.[1] ?? "";
1815
+ const decoded = decodeInboxResolutionPayload(payload);
1816
+ if (!decoded)
1817
+ return null;
1818
+ return { ...decoded, requestedBy };
1819
+ }
1741
1820
  function sessionIdFromSessionFile(sessionPath) {
1742
1821
  if (!sessionPath)
1743
1822
  return null;
@@ -1796,6 +1875,384 @@ function foldRunSessionEntries(entries, runId) {
1796
1875
  });
1797
1876
  return reduceRunJournal(events);
1798
1877
  }
1878
+ // packages/contracts/src/workflow-journal.ts
1879
+ var RIG_WORKFLOW_STARTED = "rig.workflow.started";
1880
+ var RIG_WORKFLOW_TARGET_SELECTED = "rig.workflow.target.selected";
1881
+ var RIG_WORKFLOW_TASK_SELECTED = "rig.workflow.task.selected";
1882
+ var RIG_WORKFLOW_STATUS_CHANGED = "rig.workflow.status.changed";
1883
+ var RIG_WORKFLOW_OPERATOR_NOTE = "rig.workflow.operator.note";
1884
+ var RIG_WORKFLOW_INBOX_REQUESTED = "rig.workflow.inbox.requested";
1885
+ var RIG_WORKFLOW_INBOX_RESOLVED = "rig.workflow.inbox.resolved";
1886
+ var EMPTY_PROJECTION = {
1887
+ started: null,
1888
+ target: null,
1889
+ task: null,
1890
+ status: null,
1891
+ notes: [],
1892
+ inbox: [],
1893
+ resolvedInbox: [],
1894
+ updatedAt: null
1895
+ };
1896
+ function asRecord(value) {
1897
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
1898
+ }
1899
+ function optionalString(value) {
1900
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
1901
+ }
1902
+ function requiredString(value) {
1903
+ const text = optionalString(value);
1904
+ return text ?? null;
1905
+ }
1906
+ function timestamp(value) {
1907
+ const text = requiredString(value);
1908
+ if (!text)
1909
+ return null;
1910
+ const millis = Date.parse(text);
1911
+ return Number.isFinite(millis) ? text : null;
1912
+ }
1913
+ function newer(left, right) {
1914
+ if (!right)
1915
+ return false;
1916
+ if (!left)
1917
+ return true;
1918
+ return Date.parse(right) >= Date.parse(left);
1919
+ }
1920
+ function isWorkflowTarget(value) {
1921
+ return value === "local" || value === "remote";
1922
+ }
1923
+ function isWorkflowStatus(value) {
1924
+ return value === "starting" || value === "running" || value === "waiting-approval" || value === "waiting-input" || value === "completed" || value === "failed" || value === "stopped";
1925
+ }
1926
+ function isInboxKind(value) {
1927
+ return value === "approval" || value === "input";
1928
+ }
1929
+ function isInboxDecision(value) {
1930
+ return value === "approved" || value === "rejected" || value === "answered";
1931
+ }
1932
+ function parseOwner(value) {
1933
+ const record = asRecord(value);
1934
+ if (!record)
1935
+ return null;
1936
+ const githubUserId = requiredString(record.githubUserId);
1937
+ const login = requiredString(record.login);
1938
+ const namespaceKey = requiredString(record.namespaceKey);
1939
+ return githubUserId && login && namespaceKey ? { githubUserId, login, namespaceKey } : null;
1940
+ }
1941
+ function parseStringArray(value) {
1942
+ if (!Array.isArray(value))
1943
+ return;
1944
+ const options = value.map(optionalString).filter((option) => option !== undefined);
1945
+ return options.length > 0 ? options : undefined;
1946
+ }
1947
+ function hasOwn(record, key) {
1948
+ return Object.prototype.hasOwnProperty.call(record, key);
1949
+ }
1950
+ function entryUpdatedAt(entry) {
1951
+ if ("createdAt" in entry)
1952
+ return entry.createdAt;
1953
+ if ("selectedAt" in entry)
1954
+ return entry.selectedAt;
1955
+ if ("changedAt" in entry)
1956
+ return entry.changedAt;
1957
+ if ("notedAt" in entry)
1958
+ return entry.notedAt;
1959
+ if ("requestedAt" in entry)
1960
+ return entry.requestedAt;
1961
+ return entry.resolvedAt;
1962
+ }
1963
+ function createWorkflowStarted(input) {
1964
+ return {
1965
+ schemaVersion: 1,
1966
+ workflowId: input.workflowId,
1967
+ target: input.target,
1968
+ selectedRepo: input.selectedRepo,
1969
+ owner: input.owner,
1970
+ createdAt: input.createdAt ?? new Date().toISOString()
1971
+ };
1972
+ }
1973
+ function createWorkflowTargetSelected(input) {
1974
+ return {
1975
+ schemaVersion: 1,
1976
+ target: input.target,
1977
+ ...input.reason ? { reason: input.reason } : {},
1978
+ selectedAt: input.selectedAt ?? new Date().toISOString()
1979
+ };
1980
+ }
1981
+ function createWorkflowTaskSelected(input) {
1982
+ return {
1983
+ schemaVersion: 1,
1984
+ taskId: input.taskId,
1985
+ ...input.title ? { title: input.title } : {},
1986
+ selectedAt: input.selectedAt ?? new Date().toISOString()
1987
+ };
1988
+ }
1989
+ function createWorkflowStatusChanged(input) {
1990
+ return {
1991
+ schemaVersion: 1,
1992
+ status: input.status,
1993
+ ...input.detail ? { detail: input.detail } : {},
1994
+ changedAt: input.changedAt ?? new Date().toISOString()
1995
+ };
1996
+ }
1997
+ function createWorkflowOperatorNote(input) {
1998
+ return {
1999
+ schemaVersion: 1,
2000
+ ...input.noteId ? { noteId: input.noteId } : {},
2001
+ note: input.note,
2002
+ notedAt: input.notedAt ?? new Date().toISOString()
2003
+ };
2004
+ }
2005
+ function createWorkflowInboxRequested(input) {
2006
+ return {
2007
+ schemaVersion: 1,
2008
+ requestId: input.requestId,
2009
+ kind: input.kind,
2010
+ title: input.title,
2011
+ ...input.body ? { body: input.body } : {},
2012
+ ...input.options && input.options.length > 0 ? { options: input.options } : {},
2013
+ requestedAt: input.requestedAt ?? new Date().toISOString()
2014
+ };
2015
+ }
2016
+ function createWorkflowInboxResolved(input) {
2017
+ const base = {
2018
+ schemaVersion: 1,
2019
+ requestId: input.requestId,
2020
+ decision: input.decision,
2021
+ resolvedAt: input.resolvedAt ?? new Date().toISOString()
2022
+ };
2023
+ return hasOwn(input, "answer") ? { ...base, answer: input.answer } : base;
2024
+ }
2025
+ function parseWorkflowStarted(data) {
2026
+ const record = asRecord(data);
2027
+ if (!record || record.schemaVersion !== 1)
2028
+ return null;
2029
+ const workflowId = requiredString(record.workflowId);
2030
+ const target = optionalString(record.target);
2031
+ const selectedRepo = requiredString(record.selectedRepo);
2032
+ const owner = parseOwner(record.owner);
2033
+ const createdAt = timestamp(record.createdAt);
2034
+ if (!workflowId || !isWorkflowTarget(target) || !selectedRepo || !owner || !createdAt)
2035
+ return null;
2036
+ return {
2037
+ schemaVersion: 1,
2038
+ workflowId,
2039
+ target,
2040
+ selectedRepo,
2041
+ owner,
2042
+ createdAt
2043
+ };
2044
+ }
2045
+ function parseWorkflowTargetSelected(data) {
2046
+ const record = asRecord(data);
2047
+ if (!record || record.schemaVersion !== 1)
2048
+ return null;
2049
+ const target = optionalString(record.target);
2050
+ const selectedAt = timestamp(record.selectedAt);
2051
+ if (!isWorkflowTarget(target) || !selectedAt)
2052
+ return null;
2053
+ const reason = optionalString(record.reason);
2054
+ return {
2055
+ schemaVersion: 1,
2056
+ target,
2057
+ ...reason ? { reason } : {},
2058
+ selectedAt
2059
+ };
2060
+ }
2061
+ function parseWorkflowTaskSelected(data) {
2062
+ const record = asRecord(data);
2063
+ if (!record || record.schemaVersion !== 1)
2064
+ return null;
2065
+ const taskId = requiredString(record.taskId);
2066
+ const selectedAt = timestamp(record.selectedAt);
2067
+ if (!taskId || !selectedAt)
2068
+ return null;
2069
+ const title = optionalString(record.title);
2070
+ return { schemaVersion: 1, taskId, ...title ? { title } : {}, selectedAt };
2071
+ }
2072
+ function parseWorkflowStatusChanged(data) {
2073
+ const record = asRecord(data);
2074
+ if (!record || record.schemaVersion !== 1)
2075
+ return null;
2076
+ const status = optionalString(record.status);
2077
+ const changedAt = timestamp(record.changedAt);
2078
+ if (!changedAt || !isWorkflowStatus(status))
2079
+ return null;
2080
+ const detail = optionalString(record.detail);
2081
+ return { schemaVersion: 1, status, ...detail ? { detail } : {}, changedAt };
2082
+ }
2083
+ function parseWorkflowOperatorNote(data) {
2084
+ const record = asRecord(data);
2085
+ if (!record || record.schemaVersion !== 1)
2086
+ return null;
2087
+ const note = requiredString(record.note);
2088
+ const notedAt = timestamp(record.notedAt);
2089
+ if (!note || !notedAt)
2090
+ return null;
2091
+ const noteId = optionalString(record.noteId);
2092
+ return { schemaVersion: 1, ...noteId ? { noteId } : {}, note, notedAt };
2093
+ }
2094
+ function parseWorkflowInboxRequested(data) {
2095
+ const record = asRecord(data);
2096
+ if (!record || record.schemaVersion !== 1)
2097
+ return null;
2098
+ const requestId = requiredString(record.requestId);
2099
+ const kind = optionalString(record.kind);
2100
+ const title = requiredString(record.title);
2101
+ const requestedAt = timestamp(record.requestedAt);
2102
+ if (!requestId || !isInboxKind(kind) || !title || !requestedAt)
2103
+ return null;
2104
+ const body = optionalString(record.body);
2105
+ const options = parseStringArray(record.options);
2106
+ return {
2107
+ schemaVersion: 1,
2108
+ requestId,
2109
+ kind,
2110
+ title,
2111
+ ...body ? { body } : {},
2112
+ ...options ? { options } : {},
2113
+ requestedAt
2114
+ };
2115
+ }
2116
+ function parseWorkflowInboxResolved(data) {
2117
+ const record = asRecord(data);
2118
+ if (!record || record.schemaVersion !== 1)
2119
+ return null;
2120
+ const requestId = requiredString(record.requestId);
2121
+ const decision = optionalString(record.decision);
2122
+ const resolvedAt = timestamp(record.resolvedAt);
2123
+ if (!requestId || !isInboxDecision(decision) || !resolvedAt)
2124
+ return null;
2125
+ const base = { schemaVersion: 1, requestId, decision, resolvedAt };
2126
+ return hasOwn(record, "answer") ? { ...base, answer: record.answer } : base;
2127
+ }
2128
+ function collectPendingInboxRequests(entries) {
2129
+ const requested = new Map;
2130
+ const resolved = new Map;
2131
+ for (const entry of entries) {
2132
+ if (entry.type !== "custom")
2133
+ continue;
2134
+ if (entry.customType === RIG_WORKFLOW_INBOX_REQUESTED) {
2135
+ const request = parseWorkflowInboxRequested(entry.data);
2136
+ if (request && newer(requested.get(request.requestId)?.requestedAt, request.requestedAt))
2137
+ requested.set(request.requestId, request);
2138
+ } else if (entry.customType === RIG_WORKFLOW_INBOX_RESOLVED) {
2139
+ const resolution = parseWorkflowInboxResolved(entry.data);
2140
+ if (resolution && newer(resolved.get(resolution.requestId), resolution.resolvedAt))
2141
+ resolved.set(resolution.requestId, resolution.resolvedAt);
2142
+ }
2143
+ }
2144
+ for (const [requestId, request] of requested) {
2145
+ const resolvedAt = resolved.get(requestId);
2146
+ if (resolvedAt && Date.parse(resolvedAt) >= Date.parse(request.requestedAt))
2147
+ requested.delete(requestId);
2148
+ }
2149
+ return Array.from(requested.values()).sort((a, b) => Date.parse(b.requestedAt) - Date.parse(a.requestedAt));
2150
+ }
2151
+ function collectResolvedInboxRequests(entries) {
2152
+ const requested = new Map;
2153
+ const resolved = new Map;
2154
+ for (const entry of entries) {
2155
+ if (entry.type !== "custom")
2156
+ continue;
2157
+ if (entry.customType === RIG_WORKFLOW_INBOX_REQUESTED) {
2158
+ const request = parseWorkflowInboxRequested(entry.data);
2159
+ if (request && newer(requested.get(request.requestId), request.requestedAt))
2160
+ requested.set(request.requestId, request.requestedAt);
2161
+ } else if (entry.customType === RIG_WORKFLOW_INBOX_RESOLVED) {
2162
+ const resolution = parseWorkflowInboxResolved(entry.data);
2163
+ if (resolution && newer(resolved.get(resolution.requestId)?.resolvedAt, resolution.resolvedAt)) {
2164
+ resolved.set(resolution.requestId, resolution);
2165
+ }
2166
+ }
2167
+ }
2168
+ for (const [requestId, resolution] of resolved) {
2169
+ const requestedAt = requested.get(requestId);
2170
+ if (requestedAt && Date.parse(requestedAt) > Date.parse(resolution.resolvedAt))
2171
+ resolved.delete(requestId);
2172
+ }
2173
+ return Array.from(resolved.values()).sort((a, b) => Date.parse(b.resolvedAt) - Date.parse(a.resolvedAt));
2174
+ }
2175
+ function projectCollabWorkflowMarker(collab) {
2176
+ const status = createWorkflowStatusChanged({
2177
+ status: collab.stale ? "stopped" : "running",
2178
+ detail: collab.stale ? "Stale OMP collab session discovered from the sanctioned collab registry." : "Live OMP collab session discovered from the sanctioned collab registry.",
2179
+ changedAt: collab.updatedAt
2180
+ });
2181
+ return {
2182
+ started: null,
2183
+ target: null,
2184
+ task: null,
2185
+ status,
2186
+ notes: [],
2187
+ inbox: [],
2188
+ resolvedInbox: [],
2189
+ updatedAt: newer(collab.startedAt, collab.updatedAt) ? collab.updatedAt : collab.startedAt
2190
+ };
2191
+ }
2192
+ function projectWorkflowEntries(entries) {
2193
+ let started = null;
2194
+ let target = null;
2195
+ let task = null;
2196
+ let status = null;
2197
+ const notes = [];
2198
+ let updatedAt = null;
2199
+ for (const entry of entries) {
2200
+ if (entry.type !== "custom")
2201
+ continue;
2202
+ if (entry.customType === RIG_WORKFLOW_STARTED) {
2203
+ const parsed = parseWorkflowStarted(entry.data);
2204
+ if (parsed && newer(started?.createdAt, parsed.createdAt))
2205
+ started = parsed;
2206
+ } else if (entry.customType === RIG_WORKFLOW_TARGET_SELECTED) {
2207
+ const parsed = parseWorkflowTargetSelected(entry.data);
2208
+ if (parsed && newer(target?.selectedAt, parsed.selectedAt))
2209
+ target = parsed;
2210
+ } else if (entry.customType === RIG_WORKFLOW_TASK_SELECTED) {
2211
+ const parsed = parseWorkflowTaskSelected(entry.data);
2212
+ if (parsed && newer(task?.selectedAt, parsed.selectedAt))
2213
+ task = parsed;
2214
+ } else if (entry.customType === RIG_WORKFLOW_STATUS_CHANGED) {
2215
+ const parsed = parseWorkflowStatusChanged(entry.data);
2216
+ if (parsed && newer(status?.changedAt, parsed.changedAt))
2217
+ status = parsed;
2218
+ } else if (entry.customType === RIG_WORKFLOW_OPERATOR_NOTE) {
2219
+ const parsed = parseWorkflowOperatorNote(entry.data);
2220
+ if (parsed)
2221
+ notes.push(parsed);
2222
+ }
2223
+ }
2224
+ notes.sort((a, b) => Date.parse(b.notedAt) - Date.parse(a.notedAt));
2225
+ for (const value of [started, target, task, status, ...notes].map((entry) => entry ? entryUpdatedAt(entry) : null)) {
2226
+ if (newer(updatedAt, value))
2227
+ updatedAt = value;
2228
+ }
2229
+ const inbox = collectPendingInboxRequests(entries);
2230
+ const resolvedInbox = collectResolvedInboxRequests(entries);
2231
+ for (const entry of [...inbox, ...resolvedInbox]) {
2232
+ if (newer(updatedAt, entryUpdatedAt(entry)))
2233
+ updatedAt = entryUpdatedAt(entry);
2234
+ }
2235
+ if (!started && !target && !task && !status && notes.length === 0 && inbox.length === 0 && resolvedInbox.length === 0 && !updatedAt)
2236
+ return EMPTY_PROJECTION;
2237
+ return { started, target, task, status, notes, inbox, resolvedInbox, updatedAt };
2238
+ }
2239
+ // packages/contracts/src/run-timeline.ts
2240
+ function isRecord(value) {
2241
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
2242
+ }
2243
+ function timelineEntriesFromCustomEntries(entries) {
2244
+ return entries.flatMap((entry) => {
2245
+ if (entry.customType !== CUSTOM_TYPE_FOR["timeline-entry"] || !isRecord(entry.data))
2246
+ return [];
2247
+ const payload = isRecord(entry.data.payload) ? entry.data.payload : entry.data;
2248
+ const type = typeof payload.type === "string" ? payload.type : "timeline";
2249
+ const stage = typeof payload.stage === "string" ? payload.stage : typeof payload.name === "string" ? payload.name : null;
2250
+ const status = typeof payload.status === "string" ? payload.status : typeof payload.outcome === "string" ? payload.outcome : null;
2251
+ const detail = typeof payload.detail === "string" ? payload.detail : typeof payload.message === "string" ? payload.message : null;
2252
+ const at = typeof entry.data.at === "string" ? entry.data.at : typeof payload.at === "string" ? payload.at : null;
2253
+ return [{ at, type, stage, status, detail }];
2254
+ });
2255
+ }
1799
2256
  // packages/contracts/src/run-status.ts
1800
2257
  var OPERATOR_INACTIVE_RUN_STATUSES = new Set([
1801
2258
  "completed",
@@ -4983,14 +5440,15 @@ var TOP_LEVEL_SECTIONS = [
4983
5440
  subtitle: "every run is an isolated, collaborative OMP session on the selected target",
4984
5441
  commands: [
4985
5442
  {
4986
- command: "rig run start <task|#issue|--next>",
5443
+ command: "rig run [start] <task|#issue|--next>",
4987
5444
  description: "Dispatch a run for a task (refuses if one is already active; --force overrides).",
4988
5445
  usecase: "Kick off work on a specific issue, or let Rig pick the next ready one.",
4989
5446
  examples: [
4990
- "rig run start 204 # by task/issue id",
4991
- "rig run start --next # next ready task by deps/priority",
5447
+ "rig run 204 # by task/issue id",
5448
+ "rig run --next # next ready task by deps/priority",
5449
+ "rig run --title 'Fix API' 204 # title override before the task ref",
4992
5450
  "rig run start 204 --force # dispatch even if a run is already active",
4993
- "rig run start 204 --model opus-4.8 # override the agent model"
5451
+ "rig run start 204 --model opus-4.8 --prompt 'focus tests'"
4994
5452
  ]
4995
5453
  },
4996
5454
  {
@@ -5035,15 +5493,27 @@ var TOP_LEVEL_SECTIONS = [
5035
5493
  },
5036
5494
  {
5037
5495
  command: "rig run stop <id> [--reason <text>]",
5038
- description: "Request a graceful stop of a run.",
5496
+ description: "Request a graceful stop of a run (terminal).",
5039
5497
  usecase: "Halt a run that's off-track or no longer needed.",
5040
5498
  examples: ["rig run stop 019ee11f", "rig run stop 019ee11f --reason 'superseded by #210'"]
5041
5499
  },
5042
5500
  {
5043
- command: "rig run resume|restart <id>",
5044
- description: "Re-dispatch a task (detached runs start fresh).",
5501
+ command: "rig run pause <id>",
5502
+ description: "Park a live run (running \u2192 paused) without finalizing; the session stays attachable.",
5503
+ usecase: "Hold an autonomous run mid-flight \u2014 free the agent without losing its place.",
5504
+ examples: ["rig run pause 019ee11f"]
5505
+ },
5506
+ {
5507
+ command: "rig run resume <id>",
5508
+ description: "Resume a paused run (paused \u2192 running); the agent continues. A dead/stale run is re-dispatched fresh instead.",
5509
+ usecase: "Un-pause a parked run, or retry a finished one.",
5510
+ examples: ["rig run resume 019ee11f"]
5511
+ },
5512
+ {
5513
+ command: "rig run restart <id>",
5514
+ description: "Re-dispatch a task as a fresh run (new runId, clean runtime).",
5045
5515
  usecase: "Retry a failed/stopped run from a clean slate.",
5046
- examples: ["rig run restart 019ee11f", "rig run resume 019ee11f"]
5516
+ examples: ["rig run restart 019ee11f"]
5047
5517
  },
5048
5518
  {
5049
5519
  command: "rig run timeline|replay <id>",
@@ -5059,12 +5529,12 @@ var TOP_LEVEL_SECTIONS = [
5059
5529
  subtitle: "github-issues / files task sources feed dispatch",
5060
5530
  commands: [
5061
5531
  {
5062
- command: "rig task list [--search <t>] [--status <s>]",
5532
+ command: "rig task list [--search <t>] [--state <open|closed>]",
5063
5533
  description: "List tasks from the configured source, with filters.",
5064
5534
  usecase: "Find what's available to dispatch; filter by text or lifecycle status.",
5065
5535
  examples: [
5066
5536
  "rig task list",
5067
- "rig task list --status open",
5537
+ "rig task list --state open",
5068
5538
  "rig task list --search 'auth'"
5069
5539
  ]
5070
5540
  },
@@ -5076,10 +5546,10 @@ var TOP_LEVEL_SECTIONS = [
5076
5546
  examples: ["rig task show 204", "rig task info 204"]
5077
5547
  },
5078
5548
  {
5079
- command: "rig task scope|deps|status <id>",
5080
- description: "Inspect a task's scope globs, dependencies, or lifecycle status.",
5549
+ command: "rig task scope|deps --task <id>; rig task status",
5550
+ description: "Inspect a task's scope globs/dependencies, or show project task status.",
5081
5551
  usecase: "Check what files a run may touch / what's blocking it.",
5082
- examples: ["rig task scope 204", "rig task deps 204", "rig task status 204"]
5552
+ examples: ["rig task scope --task 204", "rig task deps --task 204", "rig task status"]
5083
5553
  },
5084
5554
  { command: "rig task lookup <term>", description: "Find a task by id/title substring.", examples: ["rig task lookup revoke-invite"] },
5085
5555
  { command: "rig task record \u2026", description: "Write task state/metadata back to the source.", usecase: "Programmatically update task lifecycle from scripts/CI." },
@@ -5132,20 +5602,19 @@ var TOP_LEVEL_SECTIONS = [
5132
5602
  title: "Placement & target \u2014 local vs remote execution",
5133
5603
  subtitle: "where runs execute; the backbone relay/registry is shared",
5134
5604
  commands: [
5135
- { command: "rig server status", description: "Show the selected placement (local/remote) and project-root link.", examples: ["rig server status"] },
5605
+ { command: "rig server status", description: "Show the selected placement (local/remote) and task source.", examples: ["rig server status"] },
5136
5606
  { command: "rig server list", description: "List configured server targets.", examples: ["rig server list"] },
5137
5607
  {
5138
- command: "rig server use <alias>",
5608
+ command: "rig server use <local|alias>",
5139
5609
  description: "Select a server target (execution placement).",
5140
5610
  usecase: "Switch a repo between local and a remote host for run execution.",
5141
5611
  examples: ["rig server use local", "rig server use prod-box"]
5142
5612
  },
5143
5613
  {
5144
- command: "rig server add|remove <alias>",
5614
+ command: "rig server add --alias <alias> --host <host> [--port <n>] | remove <alias>",
5145
5615
  description: "Configure or remove a remote server target.",
5146
- examples: ["rig server add prod-box ubuntu@host", "rig server remove prod-box"]
5616
+ examples: ["rig server add --alias prod-box --host ubuntu@host", "rig server remove prod-box"]
5147
5617
  },
5148
- { command: "rig server repair-link", description: "Repair the project-root link for the selected target.", usecase: "Fix a remote that shows unavailable after a host/checkout change.", examples: ["rig server repair-link"] },
5149
5618
  {
5150
5619
  command: "rig remote <list|add|test|status|\u2026>",
5151
5620
  description: "Lower-level remote endpoint management + run control over a remote.",
@@ -5164,10 +5633,10 @@ var TOP_LEVEL_SECTIONS = [
5164
5633
  examples: ["rig inbox approvals", "rig inbox inputs"]
5165
5634
  },
5166
5635
  {
5167
- command: "rig inbox approve <id> | respond <id> <text>",
5168
- description: "Approve an entry or answer a user-input prompt.",
5169
- usecase: "Unblock a paused run from the CLI.",
5170
- examples: ["rig inbox approve abc123", "rig inbox respond abc123 'use option B'"]
5636
+ command: "rig inbox approve --run <id> --request <id> --decision approve|reject | respond --run <id> --request <id> --text <answer>",
5637
+ description: "Attempt to resolve an approval or answer a user-input prompt; attach if one-shot delivery is unavailable.",
5638
+ usecase: "Resolve pending requests from automation when the live run accepts out-of-band resolution.",
5639
+ examples: ["rig inbox approve --run run1 --request abc123 --decision approve", "rig inbox respond --run run1 --request abc123 --text 'use option B'"]
5171
5640
  },
5172
5641
  { command: "rig inbox watch", description: "Stream inbox changes live.", examples: ["rig inbox watch"] },
5173
5642
  { command: "rig doctor", description: "Cheap health checks: session discovery, registry, selected target, workflow entries.", usecase: "First thing to run when something seems off.", examples: ["rig doctor"] }
@@ -5178,14 +5647,14 @@ var TOP_LEVEL_SECTIONS = [
5178
5647
  subtitle: "logs, artifacts, diffs, failure analysis",
5179
5648
  commands: [
5180
5649
  {
5181
- command: "rig inspect run-logs|logs --run <id>",
5182
- description: "Tail a run's process / session logs.",
5650
+ command: "rig inspect run-logs --run <id> | logs --task <id>",
5651
+ description: "Print run/session log lines.",
5183
5652
  usecase: "Debug why a run failed or stalled.",
5184
- examples: ["rig inspect run-logs --run 019ee11f", "rig inspect logs --run 019ee11f"]
5653
+ examples: ["rig inspect run-logs --run 019ee11f", "rig inspect logs --task 204"]
5185
5654
  },
5186
5655
  { command: "rig inspect runs", description: "List runs from on-disk runtime state.", examples: ["rig inspect runs"] },
5187
- { command: "rig inspect artifact(s) --task <id>", description: "Inspect a task/run's artifacts.", examples: ["rig inspect artifacts --task 204"] },
5188
- { command: "rig inspect diff|graph", description: "Run diff / task dependency graph.", examples: ["rig inspect diff", "rig inspect graph"] },
5656
+ { command: "rig inspect artifact --task <id> --file <name> | artifacts --task <id>", description: "Inspect a task/run's artifacts.", examples: ["rig inspect artifacts --task 204", "rig inspect artifact --task 204 --file task-result.json"] },
5657
+ { command: "rig inspect diff --task <id> | graph [--task <id>]", description: "Run diff / task dependency graph.", examples: ["rig inspect diff --task 204", "rig inspect graph --task 204"] },
5189
5658
  { command: "rig inspect failures --task <id>", description: "Classified failure diagnostics for a task's runs.", usecase: "Triage repeated failures on one task.", examples: ["rig inspect failures --task 204"] },
5190
5659
  { command: "rig stats", description: "Aggregate run stats over a window.", examples: ["rig stats", "rig stats --since 7d"] }
5191
5660
  ]
@@ -5226,15 +5695,14 @@ var PRIMARY_GROUPS = [
5226
5695
  {
5227
5696
  name: "server",
5228
5697
  summary: "Compatibility server selector; the product Server target screen lives in Rig Cockpit.",
5229
- usage: ["rig server <status|list|add|use|repair-link|start> [options]"],
5698
+ usage: ["rig server <status|list|add|use|remove> [options]"],
5230
5699
  commands: [
5231
- { command: "status", description: "Legacy automation-only: show the selected server and project-root link.", primary: true },
5700
+ { command: "status", description: "Legacy automation-only: show the selected placement and task source.", primary: true },
5232
5701
  { command: "use local", description: "Legacy automation-only: switch this repo to local execution placement.", primary: true },
5233
- { command: "add <alias> <url>", description: "Legacy automation-only: save a remote server URL.", primary: true },
5702
+ { command: "add --alias <alias> --host <host> [--port <n>]", description: "Legacy automation-only: save a remote execution target.", primary: true },
5234
5703
  { command: "use <alias>", description: "Legacy automation-only: select a remote execution target alias.", primary: true },
5235
- { command: "repair-link [--prepare|--backfill-only] [--repo owner/repo]", description: "Legacy automation-only: repair a server-host checkout link.", primary: true },
5236
- { command: "list", description: "Legacy automation-only: list saved local/remote server aliases.", primary: true },
5237
- { command: "start [--host <host>] [--port <n>]", description: "Legacy diagnostic-only: start a local rig-server process." }
5704
+ { command: "remove <alias>", description: "Legacy automation-only: remove a saved remote execution target.", primary: true },
5705
+ { command: "list", description: "Legacy automation-only: list saved local/remote server aliases.", primary: true }
5238
5706
  ],
5239
5707
  examples: [
5240
5708
  "rig server status # legacy automation only",
@@ -5250,9 +5718,9 @@ var PRIMARY_GROUPS = [
5250
5718
  { command: "list [--assignee <login|me|@me>] [--state open|closed]", description: "Legacy automation-only: list tasks from the configured source.", primary: true },
5251
5719
  { command: "next [filters]", description: "Legacy automation-only: render the next matching task card.", primary: true },
5252
5720
  { command: "show <id>|--task <id> [--raw]", description: "Legacy automation-only: show a task payload for scripts.", primary: true },
5253
- { command: "run [#<issue>|<task-id>|--task <id>]", description: "Legacy/fenced: dispatch through the old task-run CLI path; not the task-detail dispatch path.", primary: true },
5721
+ { command: "run [#<issue>|<task-id>|--task <id>] [--title <t>] [--model <m>] [--prompt <p>|--initial-prompt <p>]", description: "Legacy/fenced: dispatch through the CLI run path; not the task-detail dispatch path.", primary: true },
5254
5722
  { command: "ready", description: "Legacy automation-only: list task IDs that old dispatch can run now." },
5255
- { command: "validate|verify [--task <id>]", description: "Legacy automation-only: run configured task checks/review gates." },
5723
+ { command: "validate|verify [--task <id>]", description: "Legacy automation-only: run configured task checks/review gates; failing checks exit nonzero." },
5256
5724
  { command: "details --task <id>", description: "Legacy automation-only: show full task info from the configured source." },
5257
5725
  { command: "reopen [--task <id> | --all] [--reason <text>]", description: "Legacy automation-only: reopen closed task(s) in the configured source." },
5258
5726
  { command: "artifacts|artifact-dir|artifact-write", description: "Legacy automation-only: inspect or write task artifacts." }
@@ -5260,30 +5728,30 @@ var PRIMARY_GROUPS = [
5260
5728
  examples: [
5261
5729
  "rig task list --assignee @me --limit 20 # legacy automation only",
5262
5730
  "rig task show 123 --raw # legacy automation only",
5263
- "rig task run #123 --runtime-adapter pi # explicit legacy dispatch only"
5731
+ "rig task run #123 --model opus-4.8 --prompt 'focus tests'"
5264
5732
  ],
5265
5733
  next: ["For normal UX, run bare `rig`, use Cockpit Server/Tasks, then dispatch from Task detail."]
5266
5734
  },
5267
5735
  {
5268
5736
  name: "run",
5269
5737
  summary: "Legacy automation-only run-record inspection; OMP Runs/collab is the live surface.",
5270
- usage: ["rig run <list|status|show|steer|stop|resume|restart> [options]"],
5738
+ usage: ["rig run [start] <task|#issue|--next> [--title <t>] [--model <m>] [--prompt <p>|--initial-prompt <p>]", "rig run <list|status|show|steer|stop|resume|restart> [options]"],
5271
5739
  commands: [
5740
+ { command: "[start] <task|#issue|--next> [--title <t>] [--model <m>] [--prompt <p>|--initial-prompt <p>]", description: "Legacy automation-only: dispatch a task run through the unified run launcher.", primary: true },
5272
5741
  { command: "list", description: "Legacy automation-only: list old run records from selected server/local state.", primary: true },
5273
5742
  { command: "status", description: "Legacy automation-only: render old active/recent run-record groups; not live OMP status.", primary: true },
5274
5743
  { command: "show <id>|--run <id> [--raw]", description: "Legacy automation-only: show an old run-record payload for scripts.", primary: true },
5275
5744
  { command: "attach <run-id>|--run <id>", description: "Legacy/fenced: not the Rig Cockpit attach path; use OMP Runs or `rig join <link>`.", primary: true },
5276
5745
  { command: "steer <run-id> --message <text>", description: "Legacy automation-only: queue steering into an old live worker.", primary: true },
5277
- { command: "stop [<run-id>|--run <id>]", description: "Legacy automation-only: request stop for old run records.", primary: true },
5278
- { command: "resume [<run-id>]", description: "Legacy automation-only: resume an interrupted old run record." },
5279
- { command: "restart [<run-id>]", description: "Legacy automation-only: re-dispatch an old run from a clean runtime." },
5280
- { command: "timeline --run <id> [--follow]", description: "Legacy automation-only: stream raw old timeline events." },
5281
- { command: "replay <run-id>|--run <id> [--with-session]", description: "Legacy automation-only: print an old consolidated run timeline." },
5282
- { command: "delete|cleanup", description: "Legacy automation-only: remove completed old run records/artifacts." }
5746
+ { command: "stop <run-id>|--run <id> [--reason <text>]", description: "Legacy automation-only: request stop for old run records.", primary: true },
5747
+ { command: "resume <run-id>|--run <id>", description: "Legacy automation-only: resume an interrupted old run record." },
5748
+ { command: "restart <run-id>|--run <id>", description: "Legacy automation-only: re-dispatch an old run from a clean runtime." },
5749
+ { command: "timeline|replay <run-id>|--run <id> [--with-session]", description: "Legacy automation-only: print an old consolidated run timeline." },
5750
+ { command: "delete|cleanup [<run-id>|--run <id>]", description: "Legacy automation-only: remove stale live-registry entries; journals are retained." }
5283
5751
  ],
5284
5752
  examples: [
5285
- "rig run list # legacy automation only",
5286
- "rig run show <run-id> # legacy automation only",
5753
+ "rig run 204 # dispatch task 204",
5754
+ "rig run --title 'Fix API' 204",
5287
5755
  "rig run stop <run-id> # legacy automation only"
5288
5756
  ],
5289
5757
  next: [
@@ -5299,7 +5767,7 @@ var PRIMARY_GROUPS = [
5299
5767
  { command: "approvals [--run <id>] [--task <id>]", description: "Legacy automation-only: list pending approval records.", primary: true },
5300
5768
  { command: "inputs [--run <id>] [--task <id>]", description: "Legacy automation-only: list pending user-input records.", primary: true },
5301
5769
  { command: "approve --run <id> --request <id> --decision approve|reject", description: "Legacy automation-only: resolve an approval record." },
5302
- { command: "respond --run <id> --request <id> --answer key=value", description: "Legacy automation-only: answer a user-input record." }
5770
+ { command: "respond --run <id> --request <id> --text <answer> | --answer <answer>", description: "Legacy automation-only: answer a user-input record." }
5303
5771
  ],
5304
5772
  examples: [
5305
5773
  "rig inbox approvals # legacy automation only"
@@ -5321,15 +5789,17 @@ var PRIMARY_GROUPS = [
5321
5789
  {
5322
5790
  name: "inspect",
5323
5791
  summary: "Legacy automation-only artifact/log inspection; normal UX is OMP session history.",
5324
- usage: ["rig inspect <logs|artifacts|failures|graph|audit> --task <id>"],
5792
+ usage: ["rig inspect <logs|artifact|artifacts|run-logs|runs|failures|graph|diff> [options]"],
5325
5793
  commands: [
5326
5794
  { command: "logs --task <id>", description: "Legacy automation-only: latest old run log for a task.", primary: true },
5795
+ { command: "run-logs --run <id>", description: "Legacy automation-only: log lines for a specific run.", primary: true },
5796
+ { command: "runs", description: "Legacy automation-only: list projected runs." },
5797
+ { command: "artifact --task <id> --file <name>", description: "Legacy automation-only: preview one completion artifact." },
5327
5798
  { command: "artifacts --task <id>", description: "Legacy automation-only: list completion artifacts.", primary: true },
5799
+ { command: "diff --task <id>", description: "Legacy automation-only: list task changed files." },
5328
5800
  { command: "failures --task <id>", description: "Legacy automation-only: recorded failures for a task.", primary: true },
5329
- { command: "graph", description: "Legacy automation-only: task dependency graph." },
5330
- { command: "audit", description: "Legacy automation-only: controlled-command audit trail." }
5801
+ { command: "graph [--task <id>]", description: "Legacy automation-only: task dependency graph." }
5331
5802
  ],
5332
- examples: ["rig inspect logs --task <id> # legacy automation only"],
5333
5803
  next: ["For normal UX, use the OMP Runs screen and OMP session history."]
5334
5804
  },
5335
5805
  {
@@ -5504,9 +5974,22 @@ var ADVANCED_COMMANDS = [
5504
5974
  ];
5505
5975
  var ALL_GROUPS = [...PRIMARY_GROUPS, ...ADVANCED_GROUPS];
5506
5976
  export {
5977
+ timelineEntriesFromCustomEntries,
5507
5978
  sessionIdFromSessionFile,
5508
5979
  reduceRunJournal,
5980
+ projectWorkflowEntries,
5981
+ projectCollabWorkflowMarker,
5982
+ parseWorkflowTaskSelected,
5983
+ parseWorkflowTargetSelected,
5984
+ parseWorkflowStatusChanged,
5985
+ parseWorkflowStarted,
5986
+ parseWorkflowOperatorNote,
5987
+ parseWorkflowInboxResolved,
5988
+ parseWorkflowInboxRequested,
5509
5989
  parseStopSentinel,
5990
+ parseResumeSentinel,
5991
+ parsePauseSentinel,
5992
+ parseInboxResolutionSentinel,
5510
5993
  normalizeRunStatusToken,
5511
5994
  isTerminalRunStatus,
5512
5995
  isRunSessionCustomType,
@@ -5515,8 +5998,20 @@ export {
5515
5998
  helpCatalog,
5516
5999
  foldRunSessionEntries,
5517
6000
  decodeRunJournalEvent,
6001
+ createWorkflowTaskSelected,
6002
+ createWorkflowTargetSelected,
6003
+ createWorkflowStatusChanged,
6004
+ createWorkflowStarted,
6005
+ createWorkflowOperatorNote,
6006
+ createWorkflowInboxResolved,
6007
+ createWorkflowInboxRequested,
6008
+ collectResolvedInboxRequests,
6009
+ collectPendingInboxRequests,
5518
6010
  canTransitionRunStatus,
5519
6011
  buildStopSentinel,
6012
+ buildResumeSentinel,
6013
+ buildPauseSentinel,
6014
+ buildInboxResolutionSentinel,
5520
6015
  assertRunStatusTransition,
5521
6016
  WsWelcomePayload,
5522
6017
  WsResponse,
@@ -5794,6 +6289,13 @@ export {
5794
6289
  RUN_STATUS_TRANSITIONS,
5795
6290
  RIG_WS_METHODS,
5796
6291
  RIG_WS_CHANNELS,
6292
+ RIG_WORKFLOW_TASK_SELECTED,
6293
+ RIG_WORKFLOW_TARGET_SELECTED,
6294
+ RIG_WORKFLOW_STATUS_CHANGED,
6295
+ RIG_WORKFLOW_STARTED,
6296
+ RIG_WORKFLOW_OPERATOR_NOTE,
6297
+ RIG_WORKFLOW_INBOX_RESOLVED,
6298
+ RIG_WORKFLOW_INBOX_REQUESTED,
5797
6299
  RIG_STOP_SENTINEL_END,
5798
6300
  RIG_STOP_SENTINEL,
5799
6301
  RIG_RUN_TIMELINE_ENTRY,
@@ -5808,7 +6310,11 @@ export {
5808
6310
  RIG_RUN_APPROVAL_RESOLVED,
5809
6311
  RIG_RUN_APPROVAL_REQUESTED,
5810
6312
  RIG_RUN_ADOPTED,
6313
+ RIG_RESUME_SENTINEL,
5811
6314
  RIG_PROTOCOL_VERSION,
6315
+ RIG_PAUSE_SENTINEL,
6316
+ RIG_INBOX_RESOLUTION_SENTINEL,
6317
+ RIG_CONTROL_SENTINEL_END,
5812
6318
  REASONING_EFFORT_OPTIONS_BY_PROVIDER,
5813
6319
  QueueEntry,
5814
6320
  PullRequestConfig,