@treeseed/sdk 0.3.3 → 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.
Files changed (54) hide show
  1. package/README.md +3 -3
  2. package/dist/index.d.ts +1 -7
  3. package/dist/index.js +0 -6
  4. package/dist/operations/runtime.js +1 -1
  5. package/dist/operations/services/config-runtime.d.ts +5 -5
  6. package/dist/operations/services/config-runtime.js +1 -1
  7. package/dist/operations/services/deploy.js +1 -1
  8. package/dist/operations/services/runtime-paths.d.ts +1 -0
  9. package/dist/operations/services/runtime-paths.js +3 -1
  10. package/dist/operations/services/runtime-tools.js +1 -1
  11. package/dist/operations/services/template-registry.d.ts +3 -3
  12. package/dist/operations/services/template-registry.js +5 -4
  13. package/dist/platform/books-data.d.ts +29 -1
  14. package/dist/platform/books-data.js +82 -1
  15. package/dist/platform/deploy-config.d.ts +4 -1
  16. package/dist/platform/deploy-config.js +222 -1
  17. package/dist/platform/deploy-runtime.js +1 -1
  18. package/dist/platform/environment.d.ts +1 -1
  19. package/dist/platform/environment.js +3 -3
  20. package/dist/platform/plugin.d.ts +51 -2
  21. package/dist/platform/plugin.js +3 -1
  22. package/dist/platform/plugins/constants.d.ts +1 -1
  23. package/dist/platform/plugins/constants.js +1 -1
  24. package/dist/platform/plugins/runtime.d.ts +1 -1
  25. package/dist/platform/plugins/runtime.js +5 -5
  26. package/dist/platform/plugins.d.ts +2 -2
  27. package/dist/platform/plugins.js +1 -1
  28. package/dist/platform/tenant/runtime-config.js +1 -1
  29. package/dist/platform/tenant-config.d.ts +7 -1
  30. package/dist/platform/tenant-config.js +153 -1
  31. package/dist/plugin-default.d.ts +25 -0
  32. package/dist/plugin-default.js +37 -0
  33. package/dist/scripts/aggregate-book.js +1 -1
  34. package/dist/scripts/build-tenant-worker.js +2 -2
  35. package/dist/scripts/tenant-destroy.js +1 -1
  36. package/dist/scripts/tenant-dev.js +1 -1
  37. package/dist/treeseed/template-catalog/templates/starter-basic/template/package.json +1 -0
  38. package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +1 -1
  39. package/dist/treeseed/template-catalog/templates/starter-basic/template.config.json +6 -0
  40. package/package.json +5 -25
  41. package/dist/platform/deploy/config.d.ts +0 -4
  42. package/dist/platform/deploy/config.js +0 -222
  43. package/dist/platform/plugins/plugin.d.ts +0 -51
  44. package/dist/platform/plugins/plugin.js +0 -6
  45. package/dist/platform/tenant/config.d.ts +0 -9
  46. package/dist/platform/tenant/config.js +0 -154
  47. package/dist/platform/utils/books-data.d.ts +0 -29
  48. package/dist/platform/utils/books-data.js +0 -82
  49. package/dist/utils/agents/contracts/messages.d.ts +0 -88
  50. package/dist/utils/agents/contracts/messages.js +0 -139
  51. package/dist/utils/agents/contracts/run.d.ts +0 -20
  52. package/dist/utils/agents/contracts/run.js +0 -0
  53. package/dist/utils/agents/runtime-types.d.ts +0 -117
  54. package/dist/utils/agents/runtime-types.js +0 -4
