@h-rig/run-plugin 0.0.6-alpha.186
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/README.md +1 -0
- package/dist/src/plugin.d.ts +4 -0
- package/dist/src/plugin.js +4319 -0
- package/dist/src/read-model/inspect-command.d.ts +19 -0
- package/dist/src/read-model/inspect-command.js +341 -0
- package/dist/src/read-model/plugin.d.ts +4 -0
- package/dist/src/read-model/plugin.js +2550 -0
- package/dist/src/read-model/read-model-backend/diagnostics.d.ts +9 -0
- package/dist/src/read-model/read-model-backend/diagnostics.js +51 -0
- package/dist/src/read-model/read-model-backend/guard.d.ts +4 -0
- package/dist/src/read-model/read-model-backend/guard.js +25 -0
- package/dist/src/read-model/read-model-backend/inbox.d.ts +23 -0
- package/dist/src/read-model/read-model-backend/inbox.js +669 -0
- package/dist/src/read-model/read-model-backend/index.d.ts +8 -0
- package/dist/src/read-model/read-model-backend/index.js +1163 -0
- package/dist/src/read-model/read-model-backend/inspect.d.ts +26 -0
- package/dist/src/read-model/read-model-backend/inspect.js +770 -0
- package/dist/src/read-model/read-model-backend/projection.d.ts +39 -0
- package/dist/src/read-model/read-model-backend/projection.js +669 -0
- package/dist/src/read-model/read-model-backend/run-status.d.ts +27 -0
- package/dist/src/read-model/read-model-backend/run-status.js +237 -0
- package/dist/src/read-model/read-model-backend/stats.d.ts +12 -0
- package/dist/src/read-model/read-model-backend/stats.js +800 -0
- package/dist/src/read-model/read-model-service.d.ts +2 -0
- package/dist/src/read-model/read-model-service.js +1725 -0
- package/dist/src/read-model/reconcile.d.ts +23 -0
- package/dist/src/read-model/reconcile.js +306 -0
- package/dist/src/read-model/run-format.d.ts +23 -0
- package/dist/src/read-model/run-format.js +202 -0
- package/dist/src/read-model/runs-screen.d.ts +14 -0
- package/dist/src/read-model/runs-screen.js +217 -0
- package/dist/src/read-model/session-journal.d.ts +26 -0
- package/dist/src/read-model/session-journal.js +355 -0
- package/dist/src/read-model/stats-command.d.ts +16 -0
- package/dist/src/read-model/stats-command.js +88 -0
- package/dist/src/read-model/stats-format.d.ts +1 -0
- package/dist/src/read-model/stats-format.js +8 -0
- package/dist/src/worker/autohost.d.ts +11 -0
- package/dist/src/worker/autohost.js +858 -0
- package/dist/src/worker/constants.d.ts +3 -0
- package/dist/src/worker/constants.js +10 -0
- package/dist/src/worker/extension.d.ts +14 -0
- package/dist/src/worker/extension.js +881 -0
- package/dist/src/worker/host.d.ts +1 -0
- package/dist/src/worker/host.js +1 -0
- package/dist/src/worker/inbox-command.d.ts +23 -0
- package/dist/src/worker/inbox-command.js +163 -0
- package/dist/src/worker/index.d.ts +2 -0
- package/dist/src/worker/index.js +1767 -0
- package/dist/src/worker/local-run-changes.d.ts +3 -0
- package/dist/src/worker/local-run-changes.js +65 -0
- package/dist/src/worker/notifications.d.ts +1 -0
- package/dist/src/worker/notifications.js +27 -0
- package/dist/src/worker/notify-cap.d.ts +11 -0
- package/dist/src/worker/notify-cap.js +13 -0
- package/dist/src/worker/panel-plugin.d.ts +11 -0
- package/dist/src/worker/panel-plugin.js +37 -0
- package/dist/src/worker/plugin.d.ts +3 -0
- package/dist/src/worker/plugin.js +1761 -0
- package/dist/src/worker/run-control-service.d.ts +2 -0
- package/dist/src/worker/run-control-service.js +210 -0
- package/dist/src/worker/session-journal-writer.d.ts +4 -0
- package/dist/src/worker/session-journal-writer.js +184 -0
- package/dist/src/worker/stall.d.ts +21 -0
- package/dist/src/worker/stall.js +55 -0
- package/dist/src/worker/utils.d.ts +21 -0
- package/dist/src/worker/utils.js +29 -0
- package/dist/src/worker/workflow-journal-writer.d.ts +7 -0
- package/dist/src/worker/workflow-journal-writer.js +76 -0
- package/package.json +47 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RunJournalProjection } from "@rig/contracts";
|
|
2
|
+
/**
|
|
3
|
+
* Extract the most useful human-facing failure diagnostic from the folded run journal.
|
|
4
|
+
*
|
|
5
|
+
* The live projection deliberately does not retain log/timeline lines, so this mirrors the
|
|
6
|
+
* deleted server-side categorization using only fields that survive folding: record fields,
|
|
7
|
+
* status reasons, closeout details, and reducer anomalies.
|
|
8
|
+
*/
|
|
9
|
+
export declare function summarizeRunError(projection: RunJournalProjection): string | null;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/run-plugin/src/read-model/read-model-backend/diagnostics.ts
|
|
3
|
+
function normalizeString(value) {
|
|
4
|
+
if (typeof value !== "string")
|
|
5
|
+
return null;
|
|
6
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
7
|
+
return normalized.length > 0 ? normalized : null;
|
|
8
|
+
}
|
|
9
|
+
function isGenericRunFailure(value) {
|
|
10
|
+
const text = normalizeString(value);
|
|
11
|
+
return Boolean(text && /^Task run failed \([^)]*\)$/i.test(text));
|
|
12
|
+
}
|
|
13
|
+
function appendCandidate(candidates, value) {
|
|
14
|
+
const text = normalizeString(value);
|
|
15
|
+
if (text && !candidates.includes(text))
|
|
16
|
+
candidates.push(text);
|
|
17
|
+
}
|
|
18
|
+
function categorizeUsefulRunError(lines) {
|
|
19
|
+
const taskSourceFailure = lines.find((line) => /failed to update task source/i.test(line));
|
|
20
|
+
if (taskSourceFailure)
|
|
21
|
+
return `Task source update failed: ${taskSourceFailure}`;
|
|
22
|
+
const moduleFailure = lines.find((line) => /cannot find module/i.test(line));
|
|
23
|
+
if (moduleFailure)
|
|
24
|
+
return `Runtime module resolution failed: ${moduleFailure}`;
|
|
25
|
+
const providerFailure = lines.find((line) => /no api key found|unauthorized|authentication failed|invalid api key/i.test(line));
|
|
26
|
+
if (providerFailure)
|
|
27
|
+
return `Provider authentication failed: ${providerFailure}`;
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
function summarizeRunError(projection) {
|
|
31
|
+
if (projection.status !== "failed")
|
|
32
|
+
return null;
|
|
33
|
+
const candidates = [];
|
|
34
|
+
for (const anomaly of projection.anomalies) {
|
|
35
|
+
appendCandidate(candidates, `Journal anomaly (${anomaly.kind}): ${anomaly.detail}`);
|
|
36
|
+
}
|
|
37
|
+
for (const phase of projection.closeoutPhases) {
|
|
38
|
+
if (phase.outcome === "failed")
|
|
39
|
+
appendCandidate(candidates, phase.detail);
|
|
40
|
+
}
|
|
41
|
+
for (const entry of projection.statusHistory) {
|
|
42
|
+
appendCandidate(candidates, entry.reason);
|
|
43
|
+
}
|
|
44
|
+
appendCandidate(candidates, projection.record.statusDetail);
|
|
45
|
+
appendCandidate(candidates, projection.record.errorText);
|
|
46
|
+
const nonGeneric = candidates.filter((candidate) => !isGenericRunFailure(candidate));
|
|
47
|
+
return categorizeUsefulRunError(nonGeneric) ?? nonGeneric.at(-1) ?? normalizeString(projection.record.errorText);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
summarizeRunError
|
|
51
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RunRecord } from "./projection";
|
|
2
|
+
export declare function runBlocksNewRunForTask(run: RunRecord): boolean;
|
|
3
|
+
export declare function activeRunByTaskId(listRuns: (projectRoot: string) => Promise<RunRecord[]>, projectRoot: string): Promise<Map<string, string>>;
|
|
4
|
+
export declare function assertNoActiveRunForTask(listRuns: (projectRoot: string) => Promise<RunRecord[]>, projectRoot: string, taskId: string): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/run-plugin/src/read-model/read-model-backend/guard.ts
|
|
3
|
+
var TERMINAL = new Set(["completed", "failed", "stopped"]);
|
|
4
|
+
function runBlocksNewRunForTask(run) {
|
|
5
|
+
return run.live && !run.stale && !TERMINAL.has(run.status) && run.status !== "needs-attention" && run.status !== "needs_attention";
|
|
6
|
+
}
|
|
7
|
+
async function activeRunByTaskId(listRuns, projectRoot) {
|
|
8
|
+
const active = new Map;
|
|
9
|
+
for (const run of await listRuns(projectRoot)) {
|
|
10
|
+
if (run.taskId && runBlocksNewRunForTask(run) && !active.has(run.taskId))
|
|
11
|
+
active.set(run.taskId, run.runId);
|
|
12
|
+
}
|
|
13
|
+
return active;
|
|
14
|
+
}
|
|
15
|
+
async function assertNoActiveRunForTask(listRuns, projectRoot, taskId) {
|
|
16
|
+
const existing = (await activeRunByTaskId(listRuns, projectRoot)).get(taskId);
|
|
17
|
+
if (existing) {
|
|
18
|
+
throw new Error(`Task ${taskId} already has an active run: ${existing}. Attach instead: rig run attach ${existing} \u2014 or re-dispatch anyway with --force.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
runBlocksNewRunForTask,
|
|
23
|
+
assertNoActiveRunForTask,
|
|
24
|
+
activeRunByTaskId
|
|
25
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type RunRecord } from "./projection";
|
|
2
|
+
export type InboxKind = "approvals" | "inputs";
|
|
3
|
+
export interface InboxFilters {
|
|
4
|
+
readonly run?: string;
|
|
5
|
+
readonly task?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface InboxRecord {
|
|
8
|
+
readonly runId: string;
|
|
9
|
+
readonly taskId: string | null;
|
|
10
|
+
readonly requestId: string;
|
|
11
|
+
readonly status: "pending";
|
|
12
|
+
readonly prompt: string;
|
|
13
|
+
readonly requestedAt: string;
|
|
14
|
+
readonly payload: unknown;
|
|
15
|
+
readonly kind: "approval" | "input";
|
|
16
|
+
}
|
|
17
|
+
export declare function recordsFromRun(run: RunRecord, kind: InboxKind): InboxRecord[];
|
|
18
|
+
export interface InboxDeps {
|
|
19
|
+
readonly listRuns?: (projectRoot: string) => Promise<readonly RunRecord[]>;
|
|
20
|
+
}
|
|
21
|
+
export declare function listInboxRecords(input: {
|
|
22
|
+
readonly projectRoot: string;
|
|
23
|
+
}, kind: InboxKind, filters?: InboxFilters, deps?: InboxDeps): Promise<InboxRecord[]>;
|