@treeseed/sdk 0.5.3 → 0.6.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.
Files changed (66) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +46 -0
  3. package/dist/operations/providers/default.js +1 -1
  4. package/dist/operations/services/config-runtime.d.ts +49 -42
  5. package/dist/operations/services/config-runtime.js +449 -136
  6. package/dist/operations/services/deploy.d.ts +298 -0
  7. package/dist/operations/services/deploy.js +381 -137
  8. package/dist/operations/services/git-workflow.d.ts +9 -0
  9. package/dist/operations/services/git-workflow.js +32 -0
  10. package/dist/operations/services/github-api.d.ts +115 -0
  11. package/dist/operations/services/github-api.js +455 -0
  12. package/dist/operations/services/github-automation.d.ts +19 -33
  13. package/dist/operations/services/github-automation.js +44 -131
  14. package/dist/operations/services/key-agent.d.ts +20 -1
  15. package/dist/operations/services/key-agent.js +267 -102
  16. package/dist/operations/services/knowledge-coop-launch.d.ts +2 -3
  17. package/dist/operations/services/knowledge-coop-launch.js +26 -12
  18. package/dist/operations/services/project-platform.d.ts +157 -150
  19. package/dist/operations/services/project-platform.js +129 -26
  20. package/dist/operations/services/railway-api.d.ts +244 -0
  21. package/dist/operations/services/railway-api.js +882 -0
  22. package/dist/operations/services/railway-deploy.d.ts +171 -27
  23. package/dist/operations/services/railway-deploy.js +672 -172
  24. package/dist/operations/services/runtime-tools.d.ts +18 -0
  25. package/dist/operations/services/runtime-tools.js +19 -6
  26. package/dist/operations/services/workspace-preflight.js +2 -2
  27. package/dist/platform/contracts.d.ts +7 -0
  28. package/dist/platform/deploy-config.js +23 -0
  29. package/dist/platform/deploy-runtime.d.ts +1 -0
  30. package/dist/platform/deploy-runtime.js +7 -9
  31. package/dist/platform/env.yaml +10 -9
  32. package/dist/platform/environment.js +4 -0
  33. package/dist/platform/plugin.d.ts +6 -0
  34. package/dist/platform/plugins/constants.d.ts +1 -0
  35. package/dist/platform/plugins/constants.js +1 -0
  36. package/dist/platform/plugins/runtime.d.ts +4 -0
  37. package/dist/platform/plugins/runtime.js +8 -1
  38. package/dist/platform/published-content.js +27 -4
  39. package/dist/platform/tenant/runtime-config.js +33 -24
  40. package/dist/plugin-default.d.ts +1 -0
  41. package/dist/plugin-default.js +1 -0
  42. package/dist/reconcile/builtin-adapters.d.ts +3 -0
  43. package/dist/reconcile/builtin-adapters.js +2093 -0
  44. package/dist/reconcile/contracts.d.ts +155 -0
  45. package/dist/reconcile/contracts.js +0 -0
  46. package/dist/reconcile/desired-state.d.ts +179 -0
  47. package/dist/reconcile/desired-state.js +319 -0
  48. package/dist/reconcile/engine.d.ts +405 -0
  49. package/dist/reconcile/engine.js +356 -0
  50. package/dist/reconcile/errors.d.ts +5 -0
  51. package/dist/reconcile/errors.js +13 -0
  52. package/dist/reconcile/index.d.ts +7 -0
  53. package/dist/reconcile/index.js +7 -0
  54. package/dist/reconcile/registry.d.ts +7 -0
  55. package/dist/reconcile/registry.js +64 -0
  56. package/dist/reconcile/state.d.ts +7 -0
  57. package/dist/reconcile/state.js +303 -0
  58. package/dist/reconcile/units.d.ts +6 -0
  59. package/dist/reconcile/units.js +68 -0
  60. package/dist/scripts/config-treeseed.js +27 -19
  61. package/dist/scripts/tenant-deploy.js +35 -14
  62. package/dist/workflow/operations.js +127 -22
  63. package/dist/workflow-support.d.ts +3 -1
  64. package/dist/workflow-support.js +50 -0
  65. package/dist/workflow.d.ts +2 -0
  66. package/package.json +7 -1
