@amaster.ai/employee-runtime-connector 0.1.1-beta.1 → 0.1.1-beta.3

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.
@@ -1593,8 +1593,6 @@ var MANAGED_PI_PROVIDER_ENV_NAMES = Object.freeze([
1593
1593
  "AMASTER_MODEL_CREDENTIAL_REF",
1594
1594
  "AMASTER_API_KEY",
1595
1595
  "AMASTER_PROVIDER_BASE_URL",
1596
- "AMASTER_PROVIDER_DEFAULT_MODEL",
1597
- "AMASTER_PROVIDER_FLASH_MODEL",
1598
1596
  "AMASTER_PLATFORM_OAUTH_TOKEN",
1599
1597
  "AMASTER_PLATFORM_ORGANIZATION_ID",
1600
1598
  "AMASTER_BILLING_TURN_ID"
@@ -1636,28 +1634,6 @@ function imageGenBaseUrlFromProviderBaseUrl(value) {
1636
1634
  return input.replace(/\/v1\/?$/, "");
1637
1635
  }
1638
1636
  }
1639
- function ensureAmasterProviderModel(models, modelId, flash) {
1640
- const id = readString(modelId);
1641
- if (!id) return;
1642
- const existing = Array.isArray(models) ? models : [];
1643
- const index = existing.findIndex((entry) => asRecord(entry).id === id);
1644
- if (index >= 0) {
1645
- existing[index] = {
1646
- ...asRecord(existing[index]),
1647
- id,
1648
- input: readStringArray(asRecord(existing[index]).input).length > 0 ? asRecord(existing[index]).input : ["text", "image"],
1649
- reasoning: asRecord(existing[index]).reasoning ?? true,
1650
- ...flash ? { flash: true } : {}
1651
- };
1652
- return;
1653
- }
1654
- existing.push({
1655
- id,
1656
- input: ["text", "image"],
1657
- reasoning: true,
1658
- ...flash ? { flash: true } : {}
1659
- });
1660
- }
1661
1637
  function withoutManagedBillingHeaders(value) {
1662
1638
  const headers = { ...asRecord(value) };
1663
1639
  for (const name of Object.keys(AMASTER_BILLING_HEADER_ENV_REFERENCES)) {
@@ -1689,10 +1665,6 @@ function syncAmasterProviderModels(agentDir, executorEnv) {
1689
1665
  const headers = syncManagedBillingHeaders(amaster.headers, executorEnv);
1690
1666
  if (headers) amaster.headers = headers;
1691
1667
  else delete amaster.headers;
1692
- const models = Array.isArray(amaster.models) ? [...amaster.models] : [];
1693
- ensureAmasterProviderModel(models, executorEnv.AMASTER_PROVIDER_DEFAULT_MODEL, false);
1694
- ensureAmasterProviderModel(models, executorEnv.AMASTER_PROVIDER_FLASH_MODEL, true);
1695
- if (models.length > 0) amaster.models = models;
1696
1668
  writeJsonFileAtomic(modelsPath, {
1697
1669
  ...config,
1698
1670
  providers: {
@@ -1709,19 +1681,8 @@ function syncAmasterProviderSettings(agentDir, executorEnv) {
1709
1681
  if (!existsSync2(settingsPath)) return false;
1710
1682
  const settings = readJsonFile(settingsPath);
1711
1683
  const baseUrl = readString(executorEnv.AMASTER_PROVIDER_BASE_URL);
1712
- const defaultModel = readString(executorEnv.AMASTER_PROVIDER_DEFAULT_MODEL);
1713
1684
  const imageGenBaseUrl = imageGenBaseUrlFromProviderBaseUrl(baseUrl);
1714
1685
  let changed = false;
1715
- if (defaultModel) {
1716
- if (settings.defaultProvider !== "amaster") {
1717
- settings.defaultProvider = "amaster";
1718
- changed = true;
1719
- }
1720
- if (settings.defaultModel !== defaultModel) {
1721
- settings.defaultModel = defaultModel;
1722
- changed = true;
1723
- }
1724
- }
1725
1686
  const imageGen = settings["pi-image-gen"];
1726
1687
  if (isRecord(imageGen) && isRecord(imageGen.customProviders) && isRecord(imageGen.customProviders.amaster)) {
1727
1688
  const customProviders = imageGen.customProviders;
@@ -1828,19 +1789,161 @@ function escapeLiteralJsonStringControlCharacters(value) {
1828
1789
  }
1829
1790
  return changed ? output : value;
1830
1791
  }
1792
+ function escapeLikelyLiteralJsonStringQuotes(value) {
1793
+ let output = "";
1794
+ let inString = false;
1795
+ let escaped = false;
1796
+ let changed = false;
1797
+ let stringRole = null;
1798
+ let previousSignificantCharacter = null;
1799
+ function followingObjectProperty(offset) {
1800
+ let cursor = offset;
1801
+ while (cursor < value.length && /\s/u.test(value[cursor])) cursor += 1;
1802
+ if (value[cursor] !== '"') return { valid: false, simpleIdentifier: false };
1803
+ cursor += 1;
1804
+ let propertyName = "";
1805
+ let propertyEscaped = false;
1806
+ for (; cursor < value.length; cursor += 1) {
1807
+ const propertyCharacter = value[cursor];
1808
+ if (propertyEscaped) {
1809
+ propertyName += propertyCharacter;
1810
+ propertyEscaped = false;
1811
+ continue;
1812
+ }
1813
+ if (propertyCharacter === "\\") {
1814
+ propertyEscaped = true;
1815
+ continue;
1816
+ }
1817
+ if (propertyCharacter !== '"') {
1818
+ propertyName += propertyCharacter;
1819
+ continue;
1820
+ }
1821
+ cursor += 1;
1822
+ while (cursor < value.length && /\s/u.test(value[cursor])) cursor += 1;
1823
+ return {
1824
+ valid: value[cursor] === ":",
1825
+ simpleIdentifier: /^[A-Za-z_][A-Za-z0-9_-]*$/u.test(propertyName)
1826
+ };
1827
+ }
1828
+ return { valid: false, simpleIdentifier: false };
1829
+ }
1830
+ for (let index = 0; index < value.length; index += 1) {
1831
+ const character = value[index];
1832
+ if (!inString) {
1833
+ output += character;
1834
+ if (character === '"') {
1835
+ inString = true;
1836
+ stringRole = previousSignificantCharacter === ":" ? "object_value" : null;
1837
+ } else if (!/\s/u.test(character)) {
1838
+ previousSignificantCharacter = character;
1839
+ }
1840
+ continue;
1841
+ }
1842
+ if (escaped) {
1843
+ output += character;
1844
+ escaped = false;
1845
+ continue;
1846
+ }
1847
+ if (character === "\\") {
1848
+ output += character;
1849
+ escaped = true;
1850
+ continue;
1851
+ }
1852
+ if (character !== '"') {
1853
+ output += character;
1854
+ continue;
1855
+ }
1856
+ let nextIndex = index + 1;
1857
+ while (nextIndex < value.length && /\s/u.test(value[nextIndex])) nextIndex += 1;
1858
+ const nextCharacter = value[nextIndex];
1859
+ if (nextCharacter === "," && stringRole === "object_value") {
1860
+ const following = followingObjectProperty(nextIndex + 1);
1861
+ if (!following.valid && !following.simpleIdentifier) {
1862
+ output += '\\"';
1863
+ changed = true;
1864
+ continue;
1865
+ }
1866
+ }
1867
+ if (nextCharacter === void 0 || [":", ",", "}", "]"].includes(nextCharacter)) {
1868
+ output += character;
1869
+ inString = false;
1870
+ stringRole = null;
1871
+ previousSignificantCharacter = character;
1872
+ } else {
1873
+ output += '\\"';
1874
+ changed = true;
1875
+ }
1876
+ }
1877
+ return changed ? output : value;
1878
+ }
1879
+ function insertSingleMissingObjectPropertyComma(value) {
1880
+ let parseError;
1881
+ try {
1882
+ JSON.parse(value);
1883
+ return value;
1884
+ } catch (error) {
1885
+ parseError = error;
1886
+ }
1887
+ const positionMatch = String(parseError?.message ?? "").match(
1888
+ /Expected ',' or '\}' after property value in JSON at position (\d+)/u
1889
+ );
1890
+ if (!positionMatch) return value;
1891
+ const position = Number(positionMatch[1]);
1892
+ if (!Number.isSafeInteger(position) || position < 1 || position >= value.length) return value;
1893
+ let propertyStart = position;
1894
+ while (propertyStart < value.length && /\s/u.test(value[propertyStart])) propertyStart += 1;
1895
+ if (value[propertyStart] !== '"') return value;
1896
+ let cursor = propertyStart + 1;
1897
+ let escaped = false;
1898
+ let propertyName = "";
1899
+ for (; cursor < value.length; cursor += 1) {
1900
+ const character = value[cursor];
1901
+ if (escaped) {
1902
+ propertyName += character;
1903
+ escaped = false;
1904
+ continue;
1905
+ }
1906
+ if (character === "\\") {
1907
+ escaped = true;
1908
+ continue;
1909
+ }
1910
+ if (character === '"') break;
1911
+ propertyName += character;
1912
+ }
1913
+ if (cursor >= value.length || !/^[A-Za-z_][A-Za-z0-9_-]*$/u.test(propertyName)) return value;
1914
+ cursor += 1;
1915
+ while (cursor < value.length && /\s/u.test(value[cursor])) cursor += 1;
1916
+ if (value[cursor] !== ":") return value;
1917
+ let previous = position - 1;
1918
+ while (previous >= 0 && /\s/u.test(value[previous])) previous -= 1;
1919
+ if (previous < 0 || !['"', "}", "]", "e", "l"].includes(value[previous]) && !/[0-9]/u.test(value[previous])) {
1920
+ return value;
1921
+ }
1922
+ const candidate = `${value.slice(0, position)},${value.slice(position)}`;
1923
+ try {
1924
+ return isJsonObject(JSON.parse(candidate)) ? candidate : value;
1925
+ } catch {
1926
+ return value;
1927
+ }
1928
+ }
1831
1929
  function normalizePiMcpProxyArgs(value) {
1832
1930
  if (typeof value !== "string") return { value, repaired: false };
1833
1931
  try {
1834
1932
  JSON.parse(value);
1835
1933
  return { value, repaired: false };
1836
1934
  } catch {
1837
- const repairedValue = escapeLiteralJsonStringControlCharacters(value);
1838
- if (repairedValue === value) return { value, repaired: false };
1839
- try {
1840
- return isJsonObject(JSON.parse(repairedValue)) ? { value: repairedValue, repaired: true } : { value, repaired: false };
1841
- } catch {
1842
- return { value, repaired: false };
1935
+ const repairedControlCharacters = escapeLiteralJsonStringControlCharacters(value);
1936
+ const repairedValue = escapeLikelyLiteralJsonStringQuotes(repairedControlCharacters);
1937
+ if (repairedValue !== value) {
1938
+ try {
1939
+ if (isJsonObject(JSON.parse(repairedValue))) {
1940
+ return { value: repairedValue, repaired: true };
1941
+ }
1942
+ } catch {
1943
+ }
1843
1944
  }
1945
+ const commaRepairedValue = insertSingleMissingObjectPropertyComma(repairedControlCharacters);
1946
+ return commaRepairedValue !== value ? { value: commaRepairedValue, repaired: true } : { value, repaired: false };
1844
1947
  }
1845
1948
  }
1846
1949
  function registerManagedPiMcpArgsNormalizer(pi) {
@@ -1854,6 +1957,8 @@ function managedPiMcpArgsNormalizerExtensionSource() {
1854
1957
  return [
1855
1958
  isJsonObject.toString(),
1856
1959
  escapeLiteralJsonStringControlCharacters.toString(),
1960
+ escapeLikelyLiteralJsonStringQuotes.toString(),
1961
+ insertSingleMissingObjectPropertyComma.toString(),
1857
1962
  normalizePiMcpProxyArgs.toString(),
1858
1963
  `export default ${registerManagedPiMcpArgsNormalizer.toString()};`,
1859
1964
  ""
@@ -2270,7 +2375,7 @@ function createManagedPiMcpProfileApi(options = {}) {
2270
2375
  } catch {
2271
2376
  throw new Error(`pi_managed_mcp_attestation_failed: configured ${MANAGED_WEB_ACCESS_PACKAGE} package metadata is invalid`);
2272
2377
  }
2273
- if (packageMetadata.name !== MANAGED_WEB_ACCESS_PACKAGE) {
2378
+ if (!packageMetadata || packageMetadata.name !== MANAGED_WEB_ACCESS_PACKAGE) {
2274
2379
  throw new Error(`pi_managed_mcp_attestation_failed: configured ${MANAGED_WEB_ACCESS_PACKAGE} package identity mismatch`);
2275
2380
  }
2276
2381
  return {
@@ -2479,6 +2584,9 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
2479
2584
  const restoredNativeSession = restoreManagedPiSessionRollout(input, sessionsRoot, runDir, executorHome, authority);
2480
2585
  const configPath = join4(piCodingAgentDir, "mcp.json");
2481
2586
  const config = {
2587
+ settings: {
2588
+ toolPrefix: "none"
2589
+ },
2482
2590
  mcpServers: {
2483
2591
  [SUPPORTED_SERVER_NAME2]: {
2484
2592
  type: "http",
@@ -3369,13 +3477,16 @@ function wikiAccessRuleLine(input) {
3369
3477
  return "";
3370
3478
  }
3371
3479
  function fixedRules(input, includeIssueLine) {
3480
+ const issue = asRecord(asRecord(input.context).paperclipIssue);
3481
+ const businessOutcome = asRecord(asRecord(issue.taskRequirements).businessOutcome);
3482
+ const serverOwnedBusinessOutcomeReview = businessOutcome.mode === "required";
3372
3483
  return [
3373
3484
  "## AMaster Runtime Connector Task",
3374
3485
  "MirrorX task.",
3375
3486
  "Use only the declared workspace; make concrete progress and report concisely.",
3376
3487
  "Before changing the task status to done, audit every explicit requirement in the task against the final evidence. A successful tool or document write proves delivery, not acceptance: inspect the delivered content for required sections, diagrams, tables, and factual constraints.",
3377
3488
  "Do not leave stale in-progress wording such as \u201Ccurrent run\u201D in a terminal deliverable; rewrite it to the final observed state. Do not list finalization itself as remaining or next work in a terminal deliverable.",
3378
- "If any requirement is missing or cannot be verified, do not mark done. To request review, use create_interaction with kind request_confirmation and payload.resolutionMode review; never call update_parent with status in_review. Otherwise keep the issue todo or blocked with the exact gap and next owner.",
3489
+ serverOwnedBusinessOutcomeReview ? "If any requirement is missing or cannot be verified, do not mark done or request final completion or Business Outcome review. Keep the issue in_progress or blocked with the exact gap and next owner. An intermediate review remains available only for an exact document revision that must be approved before execution can continue: use create_interaction with kind request_confirmation, payload.resolutionMode review, and purposeCode review_document_revision; never use that interaction as final completion or Outcome acceptance." : "If any requirement is missing or cannot be verified, do not mark done. To request review, use create_interaction with kind request_confirmation and payload.resolutionMode review; never call update_parent with status in_review. Otherwise keep the issue todo or blocked with the exact gap and next owner.",
3379
3490
  DEADLINE_POSTURE_GUARD,
3380
3491
  "Do not install operating-system or user-global packages, and do not use host package managers such as brew, apt, yum, or global pip/npm installs. Use tools already available or workspace-local dependencies or virtual environments. If a required renderer or evaluator is unavailable, keep the source artifact, record the exact verification gap, and do not mutate the host.",
3381
3492
  `- command id: ${input.commandId}`,
@@ -3409,7 +3520,7 @@ function interactionResolutionText(context) {
3409
3520
  if (Object.keys(resolution).length === 0) return "";
3410
3521
  const target = asRecord(resolution.target);
3411
3522
  const exactDocumentRevisionDirective = readString(resolution.status) === "changes_requested" && readString(target.type) === "issue_document" && readString(target.issueId) && readString(target.documentId) && readString(target.key) && readString(target.revisionId) ? [
3412
- "The review target is an exact issue_document revision. Revise that same document with upsert_document_revision: copy target.issueId, target.documentId, and target.key, and use target.revisionId as baseRevisionId.",
3523
+ "The review target is an exact issue_document revision. Revise that same document with upsert_document_revision: copy target.issueId, target.documentId, and target.key, use target.revisionId as baseRevisionId, and put the complete revised markdown in the required action.body; metadata-only revisions are invalid.",
3413
3524
  "Do not copy the reviewed document into the current issue and do not restart its revision lineage at 1."
3414
3525
  ].join(" ") : "";
3415
3526
  return [
@@ -3520,7 +3631,10 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
3520
3631
  optionId: readString(optionId)
3521
3632
  })).filter((entry) => entry.optionId && !allowed.has(entry.authorizationClass));
3522
3633
  const issue = asRecord(context.paperclipIssue);
3523
- const completion = asRecord(asRecord(issue.taskRequirements).completion);
3634
+ const requirements = asRecord(issue.taskRequirements);
3635
+ const completion = asRecord(requirements.completion);
3636
+ const delivery = asRecord(requirements.delivery);
3637
+ const businessOutcome = asRecord(requirements.businessOutcome);
3524
3638
  const completionRole = readString(completion.role);
3525
3639
  const completionDeliverable = readString(completion.deliverable);
3526
3640
  const manifestRefreshOnly = isManifestRefreshOnly(context);
@@ -3530,13 +3644,26 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
3530
3644
  firstDocumentCheckpoint,
3531
3645
  "If work remains in an ordinary productive run, call update_parent with status: in_progress and a concrete next action so bounded continuation recovery can preserve a live path. Status: todo does not queue a normal continuation from an ordinary productive run. Only a server-issued successful-run handoff recovery may use status: todo, and only according to its exact Recovery Instruction. Otherwise use a supported terminal or waiting disposition."
3532
3646
  ].filter(Boolean).join(" ") : "";
3647
+ const businessOutcomeOwnershipContract = businessOutcome.mode === "required" ? [
3648
+ "Business Outcome review is owned by the Server terminal reconciler.",
3649
+ "Do not create a generic review-mode request_confirmation to ask the Board to accept final completion or the Outcome, and do not mark the issue done yourself. This does not prohibit an explicit intermediate review of an exact document revision before execution continues."
3650
+ ].join(" ") : "";
3651
+ const businessOutcomeTerminalContract = !suppressOrdinaryCompletionContract && businessOutcome.mode === "required" ? [
3652
+ delivery.mode === "required" ? "When every acceptance criterion is satisfied and the exact current Delivery Manifest is ready, record the final execution disposition with update_parent status in_progress and a concise evidence summary, then end the run successfully without creating a final review interaction." : "When every acceptance criterion is satisfied, record the final execution disposition with update_parent status in_progress and a concise evidence summary, then end the run successfully without creating a final review interaction.",
3653
+ delivery.mode === "required" ? "Only after the run and command succeed does the Server bind the exact current Delivery Manifest and terminal Outcome evidence, create the formal Board review before generic continuation handoff is evaluated, and move the issue to in_review. Board acceptance then finalizes the issue as done atomically." : "Only after the run and command succeed does the Server bind the terminal Outcome evidence, create the formal Board review before generic continuation handoff is evaluated, and move the issue to in_review. Board acceptance then finalizes the issue as done atomically."
3654
+ ].join(" ") : "";
3533
3655
  const authorizationContract = missing.length > 0 ? [
3534
3656
  `Current allowed action classes: ${[...allowed].join(", ") || "task_governance"}.`,
3535
3657
  "If the task requires a missing runtime action class, create a request_checkbox_confirmation interaction using the exact option id below and wait for its accepted continuation:",
3536
3658
  ...missing.map((entry) => `- ${entry.authorizationClass}: ${entry.optionId}`),
3537
3659
  "Never use request_confirmation to authorize a runtime action class."
3538
3660
  ].join("\n") : "";
3539
- return [completionContract, authorizationContract].filter(Boolean).join("\n");
3661
+ return [
3662
+ completionContract,
3663
+ businessOutcomeOwnershipContract,
3664
+ businessOutcomeTerminalContract,
3665
+ authorizationContract
3666
+ ].filter(Boolean).join("\n");
3540
3667
  }
3541
3668
  function runtimeDecompositionRequirementText(context) {
3542
3669
  const issue = asRecord(context.paperclipIssue);
@@ -3661,12 +3788,13 @@ function piMcpProxyExamplesText(input) {
3661
3788
  args: JSON.stringify(args)
3662
3789
  });
3663
3790
  return [
3664
- "The Pi native tool is the outer `mcp` proxy. Emit these as actual tool calls; `args` is the stringified inner canonical object:",
3791
+ "The Pi native tool is the outer `mcp` proxy. Emit these as actual tool calls; `args` is the stringified inner canonical object. Pi validates this string schema before extension hooks, so never send object-valued `args`:",
3665
3792
  "Keep review payload strings short. Reference the exact document key and revision in `target`; do not duplicate the reviewed document body in `prompt` or `detailsMarkdown`.",
3793
+ "payload.supersedesInteractionId is invalid. provenance.supersedesInteractionId is only for replacing a currently pending governed interaction; after changes_requested or rejected resolution, do not send a supersession id.",
3666
3794
  "update_parent.comment creates a separate persistent issue comment. Omit it when add_comment already recorded the message.",
3667
3795
  `- describe: ${proxy("runtime_action.describe", { schemaVersion: "runtime-action-v1", actionType: "update_parent" })}`,
3668
3796
  `- submit: ${proxy("runtime_action.submit", { schemaVersion: "runtime-action-v1", idempotencyKey: "task-123-progress", action: { type: "update_parent", status: "in_progress" } })}`,
3669
- `- submit review interaction: ${proxy("runtime_action.submit", { schemaVersion: "runtime-action-v1", idempotencyKey: "task-123-review", action: { type: "create_interaction", kind: "request_confirmation", continuationPolicy: "wake_assignee_on_accept", provenance: { purposeCode: "review_document_revision", requirementRefs: ["acceptance:document_review"], attentionOwner: { kind: "board", id: "board" }, epochKey: "document_revision:22222222-2222-4222-8222-222222222222" }, payload: { version: 1, resolutionMode: "review", prompt: "Review `plan` revision 1.", target: { type: "issue_document", issueId: "11111111-1111-4111-8111-111111111111", documentId: "33333333-3333-4333-8333-333333333333", key: "plan", revisionId: "22222222-2222-4222-8222-222222222222", revisionNumber: 1 } } } })}`,
3797
+ `- submit intermediate document review interaction: ${proxy("runtime_action.submit", { schemaVersion: "runtime-action-v1", idempotencyKey: "task-123-review", action: { type: "create_interaction", kind: "request_confirmation", continuationPolicy: "wake_assignee_on_accept", provenance: { purposeCode: "review_document_revision", requirementRefs: ["acceptance:document_review"], attentionOwner: { kind: "board", id: "board" }, epochKey: "document_revision:22222222-2222-4222-8222-222222222222" }, payload: { version: 1, resolutionMode: "review", prompt: "Review `plan` revision 1.", target: { type: "issue_document", issueId: "11111111-1111-4111-8111-111111111111", documentId: "33333333-3333-4333-8333-333333333333", key: "plan", revisionId: "22222222-2222-4222-8222-222222222222", revisionNumber: 1 } } } })}`,
3670
3798
  `- plan: ${proxy("runtime_action.plan", { schemaVersion: "runtime-action-v1", idempotencyKey: "task-123-plan", actions: [{ type: "update_parent", status: "in_progress" }] })}`,
3671
3799
  `- commit the returned plan revision: ${proxy("runtime_action.commit", { schemaVersion: "runtime-action-v1", planId: "11111111-1111-4111-8111-111111111111", revision: "plan-revision-1" })}`,
3672
3800
  `- read document: ${proxy("amaster.read_issue_document", { issueId: "AM-123", key: "plan" })}`
@@ -4153,16 +4281,38 @@ function tcReadNumber(value, fallback = 0) {
4153
4281
  return typeof value === "number" && Number.isFinite(value) ? value : fallback;
4154
4282
  }
4155
4283
  var TC_PI_ARGUMENT_VALIDATION_NODE_BUDGET = 4e3;
4156
- function tcContainsPiArgumentValidation(value, depth = 0, seen = /* @__PURE__ */ new WeakSet(), budget = { remaining: TC_PI_ARGUMENT_VALIDATION_NODE_BUDGET }) {
4157
- if (budget.remaining <= 0) return false;
4284
+ var TC_PI_ARGUMENT_VALIDATION_PATTERN = /\binvalid(?:[_ -]+)tool(?:[_ -]+)arguments?\b|\binvalid args json\b|\btool[- ]arguments? (?:failed )?validation\b/i;
4285
+ function tcFindPiArgumentValidationText(value, depth = 0, seen = /* @__PURE__ */ new WeakSet(), budget = { remaining: TC_PI_ARGUMENT_VALIDATION_NODE_BUDGET }) {
4286
+ if (budget.remaining <= 0) return null;
4158
4287
  budget.remaining -= 1;
4159
4288
  if (typeof value === "string") {
4160
- return /\binvalid(?:[_ -]+)tool(?:[_ -]+)arguments?\b|\binvalid args json\b|\btool[- ]arguments? (?:failed )?validation\b/i.test(value.slice(0, 2e4));
4289
+ const bounded = value.slice(0, 2e4);
4290
+ return TC_PI_ARGUMENT_VALIDATION_PATTERN.test(bounded) ? bounded : null;
4161
4291
  }
4162
- if (!value || typeof value !== "object" || depth >= 6 || seen.has(value)) return false;
4292
+ if (!value || typeof value !== "object" || depth >= 6 || seen.has(value)) return null;
4163
4293
  seen.add(value);
4164
4294
  const entries = Array.isArray(value) ? value.slice(0, 40).map((entry, index) => [String(index), entry]) : Object.entries(value).slice(0, 80);
4165
- return entries.some(([, entry]) => tcContainsPiArgumentValidation(entry, depth + 1, seen, budget));
4295
+ for (const [, entry] of entries) {
4296
+ const match = tcFindPiArgumentValidationText(entry, depth + 1, seen, budget);
4297
+ if (match) return match;
4298
+ }
4299
+ return null;
4300
+ }
4301
+ function tcPiArgumentValidationDiagnostic(value) {
4302
+ const text = tcFindPiArgumentValidationText(value);
4303
+ if (!text) return null;
4304
+ const normalized = text.toLowerCase();
4305
+ const validationSource = /\binvalid args json\b/iu.test(text) ? "invalid_args_json" : /\binvalid(?:[_ -]+)tool(?:[_ -]+)arguments?\b/iu.test(text) ? "invalid_tool_arguments" : "tool_argument_validation";
4306
+ const parseErrorKind = validationSource !== "invalid_args_json" ? null : normalized.includes("unexpected end") ? "unexpected_end" : normalized.includes("unexpected token") || normalized.includes("unexpected non-whitespace") ? "unexpected_token" : normalized.includes("unterminated string") ? "unterminated_string" : normalized.includes("bad control character") ? "bad_control_character" : normalized.includes("bad escaped character") || normalized.includes("invalid escape") ? "bad_escape" : /expected (?:','|'\}'|':'|property name|double-quoted property)/u.test(normalized) ? "missing_delimiter" : "other";
4307
+ const rawPosition = validationSource === "invalid_args_json" ? text.match(/\bposition\s+(\d{1,9})\b/iu)?.[1] : null;
4308
+ const parseErrorPosition = rawPosition ? Number(rawPosition) : null;
4309
+ return {
4310
+ validationSource,
4311
+ validationPath: validationSource === "invalid_args_json" ? "$.args" : "$",
4312
+ pathPrecision: validationSource === "invalid_args_json" ? "exact" : "root_only",
4313
+ ...parseErrorKind ? { parseErrorKind } : {},
4314
+ ...typeof parseErrorPosition === "number" && Number.isSafeInteger(parseErrorPosition) && parseErrorPosition >= 0 ? { parseErrorPosition } : {}
4315
+ };
4166
4316
  }
4167
4317
  function tcTruncateText(value, maxChars = 16e3) {
4168
4318
  const text = String(value ?? "");
@@ -4535,7 +4685,7 @@ function summarizePiEvent(event) {
4535
4685
  if (type === "tool_execution_start" || type === "tool_execution_end") {
4536
4686
  const toolName = tcReadString(event.toolName) ?? "unknown";
4537
4687
  const completed = type === "tool_execution_end";
4538
- const argumentValidationFailed = completed && event.isError === true && tcContainsPiArgumentValidation(event.result);
4688
+ const argumentValidationDiagnostic = completed && event.isError === true ? tcPiArgumentValidationDiagnostic(event.result) : null;
4539
4689
  return {
4540
4690
  stream: "system",
4541
4691
  level: completed && event.isError === true ? "error" : "info",
@@ -4546,7 +4696,7 @@ function summarizePiEvent(event) {
4546
4696
  toolName,
4547
4697
  toolCallId: tcReadString(event.toolCallId),
4548
4698
  status: completed ? event.isError === true ? "failed" : "completed" : "started",
4549
- ...argumentValidationFailed ? { errorCode: "invalid_tool_arguments" } : {}
4699
+ ...argumentValidationDiagnostic ? { errorCode: "invalid_tool_arguments", ...argumentValidationDiagnostic } : {}
4550
4700
  }
4551
4701
  };
4552
4702
  }
@@ -8021,7 +8171,7 @@ function assertSourceAcquisitionRuntimeAuthority({
8021
8171
  }
8022
8172
 
8023
8173
  // src/amaster-runtime-daemon.mjs
8024
- var CONNECTOR_VERSION = "0.1.1-beta.1";
8174
+ var CONNECTOR_VERSION = "0.1.1-beta.3";
8025
8175
  var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
8026
8176
  var SOURCE_ACQUISITION_CAPABILITY = "source_acquisition_v1";
8027
8177
  var SOURCE_ACQUISITION_PROFILE_VERSION = "source_acquisition_v1";
@@ -8745,9 +8895,7 @@ function readPiAgentLocalPlatformCredential(credentialsDir) {
8745
8895
  return {
8746
8896
  organizationId,
8747
8897
  apiKey,
8748
- ...readString(credential.baseUrl) ? { baseUrl: readString(credential.baseUrl) } : {},
8749
- ...readString(credential.defaultModel) ? { defaultModel: readString(credential.defaultModel) } : {},
8750
- ...readString(credential.flashModel) ? { flashModel: readString(credential.flashModel) } : {}
8898
+ ...readString(credential.baseUrl) ? { baseUrl: readString(credential.baseUrl) } : {}
8751
8899
  };
8752
8900
  }
8753
8901
  function piAgentLocalPlatformCredentials(config) {
@@ -9368,9 +9516,7 @@ async function syncPiExecutorProviderConfig(config, command, agentDir, resolvedP
9368
9516
  modelsSynced,
9369
9517
  settingsSynced,
9370
9518
  credentialSource,
9371
- providerBaseUrlConfigured: Boolean(readString(providerConfig.AMASTER_PROVIDER_BASE_URL)),
9372
- defaultModelConfigured: Boolean(readString(providerConfig.AMASTER_PROVIDER_DEFAULT_MODEL)),
9373
- flashModelConfigured: Boolean(readString(providerConfig.AMASTER_PROVIDER_FLASH_MODEL))
9519
+ providerBaseUrlConfigured: Boolean(readString(providerConfig.AMASTER_PROVIDER_BASE_URL))
9374
9520
  });
9375
9521
  }
9376
9522
  }
@@ -9384,9 +9530,7 @@ function piAgentLocalPlatformCredentialForCommand(config, command) {
9384
9530
  if (!credential) return null;
9385
9531
  return {
9386
9532
  AMASTER_API_KEY: credential.apiKey,
9387
- ...credential.baseUrl ? { AMASTER_PROVIDER_BASE_URL: credential.baseUrl } : {},
9388
- ...credential.defaultModel ? { AMASTER_PROVIDER_DEFAULT_MODEL: credential.defaultModel } : {},
9389
- ...credential.flashModel ? { AMASTER_PROVIDER_FLASH_MODEL: credential.flashModel } : {}
9533
+ ...credential.baseUrl ? { AMASTER_PROVIDER_BASE_URL: credential.baseUrl } : {}
9390
9534
  };
9391
9535
  }
9392
9536
  function normalizeWorkspaceContext(workspace) {
@@ -12458,8 +12602,6 @@ async function executeRunCommand(config, command) {
12458
12602
  if (piAgentLocalPlatformRunnerEnabled(config)) {
12459
12603
  delete executorEnv.AMASTER_API_KEY;
12460
12604
  delete executorEnv.AMASTER_PROVIDER_BASE_URL;
12461
- delete executorEnv.AMASTER_PROVIDER_DEFAULT_MODEL;
12462
- delete executorEnv.AMASTER_PROVIDER_FLASH_MODEL;
12463
12605
  }
12464
12606
  piResolvedProviderConfig = resolvePiExecutorProviderConfig(config, command, executorEnv);
12465
12607
  for (const envName of ["AMASTER_API_KEY", "AMASTER_PLATFORM_OAUTH_TOKEN"]) {
@@ -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.1-beta.1";
8
+ const CONNECTOR_VERSION = "0.1.1-beta.3";
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.1-beta.1",
3
+ "version": "0.1.1-beta.3",
4
4
  "description": "MirrorX runtime connector CLI and daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",