@amaster.ai/employee-runtime-connector 0.1.1-beta.82 → 0.1.1-beta.84

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 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 turnKind = source.turn === "closure" ? "closure" : source.turn === "terminal_text_repair" ? "terminal_text_repair" : "primary";
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 = { primary: 0, terminal_text_repair: 1, closure: 2 };
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 === "closure" ? 1 : current.closureAttempt,
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 > 3) throw new Error("run_completion_state_invalid:usage_turns");
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");
@@ -6437,11 +6460,23 @@ function resolvedDependencySections(context, input, contextScope, snapshotFreshn
6437
6460
  ` \u2026mandatory required reads are capped at ${MAX_RESOLVED_DEPENDENCY_REQUIRED_READS}; the remaining ${overflowRefs.length} predecessor document(s) are listed under On-demand Context References.`
6438
6461
  );
6439
6462
  }
6440
- const requiredLines = tuples.length > 0 ? [
6441
- "Accepted predecessor outputs are binding inputs unless this issue explicitly requests reconsideration.",
6442
- "Before any downstream document/artifact write, review request, status mutation, or completion, perform every Required read.",
6443
- "Current-issue documents, parent-issue documents, summaries, and workspace files are not substitutes for these predecessor documents.",
6444
- "Compare each returned latestRevisionId with the expected value. On revision mismatch, do not perform downstream writes; report it.",
6463
+ const completionContext = asRecord(context.completionContext);
6464
+ const requiredChildIssueIds = Array.isArray(completionContext.requiredChildIssueIds) ? completionContext.requiredChildIssueIds.map(readString).filter(Boolean) : [];
6465
+ const multiAcceptanceParentClosure = completionContext.acceptanceRefreshRequired === true && !readString(completionContext.finalAggregationIssueId) && requiredChildIssueIds.length > 0;
6466
+ const multiAcceptanceLines = multiAcceptanceParentClosure ? [
6467
+ "Multi-acceptance parent closure contract:",
6468
+ "- A parent-only summary or parent-only Delivery Manifest is not sufficient, even when every child is already done and accepted.",
6469
+ "- The refreshed parent Delivery Manifest must include at least one exact current deliverable from every required child as a supporting exact_ref. Use the Required reads below when they identify a current document revision. For a required child without a document tuple, read that child's current Delivery Manifest and copy an exact current ref; never invent one. Keep the parent aggregation deliverable as primary when applicable.",
6470
+ "- Re-read current parent delivery readiness immediately before publishing the replacement Manifest. Do not attempt terminal status while any required child is absent from the Manifest."
6471
+ ] : [];
6472
+ const requiredLines = tuples.length > 0 || multiAcceptanceLines.length > 0 ? [
6473
+ ...tuples.length > 0 ? [
6474
+ "Accepted predecessor outputs are binding inputs unless this issue explicitly requests reconsideration.",
6475
+ "Before any downstream document/artifact write, review request, status mutation, or completion, perform every Required read.",
6476
+ "Current-issue documents, parent-issue documents, summaries, and workspace files are not substitutes for these predecessor documents.",
6477
+ "Compare each returned latestRevisionId with the expected value. On revision mismatch, do not perform downstream writes; report it."
6478
+ ] : [],
6479
+ ...multiAcceptanceLines,
6445
6480
  ...tuples.flatMap((tuple, index) => {
6446
6481
  const readArguments = { issueId: tuple.blockerSelector, key: tuple.key };
6447
6482
  const directToolName = managedDirectToolName(input, "amaster.read_issue_document");
@@ -8094,6 +8129,7 @@ var CAPABILITIES = [
8094
8129
  "workspace_binding",
8095
8130
  "run_wakeup",
8096
8131
  "runtime_actions_v2",
8132
+ "run_exit_live_path_closure_v1",
8097
8133
  "model_call",
8098
8134
  "model_call_output_contract_v1",
8099
8135
  "run_cancel",
@@ -11650,7 +11686,7 @@ var source_acquisition_compatibility_default = {
11650
11686
  };
11651
11687
 
11652
11688
  // src/amaster-runtime-daemon.mjs
11653
- var CONNECTOR_VERSION = "0.1.1-beta.82";
11689
+ var CONNECTOR_VERSION = "0.1.1-beta.84";
11654
11690
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
11655
11691
  var SOURCE_ACQUISITION_CAPABILITY = source_acquisition_compatibility_default.profileVersion;
11656
11692
  var daemonRequire = createRequire(import.meta.url);
@@ -14567,14 +14603,21 @@ function runCompletionCheckRequest(state) {
14567
14603
  const turns = Array.isArray(asRecord(state.usageRecord).turns) ? asRecord(state.usageRecord).turns.map(asRecord) : [];
14568
14604
  const terminalTextRepairAttempt = turns.some((turn) => turn.turn === "terminal_text_repair") ? 1 : 0;
14569
14605
  const closureAttempt = state.closureAttempt === 1 ? 1 : 0;
14606
+ const closureAttempts = {
14607
+ workDisposition: readNumber(asRecord(state.closureAttempts).workDisposition, 0) === 1 ? 1 : 0,
14608
+ livePath: readNumber(asRecord(state.closureAttempts).livePath, 0) === 1 ? 1 : 0,
14609
+ terminalDisposition: readNumber(asRecord(state.closureAttempts).terminalDisposition, 0) === 1 ? 1 : 0
14610
+ };
14611
+ const v2 = prior.contractVersion === "amaster.runtime-connector.completion-check.v2";
14612
+ const closureTurnCount = v2 ? closureAttempts.workDisposition + closureAttempts.livePath + closureAttempts.terminalDisposition : closureAttempt;
14570
14613
  return {
14571
- contractVersion: "amaster.runtime-connector.completion-check.v1",
14614
+ contractVersion: v2 ? "amaster.runtime-connector.completion-check.v2" : "amaster.runtime-connector.completion-check.v1",
14572
14615
  ...readString(asRecord(state.command).leaseId) ? { leaseId: readString(asRecord(state.command).leaseId) } : {},
14573
14616
  proposedStatus: state.candidateStatus,
14574
14617
  resultSignals: {
14575
14618
  productiveSuccessfulRun: prior.resultSignals?.productiveSuccessfulRun === true,
14576
- executorTurnCount: 1 + terminalTextRepairAttempt + closureAttempt,
14577
- closureAttempt,
14619
+ executorTurnCount: 1 + terminalTextRepairAttempt + closureTurnCount,
14620
+ ...v2 ? { closureAttempts } : { closureAttempt },
14578
14621
  ...terminalTextRepairAttempt === 1 ? { terminalTextRepairAttempt } : {}
14579
14622
  }
14580
14623
  };
@@ -14654,7 +14697,10 @@ async function requestRunCompletionCheck(config, inputState) {
14654
14697
  for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
14655
14698
  try {
14656
14699
  const response = asRecord(await postJson(config, path, runCompletionCheckRequest(state)));
14657
- if (response.contractVersion !== "amaster.runtime-connector.completion-check.v1" || !["ready_to_terminalize", "disposition_required"].includes(response.outcome) || !["observe", "enforce"].includes(response.enforcementMode)) {
14700
+ if (![
14701
+ "amaster.runtime-connector.completion-check.v1",
14702
+ "amaster.runtime-connector.completion-check.v2"
14703
+ ].includes(response.contractVersion) || response.contractVersion !== runCompletionCheckRequest(state).contractVersion || !["ready_to_terminalize", "disposition_required"].includes(response.outcome) || !["observe", "enforce"].includes(response.enforcementMode)) {
14658
14704
  const error = new Error("runtime_completion_check_response_invalid");
14659
14705
  error.code = "runtime_completion_check_response_invalid";
14660
14706
  throw error;
@@ -14750,6 +14796,8 @@ function runExitClosurePrompt(state, options = {}) {
14750
14796
  const issueId = commandIssueId(command) ?? "unknown";
14751
14797
  const runId = commandRunId(command) ?? "unknown";
14752
14798
  const closureStrategy = readString(response.closureStrategy) ?? "select_issue_disposition";
14799
+ const closurePhase = readString(response.closurePhase) ?? "disposition_closure";
14800
+ const workDispositionClosure = closureStrategy === "record_work_disposition" || closurePhase === "work_disposition_closure";
14753
14801
  const describeRequired = options.describeRequired !== false;
14754
14802
  const allowedActions = Array.isArray(response.allowedActions) ? response.allowedActions.filter((value) => typeof value === "string") : [];
14755
14803
  return [
@@ -14759,11 +14807,11 @@ function runExitClosurePrompt(state, options = {}) {
14759
14807
  `Completion reason: ${readString(response.reasonCode) ?? "successful_run_missing_state"}`,
14760
14808
  summary ? `Primary turn summary: ${summary}` : null,
14761
14809
  "Do not perform more business work, edit files, create artifacts/documents/children/plans, or mutate company/profile/milestone state.",
14762
- closureStrategy === "record_work_disposition" ? "Effective closure action for this turn: record_work_disposition only." : `Server-allowed closure actions: ${allowedActions.join(", ") || "none"}.`,
14763
- describeRequired ? closureStrategy === "record_work_disposition" ? "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.",
14764
- closureStrategy === "record_work_disposition" ? "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." : "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.",
14765
- closureStrategy === "record_work_disposition" ? `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,
14766
- `The idempotencyKey must be runtime-command-closure:${state.commandId}.`,
14810
+ 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"}.`,
14811
+ 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.",
14812
+ 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.",
14813
+ 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,
14814
+ `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
14815
  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
14816
  ].filter(Boolean).join("\n\n");
14769
14817
  }
@@ -15369,16 +15417,23 @@ async function coordinateRunCompletion(config, inputState, options = {}) {
15369
15417
  };
15370
15418
  }
15371
15419
  if (checked.pending) return { pending: true, resultDelivered: false, state };
15372
- if (state.phase === "disposition_required") {
15373
- const closureAlreadyRecorded = state.closureTurnRecorded === true;
15420
+ while (state.phase === "disposition_required") {
15421
+ const completionResponse = asRecord(state.completionResponse);
15422
+ const closurePhase = readString(completionResponse.closurePhase) ?? "disposition_closure";
15423
+ const closureAttemptKey = closurePhase === "work_disposition_closure" ? "workDisposition" : closurePhase === "live_path_closure" ? "livePath" : closurePhase === "terminal_disposition_closure" ? "terminalDisposition" : null;
15424
+ const v2 = readString(completionResponse.contractVersion) === "amaster.runtime-connector.completion-check.v2";
15425
+ const closureTurns = asRecord(state.closureTurns);
15426
+ const closureAlreadyRecorded = closureAttemptKey ? Boolean(closureTurns[closureAttemptKey]) : state.closureTurnRecorded === true;
15374
15427
  const recoveryCount = readNumber(state.closureRecoveryCount, 0);
15375
15428
  const mayResumeUncertainClosure = recoveringClosure && !closureAlreadyRecorded && recoveryCount < 1;
15376
- if (state.closureAttempt === 0 || mayResumeUncertainClosure) {
15429
+ const priorAttempt = closureAttemptKey ? readNumber(asRecord(state.closureAttempts)[closureAttemptKey], 0) : readNumber(state.closureAttempt, 0);
15430
+ if (priorAttempt === 0 || mayResumeUncertainClosure) {
15431
+ const nextClosureAttempts = closureAttemptKey ? { ...asRecord(state.closureAttempts), [closureAttemptKey]: 1 } : asRecord(state.closureAttempts);
15377
15432
  state = persistPendingRunCompletion(config, transitionRunCompletionState(
15378
15433
  state,
15379
15434
  "closure_started",
15380
15435
  {
15381
- closureAttempt: 1,
15436
+ ...v2 ? { closureAttempts: nextClosureAttempts } : { closureAttempt: 1 },
15382
15437
  ...mayResumeUncertainClosure ? { closureRecoveryCount: recoveryCount + 1 } : {}
15383
15438
  }
15384
15439
  ));
@@ -15398,15 +15453,17 @@ async function coordinateRunCompletion(config, inputState, options = {}) {
15398
15453
  }
15399
15454
  };
15400
15455
  }
15456
+ const candidateResult = asRecord(state.candidateResult);
15401
15457
  state = appendRunCompletionUsageTurn({
15402
15458
  ...state,
15403
- closureTurnRecorded: true,
15459
+ ...closureAttemptKey ? { closureTurns: { ...closureTurns, [closureAttemptKey]: closure.audit } } : { closureTurnRecorded: true },
15404
15460
  candidateResult: {
15405
- ...asRecord(state.candidateResult),
15406
- closureTurn: closure.audit
15461
+ ...candidateResult,
15462
+ closureTurn: closure.audit,
15463
+ ...closureAttemptKey ? { closureTurns: { ...asRecord(candidateResult.closureTurns), [closureAttemptKey]: closure.audit } } : {}
15407
15464
  }
15408
15465
  }, {
15409
- turn: "closure",
15466
+ turn: closureAttemptKey === "workDisposition" ? "work_disposition_closure" : closureAttemptKey === "livePath" ? "live_path_closure" : closureAttemptKey === "terminalDisposition" ? "terminal_disposition_closure" : "closure",
15410
15467
  usage: closure.usage,
15411
15468
  recordedAt: (/* @__PURE__ */ new Date()).toISOString()
15412
15469
  });
@@ -15428,7 +15485,9 @@ async function coordinateRunCompletion(config, inputState, options = {}) {
15428
15485
  };
15429
15486
  }
15430
15487
  if (checked.pending) return { pending: true, resultDelivered: false, state };
15488
+ continue;
15431
15489
  }
15490
+ break;
15432
15491
  }
15433
15492
  if (state.phase === "disposition_required") {
15434
15493
  const command = asRecord(state.command);
@@ -17048,13 +17107,19 @@ async function executeRunCommand(config, command) {
17048
17107
  }
17049
17108
  },
17050
17109
  completionRequest: {
17051
- contractVersion: "amaster.runtime-connector.completion-check.v1",
17110
+ contractVersion: config.capabilities.includes("run_exit_live_path_closure_v1") ? "amaster.runtime-connector.completion-check.v2" : "amaster.runtime-connector.completion-check.v1",
17052
17111
  leaseId: command.leaseId,
17053
17112
  proposedStatus: "succeeded",
17054
17113
  resultSignals: {
17055
17114
  productiveSuccessfulRun,
17056
17115
  executorTurnCount: terminalTextRepairUsageBreakdown ? 2 : 1,
17057
- closureAttempt: 0,
17116
+ ...config.capabilities.includes("run_exit_live_path_closure_v1") ? {
17117
+ closureAttempts: {
17118
+ workDisposition: 0,
17119
+ livePath: 0,
17120
+ terminalDisposition: 0
17121
+ }
17122
+ } : { closureAttempt: 0 },
17058
17123
  ...terminalTextRepairUsageBreakdown ? { terminalTextRepairAttempt: 1 } : {}
17059
17124
  }
17060
17125
  },
@@ -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.82";
9
+ const CONNECTOR_VERSION = "0.1.1-beta.84";
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.82",
3
+ "version": "0.1.1-beta.84",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",