@treeseed/core 0.4.13 → 0.5.3

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 (81) hide show
  1. package/dist/agents/adapters/notification.d.ts +16 -1
  2. package/dist/agents/adapters/notification.js +31 -1
  3. package/dist/agents/adapters/research.d.ts +13 -1
  4. package/dist/agents/adapters/research.js +35 -1
  5. package/dist/agents/contracts/run.d.ts +1 -0
  6. package/dist/agents/kernel/agent-kernel.d.ts +2 -2
  7. package/dist/agents/kernel/agent-kernel.js +10 -3
  8. package/dist/agents/kernel/trigger-resolver.d.ts +1 -0
  9. package/dist/agents/kernel/trigger-resolver.js +5 -1
  10. package/dist/agents/runtime-types.d.ts +1 -0
  11. package/dist/api/app.js +10 -0
  12. package/dist/api/auth/d1-store.js +5 -0
  13. package/dist/api/auth/memory-provider.js +6 -1
  14. package/dist/api/auth/rbac.d.ts +2 -2
  15. package/dist/api/auth/rbac.js +2 -0
  16. package/dist/api/capabilities.d.ts +9 -0
  17. package/dist/api/capabilities.js +33 -0
  18. package/dist/api/operations-routes.d.ts +4 -0
  19. package/dist/api/operations-routes.js +49 -1
  20. package/dist/api/project-routes.d.ts +8 -0
  21. package/dist/api/project-routes.js +586 -0
  22. package/dist/api/types.d.ts +7 -0
  23. package/dist/components/site/NotesList.astro +13 -2
  24. package/dist/components/site/PublishedContentBody.astro +5 -0
  25. package/dist/content.js +77 -9
  26. package/dist/dev.d.ts +2 -2
  27. package/dist/dev.js +0 -15
  28. package/dist/env.yaml +39 -26
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +7 -1
  31. package/dist/launch.d.ts +3 -0
  32. package/dist/launch.js +8 -0
  33. package/dist/layouts/AuthoredEntryLayout.astro +76 -28
  34. package/dist/layouts/ProfileLayout.astro +9 -5
  35. package/dist/middleware.js +11 -0
  36. package/dist/pages/[slug].astro +10 -6
  37. package/dist/pages/agents/[slug].astro +17 -7
  38. package/dist/pages/agents/index.astro +2 -1
  39. package/dist/pages/books/[slug].astro +10 -5
  40. package/dist/pages/books/index.astro +4 -1
  41. package/dist/pages/decisions/[slug].astro +73 -0
  42. package/dist/pages/decisions/index.astro +47 -0
  43. package/dist/pages/docs-runtime/[...slug].astro +102 -0
  44. package/dist/pages/docs-runtime/index.astro +89 -0
  45. package/dist/pages/feed.xml.js +2 -1
  46. package/dist/pages/index.astro +160 -16
  47. package/dist/pages/notes/[slug].astro +10 -5
  48. package/dist/pages/notes/index.astro +6 -3
  49. package/dist/pages/objectives/[slug].astro +27 -9
  50. package/dist/pages/objectives/index.astro +19 -2
  51. package/dist/pages/people/[slug].astro +17 -7
  52. package/dist/pages/people/index.astro +2 -1
  53. package/dist/pages/proposals/[slug].astro +72 -0
  54. package/dist/pages/proposals/index.astro +47 -0
  55. package/dist/pages/questions/[slug].astro +27 -9
  56. package/dist/pages/questions/index.astro +19 -2
  57. package/dist/scripts/dev-platform.js +0 -1
  58. package/dist/scripts/release-verify.js +29 -2
  59. package/dist/scripts/tenant-build.js +4 -1
  60. package/dist/scripts/tenant-check.js +4 -1
  61. package/dist/services/agents.d.ts +1 -12
  62. package/dist/services/agents.js +28 -9
  63. package/dist/services/index.d.ts +0 -2
  64. package/dist/services/index.js +0 -6
  65. package/dist/services/manager.d.ts +4 -4
  66. package/dist/services/manager.js +123 -50
  67. package/dist/services/workday-report.d.ts +3 -3
  68. package/dist/services/workday-start.d.ts +3 -3
  69. package/dist/services/worker-capacity.d.ts +58 -0
  70. package/dist/services/worker-capacity.js +208 -0
  71. package/dist/services/worker.js +70 -13
  72. package/dist/site.js +18 -5
  73. package/dist/tenant/runtime-config.js +8 -1
  74. package/dist/utils/hub-content.js +14 -0
  75. package/dist/utils/published-content.js +13 -0
  76. package/dist/utils/site-config.js +20 -0
  77. package/dist/utils/site-content-runtime.js +185 -0
  78. package/dist/utils/web-cache.js +149 -0
  79. package/package.json +11 -6
  80. package/scripts/verify-driver.mjs +34 -0
  81. package/templates/github/deploy.workflow.yml +11 -1
