@amaster.ai/employee-runtime-connector 0.1.1-beta.138 → 0.1.1-beta.139

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
@@ -29,7 +29,7 @@ configure a connector-local capability list. Historical `AMASTER_CAPABILITIES` a
29
29
  but are ignored and reported as deprecated. They cannot add, remove, or authorize a
30
30
  capability.
31
31
 
32
- The publish workflow verifies that npm records the publishing commit as the package `gitHead`, then updates the repository deployment pin. Remote deployment accepts that package only when its `gitHead` is an ancestor of the target source commit and the connector runtime build inputs are unchanged between them. Those inputs are the package path plus `packages/shared/src/source-acquisition-compatibility.json`, which is copied into the published package and bundled into the daemon. If another workspace source becomes a runtime build input, expand the provenance scope and tests before release. After restart, deployment also verifies the package CLI version inside the container. Do not update the deployment pin manually to bypass either provenance check.
32
+ The publish workflow verifies that npm records the publishing commit as the package `gitHead`, then updates the repository deployment pin. Remote deployment accepts that package only when its `gitHead` is an ancestor of the target source commit and the connector runtime build inputs are unchanged between them. Those inputs are the package path plus `packages/shared/src/source-acquisition-compatibility.json`, which is copied into the published package and bundled into the daemon. The manifest's failure-classification allowlists are therefore immutable build inputs too; Connector classification and any authorized Server parser must consume the same exact package truth. If another workspace source becomes a runtime build input, expand the provenance scope and tests before release. After restart, deployment also verifies the package CLI version inside the container. Do not update the deployment pin manually to bypass either provenance check.
33
33
 
34
34
  ## Package Contents
35
35
 
@@ -37,6 +37,8 @@ The publish workflow verifies that npm records the publishing commit as the pack
37
37
  - `dist/amaster-runtime-daemon.mjs`: standalone daemon bundle for connector registration, heartbeat, command execution, and result ingestion.
38
38
  - `dist/source-acquisition-compatibility.json`: versioned Source Acquisition compatibility manifest. Runner image builds must read this file from the exact installed connector package and fail before publishing when their Source Acquisition profile, adapter, or required package versions do not match it.
39
39
 
40
+ Source executor diagnostics remain inside the complete run result JSON for authorized Server/read-surface handling. They contain only manifest-allowlisted failure and reason codes plus bounded phase/retry/start-state fields; raw error messages, arbitrary error codes, paths, locators, stdout, and stderr are not part of that contract. This Connector-only slice does not add a Company Sources client projection.
41
+
40
42
  The source of truth lives under this package's `src/` directory. The package build copies the CLI and bundles the daemon modules into publishable output; do not edit generated files under `dist/`.
41
43
 
42
44
  Runtime code belongs in the container image. Persist only connector state, the result outbox, and workspaces under the configured state directory.
@@ -9,6 +9,7 @@ export const BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
9
9
  "artifact_template_catalog_v1",
10
10
  "final_model_context_attestation_v1",
11
11
  "runtime_actions_v2",
12
+ "continue_task_v1",
12
13
  "run_exit_live_path_closure_v1",
13
14
  "model_call",
14
15
  "model_call_output_contract_v1",
@@ -4073,6 +4073,102 @@ var source_acquisition_compatibility_default = {
4073
4073
  ],
4074
4074
  requiredPackages: {
4075
4075
  "@amaster.ai/pi-browser-use": "0.1.2-beta.61"
4076
+ },
4077
+ failureClassification: {
4078
+ phases: [
4079
+ "source_profile",
4080
+ "managed_mcp",
4081
+ "provider_config",
4082
+ "context_attestation",
4083
+ "prompt_compilation",
4084
+ "spawn",
4085
+ "execution",
4086
+ "unknown",
4087
+ "attestation",
4088
+ "model_contract"
4089
+ ],
4090
+ preActionPhases: [
4091
+ "source_profile",
4092
+ "managed_mcp",
4093
+ "provider_config",
4094
+ "context_attestation",
4095
+ "prompt_compilation"
4096
+ ],
4097
+ retryClasses: [
4098
+ "operator_repair",
4099
+ "transient_infra",
4100
+ "unknown"
4101
+ ],
4102
+ failureCodes: [
4103
+ "source_acquisition_executor_failed",
4104
+ "source_acquisition_executor_config_failed",
4105
+ "source_acquisition_executor_binary_missing",
4106
+ "source_acquisition_executor_permission_denied",
4107
+ "source_acquisition_executor_resource_exhausted",
4108
+ "source_acquisition_tool_attestation_rejected",
4109
+ "source_acquisition_model_missing",
4110
+ "source_acquisition_model_contract_failed",
4111
+ "source_acquisition_profile_invalid",
4112
+ "source_acquisition_browser_profile_invalid",
4113
+ "source_acquisition_browser_executable_unavailable",
4114
+ "source_acquisition_extension_profile_digest_invalid",
4115
+ "source_acquisition_extension_missing",
4116
+ "source_acquisition_extension_unsafe",
4117
+ "source_acquisition_extension_digest_mismatch",
4118
+ "source_acquisition_invocation_invalid",
4119
+ "source_acquisition_tool_allowlist_invalid",
4120
+ "source_acquisition_prompt_authority_invalid",
4121
+ "source_acquisition_direct_tools_unavailable",
4122
+ "source_acquisition_profile_canonicalization_failed",
4123
+ "source_acquisition_governed_profile_required"
4124
+ ],
4125
+ reasonCodes: [
4126
+ "source_profile_setup_failed",
4127
+ "managed_mcp_setup_failed",
4128
+ "provider_config_setup_failed",
4129
+ "context_attestation_failed",
4130
+ "prompt_compilation_failed",
4131
+ "executor_spawn_failed",
4132
+ "executor_failure_unknown",
4133
+ "execution_phase_unknown",
4134
+ "execution_receipt_missing",
4135
+ "source_read_receipt_inconsistent",
4136
+ "executor_binary_missing",
4137
+ "executor_permission_denied",
4138
+ "executor_resource_exhausted",
4139
+ "effective_tool_manifest_invalid",
4140
+ "effective_tool_surface_mismatch",
4141
+ "effective_tool_set_hash_mismatch",
4142
+ "managed_mcp_cache_mismatch",
4143
+ "managed_mcp_config_mismatch",
4144
+ "attestor_unknown",
4145
+ "model_missing",
4146
+ "model_output_contract_failed",
4147
+ "model_contract_unknown",
4148
+ "executor_exit_78_unknown"
4149
+ ],
4150
+ preActionDefaults: {
4151
+ source_profile: {
4152
+ reasonCode: "source_profile_setup_failed",
4153
+ retryClass: "operator_repair"
4154
+ },
4155
+ managed_mcp: {
4156
+ reasonCode: "managed_mcp_setup_failed",
4157
+ retryClass: "unknown"
4158
+ },
4159
+ provider_config: {
4160
+ reasonCode: "provider_config_setup_failed",
4161
+ retryClass: "unknown"
4162
+ },
4163
+ context_attestation: {
4164
+ reasonCode: "context_attestation_failed",
4165
+ retryClass: "unknown"
4166
+ },
4167
+ prompt_compilation: {
4168
+ reasonCode: "prompt_compilation_failed",
4169
+ retryClass: "unknown"
4170
+ }
4171
+ }
4076
4172
  }
