@ai-matrx/agents 0.13.15 → 0.14.0
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/CHANGELOG.md +26 -0
- package/dist/content-transfer/index.cjs +1 -0
- package/dist/content-transfer/index.cjs.map +1 -1
- package/dist/content-transfer/index.js +1 -0
- package/dist/content-transfer/index.js.map +1 -1
- package/dist/content-transfer/react/index.cjs +1 -0
- package/dist/content-transfer/react/index.cjs.map +1 -1
- package/dist/content-transfer/react/index.js +1 -0
- package/dist/content-transfer/react/index.js.map +1 -1
- package/dist/index.cjs +241 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +162 -0
- package/dist/index.d.ts +162 -0
- package/dist/index.js +241 -1
- package/dist/index.js.map +1 -1
- package/dist/mandates/index.cjs +3 -2
- package/dist/mandates/index.cjs.map +1 -1
- package/dist/mandates/index.d.cts +6 -5
- package/dist/mandates/index.d.ts +6 -5
- package/dist/mandates/index.js +3 -2
- package/dist/mandates/index.js.map +1 -1
- package/dist/presentation/decision-answers.cjs +195 -0
- package/dist/presentation/decision-answers.cjs.map +1 -0
- package/dist/presentation/decision-answers.d.cts +113 -0
- package/dist/presentation/decision-answers.d.ts +113 -0
- package/dist/presentation/decision-answers.js +174 -0
- package/dist/presentation/decision-answers.js.map +1 -0
- package/mandates/snapshots/keys.0.13.15.json +2 -1
- package/mandates/snapshots/keys.0.13.16.json +619 -0
- package/mandates/snapshots/keys.0.14.0.json +619 -0
- package/package.json +12 -2
package/dist/index.cjs
CHANGED
|
@@ -20,14 +20,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
AUDIO_REFERENCE_ROLES: () => AUDIO_REFERENCE_ROLES,
|
|
23
24
|
DEFAULT_MATRX_NDJSON_READ_AHEAD: () => DEFAULT_MATRX_NDJSON_READ_AHEAD,
|
|
24
25
|
DEFAULT_WORKFLOW_PROJECTION_LIMITS: () => DEFAULT_WORKFLOW_PROJECTION_LIMITS,
|
|
26
|
+
IMAGE_REFERENCE_ROLES: () => IMAGE_REFERENCE_ROLES,
|
|
27
|
+
IMAGE_ROLE_META: () => IMAGE_ROLE_META,
|
|
25
28
|
MATRX_AI_API_VERSION_DEFAULT: () => MATRX_AI_API_VERSION_DEFAULT,
|
|
26
29
|
MatrxApiError: () => MatrxApiError,
|
|
27
30
|
MatrxRunError: () => MatrxRunError,
|
|
28
31
|
OrganizationContextError: () => OrganizationContextError,
|
|
29
32
|
TERMINAL_MATRX_RUNTIME_STATUSES: () => TERMINAL_MATRX_RUNTIME_STATUSES,
|
|
30
33
|
V2_COVERED_AI_PATH_TEMPLATES: () => V2_COVERED_AI_PATH_TEMPLATES,
|
|
34
|
+
VIDEO_IMAGE_ROLES: () => VIDEO_IMAGE_ROLES,
|
|
35
|
+
VIDEO_REFERENCE_ROLES: () => VIDEO_REFERENCE_ROLES,
|
|
31
36
|
applyAiApiVersion: () => applyAiApiVersion,
|
|
32
37
|
applyOrganizationContextHeader: () => applyOrganizationContextHeader,
|
|
33
38
|
assertOrganizationMatchesOperation: () => assertOrganizationMatchesOperation,
|
|
@@ -42,6 +47,7 @@ __export(index_exports, {
|
|
|
42
47
|
createMatrxTransport: () => createMatrxTransport,
|
|
43
48
|
createOrganizationOperation: () => createOrganizationOperation,
|
|
44
49
|
createWorkflowNodeProjection: () => createWorkflowNodeProjection,
|
|
50
|
+
deriveRunInputs: () => deriveRunInputs,
|
|
45
51
|
extractMatrxErrorCode: () => extractMatrxErrorCode,
|
|
46
52
|
extractMatrxErrorMessage: () => extractMatrxErrorMessage,
|
|
47
53
|
fetchWithMatrxProtocolFallback: () => fetchWithMatrxProtocolFallback,
|
|
@@ -49,32 +55,48 @@ __export(index_exports, {
|
|
|
49
55
|
followRuntimeOperationToEnd: () => followRuntimeOperationToEnd,
|
|
50
56
|
getRuntimeOperationStatus: () => getRuntimeOperationStatus,
|
|
51
57
|
getRuntimeOperationsByLink: () => getRuntimeOperationsByLink,
|
|
58
|
+
imageRoleVerdict: () => imageRoleVerdict,
|
|
59
|
+
isControlVariable: () => isControlVariable,
|
|
52
60
|
isCoveredAiPath: () => isCoveredAiPath,
|
|
61
|
+
isImageReferenceRole: () => isImageReferenceRole,
|
|
62
|
+
isReferenceRole: () => isReferenceRole,
|
|
53
63
|
isV2Path: () => isV2Path,
|
|
54
64
|
listConversationPendingToolCalls: () => listConversationPendingToolCalls,
|
|
55
65
|
listRuntimeOperationEvents: () => listRuntimeOperationEvents,
|
|
56
66
|
listUserPendingToolCalls: () => listUserPendingToolCalls,
|
|
57
67
|
mintMatrxConversationId: () => mintMatrxConversationId,
|
|
68
|
+
namedReferenceVerdict: () => namedReferenceVerdict,
|
|
58
69
|
newEphemeralConversationStart: () => newEphemeralConversationStart,
|
|
59
70
|
newStoredConversationStart: () => newStoredConversationStart,
|
|
60
71
|
normalizeMatrxError: () => normalizeMatrxError,
|
|
61
72
|
normalizeMatrxStreamEnvelope: () => normalizeMatrxStreamEnvelope,
|
|
73
|
+
normalizeReferenceName: () => normalizeReferenceName,
|
|
74
|
+
orderVariablesForForm: () => orderVariablesForForm,
|
|
62
75
|
parseMatrxSseFrame: () => parseMatrxSseFrame,
|
|
76
|
+
partitionControlVariables: () => partitionControlVariables,
|
|
63
77
|
projectAgentEvent: () => projectAgentEvent,
|
|
64
78
|
projectAgentEvents: () => projectAgentEvents,
|
|
65
79
|
projectAgentResultForDisplay: () => projectAgentResultForDisplay,
|
|
66
80
|
projectWorkflowNodeEvent: () => projectWorkflowNodeEvent,
|
|
81
|
+
readImageRoleLimits: () => readImageRoleLimits,
|
|
67
82
|
readMatrxNdjsonStream: () => readMatrxNdjsonStream,
|
|
68
83
|
readMatrxSseStream: () => readMatrxSseStream,
|
|
84
|
+
referenceRoleCaption: () => referenceRoleCaption,
|
|
69
85
|
rejoinRuntimeOperation: () => rejoinRuntimeOperation,
|
|
70
86
|
requireOrganizationContext: () => requireOrganizationContext,
|
|
71
87
|
resumeAgentConversation: () => resumeAgentConversation,
|
|
88
|
+
roleTakesName: () => roleTakesName,
|
|
89
|
+
rolesFor: () => rolesFor,
|
|
72
90
|
runAgentToCompletion: () => runAgentToCompletion,
|
|
73
91
|
startAgentRun: () => startAgentRun,
|
|
74
92
|
startMandateRun: () => startMandateRun,
|
|
75
93
|
submitAgentToolResults: () => submitAgentToolResults,
|
|
76
94
|
toV1FallbackUrl: () => toV1FallbackUrl,
|
|
77
|
-
toV2Path: () => toV2Path
|
|
95
|
+
toV2Path: () => toV2Path,
|
|
96
|
+
variableNameOfImageUrl: () => variableNameOfImageUrl,
|
|
97
|
+
variableNameOfMediaUrl: () => variableNameOfMediaUrl,
|
|
98
|
+
variableRunHint: () => variableRunHint,
|
|
99
|
+
variableRunLabel: () => variableRunLabel
|
|
78
100
|
});
|
|
79
101
|
module.exports = __toCommonJS(index_exports);
|
|
80
102
|
|
|
@@ -1679,4 +1701,222 @@ function listUserPendingToolCalls(transport, options = {}) {
|
|
|
1679
1701
|
}
|
|
1680
1702
|
);
|
|
1681
1703
|
}
|
|
1704
|
+
|
|
1705
|
+
// variables/reference-roles.ts
|
|
1706
|
+
var IMAGE_REFERENCE_ROLES = [
|
|
1707
|
+
"subject",
|
|
1708
|
+
"character",
|
|
1709
|
+
"style",
|
|
1710
|
+
"mask",
|
|
1711
|
+
"edit_target",
|
|
1712
|
+
"composition_control"
|
|
1713
|
+
];
|
|
1714
|
+
var VIDEO_IMAGE_ROLES = [
|
|
1715
|
+
"first_frame",
|
|
1716
|
+
"last_frame",
|
|
1717
|
+
"asset",
|
|
1718
|
+
"style"
|
|
1719
|
+
];
|
|
1720
|
+
var VIDEO_REFERENCE_ROLES = ["extend", "restyle"];
|
|
1721
|
+
var AUDIO_REFERENCE_ROLES = ["lip_sync"];
|
|
1722
|
+
var ALL_IMAGE_ROLES = [
|
|
1723
|
+
...IMAGE_REFERENCE_ROLES,
|
|
1724
|
+
...VIDEO_IMAGE_ROLES
|
|
1725
|
+
];
|
|
1726
|
+
var IMAGE_ROLE_META = {
|
|
1727
|
+
subject: {
|
|
1728
|
+
label: "Subject",
|
|
1729
|
+
ask: "Subject reference",
|
|
1730
|
+
explanation: "Keeps this exact product or object recognisable: shape, materials, labels."
|
|
1731
|
+
},
|
|
1732
|
+
character: {
|
|
1733
|
+
label: "Character",
|
|
1734
|
+
ask: "Character reference",
|
|
1735
|
+
explanation: "Keeps this person or character looking the same."
|
|
1736
|
+
},
|
|
1737
|
+
style: {
|
|
1738
|
+
label: "Style",
|
|
1739
|
+
ask: "Style reference",
|
|
1740
|
+
explanation: "Borrows only the look (colours, lighting, medium), never the content."
|
|
1741
|
+
},
|
|
1742
|
+
mask: {
|
|
1743
|
+
label: "Mask",
|
|
1744
|
+
ask: "Mask",
|
|
1745
|
+
explanation: "Marks the only area of the edited image that is allowed to change."
|
|
1746
|
+
},
|
|
1747
|
+
edit_target: {
|
|
1748
|
+
label: "Edit this",
|
|
1749
|
+
ask: "Image to edit",
|
|
1750
|
+
explanation: "The image being edited; everything not asked for stays the same."
|
|
1751
|
+
},
|
|
1752
|
+
composition_control: {
|
|
1753
|
+
label: "Composition",
|
|
1754
|
+
ask: "Composition reference",
|
|
1755
|
+
explanation: "Follows its layout, pose and geometry, not its appearance."
|
|
1756
|
+
},
|
|
1757
|
+
first_frame: {
|
|
1758
|
+
label: "First frame",
|
|
1759
|
+
ask: "First frame",
|
|
1760
|
+
explanation: "The video starts on exactly this image."
|
|
1761
|
+
},
|
|
1762
|
+
last_frame: {
|
|
1763
|
+
label: "Last frame",
|
|
1764
|
+
ask: "Last frame",
|
|
1765
|
+
explanation: "The video ends on exactly this image (needs a first frame)."
|
|
1766
|
+
},
|
|
1767
|
+
asset: {
|
|
1768
|
+
label: "Asset",
|
|
1769
|
+
ask: "Asset reference",
|
|
1770
|
+
explanation: "Keeps this product, object or character recognisable throughout the clip."
|
|
1771
|
+
},
|
|
1772
|
+
extend: {
|
|
1773
|
+
label: "Extend",
|
|
1774
|
+
ask: "Video to extend",
|
|
1775
|
+
explanation: "The new clip continues this video from its last frame."
|
|
1776
|
+
},
|
|
1777
|
+
restyle: {
|
|
1778
|
+
label: "Restyle",
|
|
1779
|
+
ask: "Reference video",
|
|
1780
|
+
explanation: "Re-renders this video: same motion and timing, a new look."
|
|
1781
|
+
},
|
|
1782
|
+
lip_sync: {
|
|
1783
|
+
label: "Lip sync",
|
|
1784
|
+
ask: "Lip-sync audio",
|
|
1785
|
+
explanation: "The speech the on-screen face mouths, word for word."
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1788
|
+
function rolesFor(blockKind, output) {
|
|
1789
|
+
if (output === "image") return blockKind === "image" ? IMAGE_REFERENCE_ROLES : [];
|
|
1790
|
+
if (blockKind === "image") return VIDEO_IMAGE_ROLES;
|
|
1791
|
+
if (blockKind === "video") return VIDEO_REFERENCE_ROLES;
|
|
1792
|
+
return AUDIO_REFERENCE_ROLES;
|
|
1793
|
+
}
|
|
1794
|
+
function roleTakesName(role) {
|
|
1795
|
+
return role === "asset" || role === "style" || role === "restyle" || role === "extend";
|
|
1796
|
+
}
|
|
1797
|
+
function normalizeReferenceName(raw) {
|
|
1798
|
+
const candidate = raw.trim().replace(/^@/, "");
|
|
1799
|
+
if (!candidate) return null;
|
|
1800
|
+
return /^[A-Za-z][A-Za-z0-9_-]{0,31}$/.test(candidate) ? candidate : null;
|
|
1801
|
+
}
|
|
1802
|
+
function isReferenceRole(value) {
|
|
1803
|
+
return typeof value === "string" && value in IMAGE_ROLE_META;
|
|
1804
|
+
}
|
|
1805
|
+
function isImageReferenceRole(value) {
|
|
1806
|
+
return typeof value === "string" && ALL_IMAGE_ROLES.includes(value);
|
|
1807
|
+
}
|
|
1808
|
+
function readLimitMap(source, accept, out) {
|
|
1809
|
+
if (typeof source !== "object" || source === null || Array.isArray(source)) return;
|
|
1810
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1811
|
+
if (accept(key) && typeof value === "number" && Number.isInteger(value) && value >= 0) {
|
|
1812
|
+
out[key] = value;
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
function readImageRoleLimits(raw) {
|
|
1817
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return {};
|
|
1818
|
+
const record = raw;
|
|
1819
|
+
const out = {};
|
|
1820
|
+
readLimitMap(
|
|
1821
|
+
record.image_reference_roles,
|
|
1822
|
+
(k) => isImageReferenceRole(k) || k === "total",
|
|
1823
|
+
out
|
|
1824
|
+
);
|
|
1825
|
+
readLimitMap(
|
|
1826
|
+
record.video_reference_roles,
|
|
1827
|
+
(k) => VIDEO_REFERENCE_ROLES.includes(k) || AUDIO_REFERENCE_ROLES.includes(k) || k === "named",
|
|
1828
|
+
out
|
|
1829
|
+
);
|
|
1830
|
+
return out;
|
|
1831
|
+
}
|
|
1832
|
+
function imageRoleVerdict(role, limits, modelLabel, countOfRole = 1) {
|
|
1833
|
+
const label = IMAGE_ROLE_META[role].label;
|
|
1834
|
+
const noun = VIDEO_REFERENCE_ROLES.includes(role) ? "video" : role === "lip_sync" ? "audio clip" : ALL_IMAGE_ROLES.includes(role) && !IMAGE_REFERENCE_ROLES.includes(role) ? "image" : "reference image";
|
|
1835
|
+
const allowed = limits[role] ?? 0;
|
|
1836
|
+
if (allowed <= 0) {
|
|
1837
|
+
return {
|
|
1838
|
+
verdict: "refused",
|
|
1839
|
+
reason: `${modelLabel} cannot take a ${label} ${noun}. Pick another role or another model.`
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
if (countOfRole > allowed) {
|
|
1843
|
+
return {
|
|
1844
|
+
verdict: "refused",
|
|
1845
|
+
reason: `${modelLabel} takes at most ${allowed} ${label} ${noun}${allowed === 1 ? "" : "s"}; this message has ${countOfRole}.`
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
return { verdict: "ok" };
|
|
1849
|
+
}
|
|
1850
|
+
function namedReferenceVerdict(limits, modelLabel) {
|
|
1851
|
+
return (limits.named ?? 0) > 0 ? { verdict: "ok" } : {
|
|
1852
|
+
verdict: "refused",
|
|
1853
|
+
reason: `${modelLabel} cannot take named references. Clear the name, or pick a model with named elements.`
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
function variableNameOfImageUrl(url) {
|
|
1857
|
+
return variableNameOfMediaUrl(url);
|
|
1858
|
+
}
|
|
1859
|
+
function variableNameOfMediaUrl(url) {
|
|
1860
|
+
if (typeof url !== "string") return null;
|
|
1861
|
+
const match = /^\s*\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}\s*$/.exec(url);
|
|
1862
|
+
return match?.[1] ?? null;
|
|
1863
|
+
}
|
|
1864
|
+
function referenceRoleCaption(role, name) {
|
|
1865
|
+
const roleLabel = typeof role === "string" && role ? isReferenceRole(role) ? IMAGE_ROLE_META[role].ask : role : null;
|
|
1866
|
+
const refName = typeof name === "string" ? normalizeReferenceName(name) : null;
|
|
1867
|
+
if (!roleLabel && !refName) return null;
|
|
1868
|
+
return [roleLabel, refName ? `@${refName}` : null].filter(Boolean).join(" \xB7 ");
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
// variables/run-inputs.ts
|
|
1872
|
+
var MEDIA_KINDS = ["image", "video", "audio", "document", "youtube"];
|
|
1873
|
+
function isControlVariable(def) {
|
|
1874
|
+
return typeof def.control?.key === "string" && def.control.key.length > 0;
|
|
1875
|
+
}
|
|
1876
|
+
function partitionControlVariables(defs) {
|
|
1877
|
+
const content = [];
|
|
1878
|
+
const settings = [];
|
|
1879
|
+
for (const d of defs) (isControlVariable(d) ? settings : content).push(d);
|
|
1880
|
+
return { content, settings };
|
|
1881
|
+
}
|
|
1882
|
+
function orderVariablesForForm(defs) {
|
|
1883
|
+
const { content, settings } = partitionControlVariables(defs);
|
|
1884
|
+
if (settings.length === 0) return defs;
|
|
1885
|
+
const ordered = [...content, ...settings];
|
|
1886
|
+
return ordered.every((d, i) => d === defs[i]) ? defs : ordered;
|
|
1887
|
+
}
|
|
1888
|
+
function roleOf(variable) {
|
|
1889
|
+
const type = variable.customComponent?.type;
|
|
1890
|
+
const role = variable.customComponent?.imageRole;
|
|
1891
|
+
const roled = type === "image" || type === "video" || type === "audio";
|
|
1892
|
+
return roled && isReferenceRole(role) ? role : null;
|
|
1893
|
+
}
|
|
1894
|
+
function variableRunLabel(variable, formatName) {
|
|
1895
|
+
const role = roleOf(variable);
|
|
1896
|
+
return role ? IMAGE_ROLE_META[role].ask : formatName(variable.name);
|
|
1897
|
+
}
|
|
1898
|
+
function variableRunHint(variable) {
|
|
1899
|
+
if (variable.helpText) return variable.helpText;
|
|
1900
|
+
const role = roleOf(variable);
|
|
1901
|
+
return role ? IMAGE_ROLE_META[role].explanation : void 0;
|
|
1902
|
+
}
|
|
1903
|
+
function deriveRunInputs(defs, formatName) {
|
|
1904
|
+
return orderVariablesForForm([...defs ?? []]).map((variable) => {
|
|
1905
|
+
const type = variable.customComponent?.type ?? "textarea";
|
|
1906
|
+
const options = variable.customComponent?.options ?? void 0;
|
|
1907
|
+
return {
|
|
1908
|
+
name: variable.name,
|
|
1909
|
+
label: variableRunLabel(variable, formatName),
|
|
1910
|
+
hint: variableRunHint(variable),
|
|
1911
|
+
group: isControlVariable(variable) ? "settings" : "content",
|
|
1912
|
+
required: Boolean(variable.required),
|
|
1913
|
+
component: type,
|
|
1914
|
+
options: options && options.length > 0 ? options : void 0,
|
|
1915
|
+
mediaKind: MEDIA_KINDS.includes(type) ? type : null,
|
|
1916
|
+
role: roleOf(variable),
|
|
1917
|
+
controlKey: isControlVariable(variable) ? variable.control?.key ?? null : null,
|
|
1918
|
+
variable
|
|
1919
|
+
};
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
1682
1922
|
//# sourceMappingURL=index.cjs.map
|