@amaster.ai/employee-runtime-connector 0.1.1-beta.31 → 0.1.1-beta.33

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.
@@ -2755,7 +2755,8 @@ function createManagedPiMcpProfileApi(options = {}) {
2755
2755
  const DELEGATED_PROFILE_MARKER = ".amaster-delegated-pi-profile.json";
2756
2756
  const SESSION_ROLLOUT_MARKER2 = ".amaster-pi-session-rollout.json";
2757
2757
  const DEFAULT_SESSION_ROLLOUT_TTL_MS2 = 24 * 60 * 60 * 1e3;
2758
- const PI_ATTESTATION_TIMEOUT_MS = 1e4;
2758
+ const PI_VERSION_ATTESTATION_TIMEOUT_MS = 1e4;
2759
+ const PI_EFFECTIVE_TOOLS_ATTESTATION_TIMEOUT_MS = 3e4;
2759
2760
  const PI_ATTESTATION_MAX_ATTEMPTS = 2;
2760
2761
  const PI_ATTESTATION_RECENT_LIVE_TTL_MS = Number.isFinite(options.recentLiveTtlMs) && options.recentLiveTtlMs > 0 ? options.recentLiveTtlMs : 30 * 60 * 1e3;
2761
2762
  const recentLivePiVersionProbes = /* @__PURE__ */ new Map();
@@ -3343,7 +3344,7 @@ function createManagedPiMcpProfileApi(options = {}) {
3343
3344
  cwd: env.AMASTER_RUNTIME_EXECUTION_WORKDIR,
3344
3345
  env,
3345
3346
  encoding: "utf8",
3346
- timeout: PI_ATTESTATION_TIMEOUT_MS,
3347
+ timeout: PI_VERSION_ATTESTATION_TIMEOUT_MS,
3347
3348
  killSignal: "SIGKILL",
3348
3349
  maxBuffer: 1024 * 1024,
3349
3350
  ...spawnIdentity ?? {}
@@ -3407,7 +3408,18 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3407
3408
  liveProbeAgeMs
3408
3409
  };
3409
3410
  }
