@treeseed/core 0.4.6 → 0.4.8

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 (65) hide show
  1. package/README.md +8 -16
  2. package/dist/agent-runtime.d.ts +17 -0
  3. package/dist/agent-runtime.js +111 -0
  4. package/dist/agent.d.ts +11 -0
  5. package/dist/agent.js +25 -0
  6. package/dist/agents/adapters/execution.d.ts +46 -0
  7. package/dist/agents/adapters/execution.js +90 -0
  8. package/dist/agents/adapters/mutations.d.ts +22 -0
  9. package/dist/agents/adapters/mutations.js +30 -0
  10. package/dist/agents/adapters/notification.d.ts +11 -0
  11. package/dist/agents/adapters/notification.js +16 -0
  12. package/dist/agents/adapters/repository.d.ts +23 -0
  13. package/dist/agents/adapters/repository.js +61 -0
  14. package/dist/agents/adapters/research.d.ts +14 -0
  15. package/dist/agents/adapters/research.js +25 -0
  16. package/dist/agents/adapters/verification.d.ts +36 -0
  17. package/dist/agents/adapters/verification.js +62 -0
  18. package/dist/agents/cli-tools.d.ts +1 -0
  19. package/dist/agents/cli-tools.js +5 -0
  20. package/dist/agents/cli.d.ts +15 -0
  21. package/dist/agents/cli.js +109 -0
  22. package/dist/agents/contracts/messages.d.ts +88 -0
  23. package/dist/agents/contracts/messages.js +138 -0
  24. package/dist/agents/contracts/run.d.ts +20 -0
  25. package/dist/agents/contracts/run.js +0 -0
  26. package/dist/agents/index.d.ts +1 -0
  27. package/dist/agents/index.js +5 -0
  28. package/dist/agents/kernel/agent-kernel.d.ts +51 -0
  29. package/dist/agents/kernel/agent-kernel.js +285 -0
  30. package/dist/agents/kernel/trigger-resolver.d.ts +18 -0
  31. package/dist/agents/kernel/trigger-resolver.js +153 -0
  32. package/dist/agents/registry-helper.d.ts +4 -0
  33. package/dist/agents/registry-helper.js +14 -0
  34. package/dist/agents/registry.d.ts +6 -0
  35. package/dist/agents/registry.js +98 -0
  36. package/dist/agents/runtime-types.d.ts +117 -0
  37. package/dist/agents/runtime-types.js +0 -0
  38. package/dist/agents/spec-loader.d.ts +18 -0
  39. package/dist/agents/spec-loader.js +55 -0
  40. package/dist/agents/spec-normalizer.d.ts +2 -0
  41. package/dist/agents/spec-normalizer.js +257 -0
  42. package/dist/agents/spec-types.d.ts +64 -0
  43. package/dist/agents/spec-types.js +0 -0
  44. package/dist/agents/testing/agents-smoke.d.ts +1 -0
  45. package/dist/agents/testing/agents-smoke.js +32 -0
  46. package/dist/agents/testing/e2e-harness.d.ts +44 -0
  47. package/dist/agents/testing/e2e-harness.js +504 -0
  48. package/dist/api/agent-routes.js +2 -10
  49. package/dist/scripts/build-dist.js +5 -0
  50. package/dist/scripts/run-fixture-astro-command.js +2 -170
  51. package/dist/scripts/test-smoke.js +15 -1
  52. package/dist/scripts/workspace-bootstrap.js +0 -1
  53. package/dist/services/common.d.ts +20 -0
  54. package/dist/services/common.js +66 -0
  55. package/dist/services/index.d.ts +4 -0
  56. package/dist/services/index.js +11 -0
  57. package/dist/services/manager.d.ts +4 -0
  58. package/dist/services/manager.js +199 -0
  59. package/dist/services/workday-report.d.ts +17 -0
  60. package/dist/services/workday-report.js +44 -0
  61. package/dist/services/workday-start.d.ts +2 -0
  62. package/dist/services/workday-start.js +27 -0
  63. package/dist/services/worker.d.ts +6 -0
  64. package/dist/services/worker.js +108 -0
  65. package/package.json +43 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @treeseed/core
