@amaster.ai/employee-runtime-connector 0.1.1-beta.23 → 0.1.1-beta.230

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.
Files changed (36) hide show
  1. package/README.md +48 -5
  2. package/dist/amaster-runtime-daemon/capability-registry.mjs +91 -0
  3. package/dist/amaster-runtime-daemon.mjs +25517 -4788
  4. package/dist/amaster-runtime.mjs +15 -21
  5. package/dist/templates/.mirrorx-preset-templates.json +155 -0
  6. package/dist/templates/CEO/347/273/217/350/220/245/347/256/200/346/212/245/346/250/241/346/235/277.md +87 -0
  7. package/dist/templates//344/272/247/345/223/201/347/274/272/351/231/267/346/270/205/345/215/225/346/250/241/346/235/277.md +83 -0
  8. package/dist/templates//344/274/201/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277V0.1 /345/211/257/346/234/254.md" +470 -0
  9. package/dist/templates//344/275/216/347/251/272/347/273/217/346/265/216/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +470 -0
  10. package/dist/templates//345/205/203/345/256/207/345/256/231/344/270/216/346/225/260/345/255/227/345/206/205/345/256/271/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +306 -0
  11. package/dist/templates//345/205/254/345/217/270/346/263/225/345/212/241/346/262/273/347/220/206/344/270/216/351/243/216/351/231/251/350/247/204/345/210/222/346/250/241/346/235/277.md +431 -0
  12. package/dist/templates//345/206/205/351/203/250/344/275/277/347/224/250/346/212/245/345/221/212/346/250/241/346/235/277.md +141 -0
  13. package/dist/templates//345/206/234/344/270/232/344/270/216/351/243/237/345/223/201/346/267/261/345/212/240/345/267/245/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +466 -0
  14. package/dist/templates//345/214/273/347/226/227/345/201/245/345/272/267/344/270/216/347/224/237/345/221/275/347/247/221/345/255/246/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +474 -0
  15. package/dist/templates//345/220/210/346/210/220/347/224/237/347/211/251/345/255/246/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +298 -0
  16. package/dist/templates//345/225/206/344/270/232/350/210/252/345/244/251/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +389 -0
  17. package/dist/templates//345/270/202/345/234/272/345/210/206/346/236/220/344/270/216/347/253/236/345/257/271/350/260/203/347/240/224/346/250/241/346/235/277.md +398 -0
  18. package/dist/templates//345/272/224/344/273/230/350/264/246/346/254/276/350/264/246/351/276/204/345/210/206/346/236/220/350/241/250/346/250/241/346/235/277.xlsx +0 -0
  19. package/dist/templates//345/272/224/346/224/266/350/264/246/346/254/276/350/264/246/351/276/204/345/210/206/346/236/220/350/241/250/346/250/241/346/235/277.xlsx +0 -0
  20. package/dist/templates//345/273/272/347/255/221/344/270/216/346/210/277/345/234/260/344/272/247/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +458 -0
  21. package/dist/templates//346/226/207/346/227/205/344/270/216/346/226/207/344/275/223/346/225/231/350/202/262/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +464 -0
  22. package/dist/templates//346/234/210/345/272/246/347/250/216/345/212/241/347/224/263/346/212/245/345/207/206/345/244/207/346/270/205/345/215/225/346/250/241/346/235/277.xlsx +0 -0
  23. package/dist/templates//346/234/210/345/272/246/347/273/223/350/264/246/346/270/205/345/215/225/346/250/241/346/235/277.xlsx +0 -0
  24. package/dist/templates//346/257/217/345/221/250/347/216/260/351/207/221/345/277/253/347/205/247/346/250/241/346/235/277.xlsx +0 -0
  25. package/dist/templates//346/263/225/345/256/232/350/264/242/345/212/241/346/212/245/350/241/250/346/250/241/346/235/277.xlsx +0 -0
  26. package/dist/templates//346/266/210/350/264/271/344/270/216/351/233/266/345/224/256/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +456 -0
  27. package/dist/templates//347/211/251/346/265/201/344/270/216/344/276/233/345/272/224/351/223/276/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +452 -0
  28. package/dist/templates//347/247/221/346/212/200/344/270/216/344/272/222/350/201/224/347/275/221/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +432 -0
  29. package/dist/templates//347/247/221/347/233/256/344/275/231/351/242/235/350/241/250/344/270/216/350/257/225/347/256/227/345/271/263/350/241/241/346/250/241/346/235/277.xlsx +0 -0
  30. package/dist/templates//350/203/275/346/272/220/344/270/216/347/216/257/344/277/235/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +446 -0
  31. package/dist/templates//351/207/221/350/236/215/344/270/216/344/270/223/344/270/232/346/234/215/345/212/241/350/241/214/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +436 -0
  32. package/dist/templates//351/223/266/350/241/214/345/255/230/346/254/276/344/275/231/351/242/235/350/260/203/350/212/202/350/241/250/346/250/241/346/235/277.xlsx +0 -0
  33. package/dist/templates//351/227/255/347/216/257/346/265/201/347/250/213/350/257/264/346/230/216/344/270/216/345/256/241/350/256/241/350/257/201/346/215/256/346/240/267/344/276/213/346/250/241/346/235/277.md +125 -0
  34. package/dist/templates//351/242/204/347/256/227/344/270/216/345/256/236/351/231/205/345/267/256/345/274/202/345/210/206/346/236/220/346/250/241/346/235/277.xlsx +0 -0
  35. package/dist/templates//351/253/230/347/253/257/344/270/216/345/205/210/350/277/233/345/210/266/351/200/240/344/270/232/346/210/230/347/225/245/350/247/204/345/210/222/346/250/241/346/235/277.md +466 -0
  36. package/package.json +5 -2
