@amaster.ai/employee-runtime-connector 0.1.1-beta.20 → 0.1.1-beta.22

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
@@ -13,7 +13,7 @@ For production images, install an exact version and invoke the package bin:
13
13
  ```sh
14
14
  npm install --omit=dev --prefix /opt/pi-cli-runtime @amaster.ai/employee-runtime-connector@0.1.0
15
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,run_cancel,run_terminate,logs_cost_workspace_status
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
17
17
  /opt/pi-cli-runtime/node_modules/.bin/amaster-runtime daemon start --foreground
18
18
  ```
19
19
 
@@ -2,7 +2,7 @@
2
2
  // MirrorX runtime connector daemon bundle.
3
3
 
4
4
  // src/amaster-runtime-daemon.mjs
5
- import { createHash as createHash13 } from "node:crypto";
5
+ import { createHash as createHash15 } from "node:crypto";
6
6
  import { chmodSync as chmodSync6, copyFileSync as copyFileSync3, existsSync as existsSync14, lstatSync as lstatSync7, mkdirSync as mkdirSync9, mkdtempSync, readFileSync as readFileSync11, readdirSync as readdirSync9, realpathSync as realpathSync5, renameSync as renameSync6, rmSync as rmSync7, statSync as statSync8, symlinkSync as symlinkSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync9 } from "node:fs";
7
7
  import { arch as arch3, homedir as homedir3, hostname as hostname2, platform as platform3, tmpdir } from "node:os";
8
8
  import { basename as basename6, delimiter as delimiter3, dirname as dirname9, extname as extname2, isAbsolute as isAbsolute8, join as join15, relative as relative9, resolve as resolve12 } from "node:path";
@@ -2005,6 +2005,43 @@ function syncAmasterProviderFiles(agentDir, executorEnv) {
2005
2005
  settingsSynced: syncAmasterProviderSettings(agentDir, executorEnv)
2006
2006
  };
2007
2007
  }
2008
+ function normalizePiModelId(modelId) {
2009
+ return readString(modelId)?.replace(/:(?:off|minimal|low|medium|high|xhigh|max)$/i, "") ?? null;
2010
+ }
2011
+ function applyModelCallOutputContract(agentDir, providerId, modelId, maxOutputTokens) {
2012
+ const provider = readString(providerId);
2013
+ const model = normalizePiModelId(modelId);
2014
+ const tokenLimit = Number(maxOutputTokens);
2015
+ if (!provider || !model || !Number.isSafeInteger(tokenLimit) || tokenLimit <= 0) {
2016
+ throw new Error("pi_model_call_output_contract_invalid");
2017
+ }
2018
+ const modelsPath = join3(agentDir, "models.json");
2019
+ const config = readJsonFile(modelsPath);
2020
+ const providers = asRecord(config.providers);
2021
+ const providerConfig = asRecord(providers[provider]);
2022
+ const configuredModels = Array.isArray(providerConfig.models) ? providerConfig.models : [];
2023
+ const configuredModelExists = configuredModels.some((entry) => readString(asRecord(entry).id) === model);
2024
+ const existingOverrides = asRecord(providerConfig.modelOverrides);
2025
+ if (!configuredModelExists && !(model in existingOverrides)) {
2026
+ throw new Error(`pi_model_call_model_missing: ${provider}/${model}`);
2027
+ }
2028
+ writeJsonFileAtomic(modelsPath, {
2029
+ ...config,
2030
+ providers: {
2031
+ ...providers,
2032
+ [provider]: {
2033
+ ...providerConfig,
2034
+ modelOverrides: {
2035
+ ...existingOverrides,
2036
+ [model]: {
2037
+ ...asRecord(existingOverrides[model]),
2038
+ maxTokens: tokenLimit
2039
+ }
2040
+ }
2041
+ }
2042
+ }
2043
+ });
2044
+ }
2008
2045
 
2009
2046
  // src/amaster-runtime-daemon/pi-mcp-args-normalizer.mjs
