@treeseed/sdk 0.10.11 → 0.10.13

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 (52) hide show
  1. package/README.md +2 -2
  2. package/dist/api/auth/d1-store.js +20 -1
  3. package/dist/capacity-provider.d.ts +53 -1
  4. package/dist/capacity.d.ts +80 -1
  5. package/dist/capacity.js +687 -8
  6. package/dist/db/d1.d.ts +109 -3227
  7. package/dist/db/index.d.ts +1 -0
  8. package/dist/db/index.js +1 -0
  9. package/dist/db/market-schema.d.ts +43769 -0
  10. package/dist/db/market-schema.js +1878 -0
  11. package/dist/db/node-sqlite.d.ts +109 -3227
  12. package/dist/db/schema.d.ts +226 -5757
  13. package/dist/db/schema.js +35 -226
  14. package/dist/index.d.ts +6 -4
  15. package/dist/index.js +32 -0
  16. package/dist/market-client.d.ts +135 -0
  17. package/dist/market-client.js +134 -1
  18. package/dist/operations/services/commit-message-provider.js +1 -1
  19. package/dist/operations/services/d1-migration.js +0 -59
  20. package/dist/operations/services/deploy.js +5 -1
  21. package/dist/operations/services/github-api.d.ts +83 -0
  22. package/dist/operations/services/github-api.js +167 -0
  23. package/dist/operations/services/local-dev.js +3 -3
  24. package/dist/operations/services/mailpit-runtime.d.ts +13 -2
  25. package/dist/operations/services/mailpit-runtime.js +19 -14
  26. package/dist/operations/services/project-web-monitor.d.ts +15 -0
  27. package/dist/operations/services/project-web-monitor.js +260 -0
  28. package/dist/operations/services/railway-api.js +2 -2
  29. package/dist/operations/services/release-candidate.js +9 -9
  30. package/dist/operations/services/runtime-paths.d.ts +1 -1
  31. package/dist/operations/services/runtime-paths.js +2 -2
  32. package/dist/operations/services/template-registry.js +10 -1
  33. package/dist/operations.d.ts +1 -0
  34. package/dist/operations.js +11 -1
  35. package/dist/platform-operation-store.d.ts +4 -0
  36. package/dist/platform-operation-store.js +29 -3
  37. package/dist/platform-operations.d.ts +8 -0
  38. package/dist/platform-operations.js +19 -0
  39. package/dist/remote.js +6 -6
  40. package/dist/scripts/tenant-d1-migrate-local.js +2 -3
  41. package/dist/scripts/test-cloudflare-local.js +1 -1
  42. package/dist/scripts/workspace-command-e2e.js +3 -1
  43. package/dist/sdk-types.d.ts +281 -3
  44. package/dist/sdk-types.js +5 -1
  45. package/dist/seeds/normalize.js +6 -0
  46. package/dist/seeds/schema.js +61 -1
  47. package/dist/seeds/types.d.ts +32 -0
  48. package/drizzle/d1/0000_treeseed_d1.sql +37 -0
  49. package/drizzle/market/0000_market_control_plane.sql +2929 -0
  50. package/drizzle/market/0001_capacity_budget_mode_default.sql +4 -0
  51. package/drizzle/market/0002_user_email_addresses.sql +26 -0
  52. package/package.json +8 -1
@@ -386,7 +386,9 @@ function resolveRepositorySlug(repoDir) {
386
386
  return parseGitHubRepositoryFromRemote(remote);
387
387
  }
388
388
  function isProductionLikeTarget(repository, siteUrl) {
389
- return repository === 'karyon-life/karyon' || /karyon\.life/i.test(siteUrl ?? '');
389
+ const productionRepositories = new Set(['knowledge-coop/market', 'treeseed-ai/market']);
390
+ const normalizedSiteUrl = String(siteUrl ?? '').replace(/\/+$/u, '').toLowerCase();
391
+ return productionRepositories.has(repository) || ['https://treeseed.ai', 'https://www.treeseed.ai'].includes(normalizedSiteUrl);
390
392
  }
