@amaster.ai/employee-runtime-connector 0.1.1-beta.70 → 0.1.1-beta.72

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.
@@ -2939,6 +2939,34 @@ function applyManagedPiToolAllowlist(args, profile) {
2939
2939
  ...args.slice(printArgIndex)
2940
2940
  ];
2941
2941
  }
2942
+ function applyManagedPiRunExitClosureArgs(args, profile) {
2943
+ const narrowedArgs = applyManagedPiToolAllowlist(args, profile);
2944
+ const toolAllowlist = Array.isArray(profile?.toolAllowlist) ? profile.toolAllowlist.filter((name) => typeof name === "string" && name) : [];
2945
+ if (toolAllowlist.length === 0 || toolAllowlist.includes("read") || typeof profile?.profileRoot !== "string" || !profile.profileRoot) {
2946
+ return narrowedArgs;
2947
+ }
2948
+ const canonicalPath = (filePath) => {
2949
+ try {
2950
+ return realpathSync2(filePath);
2951
+ } catch {
2952
+ return resolve3(filePath);
2953
+ }
2954
+ };
2955
+ const roleSkillsVisibilityExtension = canonicalPath(resolve3(
2956
+ profile.profileRoot,
2957
+ "extensions",
2958
+ MANAGED_PI_ROLE_SKILLS_VISIBILITY_FILENAME
2959
+ ));
2960
+ const closureArgs = [];
2961
+ for (let index = 0; index < narrowedArgs.length; index += 1) {
2962
+ if (narrowedArgs[index] === "--extension" && typeof narrowedArgs[index + 1] === "string" && canonicalPath(narrowedArgs[index + 1]) === roleSkillsVisibilityExtension) {
2963
+ index += 1;
2964
+ continue;
2965
+ }
2966
+ closureArgs.push(narrowedArgs[index]);
2967
+ }
2968
+ return closureArgs;
2969
+ }
2942
2970
  function createManagedPiMcpProfileApi(options = {}) {
2943
2971
  const spawnSyncImpl = typeof options.spawnSync === "function" ? options.spawnSync : spawnSync2;
2944
2972
  const chownSyncImpl = typeof options.chownSync === "function" ? options.chownSync : chownSync2;
@@ -3833,6 +3861,14 @@ function createManagedPiMcpProfileApi(options = {}) {
3833
3861
  }
3834
3862
  return profile;
3835
3863
  }
