@treeseed/sdk 0.6.38 → 0.6.40

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 (46) hide show
  1. package/dist/capacity.d.ts +53 -0
  2. package/dist/capacity.js +100 -0
  3. package/dist/control-plane-client.d.ts +41 -1
  4. package/dist/control-plane-client.js +154 -0
  5. package/dist/control-plane.d.ts +6 -1
  6. package/dist/control-plane.js +39 -2
  7. package/dist/d1-store.d.ts +63 -1
  8. package/dist/d1-store.js +190 -1
  9. package/dist/index.d.ts +3 -1
  10. package/dist/index.js +12 -0
  11. package/dist/operations/services/config-runtime.js +5 -3
  12. package/dist/operations/services/deploy.js +3 -2
  13. package/dist/operations/services/github-api.d.ts +2 -1
  14. package/dist/operations/services/github-api.js +35 -26
  15. package/dist/operations/services/knowledge-coop-launch.js +5 -28
  16. package/dist/operations/services/package-reference-policy.d.ts +68 -0
  17. package/dist/operations/services/package-reference-policy.js +135 -0
  18. package/dist/operations/services/project-platform.d.ts +14 -0
  19. package/dist/operations/services/project-platform.js +3 -2
  20. package/dist/operations/services/railway-api.d.ts +33 -0
  21. package/dist/operations/services/railway-api.js +273 -0
  22. package/dist/operations/services/railway-deploy.d.ts +22 -0
  23. package/dist/operations/services/railway-deploy.js +81 -19
  24. package/dist/operations/services/release-candidate.d.ts +2 -0
  25. package/dist/operations/services/release-candidate.js +28 -0
  26. package/dist/operations/services/runtime-tools.js +1 -1
  27. package/dist/operations-registry.js +1 -0
  28. package/dist/reconcile/bootstrap-systems.js +1 -1
  29. package/dist/reconcile/builtin-adapters.js +5 -9
  30. package/dist/reconcile/contracts.d.ts +1 -1
  31. package/dist/reconcile/desired-state.js +9 -17
  32. package/dist/reconcile/state.js +4 -4
  33. package/dist/reconcile/units.js +4 -8
  34. package/dist/sdk-types.d.ts +566 -3
  35. package/dist/sdk.d.ts +12 -1
  36. package/dist/sdk.js +44 -0
  37. package/dist/stores/operational-store.d.ts +12 -1
  38. package/dist/stores/operational-store.js +283 -5
  39. package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +5 -24
  40. package/dist/types/agents.d.ts +27 -0
  41. package/dist/workflow/operations.d.ts +94 -2
  42. package/dist/workflow/operations.js +90 -32
  43. package/dist/workflow-state.js +3 -5
  44. package/dist/workflow.d.ts +8 -1
  45. package/dist/workflow.js +6 -0
  46. package/package.json +5 -1
@@ -134,7 +134,7 @@ export interface EncryptedWebHostPayload {
134
134
  nonce: string;
135
135
  ciphertext: string;
136
136
  }
137
- export type TeamWebHostProvider = 'cloudflare';
137
+ export type TeamWebHostProvider = 'cloudflare' | 'railway' | 'openai' | 'github_copilot' | 'openrouter' | 'custom';
138
138
  export type TeamWebHostOwnership = 'team_owned' | 'treeseed_managed';
