@amaster.ai/employee-runtime-connector 0.1.1-beta.224 → 0.1.1-beta.226

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.
@@ -17,6 +17,7 @@ export const BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
17
17
  "run_terminate",
18
18
  "logs_cost_workspace_status",
19
19
  "browser_credential_ref_fill_v1",
20
+ "execution_lanes_v1",
20
21
  ]);
21
22
 
22
23
  const DYNAMIC_READINESS = Object.freeze({
@@ -4072,8 +4072,11 @@ var AMASTER_RUNTIME_CONNECTOR_CAPABILITIES = [
4072
4072
  "runtime_actions_v2",
4073
4073
  "continue_task_v1",
4074
4074
  "run_exit_live_path_closure_v1",
4075
- "browser_credential_ref_fill_v1"
4075
+ "browser_credential_ref_fill_v1",
4076
+ "execution_lanes_v1"
4076
4077
  ];
4078
+ var RUNTIME_EXECUTION_LANES = ["business", "conversation"];
4079
+ var runtimeExecutionLaneSchema = external_exports.enum(RUNTIME_EXECUTION_LANES);
4077
4080
  var TERMINAL_BUSINESS_RECONCILIATION_VERSION = "mirrorx.terminal-business-reconciliation/v1";
4078
4081
  var terminalBusinessReconciliationAuthoritySnapshotSchema = external_exports.object({
4079
4082
  outcomeId: external_exports.string().uuid().nullable(),
@@ -7592,6 +7595,79 @@ var mirrorxDiscoveryTriageCandidateInputSchema = external_exports.object({
7592
7595
  }
7593
7596
  });
7594
7597
 
7598
+ // ../shared/src/mirrorx-work-purpose.ts
7599
+ var MIRRORX_CANONICAL_WORK_PURPOSES = [
7600
+ { code: "activate.customer", workPurposeKey: "customer_activation", label: "\u5BA2\u6237\u6FC0\u6D3B", description: "\u63A8\u52A8\u5BA2\u6237\u8FDB\u5165\u6FC0\u6D3B\u6216\u542F\u7528\u72B6\u6001\u3002", defaultRiskClass: "high", allowedOutcomeClasses: ["external_action", "observed_business_result"] },
7601
+ { code: "activate.growth-gap", workPurposeKey: "growth_gap_activation", label: "\u589E\u957F\u7F3A\u53E3\u884C\u52A8", description: "\u542F\u52A8\u7528\u4E8E\u6536\u655B\u589E\u957F\u7F3A\u53E3\u7684\u884C\u52A8\u3002", defaultRiskClass: "medium", allowedOutcomeClasses: ["internal_enablement", "external_action", "observed_business_result"] },
7602
+ { code: "analyze.activation", workPurposeKey: "activation_analysis", label: "\u6FC0\u6D3B\u5206\u6790", description: "\u5206\u6790\u6FC0\u6D3B\u72B6\u6001\u3001\u8BC1\u636E\u4E0E\u963B\u585E\u3002", defaultRiskClass: "low", allowedOutcomeClasses: ["internal_enablement"] },
7603
+ { code: "analyze.business-gap", workPurposeKey: "business_gap_analysis", label: "\u4E1A\u52A1\u5DEE\u8DDD\u5206\u6790", description: "\u5206\u6790\u5F53\u524D\u7ECF\u8425\u4E8B\u5B9E\u4E0E\u76EE\u6807\u4E4B\u95F4\u7684\u5DEE\u8DDD\u3002", defaultRiskClass: "low", allowedOutcomeClasses: ["internal_enablement"] },
7604
+ { code: "customer.follow_up", workPurposeKey: "customer_follow_up", label: "\u5BA2\u6237\u8DDF\u8FDB", description: "\u63A8\u8FDB\u5DF2\u6709\u5BA2\u6237\u5173\u7CFB\u4E2D\u7684\u660E\u786E\u4E0B\u4E00\u6B65\u3002", defaultRiskClass: "high", allowedOutcomeClasses: ["external_action", "observed_business_result"] },
7605
+ { code: "decision.memo.v1", workPurposeKey: "decision_memo", label: "\u51B3\u7B56\u5907\u5FD8", description: "\u5F62\u6210\u4F9B\u6CBB\u7406\u51B3\u7B56\u4F7F\u7528\u7684\u53EF\u68C0\u67E5\u5907\u5FD8\u3002", defaultRiskClass: "medium", allowedOutcomeClasses: ["governed_decision"] },
7606
+ { code: "execute.operations-gap", workPurposeKey: "operations_gap_execution", label: "\u8FD0\u8425\u7F3A\u53E3\u6267\u884C", description: "\u6267\u884C\u6536\u655B\u5DF2\u786E\u8BA4\u8FD0\u8425\u7F3A\u53E3\u7684\u5DE5\u4F5C\u3002", defaultRiskClass: "medium", allowedOutcomeClasses: ["internal_enablement", "external_action", "observed_business_result"] },
7607
+ { code: "finance.baseline", workPurposeKey: "finance_baseline", label: "\u8D22\u52A1\u57FA\u7EBF", description: "\u5EFA\u7ACB\u53EF\u8FFD\u6EAF\u7684\u8D22\u52A1\u4E8B\u5B9E\u57FA\u7EBF\u3002", defaultRiskClass: "low", allowedOutcomeClasses: ["internal_enablement"] },
7608
+ { code: "internal-enablement.activation-memo", workPurposeKey: "activation_enablement_memo", label: "\u6FC0\u6D3B\u51C6\u5907\u6750\u6599", description: "\u5F62\u6210\u89E3\u9664\u6FC0\u6D3B\u963B\u585E\u6240\u9700\u7684\u5185\u90E8\u6750\u6599\u3002", defaultRiskClass: "low", allowedOutcomeClasses: ["internal_enablement"] },
7609
+ { code: "publish_offer", workPurposeKey: "publish_offer", label: "\u53D1\u5E03 Offer", description: "\u53D1\u5E03\u7ECF\u8FC7\u6CBB\u7406\u786E\u8BA4\u7684 Offer\u3002", defaultRiskClass: "high", allowedOutcomeClasses: ["external_action"] },
7610
+ { code: "renewal_risk_package", workPurposeKey: "renewal_risk_package", label: "\u7EED\u7EA6\u98CE\u9669\u5904\u7F6E\u5305", description: "\u5F62\u6210\u53EF\u6267\u884C\u7684\u7EED\u7EA6\u98CE\u9669\u5206\u6790\u4E0E\u5904\u7F6E\u5305\u3002", defaultRiskClass: "medium", allowedOutcomeClasses: ["internal_enablement", "governed_decision"] },
7611
+ { code: "research.product-gap", workPurposeKey: "product_gap_research", label: "\u4EA7\u54C1\u7F3A\u53E3\u8C03\u7814", description: "\u6536\u96C6\u5E76\u6574\u7406\u4EA7\u54C1\u7F3A\u53E3\u6240\u9700\u8BC1\u636E\u3002", defaultRiskClass: "low", allowedOutcomeClasses: ["internal_enablement"] },
7612
+ { code: "retain.customer", workPurposeKey: "customer_retention", label: "\u5BA2\u6237\u7559\u5B58", description: "\u63A8\u8FDB\u5DF2\u786E\u8BA4\u7684\u5BA2\u6237\u7559\u5B58\u52A8\u4F5C\u3002", defaultRiskClass: "high", allowedOutcomeClasses: ["external_action", "observed_business_result"] },
7613
+ { code: "revenue.follow_up", workPurposeKey: "revenue_follow_up", label: "\u6536\u5165\u673A\u4F1A\u8DDF\u8FDB", description: "\u63A8\u8FDB\u5DF2\u6709\u6536\u5165\u673A\u4F1A\u4E2D\u7684\u660E\u786E\u4E0B\u4E00\u6B65\u3002", defaultRiskClass: "high", allowedOutcomeClasses: ["external_action", "observed_business_result"] },
7614
+ { code: "review.legacy-evidence", workPurposeKey: "legacy_evidence_review", label: "\u5386\u53F2\u8BC1\u636E\u5BA1\u67E5", description: "\u5BA1\u67E5\u5386\u53F2\u8BC1\u636E\u5E76\u5F62\u6210\u5F53\u524D\u53EF\u7528\u7ED3\u8BBA\u3002", defaultRiskClass: "low", allowedOutcomeClasses: ["internal_enablement"] },
7615
+ { code: "review_business_outcome", workPurposeKey: "business_outcome_review", label: "\u4E1A\u52A1\u7ED3\u679C\u5BA1\u67E5", description: "\u5BA1\u67E5\u4E1A\u52A1\u7ED3\u679C\u53CA\u5176\u9A8C\u6536\u4E8B\u5B9E\u3002", defaultRiskClass: "medium", allowedOutcomeClasses: ["governed_decision", "observed_business_result"] },
7616
+ { code: "validate.product-gap", workPurposeKey: "product_gap_validation", label: "\u4EA7\u54C1\u7F3A\u53E3\u9A8C\u8BC1", description: "\u7528\u53D7\u9650\u5B9E\u9A8C\u9A8C\u8BC1\u4EA7\u54C1\u7F3A\u53E3\u3002", defaultRiskClass: "medium", allowedOutcomeClasses: ["internal_enablement", "observed_business_result"] }
7617
+ ];
7618
+ var canonicalWorkKindCodes = MIRRORX_CANONICAL_WORK_PURPOSES.map((entry) => entry.code);
7619
+ var canonicalMirrorxWorkKindSchema = external_exports.enum(canonicalWorkKindCodes);
7620
+ var workPurposeSelectorSchema = external_exports.string().trim().regex(/^[a-z0-9][a-z0-9._-]{0,127}$/u);
7621
+ var mirrorxActivationDomainSchema = external_exports.string().trim().regex(/^[a-z0-9._-]{1,110}$/u);
7622
+ var ceoWorkPurposeSelectionSchema = external_exports.discriminatedUnion("kind", [
7623
+ external_exports.object({
7624
+ kind: external_exports.literal("canonical"),
7625
+ code: canonicalMirrorxWorkKindSchema
7626
+ }).strict(),
7627
+ external_exports.object({
7628
+ kind: external_exports.literal("activation_domain"),
7629
+ domain: mirrorxActivationDomainSchema
7630
+ }).strict(),
7631
+ external_exports.object({
7632
+ kind: external_exports.literal("proposed"),
7633
+ selector: workPurposeSelectorSchema,
7634
+ label: external_exports.string().trim().min(1).max(160),
7635
+ rationale: external_exports.string().trim().min(1).max(2e3)
7636
+ }).strict()
7637
+ ]).superRefine((value, ctx) => {
7638
+ if (value.kind === "proposed" && resolveMirrorxWorkKindPurpose(value.selector).status === "mapped") {
7639
+ ctx.addIssue({
7640
+ code: external_exports.ZodIssueCode.custom,
7641
+ path: ["selector"],
7642
+ message: "Proposed work purposes cannot reuse a reserved canonical selector"
7643
+ });
7644
+ }
7645
+ });
7646
+ var canonicalByCode = new Map(
7647
+ MIRRORX_CANONICAL_WORK_PURPOSES.map((entry) => [entry.code, entry])
7648
+ );
7649
+ function resolveMirrorxWorkPurposeSelection(selection) {
7650
+ if (selection.kind === "proposed") {
7651
+ return { status: "unmapped", workKind: selection.selector };
7652
+ }
7653
+ if (selection.kind === "activation_domain") {
7654
+ return {
7655
+ status: "mapped",
7656
+ workKind: `activation.domain-${selection.domain}`,
7657
+ workPurposeKey: "activation_domain"
7658
+ };
7659
+ }
7660
+ const entry = canonicalByCode.get(selection.code);
7661
+ if (!entry) return { status: "unmapped", workKind: selection.code };
7662
+ return { status: "mapped", workKind: entry.code, workPurposeKey: entry.workPurposeKey };
7663
+ }
7664
+ function resolveMirrorxWorkKindPurpose(workKind) {
7665
+ const entry = canonicalByCode.get(workKind);
7666
+ if (entry) return { status: "mapped", workKind, workPurposeKey: entry.workPurposeKey };
7667
+ const domain = /^activation\.domain-([a-z0-9._-]{1,110})$/u.exec(workKind)?.[1];
7668
+ return domain ? resolveMirrorxWorkPurposeSelection({ kind: "activation_domain", domain }) : { status: "unmapped", workKind };
7669
+ }
7670
+
7595
7671
  // ../shared/src/task-resource-input.ts
7596
7672
  var ATTACHMENT_PREPARATION_VERSION = "attachment-preparation-v1";
7597
7673
  var TASK_RESOURCE_INPUT_STATES = [
@@ -8149,6 +8225,10 @@ var GOAL_GAP_READINESS_REASONS = [
8149
8225
  "waiting_for_provider",
8150
8226
  "waiting_for_identity"
8151
8227
  ];
8228
+ var GOAL_GAP_INDEPENDENT_OBSERVATION_SOURCE_KINDS = [
8229
+ "provider_object",
8230
+ "governed_business_state"
8231
+ ];
8152
8232
  var GOAL_CRITERION_DECISION_KINDS = ["goal_scope", "business_result", "fact_correction"];
8153
8233
  var GOAL_CRITERION_DECISION_ACTIONS = [
8154
8234
  "keep_in_goal",
@@ -8176,28 +8256,83 @@ function normalizeDecimal(value) {
8176
8256
  if (!value.includes(".")) return value;
8177
8257
  return value.replace(/0+$/, "").replace(/\.$/, "");
8178
8258
  }
8179
- var decimalSchema = external_exports.string().regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/, "Expected a non-negative decimal string").transform(normalizeDecimal);
8259
+ var goalGapDecimalSchema = external_exports.string().regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/, "Expected a non-negative decimal string").transform(normalizeDecimal);
8180
8260
  var comparisonSchema = external_exports.enum(["gte", "lte", "eq"]);
8261
+ var goalGapIndependentObservationSourceKindSchema = external_exports.enum(
8262
+ GOAL_GAP_INDEPENDENT_OBSERVATION_SOURCE_KINDS
8263
+ );
8264
+ function scaledDecimal(value) {
8265
+ const [whole, fraction = ""] = value.split(".");
8266
+ return BigInt(`${whole}${fraction.padEnd(12, "0")}`);
8267
+ }
8268
+ var ratioTargetConditionSchema = external_exports.object({
8269
+ kind: external_exports.literal("ratio"),
8270
+ operator: comparisonSchema,
8271
+ value: goalGapDecimalSchema,
8272
+ ratioType: external_exports.enum(["fraction", "rate", "multiple"]).default("fraction"),
8273
+ displayUnit: external_exports.enum(["percent", "multiple", "decimal"]).default("decimal"),
8274
+ upperBound: goalGapDecimalSchema.optional()
8275
+ }).strict();
8181
8276
  var goalGapTargetConditionSchema = external_exports.discriminatedUnion("kind", [
8182
8277
  external_exports.object({
8183
8278
  kind: external_exports.literal("count"),
8184
8279
  operator: comparisonSchema,
8185
- value: external_exports.number().int().min(0)
8280
+ value: external_exports.number().int().min(0).safe()
8186
8281
  }).strict(),
8187
8282
  external_exports.object({
8188
8283
  kind: external_exports.literal("amount"),
8189
8284
  operator: comparisonSchema,
8190
- value: decimalSchema,
8285
+ value: goalGapDecimalSchema,
8286
+ currency: external_exports.string().regex(/^[A-Z]{3}$/)
8287
+ }).strict(),
8288
+ ratioTargetConditionSchema,
8289
+ external_exports.object({
8290
+ kind: external_exports.literal("boolean_milestone"),
8291
+ expected: external_exports.boolean()
8292
+ }).strict()
8293
+ ]).superRefine((value, ctx) => {
8294
+ if (value.kind !== "ratio") return;
8295
+ const upperBound = value.upperBound ?? (value.ratioType === "fraction" ? "1" : null);
8296
+ if (value.ratioType === "fraction" && value.upperBound && scaledDecimal(value.upperBound) > scaledDecimal("1")) {
8297
+ ctx.addIssue({
8298
+ code: external_exports.ZodIssueCode.custom,
8299
+ path: ["upperBound"],
8300
+ message: "A fraction upper bound cannot exceed 1"
8301
+ });
8302
+ }
8303
+ if (value.ratioType === "multiple" && value.displayUnit === "percent") {
8304
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["displayUnit"], message: "A multiple cannot use percent display" });
8305
+ }
8306
+ if (value.ratioType !== "multiple" && value.displayUnit === "multiple") {
8307
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["displayUnit"], message: "Only multiple ratios can use multiple display" });
8308
+ }
8309
+ if (upperBound && scaledDecimal(value.value) > scaledDecimal(upperBound)) {
8310
+ ctx.addIssue({
8311
+ code: external_exports.ZodIssueCode.custom,
8312
+ path: ["value"],
8313
+ message: "Ratio target exceeds the criterion upper bound"
8314
+ });
8315
+ }
8316
+ });
8317
+ var goalGapObservedValueSchema = external_exports.discriminatedUnion("kind", [
8318
+ external_exports.object({
8319
+ kind: external_exports.literal("count"),
8320
+ value: external_exports.number().int().min(0).safe()
8321
+ }).strict(),
8322
+ external_exports.object({
8323
+ kind: external_exports.literal("amount"),
8324
+ value: goalGapDecimalSchema,
8191
8325
  currency: external_exports.string().regex(/^[A-Z]{3}$/)
8192
8326
  }).strict(),
8193
8327
  external_exports.object({
8194
8328
  kind: external_exports.literal("ratio"),
8195
- operator: comparisonSchema,
8196
- value: decimalSchema.refine((value) => Number(value) <= 1, "Ratio must be between 0 and 1")
8329
+ value: goalGapDecimalSchema,
8330
+ ratioType: external_exports.enum(["fraction", "rate", "multiple"]),
8331
+ displayUnit: external_exports.enum(["percent", "multiple", "decimal"])
8197
8332
  }).strict(),
8198
8333
  external_exports.object({
8199
8334
  kind: external_exports.literal("boolean_milestone"),
8200
- expected: external_exports.boolean()
8335
+ value: external_exports.boolean()
8201
8336
  }).strict()
8202
8337
  ]);