package/README.md CHANGED
@@ -12,8 +12,7 @@ For production images, install an exact version and invoke the package bin:
12
12
 
13
13
  ```sh
14
14
  npm install --omit=dev --prefix /opt/pi-cli-runtime @amaster.ai/employee-runtime-connector@0.1.0
15
- /opt/pi-cli-runtime/node_modules/.bin/amaster-runtime setup https://employee.example.com \
16
- --capabilities remote_registration,heartbeat,executor_discovery,workspace_binding,run_wakeup,model_call,model_call_output_contract_v1,run_cancel,run_terminate,logs_cost_workspace_status
15
+ /opt/pi-cli-runtime/node_modules/.bin/amaster-runtime setup https://employee.example.com
17
16
  /opt/pi-cli-runtime/node_modules/.bin/amaster-runtime daemon start --foreground
18
17
  ```
19
18
 
@@ -21,17 +20,56 @@ Do not use `latest`, `^`, or `~` in a runtime image. The image tag and connector
21
20
 
22
21
  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.
23
22
 
24
- 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 package path is unchanged between them. This path-only comparison is valid because the published connector is self-contained; if runtime code starts importing workspace source outside this package, 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.
23
+ The governed MCP cache identity follows the installed `pi-mcp-adapter` version.
24
+ Adapter 2.26+ includes `requestHeadersCommand` even when it is unset; older
25
+ versions must retain their previous identity. Upgrade the connector together
26
+ with the adapter and verify the actual version pair using the Pi MCP contract
27
+ tests. A cache identity mismatch can reject all governed tools before execution;
28
+ deleting user configuration, credentials, sessions, or connector state cannot
29
+ repair this mismatch. Each run generates its own governed cache.
30
+
31
+ Connector capability declaration is automatic. The exact package build declares
32
+ what it implements, and runtime readiness removes dynamic capabilities when their
33
+ executor or supporting runtime is unavailable. Operators restrict what the Server
34
+ accepts with `AMASTER_RUNTIME_CONNECTOR_CAPABILITY_ALLOWLIST`; users do not need to
35
+ configure a connector-local capability list. Historical `AMASTER_CAPABILITIES` and
36
+ `--capabilities` inputs remain accepted for rollback compatibility in this release,
37
+ but are ignored and reported as deprecated. They cannot add, remove, or authorize a
38
+ capability.
39
+
40
+ `browser_credential_ref_fill_v1` is a narrow private command capability. It can
41
+ consume only a Server-issued credential ref for the exact command and writes the
42
+ resolved value to a dedicated inherited file descriptor; it does not expose the
43
+ value through prompt, argv, environment, workspace, logs, or result JSON. Normal
44
+ navigation, snapshots, form submission, waits, and challenges remain ordinary Pi
45
+ browser/task behavior.
46
+
47
+ 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 package path is unchanged between them. 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.
25
48
 