4077
4173
  };
4078
4174
 
@@ -4662,6 +4758,7 @@ var AMASTER_RUNTIME_CONNECTOR_CAPABILITIES = [
4662
4758
  "run_terminate",
4663
4759
  "logs_cost_workspace_status",
4664
4760
  "runtime_actions_v2",
4761
+ "continue_task_v1",
4665
4762
  "run_exit_live_path_closure_v1",
4666
4763
  SOURCE_ACQUISITION_CAPABILITY,
4667
4764
  "headed_browser_auth",
@@ -7566,11 +7663,11 @@ var companyRecommendationModelOutputSchema = external_exports.object({
7566
7663
  message: "Generated recommendations require at least one delivery kind"
7567
7664
  });
7568
7665
  }
7569
- if (candidate.acceptanceCriteria.some(acceptanceCriterionRequiresWikiWrite) && !candidate.deliveryAllowedKinds.includes("external_effect")) {
7666
+ if (candidate.acceptanceCriteria.some(acceptanceCriterionRequiresWikiWrite)) {
7570
7667
  ctx.addIssue({
7571
7668
  code: external_exports.ZodIssueCode.custom,
7572
- path: ["candidates", index, "deliveryAllowedKinds"],
7573
- message: "Wiki-write acceptance criteria require external_effect delivery"
7669
+ path: ["candidates", index, "acceptanceCriteria"],
7670
+ message: "Cold-start recommendations must deliver an inspectable knowledge package; Wiki publication happens only after Acceptance"
7574
7671
  });
7575
7672
  }
7576
7673
  });
