@treeseed/sdk 0.3.4 → 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.
- package/README.md +3 -3
- package/dist/index.d.ts +1 -7
- package/dist/index.js +0 -6
- package/dist/operations/runtime.js +1 -1
- package/dist/operations/services/config-runtime.d.ts +5 -5
- package/dist/operations/services/config-runtime.js +1 -1
- package/dist/operations/services/deploy.js +1 -1
- package/dist/operations/services/runtime-paths.d.ts +1 -0
- package/dist/operations/services/runtime-paths.js +3 -1
- package/dist/operations/services/runtime-tools.js +1 -1
- package/dist/operations/services/template-registry.d.ts +3 -3
- package/dist/operations/services/template-registry.js +5 -4
- package/dist/platform/books-data.d.ts +29 -1
- package/dist/platform/books-data.js +82 -1
- package/dist/platform/deploy-config.d.ts +4 -1
- package/dist/platform/deploy-config.js +222 -1
- package/dist/platform/deploy-runtime.js +1 -1
- package/dist/platform/environment.d.ts +1 -1
- package/dist/platform/environment.js +3 -3
- package/dist/platform/plugin.d.ts +51 -2
- package/dist/platform/plugin.js +3 -1
- package/dist/platform/plugins/constants.d.ts +1 -1
- package/dist/platform/plugins/constants.js +1 -1
- package/dist/platform/plugins/runtime.d.ts +1 -1
- package/dist/platform/plugins/runtime.js +5 -5
- package/dist/platform/plugins.d.ts +2 -2
- package/dist/platform/plugins.js +1 -1
- package/dist/platform/tenant/runtime-config.js +1 -1
- package/dist/platform/tenant-config.d.ts +7 -1
- package/dist/platform/tenant-config.js +153 -1
- package/dist/plugin-default.d.ts +25 -0
- package/dist/plugin-default.js +37 -0
- package/dist/scripts/aggregate-book.js +1 -1
- package/dist/scripts/build-tenant-worker.js +2 -2
- package/dist/scripts/tenant-destroy.js +1 -1
- package/dist/scripts/tenant-dev.js +1 -1
- package/dist/treeseed/template-catalog/templates/starter-basic/template/package.json +1 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +1 -1
- package/dist/treeseed/template-catalog/templates/starter-basic/template.config.json +6 -0
- package/package.json +5 -25
- package/dist/platform/deploy/config.d.ts +0 -4
- package/dist/platform/deploy/config.js +0 -222
- package/dist/platform/plugins/plugin.d.ts +0 -51
- package/dist/platform/plugins/plugin.js +0 -6
- package/dist/platform/tenant/config.d.ts +0 -9
- package/dist/platform/tenant/config.js +0 -154
- package/dist/platform/utils/books-data.d.ts +0 -29
- package/dist/platform/utils/books-data.js +0 -82
- package/dist/utils/agents/contracts/messages.d.ts +0 -88
- package/dist/utils/agents/contracts/messages.js +0 -139
- package/dist/utils/agents/contracts/run.d.ts +0 -20
- package/dist/utils/agents/contracts/run.js +0 -0
- package/dist/utils/agents/runtime-types.d.ts +0 -117
- package/dist/utils/agents/runtime-types.js +0 -4
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ Consumer contract:
|
|
|
41
41
|
## Quickstart
|
|
42
42
|
|
|
43
43
|
```ts
|
|
44
|
-
import { AgentSdk } from '@treeseed/sdk';
|
|
44
|
+
import { AgentSdk } from '@treeseed/sdk/sdk';
|
|
45
45
|
|
|
46
46
|
const sdk = new AgentSdk({
|
|
47
47
|
repoRoot: '/absolute/path/to/your-site',
|
|
@@ -51,7 +51,7 @@ const sdk = new AgentSdk({
|
|
|
51
51
|
Use `AgentSdk.createLocal()` when you want a local Wrangler-backed D1 database:
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
|
-
import { AgentSdk } from '@treeseed/sdk';
|
|
54
|
+
import { AgentSdk } from '@treeseed/sdk/sdk';
|
|
55
55
|
|
|
56
56
|
const sdk = AgentSdk.createLocal({
|
|
57
57
|
repoRoot: '/absolute/path/to/your-site',
|
|
@@ -71,7 +71,7 @@ The preferred graph API for new integrations is:
|
|
|
71
71
|
Example:
|
|
72
72
|
|
|
73
73
|
```ts
|
|
74
|
-
import { AgentSdk } from '@treeseed/sdk';
|
|
74
|
+
import { AgentSdk } from '@treeseed/sdk/sdk';
|
|
75
75
|
|
|
76
76
|
const sdk = new AgentSdk();
|
|
77
77
|
const parsed = await sdk.parseGraphDsl(
|
package/dist/index.d.ts
CHANGED
|
@@ -13,15 +13,9 @@ export { TRESEED_OPERATION_SPECS, findTreeseedOperation, listTreeseedOperationNa
|
|
|
13
13
|
export { TreeseedOperationsSdk } from './operations/runtime.ts';
|
|
14
14
|
export { TreeseedWorkflowSdk } from './workflow.ts';
|
|
15
15
|
export { getTreeseedVerifyDriverStatus, runTreeseedVerifyDriver } from './verification.ts';
|
|
16
|
-
export * from './platform/contracts.ts';
|
|
17
|
-
export * from './platform/tenant-config.ts';
|
|
18
|
-
export * from './platform/deploy-config.ts';
|
|
19
|
-
export * from './platform/deploy-runtime.ts';
|
|
20
|
-
export * from './platform/environment.ts';
|
|
21
|
-
export * from './platform/plugins.ts';
|
|
22
16
|
export type { SdkContentEntry, SdkCursorEntity, SdkFilterCondition, SdkFollowRequest, SdkGraphEdge, SdkGraphEdgeType, SdkGraphDslRelation, SdkGraphDslParseResult, SdkGraphModelConfig, SdkGraphNode, SdkGraphNodeType, SdkGraphPathExplanation, SdkGraphQueryStage, SdkGraphQueryView, SdkGraphQueryOptions, SdkGraphQueryRequest, SdkGraphQueryResult, SdkGraphRankingBuildInput, SdkGraphRankingDiagnostics, SdkGraphRankingIndex, SdkGraphRankingNodeResult, SdkGraphRankingProvider, SdkGraphRankingQueryRequest, SdkGraphRankingQueryResult, SdkGraphRankingSearchRequest, SdkGraphRefreshPayload, SdkGraphRefreshRequest, SdkGraphSearchOptions, SdkGraphSearchResult, SdkGraphSeed, SdkGraphSeedResolution, SdkGraphTraversalResult, SdkGraphWhereFilter, SdkContextPack, SdkContextPackRequest, SdkGetRequest, SdkJsonEnvelope, SdkLeaseEntity, SdkManagerContextPayload, SdkMessageEntity, SdkModelFieldBinding, SdkModelDefinition, SdkModelRegistry, SdkModelName, SdkMutationRequest, SdkOperation, SdkPickRequest, SdkPickResult, SdkQueueMessageEnvelope, SdkRunEntity, SdkSearchRequest, SdkTaskEntity, SdkTaskEventEntity, SdkTaskOutputEntity, SdkWorkDayEntity, SdkGraphRunEntity, SdkReportEntity, SdkSubscriptionEntity, SdkTemplateCatalogEntry, SdkTemplateCatalogPublisher, SdkTemplateCatalogResponse, SdkTemplateCatalogSource, SdkUpdateRequest, } from './sdk-types.ts';
|
|
23
17
|
export type { TreeseedFieldAliasBinding, TreeseedFieldAliasRegistry, } from './field-aliases.ts';
|
|
24
|
-
export type
|
|
18
|
+
export type * from './operations-types.ts';
|
|
25
19
|
export type * from './workflow.ts';
|
|
26
20
|
export type { AgentDatabase } from './d1-store.ts';
|
|
27
21
|
export type { D1DatabaseLike, D1PreparedStatementLike } from './types/cloudflare.ts';
|
package/dist/index.js
CHANGED
|
@@ -47,12 +47,6 @@ import {
|
|
|
47
47
|
import { TreeseedOperationsSdk } from "./operations/runtime.js";
|
|
48
48
|
import { TreeseedWorkflowSdk } from "./workflow.js";
|
|
49
49
|
import { getTreeseedVerifyDriverStatus, runTreeseedVerifyDriver } from "./verification.js";
|
|
50
|
-
export * from "./platform/contracts.js";
|
|
51
|
-
export * from "./platform/tenant-config.js";
|
|
52
|
-
export * from "./platform/deploy-config.js";
|
|
53
|
-
export * from "./platform/deploy-runtime.js";
|
|
54
|
-
export * from "./platform/environment.js";
|
|
55
|
-
export * from "./platform/plugins.js";
|
|
56
50
|
export {
|
|
57
51
|
AgentSdk,
|
|
58
52
|
BUILTIN_MODEL_REGISTRY,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadTreeseedDeployConfig } from "../platform/deploy
|
|
1
|
+
import { loadTreeseedDeployConfig } from "../platform/deploy-config.js";
|
|
2
2
|
import { createDefaultTreeseedOperationsProvider } from "./providers/default.js";
|
|
3
3
|
import { withProcessCwd } from "../operations/services/runtime-tools.js";
|
|
4
4
|
import {
|
|
@@ -115,7 +115,7 @@ export declare function resolveTreeseedTemplateCatalogCachePath(startRoot?: stri
|
|
|
115
115
|
export declare function ensureTreeseedGitignoreEntries(tenantRoot: any): string;
|
|
116
116
|
export declare function resolveTreeseedMachineEnvironmentValues(tenantRoot: any, scope: any): any;
|
|
117
117
|
export declare function setTreeseedMachineEnvironmentValue(tenantRoot: any, scope: any, entry: any, value: any): any;
|
|
118
|
-
export declare function collectTreeseedEnvironmentContext(tenantRoot: any): import("../../
|
|
118
|
+
export declare function collectTreeseedEnvironmentContext(tenantRoot: any): import("../../platform/environment.ts").TreeseedResolvedEnvironmentRegistry;
|
|
119
119
|
export declare function collectTreeseedConfigSeedValues(tenantRoot: any, scope: any, env?: NodeJS.ProcessEnv): any;
|
|
120
120
|
export declare function formatTreeseedConfigEnvironmentReport({ tenantRoot, scope, env, revealSecrets }: {
|
|
121
121
|
tenantRoot: any;
|
|
@@ -133,18 +133,18 @@ export declare function validateTreeseedCommandEnvironment({ tenantRoot, scope,
|
|
|
133
133
|
scope: any;
|
|
134
134
|
purpose: any;
|
|
135
135
|
}): {
|
|
136
|
-
registry: import("../../
|
|
136
|
+
registry: import("../../platform/environment.ts").TreeseedResolvedEnvironmentRegistry;
|
|
137
137
|
values: any;
|
|
138
|
-
validation: import("../../
|
|
138
|
+
validation: import("../../platform/environment.ts").TreeseedEnvironmentValidationResult;
|
|
139
139
|
};
|
|
140
140
|
export declare function assertTreeseedCommandEnvironment({ tenantRoot, scope, purpose }: {
|
|
141
141
|
tenantRoot: any;
|
|
142
142
|
scope: any;
|
|
143
143
|
purpose: any;
|
|
144
144
|
}): {
|
|
145
|
-
registry: import("../../
|
|
145
|
+
registry: import("../../platform/environment.ts").TreeseedResolvedEnvironmentRegistry;
|
|
146
146
|
values: any;
|
|
147
|
-
validation: import("../../
|
|
147
|
+
validation: import("../../platform/environment.ts").TreeseedEnvironmentValidationResult;
|
|
148
148
|
};
|
|
149
149
|
export declare function writeTreeseedLocalEnvironmentFiles(tenantRoot: any): {
|
|
150
150
|
envLocalPath: string;
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
TREESEED_ENVIRONMENT_SCOPES,
|
|
11
11
|
validateTreeseedEnvironmentValues
|
|
12
12
|
} from "../../platform/environment.js";
|
|
13
|
-
import { loadTreeseedManifest } from "../../platform/tenant
|
|
13
|
+
import { loadTreeseedManifest } from "../../platform/tenant-config.js";
|
|
14
14
|
import {
|
|
15
15
|
createPersistentDeployTarget,
|
|
16
16
|
ensureGeneratedWranglerConfig,
|
|
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node
|
|
|
3
3
|
import { dirname, relative, resolve } from "node:path";
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
import { createInterface } from "node:readline/promises";
|
|
6
|
-
import { deriveCloudflareWorkerName } from "../../platform/deploy
|
|
6
|
+
import { deriveCloudflareWorkerName } from "../../platform/deploy-config.js";
|
|
7
7
|
import { loadCliDeployConfig, resolveWranglerBin } from "./runtime-tools.js";
|
|
8
8
|
const DEFAULT_COMPATIBILITY_DATE = "2026-04-05";
|
|
9
9
|
const DEFAULT_COMPATIBILITY_FLAGS = ["nodejs_compat"];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { corePackageRoot, packageRoot, runtimeRoot } from "./runtime-tools.js";
|
|
4
|
+
import { corePackageRoot, packageRoot, runtimeRoot, sdkPackageRoot } from "./runtime-tools.js";
|
|
5
5
|
const pathsRuntimeRoot = resolve(fileURLToPath(new URL("..", import.meta.url)));
|
|
6
6
|
const cliPackageRoot = packageRoot;
|
|
7
7
|
const cliRuntimeRoot = runtimeRoot ?? pathsRuntimeRoot;
|
|
@@ -31,6 +31,7 @@ const templateCatalogRoot = resolve(cliRuntimeRoot, "template-catalog");
|
|
|
31
31
|
const localTemplateArtifactsRoot = resolve(templateCatalogRoot, "templates");
|
|
32
32
|
const cliPackageVersion = readPackageVersion(cliPackageRoot);
|
|
33
33
|
const corePackageVersion = readPackageVersion(corePackageRoot);
|
|
34
|
+
const sdkPackageVersion = readPackageVersion(sdkPackageRoot);
|
|
34
35
|
export {
|
|
35
36
|
cliPackageRoot,
|
|
36
37
|
cliPackageVersion,
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
mailpitComposeFile,
|
|
47
48
|
packageRoot,
|
|
48
49
|
referenceAppsRoot,
|
|
50
|
+
sdkPackageVersion,
|
|
49
51
|
servicesRoot,
|
|
50
52
|
templateCatalogRoot,
|
|
51
53
|
templatesRoot,
|
|
@@ -10,7 +10,7 @@ const packageRootFromSource = resolve(scriptRoot, "..", "..", "..");
|
|
|
10
10
|
const treeseedRuntimeRoot = resolve(packageRootFromSource, "src", "treeseed");
|
|
11
11
|
const TREESEED_DEFAULT_PLUGIN_REFERENCES = [
|
|
12
12
|
{
|
|
13
|
-
package: "@treeseed/
|
|
13
|
+
package: "@treeseed/sdk/plugin-default",
|
|
14
14
|
enabled: true
|
|
15
15
|
}
|
|
16
16
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SdkTemplateCatalogEntry } from '
|
|
1
|
+
import { type SdkTemplateCatalogEntry } from '../../sdk-types.ts';
|
|
2
2
|
export declare const TEMPLATE_CATEGORIES: readonly ["starter", "example", "fixture", "reference-app"];
|
|
3
3
|
export type TemplateCategory = (typeof TEMPLATE_CATEGORIES)[number];
|
|
4
4
|
export interface TemplateVariableDefinition {
|
|
@@ -77,12 +77,12 @@ export declare function serializeTemplateRegistryEntry(product: Pick<TemplatePro
|
|
|
77
77
|
featured: boolean;
|
|
78
78
|
category: import("../../sdk-types.ts").SdkTemplateCategory;
|
|
79
79
|
tags: string[];
|
|
80
|
-
publisher: import("
|
|
80
|
+
publisher: import("../../sdk-types.ts").SdkTemplateCatalogPublisher;
|
|
81
81
|
templateVersion: string;
|
|
82
82
|
templateApiVersion: number;
|
|
83
83
|
minCliVersion: string;
|
|
84
84
|
minCoreVersion: string | undefined;
|
|
85
|
-
source: import("
|
|
85
|
+
source: import("../../sdk-types.ts").SdkTemplateCatalogSource;
|
|
86
86
|
};
|
|
87
87
|
export declare function exportTemplateCatalogYaml(options?: TemplateCatalogOptions): Promise<string>;
|
|
88
88
|
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, relative, resolve } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
RemoteTemplateCatalogClient
|
|
5
|
-
} from "@treeseed/sdk";
|
|
3
|
+
import { RemoteTemplateCatalogClient } from "../../template-catalog.js";
|
|
6
4
|
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
7
5
|
import {
|
|
8
6
|
resolveTreeseedTemplateCatalogCachePath,
|
|
@@ -11,7 +9,8 @@ import {
|
|
|
11
9
|
import {
|
|
12
10
|
cliPackageVersion,
|
|
13
11
|
corePackageVersion,
|
|
14
|
-
localTemplateArtifactsRoot
|
|
12
|
+
localTemplateArtifactsRoot,
|
|
13
|
+
sdkPackageVersion
|
|
15
14
|
} from "./runtime-paths.js";
|
|
16
15
|
const TEMPLATE_CATEGORIES = ["starter", "example", "fixture", "reference-app"];
|
|
17
16
|
function loadJsonFile(filePath) {
|
|
@@ -189,6 +188,8 @@ function resolveVariableValue(variable, input) {
|
|
|
189
188
|
return `^${cliPackageVersion}`;
|
|
190
189
|
case "coreVersion":
|
|
191
190
|
return `^${corePackageVersion}`;
|
|
191
|
+
case "sdkVersion":
|
|
192
|
+
return `^${sdkPackageVersion}`;
|
|
192
193
|
default:
|
|
193
194
|
return variable.default ?? "";
|
|
194
195
|
}
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
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 +1,82 @@
|
|
|
1
|
-
|
|
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 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TreeseedDeployConfig } from './contracts.ts';
|
|
2
|
+
export declare function resolveTreeseedDeployConfigPath(configPath?: string): string;
|
|
3
|
+
export declare function deriveCloudflareWorkerName(config: TreeseedDeployConfig): string;
|
|
4
|
+
export declare function loadTreeseedDeployConfig(configPath?: string): TreeseedDeployConfig;
|
|
@@ -1 +1,222 @@
|
|
|
1
|
-
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { loadTreeseedDeployConfig } from "./deploy
|
|
1
|
+
import { loadTreeseedDeployConfig } from "./deploy-config.js";
|
|
2
2
|
import { TREESEED_DEFAULT_PLUGIN_REFERENCES, TREESEED_DEFAULT_PROVIDER_SELECTIONS } from "./plugins/constants.js";
|
|
3
3
|
let cachedDeployConfig = null;
|
|
4
4
|
function defaultDeployConfig() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TreeseedDeployConfig, TreeseedTenantConfig } from './contracts.ts';
|
|
2
|
-
import { type LoadedTreeseedPluginEntry } from './plugins
|
|
2
|
+
import { type LoadedTreeseedPluginEntry } from './plugins.ts';
|
|
3
3
|
export declare const TREESEED_ENVIRONMENT_SCOPES: readonly ["local", "staging", "prod"];
|
|
4
4
|
export declare const TREESEED_ENVIRONMENT_REQUIREMENTS: readonly ["required", "conditional", "optional"];
|
|
5
5
|
export declare const TREESEED_ENVIRONMENT_TARGETS: readonly ["local-file", "wrangler-dev-vars", "github-secret", "github-variable", "cloudflare-secret", "cloudflare-var", "railway-secret", "config-file"];
|
|
@@ -3,9 +3,9 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
3
3
|
import { dirname, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { parse as parseYaml } from "yaml";
|
|
6
|
-
import { loadTreeseedDeployConfig } from "./deploy
|
|
7
|
-
import { loadTreeseedPlugins } from "./plugins
|
|
8
|
-
import { loadTreeseedManifest } from "./tenant
|
|
6
|
+
import { loadTreeseedDeployConfig } from "./deploy-config.js";
|
|
7
|
+
import { loadTreeseedPlugins } from "./plugins.js";
|
|
8
|
+
import { loadTreeseedManifest } from "./tenant-config.js";
|
|
9
9
|
const TREESEED_ENVIRONMENT_SCOPES = ["local", "staging", "prod"];
|
|
10
10
|
const TREESEED_ENVIRONMENT_REQUIREMENTS = ["required", "conditional", "optional"];
|
|
11
11
|
const TREESEED_ENVIRONMENT_TARGETS = [
|
|
@@ -1,2 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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;
|
package/dist/platform/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const TREESEED_DEFAULT_PLUGIN_PACKAGE = "@treeseed/
|
|
1
|
+
export declare const TREESEED_DEFAULT_PLUGIN_PACKAGE = "@treeseed/sdk/plugin-default";
|
|
2
2
|
export declare const TREESEED_DEFAULT_PROVIDER_SELECTIONS: {
|
|
3
3
|
forms: string;
|
|
4
4
|
operations: string;
|