From af32ecdca3d0396d04b47fdc1bed5ffb4c8a7fe2 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 21 Nov 2026 10:55:57 +0000 Subject: [PATCH 1/2] feat(runtime): per-profile runtime.env with Dashboard key listing Load optional profiles//runtime.env on top of shared ~/.beacon/runtime.env (profile keys win). Expose sorted key names only on GET /api/profiles/:id and in the Profiles detail UI; never serialize values. Co-authored-by: nettee --- README.md | 11 ++- apps/web/src/ProfilesPage.tsx | 18 +++++ docs/macmini-deploy-and-update.md | 3 +- packages/shared/src/index.ts | 5 ++ .../src/config/runtime-environment.test.ts | 80 ++++++++++++++++++- .../daemon/src/config/runtime-environment.ts | 37 +++++++++ .../daemon/src/dashboard/profiles.test.ts | 44 +++++++++- services/daemon/src/dashboard/profiles.ts | 16 +++- services/daemon/src/dashboard/server.test.ts | 17 ++++ services/daemon/src/dashboard/server.ts | 5 ++ services/daemon/src/doctor.ts | 15 +++- services/daemon/src/manual-trigger.ts | 15 +++- services/daemon/src/schedule-trigger.ts | 15 +++- services/daemon/src/service.ts | 32 ++++++-- 14 files changed, 286 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 766acbd..6082303 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,12 @@ Copy the files under [`examples`](examples) into a private Beacon home and repla ```text ~/.beacon/ ├── config.yaml -├── runtime.env +├── runtime.env # optional shared keys for every Profile ├── secrets.json ├── profiles/ │ └── example/ -│ └── profile.yaml +│ ├── profile.yaml +│ └── runtime.env # optional Profile-only keys (override shared) └── playbook/ └── .beacon-profile/ ├── persona.md @@ -79,9 +80,11 @@ chmod 600 /Users/USERNAME/.beacon/secrets.json ``` `runtime.env` is optional. When present, Beacon loads every `KEY=VALUE` entry -once at startup and passes it to every Pi Run. This gives launchd deployments a +at startup. Each Profile may also have `profiles//runtime.env`. Merge order +is **shared first, then Profile** (Profile keys win on conflict). The effective +map is passed to that Profile's Pi Runs. This gives launchd deployments a deterministic runtime environment without executing interactive shell files such -as `.zshrc`: +as `.zshrc`. Dashboard Profile detail lists **key names only** (never values). ```dotenv GRAFANA_READER_TOKEN_PROD=replace-me diff --git a/apps/web/src/ProfilesPage.tsx b/apps/web/src/ProfilesPage.tsx index b5d13eb..b210ea4 100644 --- a/apps/web/src/ProfilesPage.tsx +++ b/apps/web/src/ProfilesPage.tsx @@ -251,6 +251,24 @@ function ProfileDetailPanel({ profile }: { profile: ProfileDetail }) {

{profile.secrets.note}

+ +
+

+ Runtime env ({profile.runtimeEnv.keys.length}) +

+

+ Key names only · values are never shown · shared ∪ profile file +

