@treeseed/core 0.8.3 → 0.8.4

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 (133) hide show
  1. package/README.md +7 -11
  2. package/dist/dev-watch.js +1 -1
  3. package/dist/dev.d.ts +2 -4
  4. package/dist/dev.js +4 -124
  5. package/dist/env.yaml +23 -175
  6. package/dist/index.d.ts +0 -4
  7. package/dist/index.js +0 -6
  8. package/dist/scripts/build-dist.js +3 -3
  9. package/dist/scripts/dev-platform.js +1 -7
  10. package/dist/scripts/run-fixture-astro-command.js +25 -51
  11. package/dist/scripts/test-smoke.js +50 -7
  12. package/package.json +5 -78
  13. package/templates/github/deploy-web.workflow.yml +106 -0
  14. package/templates/github/hosted-project.workflow.yml +4 -4
  15. package/dist/agent-runtime.d.ts +0 -17
  16. package/dist/agent-runtime.js +0 -117
  17. package/dist/agent.d.ts +0 -11
  18. package/dist/agent.js +0 -25
  19. package/dist/agents/adapters/execution.d.ts +0 -41
  20. package/dist/agents/adapters/execution.js +0 -73
  21. package/dist/agents/adapters/mutations.d.ts +0 -22
  22. package/dist/agents/adapters/mutations.js +0 -30
  23. package/dist/agents/adapters/notification.d.ts +0 -26
  24. package/dist/agents/adapters/notification.js +0 -46
  25. package/dist/agents/adapters/repository.d.ts +0 -23
  26. package/dist/agents/adapters/repository.js +0 -61
  27. package/dist/agents/adapters/research.d.ts +0 -26
  28. package/dist/agents/adapters/research.js +0 -59
  29. package/dist/agents/adapters/verification.d.ts +0 -36
  30. package/dist/agents/adapters/verification.js +0 -62
  31. package/dist/agents/cli-tools.d.ts +0 -1
  32. package/dist/agents/cli-tools.js +0 -5
  33. package/dist/agents/cli.d.ts +0 -15
  34. package/dist/agents/cli.js +0 -109
  35. package/dist/agents/contracts/messages.d.ts +0 -88
  36. package/dist/agents/contracts/messages.js +0 -138
  37. package/dist/agents/contracts/run.d.ts +0 -21
  38. package/dist/agents/contracts/run.js +0 -0
  39. package/dist/agents/index.d.ts +0 -1
  40. package/dist/agents/index.js +0 -5
  41. package/dist/agents/kernel/agent-kernel.d.ts +0 -51
  42. package/dist/agents/kernel/agent-kernel.js +0 -292
  43. package/dist/agents/kernel/trigger-resolver.d.ts +0 -19
  44. package/dist/agents/kernel/trigger-resolver.js +0 -157
  45. package/dist/agents/registry-helper.d.ts +0 -4
  46. package/dist/agents/registry-helper.js +0 -14
  47. package/dist/agents/registry.d.ts +0 -6
  48. package/dist/agents/registry.js +0 -98
  49. package/dist/agents/runtime-types.d.ts +0 -118
  50. package/dist/agents/runtime-types.js +0 -0
  51. package/dist/agents/spec-loader.d.ts +0 -18
  52. package/dist/agents/spec-loader.js +0 -55
  53. package/dist/agents/spec-normalizer.d.ts +0 -2
  54. package/dist/agents/spec-normalizer.js +0 -327
  55. package/dist/agents/spec-types.d.ts +0 -64
  56. package/dist/agents/spec-types.js +0 -0
  57. package/dist/agents/testing/agents-smoke.d.ts +0 -1
  58. package/dist/agents/testing/agents-smoke.js +0 -32
  59. package/dist/agents/testing/e2e-harness.d.ts +0 -44
  60. package/dist/agents/testing/e2e-harness.js +0 -504
  61. package/dist/api/agent-routes.d.ts +0 -13
  62. package/dist/api/agent-routes.js +0 -327
  63. package/dist/api/app.d.ts +0 -5
  64. package/dist/api/app.js +0 -361
  65. package/dist/api/auth/d1-database.d.ts +0 -3
  66. package/dist/api/auth/d1-database.js +0 -20
  67. package/dist/api/auth/d1-provider.d.ts +0 -79
  68. package/dist/api/auth/d1-provider.js +0 -92
  69. package/dist/api/auth/d1-store.d.ts +0 -114
  70. package/dist/api/auth/d1-store.js +0 -895
  71. package/dist/api/auth/memory-provider.d.ts +0 -77
  72. package/dist/api/auth/memory-provider.js +0 -249
  73. package/dist/api/auth/rbac.d.ts +0 -22
  74. package/dist/api/auth/rbac.js +0 -162
  75. package/dist/api/auth/tokens.d.ts +0 -18
  76. package/dist/api/auth/tokens.js +0 -56
  77. package/dist/api/capabilities.d.ts +0 -9
  78. package/dist/api/capabilities.js +0 -33
  79. package/dist/api/config.d.ts +0 -2
  80. package/dist/api/config.js +0 -77
  81. package/dist/api/http.d.ts +0 -28
  82. package/dist/api/http.js +0 -51
  83. package/dist/api/index.d.ts +0 -9
  84. package/dist/api/index.js +0 -18
  85. package/dist/api/operations-routes.d.ts +0 -11
  86. package/dist/api/operations-routes.js +0 -87
  87. package/dist/api/operations.d.ts +0 -3
  88. package/dist/api/operations.js +0 -26
  89. package/dist/api/project-routes.d.ts +0 -8
  90. package/dist/api/project-routes.js +0 -586
  91. package/dist/api/providers.d.ts +0 -2
  92. package/dist/api/providers.js +0 -62
  93. package/dist/api/railway.d.ts +0 -50
  94. package/dist/api/railway.js +0 -69
  95. package/dist/api/sdk-dispatch.d.ts +0 -5
  96. package/dist/api/sdk-dispatch.js +0 -13
  97. package/dist/api/sdk-routes.d.ts +0 -11
  98. package/dist/api/sdk-routes.js +0 -29
  99. package/dist/api/server.d.ts +0 -2
  100. package/dist/api/server.js +0 -10
  101. package/dist/api/templates.d.ts +0 -3
  102. package/dist/api/templates.js +0 -31
  103. package/dist/api/types.d.ts +0 -231
  104. package/dist/api/types.js +0 -0
  105. package/dist/api.d.ts +0 -1
  106. package/dist/api.js +0 -1
  107. package/dist/railway.d.ts +0 -1
  108. package/dist/railway.js +0 -4
  109. package/dist/services/agents.d.ts +0 -11
  110. package/dist/services/agents.js +0 -48
  111. package/dist/services/common.d.ts +0 -66
  112. package/dist/services/common.js +0 -212
  113. package/dist/services/index.d.ts +0 -6
  114. package/dist/services/index.js +0 -19
  115. package/dist/services/manager.d.ts +0 -267
  116. package/dist/services/manager.js +0 -1368
  117. package/dist/services/remote-runner.d.ts +0 -30
  118. package/dist/services/remote-runner.js +0 -230
  119. package/dist/services/workday-content.d.ts +0 -53
  120. package/dist/services/workday-content.js +0 -190
  121. package/dist/services/workday-manager.d.ts +0 -279
  122. package/dist/services/workday-manager.js +0 -163
  123. package/dist/services/workday-report.d.ts +0 -195
  124. package/dist/services/workday-report.js +0 -17
  125. package/dist/services/workday-start.d.ts +0 -195
  126. package/dist/services/workday-start.js +0 -17
  127. package/dist/services/worker-capacity.d.ts +0 -58
  128. package/dist/services/worker-capacity.js +0 -208
  129. package/dist/services/worker-pool-scaler.d.ts +0 -27
  130. package/dist/services/worker-pool-scaler.js +0 -127
  131. package/dist/services/worker.d.ts +0 -19
  132. package/dist/services/worker.js +0 -436
  133. package/templates/github/deploy.workflow.yml +0 -577
