@treeseed/sdk 0.10.23 → 0.10.25

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 (49) hide show
  1. package/dist/index.d.ts +12 -2
  2. package/dist/index.js +42 -1
  3. package/dist/market-client.d.ts +23 -0
  4. package/dist/market-client.js +30 -0
  5. package/dist/operations/providers/default.js +103 -10
  6. package/dist/operations/repository-operations.d.ts +6 -1
  7. package/dist/operations/repository-operations.js +44 -0
  8. package/dist/operations/services/bootstrap-runner.d.ts +5 -1
  9. package/dist/operations/services/bootstrap-runner.js +34 -5
  10. package/dist/operations/services/config-runtime.d.ts +25 -9
  11. package/dist/operations/services/config-runtime.js +60 -12
  12. package/dist/operations/services/deploy.js +6 -1
  13. package/dist/operations/services/hub-launch.js +1 -0
  14. package/dist/operations/services/hub-provider-launch.d.ts +11 -1
  15. package/dist/operations/services/hub-provider-launch.js +81 -8
  16. package/dist/operations/services/project-host-operations.d.ts +153 -0
  17. package/dist/operations/services/project-host-operations.js +365 -0
  18. package/dist/operations/services/project-platform.d.ts +207 -177
  19. package/dist/operations/services/project-platform.js +96 -29
  20. package/dist/operations/services/railway-deploy.d.ts +33 -1
  21. package/dist/operations/services/railway-deploy.js +153 -44
  22. package/dist/operations/services/release-candidate.js +8 -2
  23. package/dist/operations/services/template-host-bindings.d.ts +68 -0
  24. package/dist/operations/services/template-host-bindings.js +400 -0
  25. package/dist/operations/services/template-registry.d.ts +22 -2
  26. package/dist/operations/services/template-registry.js +93 -6
  27. package/dist/operations/services/template-secret-sync.d.ts +97 -0
  28. package/dist/operations/services/template-secret-sync.js +292 -0
  29. package/dist/platform/contracts.d.ts +1 -0
  30. package/dist/platform/deploy-config.js +8 -1
  31. package/dist/platform/deploy-runtime.js +1 -0
  32. package/dist/platform/environment.d.ts +3 -0
  33. package/dist/project-workflow.d.ts +7 -1
  34. package/dist/reconcile/engine.d.ts +2 -0
  35. package/dist/reconcile/engine.js +58 -3
  36. package/dist/scripts/scaffold-site.js +3 -2
  37. package/dist/scripts/test-scaffold.js +2 -1
  38. package/dist/sdk-types.d.ts +87 -0
  39. package/dist/sdk-types.js +29 -0
  40. package/dist/template-catalog.js +3 -1
  41. package/dist/template-launch-requirements.d.ts +118 -0
  42. package/dist/template-launch-requirements.js +759 -0
  43. package/dist/template-launch-ui.d.ts +85 -0
  44. package/dist/template-launch-ui.js +189 -0
  45. package/dist/timing.d.ts +20 -0
  46. package/dist/timing.js +73 -0
  47. package/dist/treeseed/template-catalog/catalog.fixture.json +477 -0
  48. package/package.json +13 -1
  49. package/templates/github/deploy-web.workflow.yml +4 -0
