@amaster.ai/employee-runtime-connector 0.1.1-beta.32 → 0.1.1-beta.34
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/dist/amaster-runtime-daemon.mjs +187 -72
- package/dist/amaster-runtime.mjs +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
3438
|
-
|
|
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(
|
|
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
|
}
|
|
@@ -4624,6 +4641,95 @@ function continuationText(context) {
|
|
|
4624
4641
|
if (!body) return "";
|
|
4625
4642
|
return [readString(summary.title), body].filter(Boolean).join("\n");
|
|
4626
4643
|
}
|
|
4644
|
+
function taskAcceptanceContractError(code, message) {
|
|
4645
|
+
const error = new Error(message);
|
|
4646
|
+
error.code = code;
|
|
4647
|
+
return error;
|
|
4648
|
+
}
|
|
4649
|
+
function formalTaskAcceptanceContractRequired(context) {
|
|
4650
|
+
const requirements = asRecord(asRecord(context.paperclipIssue).taskRequirements);
|
|
4651
|
+
return requirements.requirementsVersion === "v2" && asRecord(requirements.taskIntent).intent === "business" && asRecord(requirements.admission).state === "active";
|
|
4652
|
+
}
|
|
4653
|
+
function sameCanonicalJson(left, right) {
|
|
4654
|
+
return JSON.stringify(canonicalJsonValue(left)) === JSON.stringify(canonicalJsonValue(right));
|
|
4655
|
+
}
|
|
4656
|
+
function taskAcceptanceContractSection(context, input) {
|
|
4657
|
+
const required = formalTaskAcceptanceContractRequired(context);
|
|
4658
|
+
const contract = asRecord(context.taskAcceptanceContract);
|
|
4659
|
+
if (Object.keys(contract).length === 0) {
|
|
4660
|
+
if (required) {
|
|
4661
|
+
throw taskAcceptanceContractError(
|
|
4662
|
+
"task_acceptance_contract_unavailable",
|
|
4663
|
+
"Formal Business Task dispatch requires a Server-owned Task Acceptance Contract"
|
|
4664
|
+
);
|
|
4665
|
+
}
|
|
4666
|
+
return null;
|
|
4667
|
+
}
|
|
4668
|
+
const companyId = readString(asRecord(context.paperclipCompany).id);
|
|
4669
|
+
const issueId = readString(input.issueId);
|
|
4670
|
+
if (companyId && readString(contract.company_id) !== companyId || issueId && readString(contract.issue_id) !== issueId) {
|
|
4671
|
+
throw taskAcceptanceContractError(
|
|
4672
|
+
"task_acceptance_contract_scope_mismatch",
|
|
4673
|
+
"Task Acceptance Contract does not match the current Company and Issue scope"
|
|
4674
|
+
);
|
|
4675
|
+
}
|
|
4676
|
+
const enrollment = asRecord(contract.enrollment);
|
|
4677
|
+
const delivery = asRecord(contract.delivery);
|
|
4678
|
+
const acceptance = asRecord(contract.acceptance);
|
|
4679
|
+
const criteria = Array.isArray(contract.acceptance_criteria) ? contract.acceptance_criteria.map(asRecord) : [];
|
|
4680
|
+
const allowedKinds = Array.isArray(delivery.allowed_kinds) ? delivery.allowed_kinds.map(readString).filter(Boolean) : [];
|
|
4681
|
+
const acceptanceContracts = Array.isArray(delivery.acceptance_contracts) ? delivery.acceptance_contracts : [];
|
|
4682
|
+
const requirementRevision = readString(enrollment.requirement_revision);
|
|
4683
|
+
const sourceRef = readString(contract.source_ref);
|
|
4684
|
+
const validCriteria = criteria.length > 0 && criteria.every((criterion) => readString(criterion.ref) && readString(criterion.text));
|
|
4685
|
+
const validIdentity = readString(contract.schema_version) === "mirrorx.task-acceptance-contract.v1" && readString(contract.company_id) && readString(contract.issue_id) && Number.isInteger(contract.execution_epoch) && readString(contract.observed_at) && readString(enrollment.id) && Number.isInteger(enrollment.revision) && requirementRevision && readString(enrollment.request_hash) && sourceRef === `business_task_enrollment:${readString(enrollment.id)}@${requirementRevision}`;
|
|
4686
|
+
const validDelivery = allowedKinds.length > 0 && new Set(allowedKinds).size === allowedKinds.length && (delivery.contract_state === "explicit_typed" || delivery.contract_state === "acceptance_refs_only") && (delivery.contract_state !== "explicit_typed" || acceptanceContracts.length > 0);
|
|
4687
|
+
const validAcceptance = readString(acceptance.owner_agent_id) && Object.keys(asRecord(acceptance.policy)).length > 0 && readString(acceptance.expected_outcome_at);
|
|
4688
|
+
if (!validIdentity || !validCriteria || !validDelivery || !validAcceptance) {
|
|
4689
|
+
throw taskAcceptanceContractError(
|
|
4690
|
+
"task_acceptance_contract_invalid",
|
|
4691
|
+
"Task Acceptance Contract is incomplete or internally inconsistent"
|
|
4692
|
+
);
|
|
4693
|
+
}
|
|
4694
|
+
const requirements = asRecord(asRecord(context.paperclipIssue).taskRequirements);
|
|
4695
|
+
if (required) {
|
|
4696
|
+
const requirementDelivery = asRecord(requirements.delivery);
|
|
4697
|
+
const requirementOutcome = asRecord(requirements.businessOutcome);
|
|
4698
|
+
const criterionRefs = criteria.map((criterion) => readString(criterion.ref));
|
|
4699
|
+
const requirementAcceptanceRefs = Array.isArray(requirementDelivery.acceptanceRefs) ? requirementDelivery.acceptanceRefs.map(readString).filter(Boolean) : [];
|
|
4700
|
+
const requirementAllowedKinds = Array.isArray(requirementDelivery.allowedKinds) ? requirementDelivery.allowedKinds.map(readString).filter(Boolean) : [];
|
|
4701
|
+
const requirementContracts = Array.isArray(requirementDelivery.acceptanceContracts) ? requirementDelivery.acceptanceContracts : [];
|
|
4702
|
+
const revisionsMatch = [
|
|
4703
|
+
asRecord(requirementDelivery.source),
|
|
4704
|
+
asRecord(requirementOutcome.source)
|
|
4705
|
+
].every((source) => readString(source.revision) === requirementRevision);
|
|
4706
|
+
if (!revisionsMatch || !sameCanonicalJson(criterionRefs, requirementAcceptanceRefs) || !sameCanonicalJson(allowedKinds, requirementAllowedKinds) || !sameCanonicalJson(acceptanceContracts, requirementContracts) || readString(requirementOutcome.acceptanceOwnerAgentId) !== readString(acceptance.owner_agent_id) || readString(requirementOutcome.expectedOutcomeAt) !== readString(acceptance.expected_outcome_at) || !sameCanonicalJson(requirementOutcome.acceptancePolicy, acceptance.policy)) {
|
|
4707
|
+
throw taskAcceptanceContractError(
|
|
4708
|
+
"task_acceptance_contract_invalid",
|
|
4709
|
+
"Task Acceptance Contract does not match the active Task requirement projection"
|
|
4710
|
+
);
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
return {
|
|
4714
|
+
content: [
|
|
4715
|
+
"This is the immutable Server-owned acceptance authority for the current execution epoch. Treat every criterion ref and text as exact; do not replace it with the Issue description, a summary, a historical task, or your own interpretation.",
|
|
4716
|
+
"Plan and verify delivery against every criterion. Delivery evidence does not itself grant acceptance; follow the declared Acceptance policy and current Server-owned Outcome path.",
|
|
4717
|
+
"If this contract conflicts with another prompt section or becomes stale after a CAS conflict, re-read the same exact contract through the Governed Business State detail_read rendered for this Issue. Do not guess from an opaque ref.",
|
|
4718
|
+
jsonText(contract)
|
|
4719
|
+
].join("\n"),
|
|
4720
|
+
sourceRef,
|
|
4721
|
+
observedAt: readString(contract.observed_at),
|
|
4722
|
+
freshness: {
|
|
4723
|
+
kind: "immutable_enrollment",
|
|
4724
|
+
requirementRevision,
|
|
4725
|
+
executionEpoch: contract.execution_epoch
|
|
4726
|
+
},
|
|
4727
|
+
scope: {
|
|
4728
|
+
companyId: readString(contract.company_id),
|
|
4729
|
+
issueId: readString(contract.issue_id)
|
|
4730
|
+
}
|
|
4731
|
+
};
|
|
4732
|
+
}
|
|
4627
4733
|
function governedReadSection(context) {
|
|
4628
4734
|
const reads = Array.isArray(context.governedReadResults) ? context.governedReadResults : [];
|
|
4629
4735
|
if (reads.length === 0) return { content: "", provenance: [] };
|
|
@@ -4680,40 +4786,48 @@ function governedBusinessDetailRead(input, issueId) {
|
|
|
4680
4786
|
return { mode: "unavailable", canonical_tool: canonicalTool, reason: "not_in_run_catalog" };
|
|
4681
4787
|
}
|
|
4682
4788
|
if (input.executorKind === "pi" && managedPiMcpProxyAvailable(input)) {
|
|
4683
|
-
return {
|
|
4684
|
-
mode: "mcp_proxy",
|
|
4685
|
-
server: "amaster",
|
|
4686
|
-
tool: canonicalTool,
|
|
4687
|
-
args: JSON.stringify(argumentsValue)
|
|
4688
|
-
};
|
|
4789
|
+
return { mode: "mcp_proxy", ...managedPiMcpProxyCall(canonicalTool, argumentsValue) };
|
|
4689
4790
|
}
|
|
4690
4791
|
return { mode: "canonical", tool: canonicalTool, arguments: argumentsValue };
|
|
4691
4792
|
}
|
|
4692
4793
|
function governedBusinessDecisionProjection(state, detailRead) {
|
|
4693
4794
|
const record6 = asRecord(state);
|
|
4694
4795
|
const snapshot = asRecord(record6.governed_state_snapshot);
|
|
4695
|
-
const enrollment = asRecord(snapshot.business_task_enrollment);
|
|
4696
4796
|
const authoritativeObjectRefs = Array.isArray(record6.authoritative_object_refs) ? record6.authoritative_object_refs : [];
|
|
4697
|
-
const
|
|
4698
|
-
const
|
|
4699
|
-
const generatedAt = readString(snapshot.generated_at);
|
|
4797
|
+
const capabilities = Array.isArray(record6.capabilities) ? record6.capabilities : [];
|
|
4798
|
+
const availability = asRecord(record6.availability);
|
|
4700
4799
|
const projection = {
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4800
|
+
status: readString(availability.status) ?? null,
|
|
4801
|
+
objects: authoritativeObjectRefs.map((entry) => {
|
|
4802
|
+
const object = asRecord(entry);
|
|
4803
|
+
const compact = {
|
|
4804
|
+
kind: readString(object.object_kind) ?? null,
|
|
4805
|
+
ref: readString(object.ref) ?? null,
|
|
4806
|
+
status: readString(object.status) ?? null
|
|
4807
|
+
};
|
|
4808
|
+
if (typeof object.revision === "string" || typeof object.revision === "number") {
|
|
4809
|
+
compact.revision = object.revision;
|
|
4810
|
+
}
|
|
4811
|
+
return compact;
|
|
4812
|
+
}),
|
|
4813
|
+
missing: (Array.isArray(record6.missing_objects) ? record6.missing_objects : []).map((entry) => {
|
|
4814
|
+
const missing = asRecord(entry);
|
|
4815
|
+
return {
|
|
4816
|
+
kind: readString(missing.object_kind) ?? null,
|
|
4817
|
+
state: readString(missing.instance_state) ?? null,
|
|
4818
|
+
reason_code: readString(missing.reason_code) ?? null,
|
|
4819
|
+
next_owner: readString(missing.next_owner) ?? null
|
|
4820
|
+
};
|
|
4821
|
+
}),
|
|
4822
|
+
unsupported: capabilities.filter((entry) => readString(asRecord(entry).object_kind_support) === "unsupported").map((entry) => readString(asRecord(entry).object_kind)).filter(Boolean),
|
|
4823
|
+
observed_at: readString(snapshot.generated_at) ?? null,
|
|
4709
4824
|
detail_read: detailRead
|
|
4710
4825
|
};
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
};
|
|
4826
|
+
const reasonCode = readString(availability.reason_code);
|
|
4827
|
+
if (reasonCode) projection.reason_code = reasonCode;
|
|
4828
|
+
const unavailableReads = capabilities.filter((entry) => readString(asRecord(entry).read_capability) === "unavailable").map((entry) => readString(asRecord(entry).object_kind)).filter(Boolean);
|
|
4829
|
+
if (unavailableReads.length > 0) {
|
|
4830
|
+
projection.unavailable_reads = unavailableReads;
|
|
4717
4831
|
}
|
|
4718
4832
|
const continuationId = readString(record6.continuation_id);
|
|
4719
4833
|
if (continuationId) projection.continuation_id = continuationId;
|
|
@@ -4730,9 +4844,10 @@ function governedBusinessModelView(state, input) {
|
|
|
4730
4844
|
readString(snapshot.issue_id) ?? readString(input.issueId)
|
|
4731
4845
|
);
|
|
4732
4846
|
if (detailRead.mode === "unavailable") {
|
|
4847
|
+
const { task_acceptance_contract: _TaskAcceptanceContract, ...stateWithoutAcceptanceContract } = record6;
|
|
4733
4848
|
return {
|
|
4734
4849
|
mode: "full_snapshot",
|
|
4735
|
-
content:
|
|
4850
|
+
content: stateWithoutAcceptanceContract,
|
|
4736
4851
|
unavailableReason: detailRead.reason
|
|
4737
4852
|
};
|
|
4738
4853
|
}
|
|
@@ -4759,17 +4874,22 @@ function governedBusinessStateSection(context, input) {
|
|
|
4759
4874
|
const currentView = Object.keys(current).length > 0 ? governedBusinessModelView(current, input) : null;
|
|
4760
4875
|
const resumeView = Object.keys(resume).length > 0 ? governedBusinessModelView(resume, input) : null;
|
|
4761
4876
|
const retainsFullSnapshot = [currentView, resumeView].some((view) => view?.mode === "full_snapshot");
|
|
4877
|
+
const governedStates = [current, resume].filter((state) => Object.keys(state).length > 0);
|
|
4878
|
+
const hasUnsupportedObjects = governedStates.some((state) => Array.isArray(state.capabilities) && state.capabilities.some((entry) => readString(asRecord(entry).object_kind_support) === "unsupported"));
|
|
4879
|
+
const hasUnavailableRead = governedStates.some((state) => readString(asRecord(state.availability).status) === "unavailable" || Array.isArray(state.capabilities) && state.capabilities.some((entry) => readString(asRecord(entry).read_capability) === "unavailable"));
|
|
4880
|
+
const hasMissingObjects = governedStates.some((state) => Array.isArray(state.missing_objects) && state.missing_objects.length > 0);
|
|
4881
|
+
const hasFreeTextReason = governedStates.some((state) => Boolean(readString(state.free_text_reason)));
|
|
4882
|
+
const hasChildIssues = Array.isArray(context.childIssueSummaries) && context.childIssueSummaries.length > 0;
|
|
4762
4883
|
const rules = [
|
|
4763
4884
|
"This is bounded Server-owned read-side truth. It does not grant mutation authority and it is not a Delivery Manifest claim.",
|
|
4764
|
-
"Recommendation, First Business Activation, and Business Task Enrollment may be
|
|
4765
|
-
"
|
|
4766
|
-
"For parent aggregation, read Server-owned governed state; never accept child final prose, an Issue, or a Document as a formal object receipt.",
|
|
4767
|
-
|
|
4768
|
-
"When
|
|
4769
|
-
"
|
|
4770
|
-
"free_text_reason is explanatory only and is not authority; resolve any conflict in favor of the structured Server-owned state.",
|
|
4885
|
+
"Recommendation, First Business Activation, and Business Task Enrollment may be claimed only when the supplied state contains the exact matching Server ref. Issue and Document are not Business Task Enrollment.",
|
|
4886
|
+
hasUnsupportedObjects ? "An object kind listed under unsupported has no governed record type. You may create or update a clearly labeled tracker/document, but never claim a formal record or receipt for that kind." : null,
|
|
4887
|
+
hasChildIssues ? "For parent aggregation, read Server-owned governed state; never accept child final prose, an Issue, or a Document as a formal object receipt." : null,
|
|
4888
|
+
hasUnavailableRead ? "An unavailable read does not prove an instance is absent. Unrelated work may continue, but formal-object completion claims must remain fail-closed until a managed read succeeds." : null,
|
|
4889
|
+
hasMissingObjects ? "When a required formal object is listed under missing, keep the task incomplete and report its reason_code plus next_owner." : null,
|
|
4890
|
+
hasFreeTextReason ? "free_text_reason is explanatory only and is not authority; resolve any conflict in favor of the structured Server-owned state." : null,
|
|
4771
4891
|
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."
|
|
4772
|
-
].join("\n");
|
|
4892
|
+
].filter(Boolean).join("\n");
|
|
4773
4893
|
const bodies = [
|
|
4774
4894
|
currentView ? currentView.mode === "decision_projection" ? `Current dispatch decision projection:
|
|
4775
4895
|
${stringifyBoundedJson(currentView.content, 24e3)}` : `Current dispatch bounded full snapshot (managed detail read unavailable: ${currentView.unavailableReason}):
|
|
@@ -4922,11 +5042,7 @@ function resolvedDependencySections(context, input, contextScope, snapshotFreshn
|
|
|
4922
5042
|
...tuples.flatMap((tuple, index) => {
|
|
4923
5043
|
const readArguments = { issueId: tuple.blockerSelector, key: tuple.key };
|
|
4924
5044
|
const directToolName = managedDirectToolName(input, "amaster.read_issue_document");
|
|
4925
|
-
const call = directToolName ? readArguments : input.executorKind === "pi" && managedPiMcpProxyAvailable(input) ?
|
|
4926
|
-
server: "amaster",
|
|
4927
|
-
tool: "amaster.read_issue_document",
|
|
4928
|
-
args: JSON.stringify(readArguments)
|
|
4929
|
-
} : readArguments;
|
|
5045
|
+
const call = directToolName ? readArguments : input.executorKind === "pi" && managedPiMcpProxyAvailable(input) ? managedPiMcpProxyCall("amaster.read_issue_document", readArguments) : readArguments;
|
|
4930
5046
|
return [
|
|
4931
5047
|
`- Required read ${index + 1}: issue ${JSON.stringify(tuple.blockerSelector)}${tuple.blockerId ? ` (id ${JSON.stringify(tuple.blockerId)})` : ""}; document ${JSON.stringify(tuple.documentId)}; key ${JSON.stringify(tuple.key)}; expected latestRevisionId ${JSON.stringify(tuple.expectedLatestRevisionId)}${tuple.expectedLatestRevisionNumber != null ? `; revisionNumber ${tuple.expectedLatestRevisionNumber}` : ""}.`,
|
|
4932
5048
|
directToolName ? ` Call \`${directToolName}\` with these exact object arguments: ${JSON.stringify(call)}` : input.executorKind === "pi" && managedPiMcpProxyAvailable(input) ? ` Exact Pi \`mcp\` arguments: ${JSON.stringify(call)}` : ` Call amaster.read_issue_document with these exact arguments: ${JSON.stringify(call)}`
|
|
@@ -5253,6 +5369,18 @@ function managedDirectToolName(input, canonicalName) {
|
|
|
5253
5369
|
function managedPiMcpProxyAvailable(input) {
|
|
5254
5370
|
return input.managedMcpToolMode === "proxy_only" || input.managedMcpToolMode === "hybrid";
|
|
5255
5371
|
}
|
|
5372
|
+
function managedPiMcpProxyToolName(canonicalName) {
|
|
5373
|
+
const name = readString(canonicalName);
|
|
5374
|
+
if (!name) throw new TypeError("canonical MCP tool name is required");
|
|
5375
|
+
return name.replaceAll(".", "_");
|
|
5376
|
+
}
|
|
5377
|
+
function managedPiMcpProxyCall(canonicalName, args) {
|
|
5378
|
+
return {
|
|
5379
|
+
server: "amaster",
|
|
5380
|
+
tool: managedPiMcpProxyToolName(canonicalName),
|
|
5381
|
+
args: JSON.stringify(args)
|
|
5382
|
+
};
|
|
5383
|
+
}
|
|
5256
5384
|
function runtimeActionContinuationOptionText(input) {
|
|
5257
5385
|
if (!isRecoveryWakeReason(input.wakeReason)) return "";
|
|
5258
5386
|
const heading = "### Runtime Action Continuation Option";
|
|
@@ -5293,11 +5421,7 @@ Runtime Action continuation is unavailable: the run catalog does not advertise t
|
|
|
5293
5421
|
return `${heading}
|
|
5294
5422
|
Runtime Action continuation is unavailable: managed Pi MCP tool mode is not proxy_only. Do not guess a proxy or direct-tool call.`;
|
|
5295
5423
|
}
|
|
5296
|
-
const proxyCall =
|
|
5297
|
-
server: "amaster",
|
|
5298
|
-
tool: "runtime_action.submit",
|
|
5299
|
-
args: JSON.stringify(envelope)
|
|
5300
|
-
};
|
|
5424
|
+
const proxyCall = managedPiMcpProxyCall("runtime_action.submit", envelope);
|
|
5301
5425
|
return [
|
|
5302
5426
|
heading,
|
|
5303
5427
|
"Only after selecting continuation/todo from the disposition menu, emit an actual `mcp` tool call with the exact proxy arguments below. Do not print this JSON as prose and do not add an outer `action` field.",
|
|
@@ -5399,11 +5523,7 @@ function runtimeDecompositionRequirementText(context) {
|
|
|
5399
5523
|
function deliveryReadCallText(input) {
|
|
5400
5524
|
const args = { issueId: input.issueId };
|
|
5401
5525
|
if (input.executorKind === "pi" && managedPiMcpProxyAvailable(input)) {
|
|
5402
|
-
return `emit an mcp proxy call: ${JSON.stringify(
|
|
5403
|
-
server: "amaster",
|
|
5404
|
-
tool: "amaster.read_issue_delivery",
|
|
5405
|
-
args: JSON.stringify(args)
|
|
5406
|
-
})}`;
|
|
5526
|
+
return `emit an mcp proxy call: ${JSON.stringify(managedPiMcpProxyCall("amaster.read_issue_delivery", args))}`;
|
|
5407
5527
|
}
|
|
5408
5528
|
return `call amaster.read_issue_delivery with these exact arguments: ${JSON.stringify(args)}`;
|
|
5409
5529
|
}
|
|
@@ -5492,7 +5612,7 @@ function readIssueEvidenceCommentsCallText(issueId, commentIds, options) {
|
|
|
5492
5612
|
return `call \`${directToolName}\`${batchLabel} with these exact object arguments: ${JSON.stringify(readArguments)}`;
|
|
5493
5613
|
}
|
|
5494
5614
|
if (options?.executorKind === "pi" && managedPiMcpProxyAvailable(options)) {
|
|
5495
|
-
return `emit an mcp proxy call${batchLabel}: ${JSON.stringify(
|
|
5615
|
+
return `emit an mcp proxy call${batchLabel}: ${JSON.stringify(managedPiMcpProxyCall("amaster.read_issue_evidence", readArguments))}`;
|
|
5496
5616
|
}
|
|
5497
5617
|
return `call amaster.read_issue_evidence${batchLabel} with these exact arguments: ${JSON.stringify(readArguments)}`;
|
|
5498
5618
|
}).join("; then ");
|
|
@@ -5504,11 +5624,7 @@ function overflowDependencyRefsText(overflowRefs, input) {
|
|
|
5504
5624
|
...overflowRefs.flatMap((ref, index) => {
|
|
5505
5625
|
const readArguments = { issueId: ref.blockerSelector, key: ref.key };
|
|
5506
5626
|
const directToolName = managedDirectToolName(input, "amaster.read_issue_document");
|
|
5507
|
-
const call = directToolName ? readArguments : input.executorKind === "pi" && managedPiMcpProxyAvailable(input) ?
|
|
5508
|
-
server: "amaster",
|
|
5509
|
-
tool: "amaster.read_issue_document",
|
|
5510
|
-
args: JSON.stringify(readArguments)
|
|
5511
|
-
} : readArguments;
|
|
5627
|
+
const call = directToolName ? readArguments : input.executorKind === "pi" && managedPiMcpProxyAvailable(input) ? managedPiMcpProxyCall("amaster.read_issue_document", readArguments) : readArguments;
|
|
5512
5628
|
return [
|
|
5513
5629
|
`- On-demand read ${index + 1}: issue ${JSON.stringify(ref.blockerSelector)}${ref.blockerId ? ` (id ${JSON.stringify(ref.blockerId)})` : ""}; document ${JSON.stringify(ref.documentId)}; key ${JSON.stringify(ref.key)}; expected latestRevisionId ${JSON.stringify(ref.expectedLatestRevisionId)}${ref.expectedLatestRevisionNumber != null ? `; revisionNumber ${ref.expectedLatestRevisionNumber}` : ""}.`,
|
|
5514
5630
|
directToolName ? ` Call \`${directToolName}\` with these exact object arguments: ${JSON.stringify(call)}` : input.executorKind === "pi" && managedPiMcpProxyAvailable(input) ? ` Exact Pi \`mcp\` arguments: ${JSON.stringify(call)}` : input.managedMcpToolMode === "direct_typed" ? " Exact read unavailable: amaster.read_issue_document is absent from the attested direct tool catalog. Do not guess a tool name or bypass the managed transport." : ` Call amaster.read_issue_document with these exact arguments: ${JSON.stringify(call)}`
|
|
@@ -5544,11 +5660,7 @@ function taskCommentRefGuidance(input, taskText) {
|
|
|
5544
5660
|
}
|
|
5545
5661
|
function piMcpUsageText(input) {
|
|
5546
5662
|
if (!input.hasGovernedMcp || input.executorKind !== "pi" || !managedPiMcpProxyAvailable(input) || isRecoveryWakeReason(input.wakeReason)) return "";
|
|
5547
|
-
const proxy = (tool, args) => JSON.stringify(
|
|
5548
|
-
server: "amaster",
|
|
5549
|
-
tool,
|
|
5550
|
-
args: JSON.stringify(args)
|
|
5551
|
-
});
|
|
5663
|
+
const proxy = (tool, args) => JSON.stringify(managedPiMcpProxyCall(tool, args));
|
|
5552
5664
|
return [
|
|
5553
5665
|
"This run uses the outer `mcp` proxy for Governed MCP calls. Emit actual tool calls; `args` is the stringified inner canonical object. Pi validates this string schema before extension hooks, so never send object-valued `args`.",
|
|
5554
5666
|
"Before the first write, describe that exact canonical action and use the returned schema; do not infer write arguments from this example.",
|
|
@@ -5614,6 +5726,7 @@ var CONTEXT_AVAILABILITY_SECTION_TITLES = Object.freeze({
|
|
|
5614
5726
|
wake_comments: "Wake Delta",
|
|
5615
5727
|
task: "Task Context",
|
|
5616
5728
|
governed_business_state: "Governed Business State",
|
|
5729
|
+
task_acceptance_contract: "Task Acceptance Contract",
|
|
5617
5730
|
continuation_summary: "Continuation Summary",
|
|
5618
5731
|
resolved_dependencies: "Resolved Dependency Outputs",
|
|
5619
5732
|
runtime_delivery_readiness: "Current Delivery Readiness",
|
|
@@ -5708,6 +5821,7 @@ function compileCommandPromptWithManifest(input, options = {}) {
|
|
|
5708
5821
|
const suppressOrdinaryCompletionContract = completeRecoveryInstruction.length > 0;
|
|
5709
5822
|
const governedReads = governedReadSection(context);
|
|
5710
5823
|
const governedBusinessState = governedBusinessStateSection(context, input);
|
|
5824
|
+
const taskAcceptanceContract = taskAcceptanceContractSection(context, input);
|
|
5711
5825
|
const verifiedCompanyContext = verifiedCompanyContextSection(context);
|
|
5712
5826
|
const hasTask = Boolean(readString(input.taskMarkdown));
|
|
5713
5827
|
const taskText = readString(input.taskMarkdown) ?? "";
|
|
@@ -5760,6 +5874,7 @@ ${resolvedDependencies.details.content}` : ""
|
|
|
5760
5874
|
{ name: "approval_continuation", title: "Approved Runtime Action Continuation", priority: 99, sourceRef: `run:${input.runId ?? "unknown"}`, content: approvalContinuationText(input), truncationReason: mode === "continuation" ? null : "mode_selection" },
|
|
5761
5875
|
{ name: "wake_comments", title: wakeDeltaTitle, priority: interactionResolution ? 99 : 95, sourceRef: wakeDeltaSourceRefs, originalContent: wakeDeltaOriginal, content: wakeDeltaContent, truncationReason: commentsSelected ? null : "duplicate_task_context" },
|
|
5762
5876
|
{ name: "task", title: "Task Context", priority: 90, sourceRef: taskSourceRefs, originalContent: [taskText, taskCommentRefGuidance(input, taskText)].filter(Boolean).join("\n"), content: includeTask ? [taskText, taskCommentRefGuidance(input, taskText)].filter(Boolean).join("\n") : "", truncationReason: includeTask ? null : "mode_selection" },
|
|
5877
|
+
...taskAcceptanceContract ? [{ name: "task_acceptance_contract", title: "Task Acceptance Contract", priority: 100, ...taskAcceptanceContract }] : [],
|
|
5763
5878
|
...governedBusinessState ? [{ name: "governed_business_state", title: "Governed Business State", priority: 99, ...governedBusinessState }] : [],
|
|
5764
5879
|
{ name: "continuation_summary", title: "Continuation Summary", priority: 97, sourceRef: readString(asRecord(context.paperclipContinuationSummary).key) ?? `issue:${input.issueId ?? "unknown"}`, observedAt: readString(asRecord(context.paperclipContinuationSummary).updatedAt), originalContent: continuationSummary, content: mode === "cold" ? "" : continuationSummary, truncationReason: mode === "cold" ? "mode_selection" : null },
|
|
5765
5880
|
...resolvedDependencyContent ? [{
|
|
@@ -9511,7 +9626,7 @@ function assertSourceAcquisitionRuntimeAuthority({
|
|
|
9511
9626
|
}
|
|
9512
9627
|
|
|
9513
9628
|
// src/amaster-runtime-daemon.mjs
|
|
9514
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
9629
|
+
var CONNECTOR_VERSION = "0.1.1-beta.34";
|
|
9515
9630
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
9516
9631
|
var SOURCE_ACQUISITION_CAPABILITY = "source_acquisition_v1";
|
|
9517
9632
|
var SOURCE_ACQUISITION_PROFILE_VERSION = "source_acquisition_v1";
|
|
@@ -13993,7 +14108,7 @@ async function executeRunCommand(config, command) {
|
|
|
13993
14108
|
}
|
|
13994
14109
|
if (executor.kind === "pi") {
|
|
13995
14110
|
piResolvedProviderConfig = executorEnv;
|
|
13996
|
-
for (const envName of ["AMASTER_API_KEY", "AMASTER_PLATFORM_OAUTH_TOKEN"]) {
|
|
14111
|
+
for (const envName of ["AMASTER_API_KEY", "AMASTER_PLATFORM_OAUTH_TOKEN", "PLATFORM_ACCESS_TOKEN"]) {
|
|
13997
14112
|
const protectedValue = readString(piResolvedProviderConfig[envName]);
|
|
13998
14113
|
if (protectedValue && !providerProtectedValues.includes(protectedValue)) {
|
|
13999
14114
|
providerProtectedValues.push(protectedValue);
|
package/dist/amaster-runtime.mjs
CHANGED
|
@@ -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.
|
|
9
|
+
const CONNECTOR_VERSION = "0.1.1-beta.34";
|
|
10
10
|
|
|
11
11
|
const CAPABILITIES = [
|
|
12
12
|
"remote_registration",
|