@amaster.ai/employee-runtime-connector 0.1.1-beta.69 → 0.1.1-beta.70

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.
@@ -2999,6 +2999,10 @@ function createManagedPiMcpProfileApi(options = {}) {
2999
2999
  "runtime_action.submit",
3000
3000
  "runtime_action.status"
3001
3001
  ]);
3002
+ const RUN_EXIT_CLOSURE_DIRECT_TYPED_TOOL_NAMES = /* @__PURE__ */ new Set([
3003
+ "runtime_action.describe",
3004
+ "runtime_action.submit"
3005
+ ]);
3002
3006
  const PROVIDER_SAFE_TOOL_NAME = /^[A-Za-z][A-Za-z0-9_-]*$/;
3003
3007
  const PI_BUILTIN_TOOL_NAMES = /* @__PURE__ */ new Set(["read", "bash", "edit", "write", "grep", "find", "ls", "mcp"]);
3004
3008
  const MINIMUM_PI_VERSION = [0, 73, 1];
@@ -4265,6 +4269,63 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
4265
4269
  };
4266
4270
  writePrivateFile2(manifestPath, `${JSON.stringify(manifest, null, 2)}
4267
4271
  `);
4272
+ const closureTools = directCatalog.tools.filter((tool) => RUN_EXIT_CLOSURE_DIRECT_TYPED_TOOL_NAMES.has(tool.name));
4273
+ const closureProfile = closureTools.length === RUN_EXIT_CLOSURE_DIRECT_TYPED_TOOL_NAMES.size ? (() => {
4274
+ const closureToolNames = closureTools.map((tool) => tool.exposedName);
4275
+ const closureServerConfig = {
4276
+ ...serverConfig,
4277
+ directTools: closureToolNames
4278
+ };
4279
+ const closureConfigContents = `${JSON.stringify({
4280
+ ...config,
4281
+ mcpServers: { [SUPPORTED_SERVER_NAME2]: closureServerConfig }
4282
+ }, null, 2)}
4283
+ `;
4284
+ const closureCacheContents = `${JSON.stringify({
4285
+ version: 1,
4286
+ servers: {
4287
+ [SUPPORTED_SERVER_NAME2]: {
4288
+ configHash: adapterServerConfigHash(closureServerConfig, adapterVersion),
4289
+ tools: closureTools.map((tool) => ({
4290
+ name: tool.exposedName,
4291
+ description: tool.description,
4292
+ inputSchema: tool.inputSchema
4293
+ })),
4294
+ resources: [],
4295
+ cachedAt: currentTimeMs()
4296
+ }
4297
+ }
4298
+ }, null, 2)}
4299
+ `;
4300
+ const closureCacheBytes = Buffer.from(closureCacheContents);
4301
+ const closureConfigBytes = Buffer.from(closureConfigContents);
4302
+ const closureManifestContents = `${JSON.stringify({
4303
+ ...manifest,
4304
+ entries: closureTools.map((tool) => ({
4305
+ name: tool.exposedName,
4306
+ canonicalName: tool.name,
4307
+ schema: tool.inputSchema,
4308
+ effectiveSchemaHash: tool.effectiveSchemaHash
4309
+ })),
4310
+ effectiveSetHash: stablePiEffectiveToolSetHash(closureTools.map((tool) => ({
4311
+ name: tool.exposedName,
4312
+ schemaHash: tool.effectiveSchemaHash
4313
+ }))),
4314
+ configSha256: sha2562(closureConfigBytes),
4315
+ cacheSha256: sha2562(closureCacheBytes),
4316
+ cacheSemanticHash: stablePiManagedMcpCacheSemanticHash(closureCacheBytes)
4317
+ }, null, 2)}
4318
+ `;
4319
+ return {
4320
+ toolAllowlist: closureToolNames,
4321
+ cacheContentsBase64: closureCacheBytes.toString("base64"),
4322
+ cacheSha256: sha2562(closureCacheBytes),
4323
+ manifestContentsBase64: Buffer.from(closureManifestContents).toString("base64"),
4324
+ manifestSha256: sha2562(Buffer.from(closureManifestContents)),
4325
+ configContentsBase64: closureConfigBytes.toString("base64"),
4326
+ configSha256: sha2562(closureConfigBytes)
4327
+ };
4328
+ })() : null;
4268
4329
  directAttestationInput = {
4269
4330
  cachePath,
4270
4331
  manifestPath,
@@ -4277,7 +4338,8 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
4277
4338
  attestorSourceSha256,
4278
4339
  effectiveSetHash: manifest.effectiveSetHash,
4279
4340
  proxyMode: manifest.proxyMode,
4280
- extensionArgs: [...extensionArgs]
4341
+ extensionArgs: [...extensionArgs],
4342
+ closureProfile
4281
4343
  };
