@amaster.ai/employee-runtime-connector 0.1.1-beta.263 → 0.1.1-beta.264

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/README.md CHANGED
@@ -95,21 +95,42 @@ It does not expose WorkBuddy experts, projects, Office integrations, marketplace
95
95
  connectors, or Pi's `final_model_context_attestation_v1`. The connector creates a
96
96
  private per-run CodeBuddy home, supplies one strict MirrorX MCP definition, uses an
97
97
  exact native-tool allowlist, and preserves only an authority-bound native session
98
- rollout. It never inherits the user's ordinary `.codebuddy` or WorkBuddy profile.
98
+ rollout. It never inherits the user's ordinary `.codebuddy` settings, memory,
99
+ projects, MCP servers, workflows, or marketplace state. When no dedicated provider
100
+ credential is configured, it reuses only the current OS user's WorkBuddy desktop
101
+ login through a bounded encrypted-file snapshot inside the private home. The
102
+ connector copies only the active authentication id's `workbuddy-desktop.info`
103
+ opaque encrypted bytes without decrypting, parsing, logging, or serializing token
104
+ fields. Locks, logout markers, and backups are coordination/history state rather
105
+ than authentication inputs and are not copied; any logout-marker directory entry,
106
+ including a dangling symlink, makes the desktop session unavailable. CodeBuddy can
107
+ mutate only the private snapshot.
99
108
 
100
109
  This executor is off by default. Enable discovery with
101
110
  `AMASTER_ENABLE_CODEBUDDY_EXECUTOR=true`. `AMASTER_CODEBUDDY_COMMAND` can select an
102
111
  explicit CLI; on macOS the gated discovery path can also find the CLI bundled in
103
112
  `/Applications/WorkBuddy.app`. The Server task-session snapshot owns the model for
104
113
  current commands; `AMASTER_CODEBUDDY_MODEL` is only a compatibility fallback for
105
- older commands without that snapshot. The daemon environment or a Server-issued
106
- command environment must provide exactly one of `CODEBUDDY_API_KEY` or
107
- `CODEBUDDY_AUTH_TOKEN`; ordinary host login state is not a credential source.
108
- Command-scoped values override same-name daemon values. Provider routing may additionally use the supported
114
+ older commands without that snapshot. Authentication resolves in two fail-closed
115
+ modes: exactly one explicitly configured `CODEBUDDY_API_KEY` or
116
+ `CODEBUDDY_AUTH_TOKEN` wins, otherwise the current OS user's WorkBuddy desktop login
117
+ must be present. Desktop login reuse validates the complete source path chain and
118
+ opens it with no-follow file descriptors before materializing the private snapshot;
119
+ all run configuration and native sessions stay isolated. The snapshot is currently
120
+ supported on macOS and Linux, including Linux `XDG_DATA_HOME`; Windows
121
+ continues to require an explicit provider credential until an ACL-equivalent safety
122
+ check exists. If command scope supplies either auth variable, that complete auth
123
+ scope overrides daemon auth; two methods in the selected scope fail closed. Provider routing may additionally use the supported
109
124
  `CODEBUDDY_INTERNET_ENVIRONMENT`, `CODEBUDDY_BASE_URL`, or proxy variables. Secret
110
125
  values remain run-scoped and must never be placed in arguments, logs, connector
111
126
  metadata, or committed configuration.
112
127
 
128
+ Heartbeat readiness is explicitly a fresh `daemon_default` diagnostic, not command
129
+ admission: a later command may supply its own complete auth scope. The source
130
+ metadata check intentionally runs on each heartbeat so logout and permission changes
131
+ are observed immediately; the measured local cost is about 0.03 ms per check, so it
132
+ is not cached.
133
+
113
134
  This is an intentional compatibility break for the not-yet-public context-governance contract. There is no historical command migration, dual-read, or fallback from a new Server-issued envelope to an unproved executor path.
114
135
 
115
136
  ## Contracted Pi model calls
@@ -10116,6 +10116,7 @@ var goalCriterionProgressReadModelSchema = external_exports.object({
10116
10116
  relatedDemands: external_exports.array(goalCriterionRelatedWorkSchema).max(20),
10117
10117
  relatedTasks: external_exports.array(goalCriterionRelatedWorkSchema).max(20),
10118
10118
  decisionRevision: external_exports.number().int().nonnegative().nullable(),
10119
+ attentionItemKey: external_exports.string().min(1).nullable().optional(),
10119
10120
  expectedDecisionToken: sha256Schema5.nullable(),
10120
10121
  snoozedUntil: external_exports.string().datetime().nullable()
10121
10122
  }).strict();
@@ -14537,6 +14538,11 @@ var inboxActionCountSchema = external_exports.discriminatedUnion("kind", [
14537
14538
  ])
14538
14539
  }).strict()
14539
14540
  ]);
14541
+ var inboxGoalAttentionSummarySchema = external_exports.object({
14542
+ attentionItemCount: external_exports.number().int().nonnegative(),
14543
+ count: inboxActionCountSchema,
14544
+ byGoalId: external_exports.record(external_exports.string().uuid(), external_exports.number().int().positive())
14545
+ }).strict();
14540
14546
  var inboxActionItemSchema = external_exports.object({
14541
14547
  itemKey: external_exports.string().min(1),
14542
14548
  itemRevision: external_exports.string().min(1),
@@ -14563,6 +14569,7 @@ var inboxActionItemSchema = external_exports.object({
14563
14569
  label: external_exports.string().min(1)
14564
14570
  }).strict(),
14565
14571
  resourceId: external_exports.string().min(1),
14572
+ goalId: external_exports.string().uuid().nullable().optional(),
14566
14573
  issueId: external_exports.string().uuid().nullable(),
14567
14574
  issueIdentifier: external_exports.string().nullable(),
14568
14575
  issueStatus: external_exports.string().nullable(),
@@ -14593,6 +14600,8 @@ var inboxActionItemsResponseSchema = external_exports.object({
14593
14600
  governance: external_exports.number().int().nonnegative()
14594
14601
  }).strict(),
14595
14602
  count: inboxActionCountSchema,
14603
+ goalAttention: inboxGoalAttentionSummarySchema.optional(),
14604
+ scopedItemKeys: external_exports.array(external_exports.string().min(1)).optional(),
14596
14605
  nextCursor: external_exports.string().min(1).nullable()
14597
14606
  }).strict();
14598
14607
 
