@treeseed/sdk 0.8.3 → 0.8.4

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 (47) hide show
  1. package/dist/capacity.d.ts +33 -0
  2. package/dist/fixture-support.d.ts +1 -1
  3. package/dist/fixture-support.js +5 -5
  4. package/dist/managed-dependencies.js +132 -10
  5. package/dist/operations/services/bootstrap-runner.js +7 -1
  6. package/dist/operations/services/config-runtime.js +13 -4
  7. package/dist/operations/services/github-actions-verification.d.ts +3 -0
  8. package/dist/operations/services/github-actions-verification.js +3 -0
  9. package/dist/operations/services/github-api.d.ts +4 -1
  10. package/dist/operations/services/github-api.js +26 -8
  11. package/dist/operations/services/github-automation.d.ts +14 -5
  12. package/dist/operations/services/github-automation.js +45 -11
  13. package/dist/operations/services/hub-provider-launch.js +9 -8
  14. package/dist/operations/services/project-platform.d.ts +93 -210
  15. package/dist/operations/services/project-platform.js +74 -34
  16. package/dist/operations/services/railway-deploy.d.ts +25 -2
  17. package/dist/operations/services/railway-deploy.js +312 -20
  18. package/dist/operations/services/repository-save-orchestrator.d.ts +8 -0
  19. package/dist/operations/services/repository-save-orchestrator.js +40 -3
  20. package/dist/operations/services/runtime-paths.d.ts +1 -0
  21. package/dist/operations/services/runtime-paths.js +3 -1
  22. package/dist/operations/services/runtime-tools.d.ts +1 -0
  23. package/dist/operations/services/runtime-tools.js +2 -0
  24. package/dist/operations/services/template-registry.js +3 -0
  25. package/dist/platform/contracts.d.ts +9 -0
  26. package/dist/platform/deploy-config.js +28 -0
  27. package/dist/platform/env.yaml +1 -745
  28. package/dist/platform/environment.js +69 -9
  29. package/dist/reconcile/builtin-adapters.js +7 -2
  30. package/dist/scripts/install-managed-dependencies.js +12 -0
  31. package/dist/scripts/tenant-workflow-action.js +11 -9
  32. package/dist/scripts/test-scaffold.js +3 -1
  33. package/dist/scripts/workflow-commands.test.js +10 -6
  34. package/dist/scripts/workspace-command-e2e.js +1 -1
  35. package/dist/treeseed/template-catalog/templates/starter-basic/template/package.json +1 -0
  36. package/dist/treeseed/template-catalog/templates/starter-basic/template/src/api/server.js +1 -1
  37. package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +7 -6
  38. package/dist/treeseed/template-catalog/templates/starter-basic/template.config.json +6 -0
  39. package/dist/workflow/operations.d.ts +41 -8
  40. package/dist/workflow/operations.js +119 -24
  41. package/dist/workflow/runs.js +31 -0
  42. package/package.json +1 -1
  43. package/templates/github/deploy-processing.workflow.yml +115 -0
  44. package/templates/github/deploy-web.workflow.yml +111 -0
  45. package/templates/github/hosted-project.workflow.yml +4 -4
  46. package/templates/github/deploy.managed.workflow.yml +0 -208
  47. package/templates/github/deploy.workflow.yml +0 -746
@@ -1480,9 +1480,10 @@ async function runRepositorySaveOrchestrator(options) {
1480
1480
  finalizedReferences: /* @__PURE__ */ new Map(),
1481
1481
  finalizedCommits: /* @__PURE__ */ new Map(),
1482
1482
  reports: new Map(nodes.map((node) => [node.id, createReport(node)])),
1483
- remoteAccessChecked: /* @__PURE__ */ new Set()
1483
+ remoteAccessChecked: /* @__PURE__ */ new Set(),
1484
+ workflowGates: []
1484
1485
  };