@@ -0,0 +1,149 @@
1
+ import { EDITORIAL_PREVIEW_COOKIE } from "@treeseed/sdk/platform/published-content";
2
+ import { getTreeseedDeployConfig } from "@treeseed/sdk/platform/plugins";
3
+ const STATIC_FILE_PATTERN = /\.[a-z0-9]+$/i;
4
+ const PRIVATE_PATH_PREFIXES = ["/api", "/auth", "/admin", "/app", "/internal"];
5
+ const DEFAULT_LONG_LIVED_CACHE_POLICY = {
6
+ browserTtlSeconds: 0,
7
+ edgeTtlSeconds: 31536e3,
8
+ staleWhileRevalidateSeconds: 86400,
9
+ staleIfErrorSeconds: 86400
10
+ };
11
+ const DEFAULT_SOURCE_PAGE_PATHS = ["/", "/contact", "/404"];
12
+ const CONTENT_INDEX_PATHS = /* @__PURE__ */ new Set([
13
+ "/agents",
14
+ "/books",
15
+ "/notes",
16
+ "/objectives",
17
+ "/proposals",
18
+ "/people",
19
+ "/decisions",
20
+ "/questions"
21
+ ]);
22
+ function hasCookieHeader(request, cookieName) {
23
+ const cookieHeader = request.headers.get("cookie") ?? "";
24
+ return cookieHeader.includes(`${cookieName}=`);
25
+ }
26
+ function hasPreviewQuery(url) {
27
+ return url.searchParams.has("preview");
28
+ }
29
+ function isStaticAssetPath(pathname) {
30
+ return STATIC_FILE_PATTERN.test(pathname);
31
+ }
32
+ function isPrivatePath(pathname) {
33
+ return PRIVATE_PATH_PREFIXES.some(
34
+ (prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)
35
+ );
36
+ }
37
+ function normalizePath(pathname) {
38
+ if (!pathname || pathname === "/") {
39
+ return "/";
40
+ }
41
+ return pathname.replace(/\/+$/u, "");
42
+ }
43
+ function configuredSourcePagePaths() {
44
+ const configured = getTreeseedDeployConfig().surfaces?.web?.cache?.sourcePages?.paths;
45
+ return new Set((configured && configured.length ? configured : DEFAULT_SOURCE_PAGE_PATHS).map((entry) => normalizePath(entry)));
46
+ }
47
+ function isContentHtmlPath(pathname) {
48
+ const normalized = normalizePath(pathname);
49
+ if (CONTENT_INDEX_PATHS.has(normalized)) {
50
+ return true;
51
+ }
52
+ for (const prefix of CONTENT_INDEX_PATHS) {
53
+ if (normalized.startsWith(`${prefix}/`)) {
54
+ return true;
55
+ }
56
+ }
57
+ return normalized !== "/" && !configuredSourcePagePaths().has(normalized);
58
+ }
59
+ function classifyTreeseedWebRequest(request, url) {
60
+ if (!["GET", "HEAD"].includes(request.method)) {
61
+ return { kind: "api_no_cache", reason: "method" };
62
+ }
63
+ if (hasPreviewQuery(url)) {
64
+ return { kind: "preview_no_cache", reason: "preview_query" };
65
+ }
66
+ if (hasCookieHeader(request, EDITORIAL_PREVIEW_COOKIE)) {
67
+ return { kind: "preview_no_cache", reason: "preview_cookie" };
68
+ }
69
+ if (isPrivatePath(url.pathname)) {
70
+ if (normalizePath(url.pathname) === "/api" || normalizePath(url.pathname).startsWith("/api/")) {
71
+ return { kind: "api_no_cache", reason: "api_path" };
72
+ }
73
+ return { kind: "private_no_cache", reason: "private_path" };
74
+ }
75
+ if (isStaticAssetPath(url.pathname)) {
76
+ return { kind: "static_asset" };
77
+ }
78
+ if (configuredSourcePagePaths().has(normalizePath(url.pathname))) {
79
+ return { kind: "source_page_html" };
80
+ }
81
+ return isContentHtmlPath(url.pathname) ? { kind: "content_page_html" } : { kind: "source_page_html" };
82
+ }
83
+ function isHtmlResponse(response) {
84
+ const contentType = response.headers.get("content-type") ?? "";
85
+ return contentType.includes("text/html");
86
+ }
87
+ function responseSetsCookie(response) {
88
+ return response.headers.has("set-cookie");
89
+ }
90
+ function publicBrowserCacheControl(browserTtlSeconds) {
91
+ if (browserTtlSeconds <= 0) {
92
+ return "public, max-age=0, must-revalidate";
93
+ }
94
+ return `public, max-age=${browserTtlSeconds}, must-revalidate`;
95
+ }
96
+ function publicCdnCacheControl(edgeTtlSeconds, staleWhileRevalidateSeconds, staleIfErrorSeconds) {
97
+ return [
98
+ "public",
99
+ `s-maxage=${edgeTtlSeconds}`,
100
+ `stale-while-revalidate=${staleWhileRevalidateSeconds}`,
101
+ `stale-if-error=${staleIfErrorSeconds}`
102
+ ].join(", ");
103
+ }
104
+ function resolveWebCachePolicy() {
105
+ const cache = getTreeseedDeployConfig().surfaces?.web?.cache ?? {};
106
+ return {
107
+ sourcePages: {
108
+ browserTtlSeconds: cache.sourcePages?.browserTtlSeconds ?? DEFAULT_LONG_LIVED_CACHE_POLICY.browserTtlSeconds,
109
+ edgeTtlSeconds: cache.sourcePages?.edgeTtlSeconds ?? DEFAULT_LONG_LIVED_CACHE_POLICY.edgeTtlSeconds,
110
+ staleWhileRevalidateSeconds: cache.sourcePages?.staleWhileRevalidateSeconds ?? DEFAULT_LONG_LIVED_CACHE_POLICY.staleWhileRevalidateSeconds,
111
+ staleIfErrorSeconds: cache.sourcePages?.staleIfErrorSeconds ?? DEFAULT_LONG_LIVED_CACHE_POLICY.staleIfErrorSeconds
112
+ },
113
+ contentPages: {
114
+ browserTtlSeconds: cache.contentPages?.browserTtlSeconds ?? DEFAULT_LONG_LIVED_CACHE_POLICY.browserTtlSeconds,
115
+ edgeTtlSeconds: cache.contentPages?.edgeTtlSeconds ?? DEFAULT_LONG_LIVED_CACHE_POLICY.edgeTtlSeconds,
116
+ staleWhileRevalidateSeconds: cache.contentPages?.staleWhileRevalidateSeconds ?? DEFAULT_LONG_LIVED_CACHE_POLICY.staleWhileRevalidateSeconds,
117
+ staleIfErrorSeconds: cache.contentPages?.staleIfErrorSeconds ?? DEFAULT_LONG_LIVED_CACHE_POLICY.staleIfErrorSeconds
118
+ }
119
+ };
120
+ }
121
+ function applyTreeseedWebCacheHeaders(request, url, response) {
122
+ const classification = classifyTreeseedWebRequest(request, url);
123
+ if (classification.kind === "preview_no_cache" || classification.kind === "api_no_cache" || classification.kind === "private_no_cache") {
124
+ response.headers.set("Cache-Control", "no-store");
125
+ response.headers.set("CDN-Cache-Control", "no-store");
126
+ return response;
127
+ }
128
+ if (classification.kind === "static_asset") {
129
+ return response;
130
+ }
131
+ if (response.status !== 200 || !isHtmlResponse(response) || responseSetsCookie(response)) {
132
+ return response;
133
+ }
134
+ const policy = classification.kind === "source_page_html" ? resolveWebCachePolicy().sourcePages : resolveWebCachePolicy().contentPages;
135
+ response.headers.set("Cache-Control", publicBrowserCacheControl(policy.browserTtlSeconds));
136
+ response.headers.set(
137
+ "CDN-Cache-Control",
138
+ publicCdnCacheControl(
139
+ policy.edgeTtlSeconds,
140
+ policy.staleWhileRevalidateSeconds,
141
+ policy.staleIfErrorSeconds
142
+ )
143
+ );
144
+ return response;
145
+ }
146
+ export {
147
+ applyTreeseedWebCacheHeaders,
148
+ classifyTreeseedWebRequest
149
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/core",
3
- "version": "0.4.13",
3
+ "version": "0.5.3",
4
4
  "description": "Treeseed integrated platform starter for Astro/Starlight web runtimes and Hono API runtimes.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -20,6 +20,7 @@
20
20
  "files": [
21
21
  "README.md",
22
22
  "dist",
23
+ "scripts/verify-driver.mjs",
23
24
  "tsconfigs",
24
25
  "templates",
25
26
  "style",
@@ -57,9 +58,9 @@
57
58
  "test": "npm run test:unit",
58
59
  "lint": "npm run fixtures:check && npm run starlight:patch && npm run build:dist",
59
60
  "verify:direct": "npm run release:verify",
60
- "verify:local": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='direct'; await import('@treeseed/sdk/scripts/verify-driver')\"",
61
- "verify:action": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='act'; await import('@treeseed/sdk/scripts/verify-driver')\"",
62
- "verify": "node --input-type=module -e \"await import('@treeseed/sdk/scripts/verify-driver')\"",
61
+ "verify:local": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='direct'; await import('./scripts/verify-driver.mjs')\"",
62
+ "verify:action": "node --input-type=module -e \"process.env.TREESEED_VERIFY_DRIVER='act'; await import('./scripts/verify-driver.mjs')\"",
63
+ "verify": "node --input-type=module -e \"await import('./scripts/verify-driver.mjs')\"",
63
64
  "test:smoke": "node ./scripts/run-ts.mjs ./scripts/test-smoke.ts",
64
65
  "fixtures:resolve": "node ./scripts/run-ts.mjs ./scripts/fixture-tools.ts resolve",
65
66
  "fixtures:check": "node ./scripts/run-ts.mjs ./scripts/fixture-tools.ts check",
@@ -69,12 +70,12 @@
69
70
  "release:publish": "node ./scripts/run-ts.mjs ./scripts/publish-package.ts"
70
71
  },
71
72
  "dependencies": {
72
- "@treeseed/sdk": "^0.4.13",
73
73
  "@astrojs/check": "^0.9.8",
74
74
  "@astrojs/cloudflare": "^12.6.13",
75
75
  "@astrojs/sitemap": "3.7.0",
76
76
  "@astrojs/starlight": "0.37.6",
77
77
  "@tailwindcss/vite": "^4.1.4",
78
+ "@treeseed/sdk": "^0.5.3",
78
79
  "astro": "^5.6.1",
79
80
  "esbuild": "^0.28.0",
80
81
  "hono": "^4.8.2",
@@ -83,8 +84,8 @@
83
84
  "rehype-katex": "^7.0.1",
84
85
  "remark-frontmatter": "^5.0.0",
85
86
  "remark-gfm": "^4.0.1",
86
- "remark-mdx": "^3.1.1",
87
87
  "remark-math": "^6.0.0",
88
+ "remark-mdx": "^3.1.1",
88
89
  "remark-parse": "^11.0.0",
89
90
  "remark-stringify": "^11.0.0",
90
91
  "tailwindcss": "^4.1.4",
@@ -197,6 +198,10 @@
197
198
  "types": "./dist/api/app.d.ts",
198
199
  "default": "./dist/api/app.js"
199
200
  },
201
+ "./launch": {
202
+ "types": "./dist/launch.d.ts",
203
+ "default": "./dist/launch.js"
204
+ },
200
205
  "./site-resources": {
201
206
  "types": "./dist/site-resources.d.ts",
202
207
  "default": "./dist/site-resources.js"
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from 'node:child_process';
4
+
5
+ function runDirectVerify() {
6
+ const result = spawnSync('npm', ['run', 'verify:direct'], {
7
+ cwd: process.cwd(),
8
+ env: process.env,
9
+ stdio: 'inherit',
10
+ });
11
+ process.exit(result.status ?? 1);
12
+ }
13
+
14
+ const entrypointCheckOnly = process.env.TREESEED_VERIFY_ENTRYPOINT_CHECK === 'true';
15
+
16
+ try {
17
+ await import('@treeseed/sdk/scripts/verify-driver');
18
+ if (entrypointCheckOnly) {
19
+ process.exit(0);
20
+ }
21
+ } catch (error) {
22
+ if (error && typeof error === 'object' && 'code' in error && error.code === 'ERR_MODULE_NOT_FOUND') {
23
+ if (entrypointCheckOnly) {
24
+ process.stderr.write('Treeseed core verify: @treeseed/sdk is required for verify entrypoint resolution.\n');
25
+ process.exit(1);
26
+ }
27
+ if (process.env.TREESEED_VERIFY_DRIVER === 'act') {
28
+ process.stderr.write('Treeseed core verify: `act` mode requires @treeseed/sdk to be installed.\n');
29
+ process.exit(1);
30
+ }
31
+ runDirectVerify();
32
+ }
33
+ throw error;
34
+ }
@@ -98,7 +98,7 @@ jobs:
98
98
  while IFS= read -r path; do
99
99
  [[ -z "${path}" ]] && continue
100
100
  case "${path}" in
101
- src/content/*|content/*|books/*|docs/*|public/books/*|migrations/*)
101
+ src/content/*|content/*|books/*|docs/*|migrations/*)
102
102
  content_changed="true"
103
103
  ;;
104
104
  *)
@@ -287,6 +287,7 @@ __WORKING_DIRECTORY_BLOCK__
287
287
  TREESEED_RAILWAY_PROJECT_ID: ${{ vars.TREESEED_RAILWAY_PROJECT_ID }}
288
288
  TREESEED_RAILWAY_ENVIRONMENT_ID: ${{ vars.TREESEED_RAILWAY_ENVIRONMENT_ID }}
289
289
  TREESEED_RAILWAY_WORKER_SERVICE_ID: ${{ vars.TREESEED_RAILWAY_WORKER_SERVICE_ID }}
290
+ TREESEED_CONTENT_SERVING_MODE: published_runtime
290
291
  TREESEED_WORKFLOW_ACTION: deploy_code
291
292
  TREESEED_WORKFLOW_ENVIRONMENT: ${{ needs.classify.outputs.scope }}
292
293
  TREESEED_WORKFLOW_PROJECT: ${{ inputs.project_id || vars.TREESEED_PROJECT_ID }}
@@ -294,6 +295,15 @@ __WORKING_DIRECTORY_BLOCK__
294
295
  steps:
295
296
  - name: Checkout
296
297
  uses: actions/checkout@v4
298
+ with:
299
+ submodules: false
300
+ sparse-checkout: |
301
+ /*
302
+ !/src/content/
303
+ !/src/content/**
304
+ !/public/books/
305
+ !/public/books/**
306
+ sparse-checkout-cone-mode: false
297
307
 
298
308
  - name: Setup Node
299
309
  uses: actions/setup-node@v4