@treeseed/sdk 0.4.8 → 0.4.10

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 (73) hide show
  1. package/README.md +1 -1
  2. package/dist/control-plane-client.d.ts +45 -0
  3. package/dist/control-plane-client.js +229 -0
  4. package/dist/control-plane.d.ts +94 -0
  5. package/dist/control-plane.js +125 -0
  6. package/dist/d1-store.d.ts +56 -1
  7. package/dist/d1-store.js +132 -0
  8. package/dist/dispatch.d.ts +4 -0
  9. package/dist/dispatch.js +180 -0
  10. package/dist/index.d.ts +14 -2
  11. package/dist/index.js +94 -4
  12. package/dist/operations/services/config-runtime.d.ts +10 -0
  13. package/dist/operations/services/config-runtime.js +62 -4
  14. package/dist/operations/services/deploy.d.ts +95 -3
  15. package/dist/operations/services/deploy.js +351 -10
  16. package/dist/operations/services/github-automation.d.ts +37 -1
  17. package/dist/operations/services/github-automation.js +71 -14
  18. package/dist/operations/services/project-platform.d.ts +835 -0
  19. package/dist/operations/services/project-platform.js +782 -0
  20. package/dist/operations/services/railway-deploy.d.ts +113 -18
  21. package/dist/operations/services/railway-deploy.js +357 -8
  22. package/dist/operations/services/runtime-tools.d.ts +25 -1
  23. package/dist/operations/services/runtime-tools.js +66 -5
  24. package/dist/operations/services/template-registry.d.ts +1 -1
  25. package/dist/operations/services/template-registry.js +17 -3
  26. package/dist/platform/books-data.d.ts +3 -4
  27. package/dist/platform/books-data.js +30 -4
  28. package/dist/platform/contracts.d.ts +56 -4
  29. package/dist/platform/deploy-config.js +109 -4
  30. package/dist/platform/deploy-runtime.d.ts +2 -0
  31. package/dist/platform/deploy-runtime.js +9 -1
  32. package/dist/platform/env.yaml +677 -0
  33. package/dist/platform/environment.js +57 -2
  34. package/dist/platform/plugin.d.ts +8 -0
  35. package/dist/platform/plugins/constants.d.ts +2 -0
  36. package/dist/platform/plugins/constants.js +2 -0
  37. package/dist/platform/plugins/runtime.d.ts +2 -0
  38. package/dist/platform/plugins/runtime.js +9 -1
  39. package/dist/platform/plugins.d.ts +1 -1
  40. package/dist/platform/plugins.js +4 -0
  41. package/dist/platform/published-content-pipeline.d.ts +84 -0
  42. package/dist/platform/published-content-pipeline.js +543 -0
  43. package/dist/platform/published-content.d.ts +223 -0
  44. package/dist/platform/published-content.js +588 -0
  45. package/dist/platform/tenant/runtime-config.d.ts +1 -1
  46. package/dist/platform/tenant/runtime-config.js +34 -1
  47. package/dist/platform/tenant-config.d.ts +2 -1
  48. package/dist/platform/tenant-config.js +17 -1
  49. package/dist/platform/utils/site-config-schema.js +104 -0
  50. package/dist/plugin-default.d.ts +2 -0
  51. package/dist/plugin-default.js +2 -0
  52. package/dist/remote.d.ts +65 -9
  53. package/dist/remote.js +104 -28
  54. package/dist/scripts/check-build-warnings.js +50 -0
  55. package/dist/scripts/config-treeseed.js +7 -0
  56. package/dist/scripts/tenant-workflow-action.js +71 -0
  57. package/dist/sdk-dispatch.d.ts +12 -0
  58. package/dist/sdk-dispatch.js +142 -0
  59. package/dist/sdk-types.d.ts +579 -7
  60. package/dist/sdk-types.js +53 -1
  61. package/dist/sdk.d.ts +17 -1
  62. package/dist/sdk.js +109 -0
  63. package/dist/stores/operational-store.d.ts +22 -2
  64. package/dist/stores/operational-store.js +235 -0
  65. package/dist/template-catalog.js +8 -1
  66. package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +20 -0
  67. package/dist/types/cloudflare.d.ts +23 -0
  68. package/dist/workflow/operations.d.ts +12 -3
  69. package/dist/workflow/policy.d.ts +1 -1
  70. package/dist/workflow-state.js +2 -1
  71. package/package.json +7 -2
  72. package/templates/github/deploy.workflow.yml +442 -0
  73. package/templates/github/hosted-project.workflow.yml +77 -0