3864
+ function readCommonRoleSkills(piHome) {
3865
+ const skillsRoot = resolve3(piHome, "bundles", "common", "skills");
3866
+ if (!existsSync3(skillsRoot)) return [];
3867
+ return readdirSync3(skillsRoot).sort().flatMap((name) => {
3868
+ const source = join4(skillsRoot, name);
3869
+ return existsSync3(join4(source, "SKILL.md")) ? [{ name, source }] : [];
3870
+ });
3871
+ }
3836
3872
  function resolveManagedRoleSkills(piHome, skillProfiles) {
3837
3873
  const entriesByName = /* @__PURE__ */ new Map();
3838
3874
  for (const skillProfile of skillProfiles) {
@@ -3847,6 +3883,9 @@ function createManagedPiMcpProfileApi(options = {}) {
3847
3883
  entriesByName.set(entry.name, entry);
3848
3884
  }
3849
3885
  }
3886
+ for (const entry of readCommonRoleSkills(piHome)) {
3887
+ if (!entriesByName.has(entry.name)) entriesByName.set(entry.name, entry);
3888
+ }
3850
3889
  const entries = [...entriesByName.values()].map((entry) => ({
3851
3890
  name: entry.name,
3852
3891
  filePath: realpathSync2(join4(entry.source, "SKILL.md"))
@@ -6580,8 +6619,10 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
6580
6619
  const evidenceAutoAcceptance = acceptancePolicy.mode === "evidence_auto" && acceptancePolicy.verdictAuthority === "none" && acceptancePolicy.acceptanceAuthority === null && acceptanceValidatorIds.length === EVIDENCE_AUTO_VALIDATOR_IDS.size && acceptanceValidatorIds.every((value) => EVIDENCE_AUTO_VALIDATOR_IDS.has(value));
6581
6620
  const completionRole = readString(completion.role);
6582
6621
  const completionDeliverable = readString(completion.deliverable);
6622
+ const delegatedAggregationEvidence = asRecord(context.paperclipDelegatedAggregationEvidence);
6623
+ const delegatedDelivery = readString(delegatedAggregationEvidence.schemaVersion) === "delegated-aggregation-evidence-v1" && readString(delegatedAggregationEvidence.finalAggregationIssueId) && readString(delegatedAggregationEvidence.manifestId) && readString(delegatedAggregationEvidence.packageReviewInteractionId);
6583
6624
  const manifestRefreshOnly = legacyManifestRefreshOnly(context);
6584
- const firstDocumentCheckpoint = completionDeliverable === "document_or_artifact" ? manifestRefreshOnly ? "The current deliverable content already exists and this run is limited to refreshing stale immutable Manifest refs. Do not create or revise a document unless a fresh Delivery readiness read proves a content or acceptance gap beyond stale refs." : mode === "cold" ? "Before the first external browse, search, or research action, call upsert_document with a stable key. Create a checkpoint skeleton containing the acceptance criteria, a source table, and known unknowns; update the same document with each piece of verified evidence instead of waiting until broad research is complete. Immediately after upsert_document, call update_parent with status: in_progress and a concrete next action; complete both control-plane writes before the first external browse, search, or research action." : "Before the first external browse, search, or research action, read the existing stable-key document. Preserve all still-valid verified rows, source URLs, conclusions, and known unknowns; do not replace a populated document with a blank skeleton or less-informative fallback. Only when the document does not exist may you create a checkpoint skeleton. Then call update_parent with status: in_progress and a concrete next action before the first external browse, search, or research action. Update the same document with each piece of verified evidence." : "";
6625
+ const firstDocumentCheckpoint = completionDeliverable === "document_or_artifact" && !delegatedDelivery ? manifestRefreshOnly ? "The current deliverable content already exists and this run is limited to refreshing stale immutable Manifest refs. Do not create or revise a document unless a fresh Delivery readiness read proves a content or acceptance gap beyond stale refs." : mode === "cold" ? "Before the first external browse, search, or research action, call upsert_document with a stable key. Create a checkpoint skeleton containing the acceptance criteria, a source table, and known unknowns; update the same document with each piece of verified evidence instead of waiting until broad research is complete. Immediately after upsert_document, call update_parent with status: in_progress and a concrete next action; complete both control-plane writes before the first external browse, search, or research action." : "Before the first external browse, search, or research action, read the existing stable-key document. Preserve all still-valid verified rows, source URLs, conclusions, and known unknowns; do not replace a populated document with a blank skeleton or less-informative fallback. Only when the document does not exist may you create a checkpoint skeleton. Then call update_parent with status: in_progress and a concrete next action before the first external browse, search, or research action. Update the same document with each piece of verified evidence." : "";
6585
6626
  const completionContract = !suppressOrdinaryCompletionContract && completionRole && completionDeliverable ? [
6586
6627
  workDisposition.mode === "required" ? "Before the first business mutation, ensure the current required work disposition is recorded. Read-only governed checks may precede it. If no current valid receipt exists, call runtime_action.describe for record_work_disposition and persist exactly one truthful disposition before upsert_document, update_parent, add_comment, create_interaction, publish_delivery_manifest, or any other business mutation. Before ending this run, persist durable progress through Runtime Actions; browser and tool history alone are not durable progress." : "Before ending this run, persist durable progress through Runtime Actions and record one explicit task disposition. Browser and tool history alone are not durable progress.",
6587
6628
  firstDocumentCheckpoint,
@@ -6595,9 +6636,9 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
6595
6636
  "Do not create a generic review-mode request_confirmation to ask the Board to accept final completion or the Outcome, and do not mark the issue done yourself. This does not prohibit an explicit intermediate review of an exact document revision before execution continues."
6596
6637
  ].join(" ") : "";
6597
6638
  const businessOutcomeTerminalContract = !suppressOrdinaryCompletionContract && businessOutcome.mode === "required" ? [
6598
- 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.",
6639
+ delivery.mode === "required" ? delegatedDelivery ? "When every acceptance criterion is satisfied and the exact delegated final-child Manifest and package review remain current, record only the root execution disposition with update_parent status in_progress and a concise evidence summary, then end the run successfully without creating or publishing another package." : "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.",
6599
6640
  "The exact runtime_action_in_progress_server_owned rejection is the expected fail-before-effect receipt for this Server-owned handoff. After receiving it, do not retry update_parent with done or another status; end the run successfully so the Server terminal reconciler can take over.",
6600
- 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."
6641
+ evidenceAutoAcceptance ? delivery.mode === "required" ? delegatedDelivery ? "Only after the run and command succeed does the Server validate the exact delegated final-child Manifest, accepted package review, 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 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" ? delegatedDelivery ? "Only after the run and command succeed does the Server bind the exact delegated final-child Manifest, accepted package review, 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 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."
6601
6642
  ].join(" ") : "";
6602
6643
  const organizationCapabilityAllowed = asRecord(envelope.organizationCapability).allowed === true;
6603
6644
  const organizationMutationAuthorized = allowed.has("organization_mutation");
@@ -6620,6 +6661,19 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
6620
6661
  authorizationContract
6621
6662
  ].filter(Boolean).join("\n");
6622
6663
  }
6664
+ function continuationPostconditionGapSection(context, input) {
6665
+ const gap = asRecord(context.paperclipContinuationPostconditionGap);
6666
+ if (readString(gap.schemaVersion) !== "continuation-postcondition-gap-v1") return null;
6667
+ return {
6668
+ sourceRef: `run:${readString(gap.sourceRunId) ?? input.runId ?? "unknown"}:postcondition-gap`,
6669
+ freshness: { kind: "run_snapshot" },
6670
+ content: [
6671
+ "This bounded Server-owned projection overrides conflicting historical summary instructions.",
6672
+ stringifyBoundedJson(gap, 12e3),
6673
+ "Revalidate the projection, execute only the first agent-owned missing action, and do not repeat forbiddenRepeats. Board-owned and external gaps require their typed wait path."
6674
+ ].join("\n")
6675
+ };
6676
+ }
6623
6677
  function runtimeDecompositionRequirementText(context) {
6624
6678
  const issue = asRecord(context.paperclipIssue);
6625
6679
  const requirements = asRecord(issue.taskRequirements);
@@ -7239,6 +7293,7 @@ ${resolvedDependencies.details.content}` : ""
7239
7293
  const deliveryReadinessContent = runtimeDeliveryReadinessText(context, input);
7240
7294
  const optionalTaskWikiContext = optionalTaskWikiContextSection(context);
7241
7295
  const taskContextAuthority = taskContextAuthoritySection(context);
7296
+ const continuationPostconditionGap = continuationPostconditionGapSection(context, input);
7242
7297
  const companyInitializationAuthority = companyInitializationAuthoritySection(context);
7243
7298
  const rawSections = [
7244
7299
  { name: "recovery_instruction", title: "Recovery Instruction", priority: 100, sourceRef: `run:${input.runId ?? "unknown"}`, content: completeRecoveryInstruction, truncationReason: completeRecoveryInstruction ? null : "mode_selection" },
@@ -7248,6 +7303,7 @@ ${resolvedDependencies.details.content}` : ""
7248
7303
  ...companyInitializationAuthority && !includeTask ? [companyInitializationAuthority] : [],
7249
7304
  ...taskAcceptanceContract ? [{ name: "task_acceptance_contract", title: "Task Acceptance Contract", priority: 100, ...taskAcceptanceContract }] : [],
7250
7305
  ...governedBusinessState ? [{ name: "governed_business_state", title: "Governed Business State", priority: 99, ...governedBusinessState }] : [],
7306
+ ...continuationPostconditionGap ? [{ name: "continuation_postcondition_gap", title: "Continuation Postcondition Gap", priority: 100, ...continuationPostconditionGap }] : [],
7251
7307
  { name: "continuation_summary", title: continuationSectionTitle(context), priority: 97, sourceRef: readString(asRecord(context.paperclipContinuationSummary).key) ?? `issue:${input.issueId ?? "unknown"}`, observedAt: readString(asRecord(context.paperclipContinuationSummary).updatedAt), originalContent: continuationSummary, content: mode === "cold" ? "" : continuationSummary, truncationReason: mode === "cold" ? "mode_selection" : null },
7252
7308
  ...resolvedDependencyContent ? [{
7253
7309
  name: "resolved_dependencies",
@@ -8580,7 +8636,7 @@ var CODEX_REMOTE_COMPACTION_RE = /remote\s+compact\s+task/i;
8580
8636
  var CODEX_USAGE_LIMIT_RE = /you(?:'|’)ve hit your usage limit for .+\.\s+switch to another model now,\s+or try again at\s+([^.!\n]+)(?:[.!]|\n|$)/i;
8581
8637
  var PI_PROVIDER_AUTH_RE = /(?:(?:\b401\b|\b403\b)[^\n]*(?:unauthorized|forbidden|auth(?:entication|orization)?|api[_\s-]?key)|(?:invalid|missing|expired|revoked)\s+(?:provider\s+)?api[_\s-]?key|provider\s+authentication\s+required)/i;
8582
8638
  var PI_PROVIDER_QUOTA_EXHAUSTED_RE = /(?:\binsufficient[_\s-]?user[_\s-]?quota\b|河狸币余额不足|\b402\b[^\n]*(?:余额不足|payment\s+required))/i;
8583
- var PI_PROVIDER_TRANSIENT_RE = /(?:\b(?:429|5\d{2})\b|rate[-\s]?limit(?:ed)?|too\s+many\s+requests|billing\s+admission\s+failed|service\s+unavailable|upstream[^\n]*(?:unavailable|failed|timeout)|connect(?:ion)?[^\n]*refused|temporar(?:y|ily)[^\n]*(?:unavailable|failed)|try\s+again\s+later)/i;
8639
+ var PI_PROVIDER_TRANSIENT_RE = /(?:Stream ended without finish_reason|\b(?:429|5\d{2})\b|rate[-\s]?limit(?:ed)?|too\s+many\s+requests|billing\s+admission\s+failed|service\s+unavailable|upstream[^\n]*(?:unavailable|failed|timeout)|connect(?:ion)?[^\n]*refused|temporar(?:y|ily)[^\n]*(?:unavailable|failed)|try\s+again\s+later)/i;
8584
8640
  var PI_PROVIDER_PROTOCOL_RE = /provider[^\n]*finish_reason[^\n]*unexpected_state/i;
8585
8641
  var PI_PROVIDER_RETRY_AFTER_SECONDS_RE = /retry[-\s]?after\s*[:=]?\s*(\d{1,6})\s*(?:seconds?|secs?|s)\b/i;
8586
8642
  var PI_TERMINAL_CLEANUP_PERMISSION_RE = /(?:\bkill\b[^\n]*\bEPERM\b|\bEPERM\b[^\n]*\bkill\b)/i;
@@ -9016,6 +9072,15 @@ function classifyPiProviderError(input, now = /* @__PURE__ */ new Date()) {
9016
9072
  ...retryNotBefore ? { retryNotBefore: retryNotBefore.toISOString() } : {}
9017
9073
  };
9018
9074
  }
9075
+ function classifyPiOutputFailure(input, options = {}) {
9076
+ const providerFailure = classifyPiProviderError(input, options.now);
9077
+ if (providerFailure) return providerFailure;
9078
+ if (!readString(options.invalidOutputError)) return null;
9079
+ return {
9080
+ errorCode: "pi_executor_invalid_output",
9081
+ errorFamily: "validation"
9082
+ };
9083
+ }
9019
9084
  function parseClaudeStreamJson(stdout) {
9020
9085
  let sessionId = null;
9021
9086
  let summary = "";
@@ -11312,7 +11377,7 @@ var source_acquisition_compatibility_default = {
11312
11377
  };
11313
11378
 
11314
11379
  // src/amaster-runtime-daemon.mjs
11315
- var CONNECTOR_VERSION = "0.1.1-beta.70";
11380
+ var CONNECTOR_VERSION = "0.1.1-beta.72";
11316
11381
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
11317
11382
  var SOURCE_ACQUISITION_CAPABILITY = source_acquisition_compatibility_default.profileVersion;
11318
11383
  var daemonRequire = createRequire(import.meta.url);
@@ -14601,8 +14666,9 @@ async function executeRunExitClosureTurn(config, inputState, options = {}) {
14601
14666
  executionConfig.runExitClosureBaseline,
14602
14667
  { commandId: state.commandId, runId: commandRunId(command) }
14603
14668
  ) : { status: "not_required" };
14604
- const closureArgs = executorKind === "pi" ? applyManagedPiToolAllowlist(args, {
14605
- toolAllowlist: Array.isArray(managedMcpClosureBaseline.toolAllowlist) ? managedMcpClosureBaseline.toolAllowlist : null
14669
+ const closureArgs = executorKind === "pi" ? applyManagedPiRunExitClosureArgs(args, {
14670
+ toolAllowlist: Array.isArray(managedMcpClosureBaseline.toolAllowlist) ? managedMcpClosureBaseline.toolAllowlist : null,
14671
+ profileRoot: readString(asRecord(executionConfig.runExitClosureBaseline).profileRoot)
14606
14672
  }) : args;
14607
14673
  const describeRequired = executorKind !== "pi" || managedMcpClosureBaseline.status !== "restored" || Array.isArray(managedMcpClosureBaseline.toolAllowlist);
14608
14674
  await ingestLog(config, command, "system", "info", "Starting bounded run-exit disposition closure turn", {
@@ -16522,7 +16588,8 @@ async function executeRunCommand(config, command) {
16522
16588
  completionOutputType: execution.completionOutputType,
16523
16589
  completionOutputHasFinalAssistantText: terminalTextRepair?.succeeded === true ? true : execution.completionOutputHasFinalAssistantText
16524
16590
  }) : null;
16525
- const piProviderFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError ? classifyPiProviderError(parsedForValidation) : null;
16591
+ const piOutputFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError ? classifyPiOutputFailure(parsedForValidation, { invalidOutputError: piInvalidOutputError }) : null;
16592
+ const piProviderFailure = piOutputFailure?.errorCode !== "pi_executor_invalid_output" ? piOutputFailure : null;
16526
16593
  const parsedErrorMessage = outputFloodError ?? argumentAmplificationError ?? memoryLimitError ?? piTurnLimitFailure?.message ?? piInvalidOutputError ?? nativeSessionRolloutError ?? nativeSessionRolloutCleanupError ?? parsedForValidation.errorMessage;
16527
16594
  const codexTransientFailure = executor.kind === "codex" && (execution.exitCode ?? 0) !== 0 ? classifyCodexTransientUpstreamError({
16528
16595
  stdout: execution.stdout,
@@ -16619,10 +16686,7 @@ async function executeRunCommand(config, command) {
16619
16686
  ...Array.isArray(execution.killedWorkspaceResidents) && execution.killedWorkspaceResidents.length > 0 ? {
16620
16687
  killedWorkspaceResidents: execution.killedWorkspaceResidents
16621
16688
  } : {},
16622
- ...piInvalidOutputError && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError && !piTurnLimitFailure && !piProviderFailure ? {
16623
- errorCode: "pi_executor_invalid_output",
16624
- errorFamily: "validation"
16625
- } : {},
16689
+ ...piOutputFailure?.errorCode === "pi_executor_invalid_output" && !piTurnLimitFailure ? piOutputFailure : {},
16626
16690
  ...piTurnLimitFailure ? {
16627
16691
  errorCode: piTurnLimitFailure.errorCode,
16628
16692
  errorFamily: piTurnLimitFailure.errorFamily,
@@ -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.70";
9
+ const CONNECTOR_VERSION = "0.1.1-beta.72";
10
10
 
11
11
  const CAPABILITIES = [
12
12
  "remote_registration",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.70",
3
+ "version": "0.1.1-beta.72",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",