@@ -18334,7 +18343,7 @@ var oriaRunnerDeliverySchema = external_exports.object({
18334
18343
 
18335
18344
  // src/amaster-runtime-daemon.mjs
18336
18345
  import { chmodSync as chmodSync9, copyFileSync as copyFileSync3, existsSync as existsSync19, lstatSync as lstatSync12, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync3, readFileSync as readFileSync20, readdirSync as readdirSync12, realpathSync as realpathSync11, renameSync as renameSync10, rmSync as rmSync11, statSync as statSync13, symlinkSync as symlinkSync2, unlinkSync as unlinkSync4, writeFileSync as writeFileSync13 } from "node:fs";
18337
- import { arch as arch4, homedir as homedir4, hostname as hostname2, platform as platform4, tmpdir } from "node:os";
18346
+ import { arch as arch4, homedir as homedir5, hostname as hostname2, platform as platform4, tmpdir } from "node:os";
18338
18347
  import { basename as basename10, delimiter as delimiter4, dirname as dirname13, extname as extname3, isAbsolute as isAbsolute13, join as join20, relative as relative9, resolve as resolve18 } from "node:path";
18339
18348
  import { spawn as spawn2, spawnSync as spawnSync5 } from "node:child_process";
18340
18349
 
@@ -19810,7 +19819,7 @@ function skipVoid(str, ptr, banNewLines, banComments) {
19810
19819
  }
19811
19820
  return ptr;
19812
19821
  }
19813
- function skipUntil(str, ptr, sep4, end, banNewLines = false) {
19822
+ function skipUntil(str, ptr, sep5, end, banNewLines = false) {
19814
19823
  if (!end) {
19815
19824
  ptr = indexOfNewline(str, ptr);
19816
19825
  return ptr < 0 ? str.length : ptr;
@@ -19819,7 +19828,7 @@ function skipUntil(str, ptr, sep4, end, banNewLines = false) {
19819
19828
  let c = str[i];
19820
19829
  if (c === "#") {
19821
19830
  i = indexOfNewline(str, i);
19822
- } else if (c === sep4) {
19831
+ } else if (c === sep5) {
19823
19832
  return i + 1;
19824
19833
  } else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
19825
19834
  return i;
@@ -21271,14 +21280,32 @@ function reconcileManagedCodexMcpProfiles(rootPath, options = {}) {
21271
21280
 
21272
21281
  // src/amaster-runtime-daemon/codebuddy-managed-mcp-profile.mjs
21273
21282
  import { createHash as createHash5 } from "node:crypto";
21274
- import { chmodSync as chmodSync6, existsSync as existsSync7, lstatSync as lstatSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync7, readdirSync as readdirSync3, realpathSync as realpathSync4, rmSync as rmSync5, statSync as statSync5, writeFileSync as writeFileSync6 } from "node:fs";
21275
- import { arch as arch2, platform as platform2 } from "node:os";
21276
- import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute5, join as join8, relative as relative3, resolve as resolve7 } from "node:path";
21283
+ import {
21284
+ chmodSync as chmodSync6,
21285
+ closeSync,
21286
+ constants as fsConstants,
21287
+ existsSync as existsSync7,
21288
+ fstatSync,
21289
+ lstatSync as lstatSync6,
21290
+ mkdirSync as mkdirSync4,
21291
+ openSync,
21292
+ readFileSync as readFileSync7,
21293
+ readdirSync as readdirSync3,
21294
+ realpathSync as realpathSync4,
21295
+ rmSync as rmSync5,
21296
+ statSync as statSync5,
21297
+ writeFileSync as writeFileSync6
21298
+ } from "node:fs";
21299
+ import { arch as arch2, homedir as homedir3, platform as platform2 } from "node:os";
21300
+ import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute5, join as join8, parse as parse2, relative as relative3, resolve as resolve7, sep as sep2 } from "node:path";
21277
21301
  var SUPPORTED_SCHEMA_VERSION2 = "amaster.governed-mcp.v1";
21278
21302
  var SUPPORTED_SERVER_NAME2 = "amaster";
21279
21303
  var PROFILE_MARKER2 = ".mirrorx-managed-codebuddy-profile.json";
21280
21304
  var SESSION_ROLLOUT_MARKER2 = ".mirrorx-codebuddy-session-rollout.json";
21281
21305
  var DEFAULT_SESSION_ROLLOUT_TTL_MS2 = 24 * 60 * 60 * 1e3;
21306
+ var CODEBUDDY_DESKTOP_AUTH_SOURCE = "workbuddy_desktop_session";
21307
+ var CODEBUDDY_WORKBUDDY_AUTH_FILE = "workbuddy-desktop.info";
21308
+ var MAX_CODEBUDDY_DESKTOP_AUTH_BYTES = 4 * 1024 * 1024;
21282
21309
  var CODEBUDDY_NATIVE_TOOLS = [
21283
21310
  "Bash",
21284
21311
  "Edit",
@@ -21369,6 +21396,187 @@ function within3(candidate, root) {
21369
21396
  const rel = relative3(root, candidate);
21370
21397
  return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
21371
21398
  }
21399
+ function codebuddyIsolatedAuthRelativePath(targetPlatform = platform2()) {
21400
+ if (targetPlatform === "darwin") {
21401
+ return join8("Library", "Application Support", "CodeBuddyExtension", "Data", "Public", "auth");
21402
+ }
21403
+ if (targetPlatform === "linux") {
21404
+ return join8(".local", "share", "CodeBuddyExtension", "Data", "Public", "auth");
21405
+ }
21406
+ throw new Error(`codebuddy_managed_mcp_desktop_auth_unsupported: platform ${targetPlatform} is not supported`);
21407
+ }
21408
+ function codebuddyDesktopAuthDirectory(sourceHome, sourceEnv, targetPlatform) {
21409
+ if (targetPlatform === "darwin") {
21410
+ return join8(sourceHome, codebuddyIsolatedAuthRelativePath(targetPlatform));
21411
+ }
21412
+ if (targetPlatform === "linux") {
21413
+ const xdgDataHome = typeof sourceEnv?.XDG_DATA_HOME === "string" ? sourceEnv.XDG_DATA_HOME.trim() : "";
21414
+ if (xdgDataHome) {
21415
+ if (!isAbsolute5(xdgDataHome)) {
21416
+ throw new Error("codebuddy_managed_mcp_desktop_auth_xdg_invalid: XDG_DATA_HOME must be absolute");
21417
+ }
21418
+ const resolvedXdgDataHome = resolve7(xdgDataHome);
21419
+ const canonicalXdgDataHome = existsSync7(resolvedXdgDataHome) ? realpathSync4(resolvedXdgDataHome) : resolvedXdgDataHome;
21420
+ return join8(canonicalXdgDataHome, "CodeBuddyExtension", "Data", "Public", "auth");
21421
+ }
21422
+ return join8(sourceHome, codebuddyIsolatedAuthRelativePath(targetPlatform));
21423
+ }
21424
+ throw new Error(`codebuddy_managed_mcp_desktop_auth_unsupported: platform ${targetPlatform} is not supported`);
21425
+ }
21426
+ function absolutePathChain(path) {
21427
+ const absolute = resolve7(path);
21428
+ const root = parse2(absolute).root;
21429
+ const components = relative3(root, absolute).split(sep2).filter(Boolean);
21430
+ const chain = [root];
21431
+ for (const component of components) chain.push(join8(chain.at(-1), component));
21432
+ return chain;
21433
+ }
21434
+ function sameFileIdentity(left, right) {
21435
+ return left.dev === right.dev && left.ino === right.ino;
21436
+ }
21437
+ function sameTrustedFileMetadata(left, right) {
21438
+ return sameFileIdentity(left, right) && left.uid === right.uid && (left.mode & 4095) === (right.mode & 4095);
21439
+ }
21440
+ function lstatIfPresent(path) {
21441
+ try {
21442
+ return lstatSync6(path);
21443
+ } catch (error) {
21444
+ if (error && typeof error === "object" && error.code === "ENOENT") return null;
21445
+ throw error;
21446
+ }
21447
+ }
21448
+ function inspectCodebuddyDesktopAuthDirectory(sourceHome = homedir3(), sourceEnv = process.env, targetPlatform = platform2()) {
21449
+ try {
21450
+ const resolvedSourceHome = realpathSync4(resolve7(nonEmpty2(sourceHome, "desktopHome")));
21451
+ const sourceAuthDir = codebuddyDesktopAuthDirectory(resolvedSourceHome, sourceEnv, targetPlatform);
21452
+ if (!lstatIfPresent(sourceAuthDir)) {
21453
+ return { available: false, source: CODEBUDDY_DESKTOP_AUTH_SOURCE, reasonCode: "desktop_auth_directory_missing" };
21454
+ }
21455
+ const sourceAuthFile = join8(sourceAuthDir, CODEBUDDY_WORKBUDDY_AUTH_FILE);
21456
+ if (!lstatIfPresent(sourceAuthFile)) {
21457
+ return { available: false, source: CODEBUDDY_DESKTOP_AUTH_SOURCE, reasonCode: "desktop_login_missing" };
21458
+ }
21459
+ if (lstatIfPresent(`${sourceAuthFile}.logged-out`)) {
21460
+ return { available: false, source: CODEBUDDY_DESKTOP_AUTH_SOURCE, reasonCode: "desktop_login_missing" };
21461
+ }
21462
+ const chain = absolutePathChain(sourceAuthFile);
21463
+ const currentUid = typeof process.getuid === "function" ? process.getuid() : null;
21464
+ const pathChain = [];
21465
+ for (const candidate of chain) {
21466
+ const candidateStat = lstatSync6(candidate);
21467
+ const isAuthFile = candidate === sourceAuthFile;
21468
+ const isAuthDir = candidate === sourceAuthDir;
21469
+ if (candidateStat.isSymbolicLink() || (isAuthFile ? !candidateStat.isFile() : !candidateStat.isDirectory())) {
21470
+ return {
21471
+ available: false,
21472
+ source: CODEBUDDY_DESKTOP_AUTH_SOURCE,
21473
+ reasonCode: isAuthFile ? "desktop_auth_file_unsafe" : isAuthDir ? "desktop_auth_directory_unsafe" : "desktop_auth_ancestor_unsafe"
21474
+ };
21475
+ }
21476
+ const ownerAllowed = currentUid === null || candidateStat.uid === currentUid || !isAuthFile && !isAuthDir && candidateStat.uid === 0;
21477
+ if (!ownerAllowed) {
21478
+ return {
21479
+ available: false,
21480
+ source: CODEBUDDY_DESKTOP_AUTH_SOURCE,
21481
+ reasonCode: isAuthFile ? "desktop_auth_file_owner_mismatch" : isAuthDir ? "desktop_auth_owner_mismatch" : "desktop_auth_ancestor_owner_mismatch"
21482
+ };
21483
+ }
21484
+ const stickyRootOwnedDirectory = !isAuthFile && !isAuthDir && candidateStat.uid === 0 && (candidateStat.mode & 512) !== 0;
21485
+ if ((candidateStat.mode & 18) !== 0 && !stickyRootOwnedDirectory) {
21486
+ return {
21487
+ available: false,
21488
+ source: CODEBUDDY_DESKTOP_AUTH_SOURCE,
21489
+ reasonCode: isAuthFile ? "desktop_auth_file_writable_by_others" : isAuthDir ? "desktop_auth_directory_writable_by_others" : "desktop_auth_ancestor_writable_by_others"
21490
+ };
21491
+ }
21492
+ pathChain.push({ path: candidate, stat: candidateStat });
21493
+ }
21494
+ const sourceAuthFileStat = pathChain.at(-1).stat;
21495
+ if (sourceAuthFileStat.size <= 0 || sourceAuthFileStat.size > MAX_CODEBUDDY_DESKTOP_AUTH_BYTES) {
21496
+ return { available: false, source: CODEBUDDY_DESKTOP_AUTH_SOURCE, reasonCode: "desktop_auth_file_size_invalid" };
21497
+ }
21498
+ return {
21499
+ available: true,
21500
+ source: CODEBUDDY_DESKTOP_AUTH_SOURCE,
21501
+ sourceAuthDir,
21502
+ sourceAuthFile,
21503
+ pathChain,
21504
+ authFileCount: 1
21505
+ };
21506
+ } catch (error) {
21507
+ return {
21508
+ available: false,
21509
+ source: CODEBUDDY_DESKTOP_AUTH_SOURCE,
21510
+ reasonCode: error instanceof Error ? error.message.startsWith("codebuddy_managed_mcp_desktop_auth_unsupported:") ? "desktop_auth_platform_unsupported" : error.message.startsWith("codebuddy_managed_mcp_desktop_auth_xdg_invalid:") ? "desktop_auth_xdg_data_home_invalid" : "desktop_auth_inspection_failed" : "desktop_auth_inspection_failed"
21511
+ };
21512
+ }
21513
+ }
21514
+ function inspectCodebuddyDesktopAuthReadiness(sourceHome = homedir3(), sourceEnv = process.env, targetPlatform = platform2()) {
21515
+ const inspected = inspectCodebuddyDesktopAuthDirectory(sourceHome, sourceEnv, targetPlatform);
21516
+ return {
21517
+ available: inspected.available,
21518
+ source: inspected.source,
21519
+ ...inspected.available ? { authFileCount: inspected.authFileCount } : { reasonCode: inspected.reasonCode }
21520
+ };
21521
+ }
21522
+ function snapshotCodebuddyDesktopAuth(sourceHome, sourceEnv, isolatedHome) {
21523
+ const inspected = inspectCodebuddyDesktopAuthDirectory(sourceHome, sourceEnv);
21524
+ if (!inspected.available) {
21525
+ throw new Error(
21526
+ `codebuddy_managed_mcp_desktop_auth_missing: ${inspected.reasonCode}; sign in to WorkBuddy Desktop or configure exactly one of CODEBUDDY_API_KEY and CODEBUDDY_AUTH_TOKEN`
21527
+ );
21528
+ }
21529
+ const openDescriptors = [];
21530
+ let authSnapshot = null;
21531
+ try {
21532
+ for (const [index, entry] of inspected.pathChain.entries()) {
21533
+ const isAuthFile = index === inspected.pathChain.length - 1;
21534
+ const flags = fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW | (isAuthFile ? 0 : fsConstants.O_DIRECTORY);
21535
+ const fd = openSync(entry.path, flags);
21536
+ openDescriptors.push(fd);
21537
+ const openedStat = fstatSync(fd);
21538
+ if (!sameTrustedFileMetadata(openedStat, entry.stat)) {
21539
+ throw new Error("codebuddy_managed_mcp_desktop_auth_changed: source path changed during validation");
21540
+ }
21541
+ if (isAuthFile) {
21542
+ if (!openedStat.isFile() || openedStat.size <= 0 || openedStat.size > MAX_CODEBUDDY_DESKTOP_AUTH_BYTES) {
21543
+ throw new Error("codebuddy_managed_mcp_desktop_auth_unsafe: source auth file is invalid");
21544
+ }
21545
+ authSnapshot = readFileSync7(fd);
21546
+ const afterReadStat = fstatSync(fd);
21547
+ if (!sameTrustedFileMetadata(openedStat, afterReadStat) || openedStat.size !== afterReadStat.size || openedStat.mtimeMs !== afterReadStat.mtimeMs || authSnapshot.length !== openedStat.size) {
21548
+ throw new Error("codebuddy_managed_mcp_desktop_auth_changed: source auth file changed during snapshot");
21549
+ }
21550
+ }
21551
+ }
21552
+ for (const entry of inspected.pathChain) {
21553
+ const currentStat = lstatSync6(entry.path);
21554
+ if (currentStat.isSymbolicLink() || !sameTrustedFileMetadata(currentStat, entry.stat)) {
21555
+ throw new Error("codebuddy_managed_mcp_desktop_auth_changed: source path changed during snapshot");
21556
+ }
21557
+ }
21558
+ if (lstatIfPresent(`${inspected.sourceAuthFile}.logged-out`)) {
21559
+ throw new Error("codebuddy_managed_mcp_desktop_auth_changed: desktop session logged out during snapshot");
21560
+ }
21561
+ const targetAuthDir = join8(isolatedHome, codebuddyIsolatedAuthRelativePath());
21562
+ privateDir(targetAuthDir);
21563
+ const targetAuthFile = join8(targetAuthDir, CODEBUDDY_WORKBUDDY_AUTH_FILE);
21564
+ privateFile(targetAuthFile, authSnapshot);
21565
+ return {
21566
+ authMode: CODEBUDDY_DESKTOP_AUTH_SOURCE,
21567
+ targetAuthDir,
21568
+ targetAuthFile
21569
+ };
21570
+ } finally {
21571
+ if (authSnapshot) authSnapshot.fill(0);
21572
+ for (const fd of openDescriptors.reverse()) {
21573
+ try {
21574
+ closeSync(fd);
21575
+ } catch {
21576
+ }
21577
+ }
21578
+ }
21579
+ }
21372
21580
  function findCodebuddySession(configDir, sessionId) {
21373
21581
  const projectsRoot = join8(configDir, "projects");
21374
21582
  if (!existsSync7(projectsRoot)) {
@@ -21460,16 +21668,56 @@ function buildIsolatedEnvironment2(baseEnv, commandEnv) {
21460
21668
  }
21461
21669
  return env;
21462
21670
  }
21671
+ function codebuddyAuthSelection(baseEnv, commandEnv) {
21672
+ const scopes = [
21673
+ { name: "command_env", value: record5(commandEnv) },
21674
+ { name: "daemon_env", value: record5(baseEnv) }
21675
+ ];
21676
+ for (const scope of scopes) {
21677
+ const apiKey = typeof scope.value.CODEBUDDY_API_KEY === "string" ? scope.value.CODEBUDDY_API_KEY.trim() : "";
21678
+ const authToken = typeof scope.value.CODEBUDDY_AUTH_TOKEN === "string" ? scope.value.CODEBUDDY_AUTH_TOKEN.trim() : "";
21679
+ if (!apiKey && !authToken) continue;
21680
+ const sources = [
21681
+ ...apiKey ? ["CODEBUDDY_API_KEY"] : [],
21682
+ ...authToken ? ["CODEBUDDY_AUTH_TOKEN"] : []
21683
+ ];
21684
+ return {
21685
+ scope: scope.name,
21686
+ apiKey,
21687
+ authToken,
21688
+ sources,
21689
+ conflict: sources.length > 1,
21690
+ authMode: apiKey && !authToken ? "api_key" : authToken && !apiKey ? "oauth_token" : null
21691
+ };
21692
+ }
21693
+ return {
21694
+ scope: null,
21695
+ apiKey: "",
21696
+ authToken: "",
21697
+ sources: [],
21698
+ conflict: false,
21699
+ authMode: null
21700
+ };
21701
+ }
21702
+ function inspectCodebuddyProviderAuthReadiness(baseEnv = process.env, commandEnv = {}) {
21703
+ const selected = codebuddyAuthSelection(baseEnv, commandEnv);
21704
+ return {
21705
+ present: selected.sources.length > 0,
21706
+ conflict: selected.conflict,
21707
+ ...selected.sources.length > 0 ? { sources: selected.sources, scope: selected.scope } : {},
21708
+ ...selected.authMode ? { authMode: selected.authMode } : {}
21709
+ };
21710
+ }
21463
21711
  function codebuddyProviderEnvironment(baseEnv, commandEnv) {
21464
21712
  const source = { ...record5(baseEnv), ...record5(commandEnv) };
21465
- const apiKey = typeof source.CODEBUDDY_API_KEY === "string" ? source.CODEBUDDY_API_KEY.trim() : "";
21466
- const authToken = typeof source.CODEBUDDY_AUTH_TOKEN === "string" ? source.CODEBUDDY_AUTH_TOKEN.trim() : "";
21467
- if (!apiKey && !authToken) {
21468
- throw new Error("codebuddy_managed_mcp_auth_missing: configure CODEBUDDY_API_KEY or CODEBUDDY_AUTH_TOKEN in the agent runtime environment");
21469
- }
21470
- if (apiKey && authToken) {
21713
+ const selectedAuth = codebuddyAuthSelection(baseEnv, commandEnv);
21714
+ if (selectedAuth.conflict) {
21471
21715
  throw new Error("codebuddy_managed_mcp_auth_conflict: configure only one CodeBuddy authentication method");
21472
21716
  }
21717
+ delete source.CODEBUDDY_API_KEY;
21718
+ delete source.CODEBUDDY_AUTH_TOKEN;
21719
+ if (selectedAuth.apiKey) source.CODEBUDDY_API_KEY = selectedAuth.apiKey;
21720
+ if (selectedAuth.authToken) source.CODEBUDDY_AUTH_TOKEN = selectedAuth.authToken;
21473
21721
  const env = {};
21474
21722
  for (const [key, value] of Object.entries(source)) {
21475
21723
  if (!CODEBUDDY_PROVIDER_ENV.has(key) || typeof value !== "string" || value.trim() === "") continue;
@@ -21478,8 +21726,8 @@ function codebuddyProviderEnvironment(baseEnv, commandEnv) {
21478
21726
  return {
21479
21727
  env,
21480
21728
  protectedValues: [...new Set([
21481
- apiKey,
21482
- authToken,
21729
+ selectedAuth.apiKey,
21730
+ selectedAuth.authToken,
21483
21731
  source.CODEBUDDY_BASE_URL,
21484
21732
  source.HTTP_PROXY,
21485
21733
  source.HTTPS_PROXY,
@@ -21488,7 +21736,8 @@ function codebuddyProviderEnvironment(baseEnv, commandEnv) {
21488
21736
  source.https_proxy,
21489
21737
  source.all_proxy
21490
21738
  ].filter((value) => typeof value === "string" && value.trim() !== ""))],
21491
- authMode: apiKey ? "api_key" : "oauth_token"
21739
+ authMode: selectedAuth.authMode,
21740
+ authScope: selectedAuth.scope
21492
21741
  };
21493
21742
  }
21494
21743
  function validateAuthority2(input) {
@@ -21583,10 +21832,12 @@ function prepareManagedCodebuddyMcpProfile(input) {
21583
21832
  }, null, 2)}
21584
21833
  `);
21585
21834
  const provider = codebuddyProviderEnvironment(input.baseEnv, input.commandEnv);
21835
+ const desktopAuthSnapshot = provider.authMode ? null : snapshotCodebuddyDesktopAuth(input.desktopHome ?? homedir3(), input.desktopEnv ?? process.env, home);
21586
21836
  const env = {
21587
21837
  ...buildIsolatedEnvironment2(input.baseEnv, input.commandEnv),
21588
21838
  ...provider.env,
21589
21839
  HOME: home,
21840
+ ...platform2() === "win32" ? { USERPROFILE: home } : {},
21590
21841
  TMPDIR: tmp,
21591
21842
  CODEBUDDY_CONFIG_DIR: configDir,
21592
21843
  CODEBUDDY_DISABLE_MEMORY: "true",
@@ -21646,8 +21897,15 @@ function prepareManagedCodebuddyMcpProfile(input) {
21646
21897
  ...attestationFacts,
21647
21898
  attestationId: createHash5("sha256").update(JSON.stringify(attestationFacts)).digest("hex"),
21648
21899
  attestedAt: (/* @__PURE__ */ new Date()).toISOString(),
21649
- authMode: provider.authMode
21650
- }
21900
+ authMode: provider.authMode ?? desktopAuthSnapshot.authMode,
21901
+ authScope: provider.authScope ?? "desktop_os_user",
21902
+ authIsolation: desktopAuthSnapshot ? "isolated_home_desktop_auth_snapshot" : "isolated_home_provider_env"
21903
+ },
21904
+ desktopAuthSnapshot: desktopAuthSnapshot ? {
21905
+ source: CODEBUDDY_DESKTOP_AUTH_SOURCE,
21906
+ targetAuthDir: desktopAuthSnapshot.targetAuthDir,
21907
+ targetAuthFile: desktopAuthSnapshot.targetAuthFile
21908
+ } : null
21651
21909
  };
21652
21910
  } catch (error) {
21653
21911
  rmSync5(profileRoot, { recursive: true, force: true });
@@ -21821,7 +22079,7 @@ import {
21821
22079
  writeFileSync as writeFileSync7
21822
22080
  } from "node:fs";
21823
22081
  import { arch as arch3, platform as platform3 } from "node:os";
21824
- import { basename as basename5, delimiter as delimiter3, dirname as dirname7, isAbsolute as isAbsolute6, join as join10, relative as relative4, resolve as resolve9, sep as sep2 } from "node:path";
22082
+ import { basename as basename5, delimiter as delimiter3, dirname as dirname7, isAbsolute as isAbsolute6, join as join10, relative as relative4, resolve as resolve9, sep as sep3 } from "node:path";
21825
22083
  import { spawnSync as spawnSync3 } from "node:child_process";
21826
22084
 
21827
22085
  // src/amaster-runtime-daemon/pi-mcp-adapter-config.mjs
@@ -22927,7 +23185,7 @@ function createManagedPiMcpProfileApi(options = {}) {
22927
23185
  const current = pending.pop();
22928
23186
  const currentStat = lstatSync8(current);
22929
23187
  if (currentStat.isSymbolicLink()) throw new Error(`pi_managed_mcp_bootstrap_cache_unsafe: ${current}`);
22930
- const relativePath = relative4(root, current).split(sep2).join("/");
23188
+ const relativePath = relative4(root, current).split(sep3).join("/");
22931
23189
  if (currentStat.isDirectory()) {
22932
23190
  hash.update(`d:${relativePath}
22933
23191
  `);
@@ -23699,7 +23957,7 @@ function createManagedPiMcpProfileApi(options = {}) {
23699
23957
  const directory = pending.pop();
23700
23958
  for (const child of readdirSync4(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
23701
23959
  const candidate = join10(directory, child.name);
23702
- const relativePath = relative4(root, candidate).split(sep2).join("/");
23960
+ const relativePath = relative4(root, candidate).split(sep3).join("/");
23703
23961
  const stat = lstatSync8(candidate);
23704
23962
  if (stat.isSymbolicLink()) throw new Error("pi_managed_mcp_company_skill_existing_source_unsafe");
23705
23963
  if (stat.isDirectory()) {
@@ -29974,10 +30232,6 @@ function fixedRules(input, includeIssueLine, runContract = "producer") {
29974
30232
  function compileConversationPrompt(input, context, maxChars) {
29975
30233
  const mode = promptContextMode(input);
29976
30234
  const taskText = readString(input.taskMarkdown) ?? "";
29977
- const wakeBodies = commentBodies(context);
29978
- const commentsDuplicatedByTask = !Array.isArray(context.paperclipTaskMarkdownCommentIds) && taskText && wakeBodies.length > 0 && wakeBodies.every((body) => taskText.includes(body));
29979
- const commentsSelected = mode !== "cold" || !commentsDuplicatedByTask;
29980
- const comments = commentsSelected ? readString(input.comments) ?? "" : "";
29981
30235
  const contextScope = {
29982
30236
  companyId: readString(asRecord(context.paperclipCompany).id),
29983
30237
  issueId: input.issueId ?? null
@@ -29989,8 +30243,11 @@ function compileConversationPrompt(input, context, maxChars) {
29989
30243
  `- workspace: ${input.cwd}`,
29990
30244
  input.managed ? `- source workspace: ${input.sourceWorkspacePath}` : ""
29991
30245
  ].filter(Boolean).join("\n");
30246
+ const wakeComments = asRecord(context.paperclipWake).comments;
30247
+ const latestWakeMessage = Array.isArray(wakeComments) ? [...wakeComments].reverse().map((comment) => readString(asRecord(comment).body)).find(Boolean) : null;
30248
+ const userPrompt = latestWakeMessage ?? readString(asRecord(context.paperclipWakeComment).body) ?? readString(asRecord(context.paperclipIssue).description);
30249
+ if (!userPrompt) throw new Error("conversation_user_message_missing");
29992
30250
  const rawSections = [
29993
- { name: "wake_comments", title: "Latest Message", priority: 95, sourceRef: commentRefs(context).map((id) => `comment:${id}`), originalContent: readString(input.comments) ?? "", content: comments, truncationReason: commentsSelected ? null : "duplicate_task_context" },
29994
30251
  { name: "task", title: "Conversation History", priority: 90, sourceRef: "conversation", originalContent: taskText, content: mode === "cold" ? taskText : "", truncationReason: mode === "cold" ? null : "mode_selection" },
29995
30252
  { name: "runtime_safety", title: "Runtime Safety", priority: 100, sourceRef: `command:${input.commandId}`, content: runtimeSafety },
29996
30253
  ...piGovernedTools ? [{ name: "pi_governed_tools", title: "Pi Governed Tools", priority: 96, sourceRef: "amaster_governed_mcp_direct_typed_contract", content: piGovernedTools }] : [],
@@ -30002,16 +30259,24 @@ function compileConversationPrompt(input, context, maxChars) {
30002
30259
  section.scope ??= contextScope;
30003
30260
  section.freshness ??= { kind: "run_snapshot" };
30004
30261
  }
30262
+ const systemPromptBudget = maxChars === null ? null : Math.max(0, maxChars - userPrompt.length);
30005
30263
  const compiled = compilePreparedSections({
30006
30264
  rawSections,
30007
30265
  mode,
30008
- maxChars,
30266
+ maxChars: systemPromptBudget,
30009
30267
  governedReadProvenance: [],
30010
30268
  resolvedDependencyTupleCount: 0
30011
30269
  });
30012
30270
  compiled.manifest.runContract = "producer";
30013
30271
  compiled.manifest.continuationPromptContract = { capability: null, mode: "legacy_server_owned_in_progress" };
30014
- return compiled;
30272
+ const usedChars = userPrompt.length + compiled.prompt.length;
30273
+ compiled.manifest.budget = {
30274
+ ...compiled.manifest.budget,
30275
+ totalChars: maxChars,
30276
+ usedChars,
30277
+ utilization: maxChars === null ? null : (usedChars / maxChars).toFixed(4)
30278
+ };
30279
+ return { prompt: userPrompt, systemPrompt: compiled.prompt, manifest: compiled.manifest };
30015
30280
  }
30016
30281
  function approvalContinuationText(input) {
30017
30282
  if (asRecord(input.nativeSession).mode !== "governed_action_approval") return "";
@@ -31275,7 +31540,7 @@ function pathWithin(candidate, root) {
31275
31540
  const rel = relative5(root, candidate);
31276
31541
  return rel === "" || !rel.startsWith("..") && !isAbsolute8(rel);
31277
31542
  }
31278
- function lstatIfPresent(path) {
31543
+ function lstatIfPresent2(path) {
31279
31544
  try {
31280
31545
  return lstatSync9(path);
31281
31546
  } catch (error) {
@@ -31296,7 +31561,7 @@ function isManagedExecutionDirectory(directory, managedWorkspacesRoot) {
31296
31561
  const candidate = canonicalExistingPath(directory);
31297
31562
  if (!pathWithin(candidate, managedRoot)) return false;
31298
31563
  const manifestPath = join13(candidate, WORKSPACE_MANIFEST_FILENAME);
31299
- const manifestStat = lstatIfPresent(manifestPath);
31564
+ const manifestStat = lstatIfPresent2(manifestPath);
31300
31565
  if (!manifestStat?.isFile() || manifestStat.isSymbolicLink()) return false;
31301
31566
  try {
31302
31567
  const manifest = JSON.parse(readFileSync14(manifestPath, "utf8"));
@@ -31497,7 +31762,7 @@ function projectExternalWorkspaceProjectInstructions(sourceWorkspacePath, execut
31497
31762
  let modelFacingSha256 = null;
31498
31763
  if (selectedSources.length > 0) {
31499
31764
  const targetPath = resolve10(targetRoot, "AGENTS.md");
31500
- const targetStat = lstatIfPresent(targetPath);
31765
+ const targetStat = lstatIfPresent2(targetPath);
31501
31766
  if (!pathWithin(targetPath, targetRoot) || targetStat?.isSymbolicLink()) {
31502
31767
  throw instructionTopologyError(
31503
31768
  "workspace_project_instruction_projection_unsafe",
@@ -31583,8 +31848,8 @@ function agentInstructionDeliveryAudit(bundle, delivery) {
31583
31848
 
31584
31849
  // src/amaster-runtime-daemon/config-state.mjs
31585
31850
  import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync15, renameSync as renameSync8, rmSync as rmSync9, writeFileSync as writeFileSync11 } from "node:fs";
31586
- import { homedir as homedir3, hostname } from "node:os";
31587
- import { dirname as dirname10, join as join14, parse as parse2, resolve as resolve11 } from "node:path";
31851
+ import { homedir as homedir4, hostname } from "node:os";
31852
+ import { dirname as dirname10, join as join14, parse as parse3, resolve as resolve11 } from "node:path";
31588
31853
 
31589
31854
  // src/amaster-runtime-daemon/capability-registry.mjs
31590
31855
  var BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
@@ -31696,13 +31961,13 @@ function defaultMachineId() {
31696
31961
  }
31697
31962
  function runtimeHome(env) {
31698
31963
  return expandHomePath(String(
31699
- env.AMASTER_RUNTIME_STATE_HOME || env.AMASTER_RUNTIME_HOME || join14(homedir3(), ".amaster-employee")
31964
+ env.AMASTER_RUNTIME_STATE_HOME || env.AMASTER_RUNTIME_HOME || join14(homedir4(), ".amaster-employee")
31700
31965
  ));
31701
31966
  }
31702
31967
  function runtimeTemplatesRoot(env, home) {
31703
31968
  const configured = String(env.AMASTER_RUNTIME_TEMPLATES_ROOT ?? "").trim();
31704
31969
  const resolved = configured ? resolve11(expandHomePath(configured)) : resolve11(String(env.PI_CODING_AGENT_DIR ?? "")) === "/data/.pi" ? "/data/templates" : resolve11(join14(home, "templates"));
31705
- if (resolved === parse2(resolved).root) {
31970
+ if (resolved === parse3(resolved).root) {
31706
31971
  throw new Error("AMASTER_RUNTIME_TEMPLATES_ROOT must not be a filesystem root");
31707
31972
  }
31708
31973
  return resolved;
@@ -32162,7 +32427,7 @@ function createBrowserCredentialChannel({ consume }) {
32162
32427
 
32163
32428
  // src/amaster-runtime-daemon/runtime-artifact-upload.mjs
32164
32429
  import { createHash as createHash13 } from "node:crypto";
32165
- import { closeSync, constants, fstatSync, lstatSync as lstatSync10, openSync, readFileSync as readFileSync16, realpathSync as realpathSync9 } from "node:fs";
32430
+ import { closeSync as closeSync2, constants, fstatSync as fstatSync2, lstatSync as lstatSync10, openSync as openSync2, readFileSync as readFileSync16, realpathSync as realpathSync9 } from "node:fs";
32166
32431
  import { isAbsolute as isAbsolute9, relative as relative6, resolve as resolve12 } from "node:path";
32167
32432
  var SHA256_PATTERN = /^[a-f0-9]{64}$/;
32168
32433
  function requiredString2(value, name) {
@@ -32190,9 +32455,9 @@ function readOwnedWorkspaceFile(rootPath, sourceRelativePath, label = "Runtime w
32190
32455
  throw new Error(`${label} source is not an owned regular file`);
32191
32456
  }
32192
32457
  const noFollow = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
32193
- const descriptor = openSync(sourcePath, constants.O_RDONLY | noFollow);
32458
+ const descriptor = openSync2(sourcePath, constants.O_RDONLY | noFollow);
32194
32459
  try {
32195
- const before = fstatSync(descriptor);
32460
+ const before = fstatSync2(descriptor);
32196
32461
  if (!before.isFile() || !sameFileSnapshot(pathStat, before)) {
32197
32462
  throw new Error(`${label} source changed before the governed read`);
32198
32463
  }
@@ -32216,14 +32481,14 @@ function readOwnedWorkspaceFile(rootPath, sourceRelativePath, label = "Runtime w
32216
32481
  }
32217
32482
  const body = readFileSync16(descriptor);
32218
32483
  options.afterRead?.({ sourcePath, descriptor });
32219
- const after = fstatSync(descriptor);
32484
+ const after = fstatSync2(descriptor);
32220
32485
  const pathAfter = lstatSync10(sourcePath);
32221
32486
  if (!sameFileSnapshot(before, after) || !sameFileSnapshot(pathAfter, after) || !pathAfter.isFile() || pathAfter.isSymbolicLink() || !pathWithin2(realpathSync9(sourcePath), root) || body.length !== after.size) {
32222
32487
  throw new Error(`${label} source changed during the governed read`);
32223
32488
  }
32224
32489
  return { body, relativePath, stat: after };
32225
32490
  } finally {
32226
- closeSync(descriptor);
32491
+ closeSync2(descriptor);
32227
32492
  }
32228
32493
  }
32229
32494
  function prepareRuntimeArtifactUploads(cwd, mcpToolResults) {
@@ -32782,7 +33047,7 @@ import {
32782
33047
  unlinkSync as unlinkSync3,
32783
33048
  writeFileSync as writeFileSync12
32784
33049
  } from "node:fs";
32785
- import { dirname as dirname11, extname, isAbsolute as isAbsolute11, join as join17, parse as parse3, resolve as resolve15, sep as sep3 } from "node:path";
33050
+ import { dirname as dirname11, extname, isAbsolute as isAbsolute11, join as join17, parse as parse4, resolve as resolve15, sep as sep4 } from "node:path";
32786
33051
  import { fileURLToPath } from "node:url";
32787
33052
  var PRESET_TEMPLATE_MANIFEST_FILE = ".mirrorx-preset-templates.json";
32788
33053
  var MAX_PRESET_TEMPLATE_FILES = 256;
@@ -32838,7 +33103,7 @@ function hasAllowedTemplateExtension(name) {
32838
33103
  return ALLOWED_TEMPLATE_EXTENSIONS.has(extname(name).toLowerCase());
32839
33104
  }
32840
33105
  function validTemplateName(value) {
32841
- return typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !value.includes("\0") && !value.includes("/") && !value.includes("\\") && !isAbsolute11(value) && parse3(value).base === value && hasAllowedTemplateExtension(value);
33106
+ return typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !value.includes("\0") && !value.includes("/") && !value.includes("\\") && !isAbsolute11(value) && parse4(value).base === value && hasAllowedTemplateExtension(value);
32842
33107
  }
32843
33108
  function readManifest(manifestPath, { strict }) {
32844
33109
  try {
@@ -32897,7 +33162,7 @@ function removeRetiredPresetFiles(targetDir, previousManifest, nextNames) {
32897
33162
  function materializeBundledPresetTemplates(input) {
32898
33163
  const sourceDir = resolve15(input.sourceDir);
32899
33164
  const targetDir = resolve15(input.targetDir);
32900
- if (sourceDir === targetDir || sourceDir.startsWith(`${targetDir}${sep3}`) || targetDir.startsWith(`${sourceDir}${sep3}`)) {
33165
+ if (sourceDir === targetDir || sourceDir.startsWith(`${targetDir}${sep4}`) || targetDir.startsWith(`${sourceDir}${sep4}`)) {
32901
33166
  throw new Error("preset_template_source_target_overlap");
32902
33167
  }
32903
33168
  const manifest = readManifest(join17(sourceDir, PRESET_TEMPLATE_MANIFEST_FILE), { strict: true });
@@ -33745,7 +34010,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
33745
34010
  }
33746
34011
 
33747
34012
  // src/amaster-runtime-daemon.mjs
33748
- var CONNECTOR_VERSION = "0.1.1-beta.263";
34013
+ var CONNECTOR_VERSION = "0.1.1-beta.264";
33749
34014
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
33750
34015
  var daemonRequire = createRequire2(import.meta.url);
33751
34016
  var MAX_CHECKPOINT_BYTES = 20 * 1024 * 1024;
@@ -34059,7 +34324,7 @@ function objectKeyCount(value) {
34059
34324
  return value && typeof value === "object" && !Array.isArray(value) ? Object.keys(value).length : 0;
34060
34325
  }
34061
34326
  function defaultPiCodingAgentDir() {
34062
- return join20(homedir4(), ".pi", "agent");
34327
+ return join20(homedir5(), ".pi", "agent");
34063
34328
  }
34064
34329
  function piCapabilitySourcesDiagnostics() {
34065
34330
  const configuredPiCodingAgentDir = safeExpandPath(process.env.PI_CODING_AGENT_DIR);
@@ -34189,18 +34454,30 @@ function executorReadinessFor(config, executor, piFinalContextAttestation) {
34189
34454
  };
34190
34455
  }
34191
34456
  if (executor.kind === "codebuddy") {
34457
+ const providerAuthEnv = inspectCodebuddyProviderAuthReadiness(process.env);
34458
+ const providerAuthConflict = providerAuthEnv.conflict;
34459
+ const desktopSession = inspectCodebuddyDesktopAuthReadiness();
34192
34460
  return {
34193
34461
  ...entry,
34194
34462
  label: "WorkBuddy Host\uFF08CodeBuddy \u6267\u884C\u5F15\u64CE\uFF09",
34195
34463
  model: configuredValue("AMASTER_CODEBUDDY_MODEL", process.env.AMASTER_CODEBUDDY_MODEL),
34196
34464
  auth: {
34197
- providerAuthEnv: optionalEnvPresence("CODEBUDDY_API_KEY", "CODEBUDDY_AUTH_TOKEN")
34465
+ diagnosticScope: "daemon_default",
34466
+ commandOverrideSupported: true,
34467
+ source: providerAuthConflict ? "provider_env_conflict" : providerAuthEnv.present ? "provider_env" : desktopSession.source,
34468
+ available: !providerAuthConflict && (providerAuthEnv.present || desktopSession.available),
34469
+ providerAuthEnv: {
34470
+ ...providerAuthEnv,
34471
+ conflict: providerAuthConflict
34472
+ },
34473
+ desktopSession
34198
34474
  },
34199
34475
  capabilityProtection: {
34200
34476
  featureGateEnabled: process.env.AMASTER_ENABLE_CODEBUDDY_EXECUTOR === "true",
34201
34477
  isolatedConfig: true,
34202
34478
  strictManagedMcp: true,
34203
34479
  inheritedWorkBuddyProfiles: false,
34480
+ desktopAuthPrivateSnapshot: true,
34204
34481
  minimumExecutorVersion: MINIMUM_CODEBUDDY_VERSION
34205
34482
  }
34206
34483
  };
@@ -34511,7 +34788,7 @@ AMASTER_MACHINE_ID=${quoteShell(config.machineId)}
34511
34788
  AMASTER_WORKSPACE_ALLOWLIST=${quoteShell(config.workspaceBindings.join(","))}
34512
34789
  AMASTER_EXECUTORS=${quoteShell(executorEnv)}
34513
34790
  AMASTER_NETWORK_DOMAINS=${quoteShell(config.networkDomains.join(","))}
34514
- AMASTER_DAEMON_STATE_FILE=${quoteShell(join20(homedir4(), ".amaster-employee", "runtime-connector-state.json"))}
34791
+ AMASTER_DAEMON_STATE_FILE=${quoteShell(join20(homedir5(), ".amaster-employee", "runtime-connector-state.json"))}
34515
34792
  EOF
34516
34793
 
34517
34794
  set -a
@@ -38462,6 +38739,16 @@ async function executeRunCommand(config, command) {
38462
38739
  }));
38463
38740
  const prompt = promptCompilation.prompt;
38464
38741
  const contextManifest = promptCompilation.manifest;
38742
+ const appendedSystemPrompt = readString(promptCompilation.systemPrompt);
38743
+ if (executor.kind === "pi" && appendedSystemPrompt) {
38744
+ const promptRoot = managedMcpProfile?.profileRoot ?? workspace.executorHome;
38745
+ const promptDir = join20(promptRoot, "tmp");
38746
+ mkdirSync11(promptDir, { recursive: true, mode: 448 });
38747
+ const promptPath = join20(promptDir, "conversation-system.md");
38748
+ writeFileSync13(promptPath, appendedSystemPrompt, { encoding: "utf8", mode: 384, flag: "wx" });
38749
+ const printIndex = invocation.args.lastIndexOf("-p");
38750
+ invocation.args.splice(printIndex < 0 ? invocation.args.length : printIndex, 0, "--append-system-prompt", promptPath);
38751
+ }
38465
38752
  let projectInstructionSnapshot = null;
38466
38753
  if (strictContextGovernance) {
38467
38754
  const finalContextExtensions = await runExecutionStage("context_attestation", () => attachPiFinalContextAttestor(managedMcpProfile, {
@@ -7,7 +7,7 @@ import { homedir, hostname } from "node:os";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { BUILD_SUPPORTED_CAPABILITIES } from "./amaster-runtime-daemon/capability-registry.mjs";
9
9
 
10
- const CONNECTOR_VERSION = "0.1.1-beta.263";
10
+ const CONNECTOR_VERSION = "0.1.1-beta.264";
11
11
 
12
12
  const CONFIG_KEY_MAP = new Map([
13
13
  ["server_url", "AMASTER_EMPLOYEE_SERVER_URL"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.263",
3
+ "version": "0.1.1-beta.264",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",