139
139
  export interface TeamWebHost {
140
140
  id: string;
@@ -285,6 +285,13 @@ export interface WorkdayPolicy {
285
285
  projectId: string;
286
286
  environment: ProjectEnvironmentName | 'local';
287
287
  schedule: WorkdaySchedule;
288
+ enabled: boolean;
289
+ startCron: string;
290
+ durationMinutes: number;
291
+ maxRunners: number;
292
+ maxWorkersPerRunner: number;
293
+ dailyCreditBudget: number;
294
+ closeoutGraceMinutes: number;
288
295
  dailyTaskCreditBudget: number;
289
296
  maxQueuedTasks: number;
290
297
  maxQueuedCredits: number;
@@ -292,6 +299,67 @@ export interface WorkdayPolicy {
292
299
  creditWeights: TaskCreditWeight[];
293
300
  metadata?: Record<string, unknown>;
294
301
  }
302
+ export type WorkdayRequestType = 'one_off_run' | 'early_close' | 'pause' | 'retry_open';
303
+ export type WorkdayRequestState = 'pending' | 'applied' | 'rejected' | 'cancelled';
304
+ export interface WorkdayRequest {
305
+ id: string;
306
+ projectId: string;
307
+ environment: ProjectEnvironmentName | 'local';
308
+ type: WorkdayRequestType;
309
+ state: WorkdayRequestState;
310
+ workDayId: string | null;
311
+ requestedBy: string | null;
312
+ reason: string | null;
313
+ payload: Record<string, unknown>;
314
+ metadata?: Record<string, unknown>;
315
+ createdAt: string;
316
+ updatedAt: string;
317
+ }
318
+ export interface WorkdayManagerLease {
319
+ id: string;
320
+ projectId: string;
321
+ environment: ProjectEnvironmentName | 'local';
322
+ workDayId: string | null;
323
+ managerId: string;
324
+ state: 'active' | 'released' | 'stale';
325
+ heartbeatAt: string;
326
+ expiresAt: string;
327
+ metadata?: Record<string, unknown>;
328
+ createdAt: string;
329
+ updatedAt: string;
330
+ }
331
+ export type WorkerRunnerState = 'active' | 'sleeping' | 'waking' | 'draining' | 'failed';
332
+ export interface WorkerRunner {
333
+ id: string;
334
+ projectId: string;
335
+ environment: ProjectEnvironmentName | 'local';
336
+ runnerId: string;
337
+ runnerServiceName: string;
338
+ volumeIdentity: string;
339
+ state: WorkerRunnerState;
340
+ maxLocalWorkers: number;
341
+ activeLocalWorkers: number;
342
+ availableCapacity: number;
343
+ lastHeartbeatAt: string | null;
344
+ claimedRepositoryIds: string[];
345
+ metadata?: Record<string, unknown>;
346
+ createdAt: string;
347
+ updatedAt: string;
348
+ }
349
+ export interface RepositoryClaim {
350
+ id: string;
351
+ projectId: string;
352
+ repositoryId: string;
353
+ runnerId: string;
354
+ runnerServiceName: string;
355
+ volumeIdentity: string;
356
+ lastSeenCommit: string | null;
357
+ lastTaskAt: string | null;
358
+ claimState: 'active' | 'stale' | 'released';
359
+ metadata?: Record<string, unknown>;
360
+ createdAt: string;
361
+ updatedAt: string;
362
+ }
295
363
  export interface PrioritySnapshotItem {
296
364
  model: string;
297
365
  id: string;
@@ -326,11 +394,257 @@ export interface TaskCreditLedgerEntry {
326
394
  projectId: string;
327
395
  workDayId: string;
328
396
  taskId: string | null;
329
- phase: 'seed' | 'settle' | 'refund';
397
+ phase: 'seed' | 'settle' | 'refund' | 'grant' | 'reserve' | 'consume' | 'release' | 'adjustment';
398
+ credits: number;
399
+ metadata?: Record<string, unknown>;
400
+ createdAt: string;
401
+ }
402
+ export type CapacityProviderKind = 'treeseed_managed' | 'team_owned' | 'external' | 'hybrid';
403
+ export type CapacityProviderStatus = 'pending' | 'active' | 'paused' | 'configuration_required' | 'disabled';
404
+ export type CapacityProviderBillingScope = 'treeseed' | 'team' | 'external';
405
+ export type CapacityBusinessModel = 'subscription_quota' | 'token_metered' | 'hybrid_usage_based' | 'infrastructure_runtime' | 'custom';
406
+ export type CapacityLaneUnit = 'treeseed_credit' | 'quota_minute' | 'token_usd' | 'github_ai_credit' | 'worker_second' | 'request' | 'custom';
407
+ export type CapacityScarcityLevel = 'low' | 'medium' | 'high';
408
+ export type CapacityGrantScope = 'team' | 'project' | 'workday' | 'overflow_pool';
409
+ export type CapacityGrantState = 'active' | 'paused' | 'expired' | 'disabled';
410
+ export type CapacityOverflowPolicy = 'hard_grant' | 'soft_grant' | 'weighted_fair_share' | 'approval_required';
411
+ export type CapacityReservationState = 'reserved' | 'consumed' | 'released' | 'expired' | 'cancelled';
412
+ export type CapacityEstimatePhase = 'intent' | 'discovery' | 'plan' | 'execution' | 'actual';
413
+ export type CapacityEstimateConfidence = 'low' | 'medium' | 'high';
414
+ export type CapacityApprovalState = 'pending' | 'approved' | 'rejected' | 'expired' | 'superseded';
415
+ export interface CapacityProvider {
416
+ id: string;
417
+ teamId: string | null;
418
+ ownerTeamId: string | null;
419
+ name: string;
420
+ kind: CapacityProviderKind;
421
+ status: CapacityProviderStatus;
422
+ provider: TeamWebHostProvider | string;
423
+ billingScope: CapacityProviderBillingScope;
424
+ monthlyCreditBudget: number;
425
+ dailyCreditBudget: number;
426
+ maxConcurrentWorkdays: number;
427
+ maxConcurrentWorkers: number;
428
+ capacityModel: Record<string, unknown>;
429
+ metadata?: Record<string, unknown>;
430
+ createdAt: string;
431
+ updatedAt: string;
432
+ }
433
+ export interface CapacityProviderHost {
434
+ id: string;
435
+ capacityProviderId: string;
436
+ hostId: string;
437
+ role: string;
438
+ required: boolean;
439
+ metadata?: Record<string, unknown>;
440
+ createdAt: string;
441
+ updatedAt: string;
442
+ }
443
+ export interface CapacityProviderLane {
444
+ id: string;
445
+ capacityProviderId: string;
446
+ name: string;
447
+ businessModel: CapacityBusinessModel;
448
+ modelFamily: string | null;
449
+ modelClass: string | null;
450
+ regionPolicy: string | null;
451
+ unit: CapacityLaneUnit | string;
452
+ scarcityLevel: CapacityScarcityLevel;
453
+ hardLimits: Record<string, unknown>;
454
+ routingPolicy: Record<string, unknown>;
455
+ metadata?: Record<string, unknown>;
456
+ createdAt: string;
457
+ updatedAt: string;
458
+ }
459
+ export interface CapacityGrant {
460
+ id: string;
461
+ capacityProviderId: string;
462
+ laneId: string | null;
463
+ grantScope: CapacityGrantScope;
464
+ teamId: string;
465
+ projectId: string | null;
466
+ environment: ProjectEnvironmentName | 'local' | null;
467
+ state: CapacityGrantState;
468
+ dailyCreditLimit: number | null;
469
+ weeklyCreditLimit: number | null;
470
+ monthlyCreditLimit: number | null;
471
+ dailyUsdLimit: number | null;
472
+ weeklyQuotaMinutes: number | null;
473
+ monthlyProviderUnits: number | null;
474
+ priorityWeight: number;
475
+ overflowPolicy: CapacityOverflowPolicy;
476
+ metadata?: Record<string, unknown>;
477
+ createdAt: string;
478
+ updatedAt: string;
479
+ }
480
+ export interface CapacityReservation {
481
+ id: string;
482
+ capacityProviderId: string;
483
+ laneId: string;
484
+ teamId: string;
485
+ projectId: string;
486
+ workDayId: string | null;
487
+ taskId: string | null;
488
+ state: CapacityReservationState;
489
+ reservedCredits: number;
490
+ consumedCredits: number;
491
+ reservedProviderUnits: number | null;
492
+ consumedProviderUnits: number | null;
493
+ reservedUsd: number | null;
494
+ consumedUsd: number | null;
495
+ expiresAt: string | null;
496
+ metadata?: Record<string, unknown>;
497
+ createdAt: string;
498
+ updatedAt: string;
499
+ }
500
+ export interface CapacityLedgerEntry {
501
+ id: string;
502
+ capacityProviderId: string;
503
+ laneId: string | null;
504
+ reservationId: string | null;
505
+ teamId: string;
506
+ projectId: string | null;
507
+ workDayId: string | null;
508
+ taskId: string | null;
509
+ phase: TaskCreditLedgerEntry['phase'];
330
510
  credits: number;
511
+ providerUnits: number | null;
512
+ usd: number | null;
513
+ source: string;
514
+ metadata?: Record<string, unknown>;
515
+ createdAt: string;
516
+ }
517
+ export interface CapacityRoutingDecision {
518
+ id: string;
519
+ taskId: string | null;
520
+ workDayId: string | null;
521
+ projectId: string;
522
+ selectedProviderId: string;
523
+ selectedLaneId: string;
524
+ selectedModel: string | null;
525
+ decision: string;
526
+ reason: string;
527
+ candidates: Record<string, unknown>[];
528
+ scores: Record<string, unknown>;
331
529
  metadata?: Record<string, unknown>;
332
530
  createdAt: string;
333
531
  }
532
+ export interface TaskEstimate {
533
+ id: string;
534
+ taskId: string | null;
535
+ workDayId: string | null;
536
+ projectId: string;
537
+ estimatePhase: CapacityEstimatePhase;
538
+ taskSignature: string;
539
+ confidence: CapacityEstimateConfidence;
540
+ estimatedCreditsP50: number;
541
+ estimatedCreditsP90: number;
542
+ reservedCredits: number;
543
+ estimatedInputTokensP50: number | null;
544
+ estimatedInputTokensP90: number | null;
545
+ estimatedOutputTokensP50: number | null;
546
+ estimatedOutputTokensP90: number | null;
547
+ estimatedQuotaMinutesP50: number | null;
548
+ estimatedQuotaMinutesP90: number | null;
549
+ features: Record<string, unknown>;
550
+ createdAt: string;
551
+ }
552
+ export interface TaskUsageActual {
553
+ id: string;
554
+ taskId: string | null;
555
+ workDayId: string | null;
556
+ projectId: string;
557
+ taskSignature: string;
558
+ capacityProviderId: string | null;
559
+ laneId: string | null;
560
+ businessModel: CapacityBusinessModel | string;
561
+ modelName: string | null;
562
+ inputTokens: number | null;
563
+ outputTokens: number | null;
564
+ cachedInputTokens: number | null;
565
+ quotaMinutes: number | null;
566
+ wallMinutes: number | null;
567
+ filesOpened: number | null;
568
+ filesChanged: number | null;
569
+ diffLinesAdded: number | null;
570
+ diffLinesRemoved: number | null;
571
+ testRuns: number | null;
572
+ retryCount: number | null;
573
+ actualCredits: number;
574
+ actualUsd: number | null;
575
+ metadata?: Record<string, unknown>;
576
+ createdAt: string;
577
+ }
578
+ export interface TaskEstimateProfile {
579
+ taskSignature: string;
580
+ sampleCount: number;
581
+ inputTokensP50: number | null;
582
+ inputTokensP90: number | null;
583
+ outputTokensP50: number | null;
584
+ outputTokensP90: number | null;
585
+ quotaMinutesP50: number | null;
586
+ quotaMinutesP90: number | null;
587
+ filesChangedP50: number | null;
588
+ filesChangedP90: number | null;
589
+ creditsP50: number | null;
590
+ creditsP90: number | null;
591
+ updatedAt: string;
592
+ }
593
+ export interface ApprovalRequest {
594
+ id: string;
595
+ teamId: string;
596
+ projectId: string;
597
+ workDayId: string | null;
598
+ taskId: string | null;
599
+ kind: string;
600
+ state: CapacityApprovalState;
601
+ severity: 'low' | 'medium' | 'high';
602
+ requestedByType: 'agent' | 'scheduler' | 'worker' | 'service' | 'user';
603
+ requestedById: string | null;
604
+ title: string;
605
+ summary: string;
606
+ options: Record<string, unknown>[];
607
+ recommendation: Record<string, unknown>;
608
+ policySnapshot: Record<string, unknown>;
609
+ expiresAt: string | null;
610
+ decidedByType: string | null;
611
+ decidedById: string | null;
612
+ decidedAt: string | null;
613
+ decision: Record<string, unknown> | null;
614
+ createdAt: string;
615
+ updatedAt: string;
616
+ }
617
+ export interface CapacityTaskExecutionEnvelope {
618
+ providerId?: string | null;
619
+ laneId?: string | null;
620
+ model?: string | null;
621
+ modelClass?: string | null;
622
+ reservationIds?: string[];
623
+ maxCredits?: number | null;
624
+ maxProviderUnits?: number | null;
625
+ maxUsd?: number | null;
626
+ allowedFallbacks?: Array<Record<string, unknown>>;
627
+ approvalBehavior?: 'auto' | 'pause_task' | 'fail_task';
628
+ pausePolicy?: Record<string, unknown>;
629
+ metadata?: Record<string, unknown>;
630
+ }
631
+ export interface CapacityPlan {
632
+ projectId: string;
633
+ teamId: string;
634
+ environment: ProjectEnvironmentName | 'local';
635
+ providers: CapacityProvider[];
636
+ lanes: CapacityProviderLane[];
637
+ grants: CapacityGrant[];
638
+ activeReservations: CapacityReservation[];
639
+ estimateProfiles: TaskEstimateProfile[];
640
+ remaining: {
641
+ dailyCredits: number | null;
642
+ weeklyCredits: number | null;
643
+ monthlyCredits: number | null;
644
+ weeklyQuotaMinutes: number | null;
645
+ dailyUsd: number | null;
646
+ };
647
+ }
334
648
  export interface ProjectWorkdaySummary {
335
649
  id: string;
336
650
  projectId: string;
@@ -358,6 +672,18 @@ export interface ScaleDecision {
358
672
  metadata?: Record<string, unknown>;
359
673
  createdAt: string;
360
674
  }
675
+ export interface RunnerScaleDecision {
676
+ id: string;
677
+ projectId: string;
678
+ environment: ProjectEnvironmentName | 'local';
679
+ workDayId: string | null;
680
+ runnerId: string | null;
681
+ runnerServiceName: string | null;
682
+ action: 'wake' | 'sleep' | 'drain' | 'provision' | 'noop';
683
+ reason: string;
684
+ metadata?: Record<string, unknown>;
685
+ createdAt: string;
686
+ }
361
687
  export interface WorkerPoolScaleResult {
362
688
  applied: boolean;
363
689
  provider: string;
@@ -1060,6 +1386,13 @@ export interface SdkUpsertWorkPolicyRequest {
1060
1386
  projectId: string;
1061
1387
  environment: ProjectEnvironmentName | 'local';
1062
1388
  schedule: WorkdaySchedule;
1389
+ enabled?: boolean;
1390
+ startCron?: string;
1391
+ durationMinutes?: number;
1392
+ maxRunners?: number;
1393
+ maxWorkersPerRunner?: number;
1394
+ dailyCreditBudget?: number;
1395
+ closeoutGraceMinutes?: number;
1063
1396
  dailyTaskCreditBudget: number;
1064
1397
  maxQueuedTasks: number;
1065
1398
  maxQueuedCredits: number;
@@ -1067,6 +1400,58 @@ export interface SdkUpsertWorkPolicyRequest {
1067
1400
  creditWeights?: TaskCreditWeight[];
1068
1401
  metadata?: Record<string, unknown> | null;
1069
1402
  }
1403
+ export interface SdkCreateWorkdayRequest {
1404
+ id?: string;
1405
+ projectId: string;
1406
+ environment: ProjectEnvironmentName | 'local';
1407
+ type: WorkdayRequestType;
1408
+ state?: WorkdayRequestState;
1409
+ workDayId?: string | null;
1410
+ requestedBy?: string | null;
1411
+ reason?: string | null;
1412
+ payload?: Record<string, unknown> | null;
1413
+ metadata?: Record<string, unknown> | null;
1414
+ }
1415
+ export interface SdkClaimWorkdayManagerLeaseRequest {
1416
+ id?: string;
1417
+ projectId: string;
1418
+ environment: ProjectEnvironmentName | 'local';
1419
+ workDayId?: string | null;
1420
+ managerId: string;
1421
+ ttlSeconds: number;
1422
+ staleAfterSeconds?: number;
1423
+ now?: string;
1424
+ metadata?: Record<string, unknown> | null;
1425
+ }
1426
+ export interface SdkReleaseWorkdayManagerLeaseRequest {
1427
+ id: string;
1428
+ managerId: string;
1429
+ }
1430
+ export interface SdkRecordWorkerRunnerRequest {
1431
+ id?: string;
1432
+ projectId: string;
1433
+ environment: ProjectEnvironmentName | 'local';
1434
+ runnerId: string;
1435
+ runnerServiceName: string;
1436
+ volumeIdentity: string;
1437
+ state?: WorkerRunnerState;
1438
+ maxLocalWorkers: number;
1439
+ activeLocalWorkers?: number;
1440
+ claimedRepositoryIds?: string[];
1441
+ metadata?: Record<string, unknown> | null;
1442
+ }
1443
+ export interface SdkRecordRepositoryClaimRequest {
1444
+ id?: string;
1445
+ projectId: string;
1446
+ repositoryId: string;
1447
+ runnerId: string;
1448
+ runnerServiceName: string;
1449
+ volumeIdentity: string;
1450
+ lastSeenCommit?: string | null;
1451
+ lastTaskAt?: string | null;
1452
+ claimState?: RepositoryClaim['claimState'];
1453
+ metadata?: Record<string, unknown> | null;
1454
+ }
1070
1455
  export interface UpsertProjectHostingRequest {
1071
1456
  kind: TreeseedHostingKind;
1072
1457
  registration?: TreeseedHostingRegistration;
@@ -1193,10 +1578,172 @@ export interface SdkRecordTaskCreditsRequest {
1193
1578
  projectId: string;
1194
1579
  workDayId: string;
1195
1580
  taskId?: string | null;
1196
- phase: 'seed' | 'settle' | 'refund';
1581
+ phase: TaskCreditLedgerEntry['phase'];
1197
1582
  credits: number;
1198
1583
  metadata?: Record<string, unknown> | null;
1199
1584
  }
1585
+ export interface UpsertCapacityProviderRequest {
1586
+ id?: string;
1587
+ teamId?: string | null;
1588
+ ownerTeamId?: string | null;
1589
+ name: string;
1590
+ kind?: CapacityProviderKind;
1591
+ status?: CapacityProviderStatus;
1592
+ provider: TeamWebHostProvider | string;
1593
+ billingScope?: CapacityProviderBillingScope;
1594
+ monthlyCreditBudget?: number;
1595
+ dailyCreditBudget?: number;
1596
+ maxConcurrentWorkdays?: number;
1597
+ maxConcurrentWorkers?: number;
1598
+ capacityModel?: Record<string, unknown> | null;
1599
+ metadata?: Record<string, unknown> | null;
1600
+ }
1601
+ export interface UpsertCapacityProviderHostRequest {
1602
+ id?: string;
1603
+ hostId: string;
1604
+ role: string;
1605
+ required?: boolean;
1606
+ metadata?: Record<string, unknown> | null;
1607
+ }
1608
+ export interface UpsertCapacityProviderLaneRequest {
1609
+ id?: string;
1610
+ name: string;
1611
+ businessModel?: CapacityBusinessModel;
1612
+ modelFamily?: string | null;
1613
+ modelClass?: string | null;
1614
+ regionPolicy?: string | null;
1615
+ unit?: CapacityLaneUnit | string;
1616
+ scarcityLevel?: CapacityScarcityLevel;
1617
+ hardLimits?: Record<string, unknown> | null;
1618
+ routingPolicy?: Record<string, unknown> | null;
1619
+ metadata?: Record<string, unknown> | null;
1620
+ }
1621
+ export interface UpsertCapacityGrantRequest {
1622
+ id?: string;
1623
+ capacityProviderId: string;
1624
+ laneId?: string | null;
1625
+ grantScope?: CapacityGrantScope;
1626
+ teamId: string;
1627
+ projectId?: string | null;
1628
+ environment?: ProjectEnvironmentName | 'local' | null;
1629
+ state?: CapacityGrantState;
1630
+ dailyCreditLimit?: number | null;
1631
+ weeklyCreditLimit?: number | null;
1632
+ monthlyCreditLimit?: number | null;
1633
+ dailyUsdLimit?: number | null;
1634
+ weeklyQuotaMinutes?: number | null;
1635
+ monthlyProviderUnits?: number | null;
1636
+ priorityWeight?: number;
1637
+ overflowPolicy?: CapacityOverflowPolicy;
1638
+ metadata?: Record<string, unknown> | null;
1639
+ }
1640
+ export interface CreateCapacityReservationRequest {
1641
+ id?: string;
1642
+ capacityProviderId: string;
1643
+ laneId: string;
1644
+ teamId: string;
1645
+ projectId: string;
1646
+ workDayId?: string | null;
1647
+ taskId?: string | null;
1648
+ state?: CapacityReservationState;
1649
+ reservedCredits: number;
1650
+ reservedProviderUnits?: number | null;
1651
+ reservedUsd?: number | null;
1652
+ expiresAt?: string | null;
1653
+ metadata?: Record<string, unknown> | null;
1654
+ }
1655
+ export interface RecordCapacityUsageRequest {
1656
+ id?: string;
1657
+ capacityProviderId: string;
1658
+ laneId?: string | null;
1659
+ reservationId?: string | null;
1660
+ teamId: string;
1661
+ projectId?: string | null;
1662
+ workDayId?: string | null;
1663
+ taskId?: string | null;
1664
+ phase?: TaskCreditLedgerEntry['phase'];
1665
+ credits: number;
1666
+ providerUnits?: number | null;
1667
+ usd?: number | null;
1668
+ source?: string;
1669
+ metadata?: Record<string, unknown> | null;
1670
+ }
1671
+ export interface CreateCapacityRoutingDecisionRequest {
1672
+ id?: string;
1673
+ taskId?: string | null;
1674
+ workDayId?: string | null;
1675
+ projectId: string;
1676
+ selectedProviderId: string;
1677
+ selectedLaneId: string;
1678
+ selectedModel?: string | null;
1679
+ decision?: string;
1680
+ reason: string;
1681
+ candidates?: Record<string, unknown>[];
1682
+ scores?: Record<string, unknown>;
1683
+ metadata?: Record<string, unknown> | null;
1684
+ }
1685
+ export interface CreateTaskEstimateRequest {
1686
+ id?: string;
1687
+ taskId?: string | null;
1688
+ workDayId?: string | null;
1689
+ projectId: string;
1690
+ estimatePhase: CapacityEstimatePhase;
1691
+ taskSignature: string;
1692
+ confidence: CapacityEstimateConfidence;
1693
+ estimatedCreditsP50: number;
1694
+ estimatedCreditsP90: number;
1695
+ reservedCredits?: number;
1696
+ estimatedInputTokensP50?: number | null;
1697
+ estimatedInputTokensP90?: number | null;
1698
+ estimatedOutputTokensP50?: number | null;
1699
+ estimatedOutputTokensP90?: number | null;
1700
+ estimatedQuotaMinutesP50?: number | null;
1701
+ estimatedQuotaMinutesP90?: number | null;
1702
+ features?: Record<string, unknown> | null;
1703
+ }
1704
+ export interface CreateTaskUsageActualRequest {
1705
+ id?: string;
1706
+ taskId?: string | null;
1707
+ workDayId?: string | null;
1708
+ projectId: string;
1709
+ taskSignature: string;
1710
+ capacityProviderId?: string | null;
1711
+ laneId?: string | null;
1712
+ businessModel: CapacityBusinessModel | string;
1713
+ modelName?: string | null;
1714
+ inputTokens?: number | null;
1715
+ outputTokens?: number | null;
1716
+ cachedInputTokens?: number | null;
1717
+ quotaMinutes?: number | null;
1718
+ wallMinutes?: number | null;
1719
+ filesOpened?: number | null;
1720
+ filesChanged?: number | null;
1721
+ diffLinesAdded?: number | null;
1722
+ diffLinesRemoved?: number | null;
1723
+ testRuns?: number | null;
1724
+ retryCount?: number | null;
1725
+ actualCredits: number;
1726
+ actualUsd?: number | null;
1727
+ metadata?: Record<string, unknown> | null;
1728
+ }
1729
+ export interface CreateApprovalRequestRequest {
1730
+ id?: string;
1731
+ teamId: string;
1732
+ projectId: string;
1733
+ workDayId?: string | null;
1734
+ taskId?: string | null;
1735
+ kind: string;
1736
+ severity?: 'low' | 'medium' | 'high';
1737
+ requestedByType?: ApprovalRequest['requestedByType'];
1738
+ requestedById?: string | null;
1739
+ title: string;
1740
+ summary: string;
1741
+ options?: Record<string, unknown>[];
1742
+ recommendation?: Record<string, unknown> | null;
1743
+ policySnapshot?: Record<string, unknown> | null;
1744
+ expiresAt?: string | null;
1745
+ metadata?: Record<string, unknown> | null;
1746
+ }
1200
1747
  export interface SdkRecordScaleDecisionRequest {
1201
1748
  id?: string;
1202
1749
  projectId: string;
@@ -1209,6 +1756,22 @@ export interface SdkRecordScaleDecisionRequest {
1209
1756
  reason: string;
1210
1757
  metadata?: Record<string, unknown> | null;
1211
1758
  }
1759
+ export interface SdkRecordRunnerScaleDecisionRequest {
1760
+ id?: string;
1761
+ projectId: string;
1762
+ environment: ProjectEnvironmentName | 'local';
1763
+ workDayId?: string | null;
1764
+ runnerId?: string | null;
1765
+ runnerServiceName?: string | null;
1766
+ action: RunnerScaleDecision['action'];
1767
+ reason: string;
1768
+ metadata?: Record<string, unknown> | null;
1769
+ }
1770
+ export interface SdkUpdateWorkDayGraphRequest {
1771
+ id: string;
1772
+ graphVersion: string;
1773
+ summaryPatch?: Record<string, unknown> | null;
1774
+ }
1212
1775
  export interface SdkCloseWorkDayRequest {
1213
1776
  id: string;
1214
1777
  state?: 'completed' | 'cancelled' | 'failed';
package/dist/sdk.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ContentStore } from './content-store.ts';
3
3
  import { type AgentDatabase } from './d1-store.ts';
4
4
  import { type LoadedTreeseedPluginEntry } from './platform/plugins.ts';
5
5
  import type { ReleaseDetail, ReleaseSummary, SharePackageStatus, WorkstreamDetail, WorkstreamEvent, WorkstreamSummary } from './knowledge-coop.ts';
6
- import type { SdkAckMessageRequest, SdkClaimMessageRequest, SdkClaimTaskRequest, SdkCloseWorkDayRequest, SdkCompleteTaskRequest, SdkCreateReportRequest, SdkCreateMessageRequest, SdkCreatePrioritySnapshotRequest, SdkCreateTaskRequest, SdkCursorRequest, SdkFailTaskRequest, SdkFollowRequest, SdkGetRequest, SdkGetCursorRequest, SdkJsonEnvelope, SdkLeaseReleaseRequest, SdkManagerContextPayload, SdkMutationRequest, SdkGraphQueryOptions, SdkGraphQueryRequest, SdkGraphRefreshRequest, SdkGraphSearchOptions, SdkContextPackRequest, SdkGraphDslParseResult, SdkPickRequest, SdkPriorityOverrideRequest, SdkRecordRunRequest, SdkRecordScaleDecisionRequest, SdkRecordTaskCreditsRequest, SdkSearchRequest, SdkStartWorkDayRequest, SdkTaskProgressRequest, SdkTaskSearchRequest, SdkUpsertWorkPolicyRequest, SdkUpdateRequest, SdkModelDefinition, SdkModelRegistry, SdkGraphRankingProvider, SdkDispatchConfig, SdkDispatchRequest, SdkDispatchResult, PrioritySnapshot, ScaleDecision, TaskCreditLedgerEntry, WorkdayPolicy } from './sdk-types.ts';
6
+ import type { SdkAckMessageRequest, SdkClaimMessageRequest, SdkClaimTaskRequest, SdkCloseWorkDayRequest, SdkCompleteTaskRequest, SdkCreateReportRequest, SdkCreateMessageRequest, SdkCreatePrioritySnapshotRequest, SdkCreateTaskRequest, SdkCursorRequest, SdkFailTaskRequest, SdkFollowRequest, SdkGetRequest, SdkGetCursorRequest, SdkJsonEnvelope, SdkLeaseReleaseRequest, SdkManagerContextPayload, SdkMutationRequest, SdkGraphQueryOptions, SdkGraphQueryRequest, SdkGraphRefreshRequest, SdkGraphSearchOptions, SdkContextPackRequest, SdkGraphDslParseResult, SdkPickRequest, SdkPriorityOverrideRequest, SdkClaimWorkdayManagerLeaseRequest, SdkCreateWorkdayRequest, SdkRecordRepositoryClaimRequest, SdkRecordRunnerScaleDecisionRequest, SdkRecordWorkerRunnerRequest, SdkRecordRunRequest, SdkRecordScaleDecisionRequest, SdkRecordTaskCreditsRequest, SdkReleaseWorkdayManagerLeaseRequest, SdkSearchRequest, SdkStartWorkDayRequest, SdkTaskProgressRequest, SdkTaskSearchRequest, SdkUpsertWorkPolicyRequest, SdkUpdateWorkDayGraphRequest, SdkUpdateRequest, SdkModelDefinition, SdkModelRegistry, SdkGraphRankingProvider, SdkDispatchConfig, SdkDispatchRequest, SdkDispatchResult, PrioritySnapshot, RepositoryClaim, RunnerScaleDecision, ScaleDecision, TaskCreditLedgerEntry, WorkdayManagerLease, WorkdayPolicy, WorkdayRequest, WorkerRunner } from './sdk-types.ts';
7
7
  export interface AgentSdkOptions {
8
8
  repoRoot?: string;
9
9
  database?: AgentDatabase;
@@ -88,6 +88,17 @@ export declare class AgentSdk {
88
88
  getManagerContext(taskId: string): Promise<SdkJsonEnvelope<SdkManagerContextPayload>>;
89
89
  getWorkPolicy(projectId: string, environment?: string): Promise<SdkJsonEnvelope<WorkdayPolicy>>;
90
90
  upsertWorkPolicy(request: SdkUpsertWorkPolicyRequest): Promise<SdkJsonEnvelope<WorkdayPolicy>>;
91
+ createWorkdayRequest(request: SdkCreateWorkdayRequest): Promise<SdkJsonEnvelope<WorkdayRequest>>;
92
+ listWorkdayRequests(projectId: string, environment: string, state?: string | null): Promise<SdkJsonEnvelope<WorkdayRequest[]>>;
93
+ claimWorkdayManagerLease(request: SdkClaimWorkdayManagerLeaseRequest): Promise<SdkJsonEnvelope<WorkdayManagerLease>>;
94
+ releaseWorkdayManagerLease(request: SdkReleaseWorkdayManagerLeaseRequest): Promise<SdkJsonEnvelope<WorkdayManagerLease>>;
95
+ recordWorkerRunner(request: SdkRecordWorkerRunnerRequest): Promise<SdkJsonEnvelope<WorkerRunner>>;
96
+ listWorkerRunners(projectId: string, environment: string): Promise<SdkJsonEnvelope<WorkerRunner[]>>;
97
+ recordRepositoryClaim(request: SdkRecordRepositoryClaimRequest): Promise<SdkJsonEnvelope<RepositoryClaim>>;
98
+ listRepositoryClaims(projectId: string, repositoryId?: string | null): Promise<SdkJsonEnvelope<RepositoryClaim[]>>;
99
+ recordRunnerScaleDecision(request: SdkRecordRunnerScaleDecisionRequest): Promise<SdkJsonEnvelope<RunnerScaleDecision>>;
100
+ listRunnerScaleDecisions(projectId: string, environment: string, workDayId?: string | null): Promise<SdkJsonEnvelope<RunnerScaleDecision[]>>;
101
+ updateWorkDayGraph(request: SdkUpdateWorkDayGraphRequest): Promise<SdkJsonEnvelope<import("./sdk-types.ts").SdkWorkDayEntity | null>>;
91
102
  listPriorityOverrides(projectId: string): Promise<SdkJsonEnvelope<Record<string, unknown>[]>>;
92
103
  upsertPriorityOverride(request: SdkPriorityOverrideRequest): Promise<SdkJsonEnvelope<Record<string, unknown> | null>>;
93
104
  createPrioritySnapshot(request: SdkCreatePrioritySnapshotRequest): Promise<SdkJsonEnvelope<PrioritySnapshot>>;