@treeseed/sdk 0.6.39 → 0.6.40

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 (44) hide show
  1. package/dist/capacity.d.ts +53 -0
  2. package/dist/capacity.js +100 -0
  3. package/dist/control-plane-client.d.ts +41 -1
  4. package/dist/control-plane-client.js +154 -0
  5. package/dist/control-plane.d.ts +6 -1
  6. package/dist/control-plane.js +39 -2
  7. package/dist/d1-store.d.ts +63 -1
  8. package/dist/d1-store.js +190 -1
  9. package/dist/index.d.ts +3 -1
  10. package/dist/index.js +12 -0
  11. package/dist/operations/services/config-runtime.js +2 -2
  12. package/dist/operations/services/deploy.js +3 -2
  13. package/dist/operations/services/knowledge-coop-launch.js +5 -28
  14. package/dist/operations/services/package-reference-policy.d.ts +68 -0
  15. package/dist/operations/services/package-reference-policy.js +135 -0
  16. package/dist/operations/services/project-platform.d.ts +14 -0
  17. package/dist/operations/services/project-platform.js +3 -2
  18. package/dist/operations/services/railway-api.d.ts +33 -0
  19. package/dist/operations/services/railway-api.js +273 -0
  20. package/dist/operations/services/railway-deploy.d.ts +22 -0
  21. package/dist/operations/services/railway-deploy.js +81 -19
  22. package/dist/operations/services/release-candidate.d.ts +2 -0
  23. package/dist/operations/services/release-candidate.js +28 -0
  24. package/dist/operations/services/runtime-tools.js +1 -1
  25. package/dist/operations-registry.js +1 -0
  26. package/dist/reconcile/bootstrap-systems.js +1 -1
  27. package/dist/reconcile/builtin-adapters.js +5 -9
  28. package/dist/reconcile/contracts.d.ts +1 -1
  29. package/dist/reconcile/desired-state.js +9 -17
  30. package/dist/reconcile/state.js +4 -4
  31. package/dist/reconcile/units.js +4 -8
  32. package/dist/sdk-types.d.ts +566 -3
  33. package/dist/sdk.d.ts +12 -1
  34. package/dist/sdk.js +44 -0
  35. package/dist/stores/operational-store.d.ts +12 -1
  36. package/dist/stores/operational-store.js +283 -5
  37. package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +5 -24
  38. package/dist/types/agents.d.ts +27 -0
  39. package/dist/workflow/operations.d.ts +94 -2
  40. package/dist/workflow/operations.js +90 -32
  41. package/dist/workflow-state.js +3 -5
  42. package/dist/workflow.d.ts +8 -1
  43. package/dist/workflow.js +6 -0
  44. package/package.json +5 -1
@@ -13,6 +13,7 @@ import { loadCliDeployConfig } from "./runtime-tools.js";
13
13
  import { packagesWithScript, run, workspacePackages } from "./workspace-tools.js";
14
14
  import { createBuildWarningSummary, formatAllowedBuildWarnings } from "./build-warning-policy.js";
15
15
  const RELEASE_CANDIDATE_CACHE_DIR = ".treeseed/workflow/release-candidates";
16
+ const RELEASE_CANDIDATE_POLICY_VERSION = "strict-output-v1";
16
17
  const STABLE_SEMVER = /^\d+\.\d+\.\d+$/u;
