@amaster.ai/employee-runtime-connector 0.1.1-beta.39 → 0.1.1-beta.40
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// MirrorX runtime connector daemon bundle.
|
|
3
3
|
|
|
4
4
|
// src/amaster-runtime-daemon.mjs
|
|
5
|
-
import { createHash as
|
|
5
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
6
6
|
import { chmodSync as chmodSync4, copyFileSync as copyFileSync2, existsSync as existsSync11, lstatSync as lstatSync5, mkdirSync as mkdirSync7, mkdtempSync, readFileSync as readFileSync9, readdirSync as readdirSync8, realpathSync as realpathSync5, renameSync as renameSync6, rmSync as rmSync5, statSync as statSync8, symlinkSync as symlinkSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync7 } from "node:fs";
|
|
7
7
|
import { arch as arch3, homedir as homedir3, hostname as hostname2, platform as platform3, tmpdir } from "node:os";
|
|
8
8
|
import { basename as basename6, delimiter as delimiter3, dirname as dirname7, extname as extname2, isAbsolute as isAbsolute6, join as join12, relative as relative6, resolve as resolve9 } from "node:path";
|
|
@@ -4436,6 +4436,9 @@ function retainedSourceExecutorEntry(entry, executorKind) {
|
|
|
4436
4436
|
};
|
|
4437
4437
|
}
|
|
4438
4438
|
|
|
4439
|
+
// src/amaster-runtime-daemon/prompt-compiler.mjs
|
|
4440
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
4441
|
+
|
|
4439
4442
|
// src/amaster-runtime-daemon/current-run-contract.mjs
|
|
4440
4443
|
import { createHash as createHash4 } from "node:crypto";
|
|
4441
4444
|
var CONTRACT_VERSION = "mirrorx.current-run-contract.v1";
|
|
@@ -4699,6 +4702,9 @@ function formalTaskAcceptanceContractRequired(context) {
|
|
|
4699
4702
|
function sameCanonicalJson(left, right) {
|
|
4700
4703
|
return JSON.stringify(canonicalJsonValue(left)) === JSON.stringify(canonicalJsonValue(right));
|
|
4701
4704
|
}
|
|
4705
|
+
function canonicalSha256(value) {
|
|
4706
|
+
return `sha256:${createHash5("sha256").update(JSON.stringify(canonicalJsonValue(value))).digest("hex")}`;
|
|
4707
|
+
}
|
|
4702
4708
|
function taskAcceptanceContractSection(context, input) {
|
|
4703
4709
|
const required = formalTaskAcceptanceContractRequired(context);
|
|
4704
4710
|
const contract = asRecord(context.taskAcceptanceContract);
|
|
@@ -4720,36 +4726,49 @@ function taskAcceptanceContractSection(context, input) {
|
|
|
4720
4726
|
);
|
|
4721
4727
|
}
|
|
4722
4728
|
const enrollment = asRecord(contract.enrollment);
|
|
4729
|
+
const authority = asRecord(contract.authority);
|
|
4730
|
+
const requirements = asRecord(asRecord(context.paperclipIssue).taskRequirements);
|
|
4731
|
+
const requirementIntent = asRecord(requirements.taskIntent);
|
|
4732
|
+
const requirementOutcome = asRecord(requirements.businessOutcome);
|
|
4733
|
+
const requirementCompletion = asRecord(requirements.completion);
|
|
4723
4734
|
const delivery = asRecord(contract.delivery);
|
|
4724
4735
|
const acceptance = asRecord(contract.acceptance);
|
|
4725
4736
|
const criteria = Array.isArray(contract.acceptance_criteria) ? contract.acceptance_criteria.map(asRecord) : [];
|
|
4726
4737
|
const allowedKinds = Array.isArray(delivery.allowed_kinds) ? delivery.allowed_kinds.map(readString).filter(Boolean) : [];
|
|
4727
4738
|
const acceptanceContracts = Array.isArray(delivery.acceptance_contracts) ? delivery.acceptance_contracts : [];
|
|
4728
|
-
const
|
|
4739
|
+
const schemaVersion = readString(contract.schema_version);
|
|
4740
|
+
const enrollmentRequirementRevision = readString(enrollment.requirement_revision);
|
|
4741
|
+
const parentRequirementRevision = readString(authority.requirement_revision);
|
|
4742
|
+
const requirementRevision = enrollmentRequirementRevision || parentRequirementRevision;
|
|
4729
4743
|
const sourceRef = readString(contract.source_ref);
|
|
4730
4744
|
const validCriteria = criteria.length > 0 && criteria.every((criterion) => readString(criterion.ref) && readString(criterion.text));
|
|
4731
|
-
const
|
|
4745
|
+
const validEnrollmentIdentity = schemaVersion === "mirrorx.task-acceptance-contract.v1" && readString(enrollment.id) && Number.isInteger(enrollment.revision) && enrollmentRequirementRevision && readString(enrollment.request_hash) && sourceRef === `business_task_enrollment:${readString(enrollment.id)}@${enrollmentRequirementRevision}`;
|
|
4746
|
+
const validParentGovernedChildIdentity = schemaVersion === "mirrorx.task-acceptance-contract.v2" && Object.keys(enrollment).length === 0 && readString(authority.kind) === "parent_governed_child" && parentRequirementRevision && readString(authority.requirements_hash) === canonicalSha256(requirements) && ["required_execution", "final_aggregation"].includes(readString(authority.completion_role)) && ["none", "package", "own_deliverable"].includes(readString(authority.review_authority)) && sourceRef === `parent_governed_child:${readString(contract.issue_id)}@${parentRequirementRevision}`;
|
|
4747
|
+
const validIdentity = readString(contract.company_id) && readString(contract.issue_id) && Number.isInteger(contract.execution_epoch) && readString(contract.observed_at) && requirementRevision && Boolean(validEnrollmentIdentity || validParentGovernedChildIdentity);
|
|
4732
4748
|
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);
|
|
4733
|
-
const
|
|
4749
|
+
const validOwnedAcceptance = readString(acceptance.owner_agent_id) && Object.keys(asRecord(acceptance.policy)).length > 0 && readString(acceptance.expected_outcome_at);
|
|
4750
|
+
const validParentDelegatedAcceptance = validParentGovernedChildIdentity && readString(requirementIntent.reason) === "parent_governed_child" && ["required_execution", "final_aggregation"].includes(readString(requirementCompletion.role)) && readString(requirementOutcome.mode) === "none" && readString(acceptance.delegated_to) === "parent" && acceptance.owner_agent_id === null && acceptance.policy === null && acceptance.expected_outcome_at === null;
|
|
4751
|
+
const validAcceptance = validOwnedAcceptance || validParentDelegatedAcceptance;
|
|
4734
4752
|
if (!validIdentity || !validCriteria || !validDelivery || !validAcceptance) {
|
|
4735
4753
|
throw taskAcceptanceContractError(
|
|
4736
4754
|
"task_acceptance_contract_invalid",
|
|
4737
4755
|
"Task Acceptance Contract is incomplete or internally inconsistent"
|
|
4738
4756
|
);
|
|
4739
4757
|
}
|
|
4740
|
-
const requirements = asRecord(asRecord(context.paperclipIssue).taskRequirements);
|
|
4741
4758
|
if (required) {
|
|
4742
4759
|
const requirementDelivery = asRecord(requirements.delivery);
|
|
4743
|
-
const requirementOutcome = asRecord(requirements.businessOutcome);
|
|
4744
4760
|
const criterionRefs = criteria.map((criterion) => readString(criterion.ref));
|
|
4745
4761
|
const requirementAcceptanceRefs = Array.isArray(requirementDelivery.acceptanceRefs) ? requirementDelivery.acceptanceRefs.map(readString).filter(Boolean) : [];
|
|
4746
4762
|
const requirementAllowedKinds = Array.isArray(requirementDelivery.allowedKinds) ? requirementDelivery.allowedKinds.map(readString).filter(Boolean) : [];
|
|
4747
4763
|
const requirementContracts = Array.isArray(requirementDelivery.acceptanceContracts) ? requirementDelivery.acceptanceContracts : [];
|
|
4764
|
+
const requirementCriteria = Array.isArray(requirementDelivery.acceptanceCriteria) ? requirementDelivery.acceptanceCriteria : [];
|
|
4748
4765
|
const revisionsMatch = [
|
|
4749
4766
|
asRecord(requirementDelivery.source),
|
|
4750
|
-
asRecord(requirementOutcome.source)
|
|
4767
|
+
asRecord(requirementOutcome.source),
|
|
4768
|
+
...validParentGovernedChildIdentity ? [asRecord(requirementIntent.source), asRecord(requirementCompletion.source)] : []
|
|
4751
4769
|
].every((source) => readString(source.revision) === requirementRevision);
|
|
4752
|
-
|
|
4770
|
+
const parentAuthorityMatches = !validParentGovernedChildIdentity || readString(authority.completion_role) === readString(requirementCompletion.role) && readString(authority.review_authority) === readString(requirementCompletion.reviewAuthority);
|
|
4771
|
+
if (!revisionsMatch || !parentAuthorityMatches || !sameCanonicalJson(criterionRefs, requirementAcceptanceRefs) || validParentGovernedChildIdentity && !sameCanonicalJson(criteria, requirementCriteria) || !sameCanonicalJson(allowedKinds, requirementAllowedKinds) || !sameCanonicalJson(acceptanceContracts, requirementContracts) || !validParentDelegatedAcceptance && (readString(requirementOutcome.acceptanceOwnerAgentId) !== readString(acceptance.owner_agent_id) || readString(requirementOutcome.expectedOutcomeAt) !== readString(acceptance.expected_outcome_at) || !sameCanonicalJson(requirementOutcome.acceptancePolicy, acceptance.policy))) {
|
|
4753
4772
|
throw taskAcceptanceContractError(
|
|
4754
4773
|
"task_acceptance_contract_invalid",
|
|
4755
4774
|
"Task Acceptance Contract does not match the active Task requirement projection"
|
|
@@ -4766,7 +4785,7 @@ function taskAcceptanceContractSection(context, input) {
|
|
|
4766
4785
|
sourceRef,
|
|
4767
4786
|
observedAt: readString(contract.observed_at),
|
|
4768
4787
|
freshness: {
|
|
4769
|
-
kind: "immutable_enrollment",
|
|
4788
|
+
kind: validParentGovernedChildIdentity ? "parent_governed_child_requirements" : "immutable_enrollment",
|
|
4770
4789
|
requirementRevision,
|
|
4771
4790
|
executionEpoch: contract.execution_epoch
|
|
4772
4791
|
},
|
|
@@ -6082,7 +6101,7 @@ function agentInstructionDeliveryAudit(bundle, delivery) {
|
|
|
6082
6101
|
}
|
|
6083
6102
|
|
|
6084
6103
|
// src/amaster-runtime-daemon/agent-instruction-system-kernel-shadow.mjs
|
|
6085
|
-
import { createHash as
|
|
6104
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
6086
6105
|
var SHADOW_VERSION = 2;
|
|
6087
6106
|
var TARGET_CHARS = 16e3;
|
|
6088
6107
|
var FULL_HANDBOOK_PATH = ".amaster/instructions/AGENTS.full.md";
|
|
@@ -6101,7 +6120,7 @@ var ROLE_KERNEL_SECTIONS = /* @__PURE__ */ new Set([
|
|
|
6101
6120
|
"When you finish"
|
|
6102
6121
|
]);
|
|
6103
6122
|
function sha256(value) {
|
|
6104
|
-
return
|
|
6123
|
+
return createHash6("sha256").update(value, "utf8").digest("hex");
|
|
6105
6124
|
}
|
|
6106
6125
|
function normalizedText(value) {
|
|
6107
6126
|
return typeof value === "string" ? value.trim() : "";
|
|
@@ -8293,7 +8312,7 @@ var postJsonWithRetry = postRuntimeConnectorJsonWithRetry;
|
|
|
8293
8312
|
var bestEffortPostJson = bestEffortPostRuntimeConnectorJson;
|
|
8294
8313
|
|
|
8295
8314
|
// src/amaster-runtime-daemon/runtime-artifact-upload.mjs
|
|
8296
|
-
import { createHash as
|
|
8315
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
8297
8316
|
import { closeSync, constants, fstatSync, lstatSync as lstatSync4, openSync, readFileSync as readFileSync6, realpathSync as realpathSync3 } from "node:fs";
|
|
8298
8317
|
import { isAbsolute as isAbsolute3, relative as relative3, resolve as resolve4 } from "node:path";
|
|
8299
8318
|
var SHA256_PATTERN = /^[a-f0-9]{64}$/;
|
|
@@ -8383,7 +8402,7 @@ function prepareRuntimeArtifactUploads(cwd, mcpToolResults) {
|
|
|
8383
8402
|
`Runtime Artifact ${intentId}`,
|
|
8384
8403
|
{ expectedByteSize }
|
|
8385
8404
|
);
|
|
8386
|
-
const actualSha256 =
|
|
8405
|
+
const actualSha256 = createHash7("sha256").update(body).digest("hex");
|
|
8387
8406
|
if (body.length !== expectedByteSize || actualSha256 !== expectedSha256) {
|
|
8388
8407
|
throw new Error(`Runtime Artifact ${intentId} bytes do not match the governed ownership manifest`);
|
|
8389
8408
|
}
|
|
@@ -8400,7 +8419,7 @@ function prepareRuntimeArtifactUploads(cwd, mcpToolResults) {
|
|
|
8400
8419
|
}
|
|
8401
8420
|
|
|
8402
8421
|
// src/amaster-runtime-daemon/runtime-document-upload.mjs
|
|
8403
|
-
import { createHash as
|
|
8422
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
8404
8423
|
|
|
8405
8424
|
// src/amaster-runtime-daemon/workspace-sensitive-path.mjs
|
|
8406
8425
|
var SENSITIVE_PATH_SEGMENTS = /* @__PURE__ */ new Set([
|
|
@@ -8475,7 +8494,7 @@ function prepareRuntimeDocumentUploads(cwd, mcpToolResults) {
|
|
|
8475
8494
|
maxByteSize: MAX_WORKSPACE_DOCUMENT_BYTES
|
|
8476
8495
|
}
|
|
8477
8496
|
);
|
|
8478
|
-
const actualSha256 =
|
|
8497
|
+
const actualSha256 = createHash8("sha256").update(body).digest("hex");
|
|
8479
8498
|
if (body.length !== expectedByteSize || actualSha256 !== expectedSha256) {
|
|
8480
8499
|
throw new Error(`Runtime Document ${callId} bytes do not match the governed ownership manifest`);
|
|
8481
8500
|
}
|
|
@@ -8601,7 +8620,7 @@ function createRuntimeArtifactIngestQueue({ ingest, onError }) {
|
|
|
8601
8620
|
}
|
|
8602
8621
|
|
|
8603
8622
|
// src/amaster-runtime-daemon/workspace-guard.mjs
|
|
8604
|
-
import { createHash as
|
|
8623
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
8605
8624
|
import { existsSync as existsSync7, mkdirSync as mkdirSync6, realpathSync as realpathSync4, statSync as statSync4 } from "node:fs";
|
|
8606
8625
|
import { basename as basename4, join as join8, isAbsolute as isAbsolute4, relative as relative4, resolve as resolve5 } from "node:path";
|
|
8607
8626
|
|
|
@@ -8727,7 +8746,7 @@ function resolveWorkspaceCwd(config, command) {
|
|
|
8727
8746
|
return cwd;
|
|
8728
8747
|
}
|
|
8729
8748
|
function shortHash(value, length = 12) {
|
|
8730
|
-
return
|
|
8749
|
+
return createHash9("sha256").update(String(value)).digest("hex").slice(0, length);
|
|
8731
8750
|
}
|
|
8732
8751
|
function safeSegment(value, fallback) {
|
|
8733
8752
|
const raw = String(value ?? "").trim();
|
|
@@ -9172,7 +9191,7 @@ function summarizeAmasterRuntimeVersionDrift(input = {}) {
|
|
|
9172
9191
|
|
|
9173
9192
|
// src/amaster-runtime-daemon/workspace-status.mjs
|
|
9174
9193
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
9175
|
-
import { createHash as
|
|
9194
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
9176
9195
|
import { existsSync as existsSync10, readdirSync as readdirSync7, readFileSync as readFileSync8, statSync as statSync7 } from "node:fs";
|
|
9177
9196
|
import { basename as basename5, extname, isAbsolute as isAbsolute5, join as join11, relative as relative5, resolve as resolve8 } from "node:path";
|
|
9178
9197
|
var WORKSPACE_RUNTIME_SERVICES_FILENAME = ".amaster-runtime-services.json";
|
|
@@ -9243,7 +9262,7 @@ function sanitizeTrackedChange(line) {
|
|
|
9243
9262
|
return isSafeRelativePath(path) ? line : null;
|
|
9244
9263
|
}
|
|
9245
9264
|
function sha256File(filePath) {
|
|
9246
|
-
return
|
|
9265
|
+
return createHash10("sha256").update(readFileSync8(filePath)).digest("hex");
|
|
9247
9266
|
}
|
|
9248
9267
|
function artifactHashCacheKey(relativePath, stat) {
|
|
9249
9268
|
return `${relativePath}\0${stat.size}\0${stat.mtimeMs}`;
|
|
@@ -9603,7 +9622,7 @@ async function executeBrowserSessionCommand(command, dependencies = {}) {
|
|
|
9603
9622
|
}
|
|
9604
9623
|
|
|
9605
9624
|
// src/amaster-runtime-daemon/source-acquisition-invocation.mjs
|
|
9606
|
-
import { createHash as
|
|
9625
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
9607
9626
|
var SOURCE_ACQUISITION_PUBLIC_TOOLS = Object.freeze([
|
|
9608
9627
|
"source_open",
|
|
9609
9628
|
"source_snapshot",
|
|
@@ -9640,7 +9659,7 @@ function serializeSourceAcquisitionProfile(profile) {
|
|
|
9640
9659
|
const input = Buffer.from(JSON.stringify(profile), "utf8");
|
|
9641
9660
|
return {
|
|
9642
9661
|
input,
|
|
9643
|
-
sha256:
|
|
9662
|
+
sha256: createHash11("sha256").update(input).digest("hex")
|
|
9644
9663
|
};
|
|
9645
9664
|
}
|
|
9646
9665
|
function sourceAcquisitionManagedInputs(options) {
|
|
@@ -9689,7 +9708,7 @@ var source_acquisition_compatibility_default = {
|
|
|
9689
9708
|
};
|
|
9690
9709
|
|
|
9691
9710
|
// src/amaster-runtime-daemon.mjs
|
|
9692
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
9711
|
+
var CONNECTOR_VERSION = "0.1.1-beta.40";
|
|
9693
9712
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
9694
9713
|
var SOURCE_ACQUISITION_CAPABILITY = source_acquisition_compatibility_default.profileVersion;
|
|
9695
9714
|
var SOURCE_ACQUISITION_PROFILE_VERSION = source_acquisition_compatibility_default.profileVersion;
|
|
@@ -10911,7 +10930,7 @@ function sourceAcquisitionRuntimeProfile(config, command) {
|
|
|
10911
10930
|
if (!companyId || !bindingId || !/^profile_[a-z0-9]{16,64}$/i.test(localOpaqueRef ?? "")) {
|
|
10912
10931
|
throw new Error("source_acquisition_profile_invalid");
|
|
10913
10932
|
}
|
|
10914
|
-
const profileName =
|
|
10933
|
+
const profileName = createHash12("sha256").update(`${companyId}\0${bindingId}\0${localOpaqueRef}`).digest("hex");
|
|
10915
10934
|
const stateRoot = resolve9(config.browserSessionStateRoot);
|
|
10916
10935
|
const userDataDir = resolve9(stateRoot, profileName);
|
|
10917
10936
|
if (!pathWithin2(userDataDir, stateRoot)) throw new Error("source_acquisition_browser_profile_invalid");
|
|
@@ -13759,7 +13778,7 @@ async function materializeIssueAttachments(config, command, workspace) {
|
|
|
13759
13778
|
const body = await runtimeApiBuffer(runtimeAuth, contentPath);
|
|
13760
13779
|
writeFileSync7(targetPath, body);
|
|
13761
13780
|
const attachmentId = readString(attachment.id);
|
|
13762
|
-
const actualSha256 =
|
|
13781
|
+
const actualSha256 = createHash12("sha256").update(body).digest("hex");
|
|
13763
13782
|
const lineageCandidates = lineageCandidatesByAttachmentId.get(attachmentId) ?? [];
|
|
13764
13783
|
const lineage = selectAttachmentLineage(lineageCandidates, actualSha256);
|
|
13765
13784
|
if (lineageCandidates.length > 0 && !lineage) {
|
|
@@ -13851,7 +13870,7 @@ async function materializeRequiredArtifactInputs(config, command, workspace) {
|
|
|
13851
13870
|
throw new Error(`artifact_input_manifest_invalid: entry ${index} contentPath does not match attachmentId`);
|
|
13852
13871
|
}
|
|
13853
13872
|
const body = await runtimeApiBuffer(runtimeAuth, contentPath);
|
|
13854
|
-
const actualSha256 =
|
|
13873
|
+
const actualSha256 = createHash12("sha256").update(body).digest("hex");
|
|
13855
13874
|
if (body.byteLength !== byteSize || actualSha256 !== sha2562) {
|
|
13856
13875
|
throw new Error(
|
|
13857
13876
|
`artifact_input_integrity_mismatch: workProductId=${workProductId} expectedBytes=${byteSize} actualBytes=${body.byteLength} expectedSha256=${sha2562} actualSha256=${actualSha256}`
|
|
@@ -13921,7 +13940,7 @@ function safeCheckpointRelativePath(rawPath) {
|
|
|
13921
13940
|
return normalized;
|
|
13922
13941
|
}
|
|
13923
13942
|
function hashFileSha256(filePath) {
|
|
13924
|
-
return
|
|
13943
|
+
return createHash12("sha256").update(readFileSync9(filePath)).digest("hex");
|
|
13925
13944
|
}
|
|
13926
13945
|
async function materializeIssueCheckpoint(config, command, workspace) {
|
|
13927
13946
|
const checkpointDir = issueCheckpointDir(workspace);
|
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.40";
|
|
10
10
|
|
|
11
11
|
const CAPABILITIES = [
|
|
12
12
|
"remote_registration",
|