@treeseed/core 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +26 -3
  2. package/dist/config.js +1 -1
  3. package/dist/content-config.js +1 -1
  4. package/dist/content.js +3 -3
  5. package/dist/index.js +1 -68
  6. package/dist/scripts/aggregate-book.js +1 -1
  7. package/dist/scripts/build-dist.js +3 -14
  8. package/dist/scripts/build-tenant-worker.js +2 -2
  9. package/dist/scripts/run-fixture-astro-command.js +219 -0
  10. package/dist/site-resources.d.ts +2 -2
  11. package/dist/site.js +3 -3
  12. package/dist/tenant/bridge.js +1 -1
  13. package/dist/tenant/runtime-config.js +1 -1
  14. package/dist/utils/forms/config.js +5 -1
  15. package/dist/utils/forms/provider-runtime.js +42 -0
  16. package/dist/utils/forms/service.js +2 -2
  17. package/dist/utils/starlight-nav.js +6 -1
  18. package/package.json +5 -37
  19. package/dist/agents/index.js +0 -5
  20. package/dist/agents/registry-helper.js +0 -14
  21. package/dist/agents/registry.js +0 -88
  22. package/dist/contracts.d.ts +0 -1
  23. package/dist/contracts.js +0 -0
  24. package/dist/deploy/config.d.ts +0 -1
  25. package/dist/deploy/config.js +0 -10
  26. package/dist/deploy/runtime.js +0 -81
  27. package/dist/environment.d.ts +0 -2
  28. package/dist/environment.js +0 -26
  29. package/dist/plugin-default.js +0 -4
  30. package/dist/plugins/builtin/default-plugin.js +0 -37
  31. package/dist/plugins/constants.d.ts +0 -1
  32. package/dist/plugins/constants.js +0 -10
  33. package/dist/plugins/plugin.d.ts +0 -2
  34. package/dist/plugins/plugin.js +0 -4
  35. package/dist/plugins/runtime.d.ts +0 -32
  36. package/dist/plugins/runtime.js +0 -138
  37. package/dist/tenant/config.js +0 -16
  38. package/dist/types/agents.d.ts +0 -1
  39. package/dist/types/agents.js +0 -1
  40. package/dist/utils/agents/adapters/execution.js +0 -90
  41. package/dist/utils/agents/adapters/mutations.js +0 -30
  42. package/dist/utils/agents/adapters/notification.js +0 -16
  43. package/dist/utils/agents/adapters/repository.js +0 -61
  44. package/dist/utils/agents/adapters/research.js +0 -25
  45. package/dist/utils/agents/adapters/verification.js +0 -62
  46. package/dist/utils/agents/cli-tools.js +0 -5
  47. package/dist/utils/agents/contracts/messages.d.ts +0 -88
  48. package/dist/utils/agents/contracts/messages.js +0 -138
  49. package/dist/utils/agents/contracts/run.d.ts +0 -20
  50. package/dist/utils/agents/contracts/run.js +0 -0
  51. package/dist/utils/agents/runtime-types.d.ts +0 -117
  52. package/dist/utils/agents/runtime-types.js +0 -4
  53. package/dist/utils/books-data.js +0 -14
  54. package/dist/utils/plugin-runtime.js +0 -158
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@treeseed/core",
3
- "version": "0.3.0",
4
- "description": "Treeseed platform runtime package for Astro, Starlight, forms, books, plugins, and shared platform behavior.",
3
+ "version": "0.4.0",
4
+ "description": "Treeseed Research Hub package for Astro, Starlight, knowledge-factory content, and forms.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
7
7
  "type": "git",
@@ -46,6 +46,8 @@
46
46
  "test": "npm run test:unit",
47
47
  "lint": "npm run fixtures:check && npm run starlight:patch && npm run build:dist",
48
48
  "verify:direct": "npm run release:verify",
49
+ "verify:local": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='direct'; await import('@treeseed/sdk/scripts/verify-driver')\"",
50
+ "verify:action": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='act'; await import('@treeseed/sdk/scripts/verify-driver')\"",
49
51
  "verify": "node --input-type=module -e \"await import('@treeseed/sdk/scripts/verify-driver')\"",
50
52
  "test:smoke": "node ./scripts/run-ts.mjs ./scripts/test-smoke.ts",
