@treeseed/core 0.8.3 → 0.8.4

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.
Files changed (133) hide show
  1. package/README.md +7 -11
  2. package/dist/dev-watch.js +1 -1
  3. package/dist/dev.d.ts +2 -4
  4. package/dist/dev.js +4 -124
  5. package/dist/env.yaml +23 -175
  6. package/dist/index.d.ts +0 -4
  7. package/dist/index.js +0 -6
  8. package/dist/scripts/build-dist.js +3 -3
  9. package/dist/scripts/dev-platform.js +1 -7
  10. package/dist/scripts/run-fixture-astro-command.js +25 -51
  11. package/dist/scripts/test-smoke.js +50 -7
  12. package/package.json +5 -78
  13. package/templates/github/deploy-web.workflow.yml +106 -0
  14. package/templates/github/hosted-project.workflow.yml +4 -4
  15. package/dist/agent-runtime.d.ts +0 -17
  16. package/dist/agent-runtime.js +0 -117
  17. package/dist/agent.d.ts +0 -11
  18. package/dist/agent.js +0 -25
  19. package/dist/agents/adapters/execution.d.ts +0 -41
  20. package/dist/agents/adapters/execution.js +0 -73
  21. package/dist/agents/adapters/mutations.d.ts +0 -22
  22. package/dist/agents/adapters/mutations.js +0 -30
  23. package/dist/agents/adapters/notification.d.ts +0 -26
  24. package/dist/agents/adapters/notification.js +0 -46
  25. package/dist/agents/adapters/repository.d.ts +0 -23
  26. package/dist/agents/adapters/repository.js +0 -61
  27. package/dist/agents/adapters/research.d.ts +0 -26
  28. package/dist/agents/adapters/research.js +0 -59
  29. package/dist/agents/adapters/verification.d.ts +0 -36
  30. package/dist/agents/adapters/verification.js +0 -62
  31. package/dist/agents/cli-tools.d.ts +0 -1
  32. package/dist/agents/cli-tools.js +0 -5
  33. package/dist/agents/cli.d.ts +0 -15
  34. package/dist/agents/cli.js +0 -109
  35. package/dist/agents/contracts/messages.d.ts +0 -88
  36. package/dist/agents/contracts/messages.js +0 -138
  37. package/dist/agents/contracts/run.d.ts +0 -21
  38. package/dist/agents/contracts/run.js +0 -0
  39. package/dist/agents/index.d.ts +0 -1
  40. package/dist/agents/index.js +0 -5
  41. package/dist/agents/kernel/agent-kernel.d.ts +0 -51
  42. package/dist/agents/kernel/agent-kernel.js +0 -292
  43. package/dist/agents/kernel/trigger-resolver.d.ts +0 -19
  44. package/dist/agents/kernel/trigger-resolver.js +0 -157
  45. package/dist/agents/registry-helper.d.ts +0 -4
  46. package/dist/agents/registry-helper.js +0 -14
  47. package/dist/agents/registry.d.ts +0 -6
  48. package/dist/agents/registry.js +0 -98
  49. package/dist/agents/runtime-types.d.ts +0 -118
  50. package/dist/agents/runtime-types.js +0 -0
  51. package/dist/agents/spec-loader.d.ts +0 -18
  52. package/dist/agents/spec-loader.js +0 -55
  53. package/dist/agents/spec-normalizer.d.ts +0 -2
  54. package/dist/agents/spec-normalizer.js +0 -327
  55. package/dist/agents/spec-types.d.ts +0 -64
  56. package/dist/agents/spec-types.js +0 -0
  57. package/dist/agents/testing/agents-smoke.d.ts +0 -1
  58. package/dist/agents/testing/agents-smoke.js +0 -32
  59. package/dist/agents/testing/e2e-harness.d.ts +0 -44
  60. package/dist/agents/testing/e2e-harness.js +0 -504
  61. package/dist/api/agent-routes.d.ts +0 -13
  62. package/dist/api/agent-routes.js +0 -327
  63. package/dist/api/app.d.ts +0 -5
  64. package/dist/api/app.js +0 -361
  65. package/dist/api/auth/d1-database.d.ts +0 -3
  66. package/dist/api/auth/d1-database.js +0 -20
  67. package/dist/api/auth/d1-provider.d.ts +0 -79
  68. package/dist/api/auth/d1-provider.js +0 -92
  69. package/dist/api/auth/d1-store.d.ts +0 -114
  70. package/dist/api/auth/d1-store.js +0 -895
  71. package/dist/api/auth/memory-provider.d.ts +0 -77
  72. package/dist/api/auth/memory-provider.js +0 -249
  73. package/dist/api/auth/rbac.d.ts +0 -22
  74. package/dist/api/auth/rbac.js +0 -162
  75. package/dist/api/auth/tokens.d.ts +0 -18
  76. package/dist/api/auth/tokens.js +0 -56
  77. package/dist/api/capabilities.d.ts +0 -9
  78. package/dist/api/capabilities.js +0 -33
  79. package/dist/api/config.d.ts +0 -2
  80. package/dist/api/config.js +0 -77
  81. package/dist/api/http.d.ts +0 -28
  82. package/dist/api/http.js +0 -51
  83. package/dist/api/index.d.ts +0 -9
  84. package/dist/api/index.js +0 -18
  85. package/dist/api/operations-routes.d.ts +0 -11
  86. package/dist/api/operations-routes.js +0 -87
  87. package/dist/api/operations.d.ts +0 -3
  88. package/dist/api/operations.js +0 -26
  89. package/dist/api/project-routes.d.ts +0 -8
  90. package/dist/api/project-routes.js +0 -586
  91. package/dist/api/providers.d.ts +0 -2
  92. package/dist/api/providers.js +0 -62
  93. package/dist/api/railway.d.ts +0 -50
  94. package/dist/api/railway.js +0 -69
  95. package/dist/api/sdk-dispatch.d.ts +0 -5
  96. package/dist/api/sdk-dispatch.js +0 -13
  97. package/dist/api/sdk-routes.d.ts +0 -11
  98. package/dist/api/sdk-routes.js +0 -29
  99. package/dist/api/server.d.ts +0 -2
  100. package/dist/api/server.js +0 -10
  101. package/dist/api/templates.d.ts +0 -3
  102. package/dist/api/templates.js +0 -31
  103. package/dist/api/types.d.ts +0 -231
  104. package/dist/api/types.js +0 -0
  105. package/dist/api.d.ts +0 -1
  106. package/dist/api.js +0 -1
  107. package/dist/railway.d.ts +0 -1
  108. package/dist/railway.js +0 -4
  109. package/dist/services/agents.d.ts +0 -11
  110. package/dist/services/agents.js +0 -48
  111. package/dist/services/common.d.ts +0 -66
  112. package/dist/services/common.js +0 -212
  113. package/dist/services/index.d.ts +0 -6
  114. package/dist/services/index.js +0 -19
  115. package/dist/services/manager.d.ts +0 -267
  116. package/dist/services/manager.js +0 -1368
  117. package/dist/services/remote-runner.d.ts +0 -30
  118. package/dist/services/remote-runner.js +0 -230
  119. package/dist/services/workday-content.d.ts +0 -53
  120. package/dist/services/workday-content.js +0 -190
  121. package/dist/services/workday-manager.d.ts +0 -279
  122. package/dist/services/workday-manager.js +0 -163
  123. package/dist/services/workday-report.d.ts +0 -195
  124. package/dist/services/workday-report.js +0 -17
  125. package/dist/services/workday-start.d.ts +0 -195
  126. package/dist/services/workday-start.js +0 -17
  127. package/dist/services/worker-capacity.d.ts +0 -58
  128. package/dist/services/worker-capacity.js +0 -208
  129. package/dist/services/worker-pool-scaler.d.ts +0 -27
  130. package/dist/services/worker-pool-scaler.js +0 -127
  131. package/dist/services/worker.d.ts +0 -19
  132. package/dist/services/worker.js +0 -436
  133. package/templates/github/deploy.workflow.yml +0 -577
