@treeseed/sdk 0.8.7 → 0.8.9
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/capacity.d.ts +120 -1
- package/dist/capacity.js +371 -2
- package/dist/control-plane-client.d.ts +1 -1
- package/dist/d1-store.d.ts +5 -5
- package/dist/d1-store.js +24 -24
- package/dist/db/d1.d.ts +102 -0
- package/dist/db/node-sqlite.d.ts +102 -0
- package/dist/db/schema.d.ts +204 -0
- package/dist/db/schema.js +9 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +33 -23
- package/dist/market-client.d.ts +32 -0
- package/dist/market-client.js +48 -0
- package/dist/operations/services/config-runtime.js +57 -20
- package/dist/operations/services/d1-migration.js +10 -2
- package/dist/operations/services/github-automation.js +1 -1
- package/dist/operations/services/hosting-audit.d.ts +2 -1
- package/dist/operations/services/hosting-audit.js +18 -9
- package/dist/operations/services/hub-provider-launch.d.ts +3 -3
- package/dist/operations/services/hub-provider-launch.js +16 -16
- package/dist/operations/services/{knowledge-coop-packaging.d.ts → market-packaging.d.ts} +13 -13
- package/dist/operations/services/{knowledge-coop-packaging.js → market-packaging.js} +10 -10
- package/dist/operations/services/project-platform.d.ts +32 -0
- package/dist/operations/services/project-platform.js +91 -1
- package/dist/platform/contracts.d.ts +53 -31
- package/dist/platform/utils/site-config-schema.js +120 -52
- package/dist/{knowledge-coop.d.ts → project-workflow.d.ts} +15 -15
- package/dist/{knowledge-coop.js → project-workflow.js} +15 -15
- package/dist/reconcile/builtin-adapters.js +95 -11
- package/dist/scripts/tenant-d1-migrate-local.js +1 -0
- package/dist/sdk-types.d.ts +5 -4
- package/dist/sdk.d.ts +1 -1
- package/dist/stores/{knowledge-coop-store.d.ts → project-workflow-store.d.ts} +3 -3
- package/dist/stores/{knowledge-coop-store.js → project-workflow-store.js} +4 -4
- package/dist/workflow/operations.js +6 -6
- package/dist/workflow-state.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,9 +6,14 @@ import { ControlPlaneClient } from "./control-plane-client.js";
|
|
|
6
6
|
import {
|
|
7
7
|
reservationHasCapacity,
|
|
8
8
|
reserveCreditsForEstimate,
|
|
9
|
+
routeAndReserveCapacity,
|
|
9
10
|
scoreCapacityLane,
|
|
10
11
|
selectBestCapacityLane,
|
|
11
|
-
|
|
12
|
+
settleCapacityActuals,
|
|
13
|
+
createReservationReleaseEntry,
|
|
14
|
+
summarizeCapacityPlan,
|
|
15
|
+
summarizeProjectCapacityPlan,
|
|
16
|
+
summarizeTeamCapacityPlan
|
|
12
17
|
} from "./capacity.js";
|
|
13
18
|
import {
|
|
14
19
|
executeKnowledgeHubProviderLaunch,
|
|
@@ -40,20 +45,20 @@ import {
|
|
|
40
45
|
upsertRailwayVariables
|
|
41
46
|
} from "./operations/services/railway-api.js";
|
|
42
47
|
import {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} from "./operations/services/
|
|
48
|
+
buildKnowledgePackMarketPackage,
|
|
49
|
+
buildTemplateMarketPackage,
|
|
50
|
+
importKnowledgePack
|
|
51
|
+
} from "./operations/services/market-packaging.js";
|
|
47
52
|
import {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
AGENT_MESSAGE_KINDS,
|
|
54
|
+
PROJECT_JOB_STATUSES,
|
|
55
|
+
RELEASE_STATES,
|
|
56
|
+
SHARE_PACKAGE_STATES,
|
|
57
|
+
PROJECT_TEAM_CAPABILITIES,
|
|
58
|
+
WORKSTREAM_STATES,
|
|
59
|
+
normalizeProjectJobStatus,
|
|
55
60
|
normalizeRemoteJobStatus
|
|
56
|
-
} from "./
|
|
61
|
+
} from "./project-workflow.js";
|
|
57
62
|
import {
|
|
58
63
|
PUBLISHED_CONTENT_MANIFEST_SCHEMA_VERSION,
|
|
59
64
|
EDITORIAL_PREVIEW_COOKIE,
|
|
@@ -194,6 +199,7 @@ import {
|
|
|
194
199
|
import { getTreeseedVerifyDriverStatus, runTreeseedVerifyDriver } from "./verification.js";
|
|
195
200
|
import { CloudflareHttpD1Database } from "./d1-http.js";
|
|
196
201
|
export {
|
|
202
|
+
AGENT_MESSAGE_KINDS,
|
|
197
203
|
AgentSdk,
|
|
198
204
|
BUILTIN_MODEL_REGISTRY,
|
|
199
205
|
CloudflareHttpD1Database,
|
|
@@ -204,16 +210,13 @@ export {
|
|
|
204
210
|
DEFAULT_GRAPH_RANKING_PROVIDER,
|
|
205
211
|
DEFAULT_TREESEED_MARKET_BASE_URL,
|
|
206
212
|
EDITORIAL_PREVIEW_COOKIE,
|
|
207
|
-
KNOWLEDGE_COOP_AGENT_MESSAGE_KINDS,
|
|
208
|
-
KNOWLEDGE_COOP_JOB_STATUSES,
|
|
209
|
-
KNOWLEDGE_COOP_RELEASE_STATES,
|
|
210
|
-
KNOWLEDGE_COOP_SHARE_PACKAGE_STATES,
|
|
211
|
-
KNOWLEDGE_COOP_TEAM_CAPABILITIES,
|
|
212
|
-
KNOWLEDGE_COOP_WORKSTREAM_STATES,
|
|
213
213
|
MODEL_REGISTRY,
|
|
214
214
|
MarketApiError,
|
|
215
215
|
MarketClient,
|
|
216
|
+
PROJECT_JOB_STATUSES,
|
|
217
|
+
PROJECT_TEAM_CAPABILITIES,
|
|
216
218
|
PUBLISHED_CONTENT_MANIFEST_SCHEMA_VERSION,
|
|
219
|
+
RELEASE_STATES,
|
|
217
220
|
RemoteTemplateCatalogClient,
|
|
218
221
|
RemoteTreeseedAuthClient,
|
|
219
222
|
RemoteTreeseedClient,
|
|
@@ -222,6 +225,7 @@ export {
|
|
|
222
225
|
RemoteTreeseedOperationsClient,
|
|
223
226
|
RemoteTreeseedRunnerClient,
|
|
224
227
|
RemoteTreeseedSdkClient,
|
|
228
|
+
SHARE_PACKAGE_STATES,
|
|
225
229
|
ScopedAgentSdk,
|
|
226
230
|
TREESEED_CATALOG_MARKET_API_BASE_URLS_ENV,
|
|
227
231
|
TREESEED_CENTRAL_MARKET_API_BASE_URL_ENV,
|
|
@@ -233,13 +237,14 @@ export {
|
|
|
233
237
|
TeamScopedR2OverlayContentRuntimeProvider,
|
|
234
238
|
TreeseedOperationsSdk,
|
|
235
239
|
TreeseedWorkflowSdk,
|
|
240
|
+
WORKSTREAM_STATES,
|
|
236
241
|
addMarketProfile,
|
|
237
242
|
buildBuiltinModelRegistry,
|
|
238
243
|
buildCopilotAllowToolArgs,
|
|
239
|
-
|
|
240
|
-
buildKnowledgeCoopTemplatePackage,
|
|
244
|
+
buildKnowledgePackMarketPackage,
|
|
241
245
|
buildModelRegistry,
|
|
242
246
|
buildScopedModelRegistry,
|
|
247
|
+
buildTemplateMarketPackage,
|
|
243
248
|
canonicalizeFrontmatter,
|
|
244
249
|
clearMarketSession,
|
|
245
250
|
collectTreeseedDependencyStatus,
|
|
@@ -250,6 +255,7 @@ export {
|
|
|
250
255
|
createFilesystemContentSource,
|
|
251
256
|
createKnowledgeHubRepositories,
|
|
252
257
|
createPublishedContentPipeline,
|
|
258
|
+
createReservationReleaseEntry,
|
|
253
259
|
createTeamScopedR2OverlayContentPublishProvider,
|
|
254
260
|
createTeamScopedR2OverlayContentRuntimeProvider,
|
|
255
261
|
createTreeseedManagedToolEnv,
|
|
@@ -270,7 +276,7 @@ export {
|
|
|
270
276
|
getRailwayAuthProfile,
|
|
271
277
|
getTenantContentRoot,
|
|
272
278
|
getTreeseedVerifyDriverStatus,
|
|
273
|
-
|
|
279
|
+
importKnowledgePack,
|
|
274
280
|
installTreeseedDependencies,
|
|
275
281
|
isTeamScopedR2ContentEnabled,
|
|
276
282
|
listIntegratedMarketCatalog,
|
|
@@ -289,9 +295,9 @@ export {
|
|
|
289
295
|
normalizeAgentCliOptions,
|
|
290
296
|
normalizeAliasedRecord,
|
|
291
297
|
normalizeFilterFields,
|
|
292
|
-
normalizeKnowledgeCoopJobStatus,
|
|
293
298
|
normalizeKnowledgeHubLaunchIntent,
|
|
294
299
|
normalizeMutationData,
|
|
300
|
+
normalizeProjectJobStatus,
|
|
295
301
|
normalizeRecordToCanonicalShape,
|
|
296
302
|
normalizeRemoteJobStatus,
|
|
297
303
|
normalizeSortFields,
|
|
@@ -336,14 +342,18 @@ export {
|
|
|
336
342
|
resolveTreeseedTenantRoot,
|
|
337
343
|
resolveTreeseedToolBinary,
|
|
338
344
|
resolveTreeseedToolCommand,
|
|
345
|
+
routeAndReserveCapacity,
|
|
339
346
|
runTreeseedCopilotTask,
|
|
340
347
|
runTreeseedVerifyDriver,
|
|
341
348
|
scoreCapacityLane,
|
|
342
349
|
selectBestCapacityLane,
|
|
343
350
|
setActiveMarketProfile,
|
|
344
351
|
setMarketSession,
|
|
352
|
+
settleCapacityActuals,
|
|
345
353
|
signEditorialPreviewToken,
|
|
346
354
|
summarizeCapacityPlan,
|
|
355
|
+
summarizeProjectCapacityPlan,
|
|
356
|
+
summarizeTeamCapacityPlan,
|
|
347
357
|
tenantFeatureEnabled,
|
|
348
358
|
tenantModelRendered,
|
|
349
359
|
upsertRailwayVariables,
|
package/dist/market-client.d.ts
CHANGED
|
@@ -165,6 +165,38 @@ export declare class MarketClient {
|
|
|
165
165
|
environments: ProjectEnvironmentAccess[];
|
|
166
166
|
};
|
|
167
167
|
}>;
|
|
168
|
+
teamCapacity(teamId: string): Promise<{
|
|
169
|
+
ok: true;
|
|
170
|
+
payload: Record<string, unknown>;
|
|
171
|
+
}>;
|
|
172
|
+
launchManagedCapacityProvider(teamId: string, body?: Record<string, unknown>): Promise<{
|
|
173
|
+
ok: true;
|
|
174
|
+
payload: Record<string, unknown>;
|
|
175
|
+
}>;
|
|
176
|
+
capacityProvider(providerId: string): Promise<{
|
|
177
|
+
ok: true;
|
|
178
|
+
payload: Record<string, unknown>;
|
|
179
|
+
}>;
|
|
180
|
+
resetCapacityProviderApiKey(providerId: string, body?: Record<string, unknown>): Promise<{
|
|
181
|
+
ok: true;
|
|
182
|
+
payload: Record<string, unknown>;
|
|
183
|
+
}>;
|
|
184
|
+
revokeCapacityProviderApiKey(providerId: string, keyId: string): Promise<{
|
|
185
|
+
ok: true;
|
|
186
|
+
payload: Record<string, unknown>;
|
|
187
|
+
}>;
|
|
188
|
+
capacityGrants(teamId: string): Promise<{
|
|
189
|
+
ok: true;
|
|
190
|
+
payload: unknown[];
|
|
191
|
+
}>;
|
|
192
|
+
createCapacityGrant(teamId: string, body: Record<string, unknown>): Promise<{
|
|
193
|
+
ok: true;
|
|
194
|
+
payload: Record<string, unknown>;
|
|
195
|
+
}>;
|
|
196
|
+
enqueueAgentTask(projectId: string, body: Record<string, unknown>): Promise<{
|
|
197
|
+
ok: true;
|
|
198
|
+
payload: Record<string, unknown>;
|
|
199
|
+
}>;
|
|
168
200
|
catalog(kind?: string | null): Promise<{
|
|
169
201
|
ok: true;
|
|
170
202
|
payload: unknown[];
|
package/dist/market-client.js
CHANGED
|
@@ -315,6 +315,54 @@ class MarketClient {
|
|
|
315
315
|
{ requireAuth: true }
|
|
316
316
|
);
|
|
317
317
|
}
|
|
318
|
+
teamCapacity(teamId) {
|
|
319
|
+
return this.request(
|
|
320
|
+
`/v1/teams/${encodeURIComponent(teamId)}/capacity`,
|
|
321
|
+
{ requireAuth: true }
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
launchManagedCapacityProvider(teamId, body = {}) {
|
|
325
|
+
return this.request(
|
|
326
|
+
`/v1/teams/${encodeURIComponent(teamId)}/capacity/providers/managed`,
|
|
327
|
+
{ method: "POST", body, requireAuth: true }
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
capacityProvider(providerId) {
|
|
331
|
+
return this.request(
|
|
332
|
+
`/v1/capacity/providers/${encodeURIComponent(providerId)}`,
|
|
333
|
+
{ requireAuth: true }
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
resetCapacityProviderApiKey(providerId, body = {}) {
|
|
337
|
+
return this.request(
|
|
338
|
+
`/v1/capacity/providers/${encodeURIComponent(providerId)}/api-keys/reset`,
|
|
339
|
+
{ method: "POST", body, requireAuth: true }
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
revokeCapacityProviderApiKey(providerId, keyId) {
|
|
343
|
+
return this.request(
|
|
344
|
+
`/v1/capacity/providers/${encodeURIComponent(providerId)}/api-keys/${encodeURIComponent(keyId)}/revoke`,
|
|
345
|
+
{ method: "POST", requireAuth: true }
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
capacityGrants(teamId) {
|
|
349
|
+
return this.request(
|
|
350
|
+
`/v1/teams/${encodeURIComponent(teamId)}/capacity-grants`,
|
|
351
|
+
{ requireAuth: true }
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
createCapacityGrant(teamId, body) {
|
|
355
|
+
return this.request(
|
|
356
|
+
`/v1/teams/${encodeURIComponent(teamId)}/capacity-grants`,
|
|
357
|
+
{ method: "POST", body, requireAuth: true }
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
enqueueAgentTask(projectId, body) {
|
|
361
|
+
return this.request(
|
|
362
|
+
`/v1/projects/${encodeURIComponent(projectId)}/agent-tasks`,
|
|
363
|
+
{ method: "POST", body, requireAuth: true }
|
|
364
|
+
);
|
|
365
|
+
}
|
|
318
366
|
catalog(kind) {
|
|
319
367
|
const query = kind ? `?kind=${encodeURIComponent(kind)}` : "";
|
|
320
368
|
return this.request(`/v1/catalog${query}`, { requireAuth: Boolean(this.accessToken) });
|
|
@@ -1851,30 +1851,53 @@ function checkGitHubConnection({ tenantRoot, env }) {
|
|
|
1851
1851
|
if (!gh) {
|
|
1852
1852
|
return providerConnectionResult("github", false, "GitHub CLI `gh` is not installed.");
|
|
1853
1853
|
}
|
|
1854
|
-
const
|
|
1855
|
-
const
|
|
1854
|
+
const identityMode = env.TREESEED_GITHUB_IDENTITY_MODE === "account" ? "account" : "repository";
|
|
1855
|
+
const repository = identityMode === "repository" ? maybeResolveGitHubRepositorySlug(tenantRoot) : null;
|
|
1856
|
+
const owner = typeof env.TREESEED_HOSTED_HUBS_GITHUB_OWNER === "string" ? env.TREESEED_HOSTED_HUBS_GITHUB_OWNER.trim() : "";
|
|
1857
|
+
const commandCandidates = repository ? [{
|
|
1858
|
+
args: ["repo", "view", repository, "--json", "nameWithOwner", "--jq", ".nameWithOwner"],
|
|
1859
|
+
successMessage: (resolved) => `GitHub token can access ${resolved || repository}.`
|
|
1860
|
+
}] : owner ? [
|
|
1861
|
+
{
|
|
1862
|
+
args: ["api", `orgs/${owner}`, "--jq", ".login"],
|
|
1863
|
+
successMessage: (resolved) => `GitHub token can access organization ${resolved || owner}.`,
|
|
1864
|
+
optional: true
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
args: ["api", `users/${owner}`, "--jq", ".login"],
|
|
1868
|
+
successMessage: (resolved) => `GitHub token can access user ${resolved || owner}.`,
|
|
1869
|
+
optional: true
|
|
1870
|
+
}
|
|
1871
|
+
] : [
|
|
1872
|
+
{
|
|
1873
|
+
args: ["api", "user", "--jq", ".login"],
|
|
1874
|
+
successMessage: (resolved) => resolved ? `Authenticated as ${resolved}.` : "GitHub API check succeeded."
|
|
1875
|
+
}
|
|
1876
|
+
];
|
|
1877
|
+
let lastDetail = "";
|
|
1856
1878
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
1857
|
-
const
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1879
|
+
for (const candidate of commandCandidates) {
|
|
1880
|
+
const result = spawnSync(gh, candidate.args, {
|
|
1881
|
+
cwd: tenantRoot,
|
|
1882
|
+
stdio: "pipe",
|
|
1883
|
+
encoding: "utf8",
|
|
1884
|
+
env: createTreeseedManagedToolEnv({ ...process.env, ...env }),
|
|
1885
|
+
timeout: CLI_CHECK_TIMEOUT_MS
|
|
1886
|
+
});
|
|
1887
|
+
if (result.status === 0) {
|
|
1888
|
+
return providerConnectionResult("github", true, candidate.successMessage(result.stdout.trim()));
|
|
1889
|
+
}
|
|
1890
|
+
lastDetail = formatCheckOutput(result) || "GitHub API check failed.";
|
|
1891
|
+
if (candidate.optional && !isTransientProviderConnectionError(lastDetail)) {
|
|
1892
|
+
continue;
|
|
1893
|
+
}
|
|
1894
|
+
break;
|
|
1871
1895
|
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
return providerConnectionResult("github", false, detail);
|
|
1896
|
+
if (attempt >= 2 || !isTransientProviderConnectionError(lastDetail)) {
|
|
1897
|
+
return providerConnectionResult("github", false, lastDetail || "GitHub API check failed.");
|
|
1875
1898
|
}
|
|
1876
1899
|
}
|
|
1877
|
-
return providerConnectionResult("github", false, "GitHub API check failed.");
|
|
1900
|
+
return providerConnectionResult("github", false, lastDetail || "GitHub API check failed.");
|
|
1878
1901
|
}
|
|
1879
1902
|
function checkCloudflareConnection({ tenantRoot, env }) {
|
|
1880
1903
|
if (!env.CLOUDFLARE_API_TOKEN) {
|
|
@@ -1964,8 +1987,22 @@ async function checkRailwayConnection({ tenantRoot, env }) {
|
|
|
1964
1987
|
}
|
|
1965
1988
|
async function checkTreeseedProviderConnections({ tenantRoot, scope = "prod", env = process.env, valuesOverlay = {} } = {}) {
|
|
1966
1989
|
const values = collectTreeseedConfigSeedValues(tenantRoot, scope, env, valuesOverlay);
|
|
1990
|
+
const passthroughValue = (key) => {
|
|
1991
|
+
const overlayValue = valuesOverlay?.[key];
|
|
1992
|
+
if (typeof overlayValue === "string" && overlayValue.trim()) {
|
|
1993
|
+
return overlayValue.trim();
|
|
1994
|
+
}
|
|
1995
|
+
const envValue = env?.[key];
|
|
1996
|
+
if (typeof envValue === "string" && envValue.trim()) {
|
|
1997
|
+
return envValue.trim();
|
|
1998
|
+
}
|
|
1999
|
+
const resolvedValue = values?.[key];
|
|
2000
|
+
return typeof resolvedValue === "string" && resolvedValue.trim() ? resolvedValue.trim() : void 0;
|
|
2001
|
+
};
|
|
1967
2002
|
const rawCommandEnv = {
|
|
1968
2003
|
GH_TOKEN: values.GH_TOKEN,
|
|
2004
|
+
TREESEED_GITHUB_IDENTITY_MODE: passthroughValue("TREESEED_GITHUB_IDENTITY_MODE"),
|
|
2005
|
+
TREESEED_HOSTED_HUBS_GITHUB_OWNER: passthroughValue("TREESEED_HOSTED_HUBS_GITHUB_OWNER"),
|
|
1969
2006
|
CLOUDFLARE_API_TOKEN: values.CLOUDFLARE_API_TOKEN,
|
|
1970
2007
|
CLOUDFLARE_ACCOUNT_ID: values.CLOUDFLARE_ACCOUNT_ID,
|
|
1971
2008
|
RAILWAY_API_TOKEN: values.RAILWAY_API_TOKEN,
|
|
@@ -3,12 +3,14 @@ import { resolve } from "node:path";
|
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
4
|
import { resolveWranglerBin } from "./runtime-tools.js";
|
|
5
5
|
const DATABASE_BINDING = "SITE_DATA_DB";
|
|
6
|
+
const WRANGLER_D1_TIMEOUT_MS = 12e4;
|
|
6
7
|
function runWrangler(args, { cwd, capture = false } = {}) {
|
|
7
8
|
return spawnSync(process.execPath, [resolveWranglerBin(), ...args], {
|
|
8
9
|
cwd,
|
|
9
|
-
env: { ...process.env },
|
|
10
|
+
env: { ...process.env, WRANGLER_SEND_METRICS: "false" },
|
|
10
11
|
stdio: capture ? ["ignore", "pipe", "pipe"] : "inherit",
|
|
11
|
-
encoding: capture ? "utf8" : void 0
|
|
12
|
+
encoding: capture ? "utf8" : void 0,
|
|
13
|
+
timeout: WRANGLER_D1_TIMEOUT_MS
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
16
|
function executeSqlFile({ cwd, wranglerConfig, filePath, persistTo }) {
|
|
@@ -26,12 +28,18 @@ function executeSqlCommand({ cwd, wranglerConfig, command, persistTo, capture =
|
|
|
26
28
|
if (persistTo) {
|
|
27
29
|
args.push("--persist-to", persistTo);
|
|
28
30
|
}
|
|
31
|
+
if (capture) {
|
|
32
|
+
args.push("--json");
|
|
33
|
+
}
|
|
29
34
|
const result = runWrangler(args, { cwd, capture });
|
|
30
35
|
if (result.status !== 0) {
|
|
31
36
|
if (capture) {
|
|
32
37
|
if (result.stdout) process.stdout.write(result.stdout);
|
|
33
38
|
if (result.stderr) process.stderr.write(result.stderr);
|
|
34
39
|
}
|
|
40
|
+
if (result.error && "code" in result.error && result.error.code === "ETIMEDOUT") {
|
|
41
|
+
console.error(`Wrangler D1 command timed out after ${Math.round(WRANGLER_D1_TIMEOUT_MS / 1e3)} seconds.`);
|
|
42
|
+
}
|
|
35
43
|
process.exit(result.status ?? 1);
|
|
36
44
|
}
|
|
37
45
|
return result;
|
|
@@ -221,7 +221,7 @@ async function createGitHubRepository(input, { env = process.env } = {}) {
|
|
|
221
221
|
function initializeGitHubRepositoryWorkingTree(cwd, repository, {
|
|
222
222
|
defaultBranch = "main",
|
|
223
223
|
createStaging = true,
|
|
224
|
-
commitMessage = "Initialize
|
|
224
|
+
commitMessage = "Initialize TreeSeed hub",
|
|
225
225
|
remoteName = "origin",
|
|
226
226
|
push = true
|
|
227
227
|
} = {}) {
|
|
@@ -52,6 +52,7 @@ export type TreeseedHostingAuditOptions = {
|
|
|
52
52
|
env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
|
|
53
53
|
valuesOverlay?: Record<string, string | undefined>;
|
|
54
54
|
hostKinds?: TreeseedHostingAuditHostKind[];
|
|
55
|
+
providerConnectionChecks?: boolean;
|
|
55
56
|
write?: (line: string) => void;
|
|
56
57
|
};
|
|
57
58
|
export declare function resolveTreeseedHostingAuditTarget({ tenantRoot, environment, }: {
|
|
@@ -63,5 +64,5 @@ export declare function resolveTreeseedHostingAuditTarget({ tenantRoot, environm
|
|
|
63
64
|
target: TreeseedReconcileTarget;
|
|
64
65
|
branchName: string | null;
|
|
65
66
|
};
|
|
66
|
-
export declare function runTreeseedHostingAudit({ tenantRoot, environment, repair, env, valuesOverlay, hostKinds: requestedHostKinds, write, }: TreeseedHostingAuditOptions): Promise<TreeseedHostingAuditReport>;
|
|
67
|
+
export declare function runTreeseedHostingAudit({ tenantRoot, environment, repair, env, valuesOverlay, hostKinds: requestedHostKinds, providerConnectionChecks: shouldCheckProviderConnections, write, }: TreeseedHostingAuditOptions): Promise<TreeseedHostingAuditReport>;
|
|
67
68
|
export declare function formatTreeseedHostingAuditReport(report: TreeseedHostingAuditReport): string;
|
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
const HOST_KINDS = ["repository", "web", "processing", "email"];
|
|
29
29
|
const HOST_GROUPS = {
|
|
30
30
|
repository: /* @__PURE__ */ new Set(["auth", "github"]),
|
|
31
|
-
web: /* @__PURE__ */ new Set(["
|
|
32
|
-
processing: /* @__PURE__ */ new Set(["
|
|
31
|
+
web: /* @__PURE__ */ new Set(["cloudflare", "hosting"]),
|
|
32
|
+
processing: /* @__PURE__ */ new Set(["railway", "hosting"]),
|
|
33
33
|
email: /* @__PURE__ */ new Set(["smtp"])
|
|
34
34
|
};
|
|
35
35
|
function hasValue(value) {
|
|
@@ -486,6 +486,7 @@ async function runTreeseedHostingAudit({
|
|
|
486
486
|
env = process.env,
|
|
487
487
|
valuesOverlay = {},
|
|
488
488
|
hostKinds: requestedHostKinds,
|
|
489
|
+
providerConnectionChecks: shouldCheckProviderConnections = true,
|
|
489
490
|
write
|
|
490
491
|
}) {
|
|
491
492
|
const resolved = resolveTreeseedHostingAuditTarget({ tenantRoot, environment });
|
|
@@ -511,13 +512,21 @@ async function runTreeseedHostingAudit({
|
|
|
511
512
|
const checks = [];
|
|
512
513
|
appendManualConfigChecks(checks, values, hostKinds);
|
|
513
514
|
appendRegistryConfigChecks({ checks, tenantRoot, scope: resolved.scope, values, hostKinds });
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
515
|
+
if (shouldCheckProviderConnections) {
|
|
516
|
+
const connectionReport = await checkTreeseedProviderConnections({
|
|
517
|
+
tenantRoot,
|
|
518
|
+
scope: resolved.scope,
|
|
519
|
+
env: {
|
|
520
|
+
...values,
|
|
521
|
+
TREESEED_GITHUB_IDENTITY_MODE: "account"
|
|
522
|
+
},
|
|
523
|
+
valuesOverlay: {
|
|
524
|
+
...values,
|
|
525
|
+
TREESEED_GITHUB_IDENTITY_MODE: "account"
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
checks.push(...providerConnectionChecks(connectionReport, hostKinds));
|
|
529
|
+
}
|
|
521
530
|
if (hostKinds.includes("email")) {
|
|
522
531
|
checks.push(await checkSmtpReachability(values));
|
|
523
532
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { checkTreeseedProviderConnections, syncTreeseedGitHubEnvironment } from './config-runtime.ts';
|
|
2
2
|
import { configuredRailwayServices, deployRailwayService, ensureRailwayScheduledJobs, verifyRailwayScheduledJobs } from './railway-deploy.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { buildKnowledgePackMarketPackage, buildTemplateMarketPackage } from './market-packaging.ts';
|
|
4
4
|
export type KnowledgeHubProviderLaunchFailurePhase = 'repo_provision_failed' | 'content_bootstrap_failed' | 'workflow_bootstrap_failed' | 'hosting_registration_failed' | 'runtime_connection_failed';
|
|
5
5
|
export interface KnowledgeHubProviderLaunchInput {
|
|
6
6
|
projectId: string;
|
|
@@ -133,8 +133,8 @@ export interface KnowledgeHubProviderLaunchResult {
|
|
|
133
133
|
projectMetadata: Record<string, unknown>;
|
|
134
134
|
defaultWorkstream: Record<string, unknown>;
|
|
135
135
|
phases: KnowledgeHubProviderLaunchPhaseRecord[];
|
|
136
|
-
templatePackage: ReturnType<typeof
|
|
137
|
-
knowledgePackPackage: ReturnType<typeof
|
|
136
|
+
templatePackage: ReturnType<typeof buildTemplateMarketPackage>;
|
|
137
|
+
knowledgePackPackage: ReturnType<typeof buildKnowledgePackMarketPackage>;
|
|
138
138
|
}
|
|
139
139
|
export interface KnowledgeHubProviderLaunchPreflightReport {
|
|
140
140
|
ok: boolean;
|
|
@@ -16,7 +16,7 @@ import { configuredRailwayServices, deployRailwayService, ensureRailwayScheduled
|
|
|
16
16
|
import { loadCliDeployConfig } from "./runtime-tools.js";
|
|
17
17
|
import { templateCatalogRoot } from "./runtime-paths.js";
|
|
18
18
|
import { scaffoldTemplateProject } from "./template-registry.js";
|
|
19
|
-
import {
|
|
19
|
+
import { buildKnowledgePackMarketPackage, buildTemplateMarketPackage, importKnowledgePack } from "./market-packaging.js";
|
|
20
20
|
import { resolveTreeseedToolBinary } from "../../managed-dependencies.js";
|
|
21
21
|
class KnowledgeHubProviderLaunchError extends Error {
|
|
22
22
|
phase;
|
|
@@ -81,7 +81,7 @@ function updateYamlFile(path, updater) {
|
|
|
81
81
|
function currentTemplateCatalogUrl() {
|
|
82
82
|
return `file:${resolve(templateCatalogRoot, "catalog.fixture.json")}`;
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function seedLaunchContent(projectRoot, input) {
|
|
85
85
|
const objectiveId = `objective:launch-${slugify(input.projectSlug, "hub")}`;
|
|
86
86
|
const questionId = `question:operating-${slugify(input.projectSlug, "hub")}`;
|
|
87
87
|
const proposalId = `proposal:operating-${slugify(input.projectSlug, "hub")}`;
|
|
@@ -108,7 +108,7 @@ date: ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}
|
|
|
108
108
|
summary: Stand up the hub, connect the runtime, and make the first workstream visible to the team.
|
|
109
109
|
status: live
|
|
110
110
|
timeHorizon: near-term
|
|
111
|
-
motivation:
|
|
111
|
+
motivation: TreeSeed launches should create immediately usable hubs instead of leaving teams in setup limbo.
|
|
112
112
|
primaryContributor: ${stewardSlug}
|
|
113
113
|
---
|
|
114
114
|
|
|
@@ -205,7 +205,7 @@ audience:
|
|
|
205
205
|
|
|
206
206
|
# ${input.projectName}
|
|
207
207
|
|
|
208
|
-
This knowledge hub was launched from
|
|
208
|
+
This knowledge hub was launched from TreeSeed and is ready for Direct, Workstreams, Releases, and Share workflows.
|
|
209
209
|
`);
|
|
210
210
|
writeText(resolve(projectRoot, "src/content/pages", "welcome.mdx"), `---
|
|
211
211
|
title: Welcome
|
|
@@ -419,7 +419,7 @@ function createDefaultWorkstream(projectId, input, seed) {
|
|
|
419
419
|
state: "saved_remote",
|
|
420
420
|
branchName: "task/initial-launch",
|
|
421
421
|
branchRef: "refs/heads/task/initial-launch",
|
|
422
|
-
owner: "
|
|
422
|
+
owner: "TreeSeed",
|
|
423
423
|
linkedItems: [
|
|
424
424
|
{ model: "objective", id: seed.objectiveId },
|
|
425
425
|
{ model: "question", id: seed.questionId },
|
|
@@ -433,7 +433,7 @@ function createDefaultWorkstream(projectId, input, seed) {
|
|
|
433
433
|
createdAt: nowIso(),
|
|
434
434
|
updatedAt: nowIso(),
|
|
435
435
|
metadata: {
|
|
436
|
-
launchedBy: "
|
|
436
|
+
launchedBy: "treeseed_market"
|
|
437
437
|
}
|
|
438
438
|
};
|
|
439
439
|
}
|
|
@@ -567,7 +567,7 @@ function buildProcessingHostEnvironmentOverlay(input, scope) {
|
|
|
567
567
|
overlayValue(overlay, "TREESEED_WORKER_POOL_SCALER", overlay.TREESEED_WORKER_POOL_SCALER || "railway");
|
|
568
568
|
return overlay;
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function scaffoldLaunchSource(projectRoot, input) {
|
|
571
571
|
const repositoryName = slugify(input.repoName ?? input.projectSlug, "project");
|
|
572
572
|
const templateId = input.sourceKind === "template" ? slugify(input.sourceRef ?? "starter-basic", "starter-basic") : "starter-basic";
|
|
573
573
|
const templateCatalogEnv = { TREESEED_TEMPLATE_CATALOG_URL: currentTemplateCatalogUrl() };
|
|
@@ -585,7 +585,7 @@ function scaffoldKnowledgeCoopSource(projectRoot, input) {
|
|
|
585
585
|
if (!input.sourceRef) {
|
|
586
586
|
throw new Error("Knowledge pack launch requires sourceRef to point to a package manifest or directory.");
|
|
587
587
|
}
|
|
588
|
-
return
|
|
588
|
+
return importKnowledgePack(projectRoot, input.sourceRef);
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
591
|
return scaffoldTemplateProject(templateId, projectRoot, {
|
|
@@ -716,22 +716,22 @@ async function executeKnowledgeHubProviderLaunch(input, options = {}) {
|
|
|
716
716
|
description: input.summary ?? `Knowledge Hub for ${input.projectName}`,
|
|
717
717
|
visibility: input.repoVisibility ?? "private",
|
|
718
718
|
homepageUrl: resolveManagedWebUrl(repoName),
|
|
719
|
-
topics: ["
|
|
719
|
+
topics: ["treeseed", "knowledge-hub", "market"]
|
|
720
720
|
}, { env: githubEnv });
|
|
721
721
|
await appendPhase(phases, "repo_provision", "completed", `${input.existingRepository?.url ? "Connected" : "Created"} ${repository.slug}.`, reportPhase);
|
|
722
722
|
await appendPhase(phases, "content_bootstrap", "running", "Scaffolding the project and seeding initial content.", reportPhase);
|
|
723
|
-
await
|
|
723
|
+
await scaffoldLaunchSource(workingRoot, input);
|
|
724
724
|
ensureHostedProjectFiles(workingRoot);
|
|
725
725
|
const managedDefaults = applyManagedProjectDefaults(workingRoot, input);
|
|
726
|
-
const seed =
|
|
727
|
-
packageSourceRoot = mkdtempSync(join(tmpdir(), `
|
|
726
|
+
const seed = seedLaunchContent(workingRoot, input);
|
|
727
|
+
packageSourceRoot = mkdtempSync(join(tmpdir(), `market-package-${slugify(input.projectSlug, "project")}-`));
|
|
728
728
|
cpSync(workingRoot, packageSourceRoot, { recursive: true });
|
|
729
729
|
await appendPhase(phases, "content_bootstrap", "completed", "Scaffolded the repo and seeded Direct content.", reportPhase);
|
|
730
730
|
let contentRepository = null;
|
|
731
731
|
let contentRepositoryWorkingRoot = null;
|
|
732
732
|
if (input.contentRepository?.name) {
|
|
733
733
|
await appendPhase(phases, "content_repository", "running", "Creating content repository.", reportPhase);
|
|
734
|
-
contentRepositoryWorkingRoot = mkdtempSync(join(tmpdir(), `
|
|
734
|
+
contentRepositoryWorkingRoot = mkdtempSync(join(tmpdir(), `market-content-${slugify(input.projectSlug, "project")}-`));
|
|
735
735
|
prepareKnowledgeHubContentRepositoryRoot(workingRoot, contentRepositoryWorkingRoot, input);
|
|
736
736
|
const createdContentRepository = input.contentRepository.url ? {
|
|
737
737
|
slug: `${slugify(input.contentRepository.owner ?? repoOwner, "treeseed-ai")}/${slugify(input.contentRepository.name, `${repoName}-content`)}`,
|
|
@@ -745,7 +745,7 @@ async function executeKnowledgeHubProviderLaunch(input, options = {}) {
|
|
|
745
745
|
description: input.summary ?? `Content source for ${input.projectName}`,
|
|
746
746
|
visibility: input.contentRepository.visibility ?? input.repoVisibility ?? "private",
|
|
747
747
|
homepageUrl: resolveManagedWebUrl(repoName),
|
|
748
|
-
topics: ["
|
|
748
|
+
topics: ["treeseed", "knowledge-hub", "content"]
|
|
749
749
|
}, { env: githubEnv });
|
|
750
750
|
const contentInitResult = initializeGitHubRepositoryWorkingTree(contentRepositoryWorkingRoot, createdContentRepository, {
|
|
751
751
|
defaultBranch: input.contentRepository.defaultBranch ?? "main",
|
|
@@ -835,7 +835,7 @@ async function executeKnowledgeHubProviderLaunch(input, options = {}) {
|
|
|
835
835
|
{ slug: repository.slug, url: repository.url }
|
|
836
836
|
);
|
|
837
837
|
const packageRoot = packageSourceRoot ?? workingRoot;
|
|
838
|
-
const templatePackage =
|
|
838
|
+
const templatePackage = buildTemplateMarketPackage(packageRoot, {
|
|
839
839
|
projectSlug: input.projectSlug,
|
|
840
840
|
title: `${input.projectName} template`,
|
|
841
841
|
summary: input.summary ?? null,
|
|
@@ -848,7 +848,7 @@ async function executeKnowledgeHubProviderLaunch(input, options = {}) {
|
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
850
|
});
|
|
851
|
-
const knowledgePackPackage =
|
|
851
|
+
const knowledgePackPackage = buildKnowledgePackMarketPackage(packageRoot, {
|
|
852
852
|
projectSlug: input.projectSlug,
|
|
853
853
|
title: `${input.projectName} knowledge pack`,
|
|
854
854
|
summary: input.summary ?? null,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface MarketPackageManifest {
|
|
2
2
|
schemaVersion: 1;
|
|
3
3
|
kind: 'template' | 'knowledge_pack';
|
|
4
4
|
id: string;
|
|
@@ -24,36 +24,36 @@ export interface KnowledgeCoopPackageManifest {
|
|
|
24
24
|
publishMetadata: Record<string, unknown>;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
export interface
|
|
27
|
+
export interface MarketPackageBuildResult {
|
|
28
28
|
outputRoot: string;
|
|
29
29
|
payloadRoot: string;
|
|
30
30
|
manifestPath: string;
|
|
31
31
|
files: string[];
|
|
32
|
-
manifest:
|
|
32
|
+
manifest: MarketPackageManifest;
|
|
33
33
|
}
|
|
34
|
-
export interface
|
|
35
|
-
manifest:
|
|
34
|
+
export interface KnowledgePackImportResult {
|
|
35
|
+
manifest: MarketPackageManifest;
|
|
36
36
|
manifestPath: string;
|
|
37
37
|
payloadRoot: string;
|
|
38
38
|
importedPaths: string[];
|
|
39
39
|
}
|
|
40
|
-
export declare function
|
|
41
|
-
export declare function
|
|
40
|
+
export declare function resolveMarketPackageOutputRoot(projectRoot: string, kind: 'template' | 'knowledge_pack', slug: string): string;
|
|
41
|
+
export declare function buildTemplateMarketPackage(projectRoot: string, input?: {
|
|
42
42
|
id?: string;
|
|
43
43
|
title?: string;
|
|
44
44
|
summary?: string | null;
|
|
45
45
|
outputRoot?: string | null;
|
|
46
46
|
projectSlug?: string | null;
|
|
47
|
-
market?:
|
|
48
|
-
}):
|
|
49
|
-
export declare function
|
|
47
|
+
market?: MarketPackageManifest['market'];
|
|
48
|
+
}): MarketPackageBuildResult;
|
|
49
|
+
export declare function buildKnowledgePackMarketPackage(projectRoot: string, input?: {
|
|
50
50
|
id?: string;
|
|
51
51
|
title?: string;
|
|
52
52
|
summary?: string | null;
|
|
53
53
|
outputRoot?: string | null;
|
|
54
54
|
projectSlug?: string | null;
|
|
55
55
|
includePaths?: string[];
|
|
56
|
-
market?:
|
|
57
|
-
}):
|
|
58
|
-
export declare function
|
|
56
|
+
market?: MarketPackageManifest['market'];
|
|
57
|
+
}): MarketPackageBuildResult;
|
|
58
|
+
export declare function importKnowledgePack(targetRoot: string, sourcePath: string): KnowledgePackImportResult;
|
|
59
59
|
export declare function relativePackageFiles(outputRoot: string): string[];
|