@@ -1,222 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { dirname, resolve } from "node:path";
3
- import { parse as parseYaml } from "yaml";
4
- import { normalizeAliasedRecord } from "../../field-aliases.js";
5
- import { resolveTreeseedTenantRoot } from "../tenant/config.js";
6
- import {
7
- TREESEED_DEFAULT_PLUGIN_REFERENCES,
8
- TREESEED_DEFAULT_PROVIDER_SELECTIONS
9
- } from "../plugins/constants.js";
10
- const deployConfigFieldAliases = {
11
- siteUrl: { key: "siteUrl", aliases: ["site_url"] },
12
- contactEmail: { key: "contactEmail", aliases: ["contact_email"] }
13
- };
14
- const cloudflareFieldAliases = {
15
- accountId: { key: "accountId", aliases: ["account_id"] },
16
- workerName: { key: "workerName", aliases: ["worker_name"] }
17
- };
18
- const CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER = "replace-with-cloudflare-account-id";
19
- function expectString(value, label) {
20
- if (typeof value !== "string" || !value.trim()) {
21
- throw new Error(`Invalid deploy config: expected ${label} to be a non-empty string.`);
22
- }
23
- return value.trim();
24
- }
25
- function optionalString(value) {
26
- if (typeof value !== "string" || !value.trim()) {
27
- return void 0;
28
- }
29
- return value.trim();
30
- }
31
- function optionalCloudflareAccountId(value) {
32
- const accountId = optionalString(value);
33
- return accountId === CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER ? void 0 : accountId;
34
- }
35
- function optionalBoolean(value, label) {
36
- if (value === void 0) {
37
- return void 0;
38
- }
39
- if (typeof value !== "boolean") {
40
- throw new Error(`Invalid deploy config: expected ${label} to be a boolean when provided.`);
41
- }
42
- return value;
43
- }
44
- function optionalRecord(value, label) {
45
- if (value === void 0 || value === null) {
46
- return void 0;
47
- }
48
- if (typeof value !== "object" || Array.isArray(value)) {
49
- throw new Error(`Invalid deploy config: expected ${label} to be an object when provided.`);
50
- }
51
- return value;
52
- }
53
- function parsePluginReferences(value) {
54
- if (value === void 0) {
55
- return [...TREESEED_DEFAULT_PLUGIN_REFERENCES];
56
- }
57
- if (!Array.isArray(value)) {
58
- throw new Error("Invalid deploy config: expected plugins to be an array.");
59
- }
60
- return value.map((entry, index) => {
61
- const record = optionalRecord(entry, `plugins[${index}]`);
62
- return {
63
- package: expectString(record?.package, `plugins[${index}].package`),
64
- enabled: record?.enabled === void 0 ? true : optionalBoolean(record.enabled, `plugins[${index}].enabled`),
65
- config: record?.config === void 0 ? {} : optionalRecord(record.config, `plugins[${index}].config`)
66
- };
67
- });
68
- }
69
- function parseProviderSelections(value) {
70
- const record = optionalRecord(value, "providers");
71
- if (!record) {
72
- return structuredClone(TREESEED_DEFAULT_PROVIDER_SELECTIONS);
73
- }
74
- const agentProviders = optionalRecord(record.agents, "providers.agents") ?? {};
75
- const contentProviders = optionalRecord(record.content, "providers.content") ?? {};
76
- return {
77
- forms: expectString(record.forms ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.forms, "providers.forms"),
78
- operations: expectString(record.operations ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.operations, "providers.operations"),
79
- agents: {
80
- execution: expectString(
81
- agentProviders.execution ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.execution,
82
- "providers.agents.execution"
83
- ),
84
- mutation: expectString(
85
- agentProviders.mutation ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.mutation,
86
- "providers.agents.mutation"
87
- ),
88
- repository: expectString(
89
- agentProviders.repository ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.repository,
90
- "providers.agents.repository"
91
- ),
92
- verification: expectString(
93
- agentProviders.verification ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.verification,
94
- "providers.agents.verification"
95
- ),
96
- notification: expectString(
97
- agentProviders.notification ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.notification,
98
- "providers.agents.notification"
99
- ),
100
- research: expectString(
101
- agentProviders.research ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.research,
102
- "providers.agents.research"
103
- )
104
- },
105
- deploy: expectString(record.deploy ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.deploy, "providers.deploy"),
106
- content: {
107
- docs: expectString(
108
- contentProviders.docs ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.content.docs,
109
- "providers.content.docs"
110
- )
111
- },
112
- site: expectString(record.site ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.site, "providers.site")
113
- };
114
- }
115
- function parseServiceEnvironmentConfig(value, label) {
116
- const record = optionalRecord(value, label) ?? {};
117
- return {
118
- baseUrl: optionalString(record.baseUrl),
119
- domain: optionalString(record.domain),
120
- railwayEnvironment: optionalString(record.railwayEnvironment)
121
- };
122
- }
123
- function parseManagedServiceConfig(value, label) {
124
- const record = optionalRecord(value, label);
125
- if (!record) {
126
- return void 0;
127
- }
128
- const railway = optionalRecord(record.railway, `${label}.railway`) ?? {};
129
- const environments = optionalRecord(record.environments, `${label}.environments`) ?? {};
130
- return {
131
- enabled: record.enabled === void 0 ? void 0 : optionalBoolean(record.enabled, `${label}.enabled`),
132
- provider: optionalString(record.provider),
133
- rootDir: optionalString(record.rootDir),
134
- publicBaseUrl: optionalString(record.publicBaseUrl),
135
- railway: {
136
- projectId: optionalString(railway.projectId),
137
- projectName: optionalString(railway.projectName),
138
- serviceId: optionalString(railway.serviceId),
139
- serviceName: optionalString(railway.serviceName),
140
- rootDir: optionalString(railway.rootDir),
141
- buildCommand: optionalString(railway.buildCommand),
142
- startCommand: optionalString(railway.startCommand)
143
- },
144
- environments: {
145
- local: parseServiceEnvironmentConfig(environments.local, `${label}.environments.local`),
146
- staging: parseServiceEnvironmentConfig(environments.staging, `${label}.environments.staging`),
147
- prod: parseServiceEnvironmentConfig(environments.prod, `${label}.environments.prod`)
148
- }
149
- };
150
- }
151
- function parseManagedServicesConfig(value) {
152
- const record = optionalRecord(value, "services");
153
- if (!record) {
154
- return void 0;
155
- }
156
- return {
157
- api: parseManagedServiceConfig(record.api, "services.api"),
158
- agents: parseManagedServiceConfig(record.agents, "services.agents")
159
- };
160
- }
161
- function parseDeployConfig(raw) {
162
- const parsed = normalizeAliasedRecord(
163
- deployConfigFieldAliases,
164
- parseYaml(raw) ?? {}
165
- );
166
- const cloudflare = normalizeAliasedRecord(
167
- cloudflareFieldAliases,
168
- optionalRecord(parsed.cloudflare, "cloudflare") ?? {}
169
- );
170
- const smtp = optionalRecord(parsed.smtp, "smtp") ?? {};
171
- const turnstile = optionalRecord(parsed.turnstile, "turnstile") ?? {};
172
- optionalBoolean(turnstile.enabled, "turnstile.enabled");
173
- return {
174
- name: expectString(parsed.name, "name"),
175
- slug: expectString(parsed.slug, "slug"),
176
- siteUrl: expectString(parsed.siteUrl, "siteUrl"),
177
- contactEmail: expectString(parsed.contactEmail, "contactEmail"),
178
- cloudflare: {
179
- accountId: optionalCloudflareAccountId(cloudflare.accountId) ?? optionalCloudflareAccountId(process.env.CLOUDFLARE_ACCOUNT_ID) ?? CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER,
180
- workerName: optionalString(cloudflare.workerName)
181
- },
182
- plugins: parsePluginReferences(parsed.plugins),
183
- providers: parseProviderSelections(parsed.providers),
184
- services: parseManagedServicesConfig(parsed.services),
185
- smtp: {
186
- enabled: optionalBoolean(smtp.enabled, "smtp.enabled")
187
- },
188
- turnstile: {
189
- enabled: true
190
- }
191
- };
192
- }
193
- function resolveTreeseedDeployConfigPath(configPath = "treeseed.site.yaml") {
194
- const tenantRoot = resolveTreeseedTenantRoot();
195
- const candidate = resolve(tenantRoot, configPath);
196
- if (!existsSync(candidate)) {
197
- throw new Error(`Unable to resolve Treeseed deploy config at "${candidate}".`);
198
- }
199
- return candidate;
200
- }
201
- function deriveCloudflareWorkerName(config) {
202
- return config.cloudflare.workerName?.trim() || config.slug;
203
- }
204
- function loadTreeseedDeployConfig(configPath = "treeseed.site.yaml") {
205
- const resolvedConfigPath = resolveTreeseedDeployConfigPath(configPath);
206
- const tenantRoot = dirname(resolvedConfigPath);
207
- const parsed = parseDeployConfig(readFileSync(resolvedConfigPath, "utf8"));
208
- Object.defineProperty(parsed, "__tenantRoot", {
209
- value: tenantRoot,
210
- enumerable: false
211
- });
212
- Object.defineProperty(parsed, "__configPath", {
213
- value: resolvedConfigPath,
214
- enumerable: false
215
- });
216
- return parsed;
217
- }
218
- export {
219
- deriveCloudflareWorkerName,
220
- loadTreeseedDeployConfig,
221
- resolveTreeseedDeployConfigPath
222
- };
@@ -1,51 +0,0 @@
1
- import type { TreeseedDeployConfig, TreeseedTenantConfig } from '../contracts.ts';
2
- import type { TreeseedEnvironmentRegistryOverlay } from '../environment.ts';
3
- import type { SdkGraphRankingProvider } from '../../sdk-types.ts';
4
- export type TreeseedSiteLayerDefinition = {
5
- root: string;
6
- kinds?: Array<'pages' | 'styles' | 'components'>;
7
- };
8
- export type TreeseedSiteRouteContribution = {
9
- pattern: string;
10
- entrypoint?: string;
11
- resourcePath?: string;
12
- };
13
- export type TreeseedSiteExtensionContribution = {
14
- routes?: TreeseedSiteRouteContribution[];
15
- starlightComponents?: Record<string, string>;
16
- customCss?: string[];
17
- remarkPlugins?: unknown[];
18
- rehypePlugins?: unknown[];
19
- envSchema?: Record<string, unknown>;
20
- vitePlugins?: unknown[];
21
- integrations?: unknown[];
22
- routeMiddleware?: unknown[];
23
- };
24
- export type TreeseedPluginSiteContext = {
25
- projectRoot: string;
26
- tenantConfig: TreeseedTenantConfig;
27
- siteConfig?: unknown;
28
- deployConfig?: TreeseedDeployConfig;
29
- pluginConfig: Record<string, unknown>;
30
- };
31
- export type TreeseedPluginEnvironmentContext = {
32
- projectRoot: string;
33
- tenantConfig?: TreeseedTenantConfig;
34
- deployConfig?: TreeseedDeployConfig;
35
- pluginConfig: Record<string, unknown>;
36
- };
37
- export type TreeseedGraphRankingProviderContribution = SdkGraphRankingProvider | ((context: TreeseedPluginEnvironmentContext) => SdkGraphRankingProvider | undefined);
38
- export interface TreeseedPlugin {
39
- id?: string;
40
- provides?: Record<string, any> & {
41
- operations?: string[];
42
- };
43
- operationProviders?: Record<string, unknown>;
44
- siteProviders?: Record<string, TreeseedSiteExtensionContribution | ((context: TreeseedPluginSiteContext) => TreeseedSiteExtensionContribution)>;
45
- siteHooks?: TreeseedSiteExtensionContribution | ((context: TreeseedPluginSiteContext) => TreeseedSiteExtensionContribution);
46
- siteLayers?: TreeseedSiteLayerDefinition[] | ((context: TreeseedPluginSiteContext) => TreeseedSiteLayerDefinition[] | undefined);
47
- environmentRegistry?: TreeseedEnvironmentRegistryOverlay | ((context: TreeseedPluginEnvironmentContext) => TreeseedEnvironmentRegistryOverlay | undefined);
48
- graphRankingProviders?: Record<string, TreeseedGraphRankingProviderContribution>;
49
- [key: string]: unknown;
50
- }
51
- export declare function defineTreeseedPlugin<T extends TreeseedPlugin>(plugin: T): T;
@@ -1,6 +0,0 @@
1
- function defineTreeseedPlugin(plugin) {
2
- return plugin;
3
- }
4
- export {
5
- defineTreeseedPlugin
6
- };
@@ -1,9 +0,0 @@
1
- import type { TreeseedTenantConfig } from '../contracts.ts';
2
- declare function resolveTenantRoot(): string;
3
- export declare function defineTreeseedTenant<T>(tenantConfig: T): T;
4
- export declare function loadTreeseedManifest(manifestPath?: string): TreeseedTenantConfig;
5
- export declare const loadTreeseedTenantManifest: typeof loadTreeseedManifest;
6
- export declare const resolveTreeseedTenantRoot: typeof resolveTenantRoot;
7
- export declare function getTenantContentRoot(tenantConfig: Pick<TreeseedTenantConfig, 'content'>, collectionName: string): string;
8
- export declare function tenantFeatureEnabled(tenantConfig: Pick<TreeseedTenantConfig, 'features'>, featureName: string): boolean;
9
- export {};
@@ -1,154 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { dirname, resolve } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { parse as parseYaml } from "yaml";
5
- import { normalizeAliasedRecord } from "../../field-aliases.js";
6
- function resolvePackageRoot() {
7
- const moduleUrl = typeof import.meta?.url === "string" ? import.meta.url : null;
8
- if (!moduleUrl) {
9
- return process.cwd();
10
- }
11
- return resolve(dirname(fileURLToPath(moduleUrl)), "../..");
12
- }
13
- const packageRoot = resolvePackageRoot();
14
- const packageFixtureRoot = resolve(packageRoot, ".fixtures", "treeseed-fixtures", "sites", "working-site");
15
- const explicitTenantRoot = process.env.TREESEED_TENANT_ROOT ? resolve(process.env.TREESEED_TENANT_ROOT) : null;
16
- const manifestFieldAliases = {
17
- siteConfigPath: { key: "siteConfigPath", aliases: ["site_config_path"] }
18
- };
19
- const manifestContentFieldAliases = {
20
- pages: { key: "pages", aliases: ["page_root", "pages_root"] },
21
- notes: { key: "notes", aliases: ["notes_root"] },
22
- questions: { key: "questions", aliases: ["questions_root"] },
23
- objectives: { key: "objectives", aliases: ["objectives_root"] },
24
- people: { key: "people", aliases: ["people_root"] },
25
- agents: { key: "agents", aliases: ["agents_root"] },
26
- books: { key: "books", aliases: ["books_root"] },
27
- docs: { key: "docs", aliases: ["knowledge", "knowledge_root", "docs_root"] }
28
- };
29
- const manifestOverrideFieldAliases = {
30
- pagesRoot: { key: "pagesRoot", aliases: ["pages_root"] },
31
- stylesRoot: { key: "stylesRoot", aliases: ["styles_root"] },
32
- componentsRoot: { key: "componentsRoot", aliases: ["components_root"] }
33
- };
34
- function pathWithin(parent, candidate) {
35
- const normalizedParent = resolve(parent);
36
- const normalizedCandidate = resolve(candidate);
37
- return normalizedCandidate === normalizedParent || normalizedCandidate.startsWith(`${normalizedParent}/`);
38
- }
39
- function collectTenantRootCandidates(start) {
40
- const candidates = [];
41
- let current = resolve(start);
42
- while (true) {
43
- candidates.push(
44
- current,
45
- resolve(current, ".fixtures", "treeseed-fixtures", "sites", "working-site"),
46
- resolve(current, "fixture")
47
- );
48
- const parent = resolve(current, "..");
49
- if (parent === current) {
50
- break;
51
- }
52
- current = parent;
53
- }
54
- return candidates;
55
- }
56
- function uniqueCandidates(entries) {
57
- return [...new Set(entries.map((entry) => resolve(entry)))];
58
- }
59
- function tenantRootCandidates() {
60
- const cwd = resolve(process.cwd());
61
- const cwdCandidates = collectTenantRootCandidates(cwd);
62
- const packageCandidates = collectTenantRootCandidates(packageRoot);
63
- if (explicitTenantRoot) {
64
- return uniqueCandidates([explicitTenantRoot, ...cwdCandidates, packageFixtureRoot, ...packageCandidates]);
65
- }
66
- if (pathWithin(packageRoot, cwd)) {
67
- return uniqueCandidates([packageFixtureRoot, ...cwdCandidates, ...packageCandidates]);
68
- }
69
- return uniqueCandidates([...cwdCandidates, packageFixtureRoot, ...packageCandidates]);
70
- }
71
- function resolveTenantPath(manifestPath) {
72
- if (existsSync(manifestPath)) {
73
- return resolve(manifestPath);
74
- }
75
- const candidates = tenantRootCandidates().map((root) => resolve(root, manifestPath));
76
- for (const candidate of candidates) {
77
- if (existsSync(candidate)) {
78
- return candidate;
79
- }
80
- }
81
- throw new Error(
82
- `Unable to resolve Treeseed tenant manifest at "${manifestPath}" from ${process.cwd()} or ${packageFixtureRoot}.`
83
- );
84
- }
85
- function resolveTenantRoot() {
86
- const candidates = tenantRootCandidates();
87
- for (const candidate of candidates) {
88
- if (existsSync(resolve(candidate, "src/manifest.yaml"))) {
89
- return candidate;
90
- }
91
- }
92
- throw new Error(
93
- `Unable to resolve a Treeseed tenant root from ${process.cwd()} or ${packageFixtureRoot}.`
94
- );
95
- }
96
- function defineTreeseedTenant(tenantConfig) {
97
- return tenantConfig;
98
- }
99
- function loadTreeseedManifest(manifestPath = "./src/manifest.yaml") {
100
- const resolvedManifestPath = resolveTenantPath(manifestPath);
101
- const tenantRoot = resolve(dirname(resolvedManifestPath), "..");
102
- const parsed = normalizeAliasedRecord(
103
- manifestFieldAliases,
104
- parseYaml(readFileSync(resolvedManifestPath, "utf8"))
105
- );
106
- const content = normalizeAliasedRecord(
107
- manifestContentFieldAliases,
108
- parsed.content ?? {}
109
- );
110
- const overrides = parsed.overrides ? normalizeAliasedRecord(
111
- manifestOverrideFieldAliases,
112
- parsed.overrides
113
- ) : void 0;
114
- const tenantConfig = defineTreeseedTenant({
115
- ...parsed,
116
- siteConfigPath: resolve(tenantRoot, parsed.siteConfigPath),
117
- content: Object.fromEntries(
118
- Object.entries(content ?? {}).map(([collectionName, rootPath]) => [
119
- collectionName,
120
- resolve(tenantRoot, String(rootPath))
121
- ])
122
- ),
123
- overrides: overrides ? {
124
- pagesRoot: overrides.pagesRoot ? resolve(tenantRoot, overrides.pagesRoot) : void 0,
125
- stylesRoot: overrides.stylesRoot ? resolve(tenantRoot, overrides.stylesRoot) : void 0,
126
- componentsRoot: overrides.componentsRoot ? resolve(tenantRoot, overrides.componentsRoot) : void 0
127
- } : void 0
128
- });
129
- Object.defineProperty(tenantConfig, "__tenantRoot", {
130
- value: tenantRoot,
131
- enumerable: false
132
- });
133
- return tenantConfig;
134
- }
135
- const loadTreeseedTenantManifest = loadTreeseedManifest;
136
- const resolveTreeseedTenantRoot = resolveTenantRoot;
137
- function getTenantContentRoot(tenantConfig, collectionName) {
138
- const root = tenantConfig.content[collectionName];
139
- if (!root) {
140
- throw new Error(`Unknown tenant content collection: ${collectionName}`);
141
- }
142
- return root;
143
- }
144
- function tenantFeatureEnabled(tenantConfig, featureName) {
145
- return tenantConfig.features?.[featureName] !== false;
146
- }
147
- export {
148
- defineTreeseedTenant,
149
- getTenantContentRoot,
150
- loadTreeseedManifest,
151
- loadTreeseedTenantManifest,
152
- resolveTreeseedTenantRoot,
153
- tenantFeatureEnabled
154
- };
@@ -1,29 +0,0 @@
1
- import type { TreeseedBookDefinition, TreeseedTenantConfig } from '../contracts.ts';
2
- interface DocsLibraryDownload {
3
- downloadFileName: string;
4
- downloadHref: string;
5
- downloadTitle: string;
6
- }
7
- interface TenantBookRuntime {
8
- BOOKS: TreeseedBookDefinition[];
9
- BOOKS_LINK: {
10
- label: string;
11
- link: string;
12
- };
13
- TREESEED_LINKS: {
14
- home: string;
15
- };
16
- TREESEED_LIBRARY_DOWNLOAD: DocsLibraryDownload;
17
- }
18
- export declare function buildTenantBookRuntime(tenantConfig: Pick<TreeseedTenantConfig, 'content'>, options?: {
19
- projectRoot?: string;
20
- docsHomePath?: string;
21
- docsLibraryDownload?: DocsLibraryDownload;
22
- }): TenantBookRuntime;
23
- export declare const BOOKS: TreeseedBookDefinition[], BOOKS_LINK: {
24
- label: string;
25
- link: string;
26
- }, TREESEED_LINKS: {
27
- home: string;
28
- }, TREESEED_LIBRARY_DOWNLOAD: DocsLibraryDownload;
29
- export {};
@@ -1,82 +0,0 @@
1
- import { readFileSync, readdirSync, statSync } from "node:fs";
2
- import path from "node:path";
3
- import { parse as parseYaml } from "yaml";
4
- import { getTenantContentRoot } from "../tenant/config.js";
5
- import { RUNTIME_PROJECT_ROOT, RUNTIME_TENANT } from "../tenant/runtime-config.js";
6
- function sortPaths(paths) {
7
- return [...paths].sort((left, right) => left.localeCompare(right, void 0, { numeric: true, sensitivity: "base" }));
8
- }
9
- function collectMarkdownFiles(rootPath) {
10
- const stats = statSync(rootPath);
11
- if (stats.isFile()) {
12
- return [rootPath];
13
- }
14
- return sortPaths(
15
- readdirSync(rootPath, { withFileTypes: true }).flatMap((entry) => {
16
- const fullPath = path.join(rootPath, entry.name);
17
- if (entry.isDirectory()) {
18
- return collectMarkdownFiles(fullPath);
19
- }
20
- if (entry.isFile() && (entry.name.endsWith(".md") || entry.name.endsWith(".mdx"))) {
21
- return [fullPath];
22
- }
23
- return [];
24
- })
25
- );
26
- }
27
- function parseFrontmatter(filePath) {
28
- const raw = readFileSync(filePath, "utf8");
29
- const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
30
- if (!match) {
31
- throw new Error(`Book content entry is missing frontmatter: ${filePath}`);
32
- }
33
- return parseYaml(match[1]);
34
- }
35
- function inferDocsLibraryDownload(book) {
36
- const title = book?.title ? `${book.title} Library` : "Knowledge Library";
37
- return {
38
- downloadFileName: "treeseed-knowledge.md",
39
- downloadHref: "/books/treeseed-knowledge.md",
40
- downloadTitle: title
41
- };
42
- }
43
- function buildTenantBookRuntime(tenantConfig, options = {}) {
44
- const projectRoot = options.projectRoot ?? process.cwd();
45
- const booksContentRoot = path.resolve(projectRoot, getTenantContentRoot(tenantConfig, "books"));
46
- const books = collectMarkdownFiles(booksContentRoot).map((filePath) => {
47
- const frontmatter = parseFrontmatter(filePath);
48
- return {
49
- ...frontmatter,
50
- id: path.basename(filePath, path.extname(filePath))
51
- };
52
- }).sort((left, right) => left.order - right.order);
53
- const docsHomePath = options.docsHomePath ?? "/knowledge/";
54
- const docsLibraryDownload = options.docsLibraryDownload ?? inferDocsLibraryDownload(tenantConfig);
55
- return {
56
- BOOKS: books,
57
- BOOKS_LINK: {
58
- label: "Books",
59
- link: docsHomePath
60
- },
61
- TREESEED_LINKS: {
62
- home: docsHomePath
63
- },
64
- TREESEED_LIBRARY_DOWNLOAD: docsLibraryDownload
65
- };
66
- }
67
- const runtime = buildTenantBookRuntime(RUNTIME_TENANT, {
68
- projectRoot: RUNTIME_PROJECT_ROOT,
69
- docsLibraryDownload: {
70
- downloadFileName: "treeseed-knowledge.md",
71
- downloadHref: "/books/treeseed-knowledge.md",
72
- downloadTitle: "TreeSeed Knowledge Library"
73
- }
74
- });
75
- const { BOOKS, BOOKS_LINK, TREESEED_LINKS, TREESEED_LIBRARY_DOWNLOAD } = runtime;
76
- export {
77
- BOOKS,
78
- BOOKS_LINK,
79
- TREESEED_LIBRARY_DOWNLOAD,
80
- TREESEED_LINKS,
81
- buildTenantBookRuntime
82
- };
@@ -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>): string;