2010
2047
  function isJsonObject(value) {
@@ -2734,11 +2771,11 @@ function createManagedPiMcpProfileApi(options = {}) {
2734
2771
  if (!Number.isFinite(value)) throw new Error("pi_managed_mcp_attestation_failed: invalid attestation clock");
2735
2772
  return value;
2736
2773
  }
2737
- function sha256(value) {
2774
+ function sha2562(value) {
2738
2775
  return createHash3("sha256").update(value).digest("hex");
2739
2776
  }
2740
2777
  function adapterServerConfigHash(definition) {
2741
- return sha256(stablePiJson({
2778
+ return sha2562(stablePiJson({
2742
2779
  command: definition.command,
2743
2780
  args: definition.args,
2744
2781
  env: definition.env,
@@ -3278,17 +3315,17 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3278
3315
  if (receipt.status !== "attested" || receipt.mode !== "probe" || receipt.proxyMode !== input.proxyMode || receipt.proxyPresent !== expectedProxyPresent || receipt.effectiveSetHash !== input.effectiveSetHash || receipt.attestorSourceSha256 !== input.attestorSourceSha256 || receipt.configSha256 !== input.configSha256 || receipt.cacheSha256 !== input.cacheSha256) {
3279
3316
  throw new Error("pi_managed_mcp_effective_tools_failed: probe receipt mismatch");
3280
3317
  }
3281
- if (sha256(readFileSync3(input.configPath)) !== input.configSha256) {
3318
+ if (sha2562(readFileSync3(input.configPath)) !== input.configSha256) {
3282
3319
  throw new Error("pi_managed_mcp_effective_tools_failed: config drifted during probe");
3283
3320
  }
3284
- if (sha256(readFileSync3(input.cachePath)) !== input.cacheSha256) {
3321
+ if (sha2562(readFileSync3(input.cachePath)) !== input.cacheSha256) {
3285
3322
  throw new Error("pi_managed_mcp_effective_tools_failed: cache drifted during probe");
3286
3323
  }
3287
3324
  return {
3288
3325
  effectiveToolProxyMode: receipt.proxyMode,
3289
3326
  effectiveToolProxyPresent: receipt.proxyPresent,
3290
3327
  effectiveToolSetHash: receipt.effectiveSetHash,
3291
- effectiveToolProbeDigest: sha256(stablePiJson(receipt)),
3328
+ effectiveToolProbeDigest: sha2562(stablePiJson(receipt)),
3292
3329
  effectiveToolProbeAt: receipt.attestedAt,
3293
3330
  effectiveToolBindings: receipt.effectiveToolBindings
3294
3331
  };
@@ -3370,8 +3407,8 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3370
3407
  };
3371
3408
  writePrivateFile2(cachePath, `${JSON.stringify(cache, null, 2)}
3372
3409
  `);
3373
- const cacheSha256 = sha256(readFileSync3(cachePath));
3374
- const attestorSourceSha256 = sha256(managedPiEffectiveToolsAttestorExtensionSource());
3410
+ const cacheSha256 = sha2562(readFileSync3(cachePath));
3411
+ const attestorSourceSha256 = sha2562(managedPiEffectiveToolsAttestorExtensionSource());
3375
3412
  const manifestPath = join4(piCodingAgentDir, "effective-tools-manifest.json");
3376
3413
  const receiptPath = join4(tmp, "effective-tools-receipt.json");
3377
3414
  const manifest = {
@@ -3389,7 +3426,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3389
3426
  }))),
3390
3427
  proxyMode: mcpToolMode === MANAGED_PI_HYBRID_MCP_TOOL_MODE ? "required" : "forbidden",
3391
3428
  attestorSourceSha256,
3392
- configSha256: sha256(readFileSync3(configPath)),
3429
+ configSha256: sha2562(readFileSync3(configPath)),
3393
3430
  cacheSha256
3394
3431
  };
3395
3432
  writePrivateFile2(manifestPath, `${JSON.stringify(manifest, null, 2)}
@@ -3400,7 +3437,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3400
3437
  receiptPath,
3401
3438
  cacheSha256,
3402
3439
  configPath,
3403
- configSha256: sha256(readFileSync3(configPath)),
3440
+ configSha256: sha2562(readFileSync3(configPath)),
3404
3441
  attestorSourceSha256,
3405
3442
  effectiveSetHash: manifest.effectiveSetHash,
3406
3443
  proxyMode: manifest.proxyMode
@@ -3563,7 +3600,7 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
3563
3600
  sessionId: gateway.sessionId,
3564
3601
  sourcePiHome,
3565
3602
  piCodingAgentDir,
3566
- configSha256: sha256(readFileSync3(configPath))
3603
+ configSha256: sha2562(readFileSync3(configPath))
3567
3604
  };
3568
3605
  return {
3569
3606
  profileRoot,
@@ -4116,6 +4153,144 @@ function retainedSourceExecutorEntry(entry, executorKind) {
4116
4153
  };
4117
4154
  }
4118
4155
 
4156
+ // src/amaster-runtime-daemon/current-run-contract.mjs
4157
+ import { createHash as createHash4 } from "node:crypto";
4158
+ var CONTRACT_VERSION = "mirrorx.current-run-contract.v1";
4159
+ var REQUIRED_ACTIONS = [
4160
+ "amaster.read_issue_delivery",
4161
+ "amaster.read_issue",
4162
+ "amaster.read_issue_document",
4163
+ "publish_delivery_manifest"
4164
+ ];
4165
+ var FORBIDDEN_ACTIONS = [
4166
+ "upsert_document",
4167
+ "upsert_document_revision",
4168
+ "create_interaction:request_confirmation:review",
4169
+ "update_parent:done"
4170
+ ];
4171
+ var TERMINAL_DISPOSITION = "end_after_successful_manifest_publication";
4172
+ var OFFSET_DATETIME_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/u;
4173
+ function exactKeys(value, expected) {
4174
+ const keys = Object.keys(asRecord(value)).sort();
4175
+ const sortedExpected = [...expected].sort();
4176
+ return keys.length === sortedExpected.length && keys.every((key, index) => key === sortedExpected[index]);
4177
+ }
4178
+ function exactStringArray(value, expected) {
4179
+ return Array.isArray(value) && value.length === expected.length && value.every((entry, index) => entry === expected[index]);
4180
+ }
4181
+ function canonicalJson(value) {
4182
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
4183
+ if (value === void 0) return "null";
4184
+ if (!value || typeof value !== "object") return JSON.stringify(value) ?? "null";
4185
+ return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
4186
+ }
4187
+ function semanticHash(contract) {
4188
+ const { contractHash: _contractHash, compiledAt: _compiledAt, ...semantic } = contract;
4189
+ return `sha256:${createHash4("sha256").update(canonicalJson(semantic)).digest("hex")}`;
4190
+ }
4191
+ function validateBlockingGaps(value) {
4192
+ return Array.isArray(value) && value.length === 0;
4193
+ }
4194
+ function validateAuthorityRefs(value) {
4195
+ if (!Array.isArray(value) || value.length === 0 || value.length > 100) return false;
4196
+ if (value.some((ref) => typeof ref !== "string" || ref.trim().length === 0 || ref.length > 500)) {
4197
+ return false;
4198
+ }
4199
+ const canonical = [...new Set(value)].sort();
4200
+ return canonical.length === value.length && canonical.every((ref, index) => ref === value[index]);
4201
+ }
4202
+ function validateContract(value) {
4203
+ if (value === void 0 || value === null) return { kind: "missing" };
4204
+ const contract = asRecord(value);
4205
+ const authority = asRecord(contract.authority);
4206
+ const execution = asRecord(contract.execution);
4207
+ const errors = [];
4208
+ if (!exactKeys(contract, [
4209
+ "schemaVersion",
4210
+ "rolloutMode",
4211
+ "contractHash",
4212
+ "compiledAt",
4213
+ "authority",
4214
+ "execution"
4215
+ ])) errors.push("shape_invalid");
4216
+ if (contract.schemaVersion !== CONTRACT_VERSION) errors.push("schema_version_invalid");
4217
+ if (contract.rolloutMode !== "shadow") errors.push("rollout_mode_invalid");
4218
+ if (!/^sha256:[a-f0-9]{64}$/u.test(readString(contract.contractHash) ?? "")) errors.push("contract_hash_invalid");
4219
+ const compiledAt = readString(contract.compiledAt);
4220
+ if (!compiledAt || !OFFSET_DATETIME_PATTERN.test(compiledAt) || Number.isNaN(Date.parse(compiledAt))) {
4221
+ errors.push("compiled_at_invalid");
4222
+ }
4223
+ if (!exactKeys(authority, ["sourceRefs"]) || !validateAuthorityRefs(authority.sourceRefs)) {
4224
+ errors.push("authority_invalid");
4225
+ }
4226
+ if (!exactKeys(execution, [
4227
+ "mode",
4228
+ "requiredActions",
4229
+ "forbiddenActions",
4230
+ "terminalDisposition",
4231
+ "blockingGaps"
4232
+ ]) || execution.mode !== "manifest_refresh_only" || !exactStringArray(execution.requiredActions, REQUIRED_ACTIONS) || !exactStringArray(execution.forbiddenActions, FORBIDDEN_ACTIONS) || execution.terminalDisposition !== TERMINAL_DISPOSITION || !validateBlockingGaps(execution.blockingGaps)) {
4233
+ errors.push("execution_invalid");
4234
+ }
4235
+ if (errors.length === 0 && semanticHash(contract) !== contract.contractHash) {
4236
+ errors.push("contract_hash_mismatch");
4237
+ }
4238
+ return errors.length > 0 ? { kind: "invalid", errors: [...new Set(errors)] } : { kind: "valid", contract };
4239
+ }
4240
+ function legacyManifestRefreshOnly(context) {
4241
+ const readiness = asRecord(asRecord(context).paperclipDeliveryReadiness);
4242
+ const currentManifest = asRecord(readiness.currentManifest);
4243
+ const findings = (Array.isArray(readiness.findings) ? readiness.findings : []).map((entry) => asRecord(entry)).filter((entry) => readString(entry.code));
4244
+ const manifestRefs = [
4245
+ currentManifest.primaryRef,
4246
+ ...Array.isArray(currentManifest.supportingRefs) ? currentManifest.supportingRefs : []
4247
+ ].map((entry) => asRecord(entry));
4248
+ const documentRefIds = new Set(manifestRefs.filter((ref) => readString(ref.kind) === "document").map((ref) => readString(ref.refId)).filter(Boolean));
4249
+ return readString(readiness.mode) === "required" && Number.isInteger(currentManifest.revision) && readString(currentManifest.requirementRevision) === readString(readiness.requirementRevision) && findings.length > 0 && findings.every((entry) => readString(entry.code) === "deliverable_ref_stale" && documentRefIds.has(readString(entry.refId)));
4250
+ }
4251
+ function auditCurrentRunContractShadow(value, context) {
4252
+ const expected = legacyManifestRefreshOnly(context);
4253
+ const validation = validateContract(value);
4254
+ const base = {
4255
+ schemaVersion: "mirrorx.current-run-contract-shadow-audit.v1",
4256
+ expectedMode: expected ? "manifest_refresh_only" : "none"
4257
+ };
4258
+ if (validation.kind === "missing") {
4259
+ return {
4260
+ ...base,
4261
+ status: expected ? "missing" : "match",
4262
+ receivedMode: "none",
4263
+ contractHash: null,
4264
+ validationErrors: []
4265
+ };
4266
+ }
4267
+ if (validation.kind === "invalid") {
4268
+ return {
4269
+ ...base,
4270
+ status: "invalid",
4271
+ receivedMode: "invalid",
4272
+ contractHash: readString(asRecord(value).contractHash) ?? null,
4273
+ validationErrors: validation.errors
4274
+ };
4275
+ }
4276
+ return {
4277
+ ...base,
4278
+ status: expected ? "match" : "unexpected",
4279
+ receivedMode: "manifest_refresh_only",
4280
+ contractHash: validation.contract.contractHash,
4281
+ validationErrors: []
4282
+ };
4283
+ }
4284
+ function attachCurrentRunContractShadowAudit(compilation, value, context) {
4285
+ return {
4286
+ ...compilation,
4287
+ manifest: {
4288
+ ...asRecord(compilation).manifest,
4289
+ currentRunContractShadow: auditCurrentRunContractShadow(value, context)
4290
+ }
4291
+ };
4292
+ }
4293
+
4119
4294
  // src/amaster-runtime-daemon/task-context-policy.mjs
4120
4295
  var TASK_CONTEXT_MANIFEST_VERSION = "task-context-v1";
4121
4296
  function resolveTaskContextMemoryPolicy(context) {
@@ -4828,17 +5003,6 @@ Runtime Action continuation is unavailable: managed Pi MCP tool mode is not prox
4828
5003
  return `${heading}
4829
5004
  Runtime Action continuation is unavailable: executor kind does not support a governed Runtime Action continuation. Do not guess a tool call.`;
4830
5005
  }
4831
- function isManifestRefreshOnly(context) {
4832
- const readiness = asRecord(context.paperclipDeliveryReadiness);
4833
- const currentManifest = asRecord(readiness.currentManifest);
4834
- const findings = (Array.isArray(readiness.findings) ? readiness.findings : []).map((entry) => asRecord(entry)).filter((entry) => readString(entry.code));
4835
- const manifestRefs = [
4836
- currentManifest.primaryRef,
4837
- ...Array.isArray(currentManifest.supportingRefs) ? currentManifest.supportingRefs : []
4838
- ].map((entry) => asRecord(entry));
4839
- const documentRefIds = new Set(manifestRefs.filter((ref) => readString(ref.kind) === "document").map((ref) => readString(ref.refId)).filter(Boolean));
4840
- return readString(readiness.mode) === "required" && Number.isInteger(currentManifest.revision) && readString(currentManifest.requirementRevision) === readString(readiness.requirementRevision) && findings.length > 0 && findings.every((entry) => readString(entry.code) === "deliverable_ref_stale" && documentRefIds.has(readString(entry.refId)));
4841
- }
4842
5006
  function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionContract = false } = {}) {
4843
5007
  const envelope = asRecord(context.authorizationEnvelope);
4844
5008
  const allowed = new Set(
@@ -4856,7 +5020,7 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
4856
5020
  const businessOutcome = asRecord(requirements.businessOutcome);
4857
5021
  const completionRole = readString(completion.role);
4858
5022
  const completionDeliverable = readString(completion.deliverable);
4859
- const manifestRefreshOnly = isManifestRefreshOnly(context);
5023
+ const manifestRefreshOnly = legacyManifestRefreshOnly(context);
4860
5024
  const firstDocumentCheckpoint = completionDeliverable === "document_or_artifact" ? manifestRefreshOnly ? "The current deliverable content already exists and this run is limited to refreshing stale immutable Manifest refs. Do not create or revise a document unless a fresh Delivery readiness read proves a content or acceptance gap beyond stale refs." : mode === "cold" ? "Before the first external browse, search, or research action, call upsert_document with a stable key. Create a checkpoint skeleton containing the acceptance criteria, a source table, and known unknowns; update the same document with each piece of verified evidence instead of waiting until broad research is complete. Immediately after upsert_document, call update_parent with status: in_progress and a concrete next action; complete both control-plane writes before the first external browse, search, or research action." : "Before the first external browse, search, or research action, read the existing stable-key document. Preserve all still-valid verified rows, source URLs, conclusions, and known unknowns; do not replace a populated document with a blank skeleton or less-informative fallback. Only when the document does not exist may you create a checkpoint skeleton. Then call update_parent with status: in_progress and a concrete next action before the first external browse, search, or research action. Update the same document with each piece of verified evidence." : "";
4861
5025
  const completionContract = !suppressOrdinaryCompletionContract && completionRole && completionDeliverable ? [
4862
5026
  "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.",
@@ -4936,7 +5100,7 @@ function runtimeDeliveryReadinessText(context, input) {
4936
5100
  })).filter((entry) => entry.code);
4937
5101
  const manifestRequirementRevision = readString(currentManifest.requirementRevision);
4938
5102
  const requirementRevision = readString(readiness.requirementRevision);
4939
- const manifestRefreshOnly = isManifestRefreshOnly(context);
5103
+ const manifestRefreshOnly = legacyManifestRefreshOnly(context);
4940
5104
  const refSummary = (value) => {
4941
5105
  const ref = asRecord(value);
4942
5106
  return {
@@ -5323,6 +5487,249 @@ ${resolvedDependencies.details.content}` : ""
5323
5487
  return { prompt, manifest };
5324
5488
  }
5325
5489
 
5490
+ // src/amaster-runtime-daemon/agent-instruction-delivery.mjs
5491
+ var AUTO_LOAD_EXECUTOR_KINDS = /* @__PURE__ */ new Set(["codex", "pi"]);
5492
+ function resolveAgentInstructionDelivery(executorKind, options = {}) {
5493
+ const normalizedExecutorKind = typeof executorKind === "string" && executorKind.trim() ? executorKind.trim().toLowerCase() : "unknown";
5494
+ const runnerKind = typeof options.runnerKind === "string" && options.runnerKind.trim() ? options.runnerKind.trim().toLowerCase() : "unknown";
5495
+ const materializedFiles = Array.isArray(options.materializedFiles) ? [...new Set(options.materializedFiles.filter((path) => typeof path === "string" && path.trim()))].sort() : [];
5496
+ const suppliedFiles = Array.isArray(options.suppliedFiles) ? [...new Set(options.suppliedFiles.filter((path) => typeof path === "string" && path.trim()))].sort() : materializedFiles;
5497
+ const executorSupportsAutoLoad = AUTO_LOAD_EXECUTOR_KINDS.has(normalizedExecutorKind);
5498
+ const instructionsSupplied = suppliedFiles.length > 0;
5499
+ const entryFileSupplied = suppliedFiles.includes("AGENTS.md");
5500
+ const entryFileMaterialized = materializedFiles.includes("AGENTS.md");
5501
+ const autoLoaded = executorSupportsAutoLoad && entryFileSupplied && entryFileMaterialized;
5502
+ return {
5503
+ version: 1,
5504
+ runnerKind,
5505
+ executorKind: normalizedExecutorKind,
5506
+ mode: autoLoaded ? "executor_auto_load" : instructionsSupplied ? "explicit_read_required" : "not_applicable",
5507
+ channel: autoLoaded ? "workspace_project_instructions" : instructionsSupplied ? "user_prompt_pointer" : null,
5508
+ attestedBy: "runtime_executor_contract",
5509
+ reason: autoLoaded ? "executor_contract_and_materialization_attested" : !instructionsSupplied ? "agent_instructions_not_supplied" : !entryFileSupplied ? "agents_entry_not_supplied" : executorSupportsAutoLoad ? "agents_entry_not_materialized" : "executor_auto_load_not_supported",
5510
+ entryFileSupplied,
5511
+ entryFileMaterialized,
5512
+ materializedFileCount: materializedFiles.length,
5513
+ materializedFiles
5514
+ };
5515
+ }
5516
+ function agentInstructionFileNames(bundle) {
5517
+ const files = bundle && typeof bundle === "object" && bundle.files && typeof bundle.files === "object" ? bundle.files : {};
5518
+ return Object.keys(files).filter((path) => typeof files[path] === "string" && files[path].trim()).sort((left, right) => left === right ? 0 : left === "AGENTS.md" ? -1 : right === "AGENTS.md" ? 1 : left.localeCompare(right));
5519
+ }
5520
+ function renderAgentInstructionsBundle(bundle, delivery) {
5521
+ const names = agentInstructionFileNames(bundle);
5522
+ if (names.length === 0) return "";
5523
+ const resolvedDelivery = delivery ?? resolveAgentInstructionDelivery("unknown");
5524
+ const materialized = `Current agent instructions are materialized in the execution workspace as: ${names.map((name) => `./${name}`).join(", ")}.`;
5525
+ if (!names.includes("AGENTS.md")) {
5526
+ return [
5527
+ materialized,
5528
+ "No ./AGENTS.md entry is present. Read the listed instruction files before acting and follow them for the whole run."
5529
+ ].join("\n");
5530
+ }
5531
+ if (resolvedDelivery.mode === "executor_auto_load") {
5532
+ return [
5533
+ materialized,
5534
+ "This executor has already loaded ./AGENTS.md through its project-instruction channel. Follow it for the whole run; do not read it again merely to initialize. Read sibling instruction files only when ./AGENTS.md references them or the current task requires them."
5535
+ ].join("\n");
5536
+ }
5537
+ return [
5538
+ materialized,
5539
+ "Automatic project-instruction loading is not attested for this executor. Read ./AGENTS.md first and follow it (including any sibling files it references) for the whole run."
5540
+ ].join("\n");
5541
+ }
5542
+ function agentInstructionDeliveryAudit(bundle, delivery) {
5543
+ const files = agentInstructionFileNames(bundle);
5544
+ return {
5545
+ ...delivery ?? resolveAgentInstructionDelivery("unknown"),
5546
+ entryFile: files.includes("AGENTS.md") ? "AGENTS.md" : null,
5547
+ suppliedFileCount: files.length,
5548
+ suppliedFiles: files
5549
+ };
5550
+ }
5551
+
5552
+ // src/amaster-runtime-daemon/agent-instruction-system-kernel-shadow.mjs
5553
+ import { createHash as createHash5 } from "node:crypto";
5554
+ var SHADOW_VERSION = 1;
5555
+ var TARGET_CHARS = 16e3;
5556
+ var USER_RESPONSE_START = "<user-facing-response>";
5557
+ var USER_RESPONSE_END = "</user-facing-response>";
5558
+ var RUNTIME_HEADING = "# AMaster Runtime Contract";
5559
+ var RUNTIME_KERNEL_SECTIONS = /* @__PURE__ */ new Set([
5560
+ "Narrow recovery and terminalization",
5561
+ "Secrets and Safety",
5562
+ "Execution continuity"
5563
+ ]);
5564
+ var ROLE_KERNEL_SECTIONS = /* @__PURE__ */ new Set([
5565
+ "How you think",
5566
+ "What you do",
5567
+ "What you do not do",
5568
+ "When you finish"
5569
+ ]);
5570
+ function sha256(value) {
5571
+ return createHash5("sha256").update(value, "utf8").digest("hex");
5572
+ }
5573
+ function normalizedText(value) {
5574
+ return typeof value === "string" ? value.trim() : "";
5575
+ }
5576
+ function sectionAudit(scope, section, disposition) {
5577
+ return {
5578
+ scope,
5579
+ heading: section.heading,
5580
+ disposition,
5581
+ chars: section.content.length,
5582
+ sha256: sha256(section.content)
5583
+ };
5584
+ }
5585
+ function splitH2Sections(content, scope) {
5586
+ const matches = [...content.matchAll(/^## (.+)$/gm)];
5587
+ const sections = [];
5588
+ const preambleEnd = matches[0]?.index ?? content.length;
5589
+ const preamble = content.slice(0, preambleEnd).trim();
5590
+ if (preamble) {
5591
+ sections.push({
5592
+ scope,
5593
+ heading: `${scope}_preamble`,
5594
+ content: preamble
5595
+ });
5596
+ }
5597
+ for (let index = 0; index < matches.length; index += 1) {
5598
+ const match = matches[index];
5599
+ const start = match.index;
5600
+ const end = matches[index + 1]?.index ?? content.length;
5601
+ const sectionContent = content.slice(start, end).trim();
5602
+ if (!sectionContent) continue;
5603
+ sections.push({
5604
+ scope,
5605
+ heading: match[1].trim(),
5606
+ content: sectionContent
5607
+ });
5608
+ }
5609
+ return sections;
5610
+ }
5611
+ function extractUserResponseContract(content) {
5612
+ const start = content.indexOf(USER_RESPONSE_START);
5613
+ if (start === -1) return null;
5614
+ const end = content.indexOf(USER_RESPONSE_END, start);
5615
+ if (end === -1) return null;
5616
+ const contentEnd = end + USER_RESPONSE_END.length;
5617
+ return {
5618
+ start,
5619
+ end: contentEnd,
5620
+ content: content.slice(start, contentEnd).trim()
5621
+ };
5622
+ }
5623
+ function splitManagedLayout(content) {
5624
+ const userResponse = extractUserResponseContract(content);
5625
+ const runtimeStart = content.indexOf(RUNTIME_HEADING);
5626
+ if (!userResponse || runtimeStart === -1 || runtimeStart < userResponse.end) return null;
5627
+ const afterRuntime = content.slice(runtimeStart);
5628
+ const parts = afterRuntime.split(/^---$/gm);
5629
+ if (parts.length < 2) return null;
5630
+ const rolePartIndex = parts.findIndex((part, index) => index > 0 && /^## (?:How you think|What you do|What you do not do|When you finish)$/m.test(part));
5631
+ if (rolePartIndex === -1) return null;
5632
+ const runtime = parts[0].trim();
5633
+ const role = parts.slice(rolePartIndex).join("\n---\n").trim();
5634
+ if (!runtime.startsWith(RUNTIME_HEADING) || !role) return null;
5635
+ return { userResponse: userResponse.content, runtime, role };
5636
+ }
5637
+ function kernelProjection(content) {
5638
+ const layout = splitManagedLayout(content);
5639
+ if (!layout) return null;
5640
+ const selected = [{
5641
+ scope: "response",
5642
+ heading: "User-Facing Response Contract",
5643
+ content: layout.userResponse
5644
+ }];
5645
+ const onDemand = [];
5646
+ for (const section of splitH2Sections(layout.runtime, "runtime")) {
5647
+ if (section.heading === "runtime_preamble" || RUNTIME_KERNEL_SECTIONS.has(section.heading)) {
5648
+ selected.push(section);
5649
+ } else {
5650
+ onDemand.push(section);
5651
+ }
5652
+ }
5653
+ for (const section of splitH2Sections(layout.role, "role")) {
5654
+ if (section.heading === "role_preamble" || ROLE_KERNEL_SECTIONS.has(section.heading)) {
5655
+ selected.push(section);
5656
+ } else {
5657
+ onDemand.push(section);
5658
+ }
5659
+ }
5660
+ return {
5661
+ candidate: selected.map((section) => section.content).join("\n\n---\n\n"),
5662
+ selected,
5663
+ onDemand
5664
+ };
5665
+ }
5666
+ function buildAgentInstructionSystemKernelShadow(bundle) {
5667
+ const bundleMode = normalizedText(bundle?.mode).toLowerCase();
5668
+ const source = normalizedText(bundle?.files?.["AGENTS.md"]);
5669
+ const base = {
5670
+ version: SHADOW_VERSION,
5671
+ mode: "shadow_only",
5672
+ activation: "disabled",
5673
+ targetChars: TARGET_CHARS,
5674
+ bundleMode: bundleMode || "unknown",
5675
+ sourceFile: source ? "AGENTS.md" : null
5676
+ };
5677
+ if (!source) {
5678
+ return {
5679
+ candidate: "",
5680
+ audit: {
5681
+ ...base,
5682
+ status: "not_applicable",
5683
+ reason: "agents_entry_not_supplied"
5684
+ }
5685
+ };
5686
+ }
5687
+ if (bundleMode !== "managed") {
5688
+ return {
5689
+ candidate: "",
5690
+ audit: {
5691
+ ...base,
5692
+ status: "not_applicable",
5693
+ reason: bundleMode === "external" ? "external_instructions_are_user_owned" : "managed_bundle_not_attested",
5694
+ sourceChars: source.length,
5695
+ sourceSha256: sha256(source)
5696
+ }
5697
+ };
5698
+ }
5699
+ const projection = kernelProjection(source);
5700
+ if (!projection) {
5701
+ return {
5702
+ candidate: "",
5703
+ audit: {
5704
+ ...base,
5705
+ status: "unavailable",
5706
+ reason: "managed_layout_not_recognized",
5707
+ sourceChars: source.length,
5708
+ sourceSha256: sha256(source)
5709
+ }
5710
+ };
5711
+ }
5712
+ const candidateChars = projection.candidate.length;
5713
+ const reductionChars = source.length - candidateChars;
5714
+ return {
5715
+ candidate: projection.candidate,
5716
+ audit: {
5717
+ ...base,
5718
+ status: "candidate_ready",
5719
+ reason: "managed_sections_classified",
5720
+ sourceChars: source.length,
5721
+ sourceSha256: sha256(source),
5722
+ candidateChars,
5723
+ candidateSha256: sha256(projection.candidate),
5724
+ reductionChars,
5725
+ reductionRatio: source.length > 0 ? Number((reductionChars / source.length).toFixed(4)) : 0,
5726
+ withinTarget: candidateChars <= TARGET_CHARS,
5727
+ selectedSections: projection.selected.map((section) => sectionAudit(section.scope, section, "kernel_candidate")),
5728
+ onDemandSections: projection.onDemand.map((section) => sectionAudit(section.scope, section, "on_demand_candidate"))
5729
+ }
5730
+ };
5731
+ }
5732
+
5326
5733
  // src/amaster-runtime-daemon/config-state.mjs
5327
5734
  import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync5, renameSync as renameSync3, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
5328
5735
  import { homedir as homedir2, hostname } from "node:os";
@@ -5408,6 +5815,7 @@ var CAPABILITIES = [
5408
5815
  "run_wakeup",
5409
5816
  "runtime_actions_v2",
5410
5817
  "model_call",
5818
+ "model_call_output_contract_v1",
5411
5819
  "run_cancel",
5412
5820
  "run_terminate",
5413
5821
  "logs_cost_workspace_status"
@@ -6245,9 +6653,9 @@ function governedMcpToolResult(structuredContent) {
6245
6653
  const intentId = readString(effectResult.artifactIntentId);
6246
6654
  const manifestId = readString(effectResult.manifestId);
6247
6655
  const sourceRelativePath = readString(effectResult.sourceRelativePath);
6248
- const sha256 = readString(effectResult.sha256);
6656
+ const sha2562 = readString(effectResult.sha256);
6249
6657
  const byteSize = readNumber(effectResult.byteSize, 0);
6250
- const artifactIntent = providerStatus === "pending_reconcile" && intentId && manifestId && sourceRelativePath && /^[a-f0-9]{64}$/.test(sha256 ?? "") && Number.isSafeInteger(byteSize) && byteSize > 0 ? { intentId, manifestId, sourceRelativePath, sha256, byteSize } : null;
6658
+ const artifactIntent = providerStatus === "pending_reconcile" && intentId && manifestId && sourceRelativePath && /^[a-f0-9]{64}$/.test(sha2562 ?? "") && Number.isSafeInteger(byteSize) && byteSize > 0 ? { intentId, manifestId, sourceRelativePath, sha256: sha2562, byteSize } : null;
6251
6659
  const workspaceDocumentEffect = asRecord(effectResult.workspaceDocumentIntent);
6252
6660
  const workspaceDocumentCallId = readString(workspaceDocumentEffect.callId);
6253
6661
  const workspaceDocumentManifestId = readString(workspaceDocumentEffect.manifestId);
@@ -7202,7 +7610,7 @@ var postJsonWithRetry = postRuntimeConnectorJsonWithRetry;
7202
7610
  var bestEffortPostJson = bestEffortPostRuntimeConnectorJson;
7203
7611
 
7204
7612
  // src/amaster-runtime-daemon/runtime-artifact-upload.mjs
7205
- import { createHash as createHash4 } from "node:crypto";
7613
+ import { createHash as createHash6 } from "node:crypto";
7206
7614
  import { closeSync, constants, fstatSync, lstatSync as lstatSync3, openSync, readFileSync as readFileSync6, realpathSync as realpathSync3 } from "node:fs";
7207
7615
  import { isAbsolute as isAbsolute3, relative as relative3, resolve as resolve3 } from "node:path";
7208
7616
  var SHA256_PATTERN = /^[a-f0-9]{64}$/;
@@ -7292,7 +7700,7 @@ function prepareRuntimeArtifactUploads(cwd, mcpToolResults) {
7292
7700
  `Runtime Artifact ${intentId}`,
7293
7701
  { expectedByteSize }
7294
7702
  );
7295
- const actualSha256 = createHash4("sha256").update(body).digest("hex");
7703
+ const actualSha256 = createHash6("sha256").update(body).digest("hex");
7296
7704
  if (body.length !== expectedByteSize || actualSha256 !== expectedSha256) {
7297
7705
  throw new Error(`Runtime Artifact ${intentId} bytes do not match the governed ownership manifest`);
7298
7706
  }
@@ -7309,7 +7717,7 @@ function prepareRuntimeArtifactUploads(cwd, mcpToolResults) {
7309
7717
  }
7310
7718
 
7311
7719
  // src/amaster-runtime-daemon/runtime-document-upload.mjs
7312
- import { createHash as createHash5 } from "node:crypto";
7720
+ import { createHash as createHash7 } from "node:crypto";
7313
7721
 
7314
7722
  // src/amaster-runtime-daemon/workspace-sensitive-path.mjs
7315
7723
  var SENSITIVE_PATH_SEGMENTS = /* @__PURE__ */ new Set([
@@ -7384,7 +7792,7 @@ function prepareRuntimeDocumentUploads(cwd, mcpToolResults) {
7384
7792
  maxByteSize: MAX_WORKSPACE_DOCUMENT_BYTES
7385
7793
  }
7386
7794
  );
7387
- const actualSha256 = createHash5("sha256").update(body).digest("hex");
7795
+ const actualSha256 = createHash7("sha256").update(body).digest("hex");
7388
7796
  if (body.length !== expectedByteSize || actualSha256 !== expectedSha256) {
7389
7797
  throw new Error(`Runtime Document ${callId} bytes do not match the governed ownership manifest`);
7390
7798
  }
@@ -7458,9 +7866,9 @@ function createRuntimeArtifactIngestQueue({ ingest, onError }) {
7458
7866
  let queue = Promise.resolve();
7459
7867
  const artifactIdentity = (intent) => {
7460
7868
  const sourceRelativePath = readString(asRecord(intent).sourceRelativePath);
7461
- const sha256 = readString(asRecord(intent).sha256);
7869
+ const sha2562 = readString(asRecord(intent).sha256);
7462
7870
  const byteSize = asRecord(intent).byteSize;
7463
- return sourceRelativePath && sha256 && Number.isSafeInteger(byteSize) && byteSize > 0 ? `${sourceRelativePath}\0${sha256}\0${byteSize}` : null;
7871
+ return sourceRelativePath && sha2562 && Number.isSafeInteger(byteSize) && byteSize > 0 ? `${sourceRelativePath}\0${sha2562}\0${byteSize}` : null;
7464
7872
  };
7465
7873
  const retainReceipts = (receipts) => {
7466
7874
  artifacts.push(...receipts);
@@ -7510,7 +7918,7 @@ function createRuntimeArtifactIngestQueue({ ingest, onError }) {
7510
7918
  }
7511
7919
 
7512
7920
  // src/amaster-runtime-daemon/workspace-guard.mjs
7513
- import { createHash as createHash6 } from "node:crypto";
7921
+ import { createHash as createHash8 } from "node:crypto";
7514
7922
  import { existsSync as existsSync7, mkdirSync as mkdirSync6, realpathSync as realpathSync4, statSync as statSync4 } from "node:fs";
7515
7923
  import { basename as basename4, join as join8, isAbsolute as isAbsolute4, relative as relative4, resolve as resolve4 } from "node:path";
7516
7924
 
@@ -7636,7 +8044,7 @@ function resolveWorkspaceCwd(config, command) {
7636
8044
  return cwd;
7637
8045
  }
7638
8046
  function shortHash(value, length = 12) {
7639
- return createHash6("sha256").update(String(value)).digest("hex").slice(0, length);
8047
+ return createHash8("sha256").update(String(value)).digest("hex").slice(0, length);
7640
8048
  }
7641
8049
  function safeSegment(value, fallback) {
7642
8050
  const raw = String(value ?? "").trim();
@@ -8080,7 +8488,7 @@ function summarizeAmasterRuntimeVersionDrift(input = {}) {
8080
8488
  }
8081
8489
 
8082
8490
  // src/amaster-runtime-daemon/pi-child-isolation.mjs
8083
- import { createHash as createHash7 } from "node:crypto";
8491
+ import { createHash as createHash9 } from "node:crypto";
8084
8492
  import {
8085
8493
  chmodSync as chmodSync3,
8086
8494
  chownSync as chownSync2,
@@ -8091,7 +8499,7 @@ import {
8091
8499
  import { resolve as resolve7, sep } from "node:path";
8092
8500
  var defaultFs = { chmodSync: chmodSync3, chownSync: chownSync2, lchownSync, lstatSync: lstatSync4, readdirSync: readdirSync6 };
8093
8501
  function defaultHashRunId(runId) {
8094
- return Number.parseInt(createHash7("sha256").update(runId).digest("hex").slice(0, 8), 16);
8502
+ return Number.parseInt(createHash9("sha256").update(runId).digest("hex").slice(0, 8), 16);
8095
8503
  }
8096
8504
  function positiveInteger(value, label) {
8097
8505
  if (!Number.isSafeInteger(value) || value <= 0) {
@@ -8215,7 +8623,7 @@ function preparePiChildIsolation(input) {
8215
8623
  }
8216
8624
 
8217
8625
  // src/amaster-runtime-daemon/pi-company-memory.mjs
8218
- import { createHash as createHash8 } from "node:crypto";
8626
+ import { createHash as createHash10 } from "node:crypto";
8219
8627
  import {
8220
8628
  chmodSync as chmodSync4,
8221
8629
  chownSync as chownSync3,
@@ -8301,7 +8709,7 @@ function safeCompanyPiHomeSegment(companyId) {
8301
8709
  const raw = requiredString3(companyId, "companyId");
8302
8710
  if (/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/.test(raw)) return raw;
8303
8711
  const normalized = raw.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^[._-]+|[._-]+$/g, "").slice(0, 80);
8304
- const hash = createHash8("sha256").update(raw).digest("hex").slice(0, 12);
8712
+ const hash = createHash10("sha256").update(raw).digest("hex").slice(0, 12);
8305
8713
  return normalized ? `${normalized}-${hash}` : `company-${hash}`;
8306
8714
  }
8307
8715
  function ensureMemoryRoot(root, fs) {
@@ -8340,7 +8748,7 @@ function allocateCompanyGid(root, companyId, input, fs) {
8340
8748
  if (groups[companyId]) return groups[companyId];
8341
8749
  const used = new Set(Object.values(groups));
8342
8750
  const initialOffset = Number.parseInt(
8343
- createHash8("sha256").update(companyId).digest("hex").slice(0, 12),
8751
+ createHash10("sha256").update(companyId).digest("hex").slice(0, 12),
8344
8752
  16
8345
8753
  ) % gidSpan;
8346
8754
  let gid = null;
@@ -8442,7 +8850,7 @@ function prepareCompanyPiMemory(input, fs = defaultFs2) {
8442
8850
  }
8443
8851
 
8444
8852
  // src/amaster-runtime-daemon/pi-trusted-runtime-profile.mjs
8445
- import { createHash as createHash9 } from "node:crypto";
8853
+ import { createHash as createHash11 } from "node:crypto";
8446
8854
  import {
8447
8855
  chmodSync as chmodSync5,
8448
8856
  copyFileSync as copyFileSync2,
@@ -8482,7 +8890,7 @@ function sha256File(path, label) {
8482
8890
  if (!stat.isFile() || stat.isSymbolicLink()) {
8483
8891
  throw new Error(`pi_trusted_runtime_source_unsafe:${label}`);
8484
8892
  }
8485
- return createHash9("sha256").update(readFileSync9(path)).digest("hex");
8893
+ return createHash11("sha256").update(readFileSync9(path)).digest("hex");
8486
8894
  }
8487
8895
  function verifyDeclaredFiles(manifest, root, label, ignoredPaths = [], enforceComplete = true) {
8488
8896
  if (!Array.isArray(manifest.files) || manifest.files.length === 0) {
@@ -8750,12 +9158,12 @@ function materializeTrustedPiRuntimeProfile(input) {
8750
9158
  // bundle skills were enabled. Absent profile => main skills only.
8751
9159
  ...skillProfile ? {
8752
9160
  skillProfile,
8753
- enabledSkillsDigest: createHash9("sha256").update(JSON.stringify(enabledSkills)).digest("hex")
9161
+ enabledSkillsDigest: createHash11("sha256").update(JSON.stringify(enabledSkills)).digest("hex")
8754
9162
  } : {}
8755
9163
  };
8756
9164
  return {
8757
9165
  facts,
8758
- attestationId: createHash9("sha256").update(JSON.stringify(facts)).digest("hex")
9166
+ attestationId: createHash11("sha256").update(JSON.stringify(facts)).digest("hex")
8759
9167
  };
8760
9168
  }
8761
9169
  function assertAuditArgsRedacted(value) {
@@ -8951,7 +9359,7 @@ function verifyTrustedPiRuntimeAssertion(input) {
8951
9359
  if (hasSourceAssertion) {
8952
9360
  const exactTools = Array.isArray(record7(sourceProfile.tools).exactAllowlist) ? record7(sourceProfile.tools).exactAllowlist : [];
8953
9361
  const exactActions = Array.isArray(record7(sourceProfile.actions).exactAllowlist) ? record7(sourceProfile.actions).exactAllowlist : [];
8954
- const profileHash = createHash9("sha256").update(JSON.stringify(sourceProfile)).digest("hex");
9362
+ const profileHash = createHash11("sha256").update(JSON.stringify(sourceProfile)).digest("hex");
8955
9363
  if (assertion.unknownToolMode !== "deny" || maxCalls !== 0 || sourceAssertion.profileVersion !== sourceProfile.purpose || sourceAssertion.profileHash !== profileHash || sourceAssertion.retentionVersion !== sourceProfile.retention || JSON.stringify(sourceAssertion.exactTools) !== JSON.stringify(exactTools) || JSON.stringify(sourceAssertion.exactActions) !== JSON.stringify(exactActions) || sourceAssertion.sourceId !== sourceProfile.sourceId || sourceAssertion.sourceRevisionId !== sourceProfile.sourceRevisionId || sourceAssertion.sourceRevision !== sourceProfile.sourceRevision || sourceAssertion.attemptId !== sourceProfile.attemptId || sourceAssertion.epoch !== sourceProfile.epoch) {
8956
9364
  throw new Error("pi_trusted_runtime_assertion_binding_mismatch:sourceAcquisition");
8957
9365
  }
@@ -8980,7 +9388,7 @@ function verifyTrustedPiRuntimeAssertion(input) {
8980
9388
 
8981
9389
  // src/amaster-runtime-daemon/workspace-status.mjs
8982
9390
  import { spawnSync as spawnSync4 } from "node:child_process";
8983
- import { createHash as createHash10 } from "node:crypto";
9391
+ import { createHash as createHash12 } from "node:crypto";
8984
9392
  import { existsSync as existsSync12, readdirSync as readdirSync8, readFileSync as readFileSync10, statSync as statSync7 } from "node:fs";
8985
9393
  import { basename as basename5, extname, isAbsolute as isAbsolute7, join as join13, relative as relative7, resolve as resolve10 } from "node:path";
8986
9394
  var WORKSPACE_RUNTIME_SERVICES_FILENAME = ".amaster-runtime-services.json";
@@ -9051,7 +9459,7 @@ function sanitizeTrackedChange(line) {
9051
9459
  return isSafeRelativePath(path) ? line : null;
9052
9460
  }
9053
9461
  function sha256File2(filePath) {
9054
- return createHash10("sha256").update(readFileSync10(filePath)).digest("hex");
9462
+ return createHash12("sha256").update(readFileSync10(filePath)).digest("hex");
9055
9463
  }
9056
9464
  function artifactHashCacheKey(relativePath, stat) {
9057
9465
  return `${relativePath}\0${stat.size}\0${stat.mtimeMs}`;
@@ -9252,7 +9660,7 @@ function readWorkspaceStatus(cwd, opts = {}) {
9252
9660
  }
9253
9661
 
9254
9662
  // src/amaster-runtime-daemon/pi-browser-session-adapter.mjs
9255
- import { createHash as createHash11 } from "node:crypto";
9663
+ import { createHash as createHash13 } from "node:crypto";
9256
9664
  import { spawn, spawnSync as spawnSync5 } from "node:child_process";
9257
9665
  import { existsSync as existsSync13 } from "node:fs";
9258
9666
  import {
@@ -9375,7 +9783,7 @@ function fail(code) {
9375
9783
  throw Object.assign(new Error(code), { code });
9376
9784
  }
9377
9785
  function profileName(identity2) {
9378
- return createHash11("sha256").update(`${identity2.companyId}\0${identity2.bindingId}\0${identity2.localOpaqueRef}`).digest("hex");
9786
+ return createHash13("sha256").update(`${identity2.companyId}\0${identity2.bindingId}\0${identity2.localOpaqueRef}`).digest("hex");
9379
9787
  }
9380
9788
  function expectedMarker(identity2) {
9381
9789
  return {
@@ -9774,7 +10182,7 @@ async function executeBrowserSessionCommand(command, dependencies = {}) {
9774
10182
  }
9775
10183
 
9776
10184
  // src/amaster-runtime-daemon/source-acquisition-invocation.mjs
9777
- import { createHash as createHash12 } from "node:crypto";
10185
+ import { createHash as createHash14 } from "node:crypto";
9778
10186
  var SOURCE_ACQUISITION_PUBLIC_TOOLS = Object.freeze([
9779
10187
  "source_open",
9780
10188
  "source_snapshot",
@@ -9811,7 +10219,7 @@ function serializeSourceAcquisitionProfile(profile) {
9811
10219
  const input = Buffer.from(JSON.stringify(profile), "utf8");
9812
10220
  return {
9813
10221
  input,
9814
- sha256: createHash12("sha256").update(input).digest("hex")
10222
+ sha256: createHash14("sha256").update(input).digest("hex")
9815
10223
  };
9816
10224
  }
9817
10225
  function sourceAcquisitionManagedInputs(options) {
@@ -9847,7 +10255,7 @@ function assertSourceAcquisitionRuntimeAuthority({
9847
10255
  }
9848
10256
 
9849
10257
  // src/amaster-runtime-daemon.mjs
9850
- var CONNECTOR_VERSION = "0.1.1-beta.20";
10258
+ var CONNECTOR_VERSION = "0.1.1-beta.22";
9851
10259
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
9852
10260
  var SOURCE_ACQUISITION_CAPABILITY = "source_acquisition_v1";
9853
10261
  var SOURCE_ACQUISITION_PROFILE_VERSION = "source_acquisition_v1";
@@ -11123,15 +11531,6 @@ ${body}${truncatedNote}`;
11123
11531
  function renderTaskMarkdown(context) {
11124
11532
  return readString(context.paperclipTaskMarkdown);
11125
11533
  }
11126
- function renderAgentInstructionsBundle(bundle) {
11127
- const files = asRecord(asRecord(bundle).files);
11128
- const names = Object.keys(files).filter((path) => readString(files[path])).sort((left, right) => left === right ? 0 : left === "AGENTS.md" ? -1 : right === "AGENTS.md" ? 1 : left.localeCompare(right));
11129
- if (names.length === 0) return "";
11130
- return [
11131
- `Current agent instructions are materialized in the execution workspace as: ${names.map((name) => `./${name}`).join(", ")}.`,
11132
- "They are authoritative for this run and are not inlined here. Read ./AGENTS.md first and follow it (including any sibling files it references) for the whole run."
11133
- ].join("\n");
11134
- }
11135
11534
  function commandRuntimeAuth(command) {
11136
11535
  const topLevel = asRecord(command.runtimeAuth);
11137
11536
  if (readString(topLevel.apiUrl) && readString(topLevel.apiKey)) return topLevel;
@@ -11190,7 +11589,7 @@ function sourceAcquisitionRuntimeProfile(config, command) {
11190
11589
  if (!companyId || !bindingId || !/^profile_[a-z0-9]{16,64}$/i.test(localOpaqueRef ?? "")) {
11191
11590
  throw new Error("source_acquisition_profile_invalid");
11192
11591
  }
11193
- const profileName2 = createHash13("sha256").update(`${companyId}\0${bindingId}\0${localOpaqueRef}`).digest("hex");
11592
+ const profileName2 = createHash15("sha256").update(`${companyId}\0${bindingId}\0${localOpaqueRef}`).digest("hex");
11194
11593
  const stateRoot = resolve12(config.browserSessionStateRoot);
11195
11594
  const userDataDir = resolve12(stateRoot, profileName2);
11196
11595
  if (!pathWithin2(userDataDir, stateRoot)) throw new Error("source_acquisition_browser_profile_invalid");
@@ -11354,7 +11753,14 @@ function buildCommandPrompt(command, workspace, materializedAttachments = [], op
11354
11753
  }
11355
11754
  );
11356
11755
  const taskMarkdown = renderTaskMarkdown(context);
11357
- const agentInstructions = renderAgentInstructionsBundle(asRecord(payload.agentInstructionsBundle));
11756
+ const agentInstructionsBundle = asRecord(payload.agentInstructionsBundle);
11757
+ const agentInstructionDelivery = resolveAgentInstructionDelivery(options.executorKind, {
11758
+ runnerKind: options.runnerKind,
11759
+ materializedFiles: options.materializedAgentInstructionFiles,
11760
+ suppliedFiles: agentInstructionFileNames(agentInstructionsBundle)
11761
+ });
11762
+ const agentInstructions = renderAgentInstructionsBundle(agentInstructionsBundle, agentInstructionDelivery);
11763
+ const agentInstructionSystemKernelShadow = buildAgentInstructionSystemKernelShadow(agentInstructionsBundle);
11358
11764
  const runtimeAuth = commandRuntimeAuth(command);
11359
11765
  const hasGovernedMcp = Object.keys(asRecord(runtimeAuth.governedMcp)).length > 0;
11360
11766
  const attachmentsText = materializedAttachments.length > 0 ? [
@@ -11374,7 +11780,7 @@ function buildCommandPrompt(command, workspace, materializedAttachments = [], op
11374
11780
  return `- ${details}`;
11375
11781
  })
11376
11782
  ].join("\n") : "";
11377
- return compileCommandPromptWithManifest({
11783
+ const compilation = compileCommandPromptWithManifest({
11378
11784
  commandId: command.commandId,
11379
11785
  runId: commandRunId(command),
11380
11786
  issueId: commandIssueId(command),
@@ -11399,6 +11805,22 @@ function buildCommandPrompt(command, workspace, materializedAttachments = [], op
11399
11805
  treePath: wikiTreePathForCommand(command, options.workspaceBindings)
11400
11806
  }
11401
11807
  });
11808
+ const auditedCompilation = attachCurrentRunContractShadowAudit(
11809
+ compilation,
11810
+ payload.currentRunContract,
11811
+ context
11812
+ );
11813
+ return {
11814
+ ...auditedCompilation,
11815
+ manifest: {
11816
+ ...auditedCompilation.manifest,
11817
+ agentInstructionDelivery: agentInstructionDeliveryAudit(
11818
+ agentInstructionsBundle,
11819
+ agentInstructionDelivery
11820
+ ),
11821
+ agentInstructionSystemKernelShadow: agentInstructionSystemKernelShadow.audit
11822
+ }
11823
+ };
11402
11824
  }
11403
11825
  function companyPiHomeRoot(baseEnv) {
11404
11826
  const explicitRoot = readString(baseEnv.AMASTER_COMPANY_PI_HOME_ROOT);
@@ -11520,6 +11942,16 @@ function sanitizePiExtraArgs(value) {
11520
11942
  function nativeSessionResumeEnabled(session) {
11521
11943
  return process.env.AMASTER_RUNTIME_ENABLE_NATIVE_SESSION_RESUME === "true" || readString(session.mode) === "governed_action_approval" && session.required === true;
11522
11944
  }
11945
+ function modelCallResponseContract(payload) {
11946
+ if (payload.responseContract === void 0) return null;
11947
+ const contract = asRecord(payload.responseContract);
11948
+ const maxOutputTokens = Number(contract.maxOutputTokens);
11949
+ const maxSemanticBytes = Number(contract.maxSemanticBytes);
11950
+ if (readString(contract.format) !== "json" || readString(contract.thinking) !== "off" || !Number.isSafeInteger(maxOutputTokens) || maxOutputTokens < 1 || maxOutputTokens > 131072 || !Number.isSafeInteger(maxSemanticBytes) || maxSemanticBytes < 1024 || maxSemanticBytes > 256 * 1024) {
11951
+ throw new Error("model_call_response_contract_invalid");
11952
+ }
11953
+ return { format: "json", thinking: "off", maxOutputTokens, maxSemanticBytes };
11954
+ }
11523
11955
  function resolveNativeSessionRequest(command, workspace) {
11524
11956
  const payload = asRecord(command.payload);
11525
11957
  const session = asRecord(payload.nativeSession);
@@ -11553,17 +11985,21 @@ function resolveNativeSessionRequest(command, workspace) {
11553
11985
  ...enabled && requested && sessionId && requestedCwd && !cwdMatched ? { skippedReason: "native_session_cwd_mismatch" } : {}
11554
11986
  };
11555
11987
  }
11556
- function buildExecutorInvocation(executor, command = {}, workspace = null) {
11988
+ function buildExecutorInvocation(executor, command = {}, workspace = null, options = {}) {
11557
11989
  const payload = asRecord(command.payload);
11558
11990
  if (command.commandType === "model_call") {
11559
11991
  if (executor.kind === "pi") {
11560
11992
  const args = ["--mode", "json"];
11993
+ const responseContract = options.responseContract ?? null;
11561
11994
  const provider = readString(payload.provider) ?? readString(process.env.AMASTER_PI_PROVIDER);
11562
- const model = readString(payload.model) ?? readString(process.env.AMASTER_PI_MODEL);
11995
+ const configuredModel = readString(payload.model) ?? readString(process.env.AMASTER_PI_MODEL);
11996
+ const model = responseContract ? normalizePiModelId(configuredModel) : configuredModel;
11563
11997
  if (provider) args.push("--provider", provider);
11564
11998
  if (model) args.push("--model", model);
11999
+ if (responseContract?.thinking) args.push("--thinking", responseContract.thinking);
11565
12000
  args.push(...sanitizePiExtraArgs(process.env.AMASTER_PI_EXTRA_ARGS));
11566
12001
  args.push("--no-extensions", "--no-skills", "--no-session", "--no-tools");
12002
+ if (responseContract) args.push("--no-context-files");
11567
12003
  args.push("-p");
11568
12004
  return { command: executor.command, args, stdin: "prompt" };
11569
12005
  }
@@ -11651,7 +12087,8 @@ async function executeModelCallCommand(config, command, signal) {
11651
12087
  if (!prompt) {
11652
12088
  throw new Error("model_call command requires a prompt");
11653
12089
  }
11654
- const invocation = buildExecutorInvocation(executor, command);
12090
+ const responseContract = modelCallResponseContract(payload);
12091
+ const invocation = buildExecutorInvocation(executor, command, null, { responseContract });
11655
12092
  const timeoutSeconds = Math.max(1, Math.min(
11656
12093
  config.executorTimeoutSeconds,
11657
12094
  readNumber(payload.timeoutSeconds, Math.min(config.executorTimeoutSeconds, 60))
@@ -11683,6 +12120,16 @@ async function executeModelCallCommand(config, command, signal) {
11683
12120
  piModelCallProfile.env.PI_CODING_AGENT_DIR,
11684
12121
  resolvePiExecutorProviderConfig(config, command, baseEnv)
11685
12122
  );
12123
+ if (responseContract) {
12124
+ const provider = readString(payload.provider) ?? readString(process.env.AMASTER_PI_PROVIDER);
12125
+ const model = readString(payload.model) ?? readString(process.env.AMASTER_PI_MODEL);
12126
+ applyModelCallOutputContract(
12127
+ piModelCallProfile.env.PI_CODING_AGENT_DIR,
12128
+ provider,
12129
+ model,
12130
+ responseContract.maxOutputTokens
12131
+ );
12132
+ }
11686
12133
  }
11687
12134
  execution = await runExecutor(invocation.command, invocation.args, {
11688
12135
  cwd: process.cwd(),
@@ -11706,9 +12153,13 @@ async function executeModelCallCommand(config, command, signal) {
11706
12153
  const hasOutputFlood = Boolean(readString(outputFlood.stream) && readNumber(outputFlood.bytes, 0) > 0);
11707
12154
  const timedOut = execution.timedOut === true;
11708
12155
  const parsed = hasOutputFlood ? { summary: "", usage: null, errorMessage: null, messages: [] } : executor.kind === "pi" ? parsePiJsonl(execution.stdout) : parseGenericOutput(execution.stdout, execution.stderr);
11709
- const summary = truncateText(parsed.summary || parsed.finalMessage || parsed.messages?.join("\n\n") || "", 8e3);
11710
- const succeeded = !hasOutputFlood && !timedOut && !execution.spawnError && execution.exitCode === 0 && !parsed.errorMessage && Boolean(summary);
11711
- const error = timedOut ? `Runtime model call timed out after ${timeoutSeconds}s` : execution.spawnError ?? parsed.errorMessage ?? (hasOutputFlood ? `Runtime model call output flood: ${readString(outputFlood.stream)} exceeded ${readNumber(outputFlood.limitBytes, 0)} bytes` : succeeded ? null : `Runtime model call exited with code ${execution.exitCode ?? "unknown"}`);
12156
+ const rawSummary = parsed.summary || parsed.finalMessage || parsed.messages?.join("\n\n") || "";
12157
+ const semanticBytes = Buffer.byteLength(rawSummary, "utf8");
12158
+ const semanticOutputExceeded = Boolean(responseContract && semanticBytes > responseContract.maxSemanticBytes);
12159
+ const summary = semanticOutputExceeded ? "" : responseContract ? rawSummary : truncateText(rawSummary, 8e3);
12160
+ const hasTerminalCompletion = !responseContract || executor.kind !== "pi" || Boolean(parsed.terminalEventType);
12161
+ const succeeded = !hasOutputFlood && !timedOut && !semanticOutputExceeded && !execution.spawnError && execution.exitCode === 0 && hasTerminalCompletion && !parsed.errorMessage && Boolean(summary);
12162
+ const error = timedOut ? `Runtime model call timed out after ${timeoutSeconds}s` : execution.spawnError ?? parsed.errorMessage ?? (hasOutputFlood ? `Runtime model call output flood: ${readString(outputFlood.stream)} exceeded ${readNumber(outputFlood.limitBytes, 0)} bytes` : semanticOutputExceeded ? `Runtime model call semantic output exceeded ${responseContract.maxSemanticBytes} bytes` : !hasTerminalCompletion ? "Runtime model call exited without a terminal provider response" : succeeded ? null : `Runtime model call exited with code ${execution.exitCode ?? "unknown"}`);
11712
12163
  await completeCommand(config, command, succeeded ? "succeeded" : "failed", {
11713
12164
  callType: "model_call",
11714
12165
  executorKind: executor.kind,
@@ -11719,7 +12170,21 @@ async function executeModelCallCommand(config, command, signal) {
11719
12170
  timedOut,
11720
12171
  summary,
11721
12172
  usage: parsed.usage,
11722
- stdout: truncateText(execution.stdout, 8e3),
12173
+ ...responseContract ? {
12174
+ driver: "pi_cli_json_v1",
12175
+ responseContract,
12176
+ stopReason: parsed.stopReason ?? null,
12177
+ terminalEventType: parsed.terminalEventType ?? null,
12178
+ semanticBytes,
12179
+ outputBytes: Object.values(execution.outputBytes).reduce((total, bytes) => total + bytes, 0),
12180
+ outputBytesByStream: execution.outputBytes,
12181
+ retainedOutputBytes: Object.values(execution.retainedOutputBytes).reduce((total, bytes) => total + bytes, 0),
12182
+ retainedOutputBytesByStream: execution.retainedOutputBytes
12183
+ } : {},
12184
+ // Contracted model calls persist semantic output and metadata only. Pi's
12185
+ // JSONL stdout may contain provider reasoning/event content, so retaining
12186
+ // even a bounded tail would violate the response-contract data boundary.
12187
+ stdout: responseContract ? "" : truncateText(execution.stdout, 8e3),
11723
12188
  stderr: truncateText(filterExecutionStderrForResult(executor.kind, execution.stderr), 8e3),
11724
12189
  ...hasOutputFlood ? {
11725
12190
  errorCode: "model_call_output_flood",
@@ -11729,6 +12194,12 @@ async function executeModelCallCommand(config, command, signal) {
11729
12194
  bytes: readNumber(outputFlood.bytes, 0),
11730
12195
  limitBytes: readNumber(outputFlood.limitBytes, maxOutputBytes)
11731
12196
  }
12197
+ } : semanticOutputExceeded ? {
12198
+ errorCode: "model_call_semantic_output_exceeded",
12199
+ errorFamily: "validation"
12200
+ } : responseContract && !hasTerminalCompletion ? {
12201
+ errorCode: "model_call_terminal_event_missing",
12202
+ errorFamily: "provider_protocol"
11732
12203
  } : {}
11733
12204
  }, error ?? void 0);
11734
12205
  }
@@ -14001,7 +14472,7 @@ async function materializeIssueAttachments(config, command, workspace) {
14001
14472
  const body = await runtimeApiBuffer(runtimeAuth, contentPath);
14002
14473
  writeFileSync9(targetPath, body);
14003
14474
  const attachmentId = readString(attachment.id);
14004
- const actualSha256 = createHash13("sha256").update(body).digest("hex");
14475
+ const actualSha256 = createHash15("sha256").update(body).digest("hex");
14005
14476
  const lineageCandidates = lineageCandidatesByAttachmentId.get(attachmentId) ?? [];
14006
14477
  const lineage = selectAttachmentLineage(lineageCandidates, actualSha256);
14007
14478
  if (lineageCandidates.length > 0 && !lineage) {
@@ -14082,10 +14553,10 @@ async function materializeRequiredArtifactInputs(config, command, workspace) {
14082
14553
  const entry = asRecord(rawEntry);
14083
14554
  const workProductId = readString(entry.workProductId);
14084
14555
  const attachmentId = readString(entry.attachmentId);
14085
- const sha256 = readString(entry.sha256);
14556
+ const sha2562 = readString(entry.sha256);
14086
14557
  const contentPath = readString(entry.contentPath);
14087
14558
  const byteSize = readNumber(entry.byteSize, null);
14088
- if (!workProductId || !attachmentId || !/^[a-f0-9]{64}$/i.test(sha256 ?? "") || !contentPath || byteSize === null) {
14559
+ if (!workProductId || !attachmentId || !/^[a-f0-9]{64}$/i.test(sha2562 ?? "") || !contentPath || byteSize === null) {
14089
14560
  throw new Error(`artifact_input_manifest_invalid: entry ${index} is incomplete`);
14090
14561
  }
14091
14562
  const expectedContentPath = `/api/attachments/${attachmentId}/content`;
@@ -14093,10 +14564,10 @@ async function materializeRequiredArtifactInputs(config, command, workspace) {
14093
14564
  throw new Error(`artifact_input_manifest_invalid: entry ${index} contentPath does not match attachmentId`);
14094
14565
  }
14095
14566
  const body = await runtimeApiBuffer(runtimeAuth, contentPath);
14096
- const actualSha256 = createHash13("sha256").update(body).digest("hex");
14097
- if (body.byteLength !== byteSize || actualSha256 !== sha256) {
14567
+ const actualSha256 = createHash15("sha256").update(body).digest("hex");
14568
+ if (body.byteLength !== byteSize || actualSha256 !== sha2562) {
14098
14569
  throw new Error(
14099
- `artifact_input_integrity_mismatch: workProductId=${workProductId} expectedBytes=${byteSize} actualBytes=${body.byteLength} expectedSha256=${sha256} actualSha256=${actualSha256}`
14570
+ `artifact_input_integrity_mismatch: workProductId=${workProductId} expectedBytes=${byteSize} actualBytes=${body.byteLength} expectedSha256=${sha2562} actualSha256=${actualSha256}`
14100
14571
  );
14101
14572
  }
14102
14573
  const sourceDir = safeArtifactInputSourceDir(entry, index);
@@ -14126,7 +14597,7 @@ async function materializeRequiredArtifactInputs(config, command, workspace) {
14126
14597
  relativePath,
14127
14598
  contentType: readString(entry.contentType),
14128
14599
  byteSize: body.byteLength,
14129
- sha256,
14600
+ sha256: sha2562,
14130
14601
  contentPath
14131
14602
  });
14132
14603
  }
@@ -14163,7 +14634,7 @@ function safeCheckpointRelativePath(rawPath) {
14163
14634
  return normalized;
14164
14635
  }
14165
14636
  function hashFileSha256(filePath) {
14166
- return createHash13("sha256").update(readFileSync11(filePath)).digest("hex");
14637
+ return createHash15("sha256").update(readFileSync11(filePath)).digest("hex");
14167
14638
  }
14168
14639
  async function materializeIssueCheckpoint(config, command, workspace) {
14169
14640
  const checkpointDir = issueCheckpointDir(workspace);
@@ -14332,8 +14803,9 @@ async function executeRunCommand(config, command) {
14332
14803
  asRecord(asRecord(command.payload).contextSnapshot)
14333
14804
  );
14334
14805
  const cwd = workspace.cwd;
14806
+ let materializedAgentInstructions = [];
14335
14807
  try {
14336
- await materializeAgentInstructionsBundle(config, command, workspace);
14808
+ materializedAgentInstructions = await materializeAgentInstructionsBundle(config, command, workspace);
14337
14809
  } catch (err) {
14338
14810
  await ingestLog(config, command, "system", "warn", `Failed to materialize agent instruction files: ${err instanceof Error ? err.message : String(err)}`, {
14339
14811
  error: err instanceof Error ? err.message : String(err)
@@ -14351,7 +14823,9 @@ async function executeRunCommand(config, command) {
14351
14823
  }
14352
14824
  await ingestWorkspaceStatus(config, command, cwd);
14353
14825
  const promptCompilation = buildCommandPrompt(command, workspace, materializedAttachments, {
14826
+ runnerKind: config.runnerKind,
14354
14827
  executorKind: executor.kind,
14828
+ materializedAgentInstructionFiles: materializedAgentInstructions.map((entry) => entry.path),
14355
14829
  managedMcpToolMode: executor.kind === "pi" && Object.keys(governedMcp).length > 0 ? readString(governedMcp.mcpToolMode) ?? MANAGED_PI_MCP_TOOL_MODE : null,
14356
14830
  managedMcpToolCatalog: asRecord(governedMcp.toolCatalog),
14357
14831
  artifactVerifierCommands: config.artifactVerifierCommands,
@@ -14606,6 +15080,12 @@ async function executeRunCommand(config, command) {
14606
15080
  presentationKind: "context_manifest",
14607
15081
  contextManifest
14608
15082
  });
15083
+ if (contextManifest.currentRunContractShadow.status !== "match") {
15084
+ await ingestLog(config, command, "system", "warn", "Current Run Contract shadow comparison did not match the legacy runtime inference", {
15085
+ presentationKind: "current_run_contract_shadow_audit",
15086
+ currentRunContractShadow: contextManifest.currentRunContractShadow
15087
+ });
15088
+ }
14609
15089
  await ackCommand(config, command, "spawned");
14610
15090
  await ingestLog(config, command, "system", "info", `Starting ${executor.kind} executor`, {
14611
15091
  executorKind: executor.kind,
@@ -14889,10 +15369,11 @@ async function executeRunCommand(config, command) {
14889
15369
  const sourceErrorCode = sourceAcquisition ? execution.timedOut ? "source_acquisition_timeout" : cancelled ? "source_acquisition_cancelled" : hasOutputFlood ? "source_acquisition_output_flood" : hasMemoryLimit ? "source_acquisition_memory_limit" : execution.spawnError ? "source_acquisition_executor_unavailable" : succeeded ? null : "source_acquisition_executor_failed" : null;
14890
15370
  const error = sourceAcquisition ? sourceErrorCode : unsafeError;
14891
15371
  const costUsage = parsedCostUsage(parsed.usage);
15372
+ const cleanPiTerminalOutputStop = succeeded && completionOutputStopped && execution.completionOutputType === "agent_end" && parsed.terminalEventType === "agent_end" && Number.isInteger(parsed.terminalEventIndex);
14892
15373
  const executorOutcome = {
14893
- status: cancelled ? "cancelled" : execution.timedOut ? "timed_out" : execution.exitCode === 0 && execution.signal === null ? "completed" : "failed",
14894
- exitCode: execution.exitCode,
14895
- signal: execution.signal,
15374
+ status: cancelled ? "cancelled" : execution.timedOut ? "timed_out" : cleanPiTerminalOutputStop || execution.exitCode === 0 && execution.signal === null ? "completed" : "failed",
15375
+ exitCode: cleanPiTerminalOutputStop ? 0 : execution.exitCode,
15376
+ signal: cleanPiTerminalOutputStop ? null : execution.signal,
14896
15377
  terminalEvent: ["agent_end", "turn_end"].includes(readString(parsed.terminalEventType) ?? "") ? readString(parsed.terminalEventType) : null,
14897
15378
  terminalEventIndex: Number.isInteger(parsed.terminalEventIndex) ? parsed.terminalEventIndex : null
14898
15379
  };
@@ -6,7 +6,7 @@ import { basename, dirname, join, resolve } from "node:path";
6
6
  import { homedir, hostname } from "node:os";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
- const CONNECTOR_VERSION = "0.1.1-beta.20";
9
+ const CONNECTOR_VERSION = "0.1.1-beta.22";
10
10
 
11
11
  const CAPABILITIES = [
12
12
  "remote_registration",
@@ -16,6 +16,7 @@ const CAPABILITIES = [
16
16
  "run_wakeup",
17
17
  "runtime_actions_v2",
18
18
  "model_call",
19
+ "model_call_output_contract_v1",
19
20
  "run_cancel",
20
21
  "run_terminate",
21
22
  "logs_cost_workspace_status",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.1-beta.20",
3
+ "version": "0.1.1-beta.22",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",