@h-rig/contracts 0.0.6-alpha.15 → 0.0.6-alpha.151
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/index.cjs +7456 -0
- package/dist/index.mjs +7415 -0
- package/dist/src/artifact.d.ts +13 -0
- package/dist/src/artifact.js +3 -0
- package/dist/src/baseSchemas.d.ts +63 -0
- package/dist/src/baseSchemas.js +6 -0
- package/dist/src/cli-output.d.ts +324 -0
- package/dist/src/cli-output.js +190 -0
- package/dist/src/config.d.ts +536 -0
- package/dist/src/config.js +1592 -162
- package/dist/src/conversation.d.ts +50 -0
- package/dist/src/conversation.js +3 -0
- package/dist/src/drift.d.ts +28 -0
- package/dist/src/drift.js +69 -0
- package/dist/src/editor.d.ts +25 -0
- package/dist/src/editor.js +3 -0
- package/dist/src/engine.d.ts +2789 -0
- package/dist/src/engine.js +127 -13
- package/dist/src/git.d.ts +144 -0
- package/dist/src/git.js +3 -0
- package/dist/src/graph.d.ts +323 -0
- package/dist/src/graph.js +124 -1
- package/dist/src/help-catalog.d.ts +34 -0
- package/dist/src/help-catalog.js +655 -0
- package/dist/src/index.d.ts +46 -0
- package/dist/src/index.js +4095 -1228
- package/dist/src/ipc.d.ts +248 -0
- package/dist/src/kernel.d.ts +221 -0
- package/dist/src/kernel.js +269 -0
- package/dist/src/keybindings.d.ts +71 -0
- package/dist/src/keybindings.js +3 -0
- package/dist/src/model.d.ts +77 -0
- package/dist/src/orchestration.d.ts +3695 -0
- package/dist/src/orchestration.js +3 -0
- package/dist/src/pi-session.d.ts +113 -0
- package/dist/src/pi-session.js +1 -0
- package/dist/src/planning.d.ts +64 -0
- package/dist/src/planning.js +90 -0
- package/dist/src/plugin-hooks.d.ts +51 -0
- package/dist/src/plugin-hooks.js +375 -0
- package/dist/src/plugin.d.ts +416 -0
- package/dist/src/plugin.js +332 -64
- package/dist/src/policy.d.ts +16 -0
- package/dist/src/policy.js +3 -0
- package/dist/src/project.d.ts +71 -0
- package/dist/src/project.js +3 -0
- package/dist/src/protocol-version.d.ts +21 -0
- package/dist/src/protocol-version.js +6 -0
- package/dist/src/provider.d.ts +105 -0
- package/dist/src/provider.js +3 -0
- package/dist/src/providerRuntime.d.ts +3949 -0
- package/dist/src/providerRuntime.js +3 -0
- package/dist/src/remote.d.ts +326 -0
- package/dist/src/remote.js +16 -10
- package/dist/src/review.d.ts +18 -0
- package/dist/src/review.js +3 -0
- package/dist/src/rig.d.ts +783 -0
- package/dist/src/rig.js +178 -15
- package/dist/src/rollups.d.ts +41 -0
- package/dist/src/rollups.js +70 -0
- package/dist/src/run-journal.d.ts +930 -0
- package/dist/src/run-journal.js +1641 -0
- package/dist/src/run-record.d.ts +45 -0
- package/dist/src/run-record.js +1 -0
- package/dist/src/run-session-journal.d.ts +93 -0
- package/dist/src/run-session-journal.js +1809 -0
- package/dist/src/run-status.d.ts +12 -0
- package/dist/src/run-status.js +38 -0
- package/dist/src/run-timeline.d.ts +10 -0
- package/dist/src/run-timeline.js +1499 -0
- package/dist/src/runtime.d.ts +103 -0
- package/dist/src/runtime.js +9 -4
- package/dist/src/server.d.ts +106 -0
- package/dist/src/server.js +3 -0
- package/dist/src/serviceFabric.d.ts +62 -0
- package/dist/src/serviceFabric.js +5 -2
- package/dist/src/stage.d.ts +245 -0
- package/dist/src/stage.js +169 -0
- package/dist/src/supervisor-journal.d.ts +205 -0
- package/dist/src/supervisor-journal.js +1246 -0
- package/dist/src/task-source.d.ts +37 -0
- package/dist/src/terminal.d.ts +130 -0
- package/dist/src/terminal.js +3 -0
- package/dist/src/validation.d.ts +14 -0
- package/dist/src/validation.js +3 -0
- package/dist/src/workflow-journal.d.ts +124 -0
- package/dist/src/workflow-journal.js +389 -0
- package/dist/src/workspace.d.ts +204 -0
- package/dist/src/workspace.js +5 -2
- package/dist/src/ws.d.ts +747 -0
- package/dist/src/ws.js +172 -14
- package/package.json +51 -4
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/contracts/src/workflow-journal.ts
|
|
3
|
+
var RIG_WORKFLOW_STARTED = "rig.workflow.started";
|
|
4
|
+
var RIG_WORKFLOW_TARGET_SELECTED = "rig.workflow.target.selected";
|
|
5
|
+
var RIG_WORKFLOW_TASK_SELECTED = "rig.workflow.task.selected";
|
|
6
|
+
var RIG_WORKFLOW_STATUS_CHANGED = "rig.workflow.status.changed";
|
|
7
|
+
var RIG_WORKFLOW_OPERATOR_NOTE = "rig.workflow.operator.note";
|
|
8
|
+
var RIG_WORKFLOW_INBOX_REQUESTED = "rig.workflow.inbox.requested";
|
|
9
|
+
var RIG_WORKFLOW_INBOX_RESOLVED = "rig.workflow.inbox.resolved";
|
|
10
|
+
var EMPTY_PROJECTION = {
|
|
11
|
+
started: null,
|
|
12
|
+
target: null,
|
|
13
|
+
task: null,
|
|
14
|
+
status: null,
|
|
15
|
+
notes: [],
|
|
16
|
+
inbox: [],
|
|
17
|
+
resolvedInbox: [],
|
|
18
|
+
updatedAt: null
|
|
19
|
+
};
|
|
20
|
+
function asRecord(value) {
|
|
21
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
22
|
+
}
|
|
23
|
+
function optionalString(value) {
|
|
24
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
25
|
+
}
|
|
26
|
+
function requiredString(value) {
|
|
27
|
+
const text = optionalString(value);
|
|
28
|
+
return text ?? null;
|
|
29
|
+
}
|
|
30
|
+
function timestamp(value) {
|
|
31
|
+
const text = requiredString(value);
|
|
32
|
+
if (!text)
|
|
33
|
+
return null;
|
|
34
|
+
const millis = Date.parse(text);
|
|
35
|
+
return Number.isFinite(millis) ? text : null;
|
|
36
|
+
}
|
|
37
|
+
function newer(left, right) {
|
|
38
|
+
if (!right)
|
|
39
|
+
return false;
|
|
40
|
+
if (!left)
|
|
41
|
+
return true;
|
|
42
|
+
return Date.parse(right) >= Date.parse(left);
|
|
43
|
+
}
|
|
44
|
+
function isWorkflowTarget(value) {
|
|
45
|
+
return value === "local" || value === "remote";
|
|
46
|
+
}
|
|
47
|
+
function isWorkflowStatus(value) {
|
|
48
|
+
return value === "starting" || value === "running" || value === "waiting-approval" || value === "waiting-input" || value === "completed" || value === "failed" || value === "stopped";
|
|
49
|
+
}
|
|
50
|
+
function isInboxKind(value) {
|
|
51
|
+
return value === "approval" || value === "input";
|
|
52
|
+
}
|
|
53
|
+
function isInboxDecision(value) {
|
|
54
|
+
return value === "approved" || value === "rejected" || value === "answered";
|
|
55
|
+
}
|
|
56
|
+
function parseOwner(value) {
|
|
57
|
+
const record = asRecord(value);
|
|
58
|
+
if (!record)
|
|
59
|
+
return null;
|
|
60
|
+
const githubUserId = requiredString(record.githubUserId);
|
|
61
|
+
const login = requiredString(record.login);
|
|
62
|
+
const namespaceKey = requiredString(record.namespaceKey);
|
|
63
|
+
return githubUserId && login && namespaceKey ? { githubUserId, login, namespaceKey } : null;
|
|
64
|
+
}
|
|
65
|
+
function parseStringArray(value) {
|
|
66
|
+
if (!Array.isArray(value))
|
|
67
|
+
return;
|
|
68
|
+
const options = value.map(optionalString).filter((option) => option !== undefined);
|
|
69
|
+
return options.length > 0 ? options : undefined;
|
|
70
|
+
}
|
|
71
|
+
function hasOwn(record, key) {
|
|
72
|
+
return Object.prototype.hasOwnProperty.call(record, key);
|
|
73
|
+
}
|
|
74
|
+
function entryUpdatedAt(entry) {
|
|
75
|
+
if ("createdAt" in entry)
|
|
76
|
+
return entry.createdAt;
|
|
77
|
+
if ("selectedAt" in entry)
|
|
78
|
+
return entry.selectedAt;
|
|
79
|
+
if ("changedAt" in entry)
|
|
80
|
+
return entry.changedAt;
|
|
81
|
+
if ("notedAt" in entry)
|
|
82
|
+
return entry.notedAt;
|
|
83
|
+
if ("requestedAt" in entry)
|
|
84
|
+
return entry.requestedAt;
|
|
85
|
+
return entry.resolvedAt;
|
|
86
|
+
}
|
|
87
|
+
function createWorkflowStarted(input) {
|
|
88
|
+
return {
|
|
89
|
+
schemaVersion: 1,
|
|
90
|
+
workflowId: input.workflowId,
|
|
91
|
+
target: input.target,
|
|
92
|
+
selectedRepo: input.selectedRepo,
|
|
93
|
+
owner: input.owner,
|
|
94
|
+
createdAt: input.createdAt ?? new Date().toISOString()
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function createWorkflowTargetSelected(input) {
|
|
98
|
+
return {
|
|
99
|
+
schemaVersion: 1,
|
|
100
|
+
target: input.target,
|
|
101
|
+
...input.reason ? { reason: input.reason } : {},
|
|
102
|
+
selectedAt: input.selectedAt ?? new Date().toISOString()
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function createWorkflowTaskSelected(input) {
|
|
106
|
+
return {
|
|
107
|
+
schemaVersion: 1,
|
|
108
|
+
taskId: input.taskId,
|
|
109
|
+
...input.title ? { title: input.title } : {},
|
|
110
|
+
selectedAt: input.selectedAt ?? new Date().toISOString()
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function createWorkflowStatusChanged(input) {
|
|
114
|
+
return {
|
|
115
|
+
schemaVersion: 1,
|
|
116
|
+
status: input.status,
|
|
117
|
+
...input.detail ? { detail: input.detail } : {},
|
|
118
|
+
changedAt: input.changedAt ?? new Date().toISOString()
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function createWorkflowOperatorNote(input) {
|
|
122
|
+
return {
|
|
123
|
+
schemaVersion: 1,
|
|
124
|
+
...input.noteId ? { noteId: input.noteId } : {},
|
|
125
|
+
note: input.note,
|
|
126
|
+
notedAt: input.notedAt ?? new Date().toISOString()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function createWorkflowInboxRequested(input) {
|
|
130
|
+
return {
|
|
131
|
+
schemaVersion: 1,
|
|
132
|
+
requestId: input.requestId,
|
|
133
|
+
kind: input.kind,
|
|
134
|
+
title: input.title,
|
|
135
|
+
...input.body ? { body: input.body } : {},
|
|
136
|
+
...input.options && input.options.length > 0 ? { options: input.options } : {},
|
|
137
|
+
requestedAt: input.requestedAt ?? new Date().toISOString()
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function createWorkflowInboxResolved(input) {
|
|
141
|
+
const base = {
|
|
142
|
+
schemaVersion: 1,
|
|
143
|
+
requestId: input.requestId,
|
|
144
|
+
decision: input.decision,
|
|
145
|
+
resolvedAt: input.resolvedAt ?? new Date().toISOString()
|
|
146
|
+
};
|
|
147
|
+
return hasOwn(input, "answer") ? { ...base, answer: input.answer } : base;
|
|
148
|
+
}
|
|
149
|
+
function parseWorkflowStarted(data) {
|
|
150
|
+
const record = asRecord(data);
|
|
151
|
+
if (!record || record.schemaVersion !== 1)
|
|
152
|
+
return null;
|
|
153
|
+
const workflowId = requiredString(record.workflowId);
|
|
154
|
+
const target = optionalString(record.target);
|
|
155
|
+
const selectedRepo = requiredString(record.selectedRepo);
|
|
156
|
+
const owner = parseOwner(record.owner);
|
|
157
|
+
const createdAt = timestamp(record.createdAt);
|
|
158
|
+
if (!workflowId || !isWorkflowTarget(target) || !selectedRepo || !owner || !createdAt)
|
|
159
|
+
return null;
|
|
160
|
+
return {
|
|
161
|
+
schemaVersion: 1,
|
|
162
|
+
workflowId,
|
|
163
|
+
target,
|
|
164
|
+
selectedRepo,
|
|
165
|
+
owner,
|
|
166
|
+
createdAt
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function parseWorkflowTargetSelected(data) {
|
|
170
|
+
const record = asRecord(data);
|
|
171
|
+
if (!record || record.schemaVersion !== 1)
|
|
172
|
+
return null;
|
|
173
|
+
const target = optionalString(record.target);
|
|
174
|
+
const selectedAt = timestamp(record.selectedAt);
|
|
175
|
+
if (!isWorkflowTarget(target) || !selectedAt)
|
|
176
|
+
return null;
|
|
177
|
+
const reason = optionalString(record.reason);
|
|
178
|
+
return {
|
|
179
|
+
schemaVersion: 1,
|
|
180
|
+
target,
|
|
181
|
+
...reason ? { reason } : {},
|
|
182
|
+
selectedAt
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function parseWorkflowTaskSelected(data) {
|
|
186
|
+
const record = asRecord(data);
|
|
187
|
+
if (!record || record.schemaVersion !== 1)
|
|
188
|
+
return null;
|
|
189
|
+
const taskId = requiredString(record.taskId);
|
|
190
|
+
const selectedAt = timestamp(record.selectedAt);
|
|
191
|
+
if (!taskId || !selectedAt)
|
|
192
|
+
return null;
|
|
193
|
+
const title = optionalString(record.title);
|
|
194
|
+
return { schemaVersion: 1, taskId, ...title ? { title } : {}, selectedAt };
|
|
195
|
+
}
|
|
196
|
+
function parseWorkflowStatusChanged(data) {
|
|
197
|
+
const record = asRecord(data);
|
|
198
|
+
if (!record || record.schemaVersion !== 1)
|
|
199
|
+
return null;
|
|
200
|
+
const status = optionalString(record.status);
|
|
201
|
+
const changedAt = timestamp(record.changedAt);
|
|
202
|
+
if (!changedAt || !isWorkflowStatus(status))
|
|
203
|
+
return null;
|
|
204
|
+
const detail = optionalString(record.detail);
|
|
205
|
+
return { schemaVersion: 1, status, ...detail ? { detail } : {}, changedAt };
|
|
206
|
+
}
|
|
207
|
+
function parseWorkflowOperatorNote(data) {
|
|
208
|
+
const record = asRecord(data);
|
|
209
|
+
if (!record || record.schemaVersion !== 1)
|
|
210
|
+
return null;
|
|
211
|
+
const note = requiredString(record.note);
|
|
212
|
+
const notedAt = timestamp(record.notedAt);
|
|
213
|
+
if (!note || !notedAt)
|
|
214
|
+
return null;
|
|
215
|
+
const noteId = optionalString(record.noteId);
|
|
216
|
+
return { schemaVersion: 1, ...noteId ? { noteId } : {}, note, notedAt };
|
|
217
|
+
}
|
|
218
|
+
function parseWorkflowInboxRequested(data) {
|
|
219
|
+
const record = asRecord(data);
|
|
220
|
+
if (!record || record.schemaVersion !== 1)
|
|
221
|
+
return null;
|
|
222
|
+
const requestId = requiredString(record.requestId);
|
|
223
|
+
const kind = optionalString(record.kind);
|
|
224
|
+
const title = requiredString(record.title);
|
|
225
|
+
const requestedAt = timestamp(record.requestedAt);
|
|
226
|
+
if (!requestId || !isInboxKind(kind) || !title || !requestedAt)
|
|
227
|
+
return null;
|
|
228
|
+
const body = optionalString(record.body);
|
|
229
|
+
const options = parseStringArray(record.options);
|
|
230
|
+
return {
|
|
231
|
+
schemaVersion: 1,
|
|
232
|
+
requestId,
|
|
233
|
+
kind,
|
|
234
|
+
title,
|
|
235
|
+
...body ? { body } : {},
|
|
236
|
+
...options ? { options } : {},
|
|
237
|
+
requestedAt
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function parseWorkflowInboxResolved(data) {
|
|
241
|
+
const record = asRecord(data);
|
|
242
|
+
if (!record || record.schemaVersion !== 1)
|
|
243
|
+
return null;
|
|
244
|
+
const requestId = requiredString(record.requestId);
|
|
245
|
+
const decision = optionalString(record.decision);
|
|
246
|
+
const resolvedAt = timestamp(record.resolvedAt);
|
|
247
|
+
if (!requestId || !isInboxDecision(decision) || !resolvedAt)
|
|
248
|
+
return null;
|
|
249
|
+
const base = { schemaVersion: 1, requestId, decision, resolvedAt };
|
|
250
|
+
return hasOwn(record, "answer") ? { ...base, answer: record.answer } : base;
|
|
251
|
+
}
|
|
252
|
+
function collectPendingInboxRequests(entries) {
|
|
253
|
+
const requested = new Map;
|
|
254
|
+
const resolved = new Map;
|
|
255
|
+
for (const entry of entries) {
|
|
256
|
+
if (entry.type !== "custom")
|
|
257
|
+
continue;
|
|
258
|
+
if (entry.customType === RIG_WORKFLOW_INBOX_REQUESTED) {
|
|
259
|
+
const request = parseWorkflowInboxRequested(entry.data);
|
|
260
|
+
if (request && newer(requested.get(request.requestId)?.requestedAt, request.requestedAt))
|
|
261
|
+
requested.set(request.requestId, request);
|
|
262
|
+
} else if (entry.customType === RIG_WORKFLOW_INBOX_RESOLVED) {
|
|
263
|
+
const resolution = parseWorkflowInboxResolved(entry.data);
|
|
264
|
+
if (resolution && newer(resolved.get(resolution.requestId), resolution.resolvedAt))
|
|
265
|
+
resolved.set(resolution.requestId, resolution.resolvedAt);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
for (const [requestId, request] of requested) {
|
|
269
|
+
const resolvedAt = resolved.get(requestId);
|
|
270
|
+
if (resolvedAt && Date.parse(resolvedAt) >= Date.parse(request.requestedAt))
|
|
271
|
+
requested.delete(requestId);
|
|
272
|
+
}
|
|
273
|
+
return Array.from(requested.values()).sort((a, b) => Date.parse(b.requestedAt) - Date.parse(a.requestedAt));
|
|
274
|
+
}
|
|
275
|
+
function collectResolvedInboxRequests(entries) {
|
|
276
|
+
const requested = new Map;
|
|
277
|
+
const resolved = new Map;
|
|
278
|
+
for (const entry of entries) {
|
|
279
|
+
if (entry.type !== "custom")
|
|
280
|
+
continue;
|
|
281
|
+
if (entry.customType === RIG_WORKFLOW_INBOX_REQUESTED) {
|
|
282
|
+
const request = parseWorkflowInboxRequested(entry.data);
|
|
283
|
+
if (request && newer(requested.get(request.requestId), request.requestedAt))
|
|
284
|
+
requested.set(request.requestId, request.requestedAt);
|
|
285
|
+
} else if (entry.customType === RIG_WORKFLOW_INBOX_RESOLVED) {
|
|
286
|
+
const resolution = parseWorkflowInboxResolved(entry.data);
|
|
287
|
+
if (resolution && newer(resolved.get(resolution.requestId)?.resolvedAt, resolution.resolvedAt)) {
|
|
288
|
+
resolved.set(resolution.requestId, resolution);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
for (const [requestId, resolution] of resolved) {
|
|
293
|
+
const requestedAt = requested.get(requestId);
|
|
294
|
+
if (requestedAt && Date.parse(requestedAt) > Date.parse(resolution.resolvedAt))
|
|
295
|
+
resolved.delete(requestId);
|
|
296
|
+
}
|
|
297
|
+
return Array.from(resolved.values()).sort((a, b) => Date.parse(b.resolvedAt) - Date.parse(a.resolvedAt));
|
|
298
|
+
}
|
|
299
|
+
function projectCollabWorkflowMarker(collab) {
|
|
300
|
+
const status = createWorkflowStatusChanged({
|
|
301
|
+
status: collab.stale ? "stopped" : "running",
|
|
302
|
+
detail: collab.stale ? "Stale OMP collab session discovered from the sanctioned collab registry." : "Live OMP collab session discovered from the sanctioned collab registry.",
|
|
303
|
+
changedAt: collab.updatedAt
|
|
304
|
+
});
|
|
305
|
+
return {
|
|
306
|
+
started: null,
|
|
307
|
+
target: null,
|
|
308
|
+
task: null,
|
|
309
|
+
status,
|
|
310
|
+
notes: [],
|
|
311
|
+
inbox: [],
|
|
312
|
+
resolvedInbox: [],
|
|
313
|
+
updatedAt: newer(collab.startedAt, collab.updatedAt) ? collab.updatedAt : collab.startedAt
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function projectWorkflowEntries(entries) {
|
|
317
|
+
let started = null;
|
|
318
|
+
let target = null;
|
|
319
|
+
let task = null;
|
|
320
|
+
let status = null;
|
|
321
|
+
const notes = [];
|
|
322
|
+
let updatedAt = null;
|
|
323
|
+
for (const entry of entries) {
|
|
324
|
+
if (entry.type !== "custom")
|
|
325
|
+
continue;
|
|
326
|
+
if (entry.customType === RIG_WORKFLOW_STARTED) {
|
|
327
|
+
const parsed = parseWorkflowStarted(entry.data);
|
|
328
|
+
if (parsed && newer(started?.createdAt, parsed.createdAt))
|
|
329
|
+
started = parsed;
|
|
330
|
+
} else if (entry.customType === RIG_WORKFLOW_TARGET_SELECTED) {
|
|
331
|
+
const parsed = parseWorkflowTargetSelected(entry.data);
|
|
332
|
+
if (parsed && newer(target?.selectedAt, parsed.selectedAt))
|
|
333
|
+
target = parsed;
|
|
334
|
+
} else if (entry.customType === RIG_WORKFLOW_TASK_SELECTED) {
|
|
335
|
+
const parsed = parseWorkflowTaskSelected(entry.data);
|
|
336
|
+
if (parsed && newer(task?.selectedAt, parsed.selectedAt))
|
|
337
|
+
task = parsed;
|
|
338
|
+
} else if (entry.customType === RIG_WORKFLOW_STATUS_CHANGED) {
|
|
339
|
+
const parsed = parseWorkflowStatusChanged(entry.data);
|
|
340
|
+
if (parsed && newer(status?.changedAt, parsed.changedAt))
|
|
341
|
+
status = parsed;
|
|
342
|
+
} else if (entry.customType === RIG_WORKFLOW_OPERATOR_NOTE) {
|
|
343
|
+
const parsed = parseWorkflowOperatorNote(entry.data);
|
|
344
|
+
if (parsed)
|
|
345
|
+
notes.push(parsed);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
notes.sort((a, b) => Date.parse(b.notedAt) - Date.parse(a.notedAt));
|
|
349
|
+
for (const value of [started, target, task, status, ...notes].map((entry) => entry ? entryUpdatedAt(entry) : null)) {
|
|
350
|
+
if (newer(updatedAt, value))
|
|
351
|
+
updatedAt = value;
|
|
352
|
+
}
|
|
353
|
+
const inbox = collectPendingInboxRequests(entries);
|
|
354
|
+
const resolvedInbox = collectResolvedInboxRequests(entries);
|
|
355
|
+
for (const entry of [...inbox, ...resolvedInbox]) {
|
|
356
|
+
if (newer(updatedAt, entryUpdatedAt(entry)))
|
|
357
|
+
updatedAt = entryUpdatedAt(entry);
|
|
358
|
+
}
|
|
359
|
+
if (!started && !target && !task && !status && notes.length === 0 && inbox.length === 0 && resolvedInbox.length === 0 && !updatedAt)
|
|
360
|
+
return EMPTY_PROJECTION;
|
|
361
|
+
return { started, target, task, status, notes, inbox, resolvedInbox, updatedAt };
|
|
362
|
+
}
|
|
363
|
+
export {
|
|
364
|
+
projectWorkflowEntries,
|
|
365
|
+
projectCollabWorkflowMarker,
|
|
366
|
+
parseWorkflowTaskSelected,
|
|
367
|
+
parseWorkflowTargetSelected,
|
|
368
|
+
parseWorkflowStatusChanged,
|
|
369
|
+
parseWorkflowStarted,
|
|
370
|
+
parseWorkflowOperatorNote,
|
|
371
|
+
parseWorkflowInboxResolved,
|
|
372
|
+
parseWorkflowInboxRequested,
|
|
373
|
+
createWorkflowTaskSelected,
|
|
374
|
+
createWorkflowTargetSelected,
|
|
375
|
+
createWorkflowStatusChanged,
|
|
376
|
+
createWorkflowStarted,
|
|
377
|
+
createWorkflowOperatorNote,
|
|
378
|
+
createWorkflowInboxResolved,
|
|
379
|
+
createWorkflowInboxRequested,
|
|
380
|
+
collectResolvedInboxRequests,
|
|
381
|
+
collectPendingInboxRequests,
|
|
382
|
+
RIG_WORKFLOW_TASK_SELECTED,
|
|
383
|
+
RIG_WORKFLOW_TARGET_SELECTED,
|
|
384
|
+
RIG_WORKFLOW_STATUS_CHANGED,
|
|
385
|
+
RIG_WORKFLOW_STARTED,
|
|
386
|
+
RIG_WORKFLOW_OPERATOR_NOTE,
|
|
387
|
+
RIG_WORKFLOW_INBOX_RESOLVED,
|
|
388
|
+
RIG_WORKFLOW_INBOX_REQUESTED
|
|
389
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const WorkspaceSourceKind: Schema.Literals<readonly ["native", "rig-import", "manual", "remote"]>;
|
|
3
|
+
export type WorkspaceSourceKind = typeof WorkspaceSourceKind.Type;
|
|
4
|
+
export declare const WorkspaceTopologyStatus: Schema.Literals<readonly ["empty", "ready", "degraded"]>;
|
|
5
|
+
export type WorkspaceTopologyStatus = typeof WorkspaceTopologyStatus.Type;
|
|
6
|
+
export declare const WorkspaceRemoteFleetStatus: Schema.Literals<readonly ["empty", "ready", "degraded"]>;
|
|
7
|
+
export type WorkspaceRemoteFleetStatus = typeof WorkspaceRemoteFleetStatus.Type;
|
|
8
|
+
export declare const WorkspaceServiceFabricStatus: Schema.Literals<readonly ["empty", "booting", "ready", "degraded", "stopped"]>;
|
|
9
|
+
export type WorkspaceServiceFabricStatus = typeof WorkspaceServiceFabricStatus.Type;
|
|
10
|
+
export declare const WorkspaceRemoteHostStatus: Schema.Literals<readonly ["registering", "ready", "busy", "degraded", "draining", "offline", "quarantined"]>;
|
|
11
|
+
export type WorkspaceRemoteHostStatus = typeof WorkspaceRemoteHostStatus.Type;
|
|
12
|
+
export declare const WorkspaceTopologyServiceSummary: Schema.Struct<{
|
|
13
|
+
readonly name: Schema.Trim;
|
|
14
|
+
readonly relativeRootPath: Schema.Trim;
|
|
15
|
+
readonly runtime: Schema.Trim;
|
|
16
|
+
readonly port: Schema.NullOr<Schema.Number>;
|
|
17
|
+
readonly healthcheck: Schema.NullOr<Schema.Trim>;
|
|
18
|
+
readonly sourceOfTruth: Schema.Struct<{
|
|
19
|
+
readonly code: Schema.NullOr<Schema.Trim>;
|
|
20
|
+
readonly tests: Schema.NullOr<Schema.Trim>;
|
|
21
|
+
readonly infra: Schema.NullOr<Schema.Trim>;
|
|
22
|
+
readonly deploy: Schema.NullOr<Schema.Trim>;
|
|
23
|
+
readonly dependencies: Schema.NullOr<Schema.Trim>;
|
|
24
|
+
}>;
|
|
25
|
+
readonly splitReadyChecklist: Schema.$Array<Schema.Trim>;
|
|
26
|
+
}>;
|
|
27
|
+
export type WorkspaceTopologyServiceSummary = typeof WorkspaceTopologyServiceSummary.Type;
|
|
28
|
+
export declare const WorkspaceTopologySummary: Schema.Struct<{
|
|
29
|
+
readonly compiledAt: Schema.String;
|
|
30
|
+
readonly status: Schema.Literals<readonly ["empty", "ready", "degraded"]>;
|
|
31
|
+
readonly manifestCount: Schema.Number;
|
|
32
|
+
readonly serviceCount: Schema.Number;
|
|
33
|
+
readonly services: Schema.$Array<Schema.Struct<{
|
|
34
|
+
readonly name: Schema.Trim;
|
|
35
|
+
readonly relativeRootPath: Schema.Trim;
|
|
36
|
+
readonly runtime: Schema.Trim;
|
|
37
|
+
readonly port: Schema.NullOr<Schema.Number>;
|
|
38
|
+
readonly healthcheck: Schema.NullOr<Schema.Trim>;
|
|
39
|
+
readonly sourceOfTruth: Schema.Struct<{
|
|
40
|
+
readonly code: Schema.NullOr<Schema.Trim>;
|
|
41
|
+
readonly tests: Schema.NullOr<Schema.Trim>;
|
|
42
|
+
readonly infra: Schema.NullOr<Schema.Trim>;
|
|
43
|
+
readonly deploy: Schema.NullOr<Schema.Trim>;
|
|
44
|
+
readonly dependencies: Schema.NullOr<Schema.Trim>;
|
|
45
|
+
}>;
|
|
46
|
+
readonly splitReadyChecklist: Schema.$Array<Schema.Trim>;
|
|
47
|
+
}>>;
|
|
48
|
+
readonly warnings: Schema.$Array<Schema.String>;
|
|
49
|
+
}>;
|
|
50
|
+
export type WorkspaceTopologySummary = typeof WorkspaceTopologySummary.Type;
|
|
51
|
+
export declare const WorkspaceRemoteHostSummary: Schema.Struct<{
|
|
52
|
+
readonly id: Schema.Trim;
|
|
53
|
+
readonly name: Schema.Trim;
|
|
54
|
+
readonly baseUrl: Schema.Trim;
|
|
55
|
+
readonly workspacePath: Schema.NullOr<Schema.Trim>;
|
|
56
|
+
readonly transport: Schema.Trim;
|
|
57
|
+
readonly hostname: Schema.NullOr<Schema.Trim>;
|
|
58
|
+
readonly region: Schema.NullOr<Schema.Trim>;
|
|
59
|
+
readonly labels: Schema.$Array<Schema.Trim>;
|
|
60
|
+
readonly capabilities: Schema.$Array<Schema.Trim>;
|
|
61
|
+
readonly runtimeAdapters: Schema.$Array<Schema.Literal<"pi">>;
|
|
62
|
+
readonly status: Schema.Literals<readonly ["registering", "ready", "busy", "degraded", "draining", "offline", "quarantined"]>;
|
|
63
|
+
readonly currentLeaseCount: Schema.Number;
|
|
64
|
+
readonly lastHeartbeatAt: Schema.NullOr<Schema.String>;
|
|
65
|
+
readonly registeredAt: Schema.String;
|
|
66
|
+
readonly manifestPath: Schema.Trim;
|
|
67
|
+
}>;
|
|
68
|
+
export type WorkspaceRemoteHostSummary = typeof WorkspaceRemoteHostSummary.Type;
|
|
69
|
+
export declare const WorkspaceRemoteFleetSummary: Schema.Struct<{
|
|
70
|
+
readonly updatedAt: Schema.String;
|
|
71
|
+
readonly status: Schema.Literals<readonly ["empty", "ready", "degraded"]>;
|
|
72
|
+
readonly manifestCount: Schema.Number;
|
|
73
|
+
readonly hostCount: Schema.Number;
|
|
74
|
+
readonly onlineHostCount: Schema.Number;
|
|
75
|
+
readonly hosts: Schema.$Array<Schema.Struct<{
|
|
76
|
+
readonly id: Schema.Trim;
|
|
77
|
+
readonly name: Schema.Trim;
|
|
78
|
+
readonly baseUrl: Schema.Trim;
|
|
79
|
+
readonly workspacePath: Schema.NullOr<Schema.Trim>;
|
|
80
|
+
readonly transport: Schema.Trim;
|
|
81
|
+
readonly hostname: Schema.NullOr<Schema.Trim>;
|
|
82
|
+
readonly region: Schema.NullOr<Schema.Trim>;
|
|
83
|
+
readonly labels: Schema.$Array<Schema.Trim>;
|
|
84
|
+
readonly capabilities: Schema.$Array<Schema.Trim>;
|
|
85
|
+
readonly runtimeAdapters: Schema.$Array<Schema.Literal<"pi">>;
|
|
86
|
+
readonly status: Schema.Literals<readonly ["registering", "ready", "busy", "degraded", "draining", "offline", "quarantined"]>;
|
|
87
|
+
readonly currentLeaseCount: Schema.Number;
|
|
88
|
+
readonly lastHeartbeatAt: Schema.NullOr<Schema.String>;
|
|
89
|
+
readonly registeredAt: Schema.String;
|
|
90
|
+
readonly manifestPath: Schema.Trim;
|
|
91
|
+
}>>;
|
|
92
|
+
readonly warnings: Schema.$Array<Schema.String>;
|
|
93
|
+
}>;
|
|
94
|
+
export type WorkspaceRemoteFleetSummary = typeof WorkspaceRemoteFleetSummary.Type;
|
|
95
|
+
export declare const WorkspaceServiceFabricServiceSummary: Schema.Struct<{
|
|
96
|
+
readonly name: Schema.Trim;
|
|
97
|
+
readonly relativeRootPath: Schema.Trim;
|
|
98
|
+
readonly mode: Schema.Literals<readonly ["stub", "process"]>;
|
|
99
|
+
readonly port: Schema.Number;
|
|
100
|
+
readonly healthcheck: Schema.Trim;
|
|
101
|
+
readonly routePrefix: Schema.NullOr<Schema.Trim>;
|
|
102
|
+
readonly status: Schema.Literals<readonly ["planned", "booting", "healthy", "degraded", "failed", "stopped"]>;
|
|
103
|
+
readonly pid: Schema.NullOr<Schema.Number>;
|
|
104
|
+
readonly logPath: Schema.NullOr<Schema.Trim>;
|
|
105
|
+
}>;
|
|
106
|
+
export type WorkspaceServiceFabricServiceSummary = typeof WorkspaceServiceFabricServiceSummary.Type;
|
|
107
|
+
export declare const WorkspaceServiceFabricSummary: Schema.Struct<{
|
|
108
|
+
readonly updatedAt: Schema.String;
|
|
109
|
+
readonly status: Schema.Literals<readonly ["empty", "booting", "ready", "degraded", "stopped"]>;
|
|
110
|
+
readonly serviceCount: Schema.Number;
|
|
111
|
+
readonly healthyServiceCount: Schema.Number;
|
|
112
|
+
readonly stateDir: Schema.Trim;
|
|
113
|
+
readonly services: Schema.$Array<Schema.Struct<{
|
|
114
|
+
readonly name: Schema.Trim;
|
|
115
|
+
readonly relativeRootPath: Schema.Trim;
|
|
116
|
+
readonly mode: Schema.Literals<readonly ["stub", "process"]>;
|
|
117
|
+
readonly port: Schema.Number;
|
|
118
|
+
readonly healthcheck: Schema.Trim;
|
|
119
|
+
readonly routePrefix: Schema.NullOr<Schema.Trim>;
|
|
120
|
+
readonly status: Schema.Literals<readonly ["planned", "booting", "healthy", "degraded", "failed", "stopped"]>;
|
|
121
|
+
readonly pid: Schema.NullOr<Schema.Number>;
|
|
122
|
+
readonly logPath: Schema.NullOr<Schema.Trim>;
|
|
123
|
+
}>>;
|
|
124
|
+
readonly warnings: Schema.$Array<Schema.String>;
|
|
125
|
+
}>;
|
|
126
|
+
export type WorkspaceServiceFabricSummary = typeof WorkspaceServiceFabricSummary.Type;
|
|
127
|
+
export declare const WorkspaceSummary: Schema.Struct<{
|
|
128
|
+
readonly id: Schema.brand<Schema.Trim, "WorkspaceId">;
|
|
129
|
+
readonly title: Schema.Trim;
|
|
130
|
+
readonly rootPath: Schema.Trim;
|
|
131
|
+
readonly sourceKind: Schema.Literals<readonly ["native", "rig-import", "manual", "remote"]>;
|
|
132
|
+
readonly defaultRuntimeAdapter: Schema.optional<Schema.Literal<"pi">>;
|
|
133
|
+
readonly defaultProvider: Schema.optional<Schema.Literals<readonly ["codex", "claude"]>>;
|
|
134
|
+
readonly defaultModel: Schema.NullOr<Schema.Trim>;
|
|
135
|
+
readonly topology: Schema.optional<Schema.Struct<{
|
|
136
|
+
readonly compiledAt: Schema.String;
|
|
137
|
+
readonly status: Schema.Literals<readonly ["empty", "ready", "degraded"]>;
|
|
138
|
+
readonly manifestCount: Schema.Number;
|
|
139
|
+
readonly serviceCount: Schema.Number;
|
|
140
|
+
readonly services: Schema.$Array<Schema.Struct<{
|
|
141
|
+
readonly name: Schema.Trim;
|
|
142
|
+
readonly relativeRootPath: Schema.Trim;
|
|
143
|
+
readonly runtime: Schema.Trim;
|
|
144
|
+
readonly port: Schema.NullOr<Schema.Number>;
|
|
145
|
+
readonly healthcheck: Schema.NullOr<Schema.Trim>;
|
|
146
|
+
readonly sourceOfTruth: Schema.Struct<{
|
|
147
|
+
readonly code: Schema.NullOr<Schema.Trim>;
|
|
148
|
+
readonly tests: Schema.NullOr<Schema.Trim>;
|
|
149
|
+
readonly infra: Schema.NullOr<Schema.Trim>;
|
|
150
|
+
readonly deploy: Schema.NullOr<Schema.Trim>;
|
|
151
|
+
readonly dependencies: Schema.NullOr<Schema.Trim>;
|
|
152
|
+
}>;
|
|
153
|
+
readonly splitReadyChecklist: Schema.$Array<Schema.Trim>;
|
|
154
|
+
}>>;
|
|
155
|
+
readonly warnings: Schema.$Array<Schema.String>;
|
|
156
|
+
}>>;
|
|
157
|
+
readonly remoteFleet: Schema.optional<Schema.Struct<{
|
|
158
|
+
readonly updatedAt: Schema.String;
|
|
159
|
+
readonly status: Schema.Literals<readonly ["empty", "ready", "degraded"]>;
|
|
160
|
+
readonly manifestCount: Schema.Number;
|
|
161
|
+
readonly hostCount: Schema.Number;
|
|
162
|
+
readonly onlineHostCount: Schema.Number;
|
|
163
|
+
readonly hosts: Schema.$Array<Schema.Struct<{
|
|
164
|
+
readonly id: Schema.Trim;
|
|
165
|
+
readonly name: Schema.Trim;
|
|
166
|
+
readonly baseUrl: Schema.Trim;
|
|
167
|
+
readonly workspacePath: Schema.NullOr<Schema.Trim>;
|
|
168
|
+
readonly transport: Schema.Trim;
|
|
169
|
+
readonly hostname: Schema.NullOr<Schema.Trim>;
|
|
170
|
+
readonly region: Schema.NullOr<Schema.Trim>;
|
|
171
|
+
readonly labels: Schema.$Array<Schema.Trim>;
|
|
172
|
+
readonly capabilities: Schema.$Array<Schema.Trim>;
|
|
173
|
+
readonly runtimeAdapters: Schema.$Array<Schema.Literal<"pi">>;
|
|
174
|
+
readonly status: Schema.Literals<readonly ["registering", "ready", "busy", "degraded", "draining", "offline", "quarantined"]>;
|
|
175
|
+
readonly currentLeaseCount: Schema.Number;
|
|
176
|
+
readonly lastHeartbeatAt: Schema.NullOr<Schema.String>;
|
|
177
|
+
readonly registeredAt: Schema.String;
|
|
178
|
+
readonly manifestPath: Schema.Trim;
|
|
179
|
+
}>>;
|
|
180
|
+
readonly warnings: Schema.$Array<Schema.String>;
|
|
181
|
+
}>>;
|
|
182
|
+
readonly serviceFabric: Schema.optional<Schema.Struct<{
|
|
183
|
+
readonly updatedAt: Schema.String;
|
|
184
|
+
readonly status: Schema.Literals<readonly ["empty", "booting", "ready", "degraded", "stopped"]>;
|
|
185
|
+
readonly serviceCount: Schema.Number;
|
|
186
|
+
readonly healthyServiceCount: Schema.Number;
|
|
187
|
+
readonly stateDir: Schema.Trim;
|
|
188
|
+
readonly services: Schema.$Array<Schema.Struct<{
|
|
189
|
+
readonly name: Schema.Trim;
|
|
190
|
+
readonly relativeRootPath: Schema.Trim;
|
|
191
|
+
readonly mode: Schema.Literals<readonly ["stub", "process"]>;
|
|
192
|
+
readonly port: Schema.Number;
|
|
193
|
+
readonly healthcheck: Schema.Trim;
|
|
194
|
+
readonly routePrefix: Schema.NullOr<Schema.Trim>;
|
|
195
|
+
readonly status: Schema.Literals<readonly ["planned", "booting", "healthy", "degraded", "failed", "stopped"]>;
|
|
196
|
+
readonly pid: Schema.NullOr<Schema.Number>;
|
|
197
|
+
readonly logPath: Schema.NullOr<Schema.Trim>;
|
|
198
|
+
}>>;
|
|
199
|
+
readonly warnings: Schema.$Array<Schema.String>;
|
|
200
|
+
}>>;
|
|
201
|
+
readonly createdAt: Schema.String;
|
|
202
|
+
readonly updatedAt: Schema.String;
|
|
203
|
+
}>;
|
|
204
|
+
export type WorkspaceSummary = typeof WorkspaceSummary.Type;
|
package/dist/src/workspace.js
CHANGED
|
@@ -16,6 +16,9 @@ var WorkspaceId = makeEntityId("WorkspaceId");
|
|
|
16
16
|
var GraphId = makeEntityId("GraphId");
|
|
17
17
|
var TaskId = makeEntityId("TaskId");
|
|
18
18
|
var RunId = makeEntityId("RunId");
|
|
19
|
+
var SafePathSegment = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafePathSegment"));
|
|
20
|
+
var SafeRunId = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/)).pipe(Schema.brand("SafeRunId"));
|
|
21
|
+
var SafeGitRefComponent = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafeGitRefComponent"));
|
|
19
22
|
var EngineRuntimeId = makeEntityId("EngineRuntimeId");
|
|
20
23
|
var ConversationId = makeEntityId("ConversationId");
|
|
21
24
|
var ActionId = makeEntityId("ActionId");
|
|
@@ -964,7 +967,7 @@ var WorkspaceRemoteHostSummary = Schema4.Struct({
|
|
|
964
967
|
region: Schema4.NullOr(TrimmedNonEmptyString),
|
|
965
968
|
labels: Schema4.Array(TrimmedNonEmptyString),
|
|
966
969
|
capabilities: Schema4.Array(TrimmedNonEmptyString),
|
|
967
|
-
runtimeAdapters: Schema4.Array(
|
|
970
|
+
runtimeAdapters: Schema4.Array(Schema4.Literal("pi")),
|
|
968
971
|
status: WorkspaceRemoteHostStatus,
|
|
969
972
|
currentLeaseCount: Schema4.Number,
|
|
970
973
|
lastHeartbeatAt: Schema4.NullOr(IsoDateTime),
|
|
@@ -1005,7 +1008,7 @@ var WorkspaceSummary = Schema4.Struct({
|
|
|
1005
1008
|
title: TrimmedNonEmptyString,
|
|
1006
1009
|
rootPath: TrimmedNonEmptyString,
|
|
1007
1010
|
sourceKind: WorkspaceSourceKind,
|
|
1008
|
-
defaultRuntimeAdapter: Schema4.optional(
|
|
1011
|
+
defaultRuntimeAdapter: Schema4.optional(Schema4.Literal("pi")),
|
|
1009
1012
|
defaultProvider: Schema4.optional(ProviderKind),
|
|
1010
1013
|
defaultModel: Schema4.NullOr(TrimmedNonEmptyString),
|
|
1011
1014
|
topology: Schema4.optional(WorkspaceTopologySummary),
|