mirror of
https://github.com/KeygraphHQ/shannon.git
synced 2026-10-03 06:46:49 +02:00
List local scans, resolve the active or most recent workspace automatically, and make logs, status, and stop use one canonical scan identity. Add stable machine-readable failures, richer status output, explicit help errors, and seven-day Temporal retention. Treat absent Temporal pending-activity failures as absent whether the decoder represents them as `null` or missing. BREAKING CHANGE: `status --json` now returns a fixed `failureMessage`. Read `partialReasons`, `agenticSast`, and `workflow.log` for diagnostic detail.
28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
/**
|
|
* Workspace → Temporal workflow-id resolution.
|
|
*
|
|
* A workspace name is not always its workflow id: a fresh named workspace gets
|
|
* `<workspace>_shannon-<timestamp>` as its workflow id (only an auto-named workspace's
|
|
* directory name equals its original id), and each resume spawns a new workflow
|
|
* (`<workspace>_resume_<ts>`). The workspace's session.json records the authoritative
|
|
* id — the latest resume attempt, or the original — so commands that query Temporal
|
|
* (status, stop) resolve through here instead of assuming the name is the id.
|
|
*/
|
|
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { getWorkspacesDir } from './home.js';
|
|
import { resolveRunFile } from './paths.js';
|
|
|
|
/** Latest workflow id recorded for a workspace: last resume attempt, else the original. */
|
|
export function resolveWorkflowId(workspace: string): string | undefined {
|
|
const sessionPath = resolveRunFile(path.join(getWorkspacesDir(), workspace), 'session.json');
|
|
try {
|
|
const session = JSON.parse(fs.readFileSync(sessionPath, 'utf-8'));
|
|
const resumeAttempts: { workflowId?: string }[] = session.session?.resumeAttempts ?? [];
|
|
return resumeAttempts.at(-1)?.workflowId ?? session.session?.originalWorkflowId ?? undefined;
|
|
} catch {
|
|
return undefined;
|
|
}
|
|
}
|