@@ -12,6 +12,7 @@ import {
12
12
  ensureTreeseedSecretSessionForConfig,
13
13
  ensureTreeseedActVerificationTooling,
14
14
  ensureTreeseedGitignoreEntries,
15
+ inspectTreeseedPassphraseEnvDiagnostic,
15
16
  finalizeTreeseedConfig,
16
17
  getTreeseedMachineConfigPaths,
17
18
  inspectTreeseedKeyAgentStatus,
@@ -26,6 +27,7 @@ import { ControlPlaneClient } from "../control-plane-client.js";
26
27
  import { exportTreeseedCodebase } from "../operations/services/export-runtime.js";
27
28
  import {
28
29
  assertDeploymentInitialized,
30
+ buildProvisioningSummary,
29
31
  cleanupDestroyedState,
30
32
  createBranchPreviewDeployTarget,
31
33
  createPersistentDeployTarget,
@@ -33,9 +35,7 @@ import {
33
35
  ensureGeneratedWranglerConfig,
34
36
  finalizeDeploymentState,
35
37
  loadDeployState,
36
- provisionCloudflareResources,
37
38
  runRemoteD1Migrations,
38
- syncCloudflareSecrets,
39
39
  validateDeployPrerequisites,
40
40
  validateDestroyPrerequisites
41
41
  } from "../operations/services/deploy.js";
@@ -89,6 +89,7 @@ import {
89
89
  workspaceRoot
90
90
  } from "../operations/services/workspace-tools.js";
91
91
  import { resolveTreeseedWorkflowState } from "../workflow-state.js";
92
+ import { createTreeseedReconcileRegistry, deriveTreeseedDesiredUnits, planTreeseedReconciliation, reconcileTreeseedTarget } from "../reconcile/index.js";
92
93
  import {
93
94
  acquireWorkflowLock,
94
95
  createWorkflowRunJournal,
@@ -749,15 +750,19 @@ function previewStateFor(tenantRoot, branchName) {
749
750
  target: createBranchPreviewDeployTarget(branchName)
750
751
  });
751
752
  }
752
- function deployBranchPreview(tenantRoot, branchName, context, { initialize }) {
753
+ async function deployBranchPreview(tenantRoot, branchName, context, { initialize }) {
753
754
  applyTreeseedEnvironmentToProcess({ tenantRoot, scope: "staging", override: true });
754
755
  assertTreeseedCommandEnvironment({ tenantRoot, scope: "staging", purpose: "deploy" });
755
756
  const target = createBranchPreviewDeployTarget(branchName);
756
757
  const existingState = previewStateFor(tenantRoot, branchName);
757
758
  if (initialize && !existingState.readiness?.initialized) {
758
759
  validateDeployPrerequisites(tenantRoot, { requireRemote: true });
759
- provisionCloudflareResources(tenantRoot, { target });
760
- syncCloudflareSecrets(tenantRoot, { target });
760
+ await reconcileTreeseedTarget({
761
+ tenantRoot,
762
+ target,
763
+ env: { ...process.env, ...context.env ?? {} },
764
+ write: (line) => context.write?.(line)
765
+ });
761
766
  runRemoteD1Migrations(tenantRoot, { target });
762
767
  } else {
763
768
  assertDeploymentInitialized(tenantRoot, { target });
@@ -1023,6 +1028,8 @@ async function workflowConfig(helpers, input = {}) {
1023
1028
  const printEnvOnly = input.printEnvOnly === true;
1024
1029
  const rotateMachineKeyFlag = input.rotateMachineKey === true;
1025
1030
  const connectMarketFlag = input.connectMarket === true;
1031
+ const bootstrapOnly = input.bootstrap === true;
1032
+ const bootstrapPreflight = bootstrapOnly && input.preflight === true;
1026
1033
  const nonInteractive = input.nonInteractive === true;
1027
1034
  const repairs = input.repair === false ? [] : resolveTreeseedWorkflowState(tenantRoot).deployConfigPresent ? applyTreeseedSafeRepairs(tenantRoot) : [];
1028
1035
  const toolHealth = ensureTreeseedActVerificationTooling({
@@ -1031,7 +1038,8 @@ async function workflowConfig(helpers, input = {}) {
1031
1038
  env: helpers.context.env,
1032
1039
  write: (line) => maybePrint(helpers.write, line)
1033
1040
  });
1034
- const secretSession = printEnvOnly && !revealSecrets ? {
1041
+ const passphraseEnv = inspectTreeseedPassphraseEnvDiagnostic(helpers.context.env ?? process.env);
1042
+ const secretSession = printEnvOnly && !revealSecrets || bootstrapPreflight ? {
1035
1043
  status: inspectTreeseedKeyAgentStatus(tenantRoot),
1036
1044
  createdWrappedKey: false,
1037
1045
  migratedWrappedKey: false,
@@ -1050,8 +1058,21 @@ async function workflowConfig(helpers, input = {}) {
1050
1058
  scopes,
1051
1059
  env: helpers.context.env
1052
1060
  });
1061
+ if (bootstrapPreflight && !secretSession.status.unlocked && !passphraseEnv.configured) {
1062
+ workflowError(
1063
+ "config",
1064
+ "validation_failed",
1065
+ `${passphraseEnv.envVar} is not visible to this Codex process. ${passphraseEnv.recommendedLaunch}`,
1066
+ {
1067
+ details: {
1068
+ passphraseEnv,
1069
+ secretSession: secretSession.status
1070
+ }
1071
+ }
1072
+ );
1073
+ }
1053
1074
  if (printEnvOnly) {
1054
- const reports2 = scopes.map((scope) => ({
1075
+ const reports2 = await Promise.all(scopes.map(async (scope) => ({
1055
1076
  scope,
1056
1077
  environment: collectTreeseedPrintEnvReport({
1057
1078
  tenantRoot,
@@ -1059,8 +1080,8 @@ async function workflowConfig(helpers, input = {}) {
1059
1080
  env: helpers.context.env,
1060
1081
  revealSecrets
1061
1082
  }),
1062
- provider: checkTreeseedProviderConnections({ tenantRoot, scope, env: helpers.context.env })
1063
- }));
1083
+ provider: await checkTreeseedProviderConnections({ tenantRoot, scope, env: helpers.context.env })
1084
+ })));
1064
1085
  return buildWorkflowResult(
1065
1086
  "config",
1066
1087
  tenantRoot,
@@ -1115,13 +1136,90 @@ async function workflowConfig(helpers, input = {}) {
1115
1136
  toolHealth
1116
1137
  });
1117
1138
  }
1139
+ if (bootstrapPreflight) {
1140
+ maybePrint(helpers.write, "Preparing bootstrap preflight...");
1141
+ const { configPath: configPath2, keyPath: keyPath2 } = getTreeseedMachineConfigPaths(tenantRoot);
1142
+ const plansByScope = await Promise.all(scopes.filter((scope) => scope !== "local").map(async (scope) => {
1143
+ maybePrint(helpers.write, `Deriving desired units for ${scope}...`);
1144
+ const target = createPersistentDeployTarget(scope);
1145
+ const derived = deriveTreeseedDesiredUnits({ tenantRoot, target });
1146
+ const registry = createTreeseedReconcileRegistry(derived.deployConfig);
1147
+ const capabilityMatrix = derived.units.map((unit) => {
1148
+ const adapter = registry.get(unit.unitType, unit.provider);
1149
+ return {
1150
+ unitId: unit.unitId,
1151
+ unitType: unit.unitType,
1152
+ provider: unit.provider,
1153
+ logicalName: unit.logicalName,
1154
+ requiredPostconditions: adapter.requiredPostconditions?.({
1155
+ context: {
1156
+ tenantRoot,
1157
+ target,
1158
+ deployConfig: derived.deployConfig,
1159
+ launchEnv: helpers.context.env ?? process.env,
1160
+ session: /* @__PURE__ */ new Map(),
1161
+ write: (line) => maybePrint(helpers.write, line)
1162
+ },
1163
+ unit,
1164
+ persistedState: null
1165
+ }) ?? [],
1166
+ verificationSupported: typeof adapter.verify === "function"
1167
+ };
1168
+ });
1169
+ const planned = await planTreeseedReconciliation({
1170
+ tenantRoot,
1171
+ target,
1172
+ env: helpers.context.env,
1173
+ write: (line) => maybePrint(helpers.write, line)
1174
+ });
1175
+ return {
1176
+ scope,
1177
+ resourceInventory: buildProvisioningSummary(derived.deployConfig, loadDeployState(tenantRoot, derived.deployConfig, { target }), target),
1178
+ capabilityMatrix: await Promise.all(capabilityMatrix.map(async (entry) => ({
1179
+ ...entry,
1180
+ requiredPostconditions: await Promise.resolve(entry.requiredPostconditions)
1181
+ }))),
1182
+ plans: planned.plans.map((plan) => ({
1183
+ unitId: plan.unit.unitId,
1184
+ unitType: plan.unit.unitType,
1185
+ provider: plan.unit.provider,
1186
+ action: plan.diff.action,
1187
+ reasons: plan.diff.reasons
1188
+ }))
1189
+ };
1190
+ }));
1191
+ return buildWorkflowResult(
1192
+ "config",
1193
+ tenantRoot,
1194
+ {
1195
+ mode: "bootstrap-preflight",
1196
+ scopes,
1197
+ sync,
1198
+ configPath: configPath2,
1199
+ keyPath: keyPath2,
1200
+ repairs,
1201
+ preflight,
1202
+ toolHealth,
1203
+ passphraseEnv,
1204
+ secretSession,
1205
+ context: contextSnapshot,
1206
+ resourceInventoryByScope: Object.fromEntries(plansByScope.map((entry) => [entry.scope, entry.resourceInventory])),
1207
+ verificationPreflight: plansByScope
1208
+ },
1209
+ {
1210
+ nextSteps: createNextSteps([
1211
+ { operation: "config", reason: "Run bootstrap once the verification preflight is clean.", input: { environment: scopes, bootstrap: true } }
1212
+ ])
1213
+ }
1214
+ );
1215
+ }
1118
1216
  const explicitUpdates = Array.isArray(input.updates) ? input.updates.map((update) => ({
1119
1217
  scope: update.scope,
1120
1218
  entryId: String(update.entryId ?? ""),
1121
1219
  value: typeof update.value === "string" ? update.value : "",
1122
1220
  reused: update.reused === true
1123
1221
  })) : null;
1124
- if (!explicitUpdates && !nonInteractive) {
1222
+ if (!bootstrapOnly && !explicitUpdates && !nonInteractive) {
1125
1223
  workflowError(
1126
1224
  "config",
1127
1225
  "validation_failed",
@@ -1136,16 +1234,22 @@ async function workflowConfig(helpers, input = {}) {
1136
1234
  reused: entry.currentValue.length > 0 || entry.suggestedValue.length > 0
1137
1235
  }))
1138
1236
  );
1139
- maybePrint(helpers.write, "Saving resolved configuration values to machine config...");
1140
- const applyResult = applyTreeseedConfigValues({
1141
- tenantRoot,
1142
- updates: explicitUpdates ?? autoUpdates
1143
- });
1144
- const finalizeResult = finalizeTreeseedConfig({
1237
+ const applyResult = bootstrapOnly ? { updated: [], sharedStorageMigrations: [] } : (() => {
1238
+ maybePrint(helpers.write, "Saving resolved configuration values to machine config...");
1239
+ return applyTreeseedConfigValues({
1240
+ tenantRoot,
1241
+ updates: explicitUpdates ?? autoUpdates
1242
+ });
1243
+ })();
1244
+ if (bootstrapOnly) {
1245
+ maybePrint(helpers.write, "Bootstrapping platform reconciliation from existing configuration...");
1246
+ }
1247
+ const finalizeResult = await finalizeTreeseedConfig({
1145
1248
  tenantRoot,
1146
1249
  scopes,
1147
1250
  sync,
1148
1251
  env: helpers.context.env,
1252
+ checkConnections: bootstrapOnly || sync !== "none" || scopes.some((scope) => scope !== "local"),
1149
1253
  onProgress: (line) => maybePrint(helpers.write, line)
1150
1254
  });
1151
1255
  const refreshedContext = collectTreeseedConfigContext({
@@ -1153,7 +1257,7 @@ async function workflowConfig(helpers, input = {}) {
1153
1257
  scopes,
1154
1258
  env: helpers.context.env
1155
1259
  });
1156
- const reports = printEnv ? scopes.map((scope) => ({
1260
+ const reports = printEnv ? await Promise.all(scopes.map(async (scope) => ({
1157
1261
  scope,
1158
1262
  environment: collectTreeseedPrintEnvReport({
1159
1263
  tenantRoot,
@@ -1161,15 +1265,15 @@ async function workflowConfig(helpers, input = {}) {
1161
1265
  env: helpers.context.env,
1162
1266
  revealSecrets
1163
1267
  }),
1164
- provider: finalizeResult.connectionChecks.find((report) => report.scope === scope) ?? checkTreeseedProviderConnections({ tenantRoot, scope, env: helpers.context.env })
1165
- })) : [];
1268
+ provider: finalizeResult.connectionChecks.find((report) => report.scope === scope) ?? await checkTreeseedProviderConnections({ tenantRoot, scope, env: helpers.context.env })
1269
+ }))) : [];
1166
1270
  const { configPath, keyPath } = getTreeseedMachineConfigPaths(tenantRoot);
1167
1271
  const state = resolveTreeseedWorkflowState(tenantRoot);
1168
1272
  return buildWorkflowResult(
1169
1273
  "config",
1170
1274
  tenantRoot,
1171
1275
  {
1172
- mode: "configure",
1276
+ mode: bootstrapOnly ? "bootstrap" : "configure",
1173
1277
  scopes,
1174
1278
  sync,
1175
1279
  configPath,
@@ -1177,6 +1281,7 @@ async function workflowConfig(helpers, input = {}) {
1177
1281
  repairs,
1178
1282
  preflight,
1179
1283
  toolHealth,
1284
+ passphraseEnv,
1180
1285
  secretSession,
1181
1286
  context: refreshedContext,
1182
1287
  result: {
@@ -2268,7 +2373,7 @@ async function workflowRelease(helpers, input) {
2268
2373
  }
2269
2374
  continue;
2270
2375
  }
2271
- const releasedPackage = await executeJournalStep(root, workflowRun.runId, `release-${report.name}`, () => {
2376
+ const releasedPackage = await executeJournalStep(root, workflowRun.runId, `release-${report.name}`, async () => {
2272
2377
  checkoutBranch(pkg.dir, STAGING_BRANCH);
2273
2378
  if (hasMeaningfulChanges(pkg.dir)) {
2274
2379
  run("git", ["add", "-A"], { cwd: pkg.dir });
@@ -2284,7 +2389,7 @@ async function workflowRelease(helpers, input) {
2284
2389
  const tagName = String(versionPlan.versions.get(pkg.name));
2285
2390
  run("git", ["tag", "-a", tagName, "-m", `release: ${tagName}`], { cwd: pkg.dir });
2286
2391
  run("git", ["push", "origin", tagName], { cwd: pkg.dir });
2287
- const publish = waitForGitHubWorkflowCompletion(pkg.dir, {
2392
+ const publish = await waitForGitHubWorkflowCompletion(pkg.dir, {
2288
2393
  workflow: "publish.yml",
2289
2394
  headSha: mergeResult.commitSha,
2290
2395
  branch: PRODUCTION_BRANCH
@@ -1,10 +1,12 @@
1
- export { applyTreeseedConfigValues, applyTreeseedEnvironmentToProcess, applyTreeseedSafeRepairs, assertTreeseedCommandEnvironment, checkTreeseedProviderConnections, clearTreeseedRemoteSession, collectTreeseedConfigContext, collectTreeseedPrintEnvReport, createDefaultTreeseedMachineConfig, ensureTreeseedActVerificationTooling, ensureTreeseedSecretSessionForConfig, ensureTreeseedGitignoreEntries, getTreeseedMachineConfigPaths, loadTreeseedMachineConfig, listRelevantTreeseedConfigEntries, finalizeTreeseedConfig, listDeprecatedTreeseedLocalEnvFiles, inspectTreeseedKeyAgentStatus, lockTreeseedSecretSession, migrateTreeseedMachineKeyToWrapped, resolveTreeseedMachineEnvironmentValues, resolveTreeseedLaunchEnvironment, resolveTreeseedRemoteConfig, resolveTreeseedRemoteSession, rotateTreeseedMachineKey, rotateTreeseedMachineKeyPassphrase, setTreeseedRemoteSession, TREESEED_MACHINE_KEY_PASSPHRASE_ENV, TreeseedKeyAgentError, updateTreeseedDeployConfigFeatureToggles, unlockTreeseedSecretSessionFromEnv, unlockTreeseedSecretSessionInteractive, unlockTreeseedSecretSessionWithPassphrase, withTreeseedKeyAgentAutopromptDisabled, warnDeprecatedTreeseedLocalEnvFiles, writeTreeseedMachineConfig, } from './operations/services/config-runtime.ts';
1
+ export { applyTreeseedConfigValues, applyTreeseedEnvironmentToProcess, applyTreeseedSafeRepairs, assertTreeseedCommandEnvironment, checkTreeseedProviderConnections, clearTreeseedRemoteSession, collectTreeseedConfigContext, collectTreeseedPrintEnvReport, createDefaultTreeseedMachineConfig, ensureTreeseedActVerificationTooling, ensureTreeseedSecretSessionForConfig, ensureTreeseedGitignoreEntries, getTreeseedMachineConfigPaths, loadTreeseedMachineConfig, listRelevantTreeseedConfigEntries, finalizeTreeseedConfig, inspectTreeseedKeyAgentTransportDiagnostic, inspectTreeseedPassphraseEnvDiagnostic, listDeprecatedTreeseedLocalEnvFiles, inspectTreeseedKeyAgentStatus, lockTreeseedSecretSession, migrateTreeseedMachineKeyToWrapped, resolveTreeseedMachineEnvironmentValues, resolveTreeseedLaunchEnvironment, resolveTreeseedRemoteConfig, resolveTreeseedRemoteSession, rotateTreeseedMachineKey, rotateTreeseedMachineKeyPassphrase, setTreeseedRemoteSession, TREESEED_MACHINE_KEY_PASSPHRASE_ENV, TreeseedKeyAgentError, updateTreeseedDeployConfigFeatureToggles, unlockTreeseedSecretSessionFromEnv, unlockTreeseedSecretSessionInteractive, unlockTreeseedSecretSessionWithPassphrase, withTreeseedKeyAgentAutopromptDisabled, warnDeprecatedTreeseedLocalEnvFiles, writeTreeseedMachineConfig, } from './operations/services/config-runtime.ts';
2
2
  export { exportTreeseedCodebase } from './operations/services/export-runtime.ts';
3
3
  export { assertDeploymentInitialized, cleanupDestroyedState, createBranchPreviewDeployTarget, createPersistentDeployTarget, deployTargetLabel, destroyCloudflareResources, ensureGeneratedWranglerConfig, finalizeDeploymentState, loadDeployState, printDeploySummary, printDestroySummary, provisionCloudflareResources, runRemoteD1Migrations, syncCloudflareSecrets, validateDeployPrerequisites, validateDestroyPrerequisites, } from './operations/services/deploy.ts';
4
4
  export { assertCleanWorktree, assertFeatureBranch, branchExists, checkoutBranch, createDeprecatedTaskTag, createFeatureBranchFromStaging, currentManagedBranch, deleteLocalBranch, deleteRemoteBranch, ensureLocalBranchTracking, gitWorkflowRoot, listTaskBranches, mergeCurrentBranchIntoStaging, mergeStagingIntoMain, prepareReleaseBranches, PRODUCTION_BRANCH, pushBranch, remoteBranchExists, STAGING_BRANCH, syncBranchWithOrigin, waitForStagingAutomation, } from './operations/services/git-workflow.ts';
5
5
  export { loadCliDeployConfig, packageScriptPath, resolveWranglerBin, } from './operations/services/runtime-tools.ts';
6
6
  export { configuredRailwayServices, deployRailwayService, validateRailwayDeployPrerequisites, } from './operations/services/railway-deploy.ts';
7
+ export { ensureRailwayEnvironment, ensureRailwayProject, ensureRailwayService, getRailwayAuthProfile, listRailwayEnvironments, listRailwayProjects, listRailwayServices, listRailwayVariables, railwayGraphqlRequest, resolveRailwayApiToken, resolveRailwayApiUrl, resolveRailwayWorkspace, resolveRailwayWorkspaceContext, upsertRailwayVariables, } from './operations/services/railway-api.ts';
7
8
  export { runTenantDeployPreflight, runWorkspaceSavePreflight, } from './operations/services/save-deploy-preflight.ts';
8
9
  export { collectCliPreflight } from './operations/services/workspace-preflight.ts';
9
10
  export { applyWorkspaceVersionChanges, collectMergeConflictReport, currentBranch, formatMergeConflictReport, gitStatusPorcelain, hasMeaningfulChanges, incrementVersion, originRemoteUrl, planWorkspaceReleaseBump, repoRoot, } from './operations/services/workspace-save.ts';
10
11
  export { findNearestTreeseedRoot, findNearestTreeseedWorkspaceRoot, isWorkspaceRoot, run, workspaceRoot, } from './operations/services/workspace-tools.ts';
12
+ export { collectTreeseedReconcileStatus, createTreeseedReconcileRegistry, deriveTreeseedDesiredUnits, destroyTreeseedTargetUnits, observeTreeseedUnits, planTreeseedReconciliation, reconcileTreeseedTarget, } from './reconcile/index.ts';
@@ -15,6 +15,8 @@ import {
15
15
  loadTreeseedMachineConfig,
16
16
  listRelevantTreeseedConfigEntries,
17
17
  finalizeTreeseedConfig,
18
+ inspectTreeseedKeyAgentTransportDiagnostic,
19
+ inspectTreeseedPassphraseEnvDiagnostic,
18
20
  listDeprecatedTreeseedLocalEnvFiles,
19
21
  inspectTreeseedKeyAgentStatus,
20
22
  lockTreeseedSecretSession,
@@ -88,6 +90,22 @@ import {
88
90
  deployRailwayService,
89
91
  validateRailwayDeployPrerequisites
90
92
  } from "./operations/services/railway-deploy.js";
93
+ import {
94
+ ensureRailwayEnvironment,
95
+ ensureRailwayProject,
96
+ ensureRailwayService,
97
+ getRailwayAuthProfile,
98
+ listRailwayEnvironments,
99
+ listRailwayProjects,
100
+ listRailwayServices,
101
+ listRailwayVariables,
102
+ railwayGraphqlRequest,
103
+ resolveRailwayApiToken,
104
+ resolveRailwayApiUrl,
105
+ resolveRailwayWorkspace,
106
+ resolveRailwayWorkspaceContext,
107
+ upsertRailwayVariables
108
+ } from "./operations/services/railway-api.js";
91
109
  import {
92
110
  runTenantDeployPreflight,
93
111
  runWorkspaceSavePreflight
@@ -112,6 +130,15 @@ import {
112
130
  run,
113
131
  workspaceRoot
114
132
  } from "./operations/services/workspace-tools.js";
133
+ import {
134
+ collectTreeseedReconcileStatus,
135
+ createTreeseedReconcileRegistry,
136
+ deriveTreeseedDesiredUnits,
137
+ destroyTreeseedTargetUnits,
138
+ observeTreeseedUnits,
139
+ planTreeseedReconciliation,
140
+ reconcileTreeseedTarget
141
+ } from "./reconcile/index.js";
115
142
  export {
116
143
  PRODUCTION_BRANCH,
117
144
  STAGING_BRANCH,
@@ -134,21 +161,28 @@ export {
134
161
  collectMergeConflictReport,
135
162
  collectTreeseedConfigContext,
136
163
  collectTreeseedPrintEnvReport,
164
+ collectTreeseedReconcileStatus,
137
165
  configuredRailwayServices,
138
166
  createBranchPreviewDeployTarget,
139
167
  createDefaultTreeseedMachineConfig,
140
168
  createDeprecatedTaskTag,
141
169
  createFeatureBranchFromStaging,
142
170
  createPersistentDeployTarget,
171
+ createTreeseedReconcileRegistry,
143
172
  currentBranch,
144
173
  currentManagedBranch,
145
174
  deleteLocalBranch,
146
175
  deleteRemoteBranch,
147
176
  deployRailwayService,
148
177
  deployTargetLabel,
178
+ deriveTreeseedDesiredUnits,
149
179
  destroyCloudflareResources,
180
+ destroyTreeseedTargetUnits,
150
181
  ensureGeneratedWranglerConfig,
151
182
  ensureLocalBranchTracking,
183
+ ensureRailwayEnvironment,
184
+ ensureRailwayProject,
185
+ ensureRailwayService,
152
186
  ensureTreeseedActVerificationTooling,
153
187
  ensureTreeseedGitignoreEntries,
154
188
  ensureTreeseedSecretSessionForConfig,
@@ -158,14 +192,21 @@ export {
158
192
  findNearestTreeseedRoot,
159
193
  findNearestTreeseedWorkspaceRoot,
160
194
  formatMergeConflictReport,
195
+ getRailwayAuthProfile,
161
196
  getTreeseedMachineConfigPaths,
162
197
  gitStatusPorcelain,
163
198
  gitWorkflowRoot,
164
199
  hasMeaningfulChanges,
165
200
  incrementVersion,
166
201
  inspectTreeseedKeyAgentStatus,
202
+ inspectTreeseedKeyAgentTransportDiagnostic,
203
+ inspectTreeseedPassphraseEnvDiagnostic,
167
204
  isWorkspaceRoot,
168
205
  listDeprecatedTreeseedLocalEnvFiles,
206
+ listRailwayEnvironments,
207
+ listRailwayProjects,
208
+ listRailwayServices,
209
+ listRailwayVariables,
169
210
  listRelevantTreeseedConfigEntries,
170
211
  listTaskBranches,
171
212
  loadCliDeployConfig,
@@ -175,16 +216,24 @@ export {
175
216
  mergeCurrentBranchIntoStaging,
176
217
  mergeStagingIntoMain,
177
218
  migrateTreeseedMachineKeyToWrapped,
219
+ observeTreeseedUnits,
178
220
  originRemoteUrl,
179
221
  packageScriptPath,
222
+ planTreeseedReconciliation,
180
223
  planWorkspaceReleaseBump,
181
224
  prepareReleaseBranches,
182
225
  printDeploySummary,
183
226
  printDestroySummary,
184
227
  provisionCloudflareResources,
185
228
  pushBranch,
229
+ railwayGraphqlRequest,
230
+ reconcileTreeseedTarget,
186
231
  remoteBranchExists,
187
232
  repoRoot,
233
+ resolveRailwayApiToken,
234
+ resolveRailwayApiUrl,
235
+ resolveRailwayWorkspace,
236
+ resolveRailwayWorkspaceContext,
188
237
  resolveTreeseedLaunchEnvironment,
189
238
  resolveTreeseedMachineEnvironmentValues,
190
239
  resolveTreeseedRemoteConfig,
@@ -203,6 +252,7 @@ export {
203
252
  unlockTreeseedSecretSessionInteractive,
204
253
  unlockTreeseedSecretSessionWithPassphrase,
205
254
  updateTreeseedDeployConfigFeatureToggles,
255
+ upsertRailwayVariables,
206
256
  validateDeployPrerequisites,
207
257
  validateDestroyPrerequisites,
208
258
  validateRailwayDeployPrerequisites,
@@ -131,6 +131,8 @@ export type TreeseedConfigInput = {
131
131
  environment?: TreeseedConfigScope[] | TreeseedConfigScope;
132
132
  syncProviders?: 'none' | 'github' | 'cloudflare' | 'railway' | 'all';
133
133
  sync?: 'none' | 'github' | 'cloudflare' | 'railway' | 'all';
134
+ bootstrap?: boolean;
135
+ preflight?: boolean;
134
136
  updates?: Array<{
135
137
  scope: Exclude<TreeseedConfigScope, 'all'>;
136
138
  entryId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/sdk",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -54,8 +54,10 @@
54
54
  "esbuild": "^0.28.0",
55
55
  "github-slugger": "^2.0.0",
56
56
  "ink": "^7.0.0",
57
+ "libsodium-wrappers": "^0.7.15",
57
58
  "mdast-util-to-string": "^4.0.0",
58
59
  "minisearch": "^7.2.0",
60
+ "octokit": "^5.0.3",
59
61
  "react": "^19.2.5",
60
62
  "remark-mdx": "^3.1.1",
61
63
  "remark-parse": "^11.0.0",
@@ -98,6 +100,10 @@
98
100
  "types": "./dist/workflow-support.d.ts",
99
101
  "default": "./dist/workflow-support.js"
100
102
  },
103
+ "./reconcile": {
104
+ "types": "./dist/reconcile/index.d.ts",
105
+ "default": "./dist/reconcile/index.js"
106
+ },
101
107
  "./platform/contracts": {
102
108
  "types": "./dist/platform/contracts.d.ts",
103
109
  "default": "./dist/platform/contracts.js"