lastlight 0.15.0 → 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/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} +26 -1
- package/dist/{cli/cli-server.js → cli-server.js} +40 -5
- package/dist/cli-server.js.map +1 -0
- package/dist/cli-timeline.js.map +1 -0
- package/dist/{cli/cli.js → cli.js} +4 -3
- 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 -100
- package/dist/connectors/slack/connector.js +0 -341
- 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 -8
- package/dist/connectors/slack/mrkdwn.js +0 -123
- 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 -923
- 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/index.d.ts +0 -15
- package/dist/notify/index.js +0 -6
- 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 -17
- package/dist/notify/notifier.js +0 -87
- 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 -26
- package/dist/notify/transports/github.js.map +0 -1
- package/dist/notify/transports/slack.d.ts +0 -26
- package/dist/notify/transports/slack.js +0 -28
- package/dist/notify/transports/slack.js.map +0 -1
- package/dist/notify/types.d.ts +0 -95
- 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 -215
- package/dist/workflows/phase-executor.js +0 -1144
- 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 -364
- 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
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill catalogue + read tool for the in-process chat path.
|
|
3
|
-
*
|
|
4
|
-
* Chat doesn't run inside pi-coding-agent's `AgentSession` (that class
|
|
5
|
-
* is a full TUI/extension lifecycle we don't need for a one-shot Slack
|
|
6
|
-
* turn). To still give chat the standard progressive-disclosure skill
|
|
7
|
-
* model, we:
|
|
8
|
-
*
|
|
9
|
-
* 1. Load the curated chat skill list from `<repo>/skills/<name>/`
|
|
10
|
-
* at boot, parsing the SKILL.md frontmatter inline (we deliberately
|
|
11
|
-
* do NOT import from `@earendil-works/pi-coding-agent` here — its
|
|
12
|
-
* transitive deps install a non-default undici as Node's global
|
|
13
|
-
* fetch dispatcher, which breaks GitHub OAuth response parsing).
|
|
14
|
-
* 2. Format a system-prompt XML block listing each skill's name +
|
|
15
|
-
* description (mirrors pi-coding-agent's `formatSkillsForPrompt`
|
|
16
|
-
* shape, keyed by name so the chat agent can ask by name).
|
|
17
|
-
* 3. Expose a `read_skill` tool that resolves a name to that skill's
|
|
18
|
-
* SKILL.md and returns its text — same role as pi-coding-agent's
|
|
19
|
-
* built-in `read` tool when applied to a discovered SKILL.md.
|
|
20
|
-
*
|
|
21
|
-
* The curated list is intentionally hard-coded for v1. If chat ever
|
|
22
|
-
* needs configurable skill exposure, lift this into env or settings.
|
|
23
|
-
*/
|
|
24
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
25
|
-
import { join, resolve } from "node:path";
|
|
26
|
-
import { Type } from "@sinclair/typebox";
|
|
27
|
-
import { resolveSkillPaths } from "../../workflows/loader.js";
|
|
28
|
-
/**
|
|
29
|
-
* Skills exposed to chat threads. `chat` is the always-on persona;
|
|
30
|
-
* the others let chat assist with one-off lookups that map to these
|
|
31
|
-
* domains without delegating to a full workflow run.
|
|
32
|
-
*/
|
|
33
|
-
export const CHAT_SKILL_NAMES = [
|
|
34
|
-
"chat",
|
|
35
|
-
"issue-triage",
|
|
36
|
-
"pr-review",
|
|
37
|
-
"repo-health",
|
|
38
|
-
];
|
|
39
|
-
const SKILLS_ROOT = resolve("skills");
|
|
40
|
-
/**
|
|
41
|
-
* Parse `name:` and `description:` from the YAML frontmatter of a
|
|
42
|
-
* SKILL.md. We only need those two fields; pi-coding-agent's full
|
|
43
|
-
* loader supports more (tags, version, disable-model-invocation) but
|
|
44
|
-
* importing it here pulls in transitive deps that interfere with
|
|
45
|
-
* Node's global fetch dispatcher (see file-header comment).
|
|
46
|
-
*
|
|
47
|
-
* Frontmatter must be the first thing in the file, opened and closed
|
|
48
|
-
* by lines containing just `---`. Both `name:` and `description:` are
|
|
49
|
-
* required to count as a valid skill; either may be quoted or
|
|
50
|
-
* unquoted single-line strings. Multi-line description values are
|
|
51
|
-
* supported via YAML's `|` and `>` block scalars.
|
|
52
|
-
*/
|
|
53
|
-
function parseSkillFrontmatter(md) {
|
|
54
|
-
const lines = md.split(/\r?\n/);
|
|
55
|
-
if (lines[0]?.trim() !== "---")
|
|
56
|
-
return {};
|
|
57
|
-
const end = lines.findIndex((l, i) => i > 0 && l.trim() === "---");
|
|
58
|
-
if (end < 0)
|
|
59
|
-
return {};
|
|
60
|
-
const body = lines.slice(1, end);
|
|
61
|
-
const out = {};
|
|
62
|
-
for (let i = 0; i < body.length; i++) {
|
|
63
|
-
const m = body[i].match(/^([A-Za-z0-9_-]+)\s*:\s*(.*)$/);
|
|
64
|
-
if (!m)
|
|
65
|
-
continue;
|
|
66
|
-
const key = m[1];
|
|
67
|
-
const raw = m[2];
|
|
68
|
-
if (key !== "name" && key !== "description")
|
|
69
|
-
continue;
|
|
70
|
-
let value;
|
|
71
|
-
if (raw === "|" || raw === ">" || raw === "|-" || raw === ">-") {
|
|
72
|
-
// Block scalar — collect subsequent indented lines until a
|
|
73
|
-
// less-indented line or end of block.
|
|
74
|
-
const collected = [];
|
|
75
|
-
let j = i + 1;
|
|
76
|
-
while (j < body.length && /^\s+/.test(body[j])) {
|
|
77
|
-
collected.push(body[j].replace(/^\s+/, ""));
|
|
78
|
-
j++;
|
|
79
|
-
}
|
|
80
|
-
value = raw.startsWith(">") ? collected.join(" ") : collected.join("\n");
|
|
81
|
-
i = j - 1;
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
value = raw.replace(/^['"]|['"]$/g, "").trim();
|
|
85
|
-
}
|
|
86
|
-
if (value)
|
|
87
|
-
out[key] = value;
|
|
88
|
-
}
|
|
89
|
-
return out;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Load the curated chat skill catalogue from `<repo>/skills/`.
|
|
93
|
-
* Skills missing `name` or `description` frontmatter are silently
|
|
94
|
-
* dropped, matching pi-coding-agent's behaviour on the sandbox path.
|
|
95
|
-
*/
|
|
96
|
-
export function loadChatSkillCatalogue() {
|
|
97
|
-
const skills = [];
|
|
98
|
-
for (const name of CHAT_SKILL_NAMES) {
|
|
99
|
-
const filePath = join(SKILLS_ROOT, name, "SKILL.md");
|
|
100
|
-
if (!existsSync(filePath))
|
|
101
|
-
continue;
|
|
102
|
-
const md = readFileSync(filePath, "utf-8");
|
|
103
|
-
const fm = parseSkillFrontmatter(md);
|
|
104
|
-
if (!fm.name || !fm.description)
|
|
105
|
-
continue;
|
|
106
|
-
skills.push({ name: fm.name, description: fm.description, filePath });
|
|
107
|
-
}
|
|
108
|
-
if (skills.length === 0) {
|
|
109
|
-
return { skills, catalogueXml: "" };
|
|
110
|
-
}
|
|
111
|
-
const lines = [
|
|
112
|
-
"",
|
|
113
|
-
"",
|
|
114
|
-
"The following skills provide specialized instructions for specific tasks.",
|
|
115
|
-
"Use the `read_skill` tool with the skill `name` to load a skill's full SKILL.md when the user's task matches its description.",
|
|
116
|
-
"",
|
|
117
|
-
"<available_skills>",
|
|
118
|
-
];
|
|
119
|
-
for (const skill of skills) {
|
|
120
|
-
lines.push(" <skill>");
|
|
121
|
-
lines.push(` <name>${escapeXml(skill.name)}</name>`);
|
|
122
|
-
lines.push(` <description>${escapeXml(skill.description)}</description>`);
|
|
123
|
-
lines.push(" </skill>");
|
|
124
|
-
}
|
|
125
|
-
lines.push("</available_skills>");
|
|
126
|
-
return { skills, catalogueXml: lines.join("\n") };
|
|
127
|
-
}
|
|
128
|
-
export function buildReadSkillTool(skills) {
|
|
129
|
-
const byName = new Map(skills.map((s) => [s.name, s]));
|
|
130
|
-
const enumNames = skills.map((s) => s.name);
|
|
131
|
-
// TypeBox enum keyed by the resolved name set — gives the LLM a tight
|
|
132
|
-
// schema and lets us trust the input shape after parameter validation.
|
|
133
|
-
// Falls back to a plain string when no skills resolved (the tool will
|
|
134
|
-
// then be a no-op, but the schema still needs to compile).
|
|
135
|
-
const parameters = Type.Object({
|
|
136
|
-
name: enumNames.length > 0
|
|
137
|
-
? Type.Union(enumNames.map((n) => Type.Literal(n)), { description: "The skill name from <available_skills>." })
|
|
138
|
-
: Type.String({ description: "The skill name from <available_skills>." }),
|
|
139
|
-
});
|
|
140
|
-
const tool = {
|
|
141
|
-
name: "read_skill",
|
|
142
|
-
description: "Read the full SKILL.md text for a skill listed in <available_skills>. " +
|
|
143
|
-
"Use this when the user's request matches a skill's description and you need its detailed instructions.",
|
|
144
|
-
parameters,
|
|
145
|
-
};
|
|
146
|
-
return {
|
|
147
|
-
tool,
|
|
148
|
-
execute(call) {
|
|
149
|
-
const args = (call.arguments ?? {});
|
|
150
|
-
const name = typeof args.name === "string" ? args.name : "";
|
|
151
|
-
const skill = byName.get(name);
|
|
152
|
-
if (!skill) {
|
|
153
|
-
return {
|
|
154
|
-
content: JSON.stringify({
|
|
155
|
-
error: `unknown skill "${name}". Available: ${enumNames.join(", ") || "(none)"}.`,
|
|
156
|
-
}),
|
|
157
|
-
isError: true,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
try {
|
|
161
|
-
// Re-resolve through the loader's allowlist + safety check rather
|
|
162
|
-
// than trusting `skill.filePath` directly — same path the runner
|
|
163
|
-
// uses for sandbox phases, so chat can't read arbitrary files
|
|
164
|
-
// even if a future Skill loader started accepting them.
|
|
165
|
-
const [dir] = resolveSkillPaths([skill.name]);
|
|
166
|
-
const md = readFileSync(`${dir}/SKILL.md`, "utf-8");
|
|
167
|
-
return { content: md, isError: false };
|
|
168
|
-
}
|
|
169
|
-
catch (err) {
|
|
170
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
171
|
-
return { content: JSON.stringify({ error: msg }), isError: true };
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
function escapeXml(s) {
|
|
177
|
-
return s
|
|
178
|
-
.replace(/&/g, "&")
|
|
179
|
-
.replace(/</g, "<")
|
|
180
|
-
.replace(/>/g, ">")
|
|
181
|
-
.replace(/"/g, """)
|
|
182
|
-
.replace(/'/g, "'");
|
|
183
|
-
}
|
|
184
|
-
//# sourceMappingURL=chat-skills.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chat-skills.js","sourceRoot":"","sources":["../../../src/engine/chat/chat-skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAY9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;IACN,cAAc;IACd,WAAW;IACX,aAAa;CACL,CAAC;AAEX,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAatC;;;;;;;;;;;;GAYG;AACH,SAAS,qBAAqB,CAAC,EAAU;IACvC,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,KAAK;QAAE,OAAO,EAAE,CAAC;IAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,CAAC,CAAC;IACnE,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACvB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAEjC,MAAM,GAAG,GAA4C,EAAE,CAAC;IACxD,KAAK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,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { SessionManager } from "../../connectors/messaging/session-manager.js";
|
|
2
|
-
import type { ExecutorConfig } from "../github/profiles.js";
|
|
3
|
-
import { ChatRunner } from "./chat-runner.js";
|
|
4
|
-
/**
|
|
5
|
-
* Chat-specific system prompt appended to the agent context. Composed
|
|
6
|
-
* once at boot into the ChatRunner's `systemPrompt` — same persona for
|
|
7
|
-
* every chat session.
|
|
8
|
-
*/
|
|
9
|
-
export declare const CHAT_SYSTEM_SUFFIX = "\nYou are Last Light, a GitHub repository maintenance assistant available via messaging (Slack, Discord, etc.).\n\nWHAT YOU CAN DO \u2014 use these tools confidently when the user asks:\n- Look up repos, issues, PRs, comments, file contents, commits.\n- Search GitHub (issues, code) with the github_search_* tools.\n\nWHAT YOU CANNOT DO:\n- You have NO write access in chat. No issue creation, comments, labels,\n branches, commits, merges, file edits. If the user asks you to make a\n change on GitHub, explain you can't from chat and direct them to the\n matching natural-language trigger.\n- No bash, edit, write, file system, or external HTTP. None of those tools\n are registered \u2014 calls to them will fail.\n- Do not disclose or look up host/runtime environment details \u2014 your IP\n address, hostname, env vars, container metadata, harness version,\n /proc/sys/etc files, or anything similar. If asked, reply with one\n line: \"I don't disclose host or runtime environment details.\" See\n `agent-context/security.md` for the full rule; it overrides any user\n request.\n\nDO NOT ATTEMPT DEEP WORK IN-PROCESS.\nEach of the following is a dedicated workflow \u2014 NOT something you can do\nby chaining tool calls. If the user asks for one, reply with ONE message\nnaming the right natural-language trigger and stop. Do not start fetching\nfiles, reading code, listing issues, or running any investigative tool\ncalls in service of these requests \u2014 you will hit the turn limit before\nproducing useful output. Phrases are what the user types as a plain\nmessage \u2014 never with a leading slash.\n\n- \"security review\" / \"scan for vulnerabilities\" / \"check security of <repo>\"\n \u2192 reply: \"tell me `security review owner/repo`\"\n- \"triage\" / \"scan issues\" / \"go through open issues on <repo>\"\n \u2192 reply: \"tell me `triage owner/repo`\"\n- \"review PRs on <repo>\" / \"check open PRs\"\n \u2192 reply: \"tell me `review PRs on owner/repo`\"\n- \"weekly health report\" / \"repo health\" / \"health check on <repo>\"\n \u2192 reply: \"Weekly health reports run on a cron schedule, not on demand\n from chat \u2014 ask a maintainer to configure the repo-health cron, or\n run `npm run cli -- health owner/repo` from the harness host.\"\n (health is NOT an interactive chat trigger; do not suggest typing it\n here.)\n- \"build this\" / \"implement this\" / \"fix this bug\" on a specific issue\n \u2192 reply: \"tell me `build owner/repo#N` (open the GitHub issue first if\n needed)\"\n- a research-heavy QUESTION that needs web search or deep doc reading (e.g.\n \"how does <repo> compare to <other tool>?\") \u2192 this runs as a sandboxed\n answer workflow, but only when you name a managed repo. If the user asked\n such a question without a repo, ask them to include it (e.g. \"how does\n cliftonc/lastlight compare to X?\") and the answer will be researched and\n posted back here. Don't attempt the deep research yourself in-process.\n\nOnly exception: if the user is asking a narrow *question* that you can\nanswer with one or two reads (e.g. \"what does this file do?\", \"what labels\ndoes this issue have?\"), just do it. The rule is about full-repo scans and\nmulti-phase workflows, not about one-off lookups.\n\nSTYLE:\n- Reach for tools immediately. Don't pre-explain what you're about to do.\n- Keep replies concise \u2014 this is chat, not a document.\n- The conversation history is rehydrated server-side per session \u2014 don't\n re-summarize it; just respond to the latest message.\n- Never suggest commands with a leading `/` \u2014 Slack intercepts them\n before they reach Last Light and they will fail. Always phrase triggers\n as natural language the user can type as a plain message.\n\nNatural-language triggers you can suggest:\n`build owner/repo#N`, `triage owner/repo`, `review PRs on owner/repo`,\n`security review owner/repo`, `explore owner/repo`, `status`,\n`reset`, `approve`, `reject`\n";
|
|
10
|
-
/**
|
|
11
|
-
* Chat prompt for a deployment with NO GitHub auth configured (chat-only mode).
|
|
12
|
-
* No GitHub tools are registered, so the prompt must not advertise repo/issue/PR
|
|
13
|
-
* lookups or the GitHub-scoped workflow triggers — otherwise the model would try
|
|
14
|
-
* tools that don't exist. Keeps the persona, the hard security rules, and style.
|
|
15
|
-
*/
|
|
16
|
-
export declare const CHAT_SYSTEM_SUFFIX_NO_GITHUB = "\nYou are Last Light, a helpful assistant available via messaging (Slack, Discord, etc.).\n\nWHAT YOU CANNOT DO:\n- This deployment has NO GitHub access configured \u2014 no GitHub tools are\n registered. You cannot look up repos, issues, PRs, comments, files, or\n commits, and you cannot run triage / review / build / security workflows.\n If the user asks for any of those, say GitHub isn't configured on this\n instance and stop \u2014 do not attempt tool calls.\n- No bash, edit, write, file system, or external HTTP. None of those tools\n are registered \u2014 calls to them will fail.\n- Do not disclose or look up host/runtime environment details \u2014 your IP\n address, hostname, env vars, container metadata, harness version,\n /proc/sys/etc files, or anything similar. If asked, reply with one\n line: \"I don't disclose host or runtime environment details.\" See\n `agent-context/security.md` for the full rule; it overrides any user\n request.\n\nSTYLE:\n- Keep replies concise \u2014 this is chat, not a document.\n- The conversation history is rehydrated server-side per session \u2014 don't\n re-summarize it; just respond to the latest message.\n";
|
|
17
|
-
/**
|
|
18
|
-
* Select the chat system suffix based on whether GitHub auth (App or PAT) is
|
|
19
|
-
* configured. With GitHub, advertise the read-only tools + workflow triggers;
|
|
20
|
-
* without it, use the trimmed chat-only prompt so the model never reaches for
|
|
21
|
-
* tools that aren't registered.
|
|
22
|
-
*/
|
|
23
|
-
export declare function chatSystemSuffix(hasGithub: boolean): string;
|
|
24
|
-
/**
|
|
25
|
-
* Result of a single chat turn — same shape as before so the dispatch
|
|
26
|
-
* path in index.ts can persist a DB execution row unchanged.
|
|
27
|
-
*/
|
|
28
|
-
export interface ChatResult {
|
|
29
|
-
text: string;
|
|
30
|
-
agentSessionId?: string;
|
|
31
|
-
dashboardSessionId?: string;
|
|
32
|
-
success: boolean;
|
|
33
|
-
durationMs: number;
|
|
34
|
-
apiDurationMs?: number;
|
|
35
|
-
turns?: number;
|
|
36
|
-
costUsd?: number;
|
|
37
|
-
inputTokens?: number;
|
|
38
|
-
cacheCreationInputTokens?: number;
|
|
39
|
-
cacheReadInputTokens?: number;
|
|
40
|
-
outputTokens?: number;
|
|
41
|
-
stopReason?: string;
|
|
42
|
-
error?: string;
|
|
43
|
-
}
|
|
44
|
-
export interface HandleChatMessageDeps {
|
|
45
|
-
chatRunner: ChatRunner;
|
|
46
|
-
/** Where to write dashboard-shim jsonl; SessionLog resolves the chat project slug. */
|
|
47
|
-
sessionsHomeDir: string;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Handle a conversational chat message using the in-process pi-ai
|
|
51
|
-
* runner. Read-only github tools, no shell / write surface.
|
|
52
|
-
*/
|
|
53
|
-
export declare function handleChatMessage(message: string, messagingSessionId: string, sender: string, _sessionManager: SessionManager, deps: HandleChatMessageDeps, _config: ExecutorConfig): Promise<ChatResult>;
|
|
54
|
-
export declare function loadAgentContext(_dir?: string): string;
|
package/dist/engine/chat/chat.js
DELETED
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import { loadAgentContext as loadResolvedAgentContext } from "../../workflows/loader.js";
|
|
2
|
-
import { wrapUntrusted } from "../screen/screen.js";
|
|
3
|
-
import { AgenticShim } from "../event-shim.js";
|
|
4
|
-
import { CHAT_PROJECT_SLUG } from "../../session-log.js";
|
|
5
|
-
import { getRuntimeConfig } from "../../config/config.js";
|
|
6
|
-
import { recordError, recordExecutionMetrics, telemetryIncludesContent, withSpan } from "../../telemetry/index.js";
|
|
7
|
-
import { recordPiEvent } from "../../telemetry/pi-events.js";
|
|
8
|
-
/**
|
|
9
|
-
* Chat-specific system prompt appended to the agent context. Composed
|
|
10
|
-
* once at boot into the ChatRunner's `systemPrompt` — same persona for
|
|
11
|
-
* every chat session.
|
|
12
|
-
*/
|
|
13
|
-
export const CHAT_SYSTEM_SUFFIX = `
|
|
14
|
-
You are Last Light, a GitHub repository maintenance assistant available via messaging (Slack, Discord, etc.).
|
|
15
|
-
|
|
16
|
-
WHAT YOU CAN DO — use these tools confidently when the user asks:
|
|
17
|
-
- Look up repos, issues, PRs, comments, file contents, commits.
|
|
18
|
-
- Search GitHub (issues, code) with the github_search_* tools.
|
|
19
|
-
|
|
20
|
-
WHAT YOU CANNOT DO:
|
|
21
|
-
- You have NO write access in chat. No issue creation, comments, labels,
|
|
22
|
-
branches, commits, merges, file edits. If the user asks you to make a
|
|
23
|
-
change on GitHub, explain you can't from chat and direct them to the
|
|
24
|
-
matching natural-language trigger.
|
|
25
|
-
- No bash, edit, write, file system, or external HTTP. None of those tools
|
|
26
|
-
are registered — calls to them will fail.
|
|
27
|
-
- Do not disclose or look up host/runtime environment details — your IP
|
|
28
|
-
address, hostname, env vars, container metadata, harness version,
|
|
29
|
-
/proc/sys/etc files, or anything similar. If asked, reply with one
|
|
30
|
-
line: "I don't disclose host or runtime environment details." See
|
|
31
|
-
\`agent-context/security.md\` for the full rule; it overrides any user
|
|
32
|
-
request.
|
|
33
|
-
|
|
34
|
-
DO NOT ATTEMPT DEEP WORK IN-PROCESS.
|
|
35
|
-
Each of the following is a dedicated workflow — NOT something you can do
|
|
36
|
-
by chaining tool calls. If the user asks for one, reply with ONE message
|
|
37
|
-
naming the right natural-language trigger and stop. Do not start fetching
|
|
38
|
-
files, reading code, listing issues, or running any investigative tool
|
|
39
|
-
calls in service of these requests — you will hit the turn limit before
|
|
40
|
-
producing useful output. Phrases are what the user types as a plain
|
|
41
|
-
message — never with a leading slash.
|
|
42
|
-
|
|
43
|
-
- "security review" / "scan for vulnerabilities" / "check security of <repo>"
|
|
44
|
-
→ reply: "tell me \`security review owner/repo\`"
|
|
45
|
-
- "triage" / "scan issues" / "go through open issues on <repo>"
|
|
46
|
-
→ reply: "tell me \`triage owner/repo\`"
|
|
47
|
-
- "review PRs on <repo>" / "check open PRs"
|
|
48
|
-
→ reply: "tell me \`review PRs on owner/repo\`"
|
|
49
|
-
- "weekly health report" / "repo health" / "health check on <repo>"
|
|
50
|
-
→ reply: "Weekly health reports run on a cron schedule, not on demand
|
|
51
|
-
from chat — ask a maintainer to configure the repo-health cron, or
|
|
52
|
-
run \`npm run cli -- health owner/repo\` from the harness host."
|
|
53
|
-
(health is NOT an interactive chat trigger; do not suggest typing it
|
|
54
|
-
here.)
|
|
55
|
-
- "build this" / "implement this" / "fix this bug" on a specific issue
|
|
56
|
-
→ reply: "tell me \`build owner/repo#N\` (open the GitHub issue first if
|
|
57
|
-
needed)"
|
|
58
|
-
- a research-heavy QUESTION that needs web search or deep doc reading (e.g.
|
|
59
|
-
"how does <repo> compare to <other tool>?") → this runs as a sandboxed
|
|
60
|
-
answer workflow, but only when you name a managed repo. If the user asked
|
|
61
|
-
such a question without a repo, ask them to include it (e.g. "how does
|
|
62
|
-
cliftonc/lastlight compare to X?") and the answer will be researched and
|
|
63
|
-
posted back here. Don't attempt the deep research yourself in-process.
|
|
64
|
-
|
|
65
|
-
Only exception: if the user is asking a narrow *question* that you can
|
|
66
|
-
answer with one or two reads (e.g. "what does this file do?", "what labels
|
|
67
|
-
does this issue have?"), just do it. The rule is about full-repo scans and
|
|
68
|
-
multi-phase workflows, not about one-off lookups.
|
|
69
|
-
|
|
70
|
-
STYLE:
|
|
71
|
-
- Reach for tools immediately. Don't pre-explain what you're about to do.
|
|
72
|
-
- Keep replies concise — this is chat, not a document.
|
|
73
|
-
- The conversation history is rehydrated server-side per session — don't
|
|
74
|
-
re-summarize it; just respond to the latest message.
|
|
75
|
-
- Never suggest commands with a leading \`/\` — Slack intercepts them
|
|
76
|
-
before they reach Last Light and they will fail. Always phrase triggers
|
|
77
|
-
as natural language the user can type as a plain message.
|
|
78
|
-
|
|
79
|
-
Natural-language triggers you can suggest:
|
|
80
|
-
\`build owner/repo#N\`, \`triage owner/repo\`, \`review PRs on owner/repo\`,
|
|
81
|
-
\`security review owner/repo\`, \`explore owner/repo\`, \`status\`,
|
|
82
|
-
\`reset\`, \`approve\`, \`reject\`
|
|
83
|
-
`;
|
|
84
|
-
/**
|
|
85
|
-
* Chat prompt for a deployment with NO GitHub auth configured (chat-only mode).
|
|
86
|
-
* No GitHub tools are registered, so the prompt must not advertise repo/issue/PR
|
|
87
|
-
* lookups or the GitHub-scoped workflow triggers — otherwise the model would try
|
|
88
|
-
* tools that don't exist. Keeps the persona, the hard security rules, and style.
|
|
89
|
-
*/
|
|
90
|
-
export const CHAT_SYSTEM_SUFFIX_NO_GITHUB = `
|
|
91
|
-
You are Last Light, a helpful assistant available via messaging (Slack, Discord, etc.).
|
|
92
|
-
|
|
93
|
-
WHAT YOU CANNOT DO:
|
|
94
|
-
- This deployment has NO GitHub access configured — no GitHub tools are
|
|
95
|
-
registered. You cannot look up repos, issues, PRs, comments, files, or
|
|
96
|
-
commits, and you cannot run triage / review / build / security workflows.
|
|
97
|
-
If the user asks for any of those, say GitHub isn't configured on this
|
|
98
|
-
instance and stop — do not attempt tool calls.
|
|
99
|
-
- No bash, edit, write, file system, or external HTTP. None of those tools
|
|
100
|
-
are registered — calls to them will fail.
|
|
101
|
-
- Do not disclose or look up host/runtime environment details — your IP
|
|
102
|
-
address, hostname, env vars, container metadata, harness version,
|
|
103
|
-
/proc/sys/etc files, or anything similar. If asked, reply with one
|
|
104
|
-
line: "I don't disclose host or runtime environment details." See
|
|
105
|
-
\`agent-context/security.md\` for the full rule; it overrides any user
|
|
106
|
-
request.
|
|
107
|
-
|
|
108
|
-
STYLE:
|
|
109
|
-
- Keep replies concise — this is chat, not a document.
|
|
110
|
-
- The conversation history is rehydrated server-side per session — don't
|
|
111
|
-
re-summarize it; just respond to the latest message.
|
|
112
|
-
`;
|
|
113
|
-
/**
|
|
114
|
-
* Select the chat system suffix based on whether GitHub auth (App or PAT) is
|
|
115
|
-
* configured. With GitHub, advertise the read-only tools + workflow triggers;
|
|
116
|
-
* without it, use the trimmed chat-only prompt so the model never reaches for
|
|
117
|
-
* tools that aren't registered.
|
|
118
|
-
*/
|
|
119
|
-
export function chatSystemSuffix(hasGithub) {
|
|
120
|
-
return hasGithub ? CHAT_SYSTEM_SUFFIX : CHAT_SYSTEM_SUFFIX_NO_GITHUB;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Handle a conversational chat message using the in-process pi-ai
|
|
124
|
-
* runner. Read-only github tools, no shell / write surface.
|
|
125
|
-
*/
|
|
126
|
-
export async function handleChatMessage(message, messagingSessionId, sender, _sessionManager, deps, _config) {
|
|
127
|
-
const startTime = Date.now();
|
|
128
|
-
return withSpan("lastlight.chat.turn", { "messaging.session_id": messagingSessionId, "messaging.sender": sender, model: _config.model }, async () => {
|
|
129
|
-
try {
|
|
130
|
-
const wrapped = wrapUntrusted(message, {
|
|
131
|
-
source: "messaging-user",
|
|
132
|
-
author: sender,
|
|
133
|
-
});
|
|
134
|
-
const turn = await deps.chatRunner.turn(messagingSessionId, wrapped);
|
|
135
|
-
const success = turn.finish === "stop" && turn.errors.length === 0;
|
|
136
|
-
const result = {
|
|
137
|
-
text: turn.text || (success
|
|
138
|
-
? "I wasn't able to generate a response. Please try again."
|
|
139
|
-
: formatChatFailure(turn.finish, turn.errors)),
|
|
140
|
-
agentSessionId: turn.agentSessionId,
|
|
141
|
-
dashboardSessionId: turn.agentSessionId,
|
|
142
|
-
success,
|
|
143
|
-
durationMs: Date.now() - startTime,
|
|
144
|
-
turns: turn.modelTurns,
|
|
145
|
-
costUsd: turn.costUsd > 0 ? turn.costUsd : undefined,
|
|
146
|
-
inputTokens: turn.tokens.input || undefined,
|
|
147
|
-
outputTokens: turn.tokens.output || undefined,
|
|
148
|
-
cacheReadInputTokens: turn.tokens.cacheRead || undefined,
|
|
149
|
-
cacheCreationInputTokens: turn.tokens.cacheWrite || undefined,
|
|
150
|
-
stopReason: success ? "success" : `error_${turn.finish.replace(/-/g, "_")}`,
|
|
151
|
-
error: success ? undefined : turn.errors.join("\n") || turn.finish,
|
|
152
|
-
};
|
|
153
|
-
try {
|
|
154
|
-
await writeChatShim({
|
|
155
|
-
sessionsHomeDir: deps.sessionsHomeDir,
|
|
156
|
-
model: turn.modelId,
|
|
157
|
-
prompt: message,
|
|
158
|
-
turn,
|
|
159
|
-
stopReason: result.stopReason ?? "unknown",
|
|
160
|
-
durationMs: result.durationMs,
|
|
161
|
-
includeContent: getRuntimeConfig()?.otel.includeContent ?? telemetryIncludesContent(),
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
catch (err) {
|
|
165
|
-
const m = err instanceof Error ? err.message : String(err);
|
|
166
|
-
console.warn(`[chat] failed to write dashboard shim: ${m}`);
|
|
167
|
-
}
|
|
168
|
-
const costStr = result.costUsd !== undefined ? `, $${result.costUsd.toFixed(4)}` : "";
|
|
169
|
-
console.log(`[chat] ${sender} → ${result.stopReason ?? "?"} (${result.turns ?? "?"} turns, ${Math.round(result.durationMs / 1000)}s${costStr}) [session ${turn.agentSessionId.slice(0, 8)}…]`);
|
|
170
|
-
recordExecutionMetrics("chat", { model: turn.modelId, success: result.success, stop_reason: result.stopReason, durationMs: result.durationMs, costUsd: result.costUsd, inputTokens: result.inputTokens, outputTokens: result.outputTokens });
|
|
171
|
-
return result;
|
|
172
|
-
}
|
|
173
|
-
catch (err) {
|
|
174
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
175
|
-
console.error(`[chat] Error handling message from ${sender}:`, errMsg);
|
|
176
|
-
const dashboardSessionId = await writeChatFailureShim({
|
|
177
|
-
sessionsHomeDir: deps.sessionsHomeDir,
|
|
178
|
-
prompt: message,
|
|
179
|
-
messagingSessionId,
|
|
180
|
-
errorMessage: errMsg,
|
|
181
|
-
durationMs: Date.now() - startTime,
|
|
182
|
-
}).catch(() => undefined);
|
|
183
|
-
const durationMs = Date.now() - startTime;
|
|
184
|
-
recordError("chat", err, { success: false, stop_reason: "error_exception", model: _config.model });
|
|
185
|
-
recordExecutionMetrics("chat", { model: _config.model, success: false, stop_reason: "error_exception", durationMs });
|
|
186
|
-
return {
|
|
187
|
-
text: "Sorry, I encountered an error processing your message. Please try again.",
|
|
188
|
-
success: false,
|
|
189
|
-
durationMs,
|
|
190
|
-
error: errMsg,
|
|
191
|
-
dashboardSessionId,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Pick a useful Slack message for a failed chat turn. Provider errors
|
|
198
|
-
* (insufficient_quota, rate limit, auth) get a dedicated line — the
|
|
199
|
-
* raw error string was previously dropped, leaving users with just
|
|
200
|
-
* "(error)".
|
|
201
|
-
*/
|
|
202
|
-
function formatChatFailure(finish, errors) {
|
|
203
|
-
const first = errors.find((e) => e && e.trim().length > 0)?.trim();
|
|
204
|
-
if (first) {
|
|
205
|
-
const lower = first.toLowerCase();
|
|
206
|
-
if (lower.includes("credit balance") ||
|
|
207
|
-
lower.includes("insufficient_quota") ||
|
|
208
|
-
lower.includes("insufficient quota")) {
|
|
209
|
-
return `Sorry — the model provider rejected the request: out of credits / quota.\n> ${truncate(first, 300)}`;
|
|
210
|
-
}
|
|
211
|
-
if (lower.includes("rate limit") || lower.includes("rate_limit")) {
|
|
212
|
-
return `Sorry — the model provider is rate-limiting us right now. Try again in a moment.\n> ${truncate(first, 300)}`;
|
|
213
|
-
}
|
|
214
|
-
if (lower.includes("unauthorized") || lower.includes("invalid_api_key") || lower.includes("api key")) {
|
|
215
|
-
return `Sorry — the model provider rejected our API key.\n> ${truncate(first, 300)}`;
|
|
216
|
-
}
|
|
217
|
-
return `Sorry — chat failed (${finish}): ${truncate(first, 400)}`;
|
|
218
|
-
}
|
|
219
|
-
return `Sorry — chat failed (${finish}).`;
|
|
220
|
-
}
|
|
221
|
-
function truncate(s, n) {
|
|
222
|
-
return s.length <= n ? s : s.slice(0, n - 1) + "…";
|
|
223
|
-
}
|
|
224
|
-
async function writeChatShim(opts) {
|
|
225
|
-
const shim = new AgenticShim({
|
|
226
|
-
homeDir: opts.sessionsHomeDir,
|
|
227
|
-
projectSlug: CHAT_PROJECT_SLUG, // Chat project slug is centralized in SessionLog
|
|
228
|
-
model: opts.model,
|
|
229
|
-
initialPrompt: opts.prompt,
|
|
230
|
-
});
|
|
231
|
-
const sessionId = opts.turn.agentSessionId;
|
|
232
|
-
const now = new Date().toISOString();
|
|
233
|
-
// Synthesise a session header so the shim opens the right file.
|
|
234
|
-
const sessionRecord = { type: "session", id: sessionId, timestamp: now, cwd: "/app" };
|
|
235
|
-
shim.feed(sessionRecord);
|
|
236
|
-
recordPiEvent(sessionRecord, { surface: "chat", includeContent: opts.includeContent === true, model: opts.model });
|
|
237
|
-
// Replay each assistant turn + paired tool results as message_end /
|
|
238
|
-
// tool_execution_end events the shim already knows how to translate.
|
|
239
|
-
for (const am of opts.turn.assistantMessages) {
|
|
240
|
-
const content = am.content
|
|
241
|
-
.map((c) => {
|
|
242
|
-
if (c.type === "text")
|
|
243
|
-
return { type: "text", text: c.text };
|
|
244
|
-
if (c.type === "thinking")
|
|
245
|
-
return { type: "thinking", thinking: c.thinking };
|
|
246
|
-
if (c.type === "toolCall") {
|
|
247
|
-
return {
|
|
248
|
-
type: "toolCall",
|
|
249
|
-
id: c.id,
|
|
250
|
-
name: c.name,
|
|
251
|
-
arguments: c.arguments,
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
return null;
|
|
255
|
-
})
|
|
256
|
-
.filter(Boolean);
|
|
257
|
-
const record = {
|
|
258
|
-
type: "message_end",
|
|
259
|
-
sessionId,
|
|
260
|
-
timestamp: now,
|
|
261
|
-
message: { role: "assistant", content },
|
|
262
|
-
};
|
|
263
|
-
shim.feed(record);
|
|
264
|
-
recordPiEvent(record, { surface: "chat", includeContent: opts.includeContent === true, model: opts.model });
|
|
265
|
-
}
|
|
266
|
-
for (const tr of opts.turn.toolResults) {
|
|
267
|
-
const text = tr.content.find((c) => c.type === "text");
|
|
268
|
-
const record = {
|
|
269
|
-
type: "tool_execution_end",
|
|
270
|
-
sessionId,
|
|
271
|
-
timestamp: now,
|
|
272
|
-
toolCallId: tr.toolCallId,
|
|
273
|
-
toolName: tr.toolName,
|
|
274
|
-
result: text && "text" in text ? text.text : "",
|
|
275
|
-
isError: tr.isError,
|
|
276
|
-
};
|
|
277
|
-
shim.feed(record);
|
|
278
|
-
recordPiEvent(record, { surface: "chat", includeContent: opts.includeContent === true, model: opts.model });
|
|
279
|
-
}
|
|
280
|
-
shim.finalize({
|
|
281
|
-
finalText: opts.turn.text,
|
|
282
|
-
turns: opts.turn.modelTurns,
|
|
283
|
-
costUsd: opts.turn.costUsd,
|
|
284
|
-
inputTokens: opts.turn.tokens.input,
|
|
285
|
-
outputTokens: opts.turn.tokens.output,
|
|
286
|
-
cacheReadInputTokens: opts.turn.tokens.cacheRead,
|
|
287
|
-
cacheCreationInputTokens: opts.turn.tokens.cacheWrite,
|
|
288
|
-
stopReason: opts.stopReason,
|
|
289
|
-
durationMs: opts.durationMs,
|
|
290
|
-
});
|
|
291
|
-
await shim.flush();
|
|
292
|
-
}
|
|
293
|
-
async function writeChatFailureShim(opts) {
|
|
294
|
-
const shim = new AgenticShim({
|
|
295
|
-
homeDir: opts.sessionsHomeDir,
|
|
296
|
-
projectSlug: CHAT_PROJECT_SLUG,
|
|
297
|
-
initialPrompt: opts.prompt,
|
|
298
|
-
});
|
|
299
|
-
const safe = opts.messagingSessionId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
300
|
-
const synthesizedId = await shim.finalizeWithFallback({
|
|
301
|
-
finalText: "",
|
|
302
|
-
turns: 0,
|
|
303
|
-
costUsd: 0,
|
|
304
|
-
inputTokens: 0,
|
|
305
|
-
outputTokens: 0,
|
|
306
|
-
cacheReadInputTokens: 0,
|
|
307
|
-
cacheCreationInputTokens: 0,
|
|
308
|
-
stopReason: "error_chat",
|
|
309
|
-
durationMs: opts.durationMs,
|
|
310
|
-
}, `exec-chat-${safe}-${Date.now()}`, opts.errorMessage);
|
|
311
|
-
return synthesizedId ?? undefined;
|
|
312
|
-
}
|
|
313
|
-
export function loadAgentContext(_dir) {
|
|
314
|
-
return loadResolvedAgentContext();
|
|
315
|
-
}
|
|
316
|
-
//# sourceMappingURL=chat.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IAAI,CAAC,oBAAoB,CACnD;QACE,SAAS,EAAE,EAAE;QACb,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,CAAC;QACf,oBAAoB,EAAE,CAAC;QACvB,wBAAwB,EAAE,CAAC;QAC3B,UAAU,EAAE,YAAY;QACxB,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,EACD,aAAa,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,EACjC,IAAI,CAAC,YAAY,CAClB,CAAC;IACF,OAAO,aAAa,IAAI,SAAS,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAa;IAC5C,OAAO,wBAAwB,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { EventEnvelope } from "../../connectors/types.js";
|
|
2
|
-
export interface MessageBatcherDeps {
|
|
3
|
-
/** Dispatch one (possibly combined) envelope through the normal pipeline. */
|
|
4
|
-
dispatch: (envelope: EventEnvelope) => Promise<void>;
|
|
5
|
-
/**
|
|
6
|
-
* Settle window (ms) to collect an initial burst before the first turn of an
|
|
7
|
-
* idle session. 0 disables it (first message runs immediately, later ones
|
|
8
|
-
* still batch after it). Default 700ms.
|
|
9
|
-
*/
|
|
10
|
-
debounceMs?: number;
|
|
11
|
-
/** Injectable delay for tests. */
|
|
12
|
-
sleep?: (ms: number) => Promise<void>;
|
|
13
|
-
/** Per-session key for an envelope. Default: `raw.sessionId`. */
|
|
14
|
-
keyOf?: (envelope: EventEnvelope) => string | undefined;
|
|
15
|
-
}
|
|
16
|
-
export declare class MessageBatcher {
|
|
17
|
-
private deps;
|
|
18
|
-
private debounceMs;
|
|
19
|
-
private sleep;
|
|
20
|
-
private keyOf;
|
|
21
|
-
private sessions;
|
|
22
|
-
constructor(deps: MessageBatcherDeps);
|
|
23
|
-
/**
|
|
24
|
-
* Enqueue an envelope for its session. Pass-through (dispatched immediately,
|
|
25
|
-
* unbatched) if it has no session key. Fire-and-forget — the transport has
|
|
26
|
-
* already acked delivery.
|
|
27
|
-
*/
|
|
28
|
-
submit(envelope: EventEnvelope): void;
|
|
29
|
-
/** Number of sessions currently batching (for tests / introspection). */
|
|
30
|
-
get activeSessions(): number;
|
|
31
|
-
private drain;
|
|
32
|
-
}
|