2
2
 
3
- `@treeseed/core` is the Treeseed integrated platform starter for Astro/Starlight sites and Hono API runtimes. It contains the published web runtime, API runtime, integrated local dev orchestration, shared components and styles, the knowledge-factory content model, and the forms stack used by Treeseed tenants.
3
+ `@treeseed/core` is the Treeseed integrated platform starter for Astro/Starlight sites, Hono API runtimes, agent runtimes, and worker services. It contains the published web runtime, API runtime, manager/worker entrypoints, integrated local dev orchestration, shared components and styles, the knowledge-factory content model, and the forms stack used by Treeseed tenants.
4
4
 
5
5
  This repository is the package root. Run package commands from [`core`](./), not from the top-level `treeseed` workspace.
6
6
 
@@ -41,13 +41,7 @@ The package builds directly against the canonical shared working-site fixture in
41
41
 
42
42
  `@treeseed/core` validates itself against the integrated shared fixture, not a Core-specific fork.
43
43
 
44
- That means:
45
-
46
- - the fixture may reference package surfaces owned by `sdk` and `agent`
47
- - Core does not gain a real dependency on `@treeseed/agent`
48
- - isolated Core verification may provide an Agent contracts shim so the shared fixture can typecheck and build without the full Agent runtime package
49
-
50
- This keeps the shared fixture canonical while preserving Core’s package boundary.
44
+ That means the fixture may reference package surfaces owned by `sdk`, `core`, and `cli`, and isolated Core verification links the real local `core` package into the shared fixture instead of maintaining a separate agent package boundary.
51
45
 
52
46
  ## Commands
53
47
 
@@ -57,6 +51,10 @@ This keeps the shared fixture canonical while preserving Core’s package bounda
57
51
  npm run dev
58
52
  npm run dev:web
59
53
  npm run dev:api
54
+ npm run dev:manager
55
+ npm run dev:worker
56
+ npm run dev:workday-start
57
+ npm run dev:workday-report
60
58
  npm run fixtures:check
61
59
  npm run build:dist
62
60
  npm run test:unit
@@ -70,6 +68,7 @@ What they do:
70
68
  - `dev`: starts the integrated Astro UI and Hono API local runtime from `core`
71
69
  - `dev:web`: starts only the Astro UI dev surface through the `core` runtime
72
70
  - `dev:api`: starts only the Hono API dev surface through the `core` runtime
71
+ - `dev:manager`, `dev:worker`, `dev:workday-start`, `dev:workday-report`: start the worker-service entrypoints from `core`
73
72
  - `fixtures:check`: verifies that the pinned shared fixture is initialized and usable
74
73
  - `build:dist`: builds the publishable `dist/` package output
75
74
  - `test:unit`: runs package unit tests with Vitest
@@ -134,14 +133,7 @@ The published package includes:
134
133
  - `utils/`
135
134
  - `README.md`
136
135
 
137
- The package currently depends on:
138
-
139
- - `@treeseed/sdk`
140
- - Astro and Starlight runtime packages
141
- - Tailwind/Vite integration used by the site runtime
142
- - Wrangler for Cloudflare-oriented runtime and deploy support
143
-
144
- It does not depend on `@treeseed/agent`.
136
+ The package currently depends on `@treeseed/sdk` plus the runtime packages needed for its web, API, and worker surfaces. It does not depend on `@treeseed/cli`.
145
137
 
146
138
  ## Contributor Workflow
147
139
 