3411
+ function inspectEffectiveToolsProbeReceipt(receiptPath) {
3412
+ if (!existsSync3(receiptPath)) return { phase: "missing", receipt: null };
3413
+ try {
3414
+ const receipt = JSON.parse(readFileSync3(receiptPath, "utf8"));
3415
+ const phase = receipt?.status === "attested" || receipt?.status === "rejected" ? receipt.status : "present";
3416
+ return { phase, receipt };
3417
+ } catch {
3418
+ return { phase: "invalid", receipt: null };
3419
+ }
3420
+ }
3410
3421
  function attestDirectPiTools(executorCommand, env, input, spawnIdentity = null) {
3422
+ const startedAtMs = currentTimeMs();
3411
3423
  const result3 = spawnSyncImpl(executorCommand, [
3412
3424
  "--no-session",
3413
3425
  "--no-approve",
@@ -3423,25 +3435,28 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3423
3435
  cwd: env.AMASTER_RUNTIME_EXECUTION_WORKDIR,
3424
3436
  env: { ...env, AMASTER_PI_EFFECTIVE_TOOLS_MODE: "probe" },
3425
3437
  encoding: "utf8",
3426
- timeout: PI_ATTESTATION_TIMEOUT_MS,
3438
+ timeout: PI_EFFECTIVE_TOOLS_ATTESTATION_TIMEOUT_MS,
3427
3439
  killSignal: "SIGKILL",
3428
3440
  maxBuffer: 1024 * 1024,
3429
3441
  ...spawnIdentity ?? {}
3430
3442
  });
3443
+ const elapsedMs = Math.max(0, currentTimeMs() - startedAtMs);
3431
3444
  if (result3.error) {
3432
3445
  const code = typeof result3.error.code === "string" ? result3.error.code : "UNKNOWN";
3433
- throw new Error(`pi_managed_mcp_effective_tools_failed: probe error=${code}`);
3446
+ const receiptDiagnostic = inspectEffectiveToolsProbeReceipt(input.receiptPath);
3447
+ throw new Error(
3448
+ `pi_managed_mcp_effective_tools_failed: probe error=${code} elapsedMs=${elapsedMs} timeoutMs=${PI_EFFECTIVE_TOOLS_ATTESTATION_TIMEOUT_MS} receiptPhase=${receiptDiagnostic.phase}`
3449
+ );
3434
3450
  }
3435
3451
  if (result3.status !== 0) {
3452
+ const receiptDiagnostic = inspectEffectiveToolsProbeReceipt(input.receiptPath);
3436
3453
  let receiptError = "receipt unavailable";
3437
- try {
3438
- const rejectedReceipt = JSON.parse(readFileSync3(input.receiptPath, "utf8"));
3439
- if (typeof rejectedReceipt.error === "string" && rejectedReceipt.error.length > 0) {
3440
- receiptError = rejectedReceipt.error.slice(0, 512);
3441
- }
3442
- } catch {
3454
+ if (typeof receiptDiagnostic.receipt?.error === "string" && receiptDiagnostic.receipt.error.length > 0) {
3455
+ receiptError = receiptDiagnostic.receipt.error.slice(0, 512);
3443
3456
  }
3444
- throw new Error(`pi_managed_mcp_effective_tools_failed: probe exit=${result3.status ?? "unknown"} reason=${receiptError}`);
3457
+ throw new Error(
3458
+ `pi_managed_mcp_effective_tools_failed: probe exit=${result3.status ?? "unknown"} elapsedMs=${elapsedMs} timeoutMs=${PI_EFFECTIVE_TOOLS_ATTESTATION_TIMEOUT_MS} receiptPhase=${receiptDiagnostic.phase} reason=${receiptError}`
3459
+ );
3445
3460
  }
3446
3461
  let receipt;
3447
3462
  try {
@@ -3465,6 +3480,8 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3465
3480
  effectiveToolSetHash: receipt.effectiveSetHash,
3466
3481
  effectiveToolProbeDigest: sha2562(stablePiJson(receipt)),
3467
3482
  effectiveToolProbeAt: receipt.attestedAt,
3483
+ effectiveToolProbeElapsedMs: elapsedMs,
3484
+ effectiveToolProbeTimeoutMs: PI_EFFECTIVE_TOOLS_ATTESTATION_TIMEOUT_MS,
3468
3485
  effectiveToolBindings: receipt.effectiveToolBindings
3469
3486
  };
3470
3487
  }
@@ -4662,6 +4679,86 @@ function governedReadSection(context) {
4662
4679
  }))
4663
4680
  };
4664
4681
  }