17
18
  const REHEARSAL_IGNORED_SEGMENTS = /* @__PURE__ */ new Set([
18
19
  ".git",
@@ -86,6 +87,7 @@ function buildReleaseCandidateFingerprint(input) {
86
87
  ...Object.fromEntries(packages.map((pkg) => [pkg.name, fileSha256(resolve(pkg.dir, "package-lock.json"))]))
87
88
  });
88
89
  const base = {
90
+ policyVersion: RELEASE_CANDIDATE_POLICY_VERSION,
89
91
  rootSha: safeGitHead(input.root),
90
92
  packageShas,
91
93
  plannedVersions,
@@ -241,11 +243,15 @@ function runNpmRehearsalCommand(args, options) {
241
243
  throw new Error(message);
242
244
  }
243
245
  const warningSummary = createBuildWarningSummary();
246
+ const outputFailures = [];
244
247
  const emitFiltered = (text, stream) => {
245
248
  for (const line of text.split(/\r?\n/u)) {
246
249
  if (!line) continue;
247
250
  const classified = warningSummary.record(line);
248
251
  if (classified.kind === "allowed") continue;
252
+ for (const failure of collectReleaseCandidateOutputFailures(line)) {
253
+ outputFailures.push(failure);
254
+ }
249
255
  stream.write(`${line}
250
256
  `);
251
257
  }
@@ -256,6 +262,27 @@ function runNpmRehearsalCommand(args, options) {
256
262
  process.stdout.write(`${line}
257
263
  `);
258
264
  }
265
+ if (outputFailures.length > 0) {
266
+ throw new Error([
267
+ `npm ${args.join(" ")} completed with error output despite exit code 0.`,
268
+ ...outputFailures.slice(0, 12)
269
+ ].join("\n"));
270
+ }
271
+ }
272
+ function collectReleaseCandidateOutputFailures(line) {
273
+ const value = String(line ?? "").trim();
274
+ if (!value) return [];
275
+ const failures = [];
276
+ if (/^stderr\s+\|\s+/u.test(value)) {
277
+ failures.push(`Captured test stderr: ${value}`);
278
+ }
279
+ if (/(^|\s)ERROR(?:\s|\[|:)/u.test(value)) {
280
+ failures.push(`Error output: ${value}`);
281
+ }
282
+ if (/\bFailed to run background task\b/u.test(value)) {
283
+ failures.push(`Background task failure output: ${value}`);
284
+ }
285
+ return failures;
259
286
  }
260
287
  function buildRehearsalWorkspacePackageArtifacts(root) {
261
288
  for (const pkg of packagesWithScript("build:dist", root)) {
@@ -561,6 +588,7 @@ async function runReleaseCandidateGate(input) {
561
588
  }
562
589
  export {
563
590
  buildReleaseCandidateFingerprint,
591
+ collectReleaseCandidateOutputFailures,
564
592
  readCachedReleaseCandidateReport,
565
593
  runReleaseCandidateGate,
566
594
  writeReleaseCandidateReport
@@ -53,7 +53,7 @@ const TREESEED_DEFAULT_PROVIDER_SELECTIONS = {
53
53
  },
54
54
  site: "default"
55
55
  };
56
- const TRESEED_MANAGED_SERVICE_KEYS = ["api", "manager", "worker", "workdayStart", "workdayReport"];
56
+ const TRESEED_MANAGED_SERVICE_KEYS = ["api", "workdayManager", "workerRunner"];
57
57
  const TRESEED_WORKSPACE_PACKAGE_DIRS = ["sdk", "core", "cli"];
58
58
  const CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER = "replace-with-cloudflare-account-id";
59
59
  function normalizePlanesFromLegacyHosting(hosting) {
@@ -10,6 +10,7 @@ const TRESEED_OPERATION_SPECS = [
10
10
  operation({ id: "branch.save", name: "save", aliases: [], group: "Workflow", summary: "Recursively verify, commit, and push the current task checkpoint.", description: "Save dirty package repos in dependency order, then verify, commit, push, and optionally refresh preview for market.", provider: "default", related: ["switch", "stage", "status"] }),
11
11
  operation({ id: "branch.close", name: "close", aliases: [], group: "Workflow", summary: "Recursively archive and delete a task branch.", description: "Auto-save if needed, clean preview resources, create deprecated tags, and remove the task branch across market and checked-out package repos.", provider: "default", related: ["tasks", "switch", "stage"] }),
12
12
  operation({ id: "branch.stage", name: "stage", aliases: [], group: "Workflow", summary: "Squash a task branch into staging across market and packages.", description: "Auto-save if needed, squash-merge package task branches into staging first, update market submodule pointers, then squash-merge market into staging and clean up the task branch.", provider: "default", related: ["save", "release", "close"] }),
13
+ operation({ id: "workspace.tags.cleanup", name: "tags:cleanup", aliases: [], group: "Utilities", summary: "Clean stale Treeseed-managed package dev tags.", description: "Plan or delete stale staging and preview package dev tags that are older than each package current version line while preserving active references and non-Treeseed tags.", provider: "default", related: ["release", "status"] }),
13
14
  operation({ id: "workspace.resume", name: "resume", aliases: [], group: "Workflow", summary: "Resume an interrupted workflow run.", description: "Continue a failed journaled workflow run from its next incomplete step after validating current workspace preconditions.", provider: "default", related: ["recover", "status"] }),
14
15
  operation({ id: "workspace.recover", name: "recover", aliases: [], group: "Workflow", summary: "Inspect active workflow locks and interrupted runs.", description: "List active workflow locks, resumable interrupted runs, and the exact commands needed to continue or recover the workspace state.", provider: "default", related: ["resume", "status"] }),
15
16
  operation({ id: "workspace.links.status", name: workspaceCommand("status"), aliases: [], group: "Utilities", summary: "Inspect local workspace dependency links.", description: "Inspect whether Treeseed package dependencies are linked to local package checkouts or resolved through deployment references.", provider: "default", related: ["dev", "save"] }),
@@ -55,7 +55,7 @@ function agentsSystemDisabled(config) {
55
55
  if (config.runtime?.mode === "none") {
56
56
  return "runtime.mode is none.";
57
57
  }
58
- const enabled = ["manager", "worker", "workdayStart", "workdayReport"].some((serviceKey) => serviceEnabled(config, serviceKey));
58
+ const enabled = ["workdayManager", "workerRunner"].some((serviceKey) => serviceEnabled(config, serviceKey));
59
59
  return enabled ? null : "No agent Railway services are enabled.";
60
60
  }
61
61
  function hasValue(env, key) {
@@ -1439,7 +1439,7 @@ async function syncRailwayEnvironmentForScope(input, { dryRun = false } = {}) {
1439
1439
  includeInstances: !dryRun,
1440
1440
  includeVariables: false
1441
1441
  });
1442
- const workerEntry = topology.services.get("worker") ?? null;
1442
+ const workerEntry = topology.services.get("workerRunner") ?? topology.services.get("worker") ?? null;
1443
1443
  const railwayRuntimeVariables = Object.fromEntries(
1444
1444
  [
1445
1445
  ["TREESEED_RAILWAY_PROJECT_ID", workerEntry?.project?.id],
@@ -2140,16 +2140,12 @@ function createCloudflareReconcileAdapters() {
2140
2140
  function createRailwayReconcileAdapters() {
2141
2141
  return [
2142
2142
  buildRailwayAdapter("railway-service:api"),
2143
- buildRailwayAdapter("railway-service:manager"),
2144
- buildRailwayAdapter("railway-service:worker"),
2145
- buildRailwayAdapter("railway-service:workday-start"),
2146
- buildRailwayAdapter("railway-service:workday-report"),
2143
+ buildRailwayAdapter("railway-service:workday-manager"),
2144
+ buildRailwayAdapter("railway-service:worker-runner"),
2147
2145
  buildCustomDomainAdapter("custom-domain:api", "railway"),
2148
2146
  buildCompositeAdapter("api-runtime"),
2149
- buildCompositeAdapter("manager-runtime"),
2150
- buildCompositeAdapter("worker-runtime"),
2151
- buildCompositeAdapter("workday-start-runtime"),
2152
- buildCompositeAdapter("workday-report-runtime")
2147
+ buildCompositeAdapter("workday-manager-runtime"),
2148
+ buildCompositeAdapter("worker-runner-runtime")
2153
2149
  ];
2154
2150
  }
2155
2151
  export {
@@ -3,7 +3,7 @@ export type TreeseedReconcileProviderId = string;
3
3
  export type TreeseedReconcileActionKind = 'noop' | 'create' | 'update' | 'reuse' | 'drift_correct' | 'destroy';
4
4
  export type TreeseedReconcileStatusKind = 'pending' | 'ready' | 'drifted' | 'error';
5
5
  export type TreeseedReconcileVerificationSource = 'cli' | 'api' | 'sdk' | 'derived';
6
- export type TreeseedReconcileUnitType = 'web-ui' | 'api-runtime' | 'manager-runtime' | 'worker-runtime' | 'workday-start-runtime' | 'workday-report-runtime' | 'edge-worker' | 'content-store' | 'queue' | 'database' | 'kv-form-guard' | 'pages-project' | 'custom-domain:web' | 'custom-domain:api' | 'dns-record' | 'railway-service:api' | 'railway-service:manager' | 'railway-service:worker' | 'railway-service:workday-start' | 'railway-service:workday-report';
6
+ export type TreeseedReconcileUnitType = 'web-ui' | 'api-runtime' | 'workday-manager-runtime' | 'worker-runner-runtime' | 'edge-worker' | 'content-store' | 'queue' | 'database' | 'kv-form-guard' | 'pages-project' | 'custom-domain:web' | 'custom-domain:api' | 'dns-record' | 'railway-service:api' | 'railway-service:workday-manager' | 'railway-service:worker-runner';
7
7
  export type TreeseedReconcileTarget = {
8
8
  kind: 'persistent';
9
9
  scope: 'local' | 'staging' | 'prod';
@@ -11,14 +11,10 @@ function railwayConcreteUnitTypeForServiceKey(serviceKey) {
11
11
  switch (serviceKey) {
12
12
  case "api":
13
13
  return "railway-service:api";
14
- case "manager":
15
- return "railway-service:manager";
16
- case "worker":
17
- return "railway-service:worker";
18
- case "workdayStart":
19
- return "railway-service:workday-start";
20
- case "workdayReport":
21
- return "railway-service:workday-report";
14
+ case "workdayManager":
15
+ return "railway-service:workday-manager";
16
+ case "workerRunner":
17
+ return "railway-service:worker-runner";
22
18
  default:
23
19
  return "railway-service:api";
24
20
  }
@@ -227,7 +223,7 @@ function deriveTreeseedDesiredUnits({
227
223
  serviceKey,
228
224
  scheduleManaged: Array.isArray(configuredService.schedule) && configuredService.schedule.length > 0,
229
225
  scheduleBootstrap: false,
230
- scheduleDeployScopes: ["prod"],
226
+ scheduleDeployScopes: ["staging", "prod"],
231
227
  bootstrapSystem: serviceBootstrapSystem
232
228
  }
233
229
  });
@@ -270,14 +266,10 @@ function deriveTreeseedDesiredUnits({
270
266
  switch (serviceKey) {
271
267
  case "api":
272
268
  return "api-runtime";
273
- case "manager":
274
- return "manager-runtime";
275
- case "worker":
276
- return "worker-runtime";
277
- case "workdayStart":
278
- return "workday-start-runtime";
279
- case "workdayReport":
280
- return "workday-report-runtime";
269
+ case "workdayManager":
270
+ return "workday-manager-runtime";
271
+ case "workerRunner":
272
+ return "worker-runner-runtime";
281
273
  default:
282
274
  return "api-runtime";
283
275
  }
@@ -6,11 +6,11 @@ function stableHash(value) {
6
6
  return createHash("sha256").update(JSON.stringify(value)).digest("hex");
7
7
  }
8
8
  function railwayUnitTypeForServiceKey(serviceKey) {
9
- if (serviceKey === "workdayStart") {
10
- return "railway-service:workday-start";
9
+ if (serviceKey === "workdayManager") {
10
+ return "railway-service:workday-manager";
11
11
  }
12
- if (serviceKey === "workdayReport") {
13
- return "railway-service:workday-report";
12
+ if (serviceKey === "workerRunner") {
13
+ return "railway-service:worker-runner";
14
14
  }
15
15
  return `railway-service:${serviceKey}`;
16
16
  }
@@ -1,10 +1,8 @@
1
1
  const TRESEED_RECONCILE_UNIT_TYPES = [
2
2
  "web-ui",
3
3
  "api-runtime",
4
- "manager-runtime",
5
- "worker-runtime",
6
- "workday-start-runtime",
7
- "workday-report-runtime",
4
+ "workday-manager-runtime",
5
+ "worker-runner-runtime",
8
6
  "edge-worker",
9
7
  "content-store",
10
8
  "queue",
@@ -15,10 +13,8 @@ const TRESEED_RECONCILE_UNIT_TYPES = [
15
13
  "custom-domain:api",
16
14
  "dns-record",
17
15
  "railway-service:api",
18
- "railway-service:manager",
19
- "railway-service:worker",
20
- "railway-service:workday-start",
21
- "railway-service:workday-report"
16
+ "railway-service:workday-manager",
17
+ "railway-service:worker-runner"
22
18
  ];
23
19
  function targetKey(target) {
24
20
  return target.kind === "persistent" ? target.scope : `branch:${target.branchName}`;