391
393
  async function waitForGitHubWorkflow(repository, headSha, { timeoutMs = 900000 } = {}) {
392
394
  const startedAt = Date.now();
@@ -15,7 +15,9 @@ export declare const PROJECT_EXECUTION_OWNERS: readonly ["project_api", "project
15
15
  export declare const REMOTE_JOB_STATUSES: readonly ["pending", "claimed", "running", "completed", "failed", "cancelled"];
16
16
  export declare const PROJECT_ENVIRONMENT_NAMES: readonly ["local", "staging", "prod"];
17
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"];
18
+ export declare const PROJECT_WEB_DEPLOYMENT_ACTIONS: readonly ["deploy_web", "publish_content", "monitor"];
19
+ export declare const PROJECT_DEPLOYMENT_ENVIRONMENTS: readonly ["staging", "prod"];
20
+ export declare const PROJECT_DEPLOYMENT_STATUSES: readonly ["pending", "queued", "claimed", "dispatching", "running", "monitoring", "succeeded", "failed", "cancelled", "timed_out"];
19
21
  export declare const PROJECT_INFRA_RESOURCE_PROVIDERS: readonly ["cloudflare", "railway", "github", "market"];
20
22
  export declare const PROJECT_INFRA_RESOURCE_KINDS: readonly ["pages", "worker", "r2", "d1", "queue", "dlq", "railway_project", "railway_service", "railway_schedule"];
21
23
  export declare const AGENT_POOL_STATUSES: readonly ["pending", "active", "degraded", "offline"];
@@ -37,7 +39,12 @@ export type ProjectExecutionOwner = (typeof PROJECT_EXECUTION_OWNERS)[number];
37
39
  export type RemoteJobStatus = (typeof REMOTE_JOB_STATUSES)[number];
38
40
  export type ProjectEnvironmentName = (typeof PROJECT_ENVIRONMENT_NAMES)[number];
39
41
  export type ProjectDeploymentKind = (typeof PROJECT_DEPLOYMENT_KINDS)[number];
42
+ export type ProjectWebDeploymentAction = (typeof PROJECT_WEB_DEPLOYMENT_ACTIONS)[number];
43
+ export type ProjectDeploymentEnvironment = (typeof PROJECT_DEPLOYMENT_ENVIRONMENTS)[number];
40
44
  export type ProjectDeploymentStatus = (typeof PROJECT_DEPLOYMENT_STATUSES)[number];
45
+ export type ProjectWebMonitorStatus = 'healthy' | 'degraded' | 'failed' | 'unknown';
46
+ export type ProjectWebMonitorCheckStatus = 'passed' | 'warning' | 'failed' | 'skipped';
47
+ export type ProjectWebMonitorCheckSource = 'market' | 'github' | 'cloudflare' | 'http' | 'sdk';
41
48
  export type ProjectInfrastructureResourceProvider = (typeof PROJECT_INFRA_RESOURCE_PROVIDERS)[number];
42
49
  export type ProjectInfrastructureResourceKind = (typeof PROJECT_INFRA_RESOURCE_KINDS)[number];
43
50
  export type AgentPoolStatus = (typeof AGENT_POOL_STATUSES)[number];
@@ -194,20 +201,108 @@ export interface ProjectInfrastructureResource {
194
201
  }
195
202
  export interface ProjectDeployment {
196
203
  id: string;
204
+ teamId: string | null;
197
205
  projectId: string;
198
206
  environment: ProjectEnvironmentName;
199
207
  deploymentKind: ProjectDeploymentKind;
208
+ action: ProjectWebDeploymentAction | string;
200
209
  status: ProjectDeploymentStatus;
210
+ platformOperationId: string | null;
211
+ retryOfDeploymentId: string | null;
212
+ resumedFromDeploymentId: string | null;
213
+ idempotencyKey: string | null;
214
+ requestedByUserId: string | null;
201
215
  sourceRef: string | null;
202
216
  releaseTag: string | null;
203
217
  commitSha: string | null;
204
218
  triggeredByType: string | null;
205
219
  triggeredById: string | null;
220
+ repository?: Record<string, unknown>;
221
+ externalWorkflow?: Record<string, unknown>;
222
+ target?: Record<string, unknown>;
223
+ monitor?: Record<string, unknown>;
224
+ summary: string | null;
225
+ error?: Record<string, unknown>;
206
226
  metadata?: Record<string, unknown>;
207
227
  startedAt: string | null;
208
228
  finishedAt: string | null;
209
229
  createdAt: string;
210
230
  updatedAt: string;
231
+ completedAt: string | null;
232
+ }
233
+ export interface ProjectWebMonitorCheck {
234
+ key: string;
235
+ label: string;
236
+ status: ProjectWebMonitorCheckStatus;
237
+ summary: string;
238
+ source: ProjectWebMonitorCheckSource;
239
+ url?: string;
240
+ inspectCommand?: string;
241
+ }
242
+ export interface ProjectWebMonitorResult {
243
+ environment: ProjectDeploymentEnvironment;
244
+ status: ProjectWebMonitorStatus;
245
+ checkedAt: string;
246
+ checks: ProjectWebMonitorCheck[];
247
+ urls: string[];
248
+ warnings: string[];
249
+ }
250
+ export interface ProjectDeploymentEvent {
251
+ id: string;
252
+ deploymentId: string;
253
+ projectId: string;
254
+ teamId: string;
255
+ operationId: string | null;
256
+ kind: string;
257
+ message: string;
258
+ status: string | null;
259
+ severity: string;
260
+ sequence: number;
261
+ payload?: Record<string, unknown>;
262
+ createdAt: string;
263
+ }
264
+ export interface ProjectDeploymentActionAvailability {
265
+ environment: ProjectDeploymentEnvironment;
266
+ action: ProjectWebDeploymentAction;
267
+ available: boolean;
268
+ blockedBy: Array<{
269
+ code: string;
270
+ message: string;
271
+ href?: string;
272
+ }>;
273
+ }
274
+ export interface ProjectDeploymentReadiness {
275
+ ready: boolean;
276
+ blockers: Array<{
277
+ code: string;
278
+ message: string;
279
+ href?: string;
280
+ }>;
281
+ checks: Array<{
282
+ code: string;
283
+ label: string;
284
+ ready: boolean;
285
+ message: string;
286
+ href?: string;
287
+ }>;
288
+ }
289
+ export interface CreateProjectWebDeploymentRequest {
290
+ environment: ProjectDeploymentEnvironment;
291
+ action: ProjectWebDeploymentAction;
292
+ source?: 'market_ui' | 'market_api' | 'cli' | 'launch_flow';
293
+ reason?: string;
294
+ idempotencyKey?: string;
295
+ previewId?: string | null;
296
+ dryRun?: boolean;
297
+ confirmProduction?: boolean;
298
+ }
299
+ export interface CreateProjectWebDeploymentResponse {
300
+ ok: true;
301
+ deployment: ProjectDeployment;
302
+ operation: Record<string, unknown>;
303
+ pollUrl: string;
304
+ eventsUrl: string;
305
+ stateUrl: string;
211
306
  }
212
307
  export interface AgentPoolAutoscalePolicy {
213
308
  minWorkers: number;
@@ -641,6 +736,7 @@ export interface CapacityProvider {
641
736
  billingScope: CapacityProviderBillingScope;
642
737
  monthlyCreditBudget: number;
643
738
  dailyCreditBudget: number;
739
+ creditBudgetMode?: 'static' | 'hybrid' | 'derived' | string;
644
740
  maxConcurrentWorkdays: number;
645
741
  maxConcurrentWorkers: number;
646
742
  capacityModel: Record<string, unknown>;
@@ -656,6 +752,53 @@ export interface CapacityProvider {
656
752
  createdAt: string;
657
753
  updatedAt: string;
658
754
  }
755
+ export interface ExecutionProviderNativeLimit {
756
+ id: string;
757
+ executionProviderId: string;
758
+ scope: string;
759
+ nativeUnit: string;
760
+ limitAmount: number;
761
+ reserveBufferPercent: number;
762
+ resetCadence: string | null;
763
+ resetAt: string | null;
764
+ confidence: string;
765
+ source: string;
766
+ metadata?: Record<string, unknown>;
767
+ createdAt: string;
768
+ updatedAt: string;
769
+ }
770
+ export interface ExecutionProviderObservation {
771
+ id: string;
772
+ executionProviderId: string;
773
+ observedAt: string;
774
+ health: string;
775
+ activeWorkers: number | null;
776
+ queuedTasks: number | null;
777
+ throttleState: string | null;
778
+ nativeRemaining: Record<string, unknown>;
779
+ resetAt: string | null;
780
+ confidence: string;
781
+ metadata?: Record<string, unknown>;
782
+ createdAt: string;
783
+ }
784
+ export interface ExecutionProvider {
785
+ id: string;
786
+ teamId: string;
787
+ capacityProviderId: string | null;
788
+ name: string;
789
+ kind: string;
790
+ status: string;
791
+ nativeUnit: string;
792
+ quotaVisibility: string;
793
+ maxConcurrentWorkers: number;
794
+ resetCadence: string | null;
795
+ config: Record<string, unknown>;
796
+ metadata?: Record<string, unknown>;
797
+ nativeLimits?: ExecutionProviderNativeLimit[];
798
+ latestObservation?: ExecutionProviderObservation | null;
799
+ createdAt: string;
800
+ updatedAt: string;
801
+ }
659
802
  export interface CapacityProviderHost {
660
803
  id: string;
661
804
  capacityProviderId: string;
@@ -697,6 +840,10 @@ export interface CapacityGrant {
697
840
  dailyUsdLimit: number | null;
698
841
  weeklyQuotaMinutes: number | null;
699
842
  monthlyProviderUnits: number | null;
843
+ portfolioAllocationPercent?: number | null;
844
+ reservePoolPercent?: number | null;
845
+ maxDailyProjectCredits?: number | null;
846
+ emergencyOverride?: boolean;
700
847
  priorityWeight: number;
701
848
  overflowPolicy: CapacityOverflowPolicy;
702
849
  metadata?: Record<string, unknown>;
@@ -706,6 +853,7 @@ export interface CapacityGrant {
706
853
  export interface CapacityReservation {
707
854
  id: string;
708
855
  capacityProviderId: string;
856
+ executionProviderId?: string | null;
709
857
  laneId: string;
710
858
  teamId: string;
711
859
  projectId: string;
@@ -714,6 +862,9 @@ export interface CapacityReservation {
714
862
  state: CapacityReservationState;
715
863
  reservedCredits: number;
716
864
  consumedCredits: number;
865
+ nativeUnit?: string | null;
866
+ reservedNativeAmount?: number | null;
867
+ consumedNativeAmount?: number | null;
717
868
  reservedProviderUnits: number | null;
718
869
  consumedProviderUnits: number | null;
719
870
  reservedUsd: number | null;
@@ -784,6 +935,7 @@ export interface TaskUsageActual {
784
935
  taskSignature: string;
785
936
  executionProfileId: string;
786
937
  capacityProviderId: string | null;
938
+ executionProviderId?: string | null;
787
939
  laneId: string | null;
788
940
  businessModel: CapacityBusinessModel | string;
789
941
  modelName: string | null;
@@ -800,9 +952,106 @@ export interface TaskUsageActual {
800
952
  retryCount: number | null;
801
953
  actualCredits: number;
802
954
  actualUsd: number | null;
955
+ creditFormulaVersion?: string | null;
956
+ actualCreditSource?: string | null;
957
+ nativeUsage?: NativeUsageObservation | Record<string, unknown> | null;
803
958
  metadata?: Record<string, unknown>;
804
959
  createdAt: string;
805
960
  }
961
+ export interface NativeUsageObservation {
962
+ nativeUnit?: string | null;
963
+ amount?: number | null;
964
+ wallMinutes?: number | null;
965
+ quotaMinutes?: number | null;
966
+ inputTokens?: number | null;
967
+ outputTokens?: number | null;
968
+ cachedInputTokens?: number | null;
969
+ usd?: number | null;
970
+ filesOpened?: number | null;
971
+ filesChanged?: number | null;
972
+ diffLinesAdded?: number | null;
973
+ diffLinesRemoved?: number | null;
974
+ testRuns?: number | null;
975
+ retryCount?: number | null;
976
+ partial?: boolean | null;
977
+ interrupted?: boolean | null;
978
+ source?: string | null;
979
+ observedAt?: string | null;
980
+ metadata?: Record<string, unknown> | null;
981
+ [key: string]: unknown;
982
+ }
983
+ export interface CreditConversionProfile {
984
+ id?: string | null;
985
+ taskSignature: string;
986
+ executionProfileId: string;
987
+ executionProviderKind: string;
988
+ nativeUnit: string;
989
+ sampleCount: number;
990
+ completedSampleCount: number;
991
+ interruptedSampleCount?: number;
992
+ nativeUnitsPerCreditP50: number | null;
993
+ nativeUnitsPerCreditP90: number | null;
994
+ creditsPerNativeUnitP50: number | null;
995
+ creditsPerNativeUnitP90: number | null;
996
+ actualCreditsP50: number | null;
997
+ actualCreditsP90: number | null;
998
+ confidence: 'low' | 'medium' | 'high' | string;
999
+ formulaVersion: string;
1000
+ metadata?: Record<string, unknown>;
1001
+ createdAt?: string | null;
1002
+ updatedAt: string;
1003
+ }
1004
+ export interface DerivedCapacityAvailability {
1005
+ executionProviderId: string;
1006
+ capacityProviderId: string | null;
1007
+ executionProviderKind: string;
1008
+ nativeUnit: string;
1009
+ scope: string | null;
1010
+ configuredNativeLimit: number | null;
1011
+ observedNativeRemaining: number | null;
1012
+ nativeRemainingSource: 'observation' | 'configured_limit' | 'unknown';
1013
+ activeReservedNativeAmount: number;
1014
+ activeConsumedNativeAmount: number;
1015
+ reserveBufferPercent: number;
1016
+ reserveBufferNativeAmount: number;
1017
+ availableNativeAmount: number;
1018
+ nativeUnitsPerCredit: number | null;
1019
+ conversionProfileId?: string | null;
1020
+ conversionTaskSignature?: string | null;
1021
+ conversionConfidence?: string | null;
1022
+ derivedAvailableCredits: number | null;
1023
+ confidence: 'low' | 'medium' | 'high' | string;
1024
+ resetAt?: string | null;
1025
+ reasons: string[];
1026
+ metadata?: Record<string, unknown>;
1027
+ }
1028
+ export interface DerivedCapacitySummary {
1029
+ entries: DerivedCapacityAvailability[];
1030
+ totalDerivedAvailableCredits?: number | null;
1031
+ derivedEntryCount?: number;
1032
+ learningEntryCount?: number;
1033
+ availableNativeByUnit?: Record<string, number>;
1034
+ providers?: Array<{
1035
+ capacityProviderId: string;
1036
+ entries?: DerivedCapacityAvailability[];
1037
+ totalDerivedAvailableCredits?: number | null;
1038
+ derivedEntryCount?: number;
1039
+ learningEntryCount?: number;
1040
+ availableNativeByUnit?: Record<string, number>;
1041
+ [key: string]: unknown;
1042
+ }>;
1043
+ [key: string]: unknown;
1044
+ }
1045
+ export interface DerivedCapacityInput {
1046
+ executionProvider: ExecutionProvider;
1047
+ nativeLimit?: ExecutionProviderNativeLimit | null;
1048
+ latestObservation?: ExecutionProviderObservation | null;
1049
+ activeReservations?: CapacityReservation[];
1050
+ conversionProfile?: CreditConversionProfile | null;
1051
+ scope?: string | null;
1052
+ nativeUnit?: string | null;
1053
+ now?: Date | string | null;
1054
+ }
806
1055
  export interface TaskEstimateProfile {
807
1056
  taskSignature: string;
808
1057
  executionProfileId: string;
@@ -901,6 +1150,7 @@ export interface CapacityPlan {
901
1150
  grants: CapacityGrant[];
902
1151
  activeReservations: CapacityReservation[];
903
1152
  estimateProfiles: TaskEstimateProfile[];
1153
+ derivedCapacity?: DerivedCapacitySummary | null;
904
1154
  remaining: {
905
1155
  dailyCredits: number | null;
906
1156
  weeklyCredits: number | null;
@@ -1754,14 +2004,27 @@ export interface CreateProjectDeploymentRequest {
1754
2004
  environment: ProjectEnvironmentName;
1755
2005
  deploymentKind: ProjectDeploymentKind;
1756
2006
  status?: ProjectDeploymentStatus;
2007
+ action?: ProjectWebDeploymentAction | string;
2008
+ platformOperationId?: string | null;
2009
+ retryOfDeploymentId?: string | null;
2010
+ resumedFromDeploymentId?: string | null;
2011
+ idempotencyKey?: string | null;
2012
+ requestedByUserId?: string | null;
1757
2013
  sourceRef?: string | null;
1758
2014
  releaseTag?: string | null;
1759
2015
  commitSha?: string | null;
1760
2016
  triggeredByType?: string | null;
1761
2017
  triggeredById?: string | null;
2018
+ repository?: Record<string, unknown> | null;
2019
+ externalWorkflow?: Record<string, unknown> | null;
2020
+ target?: Record<string, unknown> | null;
2021
+ monitor?: Record<string, unknown> | null;
2022
+ summary?: string | null;
2023
+ error?: Record<string, unknown> | null;
1762
2024
  metadata?: Record<string, unknown> | null;
1763
2025
  startedAt?: string | null;
1764
2026
  finishedAt?: string | null;
2027
+ completedAt?: string | null;
1765
2028
  }
1766
2029
  export interface UpsertAgentPoolRequest {
1767
2030
  id?: string;
@@ -1921,6 +2184,10 @@ export interface UpsertCapacityGrantRequest {
1921
2184
  dailyUsdLimit?: number | null;
1922
2185
  weeklyQuotaMinutes?: number | null;
1923
2186
  monthlyProviderUnits?: number | null;
2187
+ portfolioAllocationPercent?: number | null;
2188
+ reservePoolPercent?: number | null;
2189
+ maxDailyProjectCredits?: number | null;
2190
+ emergencyOverride?: boolean;
1924
2191
  priorityWeight?: number;
1925
2192
  overflowPolicy?: CapacityOverflowPolicy;
1926
2193
  metadata?: Record<string, unknown> | null;
@@ -1928,6 +2195,7 @@ export interface UpsertCapacityGrantRequest {
1928
2195
  export interface CreateCapacityReservationRequest {
1929
2196
  id?: string;
1930
2197
  capacityProviderId: string;
2198
+ executionProviderId?: string | null;
1931
2199
  laneId: string;
1932
2200
  teamId: string;
1933
2201
  projectId: string;
@@ -1935,6 +2203,9 @@ export interface CreateCapacityReservationRequest {
1935
2203
  taskId?: string | null;
1936
2204
  state?: CapacityReservationState;
1937
2205
  reservedCredits: number;
2206
+ nativeUnit?: string | null;
2207
+ reservedNativeAmount?: number | null;
2208
+ consumedNativeAmount?: number | null;
1938
2209
  reservedProviderUnits?: number | null;
1939
2210
  reservedUsd?: number | null;
1940
2211
  expiresAt?: string | null;
@@ -1951,6 +2222,8 @@ export interface RecordCapacityUsageRequest {
1951
2222
  taskId?: string | null;
1952
2223
  phase?: TaskCreditLedgerEntry['phase'];
1953
2224
  credits: number;
2225
+ nativeUnit?: string | null;
2226
+ nativeAmount?: number | null;
1954
2227
  providerUnits?: number | null;
1955
2228
  usd?: number | null;
1956
2229
  source?: string;
@@ -1999,8 +2272,9 @@ export interface CreateTaskUsageActualRequest {
1999
2272
  taskSignature: string;
2000
2273
  executionProfileId?: string | null;
2001
2274
  capacityProviderId?: string | null;
2275
+ executionProviderId?: string | null;
2002
2276
  laneId?: string | null;
2003
- businessModel: CapacityBusinessModel | string;
2277
+ businessModel?: CapacityBusinessModel | string;
2004
2278
  modelName?: string | null;
2005
2279
  inputTokens?: number | null;
2006
2280
  outputTokens?: number | null;
@@ -2013,8 +2287,12 @@ export interface CreateTaskUsageActualRequest {
2013
2287
  diffLinesRemoved?: number | null;
2014
2288
  testRuns?: number | null;
2015
2289
  retryCount?: number | null;
2016
- actualCredits: number;
2290
+ actualCredits?: number | null;
2017
2291
  actualUsd?: number | null;
2292
+ creditFormulaVersion?: string | null;
2293
+ actualCreditSource?: string | null;
2294
+ actualCreditsOverride?: boolean | null;
2295
+ nativeUsage?: NativeUsageObservation | Record<string, unknown> | null;
2018
2296
  metadata?: Record<string, unknown> | null;
2019
2297
  }
2020
2298
  export interface CreateApprovalRequestRequest {
package/dist/sdk-types.js CHANGED
@@ -41,7 +41,9 @@ const PROJECT_EXECUTION_OWNERS = ["project_api", "project_runner", "market"];
41
41
  const REMOTE_JOB_STATUSES = ["pending", "claimed", "running", "completed", "failed", "cancelled"];
42
42
  const PROJECT_ENVIRONMENT_NAMES = ["local", "staging", "prod"];
43
43
  const PROJECT_DEPLOYMENT_KINDS = ["provision", "code", "content", "mixed"];
44
- const PROJECT_DEPLOYMENT_STATUSES = ["pending", "running", "succeeded", "failed", "cancelled"];
44
+ const PROJECT_WEB_DEPLOYMENT_ACTIONS = ["deploy_web", "publish_content", "monitor"];
45
+ const PROJECT_DEPLOYMENT_ENVIRONMENTS = ["staging", "prod"];
46
+ const PROJECT_DEPLOYMENT_STATUSES = ["pending", "queued", "claimed", "dispatching", "running", "monitoring", "succeeded", "failed", "cancelled", "timed_out"];
45
47
  const PROJECT_INFRA_RESOURCE_PROVIDERS = ["cloudflare", "railway", "github", "market"];
46
48
  const PROJECT_INFRA_RESOURCE_KINDS = [
47
49
  "pages",
@@ -67,6 +69,7 @@ function projectConnectionModeFromHosting(kind, registration = "none") {
67
69
  export {
68
70
  AGENT_POOL_STATUSES,
69
71
  PROJECT_CONNECTION_MODES,
72
+ PROJECT_DEPLOYMENT_ENVIRONMENTS,
70
73
  PROJECT_DEPLOYMENT_KINDS,
71
74
  PROJECT_DEPLOYMENT_STATUSES,
72
75
  PROJECT_ENVIRONMENT_NAMES,
@@ -74,6 +77,7 @@ export {
74
77
  PROJECT_INFRA_RESOURCE_KINDS,
75
78
  PROJECT_INFRA_RESOURCE_PROVIDERS,
76
79
  PROJECT_RUNNER_REGISTRATION_STATES,
80
+ PROJECT_WEB_DEPLOYMENT_ACTIONS,
77
81
  REMOTE_JOB_STATUSES,
78
82
  SDK_DISPATCH_EXECUTION_CLASSES,
79
83
  SDK_DISPATCH_NAMESPACES,
@@ -124,12 +124,14 @@ function normalizeSeedResources(manifest, selected) {
124
124
  kind: provider.kind ?? null,
125
125
  provider: provider.provider,
126
126
  billingScope: provider.billingScope ?? null,
127
+ creditBudgetMode: provider.creditBudgetMode ?? "derived",
127
128
  monthlyCreditBudget: provider.monthlyCreditBudget ?? null,
128
129
  dailyCreditBudget: provider.dailyCreditBudget ?? null,
129
130
  maxConcurrentWorkdays: provider.maxConcurrentWorkdays ?? null,
130
131
  maxConcurrentWorkers: provider.maxConcurrentWorkers ?? null,
131
132
  capacityModel: provider.capacityModel ?? null,
132
133
  registration: provider.registration ?? null,
134
+ executionProviders: provider.executionProviders ?? [],
133
135
  metadata: withMetadata(manifest, provider.key, provider.metadata)
134
136
  }
135
137
  });
@@ -175,6 +177,10 @@ function normalizeSeedResources(manifest, selected) {
175
177
  dailyUsdLimit: grant.dailyUsdLimit ?? null,
176
178
  weeklyQuotaMinutes: grant.weeklyQuotaMinutes ?? null,
177
179
  monthlyProviderUnits: grant.monthlyProviderUnits ?? null,
180
+ portfolioAllocationPercent: grant.portfolioAllocationPercent ?? null,
181
+ reservePoolPercent: grant.reservePoolPercent ?? null,
182
+ maxDailyProjectCredits: grant.maxDailyProjectCredits ?? null,
183
+ emergencyOverride: grant.emergencyOverride ?? null,
178
184
  priorityWeight: grant.priorityWeight ?? null,
179
185
  overflowPolicy: grant.overflowPolicy ?? null,
180
186
  state: grant.state ?? null,
@@ -58,6 +58,14 @@ function numberField(record, field, path, diagnostics) {
58
58
  }
59
59
  return value;
60
60
  }
61
+ function nonNegativeNumberField(record, field, path, diagnostics) {
62
+ const value = numberField(record, field, path, diagnostics);
63
+ if (value !== void 0 && value < 0) {
64
+ diagnostics.push(errorDiagnostic("seed.invalid_number", `Expected ${field} to be non-negative.`, `${path}.${field}`));
65
+ return void 0;
66
+ }
67
+ return value;
68
+ }
61
69
  function objectField(record, field, path, diagnostics) {
62
70
  const value = record[field];
63
71
  if (value === void 0) return void 0;
@@ -276,6 +284,50 @@ function parseProviderRegistration(value, path, diagnostics) {
276
284
  }
277
285
  };
278
286
  }
287
+ function parseNativeLimit(value, path, diagnostics) {
288
+ if (!isRecord(value)) {
289
+ diagnostics.push(errorDiagnostic("seed.invalid_resource", "Expected native limit to be an object.", path));
290
+ return null;
291
+ }
292
+ const limitAmount = nonNegativeNumberField(value, "limitAmount", path, diagnostics);
293
+ if (limitAmount === void 0) {
294
+ diagnostics.push(errorDiagnostic("seed.missing_field", "Missing required field: limitAmount.", `${path}.limitAmount`));
295
+ }
296
+ return {
297
+ id: asString(value.id) || void 0,
298
+ scope: asString(value.scope) || void 0,
299
+ limitScope: asString(value.limitScope) || void 0,
300
+ nativeUnit: asString(value.nativeUnit) || void 0,
301
+ limitAmount: limitAmount ?? 0,
302
+ reserveBufferPercent: nonNegativeNumberField(value, "reserveBufferPercent", path, diagnostics),
303
+ resetCadence: asString(value.resetCadence) || void 0,
304
+ resetAt: asString(value.resetAt) || void 0,
305
+ confidence: asString(value.confidence) || void 0,
306
+ source: asString(value.source) || void 0,
307
+ metadata: objectField(value, "metadata", path, diagnostics)
308
+ };
309
+ }
310
+ function parseExecutionProvider(value, path, diagnostics) {
311
+ if (!isRecord(value)) {
312
+ diagnostics.push(errorDiagnostic("seed.invalid_resource", "Expected execution provider resource to be an object.", path));
313
+ return null;
314
+ }
315
+ const limitsValue = value.nativeLimits;
316
+ const nativeLimits = limitsValue === void 0 ? [] : Array.isArray(limitsValue) ? limitsValue.map((limit, index) => parseNativeLimit(limit, `${path}.nativeLimits[${index}]`, diagnostics)).filter((limit) => Boolean(limit)) : (diagnostics.push(errorDiagnostic("seed.invalid_native_limits", "Expected nativeLimits to be an array.", `${path}.nativeLimits`)), []);
317
+ return {
318
+ id: asString(value.id) || void 0,
319
+ name: requireString(value, "name", path, diagnostics),
320
+ kind: requireString(value, "kind", path, diagnostics),
321
+ status: asString(value.status) || void 0,
322
+ nativeUnit: requireString(value, "nativeUnit", path, diagnostics),
323
+ quotaVisibility: asString(value.quotaVisibility) || void 0,
324
+ maxConcurrentWorkers: nonNegativeNumberField(value, "maxConcurrentWorkers", path, diagnostics),
325
+ resetCadence: asString(value.resetCadence) || void 0,
326
+ config: objectField(value, "config", path, diagnostics),
327
+ metadata: objectField(value, "metadata", path, diagnostics),
328
+ nativeLimits
329
+ };
330
+ }
279
331
  function parseProvider(value, path, diagnostics) {
280
332
  if (!isRecord(value)) {
281
333
  diagnostics.push(errorDiagnostic("seed.invalid_resource", "Expected capacity provider resource to be an object.", path));
@@ -283,6 +335,8 @@ function parseProvider(value, path, diagnostics) {
283
335
  }
284
336
  const lanesValue = value.lanes;
285
337
  const lanes = lanesValue === void 0 ? [] : Array.isArray(lanesValue) ? lanesValue.map((lane, index) => parseLane(lane, `${path}.lanes[${index}]`, diagnostics)).filter((lane) => Boolean(lane)) : (diagnostics.push(errorDiagnostic("seed.invalid_lanes", "Expected lanes to be an array.", `${path}.lanes`)), []);
338
+ const executionProvidersValue = value.executionProviders;
339
+ const executionProviders = executionProvidersValue === void 0 ? [] : Array.isArray(executionProvidersValue) ? executionProvidersValue.map((entry, index) => parseExecutionProvider(entry, `${path}.executionProviders[${index}]`, diagnostics)).filter((entry) => Boolean(entry)) : (diagnostics.push(errorDiagnostic("seed.invalid_execution_providers", "Expected executionProviders to be an array.", `${path}.executionProviders`)), []);
286
340
  return {
287
341
  ...keyBase(value, path, diagnostics),
288
342
  team: requireString(value, "team", path, diagnostics),
@@ -290,6 +344,7 @@ function parseProvider(value, path, diagnostics) {
290
344
  kind: asString(value.kind) || void 0,
291
345
  provider: requireString(value, "provider", path, diagnostics),
292
346
  billingScope: asString(value.billingScope) || void 0,
347
+ creditBudgetMode: asString(value.creditBudgetMode) || void 0,
293
348
  monthlyCreditBudget: numberField(value, "monthlyCreditBudget", path, diagnostics),
294
349
  dailyCreditBudget: numberField(value, "dailyCreditBudget", path, diagnostics),
295
350
  maxConcurrentWorkdays: numberField(value, "maxConcurrentWorkdays", path, diagnostics),
@@ -297,7 +352,8 @@ function parseProvider(value, path, diagnostics) {
297
352
  capacityModel: objectField(value, "capacityModel", path, diagnostics),
298
353
  registration: parseProviderRegistration(value.registration, `${path}.registration`, diagnostics),
299
354
  metadata: objectField(value, "metadata", path, diagnostics),
300
- lanes
355
+ lanes,
356
+ executionProviders
301
357
  };
302
358
  }
303
359
  function parseGrant(value, path, diagnostics) {
@@ -323,6 +379,10 @@ function parseGrant(value, path, diagnostics) {
323
379
  dailyUsdLimit: numberField(value, "dailyUsdLimit", path, diagnostics),
324
380
  weeklyQuotaMinutes: numberField(value, "weeklyQuotaMinutes", path, diagnostics),
325
381
  monthlyProviderUnits: numberField(value, "monthlyProviderUnits", path, diagnostics),
382
+ portfolioAllocationPercent: numberField(value, "portfolioAllocationPercent", path, diagnostics),
383
+ reservePoolPercent: numberField(value, "reservePoolPercent", path, diagnostics),
384
+ maxDailyProjectCredits: numberField(value, "maxDailyProjectCredits", path, diagnostics),
385
+ emergencyOverride: typeof value.emergencyOverride === "boolean" ? value.emergencyOverride : void 0,
326
386
  priorityWeight: numberField(value, "priorityWeight", path, diagnostics),
327
387
  overflowPolicy: asString(value.overflowPolicy) || void 0,
328
388
  state: asString(value.state) || void 0,
@@ -139,12 +139,39 @@ export type SeedCapacityProviderRegistrationApiKey = {
139
139
  export type SeedCapacityProviderRegistration = {
140
140
  apiKey?: SeedCapacityProviderRegistrationApiKey;
141
141
  };
142
+ export type SeedExecutionProviderNativeLimitResource = {
143
+ id?: string;
144
+ scope?: string;
145
+ limitScope?: string;
146
+ nativeUnit?: string;
147
+ limitAmount: number;
148
+ reserveBufferPercent?: number;
149
+ resetCadence?: string;
150
+ resetAt?: string;
151
+ confidence?: string;
152
+ source?: string;
153
+ metadata?: Record<string, unknown>;
154
+ };
155
+ export type SeedExecutionProviderResource = {
156
+ id?: string;
157
+ name: string;
158
+ kind: string;
159
+ status?: string;
160
+ nativeUnit: string;
161
+ quotaVisibility?: string;
162
+ maxConcurrentWorkers?: number;
163
+ resetCadence?: string;
164
+ config?: Record<string, unknown>;
165
+ metadata?: Record<string, unknown>;
166
+ nativeLimits?: SeedExecutionProviderNativeLimitResource[];
167
+ };
142
168
  export type SeedCapacityProviderResource = SeedResourceBase & {
143
169
  team: string;
144
170
  name: string;
145
171
  kind?: string;
146
172
  provider: string;
147
173
  billingScope?: string;
174
+ creditBudgetMode?: 'static' | 'hybrid' | 'derived' | string;
148
175
  monthlyCreditBudget?: number;
149
176
  dailyCreditBudget?: number;
150
177
  maxConcurrentWorkdays?: number;
@@ -153,6 +180,7 @@ export type SeedCapacityProviderResource = SeedResourceBase & {
153
180
  registration?: SeedCapacityProviderRegistration;
154
181
  metadata?: Record<string, unknown>;
155
182
  lanes?: SeedCapacityLaneResource[];
183
+ executionProviders?: SeedExecutionProviderResource[];
156
184
  };
157
185
  export type SeedCapacityGrantResource = SeedResourceBase & {
158
186
  provider: string;
@@ -167,6 +195,10 @@ export type SeedCapacityGrantResource = SeedResourceBase & {
167
195
  dailyUsdLimit?: number;
168
196
  weeklyQuotaMinutes?: number;
169
197
  monthlyProviderUnits?: number;
198
+ portfolioAllocationPercent?: number;
199
+ reservePoolPercent?: number;
200
+ maxDailyProjectCredits?: number;
201
+ emergencyOverride?: boolean;
170
202
  priorityWeight?: number;
171
203
  overflowPolicy?: string;
172
204
  state?: string;