+ {profile.runtimeEnv.keys.length === 0 ? ( +

No runtime.env keys.

+ ) : ( +
    + {profile.runtimeEnv.keys.map((key) => ( +
  • {key}
  • + ))} +
+ )} +
); } diff --git a/docs/macmini-deploy-and-update.md b/docs/macmini-deploy-and-update.md index 152e2bd..81385e6 100644 --- a/docs/macmini-deploy-and-update.md +++ b/docs/macmini-deploy-and-update.md @@ -10,7 +10,8 @@ | Beacon home | `/Users/liuyi/.beacon` | | 全局配置 | `/Users/liuyi/.beacon/config.yaml` | | 全局飞书群渠道 | `/Users/liuyi/.beacon/channels.yaml`(仅群;admin 私聊在 Profile `admin.chat_id`) | -| Pi 运行环境 | `/Users/liuyi/.beacon/runtime.env` | +| Pi 运行环境(共享) | `/Users/liuyi/.beacon/runtime.env` | +| Pi 运行环境(Profile) | `/Users/liuyi/.beacon/profiles//runtime.env`(可选;覆盖共享同名键) | | Profile | `/Users/liuyi/.beacon/profiles/` | | Profile workspace(可选) | `/Users/liuyi/.beacon/profiles//workspace`(需 `config.yaml` 里 `profile_workspace.enabled: true`;默认 off) | | 密钥 | `/Users/liuyi/.beacon/secrets.json` | diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 8f42671..1cfa0a7 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -134,6 +134,11 @@ export type ProfileDetailView = { /** Present when profile.yaml declares `skills`; omit/null = Pi default discovery. */ skills: ProfileSkillsView | null; secrets: { present: false; note: string }; + /** + * Effective runtime.env key names for this Profile (shared ∪ profile file). + * Values are never included. + */ + runtimeEnv: { keys: string[] }; }; /** diff --git a/services/daemon/src/config/runtime-environment.test.ts b/services/daemon/src/config/runtime-environment.test.ts index 5d43b44..644cb2c 100644 --- a/services/daemon/src/config/runtime-environment.test.ts +++ b/services/daemon/src/config/runtime-environment.test.ts @@ -1,10 +1,15 @@ import assert from "node:assert/strict"; -import { chmod, mkdtemp, writeFile } from "node:fs/promises"; +import { chmod, mkdir, mkdtemp, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; import test from "node:test"; -import { loadRuntimeEnvironment } from "./runtime-environment.js"; +import { + listMergedRuntimeEnvironmentKeys, + loadMergedRuntimeEnvironment, + loadRuntimeEnvironment, + profileRuntimeEnvironmentPath, +} from "./runtime-environment.js"; async function fixture(contents: string, mode = 0o600): Promise { const root = await mkdtemp(join(tmpdir(), "beacon-runtime-environment-")); @@ -51,3 +56,74 @@ for (const [name, contents, pattern] of [ await assert.rejects(loadRuntimeEnvironment(path), pattern); }); } + +test("merges shared then profile with profile overriding same keys", async () => { + const root = await mkdtemp(join(tmpdir(), "beacon-runtime-merge-")); + const sharedPath = join(root, "runtime.env"); + const profilePath = join(root, "profiles", "amr-galaxie", "runtime.env"); + await writeFile( + sharedPath, + "SHARED_ONLY=shared-secret\nOVERLAP=from-shared\n", + { mode: 0o600 }, + ); + await chmod(sharedPath, 0o600); + await mkdir(join(root, "profiles", "amr-galaxie"), { recursive: true }); + await writeFile( + profilePath, + "PROFILE_ONLY=profile-secret\nOVERLAP=from-profile\n", + { mode: 0o600 }, + ); + await chmod(profilePath, 0o600); + + const merged = await loadMergedRuntimeEnvironment({ + sharedPath, + profilePath, + }); + assert.deepEqual(merged, { + SHARED_ONLY: "shared-secret", + OVERLAP: "from-profile", + PROFILE_ONLY: "profile-secret", + }); + + const keys = await listMergedRuntimeEnvironmentKeys({ + sharedPath, + profilePath, + }); + assert.deepEqual(keys, ["OVERLAP", "PROFILE_ONLY", "SHARED_ONLY"]); + const serialized = JSON.stringify({ keys }); + assert.doesNotMatch(serialized, /shared-secret/); + assert.doesNotMatch(serialized, /profile-secret/); + assert.doesNotMatch(serialized, /from-shared/); + assert.doesNotMatch(serialized, /from-profile/); +}); + +test("merge treats missing shared or profile file as empty", async () => { + const root = await mkdtemp(join(tmpdir(), "beacon-runtime-merge-absent-")); + const sharedPath = join(root, "runtime.env"); + const profilePath = join(root, "profiles", "solo", "runtime.env"); + await mkdir(join(root, "profiles", "solo"), { recursive: true }); + await writeFile(profilePath, "SOLO=only-here\n", { mode: 0o600 }); + await chmod(profilePath, 0o600); + + assert.deepEqual( + await loadMergedRuntimeEnvironment({ sharedPath, profilePath }), + { SOLO: "only-here" }, + ); + assert.deepEqual( + await listMergedRuntimeEnvironmentKeys({ + sharedPath: join(root, "missing-shared.env"), + profilePath: join(root, "missing-profile.env"), + }), + [], + ); +}); + +test("profileRuntimeEnvironmentPath nests under the Profile directory", () => { + assert.equal( + profileRuntimeEnvironmentPath( + "/home/beacon/.beacon/profiles", + "amr-release", + ), + join("/home/beacon/.beacon/profiles", "amr-release", "runtime.env"), + ); +}); diff --git a/services/daemon/src/config/runtime-environment.ts b/services/daemon/src/config/runtime-environment.ts index c072b4f..9b245aa 100644 --- a/services/daemon/src/config/runtime-environment.ts +++ b/services/daemon/src/config/runtime-environment.ts @@ -1,4 +1,5 @@ import { readFile, stat } from "node:fs/promises"; +import { join } from "node:path"; const variableNamePattern = /^[A-Za-z_][A-Za-z0-9_]*$/; @@ -112,3 +113,39 @@ export async function loadRuntimeEnvironment( } return parseRuntimeEnvironment(raw, path); } + +/** Path to an optional per-Profile `runtime.env` under the Profile directory. */ +export function profileRuntimeEnvironmentPath( + profilesDirectory: string, + profileId: string, +): string { + return join(profilesDirectory, profileId, "runtime.env"); +} + +/** + * Merge shared + Profile runtime.env for one Profile. + * Shared is the base; Profile keys override same-named shared keys. + * Either file may be absent (treated as `{}`). + */ +export async function loadMergedRuntimeEnvironment(options: { + sharedPath: string; + profilePath: string; +}): Promise { + const shared = await loadRuntimeEnvironment(options.sharedPath); + const profile = await loadRuntimeEnvironment(options.profilePath); + return { ...shared, ...profile }; +} + +/** + * Key names only (sorted) for Dashboard / API — never returns values. + * Uses the same merge order as {@link loadMergedRuntimeEnvironment}. + */ +export async function listMergedRuntimeEnvironmentKeys(options: { + sharedPath: string; + profilePath: string; +}): Promise { + const environment = await loadMergedRuntimeEnvironment(options); + return Object.keys(environment).sort((left, right) => + left.localeCompare(right), + ); +} diff --git a/services/daemon/src/dashboard/profiles.test.ts b/services/daemon/src/dashboard/profiles.test.ts index db31cbf..92b7829 100644 --- a/services/daemon/src/dashboard/profiles.test.ts +++ b/services/daemon/src/dashboard/profiles.test.ts @@ -1,5 +1,5 @@ import assert from "node:assert/strict"; -import { mkdir, mkdtemp, writeFile } from "node:fs/promises"; +import { chmod, mkdir, mkdtemp, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; import test from "node:test"; @@ -67,6 +67,20 @@ async function fixture(): Promise { }, }), ); + const sharedEnv = join(root, "runtime.env"); + await writeFile( + sharedEnv, + "SHARED_TOKEN=shared-runtime-value\nOVERLAP=from-shared\n", + { mode: 0o600 }, + ); + await chmod(sharedEnv, 0o600); + const profileEnv = join(profiles, "amr-release", "runtime.env"); + await writeFile( + profileEnv, + "PROFILE_TOKEN=profile-runtime-value\nOVERLAP=from-profile\n", + { mode: 0o600 }, + ); + await chmod(profileEnv, 0o600); return profiles; } @@ -109,10 +123,38 @@ test("returns profile detail with channel notify references and no secrets", asy assert.equal(detail.timeoutSeconds, null); assert.equal(detail.secrets.present, false); assert.match(detail.secrets.note, /secrets\.json/); + assert.deepEqual(detail.runtimeEnv.keys, [ + "OVERLAP", + "PROFILE_TOKEN", + "SHARED_TOKEN", + ]); const serialized = JSON.stringify(detail); assert.doesNotMatch(serialized, /super-secret-value/); assert.doesNotMatch(serialized, /cli_0123456789abcdef/); assert.doesNotMatch(serialized, /app_secret/); + assert.doesNotMatch(serialized, /shared-runtime-value/); + assert.doesNotMatch(serialized, /profile-runtime-value/); + assert.doesNotMatch(serialized, /from-shared/); + assert.doesNotMatch(serialized, /from-profile/); +}); + +test("profile detail runtimeEnv keys stay empty without runtime.env files", async () => { + const root = await mkdtemp(join(tmpdir(), "beacon-dashboard-no-env-")); + const profiles = join(root, "profiles"); + await mkdir(join(profiles, "solo"), { recursive: true }); + await writeFile( + join(profiles, "solo", "profile.yaml"), + [ + "playbook: /tmp/workspace", + "runtime: pi", + "model:", + " provider: deepseek", + " id: deepseek-flash", + "", + ].join("\n"), + ); + const detail = await getProfileDetailView(profiles, "solo"); + assert.deepEqual(detail?.runtimeEnv.keys, []); }); test("accepts optional max_concurrent, max_queued, and timeout_seconds from profile.yaml", async () => { diff --git a/services/daemon/src/dashboard/profiles.ts b/services/daemon/src/dashboard/profiles.ts index 8845624..9d2da00 100644 --- a/services/daemon/src/dashboard/profiles.ts +++ b/services/daemon/src/dashboard/profiles.ts @@ -18,6 +18,10 @@ import { join } from "node:path"; import { z } from "zod"; import { channelNamePattern } from "../config/channels.js"; +import { + listMergedRuntimeEnvironmentKeys, + profileRuntimeEnvironmentPath, +} from "../config/runtime-environment.js"; import { parseStrictYaml } from "../config/yaml.js"; const profileIdPattern = /^[a-z0-9](?:[a-z0-9_-]{0,62})$/; @@ -139,6 +143,7 @@ function toNotifyView( function toDetailView( profileId: string, document: z.infer, + runtimeEnvKeys: string[], ): ProfileDetailView { return { id: profileId, @@ -172,6 +177,7 @@ function toDetailView( present: false, note: "Feishu app credentials are stored in secrets.json and are not exposed by the dashboard.", }, + runtimeEnv: { keys: runtimeEnvKeys }, }; } @@ -245,6 +251,7 @@ export async function listProfileViews( export async function getProfileDetailView( profilesDirectory: string, profileId: string, + options?: { sharedRuntimeEnvironmentPath?: string | undefined }, ): Promise { if (!isProfileId(profileId)) return null; const directory = join(profilesDirectory, profileId); @@ -256,7 +263,14 @@ export async function getProfileDetailView( } try { const document = await readProfileYaml(profilesDirectory, profileId); - return toDetailView(profileId, document); + const sharedPath = + options?.sharedRuntimeEnvironmentPath ?? + join(profilesDirectory, "..", "runtime.env"); + const runtimeEnvKeys = await listMergedRuntimeEnvironmentKeys({ + sharedPath, + profilePath: profileRuntimeEnvironmentPath(profilesDirectory, profileId), + }); + return toDetailView(profileId, document, runtimeEnvKeys); } catch (error) { throw new Error( `Cannot load Profile ${profileId}: ${error instanceof Error ? error.message : String(error)}`, diff --git a/services/daemon/src/dashboard/server.test.ts b/services/daemon/src/dashboard/server.test.ts index 79deedd..28366c2 100644 --- a/services/daemon/src/dashboard/server.test.ts +++ b/services/daemon/src/dashboard/server.test.ts @@ -271,6 +271,16 @@ test("serves profile list and detail JSON without secrets", async () => { }, }), ); + const sharedEnv = join(profiles, "..", "runtime.env"); + await writeFile(sharedEnv, "DASH_SHARED=shared-api-secret\n", { + mode: 0o600, + }); + await chmod(sharedEnv, 0o600); + const profileEnv = join(profiles, "alpha", "runtime.env"); + await writeFile(profileEnv, "DASH_PROFILE=profile-api-secret\n", { + mode: 0o600, + }); + await chmod(profileEnv, 0o600); const server = await startDashboard({ listen: "127.0.0.1", port: 0, @@ -293,6 +303,8 @@ test("serves profile list and detail JSON without secrets", async () => { const detailText = await detail.text(); assert.doesNotMatch(detailText, /should-not-leak/); assert.doesNotMatch(detailText, /app_secret/); + assert.doesNotMatch(detailText, /shared-api-secret/); + assert.doesNotMatch(detailText, /profile-api-secret/); const detailBody = JSON.parse(detailText) as { profile: { id: string; @@ -304,6 +316,7 @@ test("serves profile list and detail JSON without secrets", async () => { notify: { kind: string; name?: string } | null; }>; secrets: { present: boolean }; + runtimeEnv: { keys: string[] }; }; }; assert.equal(detailBody.profile.id, "alpha"); @@ -317,6 +330,10 @@ test("serves profile list and detail JSON without secrets", async () => { "weekday-brief-group", ); assert.equal(detailBody.profile.secrets.present, false); + assert.deepEqual(detailBody.profile.runtimeEnv.keys, [ + "DASH_PROFILE", + "DASH_SHARED", + ]); const missing = await fetch(`${origin}/api/profiles/missing`); assert.equal(missing.status, 404); diff --git a/services/daemon/src/dashboard/server.ts b/services/daemon/src/dashboard/server.ts index e6e1494..088d6cd 100644 --- a/services/daemon/src/dashboard/server.ts +++ b/services/daemon/src/dashboard/server.ts @@ -108,6 +108,8 @@ export type DashboardOptions = { codingAgentDirectory?: string | undefined; /** Beacon `runtime.env` keys forwarded into `pi auth check`. */ runtimeEnvironment?: NodeJS.ProcessEnv | undefined; + /** Shared `~/.beacon/runtime.env` path for Profile detail key listing. */ + sharedRuntimeEnvironmentPath?: string | undefined; /** * When true (default), PUT model-allocation rejects conclusively not-ready * choices. Requires `codingAgentDirectory` so probes can run. @@ -399,6 +401,9 @@ export async function startDashboard( const profile = await getProfileDetailView( options.profilesDirectory, profileId, + { + sharedRuntimeEnvironmentPath: options.sharedRuntimeEnvironmentPath, + }, ); if (!profile) { sendText(response, 404, `Unknown profile ${profileId}`); diff --git a/services/daemon/src/doctor.ts b/services/daemon/src/doctor.ts index f475506..5e4a180 100644 --- a/services/daemon/src/doctor.ts +++ b/services/daemon/src/doctor.ts @@ -2,7 +2,10 @@ import { loadChannelRegistry } from "./config/channels.js"; import { loadEventCredentials } from "./config/event-credentials.js"; import { loadGlobalConfig } from "./config/global.js"; import { loadProfileRegistry } from "./config/registry.js"; -import { loadRuntimeEnvironment } from "./config/runtime-environment.js"; +import { + loadMergedRuntimeEnvironment, + profileRuntimeEnvironmentPath, +} from "./config/runtime-environment.js"; import { feishuWsListenerProfileIds, resolveFeishuCredentialBindings, @@ -13,9 +16,6 @@ import { runPiAgent } from "./runtime/pi-rpc.js"; export async function runDoctor(configPath: string): Promise { const global = await loadGlobalConfig(configPath); - const runtimeEnvironment = await loadRuntimeEnvironment( - global.runtimeEnvironmentPath, - ); const channels = await loadChannelRegistry(global.channelsPath); const profiles = await loadProfileRegistry( global.profilesDirectory, @@ -48,6 +48,13 @@ export async function runDoctor(configPath: string): Promise { await createFeishuGateway(binding.credentials).checkReady(); checkedAppIds.add(binding.credentials.appId); } + const runtimeEnvironment = await loadMergedRuntimeEnvironment({ + sharedPath: global.runtimeEnvironmentPath, + profilePath: profileRuntimeEnvironmentPath( + global.profilesDirectory, + profile.id, + ), + }); const result = await runPiAgent( { prompt: "Reply with exactly: BEACON_PI_RPC_OK", diff --git a/services/daemon/src/manual-trigger.ts b/services/daemon/src/manual-trigger.ts index 115b915..14cb6bc 100644 --- a/services/daemon/src/manual-trigger.ts +++ b/services/daemon/src/manual-trigger.ts @@ -2,7 +2,10 @@ import { randomUUID } from "node:crypto"; import { loadChannelRegistry } from "./config/channels.js"; import { loadGlobalConfig } from "./config/global.js"; import { loadProfileRegistry } from "./config/registry.js"; -import { loadRuntimeEnvironment } from "./config/runtime-environment.js"; +import { + loadMergedRuntimeEnvironment, + profileRuntimeEnvironmentPath, +} from "./config/runtime-environment.js"; import { renderDeliveryAsText } from "./outcome/content.js"; import { startOutcomeServer } from "./outcome/server.js"; import { createPiRunOrchestrator } from "./run/create-pi-orchestrator.js"; @@ -28,9 +31,6 @@ export async function runManualTrigger( ): Promise { if (!input.trim()) throw new Error("Manual Trigger input must not be empty"); const global = await loadGlobalConfig(configPath); - const runtimeEnvironment = await loadRuntimeEnvironment( - global.runtimeEnvironmentPath, - ); const channels = await loadChannelRegistry(global.channelsPath); const profiles = await loadProfileRegistry( global.profilesDirectory, @@ -39,6 +39,13 @@ export async function runManualTrigger( ); const profile = profiles.find((candidate) => candidate.id === profileId); if (!profile) throw new Error(`Unknown Profile: ${profileId}`); + const runtimeEnvironment = await loadMergedRuntimeEnvironment({ + sharedPath: global.runtimeEnvironmentPath, + profilePath: profileRuntimeEnvironmentPath( + global.profilesDirectory, + profile.id, + ), + }); const outcomes = await startOutcomeServer(); try { const store = new TriggerStore(profile.directory, profile.id); diff --git a/services/daemon/src/schedule-trigger.ts b/services/daemon/src/schedule-trigger.ts index 976e376..b60bc7b 100644 --- a/services/daemon/src/schedule-trigger.ts +++ b/services/daemon/src/schedule-trigger.ts @@ -3,7 +3,10 @@ import { loadChannelRegistry } from "./config/channels.js"; import { loadGlobalConfig } from "./config/global.js"; import { type Profile, profileAdminChatId } from "./config/profile.js"; import { loadProfileRegistry } from "./config/registry.js"; -import { loadRuntimeEnvironment } from "./config/runtime-environment.js"; +import { + loadMergedRuntimeEnvironment, + profileRuntimeEnvironmentPath, +} from "./config/runtime-environment.js"; import { loadFeishuCredentials } from "./config/secrets.js"; import type { TriggerRecord } from "./domain/types.js"; import { createFeishuGateway } from "./feishu/gateway.js"; @@ -97,9 +100,6 @@ export async function runScheduleTrigger( options: RuntimeOptions, ): Promise { const global = await loadGlobalConfig(configPath); - const runtimeEnvironment = await loadRuntimeEnvironment( - global.runtimeEnvironmentPath, - ); const channels = await loadChannelRegistry(global.channelsPath); const profiles = await loadProfileRegistry( global.profilesDirectory, @@ -109,6 +109,13 @@ export async function runScheduleTrigger( const profile = profiles.find((candidate) => candidate.id === profileId); if (!profile) throw new Error(`Unknown Profile: ${profileId}`); findSchedule(profile, scheduleId); + const runtimeEnvironment = await loadMergedRuntimeEnvironment({ + sharedPath: global.runtimeEnvironmentPath, + profilePath: profileRuntimeEnvironmentPath( + global.profilesDirectory, + profile.id, + ), + }); const credentials = await loadFeishuCredentials( profile.id, global.secretsPath, diff --git a/services/daemon/src/service.ts b/services/daemon/src/service.ts index 4847a73..3a3f67c 100644 --- a/services/daemon/src/service.ts +++ b/services/daemon/src/service.ts @@ -4,7 +4,11 @@ import { loadEventCredentials } from "./config/event-credentials.js"; import { loadGlobalConfig } from "./config/global.js"; import { loadProfile, patchProfileModelFields } from "./config/profile.js"; import { loadProfileRegistry } from "./config/registry.js"; -import { loadRuntimeEnvironment } from "./config/runtime-environment.js"; +import { + loadMergedRuntimeEnvironment, + loadRuntimeEnvironment, + profileRuntimeEnvironmentPath, +} from "./config/runtime-environment.js"; import { feishuWsListenerProfileIds, resolveFeishuCredentialBindings, @@ -114,6 +118,7 @@ export async function runBeacon( piExecutable: global.pi.executable, codingAgentDirectory: global.pi.codingAgentDirectory, runtimeEnvironment, + sharedRuntimeEnvironmentPath: global.runtimeEnvironmentPath, rejectUnreadyModels: global.dashboard.rejectUnreadyModels, reloadProfileModel: async (profileId) => { if (!modelReloadBinding.reload) return false; @@ -159,14 +164,29 @@ export async function runBeacon( }, } : undefined; - const contexts = profiles.map((profile, index) => { + const contexts: Array<{ + profile: (typeof profiles)[number]; + store: TriggerStore; + messagePipeline: ReturnType; + orchestrator: ReturnType; + reconciler: ScheduleReconciler; + binding: (typeof credentialBindings)[number]; + }> = []; + for (const [index, profile] of profiles.entries()) { const binding = credentialBindings[index]!; const gateway = createFeishuGateway(binding.credentials); const store = new TriggerStore(profile.directory, profile.id); + const profileRuntimeEnvironment = await loadMergedRuntimeEnvironment({ + sharedPath: global.runtimeEnvironmentPath, + profilePath: profileRuntimeEnvironmentPath( + global.profilesDirectory, + profile.id, + ), + }); const orchestrator = createPiRunOrchestrator({ beaconCliPath: options.beaconCliPath, config: global, - runtimeEnvironment, + runtimeEnvironment: profileRuntimeEnvironment, profile, store, queue, @@ -192,15 +212,15 @@ export async function runBeacon( }); const loop = new ScheduleLoop(profile, reconciler, rejectFatal); loops.push(loop); - return { + contexts.push({ profile, store, messagePipeline, orchestrator, reconciler, binding, - }; - }); + }); + } modelReloadBinding.reload = async (profileId) => { const context = contexts.find((entry) => entry.profile.id === profileId); From 19638c897572c071e5a24990ef05792ee37eff55 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 21 Nov 2026 10:56:18 +0000 Subject: [PATCH 2/2] ci: auto bump patch version --- apps/cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cli/package.json b/apps/cli/package.json index 17e1d31..f061d87 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -1,6 +1,6 @@ { "name": "@nettee/beacon", - "version": "0.8.19", + "version": "0.8.20", "description": "A single-host bridge from messaging and schedules to isolated agent runs", "license": "Apache-2.0", "repository": {