@treeseed/sdk 0.3.4 → 0.4.1
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 +22 -3
- package/dist/fixture-support.d.ts +24 -0
- package/dist/fixture-support.js +337 -0
- 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 +9 -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(
|
|
@@ -102,6 +102,19 @@ ctx <target>
|
|
|
102
102
|
|
|
103
103
|
The old `key=value` graph DSL is no longer supported.
|
|
104
104
|
|
|
105
|
+
## Shared Fixture Support
|
|
106
|
+
|
|
107
|
+
SDK also owns the shared fixture support model used across the Treeseed workspace.
|
|
108
|
+
|
|
109
|
+
That support layer is responsible for:
|
|
110
|
+
|
|
111
|
+
- resolving the canonical shared fixture in `.fixtures/treeseed-fixtures`
|
|
112
|
+
- preparing fixture-local package visibility for package-scoped verification
|
|
113
|
+
- linking real workspace or installed packages into the fixture runtime when available
|
|
114
|
+
- providing the canonical `contracts-only` Agent shim used by packages such as `core` during isolated verification
|
|
115
|
+
|
|
116
|
+
The shared fixture is an integrated Treeseed project, but package verification remains package-scoped. SDK owns the tooling that lets other packages validate their own slice of that project without mutating the fixture itself.
|
|
117
|
+
|
|
105
118
|
## Advanced Graph Methods
|
|
106
119
|
|
|
107
120
|
The SDK also exposes lower-level graph primitives such as:
|
|
@@ -166,3 +179,9 @@ npm install
|
|
|
166
179
|
npm run build
|
|
167
180
|
npm test
|
|
168
181
|
```
|
|
182
|
+
|
|
183
|
+
For fixture-specific work:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npm run fixtures:check
|
|
187
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type FixtureInjectionMode = 'workspace-link' | 'installed-link' | 'contracts-only';
|
|
2
|
+
export type FixtureSupportDeclaration = {
|
|
3
|
+
packageName: string;
|
|
4
|
+
modes: readonly FixtureInjectionMode[];
|
|
5
|
+
workspaceDirName?: string;
|
|
6
|
+
entrySpecifier?: string;
|
|
7
|
+
contractsShim?: 'agent';
|
|
8
|
+
};
|
|
9
|
+
export type ResolveSharedFixtureOptions = {
|
|
10
|
+
packageRoot?: string;
|
|
11
|
+
requiredPaths?: string[];
|
|
12
|
+
};
|
|
13
|
+
export type PrepareFixturePackagesOptions = {
|
|
14
|
+
fixtureRoot: string;
|
|
15
|
+
packageRoot?: string;
|
|
16
|
+
declarations: readonly FixtureSupportDeclaration[];
|
|
17
|
+
};
|
|
18
|
+
export declare const DEFAULT_FIXTURE_ID = "treeseed-working-site";
|
|
19
|
+
export declare function resolveRequestedFixtureId(): string;
|
|
20
|
+
export declare function resolveFixturesRepoRoot(options?: ResolveSharedFixtureOptions): string;
|
|
21
|
+
export declare function resolveSharedFixtureRoot(options?: ResolveSharedFixtureOptions): string | null;
|
|
22
|
+
export declare function requireSharedFixtureRoot(options?: ResolveSharedFixtureOptions): string;
|
|
23
|
+
export declare function checkSharedFixture(options?: ResolveSharedFixtureOptions): string;
|
|
24
|
+
export declare function prepareFixturePackages(options: PrepareFixturePackagesOptions): void;
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
const require2 = createRequire(import.meta.url);
|
|
6
|
+
const sdkPackageRoot = resolve(fileURLToPath(new URL("..", import.meta.url)));
|
|
7
|
+
const DEFAULT_FIXTURE_ID = "treeseed-working-site";
|
|
8
|
+
function currentPackageRoot(packageRoot) {
|
|
9
|
+
return packageRoot ? resolve(packageRoot) : sdkPackageRoot;
|
|
10
|
+
}
|
|
11
|
+
function requiredFixturePaths(requiredPaths) {
|
|
12
|
+
return requiredPaths && requiredPaths.length > 0 ? requiredPaths : ["src/manifest.yaml", "src/content"];
|
|
13
|
+
}
|
|
14
|
+
function resolveRequestedFixtureId() {
|
|
15
|
+
return process.env.TREESEED_FIXTURE_ID?.trim() || DEFAULT_FIXTURE_ID;
|
|
16
|
+
}
|
|
17
|
+
function resolveFixturesRepoRoot(options = {}) {
|
|
18
|
+
if (process.env.TREESEED_FIXTURES_ROOT?.trim()) {
|
|
19
|
+
return resolve(process.env.TREESEED_FIXTURES_ROOT);
|
|
20
|
+
}
|
|
21
|
+
return resolve(currentPackageRoot(options.packageRoot), ".fixtures", "treeseed-fixtures");
|
|
22
|
+
}
|
|
23
|
+
function fixtureSatisfiesRequiredPaths(root, requiredPaths) {
|
|
24
|
+
return requiredFixturePaths(requiredPaths).every((relativePath) => existsSync(join(root, relativePath)));
|
|
25
|
+
}
|
|
26
|
+
function resolveSharedFixtureRoot(options = {}) {
|
|
27
|
+
const fixturesRepoRoot = resolveFixturesRepoRoot(options);
|
|
28
|
+
const sitesRoot = join(fixturesRepoRoot, "sites");
|
|
29
|
+
if (!existsSync(sitesRoot)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const requestedFixtureId = resolveRequestedFixtureId();
|
|
33
|
+
for (const entry of readdirSync(sitesRoot, { withFileTypes: true })) {
|
|
34
|
+
if (!entry.isDirectory()) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const fixtureRoot = join(sitesRoot, entry.name);
|
|
38
|
+
const manifestPath = join(fixtureRoot, "fixture.manifest.json");
|
|
39
|
+
if (!existsSync(manifestPath)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
44
|
+
if (manifest.id !== requestedFixtureId) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const root = resolve(fixtureRoot, manifest.root ?? ".");
|
|
48
|
+
if (fixtureSatisfiesRequiredPaths(root, options.requiredPaths)) {
|
|
49
|
+
return root;
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function requireSharedFixtureRoot(options = {}) {
|
|
58
|
+
const fixtureRoot = resolveSharedFixtureRoot(options);
|
|
59
|
+
if (!fixtureRoot) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Unable to resolve shared fixture "${resolveRequestedFixtureId()}". Initialize the submodule with "git submodule update --init --recursive".`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return fixtureRoot;
|
|
65
|
+
}
|
|
66
|
+
function checkSharedFixture(options = {}) {
|
|
67
|
+
const fixtureRoot = requireSharedFixtureRoot(options);
|
|
68
|
+
const missing = requiredFixturePaths(options.requiredPaths).filter((relativePath) => !existsSync(join(fixtureRoot, relativePath)));
|
|
69
|
+
if (missing.length > 0) {
|
|
70
|
+
throw new Error(`Shared fixture is missing required paths at ${fixtureRoot}: ${missing.join(", ")}.`);
|
|
71
|
+
}
|
|
72
|
+
return fixtureRoot;
|
|
73
|
+
}
|
|
74
|
+
function resolveInstalledPackageRoot(packageName, entrySpecifier) {
|
|
75
|
+
const candidates = [
|
|
76
|
+
`${packageName}/package.json`,
|
|
77
|
+
entrySpecifier ?? packageName,
|
|
78
|
+
packageName
|
|
79
|
+
];
|
|
80
|
+
for (const candidate of candidates) {
|
|
81
|
+
try {
|
|
82
|
+
const resolvedEntry = require2.resolve(candidate);
|
|
83
|
+
let currentDir = dirname(resolvedEntry);
|
|
84
|
+
while (currentDir !== dirname(currentDir)) {
|
|
85
|
+
if (existsSync(resolve(currentDir, "package.json"))) {
|
|
86
|
+
return currentDir;
|
|
87
|
+
}
|
|
88
|
+
currentDir = dirname(currentDir);
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
function resolveWorkspacePackageRoot(packageRoot, workspaceDirName) {
|
|
97
|
+
if (!workspaceDirName) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const candidate = resolve(packageRoot, "..", workspaceDirName);
|
|
101
|
+
return existsSync(resolve(candidate, "package.json")) ? candidate : null;
|
|
102
|
+
}
|
|
103
|
+
function ensureFixtureLinkedPackage(fixtureRoot, packageName, resolvedPackageRoot) {
|
|
104
|
+
const packageDir = resolve(fixtureRoot, "node_modules", ...packageName.split("/"));
|
|
105
|
+
mkdirSync(dirname(packageDir), { recursive: true });
|
|
106
|
+
rmSync(packageDir, { recursive: true, force: true });
|
|
107
|
+
symlinkSync(resolvedPackageRoot, packageDir, "dir");
|
|
108
|
+
}
|
|
109
|
+
function buildAgentContractsShimPackage(fixtureRoot) {
|
|
110
|
+
const packageDir = resolve(fixtureRoot, "node_modules", "@treeseed", "agent");
|
|
111
|
+
rmSync(packageDir, { recursive: true, force: true });
|
|
112
|
+
mkdirSync(resolve(packageDir, "contracts"), { recursive: true });
|
|
113
|
+
writeFileSync(
|
|
114
|
+
resolve(packageDir, "package.json"),
|
|
115
|
+
JSON.stringify(
|
|
116
|
+
{
|
|
117
|
+
name: "@treeseed/agent",
|
|
118
|
+
type: "module",
|
|
119
|
+
exports: {
|
|
120
|
+
"./runtime-types": {
|
|
121
|
+
types: "./runtime-types.d.js",
|
|
122
|
+
default: "./runtime-types.js"
|
|
123
|
+
},
|
|
124
|
+
"./contracts/messages": {
|
|
125
|
+
types: "./contracts/messages.d.js",
|
|
126
|
+
default: "./contracts/messages.js"
|
|
127
|
+
},
|
|
128
|
+
"./contracts/run": {
|
|
129
|
+
types: "./contracts/run.d.js",
|
|
130
|
+
default: "./contracts/run.js"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
null,
|
|
135
|
+
2
|
|
136
|
+
),
|
|
137
|
+
"utf8"
|
|
138
|
+
);
|
|
139
|
+
writeFileSync(resolve(packageDir, "runtime-types.js"), "export {};\n", "utf8");
|
|
140
|
+
writeFileSync(
|
|
141
|
+
resolve(packageDir, "runtime-types.d.ts"),
|
|
142
|
+
[
|
|
143
|
+
"import type { AgentHandlerKind, AgentRunStatus } from '@treeseed/sdk/types/agents';",
|
|
144
|
+
"export interface AgentTriggerInvocation {",
|
|
145
|
+
" kind: 'startup' | 'schedule' | 'message' | 'manual' | 'follow';",
|
|
146
|
+
" source: string;",
|
|
147
|
+
" message?: { id?: string | number; type?: string; payloadJson?: string | null } | null;",
|
|
148
|
+
"}",
|
|
149
|
+
"export interface AgentExecutionResult {",
|
|
150
|
+
" status: AgentRunStatus;",
|
|
151
|
+
" summary: string;",
|
|
152
|
+
" stdout?: string;",
|
|
153
|
+
" stderr?: string;",
|
|
154
|
+
" errorCategory?: import('./contracts/run').AgentErrorCategory | null;",
|
|
155
|
+
" metadata?: Record<string, unknown>;",
|
|
156
|
+
"}",
|
|
157
|
+
"export interface AgentContext {",
|
|
158
|
+
" runId: string;",
|
|
159
|
+
" repoRoot: string;",
|
|
160
|
+
" agent: any;",
|
|
161
|
+
" sdk: any;",
|
|
162
|
+
" trigger: AgentTriggerInvocation;",
|
|
163
|
+
" execution: any;",
|
|
164
|
+
" mutations: any;",
|
|
165
|
+
" repository: any;",
|
|
166
|
+
" verification: any;",
|
|
167
|
+
" notifications: any;",
|
|
168
|
+
" research: any;",
|
|
169
|
+
"}",
|
|
170
|
+
"export interface AgentHandler<TInputs = unknown, TResult = unknown> {",
|
|
171
|
+
" kind: AgentHandlerKind;",
|
|
172
|
+
" resolveInputs(context: AgentContext): Promise<TInputs>;",
|
|
173
|
+
" execute(context: AgentContext, inputs: TInputs): Promise<TResult>;",
|
|
174
|
+
" emitOutputs(context: AgentContext, result: TResult): Promise<AgentExecutionResult>;",
|
|
175
|
+
"}",
|
|
176
|
+
""
|
|
177
|
+
].join("\n"),
|
|
178
|
+
"utf8"
|
|
179
|
+
);
|
|
180
|
+
writeFileSync(
|
|
181
|
+
resolve(packageDir, "contracts", "messages.js"),
|
|
182
|
+
[
|
|
183
|
+
"export const AGENT_MESSAGE_TYPES = [];",
|
|
184
|
+
"export function parseAgentMessagePayload(_type, payloadJson) {",
|
|
185
|
+
" return JSON.parse(payloadJson);",
|
|
186
|
+
"}",
|
|
187
|
+
""
|
|
188
|
+
].join("\n"),
|
|
189
|
+
"utf8"
|
|
190
|
+
);
|
|
191
|
+
writeFileSync(
|
|
192
|
+
resolve(packageDir, "contracts", "messages.d.ts"),
|
|
193
|
+
[
|
|
194
|
+
"export interface QuestionPriorityUpdatedMessage {",
|
|
195
|
+
" questionId: string;",
|
|
196
|
+
" reason: string;",
|
|
197
|
+
" plannerRunId: string;",
|
|
198
|
+
"}",
|
|
199
|
+
"export interface ObjectivePriorityUpdatedMessage {",
|
|
200
|
+
" objectiveId: string;",
|
|
201
|
+
" reason: string;",
|
|
202
|
+
" plannerRunId: string;",
|
|
203
|
+
"}",
|
|
204
|
+
"export interface ArchitectureUpdatedMessage {",
|
|
205
|
+
" objectiveId: string;",
|
|
206
|
+
" knowledgeId: string;",
|
|
207
|
+
" architectRunId: string;",
|
|
208
|
+
"}",
|
|
209
|
+
"export interface SubscriberNotifiedMessage {",
|
|
210
|
+
" email: string;",
|
|
211
|
+
" itemCount: number;",
|
|
212
|
+
" notifierRunId: string;",
|
|
213
|
+
"}",
|
|
214
|
+
"export interface ResearchStartedMessage {",
|
|
215
|
+
" questionId: string;",
|
|
216
|
+
" researcherRunId: string;",
|
|
217
|
+
"}",
|
|
218
|
+
"export interface ResearchCompletedMessage {",
|
|
219
|
+
" questionId: string;",
|
|
220
|
+
" knowledgeId: string | null;",
|
|
221
|
+
" researcherRunId: string;",
|
|
222
|
+
"}",
|
|
223
|
+
"export interface TaskCompleteMessage {",
|
|
224
|
+
" branchName: string | null;",
|
|
225
|
+
" changedTargets: string[];",
|
|
226
|
+
" engineerRunId: string;",
|
|
227
|
+
"}",
|
|
228
|
+
"export interface TaskWaitingMessage {",
|
|
229
|
+
" blockingReason: string;",
|
|
230
|
+
" engineerRunId: string;",
|
|
231
|
+
"}",
|
|
232
|
+
"export interface TaskFailedMessage {",
|
|
233
|
+
" failureSummary: string;",
|
|
234
|
+
" engineerRunId: string;",
|
|
235
|
+
"}",
|
|
236
|
+
"export interface TaskVerifiedMessage {",
|
|
237
|
+
" branchName: string | null;",
|
|
238
|
+
" reviewerRunId: string;",
|
|
239
|
+
"}",
|
|
240
|
+
"export interface ReviewFailedMessage {",
|
|
241
|
+
" failureSummary: string;",
|
|
242
|
+
" reviewerRunId: string;",
|
|
243
|
+
"}",
|
|
244
|
+
"export interface ReviewWaitingMessage {",
|
|
245
|
+
" blockingReason: string;",
|
|
246
|
+
" reviewerRunId: string;",
|
|
247
|
+
"}",
|
|
248
|
+
"export interface ReleaseStartedMessage {",
|
|
249
|
+
" taskRunId: string | null;",
|
|
250
|
+
" releaserRunId: string;",
|
|
251
|
+
"}",
|
|
252
|
+
"export interface ReleaseCompletedMessage {",
|
|
253
|
+
" releaseSummary: string;",
|
|
254
|
+
" releaserRunId: string;",
|
|
255
|
+
"}",
|
|
256
|
+
"export interface ReleaseFailedMessage {",
|
|
257
|
+
" failureSummary: string;",
|
|
258
|
+
" releaserRunId: string;",
|
|
259
|
+
"}",
|
|
260
|
+
"export interface AgentMessageContracts {",
|
|
261
|
+
" question_priority_updated: QuestionPriorityUpdatedMessage;",
|
|
262
|
+
" objective_priority_updated: ObjectivePriorityUpdatedMessage;",
|
|
263
|
+
" architecture_updated: ArchitectureUpdatedMessage;",
|
|
264
|
+
" subscriber_notified: SubscriberNotifiedMessage;",
|
|
265
|
+
" research_started: ResearchStartedMessage;",
|
|
266
|
+
" research_completed: ResearchCompletedMessage;",
|
|
267
|
+
" task_complete: TaskCompleteMessage;",
|
|
268
|
+
" task_waiting: TaskWaitingMessage;",
|
|
269
|
+
" task_failed: TaskFailedMessage;",
|
|
270
|
+
" task_verified: TaskVerifiedMessage;",
|
|
271
|
+
" review_failed: ReviewFailedMessage;",
|
|
272
|
+
" review_waiting: ReviewWaitingMessage;",
|
|
273
|
+
" release_started: ReleaseStartedMessage;",
|
|
274
|
+
" release_completed: ReleaseCompletedMessage;",
|
|
275
|
+
" release_failed: ReleaseFailedMessage;",
|
|
276
|
+
"}",
|
|
277
|
+
"export type AgentMessageType = keyof AgentMessageContracts;",
|
|
278
|
+
"export type AgentMessagePayload<TType extends AgentMessageType> = AgentMessageContracts[TType];",
|
|
279
|
+
"export declare const AGENT_MESSAGE_TYPES: readonly AgentMessageType[];",
|
|
280
|
+
"export declare function parseAgentMessagePayload<TType extends AgentMessageType>(_type: TType, payloadJson: string): AgentMessagePayload<TType>;",
|
|
281
|
+
""
|
|
282
|
+
].join("\n"),
|
|
283
|
+
"utf8"
|
|
284
|
+
);
|
|
285
|
+
writeFileSync(resolve(packageDir, "contracts", "run.js"), "export {};\n", "utf8");
|
|
286
|
+
writeFileSync(
|
|
287
|
+
resolve(packageDir, "contracts", "run.d.ts"),
|
|
288
|
+
[
|
|
289
|
+
"export type AgentErrorCategory = 'execution_error' | 'mutation_error' | 'verification_error' | 'notification_error' | 'research_error' | 'sdk_error' | 'unknown';",
|
|
290
|
+
""
|
|
291
|
+
].join("\n"),
|
|
292
|
+
"utf8"
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
function prepareFixturePackages(options) {
|
|
296
|
+
const packageRoot = currentPackageRoot(options.packageRoot);
|
|
297
|
+
for (const declaration of options.declarations) {
|
|
298
|
+
let satisfied = false;
|
|
299
|
+
for (const mode of declaration.modes) {
|
|
300
|
+
if (mode === "workspace-link") {
|
|
301
|
+
const workspaceRoot = resolveWorkspacePackageRoot(packageRoot, declaration.workspaceDirName);
|
|
302
|
+
if (!workspaceRoot) {
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
ensureFixtureLinkedPackage(options.fixtureRoot, declaration.packageName, workspaceRoot);
|
|
306
|
+
satisfied = true;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
if (mode === "installed-link") {
|
|
310
|
+
const installedRoot = resolveInstalledPackageRoot(declaration.packageName, declaration.entrySpecifier);
|
|
311
|
+
if (!installedRoot) {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
ensureFixtureLinkedPackage(options.fixtureRoot, declaration.packageName, installedRoot);
|
|
315
|
+
satisfied = true;
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
if (mode === "contracts-only" && declaration.contractsShim === "agent") {
|
|
319
|
+
buildAgentContractsShimPackage(options.fixtureRoot);
|
|
320
|
+
satisfied = true;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (!satisfied) {
|
|
325
|
+
throw new Error(`Unable to prepare fixture package "${declaration.packageName}" using modes ${declaration.modes.join(", ")}.`);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
export {
|
|
330
|
+
DEFAULT_FIXTURE_ID,
|
|
331
|
+
checkSharedFixture,
|
|
332
|
+
prepareFixturePackages,
|
|
333
|
+
requireSharedFixtureRoot,
|
|
334
|
+
resolveFixturesRepoRoot,
|
|
335
|
+
resolveRequestedFixtureId,
|
|
336
|
+
resolveSharedFixtureRoot
|
|
337
|
+
};
|
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 {};
|