lastlight-core 0.16.1
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/LICENSE +21 -0
- package/README.md +10 -0
- package/agent-context/rules.md +80 -0
- package/agent-context/security.md +69 -0
- package/agent-context/soul.md +21 -0
- package/config/default.yaml +119 -0
- package/deploy/.env.production.example +100 -0
- package/deploy/entrypoint.sh +82 -0
- package/deploy/native/README.md +160 -0
- package/deploy/native/install.sh +110 -0
- package/deploy/native/lastlight.env.example +95 -0
- package/deploy/native/lastlight.service +50 -0
- package/deploy/sandbox-entrypoint.sh +93 -0
- package/deploy/slack/README.md +92 -0
- package/deploy/slack/slack-manifest.json +55 -0
- package/dist/admin/auth.d.ts +51 -0
- package/dist/admin/auth.js +121 -0
- package/dist/admin/auth.js.map +1 -0
- package/dist/admin/chat-session-reader.d.ts +39 -0
- package/dist/admin/chat-session-reader.js +84 -0
- package/dist/admin/chat-session-reader.js.map +1 -0
- package/dist/admin/docker.d.ts +61 -0
- package/dist/admin/docker.js +187 -0
- package/dist/admin/docker.js.map +1 -0
- package/dist/admin/index.d.ts +9 -0
- package/dist/admin/index.js +59 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/routes.d.ts +81 -0
- package/dist/admin/routes.js +1381 -0
- package/dist/admin/routes.js.map +1 -0
- package/dist/admin/sessions.d.ts +89 -0
- package/dist/admin/sessions.js +204 -0
- package/dist/admin/sessions.js.map +1 -0
- package/dist/admin/tail.d.ts +12 -0
- package/dist/admin/tail.js +145 -0
- package/dist/admin/tail.js.map +1 -0
- package/dist/admin/version.d.ts +22 -0
- package/dist/admin/version.js +92 -0
- package/dist/admin/version.js.map +1 -0
- package/dist/config/config-resolve.d.ts +28 -0
- package/dist/config/config-resolve.js +47 -0
- package/dist/config/config-resolve.js.map +1 -0
- package/dist/config/config.d.ts +140 -0
- package/dist/config/config.js +581 -0
- package/dist/config/config.js.map +1 -0
- package/dist/connectors/github-webhook.d.ts +45 -0
- package/dist/connectors/github-webhook.js +321 -0
- package/dist/connectors/github-webhook.js.map +1 -0
- package/dist/connectors/index.d.ts +18 -0
- package/dist/connectors/index.js +41 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/messaging/base.d.ts +42 -0
- package/dist/connectors/messaging/base.js +139 -0
- package/dist/connectors/messaging/base.js.map +1 -0
- package/dist/connectors/messaging/delivery.d.ts +14 -0
- package/dist/connectors/messaging/delivery.js +38 -0
- package/dist/connectors/messaging/delivery.js.map +1 -0
- package/dist/connectors/messaging/index.d.ts +4 -0
- package/dist/connectors/messaging/index.js +4 -0
- package/dist/connectors/messaging/index.js.map +1 -0
- package/dist/connectors/messaging/session-manager.d.ts +53 -0
- package/dist/connectors/messaging/session-manager.js +255 -0
- package/dist/connectors/messaging/session-manager.js.map +1 -0
- package/dist/connectors/messaging/types.d.ts +58 -0
- package/dist/connectors/messaging/types.js +7 -0
- package/dist/connectors/messaging/types.js.map +1 -0
- package/dist/connectors/slack/connector.d.ts +142 -0
- package/dist/connectors/slack/connector.js +494 -0
- package/dist/connectors/slack/connector.js.map +1 -0
- package/dist/connectors/slack/index.d.ts +2 -0
- package/dist/connectors/slack/index.js +3 -0
- package/dist/connectors/slack/index.js.map +1 -0
- package/dist/connectors/slack/mrkdwn.d.ts +19 -0
- package/dist/connectors/slack/mrkdwn.js +240 -0
- package/dist/connectors/slack/mrkdwn.js.map +1 -0
- package/dist/connectors/types.d.ts +61 -0
- package/dist/connectors/types.js +2 -0
- package/dist/connectors/types.js.map +1 -0
- package/dist/cron/fanout.d.ts +33 -0
- package/dist/cron/fanout.js +55 -0
- package/dist/cron/fanout.js.map +1 -0
- package/dist/cron/jobs.d.ts +18 -0
- package/dist/cron/jobs.js +37 -0
- package/dist/cron/jobs.js.map +1 -0
- package/dist/cron/scheduler.d.ts +45 -0
- package/dist/cron/scheduler.js +105 -0
- package/dist/cron/scheduler.js.map +1 -0
- package/dist/engine/agent-executor.d.ts +34 -0
- package/dist/engine/agent-executor.js +246 -0
- package/dist/engine/agent-executor.js.map +1 -0
- package/dist/engine/chat/chat-runner.d.ts +132 -0
- package/dist/engine/chat/chat-runner.js +424 -0
- package/dist/engine/chat/chat-runner.js.map +1 -0
- package/dist/engine/chat/chat-skills.d.ts +45 -0
- package/dist/engine/chat/chat-skills.js +184 -0
- package/dist/engine/chat/chat-skills.js.map +1 -0
- package/dist/engine/chat/chat.d.ts +54 -0
- package/dist/engine/chat/chat.js +316 -0
- package/dist/engine/chat/chat.js.map +1 -0
- package/dist/engine/chat/message-batcher.d.ts +32 -0
- package/dist/engine/chat/message-batcher.js +109 -0
- package/dist/engine/chat/message-batcher.js.map +1 -0
- package/dist/engine/dispatcher.d.ts +73 -0
- package/dist/engine/dispatcher.js +663 -0
- package/dist/engine/dispatcher.js.map +1 -0
- package/dist/engine/event-shim.d.ts +117 -0
- package/dist/engine/event-shim.js +435 -0
- package/dist/engine/event-shim.js.map +1 -0
- package/dist/engine/executors/orchestrator.d.ts +74 -0
- package/dist/engine/executors/orchestrator.js +365 -0
- package/dist/engine/executors/orchestrator.js.map +1 -0
- package/dist/engine/executors/shared.d.ts +189 -0
- package/dist/engine/executors/shared.js +616 -0
- package/dist/engine/executors/shared.js.map +1 -0
- package/dist/engine/github/git-auth.d.ts +62 -0
- package/dist/engine/github/git-auth.js +161 -0
- package/dist/engine/github/git-auth.js.map +1 -0
- package/dist/engine/github/github-app-client.d.ts +23 -0
- package/dist/engine/github/github-app-client.js +33 -0
- package/dist/engine/github/github-app-client.js.map +1 -0
- package/dist/engine/github/github-tools.d.ts +18 -0
- package/dist/engine/github/github-tools.js +263 -0
- package/dist/engine/github/github-tools.js.map +1 -0
- package/dist/engine/github/github.d.ts +1193 -0
- package/dist/engine/github/github.js +357 -0
- package/dist/engine/github/github.js.map +1 -0
- package/dist/engine/github/profiles.d.ts +11 -0
- package/dist/engine/github/profiles.js +42 -0
- package/dist/engine/github/profiles.js.map +1 -0
- package/dist/engine/github/review-poster.d.ts +98 -0
- package/dist/engine/github/review-poster.js +177 -0
- package/dist/engine/github/review-poster.js.map +1 -0
- package/dist/engine/llm.d.ts +79 -0
- package/dist/engine/llm.js +269 -0
- package/dist/engine/llm.js.map +1 -0
- package/dist/engine/oauth.d.ts +8 -0
- package/dist/engine/oauth.js +9 -0
- package/dist/engine/oauth.js.map +1 -0
- package/dist/engine/router.d.ts +29 -0
- package/dist/engine/router.js +680 -0
- package/dist/engine/router.js.map +1 -0
- package/dist/engine/screen/classifier.d.ts +93 -0
- package/dist/engine/screen/classifier.js +215 -0
- package/dist/engine/screen/classifier.js.map +1 -0
- package/dist/engine/screen/screen.d.ts +41 -0
- package/dist/engine/screen/screen.js +93 -0
- package/dist/engine/screen/screen.js.map +1 -0
- package/dist/evals-api.d.ts +24 -0
- package/dist/evals-api.js +22 -0
- package/dist/evals-api.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +940 -0
- package/dist/index.js.map +1 -0
- package/dist/managed-repos.d.ts +30 -0
- package/dist/managed-repos.js +72 -0
- package/dist/managed-repos.js.map +1 -0
- package/dist/notify/blocks.d.ts +23 -0
- package/dist/notify/blocks.js +118 -0
- package/dist/notify/blocks.js.map +1 -0
- package/dist/notify/index.d.ts +17 -0
- package/dist/notify/index.js +7 -0
- package/dist/notify/index.js.map +1 -0
- package/dist/notify/model.d.ts +57 -0
- package/dist/notify/model.js +89 -0
- package/dist/notify/model.js.map +1 -0
- package/dist/notify/notifier.d.ts +18 -0
- package/dist/notify/notifier.js +100 -0
- package/dist/notify/notifier.js.map +1 -0
- package/dist/notify/render.d.ts +21 -0
- package/dist/notify/render.js +59 -0
- package/dist/notify/render.js.map +1 -0
- package/dist/notify/transports/github.d.ts +26 -0
- package/dist/notify/transports/github.js +27 -0
- package/dist/notify/transports/github.js.map +1 -0
- package/dist/notify/transports/slack.d.ts +27 -0
- package/dist/notify/transports/slack.js +37 -0
- package/dist/notify/transports/slack.js.map +1 -0
- package/dist/notify/types.d.ts +111 -0
- package/dist/notify/types.js +16 -0
- package/dist/notify/types.js.map +1 -0
- package/dist/sandbox/docker.d.ts +180 -0
- package/dist/sandbox/docker.js +517 -0
- package/dist/sandbox/docker.js.map +1 -0
- package/dist/sandbox/egress-allowlist.d.ts +74 -0
- package/dist/sandbox/egress-allowlist.js +164 -0
- package/dist/sandbox/egress-allowlist.js.map +1 -0
- package/dist/sandbox/egress-firewall-config.d.ts +127 -0
- package/dist/sandbox/egress-firewall-config.js +434 -0
- package/dist/sandbox/egress-firewall-config.js.map +1 -0
- package/dist/sandbox/images.d.ts +23 -0
- package/dist/sandbox/images.js +55 -0
- package/dist/sandbox/images.js.map +1 -0
- package/dist/sandbox/index.d.ts +112 -0
- package/dist/sandbox/index.js +332 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/sandbox.d.ts +214 -0
- package/dist/sandbox/sandbox.js +453 -0
- package/dist/sandbox/sandbox.js.map +1 -0
- package/dist/sandbox/smol.d.ts +162 -0
- package/dist/sandbox/smol.js +485 -0
- package/dist/sandbox/smol.js.map +1 -0
- package/dist/session-log.d.ts +63 -0
- package/dist/session-log.js +290 -0
- package/dist/session-log.js.map +1 -0
- package/dist/state/approval-store.d.ts +88 -0
- package/dist/state/approval-store.js +149 -0
- package/dist/state/approval-store.js.map +1 -0
- package/dist/state/build-assets.d.ts +50 -0
- package/dist/state/build-assets.js +154 -0
- package/dist/state/build-assets.js.map +1 -0
- package/dist/state/db.d.ts +81 -0
- package/dist/state/db.js +155 -0
- package/dist/state/db.js.map +1 -0
- package/dist/state/execution-store.d.ts +257 -0
- package/dist/state/execution-store.js +527 -0
- package/dist/state/execution-store.js.map +1 -0
- package/dist/state/migrate.d.ts +15 -0
- package/dist/state/migrate.js +175 -0
- package/dist/state/migrate.js.map +1 -0
- package/dist/state/workflow-run-store.d.ts +216 -0
- package/dist/state/workflow-run-store.js +403 -0
- package/dist/state/workflow-run-store.js.map +1 -0
- package/dist/telemetry/index.d.ts +38 -0
- package/dist/telemetry/index.js +253 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/pi-events.d.ts +12 -0
- package/dist/telemetry/pi-events.js +134 -0
- package/dist/telemetry/pi-events.js.map +1 -0
- package/dist/workflows/dag.d.ts +1 -0
- package/dist/workflows/dag.js +2 -0
- package/dist/workflows/dag.js.map +1 -0
- package/dist/workflows/handlers/post-review.d.ts +45 -0
- package/dist/workflows/handlers/post-review.js +220 -0
- package/dist/workflows/handlers/post-review.js.map +1 -0
- package/dist/workflows/handlers/verdict-reader.d.ts +14 -0
- package/dist/workflows/handlers/verdict-reader.js +55 -0
- package/dist/workflows/handlers/verdict-reader.js.map +1 -0
- package/dist/workflows/loader.d.ts +9 -0
- package/dist/workflows/loader.js +10 -0
- package/dist/workflows/loader.js.map +1 -0
- package/dist/workflows/loop-eval.d.ts +1 -0
- package/dist/workflows/loop-eval.js +2 -0
- package/dist/workflows/loop-eval.js.map +1 -0
- package/dist/workflows/phase-executor.d.ts +1 -0
- package/dist/workflows/phase-executor.js +6 -0
- package/dist/workflows/phase-executor.js.map +1 -0
- package/dist/workflows/phase-ref.d.ts +1 -0
- package/dist/workflows/phase-ref.js +2 -0
- package/dist/workflows/phase-ref.js.map +1 -0
- package/dist/workflows/resume.d.ts +58 -0
- package/dist/workflows/resume.js +313 -0
- package/dist/workflows/resume.js.map +1 -0
- package/dist/workflows/runner.d.ts +47 -0
- package/dist/workflows/runner.js +278 -0
- package/dist/workflows/runner.js.map +1 -0
- package/dist/workflows/schema.d.ts +1 -0
- package/dist/workflows/schema.js +2 -0
- package/dist/workflows/schema.js.map +1 -0
- package/dist/workflows/simple.d.ts +90 -0
- package/dist/workflows/simple.js +393 -0
- package/dist/workflows/simple.js.map +1 -0
- package/dist/workflows/target-policy.d.ts +74 -0
- package/dist/workflows/target-policy.js +80 -0
- package/dist/workflows/target-policy.js.map +1 -0
- package/dist/workflows/templates.d.ts +1 -0
- package/dist/workflows/templates.js +2 -0
- package/dist/workflows/templates.js.map +1 -0
- package/dist/workflows/triggers.d.ts +21 -0
- package/dist/workflows/triggers.js +45 -0
- package/dist/workflows/triggers.js.map +1 -0
- package/dist/workflows/verdict.d.ts +1 -0
- package/dist/workflows/verdict.js +2 -0
- package/dist/workflows/verdict.js.map +1 -0
- package/dist/worktree/manager.d.ts +43 -0
- package/dist/worktree/manager.js +127 -0
- package/dist/worktree/manager.js.map +1 -0
- package/docker-compose.yml +280 -0
- package/package.json +93 -0
- package/sandbox.Dockerfile +68 -0
- package/skills/README.md +42 -0
- package/skills/browser-qa/SKILL.md +208 -0
- package/skills/browser-qa/scripts/agent-browser.mjs +531 -0
- package/skills/building/SKILL.md +95 -0
- package/skills/chat/SKILL.md +36 -0
- package/skills/code-review/SKILL.md +82 -0
- package/skills/debug-production/SKILL.md +108 -0
- package/skills/demo/SKILL.md +228 -0
- package/skills/demo/scripts/compose-demo.sh +243 -0
- package/skills/issue-answer/SKILL.md +91 -0
- package/skills/issue-comment/SKILL.md +49 -0
- package/skills/issue-triage/SKILL.md +149 -0
- package/skills/issue-triage/references/AGENT-BRIEF.md +65 -0
- package/skills/pr-comment/SKILL.md +64 -0
- package/skills/pr-review/SKILL.md +148 -0
- package/skills/pr-review/references/findings-schema.md +89 -0
- package/skills/qa-test/SKILL.md +97 -0
- package/skills/repo-health/SKILL.md +67 -0
- package/skills/security-feedback/SKILL.md +173 -0
- package/skills/security-feedback/references/templates.md +77 -0
- package/skills/security-review/SKILL.md +215 -0
- package/skills/security-review/references/issue-format.md +302 -0
- package/skills/verify/SKILL.md +118 -0
- package/workflows/answer.yaml +44 -0
- package/workflows/build.yaml +129 -0
- package/workflows/cron-health.yaml +6 -0
- package/workflows/cron-review.yaml +8 -0
- package/workflows/cron-security.yaml +6 -0
- package/workflows/cron-triage.yaml +8 -0
- package/workflows/demo.yaml +62 -0
- package/workflows/examples/bash-smoke.yaml +41 -0
- package/workflows/examples/parallel-review.yaml +36 -0
- package/workflows/examples/tdd-loop.yaml +17 -0
- package/workflows/explore.yaml +80 -0
- package/workflows/issue-comment.yaml +15 -0
- package/workflows/issue-triage.yaml +22 -0
- package/workflows/pr-comment.yaml +16 -0
- package/workflows/pr-fix.yaml +17 -0
- package/workflows/pr-review.yaml +50 -0
- package/workflows/prompts/answer.md +68 -0
- package/workflows/prompts/architect.md +44 -0
- package/workflows/prompts/classifier.md +60 -0
- package/workflows/prompts/classify-adds-info.md +17 -0
- package/workflows/prompts/demo.md +125 -0
- package/workflows/prompts/executor.md +42 -0
- package/workflows/prompts/explore-ask.md +99 -0
- package/workflows/prompts/explore-publish.md +31 -0
- package/workflows/prompts/explore-read.md +120 -0
- package/workflows/prompts/explore-synthesize.md +88 -0
- package/workflows/prompts/fix.md +18 -0
- package/workflows/prompts/guardrails.md +96 -0
- package/workflows/prompts/pr-fix.md +26 -0
- package/workflows/prompts/pr.md +39 -0
- package/workflows/prompts/qa-browser.md +95 -0
- package/workflows/prompts/qa-synth.md +44 -0
- package/workflows/prompts/qa-test.md +60 -0
- package/workflows/prompts/re-reviewer.md +33 -0
- package/workflows/prompts/reviewer.md +60 -0
- package/workflows/prompts/verify-browser.md +93 -0
- package/workflows/prompts/verify-synth.md +44 -0
- package/workflows/prompts/verify.md +63 -0
- package/workflows/qa-test.yaml +94 -0
- package/workflows/repo-health.yaml +15 -0
- package/workflows/security-feedback.yaml +25 -0
- package/workflows/security-review.yaml +37 -0
- package/workflows/verify.yaml +93 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/admin/auth.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS;AAEhE,MAAM,UAAU,WAAW,CAAC,MAAc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,CAAC;QAC7C,IAAI,KAAK,GAAG,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACxE,8DAA8D;QAC9D,IAAI,CAAC,KAAK;YAAE,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;QAEtD,IAAI,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,GAAG,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { StateDb } from "../state/db.js";
|
|
2
|
+
import { SessionLog, type JsonlMessage } from "../session-log.js";
|
|
3
|
+
import type { SessionSource, SessionMeta } from "./sessions.js";
|
|
4
|
+
/**
|
|
5
|
+
* DB-backed chat-session reader. Drop-in replacement for SessionReader on
|
|
6
|
+
* the chat path: same public surface (`mountSessionRoutes` works against it
|
|
7
|
+
* unchanged), but listing comes from the executions table grouped by Slack
|
|
8
|
+
* thread, and message reads target the single jsonl file owned by that
|
|
9
|
+
* thread's pi-ai session id. SessionLog owns the on-disk CHAT_PROJECT_SLUG
|
|
10
|
+
* path resolution, so this reader does not scan unrelated `agent-*.jsonl`
|
|
11
|
+
* sidechain files from other in-process Agent SDK runs.
|
|
12
|
+
*
|
|
13
|
+
* Conceptual mapping:
|
|
14
|
+
* - SessionMeta.id ← messaging_session.id (= Slack thread / executions.trigger_id)
|
|
15
|
+
* - jsonl on disk ← SessionLog CHAT_PROJECT_SLUG file for
|
|
16
|
+
* messaging_sessions.agent_session_id
|
|
17
|
+
*/
|
|
18
|
+
export declare class ChatSessionReader implements SessionSource {
|
|
19
|
+
private db;
|
|
20
|
+
private sessionLog;
|
|
21
|
+
constructor(db: StateDb, sessionsHomeDir: string);
|
|
22
|
+
constructor(db: StateDb, sessionLog: SessionLog);
|
|
23
|
+
/** All chat thread ids (= Slack threads) that have at least one chat execution. */
|
|
24
|
+
listSessionIds(): string[];
|
|
25
|
+
exists(id: string): boolean;
|
|
26
|
+
getSessionMeta(id: string): Promise<SessionMeta | null>;
|
|
27
|
+
read(id: string): Promise<Array<{
|
|
28
|
+
index: number;
|
|
29
|
+
msg: JsonlMessage;
|
|
30
|
+
}>>;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a thread id to its on-disk Agent SDK jsonl. Returns null if
|
|
33
|
+
* the thread has no agent_session_id yet (pre-resume) or the jsonl file
|
|
34
|
+
* doesn't exist on disk (deleted, rotated, or written by a different
|
|
35
|
+
* Agent SDK installation).
|
|
36
|
+
*/
|
|
37
|
+
getFilePath(id: string): string | null;
|
|
38
|
+
normalizeRawLine(raw: Record<string, unknown>): JsonlMessage[];
|
|
39
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CHAT_PROJECT_SLUG, SessionLog, } from "../session-log.js";
|
|
2
|
+
/**
|
|
3
|
+
* DB-backed chat-session reader. Drop-in replacement for SessionReader on
|
|
4
|
+
* the chat path: same public surface (`mountSessionRoutes` works against it
|
|
5
|
+
* unchanged), but listing comes from the executions table grouped by Slack
|
|
6
|
+
* thread, and message reads target the single jsonl file owned by that
|
|
7
|
+
* thread's pi-ai session id. SessionLog owns the on-disk CHAT_PROJECT_SLUG
|
|
8
|
+
* path resolution, so this reader does not scan unrelated `agent-*.jsonl`
|
|
9
|
+
* sidechain files from other in-process Agent SDK runs.
|
|
10
|
+
*
|
|
11
|
+
* Conceptual mapping:
|
|
12
|
+
* - SessionMeta.id ← messaging_session.id (= Slack thread / executions.trigger_id)
|
|
13
|
+
* - jsonl on disk ← SessionLog CHAT_PROJECT_SLUG file for
|
|
14
|
+
* messaging_sessions.agent_session_id
|
|
15
|
+
*/
|
|
16
|
+
export class ChatSessionReader {
|
|
17
|
+
db;
|
|
18
|
+
sessionLog;
|
|
19
|
+
constructor(db, sessionsHomeDirOrLog) {
|
|
20
|
+
this.db = db;
|
|
21
|
+
this.sessionLog = typeof sessionsHomeDirOrLog === "string"
|
|
22
|
+
? new SessionLog(sessionsHomeDirOrLog)
|
|
23
|
+
: sessionsHomeDirOrLog;
|
|
24
|
+
}
|
|
25
|
+
/** All chat thread ids (= Slack threads) that have at least one chat execution. */
|
|
26
|
+
listSessionIds() {
|
|
27
|
+
// Soft cap at 500 — anything older than that almost certainly won't be
|
|
28
|
+
// surfaced after the dashboard's per-tab filters anyway.
|
|
29
|
+
return this.db.executions.listChatThreads(500).map((t) => t.triggerId);
|
|
30
|
+
}
|
|
31
|
+
exists(id) {
|
|
32
|
+
return this.db.executions.getChatThread(id) !== null;
|
|
33
|
+
}
|
|
34
|
+
async getSessionMeta(id) {
|
|
35
|
+
const t = this.db.executions.getChatThread(id);
|
|
36
|
+
if (!t)
|
|
37
|
+
return null;
|
|
38
|
+
const startedAt = new Date(t.firstStartedAt).getTime() / 1000;
|
|
39
|
+
const lastMessageAt = new Date(t.lastActivityAt).getTime() / 1000;
|
|
40
|
+
// sessionType "chat" lets the dashboard SessionFilters show a chat
|
|
41
|
+
// chip and gives the user a meaningful label.
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
source: "chat",
|
|
45
|
+
sessionType: "chat",
|
|
46
|
+
model: null,
|
|
47
|
+
started_at: Number.isNaN(startedAt) ? Date.now() / 1000 : startedAt,
|
|
48
|
+
last_message_at: Number.isNaN(lastMessageAt) ? null : lastMessageAt,
|
|
49
|
+
message_count: t.turnCount,
|
|
50
|
+
tool_call_count: 0,
|
|
51
|
+
conversation_message_count: t.turnCount,
|
|
52
|
+
last_assistant_content: t.lastAssistantContent,
|
|
53
|
+
agentIds: [],
|
|
54
|
+
platform: t.platform,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async read(id) {
|
|
58
|
+
const thread = this.db.executions.getChatThread(id);
|
|
59
|
+
if (!thread?.agentSessionId)
|
|
60
|
+
return [];
|
|
61
|
+
return this.sessionLog.readNormalizedSession("chat", thread.agentSessionId, {
|
|
62
|
+
includeAgents: false,
|
|
63
|
+
skipEmptySystem: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a thread id to its on-disk Agent SDK jsonl. Returns null if
|
|
68
|
+
* the thread has no agent_session_id yet (pre-resume) or the jsonl file
|
|
69
|
+
* doesn't exist on disk (deleted, rotated, or written by a different
|
|
70
|
+
* Agent SDK installation).
|
|
71
|
+
*/
|
|
72
|
+
getFilePath(id) {
|
|
73
|
+
const thread = this.db.executions.getChatThread(id);
|
|
74
|
+
if (!thread || !thread.agentSessionId)
|
|
75
|
+
return null;
|
|
76
|
+
return this.sessionLog.pathForProject(CHAT_PROJECT_SLUG, thread.agentSessionId, {
|
|
77
|
+
requireExists: true,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
normalizeRawLine(raw) {
|
|
81
|
+
return this.sessionLog.normalizeLine(raw);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=chat-session-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-session-reader.js","sourceRoot":"","sources":["../../src/admin/chat-session-reader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,UAAU,GAEX,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAiB;IACpB,EAAE,CAAU;IACZ,UAAU,CAAa;IAI/B,YAAY,EAAW,EAAE,oBAAyC;QAChE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,OAAO,oBAAoB,KAAK,QAAQ;YACxD,CAAC,CAAC,IAAI,UAAU,CAAC,oBAA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;YACvC,sBAAsB,EAAE,CAAC,CAAC,oBAAoB;YAC9C,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ;SACrB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAU;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,EAAE,cAAc;YAAE,OAAO,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE;YAC1E,aAAa,EAAE,KAAK;YACpB,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,EAAU;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc;YAAE,OAAO,IAAI,CAAC;QACnD,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,iBAAiB,EAAE,MAAM,CAAC,cAAc,EAAE;YAC9E,aAAa,EAAE,IAAI;SACpB,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,GAA4B;QAC3C,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface ContainerInfo {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
status: string;
|
|
5
|
+
created: string;
|
|
6
|
+
taskId: string | null;
|
|
7
|
+
image: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ContainerStats {
|
|
10
|
+
name: string;
|
|
11
|
+
cpuPercent: number;
|
|
12
|
+
memUsageBytes: number;
|
|
13
|
+
memLimitBytes: number;
|
|
14
|
+
memPercent: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function killContainer(containerName: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Snapshot CPU/memory for every container whose name starts with `lastlight-`
|
|
19
|
+
* (the agent itself plus any active sandboxes). Uses `docker stats --no-stream`
|
|
20
|
+
* so each call is one read of cgroup counters — slower than a metadata lookup
|
|
21
|
+
* but still ~sub-second on a small fleet.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getContainerStats(): Promise<ContainerStats[]>;
|
|
24
|
+
export declare function listRunningContainers(): Promise<ContainerInfo[]>;
|
|
25
|
+
export interface ServerContainer {
|
|
26
|
+
name: string;
|
|
27
|
+
/** Short label derived from the compose name: lastlight-<service>-<n>. */
|
|
28
|
+
service: string;
|
|
29
|
+
status: string;
|
|
30
|
+
image: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Every `lastlight-*` container (the agent plus the egress sidecars,
|
|
34
|
+
* otel-collector, dozzle, and any live sandboxes) — running or stopped. Used
|
|
35
|
+
* by the server-logs endpoints so an operator can read the harness/docker logs
|
|
36
|
+
* over the admin API instead of SSHing to the host.
|
|
37
|
+
*/
|
|
38
|
+
export declare function listServerContainers(): Promise<ServerContainer[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Resolve a requested container (by full name OR short service label) to a real
|
|
41
|
+
* `lastlight-*` container name, validated against the live list. Returns null
|
|
42
|
+
* if nothing matches — callers reject the request, so an arbitrary container
|
|
43
|
+
* name can never reach `docker logs`. With no request, defaults to the agent.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveServerContainer(requested?: string): Promise<string | null>;
|
|
46
|
+
/**
|
|
47
|
+
* One-shot `docker logs` for a container, newest `tail` lines. `--timestamps`
|
|
48
|
+
* lets us interleave the container's stdout and stderr (captured on separate
|
|
49
|
+
* fds) back into chronological order — RFC3339 prefixes sort lexically.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getContainerLogs(name: string, opts?: {
|
|
52
|
+
tail?: number;
|
|
53
|
+
since?: string;
|
|
54
|
+
}): Promise<string[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Follow `docker logs -f` for a container, invoking `onLine` per line from both
|
|
57
|
+
* stdout and stderr. Returns a stop function that kills the child process.
|
|
58
|
+
*/
|
|
59
|
+
export declare function streamContainerLogs(name: string, opts: {
|
|
60
|
+
tail?: number;
|
|
61
|
+
}, onLine: (line: string) => void): () => void;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const exec = promisify(execFile);
|
|
4
|
+
export async function killContainer(containerName) {
|
|
5
|
+
await exec("docker", ["rm", "-f", containerName]);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Snapshot CPU/memory for every container whose name starts with `lastlight-`
|
|
9
|
+
* (the agent itself plus any active sandboxes). Uses `docker stats --no-stream`
|
|
10
|
+
* so each call is one read of cgroup counters — slower than a metadata lookup
|
|
11
|
+
* but still ~sub-second on a small fleet.
|
|
12
|
+
*/
|
|
13
|
+
export async function getContainerStats() {
|
|
14
|
+
try {
|
|
15
|
+
const { stdout } = await exec("docker", [
|
|
16
|
+
"stats",
|
|
17
|
+
"--no-stream",
|
|
18
|
+
"--format", "{{json .}}",
|
|
19
|
+
]);
|
|
20
|
+
if (!stdout.trim())
|
|
21
|
+
return [];
|
|
22
|
+
return stdout
|
|
23
|
+
.trim()
|
|
24
|
+
.split("\n")
|
|
25
|
+
.map((line) => JSON.parse(line))
|
|
26
|
+
.filter((c) => (c.Name ?? "").startsWith("lastlight"))
|
|
27
|
+
.map((c) => {
|
|
28
|
+
const name = c.Name ?? "";
|
|
29
|
+
const cpuPercent = parsePercent(c.CPUPerc);
|
|
30
|
+
const memPercent = parsePercent(c.MemPerc);
|
|
31
|
+
const [usage, limit] = parseMemUsage(c.MemUsage);
|
|
32
|
+
return {
|
|
33
|
+
name,
|
|
34
|
+
cpuPercent,
|
|
35
|
+
memUsageBytes: usage,
|
|
36
|
+
memLimitBytes: limit,
|
|
37
|
+
memPercent,
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function parsePercent(raw) {
|
|
46
|
+
if (!raw)
|
|
47
|
+
return 0;
|
|
48
|
+
const n = parseFloat(raw.replace("%", "").trim());
|
|
49
|
+
return Number.isFinite(n) ? n : 0;
|
|
50
|
+
}
|
|
51
|
+
// Docker formats memory like "123.4MiB / 7.7GiB" — convert each side to bytes.
|
|
52
|
+
function parseMemUsage(raw) {
|
|
53
|
+
if (!raw)
|
|
54
|
+
return [0, 0];
|
|
55
|
+
const parts = raw.split("/").map((p) => p.trim());
|
|
56
|
+
return [parseSize(parts[0] ?? ""), parseSize(parts[1] ?? "")];
|
|
57
|
+
}
|
|
58
|
+
function parseSize(raw) {
|
|
59
|
+
const m = raw.match(/^([\d.]+)\s*([KMGT]?i?B)$/i);
|
|
60
|
+
if (!m)
|
|
61
|
+
return 0;
|
|
62
|
+
const value = parseFloat(m[1]);
|
|
63
|
+
const unit = m[2].toLowerCase();
|
|
64
|
+
const multipliers = {
|
|
65
|
+
b: 1,
|
|
66
|
+
kb: 1e3, mb: 1e6, gb: 1e9, tb: 1e12,
|
|
67
|
+
kib: 1024, mib: 1024 ** 2, gib: 1024 ** 3, tib: 1024 ** 4,
|
|
68
|
+
};
|
|
69
|
+
return value * (multipliers[unit] ?? 1);
|
|
70
|
+
}
|
|
71
|
+
export async function listRunningContainers() {
|
|
72
|
+
try {
|
|
73
|
+
const { stdout } = await exec("docker", [
|
|
74
|
+
"ps",
|
|
75
|
+
"--filter", "name=lastlight-sandbox",
|
|
76
|
+
"--format", "{{json .}}",
|
|
77
|
+
]);
|
|
78
|
+
if (!stdout.trim())
|
|
79
|
+
return [];
|
|
80
|
+
return stdout
|
|
81
|
+
.trim()
|
|
82
|
+
.split("\n")
|
|
83
|
+
.map((line) => {
|
|
84
|
+
const c = JSON.parse(line);
|
|
85
|
+
const name = c.Names ?? c.Name ?? "";
|
|
86
|
+
// Parse taskId from: lastlight-sandbox-{taskId}-{uuid}
|
|
87
|
+
const match = name.match(/^lastlight-sandbox-(.+?)-[a-f0-9]{8}$/);
|
|
88
|
+
return {
|
|
89
|
+
id: c.ID ?? "",
|
|
90
|
+
name,
|
|
91
|
+
status: c.Status ?? "",
|
|
92
|
+
created: c.CreatedAt ?? c.RunningFor ?? "",
|
|
93
|
+
taskId: match?.[1] ?? null,
|
|
94
|
+
image: c.Image ?? "",
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Every `lastlight-*` container (the agent plus the egress sidecars,
|
|
104
|
+
* otel-collector, dozzle, and any live sandboxes) — running or stopped. Used
|
|
105
|
+
* by the server-logs endpoints so an operator can read the harness/docker logs
|
|
106
|
+
* over the admin API instead of SSHing to the host.
|
|
107
|
+
*/
|
|
108
|
+
export async function listServerContainers() {
|
|
109
|
+
try {
|
|
110
|
+
const { stdout } = await exec("docker", [
|
|
111
|
+
"ps", "-a",
|
|
112
|
+
"--filter", "name=lastlight-",
|
|
113
|
+
"--format", "{{json .}}",
|
|
114
|
+
]);
|
|
115
|
+
if (!stdout.trim())
|
|
116
|
+
return [];
|
|
117
|
+
return stdout.trim().split("\n").map((line) => {
|
|
118
|
+
const c = JSON.parse(line);
|
|
119
|
+
const name = c.Names ?? c.Name ?? "";
|
|
120
|
+
return {
|
|
121
|
+
name,
|
|
122
|
+
service: name.replace(/^lastlight-/, "").replace(/-\d+$/, ""),
|
|
123
|
+
status: c.Status ?? "",
|
|
124
|
+
image: c.Image ?? "",
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Resolve a requested container (by full name OR short service label) to a real
|
|
134
|
+
* `lastlight-*` container name, validated against the live list. Returns null
|
|
135
|
+
* if nothing matches — callers reject the request, so an arbitrary container
|
|
136
|
+
* name can never reach `docker logs`. With no request, defaults to the agent.
|
|
137
|
+
*/
|
|
138
|
+
export async function resolveServerContainer(requested) {
|
|
139
|
+
const containers = await listServerContainers();
|
|
140
|
+
if (requested) {
|
|
141
|
+
const hit = containers.find((c) => c.name === requested || c.service === requested);
|
|
142
|
+
return hit?.name ?? null;
|
|
143
|
+
}
|
|
144
|
+
const agent = containers.find((c) => c.service === "agent" || c.name.includes("-agent-"));
|
|
145
|
+
return agent?.name ?? containers[0]?.name ?? null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* One-shot `docker logs` for a container, newest `tail` lines. `--timestamps`
|
|
149
|
+
* lets us interleave the container's stdout and stderr (captured on separate
|
|
150
|
+
* fds) back into chronological order — RFC3339 prefixes sort lexically.
|
|
151
|
+
*/
|
|
152
|
+
export async function getContainerLogs(name, opts = {}) {
|
|
153
|
+
const args = ["logs", "--timestamps", "--tail", String(opts.tail ?? 200)];
|
|
154
|
+
if (opts.since)
|
|
155
|
+
args.push("--since", opts.since);
|
|
156
|
+
args.push(name);
|
|
157
|
+
const { stdout, stderr } = await exec("docker", args, { maxBuffer: 32 * 1024 * 1024 });
|
|
158
|
+
const lines = [
|
|
159
|
+
...(stdout ? stdout.split("\n") : []),
|
|
160
|
+
...(stderr ? stderr.split("\n") : []),
|
|
161
|
+
].filter((l) => l.length > 0);
|
|
162
|
+
lines.sort((a, b) => a.slice(0, 30).localeCompare(b.slice(0, 30)));
|
|
163
|
+
return lines;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Follow `docker logs -f` for a container, invoking `onLine` per line from both
|
|
167
|
+
* stdout and stderr. Returns a stop function that kills the child process.
|
|
168
|
+
*/
|
|
169
|
+
export function streamContainerLogs(name, opts, onLine) {
|
|
170
|
+
const child = spawn("docker", [
|
|
171
|
+
"logs", "-f", "--timestamps", "--tail", String(opts.tail ?? 200), name,
|
|
172
|
+
]);
|
|
173
|
+
const handle = (buf) => {
|
|
174
|
+
for (const line of buf.toString().split("\n"))
|
|
175
|
+
if (line)
|
|
176
|
+
onLine(line);
|
|
177
|
+
};
|
|
178
|
+
child.stdout?.on("data", handle);
|
|
179
|
+
child.stderr?.on("data", handle);
|
|
180
|
+
return () => {
|
|
181
|
+
try {
|
|
182
|
+
child.kill("SIGKILL");
|
|
183
|
+
}
|
|
184
|
+
catch { /* already dead */ }
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=docker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../src/admin/docker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAmBjC,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,aAAqB;IACvD,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE;YACtC,OAAO;YACP,aAAa;YACb,UAAU,EAAE,YAAY;SACzB,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC;QAE9B,OAAO,MAAM;aACV,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,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AC,QAAQ,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,IAAI,IAAI;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxE,CAAC,CAAC;IACF,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE;QACV,IAAI,CAAC;YAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { StateDb } from "../state/db.js";
|
|
3
|
+
import { type AdminConfig } from "./routes.js";
|
|
4
|
+
export { type AdminConfig } from "./routes.js";
|
|
5
|
+
/**
|
|
6
|
+
* Mount admin routes and dashboard static files onto the given Hono app.
|
|
7
|
+
* This mounts directly so paths like /admin/assets/* resolve correctly.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mountAdmin(app: Hono, db: StateDb, config: AdminConfig): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { serveStatic } from "@hono/node-server/serve-static";
|
|
2
|
+
import { SessionReader } from "./sessions.js";
|
|
3
|
+
import { ChatSessionReader } from "./chat-session-reader.js";
|
|
4
|
+
import { createAdminRoutes, binaryMimeForArtifact, rangeResponse } from "./routes.js";
|
|
5
|
+
import { SessionLog } from "../session-log.js";
|
|
6
|
+
import { BuildAssetStore } from "../state/build-assets.js";
|
|
7
|
+
/**
|
|
8
|
+
* Mount admin routes and dashboard static files onto the given Hono app.
|
|
9
|
+
* This mounts directly so paths like /admin/assets/* resolve correctly.
|
|
10
|
+
*/
|
|
11
|
+
export function mountAdmin(app, db, config) {
|
|
12
|
+
const sessionLog = new SessionLog(config.sessionsDir);
|
|
13
|
+
const sessions = new SessionReader(sessionLog, "sandbox");
|
|
14
|
+
// Chat is DB-backed: list comes from `executions` grouped by trigger_id
|
|
15
|
+
// (the Slack thread), and message reads target the single jsonl owned by
|
|
16
|
+
// that thread's agent_session_id rather than scanning every file in -app.
|
|
17
|
+
const chatSessions = new ChatSessionReader(db, sessionLog);
|
|
18
|
+
const apiRoutes = createAdminRoutes(db, sessions, chatSessions, config);
|
|
19
|
+
// PUBLIC, unauthenticated, MEDIA-ONLY artifact route — registered on the
|
|
20
|
+
// PARENT app BEFORE the `/admin/api` sub-app so it never enters that sub-app's
|
|
21
|
+
// `authMiddleware`. Browser-QA screenshots AND `/demo` videos embedded in a
|
|
22
|
+
// GitHub comment must be fetchable with no login: GitHub's image proxy fetches
|
|
23
|
+
// <img> screenshots, and a viewer's browser streams <video> (sending `Range`
|
|
24
|
+
// requests — hence rangeResponse). Non-media docs 404, so text handoff docs
|
|
25
|
+
// (architect-plan.md, status.md, …) are NEVER exposed here — they stay behind
|
|
26
|
+
// auth at `/admin/api/artifacts/*`. `BuildAssetStore`'s per-segment validation
|
|
27
|
+
// blocks path traversal on every param.
|
|
28
|
+
// NOTE: this makes screenshots/videos of the served app publicly reachable by
|
|
29
|
+
// URL — acceptable for public repos; revisit (visibility check / signed token)
|
|
30
|
+
// before enabling for private repos.
|
|
31
|
+
const publicArtifactStore = config.buildAssetsDir
|
|
32
|
+
? new BuildAssetStore(config.buildAssetsDir)
|
|
33
|
+
: null;
|
|
34
|
+
app.get("/admin/api/public/artifacts/:owner/:repo/:key/:doc", (c) => {
|
|
35
|
+
if (!publicArtifactStore)
|
|
36
|
+
return c.json({ error: "build-assets store not configured" }, 404);
|
|
37
|
+
const { owner, repo, key, doc } = c.req.param();
|
|
38
|
+
const mime = binaryMimeForArtifact(doc);
|
|
39
|
+
if (!mime)
|
|
40
|
+
return c.json({ error: `not found: ${doc}` }, 404); // media-only gate
|
|
41
|
+
try {
|
|
42
|
+
const buf = publicArtifactStore.readBuffer({ owner, repo, issueKey: key }, doc);
|
|
43
|
+
if (buf === undefined)
|
|
44
|
+
return c.json({ error: `not found: ${doc}` }, 404);
|
|
45
|
+
return rangeResponse(c.req.header("range"), buf, mime, "public, max-age=300");
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
// API at /admin/api/*
|
|
52
|
+
app.route("/admin/api", apiRoutes);
|
|
53
|
+
// Static dashboard assets at /admin/*
|
|
54
|
+
app.use("/admin/*", serveStatic({ root: "dashboard/dist", rewriteRequestPath: (p) => p.replace(/^\/admin/, "") }));
|
|
55
|
+
// SPA fallback — serve index.html for any /admin/* that didn't match above
|
|
56
|
+
app.get("/admin/*", serveStatic({ root: "dashboard/dist", path: "index.html" }));
|
|
57
|
+
app.get("/admin", serveStatic({ root: "dashboard/dist", path: "index.html" }));
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/admin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAI3D;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAS,EAAE,EAAW,EAAE,MAAmB;IACpE,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACtD,MA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} from "../state/db.js";
|
|
4
|
+
import type { CronScheduler } from "../cron/scheduler.js";
|
|
5
|
+
import type { PublicConfigBundle, BuildAssetsLocation } from "../config/config.js";
|
|
6
|
+
/**
|
|
7
|
+
* Map a build-asset filename extension to a binary MIME type, or null when the
|
|
8
|
+
* file should be served as text/plain (markdown handoff docs). Binary artifacts
|
|
9
|
+
* — PNG screenshot evidence from browser QA, and `/demo`'s mp4/webm video — must
|
|
10
|
+
* be served as raw bytes, not utf-8 text, so the dashboard can render them in an
|
|
11
|
+
* <img>/<video> and GitHub can embed them.
|
|
12
|
+
*/
|
|
13
|
+
export declare function binaryMimeForArtifact(name: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Build an HTTP response for a binary artifact buffer, honoring a `Range`
|
|
16
|
+
* request so <video> elements can seek/stream (GitHub's inline player and
|
|
17
|
+
* browsers send `Range: bytes=…`; without 206 support, seeking — and some
|
|
18
|
+
* players — break). Artifacts are small (≤ a few MB), so we slice the in-memory
|
|
19
|
+
* buffer rather than streaming from disk. Returns 206 for a satisfiable range,
|
|
20
|
+
* 416 for an unsatisfiable one, else 200 with the full body. `Accept-Ranges:
|
|
21
|
+
* bytes` is always advertised.
|
|
22
|
+
*/
|
|
23
|
+
export declare function rangeResponse(rangeHeader: string | undefined, buf: Buffer, mime: string, cacheControl: string): Response;
|
|
24
|
+
export interface AdminConfig {
|
|
25
|
+
stateDir: string;
|
|
26
|
+
sessionsDir: string;
|
|
27
|
+
/**
|
|
28
|
+
* Filesystem root for server-mode build assets (when `buildAssets.location:
|
|
29
|
+
* server`). The Artifacts endpoints read handoff docs from here. Absent when
|
|
30
|
+
* unconfigured — the endpoints then report the store as empty.
|
|
31
|
+
*/
|
|
32
|
+
buildAssetsDir?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Where build handoff docs live: "repo" (committed to the target repo) |
|
|
35
|
+
* "server" (externalized to the store). Drives the focused approval view's
|
|
36
|
+
* artifact ref: server mode → editable doc in the store; repo mode → a link
|
|
37
|
+
* to the file on GitHub. Defaults to "repo" when absent.
|
|
38
|
+
*/
|
|
39
|
+
buildAssets?: BuildAssetsLocation;
|
|
40
|
+
adminPassword: string;
|
|
41
|
+
adminSecret: string;
|
|
42
|
+
publicConfig?: PublicConfigBundle;
|
|
43
|
+
/** Built-in asset root (the lastlight checkout). Used to compute which
|
|
44
|
+
* overlay assets shadow a default vs add a new one (Config → Overrides). */
|
|
45
|
+
builtInRoot?: string;
|
|
46
|
+
/** Active deployment overlay root (`$LASTLIGHT_OVERLAY_DIR`), if any. */
|
|
47
|
+
overlayDir?: string;
|
|
48
|
+
/** Optional callback to actively resume a paused workflow after dashboard approval */
|
|
49
|
+
resumeWorkflow?: (workflowRun: WorkflowRun, sender: string) => Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Optional callback to retry a FAILED workflow run, resuming from the phase
|
|
52
|
+
* that failed with the same context (ledger-driven). Wired in `src/index.ts`;
|
|
53
|
+
* absent in environments without the runner (tests, CLI-only), in which case
|
|
54
|
+
* the retry endpoint reports 503.
|
|
55
|
+
*/
|
|
56
|
+
retryWorkflow?: (workflowRun: WorkflowRun, sender: string) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Cron scheduler. When supplied, the admin Crons tab can list/toggle/edit
|
|
59
|
+
* registered cron jobs. Optional so the admin routes still mount in
|
|
60
|
+
* environments where the scheduler isn't running (tests, CLI).
|
|
61
|
+
*/
|
|
62
|
+
cronScheduler?: CronScheduler;
|
|
63
|
+
/** Slack OAuth config (optional — enables "Login with Slack" on dashboard) */
|
|
64
|
+
slackOAuthClientId?: string;
|
|
65
|
+
slackOAuthClientSecret?: string;
|
|
66
|
+
slackOAuthRedirectUri?: string;
|
|
67
|
+
/** Restrict login to this Slack workspace team_id or team domain */
|
|
68
|
+
slackAllowedWorkspace?: string;
|
|
69
|
+
/** GitHub OAuth config (optional — enables "Login with GitHub" on dashboard) */
|
|
70
|
+
githubOAuthClientId?: string;
|
|
71
|
+
githubOAuthClientSecret?: string;
|
|
72
|
+
githubOAuthRedirectUri?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Required when GitHub OAuth is configured. Either a GitHub org slug
|
|
75
|
+
* (restricts login to confirmed members — needs read:org scope) or the
|
|
76
|
+
* literal "*" to explicitly allow any authenticated GitHub user. If
|
|
77
|
+
* client id/secret are set but this is empty, GitHub OAuth is disabled.
|
|
78
|
+
*/
|
|
79
|
+
githubAllowedOrg?: string;
|
|
80
|
+
}
|
|
81
|
+
export declare function createAdminRoutes(db: StateDb, sessions: SessionSource, chatSessions: SessionSource, config: AdminConfig): Hono;
|