@@ -0,0 +1,17 @@
1
+ import type { AgentExecutionAdapter, AgentHandler, AgentMutationAdapter, AgentNotificationAdapter, AgentRepositoryInspectionAdapter, AgentResearchAdapter, AgentVerificationAdapter } from './agents/runtime-types.ts';
2
+ export declare function resolveAgentRuntimeProviders(repoRoot: string, selections: {
3
+ execution: string;
4
+ mutation: string;
5
+ repository: string;
6
+ verification: string;
7
+ notification: string;
8
+ research: string;
9
+ }): {
10
+ execution: AgentExecutionAdapter;
11
+ mutations: AgentMutationAdapter;
12
+ repository: AgentRepositoryInspectionAdapter;
13
+ verification: AgentVerificationAdapter;
14
+ notifications: AgentNotificationAdapter;
15
+ research: AgentResearchAdapter;
16
+ handlers: Map<string, AgentHandler<unknown, unknown>>;
17
+ };
@@ -0,0 +1,111 @@
1
+ import { loadTreeseedPluginRuntime } from "@treeseed/sdk/platform/plugins";
2
+ import {
3
+ CopilotExecutionAdapter,
4
+ ManualExecutionAdapter,
5
+ StubExecutionAdapter
6
+ } from "./agents/adapters/execution.js";
7
+ import { LocalBranchMutationAdapter } from "./agents/adapters/mutations.js";
8
+ import { StubNotificationAdapter } from "./agents/adapters/notification.js";
9
+ import { GitRepositoryInspectionAdapter, StubRepositoryInspectionAdapter } from "./agents/adapters/repository.js";
10
+ import { StubResearchAdapter } from "./agents/adapters/research.js";
11
+ import { LocalVerificationAdapter, StubVerificationAdapter } from "./agents/adapters/verification.js";
12
+ let cachedAgentRuntime = null;
13
+ function readPluginRecord(pluginEntry, key) {
14
+ const value = pluginEntry.plugin[key];
15
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
16
+ }
17
+ function assertUniqueProvider(registry, id, owner) {
18
+ if (registry.has(id)) {
19
+ throw new Error(`Treeseed plugin runtime found duplicate provider "${id}" from ${owner}.`);
20
+ }
21
+ }
22
+ function collectAgentHandlersFromPlugin(pluginEntry, registry) {
23
+ const contributedHandlers = readPluginRecord(pluginEntry, "agentHandlers");
24
+ for (const [id, handler] of Object.entries(contributedHandlers)) {
25
+ assertUniqueProvider(registry, id, pluginEntry.package);
26
+ registry.set(id, handler);
27
+ }
28
+ }
29
+ function buildAgentRuntime() {
30
+ const runtime = loadTreeseedPluginRuntime();
31
+ const execution = /* @__PURE__ */ new Map([
32
+ ["stub", () => new StubExecutionAdapter()],
33
+ ["manual", () => new ManualExecutionAdapter()],
34
+ ["copilot", () => new CopilotExecutionAdapter()]
35
+ ]);
36
+ const mutation = /* @__PURE__ */ new Map([
37
+ ["local_branch", (repoRoot) => new LocalBranchMutationAdapter(repoRoot)]
38
+ ]);
39
+ const repository = /* @__PURE__ */ new Map([
40
+ ["stub", () => new StubRepositoryInspectionAdapter()],
41
+ ["git", () => new GitRepositoryInspectionAdapter()]
42
+ ]);
43
+ const verification = /* @__PURE__ */ new Map([
44
+ ["stub", () => new StubVerificationAdapter()],
45
+ ["local", () => new LocalVerificationAdapter()]
46
+ ]);
47
+ const notification = /* @__PURE__ */ new Map([["stub", () => new StubNotificationAdapter()]]);
48
+ const research = /* @__PURE__ */ new Map([["stub", () => new StubResearchAdapter()]]);
49
+ const handlers = /* @__PURE__ */ new Map();
50
+ for (const pluginEntry of runtime.plugins) {
51
+ const agentProviders = readPluginRecord(pluginEntry, "agentProviders");
52
+ for (const [id, factory] of Object.entries(agentProviders.execution ?? {})) {
53
+ assertUniqueProvider(execution, id, pluginEntry.package);
54
+ execution.set(id, factory);
55
+ }
56
+ for (const [id, factory] of Object.entries(agentProviders.mutation ?? {})) {
57
+ assertUniqueProvider(mutation, id, pluginEntry.package);
58
+ mutation.set(id, factory);
59
+ }
60
+ for (const [id, factory] of Object.entries(agentProviders.repository ?? {})) {
61
+ assertUniqueProvider(repository, id, pluginEntry.package);
62
+ repository.set(id, factory);
63
+ }
64
+ for (const [id, factory] of Object.entries(agentProviders.verification ?? {})) {
65
+ assertUniqueProvider(verification, id, pluginEntry.package);
66
+ verification.set(id, factory);
67
+ }
68
+ for (const [id, factory] of Object.entries(agentProviders.notification ?? {})) {
69
+ assertUniqueProvider(notification, id, pluginEntry.package);
70
+ notification.set(id, factory);
71
+ }
72
+ for (const [id, factory] of Object.entries(agentProviders.research ?? {})) {
73
+ assertUniqueProvider(research, id, pluginEntry.package);
74
+ research.set(id, factory);
75
+ }
76
+ collectAgentHandlersFromPlugin(pluginEntry, handlers);
77
+ }
78
+ return {
79
+ providers: { execution, mutation, repository, verification, notification, research },
80
+ handlers
81
+ };
82
+ }
83
+ function resolveAgentRuntimeProviders(repoRoot, selections) {
84
+ if (!cachedAgentRuntime) {
85
+ cachedAgentRuntime = buildAgentRuntime();
86
+ }
87
+ const executionFactory = cachedAgentRuntime.providers.execution.get(selections.execution);
88
+ const mutationFactory = cachedAgentRuntime.providers.mutation.get(selections.mutation);
89
+ const repositoryFactory = cachedAgentRuntime.providers.repository.get(selections.repository);
90
+ const verificationFactory = cachedAgentRuntime.providers.verification.get(selections.verification);
91
+ const notificationFactory = cachedAgentRuntime.providers.notification.get(selections.notification);
92
+ const researchFactory = cachedAgentRuntime.providers.research.get(selections.research);
93
+ if (!executionFactory) throw new Error(`Treeseed agent execution provider "${selections.execution}" is not registered.`);
94
+ if (!mutationFactory) throw new Error(`Treeseed agent mutation provider "${selections.mutation}" is not registered.`);
95
+ if (!repositoryFactory) throw new Error(`Treeseed agent repository provider "${selections.repository}" is not registered.`);
96
+ if (!verificationFactory) throw new Error(`Treeseed agent verification provider "${selections.verification}" is not registered.`);
97
+ if (!notificationFactory) throw new Error(`Treeseed agent notification provider "${selections.notification}" is not registered.`);
98
+ if (!researchFactory) throw new Error(`Treeseed agent research provider "${selections.research}" is not registered.`);
99
+ return {
100
+ execution: executionFactory(),
101
+ mutations: mutationFactory(repoRoot),
102
+ repository: repositoryFactory(),
103
+ verification: verificationFactory(),
104
+ notifications: notificationFactory(),
105
+ research: researchFactory(),
106
+ handlers: cachedAgentRuntime.handlers
107
+ };
108
+ }
109
+ export {
110
+ resolveAgentRuntimeProviders
111
+ };
@@ -0,0 +1,11 @@
1
+ export { AgentKernel } from './agents/kernel/agent-kernel.ts';
2
+ export { listTreeseedAgentCommands, renderTreeseedAgentHelp, runTreeseedAgentCli } from './agents/cli.ts';
3
+ export { resolveAgentHandler, listRegisteredAgentHandlers } from './agents/registry.ts';
4
+ export { resolveAgentRuntimeProviders } from './agent-runtime.ts';
5
+ export { createManagerApp } from './services/manager.ts';
6
+ export { runWorkerCycle, startWorkerLoop } from './services/worker.ts';
7
+ export { runWorkdayStart } from './services/workday-start.ts';
8
+ export { runWorkdayReport } from './services/workday-report.ts';
9
+ export { parseAgentMessagePayload, AGENT_MESSAGE_TYPES } from './agents/contracts/messages.ts';
10
+ export type * from './agents/runtime-types.ts';
11
+ export type * from './agents/contracts/run.ts';
package/dist/agent.js ADDED
@@ -0,0 +1,25 @@
1
+ import { AgentKernel } from "./agents/kernel/agent-kernel.js";
2
+ import { listTreeseedAgentCommands, renderTreeseedAgentHelp, runTreeseedAgentCli } from "./agents/cli.js";
3
+ import { resolveAgentHandler, listRegisteredAgentHandlers } from "./agents/registry.js";
4
+ import { resolveAgentRuntimeProviders } from "./agent-runtime.js";
5
+ import { createManagerApp } from "./services/manager.js";
6
+ import { runWorkerCycle, startWorkerLoop } from "./services/worker.js";
7
+ import { runWorkdayStart } from "./services/workday-start.js";
8
+ import { runWorkdayReport } from "./services/workday-report.js";
9
+ import { parseAgentMessagePayload, AGENT_MESSAGE_TYPES } from "./agents/contracts/messages.js";
10
+ export {
11
+ AGENT_MESSAGE_TYPES,
12
+ AgentKernel,
13
+ createManagerApp,
14
+ listRegisteredAgentHandlers,
15
+ listTreeseedAgentCommands,
16
+ parseAgentMessagePayload,
17
+ renderTreeseedAgentHelp,
18
+ resolveAgentHandler,
19
+ resolveAgentRuntimeProviders,
20
+ runTreeseedAgentCli,
21
+ runWorkdayReport,
22
+ runWorkdayStart,
23
+ runWorkerCycle,
24
+ startWorkerLoop
25
+ };
@@ -0,0 +1,46 @@
1
+ import type { AgentExecutionAdapter } from '../runtime-types.ts';
2
+ export declare class StubExecutionAdapter implements AgentExecutionAdapter {
3
+ runTask(input: {
4
+ prompt: string;
5
+ runId: string;
6
+ }): Promise<{
7
+ status: "completed";
8
+ summary: string;
9
+ stdout: string;
10
+ stderr: string;
11
+ }>;
12
+ }
13
+ export declare class CopilotExecutionAdapter implements AgentExecutionAdapter {
14
+ runTask(input: {
15
+ agent: {
16
+ cli?: {
17
+ model?: string;
18
+ allowTools?: string[];
19
+ additionalArgs?: string[];
20
+ };
21
+ };
22
+ prompt: string;
23
+ }): Promise<{
24
+ status: "completed";
25
+ summary: string;
26
+ stdout: string;
27
+ stderr: string;
28
+ } | {
29
+ status: "failed";
30
+ summary: string;
31
+ stdout: string;
32
+ stderr: string;
33
+ }>;
34
+ }
35
+ export declare class ManualExecutionAdapter implements AgentExecutionAdapter {
36
+ runTask(input: {
37
+ prompt: string;
38
+ runId: string;
39
+ }): Promise<{
40
+ status: "completed";
41
+ summary: string;
42
+ stdout: string;
43
+ stderr: string;
44
+ }>;
45
+ }
46
+ export declare function createExecutionAdapter(): StubExecutionAdapter | CopilotExecutionAdapter | ManualExecutionAdapter;
@@ -0,0 +1,90 @@
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 "@treeseed/sdk/platform/deploy-runtime";
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
+ };
@@ -0,0 +1,22 @@
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
+ }
@@ -0,0 +1,30 @@
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
+ };
@@ -0,0 +1,11 @@
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 function createNotificationAdapter(): StubNotificationAdapter;
@@ -0,0 +1,16 @@
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
+ };
@@ -0,0 +1,23 @@
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;
@@ -0,0 +1,61 @@
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
+ };
@@ -0,0 +1,14 @@
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 function createResearchAdapter(): StubResearchAdapter;
@@ -0,0 +1,25 @@
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
+ };
@@ -0,0 +1,36 @@
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;
@@ -0,0 +1,62 @@
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
+ };
@@ -0,0 +1 @@
1
+ export { normalizeAgentCliOptions, buildCopilotAllowToolArgs } from '@treeseed/sdk/cli-tools';