@@ -21,6 +21,16 @@ export declare const PROJECT_DEPLOYMENT_STATUSES: readonly ["pending", "queued",
21
21
  export declare const PROJECT_INFRA_RESOURCE_PROVIDERS: readonly ["cloudflare", "railway", "github", "market"];
22
22
  export declare const PROJECT_INFRA_RESOURCE_KINDS: readonly ["pages", "worker", "kv", "turnstile-widget", "r2", "d1", "queue", "dlq", "railway_project", "railway_service", "railway_schedule"];
23
23
  export declare const AGENT_POOL_STATUSES: readonly ["pending", "active", "degraded", "offline"];
24
+ export declare const TREESEED_DEFAULT_STARTER_TEMPLATE_ID: "starter-research";
25
+ export declare const TEMPLATE_HOST_REQUIREMENT_TYPES: readonly ["repository", "web", "email", "ai"];
26
+ export declare const TEMPLATE_RESOURCE_REQUIREMENT_TYPES: readonly ["service", "database", "object-storage", "queue", "dns-zone"];
27
+ export declare const TEMPLATE_SECRET_SENSITIVITIES: readonly ["secret", "plain", "derived"];
28
+ export declare const TEMPLATE_SECRET_TARGETS: readonly ["github-secret", "github-variable", "cloudflare-secret", "cloudflare-var", "railway-secret", "railway-var", "config-file", "local-runtime"];
29
+ export declare const TEMPLATE_SECRET_SOURCES: readonly ["generated", "selected-host", "user-input", "derived"];
30
+ export declare const TEMPLATE_CONFIG_WRITE_TARGETS: readonly ["treeseed.site.yaml", "src/env.yaml", "src/manifest.yaml", "package.json"];
31
+ export declare const TEMPLATE_CONFIG_WRITE_WHEN: readonly ["always", "host-selected", "feature-enabled"];
32
+ export declare const TEMPLATE_CONFIG_MERGE_STRATEGIES: readonly ["replace", "deep-merge", "append-unique"];
33
+ export declare const PROJECT_LAUNCH_REQUIREMENT_KINDS: readonly ["host", "resource", "secret"];
24
34
  export type SdkBuiltinModelName = (typeof SDK_MODEL_NAMES)[number];
25
35
  export type SdkModelName = SdkBuiltinModelName | (string & {});
26
36
  export type SdkOperation = (typeof SDK_OPERATIONS)[number];
@@ -49,6 +59,82 @@ export type ProjectInfrastructureResourceProvider = (typeof PROJECT_INFRA_RESOUR
49
59
  export type ProjectInfrastructureResourceKind = (typeof PROJECT_INFRA_RESOURCE_KINDS)[number];
50
60
  export type AgentPoolStatus = (typeof AGENT_POOL_STATUSES)[number];
51
61
  export type RemoteJobRequestedByType = 'user' | 'team_api_key' | 'service' | 'runner' | 'system';
62
+ export type TemplateHostRequirementType = (typeof TEMPLATE_HOST_REQUIREMENT_TYPES)[number];
63
+ export type TemplateResourceRequirementType = (typeof TEMPLATE_RESOURCE_REQUIREMENT_TYPES)[number];
64
+ export type TemplateSecretSensitivity = (typeof TEMPLATE_SECRET_SENSITIVITIES)[number];
65
+ export type TemplateSecretTarget = (typeof TEMPLATE_SECRET_TARGETS)[number];
66
+ export type TemplateSecretSource = (typeof TEMPLATE_SECRET_SOURCES)[number];
67
+ export type TemplateConfigWriteTarget = (typeof TEMPLATE_CONFIG_WRITE_TARGETS)[number];
68
+ export type TemplateConfigWriteWhen = (typeof TEMPLATE_CONFIG_WRITE_WHEN)[number];
69
+ export type TemplateConfigMergeStrategy = (typeof TEMPLATE_CONFIG_MERGE_STRATEGIES)[number];
70
+ export type ProjectLaunchRequirementKind = (typeof PROJECT_LAUNCH_REQUIREMENT_KINDS)[number];
71
+ export interface TemplateConfigWrite {
72
+ target: TemplateConfigWriteTarget;
73
+ path: string;
74
+ valueFrom: string;
75
+ writeWhen?: TemplateConfigWriteWhen;
76
+ mergeStrategy?: TemplateConfigMergeStrategy;
77
+ }
78
+ export interface TemplateEnvironmentWrite {
79
+ env: string;
80
+ valueFrom: string;
81
+ targets?: TemplateSecretTarget[];
82
+ scopes?: ProjectEnvironmentName[];
83
+ sensitivity?: TemplateSecretSensitivity;
84
+ }
85
+ export interface TemplateHostRequirement {
86
+ kind: 'host';
87
+ key: string;
88
+ type: TemplateHostRequirementType;
89
+ required: boolean;
90
+ compatibleProviders?: string[];
91
+ displayName: string;
92
+ purpose: string;
93
+ defaultSelection?: 'team-default' | 'managed' | 'none';
94
+ configWrites: TemplateConfigWrite[];
95
+ environmentWrites?: TemplateEnvironmentWrite[];
96
+ }
97
+ export interface TemplateResourceRequirement {
98
+ kind: 'resource';
99
+ key: string;
100
+ type: TemplateResourceRequirementType;
101
+ required: boolean;
102
+ compatibleProviders?: string[];
103
+ displayName: string;
104
+ purpose: string;
105
+ configWrites: TemplateConfigWrite[];
106
+ environmentWrites?: TemplateEnvironmentWrite[];
107
+ }
108
+ export interface TemplateSecretRequirement {
109
+ kind: 'secret';
110
+ key: string;
111
+ env: string;
112
+ required: boolean;
113
+ sensitivity: TemplateSecretSensitivity;
114
+ targets: TemplateSecretTarget[];
115
+ source: TemplateSecretSource;
116
+ }
117
+ export interface TemplateLaunchRequirements {
118
+ version?: number;
119
+ hosts?: TemplateHostRequirement[];
120
+ resources?: TemplateResourceRequirement[];
121
+ secrets?: TemplateSecretRequirement[];
122
+ }
123
+ export interface ProjectLaunchHostBindingInput {
124
+ requirementKey: string;
125
+ requirementKind: ProjectLaunchRequirementKind;
126
+ type: string;
127
+ provider: string;
128
+ hostId?: string | null;
129
+ managedHostKey?: string | null;
130
+ mode?: string | null;
131
+ displayName?: string;
132
+ environmentScopes?: ProjectEnvironmentName[];
133
+ configValues?: Record<string, unknown>;
134
+ environmentValues?: Record<string, string>;
135
+ secretRefs?: Record<string, string>;
136
+ selectedBy?: 'user' | 'team-default' | 'managed-default' | 'template-default';
137
+ }
52
138
  export declare function projectConnectionModeFromHosting(kind: TreeseedHostingKind, registration?: TreeseedHostingRegistration): ProjectConnectionMode;
53
139
  export interface SdkDispatchCapability {
54
140
  namespace: SdkDispatchNamespace;
@@ -2536,6 +2622,7 @@ export interface SdkTemplateCatalogEntry {
2536
2622
  relatedBooks?: string[];
2537
2623
  relatedKnowledge?: string[];
2538
2624
  relatedObjectives?: string[];
2625
+ launchRequirements?: TemplateLaunchRequirements;
2539
2626
  }
2540
2627
  export interface SdkTemplateCatalogResponse {
2541
2628
  items: SdkTemplateCatalogEntry[];
package/dist/sdk-types.js CHANGED
@@ -59,6 +59,25 @@ const PROJECT_INFRA_RESOURCE_KINDS = [
59
59
  "railway_schedule"
60
60
  ];
61
61
  const AGENT_POOL_STATUSES = ["pending", "active", "degraded", "offline"];
62
+ const TREESEED_DEFAULT_STARTER_TEMPLATE_ID = "starter-research";
63
+ const TEMPLATE_HOST_REQUIREMENT_TYPES = ["repository", "web", "email", "ai"];
64
+ const TEMPLATE_RESOURCE_REQUIREMENT_TYPES = ["service", "database", "object-storage", "queue", "dns-zone"];
65
+ const TEMPLATE_SECRET_SENSITIVITIES = ["secret", "plain", "derived"];
66
+ const TEMPLATE_SECRET_TARGETS = [
67
+ "github-secret",
68
+ "github-variable",
69
+ "cloudflare-secret",
70
+ "cloudflare-var",
71
+ "railway-secret",
72
+ "railway-var",
73
+ "config-file",
74
+ "local-runtime"
75
+ ];
76
+ const TEMPLATE_SECRET_SOURCES = ["generated", "selected-host", "user-input", "derived"];
77
+ const TEMPLATE_CONFIG_WRITE_TARGETS = ["treeseed.site.yaml", "src/env.yaml", "src/manifest.yaml", "package.json"];
78
+ const TEMPLATE_CONFIG_WRITE_WHEN = ["always", "host-selected", "feature-enabled"];
79
+ const TEMPLATE_CONFIG_MERGE_STRATEGIES = ["replace", "deep-merge", "append-unique"];
80
+ const PROJECT_LAUNCH_REQUIREMENT_KINDS = ["host", "resource", "secret"];
62
81
  function projectConnectionModeFromHosting(kind, registration = "none") {
63
82
  if (kind === "hosted_project") {
64
83
  return "hosted";
@@ -78,6 +97,7 @@ export {
78
97
  PROJECT_EXECUTION_OWNERS,
79
98
  PROJECT_INFRA_RESOURCE_KINDS,
80
99
  PROJECT_INFRA_RESOURCE_PROVIDERS,
100
+ PROJECT_LAUNCH_REQUIREMENT_KINDS,
81
101
  PROJECT_RUNNER_REGISTRATION_STATES,
82
102
  PROJECT_WEB_DEPLOYMENT_ACTIONS,
83
103
  REMOTE_JOB_STATUSES,
@@ -89,6 +109,15 @@ export {
89
109
  SDK_OPERATIONS,
90
110
  SDK_PICK_STRATEGIES,
91
111
  SDK_STORAGE_BACKENDS,
112
+ TEMPLATE_CONFIG_MERGE_STRATEGIES,
113
+ TEMPLATE_CONFIG_WRITE_TARGETS,
114
+ TEMPLATE_CONFIG_WRITE_WHEN,
115
+ TEMPLATE_HOST_REQUIREMENT_TYPES,
116
+ TEMPLATE_RESOURCE_REQUIREMENT_TYPES,
117
+ TEMPLATE_SECRET_SENSITIVITIES,
118
+ TEMPLATE_SECRET_SOURCES,
119
+ TEMPLATE_SECRET_TARGETS,
120
+ TREESEED_DEFAULT_STARTER_TEMPLATE_ID,
92
121
  TREESEED_HOSTING_KINDS,
93
122
  TREESEED_HOSTING_REGISTRATIONS,
94
123
  projectConnectionModeFromHosting
@@ -1,5 +1,6 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
+ import { normalizeTemplateLaunchRequirements } from "./template-launch-requirements.js";
3
4
  function expectRecord(value, label) {
4
5
  if (!value || typeof value !== "object" || Array.isArray(value)) {
5
6
  throw new Error(`Invalid template catalog response: expected ${label} to be an object.`);
@@ -91,7 +92,8 @@ function normalizeTemplateCatalogEntry(value) {
91
92
  } : void 0,
92
93
  relatedBooks: optionalStringArray(record.relatedBooks, "relatedBooks") ?? [],
93
94
  relatedKnowledge: optionalStringArray(record.relatedKnowledge, "relatedKnowledge") ?? [],
94
- relatedObjectives: optionalStringArray(record.relatedObjectives, "relatedObjectives") ?? []
95
+ relatedObjectives: optionalStringArray(record.relatedObjectives, "relatedObjectives") ?? [],
96
+ launchRequirements: normalizeTemplateLaunchRequirements(record.launchRequirements, "launchRequirements")
95
97
  };
96
98
  }
97
99
  function parseTemplateCatalogResponse(payload) {
@@ -0,0 +1,118 @@
1
+ import { type ProjectEnvironmentName, type ProjectLaunchHostBindingInput, type ProjectLaunchRequirementKind, type TemplateConfigWrite, type TemplateLaunchRequirements } from './sdk-types.ts';
2
+ type Mutable<T> = {
3
+ -readonly [P in keyof T]: T[P];
4
+ };
5
+ export type { TemplateLaunchRequirements } from './sdk-types.ts';
6
+ export interface ProjectLaunchHostInventoryRecord {
7
+ id: string;
8
+ type?: string | null;
9
+ provider: string;
10
+ ownership?: string | null;
11
+ name?: string | null;
12
+ accountLabel?: string | null;
13
+ organizationOrOwner?: string | null;
14
+ allowedEnvironments?: ProjectEnvironmentName[];
15
+ status?: string | null;
16
+ metadata?: Record<string, unknown>;
17
+ }
18
+ export interface ProjectLaunchResolvedHostBinding {
19
+ requirementKey: string;
20
+ requirementKind: ProjectLaunchRequirementKind;
21
+ type: string;
22
+ provider: string;
23
+ hostId?: string | null;
24
+ managedHostKey?: string | null;
25
+ displayName: string;
26
+ environmentScopes: ProjectEnvironmentName[];
27
+ configValues: Record<string, unknown>;
28
+ environmentValues: Record<string, string>;
29
+ secretRefs: Record<string, string>;
30
+ provenance: {
31
+ selectedBy: NonNullable<ProjectLaunchHostBindingInput['selectedBy']>;
32
+ selectedAt: string;
33
+ };
34
+ host: {
35
+ id: string;
36
+ name: string | null;
37
+ ownership: string | null;
38
+ status: string | null;
39
+ accountLabel?: string | null;
40
+ organizationOrOwner?: string | null;
41
+ metadata?: Record<string, unknown>;
42
+ } | null;
43
+ }
44
+ export interface ProjectLaunchConfigWritePlanItem extends TemplateConfigWrite {
45
+ requirementKey: string;
46
+ requirementKind: ProjectLaunchRequirementKind;
47
+ requirementType: string;
48
+ provider: string;
49
+ }
50
+ export interface ProjectLaunchSecretDeploymentPlanItem {
51
+ requirementKey: string;
52
+ requirementKind: ProjectLaunchRequirementKind;
53
+ env: string;
54
+ sensitivity: string;
55
+ source: string;
56
+ targets: string[];
57
+ scopes: ProjectEnvironmentName[];
58
+ sourceHostId?: string | null;
59
+ }
60
+ export interface ResolveProjectLaunchHostBindingsOptions {
61
+ hostBindings?: Record<string, ProjectLaunchHostBindingInput>;
62
+ launchRequirements?: TemplateLaunchRequirements | null;
63
+ repositoryHosts?: ProjectLaunchHostInventoryRecord[];
64
+ teamHosts?: ProjectLaunchHostInventoryRecord[];
65
+ managedHosts?: ProjectLaunchHostInventoryRecord[];
66
+ defaultHosts?: Record<string, unknown> | null;
67
+ domains?: Record<string, unknown> | null;
68
+ projectSlug?: string | null;
69
+ projectName?: string | null;
70
+ standardProjectLaunch?: boolean;
71
+ selectedAt?: string;
72
+ }
73
+ export interface ResolveProjectLaunchHostBindingsResult {
74
+ hostBindings: Record<string, ProjectLaunchResolvedHostBinding>;
75
+ compatibility: {
76
+ repositoryHostId?: string | null;
77
+ cloudflareHostMode?: 'team_owned' | 'treeseed_managed' | null;
78
+ cloudflareHostId?: string | null;
79
+ emailHostMode?: 'team_owned' | 'treeseed_managed' | null;
80
+ emailHostId?: string | null;
81
+ };
82
+ configWritePlan: ProjectLaunchConfigWritePlanItem[];
83
+ secretDeploymentPlan: {
84
+ items: ProjectLaunchSecretDeploymentPlanItem[];
85
+ };
86
+ diagnostics: Array<{
87
+ code: string;
88
+ message: string;
89
+ requirementKey?: string;
90
+ }>;
91
+ }
92
+ export interface ProjectLaunchLocalHostBindingSummary {
93
+ requirementKey: string;
94
+ requirementKind: ProjectLaunchRequirementKind;
95
+ type: string;
96
+ provider: string | null;
97
+ alias: string | null;
98
+ mode: 'team_owned' | 'treeseed_managed' | 'none';
99
+ displayName: string;
100
+ }
101
+ export interface ParseProjectLaunchHostBindingSpecsOptions {
102
+ specs?: string | string[] | null;
103
+ launchRequirements?: TemplateLaunchRequirements | null;
104
+ selectedAt?: string;
105
+ }
106
+ export interface ParseProjectLaunchHostBindingSpecsResult {
107
+ hostBindings: Record<string, ProjectLaunchHostBindingInput>;
108
+ repositoryHosts: ProjectLaunchHostInventoryRecord[];
109
+ teamHosts: ProjectLaunchHostInventoryRecord[];
110
+ managedHosts: ProjectLaunchHostInventoryRecord[];
111
+ summaries: ProjectLaunchLocalHostBindingSummary[];
112
+ omitted: ProjectLaunchLocalHostBindingSummary[];
113
+ }
114
+ export declare function normalizeTemplateLaunchRequirements(value: unknown, label?: string): TemplateLaunchRequirements | undefined;
115
+ export declare function validateTemplateLaunchRequirements(value: unknown, label?: string): void;
116
+ export declare function normalizeProjectLaunchHostBindings(input: unknown): Mutable<Record<string, ProjectLaunchHostBindingInput>>;
117
+ export declare function parseProjectLaunchHostBindingSpecs(options: ParseProjectLaunchHostBindingSpecsOptions): ParseProjectLaunchHostBindingSpecsResult;
118
+ export declare function resolveProjectLaunchHostBindings(options: ResolveProjectLaunchHostBindingsOptions): ResolveProjectLaunchHostBindingsResult;