@amaster.ai/employee-runtime-connector 0.1.1-beta.220 → 0.1.1-beta.221
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 +213 -11
- package/dist/amaster-runtime.mjs +1 -1
- package/package.json +1 -1
|
@@ -19999,6 +19999,81 @@ function inspectDesktopPiFinalContextReadiness(input = {}) {
|
|
|
19999
19999
|
|
|
20000
20000
|
// src/amaster-runtime-daemon/pi-managed-mcp-profile.mjs
|
|
20001
20001
|
var MANAGED_PI_DIRECT_TYPED_MCP_TOOL_MODE = "direct_typed";
|
|
20002
|
+
var MANAGED_PI_RUN_TERMINATION_FILENAME = "mirrorx-run-termination.mjs";
|
|
20003
|
+
function managedPiRunTerminationExtensionSource() {
|
|
20004
|
+
return `function asRecord(value) {
|
|
20005
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
20006
|
+
}
|
|
20007
|
+
|
|
20008
|
+
function readString(value) {
|
|
20009
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
20010
|
+
}
|
|
20011
|
+
|
|
20012
|
+
const terminalActionDispositions = new Map([
|
|
20013
|
+
["create_interaction", new Set(["waiting_human", "handoff_existing_live_path"])],
|
|
20014
|
+
["upsert_external_wait", new Set(["waiting_external"])],
|
|
20015
|
+
["schedule_monitor", new Set(["scheduled_monitor"])],
|
|
20016
|
+
]);
|
|
20017
|
+
const terminalToolNames = new Set(["runtime_action.submit", "runtime_action.status"]);
|
|
20018
|
+
|
|
20019
|
+
function shouldStopFromReceipt(rawResult) {
|
|
20020
|
+
const expectedRunId = readString(process.env.AMASTER_RUNTIME_RUN_ID);
|
|
20021
|
+
const expectedCommandId = readString(process.env.AMASTER_RUNTIME_COMMAND_ID);
|
|
20022
|
+
const expectedIssueId = readString(process.env.AMASTER_RUNTIME_ISSUE_ID);
|
|
20023
|
+
if (!expectedRunId || !expectedCommandId || !expectedIssueId) return false;
|
|
20024
|
+
|
|
20025
|
+
const result = asRecord(rawResult);
|
|
20026
|
+
const structured = asRecord(result.structuredContent);
|
|
20027
|
+
const providerContent = asRecord(structured.content);
|
|
20028
|
+
const providerResult = asRecord(providerContent.result);
|
|
20029
|
+
const effectResult = asRecord(providerResult.effectResult);
|
|
20030
|
+
const providerReceipt = asRecord(structured.providerReceipt);
|
|
20031
|
+
const invocationId = readString(structured.invocationId);
|
|
20032
|
+
const callId = readString(providerResult.callId);
|
|
20033
|
+
const receiptInvocationId = readString(providerReceipt.invocationId);
|
|
20034
|
+
const receiptCallId = readString(providerReceipt.callId);
|
|
20035
|
+
const actionType = readString(providerReceipt.actionType);
|
|
20036
|
+
const disposition = readString(effectResult.runDisposition);
|
|
20037
|
+
const existingOwner = asRecord(effectResult.existingOwner);
|
|
20038
|
+
const existingOwnerEpoch = Number(existingOwner.executionEpoch);
|
|
20039
|
+
if (!invocationId || !receiptInvocationId || !callId || !receiptCallId) return false;
|
|
20040
|
+
|
|
20041
|
+
const exactQueuedWakeHandoff = disposition === "handoff_existing_live_path"
|
|
20042
|
+
&& readString(existingOwner.kind) === "queued_wake"
|
|
20043
|
+
&& Boolean(readString(existingOwner.id))
|
|
20044
|
+
&& ["pending_dispatch", "queued", "deferred_issue_execution"].includes(readString(existingOwner.status) ?? "")
|
|
20045
|
+
&& Number.isSafeInteger(existingOwnerEpoch)
|
|
20046
|
+
&& existingOwnerEpoch > 0
|
|
20047
|
+
&& readString(existingOwner.nextAction) === "end_current_run";
|
|
20048
|
+
|
|
20049
|
+
return readString(structured.status) === "succeeded"
|
|
20050
|
+
&& readString(providerContent.status) === "accepted"
|
|
20051
|
+
&& ["succeeded", "completed"].includes(readString(providerResult.status) ?? "")
|
|
20052
|
+
&& terminalToolNames.has(readString(providerContent.toolName) ?? "")
|
|
20053
|
+
&& effectResult.mustEndRun === true
|
|
20054
|
+
&& Boolean(terminalActionDispositions.get(actionType ?? "")?.has(disposition ?? ""))
|
|
20055
|
+
&& readString(providerReceipt.provider) === "amaster_actions"
|
|
20056
|
+
&& readString(providerReceipt.status) === "accepted"
|
|
20057
|
+
&& receiptInvocationId === invocationId
|
|
20058
|
+
&& readString(providerReceipt.runId) === expectedRunId
|
|
20059
|
+
&& readString(providerReceipt.commandId) === expectedCommandId
|
|
20060
|
+
&& readString(providerReceipt.issueId) === expectedIssueId
|
|
20061
|
+
&& receiptCallId === callId
|
|
20062
|
+
&& (disposition !== "waiting_human"
|
|
20063
|
+
|| Boolean(readString(effectResult.interactionId) && readString(effectResult.epochKey)))
|
|
20064
|
+
&& (disposition !== "handoff_existing_live_path"
|
|
20065
|
+
|| Boolean(readString(effectResult.epochKey) && exactQueuedWakeHandoff));
|
|
20066
|
+
}
|
|
20067
|
+
|
|
20068
|
+
export default function mirrorxRunTermination(pi) {
|
|
20069
|
+
pi.on("tool_result", (event) => {
|
|
20070
|
+
if (event.isError === true) return undefined;
|
|
20071
|
+
const rawResult = asRecord(event.details).mcpResult;
|
|
20072
|
+
return shouldStopFromReceipt(rawResult) ? { stopAfterTurn: true } : undefined;
|
|
20073
|
+
});
|
|
20074
|
+
}
|
|
20075
|
+
`;
|
|
20076
|
+
}
|
|
20002
20077
|
var MANAGED_PI_CONFIG_MODE_SHARED = "shared_agent_dir_workspace_mcp_file";
|
|
20003
20078
|
var MANAGED_PI_TELEMETRY_PACKAGE = "@amaster.ai/pi-telemetry";
|
|
20004
20079
|
var MANAGED_PI_TELEMETRY_PACKAGE_SOURCE = "npm:@amaster.ai/pi-telemetry";
|
|
@@ -21764,7 +21839,8 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
21764
21839
|
const config = {
|
|
21765
21840
|
settings: {
|
|
21766
21841
|
toolPrefix: "none",
|
|
21767
|
-
scriptMode: false
|
|
21842
|
+
scriptMode: false,
|
|
21843
|
+
...directCatalog ? { directToolResultDetails: "bounded" } : {}
|
|
21768
21844
|
},
|
|
21769
21845
|
mcpServers: {
|
|
21770
21846
|
[SUPPORTED_SERVER_NAME2]: serverConfig
|
|
@@ -21797,6 +21873,10 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
21797
21873
|
throw new Error("pi_managed_mcp_adapter_extension_unsafe");
|
|
21798
21874
|
}
|
|
21799
21875
|
extensionArgs.push("--extension", adapterExtensionPath);
|
|
21876
|
+
writeProfileExtension(
|
|
21877
|
+
MANAGED_PI_RUN_TERMINATION_FILENAME,
|
|
21878
|
+
managedPiRunTerminationExtensionSource()
|
|
21879
|
+
);
|
|
21800
21880
|
}
|
|
21801
21881
|
const adapterVersion = piMcpAdapterVersion(sharedRuntime.home);
|
|
21802
21882
|
const {
|
|
@@ -21841,6 +21921,9 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
21841
21921
|
// The profile owns the final child environment. Never rely on a caller
|
|
21842
21922
|
// supplied correlation value when governed telemetry is active.
|
|
21843
21923
|
...telemetryExtension ? { PI_TELEMETRY_TASK_RUN_ID: runId } : {},
|
|
21924
|
+
AMASTER_RUNTIME_RUN_ID: authority.runId,
|
|
21925
|
+
AMASTER_RUNTIME_COMMAND_ID: authority.commandId,
|
|
21926
|
+
...authority.issueId ? { AMASTER_RUNTIME_ISSUE_ID: authority.issueId } : {},
|
|
21844
21927
|
HOME: home,
|
|
21845
21928
|
PI_AGENT_HOME: piAgentHome,
|
|
21846
21929
|
PI_CODING_AGENT_SESSION_DIR: sessionsRoot,
|
|
@@ -22185,7 +22268,8 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
22185
22268
|
// exact identities attested by the Server. A desktop user's adapter
|
|
22186
22269
|
// prefix is local presentation state and must not rename this run's
|
|
22187
22270
|
// governed tools.
|
|
22188
|
-
...directCatalog ? { toolPrefix: "none" } : {}
|
|
22271
|
+
...directCatalog ? { toolPrefix: "none" } : {},
|
|
22272
|
+
...directCatalog ? { directToolResultDetails: "bounded" } : {}
|
|
22189
22273
|
},
|
|
22190
22274
|
mcpServers: {
|
|
22191
22275
|
...record6(sourceMcp.mcpServers),
|
|
@@ -22210,6 +22294,12 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
22210
22294
|
if (desktopAttestationReadiness?.ready) {
|
|
22211
22295
|
extensionArgs.push("--extension", desktopAttestationReadiness.extensionPath);
|
|
22212
22296
|
}
|
|
22297
|
+
if (directCatalog) {
|
|
22298
|
+
writeProfileExtension(
|
|
22299
|
+
MANAGED_PI_RUN_TERMINATION_FILENAME,
|
|
22300
|
+
managedPiRunTerminationExtensionSource()
|
|
22301
|
+
);
|
|
22302
|
+
}
|
|
22213
22303
|
const skillProfiles = roleSkillProfilesForRun(input);
|
|
22214
22304
|
let enabledRoleSkills = null;
|
|
22215
22305
|
let enabledRoleSkillMetadataBytes = 0;
|
|
@@ -22250,6 +22340,9 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
22250
22340
|
const env = {
|
|
22251
22341
|
...input.baseEnv,
|
|
22252
22342
|
...record6(input.commandEnv),
|
|
22343
|
+
AMASTER_RUNTIME_RUN_ID: authority.runId,
|
|
22344
|
+
AMASTER_RUNTIME_COMMAND_ID: authority.commandId,
|
|
22345
|
+
...authority.issueId ? { AMASTER_RUNTIME_ISSUE_ID: authority.issueId } : {},
|
|
22253
22346
|
PI_AGENT_HOME: sourcePiHome,
|
|
22254
22347
|
PI_CODING_AGENT_DIR: piCodingAgentDir,
|
|
22255
22348
|
"AMASTER-CLI_CODING_AGENT_DIR": piCodingAgentDir,
|
|
@@ -26502,6 +26595,15 @@ var PI_TERMINAL_RUNTIME_ACTION_STATUSES = /* @__PURE__ */ new Set([
|
|
|
26502
26595
|
"completed",
|
|
26503
26596
|
"succeeded"
|
|
26504
26597
|
]);
|
|
26598
|
+
var PI_TERMINATING_RUNTIME_ACTION_TO_DISPOSITION = /* @__PURE__ */ new Map([
|
|
26599
|
+
["create_interaction", /* @__PURE__ */ new Set(["waiting_human", "handoff_existing_live_path"])],
|
|
26600
|
+
["upsert_external_wait", /* @__PURE__ */ new Set(["waiting_external"])],
|
|
26601
|
+
["schedule_monitor", /* @__PURE__ */ new Set(["scheduled_monitor"])]
|
|
26602
|
+
]);
|
|
26603
|
+
var PI_TERMINATING_RUNTIME_ACTION_TOOLS = /* @__PURE__ */ new Set([
|
|
26604
|
+
"runtime_action.submit",
|
|
26605
|
+
"runtime_action.status"
|
|
26606
|
+
]);
|
|
26505
26607
|
function approvedMcpInvocationSucceeded(results, invocationId) {
|
|
26506
26608
|
const approvedInvocationId = readString(invocationId);
|
|
26507
26609
|
return Boolean(approvedInvocationId && (Array.isArray(results) ? results : []).some((rawResult) => {
|
|
@@ -26539,20 +26641,58 @@ function governedMcpToolResult(structuredContent) {
|
|
|
26539
26641
|
} : null;
|
|
26540
26642
|
const runtimeActionToolName = readString(providerContent.toolName);
|
|
26541
26643
|
const runtimeActionError = asRecord(providerResult.error);
|
|
26644
|
+
const runtimeActionCallId = readString(providerResult.callId);
|
|
26645
|
+
const runtimeActionResultStatus = readString(providerResult.status);
|
|
26542
26646
|
const runtimeAction = runtimeActionToolName?.startsWith("runtime_action.") ? {
|
|
26543
26647
|
toolName: runtimeActionToolName,
|
|
26544
|
-
...
|
|
26648
|
+
...runtimeActionCallId ? { callId: runtimeActionCallId } : {},
|
|
26545
26649
|
...readString(providerResult.planId) ? { planId: readString(providerResult.planId) } : {},
|
|
26546
|
-
...
|
|
26650
|
+
...runtimeActionResultStatus ? { resultStatus: runtimeActionResultStatus } : {},
|
|
26547
26651
|
...readString(providerResult.errorCode) ?? readString(runtimeActionError.code) ? { errorCode: readString(providerResult.errorCode) ?? readString(runtimeActionError.code) } : {}
|
|
26548
26652
|
} : null;
|
|
26653
|
+
const receiptActionType = readString(providerReceipt.actionType);
|
|
26654
|
+
const runDisposition = readString(effectResult.runDisposition);
|
|
26655
|
+
const expectedDispositions = PI_TERMINATING_RUNTIME_ACTION_TO_DISPOSITION.get(receiptActionType ?? "");
|
|
26656
|
+
const receiptRunId = readString(providerReceipt.runId);
|
|
26657
|
+
const receiptCommandId = readString(providerReceipt.commandId);
|
|
26658
|
+
const receiptIssueId = readString(providerReceipt.issueId);
|
|
26659
|
+
const receiptCallId = readString(providerReceipt.callId);
|
|
26660
|
+
const interactionId = readString(effectResult.interactionId);
|
|
26661
|
+
const epochKey = readString(effectResult.epochKey);
|
|
26662
|
+
const existingOwner = asRecord(effectResult.existingOwner);
|
|
26663
|
+
const existingOwnerEpoch = readNumber(existingOwner.executionEpoch, 0);
|
|
26664
|
+
const exactQueuedWakeHandoff = runDisposition === "handoff_existing_live_path" && readString(existingOwner.kind) === "queued_wake" && Boolean(readString(existingOwner.id)) && ["pending_dispatch", "queued", "deferred_issue_execution"].includes(
|
|
26665
|
+
readString(existingOwner.status) ?? ""
|
|
26666
|
+
) && Number.isSafeInteger(existingOwnerEpoch) && existingOwnerEpoch > 0 && readString(existingOwner.nextAction) === "end_current_run";
|
|
26667
|
+
const terminalRunDisposition = status === "succeeded" && providerStatus === "accepted" && PI_TERMINAL_RUNTIME_ACTION_STATUSES.has(runtimeActionResultStatus ?? "") && PI_TERMINATING_RUNTIME_ACTION_TOOLS.has(runtimeActionToolName ?? "") && effectResult.mustEndRun === true && Boolean(expectedDispositions?.has(runDisposition ?? "")) && invocationId && readString(providerReceipt.provider) === "amaster_actions" && readString(providerReceipt.invocationId) === invocationId && readString(providerReceipt.status) === "accepted" && receiptRunId && receiptCommandId && receiptIssueId && runtimeActionCallId && receiptCallId === runtimeActionCallId && (runDisposition !== "waiting_human" || Boolean(interactionId && epochKey)) && (runDisposition !== "handoff_existing_live_path" || Boolean(epochKey && exactQueuedWakeHandoff)) ? {
|
|
26668
|
+
disposition: runDisposition,
|
|
26669
|
+
actionType: receiptActionType,
|
|
26670
|
+
toolName: runtimeActionToolName,
|
|
26671
|
+
invocationId,
|
|
26672
|
+
callId: runtimeActionCallId,
|
|
26673
|
+
runId: receiptRunId,
|
|
26674
|
+
commandId: receiptCommandId,
|
|
26675
|
+
issueId: receiptIssueId,
|
|
26676
|
+
...interactionId ? { interactionId } : {},
|
|
26677
|
+
...epochKey ? { epochKey } : {},
|
|
26678
|
+
...exactQueuedWakeHandoff ? {
|
|
26679
|
+
existingOwner: {
|
|
26680
|
+
kind: "queued_wake",
|
|
26681
|
+
id: readString(existingOwner.id),
|
|
26682
|
+
status: readString(existingOwner.status),
|
|
26683
|
+
executionEpoch: existingOwnerEpoch,
|
|
26684
|
+
nextAction: "end_current_run"
|
|
26685
|
+
}
|
|
26686
|
+
} : {}
|
|
26687
|
+
} : null;
|
|
26549
26688
|
return {
|
|
26550
26689
|
...invocationId ? { invocationId } : {},
|
|
26551
26690
|
status,
|
|
26552
26691
|
...providerStatus ? { providerStatus } : {},
|
|
26553
26692
|
...artifactIntent ? { artifactIntent } : {},
|
|
26554
26693
|
...workspaceDocumentIntent ? { workspaceDocumentIntent } : {},
|
|
26555
|
-
...runtimeAction ? { runtimeAction } : {}
|
|
26694
|
+
...runtimeAction ? { runtimeAction } : {},
|
|
26695
|
+
...terminalRunDisposition ? { terminalRunDisposition } : {}
|
|
26556
26696
|
};
|
|
26557
26697
|
}
|
|
26558
26698
|
function dedupeGovernedMcpToolResults(results) {
|
|
@@ -26578,16 +26718,54 @@ function dedupeGovernedMcpToolResults(results) {
|
|
|
26578
26718
|
const artifactIntent = asRecord(result2.artifactIntent);
|
|
26579
26719
|
const existingWorkspaceDocumentIntent = asRecord(existing.workspaceDocumentIntent);
|
|
26580
26720
|
const workspaceDocumentIntent = asRecord(result2.workspaceDocumentIntent);
|
|
26721
|
+
const existingTerminalRunDisposition = asRecord(existing.terminalRunDisposition);
|
|
26722
|
+
const terminalRunDisposition = asRecord(result2.terminalRunDisposition);
|
|
26581
26723
|
unique[existingIndex] = {
|
|
26582
26724
|
...existing,
|
|
26583
26725
|
...result2,
|
|
26584
26726
|
...Object.keys(existingRuntimeAction).length > 0 || Object.keys(runtimeAction).length > 0 ? { runtimeAction: { ...existingRuntimeAction, ...runtimeAction } } : {},
|
|
26585
26727
|
...Object.keys(existingArtifactIntent).length > 0 || Object.keys(artifactIntent).length > 0 ? { artifactIntent: { ...existingArtifactIntent, ...artifactIntent } } : {},
|
|
26586
|
-
...Object.keys(existingWorkspaceDocumentIntent).length > 0 || Object.keys(workspaceDocumentIntent).length > 0 ? { workspaceDocumentIntent: { ...existingWorkspaceDocumentIntent, ...workspaceDocumentIntent } } : {}
|
|
26728
|
+
...Object.keys(existingWorkspaceDocumentIntent).length > 0 || Object.keys(workspaceDocumentIntent).length > 0 ? { workspaceDocumentIntent: { ...existingWorkspaceDocumentIntent, ...workspaceDocumentIntent } } : {},
|
|
26729
|
+
...Object.keys(existingTerminalRunDisposition).length > 0 || Object.keys(terminalRunDisposition).length > 0 ? { terminalRunDisposition: { ...existingTerminalRunDisposition, ...terminalRunDisposition } } : {}
|
|
26587
26730
|
};
|
|
26588
26731
|
}
|
|
26589
26732
|
return unique;
|
|
26590
26733
|
}
|
|
26734
|
+
function piTerminatingRunDispositionEvidence(results, expected = {}) {
|
|
26735
|
+
const expectedRunId = readString(expected.runId);
|
|
26736
|
+
const expectedCommandId = readString(expected.commandId);
|
|
26737
|
+
const expectedIssueId = readString(expected.issueId);
|
|
26738
|
+
if (!expectedRunId || !expectedCommandId || !expectedIssueId) return null;
|
|
26739
|
+
const result2 = (Array.isArray(results) ? results : []).map(asRecord).find((entry) => {
|
|
26740
|
+
const disposition2 = asRecord(entry.terminalRunDisposition);
|
|
26741
|
+
return readString(entry.status) === "succeeded" && readString(disposition2.runId) === expectedRunId && readString(disposition2.commandId) === expectedCommandId && readString(disposition2.issueId) === expectedIssueId;
|
|
26742
|
+
});
|
|
26743
|
+
if (!result2) return null;
|
|
26744
|
+
const disposition = asRecord(result2.terminalRunDisposition);
|
|
26745
|
+
const existingOwner = asRecord(disposition.existingOwner);
|
|
26746
|
+
return {
|
|
26747
|
+
kind: "runtime_action_run_disposition",
|
|
26748
|
+
disposition: readString(disposition.disposition),
|
|
26749
|
+
actionType: readString(disposition.actionType),
|
|
26750
|
+
toolName: readString(disposition.toolName),
|
|
26751
|
+
invocationId: readString(disposition.invocationId),
|
|
26752
|
+
callId: readString(disposition.callId),
|
|
26753
|
+
runId: expectedRunId,
|
|
26754
|
+
commandId: expectedCommandId,
|
|
26755
|
+
issueId: expectedIssueId,
|
|
26756
|
+
...readString(disposition.interactionId) ? { interactionId: readString(disposition.interactionId) } : {},
|
|
26757
|
+
...readString(disposition.epochKey) ? { epochKey: readString(disposition.epochKey) } : {},
|
|
26758
|
+
...readString(existingOwner.kind) === "queued_wake" && readString(existingOwner.id) ? {
|
|
26759
|
+
existingOwner: {
|
|
26760
|
+
kind: "queued_wake",
|
|
26761
|
+
id: readString(existingOwner.id),
|
|
26762
|
+
status: readString(existingOwner.status),
|
|
26763
|
+
executionEpoch: readNumber(existingOwner.executionEpoch, 0),
|
|
26764
|
+
nextAction: readString(existingOwner.nextAction)
|
|
26765
|
+
}
|
|
26766
|
+
} : {}
|
|
26767
|
+
};
|
|
26768
|
+
}
|
|
26591
26769
|
function durablePiRuntimeActionEvidence(results) {
|
|
26592
26770
|
const normalizedResults = (Array.isArray(results) ? results : []).map(asRecord);
|
|
26593
26771
|
const writeCallIds = /* @__PURE__ */ new Set();
|
|
@@ -29354,7 +29532,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
|
|
|
29354
29532
|
}
|
|
29355
29533
|
|
|
29356
29534
|
// src/amaster-runtime-daemon.mjs
|
|
29357
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
29535
|
+
var CONNECTOR_VERSION = "0.1.1-beta.221";
|
|
29358
29536
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
29359
29537
|
var daemonRequire = createRequire(import.meta.url);
|
|
29360
29538
|
var MAX_CHECKPOINT_BYTES = 20 * 1024 * 1024;
|
|
@@ -34251,7 +34429,7 @@ function piCompletionOutputStopped(execution) {
|
|
|
34251
34429
|
}
|
|
34252
34430
|
function piOutputValidationError(parsed, options = {}) {
|
|
34253
34431
|
if (parsed?.errorMessage) return parsed.errorMessage;
|
|
34254
|
-
if (options.completionOutputType === "agent_settled" && options.completionOutputHasFinalAssistantText !== true) {
|
|
34432
|
+
if (options.completionOutputType === "agent_settled" && options.completionOutputHasFinalAssistantText !== true && options.allowMissingFinalAssistantText !== true) {
|
|
34255
34433
|
return "Pi Agent agent_settled without final assistant text";
|
|
34256
34434
|
}
|
|
34257
34435
|
if (!parsed?.hasAssistantOutput && options.allowMissingAssistantOutput !== true) {
|
|
@@ -34814,8 +34992,29 @@ async function executeRunCommand(config, command) {
|
|
|
34814
34992
|
const primaryUsage = { ...asRecord(parsed.usage) };
|
|
34815
34993
|
let terminalTextRepair = null;
|
|
34816
34994
|
let terminalTextRepairUsageBreakdown = null;
|
|
34995
|
+
const terminalRunDisposition = executor.kind === "pi" ? piTerminatingRunDispositionEvidence(mcpToolResults, {
|
|
34996
|
+
runId: commandRunId(command),
|
|
34997
|
+
commandId: command.commandId,
|
|
34998
|
+
issueId: commandIssueId(command)
|
|
34999
|
+
}) : null;
|
|
35000
|
+
if (terminalRunDisposition) {
|
|
35001
|
+
const disposition = readString(terminalRunDisposition.disposition);
|
|
35002
|
+
parsed.summary = disposition === "handoff_existing_live_path" ? "This run handed control to the existing queued live path and ended normally without creating a duplicate interaction." : disposition === "waiting_human" ? "The requested human interaction was persisted; this run ended normally and will resume only under its continuation policy." : disposition === "waiting_external" ? "The external wait was persisted; this run ended normally and will resume only after the recorded condition is satisfied." : "The monitor schedule was persisted; this run ended normally and will resume only at the scheduled check.";
|
|
35003
|
+
parsed.hasAssistantOutput = true;
|
|
35004
|
+
await ingestLog(
|
|
35005
|
+
config,
|
|
35006
|
+
command,
|
|
35007
|
+
"system",
|
|
35008
|
+
"info",
|
|
35009
|
+
`Accepted ${disposition} as the authoritative terminal disposition for the current run`,
|
|
35010
|
+
{
|
|
35011
|
+
presentationKind: "runtime_action_terminal_disposition",
|
|
35012
|
+
terminalRunDisposition
|
|
35013
|
+
}
|
|
35014
|
+
);
|
|
35015
|
+
}
|
|
34817
35016
|
const terminalTextRepairEvidence = executor.kind === "pi" ? piDurableCompletionEvidence(mcpToolResults, runtimeArtifacts, runtimeDocuments) : null;
|
|
34818
|
-
if (terminalTextRepairEvidence && managedMcpProfile && Array.isArray(command.requiredCapabilities) && command.requiredCapabilities.includes("runtime_actions_v2") && piTerminalTextRepairPrimaryEligible(execution, parsed)) {
|
|
35017
|
+
if (terminalTextRepairEvidence && !terminalRunDisposition && managedMcpProfile && Array.isArray(command.requiredCapabilities) && command.requiredCapabilities.includes("runtime_actions_v2") && piTerminalTextRepairPrimaryEligible(execution, parsed)) {
|
|
34819
35018
|
patchActiveRunCommand(command, { phase: "terminal_text_repair" });
|
|
34820
35019
|
const primaryRecordedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
34821
35020
|
try {
|
|
@@ -34982,6 +35181,7 @@ async function executeRunCommand(config, command) {
|
|
|
34982
35181
|
const piInvalidOutputError = executor.kind === "pi" ? piOutputValidationError(parsedForValidation, {
|
|
34983
35182
|
allowMissingTurnEnd: completionOutputStopped,
|
|
34984
35183
|
allowMissingAssistantOutput: execution.completionOutputType === "approval_required",
|
|
35184
|
+
allowMissingFinalAssistantText: Boolean(terminalRunDisposition),
|
|
34985
35185
|
completionOutputType: execution.completionOutputType,
|
|
34986
35186
|
completionOutputHasFinalAssistantText: terminalTextRepair?.succeeded === true ? true : execution.completionOutputHasFinalAssistantText
|
|
34987
35187
|
}) : null;
|
|
@@ -34994,13 +35194,14 @@ async function executeRunCommand(config, command) {
|
|
|
34994
35194
|
errorMessage: parsedErrorMessage
|
|
34995
35195
|
}) : null;
|
|
34996
35196
|
const repairedPiTerminalOutputStop = terminalTextRepair?.succeeded === true && execution.completionOutputType === "agent_settled" && execution.completionOutputHasFinalAssistantText === false && piCompletionCleanupStopped(execution);
|
|
34997
|
-
const
|
|
35197
|
+
const dispositionPiTerminalOutputStop = Boolean(terminalRunDisposition) && execution.completionOutputType === "agent_settled" && execution.completionOutputHasFinalAssistantText === false && piCompletionCleanupStopped(execution);
|
|
35198
|
+
const succeeded = !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && (execution.exitCode === 0 || completionOutputStopped || repairedPiTerminalOutputStop || dispositionPiTerminalOutputStop) && !execution.timedOut && !execution.spawnError && !parsedErrorMessage;
|
|
34998
35199
|
const resultStderr = filterExecutionStderrForResult(executor.kind, execution.stderr);
|
|
34999
35200
|
const unsafeError = execution.timedOut ? `Executor timed out after ${config.executorTimeoutSeconds}s` : cancelled ? "Executor cancelled by AMaster control plane" : execution.spawnError ?? parsedErrorMessage ?? (succeeded ? null : `Executor exited with code ${execution.exitCode ?? "unknown"}`);
|
|
35000
35201
|
const error = unsafeError;
|
|
35001
35202
|
const costUsage = parsedCostUsage(parsed.usage);
|
|
35002
|
-
const cleanPiTerminalOutputStop = succeeded && (completionOutputStopped || repairedPiTerminalOutputStop) && execution.completionOutputType === "agent_settled" && parsed.sawAgentSettled === true && Number.isInteger(parsed.settledEventIndex);
|
|
35003
35203
|
const settledTerminalOutput = execution.completionOutputType === "agent_settled" && parsed.sawAgentSettled === true && Number.isInteger(parsed.settledEventIndex);
|
|
35204
|
+
const cleanPiTerminalOutputStop = succeeded && (completionOutputStopped || repairedPiTerminalOutputStop || dispositionPiTerminalOutputStop) && settledTerminalOutput;
|
|
35004
35205
|
const executorOutcome = {
|
|
35005
35206
|
status: cancelled ? "cancelled" : execution.timedOut ? "timed_out" : cleanPiTerminalOutputStop || execution.exitCode === 0 && execution.signal === null ? "completed" : "failed",
|
|
35006
35207
|
exitCode: cleanPiTerminalOutputStop ? 0 : execution.exitCode,
|
|
@@ -35039,6 +35240,7 @@ async function executeRunCommand(config, command) {
|
|
|
35039
35240
|
...terminalTextRepairUsageBreakdown ? { usageBreakdown: terminalTextRepairUsageBreakdown } : {},
|
|
35040
35241
|
...costUsage ? { costUsage } : {},
|
|
35041
35242
|
...terminalTextRepair ? { terminalTextRepair: terminalTextRepair.audit } : {},
|
|
35243
|
+
...terminalRunDisposition ? { terminalRunDisposition } : {},
|
|
35042
35244
|
...runtimeArtifacts.length > 0 ? { runtimeArtifacts } : {},
|
|
35043
35245
|
...runtimeDocuments.length > 0 ? { runtimeDocuments } : {},
|
|
35044
35246
|
outputTelemetry,
|
package/dist/amaster-runtime.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { homedir, hostname } from "node:os";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { BUILD_SUPPORTED_CAPABILITIES } from "./amaster-runtime-daemon/capability-registry.mjs";
|
|
9
9
|
|
|
10
|
-
const CONNECTOR_VERSION = "0.1.1-beta.
|
|
10
|
+
const CONNECTOR_VERSION = "0.1.1-beta.221";
|
|
11
11
|
|
|
12
12
|
const CONFIG_KEY_MAP = new Map([
|
|
13
13
|
["server_url", "AMASTER_EMPLOYEE_SERVER_URL"],
|