@@ -7603,11 +7700,11 @@ var companyRecommendationReviseInputSchema = external_exports.object({
7603
7700
  uniqueStrings(value.selectedCandidateRefs, ctx, ["selectedCandidateRefs"]);
7604
7701
  const allowed = new Set(candidateRefs);
7605
7702
  value.candidates.forEach((candidate, index) => {
7606
- if (candidate.acceptanceCriteria.some(acceptanceCriterionRequiresWikiWrite) && !candidate.deliveryAllowedKinds.includes("external_effect")) {
7703
+ if (candidate.acceptanceCriteria.some(acceptanceCriterionRequiresWikiWrite)) {
7607
7704
  ctx.addIssue({
7608
7705
  code: external_exports.ZodIssueCode.custom,
7609
- path: ["candidates", index, "deliveryAllowedKinds"],
7610
- message: "Wiki-write acceptance criteria require external_effect delivery"
7706
+ path: ["candidates", index, "acceptanceCriteria"],
7707
+ message: "Cold-start recommendations must deliver an inspectable knowledge package; Wiki publication happens only after Acceptance"
7611
7708
  });
7612
7709
  }
7613
7710
  });
@@ -8089,6 +8186,7 @@ var ISSUE_THREAD_INTERACTION_CONTINUATION_POLICIES = [
8089
8186
  "wake_assignee",
8090
8187
  "wake_assignee_on_accept"
8091
8188
  ];
8189
+ var WIKI_PUBLICATION_RECONCILIATION_PURPOSE_CODE = "reconcile_wiki_publication_result";
8092
8190
  var ISSUE_WATCHDOG_DISCOVERY_KINDS = ["product_bug", "platform_bug"];
8093
8191
  var ISSUE_SURFACE_VISIBILITIES = ["default", "plugin_operation"];
8094
8192
  var ISSUE_RECOVERY_ACTION_KINDS = [
@@ -9350,7 +9448,7 @@ var RESOLVE_ISSUE_RECOVERY_ACTION_OUTCOMES = [
9350
9448
  "cancelled"
9351
9449
  ];
9352
9450
  var resolveIssueRecoveryActionSchema = external_exports.object({
9353
- actionId: external_exports.string().uuid().optional(),
9451
+ actionId: external_exports.string().uuid(),
9354
9452
  outcome: external_exports.enum(RESOLVE_ISSUE_RECOVERY_ACTION_OUTCOMES),
9355
9453
  sourceIssueStatus: external_exports.enum(["todo", "done", "in_review", "blocked"]),
9356
9454
  resolutionNote: multilineTextSchema.optional().nullable()
@@ -9386,6 +9484,10 @@ var resolveIssueRecoveryActionSchema = external_exports.object({
9386
9484
  return;
9387
9485
  }
9388
9486
  });
9487
+ var scheduleIssueRecoveryMonitorSchema = external_exports.object({
9488
+ actionId: external_exports.string().uuid(),
9489
+ nextCheckAt: external_exports.string().datetime()
9490
+ }).strict();
9389
9491
  var issueRequestDepthInputSchema = external_exports.number().int().nonnegative().transform((value) => clampIssueRequestDepth(value));
9390
9492
  var estimatedLaborHoursSchema = external_exports.number().finite().nonnegative().max(1e6);
9391
9493
  var issueDateSchema = external_exports.string().refine((value) => {
@@ -9530,6 +9632,43 @@ var updateIssueSchema = createIssueBaseSchema.omit({
9530
9632
  var externalWaitSnoozeSchema = external_exports.object({
9531
9633
  snoozeMinutes: external_exports.number().int().min(1).max(60 * 24 * 14)
9532
9634
  }).strict();
9635
+ var wikiPublicationPathSchema = external_exports.string().trim().min(1).max(500).superRefine((path, ctx) => {
9636
+ if (path.startsWith("/") || path.includes("\\") || !path.startsWith("wiki/") || !path.endsWith(".md") || path.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
9637
+ ctx.addIssue({
9638
+ code: external_exports.ZodIssueCode.custom,
9639
+ message: "Wiki publication path must be a canonical wiki/... markdown path without dot segments"
9640
+ });
9641
+ }
9642
+ });
9643
+ var wikiIssueDocumentPublicationSelectionSchema = external_exports.object({
9644
+ documentKey: external_exports.lazy(() => issueDocumentKeySchema),
9645
+ expectedRevisionId: external_exports.string().uuid(),
9646
+ destination: external_exports.object({
9647
+ wikiId: external_exports.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
9648
+ spaceSlug: external_exports.string().trim().min(1).max(64).regex(/^[a-z0-9][a-z0-9._-]*$/),
9649
+ path: wikiPublicationPathSchema
9650
+ }).strict(),
9651
+ expectedPageHash: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/).nullable().optional()
9652
+ }).strict();
9653
+ var bindIssueExternalWaitWikiPublicationSchema = external_exports.object({
9654
+ selection: wikiIssueDocumentPublicationSelectionSchema,
9655
+ expectedExecutionEpoch: external_exports.number().int().positive(),
9656
+ expectedWaitId: external_exports.string().uuid()
9657
+ }).strict();
9658
+ var publishIssueDocumentToWikiSchema = external_exports.object({
9659
+ expectedExecutionEpoch: external_exports.number().int().positive(),
9660
+ expectedWaitId: external_exports.string().uuid()
9661
+ }).strict();
9662
+ var reconcileWikiIssueDocumentPublicationSchema = external_exports.discriminatedUnion("action", [
9663
+ external_exports.object({
9664
+ action: external_exports.literal("link_to_matching_wait"),
9665
+ expectedExecutionEpoch: external_exports.number().int().positive(),
9666
+ expectedWaitId: external_exports.string().uuid()
9667
+ }).strict(),
9668
+ external_exports.object({
9669
+ action: external_exports.literal("acknowledge_unlinked")
9670
+ }).strict()
9671
+ ]);
9533
9672
  var upsertIssueExternalWaitSchema = external_exports.object({
9534
9673
  ownerType: external_exports.enum(["external", "user"]),
9535
9674
  actionKind: external_exports.enum(["approval", "input", "dependency", "other"]),
@@ -10396,13 +10535,28 @@ function validateUniqueInteractionRequirementRefs(value, ctx) {
10396
10535
  });
10397
10536
  }
10398
10537
  }
10538
+ function validateUnreservedInteractionPurpose(value, ctx) {
10539
+ if (value.purposeCode === WIKI_PUBLICATION_RECONCILIATION_PURPOSE_CODE) {
10540
+ ctx.addIssue({
10541
+ code: external_exports.ZodIssueCode.custom,
10542
+ message: "purposeCode is reserved for the dedicated Wiki publication producer",
10543
+ path: ["purposeCode"]
10544
+ });
10545
+ }
10546
+ }
10399
10547
  var issueThreadInteractionProvenanceInputSchema = external_exports.object(
10400
10548
  issueThreadInteractionProvenanceInputShape
10401
- ).strict().superRefine(validateUniqueInteractionRequirementRefs);
10549
+ ).strict().superRefine((value, ctx) => {
10550
+ validateUniqueInteractionRequirementRefs(value, ctx);
10551
+ validateUnreservedInteractionPurpose(value, ctx);
10552
+ });
10402
10553
  var productionIssueThreadInteractionProvenanceInputSchema = external_exports.object({
10403
10554
  ...issueThreadInteractionProvenanceInputShape,
10404
10555
  origin: external_exports.literal("production")
10405
- }).strict().superRefine(validateUniqueInteractionRequirementRefs);
10556
+ }).strict().superRefine((value, ctx) => {
10557
+ validateUniqueInteractionRequirementRefs(value, ctx);
10558
+ validateUnreservedInteractionPurpose(value, ctx);
10559
+ });
10406
10560
  var createIssueThreadInteractionSchema = external_exports.discriminatedUnion("kind", [
10407
10561
  external_exports.object({
10408
10562
  kind: external_exports.literal("suggest_tasks"),
@@ -15802,8 +15956,8 @@ function createPiToolArgumentAmplificationTracker(options = {}) {
15802
15956
  snapshot() {
15803
15957
  const toolCalls = [...calls.values()].map(publicMetrics);
15804
15958
  const nearMisses = toolCalls.flatMap((metrics) => {
15805
- const classification = nearMissClassification(metrics, config);
15806
- return classification ? [{ ...metrics, ...classification }] : [];
15959
+ const classification2 = nearMissClassification(metrics, config);
15960
+ return classification2 ? [{ ...metrics, ...classification2 }] : [];
15807
15961
  });
15808
15962
  return {
15809
15963
  mode,
@@ -18249,6 +18403,114 @@ import { createHash as createHash2 } from "node:crypto";
18249
18403
  import { randomBytes } from "node:crypto";
18250
18404
  import { chmodSync as chmodSync3, readFileSync as readFileSync3, renameSync as renameSync2, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
18251
18405
  import { dirname as dirname3, join as join4 } from "node:path";
18406
+
18407
+ // src/amaster-runtime-daemon/source-acquisition-execution-failure.mjs
18408
+ var classification = source_acquisition_compatibility_default.failureClassification;
18409
+ var PRE_ACTION_PHASES = new Set(classification.preActionPhases);
18410
+ var FAILURE_CODES = new Set(classification.failureCodes);
18411
+ var REASON_CODES = new Set(classification.reasonCodes);
18412
+ var RETRY_CLASSES = new Set(classification.retryClasses);
18413
+ var GENERIC_FAILURE_CODE = "source_acquisition_executor_failed";
18414
+ function nullableBoolean(value) {
18415
+ return value === true || value === false || value === null;
18416
+ }
18417
+ function exactAllowlistedFailureCode(error) {
18418
+ const code = typeof error?.code === "string" ? error.code.trim() : "";
18419
+ if (FAILURE_CODES.has(code)) return code;
18420
+ const message = error instanceof Error ? error.message.trim() : "";
18421
+ return FAILURE_CODES.has(message) ? message : GENERIC_FAILURE_CODE;
18422
+ }
18423
+ function validateSourceAcquisitionFailureEnvelope(failure) {
18424
+ const {
18425
+ failureCode: failureCode2,
18426
+ reasonCode,
18427
+ phase,
18428
+ retryClass,
18429
+ autoRetryEligible,
18430
+ modelInvocationStarted,
18431
+ sourceReadStarted
18432
+ } = failure ?? {};
18433
+ if (!FAILURE_CODES.has(failureCode2) || !classification.phases.includes(phase) || !REASON_CODES.has(reasonCode) || !RETRY_CLASSES.has(retryClass) || typeof autoRetryEligible !== "boolean" || !nullableBoolean(modelInvocationStarted) || !nullableBoolean(sourceReadStarted)) {
18434
+ throw new Error("source_acquisition_failure_classification_invalid");
18435
+ }
18436
+ return Object.freeze({
18437
+ failureCode: failureCode2,
18438
+ reasonCode,
18439
+ phase,
18440
+ retryClass,
18441
+ autoRetryEligible,
18442
+ modelInvocationStarted,
18443
+ sourceReadStarted
18444
+ });
18445
+ }
18446
+ function failureEnvelope({ failureCode: failureCode2, phase, reasonCode, retryClass }) {
18447
+ return validateSourceAcquisitionFailureEnvelope({
18448
+ failureCode: failureCode2,
18449
+ reasonCode,
18450
+ phase,
18451
+ retryClass,
18452
+ autoRetryEligible: false,
18453
+ modelInvocationStarted: null,
18454
+ sourceReadStarted: null
18455
+ });
18456
+ }
18457
+ function classifySourceAcquisitionStageFailure(phase, error) {
18458
+ if (!PRE_ACTION_PHASES.has(phase)) {
18459
+ throw new Error("source_acquisition_failure_phase_invalid");
18460
+ }
18461
+ const defaults = classification.preActionDefaults[phase];
18462
+ return failureEnvelope({
18463
+ failureCode: exactAllowlistedFailureCode(error),
18464
+ phase,
18465
+ reasonCode: defaults.reasonCode,
18466
+ retryClass: defaults.retryClass
18467
+ });
18468
+ }
18469
+ var SourceAcquisitionStageFailure = class extends Error {
18470
+ constructor(failure, cause) {
18471
+ super("source_acquisition_stage_failed", { cause });
18472
+ this.name = "SourceAcquisitionStageFailure";
18473
+ Object.defineProperty(this, "failure", {
18474
+ configurable: false,
18475
+ enumerable: false,
18476
+ value: failure,
18477
+ writable: false
18478
+ });
18479
+ }
18480
+ };
18481
+ function stageFailure(phase, error) {
18482
+ if (sourceAcquisitionFailureFromError(error)) return error;
18483
+ return new SourceAcquisitionStageFailure(
18484
+ classifySourceAcquisitionStageFailure(phase, error),
18485
+ error
18486
+ );
18487
+ }
18488
+ function runSourceAcquisitionStage(phase, operation) {
18489
+ if (!PRE_ACTION_PHASES.has(phase)) {
18490
+ throw new Error("source_acquisition_failure_phase_invalid");
18491
+ }
18492
+ try {
18493
+ const result3 = operation();
18494
+ return result3 && typeof result3.then === "function" ? Promise.resolve(result3).catch((error) => {
18495
+ throw stageFailure(phase, error);
18496
+ }) : result3;
18497
+ } catch (error) {
18498
+ throw stageFailure(phase, error);
18499
+ }
18500
+ }
18501
+ function sourceAcquisitionFailureFromError(error) {
18502
+ return error instanceof SourceAcquisitionStageFailure ? error.failure : null;
18503
+ }
18504
+ function sourceAcquisitionUnknownFailure() {
18505
+ return failureEnvelope({
18506
+ failureCode: GENERIC_FAILURE_CODE,
18507
+ phase: "unknown",
18508
+ reasonCode: "execution_phase_unknown",
18509
+ retryClass: "unknown"
18510
+ });
18511
+ }
18512
+
18513
+ // src/amaster-runtime-daemon/source-acquisition-execution-receipt.mjs
18252
18514
  var SOURCE_ACQUISITION_EXECUTION_RECEIPT_SCHEMA_VERSION = "mirrorx.source-acquisition-execution-receipt.v1";
18253
18515
  var ATTESTOR_STATUSES = /* @__PURE__ */ new Set(["pending", "attested", "rejected", "unknown"]);
18254
18516
  var MODEL_CONTRACT_STATUSES = /* @__PURE__ */ new Set(["pending", "validated", "rejected", "unknown"]);
@@ -18374,7 +18636,7 @@ function updateSourceAcquisitionExecutionReceipt(path, identity2, patch) {
18374
18636
  }
18375
18637
  function failureSummary(receipt, input, overrides) {
18376
18638
  const sourceReadStarted = input.readerSideEffectObserved === true && receipt?.sourceReadStarted !== true ? null : receipt?.sourceReadStarted ?? null;
18377
- return {
18639
+ return validateSourceAcquisitionFailureEnvelope({
18378
18640
  failureCode: overrides.failureCode ?? "source_acquisition_executor_config_failed",
18379
18641
  reasonCode: overrides.reasonCode,
18380
18642
  phase: overrides.phase,
@@ -18382,7 +18644,7 @@ function failureSummary(receipt, input, overrides) {
18382
18644
  autoRetryEligible: overrides.retryClass === "transient_infra" && receipt?.modelInvocationStarted === false && sourceReadStarted === false,
18383
18645
  modelInvocationStarted: receipt?.modelInvocationStarted ?? null,
18384
18646
  sourceReadStarted
18385
- };
18647
+ });
18386
18648
  }
18387
18649
  function classifySourceAcquisitionExecutionFailure(input) {
18388
18650
  const receipt = normalizeReceipt(input.receipt);
@@ -18422,7 +18684,7 @@ function classifySourceAcquisitionExecutionFailure(input) {
18422
18684
  }
18423
18685
  return failureSummary(receipt, input, {
18424
18686
  reasonCode: Number(input.exitCode) === 78 ? "executor_exit_78_unknown" : "executor_failure_unknown",
18425
- phase: "unknown",
18687
+ phase: "execution",
18426
18688
  retryClass: "unknown"
18427
18689
  });
18428
18690
  }
@@ -23169,7 +23431,8 @@ Runtime Action continuation is unavailable: executor kind does not support a gov
23169
23431
  }
23170
23432
  function runtimeAuthorizationText(context, mode, {
23171
23433
  replayAlreadyInTask = false,
23172
- suppressOrdinaryCompletionContract = false
23434
+ suppressOrdinaryCompletionContract = false,
23435
+ continueTaskEnabled = false
23173
23436
  } = {}) {
23174
23437
  const envelope = asRecord(context.authorizationEnvelope);
23175
23438
  const allowed = new Set(
@@ -23194,11 +23457,11 @@ function runtimeAuthorizationText(context, mode, {
23194
23457
  const delegatedAggregationEvidence = asRecord(context.paperclipDelegatedAggregationEvidence);
23195
23458
  const delegatedDelivery = readString(delegatedAggregationEvidence.schemaVersion) === "delegated-aggregation-evidence-v1" && readString(delegatedAggregationEvidence.finalAggregationIssueId) && readString(delegatedAggregationEvidence.manifestId) && readString(delegatedAggregationEvidence.packageReviewInteractionId);
23196
23459
  const manifestRefreshOnly = legacyManifestRefreshOnly(context);
23197
- 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." : "";
23460
+ 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" ? continueTaskEnabled ? "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." : "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." : continueTaskEnabled ? "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. Update the same document with each piece of verified evidence." : "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." : "";
23198
23461
  const completionContract = !suppressOrdinaryCompletionContract && completionRole && completionDeliverable ? [
23199
23462
  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.",
23200
23463
  firstDocumentCheckpoint,
23201
- "If work remains in an ordinary productive run, call update_parent with status: in_progress and a concrete next action so bounded continuation recovery can preserve a live path. Status: todo does not queue a normal continuation from an ordinary productive run. Only a server-issued successful-run handoff recovery may use status: todo, and only according to its exact Recovery Instruction. Otherwise use a supported terminal or waiting disposition."
23464
+ continueTaskEnabled ? "If work remains in an ordinary productive run, call continue_task with a concrete nextAction and stable idempotencyKey, then end the run. For a future time recheck use schedule_monitor; for an external person or system action use upsert_external_wait. These are mutually exclusive final live paths. Do not call update_parent with status: in_progress." : "If work remains in an ordinary productive run, call update_parent with status: in_progress and a concrete next action so bounded continuation recovery can preserve a live path. Status: todo does not queue a normal continuation from an ordinary productive run. Only a server-issued successful-run handoff recovery may use status: todo, and only according to its exact Recovery Instruction. Otherwise use a supported terminal or waiting disposition."
23202
23465
  ].filter(Boolean).join(" ") : "";
23203
23466
  const businessOutcomeOwnershipContract = businessOutcome.mode === "required" ? evidenceAutoAcceptance ? [
23204
23467
  "Evidence-auto Business Outcome closure is owned by the Server terminal reconciler.",
@@ -23797,6 +24060,7 @@ function compileCommandPromptWithManifest(input, options = {}) {
23797
24060
  throw new RangeError(`Prompt budget must be an integer of at least ${MIN_PROMPT_BUDGET_CHARS} characters`);
23798
24061
  }
23799
24062
  const context = asRecord(input.context);
24063
+ const continueTaskEnabled = Array.isArray(input.negotiatedCapabilities) && input.negotiatedCapabilities.includes("continue_task_v1");
23800
24064
  const mode = promptContextMode(input);
23801
24065
  const sourceAcquisitionTask = sourceAcquisitionTaskSection(input);
23802
24066
  if (sourceAcquisitionTask) {
@@ -23915,7 +24179,8 @@ ${resolvedDependencies.details.content}` : resolvedDependencies.details.content
23915
24179
  { name: "runtime_rules", title: "", priority: 100, sourceRef: `command:${input.commandId}`, content: fixedRules(input, !hasTask) },
23916
24180
  { name: "runtime_authorization", title: "Runtime Action Contract", priority: 98, sourceRef: `run:${input.runId ?? "unknown"}`, content: runtimeAuthorizationText(context, mode, {
23917
24181
  replayAlreadyInTask: includeTask && taskText.includes(EXACT_ORGANIZATION_INTENT_REPLAY_MARKER),
23918
- suppressOrdinaryCompletionContract
24182
+ suppressOrdinaryCompletionContract,
24183
+ continueTaskEnabled
23919
24184
  }) },
23920
24185
  { name: "runtime_decomposition_requirement", title: "Required Task Decomposition", priority: 98, sourceRef: `issue:${input.issueId ?? "unknown"}`, content: runtimeDecompositionRequirementText(context) },
23921
24186
  ...taskContextAuthority ? [{ name: "task_context_authority", title: "Task Context Authority", priority: 98, ...taskContextAuthority }] : [],
@@ -23947,13 +24212,15 @@ ${resolvedDependencies.details.content}` : resolvedDependencies.details.content
23947
24212
  section.scope ??= contextScope;
23948
24213
  section.freshness ??= snapshotFreshness;
23949
24214
  }
23950
- return compilePreparedSections({
24215
+ const compiled = compilePreparedSections({
23951
24216
  rawSections,
23952
24217
  mode,
23953
24218
  maxChars,
23954
24219
  governedReadProvenance: governedReads.provenance,
23955
24220
  resolvedDependencyTupleCount: resolvedDependencies.required.tupleCount
23956
24221
  });
24222
+ compiled.manifest.continuationPromptContract = continueTaskEnabled ? { capability: "continue_task_v1", mode: "continue_task" } : { capability: null, mode: "legacy_server_owned_in_progress" };
24223
+ return compiled;
23957
24224
  }
23958
24225
 
23959
24226
  // src/amaster-runtime-daemon/agent-instruction-delivery.mjs
@@ -24399,6 +24666,7 @@ var BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
24399
24666
  "artifact_template_catalog_v1",
24400
24667
  "final_model_context_attestation_v1",
24401
24668
  "runtime_actions_v2",
24669
+ "continue_task_v1",
24402
24670
  "run_exit_live_path_closure_v1",
24403
24671
  "model_call",
24404
24672
  "model_call_output_contract_v1",
@@ -28953,6 +29221,7 @@ function createBrowserSessionBroker({
28953
29221
  };
28954
29222
  },
28955
29223
  status: () => ({
29224
+ activeAgentReadLeases: readers.size,
28956
29225
  activeHumanLeases: [...active.values()].map((entry) => ({
28957
29226
  companyId: entry.owner.companyId,
28958
29227
  bindingId: entry.owner.bindingId,
@@ -29093,7 +29362,7 @@ function createSourceCompletionStopPolicy({
29093
29362
  }
29094
29363
 
29095
29364
  // src/amaster-runtime-daemon.mjs
29096
- var CONNECTOR_VERSION = "0.1.1-beta.138";
29365
+ var CONNECTOR_VERSION = "0.1.1-beta.139";
29097
29366
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
29098
29367
  var SOURCE_ACQUISITION_CAPABILITY2 = source_acquisition_compatibility_default.profileVersion;
29099
29368
  var daemonRequire = createRequire(import.meta.url);
@@ -30740,6 +31009,7 @@ function buildCommandPrompt(command, workspace, materializedAttachments = [], op
30740
31009
  sourceWorkspacePath: workspaceContext.sourceWorkspacePath,
30741
31010
  wakeReason: readString(context.wakeReason),
30742
31011
  hasGovernedMcp,
31012
+ negotiatedCapabilities: options.negotiatedCapabilities,
30743
31013
  executorKind: options.executorKind,
30744
31014
  managedMcpToolMode: options.managedMcpToolMode,
30745
31015
  managedMcpToolCatalog: options.managedMcpToolCatalog,
@@ -34192,9 +34462,10 @@ async function executeRunCommand(config, command) {
34192
34462
  });
34193
34463
  }
34194
34464
  await ingestWorkspaceStatus(config, command, cwd);
34195
- const sourceAcquisition = await sourceAcquisitionRuntimeProfile(config, command);
34465
+ const sourceAcquisitionIntent = Object.keys(commandSourceAcquisitionProfile(command)).length > 0;
34466
+ let sourceAcquisition = null;
34196
34467
  const nativeSessionRequest = asRecord(asRecord(command.payload).nativeSession);
34197
- const invocation = buildExecutorInvocation(executor, command, workspace);
34468
+ let invocation = null;
34198
34469
  let executorEnv = buildExecutorEnv(config, command, workspace);
34199
34470
  let managedMcpProfile = null;
34200
34471
  let managedMcpCleanup = null;
@@ -34208,16 +34479,22 @@ async function executeRunCommand(config, command) {
34208
34479
  let stopActiveRunHeartbeats = () => {
34209
34480
  };
34210
34481
  let completionOwnsManagedMcpProfile = false;
34211
- const sourceProfile = serializeSourceAcquisitionProfile(sourceAcquisition?.profile ?? null);
34482
+ let sourceProfile = null;
34212
34483
  const trustedPiRuntimeAssertion = commandTrustedPiRuntimeAssertion(command);
34213
- assertSourceAcquisitionRuntimeAuthority({
34214
- profile: sourceAcquisition,
34215
- executorKind: executor.kind,
34216
- governedMcp
34217
- });
34484
+ const runSourceStage = (phase, operation) => sourceAcquisitionIntent ? runSourceAcquisitionStage(phase, operation) : operation();
34218
34485
  try {
34486
+ await runSourceStage("source_profile", async () => {
34487
+ sourceAcquisition = await sourceAcquisitionRuntimeProfile(config, command);
34488
+ sourceProfile = serializeSourceAcquisitionProfile(sourceAcquisition?.profile ?? null);
34489
+ assertSourceAcquisitionRuntimeAuthority({
34490
+ profile: sourceAcquisition,
34491
+ executorKind: executor.kind,
34492
+ governedMcp
34493
+ });
34494
+ invocation = buildExecutorInvocation(executor, command, workspace);
34495
+ });
34219
34496
  if (executor.kind === "codex" && Object.keys(governedMcp).length > 0) {
34220
- managedMcpProfile = prepareManagedCodexMcpProfile({
34497
+ managedMcpProfile = await runSourceStage("managed_mcp", () => prepareManagedCodexMcpProfile({
34221
34498
  commandId: command.commandId,
34222
34499
  runId: commandRunId(command),
34223
34500
  connectorVersion: CONNECTOR_VERSION,
@@ -34230,7 +34507,7 @@ async function executeRunCommand(config, command) {
34230
34507
  baseEnv: executorEnv,
34231
34508
  commandEnv: commandExecutorEnv(command),
34232
34509
  extraArgs: splitExtraArgs(process.env.AMASTER_CODEX_EXTRA_ARGS)
34233
- });
34510
+ }));
34234
34511
  cleanupManagedMcpProfile = cleanupManagedCodexMcpProfile;
34235
34512
  }
34236
34513
  if (executor.kind === "pi") {
@@ -34249,7 +34526,7 @@ async function executeRunCommand(config, command) {
34249
34526
  if (Object.keys(governedMcp).length > 0) {
34250
34527
  const preparePiMcpProfile = desktopDelegatedRunnerEnabled(config) ? prepareDelegatedPiMcpProfile : prepareManagedPiMcpProfile;
34251
34528
  const piProfileCommandEnv = commandExecutorEnv(command);
34252
- managedMcpProfile = preparePiMcpProfile({
34529
+ managedMcpProfile = await runSourceStage("managed_mcp", () => preparePiMcpProfile({
34253
34530
  commandId: command.commandId,
34254
34531
  runId: commandRunId(command),
34255
34532
  connectorVersion: CONNECTOR_VERSION,
@@ -34266,20 +34543,23 @@ async function executeRunCommand(config, command) {
34266
34543
  sourceAcquisition,
34267
34544
  skillProfiles: readStringArray(asRecord(command.payload).skillProfiles),
34268
34545
  ...config.piExecutorUid > 0 && !desktopDelegatedRunnerEnabled(config) ? {
34269
- prepareExecutorAccess: ({ profileRoot, workspaceRoot }) => preparePiExecutorAccess({
34270
- uid: config.piExecutorUid,
34271
- gid: config.piExecutorGid,
34272
- effectiveUid: typeof process.getuid === "function" ? process.getuid() : null,
34273
- profileRoot,
34274
- workspaceRoot,
34275
- allowedRoot: config.runtimeWorkspacesRoot
34276
- })
34546
+ prepareExecutorAccess: ({ profileRoot, workspaceRoot }) => runSourceStage(
34547
+ "provider_config",
34548
+ () => preparePiExecutorAccess({
34549
+ uid: config.piExecutorUid,
34550
+ gid: config.piExecutorGid,
34551
+ effectiveUid: typeof process.getuid === "function" ? process.getuid() : null,
34552
+ profileRoot,
34553
+ workspaceRoot,
34554
+ allowedRoot: config.runtimeWorkspacesRoot
34555
+ })
34556
+ )
34277
34557
  } : {}
34278
- });
34279
- managedMcpProfile = attachPiOutputReserve(
34558
+ }));
34559
+ managedMcpProfile = await runSourceStage("managed_mcp", () => attachPiOutputReserve(
34280
34560
  managedMcpProfile,
34281
34561
  Number(contextContract.envelope.outputReserveTokens)
34282
- );
34562
+ ));
34283
34563
  cleanupManagedMcpProfile = desktopDelegatedRunnerEnabled(config) ? cleanupDelegatedPiMcpProfile : cleanupManagedPiMcpProfile;
34284
34564
  for (const protectedValue of providerProtectedValues) {
34285
34565
  if (!managedMcpProfile.protectedValues.includes(protectedValue)) {
@@ -34348,12 +34628,12 @@ async function executeRunCommand(config, command) {
34348
34628
  agentDir = null;
34349
34629
  }
34350
34630
  try {
34351
- await syncPiExecutorProviderConfig(
34631
+ await runSourceStage("provider_config", () => syncPiExecutorProviderConfig(
34352
34632
  config,
34353
34633
  command,
34354
34634
  agentDir,
34355
34635
  piResolvedProviderConfig
34356
- );
34636
+ ));
34357
34637
  } catch (error2) {
34358
34638
  if (managedMcpProfile && cleanupManagedMcpProfile) {
34359
34639
  cleanupManagedMcpProfile(managedMcpProfile, {
@@ -34366,54 +34646,64 @@ async function executeRunCommand(config, command) {
34366
34646
  }
34367
34647
  }
34368
34648
  if (executor.kind === "pi" && config.piExecutorUid > 0 && !piExecutorIdentity) {
34369
- piExecutorIdentity = preparePiExecutorAccess({
34649
+ piExecutorIdentity = await runSourceStage("provider_config", () => preparePiExecutorAccess({
34370
34650
  uid: config.piExecutorUid,
34371
34651
  gid: config.piExecutorGid,
34372
34652
  effectiveUid: typeof process.getuid === "function" ? process.getuid() : null,
34373
34653
  profileRoot: managedMcpProfile?.profileRoot ?? workspace.executorHome,
34374
34654
  workspaceRoot: cwd,
34375
34655
  allowedRoot: config.runtimeWorkspacesRoot
34376
- });
34656
+ }));
34377
34657
  }
34378
34658
  const governedContext = Object.keys(governedMcp).length > 0;
34379
34659
  const governedToolCatalog = asRecord(governedMcp.toolCatalog);
34380
34660
  const strictContextGovernance = governedContext && Object.keys(governedToolCatalog).length > 0;
34381
- const effectiveToolSchemaAttestation = strictContextGovernance ? requireEffectiveToolSchemaAttestation(
34382
- contextContract,
34383
- executor.kind,
34384
- governedMcp,
34385
- managedMcpProfile
34386
- ) : {
34387
- schemaVersion: "mirrorx.effective-tool-schema-attestation.v1",
34388
- executorKind: executor.kind,
34389
- status: governedContext ? "legacy_managed_command_without_tool_catalog" : "not_applicable_unmanaged_command"
34390
- };
34391
- let modelContextBudget;
34392
- if (strictContextGovernance) {
34393
- if (!managedMcpProfile || !piAgentDirForContextBudget) {
34394
- throw new Error("model_context_attestation_unavailable: managed Pi profile or Pi config home is missing");
34661
+ const { effectiveToolSchemaAttestation, modelContextBudget } = await runSourceStage(
34662
+ "context_attestation",
34663
+ () => {
34664
+ const attestation = strictContextGovernance ? requireEffectiveToolSchemaAttestation(
34665
+ contextContract,
34666
+ executor.kind,
34667
+ governedMcp,
34668
+ managedMcpProfile
34669
+ ) : {
34670
+ schemaVersion: "mirrorx.effective-tool-schema-attestation.v1",
34671
+ executorKind: executor.kind,
34672
+ status: governedContext ? "legacy_managed_command_without_tool_catalog" : "not_applicable_unmanaged_command"
34673
+ };
34674
+ if (!strictContextGovernance) {
34675
+ return {
34676
+ effectiveToolSchemaAttestation: attestation,
34677
+ modelContextBudget: {
34678
+ schemaVersion: "mirrorx.model-context-budget.v1",
34679
+ status: "legacy_unmanaged_bounded",
34680
+ outputReserveTokens: Number(contextContract.envelope.outputReserveTokens),
34681
+ dynamicPromptMaxChars: 32768
34682
+ }
34683
+ };
34684
+ }
34685
+ if (!managedMcpProfile || !piAgentDirForContextBudget) {
34686
+ throw new Error("model_context_attestation_unavailable: managed Pi profile or Pi config home is missing");
34687
+ }
34688
+ const modelContext = resolvePiRunModelContext(
34689
+ piAgentDirForContextBudget,
34690
+ readString(process.env.AMASTER_PI_PROVIDER),
34691
+ readString(process.env.AMASTER_PI_MODEL)
34692
+ );
34693
+ return {
34694
+ effectiveToolSchemaAttestation: attestation,
34695
+ modelContextBudget: resolvePiModelContextBudget({
34696
+ modelContext,
34697
+ outputReserveTokens: Number(contextContract.envelope.outputReserveTokens),
34698
+ finalAgentInstructionFiles,
34699
+ managedMcpProfile
34700
+ })
34701
+ };
34395
34702
  }
34396
- const modelContext = resolvePiRunModelContext(
34397
- piAgentDirForContextBudget,
34398
- readString(process.env.AMASTER_PI_PROVIDER),
34399
- readString(process.env.AMASTER_PI_MODEL)
34400
- );
34401
- modelContextBudget = resolvePiModelContextBudget({
34402
- modelContext,
34403
- outputReserveTokens: Number(contextContract.envelope.outputReserveTokens),
34404
- finalAgentInstructionFiles,
34405
- managedMcpProfile
34406
- });
34407
- } else {
34408
- modelContextBudget = {
34409
- schemaVersion: "mirrorx.model-context-budget.v1",
34410
- status: "legacy_unmanaged_bounded",
34411
- outputReserveTokens: Number(contextContract.envelope.outputReserveTokens),
34412
- dynamicPromptMaxChars: 32768
34413
- };
34414
- }
34415
- const promptCompilation = buildCommandPrompt(command, workspace, materializedAttachments, {
34703
+ );
34704
+ const promptCompilation = await runSourceStage("prompt_compilation", () => buildCommandPrompt(command, workspace, materializedAttachments, {
34416
34705
  runnerKind: config.runnerKind,
34706
+ negotiatedCapabilities: command.requiredCapabilities,
34417
34707
  executorKind: executor.kind,
34418
34708
  materializedAgentInstructionFiles: [...finalAgentInstructionFiles.keys()],
34419
34709
  managedMcpToolMode: governedContext ? readString(governedMcp.mcpToolMode) ?? MANAGED_PI_MCP_TOOL_MODE : null,
@@ -34427,28 +34717,28 @@ async function executeRunCommand(config, command) {
34427
34717
  modelContextBudget,
34428
34718
  runtimeInstructionInjectionEnabled: strictContextGovernance,
34429
34719
  maxChars: modelContextBudget.dynamicPromptMaxChars
34430
- });
34720
+ }));
34431
34721
  const prompt = promptCompilation.prompt;
34432
34722
  const contextManifest = promptCompilation.manifest;
34433
34723
  if (strictContextGovernance) {
34434
- const finalContextExtensions = attachPiFinalContextAttestor(managedMcpProfile, {
34724
+ const finalContextExtensions = await runSourceStage("context_attestation", () => attachPiFinalContextAttestor(managedMcpProfile, {
34435
34725
  cwd,
34436
34726
  finalAgentInstructionFiles,
34437
34727
  effectiveToolSchemaAttestation,
34438
34728
  modelContextBudget
34439
- });
34729
+ }));
34440
34730
  for (const extensionPath of finalContextExtensions) {
34441
34731
  invocation.args = [...invocation.args, "--extension", extensionPath];
34442
34732
  }
34443
34733
  if (config.piExecutorUid > 0 && !desktopDelegatedRunnerEnabled(config)) {
34444
- piExecutorIdentity = preparePiExecutorAccess({
34734
+ piExecutorIdentity = await runSourceStage("context_attestation", () => preparePiExecutorAccess({
34445
34735
  uid: config.piExecutorUid,
34446
34736
  gid: config.piExecutorGid,
34447
34737
  effectiveUid: typeof process.getuid === "function" ? process.getuid() : null,
34448
34738
  profileRoot: managedMcpProfile.profileRoot,
34449
34739
  workspaceRoot: cwd,
34450
34740
  allowedRoot: config.runtimeWorkspacesRoot
34451
- });
34741
+ }));
34452
34742
  }
34453
34743
  }
34454
34744
  const promptBudgetSummary = contextManifest.budget.totalChars === null ? `${contextManifest.budget.usedChars} characters (unbounded)` : `${contextManifest.budget.usedChars}/${contextManifest.budget.totalChars} characters`;
@@ -34456,6 +34746,15 @@ async function executeRunCommand(config, command) {
34456
34746
  presentationKind: "context_manifest",
34457
34747
  contextManifest
34458
34748
  });
34749
+ if (contextManifest.continuationPromptContract) {
34750
+ await ingestLog(config, command, "system", "info", "Compiled Runtime Action continuation prompt contract", {
34751
+ presentationKind: "runtime_action_continuation_prompt_contract",
34752
+ metricName: "mirrorx_runtime_continuation_prompt_generated_total",
34753
+ metricValue: 1,
34754
+ capability: contextManifest.continuationPromptContract.capability,
34755
+ mode: contextManifest.continuationPromptContract.mode
34756
+ });
34757
+ }
34459
34758
  if (contextManifest.currentRunContractShadow.status !== "match") {
34460
34759
  await ingestLog(config, command, "system", "warn", "Current Run Contract shadow comparison did not match the legacy runtime inference", {
34461
34760
  presentationKind: "current_run_contract_shadow_audit",
@@ -35142,16 +35441,25 @@ async function processCommand(config, command) {
35142
35441
  });
35143
35442
  } catch (err) {
35144
35443
  const sourcePurpose = Object.keys(commandSourceAcquisitionProfile(command)).length > 0;
35145
- const message = sourcePurpose ? readString(asRecord(err).code) ?? "source_acquisition_executor_failed" : err instanceof Error ? err.message : String(err);
35146
- const errorCode = commandFailureErrorCode(err);
35444
+ const sourceFailure = sourcePurpose ? sourceAcquisitionFailureFromError(err) ?? sourceAcquisitionUnknownFailure() : null;
35445
+ const message = sourceFailure?.failureCode ?? (err instanceof Error ? err.message : String(err));
35446
+ const errorCode = sourceFailure?.failureCode ?? commandFailureErrorCode(err);
35147
35447
  const runtimeArtifacts = !sourcePurpose && Array.isArray(asRecord(err).receipts) ? asRecord(err).receipts.map(asRecord) : [];
35148
35448
  await ingestLog(config, command, "system", "error", message);
35149
35449
  await completeCommand(config, command, "failed", {
35150
35450
  summary: message,
35151
35451
  commandType: command.commandType,
35152
35452
  ...errorCode && /^[a-z][a-z0-9_]{0,127}$/.test(errorCode) ? { errorCode } : {},
35453
+ ...sourceFailure ? { sourceAcquisitionFailureV1: sourceFailure } : {},
35153
35454
  ...runtimeArtifacts.length > 0 ? { runtimeArtifacts } : {}
35154
35455
  }, message);
35456
+ if (sourcePurpose) {
35457
+ await heartbeat(config, { logMode: "compact" }).catch((heartbeatError) => {
35458
+ const heartbeatMessage = heartbeatError instanceof Error ? heartbeatError.message : String(heartbeatError);
35459
+ process.stderr.write(`AMaster daemon Source cleanup heartbeat failed after command failure: ${heartbeatMessage}
35460
+ `);
35461
+ });
35462
+ }
35155
35463
  }
35156
35464
  }
35157
35465
  function hasConnectorAuth(config) {
@@ -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.138";
10
+ const CONNECTOR_VERSION = "0.1.1-beta.139";
11
11
 
12
12
  const CONFIG_KEY_MAP = new Map([
13
13
  ["server_url", "AMASTER_EMPLOYEE_SERVER_URL"],
@@ -19,5 +19,101 @@
19
19
  ],
20
20
  "requiredPackages": {
21
21
  "@amaster.ai/pi-browser-use": "0.1.2-beta.61"
22
+ },
23
+ "failureClassification": {
24
+ "phases": [
25
+ "source_profile",
26
+ "managed_mcp",
27
+ "provider_config",
28
+ "context_attestation",
29
+ "prompt_compilation",
30
+ "spawn",
31
+ "execution",
32
+ "unknown",
33
+ "attestation",
34
+ "model_contract"
35
+ ],
36
+ "preActionPhases": [
37
+ "source_profile",
38
+ "managed_mcp",
39
+ "provider_config",
40
+ "context_attestation",
41
+ "prompt_compilation"
42
+ ],
43
+ "retryClasses": [
44
+ "operator_repair",
45
+ "transient_infra",
46
+ "unknown"
47
+ ],
48
+ "failureCodes": [
49
+ "source_acquisition_executor_failed",
50
+ "source_acquisition_executor_config_failed",
51
+ "source_acquisition_executor_binary_missing",
52
+ "source_acquisition_executor_permission_denied",
53
+ "source_acquisition_executor_resource_exhausted",
54
+ "source_acquisition_tool_attestation_rejected",
55
+ "source_acquisition_model_missing",
56
+ "source_acquisition_model_contract_failed",
57
+ "source_acquisition_profile_invalid",
58
+ "source_acquisition_browser_profile_invalid",
59
+ "source_acquisition_browser_executable_unavailable",
60
+ "source_acquisition_extension_profile_digest_invalid",
61
+ "source_acquisition_extension_missing",
62
+ "source_acquisition_extension_unsafe",
63
+ "source_acquisition_extension_digest_mismatch",
64
+ "source_acquisition_invocation_invalid",
65
+ "source_acquisition_tool_allowlist_invalid",
66
+ "source_acquisition_prompt_authority_invalid",
67
+ "source_acquisition_direct_tools_unavailable",
68
+ "source_acquisition_profile_canonicalization_failed",
69
+ "source_acquisition_governed_profile_required"
70
+ ],
71
+ "reasonCodes": [
72
+ "source_profile_setup_failed",
73
+ "managed_mcp_setup_failed",
74
+ "provider_config_setup_failed",
75
+ "context_attestation_failed",
76
+ "prompt_compilation_failed",
77
+ "executor_spawn_failed",
78
+ "executor_failure_unknown",
79
+ "execution_phase_unknown",
80
+ "execution_receipt_missing",
81
+ "source_read_receipt_inconsistent",
82
+ "executor_binary_missing",
83
+ "executor_permission_denied",
84
+ "executor_resource_exhausted",
85
+ "effective_tool_manifest_invalid",
86
+ "effective_tool_surface_mismatch",
87
+ "effective_tool_set_hash_mismatch",
88
+ "managed_mcp_cache_mismatch",
89
+ "managed_mcp_config_mismatch",
90
+ "attestor_unknown",
91
+ "model_missing",
92
+ "model_output_contract_failed",
93
+ "model_contract_unknown",
94
+ "executor_exit_78_unknown"
95
+ ],
96
+ "preActionDefaults": {
97
+ "source_profile": {
98
+ "reasonCode": "source_profile_setup_failed",
99
+ "retryClass": "operator_repair"
100
+ },
101
+ "managed_mcp": {
102
+ "reasonCode": "managed_mcp_setup_failed",
103
+ "retryClass": "unknown"
104
+ },
105
+ "provider_config": {
106
+ "reasonCode": "provider_config_setup_failed",
107
+ "retryClass": "unknown"
108
+ },
109
+ "context_attestation": {
110
+ "reasonCode": "context_attestation_failed",
111
+ "retryClass": "unknown"
112
+ },
113
+ "prompt_compilation": {
114
+ "reasonCode": "prompt_compilation_failed",
115
+ "retryClass": "unknown"
116
+ }
117
+ }
22
118
  }
23
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.138",
3
+ "version": "0.1.1-beta.139",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",