@treeseed/core 0.8.3 → 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/README.md +7 -11
- package/dist/dev-watch.js +1 -1
- package/dist/dev.d.ts +2 -4
- package/dist/dev.js +4 -124
- package/dist/env.yaml +23 -175
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -6
- package/dist/scripts/build-dist.js +3 -3
- package/dist/scripts/dev-platform.js +1 -7
- package/dist/scripts/run-fixture-astro-command.js +25 -51
- package/dist/scripts/test-smoke.js +50 -7
- package/package.json +5 -78
- package/templates/github/deploy-web.workflow.yml +111 -0
- package/templates/github/hosted-project.workflow.yml +4 -4
- package/dist/agent-runtime.d.ts +0 -17
- package/dist/agent-runtime.js +0 -117
- package/dist/agent.d.ts +0 -11
- package/dist/agent.js +0 -25
- package/dist/agents/adapters/execution.d.ts +0 -41
- package/dist/agents/adapters/execution.js +0 -73
- package/dist/agents/adapters/mutations.d.ts +0 -22
- package/dist/agents/adapters/mutations.js +0 -30
- package/dist/agents/adapters/notification.d.ts +0 -26
- package/dist/agents/adapters/notification.js +0 -46
- package/dist/agents/adapters/repository.d.ts +0 -23
- package/dist/agents/adapters/repository.js +0 -61
- package/dist/agents/adapters/research.d.ts +0 -26
- package/dist/agents/adapters/research.js +0 -59
- package/dist/agents/adapters/verification.d.ts +0 -36
- package/dist/agents/adapters/verification.js +0 -62
- package/dist/agents/cli-tools.d.ts +0 -1
- package/dist/agents/cli-tools.js +0 -5
- package/dist/agents/cli.d.ts +0 -15
- package/dist/agents/cli.js +0 -109
- package/dist/agents/contracts/messages.d.ts +0 -88
- package/dist/agents/contracts/messages.js +0 -138
- package/dist/agents/contracts/run.d.ts +0 -21
- package/dist/agents/contracts/run.js +0 -0
- package/dist/agents/index.d.ts +0 -1
- package/dist/agents/index.js +0 -5
- package/dist/agents/kernel/agent-kernel.d.ts +0 -51
- package/dist/agents/kernel/agent-kernel.js +0 -292
- package/dist/agents/kernel/trigger-resolver.d.ts +0 -19
- package/dist/agents/kernel/trigger-resolver.js +0 -157
- package/dist/agents/registry-helper.d.ts +0 -4
- package/dist/agents/registry-helper.js +0 -14
- package/dist/agents/registry.d.ts +0 -6
- package/dist/agents/registry.js +0 -98
- package/dist/agents/runtime-types.d.ts +0 -118
- package/dist/agents/runtime-types.js +0 -0
- package/dist/agents/spec-loader.d.ts +0 -18
- package/dist/agents/spec-loader.js +0 -55
- package/dist/agents/spec-normalizer.d.ts +0 -2
- package/dist/agents/spec-normalizer.js +0 -327
- package/dist/agents/spec-types.d.ts +0 -64
- package/dist/agents/spec-types.js +0 -0
- package/dist/agents/testing/agents-smoke.d.ts +0 -1
- package/dist/agents/testing/agents-smoke.js +0 -32
- package/dist/agents/testing/e2e-harness.d.ts +0 -44
- package/dist/agents/testing/e2e-harness.js +0 -504
- package/dist/api/agent-routes.d.ts +0 -13
- package/dist/api/agent-routes.js +0 -327
- package/dist/api/app.d.ts +0 -5
- package/dist/api/app.js +0 -361
- package/dist/api/auth/d1-database.d.ts +0 -3
- package/dist/api/auth/d1-database.js +0 -20
- package/dist/api/auth/d1-provider.d.ts +0 -79
- package/dist/api/auth/d1-provider.js +0 -92
- package/dist/api/auth/d1-store.d.ts +0 -114
- package/dist/api/auth/d1-store.js +0 -895
- package/dist/api/auth/memory-provider.d.ts +0 -77
- package/dist/api/auth/memory-provider.js +0 -249
- package/dist/api/auth/rbac.d.ts +0 -22
- package/dist/api/auth/rbac.js +0 -162
- package/dist/api/auth/tokens.d.ts +0 -18
- package/dist/api/auth/tokens.js +0 -56
- package/dist/api/capabilities.d.ts +0 -9
- package/dist/api/capabilities.js +0 -33
- package/dist/api/config.d.ts +0 -2
- package/dist/api/config.js +0 -77
- package/dist/api/http.d.ts +0 -28
- package/dist/api/http.js +0 -51
- package/dist/api/index.d.ts +0 -9
- package/dist/api/index.js +0 -18
- package/dist/api/operations-routes.d.ts +0 -11
- package/dist/api/operations-routes.js +0 -87
- package/dist/api/operations.d.ts +0 -3
- package/dist/api/operations.js +0 -26
- package/dist/api/project-routes.d.ts +0 -8
- package/dist/api/project-routes.js +0 -586
- package/dist/api/providers.d.ts +0 -2
- package/dist/api/providers.js +0 -62
- package/dist/api/railway.d.ts +0 -50
- package/dist/api/railway.js +0 -69
- package/dist/api/sdk-dispatch.d.ts +0 -5
- package/dist/api/sdk-dispatch.js +0 -13
- package/dist/api/sdk-routes.d.ts +0 -11
- package/dist/api/sdk-routes.js +0 -29
- package/dist/api/server.d.ts +0 -2
- package/dist/api/server.js +0 -10
- package/dist/api/templates.d.ts +0 -3
- package/dist/api/templates.js +0 -31
- package/dist/api/types.d.ts +0 -231
- package/dist/api/types.js +0 -0
- package/dist/api.d.ts +0 -1
- package/dist/api.js +0 -1
- package/dist/railway.d.ts +0 -1
- package/dist/railway.js +0 -4
- package/dist/services/agents.d.ts +0 -11
- package/dist/services/agents.js +0 -48
- package/dist/services/common.d.ts +0 -66
- package/dist/services/common.js +0 -212
- package/dist/services/index.d.ts +0 -6
- package/dist/services/index.js +0 -19
- package/dist/services/manager.d.ts +0 -267
- package/dist/services/manager.js +0 -1368
- package/dist/services/remote-runner.d.ts +0 -30
- package/dist/services/remote-runner.js +0 -230
- package/dist/services/workday-content.d.ts +0 -53
- package/dist/services/workday-content.js +0 -190
- package/dist/services/workday-manager.d.ts +0 -279
- package/dist/services/workday-manager.js +0 -163
- package/dist/services/workday-report.d.ts +0 -195
- package/dist/services/workday-report.js +0 -17
- package/dist/services/workday-start.d.ts +0 -195
- package/dist/services/workday-start.js +0 -17
- package/dist/services/worker-capacity.d.ts +0 -58
- package/dist/services/worker-capacity.js +0 -208
- package/dist/services/worker-pool-scaler.d.ts +0 -27
- package/dist/services/worker-pool-scaler.js +0 -127
- package/dist/services/worker.d.ts +0 -19
- package/dist/services/worker.js +0 -436
- package/templates/github/deploy.workflow.yml +0 -577
package/dist/api/railway.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { type Server } from 'node:http';
|
|
2
|
-
import type { Hono } from 'hono';
|
|
3
|
-
import type { ApiServerOptions } from './types.ts';
|
|
4
|
-
export declare function createRailwayTreeseedApiServer(options?: ApiServerOptions): Promise<{
|
|
5
|
-
app: Hono<{
|
|
6
|
-
Variables: import("./types.ts").AppVariables;
|
|
7
|
-
}, import("hono/types").BlankSchema, "/">;
|
|
8
|
-
config: {
|
|
9
|
-
providers: {
|
|
10
|
-
agents: {
|
|
11
|
-
execution: string;
|
|
12
|
-
queue: string;
|
|
13
|
-
notification: string;
|
|
14
|
-
repository: string;
|
|
15
|
-
verification: string;
|
|
16
|
-
};
|
|
17
|
-
auth: string;
|
|
18
|
-
};
|
|
19
|
-
name: string;
|
|
20
|
-
host: string;
|
|
21
|
-
port: number;
|
|
22
|
-
baseUrl: string;
|
|
23
|
-
issuer: string;
|
|
24
|
-
repoRoot: string;
|
|
25
|
-
projectId: string;
|
|
26
|
-
authSecret: string;
|
|
27
|
-
projectApiKey?: string;
|
|
28
|
-
projectApiLabel: string;
|
|
29
|
-
projectApiPermissions: string[];
|
|
30
|
-
cloudflareAccountId?: string;
|
|
31
|
-
cloudflareApiToken?: string;
|
|
32
|
-
d1DatabaseId?: string;
|
|
33
|
-
d1DatabaseName?: string;
|
|
34
|
-
d1LocalPersistTo?: string;
|
|
35
|
-
d1WranglerConfigPath?: string;
|
|
36
|
-
webServiceId: string;
|
|
37
|
-
webServiceSecret: string;
|
|
38
|
-
webAssertionSecret: string;
|
|
39
|
-
webExchangeTtlSeconds: number;
|
|
40
|
-
bootstrapAdminAllowlist: string[];
|
|
41
|
-
accessTokenTtlSeconds: number;
|
|
42
|
-
refreshTokenTtlSeconds: number;
|
|
43
|
-
deviceCodeTtlSeconds: number;
|
|
44
|
-
deviceCodePollIntervalSeconds: number;
|
|
45
|
-
templateCatalogPath?: string;
|
|
46
|
-
};
|
|
47
|
-
server: Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>;
|
|
48
|
-
url: string;
|
|
49
|
-
close(): Promise<void>;
|
|
50
|
-
}>;
|
package/dist/api/railway.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { createServer } from "node:http";
|
|
2
|
-
import { Readable } from "node:stream";
|
|
3
|
-
import { createTreeseedApiApp } from "./app.js";
|
|
4
|
-
import { resolveApiConfig } from "./config.js";
|
|
5
|
-
function hasRequestBody(method) {
|
|
6
|
-
return method !== "GET" && method !== "HEAD";
|
|
7
|
-
}
|
|
8
|
-
async function honoNodeHandler(app, request, response) {
|
|
9
|
-
const req = request;
|
|
10
|
-
const res = response;
|
|
11
|
-
const origin = req.headers.host ? `http://${req.headers.host}` : "http://127.0.0.1";
|
|
12
|
-
const url = new URL(req.url ?? "/", origin);
|
|
13
|
-
const webRequest = new Request(url, {
|
|
14
|
-
method: req.method,
|
|
15
|
-
headers: req.headers,
|
|
16
|
-
body: hasRequestBody(req.method) ? req : void 0,
|
|
17
|
-
duplex: "half"
|
|
18
|
-
});
|
|
19
|
-
const webResponse = await app.fetch(webRequest);
|
|
20
|
-
res.statusCode = webResponse.status;
|
|
21
|
-
webResponse.headers.forEach((value, key) => {
|
|
22
|
-
res.setHeader(key, value);
|
|
23
|
-
});
|
|
24
|
-
if (!webResponse.body) {
|
|
25
|
-
res.end();
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
Readable.fromWeb(webResponse.body).pipe(res);
|
|
29
|
-
}
|
|
30
|
-
async function createRailwayTreeseedApiServer(options = {}) {
|
|
31
|
-
const config = {
|
|
32
|
-
...resolveApiConfig(),
|
|
33
|
-
...options.config ?? {},
|
|
34
|
-
providers: {
|
|
35
|
-
...resolveApiConfig().providers,
|
|
36
|
-
...options.config?.providers ?? {},
|
|
37
|
-
agents: {
|
|
38
|
-
...resolveApiConfig().providers.agents,
|
|
39
|
-
...options.config?.providers?.agents ?? {}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const app = createTreeseedApiApp({
|
|
44
|
-
...options,
|
|
45
|
-
config
|
|
46
|
-
});
|
|
47
|
-
const server = createServer((req, res) => {
|
|
48
|
-
void honoNodeHandler(app, req, res);
|
|
49
|
-
});
|
|
50
|
-
await new Promise((resolvePromise) => {
|
|
51
|
-
server.listen(config.port, config.host, () => resolvePromise());
|
|
52
|
-
});
|
|
53
|
-
const address = server.address();
|
|
54
|
-
const resolvedUrl = address ? `${config.baseUrl.startsWith("http") ? config.baseUrl : `http://${address.address}:${address.port}`}` : config.baseUrl;
|
|
55
|
-
return {
|
|
56
|
-
app,
|
|
57
|
-
config,
|
|
58
|
-
server,
|
|
59
|
-
url: resolvedUrl,
|
|
60
|
-
async close() {
|
|
61
|
-
await new Promise((resolvePromise, rejectPromise) => {
|
|
62
|
-
server.close((error) => error ? rejectPromise(error) : resolvePromise());
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
createRailwayTreeseedApiServer
|
|
69
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AgentSdk, RemoteSdkOperationRequest } from '@treeseed/sdk';
|
|
2
|
-
import { executeSdkOperation, findSdkOperation, listSdkOperationNames } from '@treeseed/sdk';
|
|
3
|
-
import type { ApiConfig } from './types.ts';
|
|
4
|
-
export { executeSdkOperation, findSdkOperation, listSdkOperationNames, };
|
|
5
|
-
export declare function resolveSdkInstance(sharedSdk: AgentSdk | undefined, config: ApiConfig, request: RemoteSdkOperationRequest): AgentSdk;
|
package/dist/api/sdk-dispatch.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AgentSdk as AgentSdkClass, executeSdkOperation, findSdkOperation, listSdkOperationNames } from "@treeseed/sdk";
|
|
2
|
-
function resolveSdkInstance(sharedSdk, config, request) {
|
|
3
|
-
if (!request.repoRoot || request.repoRoot === config.repoRoot) {
|
|
4
|
-
return sharedSdk ?? new AgentSdkClass({ repoRoot: config.repoRoot });
|
|
5
|
-
}
|
|
6
|
-
return new AgentSdkClass({ repoRoot: request.repoRoot });
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
executeSdkOperation,
|
|
10
|
-
findSdkOperation,
|
|
11
|
-
listSdkOperationNames,
|
|
12
|
-
resolveSdkInstance
|
|
13
|
-
};
|
package/dist/api/sdk-routes.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Hono } from 'hono';
|
|
2
|
-
import type { AgentSdk } from '@treeseed/sdk';
|
|
3
|
-
import type { ApiConfig } from './types.ts';
|
|
4
|
-
interface RegisterSdkRoutesOptions {
|
|
5
|
-
config: ApiConfig;
|
|
6
|
-
sharedSdk?: AgentSdk;
|
|
7
|
-
scope: string;
|
|
8
|
-
prefix?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function registerSdkRoutes(app: Hono<any>, options: RegisterSdkRoutesOptions): void;
|
|
11
|
-
export {};
|
package/dist/api/sdk-routes.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { executeSdkOperation, resolveSdkInstance } from "./sdk-dispatch.js";
|
|
2
|
-
import { jsonError, requireScope } from "./http.js";
|
|
3
|
-
function withPrefix(prefix, path) {
|
|
4
|
-
if (!prefix) return path;
|
|
5
|
-
return `${prefix}${path}`.replace(/\/{2,}/g, "/");
|
|
6
|
-
}
|
|
7
|
-
function registerSdkRoutes(app, options) {
|
|
8
|
-
app.post(withPrefix(options.prefix ?? "", "/sdk/:operation"), async (c) => {
|
|
9
|
-
const unauthorized = requireScope(c, options.scope);
|
|
10
|
-
if (unauthorized) return unauthorized;
|
|
11
|
-
const operation = c.req.param("operation");
|
|
12
|
-
const body = await c.req.json().catch(() => ({}));
|
|
13
|
-
try {
|
|
14
|
-
const result = await executeSdkOperation(
|
|
15
|
-
resolveSdkInstance(options.sharedSdk, options.config, body),
|
|
16
|
-
operation,
|
|
17
|
-
body.input ?? {}
|
|
18
|
-
);
|
|
19
|
-
return c.json(result);
|
|
20
|
-
} catch (error) {
|
|
21
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
22
|
-
const status = /Unknown SDK operation/.test(message) ? 400 : 500;
|
|
23
|
-
return jsonError(c, status, message, { operation });
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
registerSdkRoutes
|
|
29
|
-
};
|
package/dist/api/server.d.ts
DELETED
package/dist/api/server.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { createRailwayTreeseedApiServer } from "./railway.js";
|
|
4
|
-
const currentFile = fileURLToPath(import.meta.url);
|
|
5
|
-
const entryFile = process.argv[1] ?? "";
|
|
6
|
-
if (entryFile === currentFile) {
|
|
7
|
-
const instance = await createRailwayTreeseedApiServer();
|
|
8
|
-
process.stdout.write(`Treeseed API listening on ${instance.url}
|
|
9
|
-
`);
|
|
10
|
-
}
|
package/dist/api/templates.d.ts
DELETED
package/dist/api/templates.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import { dirname, resolve } from "node:path";
|
|
4
|
-
import { parseTemplateCatalogResponse } from "@treeseed/sdk/template-catalog";
|
|
5
|
-
const require2 = createRequire(import.meta.url);
|
|
6
|
-
function resolveSdkPackageRoot() {
|
|
7
|
-
const exportedEntrypoint = require2.resolve("@treeseed/sdk");
|
|
8
|
-
const distRoot = dirname(exportedEntrypoint);
|
|
9
|
-
const packageRoot = resolve(distRoot, "..");
|
|
10
|
-
return packageRoot;
|
|
11
|
-
}
|
|
12
|
-
function resolveDefaultCatalogPath() {
|
|
13
|
-
const sdkRoot = resolveSdkPackageRoot();
|
|
14
|
-
const candidates = [
|
|
15
|
-
resolve(sdkRoot, "dist", "treeseed", "template-catalog", "catalog.fixture.json"),
|
|
16
|
-
resolve(sdkRoot, "src", "treeseed", "template-catalog", "catalog.fixture.json")
|
|
17
|
-
];
|
|
18
|
-
for (const candidate of candidates) {
|
|
19
|
-
if (existsSync(candidate)) {
|
|
20
|
-
return candidate;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
throw new Error("Unable to resolve the bundled Treeseed template catalog fixture.");
|
|
24
|
-
}
|
|
25
|
-
function loadTemplateCatalog(config) {
|
|
26
|
-
const catalogPath = config.templateCatalogPath ?? resolveDefaultCatalogPath();
|
|
27
|
-
return parseTemplateCatalogResponse(JSON.parse(readFileSync(catalogPath, "utf8")));
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
loadTemplateCatalog
|
|
31
|
-
};
|
package/dist/api/types.d.ts
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import type { Hono } from 'hono';
|
|
2
|
-
import type { AgentSdk } from '@treeseed/sdk';
|
|
3
|
-
import type { ApiPrincipal, ApiScope, DeviceCodeApproveRequest as SdkDeviceCodeApproveRequest, DeviceCodePollRequest, DeviceCodePollResponse, DeviceCodeStartRequest, DeviceCodeStartResponse, RemoteWorkflowOperationRequest as WorkflowHttpOperationRequest, RemoteWorkflowOperationResponse as ApiWorkflowOperationResponse, RemoteSdkOperationRequest as SdkHttpOperationRequest, TokenRefreshRequest, TokenRefreshResponse } from '@treeseed/sdk/remote';
|
|
4
|
-
export type { ApiPrincipal, ApiScope, DeviceCodePollRequest, DeviceCodePollResponse, DeviceCodeStartRequest, DeviceCodeStartResponse, WorkflowHttpOperationRequest, ApiWorkflowOperationResponse, SdkHttpOperationRequest, TokenRefreshRequest, TokenRefreshResponse, };
|
|
5
|
-
export type DeviceCodeApproveRequest = SdkDeviceCodeApproveRequest;
|
|
6
|
-
export interface ApiAuthProvider {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
startDeviceFlow(request: DeviceCodeStartRequest): Promise<DeviceCodeStartResponse>;
|
|
9
|
-
pollDeviceFlow(request: DeviceCodePollRequest): Promise<DeviceCodePollResponse>;
|
|
10
|
-
refreshAccessToken(request: TokenRefreshRequest): Promise<TokenRefreshResponse>;
|
|
11
|
-
approveDeviceFlow(request: DeviceCodeApproveRequest): Promise<{
|
|
12
|
-
ok: true;
|
|
13
|
-
}>;
|
|
14
|
-
authenticateBearerToken(token: string): Promise<{
|
|
15
|
-
principal: ApiPrincipal;
|
|
16
|
-
credential: ApiCredential;
|
|
17
|
-
} | null>;
|
|
18
|
-
authenticateServiceCredential(serviceId: string, secret: string): Promise<{
|
|
19
|
-
principal: ApiPrincipal;
|
|
20
|
-
credential: ApiCredential;
|
|
21
|
-
} | null>;
|
|
22
|
-
createPersonalAccessToken(userId: string, input: {
|
|
23
|
-
name: string;
|
|
24
|
-
scopes?: string[];
|
|
25
|
-
expiresAt?: string | null;
|
|
26
|
-
}): Promise<{
|
|
27
|
-
id: string;
|
|
28
|
-
token: string;
|
|
29
|
-
prefix: string;
|
|
30
|
-
name: string;
|
|
31
|
-
expiresAt: string | null;
|
|
32
|
-
}>;
|
|
33
|
-
listPersonalAccessTokens(userId: string): Promise<Array<{
|
|
34
|
-
id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
token_prefix: string;
|
|
37
|
-
expires_at: string | null;
|
|
38
|
-
last_used_at: string | null;
|
|
39
|
-
revoked_at: string | null;
|
|
40
|
-
created_at: string;
|
|
41
|
-
}>>;
|
|
42
|
-
revokePersonalAccessToken(userId: string, tokenId: string): Promise<void>;
|
|
43
|
-
syncUserIdentity(identity: UserIdentityProfileInput): Promise<{
|
|
44
|
-
principal: ApiPrincipal;
|
|
45
|
-
userId: string;
|
|
46
|
-
identityId: string | null;
|
|
47
|
-
}>;
|
|
48
|
-
createUser?(input: {
|
|
49
|
-
email?: string | null;
|
|
50
|
-
username?: string | null;
|
|
51
|
-
displayName?: string | null;
|
|
52
|
-
metadata?: Record<string, unknown>;
|
|
53
|
-
}): Promise<{
|
|
54
|
-
principal: ApiPrincipal;
|
|
55
|
-
userId: string;
|
|
56
|
-
}>;
|
|
57
|
-
setUserRoles?(userId: string, roles: string[]): Promise<{
|
|
58
|
-
principal: ApiPrincipal;
|
|
59
|
-
userId: string;
|
|
60
|
-
}>;
|
|
61
|
-
createServiceToken(input: {
|
|
62
|
-
serviceId: string;
|
|
63
|
-
name: string;
|
|
64
|
-
roles?: string[];
|
|
65
|
-
permissions?: string[];
|
|
66
|
-
}): Promise<{
|
|
67
|
-
id: string;
|
|
68
|
-
serviceId: string;
|
|
69
|
-
secret: string;
|
|
70
|
-
}>;
|
|
71
|
-
rotateServiceToken(serviceId: string): Promise<{
|
|
72
|
-
id: string;
|
|
73
|
-
serviceId: string;
|
|
74
|
-
secret: string;
|
|
75
|
-
}>;
|
|
76
|
-
createTrustedUserAssertion(claims: TrustedUserAssertionClaims): string;
|
|
77
|
-
verifyTrustedUserAssertion(assertion: string): TrustedUserAssertionClaims | null;
|
|
78
|
-
exchangeTrustedUserAssertion(claims: TrustedUserAssertionClaims): Promise<{
|
|
79
|
-
ok: true;
|
|
80
|
-
accessToken: string;
|
|
81
|
-
tokenType: 'Bearer';
|
|
82
|
-
expiresAt: string;
|
|
83
|
-
expiresInSeconds: number;
|
|
84
|
-
principal: ApiPrincipal;
|
|
85
|
-
}>;
|
|
86
|
-
}
|
|
87
|
-
export type ApiRuntimeProviderSelections = {
|
|
88
|
-
auth: string;
|
|
89
|
-
agents: {
|
|
90
|
-
execution: string;
|
|
91
|
-
queue: string;
|
|
92
|
-
notification: string;
|
|
93
|
-
repository: string;
|
|
94
|
-
verification: string;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
export interface ApiConfig {
|
|
98
|
-
name: string;
|
|
99
|
-
host: string;
|
|
100
|
-
port: number;
|
|
101
|
-
baseUrl: string;
|
|
102
|
-
issuer: string;
|
|
103
|
-
repoRoot: string;
|
|
104
|
-
projectId: string;
|
|
105
|
-
authSecret: string;
|
|
106
|
-
projectApiKey?: string;
|
|
107
|
-
projectApiLabel: string;
|
|
108
|
-
projectApiPermissions: string[];
|
|
109
|
-
cloudflareAccountId?: string;
|
|
110
|
-
cloudflareApiToken?: string;
|
|
111
|
-
d1DatabaseId?: string;
|
|
112
|
-
d1DatabaseName?: string;
|
|
113
|
-
d1LocalPersistTo?: string;
|
|
114
|
-
d1WranglerConfigPath?: string;
|
|
115
|
-
webServiceId: string;
|
|
116
|
-
webServiceSecret: string;
|
|
117
|
-
webAssertionSecret: string;
|
|
118
|
-
webExchangeTtlSeconds: number;
|
|
119
|
-
bootstrapAdminAllowlist: string[];
|
|
120
|
-
accessTokenTtlSeconds: number;
|
|
121
|
-
refreshTokenTtlSeconds: number;
|
|
122
|
-
deviceCodeTtlSeconds: number;
|
|
123
|
-
deviceCodePollIntervalSeconds: number;
|
|
124
|
-
templateCatalogPath?: string;
|
|
125
|
-
providers: ApiRuntimeProviderSelections;
|
|
126
|
-
}
|
|
127
|
-
export interface AppVariables {
|
|
128
|
-
requestId: string;
|
|
129
|
-
config: ApiConfig;
|
|
130
|
-
principal: ApiPrincipal | null;
|
|
131
|
-
actingUser: ApiPrincipal | null;
|
|
132
|
-
credential: ApiCredential | null;
|
|
133
|
-
actorType: 'anonymous' | 'user' | 'service' | 'project';
|
|
134
|
-
permissionGrants: string[];
|
|
135
|
-
}
|
|
136
|
-
export interface ApiCredential {
|
|
137
|
-
type: 'access_token' | 'personal_access_token' | 'service_secret' | 'service_token' | 'project_api_key' | 'team_api_key';
|
|
138
|
-
id: string;
|
|
139
|
-
label?: string;
|
|
140
|
-
}
|
|
141
|
-
export interface TrustedUserAssertionClaims {
|
|
142
|
-
userId: string;
|
|
143
|
-
sessionId: string;
|
|
144
|
-
identityId?: string | null;
|
|
145
|
-
teamId?: string | null;
|
|
146
|
-
projectId?: string | null;
|
|
147
|
-
membershipId?: string | null;
|
|
148
|
-
teamRoles?: string[];
|
|
149
|
-
teamCapabilities?: string[];
|
|
150
|
-
authTime: string;
|
|
151
|
-
expiresAt: string;
|
|
152
|
-
nonce: string;
|
|
153
|
-
}
|
|
154
|
-
export interface UserIdentityProfileInput {
|
|
155
|
-
provider: string;
|
|
156
|
-
providerSubject: string;
|
|
157
|
-
email?: string | null;
|
|
158
|
-
emailVerified?: boolean;
|
|
159
|
-
username?: string | null;
|
|
160
|
-
displayName?: string | null;
|
|
161
|
-
profile?: Record<string, unknown>;
|
|
162
|
-
}
|
|
163
|
-
export type ApiProviderFactory<T> = (options: {
|
|
164
|
-
config: ApiConfig;
|
|
165
|
-
}) => T;
|
|
166
|
-
export interface ApiRuntimeProviders {
|
|
167
|
-
auth?: Record<string, ApiProviderFactory<ApiAuthProvider>>;
|
|
168
|
-
agentExecution?: Record<string, unknown>;
|
|
169
|
-
agentQueue?: Record<string, unknown>;
|
|
170
|
-
agentNotification?: Record<string, unknown>;
|
|
171
|
-
agentRepository?: Record<string, unknown>;
|
|
172
|
-
agentVerification?: Record<string, unknown>;
|
|
173
|
-
}
|
|
174
|
-
export interface ResolvedApiRuntimeProviders {
|
|
175
|
-
auth: ApiAuthProvider;
|
|
176
|
-
registries: {
|
|
177
|
-
auth: Map<string, ApiProviderFactory<ApiAuthProvider>>;
|
|
178
|
-
agentExecution: Map<string, unknown>;
|
|
179
|
-
agentQueue: Map<string, unknown>;
|
|
180
|
-
agentNotification: Map<string, unknown>;
|
|
181
|
-
agentRepository: Map<string, unknown>;
|
|
182
|
-
agentVerification: Map<string, unknown>;
|
|
183
|
-
};
|
|
184
|
-
selections: ApiRuntimeProviderSelections;
|
|
185
|
-
}
|
|
186
|
-
export interface ApiResolvedSettings {
|
|
187
|
-
config: ApiConfig;
|
|
188
|
-
surfaces: {
|
|
189
|
-
auth: boolean;
|
|
190
|
-
templates: boolean;
|
|
191
|
-
sdk: boolean;
|
|
192
|
-
agent: boolean;
|
|
193
|
-
operations: boolean;
|
|
194
|
-
project: boolean;
|
|
195
|
-
};
|
|
196
|
-
scopes: {
|
|
197
|
-
authMe: ApiScope;
|
|
198
|
-
sdk: ApiScope;
|
|
199
|
-
agent: ApiScope;
|
|
200
|
-
operations: ApiScope;
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
export interface ApiAppRuntime {
|
|
204
|
-
resolved: ApiResolvedSettings;
|
|
205
|
-
runtimeProviders: ResolvedApiRuntimeProviders;
|
|
206
|
-
sharedSdk: AgentSdk;
|
|
207
|
-
internalPrefix: string;
|
|
208
|
-
}
|
|
209
|
-
export interface ApiServerOptions {
|
|
210
|
-
config?: Partial<ApiConfig>;
|
|
211
|
-
runtimeProviders?: ApiRuntimeProviders;
|
|
212
|
-
sdk?: AgentSdk;
|
|
213
|
-
workflowExecutor?: (operation: string, request: WorkflowHttpOperationRequest) => Promise<ApiWorkflowOperationResponse>;
|
|
214
|
-
surfaces?: Partial<{
|
|
215
|
-
auth: boolean;
|
|
216
|
-
templates: boolean;
|
|
217
|
-
sdk: boolean;
|
|
218
|
-
agent: boolean;
|
|
219
|
-
operations: boolean;
|
|
220
|
-
project: boolean;
|
|
221
|
-
}>;
|
|
222
|
-
scopes?: Partial<{
|
|
223
|
-
authMe: ApiScope;
|
|
224
|
-
sdk: ApiScope;
|
|
225
|
-
agent: ApiScope;
|
|
226
|
-
operations: ApiScope;
|
|
227
|
-
}>;
|
|
228
|
-
internalPrefix?: string;
|
|
229
|
-
extendApp?: (app: Hono<any>, runtime: ApiAppRuntime) => void;
|
|
230
|
-
log?: (message: string, details?: Record<string, unknown>) => void;
|
|
231
|
-
}
|
package/dist/api/types.js
DELETED
|
File without changes
|
package/dist/api.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './api/index';
|
package/dist/api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./api/index.js";
|
package/dist/railway.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createRailwayTreeseedApiServer } from './api/railway';
|
package/dist/railway.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
export declare function resolveAgentsServiceConfig(): {
|
|
3
|
-
serviceName: string;
|
|
4
|
-
pollIntervalMs: number;
|
|
5
|
-
};
|
|
6
|
-
export declare function runAgentsCycle(): Promise<{
|
|
7
|
-
ok: boolean;
|
|
8
|
-
processed: number;
|
|
9
|
-
results: any[];
|
|
10
|
-
}>;
|
|
11
|
-
export declare function startAgentsLoop(): Promise<void>;
|
package/dist/services/agents.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { AgentKernel } from "../agents/kernel/agent-kernel.js";
|
|
4
|
-
import { createServiceSdk, resolveServiceRepoRoot } from "./common.js";
|
|
5
|
-
function integerFromEnv(name, fallback) {
|
|
6
|
-
const value = process.env[name];
|
|
7
|
-
if (!value) return fallback;
|
|
8
|
-
const parsed = Number.parseInt(value, 10);
|
|
9
|
-
return Number.isFinite(parsed) ? parsed : fallback;
|
|
10
|
-
}
|
|
11
|
-
function resolveAgentsServiceConfig() {
|
|
12
|
-
return {
|
|
13
|
-
serviceName: process.env.TREESEED_AGENTS_SERVICE_NAME?.trim() || "agents",
|
|
14
|
-
pollIntervalMs: integerFromEnv("TREESEED_AGENTS_POLL_INTERVAL_MS", 3e4)
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
async function runAgentsCycle() {
|
|
18
|
-
const sdk = createServiceSdk();
|
|
19
|
-
const kernel = new AgentKernel(sdk, resolveServiceRepoRoot());
|
|
20
|
-
const results = await kernel.runCycle();
|
|
21
|
-
return {
|
|
22
|
-
ok: true,
|
|
23
|
-
processed: results.length,
|
|
24
|
-
results
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
async function startAgentsLoop() {
|
|
28
|
-
const config = resolveAgentsServiceConfig();
|
|
29
|
-
for (; ; ) {
|
|
30
|
-
try {
|
|
31
|
-
await runAgentsCycle();
|
|
32
|
-
} catch (error) {
|
|
33
|
-
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
34
|
-
`);
|
|
35
|
-
}
|
|
36
|
-
await new Promise((resolve) => setTimeout(resolve, config.pollIntervalMs));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const currentFile = fileURLToPath(import.meta.url);
|
|
40
|
-
const entryFile = process.argv[1] ?? "";
|
|
41
|
-
if (entryFile === currentFile) {
|
|
42
|
-
await startAgentsLoop();
|
|
43
|
-
}
|
|
44
|
-
export {
|
|
45
|
-
resolveAgentsServiceConfig,
|
|
46
|
-
runAgentsCycle,
|
|
47
|
-
startAgentsLoop
|
|
48
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { AgentSdk } from '@treeseed/sdk';
|
|
2
|
-
import { CloudflareQueuePullClient } from '@treeseed/sdk/remote';
|
|
3
|
-
import type { SdkQueueMessageEnvelope } from '@treeseed/sdk';
|
|
4
|
-
export declare function resolveServiceRepoRoot(): string;
|
|
5
|
-
export declare function createServiceSdk(): AgentSdk;
|
|
6
|
-
export declare function createQueueClient(): CloudflareQueuePullClient;
|
|
7
|
-
export declare function createQueuePushClient(): {
|
|
8
|
-
enqueue(request: {
|
|
9
|
-
message: SdkQueueMessageEnvelope;
|
|
10
|
-
delaySeconds?: number;
|
|
11
|
-
}): Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
export declare function queueEnvelopeForTask(task: Record<string, unknown>): SdkQueueMessageEnvelope;
|
|
14
|
-
export declare function enqueueTaskFromSdk(sdk: AgentSdk, request: {
|
|
15
|
-
taskId: string;
|
|
16
|
-
queueName?: string;
|
|
17
|
-
deliveryDelaySeconds?: number;
|
|
18
|
-
actor?: string;
|
|
19
|
-
}): Promise<{
|
|
20
|
-
ok: boolean;
|
|
21
|
-
taskId: string;
|
|
22
|
-
queued: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
export declare function buildTaskContext(sdk: AgentSdk, taskId: string): Promise<{
|
|
25
|
-
agent: Record<string, unknown> | import("@treeseed/sdk").SdkContentEntry;
|
|
26
|
-
task: import("@treeseed/sdk").SdkTaskEntity | null;
|
|
27
|
-
workDay: import("@treeseed/sdk").SdkWorkDayEntity | null;
|
|
28
|
-
graph: Record<string, unknown> | null;
|
|
29
|
-
}>;
|
|
30
|
-
export declare function seedRootTasks(sdk: AgentSdk, workDayId: string): Promise<any[]>;
|
|
31
|
-
export declare function seedGraphRefreshTask(sdk: AgentSdk, request: {
|
|
32
|
-
workDayId: string;
|
|
33
|
-
projectId: string;
|
|
34
|
-
repositoryId?: string | null;
|
|
35
|
-
actor?: string;
|
|
36
|
-
}): Promise<import("@treeseed/sdk").SdkTaskEntity>;
|
|
37
|
-
export declare function startAndSeedWorkday(sdk: AgentSdk, request: {
|
|
38
|
-
id?: string;
|
|
39
|
-
projectId: string;
|
|
40
|
-
capacityBudget: number;
|
|
41
|
-
actor?: string;
|
|
42
|
-
}): Promise<{
|
|
43
|
-
ok: boolean;
|
|
44
|
-
workDay: import("@treeseed/sdk").SdkWorkDayEntity;
|
|
45
|
-
seededTasks: any[];
|
|
46
|
-
}>;
|
|
47
|
-
export declare function resolveManagerConfig(): {
|
|
48
|
-
host: string;
|
|
49
|
-
port: number;
|
|
50
|
-
projectId: string;
|
|
51
|
-
defaultCapacityBudget: number;
|
|
52
|
-
};
|
|
53
|
-
export declare function resolveWorkerConfig(): {
|
|
54
|
-
workerId: string;
|
|
55
|
-
batchSize: number;
|
|
56
|
-
maxLocalWorkers: number;
|
|
57
|
-
runnerServiceName: string;
|
|
58
|
-
volumeRoot: string;
|
|
59
|
-
volumeIdentity: string;
|
|
60
|
-
projectId: string;
|
|
61
|
-
environment: string;
|
|
62
|
-
visibilityTimeoutMs: number;
|
|
63
|
-
pollIntervalMs: number;
|
|
64
|
-
idleExitMs: number;
|
|
65
|
-
leaseSeconds: number;
|
|
66
|
-
};
|