@amaster.ai/employee-runtime-connector 0.1.1-beta.231 → 0.1.1-beta.233

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
@@ -18,6 +18,25 @@ npm install --omit=dev --prefix /opt/pi-cli-runtime @amaster.ai/employee-runtime
18
18
 
19
19
  Do not use `latest`, `^`, or `~` in a runtime image. The image tag and connector package version should identify one immutable deployment.
20
20
 
21
+ ## Incremental type safety
22
+
23
+ `pnpm typecheck` runs the legacy entry-point syntax checks plus TypeScript strict
24
+ `checkJs` over `src/amaster-runtime-daemon/typed/**/*.mjs` and compile-time contract
25
+ tests in `type-tests/`. The first migrated boundary is the run-completion phase and
26
+ event transition table. It is imported by the existing completion-state module and
27
+ bundled normally; package layout and runtime state version are unchanged.
28
+
29
+ The package declares its own TypeScript development dependency, using the same
30
+ compiler version locked by the workspace. Source-development installs need dev
31
+ dependencies for this gate; it must not depend on the root workspace exposing
32
+ `tsc` on PATH. Published runtime consumers only need the distributed artifacts.
33
+
34
+ Put newly extracted independent daemon logic in the typed lane with explicit
35
+ inputs/outputs. New files in that directory are included automatically. Do not add
36
+ `any` or disable checking to make the gate pass. Keep untrusted I/O validation at
37
+ the boundary. `check:syntax` is only a parser check; this incremental gate does not
38
+ claim that the existing CLI/daemon or all legacy helpers are fully type-checked.
39
+
21
40
  Immutable images should pin an exact package version as their baseline. The current connector does not download or replace runtime code while running; package upgrades and rollbacks belong to the image build and rollout.
22
41
 
23
42
  The governed MCP cache identity follows the installed `pi-mcp-adapter` version.
@@ -5377,6 +5377,44 @@ var ERROR_PRESENTATIONS = {
5377
5377
  };
5378
5378
  var AMASTER_RUNTIME_USER_PRESENTATION_ERROR_CODES = Object.freeze(Object.keys(ERROR_PRESENTATIONS).sort());
5379
5379
 
5380
+ // ../shared/src/mirrorx-prerequisite-validators.ts
5381
+ var taskPrerequisiteCheckSchema = external_exports.object({
5382
+ id: external_exports.string().uuid(),
5383
+ revision: external_exports.number().int().positive(),
5384
+ validatorId: external_exports.literal("accepted_product_specification_v1"),
5385
+ input: external_exports.object({ delivery: external_exports.discriminatedUnion("kind", [
5386
+ external_exports.object({ kind: external_exports.literal("missing") }).strict(),
5387
+ external_exports.object({ kind: external_exports.literal("accepted_prerequisite"), bindingId: external_exports.string().uuid(), acceptanceId: external_exports.string().uuid() }).strict()
5388
+ ]) }).strict()
5389
+ }).strict();
5390
+ var taskPrerequisiteChecksSchema = external_exports.array(taskPrerequisiteCheckSchema).max(20).superRefine((checks, ctx) => {
5391
+ if (new Set(checks.map((check) => check.id)).size !== checks.length || new Set(checks.map((check) => check.validatorId)).size !== checks.length) {
5392
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Prerequisite checks must have unique identities and validators" });
5393
+ }
5394
+ });
5395
+ var prerequisiteValidationReceiptSchema = external_exports.object({
5396
+ schemaVersion: external_exports.literal("prerequisite-validation-v1"),
5397
+ id: external_exports.string().uuid(),
5398
+ companyId: external_exports.string().uuid(),
5399
+ targetIssueId: external_exports.string().uuid(),
5400
+ targetExecutionEpoch: external_exports.number().int().positive(),
5401
+ checkId: external_exports.string().uuid(),
5402
+ checkRevision: external_exports.number().int().positive(),
5403
+ validatorId: external_exports.literal("accepted_product_specification_v1"),
5404
+ validatorRevision: external_exports.literal("1"),
5405
+ inputHash: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/),
5406
+ result: external_exports.enum(["missing", "satisfied"]),
5407
+ reasonCode: external_exports.enum(["product_specification_receipt_missing", "product_specification_receipt_accepted"]),
5408
+ deliveryBindingId: external_exports.string().uuid().nullable(),
5409
+ acceptanceId: external_exports.string().uuid().nullable(),
5410
+ validatedAt: external_exports.string().datetime({ offset: true })
5411
+ }).strict().superRefine((receipt, ctx) => {
5412
+ const satisfied = receipt.result === "satisfied";
5413
+ if (satisfied !== (receipt.reasonCode === "product_specification_receipt_accepted") || satisfied !== (receipt.deliveryBindingId !== null) || satisfied !== (receipt.acceptanceId !== null)) {
5414
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Prerequisite validation result and accepted receipt disagree" });
5415
+ }
5416
+ });
5417
+
5380
5418
  // ../shared/src/mirrorx-prerequisite-requirements.ts
