@treeseed/sdk 0.9.0 → 0.10.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/dist/api/app.d.ts +8 -0
- package/dist/api/app.js +404 -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 +902 -0
- package/dist/api/auth/memory-provider.d.ts +77 -0
- package/dist/api/auth/memory-provider.js +256 -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/config.d.ts +2 -0
- package/dist/api/config.js +118 -0
- package/dist/api/http.d.ts +28 -0
- package/dist/api/http.js +51 -0
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.js +27 -0
- package/dist/api/operations-routes.d.ts +11 -0
- package/dist/api/operations-routes.js +39 -0
- package/dist/api/operations.d.ts +3 -0
- package/dist/api/operations.js +26 -0
- package/dist/api/providers.d.ts +2 -0
- package/dist/api/providers.js +68 -0
- package/dist/api/railway.d.ts +52 -0
- package/dist/api/railway.js +71 -0
- package/dist/api/sdk-dispatch.d.ts +6 -0
- package/dist/api/sdk-dispatch.js +14 -0
- package/dist/api/sdk-routes.d.ts +11 -0
- package/dist/api/sdk-routes.js +29 -0
- package/dist/api/templates.d.ts +3 -0
- package/dist/api/templates.js +31 -0
- package/dist/api/types.d.ts +232 -0
- package/dist/api/types.js +0 -0
- package/dist/capacity-provider.d.ts +383 -0
- package/dist/capacity-provider.js +535 -0
- package/dist/capacity.d.ts +2 -35
- package/dist/control-plane-client.d.ts +8 -3
- package/dist/control-plane-client.js +12 -1
- package/dist/dispatch.js +0 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +40 -0
- package/dist/market-client.d.ts +1 -5
- package/dist/market-client.js +2 -8
- package/dist/operations/providers/default.js +0 -9
- package/dist/operations/services/config-runtime.d.ts +2 -2
- package/dist/operations/services/config-runtime.js +55 -3
- package/dist/operations/services/github-automation.d.ts +10 -15
- package/dist/operations/services/github-automation.js +3 -35
- package/dist/operations/services/hosting-audit.d.ts +1 -1
- package/dist/operations/services/hosting-audit.js +3 -27
- package/dist/operations/services/hub-launch.d.ts +0 -1
- package/dist/operations/services/hub-launch.js +1 -2
- package/dist/operations/services/hub-provider-launch.d.ts +0 -15
- package/dist/operations/services/hub-provider-launch.js +5 -41
- package/dist/operations/services/package-reference-policy.d.ts +1 -0
- package/dist/operations/services/package-reference-policy.js +10 -2
- package/dist/operations/services/project-platform.d.ts +9 -9
- package/dist/operations/services/project-platform.js +6 -17
- package/dist/operations/services/release-candidate.js +19 -3
- package/dist/operations-registry.js +1 -3
- package/dist/platform/contracts.d.ts +2 -2
- package/dist/project-workflow.d.ts +0 -3
- package/dist/scripts/publish-package.js +5 -1
- package/dist/scripts/tenant-workflow-action.js +3 -3
- package/dist/scripts/workflow-commands.test.js +3 -6
- package/dist/sdk-types.d.ts +33 -1
- package/dist/treeseed/template-catalog/templates/starter-basic/template/package.json +1 -4
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/api/server.js +1 -1
- package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +1 -17
- package/dist/workflow/operations.js +26 -8
- package/package.json +14 -1
- package/templates/github/hosted-project.workflow.yml +0 -1
- package/templates/github/deploy-processing.workflow.yml +0 -123
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import type { AgentSdk } from '../sdk.ts';
|
|
3
|
+
import type { ApiPrincipal, ApiScope, DeviceCodeApproveRequest as SdkDeviceCodeApproveRequest, DeviceCodePollRequest, DeviceCodePollResponse, DeviceCodeStartRequest, DeviceCodeStartResponse, RemoteWorkflowOperationRequest as WorkflowHttpOperationRequest, RemoteWorkflowOperationResponse as ApiWorkflowOperationResponse, RemoteSdkOperationRequest as SdkHttpOperationRequest, TokenRefreshRequest, TokenRefreshResponse } from '../remote.ts';
|
|
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
|
+
authApprovalBaseUrl?: string;
|
|
103
|
+
issuer: string;
|
|
104
|
+
repoRoot: string;
|
|
105
|
+
projectId: string;
|
|
106
|
+
authSecret: string;
|
|
107
|
+
projectApiKey?: string;
|
|
108
|
+
projectApiLabel: string;
|
|
109
|
+
projectApiPermissions: string[];
|
|
110
|
+
cloudflareAccountId?: string;
|
|
111
|
+
cloudflareApiToken?: string;
|
|
112
|
+
d1DatabaseId?: string;
|
|
113
|
+
d1DatabaseName?: string;
|
|
114
|
+
d1LocalPersistTo?: string;
|
|
115
|
+
d1WranglerConfigPath?: string;
|
|
116
|
+
webServiceId: string;
|
|
117
|
+
webServiceSecret: string;
|
|
118
|
+
webAssertionSecret: string;
|
|
119
|
+
webExchangeTtlSeconds: number;
|
|
120
|
+
bootstrapAdminAllowlist: string[];
|
|
121
|
+
accessTokenTtlSeconds: number;
|
|
122
|
+
refreshTokenTtlSeconds: number;
|
|
123
|
+
deviceCodeTtlSeconds: number;
|
|
124
|
+
deviceCodePollIntervalSeconds: number;
|
|
125
|
+
templateCatalogPath?: string;
|
|
126
|
+
providers: ApiRuntimeProviderSelections;
|
|
127
|
+
}
|
|
128
|
+
export interface AppVariables {
|
|
129
|
+
requestId: string;
|
|
130
|
+
config: ApiConfig;
|
|
131
|
+
principal: ApiPrincipal | null;
|
|
132
|
+
actingUser: ApiPrincipal | null;
|
|
133
|
+
credential: ApiCredential | null;
|
|
134
|
+
actorType: 'anonymous' | 'user' | 'service' | 'project';
|
|
135
|
+
permissionGrants: string[];
|
|
136
|
+
}
|
|
137
|
+
export interface ApiCredential {
|
|
138
|
+
type: 'access_token' | 'personal_access_token' | 'service_secret' | 'service_token' | 'project_api_key' | 'team_api_key';
|
|
139
|
+
id: string;
|
|
140
|
+
label?: string;
|
|
141
|
+
}
|
|
142
|
+
export interface TrustedUserAssertionClaims {
|
|
143
|
+
userId: string;
|
|
144
|
+
sessionId: string;
|
|
145
|
+
identityId?: string | null;
|
|
146
|
+
teamId?: string | null;
|
|
147
|
+
projectId?: string | null;
|
|
148
|
+
membershipId?: string | null;
|
|
149
|
+
teamRoles?: string[];
|
|
150
|
+
teamCapabilities?: string[];
|
|
151
|
+
authTime: string;
|
|
152
|
+
expiresAt: string;
|
|
153
|
+
nonce: string;
|
|
154
|
+
}
|
|
155
|
+
export interface UserIdentityProfileInput {
|
|
156
|
+
provider: string;
|
|
157
|
+
providerSubject: string;
|
|
158
|
+
email?: string | null;
|
|
159
|
+
emailVerified?: boolean;
|
|
160
|
+
username?: string | null;
|
|
161
|
+
displayName?: string | null;
|
|
162
|
+
profile?: Record<string, unknown>;
|
|
163
|
+
}
|
|
164
|
+
export type ApiProviderFactory<T> = (options: {
|
|
165
|
+
config: ApiConfig;
|
|
166
|
+
}) => T;
|
|
167
|
+
export interface ApiRuntimeProviders {
|
|
168
|
+
auth?: Record<string, ApiProviderFactory<ApiAuthProvider>>;
|
|
169
|
+
agentExecution?: Record<string, unknown>;
|
|
170
|
+
agentQueue?: Record<string, unknown>;
|
|
171
|
+
agentNotification?: Record<string, unknown>;
|
|
172
|
+
agentRepository?: Record<string, unknown>;
|
|
173
|
+
agentVerification?: Record<string, unknown>;
|
|
174
|
+
}
|
|
175
|
+
export interface ResolvedApiRuntimeProviders {
|
|
176
|
+
auth: ApiAuthProvider;
|
|
177
|
+
registries: {
|
|
178
|
+
auth: Map<string, ApiProviderFactory<ApiAuthProvider>>;
|
|
179
|
+
agentExecution: Map<string, unknown>;
|
|
180
|
+
agentQueue: Map<string, unknown>;
|
|
181
|
+
agentNotification: Map<string, unknown>;
|
|
182
|
+
agentRepository: Map<string, unknown>;
|
|
183
|
+
agentVerification: Map<string, unknown>;
|
|
184
|
+
};
|
|
185
|
+
selections: ApiRuntimeProviderSelections;
|
|
186
|
+
}
|
|
187
|
+
export interface ApiResolvedSettings {
|
|
188
|
+
config: ApiConfig;
|
|
189
|
+
surfaces: {
|
|
190
|
+
auth: boolean;
|
|
191
|
+
templates: boolean;
|
|
192
|
+
sdk: boolean;
|
|
193
|
+
operations: boolean;
|
|
194
|
+
};
|
|
195
|
+
scopes: {
|
|
196
|
+
authMe: ApiScope;
|
|
197
|
+
sdk: ApiScope;
|
|
198
|
+
operations: ApiScope;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
export interface ApiAppRuntime {
|
|
202
|
+
resolved: ApiResolvedSettings;
|
|
203
|
+
runtimeProviders: ResolvedApiRuntimeProviders;
|
|
204
|
+
sharedSdk: AgentSdk;
|
|
205
|
+
internalPrefix: string;
|
|
206
|
+
}
|
|
207
|
+
export type TreeseedApiContext = ApiAppRuntime;
|
|
208
|
+
export interface TreeseedApiExtension {
|
|
209
|
+
name: string;
|
|
210
|
+
mount(app: Hono<any>, context: TreeseedApiContext): void | Promise<void>;
|
|
211
|
+
}
|
|
212
|
+
export interface ApiServerOptions {
|
|
213
|
+
config?: Partial<ApiConfig>;
|
|
214
|
+
runtimeProviders?: ApiRuntimeProviders;
|
|
215
|
+
sdk?: AgentSdk;
|
|
216
|
+
workflowExecutor?: (operation: string, request: WorkflowHttpOperationRequest) => Promise<ApiWorkflowOperationResponse>;
|
|
217
|
+
surfaces?: Partial<{
|
|
218
|
+
auth: boolean;
|
|
219
|
+
templates: boolean;
|
|
220
|
+
sdk: boolean;
|
|
221
|
+
operations: boolean;
|
|
222
|
+
}>;
|
|
223
|
+
scopes?: Partial<{
|
|
224
|
+
authMe: ApiScope;
|
|
225
|
+
sdk: ApiScope;
|
|
226
|
+
operations: ApiScope;
|
|
227
|
+
}>;
|
|
228
|
+
internalPrefix?: string;
|
|
229
|
+
extensions?: TreeseedApiExtension[];
|
|
230
|
+
extendApp?: (app: Hono<any>, runtime: ApiAppRuntime) => void;
|
|
231
|
+
log?: (message: string, details?: Record<string, unknown>) => void;
|
|
232
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
export declare const CAPACITY_PROVIDER_ENDPOINTS: {
|
|
2
|
+
readonly register: "/v1/provider/register";
|
|
3
|
+
readonly heartbeat: "/v1/provider/heartbeat";
|
|
4
|
+
readonly portfolio: "/v1/provider/portfolio";
|
|
5
|
+
readonly workdays: "/v1/provider/workdays";
|
|
6
|
+
readonly claimTask: "/v1/provider/tasks/claim";
|
|
7
|
+
readonly taskEvents: (taskId: string) => string;
|
|
8
|
+
readonly completeTask: (taskId: string) => string;
|
|
9
|
+
readonly failTask: (taskId: string) => string;
|
|
10
|
+
readonly usage: "/v1/provider/usage";
|
|
11
|
+
readonly reports: "/v1/provider/reports";
|
|
12
|
+
};
|
|
13
|
+
export declare const CAPACITY_PROVIDER_SCOPES: readonly ["provider:register", "provider:heartbeat", "provider:portfolio:read", "provider:tasks:claim", "provider:tasks:update", "provider:usage:report", "provider:reports:write", "provider:capabilities:write"];
|
|
14
|
+
export declare const CAPACITY_PROVIDER_ENV_KEYS: readonly ["TREESEED_MARKET_URL", "TREESEED_MARKET_ID", "TREESEED_CAPACITY_PROVIDER_API_KEY", "TREESEED_PROVIDER_HOST_DATA_DIR", "TREESEED_PROVIDER_DATA_DIR", "TREESEED_PROVIDER_API_PORT", "TREESEED_PROVIDER_HOST_API_PORT", "TREESEED_PROVIDER_ENVIRONMENT", "TREESEED_PROVIDER_CAPABILITIES_FILE", "TREESEED_PROVIDER_BUDGET_FILE", "TREESEED_PROVIDER_MAX_CONCURRENT_WORKDAYS", "TREESEED_PROVIDER_MAX_CONCURRENT_RUNNERS", "TREESEED_PROVIDER_DAILY_CREDIT_BUDGET", "TREESEED_PROVIDER_MONTHLY_CREDIT_BUDGET", "TREESEED_PROVIDER_STARTUP_MODE", "TREESEED_CODEX_AUTH_FILE", "TREESEED_CODEX_AUTH_JSON_B64", "TREESEED_CODEX_AUTH_OVERWRITE"];
|
|
15
|
+
export type CapacityProviderScope = (typeof CAPACITY_PROVIDER_SCOPES)[number];
|
|
16
|
+
export type CapacityProviderEnvironmentName = 'local' | 'staging' | 'prod' | 'production' | string;
|
|
17
|
+
export type CapacityProviderLaunchMode = 'self_hosted' | 'managed_market_host' | 'connected_host';
|
|
18
|
+
export type CapacityProviderStatus = 'pending' | 'online' | 'offline' | 'disabled' | 'rotation_required' | string;
|
|
19
|
+
export type CapacityProviderConnectionState = 'waiting_for_provider' | 'connected' | 'auth_failed' | 'stale' | 'disabled' | string;
|
|
20
|
+
export type CapacityProviderDeploymentStatus = 'not_deployed' | 'deploying' | 'deployed' | 'failed' | string;
|
|
21
|
+
export type CapacityProviderDeploymentServiceRole = 'api' | 'manager' | 'runner';
|
|
22
|
+
export declare const CAPACITY_PROVIDER_DEPLOYMENT_SERVICE_ROLES: readonly ["api", "manager", "runner"];
|
|
23
|
+
export interface CapacityProviderRuntimeInfo {
|
|
24
|
+
package: '@treeseed/agent' | string;
|
|
25
|
+
version: string;
|
|
26
|
+
entrypoint: string;
|
|
27
|
+
roles: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface CapacityProviderCapability {
|
|
30
|
+
id: string;
|
|
31
|
+
agents: string[];
|
|
32
|
+
operations: string[];
|
|
33
|
+
models: string[];
|
|
34
|
+
repositoryAccess: string;
|
|
35
|
+
verification: string[];
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface CapacityProviderBudgetCapacity {
|
|
39
|
+
dailyCreditBudget?: number | null;
|
|
40
|
+
monthlyCreditBudget?: number | null;
|
|
41
|
+
maxConcurrentWorkdays?: number | null;
|
|
42
|
+
maxConcurrentRunners?: number | null;
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface CapacityProviderHealthState {
|
|
46
|
+
dataDirWritable?: boolean;
|
|
47
|
+
codexReady?: boolean;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
export interface CapacityProviderRegistrationRequest {
|
|
51
|
+
marketId: string;
|
|
52
|
+
runtime: CapacityProviderRuntimeInfo;
|
|
53
|
+
capabilities: CapacityProviderCapability[];
|
|
54
|
+
budgets: CapacityProviderBudgetCapacity;
|
|
55
|
+
health: CapacityProviderHealthState;
|
|
56
|
+
}
|
|
57
|
+
export interface CapacityProviderRegistrationResponse {
|
|
58
|
+
ok: true;
|
|
59
|
+
provider: {
|
|
60
|
+
id: string;
|
|
61
|
+
teamId: string;
|
|
62
|
+
name: string;
|
|
63
|
+
status: CapacityProviderStatus;
|
|
64
|
+
connectionState?: CapacityProviderConnectionState;
|
|
65
|
+
};
|
|
66
|
+
portfolioManifestUrl: string;
|
|
67
|
+
heartbeatIntervalSeconds: number;
|
|
68
|
+
}
|
|
69
|
+
export interface CapacityProviderHeartbeatRequest {
|
|
70
|
+
marketId: string;
|
|
71
|
+
providerId?: string | null;
|
|
72
|
+
runtime?: CapacityProviderRuntimeInfo;
|
|
73
|
+
capabilities?: CapacityProviderCapability[];
|
|
74
|
+
budgets?: CapacityProviderBudgetCapacity;
|
|
75
|
+
health?: CapacityProviderHealthState;
|
|
76
|
+
status?: CapacityProviderStatus;
|
|
77
|
+
connectionState?: CapacityProviderConnectionState;
|
|
78
|
+
}
|
|
79
|
+
export interface CapacityProviderHeartbeatResponse {
|
|
80
|
+
ok: true;
|
|
81
|
+
provider?: CapacityProviderRegistrationResponse['provider'];
|
|
82
|
+
heartbeatIntervalSeconds?: number;
|
|
83
|
+
}
|
|
84
|
+
export interface CapacityProviderPortfolioManifest {
|
|
85
|
+
team: {
|
|
86
|
+
id: string;
|
|
87
|
+
slug: string;
|
|
88
|
+
name: string;
|
|
89
|
+
};
|
|
90
|
+
projects: CapacityProviderPortfolioProject[];
|
|
91
|
+
}
|
|
92
|
+
export interface CapacityProviderPortfolioProject {
|
|
93
|
+
id: string;
|
|
94
|
+
slug: string;
|
|
95
|
+
name: string;
|
|
96
|
+
repository: {
|
|
97
|
+
provider: string;
|
|
98
|
+
role?: string | null;
|
|
99
|
+
owner: string;
|
|
100
|
+
name: string;
|
|
101
|
+
defaultBranch: string;
|
|
102
|
+
cloneUrl: string;
|
|
103
|
+
currentBranch?: string | null;
|
|
104
|
+
checkoutPath?: string | null;
|
|
105
|
+
submodulePath?: string | null;
|
|
106
|
+
webUrl?: string | null;
|
|
107
|
+
};
|
|
108
|
+
agentSpecs: {
|
|
109
|
+
root: string;
|
|
110
|
+
testsRoot: string;
|
|
111
|
+
};
|
|
112
|
+
workPolicy: {
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
startCron?: string | null;
|
|
115
|
+
durationMinutes?: number | null;
|
|
116
|
+
dailyCreditBudget?: number | null;
|
|
117
|
+
maxRunners?: number | null;
|
|
118
|
+
maxWorkersPerRunner?: number | null;
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
};
|
|
121
|
+
metadata?: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
export interface ProviderWorkdayRequest {
|
|
124
|
+
projectId: string;
|
|
125
|
+
environment: CapacityProviderEnvironmentName;
|
|
126
|
+
idempotencyKey?: string | null;
|
|
127
|
+
kind?: string;
|
|
128
|
+
summary?: Record<string, unknown> | null;
|
|
129
|
+
metadata?: Record<string, unknown> | null;
|
|
130
|
+
}
|
|
131
|
+
export interface ProviderWorkdayResponse {
|
|
132
|
+
ok: true;
|
|
133
|
+
workDay: Record<string, unknown>;
|
|
134
|
+
}
|
|
135
|
+
export interface ProviderTaskClaimRequest {
|
|
136
|
+
providerId?: string | null;
|
|
137
|
+
runnerId?: string | null;
|
|
138
|
+
projectId?: string | null;
|
|
139
|
+
environment?: CapacityProviderEnvironmentName | null;
|
|
140
|
+
limit?: number;
|
|
141
|
+
capabilities?: string[];
|
|
142
|
+
}
|
|
143
|
+
export interface ProviderTaskClaimResponse {
|
|
144
|
+
ok: true;
|
|
145
|
+
tasks: Record<string, unknown>[];
|
|
146
|
+
leaseSeconds?: number;
|
|
147
|
+
}
|
|
148
|
+
export interface ProviderTaskEventRequest {
|
|
149
|
+
kind: string;
|
|
150
|
+
data?: Record<string, unknown>;
|
|
151
|
+
runnerId?: string | null;
|
|
152
|
+
}
|
|
153
|
+
export interface ProviderTaskEventResponse {
|
|
154
|
+
ok: true;
|
|
155
|
+
event?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
export interface ProviderTaskCompleteRequest {
|
|
158
|
+
output?: Record<string, unknown> | null;
|
|
159
|
+
outputRef?: string | null;
|
|
160
|
+
summary?: Record<string, unknown> | null;
|
|
161
|
+
usage?: ProviderUsageReport | null;
|
|
162
|
+
}
|
|
163
|
+
export interface ProviderTaskCompleteResponse {
|
|
164
|
+
ok: true;
|
|
165
|
+
task: Record<string, unknown>;
|
|
166
|
+
}
|
|
167
|
+
export interface ProviderTaskFailRequest {
|
|
168
|
+
errorCode?: string | null;
|
|
169
|
+
errorMessage: string;
|
|
170
|
+
retryable?: boolean;
|
|
171
|
+
nextVisibleAt?: string | null;
|
|
172
|
+
usage?: ProviderUsageReport | null;
|
|
173
|
+
}
|
|
174
|
+
export interface ProviderTaskFailResponse {
|
|
175
|
+
ok: true;
|
|
176
|
+
task: Record<string, unknown>;
|
|
177
|
+
}
|
|
178
|
+
export interface ProviderUsageReport {
|
|
179
|
+
taskId?: string | null;
|
|
180
|
+
workDayId?: string | null;
|
|
181
|
+
projectId?: string | null;
|
|
182
|
+
taskSignature?: string | null;
|
|
183
|
+
executionProfileId?: string | null;
|
|
184
|
+
modelName?: string | null;
|
|
185
|
+
inputTokens?: number | null;
|
|
186
|
+
outputTokens?: number | null;
|
|
187
|
+
cachedInputTokens?: number | null;
|
|
188
|
+
quotaMinutes?: number | null;
|
|
189
|
+
wallMinutes?: number | null;
|
|
190
|
+
filesOpened?: number | null;
|
|
191
|
+
filesChanged?: number | null;
|
|
192
|
+
diffLinesAdded?: number | null;
|
|
193
|
+
diffLinesRemoved?: number | null;
|
|
194
|
+
testRuns?: number | null;
|
|
195
|
+
retryCount?: number | null;
|
|
196
|
+
actualCredits: number;
|
|
197
|
+
actualUsd?: number | null;
|
|
198
|
+
metadata?: Record<string, unknown> | null;
|
|
199
|
+
}
|
|
200
|
+
export interface ProviderUsageReportResponse {
|
|
201
|
+
ok: true;
|
|
202
|
+
usage?: Record<string, unknown>;
|
|
203
|
+
}
|
|
204
|
+
export interface ProviderReportRequest {
|
|
205
|
+
workDayId: string;
|
|
206
|
+
kind: string;
|
|
207
|
+
body: Record<string, unknown>;
|
|
208
|
+
renderedRef?: string | null;
|
|
209
|
+
metadata?: Record<string, unknown> | null;
|
|
210
|
+
}
|
|
211
|
+
export interface ProviderReportResponse {
|
|
212
|
+
ok: true;
|
|
213
|
+
report: Record<string, unknown>;
|
|
214
|
+
}
|
|
215
|
+
export interface CapacityProviderDeploymentIntent {
|
|
216
|
+
teamId: string;
|
|
217
|
+
capacityProviderId: string;
|
|
218
|
+
launchMode: CapacityProviderLaunchMode;
|
|
219
|
+
hostKind: string;
|
|
220
|
+
hostId?: string | null;
|
|
221
|
+
imageRef?: string | null;
|
|
222
|
+
serviceRefs?: Record<string, unknown>;
|
|
223
|
+
envRefs?: Record<string, unknown>;
|
|
224
|
+
}
|
|
225
|
+
export interface CapacityProviderDeploymentResult {
|
|
226
|
+
id: string;
|
|
227
|
+
teamId: string;
|
|
228
|
+
capacityProviderId: string;
|
|
229
|
+
launchMode: CapacityProviderLaunchMode;
|
|
230
|
+
hostKind: string;
|
|
231
|
+
hostId?: string | null;
|
|
232
|
+
status: CapacityProviderDeploymentStatus;
|
|
233
|
+
imageRef?: string | null;
|
|
234
|
+
serviceRefs: Record<string, unknown>;
|
|
235
|
+
envRefs: Record<string, unknown>;
|
|
236
|
+
result: Record<string, unknown>;
|
|
237
|
+
error?: Record<string, unknown> | null;
|
|
238
|
+
createdAt?: string;
|
|
239
|
+
updatedAt?: string;
|
|
240
|
+
completedAt?: string | null;
|
|
241
|
+
}
|
|
242
|
+
export interface CapacityProviderDeploymentServiceSpec {
|
|
243
|
+
role: CapacityProviderDeploymentServiceRole;
|
|
244
|
+
serviceName: string;
|
|
245
|
+
imageRef: string;
|
|
246
|
+
startCommand: string;
|
|
247
|
+
env: Record<string, string>;
|
|
248
|
+
redactedEnv: Record<string, string>;
|
|
249
|
+
}
|
|
250
|
+
export interface CapacityProviderDeploymentServiceResult {
|
|
251
|
+
role: CapacityProviderDeploymentServiceRole;
|
|
252
|
+
serviceName: string;
|
|
253
|
+
serviceId?: string | null;
|
|
254
|
+
url?: string | null;
|
|
255
|
+
status?: CapacityProviderDeploymentStatus;
|
|
256
|
+
envRefs?: Record<string, unknown>;
|
|
257
|
+
metadata?: Record<string, unknown>;
|
|
258
|
+
}
|
|
259
|
+
export interface CapacityProviderDeploymentAdapter {
|
|
260
|
+
provisionService(spec: CapacityProviderDeploymentServiceSpec): Promise<CapacityProviderDeploymentServiceResult> | CapacityProviderDeploymentServiceResult;
|
|
261
|
+
}
|
|
262
|
+
export interface CapacityProviderDeploymentPrimitiveInput {
|
|
263
|
+
intent: CapacityProviderDeploymentIntent;
|
|
264
|
+
env: Record<string, string>;
|
|
265
|
+
redactedEnv?: Record<string, string>;
|
|
266
|
+
imageRef?: string | null;
|
|
267
|
+
serviceNamePrefix?: string | null;
|
|
268
|
+
adapter?: CapacityProviderDeploymentAdapter;
|
|
269
|
+
now?: Date;
|
|
270
|
+
}
|
|
271
|
+
export interface CapacityProviderDeploymentPrimitiveResult {
|
|
272
|
+
ok: boolean;
|
|
273
|
+
launchMode: CapacityProviderLaunchMode;
|
|
274
|
+
hostKind: string;
|
|
275
|
+
imageRef: string;
|
|
276
|
+
status: CapacityProviderDeploymentStatus;
|
|
277
|
+
serviceRefs: Record<CapacityProviderDeploymentServiceRole, CapacityProviderDeploymentServiceResult>;
|
|
278
|
+
envRefs: Record<string, unknown>;
|
|
279
|
+
diagnostics: string[];
|
|
280
|
+
deployedAt?: string | null;
|
|
281
|
+
error?: Record<string, unknown> | null;
|
|
282
|
+
}
|
|
283
|
+
export interface CapacityProviderEnvironmentInput {
|
|
284
|
+
marketUrl: string;
|
|
285
|
+
marketId: string;
|
|
286
|
+
apiKey: string;
|
|
287
|
+
providerDataDir?: string;
|
|
288
|
+
providerApiPort?: number | string;
|
|
289
|
+
providerEnvironment?: CapacityProviderEnvironmentName;
|
|
290
|
+
providerHostDataDir?: string;
|
|
291
|
+
capabilitiesFile?: string;
|
|
292
|
+
budgetFile?: string;
|
|
293
|
+
maxConcurrentWorkdays?: number | string;
|
|
294
|
+
maxConcurrentRunners?: number | string;
|
|
295
|
+
dailyCreditBudget?: number | string;
|
|
296
|
+
monthlyCreditBudget?: number | string;
|
|
297
|
+
codexAuthFile?: string;
|
|
298
|
+
codexAuthJsonB64?: string;
|
|
299
|
+
codexAuthOverwrite?: boolean | number | string;
|
|
300
|
+
}
|
|
301
|
+
export interface CapacityProviderSelfHostInstructions {
|
|
302
|
+
composeFile: string;
|
|
303
|
+
commands: string[];
|
|
304
|
+
env: Record<string, string>;
|
|
305
|
+
redactedEnv: Record<string, string>;
|
|
306
|
+
summary: string;
|
|
307
|
+
}
|
|
308
|
+
export interface CapacityProviderLaunchEnvironmentInput {
|
|
309
|
+
tenantRoot?: string | null;
|
|
310
|
+
scope?: 'local' | 'staging' | 'prod' | string;
|
|
311
|
+
env?: NodeJS.ProcessEnv;
|
|
312
|
+
overrides?: Record<string, string | number | boolean | null | undefined>;
|
|
313
|
+
requireConnection?: boolean;
|
|
314
|
+
diagnostic?: boolean;
|
|
315
|
+
}
|
|
316
|
+
export interface CapacityProviderLaunchEnvironment {
|
|
317
|
+
env: Record<string, string>;
|
|
318
|
+
redactedEnv: Record<string, string>;
|
|
319
|
+
missing: string[];
|
|
320
|
+
diagnostic: boolean;
|
|
321
|
+
source: 'treeseed-config' | 'process-env';
|
|
322
|
+
}
|
|
323
|
+
export interface CapacityProviderConnectionConfigInput extends CapacityProviderEnvironmentInput {
|
|
324
|
+
tenantRoot: string;
|
|
325
|
+
scope?: 'local' | 'staging' | 'prod' | string;
|
|
326
|
+
providerHostDataDir?: string;
|
|
327
|
+
providerEnvironment?: CapacityProviderEnvironmentName;
|
|
328
|
+
}
|
|
329
|
+
export interface CapacityProviderConnectionConfigResult {
|
|
330
|
+
env: Record<string, string>;
|
|
331
|
+
redactedEnv: Record<string, string>;
|
|
332
|
+
scope: string;
|
|
333
|
+
writtenKeys: string[];
|
|
334
|
+
}
|
|
335
|
+
export interface MarketProviderClientOptions extends CapacityProviderEnvironmentInput {
|
|
336
|
+
fetchImpl?: typeof fetch;
|
|
337
|
+
userAgent?: string;
|
|
338
|
+
}
|
|
339
|
+
export declare class CapacityProviderApiError extends Error {
|
|
340
|
+
readonly status: number;
|
|
341
|
+
readonly payload: unknown;
|
|
342
|
+
constructor(message: string, status: number, payload: unknown);
|
|
343
|
+
}
|
|
344
|
+
export declare function buildCapacityProviderAuthHeaders(apiKey: string): {
|
|
345
|
+
authorization: string;
|
|
346
|
+
};
|
|
347
|
+
export declare function assertCapacityProviderOkEnvelope(value: unknown, label?: string): asserts value is {
|
|
348
|
+
ok: true;
|
|
349
|
+
};
|
|
350
|
+
export declare function assertCapacityProviderRegistrationResponse(value: unknown): asserts value is CapacityProviderRegistrationResponse;
|
|
351
|
+
export declare function assertCapacityProviderPortfolioManifest(value: unknown): asserts value is CapacityProviderPortfolioManifest;
|
|
352
|
+
export declare function resolveCapacityProviderEnvironment(input: CapacityProviderEnvironmentInput): Record<string, string>;
|
|
353
|
+
export declare function resolveCapacityProviderLaunchEnvironment(input?: CapacityProviderLaunchEnvironmentInput): CapacityProviderLaunchEnvironment;
|
|
354
|
+
export declare function persistCapacityProviderConnectionToTreeseedConfig(input: CapacityProviderConnectionConfigInput): CapacityProviderConnectionConfigResult;
|
|
355
|
+
export declare function redactCapacityProviderSecret(value: string): string;
|
|
356
|
+
export declare function isCapacityProviderSecretEnvKey(key: string): boolean;
|
|
357
|
+
export declare function redactCapacityProviderEnv(env: Record<string, string>): Record<string, string>;
|
|
358
|
+
export declare function renderCapacityProviderSelfHostInstructions(input: CapacityProviderEnvironmentInput): CapacityProviderSelfHostInstructions;
|
|
359
|
+
export declare function deployCapacityProviderToRailway(input: CapacityProviderDeploymentPrimitiveInput): Promise<CapacityProviderDeploymentPrimitiveResult>;
|
|
360
|
+
export declare function deployCapacityProviderToManagedMarketHost(input: CapacityProviderDeploymentPrimitiveInput): Promise<CapacityProviderDeploymentPrimitiveResult>;
|
|
361
|
+
export declare class MarketProviderClient {
|
|
362
|
+
private readonly marketUrl;
|
|
363
|
+
private readonly marketId;
|
|
364
|
+
private readonly apiKey;
|
|
365
|
+
private readonly fetchImpl;
|
|
366
|
+
private readonly userAgent?;
|
|
367
|
+
constructor(options: MarketProviderClientOptions);
|
|
368
|
+
private requestJson;
|
|
369
|
+
register(request: Omit<CapacityProviderRegistrationRequest, 'marketId'> & {
|
|
370
|
+
marketId?: string;
|
|
371
|
+
}): Promise<CapacityProviderRegistrationResponse>;
|
|
372
|
+
heartbeat(request?: Omit<CapacityProviderHeartbeatRequest, 'marketId'> & {
|
|
373
|
+
marketId?: string;
|
|
374
|
+
}): Promise<CapacityProviderHeartbeatResponse>;
|
|
375
|
+
portfolio(): Promise<CapacityProviderPortfolioManifest>;
|
|
376
|
+
createWorkday(request: ProviderWorkdayRequest): Promise<ProviderWorkdayResponse>;
|
|
377
|
+
claimTask(request?: ProviderTaskClaimRequest): Promise<ProviderTaskClaimResponse>;
|
|
378
|
+
appendTaskEvent(taskId: string, request: ProviderTaskEventRequest): Promise<ProviderTaskEventResponse>;
|
|
379
|
+
completeTask(taskId: string, request?: ProviderTaskCompleteRequest): Promise<ProviderTaskCompleteResponse>;
|
|
380
|
+
failTask(taskId: string, request: ProviderTaskFailRequest): Promise<ProviderTaskFailResponse>;
|
|
381
|
+
reportUsage(request: ProviderUsageReport): Promise<ProviderUsageReportResponse>;
|
|
382
|
+
writeReport(request: ProviderReportRequest): Promise<ProviderReportResponse>;
|
|
383
|
+
}
|