@treeseed/agent 0.8.5
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.
- package/Dockerfile +7 -0
- package/README.md +198 -0
- package/dist/agent-runtime.d.ts +17 -0
- package/dist/agent-runtime.js +117 -0
- package/dist/agents/adapters/execution.d.ts +41 -0
- package/dist/agents/adapters/execution.js +73 -0
- package/dist/agents/adapters/mutations.d.ts +22 -0
- package/dist/agents/adapters/mutations.js +30 -0
- package/dist/agents/adapters/notification.d.ts +26 -0
- package/dist/agents/adapters/notification.js +46 -0
- package/dist/agents/adapters/repository.d.ts +28 -0
- package/dist/agents/adapters/repository.js +61 -0
- package/dist/agents/adapters/research.d.ts +26 -0
- package/dist/agents/adapters/research.js +59 -0
- package/dist/agents/adapters/verification.d.ts +36 -0
- package/dist/agents/adapters/verification.js +62 -0
- package/dist/agents/cli-tools.d.ts +1 -0
- package/dist/agents/cli-tools.js +5 -0
- package/dist/agents/cli.d.ts +15 -0
- package/dist/agents/cli.js +109 -0
- package/dist/agents/contracts/messages.d.ts +88 -0
- package/dist/agents/contracts/messages.js +138 -0
- package/dist/agents/contracts/run.d.ts +21 -0
- package/dist/agents/contracts/run.js +0 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.js +5 -0
- package/dist/agents/kernel/agent-kernel.d.ts +63 -0
- package/dist/agents/kernel/agent-kernel.js +291 -0
- package/dist/agents/kernel/trigger-resolver.d.ts +19 -0
- package/dist/agents/kernel/trigger-resolver.js +157 -0
- package/dist/agents/registry-helper.d.ts +4 -0
- package/dist/agents/registry-helper.js +14 -0
- package/dist/agents/registry.d.ts +6 -0
- package/dist/agents/registry.js +98 -0
- package/dist/agents/runtime-types.d.ts +118 -0
- package/dist/agents/runtime-types.js +0 -0
- package/dist/agents/spec-loader.d.ts +18 -0
- package/dist/agents/spec-loader.js +54 -0
- package/dist/agents/spec-normalizer.d.ts +2 -0
- package/dist/agents/spec-normalizer.js +327 -0
- package/dist/agents/spec-types.d.ts +64 -0
- package/dist/agents/spec-types.js +0 -0
- package/dist/agents/testing/agents-smoke.d.ts +1 -0
- package/dist/agents/testing/agents-smoke.js +32 -0
- package/dist/agents/testing/e2e-harness.d.ts +44 -0
- package/dist/agents/testing/e2e-harness.js +503 -0
- package/dist/api/agent-routes.d.ts +13 -0
- package/dist/api/agent-routes.js +327 -0
- package/dist/api/app.d.ts +8 -0
- package/dist/api/app.js +444 -0
- package/dist/api/auth/d1-database.d.ts +3 -0
- package/dist/api/auth/d1-database.js +20 -0
- package/dist/api/auth/d1-provider.d.ts +79 -0
- package/dist/api/auth/d1-provider.js +92 -0
- package/dist/api/auth/d1-store.d.ts +114 -0
- package/dist/api/auth/d1-store.js +895 -0
- package/dist/api/auth/memory-provider.d.ts +77 -0
- package/dist/api/auth/memory-provider.js +249 -0
- package/dist/api/auth/rbac.d.ts +22 -0
- package/dist/api/auth/rbac.js +162 -0
- package/dist/api/auth/tokens.d.ts +18 -0
- package/dist/api/auth/tokens.js +56 -0
- package/dist/api/capabilities.d.ts +9 -0
- package/dist/api/capabilities.js +33 -0
- package/dist/api/config.d.ts +2 -0
- package/dist/api/config.js +77 -0
- package/dist/api/http.d.ts +28 -0
- package/dist/api/http.js +51 -0
- package/dist/api/index.d.ts +9 -0
- package/dist/api/index.js +20 -0
- package/dist/api/operations-routes.d.ts +11 -0
- package/dist/api/operations-routes.js +87 -0
- package/dist/api/operations.d.ts +3 -0
- package/dist/api/operations.js +26 -0
- package/dist/api/project-routes.d.ts +8 -0
- package/dist/api/project-routes.js +585 -0
- package/dist/api/providers.d.ts +2 -0
- package/dist/api/providers.js +62 -0
- package/dist/api/railway.d.ts +51 -0
- package/dist/api/railway.js +71 -0
- package/dist/api/sdk-dispatch.d.ts +5 -0
- package/dist/api/sdk-dispatch.js +13 -0
- package/dist/api/sdk-routes.d.ts +11 -0
- package/dist/api/sdk-routes.js +29 -0
- package/dist/api/server.d.ts +2 -0
- package/dist/api/server.js +10 -0
- package/dist/api/templates.d.ts +3 -0
- package/dist/api/templates.js +31 -0
- package/dist/api/types.d.ts +237 -0
- package/dist/api/types.js +0 -0
- package/dist/env.yaml +957 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +41 -0
- package/dist/scripts/assert-release-tag-version.d.ts +1 -0
- package/dist/scripts/assert-release-tag-version.js +20 -0
- package/dist/scripts/build-dist.d.ts +1 -0
- package/dist/scripts/build-dist.js +106 -0
- package/dist/scripts/package-tools.d.ts +1 -0
- package/dist/scripts/package-tools.js +7 -0
- package/dist/scripts/publish-package.d.ts +1 -0
- package/dist/scripts/publish-package.js +24 -0
- package/dist/scripts/release-verify.d.ts +1 -0
- package/dist/scripts/release-verify.js +152 -0
- package/dist/scripts/test-smoke.d.ts +1 -0
- package/dist/scripts/test-smoke.js +23 -0
- package/dist/scripts/treeseed-agent-api.d.ts +2 -0
- package/dist/scripts/treeseed-agent-api.js +25 -0
- package/dist/scripts/treeseed-agent-service.d.ts +2 -0
- package/dist/scripts/treeseed-agent-service.js +36 -0
- package/dist/scripts/treeseed-agents.d.ts +2 -0
- package/dist/scripts/treeseed-agents.js +13 -0
- package/dist/services/agents.d.ts +17 -0
- package/dist/services/agents.js +48 -0
- package/dist/services/common.d.ts +66 -0
- package/dist/services/common.js +212 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.js +19 -0
- package/dist/services/manager.d.ts +333 -0
- package/dist/services/manager.js +1368 -0
- package/dist/services/remote-runner.d.ts +30 -0
- package/dist/services/remote-runner.js +230 -0
- package/dist/services/workday-content.d.ts +53 -0
- package/dist/services/workday-content.js +190 -0
- package/dist/services/workday-manager.d.ts +391 -0
- package/dist/services/workday-manager.js +163 -0
- package/dist/services/workday-report.d.ts +238 -0
- package/dist/services/workday-report.js +17 -0
- package/dist/services/workday-start.d.ts +238 -0
- package/dist/services/workday-start.js +17 -0
- package/dist/services/worker-capacity.d.ts +58 -0
- package/dist/services/worker-capacity.js +208 -0
- package/dist/services/worker-pool-scaler.d.ts +27 -0
- package/dist/services/worker-pool-scaler.js +127 -0
- package/dist/services/worker.d.ts +19 -0
- package/dist/services/worker.js +436 -0
- package/dist/templates/github/deploy-processing.workflow.yml +119 -0
- package/package.json +136 -0
- package/templates/github/deploy-processing.workflow.yml +119 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { AgentSdk } from "@treeseed/sdk";
|
|
3
|
+
import { CloudflareQueuePullClient } from "@treeseed/sdk/remote";
|
|
4
|
+
function integerFromEnv(name, fallback) {
|
|
5
|
+
const value = process.env[name];
|
|
6
|
+
if (!value) return fallback;
|
|
7
|
+
const parsed = Number.parseInt(value, 10);
|
|
8
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
9
|
+
}
|
|
10
|
+
function resolveServiceRepoRoot() {
|
|
11
|
+
return process.env.TREESEED_AGENT_REPO_ROOT?.trim() || process.cwd();
|
|
12
|
+
}
|
|
13
|
+
function createServiceSdk() {
|
|
14
|
+
return AgentSdk.createLocal({
|
|
15
|
+
repoRoot: resolveServiceRepoRoot(),
|
|
16
|
+
databaseName: process.env.TREESEED_AGENT_D1_DATABASE ?? "karyon-docs-site-data",
|
|
17
|
+
persistTo: process.env.TREESEED_AGENT_D1_PERSIST_TO ?? void 0
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function createQueueClientConfig(token) {
|
|
21
|
+
const accountId = process.env.CLOUDFLARE_ACCOUNT_ID?.trim();
|
|
22
|
+
const queueId = process.env.TREESEED_QUEUE_ID?.trim();
|
|
23
|
+
if (!accountId || !queueId || !token) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
accountId,
|
|
28
|
+
queueId,
|
|
29
|
+
token,
|
|
30
|
+
apiBaseUrl: process.env.TREESEED_QUEUE_API_BASE_URL?.trim() || void 0
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function createQueueClient() {
|
|
34
|
+
const config = createQueueClientConfig(process.env.TREESEED_QUEUE_PULL_TOKEN?.trim() || "");
|
|
35
|
+
if (!config) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return new CloudflareQueuePullClient(config);
|
|
39
|
+
}
|
|
40
|
+
function createQueuePushClient() {
|
|
41
|
+
const config = createQueueClientConfig(
|
|
42
|
+
process.env.TREESEED_QUEUE_PUSH_TOKEN?.trim() || process.env.CLOUDFLARE_API_TOKEN?.trim() || ""
|
|
43
|
+
);
|
|
44
|
+
if (!config) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const apiBaseUrl = config.apiBaseUrl ?? "https://api.cloudflare.com/client/v4/accounts";
|
|
48
|
+
const baseUrl = `${apiBaseUrl.replace(/\/$/u, "")}/${config.accountId}/queues/${config.queueId}`;
|
|
49
|
+
return {
|
|
50
|
+
async enqueue(request) {
|
|
51
|
+
const response = await fetch(`${baseUrl}/messages`, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
headers: {
|
|
54
|
+
accept: "application/json",
|
|
55
|
+
authorization: `Bearer ${config.token}`,
|
|
56
|
+
"content-type": "application/json"
|
|
57
|
+
},
|
|
58
|
+
body: JSON.stringify({
|
|
59
|
+
body: request.message,
|
|
60
|
+
content_type: "json",
|
|
61
|
+
delay_seconds: request.delaySeconds ?? 0
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
const payload = await response.json().catch(() => ({}));
|
|
65
|
+
if (!response.ok || payload.success === false) {
|
|
66
|
+
throw new Error(payload.errors?.[0]?.message ?? `Queue request failed with ${response.status}.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function queueEnvelopeForTask(task) {
|
|
72
|
+
return {
|
|
73
|
+
messageId: crypto.randomUUID(),
|
|
74
|
+
taskId: String(task.id ?? ""),
|
|
75
|
+
workDayId: String(task.workDayId ?? task.work_day_id ?? ""),
|
|
76
|
+
agentId: String(task.agentId ?? task.agent_id ?? ""),
|
|
77
|
+
taskType: String(task.type ?? ""),
|
|
78
|
+
idempotencyKey: String(task.idempotencyKey ?? task.idempotency_key ?? ""),
|
|
79
|
+
attempt: Number(task.attemptCount ?? task.attempt_count ?? 0) + 1,
|
|
80
|
+
payloadRef: `d1:tasks/${String(task.id ?? "")}`,
|
|
81
|
+
graphVersion: task.graphVersion !== void 0 && task.graphVersion !== null ? String(task.graphVersion) : task.graph_version !== void 0 && task.graph_version !== null ? String(task.graph_version) : null,
|
|
82
|
+
budgetHint: 1
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async function enqueueTaskFromSdk(sdk, request) {
|
|
86
|
+
const queue = createQueuePushClient();
|
|
87
|
+
if (!queue) {
|
|
88
|
+
throw new Error("Queue push client not configured.");
|
|
89
|
+
}
|
|
90
|
+
const task = await sdk.get({ model: "task", id: request.taskId });
|
|
91
|
+
if (!task.payload) {
|
|
92
|
+
throw new Error("Unknown task.");
|
|
93
|
+
}
|
|
94
|
+
await queue.enqueue({
|
|
95
|
+
message: queueEnvelopeForTask(task.payload),
|
|
96
|
+
delaySeconds: request.deliveryDelaySeconds ?? 0
|
|
97
|
+
});
|
|
98
|
+
await sdk.recordTaskProgress({
|
|
99
|
+
id: request.taskId,
|
|
100
|
+
state: "queued",
|
|
101
|
+
appendEvent: { kind: "queued", data: { queueName: request.queueName ?? null } },
|
|
102
|
+
actor: request.actor
|
|
103
|
+
});
|
|
104
|
+
return { ok: true, taskId: request.taskId, queued: true };
|
|
105
|
+
}
|
|
106
|
+
async function buildTaskContext(sdk, taskId) {
|
|
107
|
+
const context = await sdk.getManagerContext(taskId);
|
|
108
|
+
const task = context.payload.task;
|
|
109
|
+
const agent = task ? (await sdk.get({ model: "agent", slug: String(task.agentId) })).payload : null;
|
|
110
|
+
return {
|
|
111
|
+
...context.payload,
|
|
112
|
+
agent
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async function seedRootTasks(sdk, workDayId) {
|
|
116
|
+
const specs = await sdk.listAgentSpecs({ enabled: true });
|
|
117
|
+
const created = [];
|
|
118
|
+
for (const spec of specs) {
|
|
119
|
+
const hasStartTrigger = spec.triggers.some((trigger) => trigger.type === "startup" || trigger.type === "schedule");
|
|
120
|
+
if (!hasStartTrigger) continue;
|
|
121
|
+
created.push(await sdk.createTask({
|
|
122
|
+
workDayId,
|
|
123
|
+
agentId: spec.slug,
|
|
124
|
+
type: "agent_root",
|
|
125
|
+
priority: 100,
|
|
126
|
+
idempotencyKey: `${workDayId}:${spec.slug}:root`,
|
|
127
|
+
payload: {
|
|
128
|
+
agentSlug: spec.slug,
|
|
129
|
+
handler: spec.handler,
|
|
130
|
+
triggerKinds: spec.triggers.map((entry) => entry.type)
|
|
131
|
+
},
|
|
132
|
+
graphVersion: null,
|
|
133
|
+
actor: "manager"
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
return created;
|
|
137
|
+
}
|
|
138
|
+
async function seedGraphRefreshTask(sdk, request) {
|
|
139
|
+
const task = await sdk.createTask({
|
|
140
|
+
workDayId: request.workDayId,
|
|
141
|
+
agentId: "system",
|
|
142
|
+
type: "refresh_project_graph",
|
|
143
|
+
priority: 1e3,
|
|
144
|
+
idempotencyKey: `${request.workDayId}:refresh_project_graph`,
|
|
145
|
+
payload: {
|
|
146
|
+
projectId: request.projectId,
|
|
147
|
+
repositoryId: request.repositoryId ?? request.projectId
|
|
148
|
+
},
|
|
149
|
+
graphVersion: null,
|
|
150
|
+
actor: request.actor ?? "manager"
|
|
151
|
+
});
|
|
152
|
+
return task.payload;
|
|
153
|
+
}
|
|
154
|
+
async function startAndSeedWorkday(sdk, request) {
|
|
155
|
+
const workDay = await sdk.startWorkDay({
|
|
156
|
+
id: request.id,
|
|
157
|
+
projectId: request.projectId,
|
|
158
|
+
capacityBudget: request.capacityBudget,
|
|
159
|
+
graphVersion: null,
|
|
160
|
+
summary: { graphRefresh: { state: "queued" } },
|
|
161
|
+
actor: request.actor ?? "manager"
|
|
162
|
+
});
|
|
163
|
+
const graphTask = workDay.payload ? await seedGraphRefreshTask(sdk, {
|
|
164
|
+
workDayId: String(workDay.payload.id),
|
|
165
|
+
projectId: request.projectId,
|
|
166
|
+
actor: request.actor ?? "manager"
|
|
167
|
+
}) : null;
|
|
168
|
+
const tasks = workDay.payload ? await seedRootTasks(sdk, String(workDay.payload.id)) : [];
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
workDay: workDay.payload,
|
|
172
|
+
seededTasks: [graphTask, ...tasks.map((entry) => entry.payload).filter(Boolean)].filter(Boolean)
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function resolveManagerConfig() {
|
|
176
|
+
return {
|
|
177
|
+
host: process.env.HOST?.trim() || "0.0.0.0",
|
|
178
|
+
port: integerFromEnv("PORT", 3100),
|
|
179
|
+
projectId: process.env.TREESEED_PROJECT_ID?.trim() || "treeseed-market",
|
|
180
|
+
defaultCapacityBudget: integerFromEnv("TREESEED_WORKDAY_CAPACITY_BUDGET", 100)
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function resolveWorkerConfig() {
|
|
184
|
+
return {
|
|
185
|
+
workerId: process.env.TREESEED_WORKER_ID?.trim() || `worker-${process.pid}`,
|
|
186
|
+
batchSize: integerFromEnv("TREESEED_QUEUE_BATCH_SIZE", integerFromEnv("TREESEED_RUNNER_MAX_LOCAL_WORKERS", 4)),
|
|
187
|
+
maxLocalWorkers: integerFromEnv("TREESEED_RUNNER_MAX_LOCAL_WORKERS", 4),
|
|
188
|
+
runnerServiceName: process.env.TREESEED_RUNNER_SERVICE_NAME?.trim() || process.env.RAILWAY_SERVICE_NAME?.trim() || `worker-runner-${process.pid}`,
|
|
189
|
+
volumeRoot: process.env.TREESEED_RUNNER_VOLUME_ROOT?.trim() || process.env.RAILWAY_VOLUME_MOUNT_PATH?.trim() || ".treeseed-runner",
|
|
190
|
+
volumeIdentity: process.env.TREESEED_RUNNER_VOLUME_ID?.trim() || process.env.RAILWAY_VOLUME_ID?.trim() || process.env.RAILWAY_VOLUME_NAME?.trim() || "local-runner-volume",
|
|
191
|
+
projectId: process.env.TREESEED_PROJECT_ID?.trim() || "treeseed-market",
|
|
192
|
+
environment: process.env.TREESEED_DEPLOY_ENVIRONMENT?.trim() || (process.env.NODE_ENV === "production" ? "prod" : "local"),
|
|
193
|
+
visibilityTimeoutMs: integerFromEnv("TREESEED_QUEUE_VISIBILITY_TIMEOUT_MS", 12e4),
|
|
194
|
+
pollIntervalMs: integerFromEnv("TREESEED_WORKER_POLL_INTERVAL_MS", 5e3),
|
|
195
|
+
idleExitMs: integerFromEnv("TREESEED_WORKER_IDLE_EXIT_MS", 0),
|
|
196
|
+
leaseSeconds: integerFromEnv("TREESEED_TASK_LEASE_SECONDS", 120)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export {
|
|
200
|
+
buildTaskContext,
|
|
201
|
+
createQueueClient,
|
|
202
|
+
createQueuePushClient,
|
|
203
|
+
createServiceSdk,
|
|
204
|
+
enqueueTaskFromSdk,
|
|
205
|
+
queueEnvelopeForTask,
|
|
206
|
+
resolveManagerConfig,
|
|
207
|
+
resolveServiceRepoRoot,
|
|
208
|
+
resolveWorkerConfig,
|
|
209
|
+
seedGraphRefreshTask,
|
|
210
|
+
seedRootTasks,
|
|
211
|
+
startAndSeedWorkday
|
|
212
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { runManagerAction, runManagerCycle, startManagerLoop } from './manager.ts';
|
|
2
|
+
export { runWorkerCycle, startWorkerLoop } from './worker.ts';
|
|
3
|
+
export { runScheduledWorkdayManager } from './workday-manager.ts';
|
|
4
|
+
export { runWorkdayStart } from './workday-start.ts';
|
|
5
|
+
export { runWorkdayReport } from './workday-report.ts';
|
|
6
|
+
export { createWorkerPoolScaler, RailwayWorkerPoolScaler, NoopWorkerPoolScaler } from './worker-pool-scaler.ts';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { runManagerAction, runManagerCycle, startManagerLoop } from "./manager.js";
|
|
2
|
+
import { runWorkerCycle, startWorkerLoop } from "./worker.js";
|
|
3
|
+
import { runScheduledWorkdayManager } from "./workday-manager.js";
|
|
4
|
+
import { runWorkdayStart } from "./workday-start.js";
|
|
5
|
+
import { runWorkdayReport } from "./workday-report.js";
|
|
6
|
+
import { createWorkerPoolScaler, RailwayWorkerPoolScaler, NoopWorkerPoolScaler } from "./worker-pool-scaler.js";
|
|
7
|
+
export {
|
|
8
|
+
NoopWorkerPoolScaler,
|
|
9
|
+
RailwayWorkerPoolScaler,
|
|
10
|
+
createWorkerPoolScaler,
|
|
11
|
+
runManagerAction,
|
|
12
|
+
runManagerCycle,
|
|
13
|
+
runScheduledWorkdayManager,
|
|
14
|
+
runWorkdayReport,
|
|
15
|
+
runWorkdayStart,
|
|
16
|
+
runWorkerCycle,
|
|
17
|
+
startManagerLoop,
|
|
18
|
+
startWorkerLoop
|
|
19
|
+
};
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type ControlPlaneReporter, type PrioritySnapshot, type PrioritySnapshotItem, type ProjectEnvironmentName, type ScaleDecision, type WorkdayPolicy, type WorkdaySchedule, type WorkerPoolScaleResult, type WorkerPoolScaler } from '@treeseed/sdk';
|
|
3
|
+
import { createServiceSdk } from './common.ts';
|
|
4
|
+
import { type WorkerPoolScalerKind } from './worker-pool-scaler.ts';
|
|
5
|
+
type ManagerSdk = ReturnType<typeof createServiceSdk>;
|
|
6
|
+
type ManagerMode = 'reconcile' | 'open-workday' | 'close-workday' | 'report-workday' | 'loop';
|
|
7
|
+
type ManagerConfig = ReturnType<typeof resolveManagerServiceConfig>;
|
|
8
|
+
type TaskRecord = Record<string, unknown>;
|
|
9
|
+
export declare function resolveManagerServiceConfig(): {
|
|
10
|
+
mode: ManagerMode;
|
|
11
|
+
managerId: string;
|
|
12
|
+
marketBaseUrl: string;
|
|
13
|
+
runnerToken: string;
|
|
14
|
+
projectId: string;
|
|
15
|
+
teamId: string;
|
|
16
|
+
environment: ProjectEnvironmentName | "local";
|
|
17
|
+
poolName: string;
|
|
18
|
+
serviceBaseUrl: string | null;
|
|
19
|
+
pollIntervalMs: number;
|
|
20
|
+
dailyTaskCreditBudget: number;
|
|
21
|
+
maxQueuedTasks: number;
|
|
22
|
+
maxQueuedCredits: number;
|
|
23
|
+
priorityModels: string[];
|
|
24
|
+
priorityLimitPerModel: number;
|
|
25
|
+
graphInvalidated: boolean;
|
|
26
|
+
defaultSchedule: WorkdaySchedule;
|
|
27
|
+
scalerKind: WorkerPoolScalerKind | null;
|
|
28
|
+
creditWeights: import("@treeseed/sdk").TaskCreditWeight[];
|
|
29
|
+
autoscale: {
|
|
30
|
+
minWorkers: number;
|
|
31
|
+
maxWorkers: number;
|
|
32
|
+
targetQueueDepth: number;
|
|
33
|
+
cooldownSeconds: number;
|
|
34
|
+
};
|
|
35
|
+
host: string;
|
|
36
|
+
port: number;
|
|
37
|
+
defaultCapacityBudget: number;
|
|
38
|
+
};
|
|
39
|
+
export declare function runManagerAction(options?: {
|
|
40
|
+
mode?: ManagerMode;
|
|
41
|
+
sdk?: ManagerSdk;
|
|
42
|
+
config?: ManagerConfig;
|
|
43
|
+
reporter?: ControlPlaneReporter;
|
|
44
|
+
scaler?: WorkerPoolScaler;
|
|
45
|
+
now?: Date;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
ok: boolean;
|
|
48
|
+
mode: "reconcile";
|
|
49
|
+
managerId: string;
|
|
50
|
+
projectId: string;
|
|
51
|
+
environment: "local" | "staging" | "prod";
|
|
52
|
+
insideWorkWindow: boolean;
|
|
53
|
+
workPolicy: WorkdayPolicy;
|
|
54
|
+
workDay: null;
|
|
55
|
+
prioritySnapshot: null;
|
|
56
|
+
seededTasks: never[];
|
|
57
|
+
queuedCount: number;
|
|
58
|
+
activeLeases: number;
|
|
59
|
+
desiredWorkers: number;
|
|
60
|
+
scaleResult: {
|
|
61
|
+
applied: boolean;
|
|
62
|
+
provider: string;
|
|
63
|
+
desiredWorkers: number;
|
|
64
|
+
metadata: {
|
|
65
|
+
reason: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
workdaySummary: null;
|
|
69
|
+
} | {
|
|
70
|
+
ok: boolean;
|
|
71
|
+
mode: "reconcile";
|
|
72
|
+
managerId: string;
|
|
73
|
+
projectId: string;
|
|
74
|
+
environment: "local" | "staging" | "prod";
|
|
75
|
+
insideWorkWindow: boolean;
|
|
76
|
+
workPolicy: WorkdayPolicy;
|
|
77
|
+
workDay: Record<string, unknown>;
|
|
78
|
+
prioritySnapshot: PrioritySnapshot | null;
|
|
79
|
+
seededTasks: TaskRecord[];
|
|
80
|
+
queuedCount: number;
|
|
81
|
+
activeLeases: number;
|
|
82
|
+
desiredWorkers: number;
|
|
83
|
+
scaleResult: WorkerPoolScaleResult;
|
|
84
|
+
workdaySummary: Record<string, unknown> | null;
|
|
85
|
+
} | {
|
|
86
|
+
ok: boolean;
|
|
87
|
+
created: boolean;
|
|
88
|
+
workDay: Record<string, unknown>;
|
|
89
|
+
skipped?: undefined;
|
|
90
|
+
reason?: undefined;
|
|
91
|
+
prioritySnapshot?: undefined;
|
|
92
|
+
} | {
|
|
93
|
+
ok: boolean;
|
|
94
|
+
created: boolean;
|
|
95
|
+
skipped: boolean;
|
|
96
|
+
reason: string;
|
|
97
|
+
workDay?: undefined;
|
|
98
|
+
prioritySnapshot?: undefined;
|
|
99
|
+
} | {
|
|
100
|
+
ok: boolean;
|
|
101
|
+
created: boolean;
|
|
102
|
+
workDay: import("@treeseed/sdk").SdkWorkDayEntity | null;
|
|
103
|
+
prioritySnapshot: PrioritySnapshot | null;
|
|
104
|
+
skipped?: undefined;
|
|
105
|
+
reason?: undefined;
|
|
106
|
+
} | {
|
|
107
|
+
ok: boolean;
|
|
108
|
+
skipped: boolean;
|
|
109
|
+
reason: string;
|
|
110
|
+
workDay?: undefined;
|
|
111
|
+
summary?: undefined;
|
|
112
|
+
scale?: undefined;
|
|
113
|
+
} | {
|
|
114
|
+
ok: boolean;
|
|
115
|
+
workDay: import("@treeseed/sdk").SdkWorkDayEntity | null;
|
|
116
|
+
summary: {
|
|
117
|
+
contentSnapshot: {
|
|
118
|
+
relativePath: string;
|
|
119
|
+
slug: string;
|
|
120
|
+
reportVersion: string;
|
|
121
|
+
title: string;
|
|
122
|
+
};
|
|
123
|
+
capacity: {
|
|
124
|
+
providerSplit: {
|
|
125
|
+
providerId: string;
|
|
126
|
+
laneId: string;
|
|
127
|
+
state: import("@treeseed/sdk/types").CapacityReservationState;
|
|
128
|
+
reservedCredits: number;
|
|
129
|
+
consumedCredits: number;
|
|
130
|
+
reservedProviderUnits: number | null;
|
|
131
|
+
consumedProviderUnits: number | null;
|
|
132
|
+
reservedUsd: number | null;
|
|
133
|
+
consumedUsd: number | null;
|
|
134
|
+
}[];
|
|
135
|
+
grantedDailyCredits: number;
|
|
136
|
+
reservedCredits: number;
|
|
137
|
+
consumedCredits: number;
|
|
138
|
+
remainingDailyCredits: number | null;
|
|
139
|
+
providerCount: number;
|
|
140
|
+
laneCount: number;
|
|
141
|
+
grantCount: number;
|
|
142
|
+
} | null;
|
|
143
|
+
projectId: string;
|
|
144
|
+
environment: "local" | "staging" | "prod";
|
|
145
|
+
workDayId: string;
|
|
146
|
+
state: string;
|
|
147
|
+
totalTasks: number;
|
|
148
|
+
completedTasks: number;
|
|
149
|
+
failedTasks: number;
|
|
150
|
+
queuedTasks: number;
|
|
151
|
+
activeTasks: number;
|
|
152
|
+
dailyTaskCreditBudget: number;
|
|
153
|
+
usedTaskCredits: number;
|
|
154
|
+
remainingTaskCredits: number;
|
|
155
|
+
creditLedgerEntries: number;
|
|
156
|
+
prioritySnapshotId: string | null;
|
|
157
|
+
priorityItemCount: number;
|
|
158
|
+
priorityItems: PrioritySnapshotItem[];
|
|
159
|
+
taskItems: {
|
|
160
|
+
id: string;
|
|
161
|
+
agentId: string | undefined;
|
|
162
|
+
type: string | undefined;
|
|
163
|
+
state: string | undefined;
|
|
164
|
+
priority: number | undefined;
|
|
165
|
+
idempotencyKey: string | undefined;
|
|
166
|
+
createdAt: string | null;
|
|
167
|
+
startedAt: string | null;
|
|
168
|
+
completedAt: string | null;
|
|
169
|
+
lastErrorCode: string | null;
|
|
170
|
+
lastErrorMessage: string | null;
|
|
171
|
+
lastEventKind: string | null;
|
|
172
|
+
outputCount: number;
|
|
173
|
+
changedFiles: string[];
|
|
174
|
+
}[];
|
|
175
|
+
changedFiles: string[];
|
|
176
|
+
releases: {
|
|
177
|
+
id: string | undefined;
|
|
178
|
+
deploymentKind: string;
|
|
179
|
+
status: string;
|
|
180
|
+
releaseTag: string | null;
|
|
181
|
+
commitSha: string | null;
|
|
182
|
+
sourceRef: string | null;
|
|
183
|
+
startedAt: string | null;
|
|
184
|
+
finishedAt: string | null;
|
|
185
|
+
createdAt: string | null;
|
|
186
|
+
}[];
|
|
187
|
+
scaleDecision: ScaleDecision;
|
|
188
|
+
scaleResult: WorkerPoolScaleResult;
|
|
189
|
+
generatedAt: string;
|
|
190
|
+
};
|
|
191
|
+
scale: WorkerPoolScaleResult;
|
|
192
|
+
skipped?: undefined;
|
|
193
|
+
reason?: undefined;
|
|
194
|
+
} | {
|
|
195
|
+
ok: boolean;
|
|
196
|
+
skipped: boolean;
|
|
197
|
+
reason: string;
|
|
198
|
+
workDayId?: undefined;
|
|
199
|
+
summary?: undefined;
|
|
200
|
+
} | {
|
|
201
|
+
ok: boolean;
|
|
202
|
+
workDayId: unknown;
|
|
203
|
+
summary: {
|
|
204
|
+
contentSnapshot: {
|
|
205
|
+
relativePath: string;
|
|
206
|
+
slug: string;
|
|
207
|
+
reportVersion: string;
|
|
208
|
+
title: string;
|
|
209
|
+
};
|
|
210
|
+
capacity: {
|
|
211
|
+
providerSplit: {
|
|
212
|
+
providerId: string;
|
|
213
|
+
laneId: string;
|
|
214
|
+
state: import("@treeseed/sdk/types").CapacityReservationState;
|
|
215
|
+
reservedCredits: number;
|
|
216
|
+
consumedCredits: number;
|
|
217
|
+
reservedProviderUnits: number | null;
|
|
218
|
+
consumedProviderUnits: number | null;
|
|
219
|
+
reservedUsd: number | null;
|
|
220
|
+
consumedUsd: number | null;
|
|
221
|
+
}[];
|
|
222
|
+
grantedDailyCredits: number;
|
|
223
|
+
reservedCredits: number;
|
|
224
|
+
consumedCredits: number;
|
|
225
|
+
remainingDailyCredits: number | null;
|
|
226
|
+
providerCount: number;
|
|
227
|
+
laneCount: number;
|
|
228
|
+
grantCount: number;
|
|
229
|
+
} | null;
|
|
230
|
+
projectId: string;
|
|
231
|
+
environment: "local" | "staging" | "prod";
|
|
232
|
+
workDayId: string;
|
|
233
|
+
state: string;
|
|
234
|
+
totalTasks: number;
|
|
235
|
+
completedTasks: number;
|
|
236
|
+
failedTasks: number;
|
|
237
|
+
queuedTasks: number;
|
|
238
|
+
activeTasks: number;
|
|
239
|
+
dailyTaskCreditBudget: number;
|
|
240
|
+
usedTaskCredits: number;
|
|
241
|
+
remainingTaskCredits: number;
|
|
242
|
+
creditLedgerEntries: number;
|
|
243
|
+
prioritySnapshotId: string | null;
|
|
244
|
+
priorityItemCount: number;
|
|
245
|
+
priorityItems: PrioritySnapshotItem[];
|
|
246
|
+
taskItems: {
|
|
247
|
+
id: string;
|
|
248
|
+
agentId: string | undefined;
|
|
249
|
+
type: string | undefined;
|
|
250
|
+
state: string | undefined;
|
|
251
|
+
priority: number | undefined;
|
|
252
|
+
idempotencyKey: string | undefined;
|
|
253
|
+
createdAt: string | null;
|
|
254
|
+
startedAt: string | null;
|
|
255
|
+
completedAt: string | null;
|
|
256
|
+
lastErrorCode: string | null;
|
|
257
|
+
lastErrorMessage: string | null;
|
|
258
|
+
lastEventKind: string | null;
|
|
259
|
+
outputCount: number;
|
|
260
|
+
changedFiles: string[];
|
|
261
|
+
}[];
|
|
262
|
+
changedFiles: string[];
|
|
263
|
+
releases: {
|
|
264
|
+
id: string | undefined;
|
|
265
|
+
deploymentKind: string;
|
|
266
|
+
status: string;
|
|
267
|
+
releaseTag: string | null;
|
|
268
|
+
commitSha: string | null;
|
|
269
|
+
sourceRef: string | null;
|
|
270
|
+
startedAt: string | null;
|
|
271
|
+
finishedAt: string | null;
|
|
272
|
+
createdAt: string | null;
|
|
273
|
+
}[];
|
|
274
|
+
scaleDecision: ScaleDecision;
|
|
275
|
+
scaleResult: WorkerPoolScaleResult;
|
|
276
|
+
generatedAt: string;
|
|
277
|
+
};
|
|
278
|
+
skipped?: undefined;
|
|
279
|
+
reason?: undefined;
|
|
280
|
+
}>;
|
|
281
|
+
export declare function runManagerCycle(options?: {
|
|
282
|
+
sdk?: ManagerSdk;
|
|
283
|
+
config?: ManagerConfig;
|
|
284
|
+
reporter?: ControlPlaneReporter;
|
|
285
|
+
scaler?: WorkerPoolScaler;
|
|
286
|
+
now?: Date;
|
|
287
|
+
}): Promise<{
|
|
288
|
+
ok: boolean;
|
|
289
|
+
mode: "reconcile";
|
|
290
|
+
managerId: string;
|
|
291
|
+
projectId: string;
|
|
292
|
+
environment: "local" | "staging" | "prod";
|
|
293
|
+
insideWorkWindow: boolean;
|
|
294
|
+
workPolicy: WorkdayPolicy;
|
|
295
|
+
workDay: null;
|
|
296
|
+
prioritySnapshot: null;
|
|
297
|
+
seededTasks: never[];
|
|
298
|
+
queuedCount: number;
|
|
299
|
+
activeLeases: number;
|
|
300
|
+
desiredWorkers: number;
|
|
301
|
+
scaleResult: {
|
|
302
|
+
applied: boolean;
|
|
303
|
+
provider: string;
|
|
304
|
+
desiredWorkers: number;
|
|
305
|
+
metadata: {
|
|
306
|
+
reason: string;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
workdaySummary: null;
|
|
310
|
+
} | {
|
|
311
|
+
ok: boolean;
|
|
312
|
+
mode: "reconcile";
|
|
313
|
+
managerId: string;
|
|
314
|
+
projectId: string;
|
|
315
|
+
environment: "local" | "staging" | "prod";
|
|
316
|
+
insideWorkWindow: boolean;
|
|
317
|
+
workPolicy: WorkdayPolicy;
|
|
318
|
+
workDay: Record<string, unknown>;
|
|
319
|
+
prioritySnapshot: PrioritySnapshot | null;
|
|
320
|
+
seededTasks: TaskRecord[];
|
|
321
|
+
queuedCount: number;
|
|
322
|
+
activeLeases: number;
|
|
323
|
+
desiredWorkers: number;
|
|
324
|
+
scaleResult: WorkerPoolScaleResult;
|
|
325
|
+
workdaySummary: Record<string, unknown> | null;
|
|
326
|
+
}>;
|
|
327
|
+
export declare function startManagerLoop(options?: {
|
|
328
|
+
sdk?: ManagerSdk;
|
|
329
|
+
config?: ManagerConfig;
|
|
330
|
+
reporter?: ControlPlaneReporter;
|
|
331
|
+
scaler?: WorkerPoolScaler;
|
|
332
|
+
}): Promise<void>;
|
|
333
|
+
export {};
|