@treeseed/core 0.8.2 → 0.8.4

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 +106 -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,157 +0,0 @@
1
- import crypto from "node:crypto";
2
- function followCursorKey(models) {
3
- return `follow:${(models ?? []).join(",") || "all"}`;
4
- }
5
- function buildManualInvocation(agent) {
6
- const scheduleLike = agent.triggers.find((trigger) => trigger.type === "schedule" || trigger.type === "startup");
7
- if (!scheduleLike) {
8
- return null;
9
- }
10
- return {
11
- kind: "manual",
12
- source: "manual",
13
- trigger: scheduleLike
14
- };
15
- }
16
- function evaluateCooldown(agent, lastRunAt) {
17
- const cooldownMs = agent.execution.cooldownSeconds * 1e3;
18
- return (lastRunAt ?? 0) > 0 && Date.now() - (lastRunAt ?? 0) < cooldownMs;
19
- }
20
- async function resolveMessageTrigger(agent, sdk, trigger, messageBatchSize) {
21
- for (let index = 0; index < messageBatchSize; index += 1) {
22
- const claimed = await sdk.claimMessage({
23
- workerId: `${agent.slug}-${crypto.randomUUID()}`,
24
- messageTypes: trigger.messageTypes ?? [],
25
- leaseSeconds: agent.execution.leaseSeconds
26
- });
27
- if (claimed.payload) {
28
- return {
29
- kind: "ready",
30
- selectedTrigger: trigger,
31
- invocation: {
32
- kind: "message",
33
- source: "message",
34
- trigger,
35
- message: claimed.payload
36
- }
37
- };
38
- }
39
- }
40
- return {
41
- kind: "no_message_available",
42
- selectedTrigger: trigger,
43
- reason: `No matching messages for ${agent.slug}.`
44
- };
45
- }
46
- async function resolveFollowTrigger(agent, sdk, trigger) {
47
- const models = trigger.models ?? [];
48
- const since = (await sdk.getCursor({
49
- agentSlug: agent.slug,
50
- cursorKey: followCursorKey(models)
51
- })).payload ?? trigger.sinceField ?? (/* @__PURE__ */ new Date(0)).toISOString();
52
- for (const model of models) {
53
- const followed = await sdk.follow({
54
- model,
55
- since: String(since)
56
- });
57
- if (followed.payload.items.length) {
58
- return {
59
- kind: "ready",
60
- selectedTrigger: trigger,
61
- invocation: {
62
- kind: "follow",
63
- source: "follow",
64
- trigger,
65
- followModels: models,
66
- cursorValue: String(since)
67
- }
68
- };
69
- }
70
- }
71
- return {
72
- kind: "no_follow_activity",
73
- selectedTrigger: trigger,
74
- reason: `No followed activity for ${agent.slug}.`
75
- };
76
- }
77
- function resolveScheduleLikeTrigger(agent, trigger, mode, lastRunAt) {
78
- if (mode !== "manual" && evaluateCooldown(agent, lastRunAt)) {
79
- return {
80
- kind: "blocked_by_cooldown",
81
- selectedTrigger: trigger,
82
- reason: `Agent ${agent.slug} is cooling down.`
83
- };
84
- }
85
- return {
86
- kind: "ready",
87
- selectedTrigger: trigger,
88
- invocation: {
89
- kind: mode === "manual" ? "manual" : trigger.type === "startup" || trigger.runOnStart ? "startup" : "schedule",
90
- source: mode === "manual" ? "manual" : trigger.type === "startup" || trigger.runOnStart ? "startup" : "schedule",
91
- trigger
92
- }
93
- };
94
- }
95
- async function resolveTriggerDecision(input) {
96
- if (input.isRunning) {
97
- return {
98
- kind: "blocked_by_concurrency",
99
- reason: `Agent ${input.agent.slug} is already running.`
100
- };
101
- }
102
- const mode = input.mode ?? "auto";
103
- const messageBatchSize = input.agent.triggerPolicy?.messageBatchSize ?? 1;
104
- const triggerGroups = {
105
- message: input.agent.triggers.filter((trigger) => trigger.type === "message"),
106
- follow: input.agent.triggers.filter((trigger) => trigger.type === "follow"),
107
- schedule: input.agent.triggers.filter((trigger) => trigger.type === "startup" || trigger.type === "schedule")
108
- };
109
- for (const trigger of triggerGroups.message) {
110
- const decision = await resolveMessageTrigger(input.agent, input.sdk, trigger, messageBatchSize);
111
- if (!decision) {
112
- continue;
113
- }
114
- if (decision.kind === "ready") {
115
- return decision;
116
- }
117
- }
118
- for (const trigger of triggerGroups.follow) {
119
- const decision = await resolveFollowTrigger(input.agent, input.sdk, trigger);
120
- if (decision.kind === "ready") {
121
- return decision;
122
- }
123
- }
124
- for (const trigger of triggerGroups.schedule) {
125
- const decision = resolveScheduleLikeTrigger(input.agent, trigger, mode, input.lastRunAt);
126
- if (decision.kind === "ready") {
127
- return decision;
128
- }
129
- if (decision.kind === "blocked_by_cooldown") {
130
- return decision;
131
- }
132
- }
133
- if (mode === "manual") {
134
- const invocation = buildManualInvocation(input.agent);
135
- return invocation ? { kind: "ready", invocation, selectedTrigger: invocation.trigger } : { kind: "no_trigger_available", reason: `No manual-capable trigger found for ${input.agent.slug}.` };
136
- }
137
- if (triggerGroups.message.length) {
138
- return {
139
- kind: "no_message_available",
140
- reason: `No matching messages for ${input.agent.slug}.`
141
- };
142
- }
143
- if (triggerGroups.follow.length) {
144
- return {
145
- kind: "no_follow_activity",
146
- reason: `No followed activity for ${input.agent.slug}.`
147
- };
148
- }
149
- return {
150
- kind: "no_trigger_available",
151
- reason: `No runnable triggers defined for ${input.agent.slug}.`
152
- };
153
- }
154
- export {
155
- followCursorKey,
156
- resolveTriggerDecision
157
- };
@@ -1,4 +0,0 @@
1
- import type { AgentHandlerKind } from '@treeseed/sdk/types/agents';
2
- import type { AgentHandler } from './runtime-types.ts';
3
- export declare function defineAgentHandlerRegistry(registry: Partial<Record<AgentHandlerKind, AgentHandler>>): Partial<Record<string, AgentHandler<unknown, unknown>>>;
4
- export declare function resolveAgentHandlerFromRegistry(registry: Partial<Record<AgentHandlerKind, AgentHandler>>, kind: AgentHandlerKind): AgentHandler<unknown, unknown>;
@@ -1,14 +0,0 @@
1
- function defineAgentHandlerRegistry(registry) {
2
- return registry;
3
- }
4
- function resolveAgentHandlerFromRegistry(registry, kind) {
5
- const handler = registry[kind];
6
- if (!handler) {
7
- throw new Error(`No runtime handler is registered for agent handler "${kind}".`);
8
- }
9
- return handler;
10
- }
11
- export {
12
- defineAgentHandlerRegistry,
13
- resolveAgentHandlerFromRegistry
14
- };
@@ -1,6 +0,0 @@
1
- import type { AgentHandlerKind } from '@treeseed/sdk/types/agents';
2
- import type { AgentHandler } from './runtime-types.ts';
3
- export declare function getTenantAgentHandlerModulePaths(kind: AgentHandlerKind, tenantRoot?: string): string[];
4
- export declare function loadTenantAgentHandlerRegistry(tenantRoot?: string): Promise<Record<string, AgentHandler>>;
5
- export declare function listRegisteredAgentHandlers(): Promise<string[]>;
6
- export declare function resolveAgentHandler(kind: AgentHandlerKind): Promise<AgentHandler<unknown, unknown>>;
@@ -1,98 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { resolve } from "node:path";
3
- import { pathToFileURL } from "node:url";
4
- import { getTreeseedAgentProviderSelections } from "@treeseed/sdk/platform/deploy-runtime";
5
- import { resolveTreeseedTenantRoot } from "@treeseed/sdk/platform/tenant-config";
6
- import { resolveAgentRuntimeProviders } from "../agent-runtime.js";
7
- const BUILTIN_HANDLER_KINDS = [
8
- "planner",
9
- "architect",
10
- "engineer",
11
- "notifier",
12
- "researcher",
13
- "reviewer",
14
- "releaser"
15
- ];
16
- const HANDLER_EXPORT_NAMES = {
17
- planner: "plannerHandler",
18
- architect: "architectHandler",
19
- engineer: "engineerHandler",
20
- notifier: "notifierHandler",
21
- researcher: "researcherHandler",
22
- reviewer: "reviewerHandler",
23
- releaser: "releaserHandler"
24
- };
25
- function getTenantAgentHandlerModulePaths(kind, tenantRoot = resolveTreeseedTenantRoot()) {
26
- return [
27
- resolve(tenantRoot, "src/agents", `${kind}.js`),
28
- resolve(tenantRoot, "src/agents", `${kind}.ts`)
29
- ];
30
- }
31
- async function loadTenantAgentHandlerRegistry(tenantRoot = resolveTreeseedTenantRoot()) {
32
- const registry = {};
33
- for (const kind of BUILTIN_HANDLER_KINDS) {
34
- const modulePath = getTenantAgentHandlerModulePaths(kind, tenantRoot).find((candidate) => existsSync(candidate));
35
- if (!modulePath) {
36
- continue;
37
- }
38
- let moduleExports;
39
- try {
40
- moduleExports = await import(
41
- /* @vite-ignore */
42
- pathToFileURL(modulePath).href
43
- );
44
- } catch (error) {
45
- const reason = error instanceof Error ? error.message : String(error);
46
- throw new Error(`Failed to import tenant agent handler "${kind}" from ${modulePath}: ${reason}`);
47
- }
48
- const exportName = HANDLER_EXPORT_NAMES[kind];
49
- const handler = moduleExports[exportName];
50
- if (!handler) {
51
- throw new Error(
52
- `Tenant agent handler module "${modulePath}" must export "${exportName}" for handler kind "${kind}".`
53
- );
54
- }
55
- const normalizedHandler = handler;
56
- if (normalizedHandler.kind !== kind) {
57
- throw new Error(
58
- `Tenant agent handler "${exportName}" from "${modulePath}" declares kind "${normalizedHandler.kind}", but "${kind}" was expected.`
59
- );
60
- }
61
- registry[kind] = normalizedHandler;
62
- }
63
- return registry;
64
- }
65
- let agentHandlerRegistryPromise = null;
66
- async function getAgentHandlerRegistry() {
67
- if (!agentHandlerRegistryPromise) {
68
- agentHandlerRegistryPromise = loadTenantAgentHandlerRegistry();
69
- }
70
- return agentHandlerRegistryPromise;
71
- }
72
- async function listRegisteredAgentHandlers() {
73
- const registry = await getAgentHandlerRegistry();
74
- const runtimeProviders = resolveAgentRuntimeProviders(resolveTreeseedTenantRoot(), getTreeseedAgentProviderSelections());
75
- return [.../* @__PURE__ */ new Set([...Object.keys(registry), ...runtimeProviders.handlers.keys()])];
76
- }
77
- async function resolveAgentHandler(kind) {
78
- const registry = await getAgentHandlerRegistry();
79
- const runtimeProviders = resolveAgentRuntimeProviders(resolveTreeseedTenantRoot(), getTreeseedAgentProviderSelections());
80
- const handler = registry[kind] ?? runtimeProviders.handlers.get(kind);
81
- if (!handler) {
82
- if (BUILTIN_HANDLER_KINDS.includes(kind)) {
83
- const expectedPath = getTenantAgentHandlerModulePaths(kind).join('" or "');
84
- const expectedExport = HANDLER_EXPORT_NAMES[kind];
85
- throw new Error(
86
- `No runtime handler is registered for agent handler "${kind}". Expected tenant file "${expectedPath}" exporting "${expectedExport}" or a plugin contribution.`
87
- );
88
- }
89
- throw new Error(`No runtime handler is registered for agent handler "${kind}".`);
90
- }
91
- return handler;
92
- }
93
- export {
94
- getTenantAgentHandlerModulePaths,
95
- listRegisteredAgentHandlers,
96
- loadTenantAgentHandlerRegistry,
97
- resolveAgentHandler
98
- };
@@ -1,118 +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 } from '@treeseed/sdk/sdk';
4
- import type { SdkMessageEntity } from '@treeseed/sdk/types';
5
- export interface AgentTriggerInvocation {
6
- kind: 'startup' | 'schedule' | 'message' | 'manual' | 'follow';
7
- source: string;
8
- trigger: AgentTriggerConfig;
9
- message?: SdkMessageEntity | null;
10
- followModels?: string[];
11
- cursorValue?: string | null;
12
- }
13
- export interface AgentExecutionResult {
14
- status: AgentRunStatus;
15
- summary: string;
16
- stdout?: string;
17
- stderr?: string;
18
- errorCategory?: AgentErrorCategory | null;
19
- metadata?: Record<string, unknown>;
20
- }
21
- export interface AgentMutationResult {
22
- branchName: string | null;
23
- commitMessage: string | null;
24
- worktreePath: string | null;
25
- commitSha: string | null;
26
- changedPaths: string[];
27
- }
28
- export interface AgentRepositoryInspectionResult {
29
- branchName: string | null;
30
- changedPaths: string[];
31
- commitSha: string | null;
32
- summary: string;
33
- }
34
- export interface AgentVerificationResult {
35
- status: 'completed' | 'failed' | 'waiting';
36
- summary: string;
37
- stdout?: string;
38
- stderr?: string;
39
- errorCategory?: AgentErrorCategory | null;
40
- }
41
- export interface AgentNotificationResult {
42
- status: 'completed' | 'failed' | 'waiting';
43
- summary: string;
44
- deliveredCount: number;
45
- }
46
- export interface AgentResearchResult {
47
- status: 'completed' | 'failed' | 'waiting';
48
- summary: string;
49
- markdown: string;
50
- sources?: string[];
51
- errorCategory?: AgentErrorCategory | null;
52
- }
53
- export interface AgentExecutionAdapter {
54
- runTask(input: {
55
- agent: AgentRuntimeSpec;
56
- runId: string;
57
- prompt: string;
58
- }): Promise<AgentExecutionResult>;
59
- }
60
- export interface AgentMutationAdapter {
61
- writeArtifact(input: {
62
- runId: string;
63
- agent: AgentRuntimeSpec;
64
- relativePath: string;
65
- content: string;
66
- commitMessage: string;
67
- }): Promise<AgentMutationResult>;
68
- }
69
- export interface AgentRepositoryInspectionAdapter {
70
- inspectBranch(input: {
71
- repoRoot: string;
72
- branchName: string | null;
73
- }): Promise<AgentRepositoryInspectionResult>;
74
- }
75
- export interface AgentVerificationAdapter {
76
- runChecks(input: {
77
- agent: AgentRuntimeSpec;
78
- runId: string;
79
- commands: string[];
80
- }): Promise<AgentVerificationResult>;
81
- }
82
- export interface AgentNotificationAdapter {
83
- deliver(input: {
84
- agent: AgentRuntimeSpec;
85
- runId: string;
86
- recipients: string[];
87
- subject: string;
88
- body: string;
89
- }): Promise<AgentNotificationResult>;
90
- }
91
- export interface AgentResearchAdapter {
92
- research(input: {
93
- agent: AgentRuntimeSpec;
94
- runId: string;
95
- questionId: string;
96
- reason: string | null;
97
- }): Promise<AgentResearchResult>;
98
- }
99
- export interface AgentContext {
100
- runId: string;
101
- repoRoot: string;
102
- agent: AgentRuntimeSpec;
103
- sdk: ScopedAgentSdk;
104
- trigger: AgentTriggerInvocation;
105
- execution: AgentExecutionAdapter;
106
- mutations: AgentMutationAdapter;
107
- repository: AgentRepositoryInspectionAdapter;
108
- verification: AgentVerificationAdapter;
109
- notifications: AgentNotificationAdapter;
110
- research: AgentResearchAdapter;
111
- }
112
- export interface AgentHandler<TInputs = unknown, TResult = unknown> {
113
- kind: AgentHandlerKind;
114
- resolveInputs(context: AgentContext): Promise<TInputs>;
115
- execute(context: AgentContext, inputs: TInputs): Promise<TResult>;
116
- emitOutputs(context: AgentContext, result: TResult): Promise<AgentExecutionResult>;
117
- }
118
- export {};
File without changes
@@ -1,18 +0,0 @@
1
- import type { AgentRuntimeSpec } from '@treeseed/sdk/types/agents';
2
- import { AgentSdk } from '@treeseed/sdk/sdk';
3
- import type { AgentSpecDiagnostic, NormalizedAgentRuntimeSpec } from './spec-types.ts';
4
- export interface AgentSpecLoadResult {
5
- specs: NormalizedAgentRuntimeSpec[];
6
- diagnostics: AgentSpecDiagnostic[];
7
- }
8
- export declare function loadAgentSpecs(sdk: AgentSdk, options?: {
9
- enabled?: boolean;
10
- }): Promise<AgentSpecLoadResult>;
11
- export declare function loadActiveAgentSpecs(sdk: AgentSdk): Promise<AgentSpecLoadResult>;
12
- export declare function loadAllAgentSpecs(sdk: AgentSdk): Promise<AgentSpecLoadResult>;
13
- export declare function summarizeAgentSpec(agent: AgentRuntimeSpec): {
14
- slug: string;
15
- handler: string;
16
- enabled: boolean;
17
- triggers: ("startup" | "schedule" | "message" | "follow")[];
18
- };
@@ -1,55 +0,0 @@
1
- import { AgentSdk } from "@treeseed/sdk/sdk";
2
- import { AGENT_MESSAGE_TYPES } from "./contracts/messages.js";
3
- import { listRegisteredAgentHandlers } from "./registry.js";
4
- import { normalizeAgentRuntimeSpec } from "./spec-normalizer.js";
5
- function extractRawSpec(entry) {
6
- const frontmatter = entry.frontmatter && typeof entry.frontmatter === "object" ? entry.frontmatter : {};
7
- return {
8
- ...frontmatter,
9
- body: entry.body,
10
- id: entry.id
11
- };
12
- }
13
- async function loadAgentSpecs(sdk, options) {
14
- const entries = typeof sdk.listRawAgentSpecs === "function" ? await sdk.listRawAgentSpecs(options) : (await sdk.listAgentSpecs(options)).map(
15
- (spec) => ({
16
- id: spec.slug,
17
- body: "",
18
- frontmatter: spec
19
- })
20
- );
21
- const diagnostics = [];
22
- const specs = [];
23
- for (const entry of entries) {
24
- const registeredHandlers = await listRegisteredAgentHandlers();
25
- const result = normalizeAgentRuntimeSpec(extractRawSpec(entry), {
26
- registeredHandlers,
27
- messageTypes: [...AGENT_MESSAGE_TYPES]
28
- });
29
- diagnostics.push(...result.diagnostics);
30
- if (result.spec) {
31
- specs.push(result.spec);
32
- }
33
- }
34
- return { specs, diagnostics };
35
- }
36
- async function loadActiveAgentSpecs(sdk) {
37
- return loadAgentSpecs(sdk, { enabled: true });
38
- }
39
- async function loadAllAgentSpecs(sdk) {
40
- return loadAgentSpecs(sdk);
41
- }
42
- function summarizeAgentSpec(agent) {
43
- return {
44
- slug: agent.slug,
45
- handler: agent.handler,
46
- enabled: agent.enabled,
47
- triggers: agent.triggers.map((trigger) => trigger.type)
48
- };
49
- }
50
- export {
51
- loadActiveAgentSpecs,
52
- loadAgentSpecs,
53
- loadAllAgentSpecs,
54
- summarizeAgentSpec
55
- };
@@ -1,2 +0,0 @@
1
- import type { AgentSpecNormalizationResult, AgentSpecValidationContext, RawAgentRuntimeSpec } from './spec-types.ts';
2
- export declare function normalizeAgentRuntimeSpec(raw: RawAgentRuntimeSpec, context: AgentSpecValidationContext): AgentSpecNormalizationResult;