26
49
  ## Package Contents
27
50
 
51
+ ## Pi plugin ownership boundary
52
+
53
+ `pi-cli-runtime` owns Pi plugin installation, versions, package resolution, and configuration. The connector must only start Pi, deliver a command, manage its process lifecycle, and return its result. Do not add Pi-plugin package/version/digest/schema/config checks to connector registration, heartbeat, capability advertisement, or command dispatch. A plugin failure is task execution evidence, not a connector admission decision.
54
+
28
55
  - `dist/amaster-runtime.mjs`: configuration, pairing, workspace, diagnostics, and daemon lifecycle CLI.
29
56
  - `dist/amaster-runtime-daemon.mjs`: standalone daemon bundle for connector registration, heartbeat, command execution, and result ingestion.
30
-
31
57
  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/`.
32
58
 
33
59
  Runtime code belongs in the container image. Persist only connector state, the result outbox, and workspaces under the configured state directory.
34
60
 
61
+ ## Enabled context-governance admission
62
+
63
+ The Server requires `final_model_context_attestation_v1` for governed Pi runs because that path disables ambient context discovery and injects a run-owned compiled instruction bundle. This is a Pi delivery contract, not a connector-wide requirement: an explicitly selected self-hosted Codex runtime continues through its own Runtime Actions V2 and native-session contracts and cannot borrow the Pi attestation claim. Adding the same final-context guarantee to another executor requires executor-specific proof for scoped project-instruction semantics, the normalized final active tool schemas, the selected model's context window, automatically visible skill metadata, and resumed-session history.
64
+
65
+ For Server-dispatched Codex `run` and `wakeup` commands, the effective model comes from the command's `mirrorxRuntimeConnectorTaskSessionV1.configuredModel` snapshot and is passed to Codex with `--model`. `AMASTER_CODEX_MODEL` is only a compatibility fallback for older commands that do not contain that snapshot; it does not override a Server-issued model or an explicit Server-issued `null` model. A malformed or identity-mismatched snapshot fails closed with `codex_model_authority_invalid`. Its non-empty `taskKey` is an opaque Server task-session identity and is not required to equal the Issue id; the current adapter binding intentionally accepts only `codex_local`.
66
+
67
+ For admitted Pi runs, the daemon compiles source-repository `AGENTS.md` and `AGENTS.override.md` topology into one root `AGENTS.md` with explicit relative scopes, same-scope override semantics, and a higher-authority MirrorX platform block. Governed Pi preserves operator-configured user extensions and tools, disables ambient skill and context-file discovery, and injects that exact compiled file through a run-owned final-system-prompt extension. `pi-mcp-adapter` normally merges the operator's user-level `mcp.json` with the run-owned workspace `.pi/mcp.json`; the workspace definition wins on a same-name server, and only environment placeholders referenced by preserved user MCP definitions are granted to the child. Governed MCP tools remain fail-closed: the daemon requires their exact catalog and schemas while accepting additional Pi-native or user-extension tools, including the adapter proxy when a user MCP needs it. Run-exit closure applies the same rule to its two required MirrorX tools as a schema-bound subset instead of rejecting the ambient user tool surface. When the operator-owned Pi settings declare `@amaster.ai/pi-telemetry`, the daemon verifies that package's immutable identity and preserves the authoritative runtime run id for trace correlation while Pi loads it normally from the shared settings. A last-ordered `before_provider_request` hook then validates every provider call, including later calls after tool results: exactly one system message contains the compiled instructions, visible role-skill metadata and the attested active tool contract match their prior attestations, and the complete serialized input fits the context window. It does not override the active model's output limit or inject provider `max_tokens`, `max_completion_tokens`, or `max_output_tokens`; no `modelMaxOutputTokens` substitute exists. Each call appends metadata-only hashes and sizes to a bounded chained receipt; a missing, broken, or oversized chain fails the run.
68
+
69
+ Pi 0.80.10's internal compaction summarizer calls the provider outside `before_provider_request`. The Enabled profile therefore records and cancels every `session_before_compact` attempt and fails immediately if `session_compact` is nevertheless observed. No model-generated compaction summary is accepted until that provider path has equivalent final-context attestation. The Server also enumerates Pi and Codex as the only supported governed executors at configuration and heartbeat dispatch boundaries; missing or unknown executor kinds fail closed.
70
+
71
+ This is an intentional compatibility break for the not-yet-public context-governance contract. There is no historical command migration, dual-read, or fallback from a new Server-issued envelope to an unproved executor path.
72
+
35
73
  ## Contracted Pi model calls
36
74
 
37
75
  Pi `model_call` commands with `model_call_output_contract_v1` keep provider and
@@ -65,6 +103,11 @@ An enforced stop returns `pi_tool_argument_stream_amplification` with
65
103
  byte counts, ratios, event/tool identity, thresholds, and near-miss distances;
66
104
  it omits the inline argument body.
67
105
 
106
+ The same governed workspace-file action supports both modes: omit
107
+ `documentId`, `baseRevisionId`, and `issueId` for the current Issue's initial
108
+ document, or provide `documentId` and `baseRevisionId` together for an exact
109
+ CAS revision. Both modes use the same ownership manifest and byte-ingest path.
110
+
68
111
  Pi JSON mode can also repeat a cumulative `message` snapshot beside each
69
112
  incremental `message_update`. The daemon compacts only that redundant snapshot
70
113
  from its retained parse/result buffer while preserving the delta, terminal
@@ -81,7 +124,7 @@ Pi execution uses three separate evidence layers:
81
124
  2. a durable, inspectable Runtime Action receipt or finalized Runtime Artifact;
82
125
  3. process cleanup disposition.
83
126
 
84
- An exact process-kill `EPERM` error emitted only after the first two layers have completed may be isolated as a failed `cleanupDisposition` warning without changing the command's successful business result. Both accepted shapes require `kill` and `EPERM`; generic filesystem/process permission text such as `EPERM: operation not permitted, unlink ...` is a business error. Durable evidence is limited to a completed Runtime Action, a finalized Runtime Artifact, or an accepted `company_diagnosis_brief` provider receipt whose invocation and returned Diagnosis/document/work-product identities are exact. A `runtime_action.status` readback is evidence only when its call/plan ref matches an earlier submit/commit receipt in the same transcript. The diagnostic and durable evidence reference remain in the result. Text-only or action-only-without-assistant-output streams, standalone governed reads, non-effect Runtime Action tools, rejected or pending effects, pre-terminal errors, provider failures, timeout, cancellation, resource limits, any signal, live residue, and uncertain ownership remain failures.
127
+ An exact process-kill `EPERM` error emitted only after the first two layers have completed may be isolated as a failed `cleanupDisposition` warning without changing the command's successful business result. Both accepted shapes require `kill` and `EPERM`; generic filesystem/process permission text such as `EPERM: operation not permitted, unlink ...` is a business error. Durable evidence is limited to a completed Runtime Action or a finalized Runtime Artifact. A `runtime_action.status` readback is evidence only when its call/plan ref matches an earlier submit/commit receipt in the same transcript. The diagnostic and durable evidence reference remain in the result. Text-only or action-only-without-assistant-output streams, standalone governed reads, non-effect Runtime Action tools, rejected or pending effects, pre-terminal errors, provider failures, timeout, cancellation, resource limits, any signal, live residue, and uncertain ownership remain failures.
85
128
 
86
129
  This isolation does not schedule a retry or a second business continuation. Command result delivery and the result outbox remain the sole idempotency boundary.
87
130
 
@@ -0,0 +1,91 @@
1
+ export const BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
2
+ "remote_registration",
3
+ "heartbeat",
4
+ "executor_discovery",
5
+ "workspace_binding",
6
+ "run_wakeup",
7
+ "context_envelope_v1",
8
+ "managed_project_instructions_v1",
9
+ "artifact_template_catalog_v1",
10
+ "final_model_context_attestation_v1",
11
+ "runtime_actions_v2",
12
+ "continue_task_v1",
13
+ "run_exit_live_path_closure_v1",
14
+ "model_call",
15
+ "model_call_output_contract_v1",
16
+ "run_cancel",
17
+ "run_terminate",
18
+ "logs_cost_workspace_status",
19
+ "browser_credential_ref_fill_v1",
20
+ "execution_lanes_v1",
21
+ ]);
22
+
23
+ const DYNAMIC_READINESS = Object.freeze({
24
+ artifact_template_catalog_v1: {
25
+ reasonCode: "artifact_template_catalog_not_ready",
26
+ ready: (input) => {
27
+ const catalog = input.templateCatalog;
28
+ return catalog?.status === "ready"
29
+ && catalog.bundleAttested === true
30
+ && catalog.materialized === true
31
+ && catalog.readable === true
32
+ && catalog.executorReadable === true
33
+ && Number.isSafeInteger(catalog.fileCount)
34
+ && catalog.fileCount > 0
35
+ && typeof catalog.manifestSha256 === "string"
36
+ && /^[a-f0-9]{64}$/u.test(catalog.manifestSha256)
37
+ && typeof catalog.targetDir === "string"
38
+ && catalog.targetDir === input.runtimeTemplatesRoot;
39
+ },
40
+ },
41
+ final_model_context_attestation_v1: {
42
+ reasonCode: (input) => input.runnerKind === "desktop_delegated"
43
+ && input.executors.some((executor) => executor.kind === "pi")
44
+ ? input.piFinalContextAttestation?.reasonCode ?? "desktop_pi_attestation_runtime_not_ready"
45
+ : "attested_pi_executor_required",
46
+ ready: (input) => input.executors.some((executor) => executor.kind === "pi")
47
+ && (
48
+ input.runnerKind === "cloud_managed"
49
+ || (
50
+ input.runnerKind === "desktop_delegated"
51
+ && input.piFinalContextAttestation?.ready === true
52
+ )
53
+ ),
54
+ },
55
+ });
56
+
57
+ function uniqueStrings(values) {
58
+ return Array.from(new Set((Array.isArray(values) ? values : [])
59
+ .map((value) => String(value ?? "").trim())
60
+ .filter(Boolean)));
61
+ }
62
+
63
+ export function buildRuntimeCapabilityReport(input) {
64
+ const legacyConfiguredCapabilities = uniqueStrings(input.legacyConfiguredCapabilities);
65
+ const runtimeUnavailable = [];
66
+ const advertised = BUILD_SUPPORTED_CAPABILITIES.filter((capability) => {
67
+ const readiness = DYNAMIC_READINESS[capability];
68
+ if (!readiness || readiness.ready(input)) return true;
69
+ runtimeUnavailable.push({
70
+ capability,
71
+ reasonCode: typeof readiness.reasonCode === "function"
72
+ ? readiness.reasonCode(input)
73
+ : readiness.reasonCode,
74
+ });
75
+ return false;
76
+ });
77
+ const buildSet = new Set(BUILD_SUPPORTED_CAPABILITIES);
78
+ const legacySet = new Set(legacyConfiguredCapabilities);
79
+ return {
80
+ schemaVersion: "mirrorx.connector-capability-report/v1",
81
+ source: "build_attested",
82
+ buildSupported: [...BUILD_SUPPORTED_CAPABILITIES],
83
+ runtimeUnavailable,
84
+ advertised,
85
+ deprecatedCapabilityOverridePresent: legacyConfiguredCapabilities.length > 0,
86
+ legacyMissingFromBuildTruth: legacyConfiguredCapabilities.length > 0
87
+ ? BUILD_SUPPORTED_CAPABILITIES.filter((capability) => !legacySet.has(capability))
88
+ : [],
89
+ legacyUnsupportedClaims: legacyConfiguredCapabilities.filter((capability) => !buildSet.has(capability)),
90
+ };
91
+ }