4682
+ function governedBusinessDetailRead(input, issueId) {
4683
+ const canonicalTool = "amaster.read_governed_business_state";
4684
+ const exactIssueId = readString(issueId);
4685
+ if (!exactIssueId) {
4686
+ return { mode: "unavailable", canonical_tool: canonicalTool, reason: "issue_scope_unavailable" };
4687
+ }
4688
+ if (!input.hasGovernedMcp) {
4689
+ return { mode: "unavailable", canonical_tool: canonicalTool, reason: "governed_mcp_unavailable" };
4690
+ }
4691
+ const argumentsValue = { issueId: exactIssueId };
4692
+ const exposedTool = managedDirectToolName(input, canonicalTool);
4693
+ if (exposedTool) {
4694
+ return { mode: "direct_typed", tool: exposedTool, arguments: argumentsValue };
4695
+ }
4696
+ if (input.managedMcpToolMode === "direct_typed") {
4697
+ return { mode: "unavailable", canonical_tool: canonicalTool, reason: "not_in_run_catalog" };
4698
+ }
4699
+ if (input.executorKind === "pi" && managedPiMcpProxyAvailable(input)) {
4700
+ return {
4701
+ mode: "mcp_proxy",
4702
+ server: "amaster",
4703
+ tool: canonicalTool,
4704
+ args: JSON.stringify(argumentsValue)
4705
+ };
4706
+ }
4707
+ return { mode: "canonical", tool: canonicalTool, arguments: argumentsValue };
4708
+ }
4709
+ function governedBusinessDecisionProjection(state, detailRead) {
4710
+ const record6 = asRecord(state);
4711
+ const snapshot = asRecord(record6.governed_state_snapshot);
4712
+ const enrollment = asRecord(snapshot.business_task_enrollment);
4713
+ const authoritativeObjectRefs = Array.isArray(record6.authoritative_object_refs) ? record6.authoritative_object_refs : [];
4714
+ const enrollmentRef = authoritativeObjectRefs.find((entry) => readString(asRecord(entry).object_kind) === "business_task_enrollment");
4715
+ const snapshotId = readString(snapshot.snapshot_id);
4716
+ const generatedAt = readString(snapshot.generated_at);
4717
+ const projection = {
4718
+ availability: record6.availability,
4719
+ capabilities: Array.isArray(record6.capabilities) ? record6.capabilities : [],
4720
+ missing_objects: Array.isArray(record6.missing_objects) ? record6.missing_objects : [],
4721
+ authoritative_object_refs: authoritativeObjectRefs,
4722
+ snapshot: {
4723
+ ref: snapshotId ? `governed_state:${snapshotId}` : null,
4724
+ observed_at: generatedAt ?? null
4725
+ },
4726
+ detail_read: detailRead
4727
+ };
4728
+ if (Object.keys(enrollment).length > 0) {
4729
+ projection.business_task_enrollment = {
4730
+ state: readString(enrollment.state) ?? null,
4731
+ authoritative_ref: readString(asRecord(enrollmentRef).ref) ?? null,
4732
+ finding: enrollment.finding ?? null
4733
+ };
4734
+ }
4735
+ const continuationId = readString(record6.continuation_id);
4736
+ if (continuationId) projection.continuation_id = continuationId;
4737
+ if (Number.isInteger(record6.outcome_revision)) projection.outcome_revision = record6.outcome_revision;
4738
+ const freeTextReason = readString(record6.free_text_reason);
4739
+ if (freeTextReason) projection.free_text_reason = freeTextReason;
4740
+ return projection;
4741
+ }
4742
+ function governedBusinessModelView(state, input) {
4743
+ const record6 = asRecord(state);
4744
+ const snapshot = asRecord(record6.governed_state_snapshot);
4745
+ const detailRead = governedBusinessDetailRead(
4746
+ input,
4747
+ readString(snapshot.issue_id) ?? readString(input.issueId)
4748
+ );
4749
+ if (detailRead.mode === "unavailable") {
4750
+ return {
4751
+ mode: "full_snapshot",
4752
+ content: record6,
4753
+ unavailableReason: detailRead.reason
4754
+ };
4755
+ }
4756
+ return {
4757
+ mode: "decision_projection",
4758
+ content: governedBusinessDecisionProjection(record6, detailRead),
4759
+ unavailableReason: null
4760
+ };
4761
+ }
4665
4762
  function governedBusinessStateSection(context, input) {
4666
4763
  const current = asRecord(context.governedBusinessState);
4667
4764
  const resume = asRecord(context.governedBusinessResume);
@@ -4676,6 +4773,9 @@ function governedBusinessStateSection(context, input) {
4676
4773
  throw new Error(`governed_business_state_scope_mismatch:${label}`);
4677
4774
  }
4678
4775
  }
