@treeseed/sdk 0.6.39 → 0.6.41
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/dist/capacity.d.ts +53 -0
- package/dist/capacity.js +100 -0
- package/dist/control-plane-client.d.ts +41 -1
- package/dist/control-plane-client.js +154 -0
- package/dist/control-plane.d.ts +6 -1
- package/dist/control-plane.js +39 -2
- package/dist/d1-store.d.ts +63 -1
- package/dist/d1-store.js +190 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -0
- package/dist/operations/services/config-runtime.js +2 -2
- package/dist/operations/services/deploy.js +3 -2
- package/dist/operations/services/knowledge-coop-launch.js +5 -28
- package/dist/operations/services/package-reference-policy.d.ts +68 -0
- package/dist/operations/services/package-reference-policy.js +135 -0
- package/dist/operations/services/project-platform.d.ts +14 -0
- package/dist/operations/services/project-platform.js +3 -2
- package/dist/operations/services/railway-api.d.ts +33 -0
- package/dist/operations/services/railway-api.js +273 -0
- package/dist/operations/services/railway-deploy.d.ts +22 -0
- package/dist/operations/services/railway-deploy.js +216 -18
- package/dist/operations/services/release-candidate.d.ts +2 -0
- package/dist/operations/services/release-candidate.js +28 -0
- package/dist/operations/services/runtime-tools.js +1 -1
- package/dist/operations-registry.js +1 -0
- package/dist/reconcile/bootstrap-systems.js +1 -1
- package/dist/reconcile/builtin-adapters.js +5 -9
- package/dist/reconcile/contracts.d.ts +1 -1
- package/dist/reconcile/desired-state.js +9 -17
- package/dist/reconcile/state.js +4 -4
- package/dist/reconcile/units.js +4 -8
- package/dist/sdk-types.d.ts +566 -3
- package/dist/sdk.d.ts +12 -1
- package/dist/sdk.js +44 -0
- package/dist/stores/operational-store.d.ts +12 -1
- package/dist/stores/operational-store.js +283 -5
- package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +5 -24
- package/dist/types/agents.d.ts +27 -0
- package/dist/workflow/operations.d.ts +94 -2
- package/dist/workflow/operations.js +90 -32
- package/dist/workflow-state.js +3 -5
- package/dist/workflow.d.ts +8 -1
- package/dist/workflow.js +6 -0
- package/package.json +5 -1
|
@@ -104,7 +104,8 @@ import {
|
|
|
104
104
|
} from "../operations/services/repository-save-orchestrator.js";
|
|
105
105
|
import {
|
|
106
106
|
assertNoInternalDevReferences,
|
|
107
|
-
|
|
107
|
+
cleanupStaleTreeseedDevTags,
|
|
108
|
+
collectTreeseedDevTagCleanupPlan,
|
|
108
109
|
collectInternalDevReferenceIssues,
|
|
109
110
|
devTagFromDependencySpec,
|
|
110
111
|
rewriteProjectInternalDependenciesToStableVersions
|
|
@@ -115,6 +116,7 @@ import {
|
|
|
115
116
|
unlinkLocalWorkspaceLinks
|
|
116
117
|
} from "../operations/services/workspace-dependency-mode.js";
|
|
117
118
|
import {
|
|
119
|
+
hasCompleteTreeseedPackageCheckout,
|
|
118
120
|
changedWorkspacePackages,
|
|
119
121
|
publishableWorkspacePackages,
|
|
120
122
|
run,
|
|
@@ -815,11 +817,10 @@ function defaultCiWorkflows(kind, branch) {
|
|
|
815
817
|
if (kind === "package") {
|
|
816
818
|
return ["verify.yml"];
|
|
817
819
|
}
|
|
818
|
-
const workflows = ["verify.yml"];
|
|
819
820
|
if (branch === STAGING_BRANCH || branch === PRODUCTION_BRANCH) {
|
|
820
|
-
|
|
821
|
+
return ["deploy.yml"];
|
|
821
822
|
}
|
|
822
|
-
return
|
|
823
|
+
return ["verify.yml"];
|
|
823
824
|
}
|
|
824
825
|
function githubRepositoryForRepo(repoDir) {
|
|
825
826
|
try {
|
|
@@ -1565,6 +1566,66 @@ function backMergeRootProductionIntoStaging(root, syncPackageStagingHeads, optio
|
|
|
1565
1566
|
function collectActiveDevTagReferences(root) {
|
|
1566
1567
|
return collectInternalDevReferenceIssues(root).map((issue) => devTagFromDependencySpec(issue.spec) ?? (issue.spec.includes("-dev.") ? issue.spec : null)).filter((value) => Boolean(value));
|
|
1567
1568
|
}
|
|
1569
|
+
function normalizeIncludePackages(value) {
|
|
1570
|
+
if (!value) return null;
|
|
1571
|
+
const values = Array.isArray(value) ? value : String(value).split(",");
|
|
1572
|
+
const normalized = values.map((entry) => String(entry).trim()).filter(Boolean);
|
|
1573
|
+
return normalized.length > 0 ? new Set(normalized) : null;
|
|
1574
|
+
}
|
|
1575
|
+
function normalizeDevTagBranchScope(value) {
|
|
1576
|
+
return value === "staging" || value === "preview" || value === "all" ? value : "all";
|
|
1577
|
+
}
|
|
1578
|
+
function packageJsonVersion(repoDir) {
|
|
1579
|
+
const packageJson = JSON.parse(readFileSync(resolve(repoDir, "package.json"), "utf8"));
|
|
1580
|
+
return String(packageJson.version ?? "");
|
|
1581
|
+
}
|
|
1582
|
+
function collectStaleDevTagCleanupReports(root, input, options) {
|
|
1583
|
+
const includePackages = normalizeIncludePackages(input.includePackages);
|
|
1584
|
+
const branchScope = normalizeDevTagBranchScope(input.branchScope);
|
|
1585
|
+
const activeDevTags = collectActiveDevTagReferences(root);
|
|
1586
|
+
const repos = checkedOutWorkspacePackageRepos(root).filter((pkg) => !includePackages || includePackages.has(pkg.name)).map((pkg) => {
|
|
1587
|
+
const currentVersion = packageJsonVersion(pkg.dir);
|
|
1588
|
+
const report = options.execute ? cleanupStaleTreeseedDevTags({
|
|
1589
|
+
repoDir: pkg.dir,
|
|
1590
|
+
packageName: pkg.name,
|
|
1591
|
+
currentVersion,
|
|
1592
|
+
activeReferences: activeDevTags,
|
|
1593
|
+
branchScope
|
|
1594
|
+
}) : {
|
|
1595
|
+
...collectTreeseedDevTagCleanupPlan({
|
|
1596
|
+
repoDir: pkg.dir,
|
|
1597
|
+
packageName: pkg.name,
|
|
1598
|
+
currentVersion,
|
|
1599
|
+
activeReferences: activeDevTags,
|
|
1600
|
+
branchScope
|
|
1601
|
+
}),
|
|
1602
|
+
status: "planned",
|
|
1603
|
+
candidateCount: 0,
|
|
1604
|
+
cleaned: [],
|
|
1605
|
+
cleanedCount: 0,
|
|
1606
|
+
skippedCount: 0
|
|
1607
|
+
};
|
|
1608
|
+
if (!options.execute) {
|
|
1609
|
+
const planned = report;
|
|
1610
|
+
planned.candidateCount = planned.candidates.length;
|
|
1611
|
+
planned.skippedCount = planned.skipped.length;
|
|
1612
|
+
}
|
|
1613
|
+
return {
|
|
1614
|
+
name: pkg.name,
|
|
1615
|
+
path: relative(root, pkg.dir),
|
|
1616
|
+
...report
|
|
1617
|
+
};
|
|
1618
|
+
});
|
|
1619
|
+
return {
|
|
1620
|
+
status: options.execute ? "completed" : "planned",
|
|
1621
|
+
branchScope,
|
|
1622
|
+
includePackages: includePackages ? [...includePackages].sort() : [],
|
|
1623
|
+
repos,
|
|
1624
|
+
candidateCount: repos.reduce((total, repo) => total + Number(repo.candidateCount ?? 0), 0),
|
|
1625
|
+
cleanedCount: repos.reduce((total, repo) => total + Number(repo.cleanedCount ?? 0), 0),
|
|
1626
|
+
skippedCount: repos.reduce((total, repo) => total + Number(repo.skippedCount ?? 0), 0)
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1568
1629
|
function releasePlanVersionMap(plannedVersions) {
|
|
1569
1630
|
return new Map(
|
|
1570
1631
|
Object.entries(plannedVersions).filter(([name]) => name !== "@treeseed/market").map(([name, version]) => [name, String(version)])
|
|
@@ -3431,13 +3492,6 @@ async function workflowStage(helpers, input) {
|
|
|
3431
3492
|
});
|
|
3432
3493
|
}
|
|
3433
3494
|
const stageWorkflowGateResult = effectiveInput.waitForStaging === false ? (skipJournalStep(root, workflowRun.runId, "wait-staging", { status: "skipped", reason: "disabled" }), { status: "skipped", reason: "disabled" }) : await executeJournalStep(root, workflowRun.runId, "wait-staging", () => waitForWorkflowGates("stage", [
|
|
3434
|
-
{
|
|
3435
|
-
name: rootRepo.name,
|
|
3436
|
-
repoPath: rootRepo.path,
|
|
3437
|
-
workflow: "verify.yml",
|
|
3438
|
-
branch: STAGING_BRANCH,
|
|
3439
|
-
headSha: rootRepo.commitSha
|
|
3440
|
-
},
|
|
3441
3495
|
{
|
|
3442
3496
|
name: rootRepo.name,
|
|
3443
3497
|
repoPath: rootRepo.path,
|
|
@@ -3562,6 +3616,25 @@ async function workflowStage(helpers, input) {
|
|
|
3562
3616
|
toError("stage", error);
|
|
3563
3617
|
}
|
|
3564
3618
|
}
|
|
3619
|
+
async function workflowTagsCleanup(helpers, input = {}) {
|
|
3620
|
+
try {
|
|
3621
|
+
return await withContextEnv(helpers.context.env, async () => {
|
|
3622
|
+
const root = resolveProjectRootOrThrow("tags:cleanup", helpers.cwd());
|
|
3623
|
+
const executionMode = input.plan === true || input.dryRun === true ? "plan" : "execute";
|
|
3624
|
+
const cleanup = collectStaleDevTagCleanupReports(root, input, { execute: executionMode === "execute" });
|
|
3625
|
+
return buildWorkflowResult("tags:cleanup", root, {
|
|
3626
|
+
...cleanup,
|
|
3627
|
+
mode: hasCompleteTreeseedPackageCheckout(root) ? "recursive-workspace" : "root-only"
|
|
3628
|
+
}, {
|
|
3629
|
+
executionMode,
|
|
3630
|
+
summary: executionMode === "plan" ? "Treeseed dev tag cleanup plan ready." : "Treeseed dev tag cleanup completed.",
|
|
3631
|
+
nextSteps: executionMode === "plan" ? createNextSteps([{ operation: "tags:cleanup", reason: "Run without --plan to delete the stale Treeseed-managed dev tags.", input: { branchScope: cleanup.branchScope } }]) : createNextSteps([{ operation: "status", reason: "Inspect workspace state after tag cleanup." }])
|
|
3632
|
+
});
|
|
3633
|
+
});
|
|
3634
|
+
} catch (error) {
|
|
3635
|
+
toError("tags:cleanup", error);
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3565
3638
|
async function workflowRelease(helpers, input) {
|
|
3566
3639
|
try {
|
|
3567
3640
|
return await withContextEnv(helpers.context.env, async () => {
|
|
@@ -4071,27 +4144,11 @@ async function workflowRelease(helpers, input) {
|
|
|
4071
4144
|
}));
|
|
4072
4145
|
const devTagCleanupMode = effectiveInput.devTagCleanup ?? "safe-after-release";
|
|
4073
4146
|
const devTagCleanup = devTagCleanupMode === "off" ? (skipJournalStep(root, workflowRun.runId, "cleanup-dev-tags", { status: "skipped", reason: "disabled" }), { status: "skipped", reason: "disabled" }) : await executeJournalStep(root, workflowRun.runId, "cleanup-dev-tags", () => {
|
|
4074
|
-
const
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
if (!tagName || !packageName) continue;
|
|
4080
|
-
byPackage.set(packageName, [...byPackage.get(packageName) ?? [], tagName]);
|
|
4081
|
-
}
|
|
4082
|
-
for (const [packageName, tagName] of releasedPackageDevTags.entries()) {
|
|
4083
|
-
byPackage.set(packageName, [...byPackage.get(packageName) ?? [], tagName]);
|
|
4084
|
-
}
|
|
4085
|
-
const cleanupReports = [];
|
|
4086
|
-
for (const pkg of checkedOutWorkspacePackageRepos(root)) {
|
|
4087
|
-
const tagNames = byPackage.get(pkg.name) ?? [];
|
|
4088
|
-
if (tagNames.length === 0) continue;
|
|
4089
|
-
cleanupReports.push({
|
|
4090
|
-
name: pkg.name,
|
|
4091
|
-
...cleanupDevTags(pkg.dir, tagNames, activeDevTags)
|
|
4092
|
-
});
|
|
4093
|
-
}
|
|
4094
|
-
return { status: "completed", repos: cleanupReports };
|
|
4147
|
+
const cleanup = collectStaleDevTagCleanupReports(root, {
|
|
4148
|
+
includePackages: effectivePackageSelection.selected,
|
|
4149
|
+
branchScope: "all"
|
|
4150
|
+
}, { execute: true });
|
|
4151
|
+
return { ...cleanup, replacedDevReferenceCount: replacedDevReferences.length, releasedPackageDevTagCount: releasedPackageDevTags.size };
|
|
4095
4152
|
});
|
|
4096
4153
|
syncAllCheckedOutPackageRepos(root, STAGING_BRANCH);
|
|
4097
4154
|
const workspaceLinks = ensureWorkflowWorkspaceLinks(root, helpers, effectiveInput.workspaceLinks ?? "auto");
|
|
@@ -4500,5 +4557,6 @@ export {
|
|
|
4500
4557
|
workflowStage,
|
|
4501
4558
|
workflowStatus,
|
|
4502
4559
|
workflowSwitch,
|
|
4560
|
+
workflowTagsCleanup,
|
|
4503
4561
|
workflowTasks
|
|
4504
4562
|
};
|
package/dist/workflow-state.js
CHANGED
|
@@ -540,10 +540,8 @@ function resolveTreeseedWorkflowState(cwd, options = {}) {
|
|
|
540
540
|
},
|
|
541
541
|
managedServices: {
|
|
542
542
|
api: { enabled: false, initialized: false, lastDeploymentTimestamp: null, lastDeployedUrl: null, provider: null },
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
workdayStart: { enabled: false, initialized: false, lastDeploymentTimestamp: null, lastDeployedUrl: null, provider: null },
|
|
546
|
-
workdayReport: { enabled: false, initialized: false, lastDeploymentTimestamp: null, lastDeployedUrl: null, provider: null }
|
|
543
|
+
workdayManager: { enabled: false, initialized: false, lastDeploymentTimestamp: null, lastDeployedUrl: null, provider: null },
|
|
544
|
+
workerRunner: { enabled: false, initialized: false, lastDeploymentTimestamp: null, lastDeployedUrl: null, provider: null }
|
|
547
545
|
},
|
|
548
546
|
files: {
|
|
549
547
|
treeseedConfig: tenantRoot,
|
|
@@ -659,7 +657,7 @@ function resolveTreeseedWorkflowState(cwd, options = {}) {
|
|
|
659
657
|
state.webCache.lastContentPurgeAt = deployState.webCache?.contentPurge?.lastPurgedAt ?? null;
|
|
660
658
|
state.webCache.lastContentPurgeCount = deployState.webCache?.contentPurge?.purgeCount ?? null;
|
|
661
659
|
}
|
|
662
|
-
for (const serviceKey of ["api", "
|
|
660
|
+
for (const serviceKey of ["api", "workdayManager", "workerRunner"]) {
|
|
663
661
|
const service = deployState.services?.[serviceKey];
|
|
664
662
|
if (!service) continue;
|
|
665
663
|
state.managedServices[serviceKey] = {
|
package/dist/workflow.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { resolveTreeseedWorkflowState, type TreeseedWorkflowStatusOptions } from
|
|
|
2
2
|
import { listTaskBranches } from './operations/services/git-workflow.ts';
|
|
3
3
|
import type { GitHubActionsVerificationReport } from './operations/services/github-actions-verification.ts';
|
|
4
4
|
import { TreeseedWorkflowError, type TreeseedWorkflowErrorCode } from './workflow/operations.ts';
|
|
5
|
-
export type TreeseedWorkflowOperationId = 'status' | 'ci' | 'config' | 'tasks' | 'switch' | 'dev' | 'save' | 'close' | 'stage' | 'release' | 'resume' | 'recover' | 'destroy' | 'export';
|
|
5
|
+
export type TreeseedWorkflowOperationId = 'status' | 'ci' | 'config' | 'tasks' | 'switch' | 'dev' | 'save' | 'close' | 'stage' | 'release' | 'tags:cleanup' | 'resume' | 'recover' | 'destroy' | 'export';
|
|
6
6
|
export type TreeseedWorkflowNextStep = {
|
|
7
7
|
operation: string;
|
|
8
8
|
reason?: string;
|
|
@@ -219,6 +219,12 @@ export type TreeseedReleaseInput = {
|
|
|
219
219
|
plan?: boolean;
|
|
220
220
|
dryRun?: boolean;
|
|
221
221
|
};
|
|
222
|
+
export type TreeseedTagsCleanupInput = {
|
|
223
|
+
includePackages?: string | string[];
|
|
224
|
+
branchScope?: 'staging' | 'preview' | 'all';
|
|
225
|
+
plan?: boolean;
|
|
226
|
+
dryRun?: boolean;
|
|
227
|
+
};
|
|
222
228
|
export type TreeseedResumeInput = {
|
|
223
229
|
runId: string;
|
|
224
230
|
};
|
|
@@ -269,6 +275,7 @@ export declare class TreeseedWorkflowSdk {
|
|
|
269
275
|
close(input: TreeseedCloseInput): Promise<TreeseedWorkflowResult>;
|
|
270
276
|
stage(input: TreeseedStageInput): Promise<TreeseedWorkflowResult>;
|
|
271
277
|
release(input: TreeseedReleaseInput): Promise<TreeseedWorkflowResult>;
|
|
278
|
+
tagsCleanup(input?: TreeseedTagsCleanupInput): Promise<TreeseedWorkflowResult>;
|
|
272
279
|
resume(input: TreeseedResumeInput): Promise<TreeseedWorkflowResult>;
|
|
273
280
|
recover(input?: TreeseedRecoverInput): Promise<TreeseedWorkflowResult>;
|
|
274
281
|
destroy(input: TreeseedDestroyInput): Promise<TreeseedWorkflowResult>;
|
package/dist/workflow.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
workflowStage,
|
|
15
15
|
workflowStatus,
|
|
16
16
|
workflowSwitch,
|
|
17
|
+
workflowTagsCleanup,
|
|
17
18
|
workflowTasks
|
|
18
19
|
} from "./workflow/operations.js";
|
|
19
20
|
function defaultWrite(output, stream = "stdout") {
|
|
@@ -61,6 +62,8 @@ class TreeseedWorkflowSdk {
|
|
|
61
62
|
return this.stage(input);
|
|
62
63
|
case "release":
|
|
63
64
|
return this.release(input);
|
|
65
|
+
case "tags:cleanup":
|
|
66
|
+
return this.tagsCleanup(input);
|
|
64
67
|
case "resume":
|
|
65
68
|
return this.resume(input);
|
|
66
69
|
case "recover":
|
|
@@ -103,6 +106,9 @@ class TreeseedWorkflowSdk {
|
|
|
103
106
|
async release(input) {
|
|
104
107
|
return workflowRelease(this.helpers(), input);
|
|
105
108
|
}
|
|
109
|
+
async tagsCleanup(input = {}) {
|
|
110
|
+
return workflowTagsCleanup(this.helpers(), input);
|
|
111
|
+
}
|
|
106
112
|
async resume(input) {
|
|
107
113
|
return workflowResume(this.helpers(), input);
|
|
108
114
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.41",
|
|
4
4
|
"description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -213,6 +213,10 @@
|
|
|
213
213
|
"types": "./dist/copilot.d.ts",
|
|
214
214
|
"default": "./dist/copilot.js"
|
|
215
215
|
},
|
|
216
|
+
"./capacity": {
|
|
217
|
+
"types": "./dist/capacity.d.ts",
|
|
218
|
+
"default": "./dist/capacity.js"
|
|
219
|
+
},
|
|
216
220
|
"./types": {
|
|
217
221
|
"types": "./dist/sdk-types.d.ts",
|
|
218
222
|
"default": "./dist/sdk-types.js"
|