51
53
  "fixtures:resolve": "node ./scripts/run-ts.mjs ./scripts/fixture-tools.ts resolve",
@@ -56,7 +58,7 @@
56
58
  "release:publish": "node ./scripts/run-ts.mjs ./scripts/publish-package.ts"
57
59
  },
58
60
  "dependencies": {
59
- "@treeseed/sdk": "^0.3.0",
61
+ "@treeseed/sdk": "^0.4.0",
60
62
  "@astrojs/check": "^0.9.8",
61
63
  "@astrojs/cloudflare": "^12.6.13",
62
64
  "@astrojs/sitemap": "3.7.0",
@@ -96,13 +98,6 @@
96
98
  "types": "./dist/config.d.ts",
97
99
  "default": "./dist/config.js"
98
100
  },
99
- "./deploy/config": {
100
- "types": "./dist/deploy/config.d.ts",
101
- "default": "./dist/deploy/config.js"
102
- },
103
- "./deploy/runtime": {
104
- "default": "./dist/deploy/runtime.js"
105
- },
106
101
  "./content": {
107
102
  "types": "./dist/content.d.ts",
108
103
  "default": "./dist/content.js"
@@ -112,41 +107,14 @@
112
107
  "default": "./dist/content-config.js"
113
108
  },
114
109
  "./tenant": "./dist/tenant/bridge.js",
115
- "./tenant-config": {
116
- "types": "./dist/tenant/config.d.ts",
117
- "default": "./dist/tenant/config.js"
118
- },
119
- "./contracts": "./dist/contracts.js",
120
- "./plugin-default": {
121
- "types": "./dist/plugin-default.d.ts",
122
- "default": "./dist/plugin-default.js"
123
- },
124
- "./plugins/plugin": {
125
- "types": "./dist/plugins/plugin.d.ts",
126
- "default": "./dist/plugins/plugin.js"
127
- },
128
- "./plugins/runtime": {
129
- "types": "./dist/plugins/runtime.d.ts",
130
- "default": "./dist/plugins/runtime.js"
131
- },
132
- "./environment": {
133
- "types": "./dist/environment.d.ts",
134
- "default": "./dist/environment.js"
135
- },
136
110
  "./scripts/workspace-bootstrap": "./dist/scripts/workspace-bootstrap.js",
137
111
  "./site-resources": {
138
112
  "types": "./dist/site-resources.d.ts",
139
113
  "default": "./dist/site-resources.js"
140
114
  },
141
- "./types/agents": "./dist/types/agents.js",
142
115
  "./types/cloudflare": "./dist/types/cloudflare.js",
143
- "./agents/registry-helper": "./dist/agents/registry-helper.js",
144
116
  "./utils/seo": "./dist/utils/seo.js",
145
117
  "./utils/site-config-schema": "./dist/utils/site-config-schema.js",
146
- "./utils/books-data": "./dist/utils/books-data.js",
147
- "./utils/agents/runtime-types": "./dist/utils/agents/runtime-types.js",
148
- "./utils/agents/contracts/messages": "./dist/utils/agents/contracts/messages.js",
149
- "./utils/agents/contracts/run": "./dist/utils/agents/contracts/run.js",
150
118
  "./components/site/CTASection.astro": "./dist/components/site/CTASection.astro",
151
119
  "./components/site/SectionIntro.astro": "./dist/components/site/SectionIntro.astro",
152
120
  "./components/site/PathCard.astro": "./dist/components/site/PathCard.astro",
