@treeseed/sdk 0.8.19 → 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/d1-store.js +27 -3
- package/dist/db/node-sqlite.js +11 -2
- 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/model-registry.js +55 -24
- 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/d1-migration.js +32 -0
- package/dist/operations/services/deploy.js +3 -0
- 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 +69 -1
- package/dist/operations/services/project-platform.js +33 -13
- package/dist/operations/services/release-candidate.js +19 -3
- package/dist/operations/services/repository-save-orchestrator.js +10 -1
- 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 +34 -2
- package/dist/sdk-types.js +2 -1
- package/dist/stores/operational-store.d.ts +13 -0
- package/dist/stores/operational-store.js +50 -0
- 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
|
@@ -15,9 +15,13 @@ if (process.env.GITHUB_ACTIONS === 'true') {
|
|
|
15
15
|
npmArgs.push(...extraArgs);
|
|
16
16
|
const result = spawnSync('npm', npmArgs, {
|
|
17
17
|
cwd: packageRoot,
|
|
18
|
-
|
|
18
|
+
encoding: 'utf8',
|
|
19
19
|
env: process.env,
|
|
20
20
|
});
|
|
21
|
+
if (result.stdout)
|
|
22
|
+
process.stdout.write(result.stdout);
|
|
23
|
+
if (result.stderr)
|
|
24
|
+
process.stderr.write(result.stderr);
|
|
21
25
|
if (result.error) {
|
|
22
26
|
console.error(result.error.message);
|
|
23
27
|
process.exit(1);
|
|
@@ -56,15 +56,15 @@ function parseArgs(argv) {
|
|
|
56
56
|
return parsed;
|
|
57
57
|
}
|
|
58
58
|
function parseAction(value) {
|
|
59
|
-
if (value === 'deploy_web' || value === '
|
|
59
|
+
if (value === 'deploy_web' || value === 'publish_content' || value === 'monitor') {
|
|
60
60
|
return value;
|
|
61
61
|
}
|
|
62
|
-
throw new Error(`Unsupported workflow action "${value}". Expected deploy_web,
|
|
62
|
+
throw new Error(`Unsupported workflow action "${value}". Expected deploy_web, publish_content, or monitor.`);
|
|
63
63
|
}
|
|
64
64
|
async function main() {
|
|
65
65
|
const options = parseArgs(process.argv.slice(2));
|
|
66
66
|
process.env.TREESEED_WORKFLOW_ACTION = options.action;
|
|
67
|
-
process.env.TREESEED_WORKFLOW_PLANE ||=
|
|
67
|
+
process.env.TREESEED_WORKFLOW_PLANE ||= 'web';
|
|
68
68
|
const scope = resolveScope(options.environment);
|
|
69
69
|
const result = await runProjectPlatformAction(options.action, {
|
|
70
70
|
tenantRoot,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
deployTargetLabel,
|
|
7
7
|
loadDeployState,
|
|
8
8
|
} from '../dist/scripts/deploy-lib.js';
|
|
9
|
-
import {
|
|
9
|
+
import { renderDeployWebWorkflow } from '../dist/operations/services/github-automation.js';
|
|
10
10
|
import { incrementVersion } from '../dist/scripts/workspace-save-lib.js';
|
|
11
11
|
import { makeTenantRoot } from './cli-test-fixtures.js';
|
|
12
12
|
|
|
@@ -25,15 +25,12 @@ test('branch preview state derives branch-specific worker names', () => {
|
|
|
25
25
|
assert.equal(state.previewEnabled, true);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
test('deploy
|
|
28
|
+
test('deploy workflow exposes final web actions only', () => {
|
|
29
29
|
const webWorkflow = renderDeployWebWorkflow({ workingDirectory: '.' });
|
|
30
|
-
const processingWorkflow = renderDeployProcessingWorkflow({ workingDirectory: '.' });
|
|
31
30
|
assert.match(webWorkflow, /default: deploy_web/);
|
|
32
31
|
assert.match(webWorkflow, /- publish_content/);
|
|
33
32
|
assert.doesNotMatch(webWorkflow, /RAILWAY_API_TOKEN/);
|
|
34
|
-
assert.
|
|
35
|
-
assert.match(processingWorkflow, /RAILWAY_API_TOKEN/);
|
|
36
|
-
assert.match(processingWorkflow, /TREESEED_CAPACITY_PROVIDER_ID/);
|
|
33
|
+
assert.doesNotMatch(webWorkflow, /deploy_processing/);
|
|
37
34
|
});
|
|
38
35
|
|
|
39
36
|
test('version bump utility supports major, minor, and patch', () => {
|
package/dist/sdk-types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TreeseedFieldAliasBinding } from './field-aliases.ts';
|
|
2
|
-
export declare const SDK_MODEL_NAMES: readonly ["page", "note", "question", "proposal", "decision", "book", "knowledge", "objective", "person", "subscription", "message", "agent", "agent_run", "agent_cursor", "content_lease", "work_day", "task", "task_event", "task_output", "graph_run", "report", "approval_request", "team_inbox_item", "workday_manager_lease", "worker_runner"];
|
|
2
|
+
export declare const SDK_MODEL_NAMES: readonly ["page", "note", "question", "proposal", "decision", "book", "knowledge", "objective", "person", "subscription", "message", "agent", "agent_run", "agent_cursor", "content_lease", "work_day", "task", "task_event", "task_output", "graph_run", "report", "approval_request", "team_inbox_item", "workday_manager_lease", "worker_runner", "repository_claim"];
|
|
3
3
|
export declare const SDK_OPERATIONS: readonly ["get", "read", "search", "follow", "pick", "create", "update"];
|
|
4
4
|
export declare const SDK_STORAGE_BACKENDS: readonly ["content", "d1"];
|
|
5
5
|
export declare const SDK_PICK_STRATEGIES: readonly ["latest", "highest_priority", "oldest"];
|
|
@@ -400,7 +400,7 @@ export interface TaskCreditLedgerEntry {
|
|
|
400
400
|
createdAt: string;
|
|
401
401
|
}
|
|
402
402
|
export type CapacityProviderKind = 'treeseed_managed' | 'team_owned' | 'external' | 'hybrid';
|
|
403
|
-
export type CapacityProviderStatus = 'pending' | 'credential_required' | 'registering' | 'active' | 'degraded' | 'draining' | 'paused' | 'configuration_required' | 'disabled' | 'failed';
|
|
403
|
+
export type CapacityProviderStatus = 'pending' | 'online' | 'offline' | 'credential_required' | 'registering' | 'active' | 'degraded' | 'draining' | 'paused' | 'configuration_required' | 'rotation_required' | 'disabled' | 'failed';
|
|
404
404
|
export type CapacityProviderBillingScope = 'treeseed' | 'team' | 'external';
|
|
405
405
|
export type CapacityBusinessModel = 'subscription_quota' | 'token_metered' | 'hybrid_usage_based' | 'infrastructure_runtime' | 'custom';
|
|
406
406
|
export type CapacityLaneUnit = 'treeseed_credit' | 'quota_minute' | 'token_usd' | 'github_ai_credit' | 'worker_second' | 'request' | 'custom';
|
|
@@ -644,6 +644,14 @@ export interface CapacityProvider {
|
|
|
644
644
|
maxConcurrentWorkdays: number;
|
|
645
645
|
maxConcurrentWorkers: number;
|
|
646
646
|
capacityModel: Record<string, unknown>;
|
|
647
|
+
connectionState?: string | null;
|
|
648
|
+
lastSeenAt?: string | null;
|
|
649
|
+
activeKeyPrefix?: string | null;
|
|
650
|
+
lastRotatedAt?: string | null;
|
|
651
|
+
rotationRequired?: boolean;
|
|
652
|
+
capabilities?: unknown[];
|
|
653
|
+
budgets?: Record<string, unknown>;
|
|
654
|
+
deployment?: Record<string, unknown> | null;
|
|
647
655
|
metadata?: Record<string, unknown>;
|
|
648
656
|
createdAt: string;
|
|
649
657
|
updatedAt: string;
|
|
@@ -1854,6 +1862,30 @@ export interface UpsertCapacityProviderRequest {
|
|
|
1854
1862
|
capacityModel?: Record<string, unknown> | null;
|
|
1855
1863
|
metadata?: Record<string, unknown> | null;
|
|
1856
1864
|
}
|
|
1865
|
+
export interface CreateCapacityProviderRequest {
|
|
1866
|
+
name: string;
|
|
1867
|
+
launchMode: 'self_hosted' | 'managed_market_host' | 'connected_host';
|
|
1868
|
+
}
|
|
1869
|
+
export interface CreateCapacityProviderResponse {
|
|
1870
|
+
ok: true;
|
|
1871
|
+
provider: CapacityProvider;
|
|
1872
|
+
apiKey: {
|
|
1873
|
+
plaintext: string;
|
|
1874
|
+
prefix: string;
|
|
1875
|
+
};
|
|
1876
|
+
selfHosting: Record<string, unknown>;
|
|
1877
|
+
}
|
|
1878
|
+
export interface RenameCapacityProviderRequest {
|
|
1879
|
+
name: string;
|
|
1880
|
+
}
|
|
1881
|
+
export interface CapacityProviderRotateKeyResponse {
|
|
1882
|
+
ok: true;
|
|
1883
|
+
apiKey: {
|
|
1884
|
+
plaintext: string;
|
|
1885
|
+
prefix: string;
|
|
1886
|
+
};
|
|
1887
|
+
requiresRestart: boolean;
|
|
1888
|
+
}
|
|
1857
1889
|
export interface UpsertCapacityProviderHostRequest {
|
|
1858
1890
|
id?: string;
|
|
1859
1891
|
hostId: string;
|
package/dist/sdk-types.js
CHANGED
|
@@ -23,7 +23,8 @@ const SDK_MODEL_NAMES = [
|
|
|
23
23
|
"approval_request",
|
|
24
24
|
"team_inbox_item",
|
|
25
25
|
"workday_manager_lease",
|
|
26
|
-
"worker_runner"
|
|
26
|
+
"worker_runner",
|
|
27
|
+
"repository_claim"
|
|
27
28
|
];
|
|
28
29
|
const SDK_OPERATIONS = ["get", "read", "search", "follow", "pick", "create", "update"];
|
|
29
30
|
const SDK_STORAGE_BACKENDS = ["content", "d1"];
|
|
@@ -19,7 +19,20 @@ export declare class OperationalStore extends SqliteStoreBase {
|
|
|
19
19
|
failTask(request: SdkFailTaskRequest): Promise<SdkTaskEntity | null>;
|
|
20
20
|
appendTaskEvent(request: SdkAppendTaskEventRequest): Promise<SdkTaskEventEntity | null>;
|
|
21
21
|
listTaskEvents(taskId: string): Promise<SdkTaskEventEntity[]>;
|
|
22
|
+
getTaskEvent(id: string): Promise<SdkTaskEventEntity | null>;
|
|
23
|
+
searchTaskEvents(request?: {
|
|
24
|
+
id?: string | string[];
|
|
25
|
+
taskId?: string | string[];
|
|
26
|
+
kind?: string | string[];
|
|
27
|
+
limit?: number;
|
|
28
|
+
}): Promise<SdkTaskEventEntity[]>;
|
|
22
29
|
listTaskOutputs(taskId: string): Promise<SdkTaskOutputEntity[]>;
|
|
30
|
+
getTaskOutput(id: string): Promise<SdkTaskOutputEntity | null>;
|
|
31
|
+
searchTaskOutputs(request?: {
|
|
32
|
+
id?: string | string[];
|
|
33
|
+
taskId?: string | string[];
|
|
34
|
+
limit?: number;
|
|
35
|
+
}): Promise<SdkTaskOutputEntity[]>;
|
|
23
36
|
createGraphRun(input: Omit<SdkGraphRunEntity, 'createdAt'> & {
|
|
24
37
|
createdAt?: string;
|
|
25
38
|
}): Promise<SdkGraphRunEntity | null>;
|
|
@@ -530,12 +530,62 @@ class OperationalStore extends SqliteStoreBase {
|
|
|
530
530
|
);
|
|
531
531
|
return rows.map(taskEventFromRow);
|
|
532
532
|
}
|
|
533
|
+
async getTaskEvent(id) {
|
|
534
|
+
const row = await this.selectFirst(`SELECT * FROM task_events WHERE id = ${toSqlValue(id)} LIMIT 1`);
|
|
535
|
+
return row ? taskEventFromRow(row) : null;
|
|
536
|
+
}
|
|
537
|
+
async searchTaskEvents(request = {}) {
|
|
538
|
+
const clauses = [];
|
|
539
|
+
if (request.id) {
|
|
540
|
+
const ids = Array.isArray(request.id) ? request.id : [request.id];
|
|
541
|
+
clauses.push(`id IN (${ids.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
542
|
+
}
|
|
543
|
+
if (request.taskId) {
|
|
544
|
+
const taskIds = Array.isArray(request.taskId) ? request.taskId : [request.taskId];
|
|
545
|
+
clauses.push(`task_id IN (${taskIds.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
546
|
+
}
|
|
547
|
+
if (request.kind) {
|
|
548
|
+
const kinds = Array.isArray(request.kind) ? request.kind : [request.kind];
|
|
549
|
+
clauses.push(`kind IN (${kinds.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
550
|
+
}
|
|
551
|
+
const sql = [
|
|
552
|
+
"SELECT * FROM task_events",
|
|
553
|
+
clauses.length ? `WHERE ${clauses.join(" AND ")}` : "",
|
|
554
|
+
"ORDER BY created_at DESC, seq DESC",
|
|
555
|
+
`LIMIT ${request.limit ?? 50}`
|
|
556
|
+
].filter(Boolean).join(" ");
|
|
557
|
+
const rows = await this.selectAll(sql);
|
|
558
|
+
return rows.map(taskEventFromRow);
|
|
559
|
+
}
|
|
533
560
|
async listTaskOutputs(taskId) {
|
|
534
561
|
const rows = await this.selectAll(
|
|
535
562
|
`SELECT * FROM task_outputs WHERE task_id = ${toSqlValue(taskId)} ORDER BY created_at ASC`
|
|
536
563
|
);
|
|
537
564
|
return rows.map(taskOutputFromRow);
|
|
538
565
|
}
|
|
566
|
+
async getTaskOutput(id) {
|
|
567
|
+
const row = await this.selectFirst(`SELECT * FROM task_outputs WHERE id = ${toSqlValue(id)} LIMIT 1`);
|
|
568
|
+
return row ? taskOutputFromRow(row) : null;
|
|
569
|
+
}
|
|
570
|
+
async searchTaskOutputs(request = {}) {
|
|
571
|
+
const clauses = [];
|
|
572
|
+
if (request.id) {
|
|
573
|
+
const ids = Array.isArray(request.id) ? request.id : [request.id];
|
|
574
|
+
clauses.push(`id IN (${ids.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
575
|
+
}
|
|
576
|
+
if (request.taskId) {
|
|
577
|
+
const taskIds = Array.isArray(request.taskId) ? request.taskId : [request.taskId];
|
|
578
|
+
clauses.push(`task_id IN (${taskIds.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
579
|
+
}
|
|
580
|
+
const sql = [
|
|
581
|
+
"SELECT * FROM task_outputs",
|
|
582
|
+
clauses.length ? `WHERE ${clauses.join(" AND ")}` : "",
|
|
583
|
+
"ORDER BY created_at DESC",
|
|
584
|
+
`LIMIT ${request.limit ?? 50}`
|
|
585
|
+
].filter(Boolean).join(" ");
|
|
586
|
+
const rows = await this.selectAll(sql);
|
|
587
|
+
return rows.map(taskOutputFromRow);
|
|
588
|
+
}
|
|
539
589
|
async createGraphRun(input) {
|
|
540
590
|
const timestamp = input.createdAt ?? nowIso();
|
|
541
591
|
await this.execute(
|
|
@@ -13,9 +13,7 @@
|
|
|
13
13
|
"config": "treeseed config",
|
|
14
14
|
"preflight": "treeseed preflight",
|
|
15
15
|
"dev": "treeseed dev",
|
|
16
|
-
"
|
|
17
|
-
"dev:api": "treeseed dev:api",
|
|
18
|
-
"dev:watch": "treeseed dev --watch",
|
|
16
|
+
"capacity": "treeseed capacity",
|
|
19
17
|
"check": "treeseed check",
|
|
20
18
|
"build:web": "treeseed build",
|
|
21
19
|
"build": "npm run build:web",
|
|
@@ -26,7 +24,6 @@
|
|
|
26
24
|
},
|
|
27
25
|
"dependencies": {
|
|
28
26
|
"@treeseed/cli": "__CLI_VERSION__",
|
|
29
|
-
"@treeseed/agent": "__AGENT_VERSION__",
|
|
30
27
|
"@treeseed/core": "__CORE_VERSION__",
|
|
31
28
|
"@treeseed/sdk": "__SDK_VERSION__",
|
|
32
29
|
"yaml": "^2.8.1"
|
|
@@ -46,27 +46,11 @@ services:
|
|
|
46
46
|
railway:
|
|
47
47
|
serviceName: __SITE_SLUG__-api
|
|
48
48
|
buildCommand: npm run build:api
|
|
49
|
-
startCommand:
|
|
49
|
+
startCommand: node ./src/api/server.js
|
|
50
50
|
healthcheckTimeoutSeconds: 120
|
|
51
51
|
environments:
|
|
52
52
|
local:
|
|
53
53
|
baseUrl: http://127.0.0.1:3000
|
|
54
|
-
workdayManager:
|
|
55
|
-
enabled: true
|
|
56
|
-
provider: railway
|
|
57
|
-
railway:
|
|
58
|
-
serviceName: __SITE_SLUG__-workday-manager
|
|
59
|
-
rootDir: .
|
|
60
|
-
buildCommand: npm run build:api
|
|
61
|
-
startCommand: npm run build:api && node ./packages/agent/dist/services/workday-manager.js
|
|
62
|
-
schedule: '0 9 * * 1-5'
|
|
63
|
-
workerRunner:
|
|
64
|
-
enabled: true
|
|
65
|
-
provider: railway
|
|
66
|
-
railway:
|
|
67
|
-
rootDir: .
|
|
68
|
-
buildCommand: npm run build:api
|
|
69
|
-
startCommand: npm run build:api && node ./packages/agent/dist/services/worker.js
|
|
70
54
|
plugins:
|
|
71
55
|
- package: '@treeseed/core/plugin-default'
|
|
72
56
|
providers:
|
|
@@ -108,6 +108,7 @@ import {
|
|
|
108
108
|
collectTreeseedDevTagCleanupPlan,
|
|
109
109
|
collectInternalDevReferenceIssues,
|
|
110
110
|
devTagFromDependencySpec,
|
|
111
|
+
normalizeGitRemoteForManifest,
|
|
111
112
|
rewriteProjectInternalDependenciesToStableVersions
|
|
112
113
|
} from "../operations/services/package-reference-policy.js";
|
|
113
114
|
import {
|
|
@@ -446,7 +447,7 @@ function recordHostedDeploymentStatesFromRootGates(root, rootRelease, workflowGa
|
|
|
446
447
|
{ scope: "staging", branch: STAGING_BRANCH, commit: releaseRecord.stagingCommit },
|
|
447
448
|
{ scope: "prod", branch: releaseTag ?? PRODUCTION_BRANCH, commit: releaseRecord.releasedCommit }
|
|
448
449
|
]) {
|
|
449
|
-
const gate = gates.find((candidate) =>
|
|
450
|
+
const gate = gates.find((candidate) => candidate.workflow === "deploy-web.yml" && candidate.branch === target.branch && candidate.status === "completed" && candidate.conclusion === "success");
|
|
450
451
|
const timestamp = typeof gate?.updatedAt === "string" && gate.updatedAt.trim() ? gate.updatedAt : null;
|
|
451
452
|
if (!gate || !timestamp) {
|
|
452
453
|
continue;
|
|
@@ -705,11 +706,13 @@ function writeJsonFile(path, value) {
|
|
|
705
706
|
`, "utf8");
|
|
706
707
|
}
|
|
707
708
|
function applyStableWorkspaceVersionChanges(root, versions) {
|
|
708
|
-
|
|
709
|
-
|
|
709
|
+
const stableGitReferences = stablePackageGitReferences(root, versions);
|
|
710
|
+
for (const target of [{ name: "@treeseed/market", dir: root }, ...workspacePackages(root).map((pkg) => ({ name: pkg.name, dir: pkg.dir }))]) {
|
|
711
|
+
const packageJsonPath = resolve(target.dir, "package.json");
|
|
712
|
+
if (!existsSync(packageJsonPath)) continue;
|
|
710
713
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
711
714
|
let changed = false;
|
|
712
|
-
const plannedVersion = versions.get(
|
|
715
|
+
const plannedVersion = versions.get(target.name);
|
|
713
716
|
if (plannedVersion && packageJson.version !== plannedVersion) {
|
|
714
717
|
packageJson.version = plannedVersion;
|
|
715
718
|
changed = true;
|
|
@@ -719,8 +722,9 @@ function applyStableWorkspaceVersionChanges(root, versions) {
|
|
|
719
722
|
if (!values || typeof values !== "object" || Array.isArray(values)) continue;
|
|
720
723
|
for (const [dependencyName, version] of versions.entries()) {
|
|
721
724
|
if (!(dependencyName in values)) continue;
|
|
722
|
-
|
|
723
|
-
values[dependencyName]
|
|
725
|
+
const dependencySpec = stableGitReferences.get(dependencyName) ?? version;
|
|
726
|
+
if (String(values[dependencyName]) === dependencySpec) continue;
|
|
727
|
+
values[dependencyName] = dependencySpec;
|
|
724
728
|
changed = true;
|
|
725
729
|
}
|
|
726
730
|
}
|
|
@@ -729,6 +733,20 @@ function applyStableWorkspaceVersionChanges(root, versions) {
|
|
|
729
733
|
}
|
|
730
734
|
}
|
|
731
735
|
}
|
|
736
|
+
function stablePackageGitReferences(root, versions) {
|
|
737
|
+
return new Map(workspacePackages(root).map((pkg) => {
|
|
738
|
+
const version = versions.get(pkg.name);
|
|
739
|
+
if (!version) return null;
|
|
740
|
+
let remote = null;
|
|
741
|
+
try {
|
|
742
|
+
remote = originRemoteUrl(pkg.dir);
|
|
743
|
+
} catch {
|
|
744
|
+
remote = null;
|
|
745
|
+
}
|
|
746
|
+
const manifestRemote = normalizeGitRemoteForManifest(remote ?? "", "preserve-origin");
|
|
747
|
+
return manifestRemote ? [pkg.name, `${manifestRemote}#${version}`] : null;
|
|
748
|
+
}).filter((entry) => Boolean(entry)));
|
|
749
|
+
}
|
|
732
750
|
function gitObjectCommit(repoDir, ref) {
|
|
733
751
|
try {
|
|
734
752
|
return run("git", ["rev-list", "-n", "1", ref], { cwd: repoDir, capture: true }).trim() || null;
|
|
@@ -843,7 +861,7 @@ function defaultCiWorkflows(kind, branch) {
|
|
|
843
861
|
return ["verify.yml"];
|
|
844
862
|
}
|
|
845
863
|
if (branch === STAGING_BRANCH || branch === PRODUCTION_BRANCH) {
|
|
846
|
-
return ["deploy-web.yml"
|
|
864
|
+
return ["deploy-web.yml"];
|
|
847
865
|
}
|
|
848
866
|
return ["verify.yml"];
|
|
849
867
|
}
|
|
@@ -1514,7 +1532,7 @@ function validateStagingWorkflowContracts(root) {
|
|
|
1514
1532
|
return;
|
|
1515
1533
|
}
|
|
1516
1534
|
const missing = [];
|
|
1517
|
-
for (const fileName of ["verify.yml", "deploy-web.yml"
|
|
1535
|
+
for (const fileName of ["verify.yml", "deploy-web.yml"]) {
|
|
1518
1536
|
if (!existsSync(resolve(root, ".github", "workflows", fileName))) {
|
|
1519
1537
|
missing.push(fileName);
|
|
1520
1538
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"extract-zip": "2.0.1",
|
|
64
64
|
"github-slugger": "^2.0.0",
|
|
65
65
|
"drizzle-orm": "^0.45.2",
|
|
66
|
+
"hono": "^4.8.2",
|
|
66
67
|
"ink": "^7.0.0",
|
|
67
68
|
"libsodium-wrappers": "^0.7.15",
|
|
68
69
|
"mdast-util-to-string": "^4.0.0",
|
|
@@ -100,6 +101,14 @@
|
|
|
100
101
|
"types": "./dist/operations/agent-tools.d.ts",
|
|
101
102
|
"default": "./dist/operations/agent-tools.js"
|
|
102
103
|
},
|
|
104
|
+
"./api": {
|
|
105
|
+
"types": "./dist/api/index.d.ts",
|
|
106
|
+
"default": "./dist/api/index.js"
|
|
107
|
+
},
|
|
108
|
+
"./api/auth/d1-provider": {
|
|
109
|
+
"types": "./dist/api/auth/d1-provider.d.ts",
|
|
110
|
+
"default": "./dist/api/auth/d1-provider.js"
|
|
111
|
+
},
|
|
103
112
|
"./workflow": {
|
|
104
113
|
"types": "./dist/workflow.d.ts",
|
|
105
114
|
"default": "./dist/workflow.js"
|
|
@@ -229,6 +238,10 @@
|
|
|
229
238
|
"types": "./dist/capacity.d.ts",
|
|
230
239
|
"default": "./dist/capacity.js"
|
|
231
240
|
},
|
|
241
|
+
"./capacity-provider": {
|
|
242
|
+
"types": "./dist/capacity-provider.d.ts",
|
|
243
|
+
"default": "./dist/capacity-provider.js"
|
|
244
|
+
},
|
|
232
245
|
"./types": {
|
|
233
246
|
"types": "./dist/sdk-types.d.ts",
|
|
234
247
|
"default": "./dist/sdk-types.js"
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
name: Treeseed Processing Deploy
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_call:
|
|
5
|
-
inputs:
|
|
6
|
-
environment:
|
|
7
|
-
required: true
|
|
8
|
-
type: string
|
|
9
|
-
action_kind:
|
|
10
|
-
required: true
|
|
11
|
-
type: string
|
|
12
|
-
project_id:
|
|
13
|
-
required: false
|
|
14
|
-
type: string
|
|
15
|
-
preview_id:
|
|
16
|
-
required: false
|
|
17
|
-
type: string
|
|
18
|
-
workflow_dispatch:
|
|
19
|
-
inputs:
|
|
20
|
-
environment:
|
|
21
|
-
required: true
|
|
22
|
-
default: staging
|
|
23
|
-
type: choice
|
|
24
|
-
options:
|
|
25
|
-
- staging
|
|
26
|
-
- prod
|
|
27
|
-
action_kind:
|
|
28
|
-
required: true
|
|
29
|
-
default: deploy_processing
|
|
30
|
-
type: choice
|
|
31
|
-
options:
|
|
32
|
-
- deploy_processing
|
|
33
|
-
- monitor
|
|
34
|
-
project_id:
|
|
35
|
-
required: false
|
|
36
|
-
type: string
|
|
37
|
-
preview_id:
|
|
38
|
-
required: false
|
|
39
|
-
type: string
|
|
40
|
-
|
|
41
|
-
jobs:
|
|
42
|
-
__WORKING_DIRECTORY_BLOCK__ processing:
|
|
43
|
-
runs-on: ubuntu-latest
|
|
44
|
-
permissions:
|
|
45
|
-
contents: read
|
|
46
|
-
environment: ${{ inputs.environment == 'prod' && 'production' || 'staging' }}
|
|
47
|
-
env:
|
|
48
|
-
TREESEED_BOOTSTRAP_MODE: auto
|
|
49
|
-
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
50
|
-
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
|
|
51
|
-
RAILWAY_API_TOKEN: ${{ secrets.RAILWAY_API_TOKEN }}
|
|
52
|
-
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
|
|
53
|
-
TREESEED_RAILWAY_WORKSPACE: ${{ vars.TREESEED_RAILWAY_WORKSPACE }}
|
|
54
|
-
TREESEED_API_BASE_URL: ${{ vars.TREESEED_API_BASE_URL }}
|
|
55
|
-
TREESEED_API_AUTH_SECRET: ${{ secrets.TREESEED_API_AUTH_SECRET }}
|
|
56
|
-
TREESEED_API_D1_DATABASE_ID: ${{ vars.TREESEED_API_D1_DATABASE_ID }}
|
|
57
|
-
TREESEED_API_WEB_SERVICE_ID: ${{ vars.TREESEED_API_WEB_SERVICE_ID }}
|
|
58
|
-
TREESEED_API_WEB_SERVICE_SECRET: ${{ secrets.TREESEED_API_WEB_SERVICE_SECRET }}
|
|
59
|
-
TREESEED_API_WEB_ASSERTION_SECRET: ${{ secrets.TREESEED_API_WEB_ASSERTION_SECRET }}
|
|
60
|
-
TREESEED_API_BOOTSTRAP_ADMIN_ALLOWLIST: ${{ vars.TREESEED_API_BOOTSTRAP_ADMIN_ALLOWLIST }}
|
|
61
|
-
TREESEED_API_AUTH_APPROVAL_BASE_URL: ${{ vars.TREESEED_API_AUTH_APPROVAL_BASE_URL || vars.TREESEED_SITE_URL }}
|
|
62
|
-
TREESEED_SITE_URL: ${{ vars.TREESEED_SITE_URL }}
|
|
63
|
-
BETTER_AUTH_URL: ${{ vars.BETTER_AUTH_URL || vars.TREESEED_SITE_URL }}
|
|
64
|
-
TREESEED_PROJECT_ID: ${{ inputs.project_id || vars.TREESEED_PROJECT_ID }}
|
|
65
|
-
TREESEED_PROJECT_RUNNER_TOKEN: ${{ secrets.TREESEED_PROJECT_RUNNER_TOKEN }}
|
|
66
|
-
TREESEED_WORKER_POOL_SCALER: ${{ vars.TREESEED_WORKER_POOL_SCALER }}
|
|
67
|
-
TREESEED_AGENT_POOL_MIN_WORKERS: ${{ vars.TREESEED_AGENT_POOL_MIN_WORKERS }}
|
|
68
|
-
TREESEED_AGENT_POOL_MAX_WORKERS: ${{ vars.TREESEED_AGENT_POOL_MAX_WORKERS }}
|
|
69
|
-
TREESEED_AGENT_POOL_TARGET_QUEUE_DEPTH: ${{ vars.TREESEED_AGENT_POOL_TARGET_QUEUE_DEPTH }}
|
|
70
|
-
TREESEED_AGENT_POOL_COOLDOWN_SECONDS: ${{ vars.TREESEED_AGENT_POOL_COOLDOWN_SECONDS }}
|
|
71
|
-
TREESEED_WORKDAY_TIMEZONE: ${{ vars.TREESEED_WORKDAY_TIMEZONE }}
|
|
72
|
-
TREESEED_WORKDAY_WINDOWS_JSON: ${{ vars.TREESEED_WORKDAY_WINDOWS_JSON }}
|
|
73
|
-
TREESEED_WORKDAY_TASK_CREDIT_BUDGET: ${{ vars.TREESEED_WORKDAY_TASK_CREDIT_BUDGET }}
|
|
74
|
-
TREESEED_MANAGER_MAX_QUEUED_TASKS: ${{ vars.TREESEED_MANAGER_MAX_QUEUED_TASKS }}
|
|
75
|
-
TREESEED_MANAGER_MAX_QUEUED_CREDITS: ${{ vars.TREESEED_MANAGER_MAX_QUEUED_CREDITS }}
|
|
76
|
-
TREESEED_MANAGER_PRIORITY_MODELS: ${{ vars.TREESEED_MANAGER_PRIORITY_MODELS }}
|
|
77
|
-
TREESEED_TASK_CREDIT_WEIGHTS_JSON: ${{ vars.TREESEED_TASK_CREDIT_WEIGHTS_JSON }}
|
|
78
|
-
TREESEED_RAILWAY_PROJECT_ID: ${{ vars.TREESEED_RAILWAY_PROJECT_ID }}
|
|
79
|
-
TREESEED_RAILWAY_ENVIRONMENT_ID: ${{ vars.TREESEED_RAILWAY_ENVIRONMENT_ID }}
|
|
80
|
-
TREESEED_RAILWAY_WORKER_SERVICE_ID: ${{ vars.TREESEED_RAILWAY_WORKER_SERVICE_ID }}
|
|
81
|
-
TREESEED_CAPACITY_PROVIDER_ID: ${{ vars.TREESEED_CAPACITY_PROVIDER_ID }}
|
|
82
|
-
TREESEED_CAPACITY_PROVIDER_TEAM_ID: ${{ vars.TREESEED_CAPACITY_PROVIDER_TEAM_ID }}
|
|
83
|
-
TREESEED_CAPACITY_PROVIDER_SERVICE_BASE_URL: ${{ vars.TREESEED_CAPACITY_PROVIDER_SERVICE_BASE_URL }}
|
|
84
|
-
TREESEED_PROCESSING_DRAIN: ${{ vars.TREESEED_PROCESSING_DRAIN }}
|
|
85
|
-
TREESEED_WORKFLOW_ACTION: ${{ inputs.action_kind }}
|
|
86
|
-
TREESEED_WORKFLOW_ENVIRONMENT: ${{ inputs.environment }}
|
|
87
|
-
TREESEED_WORKFLOW_PLANE: processing
|
|
88
|
-
TREESEED_WORKFLOW_PROJECT: ${{ inputs.project_id || vars.TREESEED_PROJECT_ID }}
|
|
89
|
-
TREESEED_WORKFLOW_PREVIEW_ID: ${{ inputs.preview_id }}
|
|
90
|
-
steps:
|
|
91
|
-
- uses: actions/checkout@v4
|
|
92
|
-
with:
|
|
93
|
-
submodules: recursive
|
|
94
|
-
|
|
95
|
-
- uses: actions/setup-node@v4
|
|
96
|
-
with:
|
|
97
|
-
node-version: 22
|
|
98
|
-
cache: npm
|
|
99
|
-
cache-dependency-path: __CACHE_DEPENDENCY_PATH__
|
|
100
|
-
|
|
101
|
-
- name: Install dependencies
|
|
102
|
-
shell: bash
|
|
103
|
-
run: |
|
|
104
|
-
set -euo pipefail
|
|
105
|
-
node -e "const fs = require('fs'); for (const file of ['packages/sdk/package.json', 'packages/agent/package.json', 'packages/core/package.json', 'packages/cli/package.json']) { if (!fs.existsSync(file)) continue; const p = JSON.parse(fs.readFileSync(file, 'utf8')); if (p.scripts) delete p.scripts.prepare; fs.writeFileSync(file, JSON.stringify(p, null, '\t') + '\n'); }"
|
|
106
|
-
npm ci --ignore-scripts
|
|
107
|
-
|
|
108
|
-
- name: Build package artifacts
|
|
109
|
-
shell: bash
|
|
110
|
-
run: |
|
|
111
|
-
set -euo pipefail
|
|
112
|
-
for dir in packages/sdk packages/agent packages/core packages/cli; do
|
|
113
|
-
if test -f "${dir}/package.json"; then npm --prefix "${dir}" run build:dist; fi
|
|
114
|
-
done
|
|
115
|
-
|
|
116
|
-
- name: Run processing workflow action
|
|
117
|
-
shell: bash
|
|
118
|
-
run: |
|
|
119
|
-
set -euo pipefail
|
|
120
|
-
EXTRA_ARGS=()
|
|
121
|
-
if [[ -n "${TREESEED_WORKFLOW_PROJECT:-}" ]]; then EXTRA_ARGS+=(--project-id "${TREESEED_WORKFLOW_PROJECT}"); fi
|
|
122
|
-
if [[ -n "${TREESEED_WORKFLOW_PREVIEW_ID:-}" ]]; then EXTRA_ARGS+=(--preview-id "${TREESEED_WORKFLOW_PREVIEW_ID}"); fi
|
|
123
|
-
node ./packages/sdk/scripts/run-ts.mjs ./packages/sdk/scripts/tenant-workflow-action.ts --action "${TREESEED_WORKFLOW_ACTION}" --environment "${TREESEED_WORKFLOW_ENVIRONMENT}" "${EXTRA_ARGS[@]}"
|