@treeseed/core 0.3.0 → 0.4.0
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 +26 -3
- package/dist/config.js +1 -1
- package/dist/content-config.js +1 -1
- package/dist/content.js +3 -3
- package/dist/index.js +1 -68
- package/dist/scripts/aggregate-book.js +1 -1
- package/dist/scripts/build-dist.js +3 -14
- package/dist/scripts/build-tenant-worker.js +2 -2
- package/dist/scripts/run-fixture-astro-command.js +219 -0
- package/dist/site-resources.d.ts +2 -2
- package/dist/site.js +3 -3
- package/dist/tenant/bridge.js +1 -1
- package/dist/tenant/runtime-config.js +1 -1
- package/dist/utils/forms/config.js +5 -1
- package/dist/utils/forms/provider-runtime.js +42 -0
- package/dist/utils/forms/service.js +2 -2
- package/dist/utils/starlight-nav.js +6 -1
- package/package.json +5 -37
- package/dist/agents/index.js +0 -5
- package/dist/agents/registry-helper.js +0 -14
- package/dist/agents/registry.js +0 -88
- package/dist/contracts.d.ts +0 -1
- package/dist/contracts.js +0 -0
- package/dist/deploy/config.d.ts +0 -1
- package/dist/deploy/config.js +0 -10
- package/dist/deploy/runtime.js +0 -81
- package/dist/environment.d.ts +0 -2
- package/dist/environment.js +0 -26
- package/dist/plugin-default.js +0 -4
- package/dist/plugins/builtin/default-plugin.js +0 -37
- package/dist/plugins/constants.d.ts +0 -1
- package/dist/plugins/constants.js +0 -10
- package/dist/plugins/plugin.d.ts +0 -2
- package/dist/plugins/plugin.js +0 -4
- package/dist/plugins/runtime.d.ts +0 -32
- package/dist/plugins/runtime.js +0 -138
- package/dist/tenant/config.js +0 -16
- package/dist/types/agents.d.ts +0 -1
- package/dist/types/agents.js +0 -1
- package/dist/utils/agents/adapters/execution.js +0 -90
- package/dist/utils/agents/adapters/mutations.js +0 -30
- package/dist/utils/agents/adapters/notification.js +0 -16
- package/dist/utils/agents/adapters/repository.js +0 -61
- package/dist/utils/agents/adapters/research.js +0 -25
- package/dist/utils/agents/adapters/verification.js +0 -62
- package/dist/utils/agents/cli-tools.js +0 -5
- package/dist/utils/agents/contracts/messages.d.ts +0 -88
- package/dist/utils/agents/contracts/messages.js +0 -138
- package/dist/utils/agents/contracts/run.d.ts +0 -20
- package/dist/utils/agents/contracts/run.js +0 -0
- package/dist/utils/agents/runtime-types.d.ts +0 -117
- package/dist/utils/agents/runtime-types.js +0 -4
- package/dist/utils/books-data.js +0 -14
- package/dist/utils/plugin-runtime.js +0 -158
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { promisify } from "node:util";
|
|
3
|
-
import { normalizeAgentCliOptions, buildCopilotAllowToolArgs } from "../cli-tools.js";
|
|
4
|
-
import { getTreeseedAgentProviderSelections } from "../../../deploy/runtime.js";
|
|
5
|
-
const execFileAsync = promisify(execFile);
|
|
6
|
-
class StubExecutionAdapter {
|
|
7
|
-
async runTask(input) {
|
|
8
|
-
return {
|
|
9
|
-
status: "completed",
|
|
10
|
-
summary: `Stubbed Copilot execution for ${input.runId}.`,
|
|
11
|
-
stdout: [
|
|
12
|
-
"# Planned Task",
|
|
13
|
-
"",
|
|
14
|
-
"1. Inspect the requested architecture context.",
|
|
15
|
-
"2. Produce a safe local change artifact.",
|
|
16
|
-
"3. Summarize the implementation intent.",
|
|
17
|
-
"",
|
|
18
|
-
`Prompt digest: ${input.prompt.slice(0, 240)}`
|
|
19
|
-
].join("\n"),
|
|
20
|
-
stderr: ""
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
class CopilotExecutionAdapter {
|
|
25
|
-
async runTask(input) {
|
|
26
|
-
const cli = normalizeAgentCliOptions(input.agent.cli);
|
|
27
|
-
const args = ["copilot", "-p", input.prompt];
|
|
28
|
-
if (cli.model) {
|
|
29
|
-
args.push("--model", cli.model);
|
|
30
|
-
}
|
|
31
|
-
args.push(...buildCopilotAllowToolArgs(cli.allowTools));
|
|
32
|
-
args.push(...cli.additionalArgs ?? []);
|
|
33
|
-
try {
|
|
34
|
-
const { stdout, stderr } = await execFileAsync("gh", args, {
|
|
35
|
-
cwd: process.cwd(),
|
|
36
|
-
env: process.env,
|
|
37
|
-
maxBuffer: 10 * 1024 * 1024
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
status: "completed",
|
|
41
|
-
summary: "Copilot task completed.",
|
|
42
|
-
stdout,
|
|
43
|
-
stderr
|
|
44
|
-
};
|
|
45
|
-
} catch (error) {
|
|
46
|
-
const stderr = error && typeof error === "object" && "stderr" in error ? String(error.stderr ?? "") : error instanceof Error ? error.message : String(error);
|
|
47
|
-
return {
|
|
48
|
-
status: "failed",
|
|
49
|
-
summary: "Copilot task failed.",
|
|
50
|
-
stdout: "",
|
|
51
|
-
stderr
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
class ManualExecutionAdapter {
|
|
57
|
-
async runTask(input) {
|
|
58
|
-
return {
|
|
59
|
-
status: "completed",
|
|
60
|
-
summary: `Manual execution mode is enabled for ${input.runId}.`,
|
|
61
|
-
stdout: [
|
|
62
|
-
"# Manual Execution Required",
|
|
63
|
-
"",
|
|
64
|
-
"This agent run is configured for manual execution.",
|
|
65
|
-
"Review the prompt below and complete the work outside the automated adapter.",
|
|
66
|
-
"",
|
|
67
|
-
input.prompt
|
|
68
|
-
].join("\n"),
|
|
69
|
-
stderr: ""
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function createExecutionAdapter() {
|
|
74
|
-
const configuredMode = String(
|
|
75
|
-
process.env.TREESEED_AGENT_EXECUTION_PROVIDER ?? getTreeseedAgentProviderSelections().execution
|
|
76
|
-
).toLowerCase();
|
|
77
|
-
if (configuredMode === "manual") {
|
|
78
|
-
return new ManualExecutionAdapter();
|
|
79
|
-
}
|
|
80
|
-
if (configuredMode !== "copilot") {
|
|
81
|
-
return new StubExecutionAdapter();
|
|
82
|
-
}
|
|
83
|
-
return new CopilotExecutionAdapter();
|
|
84
|
-
}
|
|
85
|
-
export {
|
|
86
|
-
CopilotExecutionAdapter,
|
|
87
|
-
ManualExecutionAdapter,
|
|
88
|
-
StubExecutionAdapter,
|
|
89
|
-
createExecutionAdapter
|
|
90
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { GitRuntime } from "@treeseed/sdk/git-runtime";
|
|
4
|
-
class LocalBranchMutationAdapter {
|
|
5
|
-
git;
|
|
6
|
-
constructor(repoRoot) {
|
|
7
|
-
this.git = new GitRuntime(
|
|
8
|
-
repoRoot,
|
|
9
|
-
process.env.TREESEED_AGENT_DISABLE_GIT === "true"
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
async writeArtifact(input) {
|
|
13
|
-
const branchName = `${input.agent.execution.branchPrefix}/${input.runId}`;
|
|
14
|
-
const worktreePath = await this.git.ensureWorktree(branchName);
|
|
15
|
-
const filePath = path.join(worktreePath, input.relativePath);
|
|
16
|
-
await mkdir(path.dirname(filePath), { recursive: true });
|
|
17
|
-
await writeFile(filePath, input.content, "utf8");
|
|
18
|
-
const git = await this.git.commitFileChange(filePath, branchName, input.commitMessage);
|
|
19
|
-
return {
|
|
20
|
-
branchName: git.branchName,
|
|
21
|
-
commitMessage: git.commitMessage,
|
|
22
|
-
worktreePath: git.worktreePath,
|
|
23
|
-
commitSha: git.commitSha,
|
|
24
|
-
changedPaths: git.changedPaths
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
LocalBranchMutationAdapter
|
|
30
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class StubNotificationAdapter {
|
|
2
|
-
async deliver(input) {
|
|
3
|
-
return {
|
|
4
|
-
status: input.recipients.length ? "completed" : "waiting",
|
|
5
|
-
summary: input.recipients.length ? `Prepared ${input.recipients.length} notification(s).` : "No recipients available for notification.",
|
|
6
|
-
deliveredCount: input.recipients.length
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function createNotificationAdapter() {
|
|
11
|
-
return new StubNotificationAdapter();
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
StubNotificationAdapter,
|
|
15
|
-
createNotificationAdapter
|
|
16
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { promisify } from "node:util";
|
|
3
|
-
import { getTreeseedAgentProviderSelections } from "../../../deploy/runtime.js";
|
|
4
|
-
const execFileAsync = promisify(execFile);
|
|
5
|
-
class StubRepositoryInspectionAdapter {
|
|
6
|
-
async inspectBranch(input) {
|
|
7
|
-
return {
|
|
8
|
-
branchName: input.branchName,
|
|
9
|
-
changedPaths: [],
|
|
10
|
-
commitSha: null,
|
|
11
|
-
summary: input.branchName ? `Stub repository inspection for ${input.branchName}.` : "No branch to inspect."
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
class GitRepositoryInspectionAdapter {
|
|
16
|
-
async inspectBranch(input) {
|
|
17
|
-
if (!input.branchName) {
|
|
18
|
-
return {
|
|
19
|
-
branchName: null,
|
|
20
|
-
changedPaths: [],
|
|
21
|
-
commitSha: null,
|
|
22
|
-
summary: "No branch to inspect."
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const { stdout: changedStdout } = await execFileAsync(
|
|
27
|
-
"git",
|
|
28
|
-
["diff", "--name-only", "HEAD~1..HEAD"],
|
|
29
|
-
{ cwd: input.repoRoot, env: process.env }
|
|
30
|
-
);
|
|
31
|
-
const { stdout: shaStdout } = await execFileAsync("git", ["rev-parse", "HEAD"], {
|
|
32
|
-
cwd: input.repoRoot,
|
|
33
|
-
env: process.env
|
|
34
|
-
});
|
|
35
|
-
const changedPaths = changedStdout.split("\n").map((entry) => entry.trim()).filter(Boolean);
|
|
36
|
-
return {
|
|
37
|
-
branchName: input.branchName,
|
|
38
|
-
changedPaths,
|
|
39
|
-
commitSha: shaStdout.trim() || null,
|
|
40
|
-
summary: `Inspected ${changedPaths.length} changed path(s) on ${input.branchName}.`
|
|
41
|
-
};
|
|
42
|
-
} catch {
|
|
43
|
-
return {
|
|
44
|
-
branchName: input.branchName,
|
|
45
|
-
changedPaths: [],
|
|
46
|
-
commitSha: null,
|
|
47
|
-
summary: `Unable to inspect branch ${input.branchName}.`
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function createRepositoryInspectionAdapter() {
|
|
53
|
-
return String(
|
|
54
|
-
process.env.TREESEED_AGENT_REPOSITORY_PROVIDER ?? getTreeseedAgentProviderSelections().repository
|
|
55
|
-
).toLowerCase() !== "git" ? new StubRepositoryInspectionAdapter() : new GitRepositoryInspectionAdapter();
|
|
56
|
-
}
|
|
57
|
-
export {
|
|
58
|
-
GitRepositoryInspectionAdapter,
|
|
59
|
-
StubRepositoryInspectionAdapter,
|
|
60
|
-
createRepositoryInspectionAdapter
|
|
61
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
class StubResearchAdapter {
|
|
2
|
-
async research(input) {
|
|
3
|
-
return {
|
|
4
|
-
status: "completed",
|
|
5
|
-
summary: `Research prepared for ${input.questionId}.`,
|
|
6
|
-
markdown: [
|
|
7
|
-
"# Research Summary",
|
|
8
|
-
"",
|
|
9
|
-
`Question: ${input.questionId}`,
|
|
10
|
-
`Reason: ${input.reason ?? "not provided"}`,
|
|
11
|
-
`Run: ${input.runId}`,
|
|
12
|
-
"",
|
|
13
|
-
"This is a stub research summary produced by the runtime adapter."
|
|
14
|
-
].join("\n"),
|
|
15
|
-
sources: []
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function createResearchAdapter() {
|
|
20
|
-
return new StubResearchAdapter();
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
StubResearchAdapter,
|
|
24
|
-
createResearchAdapter
|
|
25
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { promisify } from "node:util";
|
|
3
|
-
import { getTreeseedAgentProviderSelections } from "../../../deploy/runtime.js";
|
|
4
|
-
const execFileAsync = promisify(execFile);
|
|
5
|
-
class StubVerificationAdapter {
|
|
6
|
-
async runChecks(input) {
|
|
7
|
-
return {
|
|
8
|
-
status: "completed",
|
|
9
|
-
summary: input.commands.length ? `Stub verification completed for ${input.runId}.` : "No verification commands configured.",
|
|
10
|
-
stdout: input.commands.join("\n"),
|
|
11
|
-
stderr: ""
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
class LocalVerificationAdapter {
|
|
16
|
-
async runChecks(input) {
|
|
17
|
-
if (!input.commands.length) {
|
|
18
|
-
return {
|
|
19
|
-
status: "waiting",
|
|
20
|
-
summary: "No verification commands configured.",
|
|
21
|
-
stdout: "",
|
|
22
|
-
stderr: ""
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
const stdoutChunks = [];
|
|
26
|
-
const stderrChunks = [];
|
|
27
|
-
for (const command of input.commands) {
|
|
28
|
-
try {
|
|
29
|
-
const { stdout, stderr } = await execFileAsync("/bin/bash", ["-lc", command], {
|
|
30
|
-
env: process.env,
|
|
31
|
-
maxBuffer: 10 * 1024 * 1024
|
|
32
|
-
});
|
|
33
|
-
stdoutChunks.push(stdout);
|
|
34
|
-
stderrChunks.push(stderr);
|
|
35
|
-
} catch (error) {
|
|
36
|
-
return {
|
|
37
|
-
status: "failed",
|
|
38
|
-
summary: `Verification command failed: ${command}`,
|
|
39
|
-
stdout: stdoutChunks.join("\n"),
|
|
40
|
-
stderr: error && typeof error === "object" && "stderr" in error ? String(error.stderr ?? "") : String(error),
|
|
41
|
-
errorCategory: "execution_error"
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
status: "completed",
|
|
47
|
-
summary: `Verification completed for ${input.commands.length} command(s).`,
|
|
48
|
-
stdout: stdoutChunks.join("\n"),
|
|
49
|
-
stderr: stderrChunks.join("\n")
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function createVerificationAdapter() {
|
|
54
|
-
return String(
|
|
55
|
-
process.env.TREESEED_AGENT_VERIFICATION_PROVIDER ?? getTreeseedAgentProviderSelections().verification
|
|
56
|
-
).toLowerCase() !== "local" ? new StubVerificationAdapter() : new LocalVerificationAdapter();
|
|
57
|
-
}
|
|
58
|
-
export {
|
|
59
|
-
LocalVerificationAdapter,
|
|
60
|
-
StubVerificationAdapter,
|
|
61
|
-
createVerificationAdapter
|
|
62
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
export interface QuestionPriorityUpdatedMessage {
|
|
2
|
-
questionId: string;
|
|
3
|
-
reason: string;
|
|
4
|
-
plannerRunId: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ObjectivePriorityUpdatedMessage {
|
|
7
|
-
objectiveId: string;
|
|
8
|
-
reason: string;
|
|
9
|
-
plannerRunId: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ArchitectureUpdatedMessage {
|
|
12
|
-
objectiveId: string;
|
|
13
|
-
knowledgeId: string;
|
|
14
|
-
architectRunId: string;
|
|
15
|
-
}
|
|
16
|
-
export interface SubscriberNotifiedMessage {
|
|
17
|
-
email: string;
|
|
18
|
-
itemCount: number;
|
|
19
|
-
notifierRunId: string;
|
|
20
|
-
}
|
|
21
|
-
export interface ResearchStartedMessage {
|
|
22
|
-
questionId: string;
|
|
23
|
-
researcherRunId: string;
|
|
24
|
-
}
|
|
25
|
-
export interface ResearchCompletedMessage {
|
|
26
|
-
questionId: string;
|
|
27
|
-
knowledgeId: string | null;
|
|
28
|
-
researcherRunId: string;
|
|
29
|
-
}
|
|
30
|
-
export interface TaskCompleteMessage {
|
|
31
|
-
branchName: string | null;
|
|
32
|
-
changedTargets: string[];
|
|
33
|
-
engineerRunId: string;
|
|
34
|
-
}
|
|
35
|
-
export interface TaskWaitingMessage {
|
|
36
|
-
blockingReason: string;
|
|
37
|
-
engineerRunId: string;
|
|
38
|
-
}
|
|
39
|
-
export interface TaskFailedMessage {
|
|
40
|
-
failureSummary: string;
|
|
41
|
-
engineerRunId: string;
|
|
42
|
-
}
|
|
43
|
-
export interface TaskVerifiedMessage {
|
|
44
|
-
branchName: string | null;
|
|
45
|
-
reviewerRunId: string;
|
|
46
|
-
}
|
|
47
|
-
export interface ReviewFailedMessage {
|
|
48
|
-
failureSummary: string;
|
|
49
|
-
reviewerRunId: string;
|
|
50
|
-
}
|
|
51
|
-
export interface ReviewWaitingMessage {
|
|
52
|
-
blockingReason: string;
|
|
53
|
-
reviewerRunId: string;
|
|
54
|
-
}
|
|
55
|
-
export interface ReleaseStartedMessage {
|
|
56
|
-
taskRunId: string | null;
|
|
57
|
-
releaserRunId: string;
|
|
58
|
-
}
|
|
59
|
-
export interface ReleaseCompletedMessage {
|
|
60
|
-
releaseSummary: string;
|
|
61
|
-
releaserRunId: string;
|
|
62
|
-
}
|
|
63
|
-
export interface ReleaseFailedMessage {
|
|
64
|
-
failureSummary: string;
|
|
65
|
-
releaserRunId: string;
|
|
66
|
-
}
|
|
67
|
-
export interface AgentMessageContracts {
|
|
68
|
-
question_priority_updated: QuestionPriorityUpdatedMessage;
|
|
69
|
-
objective_priority_updated: ObjectivePriorityUpdatedMessage;
|
|
70
|
-
architecture_updated: ArchitectureUpdatedMessage;
|
|
71
|
-
subscriber_notified: SubscriberNotifiedMessage;
|
|
72
|
-
research_started: ResearchStartedMessage;
|
|
73
|
-
research_completed: ResearchCompletedMessage;
|
|
74
|
-
task_complete: TaskCompleteMessage;
|
|
75
|
-
task_waiting: TaskWaitingMessage;
|
|
76
|
-
task_failed: TaskFailedMessage;
|
|
77
|
-
task_verified: TaskVerifiedMessage;
|
|
78
|
-
review_failed: ReviewFailedMessage;
|
|
79
|
-
review_waiting: ReviewWaitingMessage;
|
|
80
|
-
release_started: ReleaseStartedMessage;
|
|
81
|
-
release_completed: ReleaseCompletedMessage;
|
|
82
|
-
release_failed: ReleaseFailedMessage;
|
|
83
|
-
}
|
|
84
|
-
export type AgentMessageType = keyof AgentMessageContracts;
|
|
85
|
-
export type AgentMessagePayload<TType extends AgentMessageType> = AgentMessageContracts[TType];
|
|
86
|
-
export declare const AGENT_MESSAGE_TYPES: readonly ["question_priority_updated", "objective_priority_updated", "architecture_updated", "subscriber_notified", "research_started", "research_completed", "task_complete", "task_waiting", "task_failed", "task_verified", "review_failed", "review_waiting", "release_started", "release_completed", "release_failed"];
|
|
87
|
-
export declare function parseAgentMessagePayload<TType extends AgentMessageType>(type: TType, payloadJson: string): AgentMessagePayload<TType>;
|
|
88
|
-
export declare function serializeAgentMessagePayload<TType extends AgentMessageType>(type: TType, payload: AgentMessagePayload<TType>): Record<string, unknown>;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
const AGENT_MESSAGE_TYPES = [
|
|
2
|
-
"question_priority_updated",
|
|
3
|
-
"objective_priority_updated",
|
|
4
|
-
"architecture_updated",
|
|
5
|
-
"subscriber_notified",
|
|
6
|
-
"research_started",
|
|
7
|
-
"research_completed",
|
|
8
|
-
"task_complete",
|
|
9
|
-
"task_waiting",
|
|
10
|
-
"task_failed",
|
|
11
|
-
"task_verified",
|
|
12
|
-
"review_failed",
|
|
13
|
-
"review_waiting",
|
|
14
|
-
"release_started",
|
|
15
|
-
"release_completed",
|
|
16
|
-
"release_failed"
|
|
17
|
-
];
|
|
18
|
-
function ensureString(value, label) {
|
|
19
|
-
if (typeof value !== "string" || value.trim().length === 0) {
|
|
20
|
-
throw new Error(`Invalid ${label}: expected non-empty string.`);
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
function ensureOptionalString(value, label) {
|
|
25
|
-
if (value === null || value === void 0) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return ensureString(value, label);
|
|
29
|
-
}
|
|
30
|
-
function ensureStringArray(value, label) {
|
|
31
|
-
if (!Array.isArray(value)) {
|
|
32
|
-
throw new Error(`Invalid ${label}: expected array.`);
|
|
33
|
-
}
|
|
34
|
-
return value.map((entry, index) => ensureString(entry, `${label}[${index}]`));
|
|
35
|
-
}
|
|
36
|
-
function ensureNumber(value, label) {
|
|
37
|
-
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
38
|
-
throw new Error(`Invalid ${label}: expected number.`);
|
|
39
|
-
}
|
|
40
|
-
return value;
|
|
41
|
-
}
|
|
42
|
-
function parseAgentMessagePayload(type, payloadJson) {
|
|
43
|
-
const parsed = JSON.parse(payloadJson);
|
|
44
|
-
switch (type) {
|
|
45
|
-
case "question_priority_updated":
|
|
46
|
-
return {
|
|
47
|
-
questionId: ensureString(parsed.questionId, "questionId"),
|
|
48
|
-
reason: ensureString(parsed.reason, "reason"),
|
|
49
|
-
plannerRunId: ensureString(parsed.plannerRunId, "plannerRunId")
|
|
50
|
-
};
|
|
51
|
-
case "objective_priority_updated":
|
|
52
|
-
return {
|
|
53
|
-
objectiveId: ensureString(parsed.objectiveId, "objectiveId"),
|
|
54
|
-
reason: ensureString(parsed.reason, "reason"),
|
|
55
|
-
plannerRunId: ensureString(parsed.plannerRunId, "plannerRunId")
|
|
56
|
-
};
|
|
57
|
-
case "architecture_updated":
|
|
58
|
-
return {
|
|
59
|
-
objectiveId: ensureString(parsed.objectiveId, "objectiveId"),
|
|
60
|
-
knowledgeId: ensureString(parsed.knowledgeId, "knowledgeId"),
|
|
61
|
-
architectRunId: ensureString(parsed.architectRunId, "architectRunId")
|
|
62
|
-
};
|
|
63
|
-
case "subscriber_notified":
|
|
64
|
-
return {
|
|
65
|
-
email: ensureString(parsed.email, "email"),
|
|
66
|
-
itemCount: ensureNumber(parsed.itemCount, "itemCount"),
|
|
67
|
-
notifierRunId: ensureString(parsed.notifierRunId, "notifierRunId")
|
|
68
|
-
};
|
|
69
|
-
case "research_started":
|
|
70
|
-
return {
|
|
71
|
-
questionId: ensureString(parsed.questionId, "questionId"),
|
|
72
|
-
researcherRunId: ensureString(parsed.researcherRunId, "researcherRunId")
|
|
73
|
-
};
|
|
74
|
-
case "research_completed":
|
|
75
|
-
return {
|
|
76
|
-
questionId: ensureString(parsed.questionId, "questionId"),
|
|
77
|
-
knowledgeId: ensureOptionalString(parsed.knowledgeId, "knowledgeId"),
|
|
78
|
-
researcherRunId: ensureString(parsed.researcherRunId, "researcherRunId")
|
|
79
|
-
};
|
|
80
|
-
case "task_complete":
|
|
81
|
-
return {
|
|
82
|
-
branchName: ensureOptionalString(parsed.branchName, "branchName"),
|
|
83
|
-
changedTargets: ensureStringArray(parsed.changedTargets, "changedTargets"),
|
|
84
|
-
engineerRunId: ensureString(parsed.engineerRunId, "engineerRunId")
|
|
85
|
-
};
|
|
86
|
-
case "task_waiting":
|
|
87
|
-
return {
|
|
88
|
-
blockingReason: ensureString(parsed.blockingReason, "blockingReason"),
|
|
89
|
-
engineerRunId: ensureString(parsed.engineerRunId, "engineerRunId")
|
|
90
|
-
};
|
|
91
|
-
case "task_failed":
|
|
92
|
-
return {
|
|
93
|
-
failureSummary: ensureString(parsed.failureSummary, "failureSummary"),
|
|
94
|
-
engineerRunId: ensureString(parsed.engineerRunId, "engineerRunId")
|
|
95
|
-
};
|
|
96
|
-
case "task_verified":
|
|
97
|
-
return {
|
|
98
|
-
branchName: ensureOptionalString(parsed.branchName, "branchName"),
|
|
99
|
-
reviewerRunId: ensureString(parsed.reviewerRunId, "reviewerRunId")
|
|
100
|
-
};
|
|
101
|
-
case "review_failed":
|
|
102
|
-
return {
|
|
103
|
-
failureSummary: ensureString(parsed.failureSummary, "failureSummary"),
|
|
104
|
-
reviewerRunId: ensureString(parsed.reviewerRunId, "reviewerRunId")
|
|
105
|
-
};
|
|
106
|
-
case "review_waiting":
|
|
107
|
-
return {
|
|
108
|
-
blockingReason: ensureString(parsed.blockingReason, "blockingReason"),
|
|
109
|
-
reviewerRunId: ensureString(parsed.reviewerRunId, "reviewerRunId")
|
|
110
|
-
};
|
|
111
|
-
case "release_started":
|
|
112
|
-
return {
|
|
113
|
-
taskRunId: ensureOptionalString(parsed.taskRunId, "taskRunId"),
|
|
114
|
-
releaserRunId: ensureString(parsed.releaserRunId, "releaserRunId")
|
|
115
|
-
};
|
|
116
|
-
case "release_completed":
|
|
117
|
-
return {
|
|
118
|
-
releaseSummary: ensureString(parsed.releaseSummary, "releaseSummary"),
|
|
119
|
-
releaserRunId: ensureString(parsed.releaserRunId, "releaserRunId")
|
|
120
|
-
};
|
|
121
|
-
case "release_failed":
|
|
122
|
-
return {
|
|
123
|
-
failureSummary: ensureString(parsed.failureSummary, "failureSummary"),
|
|
124
|
-
releaserRunId: ensureString(parsed.releaserRunId, "releaserRunId")
|
|
125
|
-
};
|
|
126
|
-
default:
|
|
127
|
-
throw new Error(`Unsupported message type "${type}".`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function serializeAgentMessagePayload(type, payload) {
|
|
131
|
-
parseAgentMessagePayload(type, JSON.stringify(payload));
|
|
132
|
-
return payload;
|
|
133
|
-
}
|
|
134
|
-
export {
|
|
135
|
-
AGENT_MESSAGE_TYPES,
|
|
136
|
-
parseAgentMessagePayload,
|
|
137
|
-
serializeAgentMessagePayload
|
|
138
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type AgentErrorCategory = 'trigger_resolution_error' | 'permission_error' | 'message_claim_error' | 'lease_error' | 'execution_error' | 'mutation_error' | 'sdk_error';
|
|
2
|
-
export interface AgentRunTrace {
|
|
3
|
-
[key: string]: unknown;
|
|
4
|
-
runId: string;
|
|
5
|
-
agentSlug: string;
|
|
6
|
-
handlerKind: string;
|
|
7
|
-
triggerKind: string;
|
|
8
|
-
triggerSource: string;
|
|
9
|
-
claimedMessageId: number | null;
|
|
10
|
-
selectedItemKey: string | null;
|
|
11
|
-
branchName: string | null;
|
|
12
|
-
commitSha: string | null;
|
|
13
|
-
changedPaths: string[];
|
|
14
|
-
summary: string | null;
|
|
15
|
-
error: string | null;
|
|
16
|
-
errorCategory: AgentErrorCategory | null;
|
|
17
|
-
startedAt: string;
|
|
18
|
-
finishedAt: string | null;
|
|
19
|
-
status: string;
|
|
20
|
-
}
|
|
File without changes
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { AgentHandlerKind, AgentRuntimeSpec, AgentRunStatus, AgentTriggerConfig } from '@treeseed/sdk/types/agents';
|
|
2
|
-
import type { AgentErrorCategory } from './contracts/run.ts';
|
|
3
|
-
import type { ScopedAgentSdk, SdkMessageEntity } from '@treeseed/sdk';
|
|
4
|
-
export interface AgentTriggerInvocation {
|
|
5
|
-
kind: 'startup' | 'schedule' | 'message' | 'manual' | 'follow';
|
|
6
|
-
source: string;
|
|
7
|
-
trigger: AgentTriggerConfig;
|
|
8
|
-
message?: SdkMessageEntity | null;
|
|
9
|
-
followModels?: string[];
|
|
10
|
-
cursorValue?: string | null;
|
|
11
|
-
}
|
|
12
|
-
export interface AgentExecutionResult {
|
|
13
|
-
status: AgentRunStatus;
|
|
14
|
-
summary: string;
|
|
15
|
-
stdout?: string;
|
|
16
|
-
stderr?: string;
|
|
17
|
-
errorCategory?: AgentErrorCategory | null;
|
|
18
|
-
metadata?: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
|
-
export interface AgentMutationResult {
|
|
21
|
-
branchName: string | null;
|
|
22
|
-
commitMessage: string | null;
|
|
23
|
-
worktreePath: string | null;
|
|
24
|
-
commitSha: string | null;
|
|
25
|
-
changedPaths: string[];
|
|
26
|
-
}
|
|
27
|
-
export interface AgentRepositoryInspectionResult {
|
|
28
|
-
branchName: string | null;
|
|
29
|
-
changedPaths: string[];
|
|
30
|
-
commitSha: string | null;
|
|
31
|
-
summary: string;
|
|
32
|
-
}
|
|
33
|
-
export interface AgentVerificationResult {
|
|
34
|
-
status: 'completed' | 'failed' | 'waiting';
|
|
35
|
-
summary: string;
|
|
36
|
-
stdout?: string;
|
|
37
|
-
stderr?: string;
|
|
38
|
-
errorCategory?: AgentErrorCategory | null;
|
|
39
|
-
}
|
|
40
|
-
export interface AgentNotificationResult {
|
|
41
|
-
status: 'completed' | 'failed' | 'waiting';
|
|
42
|
-
summary: string;
|
|
43
|
-
deliveredCount: number;
|
|
44
|
-
}
|
|
45
|
-
export interface AgentResearchResult {
|
|
46
|
-
status: 'completed' | 'failed' | 'waiting';
|
|
47
|
-
summary: string;
|
|
48
|
-
markdown: string;
|
|
49
|
-
sources?: string[];
|
|
50
|
-
errorCategory?: AgentErrorCategory | null;
|
|
51
|
-
}
|
|
52
|
-
export interface AgentExecutionAdapter {
|
|
53
|
-
runTask(input: {
|
|
54
|
-
agent: AgentRuntimeSpec;
|
|
55
|
-
runId: string;
|
|
56
|
-
prompt: string;
|
|
57
|
-
}): Promise<AgentExecutionResult>;
|
|
58
|
-
}
|
|
59
|
-
export interface AgentMutationAdapter {
|
|
60
|
-
writeArtifact(input: {
|
|
61
|
-
runId: string;
|
|
62
|
-
agent: AgentRuntimeSpec;
|
|
63
|
-
relativePath: string;
|
|
64
|
-
content: string;
|
|
65
|
-
commitMessage: string;
|
|
66
|
-
}): Promise<AgentMutationResult>;
|
|
67
|
-
}
|
|
68
|
-
export interface AgentRepositoryInspectionAdapter {
|
|
69
|
-
inspectBranch(input: {
|
|
70
|
-
repoRoot: string;
|
|
71
|
-
branchName: string | null;
|
|
72
|
-
}): Promise<AgentRepositoryInspectionResult>;
|
|
73
|
-
}
|
|
74
|
-
export interface AgentVerificationAdapter {
|
|
75
|
-
runChecks(input: {
|
|
76
|
-
agent: AgentRuntimeSpec;
|
|
77
|
-
runId: string;
|
|
78
|
-
commands: string[];
|
|
79
|
-
}): Promise<AgentVerificationResult>;
|
|
80
|
-
}
|
|
81
|
-
export interface AgentNotificationAdapter {
|
|
82
|
-
deliver(input: {
|
|
83
|
-
agent: AgentRuntimeSpec;
|
|
84
|
-
runId: string;
|
|
85
|
-
recipients: string[];
|
|
86
|
-
subject: string;
|
|
87
|
-
body: string;
|
|
88
|
-
}): Promise<AgentNotificationResult>;
|
|
89
|
-
}
|
|
90
|
-
export interface AgentResearchAdapter {
|
|
91
|
-
research(input: {
|
|
92
|
-
agent: AgentRuntimeSpec;
|
|
93
|
-
runId: string;
|
|
94
|
-
questionId: string;
|
|
95
|
-
reason: string | null;
|
|
96
|
-
}): Promise<AgentResearchResult>;
|
|
97
|
-
}
|
|
98
|
-
export interface AgentContext {
|
|
99
|
-
runId: string;
|
|
100
|
-
repoRoot: string;
|
|
101
|
-
agent: AgentRuntimeSpec;
|
|
102
|
-
sdk: ScopedAgentSdk;
|
|
103
|
-
trigger: AgentTriggerInvocation;
|
|
104
|
-
execution: AgentExecutionAdapter;
|
|
105
|
-
mutations: AgentMutationAdapter;
|
|
106
|
-
repository: AgentRepositoryInspectionAdapter;
|
|
107
|
-
verification: AgentVerificationAdapter;
|
|
108
|
-
notifications: AgentNotificationAdapter;
|
|
109
|
-
research: AgentResearchAdapter;
|
|
110
|
-
}
|
|
111
|
-
export interface AgentHandler<TInputs = unknown, TResult = unknown> {
|
|
112
|
-
kind: AgentHandlerKind;
|
|
113
|
-
resolveInputs(context: AgentContext): Promise<TInputs>;
|
|
114
|
-
execute(context: AgentContext, inputs: TInputs): Promise<TResult>;
|
|
115
|
-
emitOutputs(context: AgentContext, result: TResult): Promise<AgentExecutionResult>;
|
|
116
|
-
}
|
|
117
|
-
export declare const TRESEED_AGENT_RUNTIME_TYPES_MODULE = true;
|
package/dist/utils/books-data.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BOOKS,
|
|
3
|
-
BOOKS_LINK,
|
|
4
|
-
TREESEED_LIBRARY_DOWNLOAD,
|
|
5
|
-
TREESEED_LINKS,
|
|
6
|
-
buildTenantBookRuntime
|
|
7
|
-
} from "@treeseed/sdk/platform/books-data";
|
|
8
|
-
export {
|
|
9
|
-
BOOKS,
|
|
10
|
-
BOOKS_LINK,
|
|
11
|
-
TREESEED_LIBRARY_DOWNLOAD,
|
|
12
|
-
TREESEED_LINKS,
|
|
13
|
-
buildTenantBookRuntime
|
|
14
|
-
};
|