@@ -3,12 +3,416 @@ export declare const SDK_MODEL_NAMES: readonly ["page", "note", "question", "boo
3
3
  export declare const SDK_OPERATIONS: readonly ["get", "read", "search", "follow", "pick", "create", "update"];
4
4
  export declare const SDK_STORAGE_BACKENDS: readonly ["content", "d1"];
5
5
  export declare const SDK_PICK_STRATEGIES: readonly ["latest", "highest_priority", "oldest"];
6
+ export declare const SDK_DISPATCH_EXECUTION_CLASSES: readonly ["local_only", "remote_inline", "remote_job"];
7
+ export declare const SDK_DISPATCH_TARGETS: readonly ["local", "project_api", "project_runner", "market_catalog"];
8
+ export declare const SDK_DISPATCH_POLICIES: readonly ["auto", "prefer_local", "prefer_remote", "remote_only"];
9
+ export declare const SDK_DISPATCH_NAMESPACES: readonly ["sdk", "workflow"];
10
+ export declare const TREESEED_HOSTING_KINDS: readonly ["market_control_plane", "hosted_project", "self_hosted_project"];
11
+ export declare const TREESEED_HOSTING_REGISTRATIONS: readonly ["optional", "none"];
12
+ export declare const PROJECT_CONNECTION_MODES: readonly ["hosted", "self_hosted", "hybrid"];
13
+ export declare const PROJECT_RUNNER_REGISTRATION_STATES: readonly ["pending", "registered", "offline"];
14
+ export declare const PROJECT_EXECUTION_OWNERS: readonly ["project_api", "project_runner", "market"];
15
+ export declare const REMOTE_JOB_STATUSES: readonly ["pending", "claimed", "running", "completed", "failed", "cancelled"];
16
+ export declare const PROJECT_ENVIRONMENT_NAMES: readonly ["local", "staging", "prod"];
17
+ export declare const PROJECT_DEPLOYMENT_KINDS: readonly ["provision", "code", "content", "mixed"];
18
+ export declare const PROJECT_DEPLOYMENT_STATUSES: readonly ["pending", "running", "succeeded", "failed", "cancelled"];
19
+ export declare const PROJECT_INFRA_RESOURCE_PROVIDERS: readonly ["cloudflare", "railway", "github", "market"];
20
+ export declare const PROJECT_INFRA_RESOURCE_KINDS: readonly ["pages", "worker", "r2", "d1", "queue", "dlq", "railway_project", "railway_service", "railway_schedule"];
21
+ export declare const AGENT_POOL_STATUSES: readonly ["pending", "active", "degraded", "offline"];
6
22
  export type SdkBuiltinModelName = (typeof SDK_MODEL_NAMES)[number];
7
23
  export type SdkModelName = SdkBuiltinModelName | (string & {});
8
24
  export type SdkOperation = (typeof SDK_OPERATIONS)[number];
9
25
  export type SdkStorageBackend = (typeof SDK_STORAGE_BACKENDS)[number];
10
26
  export type SdkPickStrategy = (typeof SDK_PICK_STRATEGIES)[number];
11
27
  export type SdkComparableAs = 'string' | 'number' | 'date' | 'boolean' | 'string_array';
28
+ export type SdkDispatchExecutionClass = (typeof SDK_DISPATCH_EXECUTION_CLASSES)[number];
29
+ export type SdkDispatchTarget = (typeof SDK_DISPATCH_TARGETS)[number];
30
+ export type SdkDispatchPolicy = (typeof SDK_DISPATCH_POLICIES)[number];
31
+ export type SdkDispatchNamespace = (typeof SDK_DISPATCH_NAMESPACES)[number];
32
+ export type TreeseedHostingKind = (typeof TREESEED_HOSTING_KINDS)[number];
33
+ export type TreeseedHostingRegistration = (typeof TREESEED_HOSTING_REGISTRATIONS)[number];
34
+ export type ProjectConnectionMode = (typeof PROJECT_CONNECTION_MODES)[number];
35
+ export type ProjectRunnerRegistrationState = (typeof PROJECT_RUNNER_REGISTRATION_STATES)[number];
36
+ export type ProjectExecutionOwner = (typeof PROJECT_EXECUTION_OWNERS)[number];
37
+ export type RemoteJobStatus = (typeof REMOTE_JOB_STATUSES)[number];
38
+ export type ProjectEnvironmentName = (typeof PROJECT_ENVIRONMENT_NAMES)[number];
39
+ export type ProjectDeploymentKind = (typeof PROJECT_DEPLOYMENT_KINDS)[number];
40
+ export type ProjectDeploymentStatus = (typeof PROJECT_DEPLOYMENT_STATUSES)[number];
41
+ export type ProjectInfrastructureResourceProvider = (typeof PROJECT_INFRA_RESOURCE_PROVIDERS)[number];
42
+ export type ProjectInfrastructureResourceKind = (typeof PROJECT_INFRA_RESOURCE_KINDS)[number];
43
+ export type AgentPoolStatus = (typeof AGENT_POOL_STATUSES)[number];
44
+ export type RemoteJobRequestedByType = 'user' | 'team_api_key' | 'service' | 'runner' | 'system';
45
+ export declare function projectConnectionModeFromHosting(kind: TreeseedHostingKind, registration?: TreeseedHostingRegistration): ProjectConnectionMode;
46
+ export interface SdkDispatchCapability {
47
+ namespace: SdkDispatchNamespace;
48
+ operation: string;
49
+ executionClass: SdkDispatchExecutionClass;
50
+ allowedTargets: SdkDispatchTarget[];
51
+ defaultTarget: SdkDispatchTarget;
52
+ defaultDispatchMode: SdkDispatchPolicy;
53
+ summary?: string;
54
+ }
55
+ export interface ProjectConnection {
56
+ id: string;
57
+ projectId: string;
58
+ mode: ProjectConnectionMode;
59
+ projectApiBaseUrl: string | null;
60
+ runnerRegistrationState: ProjectRunnerRegistrationState;
61
+ executionOwner: ProjectExecutionOwner;
62
+ runnerRegisteredAt: string | null;
63
+ runnerLastSeenAt: string | null;
64
+ createdAt: string;
65
+ updatedAt: string;
66
+ metadata?: Record<string, unknown>;
67
+ }
68
+ export type CatalogItemOfferMode = 'free' | 'paid' | 'contact' | 'one_time_current_version' | 'subscription_updates' | 'private';
69
+ export interface TeamStorageLocator {
70
+ id: string;
71
+ teamId: string;
72
+ bucketName: string;
73
+ manifestKeyTemplate: string;
74
+ previewRootTemplate: string;
75
+ publicBaseUrl: string | null;
76
+ metadata?: Record<string, unknown>;
77
+ createdAt: string;
78
+ updatedAt: string;
79
+ }
80
+ export interface CatalogItem {
81
+ id: string;
82
+ teamId: string;
83
+ kind: string;
84
+ slug: string;
85
+ title: string;
86
+ summary: string | null;
87
+ visibility: 'public' | 'authenticated' | 'team' | 'private';
88
+ listingEnabled: boolean;
89
+ offerMode: CatalogItemOfferMode;
90
+ manifestKey: string | null;
91
+ artifactKey: string | null;
92
+ searchText: string | null;
93
+ metadata?: Record<string, unknown>;
94
+ createdAt: string;
95
+ updatedAt: string;
96
+ }
97
+ export interface CatalogArtifactVersion {
98
+ id: string;
99
+ itemId: string;
100
+ teamId: string;
101
+ kind: string;
102
+ version: string;
103
+ contentKey: string;
104
+ manifestKey: string | null;
105
+ metadata?: Record<string, unknown>;
106
+ publishedAt: string;
107
+ createdAt: string;
108
+ updatedAt: string;
109
+ }
110
+ export interface ProjectHosting {
111
+ id: string;
112
+ projectId: string;
113
+ kind: TreeseedHostingKind;
114
+ registration: TreeseedHostingRegistration;
115
+ marketBaseUrl: string | null;
116
+ sourceRepoOwner: string | null;
117
+ sourceRepoName: string | null;
118
+ sourceRepoUrl: string | null;
119
+ sourceRepoWorkflowPath: string | null;
120
+ metadata?: Record<string, unknown>;
121
+ createdAt: string;
122
+ updatedAt: string;
123
+ }
124
+ export interface ProjectEnvironment {
125
+ id: string;
126
+ projectId: string;
127
+ environment: ProjectEnvironmentName;
128
+ deploymentProfile: TreeseedHostingKind;
129
+ baseUrl: string | null;
130
+ cloudflareAccountId: string | null;
131
+ pagesProjectName: string | null;
132
+ workerName: string | null;
133
+ r2BucketName: string | null;
134
+ d1DatabaseName: string | null;
135
+ queueName: string | null;
136
+ railwayProjectName: string | null;
137
+ metadata?: Record<string, unknown>;
138
+ createdAt: string;
139
+ updatedAt: string;
140
+ }
141
+ export interface ProjectInfrastructureResource {
142
+ id: string;
143
+ projectId: string;
144
+ environment: ProjectEnvironmentName;
145
+ provider: ProjectInfrastructureResourceProvider;
146
+ resourceKind: ProjectInfrastructureResourceKind;
147
+ logicalName: string;
148
+ locator: string | null;
149
+ metadata?: Record<string, unknown>;
150
+ createdAt: string;
151
+ updatedAt: string;
152
+ }
153
+ export interface ProjectDeployment {
154
+ id: string;
155
+ projectId: string;
156
+ environment: ProjectEnvironmentName;
157
+ deploymentKind: ProjectDeploymentKind;
158
+ status: ProjectDeploymentStatus;
159
+ sourceRef: string | null;
160
+ releaseTag: string | null;
161
+ commitSha: string | null;
162
+ triggeredByType: string | null;
163
+ triggeredById: string | null;
164
+ metadata?: Record<string, unknown>;
165
+ startedAt: string | null;
166
+ finishedAt: string | null;
167
+ createdAt: string;
168
+ updatedAt: string;
169
+ }
170
+ export interface AgentPoolAutoscalePolicy {
171
+ minWorkers: number;
172
+ maxWorkers: number;
173
+ targetQueueDepth: number;
174
+ cooldownSeconds: number;
175
+ }
176
+ export interface AgentPool {
177
+ id: string;
178
+ projectId: string;
179
+ teamId: string;
180
+ environment: ProjectEnvironmentName;
181
+ name: string;
182
+ registrationIdentity: string | null;
183
+ serviceBaseUrl: string | null;
184
+ status: AgentPoolStatus;
185
+ autoscale: AgentPoolAutoscalePolicy;
186
+ metadata?: Record<string, unknown>;
187
+ createdAt: string;
188
+ updatedAt: string;
189
+ }
190
+ export interface AgentPoolRegistration {
191
+ id: string;
192
+ poolId: string;
193
+ projectId: string;
194
+ runnerId: string | null;
195
+ managerId: string | null;
196
+ serviceName: string | null;
197
+ heartbeatAt: string;
198
+ desiredWorkers: number | null;
199
+ observedQueueDepth: number | null;
200
+ observedActiveLeases: number | null;
201
+ metadata?: Record<string, unknown>;
202
+ createdAt: string;
203
+ updatedAt: string;
204
+ }
205
+ export interface AgentPoolScaleDecision {
206
+ id: string;
207
+ poolId: string;
208
+ projectId: string;
209
+ environment: ProjectEnvironmentName;
210
+ desiredWorkers: number;
211
+ observedQueueDepth: number;
212
+ observedActiveLeases: number;
213
+ workDayId: string | null;
214
+ reason: string;
215
+ metadata?: Record<string, unknown>;
216
+ createdAt: string;
217
+ updatedAt: string;
218
+ }
219
+ export interface WorkdayWindow {
220
+ days: number[];
221
+ startTime: string;
222
+ endTime: string;
223
+ }
224
+ export interface WorkdaySchedule {
225
+ timezone: string;
226
+ windows: WorkdayWindow[];
227
+ }
228
+ export interface TaskCreditWeight {
229
+ id?: string;
230
+ taskType?: string | null;
231
+ agentId?: string | null;
232
+ handler?: string | null;
233
+ credits: number;
234
+ }
235
+ export interface TaskCreditBudget {
236
+ dailyLimit: number;
237
+ used: number;
238
+ remaining: number;
239
+ maxQueuedTasks: number;
240
+ maxQueuedCredits: number;
241
+ }
242
+ export interface WorkdayPolicy {
243
+ projectId: string;
244
+ environment: ProjectEnvironmentName | 'local';
245
+ schedule: WorkdaySchedule;
246
+ dailyTaskCreditBudget: number;
247
+ maxQueuedTasks: number;
248
+ maxQueuedCredits: number;
249
+ autoscale: AgentPoolAutoscalePolicy;
250
+ creditWeights: TaskCreditWeight[];
251
+ metadata?: Record<string, unknown>;
252
+ }
253
+ export interface PrioritySnapshotItem {
254
+ model: string;
255
+ id: string;
256
+ slug?: string | null;
257
+ title?: string | null;
258
+ priority: number;
259
+ estimatedCredits: number;
260
+ reasons: string[];
261
+ metadata?: Record<string, unknown>;
262
+ }
263
+ export interface PrioritySnapshot {
264
+ id: string;
265
+ projectId: string;
266
+ workDayId: string | null;
267
+ generatedAt: string;
268
+ items: PrioritySnapshotItem[];
269
+ metadata?: Record<string, unknown>;
270
+ }
271
+ export interface PriorityOverride {
272
+ id: string;
273
+ projectId: string;
274
+ model: string;
275
+ subjectId: string;
276
+ priority: number;
277
+ estimatedCredits: number | null;
278
+ metadata?: Record<string, unknown>;
279
+ createdAt: string;
280
+ updatedAt: string;
281
+ }
282
+ export interface TaskCreditLedgerEntry {
283
+ id: string;
284
+ projectId: string;
285
+ workDayId: string;
286
+ taskId: string | null;
287
+ phase: 'seed' | 'settle' | 'refund';
288
+ credits: number;
289
+ metadata?: Record<string, unknown>;
290
+ createdAt: string;
291
+ }
292
+ export interface ProjectWorkdaySummary {
293
+ id: string;
294
+ projectId: string;
295
+ environment: ProjectEnvironmentName | 'local';
296
+ workDayId: string;
297
+ kind: string;
298
+ state: string | null;
299
+ startedAt: string | null;
300
+ endedAt: string | null;
301
+ summary: Record<string, unknown>;
302
+ metadata?: Record<string, unknown>;
303
+ createdAt: string;
304
+ updatedAt: string;
305
+ }
306
+ export interface ScaleDecision {
307
+ id: string;
308
+ projectId: string;
309
+ environment: ProjectEnvironmentName | 'local';
310
+ poolName: string;
311
+ workDayId: string | null;
312
+ desiredWorkers: number;
313
+ observedQueueDepth: number;
314
+ observedActiveLeases: number;
315
+ reason: string;
316
+ metadata?: Record<string, unknown>;
317
+ createdAt: string;
318
+ }
319
+ export interface WorkerPoolScaleResult {
320
+ applied: boolean;
321
+ provider: string;
322
+ desiredWorkers: number;
323
+ metadata?: Record<string, unknown>;
324
+ }
325
+ export interface WorkerPoolScaler {
326
+ scale(decision: ScaleDecision): Promise<WorkerPoolScaleResult>;
327
+ }
328
+ export interface ProjectCapabilityGrant {
329
+ id: string;
330
+ projectId: string;
331
+ namespace: SdkDispatchNamespace;
332
+ operation: string;
333
+ executionClass: SdkDispatchExecutionClass;
334
+ allowedTargets: SdkDispatchTarget[];
335
+ defaultDispatchMode: SdkDispatchPolicy;
336
+ enabled: boolean;
337
+ createdAt: string;
338
+ updatedAt: string;
339
+ }
340
+ export interface RemoteJobError {
341
+ code?: string | null;
342
+ message: string;
343
+ }
344
+ export interface RemoteJob {
345
+ id: string;
346
+ projectId: string;
347
+ namespace: SdkDispatchNamespace;
348
+ operation: string;
349
+ status: RemoteJobStatus;
350
+ preferredMode: SdkDispatchPolicy;
351
+ selectedTarget: SdkDispatchTarget;
352
+ input: Record<string, unknown>;
353
+ output?: unknown;
354
+ error?: RemoteJobError | null;
355
+ requestedByType: RemoteJobRequestedByType;
356
+ requestedById: string | null;
357
+ assignedRunnerId: string | null;
358
+ idempotencyKey: string | null;
359
+ capability?: SdkDispatchCapability | null;
360
+ pollUrl?: string | null;
361
+ streamUrl?: string | null;
362
+ createdAt: string;
363
+ updatedAt: string;
364
+ startedAt: string | null;
365
+ finishedAt: string | null;
366
+ cancelledAt: string | null;
367
+ }
368
+ export interface RemoteJobEvent {
369
+ id: string;
370
+ jobId: string;
371
+ seq: number;
372
+ kind: string;
373
+ data?: Record<string, unknown>;
374
+ createdAt: string;
375
+ }
376
+ export interface SdkDispatchRequest {
377
+ namespace?: SdkDispatchNamespace;
378
+ operation: string;
379
+ input?: Record<string, unknown>;
380
+ preferredMode?: SdkDispatchPolicy;
381
+ idempotencyKey?: string;
382
+ }
383
+ export interface SdkDispatchInlineResult {
384
+ ok: true;
385
+ mode: 'inline';
386
+ namespace: SdkDispatchNamespace;
387
+ operation: string;
388
+ target: SdkDispatchTarget;
389
+ capability: SdkDispatchCapability;
390
+ payload: unknown;
391
+ }
392
+ export interface SdkDispatchJobResult {
393
+ ok: true;
394
+ mode: 'job';
395
+ namespace: SdkDispatchNamespace;
396
+ operation: string;
397
+ target: SdkDispatchTarget;
398
+ capability: SdkDispatchCapability;
399
+ job: RemoteJob;
400
+ }
401
+ export type SdkDispatchResult = SdkDispatchInlineResult | SdkDispatchJobResult;
402
+ export type SdkDispatchCredentialSource = {
403
+ type: 'bearer';
404
+ token: string;
405
+ } | {
406
+ type: 'resolver';
407
+ resolveToken: () => Promise<string | null> | string | null;
408
+ };
409
+ export interface SdkDispatchConfig {
410
+ projectId: string;
411
+ marketBaseUrl: string;
412
+ policy?: SdkDispatchPolicy;
413
+ credentialSource?: SdkDispatchCredentialSource;
414
+ fetchImpl?: typeof fetch;
415
+ }
12
416
  export type SdkFilterOperator = 'eq' | 'in' | 'contains' | 'prefix' | 'gt' | 'gte' | 'lt' | 'lte' | 'updated_since' | 'related_to';
13
417
  export type TreeseedSchemaVersion = number;
14
418
  export type TreeseedRuntimeRecordType = 'subscription' | 'contact_submission' | 'agent_run' | 'message' | 'agent_cursor' | 'content_lease' | 'work_day' | 'task' | 'task_event' | 'task_output' | 'graph_run' | 'report';
@@ -610,6 +1014,159 @@ export interface SdkStartWorkDayRequest {
610
1014
  summary?: Record<string, unknown> | null;
611
1015
  actor: string;
612
1016
  }
1017
+ export interface SdkUpsertWorkPolicyRequest {
1018
+ projectId: string;
1019
+ environment: ProjectEnvironmentName | 'local';
1020
+ schedule: WorkdaySchedule;
1021
+ dailyTaskCreditBudget: number;
1022
+ maxQueuedTasks: number;
1023
+ maxQueuedCredits: number;
1024
+ autoscale: AgentPoolAutoscalePolicy;
1025
+ creditWeights?: TaskCreditWeight[];
1026
+ metadata?: Record<string, unknown> | null;
1027
+ }
1028
+ export interface UpsertProjectHostingRequest {
1029
+ kind: TreeseedHostingKind;
1030
+ registration?: TreeseedHostingRegistration;
1031
+ marketBaseUrl?: string | null;
1032
+ sourceRepoOwner?: string | null;
1033
+ sourceRepoName?: string | null;
1034
+ sourceRepoUrl?: string | null;
1035
+ sourceRepoWorkflowPath?: string | null;
1036
+ projectApiBaseUrl?: string | null;
1037
+ executionOwner?: ProjectExecutionOwner | null;
1038
+ metadata?: Record<string, unknown> | null;
1039
+ }
1040
+ export interface UpsertProjectEnvironmentRequest {
1041
+ deploymentProfile?: TreeseedHostingKind;
1042
+ baseUrl?: string | null;
1043
+ cloudflareAccountId?: string | null;
1044
+ pagesProjectName?: string | null;
1045
+ workerName?: string | null;
1046
+ r2BucketName?: string | null;
1047
+ d1DatabaseName?: string | null;
1048
+ queueName?: string | null;
1049
+ railwayProjectName?: string | null;
1050
+ metadata?: Record<string, unknown> | null;
1051
+ }
1052
+ export interface UpsertProjectInfrastructureResourceRequest {
1053
+ id?: string;
1054
+ environment: ProjectEnvironmentName;
1055
+ provider: ProjectInfrastructureResourceProvider;
1056
+ resourceKind: ProjectInfrastructureResourceKind;
1057
+ logicalName: string;
1058
+ locator?: string | null;
1059
+ metadata?: Record<string, unknown> | null;
1060
+ }
1061
+ export interface CreateProjectDeploymentRequest {
1062
+ id?: string;
1063
+ environment: ProjectEnvironmentName;
1064
+ deploymentKind: ProjectDeploymentKind;
1065
+ status?: ProjectDeploymentStatus;
1066
+ sourceRef?: string | null;
1067
+ releaseTag?: string | null;
1068
+ commitSha?: string | null;
1069
+ triggeredByType?: string | null;
1070
+ triggeredById?: string | null;
1071
+ metadata?: Record<string, unknown> | null;
1072
+ startedAt?: string | null;
1073
+ finishedAt?: string | null;
1074
+ }
1075
+ export interface UpsertAgentPoolRequest {
1076
+ id?: string;
1077
+ teamId: string;
1078
+ environment: ProjectEnvironmentName;
1079
+ name: string;
1080
+ registrationIdentity?: string | null;
1081
+ serviceBaseUrl?: string | null;
1082
+ status?: AgentPoolStatus;
1083
+ autoscale?: Partial<AgentPoolAutoscalePolicy> | null;
1084
+ metadata?: Record<string, unknown> | null;
1085
+ }
1086
+ export interface RecordAgentPoolRegistrationRequest {
1087
+ poolId: string;
1088
+ id?: string;
1089
+ runnerId?: string | null;
1090
+ managerId?: string | null;
1091
+ serviceName?: string | null;
1092
+ heartbeatAt?: string | null;
1093
+ desiredWorkers?: number | null;
1094
+ observedQueueDepth?: number | null;
1095
+ observedActiveLeases?: number | null;
1096
+ metadata?: Record<string, unknown> | null;
1097
+ }
1098
+ export interface CatalogItemFilters {
1099
+ kind?: string;
1100
+ teamId?: string;
1101
+ slug?: string;
1102
+ }
1103
+ export interface UpsertCatalogItemRequest {
1104
+ id?: string;
1105
+ kind: string;
1106
+ slug: string;
1107
+ title: string;
1108
+ summary?: string | null;
1109
+ visibility?: CatalogItem['visibility'];
1110
+ listingEnabled?: boolean;
1111
+ offerMode?: CatalogItemOfferMode;
1112
+ manifestKey?: string | null;
1113
+ artifactKey?: string | null;
1114
+ searchText?: string | null;
1115
+ metadata?: Record<string, unknown> | null;
1116
+ }
1117
+ export interface UpsertCatalogArtifactVersionRequest {
1118
+ id?: string;
1119
+ kind: string;
1120
+ version: string;
1121
+ contentKey: string;
1122
+ manifestKey?: string | null;
1123
+ metadata?: Record<string, unknown> | null;
1124
+ publishedAt?: string | null;
1125
+ }
1126
+ export interface UpsertTeamStorageLocatorRequest {
1127
+ bucketName: string;
1128
+ manifestKeyTemplate: string;
1129
+ previewRootTemplate: string;
1130
+ publicBaseUrl?: string | null;
1131
+ metadata?: Record<string, unknown> | null;
1132
+ }
1133
+ export interface SdkPriorityOverrideRequest {
1134
+ id?: string;
1135
+ projectId: string;
1136
+ model: string;
1137
+ subjectId: string;
1138
+ priority: number;
1139
+ estimatedCredits?: number | null;
1140
+ metadata?: Record<string, unknown> | null;
1141
+ }
1142
+ export interface SdkCreatePrioritySnapshotRequest {
1143
+ id?: string;
1144
+ projectId: string;
1145
+ workDayId?: string | null;
1146
+ items: PrioritySnapshotItem[];
1147
+ metadata?: Record<string, unknown> | null;
1148
+ }
1149
+ export interface SdkRecordTaskCreditsRequest {
1150
+ id?: string;
1151
+ projectId: string;
1152
+ workDayId: string;
1153
+ taskId?: string | null;
1154
+ phase: 'seed' | 'settle' | 'refund';
1155
+ credits: number;
1156
+ metadata?: Record<string, unknown> | null;
1157
+ }
1158
+ export interface SdkRecordScaleDecisionRequest {
1159
+ id?: string;
1160
+ projectId: string;
1161
+ environment: ProjectEnvironmentName | 'local';
1162
+ poolName: string;
1163
+ workDayId?: string | null;
1164
+ desiredWorkers: number;
1165
+ observedQueueDepth: number;
1166
+ observedActiveLeases: number;
1167
+ reason: string;
1168
+ metadata?: Record<string, unknown> | null;
1169
+ }
613
1170
  export interface SdkCloseWorkDayRequest {
614
1171
  id: string;
615
1172
  state?: 'completed' | 'cancelled' | 'failed';
@@ -701,12 +1258,14 @@ export interface SdkManagerContextPayload {
701
1258
  agent: Record<string, unknown> | null;
702
1259
  graph: Record<string, unknown> | null;
703
1260
  }
704
- export interface SdkGatewayClientConfig {
705
- baseUrl: string;
706
- bearerToken: string;
1261
+ export interface SdkQueuePullClientConfig {
1262
+ accountId: string;
1263
+ queueId: string;
1264
+ token: string;
1265
+ apiBaseUrl?: string;
707
1266
  fetchImpl?: typeof fetch;
708
1267
  }
709
- export interface SdkQueuePullClientConfig {
1268
+ export interface SdkQueuePushClientConfig {
710
1269
  accountId: string;
711
1270
  queueId: string;
712
1271
  token: string;
@@ -738,6 +1297,10 @@ export interface SdkPulledQueueMessage {
738
1297
  export interface SdkQueuePullResult {
739
1298
  messages: SdkPulledQueueMessage[];
740
1299
  }
1300
+ export interface SdkQueuePushRequest {
1301
+ message: SdkQueueMessageEnvelope;
1302
+ delaySeconds?: number;
1303
+ }
741
1304
  export interface SdkFollowResult<TItem> {
742
1305
  items: TItem[];
743
1306
  since: string;
@@ -753,13 +1316,22 @@ export interface SdkTemplateCatalogPublisher {
753
1316
  name: string;
754
1317
  url?: string;
755
1318
  }
756
- export interface SdkTemplateCatalogSource {
1319
+ export interface SdkTemplateCatalogGitSource {
757
1320
  kind: 'git';
758
1321
  repoUrl: string;
759
1322
  directory: string;
760
1323
  ref: string;
761
1324
  integrity?: string;
762
1325
  }
1326
+ export interface SdkTemplateCatalogR2Source {
1327
+ kind: 'r2';
1328
+ bucket?: string;
1329
+ objectKey: string;
1330
+ version: string;
1331
+ publicUrl?: string;
1332
+ integrity?: string;
1333
+ }
1334
+ export type SdkTemplateCatalogSource = SdkTemplateCatalogGitSource | SdkTemplateCatalogR2Source;
763
1335
  export interface SdkTemplateCatalogEntry {
764
1336
  id: string;
765
1337
  displayName: string;
@@ -777,13 +1349,13 @@ export interface SdkTemplateCatalogEntry {
777
1349
  minCliVersion: string;
778
1350
  minCoreVersion?: string;
779
1351
  fulfillment: {
780
- mode?: 'packaged' | 'git';
1352
+ mode?: 'packaged' | 'git' | 'r2';
781
1353
  source: SdkTemplateCatalogSource;
782
1354
  hooksPolicy: 'builtin_only' | 'trusted_only' | 'disabled';
783
1355
  supportsReconcile: boolean;
784
1356
  };
785
1357
  offer?: {
786
- priceModel?: 'free' | 'paid' | 'contact';
1358
+ priceModel?: 'free' | 'paid' | 'contact' | 'one_time_current_version' | 'subscription_updates' | 'private';
787
1359
  license?: string;
788
1360
  support?: string;
789
1361
  };
package/dist/sdk-types.js CHANGED
@@ -22,9 +22,61 @@ const SDK_MODEL_NAMES = [
22
22
  const SDK_OPERATIONS = ["get", "read", "search", "follow", "pick", "create", "update"];
23
23
  const SDK_STORAGE_BACKENDS = ["content", "d1"];
24
24
  const SDK_PICK_STRATEGIES = ["latest", "highest_priority", "oldest"];
25
+ const SDK_DISPATCH_EXECUTION_CLASSES = ["local_only", "remote_inline", "remote_job"];
26
+ const SDK_DISPATCH_TARGETS = ["local", "project_api", "project_runner", "market_catalog"];
27
+ const SDK_DISPATCH_POLICIES = ["auto", "prefer_local", "prefer_remote", "remote_only"];
28
+ const SDK_DISPATCH_NAMESPACES = ["sdk", "workflow"];
29
+ const TREESEED_HOSTING_KINDS = ["market_control_plane", "hosted_project", "self_hosted_project"];
30
+ const TREESEED_HOSTING_REGISTRATIONS = ["optional", "none"];
31
+ const PROJECT_CONNECTION_MODES = ["hosted", "self_hosted", "hybrid"];
32
+ const PROJECT_RUNNER_REGISTRATION_STATES = ["pending", "registered", "offline"];
33
+ const PROJECT_EXECUTION_OWNERS = ["project_api", "project_runner", "market"];
34
+ const REMOTE_JOB_STATUSES = ["pending", "claimed", "running", "completed", "failed", "cancelled"];
35
+ const PROJECT_ENVIRONMENT_NAMES = ["local", "staging", "prod"];
36
+ const PROJECT_DEPLOYMENT_KINDS = ["provision", "code", "content", "mixed"];
37
+ const PROJECT_DEPLOYMENT_STATUSES = ["pending", "running", "succeeded", "failed", "cancelled"];
38
+ const PROJECT_INFRA_RESOURCE_PROVIDERS = ["cloudflare", "railway", "github", "market"];
39
+ const PROJECT_INFRA_RESOURCE_KINDS = [
40
+ "pages",
41
+ "worker",
42
+ "r2",
43
+ "d1",
44
+ "queue",
45
+ "dlq",
46
+ "railway_project",
47
+ "railway_service",
48
+ "railway_schedule"
49
+ ];
50
+ const AGENT_POOL_STATUSES = ["pending", "active", "degraded", "offline"];
51
+ function projectConnectionModeFromHosting(kind, registration = "none") {
52
+ if (kind === "hosted_project") {
53
+ return "hosted";
54
+ }
55
+ if (kind === "self_hosted_project") {
56
+ return registration === "optional" ? "hybrid" : "self_hosted";
57
+ }
58
+ return "hosted";
59
+ }
25
60
  export {
61
+ AGENT_POOL_STATUSES,
62
+ PROJECT_CONNECTION_MODES,
63
+ PROJECT_DEPLOYMENT_KINDS,
64
+ PROJECT_DEPLOYMENT_STATUSES,
65
+ PROJECT_ENVIRONMENT_NAMES,
66
+ PROJECT_EXECUTION_OWNERS,
67
+ PROJECT_INFRA_RESOURCE_KINDS,
68
+ PROJECT_INFRA_RESOURCE_PROVIDERS,
69
+ PROJECT_RUNNER_REGISTRATION_STATES,
70
+ REMOTE_JOB_STATUSES,
71
+ SDK_DISPATCH_EXECUTION_CLASSES,
72
+ SDK_DISPATCH_NAMESPACES,
73
+ SDK_DISPATCH_POLICIES,
74
+ SDK_DISPATCH_TARGETS,
26
75
  SDK_MODEL_NAMES,
27
76
  SDK_OPERATIONS,
28
77
  SDK_PICK_STRATEGIES,
29
- SDK_STORAGE_BACKENDS
78
+ SDK_STORAGE_BACKENDS,
79
+ TREESEED_HOSTING_KINDS,
80
+ TREESEED_HOSTING_REGISTRATIONS,
81
+ projectConnectionModeFromHosting
30
82
  };