4282
4344
  }
4283
4345
  let enabledRoleSkills = null;
@@ -4335,7 +4397,11 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
4335
4397
  effectiveToolsBootstrapCache?.key ?? null
4336
4398
  ) : {};
4337
4399
  const effectiveToolProbeBootstrapCache = effectiveToolsBootstrapCache ? publishEffectiveToolsBootstrapCache(effectiveToolsBootstrapCache) : null;
4338
- const runExitClosureCacheOwnership = directAttestationInput ? ownershipStatSyncImpl(directAttestationInput.cachePath) : null;
4400
+ const runExitClosureOwnership = directAttestationInput ? {
4401
+ cache: ownershipStatSyncImpl(directAttestationInput.cachePath),
4402
+ manifest: ownershipStatSyncImpl(directAttestationInput.manifestPath),
4403
+ config: ownershipStatSyncImpl(directAttestationInput.configPath)
4404
+ } : null;
4339
4405
  const attestationFacts = {
4340
4406
  connectorVersion: nonEmpty2(input.connectorVersion, "connectorVersion"),
4341
4407
  executorKind: "pi",
@@ -4372,18 +4438,25 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
4372
4438
  workspaceMcpConfigPath,
4373
4439
  ...directAttestationInput ? {
4374
4440
  runExitClosureBaseline: {
4375
- schemaVersion: "amaster.pi-run-exit-closure-baseline.v1",
4441
+ schemaVersion: directAttestationInput.closureProfile ? "amaster.pi-run-exit-closure-baseline.v2" : "amaster.pi-run-exit-closure-baseline.v1",
4376
4442
  owner,
4377
4443
  profileRoot,
4378
4444
  cachePath: directAttestationInput.cachePath,
4379
4445
  cacheSha256: directAttestationInput.cacheSha256,
4380
4446
  cacheContentsBase64: directAttestationInput.cacheContentsBase64,
4381
- cacheOwnership: runExitClosureCacheOwnership ? { uid: runExitClosureCacheOwnership.uid, gid: runExitClosureCacheOwnership.gid } : null,
4447
+ cacheOwnership: runExitClosureOwnership ? { uid: runExitClosureOwnership.cache.uid, gid: runExitClosureOwnership.cache.gid } : null,
4382
4448
  manifestPath: directAttestationInput.manifestPath,
4383
4449
  manifestSha256: sha2562(readFileSync3(directAttestationInput.manifestPath)),
4384
4450
  configPath: directAttestationInput.configPath,
4385
4451
  configSha256: directAttestationInput.configSha256,
4386
- receiptPath: directAttestationInput.receiptPath
4452
+ receiptPath: directAttestationInput.receiptPath,
4453
+ ...directAttestationInput.closureProfile ? {
4454
+ closureProfile: {
4455
+ ...directAttestationInput.closureProfile,
4456
+ manifestOwnership: runExitClosureOwnership ? { uid: runExitClosureOwnership.manifest.uid, gid: runExitClosureOwnership.manifest.gid } : null,
4457
+ configOwnership: runExitClosureOwnership ? { uid: runExitClosureOwnership.config.uid, gid: runExitClosureOwnership.config.gid } : null
4458
+ }
4459
+ } : {}
4387
4460
  }
4388
4461
  } : {},
4389
4462
  // Only narrowed specialized catalogs (diagnosis/source-acquisition) pin
@@ -4413,7 +4486,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
4413
4486
  function restoreManagedPiRunExitClosureBaseline2(input, expectedOwner2) {
4414
4487
  if (!input) return { status: "not_required" };
4415
4488
  const baseline = record6(input);
4416
- if (baseline.schemaVersion !== "amaster.pi-run-exit-closure-baseline.v1") {
4489
+ if (!["amaster.pi-run-exit-closure-baseline.v1", "amaster.pi-run-exit-closure-baseline.v2"].includes(baseline.schemaVersion)) {
4417
4490
  throw new Error("pi_run_exit_closure_baseline_invalid: unsupported schema version");
4418
4491
  }
4419
4492
  const owner = record6(baseline.owner);
@@ -4450,26 +4523,80 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
4450
4523
  if (!cacheOwnership) {
4451
4524
  throw new Error("pi_run_exit_closure_baseline_cache_owner_missing");
4452
4525
  }
4453
- if (sha2562(readFileSync3(manifestPath)) !== nonEmpty2(baseline.manifestSha256, "runExitClosureBaseline.manifestSha256")) {
4526
+ const closureProfile = baseline.schemaVersion === "amaster.pi-run-exit-closure-baseline.v2" ? record6(baseline.closureProfile) : null;
4527
+ const closureToolAllowlist = closureProfile ? Array.isArray(closureProfile.toolAllowlist) ? closureProfile.toolAllowlist.filter((name) => typeof name === "string") : [] : null;
4528
+ if (closureToolAllowlist && (closureToolAllowlist.length !== RUN_EXIT_CLOSURE_DIRECT_TYPED_TOOL_NAMES.size || new Set(closureToolAllowlist).size !== RUN_EXIT_CLOSURE_DIRECT_TYPED_TOOL_NAMES.size || closureToolAllowlist.some((name) => !PROVIDER_SAFE_TOOL_NAME.test(name)))) {
4529
+ throw new Error("pi_run_exit_closure_baseline_tool_allowlist_invalid");
4530
+ }
4531
+ const currentManifestSha256 = sha2562(readFileSync3(manifestPath));
4532
+ const acceptedManifestDigests = /* @__PURE__ */ new Set([
4533
+ nonEmpty2(baseline.manifestSha256, "runExitClosureBaseline.manifestSha256"),
4534
+ ...closureProfile ? [nonEmpty2(closureProfile.manifestSha256, "closureProfile.manifestSha256")] : []
4535
+ ]);
4536
+ if (!acceptedManifestDigests.has(currentManifestSha256)) {
4454
4537
  throw new Error("pi_run_exit_closure_baseline_manifest_drift");
4455
4538
  }
4456
- if (sha2562(readFileSync3(configPath)) !== nonEmpty2(baseline.configSha256, "runExitClosureBaseline.configSha256")) {
4539
+ const currentConfigSha256 = sha2562(readFileSync3(configPath));
4540
+ const acceptedConfigDigests = /* @__PURE__ */ new Set([
4541
+ nonEmpty2(baseline.configSha256, "runExitClosureBaseline.configSha256"),
4542
+ ...closureProfile ? [nonEmpty2(closureProfile.configSha256, "closureProfile.configSha256")] : []
4543
+ ]);
4544
+ if (!acceptedConfigDigests.has(currentConfigSha256)) {
4457
4545
  throw new Error("pi_run_exit_closure_baseline_config_drift");
4458
4546
  }
4547
+ const phaseContents = closureProfile ? [
4548
+ {
4549
+ path: configPath,
4550
+ bytes: Buffer.from(nonEmpty2(closureProfile.configContentsBase64, "closureProfile.configContentsBase64"), "base64"),
4551
+ expectedSha256: nonEmpty2(closureProfile.configSha256, "closureProfile.configSha256"),
4552
+ ownership: record6(closureProfile.configOwnership),
4553
+ label: "config"
4554
+ },
4555
+ {
4556
+ path: cachePath,
4557
+ bytes: Buffer.from(nonEmpty2(closureProfile.cacheContentsBase64, "closureProfile.cacheContentsBase64"), "base64"),
4558
+ expectedSha256: nonEmpty2(closureProfile.cacheSha256, "closureProfile.cacheSha256"),
4559
+ ownership: baselineCacheOwnership,
4560
+ label: "cache"
4561
+ },
4562
+ {
4563
+ path: manifestPath,
4564
+ bytes: Buffer.from(nonEmpty2(closureProfile.manifestContentsBase64, "closureProfile.manifestContentsBase64"), "base64"),
4565
+ expectedSha256: nonEmpty2(closureProfile.manifestSha256, "closureProfile.manifestSha256"),
4566
+ ownership: record6(closureProfile.manifestOwnership),
4567
+ label: "manifest"
4568
+ }
4569
+ ] : [{
4570
+ path: cachePath,
4571
+ bytes: cacheContents,
4572
+ expectedSha256: cacheSha256,
4573
+ ownership: baselineCacheOwnership,
4574
+ label: "cache"
4575
+ }];
4459
4576
  if (existsSync3(receiptPath)) rmSync2(receiptPath);
4460
- writeOwnedFileAtomic(cachePath, cacheContents);
4461
- const replacedCacheStat = ownershipStatSyncImpl(cachePath);
4462
- if (replacedCacheStat.uid !== cacheOwnership.uid || replacedCacheStat.gid !== cacheOwnership.gid) {
4463
- chownSyncImpl(cachePath, cacheOwnership.uid, cacheOwnership.gid);
4464
- }
4465
- if (sha2562(readFileSync3(cachePath)) !== cacheSha256) {
4466
- throw new Error("pi_run_exit_closure_baseline_restore_failed");
4467
- }
4468
- const restoredCacheStat = ownershipStatSyncImpl(cachePath);
4469
- if (restoredCacheStat.uid !== cacheOwnership.uid || restoredCacheStat.gid !== cacheOwnership.gid) {
4470
- throw new Error("pi_run_exit_closure_baseline_owner_restore_failed");
4577
+ for (const entry of phaseContents) {
4578
+ if (sha2562(entry.bytes) !== entry.expectedSha256) {
4579
+ throw new Error(`pi_run_exit_closure_${entry.label}_digest_mismatch`);
4580
+ }
4581
+ const recordedOwnership = Number.isSafeInteger(entry.ownership.uid) && entry.ownership.uid >= 0 && Number.isSafeInteger(entry.ownership.gid) && entry.ownership.gid >= 0 ? { uid: entry.ownership.uid, gid: entry.ownership.gid } : entry.path === cachePath ? cacheOwnership : ownershipStatSyncImpl(entry.path);
4582
+ writeOwnedFileAtomic(entry.path, entry.bytes);
4583
+ const replacedStat = ownershipStatSyncImpl(entry.path);
4584
+ if (replacedStat.uid !== recordedOwnership.uid || replacedStat.gid !== recordedOwnership.gid) {
4585
+ chownSyncImpl(entry.path, recordedOwnership.uid, recordedOwnership.gid);
4586
+ }
4587
+ if (sha2562(readFileSync3(entry.path)) !== entry.expectedSha256) {
4588
+ throw new Error(`pi_run_exit_closure_${entry.label}_restore_failed`);
4589
+ }
4590
+ const restoredStat = ownershipStatSyncImpl(entry.path);
4591
+ if (restoredStat.uid !== recordedOwnership.uid || restoredStat.gid !== recordedOwnership.gid) {
4592
+ throw new Error(`pi_run_exit_closure_${entry.label}_owner_restore_failed`);
4593
+ }
4471
4594
  }
4472
- return { status: "restored", cacheSha256 };
4595
+ return {
4596
+ status: "restored",
4597
+ cacheSha256: closureProfile?.cacheSha256 ?? cacheSha256,
4598
+ ...closureToolAllowlist ? { toolAllowlist: closureToolAllowlist } : {}
4599
+ };
4473
4600
  }
4474
4601
  function inspectManagedPiRunExitClosureAttestation2(input, expectedOwner2) {
4475
4602
  if (!input) return { status: "not_required" };
@@ -11185,7 +11312,7 @@ var source_acquisition_compatibility_default = {
11185
11312
  };
11186
11313
 
11187
11314
  // src/amaster-runtime-daemon.mjs
11188
- var CONNECTOR_VERSION = "0.1.1-beta.69";
11315
+ var CONNECTOR_VERSION = "0.1.1-beta.70";
11189
11316
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
11190
11317
  var SOURCE_ACQUISITION_CAPABILITY = source_acquisition_compatibility_default.profileVersion;
11191
11318
  var daemonRequire = createRequire(import.meta.url);
@@ -14275,13 +14402,14 @@ async function requestRunCompletionCheck(config, inputState) {
14275
14402
  }
14276
14403
  return { pending: true, state };
14277
14404
  }
14278
- function runExitClosurePrompt(state) {
14405
+ function runExitClosurePrompt(state, options = {}) {
14279
14406
  const command = asRecord(state.command);
14280
14407
  const response = asRecord(state.completionResponse);
14281
14408
  const summary = truncateText(readString(asRecord(state.candidateResult).summary) ?? "", 1200);
14282
14409
  const issueId = commandIssueId(command) ?? "unknown";
14283
14410
  const runId = commandRunId(command) ?? "unknown";
14284
14411
  const closureStrategy = readString(response.closureStrategy) ?? "select_issue_disposition";
14412
+ const describeRequired = options.describeRequired !== false;
14285
14413
  const allowedActions = Array.isArray(response.allowedActions) ? response.allowedActions.filter((value) => typeof value === "string") : [];
14286
14414
  return [
14287
14415
  "# AMaster Run-Exit Disposition Closure",
@@ -14291,11 +14419,11 @@ function runExitClosurePrompt(state) {
14291
14419
  summary ? `Primary turn summary: ${summary}` : null,
14292
14420
  "Do not perform more business work, edit files, create artifacts/documents/children/plans, or mutate company/profile/milestone state.",
14293
14421
  closureStrategy === "record_work_disposition" ? "Effective closure action for this turn: record_work_disposition only." : `Server-allowed closure actions: ${allowedActions.join(", ") || "none"}.`,
14294
- "Use exactly one runtime_action.submit mutation.",
14422
+ describeRequired ? closureStrategy === "record_work_disposition" ? "Call runtime_action.describe exactly once for record_work_disposition, then use exactly one runtime_action.submit mutation with that described shape." : "Choose one Server-allowed action, call runtime_action.describe exactly once for that action type, then use exactly one runtime_action.submit mutation with that described shape." : "Use exactly one runtime_action.submit mutation with the already-issued phase-specific schema.",
14295
14423
  closureStrategy === "record_work_disposition" ? "The Server selected record_work_disposition as the only closure strategy. For this already-productive source run, record execute_inline with truthful source-run evidence; do not also mutate issue status or create an interaction. After command terminalization, the Server writes the Business Outcome and owns the matching Board review or terminal-state transition." : "The Server selected an Issue disposition closure. Choose update_parent, create_interaction (not suggest_tasks), or add_comment only when a comment is truly the intended exit path. A comment alone does not establish completion.",
14296
14424
  closureStrategy === "record_work_disposition" ? `Use evidenceRefs ["run:${runId}", "command:${state.commandId}"], structure.deliverableType "runtime_command_result", structure.deliverableKey "runtime-command-${state.commandId}", and structure.acceptanceMethodCode "governed_business_outcome". Supply a concise truthful reason based only on the primary turn summary.` : null,
14297
14425
  `The idempotencyKey must be runtime-command-closure:${state.commandId}.`,
14298
- "Do not call runtime_action.plan or runtime_action.commit. Stop immediately after the one allowed mutation returns."
14426
+ describeRequired ? "Do not call runtime_action.plan or runtime_action.commit. Do not call runtime_action.describe more than once. Stop immediately after the one allowed mutation returns." : "Do not call runtime_action.describe, runtime_action.plan, or runtime_action.commit. Stop immediately after the one allowed mutation returns."
14299
14427
  ].filter(Boolean).join("\n\n");
14300
14428
  }
14301
14429
  function parseExecutorTurnOutput(executorKind, execution, liveOutputLogger, hasOutputFlood) {
@@ -14473,18 +14601,23 @@ async function executeRunExitClosureTurn(config, inputState, options = {}) {
14473
14601
  executionConfig.runExitClosureBaseline,
14474
14602
  { commandId: state.commandId, runId: commandRunId(command) }
14475
14603
  ) : { status: "not_required" };
14604
+ const closureArgs = executorKind === "pi" ? applyManagedPiToolAllowlist(args, {
14605
+ toolAllowlist: Array.isArray(managedMcpClosureBaseline.toolAllowlist) ? managedMcpClosureBaseline.toolAllowlist : null
14606
+ }) : args;
14607
+ const describeRequired = executorKind !== "pi" || managedMcpClosureBaseline.status !== "restored" || Array.isArray(managedMcpClosureBaseline.toolAllowlist);
14476
14608
  await ingestLog(config, command, "system", "info", "Starting bounded run-exit disposition closure turn", {
14477
14609
  presentationKind: "run_exit_disposition_closure",
14478
14610
  commandId: state.commandId,
14479
14611
  closureAttempt: 1,
14480
- managedMcpClosureBaselineStatus: managedMcpClosureBaseline.status
14612
+ managedMcpClosureBaselineStatus: managedMcpClosureBaseline.status,
14613
+ managedMcpClosureToolAllowlist: managedMcpClosureBaseline.toolAllowlist ?? null
14481
14614
  });
14482
14615
  let execution;
14483
14616
  try {
14484
- execution = await runExecutor(executable, args, {
14617
+ execution = await runExecutor(executable, closureArgs, {
14485
14618
  cwd,
14486
14619
  env,
14487
- stdin: runExitClosurePrompt(state),
14620
+ stdin: runExitClosurePrompt(state, { describeRequired }),
14488
14621
  timeoutSeconds: Math.max(1, readNumber(executionConfig.timeoutSeconds, config.executorTimeoutSeconds)),
14489
14622
  maxOutputBytes: Math.max(1, readNumber(executionConfig.maxOutputBytes, config.executorMaxOutputBytes)),
14490
14623
  maxRssMb: Math.max(0, readNumber(executionConfig.maxRssMb, config.executorMaxRssMb)),
@@ -6,7 +6,7 @@ import { basename, dirname, join, resolve } from "node:path";
6
6
  import { homedir, hostname } from "node:os";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
- const CONNECTOR_VERSION = "0.1.1-beta.69";
9
+ const CONNECTOR_VERSION = "0.1.1-beta.70";
10
10
 
11
11
  const CAPABILITIES = [
12
12
  "remote_registration",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.69",
3
+ "version": "0.1.1-beta.70",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",