1485
- for (const wave of waves) {
1486
+ for (const [index, wave] of waves.entries()) {
1486
1487
  await runLimited(wave, 3, async (node) => {
1487
1488
  try {
1488
1489
  await saveOneRepository(node, options, state);
@@ -1508,6 +1509,41 @@ async function runRepositorySaveOrchestrator(options) {
1508
1509
  });
1509
1510
  }
1510
1511
  });
1512
+ const waveReports = wave.map((node) => state.reports.get(node.id) ?? createReport(node));
1513
+ const allReports = [...state.reports.values()];
1514
+ let waveGates;
1515
+ try {
1516
+ waveGates = await options.onWaveSaved?.({
1517
+ index: index + 1,
1518
+ nodes: wave,
1519
+ reports: waveReports,
1520
+ allReports,
1521
+ rootRepo: state.reports.get(".") ?? null
1522
+ });
1523
+ } catch (error) {
1524
+ const existing = repositorySaveErrorDetails(error);
1525
+ const errorDetails = existing.details ?? (error && typeof error === "object" && "details" in error && error.details && typeof error.details === "object" ? error.details : void 0);
1526
+ const errorExitCode = existing.exitCode ?? (error && typeof error === "object" && "exitCode" in error && typeof error.exitCode === "number" ? error.exitCode : void 0);
1527
+ const gate = errorDetails?.gate;
1528
+ const failingRepo = gate && typeof gate === "object" && "name" in gate && typeof gate.name === "string" ? gate.name : wave.map((node) => node.name).join(", ");
1529
+ throw new RepositorySaveError(error instanceof Error ? error.message : String(error), {
1530
+ exitCode: errorExitCode,
1531
+ details: {
1532
+ ...errorDetails ?? {},
1533
+ partialFailure: {
1534
+ message: `Treeseed save stopped while waiting for hosted gates after wave ${index + 1}.`,
1535
+ failingRepo,
1536
+ nextCommand: `treeseed resume ${options.workflowRunId ?? "<run-id>"}`,
1537
+ repos: allReports.filter((report) => report.name !== "@treeseed/market"),
1538
+ rootRepo: state.reports.get(".") ?? null,
1539
+ error: error instanceof Error ? error.message : String(error)
1540
+ }
1541
+ }
1542
+ });
1543
+ }
1544
+ if (Array.isArray(waveGates)) {
1545
+ state.workflowGates.push(...waveGates);
1546
+ }
1511
1547
  }
1512
1548
  const rootNode = nodes.find((node) => node.id === ".") ?? allNodes.find((node) => node.id === ".");
