@amaster.ai/employee-runtime-connector 0.1.1-beta.1 → 0.1.1-beta.2
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/dist/amaster-runtime-daemon.mjs +210 -21
- package/dist/amaster-runtime.mjs +1 -1
- package/package.json +1 -1
|
@@ -1828,19 +1828,161 @@ function escapeLiteralJsonStringControlCharacters(value) {
|
|
|
1828
1828
|
}
|
|
1829
1829
|
return changed ? output : value;
|
|
1830
1830
|
}
|
|
1831
|
+
function escapeLikelyLiteralJsonStringQuotes(value) {
|
|
1832
|
+
let output = "";
|
|
1833
|
+
let inString = false;
|
|
1834
|
+
let escaped = false;
|
|
1835
|
+
let changed = false;
|
|
1836
|
+
let stringRole = null;
|
|
1837
|
+
let previousSignificantCharacter = null;
|
|
1838
|
+
function followingObjectProperty(offset) {
|
|
1839
|
+
let cursor = offset;
|
|
1840
|
+
while (cursor < value.length && /\s/u.test(value[cursor])) cursor += 1;
|
|
1841
|
+
if (value[cursor] !== '"') return { valid: false, simpleIdentifier: false };
|
|
1842
|
+
cursor += 1;
|
|
1843
|
+
let propertyName = "";
|
|
1844
|
+
let propertyEscaped = false;
|
|
1845
|
+
for (; cursor < value.length; cursor += 1) {
|
|
1846
|
+
const propertyCharacter = value[cursor];
|
|
1847
|
+
if (propertyEscaped) {
|
|
1848
|
+
propertyName += propertyCharacter;
|
|
1849
|
+
propertyEscaped = false;
|
|
1850
|
+
continue;
|
|
1851
|
+
}
|
|
1852
|
+
if (propertyCharacter === "\\") {
|
|
1853
|
+
propertyEscaped = true;
|
|
1854
|
+
continue;
|
|
1855
|
+
}
|
|
1856
|
+
if (propertyCharacter !== '"') {
|
|
1857
|
+
propertyName += propertyCharacter;
|
|
1858
|
+
continue;
|
|
1859
|
+
}
|
|
1860
|
+
cursor += 1;
|
|
1861
|
+
while (cursor < value.length && /\s/u.test(value[cursor])) cursor += 1;
|
|
1862
|
+
return {
|
|
1863
|
+
valid: value[cursor] === ":",
|
|
1864
|
+
simpleIdentifier: /^[A-Za-z_][A-Za-z0-9_-]*$/u.test(propertyName)
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1867
|
+
return { valid: false, simpleIdentifier: false };
|
|
1868
|
+
}
|
|
1869
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
1870
|
+
const character = value[index];
|
|
1871
|
+
if (!inString) {
|
|
1872
|
+
output += character;
|
|
1873
|
+
if (character === '"') {
|
|
1874
|
+
inString = true;
|
|
1875
|
+
stringRole = previousSignificantCharacter === ":" ? "object_value" : null;
|
|
1876
|
+
} else if (!/\s/u.test(character)) {
|
|
1877
|
+
previousSignificantCharacter = character;
|
|
1878
|
+
}
|
|
1879
|
+
continue;
|
|
1880
|
+
}
|
|
1881
|
+
if (escaped) {
|
|
1882
|
+
output += character;
|
|
1883
|
+
escaped = false;
|
|
1884
|
+
continue;
|
|
1885
|
+
}
|
|
1886
|
+
if (character === "\\") {
|
|
1887
|
+
output += character;
|
|
1888
|
+
escaped = true;
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
if (character !== '"') {
|
|
1892
|
+
output += character;
|
|
1893
|
+
continue;
|
|
1894
|
+
}
|
|
1895
|
+
let nextIndex = index + 1;
|
|
1896
|
+
while (nextIndex < value.length && /\s/u.test(value[nextIndex])) nextIndex += 1;
|
|
1897
|
+
const nextCharacter = value[nextIndex];
|
|
1898
|
+
if (nextCharacter === "," && stringRole === "object_value") {
|
|
1899
|
+
const following = followingObjectProperty(nextIndex + 1);
|
|
1900
|
+
if (!following.valid && !following.simpleIdentifier) {
|
|
1901
|
+
output += '\\"';
|
|
1902
|
+
changed = true;
|
|
1903
|
+
continue;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
if (nextCharacter === void 0 || [":", ",", "}", "]"].includes(nextCharacter)) {
|
|
1907
|
+
output += character;
|
|
1908
|
+
inString = false;
|
|
1909
|
+
stringRole = null;
|
|
1910
|
+
previousSignificantCharacter = character;
|
|
1911
|
+
} else {
|
|
1912
|
+
output += '\\"';
|
|
1913
|
+
changed = true;
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
return changed ? output : value;
|
|
1917
|
+
}
|
|
1918
|
+
function insertSingleMissingObjectPropertyComma(value) {
|
|
1919
|
+
let parseError;
|
|
1920
|
+
try {
|
|
1921
|
+
JSON.parse(value);
|
|
1922
|
+
return value;
|
|
1923
|
+
} catch (error) {
|
|
1924
|
+
parseError = error;
|
|
1925
|
+
}
|
|
1926
|
+
const positionMatch = String(parseError?.message ?? "").match(
|
|
1927
|
+
/Expected ',' or '\}' after property value in JSON at position (\d+)/u
|
|
1928
|
+
);
|
|
1929
|
+
if (!positionMatch) return value;
|
|
1930
|
+
const position = Number(positionMatch[1]);
|
|
1931
|
+
if (!Number.isSafeInteger(position) || position < 1 || position >= value.length) return value;
|
|
1932
|
+
let propertyStart = position;
|
|
1933
|
+
while (propertyStart < value.length && /\s/u.test(value[propertyStart])) propertyStart += 1;
|
|
1934
|
+
if (value[propertyStart] !== '"') return value;
|
|
1935
|
+
let cursor = propertyStart + 1;
|
|
1936
|
+
let escaped = false;
|
|
1937
|
+
let propertyName = "";
|
|
1938
|
+
for (; cursor < value.length; cursor += 1) {
|
|
1939
|
+
const character = value[cursor];
|
|
1940
|
+
if (escaped) {
|
|
1941
|
+
propertyName += character;
|
|
1942
|
+
escaped = false;
|
|
1943
|
+
continue;
|
|
1944
|
+
}
|
|
1945
|
+
if (character === "\\") {
|
|
1946
|
+
escaped = true;
|
|
1947
|
+
continue;
|
|
1948
|
+
}
|
|
1949
|
+
if (character === '"') break;
|
|
1950
|
+
propertyName += character;
|
|
1951
|
+
}
|
|
1952
|
+
if (cursor >= value.length || !/^[A-Za-z_][A-Za-z0-9_-]*$/u.test(propertyName)) return value;
|
|
1953
|
+
cursor += 1;
|
|
1954
|
+
while (cursor < value.length && /\s/u.test(value[cursor])) cursor += 1;
|
|
1955
|
+
if (value[cursor] !== ":") return value;
|
|
1956
|
+
let previous = position - 1;
|
|
1957
|
+
while (previous >= 0 && /\s/u.test(value[previous])) previous -= 1;
|
|
1958
|
+
if (previous < 0 || !['"', "}", "]", "e", "l"].includes(value[previous]) && !/[0-9]/u.test(value[previous])) {
|
|
1959
|
+
return value;
|
|
1960
|
+
}
|
|
1961
|
+
const candidate = `${value.slice(0, position)},${value.slice(position)}`;
|
|
1962
|
+
try {
|
|
1963
|
+
return isJsonObject(JSON.parse(candidate)) ? candidate : value;
|
|
1964
|
+
} catch {
|
|
1965
|
+
return value;
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1831
1968
|
function normalizePiMcpProxyArgs(value) {
|
|
1832
1969
|
if (typeof value !== "string") return { value, repaired: false };
|
|
1833
1970
|
try {
|
|
1834
1971
|
JSON.parse(value);
|
|
1835
1972
|
return { value, repaired: false };
|
|
1836
1973
|
} catch {
|
|
1837
|
-
const
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1974
|
+
const repairedControlCharacters = escapeLiteralJsonStringControlCharacters(value);
|
|
1975
|
+
const repairedValue = escapeLikelyLiteralJsonStringQuotes(repairedControlCharacters);
|
|
1976
|
+
if (repairedValue !== value) {
|
|
1977
|
+
try {
|
|
1978
|
+
if (isJsonObject(JSON.parse(repairedValue))) {
|
|
1979
|
+
return { value: repairedValue, repaired: true };
|
|
1980
|
+
}
|
|
1981
|
+
} catch {
|
|
1982
|
+
}
|
|
1843
1983
|
}
|
|
1984
|
+
const commaRepairedValue = insertSingleMissingObjectPropertyComma(repairedControlCharacters);
|
|
1985
|
+
return commaRepairedValue !== value ? { value: commaRepairedValue, repaired: true } : { value, repaired: false };
|
|
1844
1986
|
}
|
|
1845
1987
|
}
|
|
1846
1988
|
function registerManagedPiMcpArgsNormalizer(pi) {
|
|
@@ -1854,6 +1996,8 @@ function managedPiMcpArgsNormalizerExtensionSource() {
|
|
|
1854
1996
|
return [
|
|
1855
1997
|
isJsonObject.toString(),
|
|
1856
1998
|
escapeLiteralJsonStringControlCharacters.toString(),
|
|
1999
|
+
escapeLikelyLiteralJsonStringQuotes.toString(),
|
|
2000
|
+
insertSingleMissingObjectPropertyComma.toString(),
|
|
1857
2001
|
normalizePiMcpProxyArgs.toString(),
|
|
1858
2002
|
`export default ${registerManagedPiMcpArgsNormalizer.toString()};`,
|
|
1859
2003
|
""
|
|
@@ -2270,7 +2414,7 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
2270
2414
|
} catch {
|
|
2271
2415
|
throw new Error(`pi_managed_mcp_attestation_failed: configured ${MANAGED_WEB_ACCESS_PACKAGE} package metadata is invalid`);
|
|
2272
2416
|
}
|
|
2273
|
-
if (packageMetadata.name !== MANAGED_WEB_ACCESS_PACKAGE) {
|
|
2417
|
+
if (!packageMetadata || packageMetadata.name !== MANAGED_WEB_ACCESS_PACKAGE) {
|
|
2274
2418
|
throw new Error(`pi_managed_mcp_attestation_failed: configured ${MANAGED_WEB_ACCESS_PACKAGE} package identity mismatch`);
|
|
2275
2419
|
}
|
|
2276
2420
|
return {
|
|
@@ -2479,6 +2623,9 @@ ${result3.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
2479
2623
|
const restoredNativeSession = restoreManagedPiSessionRollout(input, sessionsRoot, runDir, executorHome, authority);
|
|
2480
2624
|
const configPath = join4(piCodingAgentDir, "mcp.json");
|
|
2481
2625
|
const config = {
|
|
2626
|
+
settings: {
|
|
2627
|
+
toolPrefix: "none"
|
|
2628
|
+
},
|
|
2482
2629
|
mcpServers: {
|
|
2483
2630
|
[SUPPORTED_SERVER_NAME2]: {
|
|
2484
2631
|
type: "http",
|
|
@@ -3369,13 +3516,16 @@ function wikiAccessRuleLine(input) {
|
|
|
3369
3516
|
return "";
|
|
3370
3517
|
}
|
|
3371
3518
|
function fixedRules(input, includeIssueLine) {
|
|
3519
|
+
const issue = asRecord(asRecord(input.context).paperclipIssue);
|
|
3520
|
+
const businessOutcome = asRecord(asRecord(issue.taskRequirements).businessOutcome);
|
|
3521
|
+
const serverOwnedBusinessOutcomeReview = businessOutcome.mode === "required";
|
|
3372
3522
|
return [
|
|
3373
3523
|
"## AMaster Runtime Connector Task",
|
|
3374
3524
|
"MirrorX task.",
|
|
3375
3525
|
"Use only the declared workspace; make concrete progress and report concisely.",
|
|
3376
3526
|
"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
3527
|
"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.",
|
|
3528
|
+
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
3529
|
DEADLINE_POSTURE_GUARD,
|
|
3380
3530
|
"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
3531
|
`- command id: ${input.commandId}`,
|
|
@@ -3409,7 +3559,7 @@ function interactionResolutionText(context) {
|
|
|
3409
3559
|
if (Object.keys(resolution).length === 0) return "";
|
|
3410
3560
|
const target = asRecord(resolution.target);
|
|
3411
3561
|
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,
|
|
3562
|
+
"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
3563
|
"Do not copy the reviewed document into the current issue and do not restart its revision lineage at 1."
|
|
3414
3564
|
].join(" ") : "";
|
|
3415
3565
|
return [
|
|
@@ -3520,7 +3670,10 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
|
|
|
3520
3670
|
optionId: readString(optionId)
|
|
3521
3671
|
})).filter((entry) => entry.optionId && !allowed.has(entry.authorizationClass));
|
|
3522
3672
|
const issue = asRecord(context.paperclipIssue);
|
|
3523
|
-
const
|
|
3673
|
+
const requirements = asRecord(issue.taskRequirements);
|
|
3674
|
+
const completion = asRecord(requirements.completion);
|
|
3675
|
+
const delivery = asRecord(requirements.delivery);
|
|
3676
|
+
const businessOutcome = asRecord(requirements.businessOutcome);
|
|
3524
3677
|
const completionRole = readString(completion.role);
|
|
3525
3678
|
const completionDeliverable = readString(completion.deliverable);
|
|
3526
3679
|
const manifestRefreshOnly = isManifestRefreshOnly(context);
|
|
@@ -3530,13 +3683,26 @@ function runtimeAuthorizationText(context, mode, { suppressOrdinaryCompletionCon
|
|
|
3530
3683
|
firstDocumentCheckpoint,
|
|
3531
3684
|
"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
3685
|
].filter(Boolean).join(" ") : "";
|
|
3686
|
+
const businessOutcomeOwnershipContract = businessOutcome.mode === "required" ? [
|
|
3687
|
+
"Business Outcome review is owned by the Server terminal reconciler.",
|
|
3688
|
+
"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."
|
|
3689
|
+
].join(" ") : "";
|
|
3690
|
+
const businessOutcomeTerminalContract = !suppressOrdinaryCompletionContract && businessOutcome.mode === "required" ? [
|
|
3691
|
+
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.",
|
|
3692
|
+
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."
|
|
3693
|
+
].join(" ") : "";
|
|
3533
3694
|
const authorizationContract = missing.length > 0 ? [
|
|
3534
3695
|
`Current allowed action classes: ${[...allowed].join(", ") || "task_governance"}.`,
|
|
3535
3696
|
"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
3697
|
...missing.map((entry) => `- ${entry.authorizationClass}: ${entry.optionId}`),
|
|
3537
3698
|
"Never use request_confirmation to authorize a runtime action class."
|
|
3538
3699
|
].join("\n") : "";
|
|
3539
|
-
return [
|
|
3700
|
+
return [
|
|
3701
|
+
completionContract,
|
|
3702
|
+
businessOutcomeOwnershipContract,
|
|
3703
|
+
businessOutcomeTerminalContract,
|
|
3704
|
+
authorizationContract
|
|
3705
|
+
].filter(Boolean).join("\n");
|
|
3540
3706
|
}
|
|
3541
3707
|
function runtimeDecompositionRequirementText(context) {
|
|
3542
3708
|
const issue = asRecord(context.paperclipIssue);
|
|
@@ -3661,12 +3827,13 @@ function piMcpProxyExamplesText(input) {
|
|
|
3661
3827
|
args: JSON.stringify(args)
|
|
3662
3828
|
});
|
|
3663
3829
|
return [
|
|
3664
|
-
"The Pi native tool is the outer `mcp` proxy. Emit these as actual tool calls; `args` is the stringified inner canonical object
|
|
3830
|
+
"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
3831
|
"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`.",
|
|
3832
|
+
"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
3833
|
"update_parent.comment creates a separate persistent issue comment. Omit it when add_comment already recorded the message.",
|
|
3667
3834
|
`- describe: ${proxy("runtime_action.describe", { schemaVersion: "runtime-action-v1", actionType: "update_parent" })}`,
|
|
3668
3835
|
`- 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 } } } })}`,
|
|
3836
|
+
`- 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
3837
|
`- plan: ${proxy("runtime_action.plan", { schemaVersion: "runtime-action-v1", idempotencyKey: "task-123-plan", actions: [{ type: "update_parent", status: "in_progress" }] })}`,
|
|
3671
3838
|
`- commit the returned plan revision: ${proxy("runtime_action.commit", { schemaVersion: "runtime-action-v1", planId: "11111111-1111-4111-8111-111111111111", revision: "plan-revision-1" })}`,
|
|
3672
3839
|
`- read document: ${proxy("amaster.read_issue_document", { issueId: "AM-123", key: "plan" })}`
|
|
@@ -4153,16 +4320,38 @@ function tcReadNumber(value, fallback = 0) {
|
|
|
4153
4320
|
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
4154
4321
|
}
|
|
4155
4322
|
var TC_PI_ARGUMENT_VALIDATION_NODE_BUDGET = 4e3;
|
|
4156
|
-
|
|
4157
|
-
|
|
4323
|
+
var TC_PI_ARGUMENT_VALIDATION_PATTERN = /\binvalid(?:[_ -]+)tool(?:[_ -]+)arguments?\b|\binvalid args json\b|\btool[- ]arguments? (?:failed )?validation\b/i;
|
|
4324
|
+
function tcFindPiArgumentValidationText(value, depth = 0, seen = /* @__PURE__ */ new WeakSet(), budget = { remaining: TC_PI_ARGUMENT_VALIDATION_NODE_BUDGET }) {
|
|
4325
|
+
if (budget.remaining <= 0) return null;
|
|
4158
4326
|
budget.remaining -= 1;
|
|
4159
4327
|
if (typeof value === "string") {
|
|
4160
|
-
|
|
4328
|
+
const bounded = value.slice(0, 2e4);
|
|
4329
|
+
return TC_PI_ARGUMENT_VALIDATION_PATTERN.test(bounded) ? bounded : null;
|
|
4161
4330
|
}
|
|
4162
|
-
if (!value || typeof value !== "object" || depth >= 6 || seen.has(value)) return
|
|
4331
|
+
if (!value || typeof value !== "object" || depth >= 6 || seen.has(value)) return null;
|
|
4163
4332
|
seen.add(value);
|
|
4164
4333
|
const entries = Array.isArray(value) ? value.slice(0, 40).map((entry, index) => [String(index), entry]) : Object.entries(value).slice(0, 80);
|
|
4165
|
-
|
|
4334
|
+
for (const [, entry] of entries) {
|
|
4335
|
+
const match = tcFindPiArgumentValidationText(entry, depth + 1, seen, budget);
|
|
4336
|
+
if (match) return match;
|
|
4337
|
+
}
|
|
4338
|
+
return null;
|
|
4339
|
+
}
|
|
4340
|
+
function tcPiArgumentValidationDiagnostic(value) {
|
|
4341
|
+
const text = tcFindPiArgumentValidationText(value);
|
|
4342
|
+
if (!text) return null;
|
|
4343
|
+
const normalized = text.toLowerCase();
|
|
4344
|
+
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";
|
|
4345
|
+
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";
|
|
4346
|
+
const rawPosition = validationSource === "invalid_args_json" ? text.match(/\bposition\s+(\d{1,9})\b/iu)?.[1] : null;
|
|
4347
|
+
const parseErrorPosition = rawPosition ? Number(rawPosition) : null;
|
|
4348
|
+
return {
|
|
4349
|
+
validationSource,
|
|
4350
|
+
validationPath: validationSource === "invalid_args_json" ? "$.args" : "$",
|
|
4351
|
+
pathPrecision: validationSource === "invalid_args_json" ? "exact" : "root_only",
|
|
4352
|
+
...parseErrorKind ? { parseErrorKind } : {},
|
|
4353
|
+
...typeof parseErrorPosition === "number" && Number.isSafeInteger(parseErrorPosition) && parseErrorPosition >= 0 ? { parseErrorPosition } : {}
|
|
4354
|
+
};
|
|
4166
4355
|
}
|
|
4167
4356
|
function tcTruncateText(value, maxChars = 16e3) {
|
|
4168
4357
|
const text = String(value ?? "");
|
|
@@ -4535,7 +4724,7 @@ function summarizePiEvent(event) {
|
|
|
4535
4724
|
if (type === "tool_execution_start" || type === "tool_execution_end") {
|
|
4536
4725
|
const toolName = tcReadString(event.toolName) ?? "unknown";
|
|
4537
4726
|
const completed = type === "tool_execution_end";
|
|
4538
|
-
const
|
|
4727
|
+
const argumentValidationDiagnostic = completed && event.isError === true ? tcPiArgumentValidationDiagnostic(event.result) : null;
|
|
4539
4728
|
return {
|
|
4540
4729
|
stream: "system",
|
|
4541
4730
|
level: completed && event.isError === true ? "error" : "info",
|
|
@@ -4546,7 +4735,7 @@ function summarizePiEvent(event) {
|
|
|
4546
4735
|
toolName,
|
|
4547
4736
|
toolCallId: tcReadString(event.toolCallId),
|
|
4548
4737
|
status: completed ? event.isError === true ? "failed" : "completed" : "started",
|
|
4549
|
-
...
|
|
4738
|
+
...argumentValidationDiagnostic ? { errorCode: "invalid_tool_arguments", ...argumentValidationDiagnostic } : {}
|
|
4550
4739
|
}
|
|
4551
4740
|
};
|
|
4552
4741
|
}
|
|
@@ -8021,7 +8210,7 @@ function assertSourceAcquisitionRuntimeAuthority({
|
|
|
8021
8210
|
}
|
|
8022
8211
|
|
|
8023
8212
|
// src/amaster-runtime-daemon.mjs
|
|
8024
|
-
var CONNECTOR_VERSION = "0.1.1-beta.
|
|
8213
|
+
var CONNECTOR_VERSION = "0.1.1-beta.2";
|
|
8025
8214
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
8026
8215
|
var SOURCE_ACQUISITION_CAPABILITY = "source_acquisition_v1";
|
|
8027
8216
|
var SOURCE_ACQUISITION_PROFILE_VERSION = "source_acquisition_v1";
|
package/dist/amaster-runtime.mjs
CHANGED
|
@@ -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.
|
|
8
|
+
const CONNECTOR_VERSION = "0.1.1-beta.2";
|
|
9
9
|
|
|
10
10
|
const CAPABILITIES = [
|
|
11
11
|
"remote_registration",
|