8203
8338
  var goalGapObservationRefSchema = external_exports.object({
@@ -8215,6 +8350,59 @@ var goalGapAcceptanceContractSchema = external_exports.discriminatedUnion("verdi
8215
8350
  acceptanceAuthority: external_exports.object({ kind: external_exports.literal("company_board") }).strict()
8216
8351
  }).strict()
8217
8352
  ]);
8353
+ var GOAL_ACCEPTANCE_EVALUATION_SCHEMA_VERSION = "goal-acceptance-evaluation-v2";
8354
+ var goalAcceptanceEvaluationSpecV2Schema = external_exports.object({
8355
+ schemaVersion: external_exports.literal(GOAL_ACCEPTANCE_EVALUATION_SCHEMA_VERSION),
8356
+ evaluationType: external_exports.enum(GOAL_GAP_EVALUATION_TYPES),
8357
+ businessSubjectScope: boundedRecordSchema,
8358
+ targetCondition: goalGapTargetConditionSchema,
8359
+ window: boundedRecordSchema,
8360
+ observationPolicy: external_exports.object({
8361
+ kind: external_exports.enum([
8362
+ "accepted_causal_delivery",
8363
+ "independent_readback",
8364
+ "board_or_independent_readback",
8365
+ "board_judgment"
8366
+ ])
8367
+ }).strict(),
8368
+ acceptanceContract: goalGapAcceptanceContractSchema
8369
+ }).strict().superRefine((value, ctx) => {
8370
+ for (const key of ["kind", "namespace", "objectId"]) {
8371
+ if (typeof value.businessSubjectScope[key] !== "string" || value.businessSubjectScope[key].trim().length === 0) {
8372
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["businessSubjectScope", key], message: `${key} is required` });
8373
+ }
8374
+ }
8375
+ if (typeof value.window.kind !== "string" || value.window.kind.trim().length === 0) {
8376
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["window", "kind"], message: "Window kind is required" });
8377
+ }
8378
+ if (value.window.kind === "deadline" && (typeof value.window.targetAt !== "string" || !external_exports.string().datetime({ offset: true }).safeParse(value.window.targetAt).success)) {
8379
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["window", "targetAt"], message: "Deadline targetAt must be an ISO-8601 timestamp" });
8380
+ }
8381
+ const humanJudgment = value.evaluationType === "human_judgment";
8382
+ if (humanJudgment && value.observationPolicy.kind !== "board_judgment") {
8383
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["observationPolicy", "kind"], message: "Human judgment must use Board judgment" });
8384
+ }
8385
+ if (humanJudgment && value.acceptanceContract.verdictRequirement !== "human_verdict_required") {
8386
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["acceptanceContract"], message: "Human judgment requires Company Board authority" });
8387
+ }
8388
+ if (!humanJudgment && value.acceptanceContract.verdictRequirement !== "deterministic_evidence") {
8389
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["acceptanceContract"], message: "Machine evaluation requires deterministic evidence" });
8390
+ }
8391
+ if (value.evaluationType === "deliverable_milestone") {
8392
+ if (value.targetCondition.kind !== "boolean_milestone") {
8393
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["targetCondition", "kind"], message: "Deliverable milestones require a boolean target" });
8394
+ }
8395
+ if (value.observationPolicy.kind !== "accepted_causal_delivery") {
8396
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["observationPolicy", "kind"], message: "Deliverable milestones require accepted causal delivery" });
8397
+ }
8398
+ }
8399
+ if (value.evaluationType === "observed_business_state" && ![
8400
+ "independent_readback",
8401
+ "board_or_independent_readback"
8402
+ ].includes(value.observationPolicy.kind)) {
8403
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["observationPolicy", "kind"], message: "Business state requires an independent or Board readback" });
8404
+ }
8405
+ });
8218
8406
  var goalGapEvaluationContractSchema = external_exports.object({
8219
8407
  schemaVersion: external_exports.literal("goal-gap-evaluation-v1"),
8220
8408
  criterionIndex: external_exports.number().int().min(0).max(9),
@@ -8232,6 +8420,7 @@ var goalGapEvaluationContractSchema = external_exports.object({
8232
8420
  ])
8233
8421
  }).strict(),