4776
+ const currentView = Object.keys(current).length > 0 ? governedBusinessModelView(current, input) : null;
4777
+ const resumeView = Object.keys(resume).length > 0 ? governedBusinessModelView(resume, input) : null;
4778
+ const retainsFullSnapshot = [currentView, resumeView].some((view) => view?.mode === "full_snapshot");
4679
4779
  const rules = [
4680
4780
  "This is bounded Server-owned read-side truth. It does not grant mutation authority and it is not a Delivery Manifest claim.",
4681
4781
  "Recommendation, First Business Activation, and Business Task Enrollment may be described as created/submitted/activated/enrolled only when authoritative_object_refs contains the exact matching Server ref. Issue and Document are not Business Task Enrollment.",
@@ -4684,13 +4784,16 @@ function governedBusinessStateSection(context, input) {
4684
4784
  "A read capability marked unavailable does not prove an instance is absent. A write capability marked unavailable does not prove the object kind is unsupported.",
4685
4785
  "When availability.status or a required read capability is unavailable, unrelated work may continue, but formal-object completion claims must remain fail-closed until a managed read succeeds.",
4686
4786
  "When a required formal object is missing or the current Runtime lacks its legal producer, keep the task incomplete and name missing_objects.reason_code plus next_owner. Board review remains independent final acceptance.",
4687
- "free_text_reason is explanatory only and is not authority; resolve any conflict in favor of the structured Server-owned state."
4787
+ "free_text_reason is explanatory only and is not authority; resolve any conflict in favor of the structured Server-owned state.",
4788
+ retainsFullSnapshot ? "No executable managed detail read is available for at least one state below, so its bounded full snapshot remains inline. Do not guess a tool name or claim that omitted state can be fetched." : "The default body is a decision projection, not the complete process ledger. Use detail_read only when the current task needs omitted diagnosis, recommendation, activation, enrollment, or dispatch details."
4688
4789
  ].join("\n");
4689
4790
  const bodies = [
4690
- Object.keys(current).length > 0 ? `Current dispatch snapshot:
4691
- ${stringifyBoundedJson(current, 24e3)}` : "",
4692
- Object.keys(resume).length > 0 ? `Changes-requested resume binding:
4693
- ${stringifyBoundedJson(resume, 24e3)}` : ""
4791
+ currentView ? currentView.mode === "decision_projection" ? `Current dispatch decision projection:
4792
+ ${stringifyBoundedJson(currentView.content, 24e3)}` : `Current dispatch bounded full snapshot (managed detail read unavailable: ${currentView.unavailableReason}):
4793
+ ${stringifyBoundedJson(currentView.content, 24e3)}` : "",
4794
+ resumeView ? resumeView.mode === "decision_projection" ? `Changes-requested resume decision projection:
4795
+ ${stringifyBoundedJson(resumeView.content, 24e3)}` : `Changes-requested resume bounded full snapshot (managed detail read unavailable: ${resumeView.unavailableReason}):
4796
+ ${stringifyBoundedJson(resumeView.content, 24e3)}` : ""
4694
4797
  ].filter(Boolean).join("\n\n");
4695
4798
  return {
4696
4799
  content: `${rules}
@@ -9425,7 +9528,7 @@ function assertSourceAcquisitionRuntimeAuthority({
9425
9528
  }
9426
9529
 
9427
9530
  // src/amaster-runtime-daemon.mjs
9428
- var CONNECTOR_VERSION = "0.1.1-beta.31";
9531
+ var CONNECTOR_VERSION = "0.1.1-beta.33";
9429
9532
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
9430
9533
  var SOURCE_ACQUISITION_CAPABILITY = "source_acquisition_v1";
9431
9534
  var SOURCE_ACQUISITION_PROFILE_VERSION = "source_acquisition_v1";
@@ -13907,7 +14010,7 @@ async function executeRunCommand(config, command) {
13907
14010
  }
13908
14011
  if (executor.kind === "pi") {
13909
14012
  piResolvedProviderConfig = executorEnv;
13910
- for (const envName of ["AMASTER_API_KEY", "AMASTER_PLATFORM_OAUTH_TOKEN"]) {
14013
+ for (const envName of ["AMASTER_API_KEY", "AMASTER_PLATFORM_OAUTH_TOKEN", "PLATFORM_ACCESS_TOKEN"]) {
13911
14014
  const protectedValue = readString(piResolvedProviderConfig[envName]);
13912
14015
  if (protectedValue && !providerProtectedValues.includes(protectedValue)) {
13913
14016
  providerProtectedValues.push(protectedValue);
@@ -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.31";
9
+ const CONNECTOR_VERSION = "0.1.1-beta.33";
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.31",
3
+ "version": "0.1.1-beta.33",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",