@treeseed/sdk 0.12.9 → 0.12.10
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.
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
ensureGitHubBranchFromBase
|
|
49
49
|
} from "./github-api.js";
|
|
50
50
|
import { resolveGitHubCredentialForRepository } from "./github-credentials.js";
|
|
51
|
-
import { loadCliDeployConfig, packageScriptPath, resolveWranglerBin, withProcessCwd } from "./runtime-tools.js";
|
|
51
|
+
import { loadCliDeployConfig, packageDistScriptRoot, packageScriptPath, resolveWranglerBin, withProcessCwd } from "./runtime-tools.js";
|
|
52
52
|
import { PRODUCTION_BRANCH, STAGING_BRANCH } from "./git-workflow.js";
|
|
53
53
|
import {
|
|
54
54
|
createTreeseedManagedToolEnv,
|
|
@@ -82,6 +82,7 @@ const TEMPLATE_CATALOG_CACHE_RELATIVE_PATH = "treeseed/cache/template-catalog.js
|
|
|
82
82
|
const TENANT_ENVIRONMENT_OVERLAY_PATH = "src/env.yaml";
|
|
83
83
|
const CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER = "replace-with-cloudflare-account-id";
|
|
84
84
|
const TREESEED_KEY_AGENT_AUTOPROMPT_ENV = "TREESEED_KEY_AGENT_AUTOPROMPT";
|
|
85
|
+
const KEY_AGENT_COMMAND_TIMEOUT_MS = 1e4;
|
|
85
86
|
const DEFAULT_TREESEED_API_BASE_URL = "https://api.treeseed.dev";
|
|
86
87
|
const DEFAULT_TEMPLATE_CATALOG_URL = "https://api.treeseed.dev/search/templates";
|
|
87
88
|
const TREESEED_TEMPLATE_CATALOG_URL_ENV = "TREESEED_TEMPLATE_CATALOG_URL";
|
|
@@ -335,7 +336,12 @@ function resolveManagedWorktreeMachineConfigRoot(tenantRoot) {
|
|
|
335
336
|
}
|
|
336
337
|
}
|
|
337
338
|
function keyAgentScriptPath() {
|
|
338
|
-
|
|
339
|
+
const distScriptPath = resolve(packageDistScriptRoot, "key-agent.js");
|
|
340
|
+
return existsSync(distScriptPath) ? distScriptPath : packageScriptPath("key-agent.ts");
|
|
341
|
+
}
|
|
342
|
+
function keyAgentNodeArgs() {
|
|
343
|
+
const scriptPath = keyAgentScriptPath();
|
|
344
|
+
return scriptPath.endsWith(".ts") ? ["--import", "tsx", scriptPath] : [scriptPath];
|
|
339
345
|
}
|
|
340
346
|
function keyAgentScriptCwd() {
|
|
341
347
|
return dirname(dirname(keyAgentScriptPath()));
|
|
@@ -372,11 +378,10 @@ function withTreeseedKeyAgentAutopromptDisabled(action) {
|
|
|
372
378
|
function startTreeseedKeyAgentDaemon(tenantRoot) {
|
|
373
379
|
const { keyPath } = getTreeseedMachineConfigPaths(tenantRoot);
|
|
374
380
|
const { socketPath } = getTreeseedKeyAgentPaths();
|
|
381
|
+
const scriptArgs = keyAgentNodeArgs();
|
|
375
382
|
const command = [
|
|
376
383
|
shellQuote(process.execPath),
|
|
377
|
-
|
|
378
|
-
"tsx",
|
|
379
|
-
shellQuote(keyAgentScriptPath()),
|
|
384
|
+
...scriptArgs.map((arg) => shellQuote(arg)),
|
|
380
385
|
"serve",
|
|
381
386
|
"--key-path",
|
|
382
387
|
shellQuote(keyPath),
|
|
@@ -396,9 +401,7 @@ function startTreeseedKeyAgentDaemon(tenantRoot) {
|
|
|
396
401
|
}
|
|
397
402
|
function runTreeseedKeyAgentCommand(args, options = {}) {
|
|
398
403
|
const result = spawnSync(process.execPath, [
|
|
399
|
-
|
|
400
|
-
"tsx",
|
|
401
|
-
keyAgentScriptPath(),
|
|
404
|
+
...keyAgentNodeArgs(),
|
|
402
405
|
...args
|
|
403
406
|
], {
|
|
404
407
|
cwd: keyAgentScriptCwd(),
|
|
@@ -408,8 +411,18 @@ function runTreeseedKeyAgentCommand(args, options = {}) {
|
|
|
408
411
|
...options.env ?? {}
|
|
409
412
|
},
|
|
410
413
|
stdio: options.input !== void 0 ? ["pipe", "pipe", "pipe"] : ["ignore", "pipe", "pipe"],
|
|
411
|
-
input: options.input
|
|
414
|
+
input: options.input,
|
|
415
|
+
timeout: KEY_AGENT_COMMAND_TIMEOUT_MS,
|
|
416
|
+
killSignal: "SIGTERM"
|
|
412
417
|
});
|
|
418
|
+
if (result.error) {
|
|
419
|
+
const timedOut = result.error.code === "ETIMEDOUT";
|
|
420
|
+
return {
|
|
421
|
+
ok: false,
|
|
422
|
+
code: "daemon_unavailable",
|
|
423
|
+
message: timedOut ? `Treeseed key-agent command timed out after ${KEY_AGENT_COMMAND_TIMEOUT_MS}ms.` : result.error.message || "Treeseed key-agent command failed."
|
|
424
|
+
};
|
|
425
|
+
}
|
|
413
426
|
if (result.status !== 0 && (!result.stdout || result.stdout.trim().length === 0)) {
|
|
414
427
|
return {
|
|
415
428
|
ok: false,
|