@treeseed/core 0.8.3 → 0.8.5

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.
Files changed (133) hide show
  1. package/README.md +7 -11
  2. package/dist/dev-watch.js +1 -1
  3. package/dist/dev.d.ts +2 -4
  4. package/dist/dev.js +4 -124
  5. package/dist/env.yaml +23 -175
  6. package/dist/index.d.ts +0 -4
  7. package/dist/index.js +0 -6
  8. package/dist/scripts/build-dist.js +3 -3
  9. package/dist/scripts/dev-platform.js +1 -7
  10. package/dist/scripts/run-fixture-astro-command.js +25 -51
  11. package/dist/scripts/test-smoke.js +50 -7
  12. package/package.json +5 -78
  13. package/templates/github/deploy-web.workflow.yml +111 -0
  14. package/templates/github/hosted-project.workflow.yml +4 -4
  15. package/dist/agent-runtime.d.ts +0 -17
  16. package/dist/agent-runtime.js +0 -117
  17. package/dist/agent.d.ts +0 -11
  18. package/dist/agent.js +0 -25
  19. package/dist/agents/adapters/execution.d.ts +0 -41
  20. package/dist/agents/adapters/execution.js +0 -73
  21. package/dist/agents/adapters/mutations.d.ts +0 -22
  22. package/dist/agents/adapters/mutations.js +0 -30
  23. package/dist/agents/adapters/notification.d.ts +0 -26
  24. package/dist/agents/adapters/notification.js +0 -46
  25. package/dist/agents/adapters/repository.d.ts +0 -23
  26. package/dist/agents/adapters/repository.js +0 -61
  27. package/dist/agents/adapters/research.d.ts +0 -26
  28. package/dist/agents/adapters/research.js +0 -59
  29. package/dist/agents/adapters/verification.d.ts +0 -36
  30. package/dist/agents/adapters/verification.js +0 -62
  31. package/dist/agents/cli-tools.d.ts +0 -1
  32. package/dist/agents/cli-tools.js +0 -5
  33. package/dist/agents/cli.d.ts +0 -15
  34. package/dist/agents/cli.js +0 -109
  35. package/dist/agents/contracts/messages.d.ts +0 -88
  36. package/dist/agents/contracts/messages.js +0 -138
  37. package/dist/agents/contracts/run.d.ts +0 -21
  38. package/dist/agents/contracts/run.js +0 -0
  39. package/dist/agents/index.d.ts +0 -1
  40. package/dist/agents/index.js +0 -5
  41. package/dist/agents/kernel/agent-kernel.d.ts +0 -51
  42. package/dist/agents/kernel/agent-kernel.js +0 -292
  43. package/dist/agents/kernel/trigger-resolver.d.ts +0 -19
  44. package/dist/agents/kernel/trigger-resolver.js +0 -157
  45. package/dist/agents/registry-helper.d.ts +0 -4
  46. package/dist/agents/registry-helper.js +0 -14
  47. package/dist/agents/registry.d.ts +0 -6
  48. package/dist/agents/registry.js +0 -98
  49. package/dist/agents/runtime-types.d.ts +0 -118
  50. package/dist/agents/runtime-types.js +0 -0
  51. package/dist/agents/spec-loader.d.ts +0 -18
  52. package/dist/agents/spec-loader.js +0 -55
  53. package/dist/agents/spec-normalizer.d.ts +0 -2
  54. package/dist/agents/spec-normalizer.js +0 -327
  55. package/dist/agents/spec-types.d.ts +0 -64
  56. package/dist/agents/spec-types.js +0 -0
  57. package/dist/agents/testing/agents-smoke.d.ts +0 -1
  58. package/dist/agents/testing/agents-smoke.js +0 -32
  59. package/dist/agents/testing/e2e-harness.d.ts +0 -44
  60. package/dist/agents/testing/e2e-harness.js +0 -504
  61. package/dist/api/agent-routes.d.ts +0 -13
  62. package/dist/api/agent-routes.js +0 -327
  63. package/dist/api/app.d.ts +0 -5
  64. package/dist/api/app.js +0 -361
  65. package/dist/api/auth/d1-database.d.ts +0 -3
  66. package/dist/api/auth/d1-database.js +0 -20
  67. package/dist/api/auth/d1-provider.d.ts +0 -79
  68. package/dist/api/auth/d1-provider.js +0 -92
  69. package/dist/api/auth/d1-store.d.ts +0 -114
  70. package/dist/api/auth/d1-store.js +0 -895
  71. package/dist/api/auth/memory-provider.d.ts +0 -77
  72. package/dist/api/auth/memory-provider.js +0 -249
  73. package/dist/api/auth/rbac.d.ts +0 -22
  74. package/dist/api/auth/rbac.js +0 -162
  75. package/dist/api/auth/tokens.d.ts +0 -18
  76. package/dist/api/auth/tokens.js +0 -56
  77. package/dist/api/capabilities.d.ts +0 -9
  78. package/dist/api/capabilities.js +0 -33
  79. package/dist/api/config.d.ts +0 -2
  80. package/dist/api/config.js +0 -77
  81. package/dist/api/http.d.ts +0 -28
  82. package/dist/api/http.js +0 -51
  83. package/dist/api/index.d.ts +0 -9
  84. package/dist/api/index.js +0 -18
  85. package/dist/api/operations-routes.d.ts +0 -11
  86. package/dist/api/operations-routes.js +0 -87
  87. package/dist/api/operations.d.ts +0 -3
  88. package/dist/api/operations.js +0 -26
  89. package/dist/api/project-routes.d.ts +0 -8
  90. package/dist/api/project-routes.js +0 -586
  91. package/dist/api/providers.d.ts +0 -2
  92. package/dist/api/providers.js +0 -62
  93. package/dist/api/railway.d.ts +0 -50
  94. package/dist/api/railway.js +0 -69
  95. package/dist/api/sdk-dispatch.d.ts +0 -5
  96. package/dist/api/sdk-dispatch.js +0 -13
  97. package/dist/api/sdk-routes.d.ts +0 -11
  98. package/dist/api/sdk-routes.js +0 -29
  99. package/dist/api/server.d.ts +0 -2
  100. package/dist/api/server.js +0 -10
  101. package/dist/api/templates.d.ts +0 -3
  102. package/dist/api/templates.js +0 -31
  103. package/dist/api/types.d.ts +0 -231
  104. package/dist/api/types.js +0 -0
  105. package/dist/api.d.ts +0 -1
  106. package/dist/api.js +0 -1
  107. package/dist/railway.d.ts +0 -1
  108. package/dist/railway.js +0 -4
  109. package/dist/services/agents.d.ts +0 -11
  110. package/dist/services/agents.js +0 -48
  111. package/dist/services/common.d.ts +0 -66
  112. package/dist/services/common.js +0 -212
  113. package/dist/services/index.d.ts +0 -6
  114. package/dist/services/index.js +0 -19
  115. package/dist/services/manager.d.ts +0 -267
  116. package/dist/services/manager.js +0 -1368
  117. package/dist/services/remote-runner.d.ts +0 -30
  118. package/dist/services/remote-runner.js +0 -230
  119. package/dist/services/workday-content.d.ts +0 -53
  120. package/dist/services/workday-content.js +0 -190
  121. package/dist/services/workday-manager.d.ts +0 -279
  122. package/dist/services/workday-manager.js +0 -163
  123. package/dist/services/workday-report.d.ts +0 -195
  124. package/dist/services/workday-report.js +0 -17
  125. package/dist/services/workday-start.d.ts +0 -195
  126. package/dist/services/workday-start.js +0 -17
  127. package/dist/services/worker-capacity.d.ts +0 -58
  128. package/dist/services/worker-capacity.js +0 -208
  129. package/dist/services/worker-pool-scaler.d.ts +0 -27
  130. package/dist/services/worker-pool-scaler.js +0 -127
  131. package/dist/services/worker.d.ts +0 -19
  132. package/dist/services/worker.js +0 -436
  133. package/templates/github/deploy.workflow.yml +0 -577