8234
8422
  compilerRevision: external_exports.string().min(1).max(120),
8423
+ compilerSource: external_exports.enum(["explicit_v2", "legacy_heuristic"]).optional().default("legacy_heuristic"),
8235
8424
  evaluationContractHash: sha256Schema5,
8236
8425
  targetHash: sha256Schema5
8237
8426
  }).strict().superRefine((value, ctx) => {
@@ -8549,6 +8738,22 @@ var goalCriterionProgressReadModelSchema = external_exports.object({
8549
8738
  kind: external_exports.enum(["boolean", "count", "amount", "ratio"]),
8550
8739
  currency: external_exports.string().regex(/^[A-Z]{3}$/).nullable()
8551
8740
  }).strict().nullable(),
8741
+ automaticReadiness: external_exports.object({
8742
+ state: external_exports.enum([
8743
+ "ready",
8744
+ "evaluated",
8745
+ "waiting_for_provider",
8746
+ "waiting_for_observation",
8747
+ "not_applicable"
8748
+ ]),
8749
+ label: external_exports.string().min(1),
8750
+ detail: external_exports.string().min(1),
8751
+ requiredValueKind: external_exports.enum(GOAL_GAP_METRIC_KINDS),
8752
+ sourceBinding: external_exports.object({
8753
+ namespace: external_exports.string().min(1),
8754
+ objectId: external_exports.string().min(1)
8755
+ }).strict().nullable()
8756
+ }).strict().nullable(),
8552
8757
  factSummary: external_exports.string().min(1),
8553
8758
  unknownSummary: external_exports.string().min(1).nullable(),
8554
8759
  sourceSummary: external_exports.array(external_exports.string().min(1)).max(20),
@@ -8578,7 +8783,7 @@ var correctedGoalCriterionFactSchema = external_exports.object({
8578
8783
  value: external_exports.union([
8579
8784
  external_exports.boolean(),
8580
8785
  external_exports.number().finite().nonnegative(),
8581
- decimalSchema
8786
+ goalGapDecimalSchema
8582
8787
  ]),
8583
8788
  asOf: external_exports.string().datetime({ offset: true }),
8584
8789
  source: correctedFactSourceSchema
@@ -8607,7 +8812,7 @@ var boardDecideGoalCriterionSchema = external_exports.discriminatedUnion("action
8607
8812
  }).strict(),
8608
8813
  boardDecideGoalCriterionBaseSchema.extend({
8609
8814
  action: external_exports.literal("wait_for_external_fact"),
8610
- awaitedFactKind: external_exports.string().trim().min(1).max(120),
8815
+ awaitedFactKind: goalGapIndependentObservationSourceKindSchema,
8611
8816
  expectedAt: external_exports.string().datetime({ offset: true }).optional()
8612
8817
  }).strict()
8613
8818
  ]);
@@ -11513,8 +11718,7 @@ var ceoPeriodicPortfolioAdmissionSchema = external_exports.object({
11513
11718
  });
11514
11719
  }
