lastlight 0.16.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 -142
- package/dist/connectors/slack/connector.js +0 -494
- package/dist/connectors/slack/connector.js.map +0 -1
- package/dist/connectors/slack/index.d.ts +0 -2
- package/dist/connectors/slack/index.js +0 -3
- package/dist/connectors/slack/index.js.map +0 -1
- package/dist/connectors/slack/mrkdwn.d.ts +0 -19
- package/dist/connectors/slack/mrkdwn.js +0 -240
- package/dist/connectors/slack/mrkdwn.js.map +0 -1
- package/dist/connectors/types.d.ts +0 -61
- package/dist/connectors/types.js +0 -2
- package/dist/connectors/types.js.map +0 -1
- package/dist/cron/fanout.d.ts +0 -33
- package/dist/cron/fanout.js +0 -55
- package/dist/cron/fanout.js.map +0 -1
- package/dist/cron/jobs.d.ts +0 -18
- package/dist/cron/jobs.js +0 -37
- package/dist/cron/jobs.js.map +0 -1
- package/dist/cron/scheduler.d.ts +0 -45
- package/dist/cron/scheduler.js +0 -105
- package/dist/cron/scheduler.js.map +0 -1
- package/dist/engine/agent-executor.d.ts +0 -34
- package/dist/engine/agent-executor.js +0 -246
- package/dist/engine/agent-executor.js.map +0 -1
- package/dist/engine/chat/chat-runner.d.ts +0 -132
- package/dist/engine/chat/chat-runner.js +0 -424
- package/dist/engine/chat/chat-runner.js.map +0 -1
- package/dist/engine/chat/chat-skills.d.ts +0 -45
- package/dist/engine/chat/chat-skills.js +0 -184
- package/dist/engine/chat/chat-skills.js.map +0 -1
- package/dist/engine/chat/chat.d.ts +0 -54
- package/dist/engine/chat/chat.js +0 -316
- package/dist/engine/chat/chat.js.map +0 -1
- package/dist/engine/chat/message-batcher.d.ts +0 -32
- package/dist/engine/chat/message-batcher.js +0 -109
- package/dist/engine/chat/message-batcher.js.map +0 -1
- package/dist/engine/dispatcher.d.ts +0 -73
- package/dist/engine/dispatcher.js +0 -663
- package/dist/engine/dispatcher.js.map +0 -1
- package/dist/engine/event-shim.d.ts +0 -117
- package/dist/engine/event-shim.js +0 -435
- package/dist/engine/event-shim.js.map +0 -1
- package/dist/engine/executors/orchestrator.d.ts +0 -81
- package/dist/engine/executors/orchestrator.js +0 -365
- package/dist/engine/executors/orchestrator.js.map +0 -1
- package/dist/engine/executors/shared.d.ts +0 -189
- package/dist/engine/executors/shared.js +0 -616
- package/dist/engine/executors/shared.js.map +0 -1
- package/dist/engine/github/git-auth.d.ts +0 -62
- package/dist/engine/github/git-auth.js +0 -161
- package/dist/engine/github/git-auth.js.map +0 -1
- package/dist/engine/github/github-app-client.d.ts +0 -23
- package/dist/engine/github/github-app-client.js +0 -33
- package/dist/engine/github/github-app-client.js.map +0 -1
- package/dist/engine/github/github-tools.d.ts +0 -18
- package/dist/engine/github/github-tools.js +0 -263
- package/dist/engine/github/github-tools.js.map +0 -1
- package/dist/engine/github/github.d.ts +0 -1193
- package/dist/engine/github/github.js +0 -357
- package/dist/engine/github/github.js.map +0 -1
- package/dist/engine/github/profiles.d.ts +0 -279
- package/dist/engine/github/profiles.js +0 -42
- package/dist/engine/github/profiles.js.map +0 -1
- package/dist/engine/github/review-poster.d.ts +0 -98
- package/dist/engine/github/review-poster.js +0 -177
- package/dist/engine/github/review-poster.js.map +0 -1
- package/dist/engine/llm.d.ts +0 -79
- package/dist/engine/llm.js +0 -269
- package/dist/engine/llm.js.map +0 -1
- package/dist/engine/oauth.d.ts +0 -43
- package/dist/engine/oauth.js +0 -103
- package/dist/engine/oauth.js.map +0 -1
- package/dist/engine/router.d.ts +0 -29
- package/dist/engine/router.js +0 -680
- package/dist/engine/router.js.map +0 -1
- package/dist/engine/screen/classifier.d.ts +0 -93
- package/dist/engine/screen/classifier.js +0 -215
- package/dist/engine/screen/classifier.js.map +0 -1
- package/dist/engine/screen/screen.d.ts +0 -41
- package/dist/engine/screen/screen.js +0 -93
- package/dist/engine/screen/screen.js.map +0 -1
- package/dist/evals-api.d.ts +0 -24
- package/dist/evals-api.js +0 -22
- package/dist/evals-api.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -940
- package/dist/index.js.map +0 -1
- package/dist/managed-repos.d.ts +0 -30
- package/dist/managed-repos.js +0 -72
- package/dist/managed-repos.js.map +0 -1
- package/dist/notify/blocks.d.ts +0 -23
- package/dist/notify/blocks.js +0 -118
- package/dist/notify/blocks.js.map +0 -1
- package/dist/notify/index.d.ts +0 -17
- package/dist/notify/index.js +0 -7
- package/dist/notify/index.js.map +0 -1
- package/dist/notify/model.d.ts +0 -57
- package/dist/notify/model.js +0 -89
- package/dist/notify/model.js.map +0 -1
- package/dist/notify/notifier.d.ts +0 -18
- package/dist/notify/notifier.js +0 -100
- package/dist/notify/notifier.js.map +0 -1
- package/dist/notify/render.d.ts +0 -21
- package/dist/notify/render.js +0 -59
- package/dist/notify/render.js.map +0 -1
- package/dist/notify/transports/github.d.ts +0 -26
- package/dist/notify/transports/github.js +0 -27
- package/dist/notify/transports/github.js.map +0 -1
- package/dist/notify/transports/slack.d.ts +0 -27
- package/dist/notify/transports/slack.js +0 -37
- package/dist/notify/transports/slack.js.map +0 -1
- package/dist/notify/types.d.ts +0 -119
- package/dist/notify/types.js +0 -16
- package/dist/notify/types.js.map +0 -1
- package/dist/providers.d.ts +0 -125
- package/dist/providers.js +0 -279
- package/dist/providers.js.map +0 -1
- package/dist/sandbox/docker.d.ts +0 -180
- package/dist/sandbox/docker.js +0 -517
- package/dist/sandbox/docker.js.map +0 -1
- package/dist/sandbox/egress-allowlist.d.ts +0 -74
- package/dist/sandbox/egress-allowlist.js +0 -164
- package/dist/sandbox/egress-allowlist.js.map +0 -1
- package/dist/sandbox/egress-firewall-config.d.ts +0 -127
- package/dist/sandbox/egress-firewall-config.js +0 -434
- package/dist/sandbox/egress-firewall-config.js.map +0 -1
- package/dist/sandbox/images.d.ts +0 -23
- package/dist/sandbox/images.js +0 -55
- package/dist/sandbox/images.js.map +0 -1
- package/dist/sandbox/index.d.ts +0 -112
- package/dist/sandbox/index.js +0 -332
- package/dist/sandbox/index.js.map +0 -1
- package/dist/sandbox/sandbox.d.ts +0 -214
- package/dist/sandbox/sandbox.js +0 -453
- package/dist/sandbox/sandbox.js.map +0 -1
- package/dist/sandbox/smol.d.ts +0 -162
- package/dist/sandbox/smol.js +0 -485
- package/dist/sandbox/smol.js.map +0 -1
- package/dist/session-log.d.ts +0 -63
- package/dist/session-log.js +0 -290
- package/dist/session-log.js.map +0 -1
- package/dist/state/approval-store.d.ts +0 -88
- package/dist/state/approval-store.js +0 -149
- package/dist/state/approval-store.js.map +0 -1
- package/dist/state/build-assets.d.ts +0 -50
- package/dist/state/build-assets.js +0 -154
- package/dist/state/build-assets.js.map +0 -1
- package/dist/state/db.d.ts +0 -81
- package/dist/state/db.js +0 -155
- package/dist/state/db.js.map +0 -1
- package/dist/state/execution-store.d.ts +0 -257
- package/dist/state/execution-store.js +0 -527
- package/dist/state/execution-store.js.map +0 -1
- package/dist/state/migrate.d.ts +0 -15
- package/dist/state/migrate.js +0 -175
- package/dist/state/migrate.js.map +0 -1
- package/dist/state/workflow-run-store.d.ts +0 -216
- package/dist/state/workflow-run-store.js +0 -403
- package/dist/state/workflow-run-store.js.map +0 -1
- package/dist/telemetry/index.d.ts +0 -38
- package/dist/telemetry/index.js +0 -253
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/pi-events.d.ts +0 -12
- package/dist/telemetry/pi-events.js +0 -134
- package/dist/telemetry/pi-events.js.map +0 -1
- package/dist/workflows/dag.d.ts +0 -37
- package/dist/workflows/dag.js +0 -118
- package/dist/workflows/dag.js.map +0 -1
- package/dist/workflows/loader.d.ts +0 -53
- package/dist/workflows/loader.js +0 -421
- package/dist/workflows/loader.js.map +0 -1
- package/dist/workflows/loop-eval.d.ts +0 -28
- package/dist/workflows/loop-eval.js +0 -74
- package/dist/workflows/loop-eval.js.map +0 -1
- package/dist/workflows/phase-executor.d.ts +0 -222
- package/dist/workflows/phase-executor.js +0 -1153
- package/dist/workflows/phase-executor.js.map +0 -1
- package/dist/workflows/phase-ref.d.ts +0 -50
- package/dist/workflows/phase-ref.js +0 -91
- package/dist/workflows/phase-ref.js.map +0 -1
- package/dist/workflows/resume.d.ts +0 -58
- package/dist/workflows/resume.js +0 -313
- package/dist/workflows/resume.js.map +0 -1
- package/dist/workflows/runner.d.ts +0 -63
- package/dist/workflows/runner.js +0 -381
- package/dist/workflows/runner.js.map +0 -1
- package/dist/workflows/schema.d.ts +0 -344
- package/dist/workflows/schema.js +0 -460
- package/dist/workflows/schema.js.map +0 -1
- package/dist/workflows/simple.d.ts +0 -90
- package/dist/workflows/simple.js +0 -393
- package/dist/workflows/simple.js.map +0 -1
- package/dist/workflows/target-policy.d.ts +0 -74
- package/dist/workflows/target-policy.js +0 -80
- package/dist/workflows/target-policy.js.map +0 -1
- package/dist/workflows/templates.d.ts +0 -88
- package/dist/workflows/templates.js +0 -127
- package/dist/workflows/templates.js.map +0 -1
- package/dist/workflows/triggers.d.ts +0 -21
- package/dist/workflows/triggers.js +0 -45
- package/dist/workflows/triggers.js.map +0 -1
- package/dist/workflows/verdict.d.ts +0 -19
- package/dist/workflows/verdict.js +0 -30
- package/dist/workflows/verdict.js.map +0 -1
- package/dist/worktree/manager.d.ts +0 -43
- package/dist/worktree/manager.js +0 -127
- package/dist/worktree/manager.js.map +0 -1
- package/docker-compose.yml +0 -274
- package/sandbox.Dockerfile +0 -68
- package/skills/README.md +0 -42
- package/skills/browser-qa/SKILL.md +0 -208
- package/skills/browser-qa/scripts/agent-browser.mjs +0 -531
- package/skills/building/SKILL.md +0 -95
- package/skills/chat/SKILL.md +0 -36
- package/skills/code-review/SKILL.md +0 -82
- package/skills/debug-production/SKILL.md +0 -108
- package/skills/demo/SKILL.md +0 -228
- package/skills/demo/scripts/compose-demo.sh +0 -243
- package/skills/issue-answer/SKILL.md +0 -91
- package/skills/issue-comment/SKILL.md +0 -49
- package/skills/issue-triage/SKILL.md +0 -149
- package/skills/issue-triage/references/AGENT-BRIEF.md +0 -65
- package/skills/pr-comment/SKILL.md +0 -64
- package/skills/pr-review/SKILL.md +0 -148
- package/skills/pr-review/references/findings-schema.md +0 -89
- package/skills/qa-test/SKILL.md +0 -97
- package/skills/repo-health/SKILL.md +0 -67
- package/skills/security-feedback/SKILL.md +0 -173
- package/skills/security-feedback/references/templates.md +0 -77
- package/skills/security-review/SKILL.md +0 -215
- package/skills/security-review/references/issue-format.md +0 -302
- package/skills/verify/SKILL.md +0 -118
- package/workflows/answer.yaml +0 -44
- package/workflows/build.yaml +0 -129
- package/workflows/cron-health.yaml +0 -6
- package/workflows/cron-review.yaml +0 -8
- package/workflows/cron-security.yaml +0 -6
- package/workflows/cron-triage.yaml +0 -8
- package/workflows/demo.yaml +0 -62
- package/workflows/examples/bash-smoke.yaml +0 -41
- package/workflows/examples/parallel-review.yaml +0 -36
- package/workflows/examples/tdd-loop.yaml +0 -17
- package/workflows/explore.yaml +0 -80
- package/workflows/issue-comment.yaml +0 -15
- package/workflows/issue-triage.yaml +0 -22
- package/workflows/pr-comment.yaml +0 -16
- package/workflows/pr-fix.yaml +0 -17
- package/workflows/pr-review.yaml +0 -50
- package/workflows/prompts/answer.md +0 -68
- package/workflows/prompts/architect.md +0 -44
- package/workflows/prompts/classifier.md +0 -60
- package/workflows/prompts/classify-adds-info.md +0 -17
- package/workflows/prompts/demo.md +0 -125
- package/workflows/prompts/executor.md +0 -42
- package/workflows/prompts/explore-ask.md +0 -99
- package/workflows/prompts/explore-publish.md +0 -31
- package/workflows/prompts/explore-read.md +0 -120
- package/workflows/prompts/explore-synthesize.md +0 -88
- package/workflows/prompts/fix.md +0 -18
- package/workflows/prompts/guardrails.md +0 -96
- package/workflows/prompts/pr-fix.md +0 -26
- package/workflows/prompts/pr.md +0 -39
- package/workflows/prompts/qa-browser.md +0 -95
- package/workflows/prompts/qa-synth.md +0 -44
- package/workflows/prompts/qa-test.md +0 -60
- package/workflows/prompts/re-reviewer.md +0 -33
- package/workflows/prompts/reviewer.md +0 -60
- package/workflows/prompts/verify-browser.md +0 -93
- package/workflows/prompts/verify-synth.md +0 -44
- package/workflows/prompts/verify.md +0 -63
- package/workflows/qa-test.yaml +0 -94
- package/workflows/repo-health.yaml +0 -15
- package/workflows/security-feedback.yaml +0 -25
- package/workflows/security-review.yaml +0 -37
- package/workflows/verify.yaml +0 -93
- /package/dist/{cli/cli-config.d.ts → cli-config.d.ts} +0 -0
- /package/dist/{cli/cli-config.js → cli-config.js} +0 -0
- /package/dist/{cli/cli-format.d.ts → cli-format.d.ts} +0 -0
- /package/dist/{cli/cli-format.js → cli-format.js} +0 -0
- /package/dist/{cli/cli-timeline.d.ts → cli-timeline.d.ts} +0 -0
- /package/dist/{cli/cli-timeline.js → cli-timeline.js} +0 -0
- /package/dist/{cli/cli.d.ts → cli.d.ts} +0 -0
- /package/dist/{cli/oauth-cli.d.ts → oauth-cli.d.ts} +0 -0
- /package/dist/{cli/setup.d.ts → setup.d.ts} +0 -0
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type ExecutorConfig, type ExecutionResult, type GitSandboxAccess } from "./github/profiles.js";
|
|
2
|
-
import type { SandboxFactory } from "../sandbox/sandbox.js";
|
|
3
|
-
import { type CommandSpec } from "./executors/orchestrator.js";
|
|
4
|
-
export { RunResultAccumulator, stageSkillBundle, excludeFromGit, detectAccountError } from "./executors/shared.js";
|
|
5
|
-
export type { CommandSpec } from "./executors/orchestrator.js";
|
|
6
|
-
export declare function executeAgent(prompt: string, config: ExecutorConfig, opts?: {
|
|
7
|
-
taskId?: string;
|
|
8
|
-
/**
|
|
9
|
-
* Fired as soon as the run gets a session id. Used to persist the id
|
|
10
|
-
* onto the in-flight executions row so the dashboard can deep-link
|
|
11
|
-
* the running phase to its live JSONL.
|
|
12
|
-
*/
|
|
13
|
-
onSessionId?: (sessionId: string) => void;
|
|
14
|
-
githubAccess?: GitSandboxAccess;
|
|
15
|
-
/** Test seam — substitute a FakeSandbox. Defaults to the real factory. */
|
|
16
|
-
sandboxFactory?: SandboxFactory;
|
|
17
|
-
}): Promise<ExecutionResult>;
|
|
18
|
-
export declare function executeCommand(spec: CommandSpec, config: ExecutorConfig, opts?: {
|
|
19
|
-
taskId?: string;
|
|
20
|
-
githubAccess?: GitSandboxAccess;
|
|
21
|
-
/** Per-step timeout in seconds. */
|
|
22
|
-
timeoutSeconds?: number;
|
|
23
|
-
/** Extra env forwarded into the command (e.g. upstream phase outputs). */
|
|
24
|
-
sandboxEnv?: Record<string, string>;
|
|
25
|
-
onSessionId?: (sessionId: string) => void;
|
|
26
|
-
/**
|
|
27
|
-
* Mirror the command output to a session jsonl (visible in the dashboard +
|
|
28
|
-
* CLI). Default true. Set false for internal checks like `until_bash` that
|
|
29
|
-
* shouldn't create a user-facing session log.
|
|
30
|
-
*/
|
|
31
|
-
writeSession?: boolean;
|
|
32
|
-
/** Test seam — substitute a FakeSandbox. Defaults to the real factory. */
|
|
33
|
-
sandboxFactory?: SandboxFactory;
|
|
34
|
-
}): Promise<ExecutionResult>;
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { resolve } from "path";
|
|
2
|
-
import { randomUUID } from "crypto";
|
|
3
|
-
import { refreshGitAuth } from "./github/git-auth.js";
|
|
4
|
-
import { GITHUB_PERMISSION_PROFILES, } from "./github/profiles.js";
|
|
5
|
-
import { getDockerSandboxOtelEnv, getOtelEnvForSandbox, safeSpanAttributes, withSpan } from "../telemetry/index.js";
|
|
6
|
-
import { DEFAULT_MODEL } from "./executors/shared.js";
|
|
7
|
-
import { PROVIDER_ENV_KEYS } from "../providers.js";
|
|
8
|
-
import { oauthEnvVarForProvider, oauthProviderIdForModel, resolveOAuthApiKey } from "./oauth.js";
|
|
9
|
-
import { runSandboxedAgent, runSandboxedCommand, } from "./executors/orchestrator.js";
|
|
10
|
-
// Re-exported for back-compat with existing importers (tests, dashboards,
|
|
11
|
-
// workflow phase executor).
|
|
12
|
-
export { RunResultAccumulator, stageSkillBundle, excludeFromGit, detectAccountError } from "./executors/shared.js";
|
|
13
|
-
/**
|
|
14
|
-
* Shared run preparation for {@link executeAgent} and {@link executeCommand}:
|
|
15
|
-
* resolve the taskId / state dir / backend, mint the scoped GitHub token,
|
|
16
|
-
* assemble the sandbox env (git token, provider keys, OTEL), and compute the
|
|
17
|
-
* pre-populate descriptor. Both the agent and the deterministic command paths
|
|
18
|
-
* run in the same sandbox/workspace with the same git access, so they share
|
|
19
|
-
* this setup verbatim.
|
|
20
|
-
*/
|
|
21
|
-
async function prepareRun(config, opts) {
|
|
22
|
-
const taskId = opts?.taskId || `task-${randomUUID().slice(0, 8)}`;
|
|
23
|
-
const stateDir = config.stateDir || resolve("data");
|
|
24
|
-
const backend = config.sandbox ?? "gondolin";
|
|
25
|
-
// Mint a scoped GitHub App token. Same flow as the legacy executor —
|
|
26
|
-
// defense in depth so a downstream tool gating regression can't burn
|
|
27
|
-
// more access than the profile allowed.
|
|
28
|
-
//
|
|
29
|
-
// GITHUB_APP_* env vars are forwarded to agentic-pi *only* when the access
|
|
30
|
-
// profile opts into App PEM access via `allowMcpAppAuth`. That is currently
|
|
31
|
-
// never set (see gitSandboxAccessForWorkflow): the github extension can't
|
|
32
|
-
// read the PEM in the sandbox and skips rather than falling back, so we keep
|
|
33
|
-
// the App key out entirely and every run uses just the minted `GITHUB_TOKEN`
|
|
34
|
-
// below — which also stops agents minting elevated tokens themselves. The
|
|
35
|
-
// branch is retained so per-profile App auth can be re-enabled if the
|
|
36
|
-
// sandbox-side PEM is ever materialized.
|
|
37
|
-
const ghEnv = {};
|
|
38
|
-
let mintedToken;
|
|
39
|
-
const access = opts?.githubAccess;
|
|
40
|
-
const allowAppAuth = access?.allowMcpAppAuth === true;
|
|
41
|
-
if (process.env.GITHUB_APP_ID && allowAppAuth) {
|
|
42
|
-
ghEnv.GITHUB_APP_ID = process.env.GITHUB_APP_ID;
|
|
43
|
-
if (process.env.GITHUB_APP_INSTALLATION_ID) {
|
|
44
|
-
ghEnv.GITHUB_APP_INSTALLATION_ID = process.env.GITHUB_APP_INSTALLATION_ID;
|
|
45
|
-
}
|
|
46
|
-
if (process.env.GITHUB_APP_PRIVATE_KEY_PATH) {
|
|
47
|
-
ghEnv.GITHUB_APP_PRIVATE_KEY_PATH = process.env.GITHUB_APP_PRIVATE_KEY_PATH;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
// Suppress for in-process runs that inherit our env. Empty strings
|
|
52
|
-
// override the inherited value via `applyEnv()`.
|
|
53
|
-
ghEnv.GITHUB_APP_ID = "";
|
|
54
|
-
ghEnv.GITHUB_APP_INSTALLATION_ID = "";
|
|
55
|
-
ghEnv.GITHUB_APP_PRIVATE_KEY_PATH = "";
|
|
56
|
-
}
|
|
57
|
-
if (process.env.GITHUB_APP_ID && access) {
|
|
58
|
-
try {
|
|
59
|
-
const permissions = GITHUB_PERMISSION_PROFILES[access.profile];
|
|
60
|
-
const repositories = access.repo ? [access.repo] : undefined;
|
|
61
|
-
console.log(`[executor] Minting git token: profile=${access.profile}, ` +
|
|
62
|
-
`repo=${access.repo || "(unscoped)"}, permissions=${permissions ? Object.keys(permissions).join(",") : "all"}`);
|
|
63
|
-
const { token } = await refreshGitAuth({
|
|
64
|
-
appId: process.env.GITHUB_APP_ID,
|
|
65
|
-
privateKeyPath: process.env.GITHUB_APP_PRIVATE_KEY_PATH || "",
|
|
66
|
-
installationId: process.env.GITHUB_APP_INSTALLATION_ID || "",
|
|
67
|
-
permissions,
|
|
68
|
-
repositories,
|
|
69
|
-
});
|
|
70
|
-
mintedToken = token;
|
|
71
|
-
ghEnv.GITHUB_TOKEN = token;
|
|
72
|
-
ghEnv.GIT_TOKEN = token;
|
|
73
|
-
}
|
|
74
|
-
catch (err) {
|
|
75
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
76
|
-
console.warn(`[executor] Could not mint git token (repo=${access.repo || "none"}, ` +
|
|
77
|
-
`profile=${access.profile}): ${msg}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else if (process.env.GITHUB_TOKEN && access) {
|
|
81
|
-
// PAT fallback: no GitHub App, but a static Personal Access Token is set.
|
|
82
|
-
// Forward it directly — a PAT can't be per-run downscoped like an App
|
|
83
|
-
// installation token, so it carries whatever scopes GitHub granted. A
|
|
84
|
-
// read-only fine-grained PAT is the safe default; warn on repo-write
|
|
85
|
-
// profiles so an operator running build/pr-fix under a PAT knows the
|
|
86
|
-
// requested downscope isn't being applied.
|
|
87
|
-
if (GITHUB_PERMISSION_PROFILES[access.profile]?.contents === "write") {
|
|
88
|
-
console.warn(`[executor] Using a static GITHUB_TOKEN for a repo-write workflow ` +
|
|
89
|
-
`(profile=${access.profile}, repo=${access.repo || "none"}) — the PAT's ` +
|
|
90
|
-
`own scopes apply (no per-run downscoping).`);
|
|
91
|
-
}
|
|
92
|
-
mintedToken = process.env.GITHUB_TOKEN;
|
|
93
|
-
ghEnv.GITHUB_TOKEN = process.env.GITHUB_TOKEN;
|
|
94
|
-
ghEnv.GIT_TOKEN = process.env.GITHUB_TOKEN;
|
|
95
|
-
}
|
|
96
|
-
// Provider API keys. Forwarded in registry order — see `src/providers.ts`
|
|
97
|
-
// (the single source of truth for wizard-able providers). Every entry a
|
|
98
|
-
// user can pick in the setup wizard is reachable from the sandbox because
|
|
99
|
-
// the egress firewall list is also derived from the same registry's hosts.
|
|
100
|
-
for (const envKey of PROVIDER_ENV_KEYS) {
|
|
101
|
-
const v = process.env[envKey];
|
|
102
|
-
if (v)
|
|
103
|
-
ghEnv[envKey] = v;
|
|
104
|
-
}
|
|
105
|
-
// OAuth-backed providers (subscription logins: Codex / Claude Pro / Copilot).
|
|
106
|
-
//
|
|
107
|
-
// In-process backends (none/gondolin) run the model call host-side, so the
|
|
108
|
-
// orchestrator hands agentic-pi `authFile` = our credential store and Pi's
|
|
109
|
-
// AuthStorage resolves EVERY OAuth provider (Codex included) from it. Nothing
|
|
110
|
-
// to do here for those backends.
|
|
111
|
-
//
|
|
112
|
-
// Container backends (docker/smol) run the model call inside the guest, where
|
|
113
|
-
// that host path can't be read — so we inject the refreshed token via the env
|
|
114
|
-
// var pi reads in-guest (ANTHROPIC_OAUTH_TOKEN / COPILOT_GITHUB_TOKEN). Codex
|
|
115
|
-
// has no in-guest env route (chatgpt.com backend), so it can't authenticate
|
|
116
|
-
// there — warn rather than 401 mid-run, and point at a host-side backend.
|
|
117
|
-
const inProcessBackend = backend === "none" || backend === "gondolin";
|
|
118
|
-
const modelSpec = config.model || DEFAULT_MODEL;
|
|
119
|
-
const oauthId = oauthProviderIdForModel(modelSpec);
|
|
120
|
-
if (oauthId && !inProcessBackend) {
|
|
121
|
-
const oauthEnvVar = oauthEnvVarForProvider(oauthId);
|
|
122
|
-
if (!oauthEnvVar) {
|
|
123
|
-
console.warn(`[executor] Model '${modelSpec}' uses OAuth provider '${oauthId}', which has no ` +
|
|
124
|
-
`in-guest env route — the '${backend}' sandbox can't authenticate it. Use the ` +
|
|
125
|
-
`gondolin/none backend (host-side auth via the credential store) or an API-key provider.`);
|
|
126
|
-
}
|
|
127
|
-
else if (!ghEnv[oauthEnvVar] && !process.env[oauthEnvVar]) {
|
|
128
|
-
// Only mint from stored creds when an explicit token isn't already set.
|
|
129
|
-
try {
|
|
130
|
-
const res = await resolveOAuthApiKey(oauthId, undefined, stateDir);
|
|
131
|
-
if (res) {
|
|
132
|
-
ghEnv[oauthEnvVar] = res.apiKey;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
console.warn(`[executor] Model '${modelSpec}' needs an OAuth login for '${oauthId}' but none is ` +
|
|
136
|
-
`stored. Run: lastlight oauth login ${oauthId}`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
catch (err) {
|
|
140
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
141
|
-
console.warn(`[executor] OAuth token refresh failed for '${oauthId}': ${msg}`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
// Web-search provider keys. Forwarded only when the workflow opted into
|
|
146
|
-
// web search (scoped to explore today; see webSearchEnabledForWorkflow
|
|
147
|
-
// in workflows/runner.ts). agentic-pi auto-detects the provider from
|
|
148
|
-
// whichever key is present (Tavily > Exa > Brave by default).
|
|
149
|
-
if (config.webSearch) {
|
|
150
|
-
if (process.env.TAVILY_API_KEY)
|
|
151
|
-
ghEnv.TAVILY_API_KEY = process.env.TAVILY_API_KEY;
|
|
152
|
-
if (process.env.BRAVE_SEARCH_API_KEY)
|
|
153
|
-
ghEnv.BRAVE_SEARCH_API_KEY = process.env.BRAVE_SEARCH_API_KEY;
|
|
154
|
-
if (process.env.EXA_API_KEY)
|
|
155
|
-
ghEnv.EXA_API_KEY = process.env.EXA_API_KEY;
|
|
156
|
-
}
|
|
157
|
-
// OTEL config for the agent runtime itself. On docker the agent runs
|
|
158
|
-
// inside the container, so it reads this (the container env) and is
|
|
159
|
-
// pointed at the in-network collector — never the real backend or its
|
|
160
|
-
// auth headers. On gondolin/none the agent runs in the harness process
|
|
161
|
-
// and inherits the harness SDK; forwarding the host's OTEL_* here just
|
|
162
|
-
// re-affirms that config for any child processes.
|
|
163
|
-
if (config.otel?.enabled && config.otel.forwardToSandbox) {
|
|
164
|
-
Object.assign(ghEnv, backend === "docker" ? getDockerSandboxOtelEnv() : getOtelEnvForSandbox());
|
|
165
|
-
}
|
|
166
|
-
const prePopulate = access?.prePopulateBranch && mintedToken
|
|
167
|
-
? {
|
|
168
|
-
owner: access.owner,
|
|
169
|
-
repo: access.repo,
|
|
170
|
-
branch: access.prePopulateBranch,
|
|
171
|
-
token: mintedToken,
|
|
172
|
-
runId: access.runId,
|
|
173
|
-
shallow: access.shallow,
|
|
174
|
-
recreateFromBase: access.recreateFromBase,
|
|
175
|
-
}
|
|
176
|
-
: undefined;
|
|
177
|
-
return { taskId, stateDir, backend, ghEnv, mintedToken, prePopulate };
|
|
178
|
-
}
|
|
179
|
-
export async function executeAgent(prompt, config, opts) {
|
|
180
|
-
const { taskId, stateDir, backend, ghEnv, prePopulate } = await prepareRun(config, opts);
|
|
181
|
-
const access = opts?.githubAccess;
|
|
182
|
-
const spanAttrs = safeSpanAttributes({
|
|
183
|
-
"agent.runtime": "agentic-pi",
|
|
184
|
-
"sandbox.backend": backend,
|
|
185
|
-
"task.id": taskId,
|
|
186
|
-
repo: access?.repo,
|
|
187
|
-
"github.profile": access?.profile,
|
|
188
|
-
model: config.model || DEFAULT_MODEL,
|
|
189
|
-
variant: config.variant,
|
|
190
|
-
"web_search.enabled": config.webSearch === true,
|
|
191
|
-
unrestricted_egress: config.unrestrictedEgress === true,
|
|
192
|
-
"workflow.name": config.telemetry?.workflowName,
|
|
193
|
-
"phase.name": config.telemetry?.phaseName,
|
|
194
|
-
});
|
|
195
|
-
const ctx = {
|
|
196
|
-
config,
|
|
197
|
-
taskId,
|
|
198
|
-
stateDir,
|
|
199
|
-
backend,
|
|
200
|
-
env: ghEnv,
|
|
201
|
-
prePopulate,
|
|
202
|
-
access,
|
|
203
|
-
onSessionId: opts?.onSessionId,
|
|
204
|
-
sandboxFactory: opts?.sandboxFactory,
|
|
205
|
-
};
|
|
206
|
-
return withSpan("lastlight.agent.execute", spanAttrs, () => runSandboxedAgent(prompt, ctx));
|
|
207
|
-
}
|
|
208
|
-
// ── Deterministic command path (type: bash / type: script) ───────────
|
|
209
|
-
//
|
|
210
|
-
// Runs a deterministic shell command (or inline script) inside the SAME
|
|
211
|
-
// sandbox/workspace an agent phase would use — no LLM. The command's output is
|
|
212
|
-
// mirrored to a Claude-SDK-style session jsonl via the AgenticShim (the same
|
|
213
|
-
// shim agent phases use), so a bash/script phase shows up in the admin console
|
|
214
|
-
// and `lastlight session log` exactly like an agent turn: the command renders
|
|
215
|
-
// as a `bash` tool_use and its stdout/stderr as the tool_result.
|
|
216
|
-
export async function executeCommand(spec, config, opts) {
|
|
217
|
-
const { taskId, stateDir, backend, ghEnv, prePopulate } = await prepareRun(config, opts);
|
|
218
|
-
const access = opts?.githubAccess;
|
|
219
|
-
const spanAttrs = safeSpanAttributes({
|
|
220
|
-
"agent.runtime": spec.kind,
|
|
221
|
-
"sandbox.backend": backend,
|
|
222
|
-
"task.id": taskId,
|
|
223
|
-
repo: access?.repo,
|
|
224
|
-
"github.profile": access?.profile,
|
|
225
|
-
unrestricted_egress: config.unrestrictedEgress === true,
|
|
226
|
-
"workflow.name": config.telemetry?.workflowName,
|
|
227
|
-
"phase.name": config.telemetry?.phaseName,
|
|
228
|
-
});
|
|
229
|
-
const ctx = {
|
|
230
|
-
config,
|
|
231
|
-
taskId,
|
|
232
|
-
stateDir,
|
|
233
|
-
backend,
|
|
234
|
-
env: ghEnv,
|
|
235
|
-
prePopulate,
|
|
236
|
-
access,
|
|
237
|
-
onSessionId: opts?.onSessionId,
|
|
238
|
-
sandboxFactory: opts?.sandboxFactory,
|
|
239
|
-
};
|
|
240
|
-
return withSpan("lastlight.command.execute", spanAttrs, () => runSandboxedCommand(spec, ctx, {
|
|
241
|
-
timeoutSeconds: opts?.timeoutSeconds,
|
|
242
|
-
sandboxEnv: opts?.sandboxEnv,
|
|
243
|
-
writeSession: opts?.writeSession,
|
|
244
|
-
}));
|
|
245
|
-
}
|
|
246
|
-
//# sourceMappingURL=agent-executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-executor.js","sourceRoot":"","sources":["../../src/engine/agent-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EA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AAI,EAAE,cAAc;KACrC,CAAC;IACF,OAAO,QAAQ,CAAC,2BAA2B,EAAE,SAAS,EAAE,GAAG,EAAE,CAC3D,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE;QAC7B,cAAc,EAAE,IAAI,EAAE,cAAc;QACpC,UAAU,EAAE,IAAI,EAAE,UAAU;QAC5B,YAAY,EAAE,IAAI,EAAE,YAAY;KACjC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { type AssistantMessage, type Context, type Model, type Api, type SimpleStreamOptions, type Tool, type ToolCall, type ToolResultMessage } from "@earendil-works/pi-ai";
|
|
2
|
-
import type { SessionManager } from "../../connectors/messaging/session-manager.js";
|
|
3
|
-
import { type ChatGitHubAuth } from "../github/github-tools.js";
|
|
4
|
-
/**
|
|
5
|
-
* Match transient, retryable model errors. Deliberately conservative: auth /
|
|
6
|
-
* validation / context-overflow / other 4xx (anything but 429) are NOT
|
|
7
|
-
* retried — only rate limits, server errors, and transient network faults.
|
|
8
|
-
*/
|
|
9
|
-
export declare function isRetryableModelError(message: string): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Call `complete`, retrying transient failures with exponential backoff.
|
|
12
|
-
* Handles both shapes pi-ai surfaces a failure as: a thrown error, and a
|
|
13
|
-
* returned AssistantMessage with `stopReason === "error"`. Non-retryable
|
|
14
|
-
* outcomes (and the final attempt) are returned/thrown unchanged so the
|
|
15
|
-
* caller's existing error handling still applies. Dependency-injected for
|
|
16
|
-
* testing (`delaysMs` / `sleepFn` / `onRetry`).
|
|
17
|
-
*/
|
|
18
|
-
export declare function completeWithRetry(complete: (m: Model<Api>, c: Context, o: SimpleStreamOptions) => Promise<AssistantMessage>, model: Model<Api>, context: Context, opts: SimpleStreamOptions, deps?: {
|
|
19
|
-
delaysMs?: number[];
|
|
20
|
-
sleepFn?: (ms: number) => Promise<void>;
|
|
21
|
-
onRetry?: (info: {
|
|
22
|
-
attempt: number;
|
|
23
|
-
delayMs: number;
|
|
24
|
-
reason: string;
|
|
25
|
-
}) => void;
|
|
26
|
-
}): Promise<AssistantMessage>;
|
|
27
|
-
/**
|
|
28
|
-
* Optional extra toolset merged into the chat agent's tool list
|
|
29
|
-
* alongside the github tools. Used to register the `read_skill` tool
|
|
30
|
-
* that exposes the curated chat skill catalogue.
|
|
31
|
-
*/
|
|
32
|
-
export interface ChatExtraToolset {
|
|
33
|
-
tools: Tool[];
|
|
34
|
-
execute(call: ToolCall): {
|
|
35
|
-
content: string;
|
|
36
|
-
isError: boolean;
|
|
37
|
-
} | Promise<{
|
|
38
|
-
content: string;
|
|
39
|
-
isError: boolean;
|
|
40
|
-
}>;
|
|
41
|
-
}
|
|
42
|
-
export interface ChatRunnerConfig {
|
|
43
|
-
/** Default model (pi-ai provider/id). */
|
|
44
|
-
model: string;
|
|
45
|
-
/** Pi thinking level (off..xhigh). Forwarded as `reasoning` option. */
|
|
46
|
-
thinking?: string;
|
|
47
|
-
/** Agent persona / system prompt — composed by index.ts from agent-context + CHAT_SYSTEM_SUFFIX. */
|
|
48
|
-
systemPrompt: string;
|
|
49
|
-
/** Optional GitHub App credentials. When set, read-only github tools are registered. */
|
|
50
|
-
github?: ChatGitHubAuth;
|
|
51
|
-
/**
|
|
52
|
-
* Optional extra tools (e.g. `read_skill`) registered in addition to
|
|
53
|
-
* the github toolset. Both tool lists are concatenated; per-call
|
|
54
|
-
* dispatch tries github first, then this set.
|
|
55
|
-
*/
|
|
56
|
-
extraTools?: ChatExtraToolset;
|
|
57
|
-
/** Per-turn timeout (ms). Default: 120s. */
|
|
58
|
-
timeoutMs?: number;
|
|
59
|
-
}
|
|
60
|
-
export interface ChatRunnerTurnResult {
|
|
61
|
-
/** Final assistant text. */
|
|
62
|
-
text: string;
|
|
63
|
-
/** UUID that pins this Slack thread to its on-disk JSONL. Same across all turns in one thread. */
|
|
64
|
-
agentSessionId: string;
|
|
65
|
-
/** Token + cost stats from the final assistant message. */
|
|
66
|
-
tokens: {
|
|
67
|
-
input: number;
|
|
68
|
-
output: number;
|
|
69
|
-
cacheRead: number;
|
|
70
|
-
cacheWrite: number;
|
|
71
|
-
};
|
|
72
|
-
costUsd: number;
|
|
73
|
-
/** Number of round-trips to the model in this turn (1 + tool rounds). */
|
|
74
|
-
modelTurns: number;
|
|
75
|
-
/** "stop" on a clean finish, "tool-error" / "error" / "max-rounds" otherwise. */
|
|
76
|
-
finish: string;
|
|
77
|
-
/** Errors that occurred during the turn. Empty when finish === "stop". */
|
|
78
|
-
errors: string[];
|
|
79
|
-
/** Concatenated assistant content from every model turn — for the dashboard shim. */
|
|
80
|
-
assistantMessages: AssistantMessage[];
|
|
81
|
-
/** Tool results emitted during the turn — for the dashboard shim. */
|
|
82
|
-
toolResults: ToolResultMessage[];
|
|
83
|
-
/** Resolved model id (pi-ai format). */
|
|
84
|
-
modelId: string;
|
|
85
|
-
}
|
|
86
|
-
export declare class ChatRunner {
|
|
87
|
-
private cfg;
|
|
88
|
-
private sessionManager;
|
|
89
|
-
private tools;
|
|
90
|
-
private extraTools;
|
|
91
|
-
/** Concatenated tool list passed to pi-ai (github + extra). */
|
|
92
|
-
private mergedTools;
|
|
93
|
-
/**
|
|
94
|
-
* Resolved lazily on the first chat turn. A bad chat model spec
|
|
95
|
-
* (unknown id) MUST NOT crash the whole harness — webhooks, crons and
|
|
96
|
-
* workflows don't depend on it.
|
|
97
|
-
*/
|
|
98
|
-
private model;
|
|
99
|
-
private modelError;
|
|
100
|
-
private chains;
|
|
101
|
-
/**
|
|
102
|
-
* OAuth provider id backing the chat model (e.g. `openai-codex` for a
|
|
103
|
-
* `openai-codex/gpt-5.4` spec), or undefined for API-key providers. When
|
|
104
|
-
* set, each turn resolves a fresh subscription token instead of relying on
|
|
105
|
-
* a provider env var. Derived once from `cfg.model`.
|
|
106
|
-
*/
|
|
107
|
-
private oauthProviderId;
|
|
108
|
-
constructor(cfg: ChatRunnerConfig, sessionManager: SessionManager);
|
|
109
|
-
/**
|
|
110
|
-
* Dispatch a tool call to whichever toolset registered it. Github
|
|
111
|
-
* tools take precedence (they're registered first); fall back to the
|
|
112
|
-
* extra toolset for anything not in the github name set.
|
|
113
|
-
*/
|
|
114
|
-
private dispatchTool;
|
|
115
|
-
/** Build a failed-turn result carrying a single actionable error message. */
|
|
116
|
-
private errorTurn;
|
|
117
|
-
private resolveModelLazy;
|
|
118
|
-
/**
|
|
119
|
-
* Run one chat turn. Each messagingSessionId maps to a stable pi-ai
|
|
120
|
-
* `agentSessionId` (a UUID we mint on first turn) which the dashboard
|
|
121
|
-
* uses to look up the JSONL on disk.
|
|
122
|
-
*/
|
|
123
|
-
turn(messagingSessionId: string, prompt: string): Promise<ChatRunnerTurnResult>;
|
|
124
|
-
private doTurn;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Octokit is bundled here only because github-tools.ts imports it at module
|
|
128
|
-
* load. Re-export so callers can probe whether the integration is wired
|
|
129
|
-
* without round-tripping through that file. Typed as `unknown` to avoid
|
|
130
|
-
* dragging the Octokit type chain into the published .d.ts.
|
|
131
|
-
*/
|
|
132
|
-
export declare const __octokitForTest: unknown;
|