1513
1549
  const rootReport = rootNode ? state.reports.get(rootNode.id) ?? createReport(rootNode) : createReport({
@@ -1537,7 +1573,8 @@ async function runRepositorySaveOrchestrator(options) {
1537
1573
  repos: packageReports,
1538
1574
  rootRepo: rootReport,
1539
1575
  waves: waves.map((wave) => wave.map((node) => node.name)),
1540
- plannedVersions: Object.fromEntries(state.finalizedVersions.entries())
1576
+ plannedVersions: Object.fromEntries(state.finalizedVersions.entries()),
1577
+ workflowGates: state.workflowGates
1541
1578
  };
1542
1579
  }
1543
1580
  function repositorySaveErrorDetails(error) {
@@ -16,5 +16,6 @@ export declare const fixtureSrcRoot: string;
16
16
  export declare const templateCatalogRoot: string;
17
17
  export declare const localTemplateArtifactsRoot: string;
18
18
  export declare const cliPackageVersion: any;
19
+ export declare const agentPackageVersion: any;
19
20
  export declare const corePackageVersion: any;
20
21
  export declare const sdkPackageVersion: any;
@@ -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, sdkPackageRoot } from "./runtime-tools.js";
4
+ import { agentPackageRoot, 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;
@@ -30,9 +30,11 @@ const fixtureSrcRoot = resolve(fixtureRoot, "src");
30
30
  const templateCatalogRoot = resolve(cliRuntimeRoot, "template-catalog");
31
31
  const localTemplateArtifactsRoot = resolve(templateCatalogRoot, "templates");
32
32
  const cliPackageVersion = readPackageVersion(cliPackageRoot);
33
+ const agentPackageVersion = readPackageVersion(agentPackageRoot);
33
34
  const corePackageVersion = readPackageVersion(corePackageRoot);
34
35
  const sdkPackageVersion = readPackageVersion(sdkPackageRoot);
35
36
  export {
37
+ agentPackageVersion,
36
38
  cliPackageRoot,
37
39
  cliPackageVersion,
38
40
  corePackageRoot,
@@ -18,6 +18,7 @@ export declare function treeseedWorkspacePackageCheckoutState(root?: string): {
18
18
  export declare function resolveAstroBin(): string;
19
19
  export declare function resolveWranglerBin(): string;
20
20
  export declare const corePackageRoot: string;
21
+ export declare const agentPackageRoot: string;
21
22
  export declare const sdkPackageRoot: string;
22
23
  export declare function loadPackageJson(root?: string): any;
23
24
  export declare function isWorkspaceRoot(root?: string): boolean;
@@ -326,6 +326,7 @@ function resolveWranglerBin() {
326
326
  return resolvePackageBinary("wrangler", "wrangler");
327
327
  }
328
328
  const corePackageRoot = resolveTreeseedPackageRoot("@treeseed/core", "@treeseed/core/config", "core");
329
+ const agentPackageRoot = resolveTreeseedPackageRoot("@treeseed/agent", "@treeseed/agent", "agent");
329
330
  const sdkPackageRoot = resolveTreeseedPackageRoot("@treeseed/sdk", "@treeseed/sdk", "sdk");
330
331
  function loadPackageJson(root = process.cwd()) {
331
332
  const packageJsonPath = resolve(root, "package.json");
@@ -614,6 +615,7 @@ function spawnNodeBinary(binPath, args, options = {}) {
614
615
  });
615
616
  }
616
617
  export {
618
+ agentPackageRoot,
617
619
  corePackageRoot,
618
620
  createProductionBuildEnv,
619
621
  isWorkspaceRoot,
@@ -9,6 +9,7 @@ import {
9
9
  } from "./config-runtime.js";
10
10
  import {
11
11
  cliPackageVersion,
12
+ agentPackageVersion,
12
13
  corePackageVersion,
13
14
  localTemplateArtifactsRoot,
14
15
  sdkPackageVersion
@@ -247,6 +248,8 @@ function resolveVariableValue(variable, input) {
247
248
  return input.discordUrl ?? variable.default ?? "";
248
249
  case "cliVersion":
249
250
  return `^${cliPackageVersion}`;
251
+ case "agentVersion":
252
+ return `^${agentPackageVersion}`;
250
253
  case "coreVersion":
251
254
  return `^${corePackageVersion}`;
252
255
  case "sdkVersion":
@@ -1,3 +1,4 @@
1
+ import type { CapacityProviderRegistration } from '../capacity.ts';
1
2
  export type TreeseedFeatureName = 'docs' | 'books' | 'notes' | 'questions' | 'objectives' | 'proposals' | 'decisions' | 'agents' | 'forms';
2
3
  export type TreeseedContentCollection = 'pages' | 'notes' | 'questions' | 'objectives' | 'proposals' | 'decisions' | 'people' | 'agents' | 'books' | 'docs' | 'templates' | 'knowledge_packs' | 'workdays';
3
4
  export interface TreeseedFeatureModules {
@@ -161,6 +162,7 @@ export type TreeseedHostingRegistration = 'optional' | 'none';
161
162
  export type TreeseedHubMode = 'treeseed_hosted' | 'customer_hosted';
162
163
  export type TreeseedRuntimeMode = 'none' | 'byo_attached' | 'treeseed_managed';
163
164
  export type TreeseedRuntimeRegistration = 'optional' | 'required' | 'none';
165
+ export type TreeseedProcessingMode = 'market-assigned' | 'team-owned' | 'project-owned' | 'local' | 'none';
164
166
  export interface TreeseedHostingConfig {
165
167
  kind: TreeseedHostingKind;
166
168
  registration?: TreeseedHostingRegistration;
@@ -178,6 +180,11 @@ export interface TreeseedRuntimeConfig {
178
180
  teamId?: string;
179
181
  projectId?: string;
180
182
  }
183
+ export interface TreeseedProcessingConfig {
184
+ mode: TreeseedProcessingMode;
185
+ providerRef?: string;
186
+ requiredCapabilities?: string[];
187
+ }
181
188
  export interface TreeseedManagedServiceEnvironmentConfig {
182
189
  baseUrl?: string;
183
190
  domain?: string;
@@ -272,6 +279,8 @@ export interface TreeseedDeployConfig {
272
279
  providers: TreeseedProviderSelections;
273
280
  surfaces?: TreeseedPlatformSurfacesConfig;
274
281
  services?: TreeseedManagedServicesConfig;
282
+ processing?: TreeseedProcessingConfig;
283
+ capacityProviders?: Record<string, CapacityProviderRegistration>;
275
284
  smtp?: {
276
285
  enabled?: boolean;
277
286
  };
@@ -28,6 +28,11 @@ const runtimeFieldAliases = {
28
28
  teamId: { key: "teamId", aliases: ["team_id"] },
29
29
  projectId: { key: "projectId", aliases: ["project_id"] }
30
30
  };
31
+ const processingFieldAliases = {
32
+ mode: { key: "mode", aliases: ["mode"] },
33
+ providerRef: { key: "providerRef", aliases: ["provider_ref", "providerRef"] },
34
+ requiredCapabilities: { key: "requiredCapabilities", aliases: ["required_capabilities", "requiredCapabilities"] }
35
+ };
31
36
  const cloudflareFieldAliases = {
32
37
  accountId: { key: "accountId", aliases: ["account_id"] },
33
38
  zoneId: { key: "zoneId", aliases: ["zone_id"] },
@@ -394,6 +399,26 @@ function parseManagedServicesConfig(value) {
394
399
  ])
395
400
  );
396
401
  }
402
+ function parseProcessingConfig(value, services) {
403
+ const record = normalizeAliasedRecord(
404
+ processingFieldAliases,
405
+ optionalRecord(value, "processing") ?? {}
406
+ );
407
+ const hasProcessingServices = Object.entries(services ?? {}).some(
408
+ ([serviceKey, service]) => ["api", "manager", "worker", "workerRunner", "workdayStart", "workdayReport"].includes(serviceKey) && service && service.enabled !== false
409
+ );
410
+ return {
411
+ mode: optionalEnum(record.mode, "processing.mode", [
412
+ "market-assigned",
413
+ "team-owned",
414
+ "project-owned",
415
+ "local",
416
+ "none"
417
+ ]) ?? (hasProcessingServices ? "project-owned" : "market-assigned"),
418
+ providerRef: optionalString(record.providerRef),
419
+ requiredCapabilities: optionalStringArray(record.requiredCapabilities, "processing.requiredCapabilities")
420
+ };
421
+ }
397
422
  function inferManagedRuntimeFromServices(services) {
398
423
  return Object.values(services ?? {}).some(
399
424
  (service) => service && service.enabled !== false && (service.provider ?? "railway") === "railway"
@@ -504,6 +529,7 @@ function parseDeployConfig(raw) {
504
529
  );
505
530
  const hosting = parseHostingConfig(parsed.hosting);
506
531
  const services = parseManagedServicesConfig(parsed.services);
532
+ const processing = parseProcessingConfig(parsed.processing, services);
507
533
  const normalizedPlanes = normalizePlanesFromLegacyHosting(hosting);
508
534
  const inferredPlanes = !hosting && !parsed.hub && !parsed.runtime && inferManagedRuntimeFromServices(services) ? {
509
535
  hub: { mode: "customer_hosted" },
@@ -552,6 +578,8 @@ function parseDeployConfig(raw) {
552
578
  providers: parseProviderSelections(parsed.providers),
553
579
  surfaces: parsePlatformSurfacesConfig(parsed.surfaces),
554
580
  services,
581
+ processing,
582
+ capacityProviders: optionalRecord(parsed.capacityProviders, "capacityProviders"),
555
583
  smtp: {
556
584
  enabled: optionalBoolean(smtp.enabled, "smtp.enabled")
557
585
  },