lastlight 0.16.0 → 0.16.2
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 +71 -692
- package/dist/cli-config.js.map +1 -0
- package/dist/cli-format.js.map +1 -0
- package/dist/{cli/cli-server.d.ts → cli-server.d.ts} +39 -1
- package/dist/{cli/cli-server.js → cli-server.js} +105 -5
- package/dist/cli-server.js.map +1 -0
- package/dist/cli-timeline.js.map +1 -0
- package/dist/{cli/cli.js → cli.js} +9 -7
- package/dist/cli.js.map +1 -0
- package/dist/{cli/fork-cli.d.ts → fork-cli.d.ts} +3 -3
- package/dist/{cli/fork-cli.js → fork-cli.js} +28 -27
- package/dist/fork-cli.js.map +1 -0
- package/dist/{cli/oauth-cli.js → oauth-cli.js} +1 -1
- package/dist/oauth-cli.js.map +1 -0
- package/dist/{cli/setup.js → setup.js} +10 -4
- package/dist/setup.js.map +1 -0
- package/dist/{cli/skills-install.d.ts → skills-install.d.ts} +6 -0
- package/dist/{cli/skills-install.js → skills-install.js} +6 -2
- package/dist/skills-install.js.map +1 -0
- package/package.json +20 -65
- package/plugins/lastlight/.claude-plugin/plugin.json +1 -1
- package/agent-context/rules.md +0 -80
- package/agent-context/security.md +0 -69
- package/agent-context/soul.md +0 -21
- package/config/default.yaml +0 -119
- package/deploy/.env.production.example +0 -100
- package/deploy/entrypoint.sh +0 -82
- package/deploy/native/README.md +0 -160
- package/deploy/native/install.sh +0 -110
- package/deploy/native/lastlight.env.example +0 -95
- package/deploy/native/lastlight.service +0 -50
- package/deploy/sandbox-entrypoint.sh +0 -93
- package/dist/admin/auth.d.ts +0 -51
- package/dist/admin/auth.js +0 -121
- package/dist/admin/auth.js.map +0 -1
- package/dist/admin/chat-session-reader.d.ts +0 -39
- package/dist/admin/chat-session-reader.js +0 -84
- package/dist/admin/chat-session-reader.js.map +0 -1
- package/dist/admin/docker.d.ts +0 -61
- package/dist/admin/docker.js +0 -187
- package/dist/admin/docker.js.map +0 -1
- package/dist/admin/index.d.ts +0 -9
- package/dist/admin/index.js +0 -59
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/routes.d.ts +0 -81
- package/dist/admin/routes.js +0 -1381
- package/dist/admin/routes.js.map +0 -1
- package/dist/admin/sessions.d.ts +0 -89
- package/dist/admin/sessions.js +0 -204
- package/dist/admin/sessions.js.map +0 -1
- package/dist/admin/tail.d.ts +0 -12
- package/dist/admin/tail.js +0 -145
- package/dist/admin/tail.js.map +0 -1
- package/dist/admin/version.d.ts +0 -22
- package/dist/admin/version.js +0 -92
- package/dist/admin/version.js.map +0 -1
- package/dist/cli/cli-config.js.map +0 -1
- package/dist/cli/cli-format.js.map +0 -1
- package/dist/cli/cli-server.js.map +0 -1
- package/dist/cli/cli-timeline.js.map +0 -1
- package/dist/cli/cli.js.map +0 -1
- package/dist/cli/fork-cli.js.map +0 -1
- package/dist/cli/oauth-cli.js.map +0 -1
- package/dist/cli/setup.js.map +0 -1
- package/dist/cli/skills-install.js.map +0 -1
- package/dist/config/config-resolve.d.ts +0 -28
- package/dist/config/config-resolve.js +0 -47
- package/dist/config/config-resolve.js.map +0 -1
- package/dist/config/config.d.ts +0 -157
- package/dist/config/config.js +0 -581
- package/dist/config/config.js.map +0 -1
- package/dist/config/core-pin.d.ts +0 -16
- package/dist/config/core-pin.js +0 -85
- package/dist/config/core-pin.js.map +0 -1
- package/dist/config/overlay-assets.d.ts +0 -20
- package/dist/config/overlay-assets.js +0 -114
- package/dist/config/overlay-assets.js.map +0 -1
- package/dist/config/overlay-bootstrap.d.ts +0 -44
- package/dist/config/overlay-bootstrap.js +0 -304
- package/dist/config/overlay-bootstrap.js.map +0 -1
- package/dist/connectors/github-webhook.d.ts +0 -45
- package/dist/connectors/github-webhook.js +0 -321
- package/dist/connectors/github-webhook.js.map +0 -1
- package/dist/connectors/index.d.ts +0 -18
- package/dist/connectors/index.js +0 -41
- package/dist/connectors/index.js.map +0 -1
- package/dist/connectors/messaging/base.d.ts +0 -42
- package/dist/connectors/messaging/base.js +0 -139
- package/dist/connectors/messaging/base.js.map +0 -1
- package/dist/connectors/messaging/delivery.d.ts +0 -14
- package/dist/connectors/messaging/delivery.js +0 -38
- package/dist/connectors/messaging/delivery.js.map +0 -1
- package/dist/connectors/messaging/index.d.ts +0 -4
- package/dist/connectors/messaging/index.js +0 -4
- package/dist/connectors/messaging/index.js.map +0 -1
- package/dist/connectors/messaging/session-manager.d.ts +0 -53
- package/dist/connectors/messaging/session-manager.js +0 -255
- package/dist/connectors/messaging/session-manager.js.map +0 -1
- package/dist/connectors/messaging/types.d.ts +0 -58
- package/dist/connectors/messaging/types.js +0 -7
- package/dist/connectors/messaging/types.js.map +0 -1
- package/dist/connectors/slack/connector.d.ts +0 -142
- package/dist/connectors/slack/connector.js +0 -494
- package/dist/connectors/slack/connector.js.map +0 -1
- package/dist/connectors/slack/index.d.ts +0 -2
- package/dist/connectors/slack/index.js +0 -3
- package/dist/connectors/slack/index.js.map +0 -1
- package/dist/connectors/slack/mrkdwn.d.ts +0 -19
- package/dist/connectors/slack/mrkdwn.js +0 -240
- package/dist/connectors/slack/mrkdwn.js.map +0 -1
- package/dist/connectors/types.d.ts +0 -61
- package/dist/connectors/types.js +0 -2
- package/dist/connectors/types.js.map +0 -1
- package/dist/cron/fanout.d.ts +0 -33
- package/dist/cron/fanout.js +0 -55
- package/dist/cron/fanout.js.map +0 -1
- package/dist/cron/jobs.d.ts +0 -18
- package/dist/cron/jobs.js +0 -37
- package/dist/cron/jobs.js.map +0 -1
- package/dist/cron/scheduler.d.ts +0 -45
- package/dist/cron/scheduler.js +0 -105
- package/dist/cron/scheduler.js.map +0 -1
- package/dist/engine/agent-executor.d.ts +0 -34
- package/dist/engine/agent-executor.js +0 -246
- package/dist/engine/agent-executor.js.map +0 -1
- package/dist/engine/chat/chat-runner.d.ts +0 -132
- package/dist/engine/chat/chat-runner.js +0 -424
- package/dist/engine/chat/chat-runner.js.map +0 -1
- package/dist/engine/chat/chat-skills.d.ts +0 -45
- package/dist/engine/chat/chat-skills.js +0 -184
- package/dist/engine/chat/chat-skills.js.map +0 -1
- package/dist/engine/chat/chat.d.ts +0 -54
- package/dist/engine/chat/chat.js +0 -316
- package/dist/engine/chat/chat.js.map +0 -1
- package/dist/engine/chat/message-batcher.d.ts +0 -32
- package/dist/engine/chat/message-batcher.js +0 -109
- package/dist/engine/chat/message-batcher.js.map +0 -1
- package/dist/engine/dispatcher.d.ts +0 -73
- package/dist/engine/dispatcher.js +0 -663
- package/dist/engine/dispatcher.js.map +0 -1
- package/dist/engine/event-shim.d.ts +0 -117
- package/dist/engine/event-shim.js +0 -435
- package/dist/engine/event-shim.js.map +0 -1
- package/dist/engine/executors/orchestrator.d.ts +0 -81
- package/dist/engine/executors/orchestrator.js +0 -365
- package/dist/engine/executors/orchestrator.js.map +0 -1
- package/dist/engine/executors/shared.d.ts +0 -189
- package/dist/engine/executors/shared.js +0 -616
- package/dist/engine/executors/shared.js.map +0 -1
- package/dist/engine/github/git-auth.d.ts +0 -62
- package/dist/engine/github/git-auth.js +0 -161
- package/dist/engine/github/git-auth.js.map +0 -1
- package/dist/engine/github/github-app-client.d.ts +0 -23
- package/dist/engine/github/github-app-client.js +0 -33
- package/dist/engine/github/github-app-client.js.map +0 -1
- package/dist/engine/github/github-tools.d.ts +0 -18
- package/dist/engine/github/github-tools.js +0 -263
- package/dist/engine/github/github-tools.js.map +0 -1
- package/dist/engine/github/github.d.ts +0 -1193
- package/dist/engine/github/github.js +0 -357
- package/dist/engine/github/github.js.map +0 -1
- package/dist/engine/github/profiles.d.ts +0 -279
- package/dist/engine/github/profiles.js +0 -42
- package/dist/engine/github/profiles.js.map +0 -1
- package/dist/engine/github/review-poster.d.ts +0 -98
- package/dist/engine/github/review-poster.js +0 -177
- package/dist/engine/github/review-poster.js.map +0 -1
- package/dist/engine/llm.d.ts +0 -79
- package/dist/engine/llm.js +0 -269
- package/dist/engine/llm.js.map +0 -1
- package/dist/engine/oauth.d.ts +0 -43
- package/dist/engine/oauth.js +0 -103
- package/dist/engine/oauth.js.map +0 -1
- package/dist/engine/router.d.ts +0 -29
- package/dist/engine/router.js +0 -680
- package/dist/engine/router.js.map +0 -1
- package/dist/engine/screen/classifier.d.ts +0 -93
- package/dist/engine/screen/classifier.js +0 -215
- package/dist/engine/screen/classifier.js.map +0 -1
- package/dist/engine/screen/screen.d.ts +0 -41
- package/dist/engine/screen/screen.js +0 -93
- package/dist/engine/screen/screen.js.map +0 -1
- package/dist/evals-api.d.ts +0 -24
- package/dist/evals-api.js +0 -22
- package/dist/evals-api.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -940
- package/dist/index.js.map +0 -1
- package/dist/managed-repos.d.ts +0 -30
- package/dist/managed-repos.js +0 -72
- package/dist/managed-repos.js.map +0 -1
- package/dist/notify/blocks.d.ts +0 -23
- package/dist/notify/blocks.js +0 -118
- package/dist/notify/blocks.js.map +0 -1
- package/dist/notify/index.d.ts +0 -17
- package/dist/notify/index.js +0 -7
- package/dist/notify/index.js.map +0 -1
- package/dist/notify/model.d.ts +0 -57
- package/dist/notify/model.js +0 -89
- package/dist/notify/model.js.map +0 -1
- package/dist/notify/notifier.d.ts +0 -18
- package/dist/notify/notifier.js +0 -100
- package/dist/notify/notifier.js.map +0 -1
- package/dist/notify/render.d.ts +0 -21
- package/dist/notify/render.js +0 -59
- package/dist/notify/render.js.map +0 -1
- package/dist/notify/transports/github.d.ts +0 -26
- package/dist/notify/transports/github.js +0 -27
- package/dist/notify/transports/github.js.map +0 -1
- package/dist/notify/transports/slack.d.ts +0 -27
- package/dist/notify/transports/slack.js +0 -37
- package/dist/notify/transports/slack.js.map +0 -1
- package/dist/notify/types.d.ts +0 -119
- package/dist/notify/types.js +0 -16
- package/dist/notify/types.js.map +0 -1
- package/dist/providers.d.ts +0 -125
- package/dist/providers.js +0 -279
- package/dist/providers.js.map +0 -1
- package/dist/sandbox/docker.d.ts +0 -180
- package/dist/sandbox/docker.js +0 -517
- package/dist/sandbox/docker.js.map +0 -1
- package/dist/sandbox/egress-allowlist.d.ts +0 -74
- package/dist/sandbox/egress-allowlist.js +0 -164
- package/dist/sandbox/egress-allowlist.js.map +0 -1
- package/dist/sandbox/egress-firewall-config.d.ts +0 -127
- package/dist/sandbox/egress-firewall-config.js +0 -434
- package/dist/sandbox/egress-firewall-config.js.map +0 -1
- package/dist/sandbox/images.d.ts +0 -23
- package/dist/sandbox/images.js +0 -55
- package/dist/sandbox/images.js.map +0 -1
- package/dist/sandbox/index.d.ts +0 -112
- package/dist/sandbox/index.js +0 -332
- package/dist/sandbox/index.js.map +0 -1
- package/dist/sandbox/sandbox.d.ts +0 -214
- package/dist/sandbox/sandbox.js +0 -453
- package/dist/sandbox/sandbox.js.map +0 -1
- package/dist/sandbox/smol.d.ts +0 -162
- package/dist/sandbox/smol.js +0 -485
- package/dist/sandbox/smol.js.map +0 -1
- package/dist/session-log.d.ts +0 -63
- package/dist/session-log.js +0 -290
- package/dist/session-log.js.map +0 -1
- package/dist/state/approval-store.d.ts +0 -88
- package/dist/state/approval-store.js +0 -149
- package/dist/state/approval-store.js.map +0 -1
- package/dist/state/build-assets.d.ts +0 -50
- package/dist/state/build-assets.js +0 -154
- package/dist/state/build-assets.js.map +0 -1
- package/dist/state/db.d.ts +0 -81
- package/dist/state/db.js +0 -155
- package/dist/state/db.js.map +0 -1
- package/dist/state/execution-store.d.ts +0 -257
- package/dist/state/execution-store.js +0 -527
- package/dist/state/execution-store.js.map +0 -1
- package/dist/state/migrate.d.ts +0 -15
- package/dist/state/migrate.js +0 -175
- package/dist/state/migrate.js.map +0 -1
- package/dist/state/workflow-run-store.d.ts +0 -216
- package/dist/state/workflow-run-store.js +0 -403
- package/dist/state/workflow-run-store.js.map +0 -1
- package/dist/telemetry/index.d.ts +0 -38
- package/dist/telemetry/index.js +0 -253
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/pi-events.d.ts +0 -12
- package/dist/telemetry/pi-events.js +0 -134
- package/dist/telemetry/pi-events.js.map +0 -1
- package/dist/workflows/dag.d.ts +0 -37
- package/dist/workflows/dag.js +0 -118
- package/dist/workflows/dag.js.map +0 -1
- package/dist/workflows/loader.d.ts +0 -53
- package/dist/workflows/loader.js +0 -421
- package/dist/workflows/loader.js.map +0 -1
- package/dist/workflows/loop-eval.d.ts +0 -28
- package/dist/workflows/loop-eval.js +0 -74
- package/dist/workflows/loop-eval.js.map +0 -1
- package/dist/workflows/phase-executor.d.ts +0 -222
- package/dist/workflows/phase-executor.js +0 -1153
- package/dist/workflows/phase-executor.js.map +0 -1
- package/dist/workflows/phase-ref.d.ts +0 -50
- package/dist/workflows/phase-ref.js +0 -91
- package/dist/workflows/phase-ref.js.map +0 -1
- package/dist/workflows/resume.d.ts +0 -58
- package/dist/workflows/resume.js +0 -313
- package/dist/workflows/resume.js.map +0 -1
- package/dist/workflows/runner.d.ts +0 -63
- package/dist/workflows/runner.js +0 -381
- package/dist/workflows/runner.js.map +0 -1
- package/dist/workflows/schema.d.ts +0 -344
- package/dist/workflows/schema.js +0 -460
- package/dist/workflows/schema.js.map +0 -1
- package/dist/workflows/simple.d.ts +0 -90
- package/dist/workflows/simple.js +0 -393
- package/dist/workflows/simple.js.map +0 -1
- package/dist/workflows/target-policy.d.ts +0 -74
- package/dist/workflows/target-policy.js +0 -80
- package/dist/workflows/target-policy.js.map +0 -1
- package/dist/workflows/templates.d.ts +0 -88
- package/dist/workflows/templates.js +0 -127
- package/dist/workflows/templates.js.map +0 -1
- package/dist/workflows/triggers.d.ts +0 -21
- package/dist/workflows/triggers.js +0 -45
- package/dist/workflows/triggers.js.map +0 -1
- package/dist/workflows/verdict.d.ts +0 -19
- package/dist/workflows/verdict.js +0 -30
- package/dist/workflows/verdict.js.map +0 -1
- package/dist/worktree/manager.d.ts +0 -43
- package/dist/worktree/manager.js +0 -127
- package/dist/worktree/manager.js.map +0 -1
- package/docker-compose.yml +0 -274
- package/sandbox.Dockerfile +0 -68
- package/skills/README.md +0 -42
- package/skills/browser-qa/SKILL.md +0 -208
- package/skills/browser-qa/scripts/agent-browser.mjs +0 -531
- package/skills/building/SKILL.md +0 -95
- package/skills/chat/SKILL.md +0 -36
- package/skills/code-review/SKILL.md +0 -82
- package/skills/debug-production/SKILL.md +0 -108
- package/skills/demo/SKILL.md +0 -228
- package/skills/demo/scripts/compose-demo.sh +0 -243
- package/skills/issue-answer/SKILL.md +0 -91
- package/skills/issue-comment/SKILL.md +0 -49
- package/skills/issue-triage/SKILL.md +0 -149
- package/skills/issue-triage/references/AGENT-BRIEF.md +0 -65
- package/skills/pr-comment/SKILL.md +0 -64
- package/skills/pr-review/SKILL.md +0 -148
- package/skills/pr-review/references/findings-schema.md +0 -89
- package/skills/qa-test/SKILL.md +0 -97
- package/skills/repo-health/SKILL.md +0 -67
- package/skills/security-feedback/SKILL.md +0 -173
- package/skills/security-feedback/references/templates.md +0 -77
- package/skills/security-review/SKILL.md +0 -215
- package/skills/security-review/references/issue-format.md +0 -302
- package/skills/verify/SKILL.md +0 -118
- package/workflows/answer.yaml +0 -44
- package/workflows/build.yaml +0 -129
- package/workflows/cron-health.yaml +0 -6
- package/workflows/cron-review.yaml +0 -8
- package/workflows/cron-security.yaml +0 -6
- package/workflows/cron-triage.yaml +0 -8
- package/workflows/demo.yaml +0 -62
- package/workflows/examples/bash-smoke.yaml +0 -41
- package/workflows/examples/parallel-review.yaml +0 -36
- package/workflows/examples/tdd-loop.yaml +0 -17
- package/workflows/explore.yaml +0 -80
- package/workflows/issue-comment.yaml +0 -15
- package/workflows/issue-triage.yaml +0 -22
- package/workflows/pr-comment.yaml +0 -16
- package/workflows/pr-fix.yaml +0 -17
- package/workflows/pr-review.yaml +0 -50
- package/workflows/prompts/answer.md +0 -68
- package/workflows/prompts/architect.md +0 -44
- package/workflows/prompts/classifier.md +0 -60
- package/workflows/prompts/classify-adds-info.md +0 -17
- package/workflows/prompts/demo.md +0 -125
- package/workflows/prompts/executor.md +0 -42
- package/workflows/prompts/explore-ask.md +0 -99
- package/workflows/prompts/explore-publish.md +0 -31
- package/workflows/prompts/explore-read.md +0 -120
- package/workflows/prompts/explore-synthesize.md +0 -88
- package/workflows/prompts/fix.md +0 -18
- package/workflows/prompts/guardrails.md +0 -96
- package/workflows/prompts/pr-fix.md +0 -26
- package/workflows/prompts/pr.md +0 -39
- package/workflows/prompts/qa-browser.md +0 -95
- package/workflows/prompts/qa-synth.md +0 -44
- package/workflows/prompts/qa-test.md +0 -60
- package/workflows/prompts/re-reviewer.md +0 -33
- package/workflows/prompts/reviewer.md +0 -60
- package/workflows/prompts/verify-browser.md +0 -93
- package/workflows/prompts/verify-synth.md +0 -44
- package/workflows/prompts/verify.md +0 -63
- package/workflows/qa-test.yaml +0 -94
- package/workflows/repo-health.yaml +0 -15
- package/workflows/security-feedback.yaml +0 -25
- package/workflows/security-review.yaml +0 -37
- package/workflows/verify.yaml +0 -93
- /package/dist/{cli/cli-config.d.ts → cli-config.d.ts} +0 -0
- /package/dist/{cli/cli-config.js → cli-config.js} +0 -0
- /package/dist/{cli/cli-format.d.ts → cli-format.d.ts} +0 -0
- /package/dist/{cli/cli-format.js → cli-format.js} +0 -0
- /package/dist/{cli/cli-timeline.d.ts → cli-timeline.d.ts} +0 -0
- /package/dist/{cli/cli-timeline.js → cli-timeline.js} +0 -0
- /package/dist/{cli/cli.d.ts → cli.d.ts} +0 -0
- /package/dist/{cli/oauth-cli.d.ts → oauth-cli.d.ts} +0 -0
- /package/dist/{cli/setup.d.ts → setup.d.ts} +0 -0
package/dist/session-log.js
DELETED
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { promises as fsp } from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import readline from "node:readline";
|
|
5
|
-
export const CHAT_PROJECT_SLUG = "-app";
|
|
6
|
-
/**
|
|
7
|
-
* Filesystem cwd → project-dir slug (matches the SDK convention). The
|
|
8
|
-
* absolute path with `/` replaced by `-`. `/app` → `-app`,
|
|
9
|
-
* `/home/agent/workspace` → `-home-agent-workspace`.
|
|
10
|
-
*/
|
|
11
|
-
export function projectSlugForCwd(cwd) {
|
|
12
|
-
return cwd.replace(/\//g, "-");
|
|
13
|
-
}
|
|
14
|
-
export class SessionLog {
|
|
15
|
-
homeDir;
|
|
16
|
-
constructor(homeDir) {
|
|
17
|
-
this.homeDir = homeDir;
|
|
18
|
-
}
|
|
19
|
-
normalizeSessionId(sessionId) {
|
|
20
|
-
const safeId = path.basename(sessionId);
|
|
21
|
-
if (safeId !== sessionId)
|
|
22
|
-
return null;
|
|
23
|
-
if (!/^[A-Za-z0-9_-]+$/.test(safeId))
|
|
24
|
-
return null;
|
|
25
|
-
return safeId;
|
|
26
|
-
}
|
|
27
|
-
pathForProject(projectSlug, sessionId, opts = {}) {
|
|
28
|
-
const safeId = this.normalizeSessionId(sessionId);
|
|
29
|
-
if (!safeId || !this.isSafeProjectSlug(projectSlug))
|
|
30
|
-
return null;
|
|
31
|
-
const file = path.join(this.homeDir, "projects", projectSlug, `${safeId}.jsonl`);
|
|
32
|
-
if (opts.requireExists && !fs.existsSync(file))
|
|
33
|
-
return null;
|
|
34
|
-
return file;
|
|
35
|
-
}
|
|
36
|
-
findSession(scope, sessionId) {
|
|
37
|
-
const safeId = this.normalizeSessionId(sessionId);
|
|
38
|
-
if (!safeId)
|
|
39
|
-
return null;
|
|
40
|
-
for (const projectDir of this.projectDirs(scope)) {
|
|
41
|
-
const projectSlug = path.basename(projectDir);
|
|
42
|
-
const filePath = this.pathForProject(projectSlug, safeId, { requireExists: true });
|
|
43
|
-
if (!filePath)
|
|
44
|
-
continue;
|
|
45
|
-
return {
|
|
46
|
-
id: safeId,
|
|
47
|
-
filePath,
|
|
48
|
-
mtimeMs: this.mtimeMs(filePath),
|
|
49
|
-
projectSlug,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
listSessions(scope) {
|
|
55
|
-
const entries = [];
|
|
56
|
-
for (const dir of this.projectDirs(scope)) {
|
|
57
|
-
const projectSlug = path.basename(dir);
|
|
58
|
-
try {
|
|
59
|
-
for (const f of fs.readdirSync(dir)) {
|
|
60
|
-
if (!f.endsWith(".jsonl"))
|
|
61
|
-
continue;
|
|
62
|
-
const id = f.slice(0, -6);
|
|
63
|
-
if (id.startsWith("agent-"))
|
|
64
|
-
continue;
|
|
65
|
-
const filePath = path.join(dir, f);
|
|
66
|
-
entries.push({ id, filePath, mtimeMs: this.mtimeMs(filePath), projectSlug });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// skip unreadable dirs
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
entries.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
74
|
-
return entries;
|
|
75
|
-
}
|
|
76
|
-
relatedFilesForSession(scope, sessionId, opts = {}) {
|
|
77
|
-
const entry = this.findSession(scope, sessionId);
|
|
78
|
-
if (!entry)
|
|
79
|
-
return [];
|
|
80
|
-
const files = [entry.filePath];
|
|
81
|
-
if (!opts.includeAgents)
|
|
82
|
-
return files;
|
|
83
|
-
const dir = path.dirname(entry.filePath);
|
|
84
|
-
for (const agentDir of [dir, path.join(dir, entry.id, "subagents")]) {
|
|
85
|
-
try {
|
|
86
|
-
for (const f of fs.readdirSync(agentDir)) {
|
|
87
|
-
if (!f.startsWith("agent-") || !f.endsWith(".jsonl"))
|
|
88
|
-
continue;
|
|
89
|
-
files.push(path.join(agentDir, f));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
// dir doesn't exist or is unreadable
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return files;
|
|
97
|
-
}
|
|
98
|
-
async appendEnvelopeLines(ref, lines) {
|
|
99
|
-
if (lines.length === 0)
|
|
100
|
-
return;
|
|
101
|
-
const filePath = this.pathForProject(ref.projectSlug, ref.sessionId, { requireExists: false });
|
|
102
|
-
if (!filePath)
|
|
103
|
-
return;
|
|
104
|
-
const data = lines.map((l) => JSON.stringify(l)).join("\n") + "\n";
|
|
105
|
-
await fsp.mkdir(path.dirname(filePath), { recursive: true });
|
|
106
|
-
await fsp.appendFile(filePath, data);
|
|
107
|
-
}
|
|
108
|
-
async readNormalizedFile(filePath, opts = {}) {
|
|
109
|
-
const out = [];
|
|
110
|
-
const stream = fs.createReadStream(filePath, { encoding: "utf8" });
|
|
111
|
-
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
|
|
112
|
-
for await (const line of rl) {
|
|
113
|
-
if (!line.trim())
|
|
114
|
-
continue;
|
|
115
|
-
try {
|
|
116
|
-
const raw = JSON.parse(line);
|
|
117
|
-
for (const msg of this.normalizeLine(raw)) {
|
|
118
|
-
if (opts.skipEmptySystem && msg.role === "system" && !msg.content)
|
|
119
|
-
continue;
|
|
120
|
-
const timestamp = msg.timestamp ?? raw.timestamp ?? "";
|
|
121
|
-
out.push({ timestamp, msg, raw });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
// skip malformed lines
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return out;
|
|
129
|
-
}
|
|
130
|
-
async readNormalizedSession(scope, sessionId, opts = {}) {
|
|
131
|
-
const allMessages = [];
|
|
132
|
-
for (const file of this.relatedFilesForSession(scope, sessionId, { includeAgents: opts.includeAgents })) {
|
|
133
|
-
allMessages.push(...await this.readNormalizedFile(file, { skipEmptySystem: opts.skipEmptySystem }));
|
|
134
|
-
}
|
|
135
|
-
allMessages.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
|
136
|
-
return allMessages.map((m, i) => ({ index: i, msg: m.msg }));
|
|
137
|
-
}
|
|
138
|
-
normalizeLine(raw) {
|
|
139
|
-
return unwrapLine(raw);
|
|
140
|
-
}
|
|
141
|
-
isSafeProjectSlug(projectSlug) {
|
|
142
|
-
return Boolean(projectSlug) && path.basename(projectSlug) === projectSlug && projectSlug !== "." && projectSlug !== "..";
|
|
143
|
-
}
|
|
144
|
-
projectDirs(scope) {
|
|
145
|
-
const projectsDir = path.join(this.homeDir, "projects");
|
|
146
|
-
try {
|
|
147
|
-
return fs
|
|
148
|
-
.readdirSync(projectsDir)
|
|
149
|
-
.filter((name) => (scope === "chat" ? name === CHAT_PROJECT_SLUG : name !== CHAT_PROJECT_SLUG))
|
|
150
|
-
.map((d) => path.join(projectsDir, d))
|
|
151
|
-
.filter((p) => fs.statSync(p).isDirectory());
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
mtimeMs(filePath) {
|
|
158
|
-
try {
|
|
159
|
-
return fs.statSync(filePath).mtimeMs;
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
return 0;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
function unwrapLine(raw) {
|
|
167
|
-
// Already in role-based format (Hermes / Agent SDK --print output)
|
|
168
|
-
if (typeof raw.role === "string") {
|
|
169
|
-
return [raw];
|
|
170
|
-
}
|
|
171
|
-
const type = raw.type;
|
|
172
|
-
if (!type)
|
|
173
|
-
return [];
|
|
174
|
-
// Skip internal types
|
|
175
|
-
if (type === "queue-operation" || type === "summary" || type === "login")
|
|
176
|
-
return [];
|
|
177
|
-
if (type === "last-prompt" || type === "attachment")
|
|
178
|
-
return [];
|
|
179
|
-
const timestamp = raw.timestamp;
|
|
180
|
-
// Parse the message field — can be a JSON string or an object
|
|
181
|
-
let msg = {};
|
|
182
|
-
if (raw.message != null) {
|
|
183
|
-
if (typeof raw.message === "string") {
|
|
184
|
-
try {
|
|
185
|
-
msg = JSON.parse(raw.message);
|
|
186
|
-
}
|
|
187
|
-
catch {
|
|
188
|
-
msg = { content: raw.message };
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
else if (typeof raw.message === "object") {
|
|
192
|
-
msg = raw.message;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (type === "user") {
|
|
196
|
-
const content = msg.content ?? raw.content;
|
|
197
|
-
// User messages with tool_result blocks → emit each as a separate tool message
|
|
198
|
-
if (Array.isArray(content)) {
|
|
199
|
-
const hasToolResults = content.some((b) => b.type === "tool_result");
|
|
200
|
-
if (hasToolResults) {
|
|
201
|
-
return content
|
|
202
|
-
.filter((b) => b.type === "tool_result")
|
|
203
|
-
.map((b) => {
|
|
204
|
-
const block = b;
|
|
205
|
-
return {
|
|
206
|
-
role: "tool",
|
|
207
|
-
content: block.content,
|
|
208
|
-
tool_call_id: block.tool_use_id,
|
|
209
|
-
timestamp,
|
|
210
|
-
};
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return [{ role: "user", content, timestamp }];
|
|
215
|
-
}
|
|
216
|
-
if (type === "assistant") {
|
|
217
|
-
if (raw.isApiErrorMessage || raw.error) {
|
|
218
|
-
return [{ role: "system", content: String(raw.error ?? "API error"), timestamp }];
|
|
219
|
-
}
|
|
220
|
-
const content = msg.content;
|
|
221
|
-
const model = msg.model;
|
|
222
|
-
const stopReason = msg.stop_reason;
|
|
223
|
-
let textContent;
|
|
224
|
-
let toolCalls;
|
|
225
|
-
let reasoning;
|
|
226
|
-
if (Array.isArray(content)) {
|
|
227
|
-
const textBlocks = [];
|
|
228
|
-
const tools = [];
|
|
229
|
-
for (const block of content) {
|
|
230
|
-
const b = block;
|
|
231
|
-
if (b.type === "text" && typeof b.text === "string") {
|
|
232
|
-
textBlocks.push(b.text);
|
|
233
|
-
}
|
|
234
|
-
else if (b.type === "tool_use") {
|
|
235
|
-
tools.push({
|
|
236
|
-
id: b.id,
|
|
237
|
-
function: { name: b.name, arguments: b.input },
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
else if (b.type === "thinking" || b.type === "reasoning") {
|
|
241
|
-
reasoning = b.thinking ?? b.text;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
if (textBlocks.length)
|
|
245
|
-
textContent = textBlocks.join("\n");
|
|
246
|
-
if (tools.length)
|
|
247
|
-
toolCalls = tools;
|
|
248
|
-
}
|
|
249
|
-
else if (typeof content === "string") {
|
|
250
|
-
textContent = content;
|
|
251
|
-
}
|
|
252
|
-
// Skip lines that only have thinking (no text, no tools) — they're noise
|
|
253
|
-
if (!textContent && !toolCalls && reasoning)
|
|
254
|
-
return [];
|
|
255
|
-
// Skip completely empty assistant messages
|
|
256
|
-
if (!textContent && !toolCalls)
|
|
257
|
-
return [];
|
|
258
|
-
return [{
|
|
259
|
-
role: "assistant",
|
|
260
|
-
content: textContent,
|
|
261
|
-
tool_calls: toolCalls,
|
|
262
|
-
reasoning,
|
|
263
|
-
finish_reason: stopReason,
|
|
264
|
-
model,
|
|
265
|
-
timestamp,
|
|
266
|
-
}];
|
|
267
|
-
}
|
|
268
|
-
if (type === "tool_result") {
|
|
269
|
-
const content = msg.content ?? raw.content;
|
|
270
|
-
const toolUseId = msg.tool_use_id ?? raw.tool_use_id;
|
|
271
|
-
return [{
|
|
272
|
-
role: "tool",
|
|
273
|
-
content,
|
|
274
|
-
tool_call_id: toolUseId,
|
|
275
|
-
timestamp,
|
|
276
|
-
}];
|
|
277
|
-
}
|
|
278
|
-
if (type === "tool_use") {
|
|
279
|
-
return [{
|
|
280
|
-
role: "assistant",
|
|
281
|
-
tool_calls: [{
|
|
282
|
-
id: msg.id ?? raw.uuid,
|
|
283
|
-
function: { name: msg.name, arguments: msg.input },
|
|
284
|
-
}],
|
|
285
|
-
timestamp,
|
|
286
|
-
}];
|
|
287
|
-
}
|
|
288
|
-
return [];
|
|
289
|
-
}
|
|
290
|
-
//# sourceMappingURL=session-log.js.map
|
package/dist/session-log.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-log.js","sourceRoot":"","sources":["../src/session-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,MAAM,SAAS,C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AS,GAAI,GAAG,CAAC,WAAsB,IAAK,GAAG,CAAC,WAAsB,CAAC;QAC7E,OAAO,CAAC;gBACN,IAAI,EAAE,MAAM;gBACZ,OAAO;gBACP,YAAY,EAAE,SAAS;gBACvB,SAAS;aACV,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QACxB,OAAO,CAAC;gBACN,IAAI,EAAE,WAAW;gBACjB,UAAU,EAAE,CAAC;wBACX,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI;wBACtB,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,KAAK,EAAE;qBACnD,CAAC;gBACF,SAAS;aACV,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type Database from "better-sqlite3";
|
|
2
|
-
export interface WorkflowApproval {
|
|
3
|
-
id: string;
|
|
4
|
-
workflowRunId: string;
|
|
5
|
-
gate: string;
|
|
6
|
-
summary: string;
|
|
7
|
-
status: 'pending' | 'approved' | 'rejected';
|
|
8
|
-
/**
|
|
9
|
-
* Gate flavor. `approve` gates resolve only on an explicit approve/reject
|
|
10
|
-
* command; `reply` gates resolve on any free-form reply in the same
|
|
11
|
-
* thread (used by the socratic explore loop).
|
|
12
|
-
*/
|
|
13
|
-
kind: 'approve' | 'reply';
|
|
14
|
-
/**
|
|
15
|
-
* Artifact (handoff doc) filename this gate is asking the reviewer to
|
|
16
|
-
* approve, e.g. `architect-plan.md`. Surfaced by the focused approval view.
|
|
17
|
-
*/
|
|
18
|
-
artifact?: string;
|
|
19
|
-
requestedBy?: string;
|
|
20
|
-
respondedBy?: string;
|
|
21
|
-
response?: string;
|
|
22
|
-
respondedAt?: string;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Owns the `workflow_approvals` table — the human-in-the-loop gates a workflow
|
|
27
|
-
* run can pause on. Carved out of the old `StateDb` god-class (issue #97).
|
|
28
|
-
*
|
|
29
|
-
* Pure single-table reads/writes; it holds no transaction of its own. The
|
|
30
|
-
* cross-table lifecycle operations that pair an approval mutation with a run
|
|
31
|
-
* status flip (resolve-and-resume, resolve-and-fail, pause-for-approval) live
|
|
32
|
-
* on {@link WorkflowRunStore}, the aggregate root, which is injected with an
|
|
33
|
-
* instance of this store and calls these methods inside a single transaction.
|
|
34
|
-
*/
|
|
35
|
-
export declare class ApprovalStore {
|
|
36
|
-
private db;
|
|
37
|
-
constructor(db: Database.Database);
|
|
38
|
-
/** Create a new pending approval request */
|
|
39
|
-
create(approval: Omit<WorkflowApproval, "status" | "respondedBy" | "response" | "respondedAt" | "kind"> & {
|
|
40
|
-
kind?: WorkflowApproval["kind"];
|
|
41
|
-
}): void;
|
|
42
|
-
/**
|
|
43
|
-
* Resolve a reply gate: marks the approval row as approved (reply gates
|
|
44
|
-
* don't have approve/reject semantics — any reply is a "go") and stores
|
|
45
|
-
* the reply text as the `response`. Used by the socratic explore loop.
|
|
46
|
-
*
|
|
47
|
-
* Guarded by `kind = 'reply' AND status = 'pending'` and returns the number
|
|
48
|
-
* of rows changed (1 on success, 0 if the gate is missing / wrong kind /
|
|
49
|
-
* already resolved). {@link WorkflowRunStore.resolveReplyGateAndResume} uses
|
|
50
|
-
* the count as a double-reply concurrency guard — two replies racing on the
|
|
51
|
-
* same thread, the second sees 0 rows and the transaction aborts before a
|
|
52
|
-
* duplicate resume.
|
|
53
|
-
*/
|
|
54
|
-
resolveReplyGate(id: string, replyText: string, responder: string): number;
|
|
55
|
-
/**
|
|
56
|
-
* Find the most recent pending reply gate for a given trigger id. Used by
|
|
57
|
-
* the router to short-circuit free-form replies on a paused socratic
|
|
58
|
-
* explore loop without re-running classifier logic.
|
|
59
|
-
*/
|
|
60
|
-
getPendingReplyGateByTrigger(triggerId: string): WorkflowApproval | null;
|
|
61
|
-
/** Get a single approval by ID */
|
|
62
|
-
getById(id: string): WorkflowApproval | null;
|
|
63
|
-
/** Find the pending approval for a workflow run */
|
|
64
|
-
getPendingForWorkflow(workflowRunId: string): WorkflowApproval | null;
|
|
65
|
-
/** Find the pending approval by trigger ID (join with workflow_runs) */
|
|
66
|
-
getPendingByTrigger(triggerId: string): WorkflowApproval | null;
|
|
67
|
-
/**
|
|
68
|
-
* List every approval for a workflow run — all statuses (pending, approved,
|
|
69
|
-
* rejected), oldest first. Powers the dashboard's per-run approval history
|
|
70
|
-
* (who approved/rejected a gate, when, and any comment). Unlike
|
|
71
|
-
* {@link getPendingForWorkflow} this does not filter on status.
|
|
72
|
-
*/
|
|
73
|
-
listForWorkflow(workflowRunId: string): WorkflowApproval[];
|
|
74
|
-
/** List all approvals carrying a specific artifact name, newest first */
|
|
75
|
-
listByArtifact(artifact: string): WorkflowApproval[];
|
|
76
|
-
/** List all pending approvals */
|
|
77
|
-
listPending(): WorkflowApproval[];
|
|
78
|
-
/**
|
|
79
|
-
* Record the response to a still-pending approval.
|
|
80
|
-
*
|
|
81
|
-
* Returns the number of rows changed so aggregate lifecycle operations can
|
|
82
|
-
* use this as a compare-and-set guard: if two responders race, only the
|
|
83
|
-
* first pending row update succeeds and the loser must not resume/fail the
|
|
84
|
-
* workflow a second time.
|
|
85
|
-
*/
|
|
86
|
-
respond(id: string, status: 'approved' | 'rejected', respondedBy: string, response?: string): number;
|
|
87
|
-
private deserialize;
|
|
88
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Owns the `workflow_approvals` table — the human-in-the-loop gates a workflow
|
|
3
|
-
* run can pause on. Carved out of the old `StateDb` god-class (issue #97).
|
|
4
|
-
*
|
|
5
|
-
* Pure single-table reads/writes; it holds no transaction of its own. The
|
|
6
|
-
* cross-table lifecycle operations that pair an approval mutation with a run
|
|
7
|
-
* status flip (resolve-and-resume, resolve-and-fail, pause-for-approval) live
|
|
8
|
-
* on {@link WorkflowRunStore}, the aggregate root, which is injected with an
|
|
9
|
-
* instance of this store and calls these methods inside a single transaction.
|
|
10
|
-
*/
|
|
11
|
-
export class ApprovalStore {
|
|
12
|
-
db;
|
|
13
|
-
constructor(db) {
|
|
14
|
-
this.db = db;
|
|
15
|
-
}
|
|
16
|
-
/** Create a new pending approval request */
|
|
17
|
-
create(approval) {
|
|
18
|
-
this.db
|
|
19
|
-
.prepare(`
|
|
20
|
-
INSERT INTO workflow_approvals (id, workflow_run_id, gate, summary, status, kind, artifact, requested_by, created_at)
|
|
21
|
-
VALUES (?, ?, ?, ?, 'pending', ?, ?, ?, ?)
|
|
22
|
-
`)
|
|
23
|
-
.run(approval.id, approval.workflowRunId, approval.gate, approval.summary, approval.kind ?? "approve", approval.artifact ?? null, approval.requestedBy ?? null, approval.createdAt);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Resolve a reply gate: marks the approval row as approved (reply gates
|
|
27
|
-
* don't have approve/reject semantics — any reply is a "go") and stores
|
|
28
|
-
* the reply text as the `response`. Used by the socratic explore loop.
|
|
29
|
-
*
|
|
30
|
-
* Guarded by `kind = 'reply' AND status = 'pending'` and returns the number
|
|
31
|
-
* of rows changed (1 on success, 0 if the gate is missing / wrong kind /
|
|
32
|
-
* already resolved). {@link WorkflowRunStore.resolveReplyGateAndResume} uses
|
|
33
|
-
* the count as a double-reply concurrency guard — two replies racing on the
|
|
34
|
-
* same thread, the second sees 0 rows and the transaction aborts before a
|
|
35
|
-
* duplicate resume.
|
|
36
|
-
*/
|
|
37
|
-
resolveReplyGate(id, replyText, responder) {
|
|
38
|
-
const now = new Date().toISOString();
|
|
39
|
-
const result = this.db
|
|
40
|
-
.prepare(`UPDATE workflow_approvals
|
|
41
|
-
SET status = 'approved',
|
|
42
|
-
responded_by = ?,
|
|
43
|
-
response = ?,
|
|
44
|
-
responded_at = ?
|
|
45
|
-
WHERE id = ? AND kind = 'reply' AND status = 'pending'`)
|
|
46
|
-
.run(responder, replyText, now, id);
|
|
47
|
-
return result.changes;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Find the most recent pending reply gate for a given trigger id. Used by
|
|
51
|
-
* the router to short-circuit free-form replies on a paused socratic
|
|
52
|
-
* explore loop without re-running classifier logic.
|
|
53
|
-
*/
|
|
54
|
-
getPendingReplyGateByTrigger(triggerId) {
|
|
55
|
-
const row = this.db
|
|
56
|
-
.prepare(`SELECT wa.* FROM workflow_approvals wa
|
|
57
|
-
JOIN workflow_runs wr ON wa.workflow_run_id = wr.id
|
|
58
|
-
WHERE wr.trigger_id = ? AND wa.status = 'pending' AND wa.kind = 'reply'
|
|
59
|
-
ORDER BY wa.created_at DESC
|
|
60
|
-
LIMIT 1`)
|
|
61
|
-
.get(triggerId);
|
|
62
|
-
return row ? this.deserialize(row) : null;
|
|
63
|
-
}
|
|
64
|
-
/** Get a single approval by ID */
|
|
65
|
-
getById(id) {
|
|
66
|
-
const row = this.db.prepare(`SELECT * FROM workflow_approvals WHERE id = ?`).get(id);
|
|
67
|
-
return row ? this.deserialize(row) : null;
|
|
68
|
-
}
|
|
69
|
-
/** Find the pending approval for a workflow run */
|
|
70
|
-
getPendingForWorkflow(workflowRunId) {
|
|
71
|
-
const row = this.db.prepare(`
|
|
72
|
-
SELECT * FROM workflow_approvals WHERE workflow_run_id = ? AND status = 'pending' LIMIT 1
|
|
73
|
-
`).get(workflowRunId);
|
|
74
|
-
return row ? this.deserialize(row) : null;
|
|
75
|
-
}
|
|
76
|
-
/** Find the pending approval by trigger ID (join with workflow_runs) */
|
|
77
|
-
getPendingByTrigger(triggerId) {
|
|
78
|
-
const row = this.db.prepare(`
|
|
79
|
-
SELECT wa.* FROM workflow_approvals wa
|
|
80
|
-
JOIN workflow_runs wr ON wa.workflow_run_id = wr.id
|
|
81
|
-
WHERE wr.trigger_id = ? AND wa.status = 'pending'
|
|
82
|
-
ORDER BY wa.created_at DESC
|
|
83
|
-
LIMIT 1
|
|
84
|
-
`).get(triggerId);
|
|
85
|
-
return row ? this.deserialize(row) : null;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* List every approval for a workflow run — all statuses (pending, approved,
|
|
89
|
-
* rejected), oldest first. Powers the dashboard's per-run approval history
|
|
90
|
-
* (who approved/rejected a gate, when, and any comment). Unlike
|
|
91
|
-
* {@link getPendingForWorkflow} this does not filter on status.
|
|
92
|
-
*/
|
|
93
|
-
listForWorkflow(workflowRunId) {
|
|
94
|
-
const rows = this.db.prepare(`
|
|
95
|
-
SELECT * FROM workflow_approvals WHERE workflow_run_id = ? ORDER BY created_at ASC
|
|
96
|
-
`).all(workflowRunId);
|
|
97
|
-
return rows.map((r) => this.deserialize(r));
|
|
98
|
-
}
|
|
99
|
-
/** List all approvals carrying a specific artifact name, newest first */
|
|
100
|
-
listByArtifact(artifact) {
|
|
101
|
-
const rows = this.db.prepare(`
|
|
102
|
-
SELECT * FROM workflow_approvals
|
|
103
|
-
WHERE artifact = ?
|
|
104
|
-
ORDER BY created_at DESC
|
|
105
|
-
`).all(artifact);
|
|
106
|
-
return rows.map((r) => this.deserialize(r));
|
|
107
|
-
}
|
|
108
|
-
/** List all pending approvals */
|
|
109
|
-
listPending() {
|
|
110
|
-
const rows = this.db.prepare(`
|
|
111
|
-
SELECT * FROM workflow_approvals WHERE status = 'pending' ORDER BY created_at DESC
|
|
112
|
-
`).all();
|
|
113
|
-
return rows.map((r) => this.deserialize(r));
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Record the response to a still-pending approval.
|
|
117
|
-
*
|
|
118
|
-
* Returns the number of rows changed so aggregate lifecycle operations can
|
|
119
|
-
* use this as a compare-and-set guard: if two responders race, only the
|
|
120
|
-
* first pending row update succeeds and the loser must not resume/fail the
|
|
121
|
-
* workflow a second time.
|
|
122
|
-
*/
|
|
123
|
-
respond(id, status, respondedBy, response) {
|
|
124
|
-
const now = new Date().toISOString();
|
|
125
|
-
const result = this.db.prepare(`
|
|
126
|
-
UPDATE workflow_approvals
|
|
127
|
-
SET status = ?, responded_by = ?, response = ?, responded_at = ?
|
|
128
|
-
WHERE id = ? AND status = 'pending'
|
|
129
|
-
`).run(status, respondedBy, response ?? null, now, id);
|
|
130
|
-
return result.changes;
|
|
131
|
-
}
|
|
132
|
-
deserialize(row) {
|
|
133
|
-
return {
|
|
134
|
-
id: row.id,
|
|
135
|
-
workflowRunId: row.workflow_run_id,
|
|
136
|
-
gate: row.gate,
|
|
137
|
-
summary: row.summary,
|
|
138
|
-
status: row.status,
|
|
139
|
-
kind: (row.kind || "approve"),
|
|
140
|
-
artifact: row.artifact || undefined,
|
|
141
|
-
requestedBy: row.requested_by || undefined,
|
|
142
|
-
respondedBy: row.responded_by || undefined,
|
|
143
|
-
response: row.response || undefined,
|
|
144
|
-
respondedAt: row.responded_at || undefined,
|
|
145
|
-
createdAt: row.created_at,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=approval-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"approval-store.js","sourceRoot":"","sources":["../../src/state/approval-store.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,EAAqB;QAArB,OAAE,GAAF,EAAE,CAAmB;IAAG,CAAC;IAE7C,4CAA4C;IAC5C,MAAM,CACJ,QAEC;QAED,IAAI,CAAC,EAAE;aACJ,OAAO,CACN;;;KAGH,CACE;aACA,GAAG,CACF,QAAQ,CAAC,EAAE,EACX,QAAQ,CAAC,aAAa,EACtB,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,IAAI,SAAS,EAC1B,QAAQ,CAAC,QAAQ,IAAI,IAAI,EACzB,QAAQ,CAAC,WAAW,IAAI,IAAI,EAC5B,QAAQ,CAAC,SAAS,CACnB,CAAC;IACN,CAAC;IAED;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,E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I,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACvD,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAEO,WAAW,CAAC,GAA4B;QAC9C,OAAO;YACL,EAAE,EAAE,GAAG,CAAC,EAAY;YACpB,aAAa,EAAE,GAAG,CAAC,eAAyB;YAC5C,IAAI,EAAE,GAAG,CAAC,IAAc;YACxB,OAAO,EAAE,GAAG,CAAC,OAAiB;YAC9B,MAAM,EAAE,GAAG,CAAC,MAAoC;YAChD,IAAI,EAAE,CAAE,GAAG,CAAC,IAA2B,IAAI,SAAS,CAA6B;YACjF,QAAQ,EAAE,GAAG,CAAC,QAA8B,IAAI,SAAS;YACzD,WAAW,EAAE,GAAG,CAAC,YAAkC,IAAI,SAAS;YAChE,WAAW,EAAE,GAAG,CAAC,YAAkC,IAAI,SAAS;YAChE,QAAQ,EAAE,GAAG,CAAC,QAA8B,IAAI,SAAS;YACzD,WAAW,EAAE,GAAG,CAAC,YAAkC,IAAI,SAAS;YAChE,SAAS,EAAE,GAAG,CAAC,UAAoB;SACpC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/** Identity of one run's doc set within the store. */
|
|
2
|
-
export interface BuildAssetRef {
|
|
3
|
-
owner: string;
|
|
4
|
-
repo: string;
|
|
5
|
-
issueKey: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Derive the stable per-run key used both as the store sub-path and (with a
|
|
9
|
-
* `.lastlight/` prefix) as the in-repo `issueDir`. Issue-scoped runs share a
|
|
10
|
-
* key by issue number; non-issue runs (explore, health, …) get a run-scoped
|
|
11
|
-
* key so concurrent sessions never overlap. Mirrors the derivation that lived
|
|
12
|
-
* inline in `src/workflows/simple.ts`.
|
|
13
|
-
*/
|
|
14
|
-
export declare function buildAssetIssueKey(workflowName: string, issueNumber: number | undefined, workflowId: string): string;
|
|
15
|
-
export declare class BuildAssetStore {
|
|
16
|
-
readonly root: string;
|
|
17
|
-
constructor(root: string);
|
|
18
|
-
/** Absolute directory for a run's doc set. Validates every segment. */
|
|
19
|
-
dirFor(ref: BuildAssetRef): string;
|
|
20
|
-
/** Absolute path for one doc file, with traversal validation on the name. */
|
|
21
|
-
fileFor(ref: BuildAssetRef, file: string): string;
|
|
22
|
-
/** Read one doc, or undefined when it does not exist. */
|
|
23
|
-
read(ref: BuildAssetRef, file: string): string | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Read one doc as raw bytes, or undefined when it does not exist. Same
|
|
26
|
-
* traversal validation as {@link read}, but no text decoding — the admin
|
|
27
|
-
* API uses this to serve binary artifacts (e.g. PNG screenshot evidence)
|
|
28
|
-
* intact, since `read()`'s utf-8 decode corrupts binary content.
|
|
29
|
-
*/
|
|
30
|
-
readBuffer(ref: BuildAssetRef, file: string): Buffer | undefined;
|
|
31
|
-
/** Write (create or overwrite) one doc, creating the run dir as needed. */
|
|
32
|
-
write(ref: BuildAssetRef, file: string, content: string): void;
|
|
33
|
-
/** List the `<owner>/<repo>` run keys present in the store (issueKeys). */
|
|
34
|
-
listKeys(owner: string, repo: string): string[];
|
|
35
|
-
/** List the doc filenames stored for one run. */
|
|
36
|
-
listFiles(ref: BuildAssetRef): string[];
|
|
37
|
-
/**
|
|
38
|
-
* Stage the run's stored docs into `localDir` (created fresh) so a sandbox
|
|
39
|
-
* phase reads prior-phase context. A no-op-with-empty-dir when nothing is
|
|
40
|
-
* stored yet — the first phase starts from a clean slate, identical to repo
|
|
41
|
-
* mode's empty `.lastlight/<issueKey>/`.
|
|
42
|
-
*/
|
|
43
|
-
stageInto(ref: BuildAssetRef, localDir: string): void;
|
|
44
|
-
/**
|
|
45
|
-
* Harvest docs written by a phase back into the store, replacing the stored
|
|
46
|
-
* set with whatever the phase left in `localDir`. Last-harvest-wins; the
|
|
47
|
-
* runner is sequential per workspace so there is no concurrent writer.
|
|
48
|
-
*/
|
|
49
|
-
harvestFrom(ref: BuildAssetRef, localDir: string): void;
|
|
50
|
-
}
|