@@ -1,279 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createServiceSdk } from './common.ts';
3
- import { resolveManagerServiceConfig } from './manager.ts';
4
- type WorkdayManagerSdk = ReturnType<typeof createServiceSdk>;
5
- type WorkdayManagerConfig = ReturnType<typeof resolveManagerServiceConfig>;
6
- export declare function runScheduledWorkdayManager(options?: {
7
- sdk?: WorkdayManagerSdk;
8
- config?: WorkdayManagerConfig;
9
- now?: Date;
10
- }): Promise<{
11
- ok: boolean;
12
- skipped: boolean;
13
- reason: string;
14
- initial?: undefined;
15
- latest?: undefined;
16
- closed?: undefined;
17
- } | {
18
- ok: boolean;
19
- skipped: boolean;
20
- reason: string;
21
- initial: {
22
- ok: boolean;
23
- mode: "reconcile";
24
- managerId: string;
25
- projectId: string;
26
- environment: "local" | "prod" | "staging";
27
- insideWorkWindow: boolean;
28
- workPolicy: import("@treeseed/sdk").WorkdayPolicy;
29
- workDay: Record<string, unknown>;
30
- prioritySnapshot: import("@treeseed/sdk").PrioritySnapshot;
31
- seededTasks: {
32
- [x: string]: unknown;
33
- }[];
34
- queuedCount: number;
35
- activeLeases: number;
36
- desiredWorkers: number;
37
- scaleResult: import("@treeseed/sdk").WorkerPoolScaleResult;
38
- workdaySummary: Record<string, unknown>;
39
- };
40
- latest?: undefined;
41
- closed?: undefined;
42
- } | {
43
- ok: boolean;
44
- initial: {
45
- ok: boolean;
46
- mode: "reconcile";
47
- managerId: string;
48
- projectId: string;
49
- environment: "local" | "prod" | "staging";
50
- insideWorkWindow: boolean;
51
- workPolicy: import("@treeseed/sdk").WorkdayPolicy;
52
- workDay: Record<string, unknown>;
53
- prioritySnapshot: import("@treeseed/sdk").PrioritySnapshot;
54
- seededTasks: {
55
- [x: string]: unknown;
56
- }[];
57
- queuedCount: number;
58
- activeLeases: number;
59
- desiredWorkers: number;
60
- scaleResult: import("@treeseed/sdk").WorkerPoolScaleResult;
61
- workdaySummary: Record<string, unknown>;
62
- };
63
- latest: {
64
- ok: boolean;
65
- mode: "reconcile";
66
- managerId: string;
67
- projectId: string;
68
- environment: "local" | "prod" | "staging";
69
- insideWorkWindow: boolean;
70
- workPolicy: import("@treeseed/sdk").WorkdayPolicy;
71
- workDay: Record<string, unknown>;
72
- prioritySnapshot: import("@treeseed/sdk").PrioritySnapshot;
73
- seededTasks: {
74
- [x: string]: unknown;
75
- }[];
76
- queuedCount: number;
77
- activeLeases: number;
78
- desiredWorkers: number;
79
- scaleResult: import("@treeseed/sdk").WorkerPoolScaleResult;
80
- workdaySummary: Record<string, unknown>;
81
- };
82
- closed: {
83
- ok: boolean;
84
- mode: "reconcile";
85
- managerId: string;
86
- projectId: string;
87
- environment: "local" | "prod" | "staging";
88
- insideWorkWindow: boolean;
89
- workPolicy: import("@treeseed/sdk").WorkdayPolicy;
90
- workDay: Record<string, unknown>;
91
- prioritySnapshot: import("@treeseed/sdk").PrioritySnapshot;
92
- seededTasks: {
93
- [x: string]: unknown;
94
- }[];
95
- queuedCount: number;
96
- activeLeases: number;
97
- desiredWorkers: number;
98
- scaleResult: import("@treeseed/sdk").WorkerPoolScaleResult;
99
- workdaySummary: Record<string, unknown>;
100
- } | {
101
- ok: boolean;
102
- created: boolean;
103
- workDay: Record<string, unknown>;
104
- skipped?: undefined;
105
- reason?: undefined;
106
- prioritySnapshot?: undefined;
107
- } | {
108
- ok: boolean;
109
- created: boolean;
110
- skipped: boolean;
111
- reason: string;
112
- workDay?: undefined;
113
- prioritySnapshot?: undefined;
114
- } | {
115
- ok: boolean;
116
- created: boolean;
117
- workDay: import("@treeseed/sdk").SdkWorkDayEntity;
118
- prioritySnapshot: import("@treeseed/sdk").PrioritySnapshot;
119
- skipped?: undefined;
120
- reason?: undefined;
121
- } | {
122
- ok: boolean;
123
- skipped: boolean;
124
- reason: string;
125
- workDay?: undefined;
126
- summary?: undefined;
127
- scale?: undefined;
128
- } | {
129
- ok: boolean;
130
- workDay: import("@treeseed/sdk").SdkWorkDayEntity;
131
- summary: {
132
- contentSnapshot: {
133
- relativePath: string;
134
- slug: string;
135
- reportVersion: string;
136
- title: string;
137
- };
138
- capacity: {
139
- providerSplit: any;
140
- grantedDailyCredits: number;
141
- reservedCredits: number;
142
- consumedCredits: number;
143
- remainingDailyCredits: number | null;
144
- providerCount: number;
145
- laneCount: number;
146
- grantCount: number;
147
- };
148
- projectId: string;
149
- environment: "local" | "prod" | "staging";
150
- workDayId: string;
151
- state: string;
152
- totalTasks: number;
153
- completedTasks: number;
154
- failedTasks: number;
155
- queuedTasks: number;
156
- activeTasks: number;
157
- dailyTaskCreditBudget: number;
158
- usedTaskCredits: number;
159
- remainingTaskCredits: number;
160
- creditLedgerEntries: number;
161
- prioritySnapshotId: string;
162
- priorityItemCount: number;
163
- priorityItems: import("@treeseed/sdk").PrioritySnapshotItem[];
164
- taskItems: {
165
- id: string;
166
- agentId: string;
167
- type: string;
168
- state: string;
169
- priority: number;
170
- idempotencyKey: string;
171
- createdAt: string;
172
- startedAt: string;
173
- completedAt: string;
174
- lastErrorCode: string;
175
- lastErrorMessage: string;
176
- lastEventKind: string;
177
- outputCount: number;
178
- changedFiles: string[];
179
- }[];
180
- changedFiles: string[];
181
- releases: {
182
- id: string;
183
- deploymentKind: string;
184
- status: string;
185
- releaseTag: string;
186
- commitSha: string;
187
- sourceRef: string;
188
- startedAt: string;
189
- finishedAt: string;
190
- createdAt: string;
191
- }[];
192
- scaleDecision: import("@treeseed/sdk").ScaleDecision;
193
- scaleResult: import("@treeseed/sdk").WorkerPoolScaleResult;
194
- generatedAt: string;
195
- };
196
- scale: import("@treeseed/sdk").WorkerPoolScaleResult;
197
- skipped?: undefined;
198
- reason?: undefined;
199
- } | {
200
- ok: boolean;
201
- skipped: boolean;
202
- reason: string;
203
- workDayId?: undefined;
204
- summary?: undefined;
205
- } | {
206
- ok: boolean;
207
- workDayId: unknown;
208
- summary: {
209
- contentSnapshot: {
210
- relativePath: string;
211
- slug: string;
212
- reportVersion: string;
213
- title: string;
214
- };
215
- capacity: {
216
- providerSplit: any;
217
- grantedDailyCredits: number;
218
- reservedCredits: number;
219
- consumedCredits: number;
220
- remainingDailyCredits: number | null;
221
- providerCount: number;
222
- laneCount: number;
223
- grantCount: number;
224
- };
225
- projectId: string;
226
- environment: "local" | "prod" | "staging";
227
- workDayId: string;
228
- state: string;
229
- totalTasks: number;
230
- completedTasks: number;
231
- failedTasks: number;
232
- queuedTasks: number;
233
- activeTasks: number;
234
- dailyTaskCreditBudget: number;
235
- usedTaskCredits: number;
236
- remainingTaskCredits: number;
237
- creditLedgerEntries: number;
238
- prioritySnapshotId: string;
239
- priorityItemCount: number;
240
- priorityItems: import("@treeseed/sdk").PrioritySnapshotItem[];
241
- taskItems: {
242
- id: string;
243
- agentId: string;
244
- type: string;
245
- state: string;
246
- priority: number;
247
- idempotencyKey: string;
248
- createdAt: string;
249
- startedAt: string;
250
- completedAt: string;
251
- lastErrorCode: string;
252
- lastErrorMessage: string;
253
- lastEventKind: string;
254
- outputCount: number;
255
- changedFiles: string[];
256
- }[];
257
- changedFiles: string[];
258
- releases: {
259
- id: string;
260
- deploymentKind: string;
261
- status: string;
262
- releaseTag: string;
263
- commitSha: string;
264
- sourceRef: string;
265
- startedAt: string;
266
- finishedAt: string;
267
- createdAt: string;
268
- }[];
269
- scaleDecision: import("@treeseed/sdk").ScaleDecision;
270
- scaleResult: import("@treeseed/sdk").WorkerPoolScaleResult;
271
- generatedAt: string;
272
- };
273
- skipped?: undefined;
274
- reason?: undefined;
275
- };
276
- skipped?: undefined;
277
- reason?: undefined;
278
- }>;
279
- export {};
@@ -1,163 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from "node:url";
3
- import { createServiceSdk } from "./common.js";
4
- import {
5
- resolveManagerServiceConfig,
6
- runManagerAction,
7
- runManagerCycle
8
- } from "./manager.js";
9
- function readDate(value) {
10
- if (typeof value !== "string") return null;
11
- const parsed = new Date(value);
12
- return Number.isFinite(parsed.valueOf()) ? parsed : null;
13
- }
14
- function workdayCloseDeadline(workDay, durationMinutes, now) {
15
- const startedAt = readDate(workDay?.startedAt) ?? readDate(workDay?.started_at) ?? now;
16
- return new Date(startedAt.valueOf() + durationMinutes * 60 * 1e3);
17
- }
18
- async function sleep(ms) {
19
- await new Promise((resolve) => setTimeout(resolve, ms));
20
- }
21
- async function acquireLease(sdk, config, workDayId) {
22
- if (typeof sdk.claimWorkdayManagerLease !== "function") {
23
- return { payload: { id: `local:${config.managerId}`, managerId: config.managerId } };
24
- }
25
- return sdk.claimWorkdayManagerLease({
26
- projectId: config.projectId,
27
- environment: config.environment,
28
- workDayId,
29
- managerId: config.managerId,
30
- ttlSeconds: Math.max(60, Math.ceil(config.pollIntervalMs / 1e3) * 4),
31
- staleAfterSeconds: Math.max(120, Math.ceil(config.pollIntervalMs / 1e3) * 8),
32
- metadata: {
33
- service: "workdayManager"
34
- }
35
- });
36
- }
37
- async function heartbeatLease(sdk, config, leaseId, workDayId) {
38
- if (typeof sdk.claimWorkdayManagerLease !== "function") return;
39
- await sdk.claimWorkdayManagerLease({
40
- id: leaseId,
41
- projectId: config.projectId,
42
- environment: config.environment,
43
- workDayId,
44
- managerId: config.managerId,
45
- ttlSeconds: Math.max(60, Math.ceil(config.pollIntervalMs / 1e3) * 4),
46
- metadata: {
47
- service: "workdayManager",
48
- heartbeat: true
49
- }
50
- });
51
- }
52
- async function releaseLease(sdk, managerId, leaseId) {
53
- if (!leaseId || typeof sdk.releaseWorkdayManagerLease !== "function") return;
54
- await sdk.releaseWorkdayManagerLease({ id: leaseId, managerId }).catch(() => null);
55
- }
56
- async function recordRunnerCloseDecision(sdk, config, workDayId, action, reason) {
57
- if (typeof sdk.recordRunnerScaleDecision !== "function") return;
58
- const runners = typeof sdk.listWorkerRunners === "function" ? (await sdk.listWorkerRunners(config.projectId, config.environment).catch(() => ({ payload: [] }))).payload ?? [] : [];
59
- if (runners.length === 0) {
60
- await sdk.recordRunnerScaleDecision({
61
- projectId: config.projectId,
62
- environment: config.environment,
63
- workDayId,
64
- action: "noop",
65
- reason: `${reason}:no_runners`,
66
- metadata: { service: "workdayManager" }
67
- }).catch(() => null);
68
- return;
69
- }
70
- for (const runner of runners) {
71
- await sdk.recordRunnerScaleDecision({
72
- projectId: config.projectId,
73
- environment: config.environment,
74
- workDayId,
75
- runnerId: typeof runner.runnerId === "string" ? runner.runnerId : null,
76
- runnerServiceName: typeof runner.runnerServiceName === "string" ? runner.runnerServiceName : null,
77
- action,
78
- reason,
79
- metadata: { service: "workdayManager" }
80
- }).catch(() => null);
81
- }
82
- }
83
- async function runScheduledWorkdayManager(options = {}) {
84
- const sdk = options.sdk ?? createServiceSdk();
85
- const config = options.config ?? {
86
- ...resolveManagerServiceConfig(),
87
- mode: "reconcile"
88
- };
89
- let now = options.now ?? /* @__PURE__ */ new Date();
90
- const policyEnvelope = await sdk.getWorkPolicy(config.projectId, config.environment);
91
- const policy = policyEnvelope.payload ?? await sdk.upsertWorkPolicy({
92
- projectId: config.projectId,
93
- environment: config.environment,
94
- schedule: config.defaultSchedule,
95
- enabled: true,
96
- startCron: process.env.TREESEED_WORKDAY_START_CRON?.trim() || "0 9 * * 1-5",
97
- durationMinutes: Number(process.env.TREESEED_WORKDAY_DURATION_MINUTES ?? 480),
98
- maxRunners: config.autoscale.maxWorkers,
99
- maxWorkersPerRunner: Number(process.env.TREESEED_RUNNER_MAX_LOCAL_WORKERS ?? 4),
100
- dailyCreditBudget: config.dailyTaskCreditBudget,
101
- closeoutGraceMinutes: Number(process.env.TREESEED_WORKDAY_CLOSEOUT_GRACE_MINUTES ?? 15),
102
- dailyTaskCreditBudget: config.dailyTaskCreditBudget,
103
- maxQueuedTasks: config.maxQueuedTasks,
104
- maxQueuedCredits: config.maxQueuedCredits,
105
- autoscale: config.autoscale,
106
- creditWeights: config.creditWeights,
107
- metadata: { managedBy: "workdayManager" }
108
- }).then((created) => created.payload);
109
- if (!policy?.enabled) {
110
- return { ok: true, skipped: true, reason: "workday_policy_disabled" };
111
- }
112
- const requests = typeof sdk.listWorkdayRequests === "function" ? (await sdk.listWorkdayRequests(config.projectId, config.environment, "pending").catch(() => ({ payload: [] }))).payload ?? [] : [];
113
- const oneOffRunRequested = requests.some((entry) => entry.type === "one_off_run");
114
- const initial = await runManagerCycle({ sdk, config, now });
115
- const workDay = initial.workDay;
116
- if (!workDay && !oneOffRunRequested) {
117
- return { ok: true, skipped: true, reason: "no_workday_started", initial };
118
- }
119
- const lease = await acquireLease(sdk, config, workDay ? String(workDay.id ?? "") : null);
120
- if (!lease.payload) {
121
- return { ok: true, skipped: true, reason: "healthy_manager_lease_exists" };
122
- }
123
- const leaseId = String(lease.payload.id ?? "");
124
- let latest = initial;
125
- try {
126
- let activeWorkDay = workDay;
127
- let closeDeadline = workdayCloseDeadline(activeWorkDay, Number(policy.durationMinutes ?? 480), now);
128
- while (Date.now() < closeDeadline.valueOf()) {
129
- await heartbeatLease(sdk, config, leaseId, activeWorkDay ? String(activeWorkDay.id ?? "") : null);
130
- await sleep(config.pollIntervalMs);
131
- now = /* @__PURE__ */ new Date();
132
- latest = await runManagerCycle({ sdk, config, now });
133
- activeWorkDay = latest.workDay;
134
- closeDeadline = workdayCloseDeadline(activeWorkDay, Number(policy.durationMinutes ?? 480), now);
135
- }
136
- const workDayId = activeWorkDay ? String(activeWorkDay.id ?? "") : null;
137
- await recordRunnerCloseDecision(sdk, config, workDayId, "drain", "workday_closeout");
138
- const graceMs = Number(policy.closeoutGraceMinutes ?? 15) * 60 * 1e3;
139
- const graceEnd = Date.now() + graceMs;
140
- while (Date.now() < graceEnd) {
141
- const result = await runManagerCycle({ sdk, config, now: /* @__PURE__ */ new Date() });
142
- latest = result;
143
- if (Number(result.queuedCount ?? 0) === 0 && Number(result.activeLeases ?? 0) === 0) {
144
- break;
145
- }
146
- await sleep(config.pollIntervalMs);
147
- }
148
- const closed = await runManagerAction({ sdk, config, mode: "close-workday" });
149
- await recordRunnerCloseDecision(sdk, config, workDayId, "sleep", "workday_closed");
150
- return { ok: true, initial, latest, closed };
151
- } finally {
152
- await releaseLease(sdk, config.managerId, leaseId);
153
- }
154
- }
155
- const currentFile = fileURLToPath(import.meta.url);
156
- const entryFile = process.argv[1] ?? "";
157
- if (entryFile === currentFile) {
158
- process.stdout.write(`${JSON.stringify(await runScheduledWorkdayManager(), null, 2)}
159
- `);
160
- }
161
- export {
162
- runScheduledWorkdayManager
163
- };
@@ -1,195 +0,0 @@
1
- #!/usr/bin/env node
2
- export declare function runWorkdayReport(): Promise<{
3
- ok: boolean;
4
- mode: "reconcile";
5
- managerId: string;
6
- projectId: string;
7
- environment: "local" | "prod" | "staging";
8
- insideWorkWindow: boolean;
9
- workPolicy: import("@treeseed/sdk").WorkdayPolicy;
10
- workDay: Record<string, unknown>;
11
- prioritySnapshot: import("@treeseed/sdk").PrioritySnapshot;
12
- seededTasks: {
13
- [x: string]: unknown;
14
- }[];
15
- queuedCount: number;
16
- activeLeases: number;
17
- desiredWorkers: number;
18
- scaleResult: import("@treeseed/sdk").WorkerPoolScaleResult;
19
- workdaySummary: Record<string, unknown>;
20
- } | {
21
- ok: boolean;
22
- created: boolean;
23
- workDay: Record<string, unknown>;
24
- skipped?: undefined;
25
- reason?: undefined;
26
- prioritySnapshot?: undefined;
27
- } | {
28
- ok: boolean;
29
- created: boolean;
30
- skipped: boolean;
31
- reason: string;
32
- workDay?: undefined;
33
- prioritySnapshot?: undefined;
34
- } | {
35
- ok: boolean;
36
- created: boolean;
37
- workDay: import("@treeseed/sdk").SdkWorkDayEntity;
38
- prioritySnapshot: import("@treeseed/sdk").PrioritySnapshot;
39
- skipped?: undefined;
40
- reason?: undefined;
41
- } | {
42
- ok: boolean;
43
- skipped: boolean;
44
- reason: string;
45
- workDay?: undefined;
46
- summary?: undefined;
47
- scale?: undefined;
48
- } | {
49
- ok: boolean;
50
- workDay: import("@treeseed/sdk").SdkWorkDayEntity;
51
- summary: {
52
- contentSnapshot: {
53
- relativePath: string;
54
- slug: string;
55
- reportVersion: string;
56
- title: string;
57
- };
58
- capacity: {
59
- providerSplit: any;
60
- grantedDailyCredits: number;
61
- reservedCredits: number;
62
- consumedCredits: number;
63
- remainingDailyCredits: number | null;
64
- providerCount: number;
65
- laneCount: number;
66
- grantCount: number;
67
- };
68
- projectId: string;
69
- environment: "local" | "prod" | "staging";
70
- workDayId: string;
71
- state: string;
72
- totalTasks: number;
73
- completedTasks: number;
74
- failedTasks: number;
75
- queuedTasks: number;
76
- activeTasks: number;
77
- dailyTaskCreditBudget: number;
78
- usedTaskCredits: number;
79
- remainingTaskCredits: number;
80
- creditLedgerEntries: number;
81
- prioritySnapshotId: string;
82
- priorityItemCount: number;
83
- priorityItems: import("@treeseed/sdk").PrioritySnapshotItem[];
84
- taskItems: {
85
- id: string;
86
- agentId: string;
87
- type: string;
88
- state: string;
89
- priority: number;
90
- idempotencyKey: string;
91
- createdAt: string;
92
- startedAt: string;
93
- completedAt: string;
94
- lastErrorCode: string;
95
- lastErrorMessage: string;
96
- lastEventKind: string;
97
- outputCount: number;
98
- changedFiles: string[];
99
- }[];
100
- changedFiles: string[];
101
- releases: {
102
- id: string;
103
- deploymentKind: string;
104
- status: string;
105
- releaseTag: string;
106
- commitSha: string;
107
- sourceRef: string;
108
- startedAt: string;
109
- finishedAt: string;
110
- createdAt: string;
111
- }[];
112
- scaleDecision: import("@treeseed/sdk").ScaleDecision;
113
- scaleResult: import("@treeseed/sdk").WorkerPoolScaleResult;
114
- generatedAt: string;
115
- };
116
- scale: import("@treeseed/sdk").WorkerPoolScaleResult;
117
- skipped?: undefined;
118
- reason?: undefined;
119
- } | {
120
- ok: boolean;
121
- skipped: boolean;
122
- reason: string;
123
- workDayId?: undefined;
124
- summary?: undefined;
125
- } | {
126
- ok: boolean;
127
- workDayId: unknown;
128
- summary: {
129
- contentSnapshot: {
130
- relativePath: string;
131
- slug: string;
132
- reportVersion: string;
133
- title: string;
134
- };
135
- capacity: {
136
- providerSplit: any;
137
- grantedDailyCredits: number;
138
- reservedCredits: number;
139
- consumedCredits: number;
140
- remainingDailyCredits: number | null;
141
- providerCount: number;
142
- laneCount: number;
143
- grantCount: number;
144
- };
145
- projectId: string;
146
- environment: "local" | "prod" | "staging";
147
- workDayId: string;
148
- state: string;
149
- totalTasks: number;
150
- completedTasks: number;
151
- failedTasks: number;
152
- queuedTasks: number;
153
- activeTasks: number;
154
- dailyTaskCreditBudget: number;
155
- usedTaskCredits: number;
156
- remainingTaskCredits: number;
157
- creditLedgerEntries: number;
158
- prioritySnapshotId: string;
159
- priorityItemCount: number;
160
- priorityItems: import("@treeseed/sdk").PrioritySnapshotItem[];
161
- taskItems: {
162
- id: string;
163
- agentId: string;
164
- type: string;
165
- state: string;
166
- priority: number;
167
- idempotencyKey: string;
168
- createdAt: string;
169
- startedAt: string;
170
- completedAt: string;
171
- lastErrorCode: string;
172
- lastErrorMessage: string;
173
- lastEventKind: string;
174
- outputCount: number;
175
- changedFiles: string[];
176
- }[];
177
- changedFiles: string[];
178
- releases: {
179
- id: string;
180
- deploymentKind: string;
181
- status: string;
182
- releaseTag: string;
183
- commitSha: string;
184
- sourceRef: string;
185
- startedAt: string;
186
- finishedAt: string;
187
- createdAt: string;
188
- }[];
189
- scaleDecision: import("@treeseed/sdk").ScaleDecision;
190
- scaleResult: import("@treeseed/sdk").WorkerPoolScaleResult;
191
- generatedAt: string;
192
- };
193
- skipped?: undefined;
194
- reason?: undefined;
195
- }>;
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from "node:url";
3
- import { runManagerAction } from "./manager.js";
4
- async function runWorkdayReport() {
5
- return runManagerAction({
6
- mode: "report-workday"
7
- });
8
- }
9
- const currentFile = fileURLToPath(import.meta.url);
10
- const entryFile = process.argv[1] ?? "";
11
- if (entryFile === currentFile) {
12
- process.stdout.write(`${JSON.stringify(await runWorkdayReport(), null, 2)}
13
- `);
14
- }
15
- export {
16
- runWorkdayReport
17
- };