@amaster.ai/employee-runtime-connector 0.1.0-beta.2 → 0.1.0-beta.4

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
@@ -21,6 +21,8 @@ Do not use `latest`, `^`, or `~` in a runtime image. The image tag and connector
21
21
 
22
22
  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
23
 
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.
25
+
24
26
  ## Package Contents
25
27
 
26
28
  - `dist/amaster-runtime.mjs`: configuration, pairing, workspace, diagnostics, and daemon lifecycle CLI.
@@ -2314,7 +2314,7 @@ import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSy
2314
2314
  import { homedir, hostname } from "node:os";
2315
2315
  import { basename, delimiter, dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
2316
2316
  import { spawn, spawnSync } from "node:child_process";
2317
- const CONNECTOR_VERSION = "0.1.0-beta.2";
2317
+ const CONNECTOR_VERSION = "0.1.0-beta.4";
2318
2318
  const MAX_INFERRED_ARTIFACT_UPLOADS = 20;
2319
2319
  const MAX_CHECKPOINT_BYTES = 20 * 1024 * 1024;
2320
2320
  const CHECKPOINT_TTL_MS = 24 * 60 * 60 * 1000;
@@ -3508,7 +3508,9 @@ function runtimeActionsInstruction(options = {}) {
3508
3508
  : [];
3509
3509
  return [
3510
3510
  "Runtime action bridge:",
3511
- "If direct AMaster API requests are unavailable from the executor sandbox, do not stop at blocked. Instead finish with this exact marker and a JSON object:",
3511
+ "Choose exactly one mutation path for each requested action: direct AMaster API or the runtime action bridge. Never replay the same mutation through both paths.",
3512
+ "If direct AMaster API requests succeed for all requested mutations, finish with a normal summary and do not emit or mention the AMASTER_RUNTIME_ACTIONS marker.",
3513
+ "If direct AMaster API requests are unavailable from the executor sandbox, do not stop at blocked. Use the runtime action bridge for the unapplied mutations.",
3512
3514
  "Use runtime actions as a continuation patch, not as a full replay. If the wake reason or latest comments say a confirmation was accepted, rejected, or that no more child tasks/interactions should be created, do not recreate those earlier actions. Add the final result comment and update the parent task instead.",
3513
3515
  "If the wake reason is issue_children_completed, treat the completed child tasks as already resolved blockers. Do not recreate blocker child tasks, do not repeat the first-run blocker plan, and do not create another review path unless new human input is truly required. Summarize the completed child work and use update_parent status done when no human review is needed.",
3514
3516
  "Use update_parent status done when no human review is needed. Prefer creating a pending review path such as request_confirmation, request_checkbox_confirmation, ask_user_questions, or suggest_tasks before status in_review; if a bare in_review update is emitted, AMaster will create a fallback request_confirmation before PATCH.",
@@ -3530,10 +3532,11 @@ function runtimeActionsInstruction(options = {}) {
3530
3532
  options.canOrchestrateOrganization
3531
3533
  ? "When assigning a newly hired agent's first task in the same action batch, set clientKey on the agent_hire action and set assigneeAgentClientKey or agentClientKey on the create_child_task action to that same key. Do not leave the first task assigned to the current CEO/executing agent unless the CEO should actually do the work."
3532
3534
  : "",
3533
- "Output format: write the marker AMASTER_RUNTIME_ACTIONS, then exactly one fenced json object. Use this literal shape with real action objects: {\"version\":1,\"actions\":[{\"type\":\"add_comment\",\"body\":\"Progress or result summary\"}]}.",
3535
+ "Fallback output format: write the marker AMASTER_RUNTIME_ACTIONS, then exactly one fenced json object. Use this literal shape with real action objects: {\"version\":1,\"actions\":[{\"type\":\"add_comment\",\"body\":\"Progress or result summary\"}]}.",
3534
3536
  "The runtime action block must be strict JSON parseable by JSON.parse. Do not use ellipses, placeholders such as [...], comments, trailing commas, single quotes, markdown tables outside quoted strings, or raw double quotes inside string values. Escape quotes and newlines in string values, or generate the block with JSON.stringify / @amaster/runtime-sdk before printing it.",
3535
3537
  "Before final output, validate the runtime action block with JSON.parse. If it would fail, fix the JSON and only then print AMASTER_RUNTIME_ACTIONS.",
3536
3538
  `Allowed action types: ${allowedActionTypes}.`,
3539
+ "For every create_interaction action, set top-level kind to the interaction kind and set payload to a JSON object. Use this complete canonical request_confirmation example: {\"type\":\"create_interaction\",\"kind\":\"request_confirmation\",\"payload\":{\"version\":1,\"prompt\":\"Confirm this result?\",\"acceptLabel\":\"确认\",\"rejectLabel\":\"调整\"}}. Never use interactionType.",
3537
3540
  "For create_interaction ask_user_questions, use payload {\"version\":1,\"title\":\"...\",\"questions\":[{\"id\":\"question_key\",\"prompt\":\"Question text\",\"selectionMode\":\"single\",\"required\":true,\"options\":[{\"id\":\"option_key\",\"label\":\"Option label\"}]}]}. Do not use question/options.value at the top level.",
3538
3541
  "For create_interaction request_confirmation, use payload {\"version\":1,\"prompt\":\"Confirm this result?\",\"acceptLabel\":\"确认\",\"rejectLabel\":\"调整\"}. Do not use options arrays for request_confirmation.",
3539
3542
  "For create_interaction request_checkbox_confirmation, use payload {\"version\":1,\"prompt\":\"Select approved items\",\"options\":[{\"id\":\"option_key\",\"label\":\"Option label\"}],\"minSelected\":1,\"maxSelected\":2,\"acceptLabel\":\"确认\",\"rejectLabel\":\"调整\"}.",
@@ -5269,9 +5272,10 @@ function extractRuntimeActionEnvelope(text) {
5269
5272
  const structuredEnvelope = tryExtractStructuredRuntimeActionEnvelope(text);
5270
5273
  if (structuredEnvelope) return structuredEnvelope;
5271
5274
 
5272
- const markerIndex = text.indexOf("AMASTER_RUNTIME_ACTIONS");
5273
- if (markerIndex === -1) return null;
5274
- const jsonStart = text.indexOf("{", markerIndex);
5275
+ const markerMatch = /^[ \t]*AMASTER_RUNTIME_ACTIONS[ \t]*$/m.exec(text);
5276
+ if (!markerMatch) return null;
5277
+ const markerEnd = markerMatch.index + markerMatch[0].length;
5278
+ const jsonStart = text.indexOf("{", markerEnd);
5275
5279
  if (jsonStart === -1) {
5276
5280
  const err = new Error("AMASTER_RUNTIME_ACTIONS JSON could not be parsed: missing JSON object");
5277
5281
  err.runtimeActionType = "parse";
@@ -5290,7 +5294,9 @@ function extractRuntimeActionEnvelope(text) {
5290
5294
 
5291
5295
  function tryExtractStructuredRuntimeActionEnvelope(text) {
5292
5296
  const source = String(text ?? "");
5293
- const markerRe = /(^|\r?\n)[ \t]*AMASTER_RUNTIME_ACTIONS\b/g;
5297
+ // Completion detection is permissive about fenced JSON, but the protocol
5298
+ // marker itself must still be the only content on its line.
5299
+ const markerRe = /(^|\r?\n)[ \t]*AMASTER_RUNTIME_ACTIONS[ \t]*(?:\r?\n|$)/g;
5294
5300
  let match;
5295
5301
  while ((match = markerRe.exec(source)) !== null) {
5296
5302
  let cursor = markerRe.lastIndex;
@@ -6116,8 +6122,13 @@ function runtimeActionReviewConfirmation(action, runtimeAuth, command, actionCon
6116
6122
  payload: {
6117
6123
  version: 1,
6118
6124
  prompt: copy.prompt,
6119
- acceptLabel: "确认,继续推进",
6120
- rejectLabel: "需要修订",
6125
+ resolutionMode: "review",
6126
+ acceptLabel: "接受并继续",
6127
+ requestChangesLabel: "退回修改",
6128
+ requestChangesReasonLabel: "说明需要补充或修改的内容",
6129
+ rejectLabel: "拒绝并停止",
6130
+ rejectRequiresReason: true,
6131
+ rejectReasonLabel: "说明停止该任务的原因",
6121
6132
  detailsMarkdown,
6122
6133
  target: {
6123
6134
  type: "custom",
@@ -6599,9 +6610,14 @@ function normalizeRequestConfirmationPayload(payload, action) {
6599
6610
  return {
6600
6611
  version: normalized.version === 1 ? normalized.version : 1,
6601
6612
  prompt,
6613
+ ...(readString(normalized.resolutionMode) === "review" ? { resolutionMode: "review" } : {}),
6602
6614
  ...(readString(normalized.acceptLabel) ?? readString(action.acceptLabel)
6603
6615
  ? { acceptLabel: readString(normalized.acceptLabel) ?? readString(action.acceptLabel) }
6604
6616
  : {}),
6617
+ ...(readString(normalized.requestChangesLabel) ? { requestChangesLabel: readString(normalized.requestChangesLabel) } : {}),
6618
+ ...(readString(normalized.requestChangesReasonLabel)
6619
+ ? { requestChangesReasonLabel: readString(normalized.requestChangesReasonLabel) }
6620
+ : {}),
6605
6621
  ...(readString(normalized.rejectLabel) ?? readString(action.rejectLabel)
6606
6622
  ? { rejectLabel: readString(normalized.rejectLabel) ?? readString(action.rejectLabel) }
6607
6623
  : {}),
@@ -5,7 +5,7 @@ import { dirname, join, resolve } from "node:path";
5
5
  import { homedir, hostname } from "node:os";
6
6
  import { fileURLToPath } from "node:url";
7
7
 
8
- const CONNECTOR_VERSION = "0.1.0-beta.2";
8
+ const CONNECTOR_VERSION = "0.1.0-beta.4";
9
9
 
10
10
  const CAPABILITIES = [
11
11
  "remote_registration",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/employee-runtime-connector",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.4",
4
4
  "description": "AMaster Employee runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",