@@ -1,3 +0,0 @@
1
- import type { D1DatabaseLike } from '@treeseed/sdk/types/cloudflare';
2
- import type { ApiConfig } from '../types.ts';
3
- export declare function resolveApiD1Database(config: ApiConfig): D1DatabaseLike;
@@ -1,20 +0,0 @@
1
- import { CloudflareHttpD1Database } from "@treeseed/sdk";
2
- import { NodeSqliteD1Database } from "@treeseed/sdk/db/node-sqlite";
3
- function resolveApiD1Database(config) {
4
- if (config.cloudflareAccountId && config.cloudflareApiToken && config.d1DatabaseId) {
5
- return new CloudflareHttpD1Database({
6
- accountId: config.cloudflareAccountId,
7
- apiToken: config.cloudflareApiToken,
8
- databaseId: config.d1DatabaseId
9
- });
10
- }
11
- if (config.d1LocalPersistTo || config.d1DatabaseName) {
12
- return new NodeSqliteD1Database(config.d1LocalPersistTo);
13
- }
14
- throw new Error(
15
- "Treeseed API auth requires either CLOUDFLARE_ACCOUNT_ID + CLOUDFLARE_API_TOKEN + TREESEED_API_D1_DATABASE_ID for remote D1 access, or TREESEED_API_D1_LOCAL_PERSIST_TO for local SQLite-backed D1-compatible access."
16
- );
17
- }
18
- export {
19
- resolveApiD1Database
20
- };
@@ -1,79 +0,0 @@
1
- import type { D1DatabaseLike } from '@treeseed/sdk/types/cloudflare';
2
- import type { ApiAuthProvider, ApiConfig, ApiCredential, ApiPrincipal, DeviceCodeApproveRequest, DeviceCodePollRequest, DeviceCodePollResponse, DeviceCodeStartRequest, DeviceCodeStartResponse, TokenRefreshRequest, TokenRefreshResponse, TrustedUserAssertionClaims, UserIdentityProfileInput } from '../types.ts';
3
- export declare class D1AuthProvider implements ApiAuthProvider {
4
- private readonly config;
5
- readonly id = "d1";
6
- private readonly store;
7
- constructor(config: ApiConfig, options?: {
8
- db?: D1DatabaseLike;
9
- });
10
- startDeviceFlow(request: DeviceCodeStartRequest): Promise<DeviceCodeStartResponse>;
11
- pollDeviceFlow(request: DeviceCodePollRequest): Promise<DeviceCodePollResponse>;
12
- refreshAccessToken(request: TokenRefreshRequest): Promise<TokenRefreshResponse>;
13
- approveDeviceFlow(request: DeviceCodeApproveRequest): Promise<{
14
- ok: true;
15
- }>;
16
- authenticateBearerToken(token: string): Promise<{
17
- principal: ApiPrincipal;
18
- credential: ApiCredential;
19
- } | null>;
20
- authenticateServiceCredential(serviceId: string, secret: string): Promise<{
21
- principal: ApiPrincipal;
22
- credential: ApiCredential;
23
- } | null>;
24
- createPersonalAccessToken(userId: string, input: {
25
- name: string;
26
- scopes?: string[];
27
- expiresAt?: string | null;
28
- }): Promise<{
29
- id: `${string}-${string}-${string}-${string}-${string}`;
30
- token: string;
31
- prefix: string;
32
- name: string;
33
- expiresAt: string;
34
- }>;
35
- listPersonalAccessTokens(userId: string): Promise<{
36
- id: string;
37
- name: string;
38
- token_prefix: string;
39
- expires_at: string | null;
40
- last_used_at: string | null;
41
- revoked_at: string | null;
42
- created_at: string;
43
- }[]>;
44
- revokePersonalAccessToken(userId: string, tokenId: string): Promise<void>;
45
- syncUserIdentity(identity: UserIdentityProfileInput): Promise<{
46
- identityId: string;
47
- principal: ApiPrincipal;
48
- userId: string;
49
- }>;
50
- createUser(input: {
51
- email?: string | null;
52
- displayName?: string | null;
53
- metadata?: Record<string, unknown>;
54
- }): Promise<{
55
- principal: ApiPrincipal;
56
- userId: string;
57
- }>;
58
- setUserRoles(userId: string, roles: string[]): Promise<{
59
- principal: ApiPrincipal;
60
- userId: string;
61
- }>;
62
- createServiceToken(input: {
63
- serviceId: string;
64
- name: string;
65
- roles?: string[];
66
- permissions?: string[];
67
- }): Promise<import("./d1-store.ts").ServiceCredentialResult>;
68
- rotateServiceToken(serviceId: string): Promise<import("./d1-store.ts").ServiceCredentialResult>;
69
- createTrustedUserAssertion(claims: TrustedUserAssertionClaims): string;
70
- verifyTrustedUserAssertion(assertion: string): TrustedUserAssertionClaims;
71
- exchangeTrustedUserAssertion(claims: TrustedUserAssertionClaims): Promise<{
72
- ok: true;
73
- accessToken: string;
74
- tokenType: "Bearer";
75
- expiresAt: string;
76
- expiresInSeconds: number;
77
- principal: ApiPrincipal;
78
- }>;
79
- }
@@ -1,92 +0,0 @@
1
- import { createHmac, timingSafeEqual } from "node:crypto";
2
- import { D1AuthStore } from "./d1-store.js";
3
- function encodePayload(payload) {
4
- return Buffer.from(JSON.stringify(payload)).toString("base64url");
5
- }
6
- function decodePayload(value) {
7
- return JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
8
- }
9
- function signPayload(payload, secret) {
10
- return createHmac("sha256", secret).update(payload).digest("base64url");
11
- }
12
- function safeEqual(left, right) {
13
- const leftBuffer = Buffer.from(left);
14
- const rightBuffer = Buffer.from(right);
15
- return leftBuffer.length === rightBuffer.length && timingSafeEqual(leftBuffer, rightBuffer);
16
- }
17
- class D1AuthProvider {
18
- constructor(config, options = {}) {
19
- this.config = config;
20
- if (!options.db) {
21
- throw new Error("D1AuthProvider requires an explicit database binding or adapter.");
22
- }
23
- this.store = new D1AuthStore(config, options.db);
24
- }
25
- config;
26
- id = "d1";
27
- store;
28
- startDeviceFlow(request) {
29
- return this.store.startDeviceFlow(request);
30
- }
31
- pollDeviceFlow(request) {
32
- return this.store.pollDeviceFlow(request);
33
- }
34
- refreshAccessToken(request) {
35
- return this.store.refreshAccessToken(request);
36
- }
37
- approveDeviceFlow(request) {
38
- return this.store.approveDeviceFlow(request);
39
- }
40
- authenticateBearerToken(token) {
41
- return this.store.authenticateBearerToken(token);
42
- }
43
- authenticateServiceCredential(serviceId, secret) {
44
- return this.store.authenticateService(serviceId, secret);
45
- }
46
- createPersonalAccessToken(userId, input) {
47
- return this.store.createPersonalAccessToken(userId, input);
48
- }
49
- listPersonalAccessTokens(userId) {
50
- return this.store.listPersonalAccessTokens(userId);
51
- }
52
- revokePersonalAccessToken(userId, tokenId) {
53
- return this.store.revokePersonalAccessToken(userId, tokenId);
54
- }
55
- syncUserIdentity(identity) {
56
- return this.store.syncUser(identity);
57
- }
58
- createUser(input) {
59
- return this.store.createUser(input);
60
- }
61
- setUserRoles(userId, roles) {
62
- return this.store.setUserRoles(userId, roles);
63
- }
64
- createServiceToken(input) {
65
- return this.store.createServiceCredential(input);
66
- }
67
- rotateServiceToken(serviceId) {
68
- return this.store.rotateServiceCredential(serviceId);
69
- }
70
- createTrustedUserAssertion(claims) {
71
- const payload = encodePayload(claims);
72
- const signature = signPayload(payload, this.config.webAssertionSecret);
73
- return `${payload}.${signature}`;
74
- }
75
- verifyTrustedUserAssertion(assertion) {
76
- const [payload, signature] = assertion.split(".");
77
- if (!payload || !signature) return null;
78
- const expectedSignature = signPayload(payload, this.config.webAssertionSecret);
79
- if (!safeEqual(signature, expectedSignature)) return null;
80
- const claims = decodePayload(payload);
81
- if (!claims.expiresAt || new Date(claims.expiresAt).getTime() <= Date.now()) {
82
- return null;
83
- }
84
- return claims;
85
- }
86
- exchangeTrustedUserAssertion(claims) {
87
- return this.store.exchangeTrustedUserAssertion(claims);
88
- }
89
- }
90
- export {
91
- D1AuthProvider
92
- };
@@ -1,114 +0,0 @@
1
- import type { D1DatabaseLike } from '@treeseed/sdk/types/cloudflare';
2
- import type { ApiConfig, ApiCredential, ApiPrincipal, DeviceCodeApproveRequest, DeviceCodePollRequest, DeviceCodePollResponse, DeviceCodeStartRequest, DeviceCodeStartResponse, TokenRefreshRequest, TokenRefreshResponse, TrustedUserAssertionClaims, UserIdentityProfileInput } from '../types.ts';
3
- type PrincipalRecord = {
4
- principal: ApiPrincipal;
5
- userId: string;
6
- };
7
- export interface PersonalAccessTokenResult {
8
- id: string;
9
- token: string;
10
- prefix: string;
11
- name: string;
12
- expiresAt: string | null;
13
- }
14
- export interface ServiceCredentialResult {
15
- id: string;
16
- serviceId: string;
17
- secret: string;
18
- }
19
- export declare class D1AuthStore {
20
- private readonly config;
21
- private readonly db;
22
- private initializationPromise;
23
- constructor(config: ApiConfig, db: D1DatabaseLike);
24
- private run;
25
- private first;
26
- private all;
27
- private ensureInitialized;
28
- private ensureAuthSchema;
29
- private seedCatalog;
30
- private seedConfiguredServices;
31
- private loadUser;
32
- private loadIdentityByProvider;
33
- private loadUserByVerifiedEmail;
34
- private rolesForUser;
35
- private permissionsForUser;
36
- private permissionsForRoles;
37
- private scopesForPrincipal;
38
- private principalForUser;
39
- private assignRole;
40
- private replaceRoles;
41
- private bootstrapRolesForUser;
42
- private writeAuditEvent;
43
- private userMetadata;
44
- syncUser(identity: UserIdentityProfileInput): Promise<{
45
- identityId: string;
46
- principal: ApiPrincipal;
47
- userId: string;
48
- }>;
49
- createUser(input: {
50
- email?: string | null;
51
- username?: string | null;
52
- displayName?: string | null;
53
- metadata?: Record<string, unknown>;
54
- }): Promise<PrincipalRecord>;
55
- setUserRoles(userId: string, roles: string[]): Promise<PrincipalRecord>;
56
- startDeviceFlow(request: DeviceCodeStartRequest): Promise<DeviceCodeStartResponse>;
57
- approveDeviceFlow(request: DeviceCodeApproveRequest): Promise<{
58
- ok: true;
59
- }>;
60
- pollDeviceFlow(request: DeviceCodePollRequest): Promise<DeviceCodePollResponse>;
61
- refreshAccessToken(request: TokenRefreshRequest): Promise<TokenRefreshResponse>;
62
- createPersonalAccessToken(userId: string, input: {
63
- name: string;
64
- scopes?: string[];
65
- expiresAt?: string | null;
66
- }): Promise<{
67
- id: `${string}-${string}-${string}-${string}-${string}`;
68
- token: string;
69
- prefix: string;
70
- name: string;
71
- expiresAt: string;
72
- }>;
73
- listPersonalAccessTokens(userId: string): Promise<{
74
- id: string;
75
- name: string;
76
- token_prefix: string;
77
- expires_at: string | null;
78
- last_used_at: string | null;
79
- revoked_at: string | null;
80
- created_at: string;
81
- }[]>;
82
- revokePersonalAccessToken(userId: string, tokenId: string): Promise<void>;
83
- upsertServiceCredential(input: {
84
- serviceId: string;
85
- name: string;
86
- secret: string;
87
- roles?: string[];
88
- permissions?: string[];
89
- }): Promise<string>;
90
- createServiceCredential(input: {
91
- serviceId: string;
92
- name: string;
93
- roles?: string[];
94
- permissions?: string[];
95
- }): Promise<ServiceCredentialResult>;
96
- rotateServiceCredential(serviceId: string): Promise<ServiceCredentialResult>;
97
- authenticateBearerToken(token: string): Promise<{
98
- principal: ApiPrincipal;
99
- credential: ApiCredential;
100
- } | null>;
101
- authenticateService(serviceId: string, secret: string): Promise<{
102
- principal: ApiPrincipal;
103
- credential: ApiCredential;
104
- } | null>;
105
- exchangeTrustedUserAssertion(claims: TrustedUserAssertionClaims): Promise<{
106
- ok: true;
107
- accessToken: string;
108
- tokenType: "Bearer";
109
- expiresAt: string;
110
- expiresInSeconds: number;
111
- principal: ApiPrincipal;
112
- }>;
113
- }
114
- export {};