@amaster.ai/employee-runtime-connector 0.1.1-beta.82 → 0.1.1-beta.83
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/README.md +1 -1
- package/dist/amaster-runtime-daemon.mjs +78 -25
- package/dist/amaster-runtime.mjs +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ For production images, install an exact version and invoke the package bin:
|
|
|
13
13
|
```sh
|
|
14
14
|
npm install --omit=dev --prefix /opt/pi-cli-runtime @amaster.ai/employee-runtime-connector@0.1.0
|
|
15
15
|
/opt/pi-cli-runtime/node_modules/.bin/amaster-runtime setup https://employee.example.com \
|
|
16
|
-
--capabilities remote_registration,heartbeat,executor_discovery,workspace_binding,run_wakeup,model_call,model_call_output_contract_v1,run_cancel,run_terminate,logs_cost_workspace_status
|
|
16
|
+
--capabilities remote_registration,heartbeat,executor_discovery,workspace_binding,run_wakeup,runtime_actions_v2,run_exit_live_path_closure_v1,model_call,model_call_output_contract_v1,run_cancel,run_terminate,logs_cost_workspace_status
|
|
17
17
|
/opt/pi-cli-runtime/node_modules/.bin/amaster-runtime daemon start --foreground
|
|
18
18
|
```
|
|
19
19
|
|
|
@@ -5453,7 +5453,15 @@ function normalizeRunTurnUsage(turn) {
|
|
|
5453
5453
|
const source = record4(turn);
|
|
5454
5454
|
const nestedUsage = record4(source.usage);
|
|
5455
5455
|
const usage = Object.keys(nestedUsage).length > 0 ? nestedUsage : source;
|
|
5456
|
-
const
|
|
5456
|
+
const allowedTurnKinds = /* @__PURE__ */ new Set([
|
|
5457
|
+
"primary",
|
|
5458
|
+
"terminal_text_repair",
|
|
5459
|
+
"closure",
|
|
5460
|
+
"work_disposition_closure",
|
|
5461
|
+
"live_path_closure",
|
|
5462
|
+
"terminal_disposition_closure"
|
|
5463
|
+
]);
|
|
5464
|
+
const turnKind = allowedTurnKinds.has(source.turn) ? source.turn : "primary";
|
|
5457
5465
|
return {
|
|
5458
5466
|
turn: turnKind,
|
|
5459
5467
|
attempt: turnKind === "primary" ? 0 : 1,
|
|
@@ -5496,6 +5504,11 @@ function createRunCompletionState(input) {
|
|
|
5496
5504
|
connectorId,
|
|
5497
5505
|
phase: "usage_snapshot_persisted",
|
|
5498
5506
|
closureAttempt: 0,
|
|
5507
|
+
closureAttempts: {
|
|
5508
|
+
workDisposition: 0,
|
|
5509
|
+
livePath: 0,
|
|
5510
|
+
terminalDisposition: 0
|
|
5511
|
+
},
|
|
5499
5512
|
command,
|
|
5500
5513
|
executor: record4(input.executor),
|
|
5501
5514
|
completionRequest: record4(input.completionRequest),
|
|
@@ -5518,11 +5531,18 @@ function appendRunCompletionUsageTurn(state, input) {
|
|
|
5518
5531
|
const current = assertValidRunCompletionState(state);
|
|
5519
5532
|
const turn = normalizeRunTurnUsage(input);
|
|
5520
5533
|
const priorTurns = current.usageRecord.turns.filter((entry) => entry.turn !== turn.turn);
|
|
5521
|
-
const turnOrder = {
|
|
5534
|
+
const turnOrder = {
|
|
5535
|
+
primary: 0,
|
|
5536
|
+
terminal_text_repair: 1,
|
|
5537
|
+
closure: 2,
|
|
5538
|
+
work_disposition_closure: 2,
|
|
5539
|
+
live_path_closure: 3,
|
|
5540
|
+
terminal_disposition_closure: 4
|
|
5541
|
+
};
|
|
5522
5542
|
const turns = [...priorTurns, turn].sort((left, right) => turnOrder[left.turn] - turnOrder[right.turn]);
|
|
5523
5543
|
return {
|
|
5524
5544
|
...current,
|
|
5525
|
-
closureAttempt: turn.turn
|
|
5545
|
+
closureAttempt: turn.turn.endsWith("closure") ? 1 : current.closureAttempt,
|
|
5526
5546
|
phase: "usage_snapshot_persisted",
|
|
5527
5547
|
usageRecord: {
|
|
5528
5548
|
...current.usageRecord,
|
|
@@ -5580,7 +5600,7 @@ function assertValidRunCompletionState(value) {
|
|
|
5580
5600
|
throw new Error("run_completion_state_invalid:usage_idempotency_key");
|
|
5581
5601
|
}
|
|
5582
5602
|
const turns = Array.isArray(usageRecord.turns) ? usageRecord.turns.map(normalizeRunTurnUsage) : [];
|
|
5583
|
-
if (turns.length < 1 || turns.length >
|
|
5603
|
+
if (turns.length < 1 || turns.length > 5) throw new Error("run_completion_state_invalid:usage_turns");
|
|
5584
5604
|
const kinds = new Set(turns.map((turn) => turn.turn));
|
|
5585
5605
|
if (kinds.size !== turns.length || !kinds.has("primary")) {
|
|
5586
5606
|
throw new Error("run_completion_state_invalid:usage_turn_identity");
|
|
@@ -5588,7 +5608,10 @@ function assertValidRunCompletionState(value) {
|
|
|
5588
5608
|
const expectedTurnOrder = [
|
|
5589
5609
|
"primary",
|
|
5590
5610
|
...kinds.has("terminal_text_repair") ? ["terminal_text_repair"] : [],
|
|
5591
|
-
...kinds.has("closure") ? ["closure"] : []
|
|
5611
|
+
...kinds.has("closure") ? ["closure"] : [],
|
|
5612
|
+
...kinds.has("work_disposition_closure") ? ["work_disposition_closure"] : [],
|
|
5613
|
+
...kinds.has("live_path_closure") ? ["live_path_closure"] : [],
|
|
5614
|
+
...kinds.has("terminal_disposition_closure") ? ["terminal_disposition_closure"] : []
|
|
5592
5615
|
];
|
|
5593
5616
|
if (turns.some((turn, index) => turn.turn !== expectedTurnOrder[index])) {
|
|
5594
5617
|
throw new Error("run_completion_state_invalid:usage_turn_order");
|
|
@@ -8094,6 +8117,7 @@ var CAPABILITIES = [
|
|
|
8094
8117
|
"workspace_binding",
|
|
8095
8118
|
"run_wakeup",
|
|
8096
8119
|
"runtime_actions_v2",
|
|
8120
|
+
"run_exit_live_path_closure_v1",
|
|
8097
8121
|
"model_call",
|
|
8098
8122
|
"model_call_output_contract_v1",
|
|
8099
8123
|
"run_cancel",
|
|
@@ -11650,7 +11674,7 @@ var source_acquisition_compatibility_default = {
|
|
|
11650
11674
|
};
|
|
11651
11675
|
|
|
11652
11676
|
// src/amaster-runtime-daemon.mjs
|
|
11653
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
11677
|
+
var CONNECTOR_VERSION = "0.1.1-beta.83";
|
|
11654
11678
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
11655
11679
|
var SOURCE_ACQUISITION_CAPABILITY = source_acquisition_compatibility_default.profileVersion;
|
|
11656
11680
|
var daemonRequire = createRequire(import.meta.url);
|
|
@@ -14567,14 +14591,21 @@ function runCompletionCheckRequest(state) {
|
|
|
14567
14591
|
const turns = Array.isArray(asRecord(state.usageRecord).turns) ? asRecord(state.usageRecord).turns.map(asRecord) : [];
|
|
14568
14592
|
const terminalTextRepairAttempt = turns.some((turn) => turn.turn === "terminal_text_repair") ? 1 : 0;
|
|
14569
14593
|
const closureAttempt = state.closureAttempt === 1 ? 1 : 0;
|
|
14594
|
+
const closureAttempts = {
|
|
14595
|
+
workDisposition: readNumber(asRecord(state.closureAttempts).workDisposition, 0) === 1 ? 1 : 0,
|
|
14596
|
+
livePath: readNumber(asRecord(state.closureAttempts).livePath, 0) === 1 ? 1 : 0,
|
|
14597
|
+
terminalDisposition: readNumber(asRecord(state.closureAttempts).terminalDisposition, 0) === 1 ? 1 : 0
|
|
14598
|
+
};
|
|
14599
|
+
const v2 = prior.contractVersion === "amaster.runtime-connector.completion-check.v2";
|
|
14600
|
+
const closureTurnCount = v2 ? closureAttempts.workDisposition + closureAttempts.livePath + closureAttempts.terminalDisposition : closureAttempt;
|
|
14570
14601
|
return {
|
|
14571
|
-
contractVersion: "amaster.runtime-connector.completion-check.v1",
|
|
14602
|
+
contractVersion: v2 ? "amaster.runtime-connector.completion-check.v2" : "amaster.runtime-connector.completion-check.v1",
|
|
14572
14603
|
...readString(asRecord(state.command).leaseId) ? { leaseId: readString(asRecord(state.command).leaseId) } : {},
|
|
14573
14604
|
proposedStatus: state.candidateStatus,
|
|
14574
14605
|
resultSignals: {
|
|
14575
14606
|
productiveSuccessfulRun: prior.resultSignals?.productiveSuccessfulRun === true,
|
|
14576
|
-
executorTurnCount: 1 + terminalTextRepairAttempt +
|
|
14577
|
-
closureAttempt,
|
|
14607
|
+
executorTurnCount: 1 + terminalTextRepairAttempt + closureTurnCount,
|
|
14608
|
+
...v2 ? { closureAttempts } : { closureAttempt },
|
|
14578
14609
|
...terminalTextRepairAttempt === 1 ? { terminalTextRepairAttempt } : {}
|
|
14579
14610
|
}
|
|
14580
14611
|
};
|
|
@@ -14654,7 +14685,10 @@ async function requestRunCompletionCheck(config, inputState) {
|
|
|
14654
14685
|
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
14655
14686
|
try {
|
|
14656
14687
|
const response = asRecord(await postJson(config, path, runCompletionCheckRequest(state)));
|
|
14657
|
-
if (
|
|
14688
|
+
if (![
|
|
14689
|
+
"amaster.runtime-connector.completion-check.v1",
|
|
14690
|
+
"amaster.runtime-connector.completion-check.v2"
|
|
14691
|
+
].includes(response.contractVersion) || response.contractVersion !== runCompletionCheckRequest(state).contractVersion || !["ready_to_terminalize", "disposition_required"].includes(response.outcome) || !["observe", "enforce"].includes(response.enforcementMode)) {
|
|
14658
14692
|
const error = new Error("runtime_completion_check_response_invalid");
|
|
14659
14693
|
error.code = "runtime_completion_check_response_invalid";
|
|
14660
14694
|
throw error;
|
|
@@ -14750,6 +14784,8 @@ function runExitClosurePrompt(state, options = {}) {
|
|
|
14750
14784
|
const issueId = commandIssueId(command) ?? "unknown";
|
|
14751
14785
|
const runId = commandRunId(command) ?? "unknown";
|
|
14752
14786
|
const closureStrategy = readString(response.closureStrategy) ?? "select_issue_disposition";
|
|
14787
|
+
const closurePhase = readString(response.closurePhase) ?? "disposition_closure";
|
|
14788
|
+
const workDispositionClosure = closureStrategy === "record_work_disposition" || closurePhase === "work_disposition_closure";
|
|
14753
14789
|
const describeRequired = options.describeRequired !== false;
|
|
14754
14790
|
const allowedActions = Array.isArray(response.allowedActions) ? response.allowedActions.filter((value) => typeof value === "string") : [];
|
|
14755
14791
|
return [
|
|
@@ -14759,11 +14795,11 @@ function runExitClosurePrompt(state, options = {}) {
|
|
|
14759
14795
|
`Completion reason: ${readString(response.reasonCode) ?? "successful_run_missing_state"}`,
|
|
14760
14796
|
summary ? `Primary turn summary: ${summary}` : null,
|
|
14761
14797
|
"Do not perform more business work, edit files, create artifacts/documents/children/plans, or mutate company/profile/milestone state.",
|
|
14762
|
-
|
|
14763
|
-
describeRequired ?
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
`The idempotencyKey must be runtime-command-closure:${state.commandId}.`,
|
|
14798
|
+
closurePhase === "live_path_closure" ? "Effective closure action for this turn: choose exactly one typed external wait, scheduled monitor, or choose_task_disposition interaction." : closurePhase === "terminal_disposition_closure" ? "Effective closure action for this turn: establish the authorized terminal disposition or one Board decision interaction." : workDispositionClosure ? "Effective closure action for this turn: record_work_disposition only." : `Server-allowed closure actions: ${allowedActions.join(", ") || "none"}.`,
|
|
14799
|
+
describeRequired ? workDispositionClosure ? "Call runtime_action.describe exactly once for record_work_disposition, then use exactly one runtime_action.submit mutation with that described shape." : "Choose one Server-allowed action, call runtime_action.describe exactly once for that action type, then use exactly one runtime_action.submit mutation with that described shape." : "Use exactly one runtime_action.submit mutation with the already-issued phase-specific schema.",
|
|
14800
|
+
workDispositionClosure ? "The Server selected record_work_disposition as the only closure strategy. For this already-productive source run, record execute_inline with truthful source-run evidence; do not also mutate issue status or create an interaction. After command terminalization, the Server writes the Business Outcome and owns the matching Board review or terminal-state transition." : closurePhase === "live_path_closure" ? "The Server selected Durable Live Path closure. Establish exactly one typed external wait, scheduled monitor, or Board disposition interaction; a comment or Work Disposition does not satisfy this gate." : closurePhase === "terminal_disposition_closure" ? "The Server selected terminal disposition closure. Establish the authorized terminal state or one Board decision interaction; do not create a new live wait merely to avoid terminalization." : "The Server selected an Issue disposition closure. Choose update_parent, create_interaction (not suggest_tasks), or add_comment only when a comment is truly the intended exit path. A comment alone does not establish completion.",
|
|
14801
|
+
workDispositionClosure ? `Use evidenceRefs ["run:${runId}", "command:${state.commandId}"], structure.deliverableType "runtime_command_result", structure.deliverableKey "runtime-command-${state.commandId}", and structure.acceptanceMethodCode "governed_business_outcome". Supply a concise truthful reason based only on the primary turn summary.` : null,
|
|
14802
|
+
`The idempotencyKey must be runtime-command-closure:${state.commandId}${closurePhase === "work_disposition_closure" ? ":work-disposition" : closurePhase === "live_path_closure" ? ":live-path" : closurePhase === "terminal_disposition_closure" ? ":terminal-disposition" : ""}.`,
|
|
14767
14803
|
describeRequired ? "Do not call runtime_action.plan or runtime_action.commit. Do not call runtime_action.describe more than once. Stop immediately after the one allowed mutation returns." : "Do not call runtime_action.describe, runtime_action.plan, or runtime_action.commit. Stop immediately after the one allowed mutation returns."
|
|
14768
14804
|
].filter(Boolean).join("\n\n");
|
|
14769
14805
|
}
|
|
@@ -15369,16 +15405,23 @@ async function coordinateRunCompletion(config, inputState, options = {}) {
|
|
|
15369
15405
|
};
|
|
15370
15406
|
}
|
|
15371
15407
|
if (checked.pending) return { pending: true, resultDelivered: false, state };
|
|
15372
|
-
|
|
15373
|
-
const
|
|
15408
|
+
while (state.phase === "disposition_required") {
|
|
15409
|
+
const completionResponse = asRecord(state.completionResponse);
|
|
15410
|
+
const closurePhase = readString(completionResponse.closurePhase) ?? "disposition_closure";
|
|
15411
|
+
const closureAttemptKey = closurePhase === "work_disposition_closure" ? "workDisposition" : closurePhase === "live_path_closure" ? "livePath" : closurePhase === "terminal_disposition_closure" ? "terminalDisposition" : null;
|
|
15412
|
+
const v2 = readString(completionResponse.contractVersion) === "amaster.runtime-connector.completion-check.v2";
|
|
15413
|
+
const closureTurns = asRecord(state.closureTurns);
|
|
15414
|
+
const closureAlreadyRecorded = closureAttemptKey ? Boolean(closureTurns[closureAttemptKey]) : state.closureTurnRecorded === true;
|
|
15374
15415
|
const recoveryCount = readNumber(state.closureRecoveryCount, 0);
|
|
15375
15416
|
const mayResumeUncertainClosure = recoveringClosure && !closureAlreadyRecorded && recoveryCount < 1;
|
|
15376
|
-
|
|
15417
|
+
const priorAttempt = closureAttemptKey ? readNumber(asRecord(state.closureAttempts)[closureAttemptKey], 0) : readNumber(state.closureAttempt, 0);
|
|
15418
|
+
if (priorAttempt === 0 || mayResumeUncertainClosure) {
|
|
15419
|
+
const nextClosureAttempts = closureAttemptKey ? { ...asRecord(state.closureAttempts), [closureAttemptKey]: 1 } : asRecord(state.closureAttempts);
|
|
15377
15420
|
state = persistPendingRunCompletion(config, transitionRunCompletionState(
|
|
15378
15421
|
state,
|
|
15379
15422
|
"closure_started",
|
|
15380
15423
|
{
|
|
15381
|
-
closureAttempt: 1,
|
|
15424
|
+
...v2 ? { closureAttempts: nextClosureAttempts } : { closureAttempt: 1 },
|
|
15382
15425
|
...mayResumeUncertainClosure ? { closureRecoveryCount: recoveryCount + 1 } : {}
|
|
15383
15426
|
}
|
|
15384
15427
|
));
|
|
@@ -15398,15 +15441,17 @@ async function coordinateRunCompletion(config, inputState, options = {}) {
|
|
|
15398
15441
|
}
|
|
15399
15442
|
};
|
|
15400
15443
|
}
|
|
15444
|
+
const candidateResult = asRecord(state.candidateResult);
|
|
15401
15445
|
state = appendRunCompletionUsageTurn({
|
|
15402
15446
|
...state,
|
|
15403
|
-
closureTurnRecorded: true,
|
|
15447
|
+
...closureAttemptKey ? { closureTurns: { ...closureTurns, [closureAttemptKey]: closure.audit } } : { closureTurnRecorded: true },
|
|
15404
15448
|
candidateResult: {
|
|
15405
|
-
...
|
|
15406
|
-
closureTurn: closure.audit
|
|
15449
|
+
...candidateResult,
|
|
15450
|
+
closureTurn: closure.audit,
|
|
15451
|
+
...closureAttemptKey ? { closureTurns: { ...asRecord(candidateResult.closureTurns), [closureAttemptKey]: closure.audit } } : {}
|
|
15407
15452
|
}
|
|
15408
15453
|
}, {
|
|
15409
|
-
turn: "closure",
|
|
15454
|
+
turn: closureAttemptKey === "workDisposition" ? "work_disposition_closure" : closureAttemptKey === "livePath" ? "live_path_closure" : closureAttemptKey === "terminalDisposition" ? "terminal_disposition_closure" : "closure",
|
|
15410
15455
|
usage: closure.usage,
|
|
15411
15456
|
recordedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
15412
15457
|
});
|
|
@@ -15428,7 +15473,9 @@ async function coordinateRunCompletion(config, inputState, options = {}) {
|
|
|
15428
15473
|
};
|
|
15429
15474
|
}
|
|
15430
15475
|
if (checked.pending) return { pending: true, resultDelivered: false, state };
|
|
15476
|
+
continue;
|
|
15431
15477
|
}
|
|
15478
|
+
break;
|
|
15432
15479
|
}
|
|
15433
15480
|
if (state.phase === "disposition_required") {
|
|
15434
15481
|
const command = asRecord(state.command);
|
|
@@ -17048,13 +17095,19 @@ async function executeRunCommand(config, command) {
|
|
|
17048
17095
|
}
|
|
17049
17096
|
},
|
|
17050
17097
|
completionRequest: {
|
|
17051
|
-
contractVersion: "amaster.runtime-connector.completion-check.v1",
|
|
17098
|
+
contractVersion: config.capabilities.includes("run_exit_live_path_closure_v1") ? "amaster.runtime-connector.completion-check.v2" : "amaster.runtime-connector.completion-check.v1",
|
|
17052
17099
|
leaseId: command.leaseId,
|
|
17053
17100
|
proposedStatus: "succeeded",
|
|
17054
17101
|
resultSignals: {
|
|
17055
17102
|
productiveSuccessfulRun,
|
|
17056
17103
|
executorTurnCount: terminalTextRepairUsageBreakdown ? 2 : 1,
|
|
17057
|
-
|
|
17104
|
+
...config.capabilities.includes("run_exit_live_path_closure_v1") ? {
|
|
17105
|
+
closureAttempts: {
|
|
17106
|
+
workDisposition: 0,
|
|
17107
|
+
livePath: 0,
|
|
17108
|
+
terminalDisposition: 0
|
|
17109
|
+
}
|
|
17110
|
+
} : { closureAttempt: 0 },
|
|
17058
17111
|
...terminalTextRepairUsageBreakdown ? { terminalTextRepairAttempt: 1 } : {}
|
|
17059
17112
|
}
|
|
17060
17113
|
},
|
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.83";
|
|
10
10
|
|
|
11
11
|
const CAPABILITIES = [
|
|
12
12
|
"remote_registration",
|
|
@@ -15,6 +15,7 @@ const CAPABILITIES = [
|
|
|
15
15
|
"workspace_binding",
|
|
16
16
|
"run_wakeup",
|
|
17
17
|
"runtime_actions_v2",
|
|
18
|
+
"run_exit_live_path_closure_v1",
|
|
18
19
|
"model_call",
|
|
19
20
|
"model_call_output_contract_v1",
|
|
20
21
|
"run_cancel",
|