@@ -1,5 +0,0 @@
1
- import { AGENT_HANDLER_REGISTRY, resolveAgentHandler } from "./registry.js";
2
- export {
3
- AGENT_HANDLER_REGISTRY,
4
- resolveAgentHandler
5
- };
@@ -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,88 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { resolve } from "node:path";
3
- import { pathToFileURL } from "node:url";
4
- import { resolveTreeseedTenantRoot } from "../tenant/config.js";
5
- import { resolveAgentRuntimeProviders } from "../utils/plugin-runtime.js";
6
- import { getTreeseedAgentProviderSelections } from "../deploy/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 getTenantAgentHandlerModulePath(kind, tenantRoot = resolveTreeseedTenantRoot()) {
26
- return resolve(tenantRoot, "src/agents", `${kind}.ts`);
27
- }
28
- async function loadTenantAgentHandlerRegistry(tenantRoot = resolveTreeseedTenantRoot()) {
29
- const registry = {};
30
- for (const kind of BUILTIN_HANDLER_KINDS) {
31
- const modulePath = getTenantAgentHandlerModulePath(kind, tenantRoot);
32
- if (!existsSync(modulePath)) {
33
- continue;
34
- }
35
- let moduleExports;
36
- try {
37
- moduleExports = await import(
38
- /* @vite-ignore */
39
- pathToFileURL(modulePath).href
40
- );
41
- } catch (error) {
42
- const reason = error instanceof Error ? error.message : String(error);
43
- throw new Error(`Failed to import tenant agent handler "${kind}" from ${modulePath}: ${reason}`);
44
- }
45
- const exportName = HANDLER_EXPORT_NAMES[kind];
46
- const handler = moduleExports[exportName];
47
- if (!handler) {
48
- throw new Error(
49
- `Tenant agent handler module "${modulePath}" must export "${exportName}" for handler kind "${kind}".`
50
- );
51
- }
52
- const normalizedHandler = handler;
53
- if (normalizedHandler.kind !== kind) {
54
- throw new Error(
55
- `Tenant agent handler "${exportName}" from "${modulePath}" declares kind "${normalizedHandler.kind}", but "${kind}" was expected.`
56
- );
57
- }
58
- registry[kind] = normalizedHandler;
59
- }
60
- return registry;
61
- }
62
- const AGENT_HANDLER_REGISTRY = await loadTenantAgentHandlerRegistry();
63
- function listRegisteredAgentHandlers() {
64
- const runtimeProviders = resolveAgentRuntimeProviders(resolveTreeseedTenantRoot(), getTreeseedAgentProviderSelections());
65
- return [.../* @__PURE__ */ new Set([...Object.keys(AGENT_HANDLER_REGISTRY), ...runtimeProviders.handlers.keys()])];
66
- }
67
- function resolveAgentHandler(kind) {
68
- const runtimeProviders = resolveAgentRuntimeProviders(resolveTreeseedTenantRoot(), getTreeseedAgentProviderSelections());
69
- const handler = AGENT_HANDLER_REGISTRY[kind] ?? runtimeProviders.handlers.get(kind);
70
- if (!handler) {
71
- if (BUILTIN_HANDLER_KINDS.includes(kind)) {
72
- const expectedPath = getTenantAgentHandlerModulePath(kind);
73
- const expectedExport = HANDLER_EXPORT_NAMES[kind];
74
- throw new Error(
75
- `No runtime handler is registered for agent handler "${kind}". Expected tenant file "${expectedPath}" exporting "${expectedExport}" or a plugin contribution.`
76
- );
77
- }
78
- throw new Error(`No runtime handler is registered for agent handler "${kind}".`);
79
- }
80
- return handler;
81
- }
82
- export {
83
- AGENT_HANDLER_REGISTRY,
84
- getTenantAgentHandlerModulePath,
85
- listRegisteredAgentHandlers,
86
- loadTenantAgentHandlerRegistry,
87
- resolveAgentHandler
88
- };
@@ -1 +0,0 @@
1
- export type { TreeseedBookDefinition, TreeseedContentCollection, TreeseedContentMap, TreeseedDeployConfig, TreeseedFeatureModules, TreeseedFeatureName, TreeseedManagedServiceConfig, TreeseedManagedServiceEnvironmentConfig, TreeseedManagedServiceRailwayConfig, TreeseedManagedServicesConfig, TreeseedPluginReference, TreeseedProviderSelections, TreeseedTenantConfig, TreeseedThemeConfig, } from '@treeseed/sdk/platform/contracts';
package/dist/contracts.js DELETED
File without changes
@@ -1 +0,0 @@
1
- export { deriveCloudflareWorkerName, loadTreeseedDeployConfig, resolveTreeseedDeployConfigPath, } from '@treeseed/sdk/platform/deploy-config';
@@ -1,10 +0,0 @@
1
- import {
2
- deriveCloudflareWorkerName,
3
- loadTreeseedDeployConfig,
4
- resolveTreeseedDeployConfigPath
5
- } from "@treeseed/sdk/platform/deploy-config";
6
- export {
7
- deriveCloudflareWorkerName,
8
- loadTreeseedDeployConfig,
9
- resolveTreeseedDeployConfigPath
10
- };
@@ -1,81 +0,0 @@
1
- import { loadTreeseedDeployConfig } from "./config.js";
2
- import {
3
- TREESEED_DEFAULT_PLUGIN_REFERENCES,
4
- TREESEED_DEFAULT_PROVIDER_SELECTIONS
5
- } from "../plugins/constants.js";
6
- let cachedDeployConfig = null;
7
- function defaultDeployConfig() {
8
- return {
9
- name: "Treeseed Site",
10
- slug: "treeseed-site",
11
- siteUrl: "https://example.com",
12
- contactEmail: "contact@example.com",
13
- cloudflare: {
14
- accountId: "",
15
- workerName: "treeseed-site"
16
- },
17
- plugins: [...TREESEED_DEFAULT_PLUGIN_REFERENCES],
18
- providers: structuredClone(TREESEED_DEFAULT_PROVIDER_SELECTIONS),
19
- smtp: {
20
- enabled: false
21
- },
22
- turnstile: {
23
- enabled: true
24
- }
25
- };
26
- }
27
- function getTreeseedDeployConfig() {
28
- if (cachedDeployConfig) {
29
- return cachedDeployConfig;
30
- }
31
- if (typeof __TREESEED_DEPLOY_CONFIG__ !== "undefined" && __TREESEED_DEPLOY_CONFIG__) {
32
- cachedDeployConfig = __TREESEED_DEPLOY_CONFIG__;
33
- return cachedDeployConfig;
34
- }
35
- try {
36
- cachedDeployConfig = loadTreeseedDeployConfig();
37
- return cachedDeployConfig;
38
- } catch {
39
- cachedDeployConfig = defaultDeployConfig();
40
- return cachedDeployConfig;
41
- }
42
- }
43
- function resetTreeseedDeployConfigForTests() {
44
- cachedDeployConfig = null;
45
- }
46
- function getTreeseedFormsProvider() {
47
- return getTreeseedDeployConfig().providers?.forms ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.forms;
48
- }
49
- function getTreeseedOperationsProvider() {
50
- return getTreeseedDeployConfig().providers?.operations ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.operations;
51
- }
52
- function getTreeseedAgentProviderSelections() {
53
- return getTreeseedDeployConfig().providers?.agents ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents;
54
- }
55
- function getTreeseedDeployProvider() {
56
- return getTreeseedDeployConfig().providers?.deploy ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.deploy;
57
- }
58
- function getTreeseedDocsProvider() {
59
- return getTreeseedDeployConfig().providers?.content?.docs ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.content.docs;
60
- }
61
- function getTreeseedSiteProvider() {
62
- return getTreeseedDeployConfig().providers?.site ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.site;
63
- }
64
- function isTreeseedSmtpEnabled() {
65
- return getTreeseedDeployConfig().smtp?.enabled ?? false;
66
- }
67
- function isTreeseedTurnstileEnabled() {
68
- return getTreeseedDeployConfig().turnstile?.enabled ?? true;
69
- }
70
- export {
71
- getTreeseedAgentProviderSelections,
72
- getTreeseedDeployConfig,
73
- getTreeseedDeployProvider,
74
- getTreeseedDocsProvider,
75
- getTreeseedFormsProvider,
76
- getTreeseedOperationsProvider,
77
- getTreeseedSiteProvider,
78
- isTreeseedSmtpEnabled,
79
- isTreeseedTurnstileEnabled,
80
- resetTreeseedDeployConfigForTests
81
- };
@@ -1,2 +0,0 @@
1
- export { getTreeseedEnvironmentSuggestedValues, isTreeseedEnvironmentEntryRelevant, loadTreeseedEnvironmentOverlay, resolveTreeseedEnvironmentContext, resolveTreeseedEnvironmentRegistry, TREESEED_ENVIRONMENT_PURPOSES, TREESEED_ENVIRONMENT_REQUIREMENTS, TREESEED_ENVIRONMENT_SCOPES, TREESEED_ENVIRONMENT_SENSITIVITY, TREESEED_ENVIRONMENT_TARGETS, validateTreeseedEnvironmentValues, } from '@treeseed/sdk/platform/environment';
2
- export type * from '@treeseed/sdk/platform/environment';
@@ -1,26 +0,0 @@
1
- import {
2
- getTreeseedEnvironmentSuggestedValues,
3
- isTreeseedEnvironmentEntryRelevant,
4
- loadTreeseedEnvironmentOverlay,
5
- resolveTreeseedEnvironmentContext,
6
- resolveTreeseedEnvironmentRegistry,
7
- TREESEED_ENVIRONMENT_PURPOSES,
8
- TREESEED_ENVIRONMENT_REQUIREMENTS,
9
- TREESEED_ENVIRONMENT_SCOPES,
10
- TREESEED_ENVIRONMENT_SENSITIVITY,
11
- TREESEED_ENVIRONMENT_TARGETS,
12
- validateTreeseedEnvironmentValues
13
- } from "@treeseed/sdk/platform/environment";
14
- export {
15
- TREESEED_ENVIRONMENT_PURPOSES,
16
- TREESEED_ENVIRONMENT_REQUIREMENTS,
17
- TREESEED_ENVIRONMENT_SCOPES,
18
- TREESEED_ENVIRONMENT_SENSITIVITY,
19
- TREESEED_ENVIRONMENT_TARGETS,
20
- getTreeseedEnvironmentSuggestedValues,
21
- isTreeseedEnvironmentEntryRelevant,
22
- loadTreeseedEnvironmentOverlay,
23
- resolveTreeseedEnvironmentContext,
24
- resolveTreeseedEnvironmentRegistry,
25
- validateTreeseedEnvironmentValues
26
- };
@@ -1,4 +0,0 @@
1
- import { default as default2 } from "./plugins/builtin/default-plugin.js";
2
- export {
3
- default2 as default
4
- };
@@ -1,37 +0,0 @@
1
- import { createDefaultGraphRankingProvider } from "@treeseed/sdk";
2
- import { defineTreeseedPlugin } from "../plugin.js";
3
- var default_plugin_default = defineTreeseedPlugin({
4
- id: "treeseed-core-default",
5
- provides: {
6
- forms: ["store_only", "notify_admin", "full_email"],
7
- operations: ["default"],
8
- agents: {
9
- execution: ["stub", "manual", "copilot"],
10
- mutation: ["local_branch"],
11
- repository: ["stub", "git"],
12
- verification: ["stub", "local"],
13
- notification: ["stub"],
14
- research: ["stub"],
15
- handlers: [
16
- "planner",
17
- "architect",
18
- "engineer",
19
- "notifier",
20
- "researcher",
21
- "reviewer",
22
- "releaser"
23
- ]
24
- },
25
- deploy: ["cloudflare"],
26
- content: {
27
- docs: ["default"]
28
- },
29
- site: ["default"]
30
- },
31
- graphRankingProviders: {
32
- default: createDefaultGraphRankingProvider()
33
- }
34
- });
35
- export {
36
- default_plugin_default as default
37
- };
@@ -1 +0,0 @@
1
- export { TREESEED_DEFAULT_PLUGIN_PACKAGE, TREESEED_DEFAULT_PLUGIN_REFERENCES, TREESEED_DEFAULT_PROVIDER_SELECTIONS, } from '@treeseed/sdk/platform/plugins';
@@ -1,10 +0,0 @@
1
- import {
2
- TREESEED_DEFAULT_PLUGIN_PACKAGE,
3
- TREESEED_DEFAULT_PLUGIN_REFERENCES,
4
- TREESEED_DEFAULT_PROVIDER_SELECTIONS
5
- } from "@treeseed/sdk/platform/plugins";
6
- export {
7
- TREESEED_DEFAULT_PLUGIN_PACKAGE,
8
- TREESEED_DEFAULT_PLUGIN_REFERENCES,
9
- TREESEED_DEFAULT_PROVIDER_SELECTIONS
10
- };
@@ -1,2 +0,0 @@
1
- export { defineTreeseedPlugin } from '@treeseed/sdk/platform/plugin';
2
- export type * from '@treeseed/sdk/platform/plugin';
@@ -1,4 +0,0 @@
1
- import { defineTreeseedPlugin } from "@treeseed/sdk/platform/plugin";
2
- export {
3
- defineTreeseedPlugin
4
- };
@@ -1,32 +0,0 @@
1
- import type { TreeseedDeployConfig } from '../contracts';
2
- type LoadedPluginEntry = {
3
- package: string;
4
- config: Record<string, unknown>;
5
- baseDir: string;
6
- plugin: Record<string, any>;
7
- };
8
- export type LoadedTreeseedPluginEntry = LoadedPluginEntry;
9
- export declare function loadTreeseedPlugins(config?: TreeseedDeployConfig): LoadedPluginEntry[];
10
- export declare function loadTreeseedPluginRuntime(config?: TreeseedDeployConfig): {
11
- config: TreeseedDeployConfig;
12
- plugins: LoadedPluginEntry[];
13
- provided: {
14
- forms: Set<string>;
15
- operations: Set<string>;
16
- agents: {
17
- execution: Set<string>;
18
- mutation: Set<string>;
19
- repository: Set<string>;
20
- verification: Set<string>;
21
- notification: Set<string>;
22
- research: Set<string>;
23
- handlers: Set<string>;
24
- };
25
- deploy: Set<string>;
26
- content: {
27
- docs: Set<string>;
28
- };
29
- site: Set<string>;
30
- };
31
- };
32
- export {};
@@ -1,138 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { createRequire } from "node:module";
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { loadTreeseedDeployConfig } from "../deploy/config.js";
6
- import { TREESEED_DEFAULT_PLUGIN_PACKAGE } from "./constants.js";
7
- const require2 = createRequire(import.meta.url);
8
- const runtimeDir = path.dirname(fileURLToPath(import.meta.url));
9
- function normalizeLoadedPlugin(moduleExports, packageName) {
10
- const plugin = moduleExports?.default ?? moduleExports;
11
- if (!plugin || typeof plugin !== "object") {
12
- throw new Error(`Treeseed plugin "${packageName}" did not export a plugin object.`);
13
- }
14
- return plugin;
15
- }
16
- function isPathLikePluginReference(packageName) {
17
- return packageName.startsWith(".") || packageName.startsWith("/") || packageName.startsWith("file:");
18
- }
19
- function resolveLocalDefaultPluginPath() {
20
- const candidates = [
21
- path.resolve(runtimeDir, "../plugin-default.js"),
22
- path.resolve(runtimeDir, "../../dist/plugin-default.js")
23
- ];
24
- for (const candidate of candidates) {
25
- if (existsSync(candidate)) {
26
- return candidate;
27
- }
28
- }
29
- return null;
30
- }
31
- function loadPluginModule(packageName, tenantRoot) {
32
- if (packageName === TREESEED_DEFAULT_PLUGIN_PACKAGE) {
33
- const localDefaultPluginPath = resolveLocalDefaultPluginPath();
34
- const resolvedPath2 = localDefaultPluginPath ?? require2.resolve(packageName);
35
- return {
36
- moduleExports: require2(resolvedPath2),
37
- baseDir: path.dirname(resolvedPath2)
38
- };
39
- }
40
- if (isPathLikePluginReference(packageName)) {
41
- const resolvedPath2 = packageName.startsWith("file:") ? fileURLToPath(packageName) : path.resolve(tenantRoot, packageName);
42
- return {
43
- moduleExports: require2(resolvedPath2),
44
- baseDir: path.dirname(resolvedPath2)
45
- };
46
- }
47
- const resolvedPath = require2.resolve(packageName);
48
- return {
49
- moduleExports: require2(resolvedPath),
50
- baseDir: path.dirname(resolvedPath)
51
- };
52
- }
53
- function loadTreeseedPlugins(config = loadTreeseedDeployConfig()) {
54
- const tenantRoot = config.__tenantRoot ?? process.cwd();
55
- const plugins = [];
56
- for (const pluginRef of config.plugins ?? []) {
57
- if (pluginRef?.enabled === false) {
58
- continue;
59
- }
60
- const loaded = loadPluginModule(pluginRef.package, tenantRoot);
61
- const plugin = normalizeLoadedPlugin(loaded.moduleExports, pluginRef.package);
62
- plugins.push({
63
- package: pluginRef.package,
64
- config: pluginRef.config ?? {},
65
- baseDir: loaded.baseDir,
66
- plugin
67
- });
68
- }
69
- return plugins;
70
- }
71
- function collectProvidedIds(plugins) {
72
- const provided = {
73
- forms: /* @__PURE__ */ new Set(),
74
- operations: /* @__PURE__ */ new Set(),
75
- agents: {
76
- execution: /* @__PURE__ */ new Set(),
77
- mutation: /* @__PURE__ */ new Set(),
78
- repository: /* @__PURE__ */ new Set(),
79
- verification: /* @__PURE__ */ new Set(),
80
- notification: /* @__PURE__ */ new Set(),
81
- research: /* @__PURE__ */ new Set(),
82
- handlers: /* @__PURE__ */ new Set()
83
- },
84
- deploy: /* @__PURE__ */ new Set(),
85
- content: {
86
- docs: /* @__PURE__ */ new Set()
87
- },
88
- site: /* @__PURE__ */ new Set()
89
- };
90
- for (const { plugin } of plugins) {
91
- for (const id of plugin.provides?.forms ?? []) provided.forms.add(id);
92
- for (const id of plugin.provides?.operations ?? []) provided.operations.add(id);
93
- for (const id of plugin.provides?.agents?.execution ?? []) provided.agents.execution.add(id);
94
- for (const id of plugin.provides?.agents?.mutation ?? []) provided.agents.mutation.add(id);
95
- for (const id of plugin.provides?.agents?.repository ?? []) provided.agents.repository.add(id);
96
- for (const id of plugin.provides?.agents?.verification ?? []) provided.agents.verification.add(id);
97
- for (const id of plugin.provides?.agents?.notification ?? []) provided.agents.notification.add(id);
98
- for (const id of plugin.provides?.agents?.research ?? []) provided.agents.research.add(id);
99
- for (const id of plugin.provides?.agents?.handlers ?? []) provided.agents.handlers.add(id);
100
- for (const id of plugin.provides?.deploy ?? []) provided.deploy.add(id);
101
- for (const id of plugin.provides?.content?.docs ?? []) provided.content.docs.add(id);
102
- for (const id of plugin.provides?.site ?? []) provided.site.add(id);
103
- }
104
- return provided;
105
- }
106
- function assertSelectedProvider(provided, label, id) {
107
- if (!id) {
108
- throw new Error(`Treeseed plugin runtime is missing selected provider id for ${label}.`);
109
- }
110
- if (!provided.has(id)) {
111
- throw new Error(`Treeseed plugin runtime could not resolve ${label} provider "${id}".`);
112
- }
113
- }
114
- function loadTreeseedPluginRuntime(config = loadTreeseedDeployConfig()) {
115
- const plugins = loadTreeseedPlugins(config);
116
- const provided = collectProvidedIds(plugins);
117
- const providers = config.providers;
118
- assertSelectedProvider(provided.forms, "forms", providers.forms);
119
- assertSelectedProvider(provided.operations, "operations", providers.operations);
120
- assertSelectedProvider(provided.agents.execution, "agents.execution", providers.agents.execution);
121
- assertSelectedProvider(provided.agents.mutation, "agents.mutation", providers.agents.mutation);
122
- assertSelectedProvider(provided.agents.repository, "agents.repository", providers.agents.repository);
123
- assertSelectedProvider(provided.agents.verification, "agents.verification", providers.agents.verification);
124
- assertSelectedProvider(provided.agents.notification, "agents.notification", providers.agents.notification);
125
- assertSelectedProvider(provided.agents.research, "agents.research", providers.agents.research);
126
- assertSelectedProvider(provided.deploy, "deploy", providers.deploy);
127
- assertSelectedProvider(provided.content.docs, "content.docs", providers.content?.docs);
128
- assertSelectedProvider(provided.site, "site", providers.site);
129
- return {
130
- config,
131
- plugins,
132
- provided
133
- };
134
- }
135
- export {
136
- loadTreeseedPluginRuntime,
137
- loadTreeseedPlugins
138
- };
@@ -1,16 +0,0 @@
1
- import {
2
- defineTreeseedTenant,
3
- getTenantContentRoot,
4
- loadTreeseedManifest,
5
- loadTreeseedTenantManifest,
6
- resolveTreeseedTenantRoot,
7
- tenantFeatureEnabled
8
- } from "@treeseed/sdk/platform/tenant-config";
9
- export {
10
- defineTreeseedTenant,
11
- getTenantContentRoot,
12
- loadTreeseedManifest,
13
- loadTreeseedTenantManifest,
14
- resolveTreeseedTenantRoot,
15
- tenantFeatureEnabled
16
- };
@@ -1 +0,0 @@
1
- export * from '@treeseed/sdk/types/agents';
@@ -1 +0,0 @@
1
- export * from "@treeseed/sdk/types/agents";