@treeseed/core 0.8.13 → 0.8.15

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/content.js CHANGED
@@ -27,7 +27,7 @@ const decisionTypeValues = ["approved", "rejected", "deferred", "superseded"];
27
27
  const timeHorizonValues = ["near-term", "mid-term", "long-term"];
28
28
  const runtimeStatusValues = ["active", "experimental", "dormant"];
29
29
  const agentTriggerTypeValues = ["schedule", "message", "follow", "startup"];
30
- const agentPermissionOperationValues = ["get", "search", "follow", "pick", "create", "update"];
30
+ const agentPermissionOperationValues = ["get", "read", "search", "follow", "pick", "create", "update"];
31
31
  const treeseedDocsExtensions = ["markdown", "mdown", "mkdn", "mkd", "mdwn", "md", "mdx"];
32
32
  function hasMarkdownContent(base) {
33
33
  if (!existsSync(base)) {
@@ -274,13 +274,27 @@ function createTreeseedCollections(tenantConfig, { docsLoader, docsSchema }) {
274
274
  model: z.string(),
275
275
  operations: z.array(z.enum(agentPermissionOperationValues)).min(1)
276
276
  });
277
+ const agentWorktreeSchema = z.object({
278
+ enabled: z.boolean().default(true),
279
+ root: z.string().optional(),
280
+ branchPrefix: z.string().optional()
281
+ });
277
282
  const agentExecutionSchema = z.object({
283
+ provider: z.string().optional(),
284
+ model: z.string().optional(),
285
+ approvalPolicy: z.string().optional(),
286
+ sandboxMode: z.string().optional(),
287
+ reasoningEffort: z.string().optional(),
288
+ allowedPaths: z.array(z.string()).default([]),
289
+ forbiddenPaths: z.array(z.string()).default([]),
290
+ worktree: agentWorktreeSchema.default({}),
278
291
  maxConcurrency: z.number().int().positive().default(1),
279
292
  timeoutSeconds: z.number().int().positive().default(900),
280
293
  cooldownSeconds: z.number().int().nonnegative().default(30),
281
294
  leaseSeconds: z.number().int().positive().default(300),
282
295
  retryLimit: z.number().int().nonnegative().default(3),
283
- branchPrefix: z.string().default("agent")
296
+ branchPrefix: z.string().default("agent"),
297
+ providerProfile: z.record(z.unknown()).optional()
284
298
  });
285
299
  const agentTriggerPolicySchema = z.object({
286
300
  maxRunsPerCycle: z.number().int().positive().optional(),
@@ -290,6 +304,27 @@ function createTreeseedCollections(tenantConfig, { docsLoader, docsSchema }) {
290
304
  messageTypes: z.array(z.string()).default([]),
291
305
  modelMutations: z.array(z.string()).default([])
292
306
  });
307
+ const agentContextQuerySchema = z.object({
308
+ id: z.string(),
309
+ purpose: z.string(),
310
+ query: z.string(),
311
+ scope: z.string().optional(),
312
+ relations: z.array(z.string()).optional(),
313
+ depth: z.number().optional(),
314
+ budget: z.number().optional(),
315
+ format: z.string().optional()
316
+ });
317
+ const agentContextSchema = z.object({
318
+ queries: z.array(agentContextQuerySchema).default([])
319
+ });
320
+ const agentGovernanceSchema = z.object({
321
+ mutationClass: z.string().optional(),
322
+ approvalRequiredForCanonicalContent: z.boolean().optional(),
323
+ approvalRequiredForCode: z.boolean().optional(),
324
+ requireSourceMap: z.boolean().optional(),
325
+ requireHumanApproval: z.boolean().optional(),
326
+ notes: z.array(z.string()).default([])
327
+ }).passthrough();
293
328
  const peopleSchema = z.object({
294
329
  name: z.string(),
295
330
  description: z.string(),
@@ -322,8 +357,10 @@ function createTreeseedCollections(tenantConfig, { docsLoader, docsSchema }) {
322
357
  triggers: z.array(agentTriggerSchema).min(1),
323
358
  triggerPolicy: agentTriggerPolicySchema.optional(),
324
359
  permissions: z.array(agentPermissionSchema).min(1),
360
+ context: agentContextSchema.optional(),
325
361
  execution: agentExecutionSchema.default({}),
326
- outputs: agentOutputSchema.default({})
362
+ outputs: agentOutputSchema.default({}),
363
+ governance: agentGovernanceSchema.optional()
327
364
  }));
328
365
  const bookSchema = z.preprocess((value) => preprocessAliasedRecord(bookFieldAliases, value), z.object({
329
366
  order: z.number().int().nonnegative(),
package/dist/dev.js CHANGED
@@ -1,9 +1,10 @@
1
- import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
1
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
2
2
  import { spawn, spawnSync } from "node:child_process";
3
3
  import { createRequire } from "node:module";
4
4
  import { dirname, isAbsolute, resolve, sep } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { setTimeout as delay } from "node:timers/promises";
7
+ import { DatabaseSync } from "node:sqlite";
7
8
  import {
8
9
  applyTreeseedEnvironmentToProcess,
9
10
  assertTreeseedCommandEnvironment,
@@ -112,7 +113,7 @@ function normalizeFeedbackMode(value) {
112
113
  return value ?? "live";
113
114
  }
114
115
  function normalizeOpenMode(value) {
115
- return value ?? "auto";
116
+ return value ?? "off";
116
117
  }
117
118
  function normalizeLocalRuntimeMode(value) {
118
119
  return value === "provider" || value === "local" ? value : "auto";
@@ -234,6 +235,42 @@ function resetActionForPath(id, label, path) {
234
235
  detail: existsSync(path) ? void 0 : "Path does not exist."
235
236
  };
236
237
  }
238
+ function resolveLocalD1SqlitePath(persistTo) {
239
+ if (/\.sqlite$/u.test(persistTo) && existsSync(persistTo)) {
240
+ return persistTo;
241
+ }
242
+ const miniflareRoot = resolve(persistTo, "miniflare-D1DatabaseObject");
243
+ if (existsSync(miniflareRoot)) {
244
+ const candidates = readdirSync(miniflareRoot).filter((entry) => /\.sqlite$/u.test(entry) && entry !== "metadata.sqlite").map((entry) => {
245
+ const path = resolve(miniflareRoot, entry);
246
+ return {
247
+ path,
248
+ size: statSync(path).size
249
+ };
250
+ }).sort((left, right) => right.size - left.size || left.path.localeCompare(right.path));
251
+ if (candidates[0]?.path) {
252
+ return candidates[0].path;
253
+ }
254
+ }
255
+ const siteDataPath = resolve(persistTo, "site-data.sqlite");
256
+ return existsSync(siteDataPath) ? siteDataPath : null;
257
+ }
258
+ function resolveSeededLocalProjectId(persistTo, projectSlug = "market") {
259
+ const sqlitePath = resolveLocalD1SqlitePath(persistTo);
260
+ if (!sqlitePath) return null;
261
+ let db = null;
262
+ try {
263
+ db = new DatabaseSync(sqlitePath, { readOnly: true });
264
+ const row = db.prepare(
265
+ `SELECT id FROM projects WHERE LOWER(slug) = LOWER(?) ORDER BY created_at ASC LIMIT 1`
266
+ ).get(projectSlug);
267
+ return typeof row?.id === "string" && row.id.trim() ? row.id.trim() : null;
268
+ } catch {
269
+ return null;
270
+ } finally {
271
+ db?.close();
272
+ }
273
+ }
237
274
  function createTreeseedIntegratedDevResetPlan(options) {
238
275
  if (!options.enabled) {
239
276
  return null;
@@ -484,7 +521,6 @@ function createTreeseedIntegratedDevPlan(options = {}) {
484
521
  const apiPort = normalizePort(options.apiPort, TREESEED_DEFAULT_API_PORT);
485
522
  const machineEnv = resolveLocalMachineEnv(tenantRoot);
486
523
  const mergedEnv = { ...process.env, ...machineEnv, ...options.env ?? {} };
487
- const projectId = options.projectId ?? mergedEnv.TREESEED_PROJECT_ID;
488
524
  const teamId = options.teamId ?? mergedEnv.TREESEED_HOSTING_TEAM_ID;
489
525
  const apiBaseUrl = options.apiHost != null || options.apiPort != null ? `http://${apiHost}:${apiPort}` : mergedEnv.TREESEED_API_BASE_URL?.trim() || `http://${apiHost}:${apiPort}`;
490
526
  const selectedCommandIds = selectedSurfaceCommandIds(options);
@@ -495,6 +531,8 @@ function createTreeseedIntegratedDevPlan(options = {}) {
495
531
  const deployConfig = loadDevDeployConfig(tenantRoot);
496
532
  const webLocalRuntime = selectWebLocalRuntime(deployConfig?.surfaces?.web, fallbackWebProviderFromDeployConfig(deployConfig));
497
533
  const usesCloudflareWebRuntime = webLocalRuntime.selected === "cloudflare-wrangler-local";
534
+ const localD1PersistTo = mergedEnv.TREESEED_API_D1_LOCAL_PERSIST_TO ?? (usesCloudflareWebRuntime ? resolve(tenantRoot, ".treeseed", "generated", "environments", "local", ".wrangler", "state", "v3", "d1") : resolve(tenantRoot, ".wrangler", "state", "v3", "d1"));
535
+ const projectId = options.projectId ?? mergedEnv.TREESEED_PROJECT_ID ?? resolveSeededLocalProjectId(localD1PersistTo);
498
536
  const webEntrypoint = resolveNodeEntrypoint(
499
537
  sdkPackageRoot,
500
538
  "scripts/tenant-astro-command.ts",
@@ -528,7 +566,7 @@ function createTreeseedIntegratedDevPlan(options = {}) {
528
566
  TREESEED_HOSTING_TEAM_ID: teamId ?? mergedEnv.TREESEED_HOSTING_TEAM_ID,
529
567
  TREESEED_API_D1_DATABASE_NAME: mergedEnv.TREESEED_API_D1_DATABASE_NAME ?? "SITE_DATA_DB",
530
568
  SITE_DATA_DB: mergedEnv.SITE_DATA_DB ?? "SITE_DATA_DB",
531
- TREESEED_API_D1_LOCAL_PERSIST_TO: mergedEnv.TREESEED_API_D1_LOCAL_PERSIST_TO ?? (usesCloudflareWebRuntime ? resolve(tenantRoot, ".treeseed", "generated", "environments", "local", ".wrangler", "state", "v3", "d1") : resolve(tenantRoot, ".wrangler", "state", "v3", "d1")),
569
+ TREESEED_API_D1_LOCAL_PERSIST_TO: localD1PersistTo,
532
570
  TREESEED_FORM_TOKEN_SECRET: mergedEnv.TREESEED_FORM_TOKEN_SECRET ?? "treeseed-local-form-token-secret",
533
571
  TREESEED_BETTER_AUTH_SECRET: mergedEnv.TREESEED_BETTER_AUTH_SECRET ?? "treeseed-local-better-auth-secret-minimum-32-characters",
534
572
  TREESEED_SMTP_HOST: TREESEED_DEFAULT_LOCAL_SMTP_HOST,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/core",
3
- "version": "0.8.13",
3
+ "version": "0.8.15",
4
4
  "description": "Treeseed web framework package for Astro/Starlight site runtimes.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -70,7 +70,7 @@
70
70
  "@astrojs/sitemap": "3.7.0",
71
71
  "@astrojs/starlight": "0.37.6",
72
72
  "@tailwindcss/vite": "^4.1.4",
73
- "@treeseed/sdk": "0.8.13",
73
+ "@treeseed/sdk": "0.8.15",
74
74
  "astro": "^5.6.1",
75
75
  "esbuild": "^0.28.0",
76
76
  "katex": "^0.16.22",