11515
11720
  });
11516
- var ceoPeriodicDiscoveredWorkInputSchema = external_exports.object({
11517
- workKind: external_exports.string().trim().regex(/^[a-z0-9][a-z0-9._-]{0,127}$/u),
11721
+ var ceoPeriodicDiscoveredWorkInputShape = {
11518
11722
  title: external_exports.string().trim().min(1).max(240),
11519
11723
  description: external_exports.string().trim().min(1).max(8e3),
11520
11724
  whyNow: external_exports.string().trim().min(1).max(2e3),
@@ -11529,7 +11733,8 @@ var ceoPeriodicDiscoveredWorkInputSchema = external_exports.object({
11529
11733
  executionShape: external_exports.enum(["direct", "team_decomposition", "agent_decides"]).default("agent_decides"),
11530
11734
  completionStrategy: external_exports.enum(["single_aggregation", "multi_acceptance"]).nullable().default(null),
11531
11735
  portfolioAdmission: ceoPeriodicPortfolioAdmissionSchema.optional()
11532
- }).strict().superRefine((value, ctx) => {
11736
+ };
11737
+ function validateCeoPeriodicDiscoveredWorkShape(value, ctx) {
11533
11738
  if (value.executionShape === "team_decomposition" && !value.completionStrategy) {
11534
11739
  ctx.addIssue({
11535
11740
  code: external_exports.ZodIssueCode.custom,
@@ -11544,7 +11749,22 @@ var ceoPeriodicDiscoveredWorkInputSchema = external_exports.object({
11544
11749
  message: "Only team decomposition may declare a completion strategy"
11545
11750
  });
11546
11751
  }
11547
- });
11752
+ }
11753
+ var ceoPeriodicLegacyDiscoveredWorkInputSchema = external_exports.object({
11754
+ ...ceoPeriodicDiscoveredWorkInputShape,
11755
+ workKind: external_exports.string().trim().regex(/^[a-z0-9][a-z0-9._-]{0,127}$/u)
11756
+ }).strict().superRefine(validateCeoPeriodicDiscoveredWorkShape);
11757
+ var ceoPeriodicStructuredDiscoveredWorkInputSchema = external_exports.object({
11758
+ ...ceoPeriodicDiscoveredWorkInputShape,
11759
+ workPurpose: ceoWorkPurposeSelectionSchema
11760
+ }).strict().superRefine(validateCeoPeriodicDiscoveredWorkShape).transform((value) => ({
11761
+ ...value,
11762
+ workKind: resolveMirrorxWorkPurposeSelection(value.workPurpose).workKind
11763
+ }));
11764
+ var ceoPeriodicDiscoveredWorkInputSchema = external_exports.union([
11765
+ ceoPeriodicStructuredDiscoveredWorkInputSchema,
11766
+ ceoPeriodicLegacyDiscoveredWorkInputSchema
11767
+ ]);
11548
11768
  var ceoPeriodicGoalGapCandidateSchema = external_exports.object({
11549
11769
  candidateGapKey: external_exports.string().regex(/^[a-z0-9][a-z0-9._:-]{0,119}$/u),
11550
11770
  criterionIndex: external_exports.number().int().min(0).max(9),
@@ -12051,6 +12271,14 @@ var governedBusinessTaskWakeDispatchSchema = external_exports.object({
12051
12271
  deliveredAt: external_exports.string().datetime({ offset: true }).nullable(),
12052
12272
  lastError: external_exports.string().nullable()
12053
12273
  }).strict();
12274
+ var governedBusinessTaskDiscoverySourceSchema = external_exports.object({
12275
+ controllerIssue: external_exports.object({
12276
+ id: external_exports.string().uuid(),
12277
+ identifier: external_exports.string().nullable(),
12278
+ title: external_exports.string()
12279
+ }).strict(),
12280
+ routineRunId: external_exports.string().uuid().nullable()
12281
+ }).strict();
12054
12282
  var governedBusinessTaskEnrollmentReadModelSchema = external_exports.object({
12055
12283
  state: external_exports.enum(BUSINESS_TASK_ENROLLMENT_READ_STATES),
12056
12284
  companyId: external_exports.string().uuid(),
@@ -12059,6 +12287,7 @@ var governedBusinessTaskEnrollmentReadModelSchema = external_exports.object({
12059
12287
  taskRequirements: issueTaskRequirementsSchema,
12060
12288
  enrollment: governedBusinessTaskEnrollmentSchema.nullable(),
12061
12289
  dispatch: governedBusinessTaskWakeDispatchSchema.nullable(),
12290
+ discoverySource: governedBusinessTaskDiscoverySourceSchema.nullable(),
12062
12291
  finding: external_exports.object({
12063
12292
  code: external_exports.string().trim().min(1),
12064
12293
  message: external_exports.string().trim().min(1)
@@ -12092,17 +12321,36 @@ var companyWorkPurposeCatalogEntrySchema = external_exports.object({
12092
12321
  status: companyWorkPurposeCatalogEntryStatusSchema,
12093
12322
  sourceCandidateId: external_exports.string().uuid()
12094
12323
  }).strict();
12095
- var boardDecideCompanyWorkPurposeCandidateSchema = external_exports.object({
12096
- candidateId: external_exports.string().uuid(),
12324
+ var optionalDecisionRationaleSchema = external_exports.preprocess(
12325
+ (value) => typeof value === "string" && value.trim().length === 0 ? null : value,
12326
+ external_exports.string().trim().min(1).max(2e3).nullable().optional()
12327
+ );
12328
+ var businessDemandDecisionShape = {
12097
12329
  interactionId: external_exports.string().uuid(),
12098
12330
  expectedRevision: external_exports.number().int().positive(),
12099
12331
  idempotencyKey: external_exports.string().trim().min(8).max(200),
12100
12332
  decision: external_exports.enum(["reject", "approve_once", "approve_reusable"]),
12101
- rationale: external_exports.string().trim().min(1).max(2e3).nullable().optional()
12102
- }).strict();
12103
- var boardDecideBusinessDemandSchema = boardDecideCompanyWorkPurposeCandidateSchema.omit({
12104
- candidateId: true
12105
- }).strict();
12333
+ rationale: optionalDecisionRationaleSchema
12334
+ };
12335
+ function requireReusableDecisionRationale(schema) {
12336
+ return schema.superRefine((value, context) => {
12337
+ if (value.decision !== "approve_reusable" || value.rationale) return;
12338
+ context.addIssue({
12339
+ code: external_exports.ZodIssueCode.custom,
12340
+ path: ["rationale"],
12341
+ message: "Reusable automatic work approval requires a rationale"
12342
+ });
12343
+ });
12344
+ }
12345
+ var boardDecideCompanyWorkPurposeCandidateSchema = requireReusableDecisionRationale(
12346
+ external_exports.object({
12347
+ candidateId: external_exports.string().uuid(),
12348
+ ...businessDemandDecisionShape
12349
+ }).strict()
12350
+ );
12351
+ var boardDecideBusinessDemandSchema = requireReusableDecisionRationale(
12352
+ external_exports.object(businessDemandDecisionShape).strict()
12353
+ );
12106
12354
  var boardDisableCompanyWorkPurposeCatalogEntrySchema = external_exports.object({
12107
12355
  expectedRevision: external_exports.number().int().positive(),
12108
12356
  idempotencyKey: external_exports.string().trim().min(8).max(200),
@@ -14511,9 +14759,16 @@ var goalAcceptanceCriteriaSchema = external_exports.array(
14511
14759
  ).min(1).max(10);
14512
14760
  var goalAcceptanceCriteriaItemSchema = external_exports.object({
14513
14761
  id: external_exports.string().uuid().optional(),
14514
- text: external_exports.string().trim().min(1).max(1e3)
14762
+ text: external_exports.string().trim().min(1).max(1e3),
14763
+ evaluation: goalAcceptanceEvaluationSpecV2Schema.optional()
14515
14764
  }).strict();
14516
14765
  var goalAcceptanceCriteriaItemsSchema = external_exports.array(goalAcceptanceCriteriaItemSchema).min(1).max(10);
14766
+ var goalAcceptanceCriterionDraftV2Schema = external_exports.object({
14767
+ id: external_exports.string().uuid().optional(),
14768
+ text: external_exports.string().trim().min(1).max(1e3),
14769
+ evaluation: goalAcceptanceEvaluationSpecV2Schema
14770
+ }).strict();
14771
+ var goalAcceptanceCriteriaItemsV2Schema = external_exports.array(goalAcceptanceCriterionDraftV2Schema).min(1).max(10);
14517
14772
  var goalStringListSchema = external_exports.array(external_exports.string().trim().min(1).max(1e3)).max(20);
14518
14773
  var goalSourceRefSchema = external_exports.object({
14519
14774
  kind: external_exports.string().trim().min(1).max(100),
@@ -14574,11 +14829,10 @@ var createGoalProposalSchema = external_exports.object({
14574
14829
  var goalProposalMessageSchema = external_exports.object({
14575
14830
  message: external_exports.string().trim().min(1).max(8e3)
14576
14831
  }).strict();
14577
- var goalProposalRevisionInputSchema = external_exports.object({
14832
+ var goalProposalRevisionBaseShape = {
14578
14833
  title: external_exports.string().trim().min(1).max(300),
14579
14834
  description: external_exports.string().trim().min(1).max(8e3),
14580
14835
  findingSummary: external_exports.string().trim().min(1).max(4e3),
14581
- acceptanceCriteria: goalAcceptanceCriteriaSchema,
14582
14836
  assumptions: goalStringListSchema.optional().default([]),
14583
14837
  unknowns: goalStringListSchema.optional().default([]),
14584
14838
  constraints: goalStringListSchema.optional().default([]),
@@ -14586,7 +14840,31 @@ var goalProposalRevisionInputSchema = external_exports.object({
14586
14840
  proposedOutcomeOwnerUserId: external_exports.string().trim().min(1).max(200),
14587
14841
  proposedOwnerAgentId: external_exports.string().uuid().optional().nullable(),
14588
14842
  targetAt: external_exports.coerce.date()
14589
- }).strict();
14843
+ };
14844
+ var typedGoalProposalRevisionInputSchema = external_exports.object({
14845
+ ...goalProposalRevisionBaseShape,
14846
+ acceptanceCriteriaItems: goalAcceptanceCriteriaItemsV2Schema
14847
+ }).strict().transform((value) => ({
14848
+ ...value,
14849
+ acceptanceCriteria: value.acceptanceCriteriaItems.map((item) => item.text)
14850
+ }));
14851
+ var normalizedTypedGoalProposalRevisionInputSchema = external_exports.object({
14852
+ ...goalProposalRevisionBaseShape,
14853
+ acceptanceCriteriaItems: goalAcceptanceCriteriaItemsV2Schema,
14854
+ acceptanceCriteria: goalAcceptanceCriteriaSchema
14855
+ }).strict().superRefine((value, ctx) => {
14856
+ if (value.acceptanceCriteria.length !== value.acceptanceCriteriaItems.length || value.acceptanceCriteria.some((text2, index) => text2 !== value.acceptanceCriteriaItems[index]?.text)) {
14857
+ ctx.addIssue({
14858
+ code: external_exports.ZodIssueCode.custom,
14859
+ path: ["acceptanceCriteria"],
14860
+ message: "Acceptance criteria projection does not match typed items"
14861
+ });
14862
+ }
14863
+ });
14864
+ var goalProposalRevisionInputSchema = external_exports.union([
14865
+ typedGoalProposalRevisionInputSchema,
14866
+ normalizedTypedGoalProposalRevisionInputSchema
14867
+ ]);
14590
14868
  var acceptGoalProposalSchema = external_exports.object({
14591
14869
  revisionId: external_exports.string().uuid()
14592
14870
  }).strict();
@@ -20032,6 +20310,7 @@ const terminalActionDispositions = new Map([
20032
20310
  ["create_interaction", new Set(["waiting_human", "handoff_existing_live_path"])],
20033
20311
  ["upsert_external_wait", new Set(["waiting_external"])],
20034
20312
  ["schedule_monitor", new Set(["scheduled_monitor"])],
20313
+ ["continue_task", new Set(["continuation_scheduled"])],
20035
20314
  ]);
20036
20315
  const terminalToolNames = new Set(["runtime_action.submit", "runtime_action.status"]);
20037
20316
 
@@ -20055,6 +20334,18 @@ function shouldStopFromReceipt(rawResult) {
20055
20334
  const disposition = readString(effectResult.runDisposition);
20056
20335
  const existingOwner = asRecord(effectResult.existingOwner);
20057
20336
  const existingOwnerEpoch = Number(existingOwner.executionEpoch);
20337
+ const continuationCount = Number(effectResult.continuationCount);
20338
+ const maxContinuations = Number(effectResult.maxContinuations);
20339
+ const exactContinuation = disposition === "continuation_scheduled"
20340
+ && Boolean(readString(effectResult.chainId))
20341
+ && Boolean(readString(effectResult.continuationIntentId))
20342
+ && Boolean(readString(effectResult.wakeId))
20343
+ && Number.isSafeInteger(Number(effectResult.executionEpoch))
20344
+ && Number(effectResult.executionEpoch) > 0
20345
+ && Number.isSafeInteger(continuationCount)
20346
+ && continuationCount > 0
20347
+ && Number.isSafeInteger(maxContinuations)
20348
+ && continuationCount <= maxContinuations;
20058
20349
  if (!invocationId || !receiptInvocationId || !callId || !receiptCallId) return false;
20059
20350
 
20060
20351
  const exactQueuedWakeHandoff = disposition === "handoff_existing_live_path"
@@ -20081,7 +20372,8 @@ function shouldStopFromReceipt(rawResult) {
20081
20372
  && (disposition !== "waiting_human"
20082
20373
  || Boolean(readString(effectResult.interactionId) && readString(effectResult.epochKey)))
20083
20374
  && (disposition !== "handoff_existing_live_path"
20084
- || Boolean(readString(effectResult.epochKey) && exactQueuedWakeHandoff));
20375
+ || Boolean(readString(effectResult.epochKey) && exactQueuedWakeHandoff))
20376
+ && (disposition !== "continuation_scheduled" || exactContinuation);
20085
20377
  }
20086
20378
 
20087
20379
  export default function mirrorxRunTermination(pi) {
@@ -20273,7 +20565,7 @@ function createManagedPiMcpProfileApi(options = {}) {
20273
20565
  const DELEGATED_PROFILE_MARKER = ".amaster-delegated-pi-profile.json";
20274
20566
  const SESSION_ROLLOUT_MARKER2 = ".amaster-pi-session-rollout.json";
20275
20567
  const DEFAULT_SESSION_ROLLOUT_TTL_MS2 = 24 * 60 * 60 * 1e3;
20276
- const PI_VERSION_ATTESTATION_TIMEOUT_MS = 1e4;
20568
+ const PI_VERSION_ATTESTATION_TIMEOUT_MS = 3e4;
20277
20569
  const PI_EFFECTIVE_TOOLS_ATTESTATION_TIMEOUT_MS = 6e4;
20278
20570
  const PI_EFFECTIVE_TOOLS_RETRY_TIMEOUT_MS = 3e4;
20279
20571
  const PI_EFFECTIVE_TOOLS_TOTAL_TIMEOUT_MS = PI_EFFECTIVE_TOOLS_ATTESTATION_TIMEOUT_MS + PI_EFFECTIVE_TOOLS_RETRY_TIMEOUT_MS;
@@ -23225,6 +23517,39 @@ function resolveRuntimeCostModelIdentity({
23225
23517
  };
23226
23518
  }
23227
23519
 
23520
+ // src/amaster-runtime-daemon/execution-lanes.mjs
23521
+ function normalizeRuntimeExecutionLane(value) {
23522
+ return value === "conversation" ? "conversation" : "business";
23523
+ }
23524
+ function runtimeExecutionLaneForCapabilities(value, capabilities) {
23525
+ const lane = normalizeRuntimeExecutionLane(value);
23526
+ return lane === "conversation" && !(Array.isArray(capabilities) && capabilities.includes("execution_lanes_v1")) ? "business" : lane;
23527
+ }
23528
+ function localRuntimeCommandLimit(input) {
23529
+ const businessLimit = Number.isInteger(input.businessLimit) && input.businessLimit > 0 ? Math.min(input.businessLimit, 3) : 1;
23530
+ const supportsExecutionLanes = Array.isArray(input.capabilities) && input.capabilities.includes("execution_lanes_v1");
23531
+ return Math.min(4, businessLimit + (supportsExecutionLanes ? 1 : 0));
23532
+ }
23533
+ function selectRuntimeCommandsWithinLaneLimits(input) {
23534
+ const businessLimit = Number.isInteger(input.businessLimit) && input.businessLimit > 0 ? Math.min(input.businessLimit, 3) : 1;
23535
+ const totalLimit = Number.isInteger(input.totalLimit) && input.totalLimit > 0 ? Math.min(input.totalLimit, 4) : 1;
23536
+ const counts = { business: 0, conversation: 0 };
23537
+ for (const lane of Array.isArray(input.activeLanes) ? input.activeLanes : []) {
23538
+ counts[runtimeExecutionLaneForCapabilities(lane, input.capabilities)] += 1;
23539
+ }
23540
+ const selected = [];
23541
+ for (const command of Array.isArray(input.commands) ? input.commands : []) {
23542
+ const lane = runtimeExecutionLaneForCapabilities(command?.executionLane, input.capabilities);
23543
+ const total = counts.business + counts.conversation;
23544
+ if (total >= totalLimit) continue;
23545
+ if (lane === "business" && counts.business >= businessLimit) continue;
23546
+ if (lane === "conversation" && counts.conversation >= 1) continue;
23547
+ selected.push(command);
23548
+ counts[lane] += 1;
23549
+ }
23550
+ return selected;
23551
+ }
23552
+
23228
23553
  // src/amaster-runtime-daemon/prompt-compiler.mjs
23229
23554
  import { createHash as createHash9 } from "node:crypto";
23230
23555
  import { isAbsolute as isAbsolute5 } from "node:path";
@@ -24423,7 +24748,7 @@ function runtimeAuthorizationText(context, mode, {
24423
24748
  const completionContract = !suppressOrdinaryCompletionContract && completionRole && completionDeliverable ? [
24424
24749
  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.",
24425
24750
  firstDocumentCheckpoint,
24426
- 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."
24751
+ continueTaskEnabled ? "Treat one Run as one bounded, durable checkpoint. Once that checkpoint is persisted and another independent research, build, or revision phase remains, call continue_task immediately with a concrete nextAction and stable idempotencyKey instead of keeping the current Run open, then end the run. Do not split an unfinished atomic mutation or claim progress that is not durable. 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."
24427
24752
  ].filter(Boolean).join(" ") : "";
24428
24753
  const businessOutcomeOwnershipContract = businessOutcome.mode === "required" ? evidenceAutoAcceptance ? [
24429
24754
  "Evidence-auto Business Outcome closure is owned by the Server terminal reconciler.",
@@ -25688,7 +26013,8 @@ var BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
25688
26013
  "run_cancel",
25689
26014
  "run_terminate",
25690
26015
  "logs_cost_workspace_status",
25691
- "browser_credential_ref_fill_v1"
26016
+ "browser_credential_ref_fill_v1",
26017
+ "execution_lanes_v1"
25692
26018
  ]);
25693
26019
  var DYNAMIC_READINESS = Object.freeze({
25694
26020
  artifact_template_catalog_v1: {
@@ -26653,7 +26979,8 @@ var PI_TERMINAL_RUNTIME_ACTION_STATUSES = /* @__PURE__ */ new Set([
26653
26979
  var PI_TERMINATING_RUNTIME_ACTION_TO_DISPOSITION = /* @__PURE__ */ new Map([
26654
26980
  ["create_interaction", /* @__PURE__ */ new Set(["waiting_human", "handoff_existing_live_path"])],
26655
26981
  ["upsert_external_wait", /* @__PURE__ */ new Set(["waiting_external"])],
26656
- ["schedule_monitor", /* @__PURE__ */ new Set(["scheduled_monitor"])]
26982
+ ["schedule_monitor", /* @__PURE__ */ new Set(["scheduled_monitor"])],
26983
+ ["continue_task", /* @__PURE__ */ new Set(["continuation_scheduled"])]
26657
26984
  ]);
26658
26985
  var PI_TERMINATING_RUNTIME_ACTION_TOOLS = /* @__PURE__ */ new Set([
26659
26986
  "runtime_action.submit",
@@ -26716,10 +27043,17 @@ function governedMcpToolResult(structuredContent) {
26716
27043
  const epochKey = readString(effectResult.epochKey);
26717
27044
  const existingOwner = asRecord(effectResult.existingOwner);
26718
27045
  const existingOwnerEpoch = readNumber(existingOwner.executionEpoch, 0);
27046
+ const continuationChainId = readString(effectResult.chainId);
27047
+ const continuationIntentId = readString(effectResult.continuationIntentId);
27048
+ const continuationWakeId = readString(effectResult.wakeId);
27049
+ const continuationExecutionEpoch = readNumber(effectResult.executionEpoch, 0);
27050
+ const continuationCount = readNumber(effectResult.continuationCount, 0);
27051
+ const maxContinuations = readNumber(effectResult.maxContinuations, 0);
27052
+ const exactContinuation = runDisposition === "continuation_scheduled" && continuationChainId && continuationIntentId && continuationWakeId && Number.isSafeInteger(continuationExecutionEpoch) && continuationExecutionEpoch > 0 && Number.isSafeInteger(continuationCount) && continuationCount > 0 && Number.isSafeInteger(maxContinuations) && continuationCount <= maxContinuations;
26719
27053
  const exactQueuedWakeHandoff = runDisposition === "handoff_existing_live_path" && readString(existingOwner.kind) === "queued_wake" && Boolean(readString(existingOwner.id)) && ["pending_dispatch", "queued", "deferred_issue_execution"].includes(
26720
27054
  readString(existingOwner.status) ?? ""
26721
27055
  ) && Number.isSafeInteger(existingOwnerEpoch) && existingOwnerEpoch > 0 && readString(existingOwner.nextAction) === "end_current_run";
26722
- const terminalRunDisposition = status === "succeeded" && providerStatus === "accepted" && PI_TERMINAL_RUNTIME_ACTION_STATUSES.has(runtimeActionResultStatus ?? "") && PI_TERMINATING_RUNTIME_ACTION_TOOLS.has(runtimeActionToolName ?? "") && effectResult.mustEndRun === true && Boolean(expectedDispositions?.has(runDisposition ?? "")) && invocationId && readString(providerReceipt.provider) === "amaster_actions" && readString(providerReceipt.invocationId) === invocationId && readString(providerReceipt.status) === "accepted" && receiptRunId && receiptCommandId && receiptIssueId && runtimeActionCallId && receiptCallId === runtimeActionCallId && (runDisposition !== "waiting_human" || Boolean(interactionId && epochKey)) && (runDisposition !== "handoff_existing_live_path" || Boolean(epochKey && exactQueuedWakeHandoff)) ? {
27056
+ const terminalRunDisposition = status === "succeeded" && providerStatus === "accepted" && PI_TERMINAL_RUNTIME_ACTION_STATUSES.has(runtimeActionResultStatus ?? "") && PI_TERMINATING_RUNTIME_ACTION_TOOLS.has(runtimeActionToolName ?? "") && effectResult.mustEndRun === true && Boolean(expectedDispositions?.has(runDisposition ?? "")) && invocationId && readString(providerReceipt.provider) === "amaster_actions" && readString(providerReceipt.invocationId) === invocationId && readString(providerReceipt.status) === "accepted" && receiptRunId && receiptCommandId && receiptIssueId && runtimeActionCallId && receiptCallId === runtimeActionCallId && (runDisposition !== "waiting_human" || Boolean(interactionId && epochKey)) && (runDisposition !== "handoff_existing_live_path" || Boolean(epochKey && exactQueuedWakeHandoff)) && (runDisposition !== "continuation_scheduled" || Boolean(exactContinuation)) ? {
26723
27057
  disposition: runDisposition,
26724
27058
  actionType: receiptActionType,
26725
27059
  toolName: runtimeActionToolName,
@@ -26730,6 +27064,16 @@ function governedMcpToolResult(structuredContent) {
26730
27064
  issueId: receiptIssueId,
26731
27065
  ...interactionId ? { interactionId } : {},
26732
27066
  ...epochKey ? { epochKey } : {},
27067
+ ...exactContinuation ? {
27068
+ continuation: {
27069
+ chainId: continuationChainId,
27070
+ intentId: continuationIntentId,
27071
+ wakeId: continuationWakeId,
27072
+ executionEpoch: continuationExecutionEpoch,
27073
+ count: continuationCount,
27074
+ max: maxContinuations
27075
+ }
27076
+ } : {},
26733
27077
  ...exactQueuedWakeHandoff ? {
26734
27078
  existingOwner: {
26735
27079
  kind: "queued_wake",
@@ -26798,6 +27142,7 @@ function piTerminatingRunDispositionEvidence(results, expected = {}) {
26798
27142
  if (!result2) return null;
26799
27143
  const disposition = asRecord(result2.terminalRunDisposition);
26800
27144
  const existingOwner = asRecord(disposition.existingOwner);
27145
+ const continuation = asRecord(disposition.continuation);
26801
27146
  return {
26802
27147
  kind: "runtime_action_run_disposition",
26803
27148
  disposition: readString(disposition.disposition),
@@ -26810,6 +27155,16 @@ function piTerminatingRunDispositionEvidence(results, expected = {}) {
26810
27155
  issueId: expectedIssueId,
26811
27156
  ...readString(disposition.interactionId) ? { interactionId: readString(disposition.interactionId) } : {},
26812
27157
  ...readString(disposition.epochKey) ? { epochKey: readString(disposition.epochKey) } : {},
27158
+ ...readString(continuation.chainId) && readString(continuation.intentId) && readString(continuation.wakeId) ? {
27159
+ continuation: {
27160
+ chainId: readString(continuation.chainId),
27161
+ intentId: readString(continuation.intentId),
27162
+ wakeId: readString(continuation.wakeId),
27163
+ executionEpoch: readNumber(continuation.executionEpoch, 0),
27164
+ count: readNumber(continuation.count, 0),
27165
+ max: readNumber(continuation.max, 0)
27166
+ }
27167
+ } : {},
26813
27168
  ...readString(existingOwner.kind) === "queued_wake" && readString(existingOwner.id) ? {
26814
27169
  existingOwner: {
26815
27170
  kind: "queued_wake",
@@ -26898,7 +27253,8 @@ function classifyPiTerminalCleanupDisposition(parsed, runtimeArtifacts) {
26898
27253
  diagnostics
26899
27254
  };
26900
27255
  }
26901
- function classifyPiTurnLimitResult(parsed) {
27256
+ function classifyPiTurnLimitResult(parsed, options = {}) {
27257
+ if (options.authoritativeTerminalDisposition === true) return null;
26902
27258
  const stopReason = readString(parsed?.stopReason);
26903
27259
  if (parsed?.sawAgentSettled !== true || !Number.isInteger(parsed?.settledEventIndex) || parsed?.terminalEventType !== "agent_end" || !["toolUse", "tool_use"].includes(stopReason ?? "")) return null;
26904
27260
  return {
@@ -29587,7 +29943,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
29587
29943
  }
29588
29944
 
29589
29945
  // src/amaster-runtime-daemon.mjs
29590
- var CONNECTOR_VERSION = "0.1.1-beta.224";
29946
+ var CONNECTOR_VERSION = "0.1.1-beta.226";
29591
29947
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
29592
29948
  var daemonRequire = createRequire(import.meta.url);
29593
29949
  var MAX_CHECKPOINT_BYTES = 20 * 1024 * 1024;
@@ -29603,7 +29959,7 @@ var activeRunCommands = /* @__PURE__ */ new Map();
29603
29959
  var pendingResultOutboxRunCommands = /* @__PURE__ */ new Map();
29604
29960
  var pendingRunCompletionCommands = /* @__PURE__ */ new Map();
29605
29961
  var runCompletionFlights = /* @__PURE__ */ new Map();
29606
- var localDispatchCommandIds = /* @__PURE__ */ new Set();
29962
+ var localDispatchCommands = /* @__PURE__ */ new Map();
29607
29963
  var workspaceStatusHashCache = /* @__PURE__ */ new Map();
29608
29964
  var processGroupRssSampleCache = null;
29609
29965
  var lastOrphanReaperRunAtMs = 0;
@@ -29677,6 +30033,7 @@ function runCompletionStateActiveRunCommands(config) {
29677
30033
  const command = asRecord(state.command);
29678
30034
  return {
29679
30035
  commandId: state.commandId,
30036
+ executionLane: normalizeRuntimeExecutionLane(command.executionLane),
29680
30037
  ...readString(commandRunId(command)) ? { runId: readString(commandRunId(command)) } : {},
29681
30038
  ...readString(commandIssueId(command)) ? { issueId: readString(commandIssueId(command)) } : {},
29682
30039
  ...readString(executor.kind) ? { executorKind: readString(executor.kind) } : {},
@@ -29705,6 +30062,7 @@ function resultOutboxActiveRunCommands(config) {
29705
30062
  if (!commandId) continue;
29706
30063
  entries.push({
29707
30064
  commandId,
30065
+ executionLane: normalizeRuntimeExecutionLane(activeRun.executionLane),
29708
30066
  ...readString(activeRun.runId) ? { runId: readString(activeRun.runId) } : {},
29709
30067
  ...readString(activeRun.issueId) ? { issueId: readString(activeRun.issueId) } : {},
29710
30068
  ...readString(activeRun.executorKind) ? { executorKind: readString(activeRun.executorKind) } : {},
@@ -30109,7 +30467,7 @@ function buildHeartbeatPayload(config, options = {}) {
30109
30467
  const orphanReaperSummary = asRecord(options.orphanReaper ?? lastOrphanReaperSummary);
30110
30468
  const activeRunCommandById = /* @__PURE__ */ new Map();
30111
30469
  for (const entry of [
30112
- ...Array.from(localDispatchCommandIds, (commandId) => ({ commandId, phase: "preparing" })),
30470
+ ...Array.from(localDispatchCommands.values()),
30113
30471
  ...Array.from(activeRunCommands.values()),
30114
30472
  ...Array.from(pendingResultOutboxRunCommands.values()),
30115
30473
  ...Array.from(pendingRunCompletionCommands.values()),
@@ -30420,7 +30778,10 @@ function activeRunHeartbeatIntervalMs(config) {
30420
30778
  }
30421
30779
  function maxConcurrentCommands(config) {
30422
30780
  const configured = Number(config.maxConcurrentCommands);
30423
- return Number.isInteger(configured) && configured > 0 ? Math.min(configured, 50) : 1;
30781
+ return localRuntimeCommandLimit({
30782
+ businessLimit: Number.isInteger(configured) && configured > 0 ? configured : 1,
30783
+ capabilities: config.capabilities
30784
+ });
30424
30785
  }
30425
30786
  function activeRunCommandCount(config, options = {}) {
30426
30787
  const excludeCommandIds = new Set(readStringArray(options.excludeCommandIds));
@@ -30429,19 +30790,54 @@ function activeRunCommandCount(config, options = {}) {
30429
30790
  ...pendingResultOutboxRunCommands.keys(),
30430
30791
  ...pendingRunCompletionCommands.keys(),
30431
30792
  ...runCompletionStateEntries(config).map(({ state }) => state.commandId),
30432
- ...localDispatchCommandIds
30793
+ ...localDispatchCommands.keys()
30433
30794
  ].filter((commandId) => !excludeCommandIds.has(commandId)));
30434
30795
  return commandIds.size;
30435
30796
  }
30436
30797
  function availableCommandSlots(config) {
30437
30798
  return Math.max(0, maxConcurrentCommands(config) - activeRunCommandCount(config));
30438
30799
  }
30800
+ function activeRuntimeExecutionLanes(config) {
30801
+ const laneByCommandId = /* @__PURE__ */ new Map();
30802
+ for (const entry of [
30803
+ ...activeRunCommands.values(),
30804
+ ...pendingResultOutboxRunCommands.values(),
30805
+ ...pendingRunCompletionCommands.values(),
30806
+ ...runCompletionStateActiveRunCommands(config),
30807
+ ...localDispatchCommands.values()
30808
+ ]) {
30809
+ const commandId = readString(entry.commandId);
30810
+ if (!commandId) continue;
30811
+ const lane = runtimeExecutionLaneForCapabilities(entry.executionLane, config.capabilities);
30812
+ if (!laneByCommandId.has(commandId) || lane === "conversation") {
30813
+ laneByCommandId.set(commandId, lane);
30814
+ }
30815
+ }
30816
+ return [...laneByCommandId.values()];
30817
+ }
30818
+ function locallyAdmittedCommands(config, commands) {
30819
+ const admitted = selectRuntimeCommandsWithinLaneLimits({
30820
+ commands,
30821
+ activeLanes: activeRuntimeExecutionLanes(config),
30822
+ businessLimit: Number(config.maxConcurrentCommands),
30823
+ totalLimit: maxConcurrentCommands(config),
30824
+ capabilities: config.capabilities
30825
+ });
30826
+ if (admitted.length !== commands.length) {
30827
+ process.stderr.write(
30828
+ `AMaster daemon deferred ${commands.length - admitted.length} leased command(s) at the local execution-lane guard.
30829
+ `
30830
+ );
30831
+ }
30832
+ return admitted;
30833
+ }
30439
30834
  function rememberActiveRunCommand(command, metadata) {
30440
30835
  const commandId = readString(command.commandId) ?? readString(command.id);
30441
30836
  if (!commandId) return () => {
30442
30837
  };
30443
30838
  activeRunCommands.set(commandId, {
30444
30839
  commandId,
30840
+ executionLane: normalizeRuntimeExecutionLane(command.executionLane),
30445
30841
  ...readString(commandRunId(command)) ? { runId: readString(commandRunId(command)) } : {},
30446
30842
  ...readString(commandIssueId(command)) ? { issueId: readString(commandIssueId(command)) } : {},
30447
30843
  ...metadata.executorKind ? { executorKind: metadata.executorKind } : {},
@@ -32122,7 +32518,7 @@ function walkManagedWorkdirs(root) {
32122
32518
  }
32123
32519
  function activeRuntimeExecutionRefs() {
32124
32520
  const activeRunIds = /* @__PURE__ */ new Set();
32125
- const activeCommandIds = new Set(localDispatchCommandIds);
32521
+ const activeCommandIds = new Set(localDispatchCommands.keys());
32126
32522
  const activeWorkspacePaths = /* @__PURE__ */ new Set();
32127
32523
  for (const entry of [
32128
32524
  ...Array.from(activeRunCommands.values()),
@@ -32604,6 +33000,7 @@ function pendingRunCompletionSnapshot(config, state) {
32604
33000
  const execution = asRecord(executor.closureExecution);
32605
33001
  return {
32606
33002
  commandId: state.commandId,
33003
+ executionLane: normalizeRuntimeExecutionLane(command.executionLane),
32607
33004
  ...readString(commandRunId(command)) ? { runId: readString(commandRunId(command)) } : {},
32608
33005
  ...readString(commandIssueId(command)) ? { issueId: readString(commandIssueId(command)) } : {},
32609
33006
  ...readString(executor.kind) ? { executorKind: readString(executor.kind) } : {},
@@ -33832,6 +34229,7 @@ function resultOutboxActiveRunSnapshot(command) {
33832
34229
  if (!current) return null;
33833
34230
  return {
33834
34231
  commandId,
34232
+ executionLane: normalizeRuntimeExecutionLane(current.executionLane),
33835
34233
  ...readString(current.runId) ? { runId: readString(current.runId) } : {},
33836
34234
  ...readString(current.issueId) ? { issueId: readString(current.issueId) } : {},
33837
34235
  ...readString(current.executorKind) ? { executorKind: readString(current.executorKind) } : {},
@@ -35074,7 +35472,7 @@ async function executeRunCommand(config, command) {
35074
35472
  }) : null;
35075
35473
  if (terminalRunDisposition) {
35076
35474
  const disposition = readString(terminalRunDisposition.disposition);
35077
- parsed.summary = disposition === "handoff_existing_live_path" ? "This run handed control to the existing queued live path and ended normally without creating a duplicate interaction." : disposition === "waiting_human" ? "The requested human interaction was persisted; this run ended normally and will resume only under its continuation policy." : disposition === "waiting_external" ? "The external wait was persisted; this run ended normally and will resume only after the recorded condition is satisfied." : "The monitor schedule was persisted; this run ended normally and will resume only at the scheduled check.";
35475
+ parsed.summary = disposition === "handoff_existing_live_path" ? "This run handed control to the existing queued live path and ended normally without creating a duplicate interaction." : disposition === "continuation_scheduled" ? "A bounded continuation was persisted; this run ended normally so another queued command can use the released execution slot." : disposition === "waiting_human" ? "The requested human interaction was persisted; this run ended normally and will resume only under its continuation policy." : disposition === "waiting_external" ? "The external wait was persisted; this run ended normally and will resume only after the recorded condition is satisfied." : "The monitor schedule was persisted; this run ended normally and will resume only at the scheduled check.";
35078
35476
  parsed.hasAssistantOutput = true;
35079
35477
  await ingestLog(
35080
35478
  config,
@@ -35252,7 +35650,9 @@ async function executeRunCommand(config, command) {
35252
35650
  );
35253
35651
  }
35254
35652
  const parsedForValidation = parsed;
35255
- const piTurnLimitFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError ? classifyPiTurnLimitResult(parsedForValidation) : null;
35653
+ const piTurnLimitFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError ? classifyPiTurnLimitResult(parsedForValidation, {
35654
+ authoritativeTerminalDisposition: Boolean(terminalRunDisposition)
35655
+ }) : null;
35256
35656
  const piInvalidOutputError = executor.kind === "pi" ? piOutputValidationError(parsedForValidation, {
35257
35657
  allowMissingTurnEnd: completionOutputStopped,
35258
35658
  allowMissingAssistantOutput: execution.completionOutputType === "approval_required",
@@ -35626,7 +36026,10 @@ async function runOnce(config) {
35626
36026
  leaseId,
35627
36027
  leaseSeconds: config.leaseSeconds
35628
36028
  });
35629
- const commands = Array.isArray(polled.commands) ? polled.commands : [];
36029
+ const commands = locallyAdmittedCommands(
36030
+ config,
36031
+ Array.isArray(polled.commands) ? polled.commands : []
36032
+ );
35630
36033
  await Promise.all(commands.map((command) => processCommand(config, command)));
35631
36034
  return commands.length;
35632
36035
  }
@@ -35659,10 +36062,19 @@ async function dispatchAvailableCommands(config, options = {}) {
35659
36062
  leaseId,
35660
36063
  leaseSeconds: config.leaseSeconds
35661
36064
  });
35662
- const commands = Array.isArray(polled.commands) ? polled.commands : [];
36065
+ const commands = locallyAdmittedCommands(
36066
+ config,
36067
+ Array.isArray(polled.commands) ? polled.commands : []
36068
+ );
35663
36069
  for (const command of commands) {
35664
36070
  const commandId = readString(command.commandId) ?? readString(command.id);
35665
- if (commandId) localDispatchCommandIds.add(commandId);
36071
+ if (commandId) {
36072
+ localDispatchCommands.set(commandId, {
36073
+ commandId,
36074
+ executionLane: normalizeRuntimeExecutionLane(command.executionLane),
36075
+ phase: "preparing"
36076
+ });
36077
+ }
35666
36078
  void processCommand(config, command).catch((err) => {
35667
36079
  const idForLog = commandId ?? "unknown";
35668
36080
  const message = err instanceof Error ? err.stack || err.message : String(err);
@@ -35670,7 +36082,7 @@ async function dispatchAvailableCommands(config, options = {}) {
35670
36082
  ${message}
35671
36083
  `);
35672
36084
  }).finally(() => {
35673
- if (commandId) localDispatchCommandIds.delete(commandId);
36085
+ if (commandId) localDispatchCommands.delete(commandId);
35674
36086
  });
35675
36087
  }
35676
36088
  return commands.length;
@@ -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.224";
10
+ const CONNECTOR_VERSION = "0.1.1-beta.226";
11
11
 
12
12
  const CONFIG_KEY_MAP = new Map([
13
13
  ["server_url", "AMASTER_EMPLOYEE_SERVER_URL"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.224",
3
+ "version": "0.1.1-beta.226",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",