5381
5419
  var taskPrerequisiteSlotSchema = external_exports.object({
5382
5420
  id: external_exports.string().uuid(),
@@ -6665,6 +6703,7 @@ var issueDeliveryRequirementV2Schema = external_exports.object({
6665
6703
  var issueTaskRequirementsV2Schema = external_exports.object({
6666
6704
  requirementsVersion: external_exports.literal("v2"),
6667
6705
  prerequisiteSlots: taskPrerequisiteSlotsSchema.optional(),
6706
+ prerequisiteChecks: taskPrerequisiteChecksSchema.optional(),
6668
6707
  taskIntent: taskIntentRequirementSchema,
6669
6708
  executionShape: external_exports.enum(TASK_EXECUTION_SHAPES),
6670
6709
  completionStrategy: external_exports.enum(TASK_COMPLETION_STRATEGIES).nullable(),
@@ -9867,6 +9906,7 @@ function withCreateIssueStatusDefault(schema) {
9867
9906
  }
9868
9907
  var createIssueBaseSchema = external_exports.object({
9869
9908
  prerequisiteSlots: taskPrerequisiteSlotsSchema.optional(),
9909
+ prerequisiteChecks: taskPrerequisiteChecksSchema.optional(),
9870
9910
  creationProfile: external_exports.literal(MIRRORX_AGENT_SESSION_CREATION_PROFILE).optional(),
9871
9911
  projectId: external_exports.string().uuid().optional().nullable(),
9872
9912
  projectWorkspaceId: external_exports.string().uuid().optional().nullable(),
@@ -9953,7 +9993,7 @@ var createIssueSchema = withCreateIssueStatusDefault(external_exports.union([
9953
9993
  ordinaryCreateIssueSchema
9954
9994
  ]));
9955
9995
  var createModelIssueSchema = createIssueSchema.superRefine((value, ctx) => {
9956
- if (value.prerequisiteSlots !== void 0) {
9996
+ if (value.prerequisiteSlots !== void 0 || value.prerequisiteChecks !== void 0) {
9957
9997
  ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["prerequisiteSlots"], message: "Model creation cannot declare cross-Issue prerequisite authority" });
9958
9998
  }
9959
9999
  const systemWatchdogFollowUp = value.watchdogDiscovery?.kind === "product_bug";
@@ -9982,6 +10022,7 @@ var createChildIssueSchema = withCreateIssueStatusDefault(createIssueBaseSchema.
9982
10022
  }).extend({
9983
10023
  creationProfile: external_exports.never().optional(),
9984
10024
  prerequisiteSlots: external_exports.never().optional(),
10025
+ prerequisiteChecks: external_exports.never().optional(),
9985
10026
  delegation: issueDelegationInputSchema,
9986
10027
  acceptanceCriteria: external_exports.array(external_exports.string().trim().min(1).max(500)).max(20).optional(),
9987
10028
  blockParentUntilDone: external_exports.boolean().optional().default(false),
@@ -10008,6 +10049,7 @@ var updateIssueSchema = createIssueBaseSchema.omit({
10008
10049
  }).partial().extend({
10009
10050
  creationProfile: external_exports.never().optional(),
10010
10051
  prerequisiteSlots: external_exports.never().optional(),
10052
+ prerequisiteChecks: external_exports.never().optional(),
10011
10053
  taskIntent: external_exports.enum(["business", "system", "legacy"]).optional(),
10012
10054
  requestDepth: issueRequestDepthInputSchema.optional(),
10013
10055
  assigneeAgentId: external_exports.string().trim().min(1).optional().nullable(),
@@ -12281,6 +12323,8 @@ var BUSINESS_TASK_ENROLLMENT_READ_STATES = [
12281
12323
  var BUSINESS_TASK_ENROLLMENT_WAKE_STATUSES = [
12282
12324
  "pending",
12283
12325
  "waiting_dependency",
12326
+ "waiting_prerequisite",
12327
+ "transferred_prerequisite",
12284
12328
  "leased",
12285
12329
  "delivered",
12286
12330
  "cancelled",
@@ -12404,6 +12448,8 @@ var governedBusinessTaskEnrollmentSchema = external_exports.object({
12404
12448
  }).strict();
12405
12449
  var governedBusinessTaskWakeDispatchSchema = external_exports.object({
12406
12450
  outboxId: external_exports.string().uuid(),
12451
+ prerequisiteAssignmentReceiptId: external_exports.string().uuid().nullable(),
12452
+ prerequisiteReleaseBindingId: external_exports.string().uuid().nullable(),
12407
12453
  enrollmentId: external_exports.string().uuid(),
12408
12454
  executionEpoch: external_exports.number().int().positive(),
12409
12455
  agentId: external_exports.string().uuid(),
@@ -15985,6 +16031,16 @@ var listPluginStateSchema = external_exports.object({
15985
16031
  namespace: external_exports.string().min(1).optional()
15986
16032
  });
15987
16033
 
16034
+ // ../shared/src/validators/company-execution-control.ts
16035
+ var companyExecutionControlSchema = external_exports.object({
16036
+ action: external_exports.enum(["pause", "resume"]),
16037
+ confirmed: external_exports.literal(true)
16038
+ }).strict();
16039
+ var companyExecutionControlStatusSchema = external_exports.object({
16040
+ companyId: external_exports.string().uuid(),
16041
+ state: external_exports.enum(["running", "pausing", "paused", "resuming", "unavailable"])
16042
+ });
16043
+
15988
16044
  // ../shared/src/api.ts
15989
16045
  var API_PREFIX = "/api";
15990
16046
  var API = {
@@ -20713,14 +20769,18 @@ function createManagedPiMcpProfileApi(options = {}) {
20713
20769
  "mirrorx.read_issue_evidence",
20714
20770
  "mirrorx.read_governed_business_state"
20715
20771
  ]);
20716
- const FULL_DIRECT_TYPED_V1_WIKI_TOOL_NAMES = /* @__PURE__ */ new Set([
20772
+ const FULL_DIRECT_TYPED_V1_WIKI_READ_TOOL_NAMES = /* @__PURE__ */ new Set([
20717
20773
  "wiki_list",
20718
20774
  "wiki_search",
20719
20775
  "wiki_read",
20720
- "wiki_write",
20721
20776
  "wiki_list_versions",
20722
20777
  "wiki_diff_versions"
20723
20778
  ]);
20779
+ const FULL_DIRECT_TYPED_V1_WIKI_WRITE_TOOL_NAME = "wiki_write";
20780
+ const FULL_DIRECT_TYPED_V1_WIKI_TOOL_NAMES = /* @__PURE__ */ new Set([
20781
+ ...FULL_DIRECT_TYPED_V1_WIKI_READ_TOOL_NAMES,
20782
+ FULL_DIRECT_TYPED_V1_WIKI_WRITE_TOOL_NAME
20783
+ ]);
20724
20784
  const FULL_DIRECT_TYPED_V1_CONNECTOR_TOOL_NAMES = /* @__PURE__ */ new Set([
20725
20785
  "connector.search_actions",
20726
20786
  "connector.get_action_guide",
@@ -21311,9 +21371,11 @@ function createManagedPiMcpProfileApi(options = {}) {
21311
21371
  const declaredToolNames = new Set(tools.map((tool) => tool.name).filter((name) => typeof name === "string"));
21312
21372
  const covers = (set) => [...set].every((name) => declaredToolNames.has(name));
21313
21373
  const countIn = (set) => tools.filter((tool) => set.has(tool.name)).length;
21314
- const fullWikiCount = countIn(FULL_DIRECT_TYPED_V1_WIKI_TOOL_NAMES);
21374
+ const fullWikiReadCount = countIn(FULL_DIRECT_TYPED_V1_WIKI_READ_TOOL_NAMES);
21375
+ const hasWikiWrite = declaredToolNames.has(FULL_DIRECT_TYPED_V1_WIKI_WRITE_TOOL_NAME);
21376
+ const fullWikiCount = fullWikiReadCount + (hasWikiWrite ? 1 : 0);
21315
21377
  const fullConnectorCount = countIn(FULL_DIRECT_TYPED_V1_CONNECTOR_TOOL_NAMES);
21316
- const fullCatalog = mcpToolMode === MANAGED_PI_DIRECT_TYPED_MCP_TOOL_MODE && tools.length === FULL_DIRECT_TYPED_V1_BASE_TOOL_NAMES.size + fullWikiCount + fullConnectorCount && covers(FULL_DIRECT_TYPED_V1_BASE_TOOL_NAMES) && (fullWikiCount === 0 || fullWikiCount === FULL_DIRECT_TYPED_V1_WIKI_TOOL_NAMES.size) && (fullConnectorCount === 0 || fullConnectorCount === FULL_DIRECT_TYPED_V1_CONNECTOR_TOOL_NAMES.size) && tools.every((tool) => FULL_DIRECT_TYPED_V1_TOOL_NAMES.has(tool.name));
21378
+ const fullCatalog = mcpToolMode === MANAGED_PI_DIRECT_TYPED_MCP_TOOL_MODE && tools.length === FULL_DIRECT_TYPED_V1_BASE_TOOL_NAMES.size + fullWikiCount + fullConnectorCount && covers(FULL_DIRECT_TYPED_V1_BASE_TOOL_NAMES) && (fullWikiReadCount === 0 && !hasWikiWrite || fullWikiReadCount === FULL_DIRECT_TYPED_V1_WIKI_READ_TOOL_NAMES.size) && (fullConnectorCount === 0 || fullConnectorCount === FULL_DIRECT_TYPED_V1_CONNECTOR_TOOL_NAMES.size) && tools.every((tool) => FULL_DIRECT_TYPED_V1_TOOL_NAMES.has(tool.name));
21317
21379
  if (mcpToolMode === MANAGED_PI_DIRECT_TYPED_MCP_TOOL_MODE && !fullCatalog) {
21318
21380
  throw new Error("pi_managed_mcp_invalid: direct tool catalog size mismatch");
21319
21381
  }
@@ -23491,8 +23553,8 @@ function isTerminalResultOutboxStatus(status) {
23491
23553
  // src/amaster-runtime-daemon/run-completion-state.mjs
23492
23554
  import { existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync10, readdirSync as readdirSync5, renameSync as renameSync5, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
23493
23555
  import { join as join8 } from "node:path";
23494
- var RUN_COMPLETION_STATE_VERSION = 1;
23495
- var RUN_COMPLETION_USAGE_SCHEMA_VERSION = "runtime-command-usage-v1";
23556
+
23557
+ // src/amaster-runtime-daemon/typed/run-completion-transitions.mjs
23496
23558
  var RUN_COMPLETION_PHASES = /* @__PURE__ */ new Set([
23497
23559
  "executing",
23498
23560
  "usage_snapshot_persisted",
@@ -23532,6 +23594,16 @@ var PHASE_TRANSITIONS = /* @__PURE__ */ new Map([
23532
23594
  ["profile_cleanup:profile_cleanup_abandoned", "result_post_pending"],
23533
23595
  ["result_post_pending:result_post_delivered", "terminal"]
23534
23596
  ]);
23597
+ function isRunCompletionPhase(value) {
23598
+ return typeof value === "string" && RUN_COMPLETION_PHASES.has(value);
23599
+ }
23600
+ function nextRunCompletionPhase(phase, event) {
23601
+ return PHASE_TRANSITIONS.get(`${phase}:${event}`);
23602
+ }
23603
+
23604
+ // src/amaster-runtime-daemon/run-completion-state.mjs
23605
+ var RUN_COMPLETION_STATE_VERSION = 1;
23606
+ var RUN_COMPLETION_USAGE_SCHEMA_VERSION = "runtime-command-usage-v1";
23535
23607
  function record4(value) {
23536
23608
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
23537
23609
  }
@@ -23662,7 +23734,7 @@ function appendRunCompletionUsageTurn(state, input) {
23662
23734
  }
23663
23735
  function transitionRunCompletionState(state, event, patch = {}, now = (/* @__PURE__ */ new Date()).toISOString()) {
23664
23736
  const current = assertValidRunCompletionState(state);
23665
- const nextPhase = PHASE_TRANSITIONS.get(`${current.phase}:${event}`);
23737
+ const nextPhase = nextRunCompletionPhase(current.phase, event);
23666
23738
  if (!nextPhase) {
23667
23739
  throw new Error(`run_completion_state_transition_invalid:${current.phase}:${event}`);
23668
23740
  }
@@ -23690,7 +23762,7 @@ function assertValidRunCompletionState(value) {
23690
23762
  if (state.version !== RUN_COMPLETION_STATE_VERSION) throw new Error("run_completion_state_invalid:version");
23691
23763
  const commandId = nonEmptyString(state.commandId, "commandId");
23692
23764
  const connectorId = nonEmptyString(state.connectorId, "connectorId");
23693
- if (!RUN_COMPLETION_PHASES.has(state.phase)) throw new Error("run_completion_state_invalid:phase");
23765
+ if (!isRunCompletionPhase(state.phase)) throw new Error("run_completion_state_invalid:phase");
23694
23766
  const command = record4(state.command);
23695
23767
  if (nonEmptyString(command.commandId ?? command.id, "command.commandId") !== commandId) {
23696
23768
  throw new Error("run_completion_state_invalid:command_binding");
@@ -30303,7 +30375,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
30303
30375
  }
30304
30376
 
30305
30377
  // src/amaster-runtime-daemon.mjs
30306
- var CONNECTOR_VERSION = "0.1.1-beta.231";
30378
+ var CONNECTOR_VERSION = "0.1.1-beta.233";
30307
30379
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
30308
30380
  var daemonRequire = createRequire(import.meta.url);
30309
30381
  var MAX_CHECKPOINT_BYTES = 20 * 1024 * 1024;
@@ -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.231";
10
+ const CONNECTOR_VERSION = "0.1.1-beta.233";
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.231",
3
+ "version": "0.1.1-beta.233",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,8 @@
17
17
  "clean": "node scripts/clean.mjs",
18
18
  "phase0b:live": "node probes/runtime-v2-phase0b/live-probe.mjs",
19
19
  "phase0b:test": "node --test probes/runtime-v2-phase0b/*.test.mjs",
20
- "typecheck": "node --check scripts/build.mjs && node --check scripts/bundle.mjs && node --check src/amaster-runtime.mjs && node --check src/amaster-runtime-daemon.mjs",
20
+ "check:syntax": "node --check scripts/build.mjs && node --check scripts/bundle.mjs && node --check src/amaster-runtime.mjs && node --check src/amaster-runtime-daemon.mjs",
21
+ "typecheck": "pnpm run check:syntax && tsc --project tsconfig.json",
21
22
  "test": "pnpm run build && node --test test/*.test.mjs src/amaster-runtime-daemon/*.test.mjs",
22
23
  "prepack": "pnpm run test"
23
24
  },
@@ -30,7 +31,8 @@
30
31
  "devDependencies": {
31
32
  "@paperclipai/shared": "workspace:*",
32
33
  "esbuild": "^0.27.3",
33
- "smol-toml": "1.7.0"
34
+ "smol-toml": "1.7.0",
35
+ "typescript": "^5.7.3"
34
36
  },
35
37
  "dependencies": {
36
38
  "playwright-core": "^1.58.2"