@amaster.ai/employee-runtime-connector 0.1.1-beta.44 → 0.1.1-beta.46
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 +152 -46
- package/dist/amaster-runtime.mjs +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
// src/amaster-runtime-daemon.mjs
|
|
5
5
|
import { createHash as createHash12 } from "node:crypto";
|
|
6
|
-
import { chmodSync as chmodSync4, copyFileSync as copyFileSync2, existsSync as existsSync11, lstatSync as lstatSync5, mkdirSync as mkdirSync7, mkdtempSync, readFileSync as
|
|
6
|
+
import { chmodSync as chmodSync4, copyFileSync as copyFileSync2, existsSync as existsSync11, lstatSync as lstatSync5, mkdirSync as mkdirSync7, mkdtempSync, readFileSync as readFileSync10, readdirSync as readdirSync9, 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";
|
|
9
9
|
import { spawn, spawnSync as spawnSync5 } from "node:child_process";
|
|
@@ -4162,13 +4162,52 @@ function selectExecutor(config, command) {
|
|
|
4162
4162
|
}
|
|
4163
4163
|
|
|
4164
4164
|
// src/amaster-runtime-daemon/executor-process.mjs
|
|
4165
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync4 } from "node:fs";
|
|
4166
|
+
var TERMINAL_LINUX_PROCESS_STATES = /* @__PURE__ */ new Set(["Z", "X", "x"]);
|
|
4165
4167
|
function processGroupIdForChild(child, processPlatform = process.platform) {
|
|
4166
4168
|
return processPlatform === "win32" || typeof child.pid !== "number" || child.pid <= 0 ? null : child.pid;
|
|
4167
4169
|
}
|
|
4168
|
-
function
|
|
4170
|
+
function linuxProcState(stat) {
|
|
4171
|
+
const commandEnd = stat.lastIndexOf(")");
|
|
4172
|
+
if (commandEnd === -1) return null;
|
|
4173
|
+
const fields = stat.slice(commandEnd + 1).trim().split(/\s+/);
|
|
4174
|
+
if (fields.length < 3) return null;
|
|
4175
|
+
const processGroupId = Number.parseInt(fields[2], 10);
|
|
4176
|
+
return Number.isInteger(processGroupId) ? { state: fields[0], processGroupId } : null;
|
|
4177
|
+
}
|
|
4178
|
+
function linuxProcessGroupHasLiveMembers(processGroupId, procRoot = "/proc", fsApi = { readdirSync: readdirSync4, readFileSync: readFileSync4 }) {
|
|
4179
|
+
let entries;
|
|
4180
|
+
try {
|
|
4181
|
+
entries = fsApi.readdirSync(procRoot, { withFileTypes: true });
|
|
4182
|
+
} catch {
|
|
4183
|
+
return null;
|
|
4184
|
+
}
|
|
4185
|
+
let foundMember = false;
|
|
4186
|
+
let unreadableMember = false;
|
|
4187
|
+
for (const entry of entries) {
|
|
4188
|
+
if (!entry.isDirectory() || !/^\d+$/.test(entry.name)) continue;
|
|
4189
|
+
let parsed;
|
|
4190
|
+
try {
|
|
4191
|
+
parsed = linuxProcState(fsApi.readFileSync(`${procRoot}/${entry.name}/stat`, "utf8"));
|
|
4192
|
+
} catch {
|
|
4193
|
+
unreadableMember = true;
|
|
4194
|
+
continue;
|
|
4195
|
+
}
|
|
4196
|
+
if (parsed?.processGroupId !== processGroupId) continue;
|
|
4197
|
+
foundMember = true;
|
|
4198
|
+
if (!TERMINAL_LINUX_PROCESS_STATES.has(parsed.state)) return true;
|
|
4199
|
+
}
|
|
4200
|
+
if (foundMember) return false;
|
|
4201
|
+
return unreadableMember ? null : false;
|
|
4202
|
+
}
|
|
4203
|
+
function isExecutorProcessAlive(child, processGroupId = processGroupIdForChild(child), processApi = process, inspectLinuxProcessGroup = linuxProcessGroupHasLiveMembers) {
|
|
4169
4204
|
if (processGroupId !== null) {
|
|
4170
4205
|
try {
|
|
4171
4206
|
processApi.kill(-processGroupId, 0);
|
|
4207
|
+
if (processApi.platform === "linux") {
|
|
4208
|
+
const hasLiveMembers = inspectLinuxProcessGroup(processGroupId);
|
|
4209
|
+
if (hasLiveMembers !== null) return hasLiveMembers;
|
|
4210
|
+
}
|
|
4172
4211
|
return true;
|
|
4173
4212
|
} catch (error) {
|
|
4174
4213
|
if (error?.code === "ESRCH") return false;
|
|
@@ -4181,6 +4220,13 @@ function isProcessIdAlive(pid, processApi = process) {
|
|
|
4181
4220
|
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
4182
4221
|
try {
|
|
4183
4222
|
processApi.kill(pid, 0);
|
|
4223
|
+
if (processApi.platform === "linux") {
|
|
4224
|
+
try {
|
|
4225
|
+
const parsed = linuxProcState(readFileSync4(`/proc/${pid}/stat`, "utf8"));
|
|
4226
|
+
if (parsed && TERMINAL_LINUX_PROCESS_STATES.has(parsed.state)) return false;
|
|
4227
|
+
} catch {
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
4184
4230
|
return true;
|
|
4185
4231
|
} catch (error) {
|
|
4186
4232
|
return error?.code !== "ESRCH";
|
|
@@ -4226,7 +4272,7 @@ function isTerminalResultOutboxStatus(status) {
|
|
|
4226
4272
|
}
|
|
4227
4273
|
|
|
4228
4274
|
// src/amaster-runtime-daemon/run-completion-state.mjs
|
|
4229
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as
|
|
4275
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync5, readdirSync as readdirSync5, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
4230
4276
|
import { join as join5 } from "node:path";
|
|
4231
4277
|
var RUN_COMPLETION_STATE_VERSION = 1;
|
|
4232
4278
|
var RUN_COMPLETION_USAGE_SCHEMA_VERSION = "runtime-command-usage-v1";
|
|
@@ -4465,11 +4511,11 @@ function writeRunCompletionState(directory, state) {
|
|
|
4465
4511
|
return filePath;
|
|
4466
4512
|
}
|
|
4467
4513
|
function readRunCompletionState(filePath) {
|
|
4468
|
-
return assertValidRunCompletionState(JSON.parse(
|
|
4514
|
+
return assertValidRunCompletionState(JSON.parse(readFileSync5(filePath, "utf8")));
|
|
4469
4515
|
}
|
|
4470
4516
|
function listRunCompletionStateFiles(directory) {
|
|
4471
4517
|
if (!existsSync4(directory)) return [];
|
|
4472
|
-
return
|
|
4518
|
+
return readdirSync5(directory).filter((name) => name.endsWith(".json")).sort().map((name) => join5(directory, name));
|
|
4473
4519
|
}
|
|
4474
4520
|
function removeRunCompletionState(directory, commandId) {
|
|
4475
4521
|
const filePath = join5(directory, runCompletionStateFileName(commandId));
|
|
@@ -5524,6 +5570,27 @@ function interactionResolutionText(context) {
|
|
|
5524
5570
|
jsonText(resolution)
|
|
5525
5571
|
].filter(Boolean).join("\n");
|
|
5526
5572
|
}
|
|
5573
|
+
function currentIssueMetadataReadText(input) {
|
|
5574
|
+
const issueId = readString(input.issueId) ?? readString(asRecord(asRecord(input.context).paperclipIssue).id);
|
|
5575
|
+
if (!issueId) {
|
|
5576
|
+
return "Required current-issue read is unavailable because the current Issue id is missing. Stop without recording a disposition.";
|
|
5577
|
+
}
|
|
5578
|
+
if (!input.hasGovernedMcp) {
|
|
5579
|
+
return "Required current-issue read is unavailable because managed governed MCP is missing. Stop without recording a disposition.";
|
|
5580
|
+
}
|
|
5581
|
+
const args = { issueId };
|
|
5582
|
+
const directToolName = managedDirectToolName(input, "amaster.read_issue");
|
|
5583
|
+
if (directToolName) {
|
|
5584
|
+
return `Required current-issue read: call \`${directToolName}\` with these exact object arguments: ${JSON.stringify(args)}`;
|
|
5585
|
+
}
|
|
5586
|
+
if (input.executorKind === "pi" && managedPiMcpProxyAvailable(input)) {
|
|
5587
|
+
return `Required current-issue read: emit an actual \`mcp\` tool call with these exact proxy arguments: ${JSON.stringify(managedPiMcpProxyCall("amaster.read_issue", args))}`;
|
|
5588
|
+
}
|
|
5589
|
+
if (input.managedMcpToolMode === "direct_typed") {
|
|
5590
|
+
return "Required current-issue read is unavailable because amaster.read_issue is absent from the attested direct tool catalog. Stop without recording a disposition.";
|
|
5591
|
+
}
|
|
5592
|
+
return `Required current-issue read: call amaster.read_issue with these exact arguments: ${JSON.stringify(args)}`;
|
|
5593
|
+
}
|
|
5527
5594
|
function recoveryInstructionText(input) {
|
|
5528
5595
|
const context = asRecord(input.context);
|
|
5529
5596
|
if (input.wakeReason === "finish_successful_run_handoff" && context.handoffRequired === true) {
|
|
@@ -5580,7 +5647,9 @@ function recoveryInstructionText(input) {
|
|
|
5580
5647
|
].join("\n");
|
|
5581
5648
|
return [
|
|
5582
5649
|
"This is a status-only source recovery. Do not repeat the original source work or create or revise deliverables.",
|
|
5583
|
-
|
|
5650
|
+
`Before choosing or recording any disposition, execute this required current-issue read and inspect result.content.documents for every persisted document identity: ${currentIssueMetadataReadText(input)}`,
|
|
5651
|
+
"Do not claim that a durable document is absent from workspace or Delivery-readiness evidence. The required read is authoritative for current Issue document metadata; use amaster.read_issue_document only when a returned key needs body inspection.",
|
|
5652
|
+
"After the required read succeeds, inspect the existing task and run evidence, then choose exactly one explicit disposition using task-governance actions:",
|
|
5584
5653
|
"- done only when the existing evidence already satisfies acceptance;",
|
|
5585
5654
|
"- in_review or input when a specific human review or answer is required;",
|
|
5586
5655
|
blockedDisposition,
|
|
@@ -5718,11 +5787,19 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
|
|
|
5718
5787
|
delivery.mode === "required" ? "When every acceptance criterion is satisfied and the exact current Delivery Manifest is ready, record the final execution disposition with update_parent status in_progress and a concise evidence summary, then end the run successfully without creating a final review interaction." : "When every acceptance criterion is satisfied, record the final execution disposition with update_parent status in_progress and a concise evidence summary, then end the run successfully without creating a final review interaction.",
|
|
5719
5788
|
evidenceAutoAcceptance ? delivery.mode === "required" ? "Only after the run and command succeed does the Server validate the exact current Delivery Manifest and terminal Outcome evidence, auto-accept the Outcome, and finalize the issue as done atomically. This evidence-auto path does not create a Board review; report the actual Server-owned terminal disposition without implying a handoff." : "Only after the run and command succeed does the Server validate the terminal Outcome evidence, auto-accept the Outcome, and finalize the issue as done atomically. This evidence-auto path does not create a Board review; report the actual Server-owned terminal disposition without implying a handoff." : delivery.mode === "required" ? "Only after the run and command succeed does the Server bind the exact current Delivery Manifest and terminal Outcome evidence, create the formal Board review before generic continuation handoff is evaluated, and move the issue to in_review. Board acceptance then finalizes the issue as done atomically." : "Only after the run and command succeed does the Server bind the terminal Outcome evidence, create the formal Board review before generic continuation handoff is evaluated, and move the issue to in_review. Board acceptance then finalizes the issue as done atomically."
|
|
5720
5789
|
].join(" ") : "";
|
|
5721
|
-
const
|
|
5790
|
+
const organizationCapabilityAllowed = asRecord(envelope.organizationCapability).allowed === true;
|
|
5791
|
+
const organizationMutationAuthorized = allowed.has("organization_mutation");
|
|
5792
|
+
const authorizationContract = Object.keys(optionIds).length > 0 ? [
|
|
5722
5793
|
`Current allowed action classes: ${[...allowed].join(", ") || "task_governance"}.`,
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5794
|
+
`Organization capability (persistent Agent permission): ${organizationCapabilityAllowed ? "allowed" : "disabled"}.`,
|
|
5795
|
+
`Organization capability revision: ${readString(asRecord(asRecord(envelope.organizationCapability).source).revision) ?? "missing"}.`,
|
|
5796
|
+
`Run-scoped organization_mutation authorization: ${organizationMutationAuthorized ? "authorized" : "not_authorized"}.`,
|
|
5797
|
+
organizationCapabilityAllowed && organizationMutationAuthorized ? "Persistent organization capability and run-scoped authorization are both present. Use agent_hire for bounded organization changes; do not request another authorization or staffing interaction." : organizationCapabilityAllowed ? "If organization_mutation is required, call request_runtime_authorization with authorizationClass=organization_mutation and a stable idempotencyKey for the bounded organization-change scope. Wait for its accepted continuation; do not create a generic checkbox or staffing request." : "Persistent organization capability is disabled. Use the Server-resolved create_staffing_request route; staffing acceptance does not grant organization_mutation.",
|
|
5798
|
+
...missing.length > 0 ? [
|
|
5799
|
+
"Canonical authorization option ids are informational output from the Server-owned target:",
|
|
5800
|
+
...missing.map((entry) => `- ${entry.authorizationClass}: ${entry.optionId}`)
|
|
5801
|
+
] : [],
|
|
5802
|
+
"Never use create_interaction, request_confirmation, comment metadata, or free text to authorize a runtime action class."
|
|
5726
5803
|
].join("\n") : "";
|
|
5727
5804
|
return [
|
|
5728
5805
|
completionContract,
|
|
@@ -6732,7 +6809,7 @@ function resolveAgentInstructionSystemKernelBundle(bundle, options = {}) {
|
|
|
6732
6809
|
}
|
|
6733
6810
|
|
|
6734
6811
|
// src/amaster-runtime-daemon/config-state.mjs
|
|
6735
|
-
import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as
|
|
6812
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync4, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
6736
6813
|
import { homedir as homedir2, hostname } from "node:os";
|
|
6737
6814
|
import { dirname as dirname4, join as join6 } from "node:path";
|
|
6738
6815
|
|
|
@@ -6885,7 +6962,7 @@ function readState(env) {
|
|
|
6885
6962
|
const path = stateFilePath(env);
|
|
6886
6963
|
if (!existsSync5(path)) return {};
|
|
6887
6964
|
try {
|
|
6888
|
-
const state = JSON.parse(
|
|
6965
|
+
const state = JSON.parse(readFileSync6(path, "utf8"));
|
|
6889
6966
|
if (!state || typeof state !== "object" || Array.isArray(state)) {
|
|
6890
6967
|
throw new TypeError("runtime connector state must be a JSON object");
|
|
6891
6968
|
}
|
|
@@ -8667,7 +8744,7 @@ var bestEffortPostJson = bestEffortPostRuntimeConnectorJson;
|
|
|
8667
8744
|
|
|
8668
8745
|
// src/amaster-runtime-daemon/runtime-artifact-upload.mjs
|
|
8669
8746
|
import { createHash as createHash8 } from "node:crypto";
|
|
8670
|
-
import { closeSync, constants, fstatSync, lstatSync as lstatSync4, openSync, readFileSync as
|
|
8747
|
+
import { closeSync, constants, fstatSync, lstatSync as lstatSync4, openSync, readFileSync as readFileSync7, realpathSync as realpathSync3 } from "node:fs";
|
|
8671
8748
|
import { isAbsolute as isAbsolute3, relative as relative3, resolve as resolve4 } from "node:path";
|
|
8672
8749
|
var SHA256_PATTERN = /^[a-f0-9]{64}$/;
|
|
8673
8750
|
function requiredString(value, name) {
|
|
@@ -8719,7 +8796,7 @@ function readOwnedWorkspaceFile(rootPath, sourceRelativePath, label = "Runtime w
|
|
|
8719
8796
|
);
|
|
8720
8797
|
}
|
|
8721
8798
|
}
|
|
8722
|
-
const body =
|
|
8799
|
+
const body = readFileSync7(descriptor);
|
|
8723
8800
|
options.afterRead?.({ sourcePath, descriptor });
|
|
8724
8801
|
const after = fstatSync(descriptor);
|
|
8725
8802
|
const pathAfter = lstatSync4(sourcePath);
|
|
@@ -8867,23 +8944,48 @@ function prepareRuntimeDocumentUploads(cwd, mcpToolResults) {
|
|
|
8867
8944
|
// src/amaster-runtime-daemon/runtime-document-ingest-queue.mjs
|
|
8868
8945
|
function createRuntimeDocumentIngestQueue({ ingest }) {
|
|
8869
8946
|
const handledCallIds = /* @__PURE__ */ new Set();
|
|
8947
|
+
const documentIdentityByCallId = /* @__PURE__ */ new Map();
|
|
8948
|
+
const finalizedDocumentIdentities = /* @__PURE__ */ new Set();
|
|
8870
8949
|
const receipts = [];
|
|
8871
8950
|
const errors = [];
|
|
8872
8951
|
let queue = Promise.resolve();
|
|
8952
|
+
const documentIdentity = (intent) => {
|
|
8953
|
+
const sourceRelativePath = readString(asRecord(intent).sourceRelativePath);
|
|
8954
|
+
const sha2562 = readString(asRecord(intent).sha256);
|
|
8955
|
+
const byteSize = asRecord(intent).byteSize;
|
|
8956
|
+
return sourceRelativePath && sha2562 && Number.isSafeInteger(byteSize) && byteSize > 0 ? `document:${sourceRelativePath}\0${sha2562}\0${byteSize}` : null;
|
|
8957
|
+
};
|
|
8958
|
+
const retainReceipts = (nextReceipts) => {
|
|
8959
|
+
receipts.push(...nextReceipts);
|
|
8960
|
+
for (const receipt of nextReceipts) {
|
|
8961
|
+
const callId = readString(asRecord(receipt).callId);
|
|
8962
|
+
const identity2 = callId ? documentIdentityByCallId.get(callId) : null;
|
|
8963
|
+
if (identity2) finalizedDocumentIdentities.add(identity2);
|
|
8964
|
+
}
|
|
8965
|
+
};
|
|
8873
8966
|
return {
|
|
8874
8967
|
enqueue(results) {
|
|
8875
8968
|
const pending = results.filter((result3) => {
|
|
8876
|
-
const
|
|
8877
|
-
|
|
8969
|
+
const intent = asRecord(result3).workspaceDocumentIntent;
|
|
8970
|
+
const callId = readString(asRecord(intent).callId);
|
|
8971
|
+
if (!callId || handledCallIds.has(callId)) return false;
|
|
8878
8972
|
handledCallIds.add(callId);
|
|
8973
|
+
documentIdentityByCallId.set(callId, documentIdentity(intent) ?? `call:${callId}`);
|
|
8879
8974
|
return true;
|
|
8880
8975
|
});
|
|
8881
8976
|
if (pending.length === 0) return;
|
|
8977
|
+
const pendingIdentities = new Set(pending.map((result3) => {
|
|
8978
|
+
const callId = readString(asRecord(asRecord(result3).workspaceDocumentIntent).callId);
|
|
8979
|
+
return callId ? documentIdentityByCallId.get(callId) : null;
|
|
8980
|
+
}).filter(Boolean));
|
|
8882
8981
|
queue = queue.then(async () => {
|
|
8883
8982
|
try {
|
|
8884
|
-
|
|
8983
|
+
retainReceipts(await ingest(pending));
|
|
8885
8984
|
} catch (error) {
|
|
8886
|
-
errors.push(
|
|
8985
|
+
errors.push({
|
|
8986
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
8987
|
+
identities: pendingIdentities
|
|
8988
|
+
});
|
|
8887
8989
|
}
|
|
8888
8990
|
});
|
|
8889
8991
|
},
|
|
@@ -8892,8 +8994,12 @@ function createRuntimeDocumentIngestQueue({ ingest }) {
|
|
|
8892
8994
|
},
|
|
8893
8995
|
async flush() {
|
|
8894
8996
|
await queue;
|
|
8895
|
-
|
|
8896
|
-
|
|
8997
|
+
const unresolvedErrors = errors.filter(({ identities }) => identities.size === 0 || [...identities].some((identity2) => !finalizedDocumentIdentities.has(identity2))).map(({ error }) => error);
|
|
8998
|
+
if (unresolvedErrors.length > 0) {
|
|
8999
|
+
throw new AggregateError(
|
|
9000
|
+
unresolvedErrors,
|
|
9001
|
+
`${unresolvedErrors.length} Runtime Document ingest operation(s) failed`
|
|
9002
|
+
);
|
|
8897
9003
|
}
|
|
8898
9004
|
return [...receipts];
|
|
8899
9005
|
}
|
|
@@ -8979,7 +9085,7 @@ import { existsSync as existsSync7, mkdirSync as mkdirSync6, realpathSync as rea
|
|
|
8979
9085
|
import { basename as basename4, join as join8, isAbsolute as isAbsolute4, relative as relative4, resolve as resolve5 } from "node:path";
|
|
8980
9086
|
|
|
8981
9087
|
// src/amaster-runtime-daemon/workspace-manifest.mjs
|
|
8982
|
-
import { chownSync as chownSync2, existsSync as existsSync6, readFileSync as
|
|
9088
|
+
import { chownSync as chownSync2, existsSync as existsSync6, readFileSync as readFileSync8, renameSync as renameSync5, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "node:fs";
|
|
8983
9089
|
import { basename as basename3, dirname as dirname5, join as join7 } from "node:path";
|
|
8984
9090
|
var WORKSPACE_MANIFEST_FILENAME = ".amaster-runtime.json";
|
|
8985
9091
|
function syncManifestDirOwnership(manifestPath, deps = {}) {
|
|
@@ -9008,7 +9114,7 @@ function workspaceManifestPath(workspaceOrCwd) {
|
|
|
9008
9114
|
function readWorkspaceManifest(manifestPath) {
|
|
9009
9115
|
if (!manifestPath || !existsSync6(manifestPath)) return null;
|
|
9010
9116
|
try {
|
|
9011
|
-
const parsed = JSON.parse(
|
|
9117
|
+
const parsed = JSON.parse(readFileSync8(manifestPath, "utf8"));
|
|
9012
9118
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
9013
9119
|
} catch {
|
|
9014
9120
|
return null;
|
|
@@ -9164,7 +9270,7 @@ function resolveExecutionWorkspace(config, command, opts = {}) {
|
|
|
9164
9270
|
}
|
|
9165
9271
|
|
|
9166
9272
|
// src/amaster-runtime-daemon/workspace-gc.mjs
|
|
9167
|
-
import { existsSync as existsSync8, readdirSync as
|
|
9273
|
+
import { existsSync as existsSync8, readdirSync as readdirSync6, statSync as statSync5 } from "node:fs";
|
|
9168
9274
|
import { join as join9, resolve as resolve6 } from "node:path";
|
|
9169
9275
|
function readIsoTime(value) {
|
|
9170
9276
|
if (typeof value !== "string" || !value.trim()) return null;
|
|
@@ -9182,7 +9288,7 @@ function walkWorkdirs(root) {
|
|
|
9182
9288
|
if (!current) continue;
|
|
9183
9289
|
let entries = [];
|
|
9184
9290
|
try {
|
|
9185
|
-
entries =
|
|
9291
|
+
entries = readdirSync6(current, { withFileTypes: true });
|
|
9186
9292
|
} catch {
|
|
9187
9293
|
continue;
|
|
9188
9294
|
}
|
|
@@ -9215,7 +9321,7 @@ function directorySizeBytes(path) {
|
|
|
9215
9321
|
if (stat.isDirectory()) {
|
|
9216
9322
|
let entries = [];
|
|
9217
9323
|
try {
|
|
9218
|
-
entries =
|
|
9324
|
+
entries = readdirSync6(current, { withFileTypes: true });
|
|
9219
9325
|
} catch {
|
|
9220
9326
|
continue;
|
|
9221
9327
|
}
|
|
@@ -9292,11 +9398,11 @@ function planManagedWorkspaceGcDryRun(input) {
|
|
|
9292
9398
|
}
|
|
9293
9399
|
|
|
9294
9400
|
// src/amaster-runtime-daemon/runtime-status-summary.mjs
|
|
9295
|
-
import { existsSync as existsSync9, readdirSync as
|
|
9401
|
+
import { existsSync as existsSync9, readdirSync as readdirSync7, statSync as statSync6 } from "node:fs";
|
|
9296
9402
|
import { dirname as dirname6, join as join10, resolve as resolve7 } from "node:path";
|
|
9297
9403
|
function runtimeStatusDirectoryEntries(path) {
|
|
9298
9404
|
try {
|
|
9299
|
-
return
|
|
9405
|
+
return readdirSync7(path, { withFileTypes: true });
|
|
9300
9406
|
} catch {
|
|
9301
9407
|
return [];
|
|
9302
9408
|
}
|
|
@@ -9546,7 +9652,7 @@ function summarizeAmasterRuntimeVersionDrift(input = {}) {
|
|
|
9546
9652
|
// src/amaster-runtime-daemon/workspace-status.mjs
|
|
9547
9653
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
9548
9654
|
import { createHash as createHash11 } from "node:crypto";
|
|
9549
|
-
import { existsSync as existsSync10, readdirSync as
|
|
9655
|
+
import { existsSync as existsSync10, readdirSync as readdirSync8, readFileSync as readFileSync9, statSync as statSync7 } from "node:fs";
|
|
9550
9656
|
import { basename as basename5, extname, isAbsolute as isAbsolute5, join as join11, relative as relative5, resolve as resolve8 } from "node:path";
|
|
9551
9657
|
var WORKSPACE_RUNTIME_SERVICES_FILENAME = ".amaster-runtime-services.json";
|
|
9552
9658
|
var ARTIFACT_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
@@ -9616,7 +9722,7 @@ function sanitizeTrackedChange(line) {
|
|
|
9616
9722
|
return isSafeRelativePath(path) ? line : null;
|
|
9617
9723
|
}
|
|
9618
9724
|
function sha256File(filePath) {
|
|
9619
|
-
return createHash11("sha256").update(
|
|
9725
|
+
return createHash11("sha256").update(readFileSync9(filePath)).digest("hex");
|
|
9620
9726
|
}
|
|
9621
9727
|
function artifactHashCacheKey(relativePath, stat) {
|
|
9622
9728
|
return `${relativePath}\0${stat.size}\0${stat.mtimeMs}`;
|
|
@@ -9654,7 +9760,7 @@ function scanArtifactCandidates(cwd, opts = {}) {
|
|
|
9654
9760
|
const current = stack.pop();
|
|
9655
9761
|
let entries;
|
|
9656
9762
|
try {
|
|
9657
|
-
entries =
|
|
9763
|
+
entries = readdirSync8(current, { withFileTypes: true });
|
|
9658
9764
|
} catch {
|
|
9659
9765
|
continue;
|
|
9660
9766
|
}
|
|
@@ -9746,7 +9852,7 @@ function readRuntimeServicesSnapshot(cwd) {
|
|
|
9746
9852
|
const snapshotPath = join11(resolve8(cwd), WORKSPACE_RUNTIME_SERVICES_FILENAME);
|
|
9747
9853
|
if (!existsSync10(snapshotPath)) return [];
|
|
9748
9854
|
try {
|
|
9749
|
-
const parsed = JSON.parse(
|
|
9855
|
+
const parsed = JSON.parse(readFileSync9(snapshotPath, "utf8"));
|
|
9750
9856
|
const rawServices = Array.isArray(parsed) ? parsed : Array.isArray(parsed?.services) ? parsed.services : [];
|
|
9751
9857
|
return rawServices.map((entry) => sanitizeRuntimeService(entry)).filter((entry) => entry !== null).slice(0, 50);
|
|
9752
9858
|
} catch {
|
|
@@ -9991,7 +10097,7 @@ var source_acquisition_compatibility_default = {
|
|
|
9991
10097
|
};
|
|
9992
10098
|
|
|
9993
10099
|
// src/amaster-runtime-daemon.mjs
|
|
9994
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
10100
|
+
var CONNECTOR_VERSION = "0.1.1-beta.46";
|
|
9995
10101
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
9996
10102
|
var SOURCE_ACQUISITION_CAPABILITY = source_acquisition_compatibility_default.profileVersion;
|
|
9997
10103
|
var SOURCE_ACQUISITION_PROFILE_VERSION = source_acquisition_compatibility_default.profileVersion;
|
|
@@ -10032,7 +10138,7 @@ function resultOutboxPendingCount(config) {
|
|
|
10032
10138
|
if (!existsSync11(dir)) return 0;
|
|
10033
10139
|
try {
|
|
10034
10140
|
let pending = 0;
|
|
10035
|
-
for (const file of
|
|
10141
|
+
for (const file of readdirSync9(dir).filter((name) => name.endsWith(".json"))) {
|
|
10036
10142
|
if (readValidResultOutboxEntryOrQuarantine(config, file, join12(dir, file))) {
|
|
10037
10143
|
pending += 1;
|
|
10038
10144
|
}
|
|
@@ -10109,7 +10215,7 @@ function resultOutboxActiveRunCommands(config) {
|
|
|
10109
10215
|
if (!existsSync11(dir)) return [];
|
|
10110
10216
|
const outboxPending = resultOutboxPendingCount(config);
|
|
10111
10217
|
const entries = [];
|
|
10112
|
-
for (const file of
|
|
10218
|
+
for (const file of readdirSync9(dir).filter((name) => name.endsWith(".json")).sort()) {
|
|
10113
10219
|
const entry = readValidResultOutboxEntryOrQuarantine(config, file, join12(dir, file));
|
|
10114
10220
|
if (!entry) continue;
|
|
10115
10221
|
const activeRun = asRecord(entry.activeRun);
|
|
@@ -10142,10 +10248,10 @@ function resultOutboxFailedRunCommands(config) {
|
|
|
10142
10248
|
const dir = resultOutboxInvalidDir(config);
|
|
10143
10249
|
if (!existsSync11(dir)) return [];
|
|
10144
10250
|
const entries = [];
|
|
10145
|
-
for (const file of
|
|
10251
|
+
for (const file of readdirSync9(dir).filter((name) => name.endsWith(".json")).sort().slice(-100)) {
|
|
10146
10252
|
let entry;
|
|
10147
10253
|
try {
|
|
10148
|
-
entry = asRecord(JSON.parse(
|
|
10254
|
+
entry = asRecord(JSON.parse(readFileSync10(join12(dir, file), "utf8")));
|
|
10149
10255
|
} catch {
|
|
10150
10256
|
continue;
|
|
10151
10257
|
}
|
|
@@ -10212,7 +10318,7 @@ function safeExpandPath(value) {
|
|
|
10212
10318
|
}
|
|
10213
10319
|
function safeJsonObjectFromFile(filePath) {
|
|
10214
10320
|
try {
|
|
10215
|
-
const parsed = JSON.parse(
|
|
10321
|
+
const parsed = JSON.parse(readFileSync10(filePath, "utf8"));
|
|
10216
10322
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
10217
10323
|
} catch {
|
|
10218
10324
|
return null;
|
|
@@ -10229,7 +10335,7 @@ function safeDirectorySummary(pathValue) {
|
|
|
10229
10335
|
}
|
|
10230
10336
|
let entryCount = 0;
|
|
10231
10337
|
let truncated = false;
|
|
10232
|
-
for (const name of
|
|
10338
|
+
for (const name of readdirSync9(pathValue)) {
|
|
10233
10339
|
if (name.startsWith(".")) continue;
|
|
10234
10340
|
entryCount += 1;
|
|
10235
10341
|
if (entryCount >= MAX_PI_CAPABILITY_SOURCE_ENTRIES) {
|
|
@@ -10253,7 +10359,7 @@ function safeSkillRootSummary(kind, source, pathValue) {
|
|
|
10253
10359
|
let truncated = false;
|
|
10254
10360
|
if (directory.available && pathValue) {
|
|
10255
10361
|
try {
|
|
10256
|
-
for (const name of
|
|
10362
|
+
for (const name of readdirSync9(pathValue)) {
|
|
10257
10363
|
if (name.startsWith(".")) continue;
|
|
10258
10364
|
const skillDir = join12(pathValue, name);
|
|
10259
10365
|
try {
|
|
@@ -11226,7 +11332,7 @@ function sourceAcquisitionRuntimeProfile(config, command) {
|
|
|
11226
11332
|
}
|
|
11227
11333
|
function readJsonFile2(filePath) {
|
|
11228
11334
|
try {
|
|
11229
|
-
const parsed = JSON.parse(
|
|
11335
|
+
const parsed = JSON.parse(readFileSync10(filePath, "utf8"));
|
|
11230
11336
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
11231
11337
|
} catch {
|
|
11232
11338
|
return {};
|
|
@@ -12147,7 +12253,7 @@ function allProcessCwdsByPid() {
|
|
|
12147
12253
|
if (process.platform === "linux") {
|
|
12148
12254
|
const procEntries = (() => {
|
|
12149
12255
|
try {
|
|
12150
|
-
return
|
|
12256
|
+
return readdirSync9("/proc", { withFileTypes: true });
|
|
12151
12257
|
} catch {
|
|
12152
12258
|
return [];
|
|
12153
12259
|
}
|
|
@@ -12250,7 +12356,7 @@ function walkManagedWorkdirs(root) {
|
|
|
12250
12356
|
if (!current) continue;
|
|
12251
12357
|
let entries = [];
|
|
12252
12358
|
try {
|
|
12253
|
-
entries =
|
|
12359
|
+
entries = readdirSync9(current, { withFileTypes: true });
|
|
12254
12360
|
} catch {
|
|
12255
12361
|
continue;
|
|
12256
12362
|
}
|
|
@@ -13927,7 +14033,7 @@ function moveResultOutboxEntryToInvalid(config, file, fullPath, reason, detail,
|
|
|
13927
14033
|
function readValidResultOutboxEntryOrQuarantine(config, file, fullPath) {
|
|
13928
14034
|
let entry;
|
|
13929
14035
|
try {
|
|
13930
|
-
entry = JSON.parse(
|
|
14036
|
+
entry = JSON.parse(readFileSync10(fullPath, "utf8"));
|
|
13931
14037
|
} catch (err) {
|
|
13932
14038
|
const message = err instanceof Error ? err.message : String(err);
|
|
13933
14039
|
moveResultOutboxEntryToInvalid(config, file, fullPath, "malformed_result_outbox_json", message);
|
|
@@ -13987,7 +14093,7 @@ function quarantineResultOutboxEntry(config, fullPath, file, entry, reason, err)
|
|
|
13987
14093
|
async function flushResultOutbox(config) {
|
|
13988
14094
|
const dir = resultOutboxDir(config);
|
|
13989
14095
|
if (!existsSync11(dir)) return { attempted: 0, completed: 0 };
|
|
13990
|
-
const files =
|
|
14096
|
+
const files = readdirSync9(dir).filter((name) => name.endsWith(".json")).sort();
|
|
13991
14097
|
let completed = 0;
|
|
13992
14098
|
for (const file of files) {
|
|
13993
14099
|
const fullPath = join12(dir, file);
|
|
@@ -14368,7 +14474,7 @@ function safeCheckpointRelativePath(rawPath) {
|
|
|
14368
14474
|
return normalized;
|
|
14369
14475
|
}
|
|
14370
14476
|
function hashFileSha256(filePath) {
|
|
14371
|
-
return createHash12("sha256").update(
|
|
14477
|
+
return createHash12("sha256").update(readFileSync10(filePath)).digest("hex");
|
|
14372
14478
|
}
|
|
14373
14479
|
async function materializeIssueCheckpoint(config, command, workspace) {
|
|
14374
14480
|
const checkpointDir = issueCheckpointDir(workspace);
|
|
@@ -14376,7 +14482,7 @@ async function materializeIssueCheckpoint(config, command, workspace) {
|
|
|
14376
14482
|
if (!existsSync11(manifestPath)) return [];
|
|
14377
14483
|
let manifest;
|
|
14378
14484
|
try {
|
|
14379
|
-
manifest = asRecord(JSON.parse(
|
|
14485
|
+
manifest = asRecord(JSON.parse(readFileSync10(manifestPath, "utf8")));
|
|
14380
14486
|
} catch (err) {
|
|
14381
14487
|
rmSync5(checkpointDir, { recursive: true, force: true });
|
|
14382
14488
|
throw new Error(`invalid issue checkpoint manifest: ${err instanceof Error ? err.message : String(err)}`);
|
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.46";
|
|
10
10
|
|
|
11
11
|
const CAPABILITIES = [
|
|
12
12
|
"remote_registration",
|