@@ -1,73 +0,0 @@
1
- import { normalizeAgentCliOptions } from "../cli-tools.js";
2
- import { getTreeseedAgentProviderSelections } from "@treeseed/sdk/platform/deploy-runtime";
3
- import { runTreeseedCopilotTask } from "@treeseed/sdk/copilot";
4
- class StubExecutionAdapter {
5
- async runTask(input) {
6
- return {
7
- status: "completed",
8
- summary: `Stubbed Copilot execution for ${input.runId}.`,
9
- stdout: [
10
- "# Planned Task",
11
- "",
12
- "1. Inspect the requested architecture context.",
13
- "2. Produce a safe local change artifact.",
14
- "3. Summarize the implementation intent.",
15
- "",
16
- `Prompt digest: ${input.prompt.slice(0, 240)}`
17
- ].join("\n"),
18
- stderr: ""
19
- };
20
- }
21
- }
22
- class CopilotExecutionAdapter {
23
- async runTask(input) {
24
- const cli = normalizeAgentCliOptions(input.agent.cli);
25
- const result = await runTreeseedCopilotTask({
26
- prompt: input.prompt,
27
- cwd: process.cwd(),
28
- model: cli.model,
29
- allowTools: cli.allowTools,
30
- env: process.env
31
- });
32
- const ignoredArgs = cli.additionalArgs?.length ? `Ignored Copilot CLI-only arguments because Treeseed uses @github/copilot-sdk internally: ${cli.additionalArgs.join(" ")}` : "";
33
- return {
34
- ...result,
35
- stderr: [result.stderr, ignoredArgs].filter(Boolean).join("\n")
36
- };
37
- }
38
- }
39
- class ManualExecutionAdapter {
40
- async runTask(input) {
41
- return {
42
- status: "completed",
43
- summary: `Manual execution mode is enabled for ${input.runId}.`,
44
- stdout: [
45
- "# Manual Execution Required",
46
- "",
47
- "This agent run is configured for manual execution.",
48
- "Review the prompt below and complete the work outside the automated adapter.",
49
- "",
50
- input.prompt
51
- ].join("\n"),
52
- stderr: ""
53
- };
54
- }
55
- }
56
- function createExecutionAdapter() {
57
- const configuredMode = String(
58
- process.env.TREESEED_AGENT_EXECUTION_PROVIDER ?? getTreeseedAgentProviderSelections().execution
59
- ).toLowerCase();
60
- if (configuredMode === "manual") {
61
- return new ManualExecutionAdapter();
62
- }
63
- if (configuredMode !== "copilot") {
64
- return new StubExecutionAdapter();
65
- }
66
- return new CopilotExecutionAdapter();
67
- }
68
- export {
69
- CopilotExecutionAdapter,
70
- ManualExecutionAdapter,
71
- StubExecutionAdapter,
72
- createExecutionAdapter
73
- };
@@ -1,22 +0,0 @@
1
- import type { AgentMutationAdapter } from '../runtime-types.ts';
2
- export declare class LocalBranchMutationAdapter implements AgentMutationAdapter {
3
- private readonly git;
4
- constructor(repoRoot: string);
5
- writeArtifact(input: {
6
- runId: string;
7
- agent: {
8
- execution: {
9
- branchPrefix: string;
10
- };
11
- };
12
- relativePath: string;
13
- content: string;
14
- commitMessage: string;
15
- }): Promise<{
16
- branchName: string;
17
- commitMessage: string;
18
- worktreePath: string;
19
- commitSha: string;
20
- changedPaths: string[];
21
- }>;
22
- }
@@ -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,26 +0,0 @@
1
- import type { AgentNotificationAdapter } from '../runtime-types.ts';
2
- export declare class StubNotificationAdapter implements AgentNotificationAdapter {
3
- deliver(input: {
4
- recipients: string[];
5
- }): Promise<{
6
- status: "completed" | "waiting";
7
- summary: string;
8
- deliveredCount: number;
9
- }>;
10
- }
11
- export declare class SdkMessageNotificationAdapter implements AgentNotificationAdapter {
12
- deliver(input: {
13
- agent: {
14
- slug: string;
15
- };
16
- runId: string;
17
- recipients: string[];
18
- subject: string;
19
- body: string;
20
- }): Promise<{
21
- status: "completed";
22
- summary: string;
23
- deliveredCount: number;
24
- }>;
25
- }
26
- export declare function createNotificationAdapter(): StubNotificationAdapter | SdkMessageNotificationAdapter;
@@ -1,46 +0,0 @@
1
- import { AgentSdk } from "@treeseed/sdk";
2
- import { resolveTreeseedTenantRoot } from "@treeseed/sdk/platform/tenant-config";
3
- import { getTreeseedAgentProviderSelections } from "@treeseed/sdk/platform/deploy-runtime";
4
- class StubNotificationAdapter {
5
- async deliver(input) {
6
- return {
7
- status: input.recipients.length ? "completed" : "waiting",
8
- summary: input.recipients.length ? `Prepared ${input.recipients.length} notification(s).` : "No recipients available for notification.",
9
- deliveredCount: input.recipients.length
10
- };
11
- }
12
- }
13
- class SdkMessageNotificationAdapter {
14
- async deliver(input) {
15
- const sdk = AgentSdk.createLocal({ repoRoot: resolveTreeseedTenantRoot() });
16
- await sdk.createMessage({
17
- type: "agent.notification",
18
- payload: {
19
- agentSlug: input.agent.slug,
20
- runId: input.runId,
21
- recipients: input.recipients,
22
- subject: input.subject,
23
- body: input.body,
24
- summary: `Prepared ${input.recipients.length} notification(s).`
25
- },
26
- relatedModel: "agent",
27
- relatedId: input.agent.slug,
28
- actor: "agent"
29
- });
30
- return {
31
- status: "completed",
32
- summary: input.recipients.length ? `Prepared ${input.recipients.length} notification(s).` : "Notification recorded without recipients.",
33
- deliveredCount: input.recipients.length
34
- };
35
- }
36
- }
37
- function createNotificationAdapter() {
38
- return String(
39
- process.env.TREESEED_AGENT_NOTIFICATION_PROVIDER ?? getTreeseedAgentProviderSelections().notification
40
- ).toLowerCase() === "sdk_message" ? new SdkMessageNotificationAdapter() : new StubNotificationAdapter();
41
- }
42
- export {
43
- SdkMessageNotificationAdapter,
44
- StubNotificationAdapter,
45
- createNotificationAdapter
46
- };
@@ -1,23 +0,0 @@
1
- import type { AgentRepositoryInspectionAdapter } from '../runtime-types.ts';
2
- export declare class StubRepositoryInspectionAdapter implements AgentRepositoryInspectionAdapter {
3
- inspectBranch(input: {
4
- branchName: string | null;
5
- }): Promise<{
6
- branchName: string;
7
- changedPaths: any[];
8
- commitSha: any;
9
- summary: string;
10
- }>;
11
- }
12
- export declare class GitRepositoryInspectionAdapter implements AgentRepositoryInspectionAdapter {
13
- inspectBranch(input: {
14
- repoRoot: string;
15
- branchName: string | null;
16
- }): Promise<{
17
- branchName: string;
18
- changedPaths: string[];
19
- commitSha: string;
20
- summary: string;
21
- }>;
22
- }
23
- export declare function createRepositoryInspectionAdapter(): StubRepositoryInspectionAdapter | GitRepositoryInspectionAdapter;
@@ -1,61 +0,0 @@
1
- import { execFile } from "node:child_process";
2
- import { promisify } from "node:util";
3
- import { getTreeseedAgentProviderSelections } from "@treeseed/sdk/platform/deploy-runtime";
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,26 +0,0 @@
1
- import type { AgentResearchAdapter } from '../runtime-types.ts';
2
- export declare class StubResearchAdapter implements AgentResearchAdapter {
3
- research(input: {
4
- questionId: string;
5
- reason: string | null;
6
- runId: string;
7
- }): Promise<{
8
- status: "completed";
9
- summary: string;
10
- markdown: string;
11
- sources: any[];
12
- }>;
13
- }
14
- export declare class ProjectGraphResearchAdapter implements AgentResearchAdapter {
15
- research(input: {
16
- questionId: string;
17
- reason: string | null;
18
- runId: string;
19
- }): Promise<{
20
- status: "completed";
21
- summary: string;
22
- markdown: string;
23
- sources: any;
24
- }>;
25
- }
26
- export declare function createResearchAdapter(): StubResearchAdapter | ProjectGraphResearchAdapter;
@@ -1,59 +0,0 @@
1
- import { AgentSdk } from "@treeseed/sdk";
2
- import { resolveTreeseedTenantRoot } from "@treeseed/sdk/platform/tenant-config";
3
- import { getTreeseedAgentProviderSelections } from "@treeseed/sdk/platform/deploy-runtime";
4
- class StubResearchAdapter {
5
- async research(input) {
6
- return {
7
- status: "completed",
8
- summary: `Research prepared for ${input.questionId}.`,
9
- markdown: [
10
- "# Research Summary",
11
- "",
12
- `Question: ${input.questionId}`,
13
- `Reason: ${input.reason ?? "not provided"}`,
14
- `Run: ${input.runId}`,
15
- "",
16
- "This is a stub research summary produced by the runtime adapter."
17
- ].join("\n"),
18
- sources: []
19
- };
20
- }
21
- }
22
- class ProjectGraphResearchAdapter {
23
- async research(input) {
24
- const repoRoot = resolveTreeseedTenantRoot();
25
- const sdk = AgentSdk.createLocal({ repoRoot });
26
- const graphResult = await sdk.queryGraph({
27
- query: input.questionId,
28
- options: {
29
- limit: 5
30
- }
31
- }).catch(() => null);
32
- const items = Array.isArray(graphResult?.items) ? graphResult.items : [];
33
- return {
34
- status: "completed",
35
- summary: `Graph-backed research prepared for ${input.questionId}.`,
36
- markdown: [
37
- "# Research Summary",
38
- "",
39
- `Question: ${input.questionId}`,
40
- `Reason: ${input.reason ?? "not provided"}`,
41
- `Run: ${input.runId}`,
42
- "",
43
- items.length ? "Relevant graph context:" : "No ranked graph context was available. The question is still recorded for follow-up.",
44
- ...items.map((item) => `- ${String(item.title ?? item.id ?? "context")}`)
45
- ].join("\n"),
46
- sources: items.map((item) => String(item.id ?? item.title ?? "")).filter(Boolean)
47
- };
48
- }
49
- }
50
- function createResearchAdapter() {
51
- return String(
52
- process.env.TREESEED_AGENT_RESEARCH_PROVIDER ?? getTreeseedAgentProviderSelections().research
53
- ).toLowerCase() === "project_graph" ? new ProjectGraphResearchAdapter() : new StubResearchAdapter();
54
- }
55
- export {
56
- ProjectGraphResearchAdapter,
57
- StubResearchAdapter,
58
- createResearchAdapter
59
- };
@@ -1,36 +0,0 @@
1
- import type { AgentVerificationAdapter } from '../runtime-types.ts';
2
- export declare class StubVerificationAdapter implements AgentVerificationAdapter {
3
- runChecks(input: {
4
- commands: string[];
5
- runId: string;
6
- }): Promise<{
7
- status: "completed";
8
- summary: string;
9
- stdout: string;
10
- stderr: string;
11
- }>;
12
- }
13
- export declare class LocalVerificationAdapter implements AgentVerificationAdapter {
14
- runChecks(input: {
15
- commands: string[];
16
- }): Promise<{
17
- status: "waiting";
18
- summary: string;
19
- stdout: string;
20
- stderr: string;
21
- errorCategory?: undefined;
22
- } | {
23
- status: "failed";
24
- summary: string;
25
- stdout: string;
26
- stderr: string;
27
- errorCategory: "execution_error";
28
- } | {
29
- status: "completed";
30
- summary: string;
31
- stdout: string;
32
- stderr: string;
33
- errorCategory?: undefined;
34
- }>;
35
- }
36
- export declare function createVerificationAdapter(): StubVerificationAdapter | LocalVerificationAdapter;
@@ -1,62 +0,0 @@
1
- import { execFile } from "node:child_process";
2
- import { promisify } from "node:util";
3
- import { getTreeseedAgentProviderSelections } from "@treeseed/sdk/platform/deploy-runtime";
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 +0,0 @@
1
- export { normalizeAgentCliOptions, buildCopilotAllowToolArgs } from '@treeseed/sdk/cli-tools';
@@ -1,5 +0,0 @@
1
- import { normalizeAgentCliOptions, buildCopilotAllowToolArgs } from "@treeseed/sdk/cli-tools";
2
- export {
3
- buildCopilotAllowToolArgs,
4
- normalizeAgentCliOptions
5
- };
@@ -1,15 +0,0 @@
1
- export type TreeseedAgentCliCommandName = 'doctor' | 'run-agent' | 'drain-messages' | 'release-leases' | 'replay-message' | 'start';
2
- export type TreeseedAgentCliCommandSpec = {
3
- name: TreeseedAgentCliCommandName;
4
- usage: string;
5
- summary: string;
6
- };
7
- export type TreeseedAgentCliContext = {
8
- cwd?: string;
9
- env?: NodeJS.ProcessEnv;
10
- write?: (output: string, stream?: 'stdout' | 'stderr') => void;
11
- outputFormat?: 'human' | 'json';
12
- };
13
- export declare function listTreeseedAgentCommands(): TreeseedAgentCliCommandSpec[];
14
- export declare function renderTreeseedAgentHelp(): string;
15
- export declare function runTreeseedAgentCli(argv: string[], context?: TreeseedAgentCliContext): Promise<number>;
@@ -1,109 +0,0 @@
1
- import { realpathSync } from "node:fs";
2
- import { resolve } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- const AGENT_COMMAND_SPECS = [
5
- { name: "doctor", usage: "doctor", summary: "Inspect agent runtime readiness for the current tenant." },
6
- { name: "run-agent", usage: "run-agent <slug>", summary: "Run one registered agent handler by slug." },
7
- { name: "drain-messages", usage: "drain-messages", summary: "Drain queued agent messages through the local kernel." },
8
- { name: "release-leases", usage: "release-leases", summary: "Release active task leases held by the local kernel." },
9
- { name: "replay-message", usage: "replay-message <id>", summary: "Replay one message by numeric id." },
10
- { name: "start", usage: "start", summary: "Start the local agent kernel loop." }
11
- ];
12
- function parseArgs(argv) {
13
- const [command = "doctor", ...rest] = argv;
14
- return {
15
- command,
16
- args: rest
17
- };
18
- }
19
- function listTreeseedAgentCommands() {
20
- return [...AGENT_COMMAND_SPECS];
21
- }
22
- function renderTreeseedAgentHelp() {
23
- return [
24
- "treeseed agents <command>",
25
- "",
26
- "Commands:",
27
- ...AGENT_COMMAND_SPECS.map((command) => ` ${command.usage.padEnd(24)}${command.summary}`)
28
- ].join("\n");
29
- }
30
- function defaultWrite(output, stream = "stdout") {
31
- if (!output) return;
32
- (stream === "stderr" ? process.stderr : process.stdout).write(`${output}
33
- `);
34
- }
35
- function resolveExecutablePath(path) {
36
- try {
37
- return realpathSync(path);
38
- } catch {
39
- return resolve(path);
40
- }
41
- }
42
- async function runTreeseedAgentCli(argv, context = {}) {
43
- const { command, args } = parseArgs(argv);
44
- const write = context.write ?? defaultWrite;
45
- if (command === "--help" || command === "-h" || command === "help") {
46
- write(renderTreeseedAgentHelp(), "stdout");
47
- return 0;
48
- }
49
- const [{ AgentKernel }, { AgentSdk }] = await Promise.all([
50
- import("./kernel/agent-kernel.js"),
51
- import("@treeseed/sdk/sdk")
52
- ]);
53
- const repoRoot = context.cwd ?? process.cwd();
54
- const env = { ...process.env, ...context.env ?? {} };
55
- const sdk = AgentSdk.createLocal({
56
- repoRoot,
57
- databaseName: env.TREESEED_AGENT_D1_DATABASE ?? "karyon-docs-site-data",
58
- persistTo: env.TREESEED_AGENT_D1_PERSIST_TO ?? void 0
59
- });
60
- const kernel = new AgentKernel(sdk, repoRoot);
61
- const emitPayload = async (payload) => {
62
- write(JSON.stringify(await payload, null, 2), "stdout");
63
- return 0;
64
- };
65
- if (command === "doctor") {
66
- return emitPayload({ ok: true, command, ...await kernel.doctor() });
67
- }
68
- if (command === "run-agent") {
69
- return emitPayload({ ok: true, command, slug: args[0], result: await kernel.runAgent(args[0]) });
70
- }
71
- if (command === "drain-messages") {
72
- return emitPayload({ ok: true, command, results: await kernel.drainMessages() });
73
- }
74
- if (command === "release-leases") {
75
- return emitPayload({ ok: true, command, result: await kernel.releaseLeases() });
76
- }
77
- if (command === "replay-message") {
78
- return emitPayload({ ok: true, command, result: await kernel.replayMessage(Number(args[0])) });
79
- }
80
- if (command === "start") {
81
- write(JSON.stringify({ ok: true, command, status: "starting" }, null, 2), "stdout");
82
- await kernel.start();
83
- return 0;
84
- }
85
- throw new Error(`Unknown Treeseed command "${command}".`);
86
- }
87
- const currentFile = resolveExecutablePath(fileURLToPath(import.meta.url));
88
- const entryFile = resolveExecutablePath(process.argv[1] ?? "");
89
- if (entryFile === currentFile) {
90
- runTreeseedAgentCli(process.argv.slice(2)).catch((error) => {
91
- defaultWrite(
92
- JSON.stringify(
93
- {
94
- ok: false,
95
- error: error instanceof Error ? error.message : String(error)
96
- },
97
- null,
98
- 2
99
- ),
100
- "stderr"
101
- );
102
- process.exit(1);
103
- });
104
- }
105
- export {
106
- listTreeseedAgentCommands,
107
- renderTreeseedAgentHelp,
108
- runTreeseedAgentCli
109
- };