@ai-matrx/agents 0.13.15 → 0.13.16
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 +6 -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/mandates/snapshots/keys.0.13.15.json +2 -1
- package/mandates/snapshots/keys.0.13.16.json +619 -0
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -7,3 +7,165 @@ export { F as FollowRuntimeOperationOptions, a as FollowRuntimeOperationToEndOpt
|
|
|
7
7
|
export { CreateMatrxTransportOptions, MATRX_AI_API_VERSION_DEFAULT, MatrxAiApiVersion, MatrxCallError, MatrxClientToolResult, MatrxPendingCallSummary, MatrxProtocolDowngrade, MatrxProtocolFallbackOptions, MatrxRequestInfo, MatrxToolResultsResponse, MatrxTransportDiagnostics, MatrxTransportTarget, OrganizationContextError, OrganizationContextErrorCode, OrganizationOperation, V2_COVERED_AI_PATH_TEMPLATES, applyAiApiVersion, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createMatrxTransport, createOrganizationOperation, fetchWithMatrxProtocolFallback, isCoveredAiPath, isV2Path, listConversationPendingToolCalls, listUserPendingToolCalls, normalizeMatrxError, requireOrganizationContext, submitAgentToolResults, toV1FallbackUrl, toV2Path } from './matrx/index.cjs';
|
|
8
8
|
import '@ai-matrx/data';
|
|
9
9
|
import '@ai-matrx/data/net';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Media reference roles — the builder's side of the one vocabulary.
|
|
13
|
+
*
|
|
14
|
+
* Image generation reads an image as subject / character / style / mask /
|
|
15
|
+
* edit target / composition. Video generation reads an image as first frame /
|
|
16
|
+
* last frame / asset / style, a video as extend / restyle, and an audio clip as
|
|
17
|
+
* lip sync; an asset/style image or a reference video may carry a `name` the
|
|
18
|
+
* prompt addresses as `@name` (server: `matrx_ai/media/video_reference_roles.py`).
|
|
19
|
+
*
|
|
20
|
+
* A reference image in an image-generation request says what it controls.
|
|
21
|
+
* The role rides on the image block itself (`role` on the image part); absent
|
|
22
|
+
* = a plain image the model sees. The server owns the wire mapping and the
|
|
23
|
+
* refusal gate (aidream `matrx_ai/media/image_reference_roles.py`); this module
|
|
24
|
+
* mirrors its vocabulary and limits so the builder can tell the truth BEFORE a
|
|
25
|
+
* run: a role the selected model cannot take is shown greyed with the reason.
|
|
26
|
+
*
|
|
27
|
+
* Limits come from the catalog: the routing offering's
|
|
28
|
+
* `capabilities_override.image_reference_roles` (`{role: max, total: n}`).
|
|
29
|
+
* Law: `common-docs/systems/agents/typed-messages/FEATURE.md` (Image generation).
|
|
30
|
+
* Home: `@ai-matrx/agents` (moved from matrx-frontend `features/agents/image-roles/roles.ts`).
|
|
31
|
+
*/
|
|
32
|
+
/** The roles an IMAGE-generating model reads an image as (vocabulary order). */
|
|
33
|
+
declare const IMAGE_REFERENCE_ROLES: readonly ["subject", "character", "style", "mask", "edit_target", "composition_control"];
|
|
34
|
+
/** The roles a VIDEO-generating model reads an image as (`style` is shared). */
|
|
35
|
+
declare const VIDEO_IMAGE_ROLES: readonly ["first_frame", "last_frame", "asset", "style"];
|
|
36
|
+
/** Roles on a video part beside a video prompt. */
|
|
37
|
+
declare const VIDEO_REFERENCE_ROLES: readonly ["extend", "restyle"];
|
|
38
|
+
/** Roles on an audio part beside a video prompt. */
|
|
39
|
+
declare const AUDIO_REFERENCE_ROLES: readonly ["lip_sync"];
|
|
40
|
+
type ImageReferenceRole = (typeof IMAGE_REFERENCE_ROLES)[number] | (typeof VIDEO_IMAGE_ROLES)[number];
|
|
41
|
+
type VideoReferenceRole = (typeof VIDEO_REFERENCE_ROLES)[number];
|
|
42
|
+
type AudioReferenceRole = (typeof AUDIO_REFERENCE_ROLES)[number];
|
|
43
|
+
/** Any role a media part can carry — one union, one metadata table. */
|
|
44
|
+
type ReferenceRole = ImageReferenceRole | VideoReferenceRole | AudioReferenceRole;
|
|
45
|
+
interface ImageRoleMeta {
|
|
46
|
+
/** Segment label — plain words, never the wire token. */
|
|
47
|
+
label: string;
|
|
48
|
+
/** What the run form asks for when a variable fills this role. */
|
|
49
|
+
ask: string;
|
|
50
|
+
/** One line: what the model does with an image in this role. */
|
|
51
|
+
explanation: string;
|
|
52
|
+
}
|
|
53
|
+
declare const IMAGE_ROLE_META: Record<ReferenceRole, ImageRoleMeta>;
|
|
54
|
+
/** Which roles a block of this kind offers for this output modality. */
|
|
55
|
+
declare function rolesFor(blockKind: "image" | "video" | "audio", output: "image" | "video"): readonly ReferenceRole[];
|
|
56
|
+
/** Roles whose reference may carry a name the prompt addresses as `@name`. */
|
|
57
|
+
declare function roleTakesName(role: ReferenceRole | null | undefined): boolean;
|
|
58
|
+
/** `@name` rule shared with the server (media/video_reference_roles.py). */
|
|
59
|
+
declare function normalizeReferenceName(raw: string): string | null;
|
|
60
|
+
declare function isReferenceRole(value: unknown): value is ReferenceRole;
|
|
61
|
+
declare function isImageReferenceRole(value: unknown): value is ImageReferenceRole;
|
|
62
|
+
/**
|
|
63
|
+
* `{role: max, total: n, named: n}` — image roles from
|
|
64
|
+
* `capabilities_override.image_reference_roles`, video/audio roles and the
|
|
65
|
+
* named-reference cap from `capabilities_override.video_reference_roles`.
|
|
66
|
+
* Empty = the model takes no roled reference.
|
|
67
|
+
*/
|
|
68
|
+
type ImageRoleLimits = Partial<Record<ReferenceRole | "total" | "named", number>>;
|
|
69
|
+
/** Read the offering's role limits (image + video maps) defensively. */
|
|
70
|
+
declare function readImageRoleLimits(raw: unknown): ImageRoleLimits;
|
|
71
|
+
type ImageRoleVerdict = {
|
|
72
|
+
verdict: "ok";
|
|
73
|
+
} | {
|
|
74
|
+
verdict: "refused";
|
|
75
|
+
reason: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Can this model take an image in this role? The reason is a sentence a
|
|
79
|
+
* person can act on; it names the role and the model, like the server's
|
|
80
|
+
* refusal does.
|
|
81
|
+
*/
|
|
82
|
+
declare function imageRoleVerdict(role: ReferenceRole, limits: ImageRoleLimits, modelLabel: string, countOfRole?: number): ImageRoleVerdict;
|
|
83
|
+
/** Can this model take a named (`@name`) reference at all? */
|
|
84
|
+
declare function namedReferenceVerdict(limits: ImageRoleLimits, modelLabel: string): ImageRoleVerdict;
|
|
85
|
+
/** The variable an image block is filled by, when its url is exactly `{{name}}`. */
|
|
86
|
+
declare function variableNameOfImageUrl(url: unknown): string | null;
|
|
87
|
+
/** The variable any media block (image, video, audio) is filled by. */
|
|
88
|
+
declare function variableNameOfMediaUrl(url: unknown): string | null;
|
|
89
|
+
/**
|
|
90
|
+
* The one-line caption a REDISPLAYED reference shows — "Subject reference",
|
|
91
|
+
* "Style reference · @brand". Shared by the attachment chip and the inline
|
|
92
|
+
* image/video block so a role set in the builder is never lost on reload. An
|
|
93
|
+
* unrecognised role string is shown as-is (honest) rather than dropped.
|
|
94
|
+
*/
|
|
95
|
+
declare function referenceRoleCaption(role: unknown, name: unknown): string | null;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Run inputs — the ONE derivation from an agent's variable definitions to the
|
|
99
|
+
* inputs a run surface asks for.
|
|
100
|
+
*
|
|
101
|
+
* Every surface that runs an agent (the run page and chat composer, Agent
|
|
102
|
+
* Battle's shared request, a Workflow Studio Step node) asks the same
|
|
103
|
+
* questions in the same order: content inputs first, then bound model
|
|
104
|
+
* controls in a "Settings" group; a media variable that fills a reference role
|
|
105
|
+
* is asked for BY that role ("Style reference"); a control keeps the catalog
|
|
106
|
+
* component the builder stamped on it. A speech-script variable is an ordinary
|
|
107
|
+
* content variable — its `{{name}}` lives in a turn's text.
|
|
108
|
+
*
|
|
109
|
+
* Canonical doc: common-docs/systems/agents/typed-messages/FEATURE.md.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/** The minimum variable shape this derivation reads (a superset is fine). */
|
|
113
|
+
interface RunInputVariable {
|
|
114
|
+
name: string;
|
|
115
|
+
defaultValue?: unknown;
|
|
116
|
+
helpText?: string | null;
|
|
117
|
+
required?: boolean | null;
|
|
118
|
+
customComponent?: {
|
|
119
|
+
type?: string | null;
|
|
120
|
+
options?: readonly string[] | null;
|
|
121
|
+
imageRole?: unknown;
|
|
122
|
+
min?: number | null;
|
|
123
|
+
max?: number | null;
|
|
124
|
+
step?: number | null;
|
|
125
|
+
toggleValues?: readonly [string, string] | readonly string[] | null;
|
|
126
|
+
} | null;
|
|
127
|
+
control?: {
|
|
128
|
+
key?: string | null;
|
|
129
|
+
} | null;
|
|
130
|
+
}
|
|
131
|
+
type RunInputGroup = "content" | "settings";
|
|
132
|
+
type RunInputMediaKind = "image" | "video" | "audio" | "document" | "youtube";
|
|
133
|
+
interface RunInput<V extends RunInputVariable = RunInputVariable> {
|
|
134
|
+
name: string;
|
|
135
|
+
/** What the form asks: the role's ask for a roled media input, else the formatted name. */
|
|
136
|
+
label: string;
|
|
137
|
+
/** The variable's help text, else the role's one-line explanation. */
|
|
138
|
+
hint: string | undefined;
|
|
139
|
+
group: RunInputGroup;
|
|
140
|
+
required: boolean;
|
|
141
|
+
/** The component type the builder chose (`textarea` when none). */
|
|
142
|
+
component: string;
|
|
143
|
+
options: readonly string[] | undefined;
|
|
144
|
+
/** Set when this input takes a file / media reference. */
|
|
145
|
+
mediaKind: RunInputMediaKind | null;
|
|
146
|
+
/** The reference role a media input fills (subject, style, first_frame, …). */
|
|
147
|
+
role: ReferenceRole | null;
|
|
148
|
+
/** The model control this input IS (aspect_ratio, quality, voice, …). */
|
|
149
|
+
controlKey: string | null;
|
|
150
|
+
variable: V;
|
|
151
|
+
}
|
|
152
|
+
declare function isControlVariable(def: RunInputVariable): boolean;
|
|
153
|
+
/** Content inputs first, bound controls after — stable within each group. */
|
|
154
|
+
declare function partitionControlVariables<T extends RunInputVariable>(defs: readonly T[]): {
|
|
155
|
+
content: T[];
|
|
156
|
+
settings: T[];
|
|
157
|
+
};
|
|
158
|
+
/** The order every variable form renders in. Returns the same array when already ordered. */
|
|
159
|
+
declare function orderVariablesForForm<T extends RunInputVariable>(defs: T[]): T[];
|
|
160
|
+
/**
|
|
161
|
+
* The label a run form shows for a variable: a media variable that fills a
|
|
162
|
+
* reference role is asked for BY that role ("Style reference"); every other
|
|
163
|
+
* variable keeps its formatted name.
|
|
164
|
+
*/
|
|
165
|
+
declare function variableRunLabel(variable: RunInputVariable, formatName: (name: string) => string): string;
|
|
166
|
+
/** The hint under / beside a variable: its own help text, else the role's line. */
|
|
167
|
+
declare function variableRunHint(variable: RunInputVariable): string | undefined;
|
|
168
|
+
/** Derive the ordered, grouped, labelled run inputs for an agent's variables. */
|
|
169
|
+
declare function deriveRunInputs<V extends RunInputVariable>(defs: readonly V[] | null | undefined, formatName: (name: string) => string): RunInput<V>[];
|
|
170
|
+
|
|
171
|
+
export { AUDIO_REFERENCE_ROLES, type AudioReferenceRole, IMAGE_REFERENCE_ROLES, IMAGE_ROLE_META, type ImageReferenceRole, type ImageRoleLimits, type ImageRoleMeta, type ImageRoleVerdict, type ReferenceRole, type RunInput, type RunInputGroup, type RunInputMediaKind, type RunInputVariable, VIDEO_IMAGE_ROLES, VIDEO_REFERENCE_ROLES, type VideoReferenceRole, deriveRunInputs, imageRoleVerdict, isControlVariable, isImageReferenceRole, isReferenceRole, namedReferenceVerdict, normalizeReferenceName, orderVariablesForForm, partitionControlVariables, readImageRoleLimits, referenceRoleCaption, roleTakesName, rolesFor, variableNameOfImageUrl, variableNameOfMediaUrl, variableRunHint, variableRunLabel };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,3 +7,165 @@ export { F as FollowRuntimeOperationOptions, a as FollowRuntimeOperationToEndOpt
|
|
|
7
7
|
export { CreateMatrxTransportOptions, MATRX_AI_API_VERSION_DEFAULT, MatrxAiApiVersion, MatrxCallError, MatrxClientToolResult, MatrxPendingCallSummary, MatrxProtocolDowngrade, MatrxProtocolFallbackOptions, MatrxRequestInfo, MatrxToolResultsResponse, MatrxTransportDiagnostics, MatrxTransportTarget, OrganizationContextError, OrganizationContextErrorCode, OrganizationOperation, V2_COVERED_AI_PATH_TEMPLATES, applyAiApiVersion, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createMatrxTransport, createOrganizationOperation, fetchWithMatrxProtocolFallback, isCoveredAiPath, isV2Path, listConversationPendingToolCalls, listUserPendingToolCalls, normalizeMatrxError, requireOrganizationContext, submitAgentToolResults, toV1FallbackUrl, toV2Path } from './matrx/index.js';
|
|
8
8
|
import '@ai-matrx/data';
|
|
9
9
|
import '@ai-matrx/data/net';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Media reference roles — the builder's side of the one vocabulary.
|
|
13
|
+
*
|
|
14
|
+
* Image generation reads an image as subject / character / style / mask /
|
|
15
|
+
* edit target / composition. Video generation reads an image as first frame /
|
|
16
|
+
* last frame / asset / style, a video as extend / restyle, and an audio clip as
|
|
17
|
+
* lip sync; an asset/style image or a reference video may carry a `name` the
|
|
18
|
+
* prompt addresses as `@name` (server: `matrx_ai/media/video_reference_roles.py`).
|
|
19
|
+
*
|
|
20
|
+
* A reference image in an image-generation request says what it controls.
|
|
21
|
+
* The role rides on the image block itself (`role` on the image part); absent
|
|
22
|
+
* = a plain image the model sees. The server owns the wire mapping and the
|
|
23
|
+
* refusal gate (aidream `matrx_ai/media/image_reference_roles.py`); this module
|
|
24
|
+
* mirrors its vocabulary and limits so the builder can tell the truth BEFORE a
|
|
25
|
+
* run: a role the selected model cannot take is shown greyed with the reason.
|
|
26
|
+
*
|
|
27
|
+
* Limits come from the catalog: the routing offering's
|
|
28
|
+
* `capabilities_override.image_reference_roles` (`{role: max, total: n}`).
|
|
29
|
+
* Law: `common-docs/systems/agents/typed-messages/FEATURE.md` (Image generation).
|
|
30
|
+
* Home: `@ai-matrx/agents` (moved from matrx-frontend `features/agents/image-roles/roles.ts`).
|
|
31
|
+
*/
|
|
32
|
+
/** The roles an IMAGE-generating model reads an image as (vocabulary order). */
|
|
33
|
+
declare const IMAGE_REFERENCE_ROLES: readonly ["subject", "character", "style", "mask", "edit_target", "composition_control"];
|
|
34
|
+
/** The roles a VIDEO-generating model reads an image as (`style` is shared). */
|
|
35
|
+
declare const VIDEO_IMAGE_ROLES: readonly ["first_frame", "last_frame", "asset", "style"];
|
|
36
|
+
/** Roles on a video part beside a video prompt. */
|
|
37
|
+
declare const VIDEO_REFERENCE_ROLES: readonly ["extend", "restyle"];
|
|
38
|
+
/** Roles on an audio part beside a video prompt. */
|
|
39
|
+
declare const AUDIO_REFERENCE_ROLES: readonly ["lip_sync"];
|
|
40
|
+
type ImageReferenceRole = (typeof IMAGE_REFERENCE_ROLES)[number] | (typeof VIDEO_IMAGE_ROLES)[number];
|
|
41
|
+
type VideoReferenceRole = (typeof VIDEO_REFERENCE_ROLES)[number];
|
|
42
|
+
type AudioReferenceRole = (typeof AUDIO_REFERENCE_ROLES)[number];
|
|
43
|
+
/** Any role a media part can carry — one union, one metadata table. */
|
|
44
|
+
type ReferenceRole = ImageReferenceRole | VideoReferenceRole | AudioReferenceRole;
|
|
45
|
+
interface ImageRoleMeta {
|
|
46
|
+
/** Segment label — plain words, never the wire token. */
|
|
47
|
+
label: string;
|
|
48
|
+
/** What the run form asks for when a variable fills this role. */
|
|
49
|
+
ask: string;
|
|
50
|
+
/** One line: what the model does with an image in this role. */
|
|
51
|
+
explanation: string;
|
|
52
|
+
}
|
|
53
|
+
declare const IMAGE_ROLE_META: Record<ReferenceRole, ImageRoleMeta>;
|
|
54
|
+
/** Which roles a block of this kind offers for this output modality. */
|
|
55
|
+
declare function rolesFor(blockKind: "image" | "video" | "audio", output: "image" | "video"): readonly ReferenceRole[];
|
|
56
|
+
/** Roles whose reference may carry a name the prompt addresses as `@name`. */
|
|
57
|
+
declare function roleTakesName(role: ReferenceRole | null | undefined): boolean;
|
|
58
|
+
/** `@name` rule shared with the server (media/video_reference_roles.py). */
|
|
59
|
+
declare function normalizeReferenceName(raw: string): string | null;
|
|
60
|
+
declare function isReferenceRole(value: unknown): value is ReferenceRole;
|
|
61
|
+
declare function isImageReferenceRole(value: unknown): value is ImageReferenceRole;
|
|
62
|
+
/**
|
|
63
|
+
* `{role: max, total: n, named: n}` — image roles from
|
|
64
|
+
* `capabilities_override.image_reference_roles`, video/audio roles and the
|
|
65
|
+
* named-reference cap from `capabilities_override.video_reference_roles`.
|
|
66
|
+
* Empty = the model takes no roled reference.
|
|
67
|
+
*/
|
|
68
|
+
type ImageRoleLimits = Partial<Record<ReferenceRole | "total" | "named", number>>;
|
|
69
|
+
/** Read the offering's role limits (image + video maps) defensively. */
|
|
70
|
+
declare function readImageRoleLimits(raw: unknown): ImageRoleLimits;
|
|
71
|
+
type ImageRoleVerdict = {
|
|
72
|
+
verdict: "ok";
|
|
73
|
+
} | {
|
|
74
|
+
verdict: "refused";
|
|
75
|
+
reason: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Can this model take an image in this role? The reason is a sentence a
|
|
79
|
+
* person can act on; it names the role and the model, like the server's
|
|
80
|
+
* refusal does.
|
|
81
|
+
*/
|
|
82
|
+
declare function imageRoleVerdict(role: ReferenceRole, limits: ImageRoleLimits, modelLabel: string, countOfRole?: number): ImageRoleVerdict;
|
|
83
|
+
/** Can this model take a named (`@name`) reference at all? */
|
|
84
|
+
declare function namedReferenceVerdict(limits: ImageRoleLimits, modelLabel: string): ImageRoleVerdict;
|
|
85
|
+
/** The variable an image block is filled by, when its url is exactly `{{name}}`. */
|
|
86
|
+
declare function variableNameOfImageUrl(url: unknown): string | null;
|
|
87
|
+
/** The variable any media block (image, video, audio) is filled by. */
|
|
88
|
+
declare function variableNameOfMediaUrl(url: unknown): string | null;
|
|
89
|
+
/**
|
|
90
|
+
* The one-line caption a REDISPLAYED reference shows — "Subject reference",
|
|
91
|
+
* "Style reference · @brand". Shared by the attachment chip and the inline
|
|
92
|
+
* image/video block so a role set in the builder is never lost on reload. An
|
|
93
|
+
* unrecognised role string is shown as-is (honest) rather than dropped.
|
|
94
|
+
*/
|
|
95
|
+
declare function referenceRoleCaption(role: unknown, name: unknown): string | null;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Run inputs — the ONE derivation from an agent's variable definitions to the
|
|
99
|
+
* inputs a run surface asks for.
|
|
100
|
+
*
|
|
101
|
+
* Every surface that runs an agent (the run page and chat composer, Agent
|
|
102
|
+
* Battle's shared request, a Workflow Studio Step node) asks the same
|
|
103
|
+
* questions in the same order: content inputs first, then bound model
|
|
104
|
+
* controls in a "Settings" group; a media variable that fills a reference role
|
|
105
|
+
* is asked for BY that role ("Style reference"); a control keeps the catalog
|
|
106
|
+
* component the builder stamped on it. A speech-script variable is an ordinary
|
|
107
|
+
* content variable — its `{{name}}` lives in a turn's text.
|
|
108
|
+
*
|
|
109
|
+
* Canonical doc: common-docs/systems/agents/typed-messages/FEATURE.md.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/** The minimum variable shape this derivation reads (a superset is fine). */
|
|
113
|
+
interface RunInputVariable {
|
|
114
|
+
name: string;
|
|
115
|
+
defaultValue?: unknown;
|
|
116
|
+
helpText?: string | null;
|
|
117
|
+
required?: boolean | null;
|
|
118
|
+
customComponent?: {
|
|
119
|
+
type?: string | null;
|
|
120
|
+
options?: readonly string[] | null;
|
|
121
|
+
imageRole?: unknown;
|
|
122
|
+
min?: number | null;
|
|
123
|
+
max?: number | null;
|
|
124
|
+
step?: number | null;
|
|
125
|
+
toggleValues?: readonly [string, string] | readonly string[] | null;
|
|
126
|
+
} | null;
|
|
127
|
+
control?: {
|
|
128
|
+
key?: string | null;
|
|
129
|
+
} | null;
|
|
130
|
+
}
|
|
131
|
+
type RunInputGroup = "content" | "settings";
|
|
132
|
+
type RunInputMediaKind = "image" | "video" | "audio" | "document" | "youtube";
|
|
133
|
+
interface RunInput<V extends RunInputVariable = RunInputVariable> {
|
|
134
|
+
name: string;
|
|
135
|
+
/** What the form asks: the role's ask for a roled media input, else the formatted name. */
|
|
136
|
+
label: string;
|
|
137
|
+
/** The variable's help text, else the role's one-line explanation. */
|
|
138
|
+
hint: string | undefined;
|
|
139
|
+
group: RunInputGroup;
|
|
140
|
+
required: boolean;
|
|
141
|
+
/** The component type the builder chose (`textarea` when none). */
|
|
142
|
+
component: string;
|
|
143
|
+
options: readonly string[] | undefined;
|
|
144
|
+
/** Set when this input takes a file / media reference. */
|
|
145
|
+
mediaKind: RunInputMediaKind | null;
|
|
146
|
+
/** The reference role a media input fills (subject, style, first_frame, …). */
|
|
147
|
+
role: ReferenceRole | null;
|
|
148
|
+
/** The model control this input IS (aspect_ratio, quality, voice, …). */
|
|
149
|
+
controlKey: string | null;
|
|
150
|
+
variable: V;
|
|
151
|
+
}
|
|
152
|
+
declare function isControlVariable(def: RunInputVariable): boolean;
|
|
153
|
+
/** Content inputs first, bound controls after — stable within each group. */
|
|
154
|
+
declare function partitionControlVariables<T extends RunInputVariable>(defs: readonly T[]): {
|
|
155
|
+
content: T[];
|
|
156
|
+
settings: T[];
|
|
157
|
+
};
|
|
158
|
+
/** The order every variable form renders in. Returns the same array when already ordered. */
|
|
159
|
+
declare function orderVariablesForForm<T extends RunInputVariable>(defs: T[]): T[];
|
|
160
|
+
/**
|
|
161
|
+
* The label a run form shows for a variable: a media variable that fills a
|
|
162
|
+
* reference role is asked for BY that role ("Style reference"); every other
|
|
163
|
+
* variable keeps its formatted name.
|
|
164
|
+
*/
|
|
165
|
+
declare function variableRunLabel(variable: RunInputVariable, formatName: (name: string) => string): string;
|
|
166
|
+
/** The hint under / beside a variable: its own help text, else the role's line. */
|
|
167
|
+
declare function variableRunHint(variable: RunInputVariable): string | undefined;
|
|
168
|
+
/** Derive the ordered, grouped, labelled run inputs for an agent's variables. */
|
|
169
|
+
declare function deriveRunInputs<V extends RunInputVariable>(defs: readonly V[] | null | undefined, formatName: (name: string) => string): RunInput<V>[];
|
|
170
|
+
|
|
171
|
+
export { AUDIO_REFERENCE_ROLES, type AudioReferenceRole, IMAGE_REFERENCE_ROLES, IMAGE_ROLE_META, type ImageReferenceRole, type ImageRoleLimits, type ImageRoleMeta, type ImageRoleVerdict, type ReferenceRole, type RunInput, type RunInputGroup, type RunInputMediaKind, type RunInputVariable, VIDEO_IMAGE_ROLES, VIDEO_REFERENCE_ROLES, type VideoReferenceRole, deriveRunInputs, imageRoleVerdict, isControlVariable, isImageReferenceRole, isReferenceRole, namedReferenceVerdict, normalizeReferenceName, orderVariablesForForm, partitionControlVariables, readImageRoleLimits, referenceRoleCaption, roleTakesName, rolesFor, variableNameOfImageUrl, variableNameOfMediaUrl, variableRunHint, variableRunLabel };
|
package/dist/index.js
CHANGED
|
@@ -1602,15 +1602,238 @@ function listUserPendingToolCalls(transport, options = {}) {
|
|
|
1602
1602
|
}
|
|
1603
1603
|
);
|
|
1604
1604
|
}
|
|
1605
|
+
|
|
1606
|
+
// variables/reference-roles.ts
|
|
1607
|
+
var IMAGE_REFERENCE_ROLES = [
|
|
1608
|
+
"subject",
|
|
1609
|
+
"character",
|
|
1610
|
+
"style",
|
|
1611
|
+
"mask",
|
|
1612
|
+
"edit_target",
|
|
1613
|
+
"composition_control"
|
|
1614
|
+
];
|
|
1615
|
+
var VIDEO_IMAGE_ROLES = [
|
|
1616
|
+
"first_frame",
|
|
1617
|
+
"last_frame",
|
|
1618
|
+
"asset",
|
|
1619
|
+
"style"
|
|
1620
|
+
];
|
|
1621
|
+
var VIDEO_REFERENCE_ROLES = ["extend", "restyle"];
|
|
1622
|
+
var AUDIO_REFERENCE_ROLES = ["lip_sync"];
|
|
1623
|
+
var ALL_IMAGE_ROLES = [
|
|
1624
|
+
...IMAGE_REFERENCE_ROLES,
|
|
1625
|
+
...VIDEO_IMAGE_ROLES
|
|
1626
|
+
];
|
|
1627
|
+
var IMAGE_ROLE_META = {
|
|
1628
|
+
subject: {
|
|
1629
|
+
label: "Subject",
|
|
1630
|
+
ask: "Subject reference",
|
|
1631
|
+
explanation: "Keeps this exact product or object recognisable: shape, materials, labels."
|
|
1632
|
+
},
|
|
1633
|
+
character: {
|
|
1634
|
+
label: "Character",
|
|
1635
|
+
ask: "Character reference",
|
|
1636
|
+
explanation: "Keeps this person or character looking the same."
|
|
1637
|
+
},
|
|
1638
|
+
style: {
|
|
1639
|
+
label: "Style",
|
|
1640
|
+
ask: "Style reference",
|
|
1641
|
+
explanation: "Borrows only the look (colours, lighting, medium), never the content."
|
|
1642
|
+
},
|
|
1643
|
+
mask: {
|
|
1644
|
+
label: "Mask",
|
|
1645
|
+
ask: "Mask",
|
|
1646
|
+
explanation: "Marks the only area of the edited image that is allowed to change."
|
|
1647
|
+
},
|
|
1648
|
+
edit_target: {
|
|
1649
|
+
label: "Edit this",
|
|
1650
|
+
ask: "Image to edit",
|
|
1651
|
+
explanation: "The image being edited; everything not asked for stays the same."
|
|
1652
|
+
},
|
|
1653
|
+
composition_control: {
|
|
1654
|
+
label: "Composition",
|
|
1655
|
+
ask: "Composition reference",
|
|
1656
|
+
explanation: "Follows its layout, pose and geometry, not its appearance."
|
|
1657
|
+
},
|
|
1658
|
+
first_frame: {
|
|
1659
|
+
label: "First frame",
|
|
1660
|
+
ask: "First frame",
|
|
1661
|
+
explanation: "The video starts on exactly this image."
|
|
1662
|
+
},
|
|
1663
|
+
last_frame: {
|
|
1664
|
+
label: "Last frame",
|
|
1665
|
+
ask: "Last frame",
|
|
1666
|
+
explanation: "The video ends on exactly this image (needs a first frame)."
|
|
1667
|
+
},
|
|
1668
|
+
asset: {
|
|
1669
|
+
label: "Asset",
|
|
1670
|
+
ask: "Asset reference",
|
|
1671
|
+
explanation: "Keeps this product, object or character recognisable throughout the clip."
|
|
1672
|
+
},
|
|
1673
|
+
extend: {
|
|
1674
|
+
label: "Extend",
|
|
1675
|
+
ask: "Video to extend",
|
|
1676
|
+
explanation: "The new clip continues this video from its last frame."
|
|
1677
|
+
},
|
|
1678
|
+
restyle: {
|
|
1679
|
+
label: "Restyle",
|
|
1680
|
+
ask: "Reference video",
|
|
1681
|
+
explanation: "Re-renders this video: same motion and timing, a new look."
|
|
1682
|
+
},
|
|
1683
|
+
lip_sync: {
|
|
1684
|
+
label: "Lip sync",
|
|
1685
|
+
ask: "Lip-sync audio",
|
|
1686
|
+
explanation: "The speech the on-screen face mouths, word for word."
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
function rolesFor(blockKind, output) {
|
|
1690
|
+
if (output === "image") return blockKind === "image" ? IMAGE_REFERENCE_ROLES : [];
|
|
1691
|
+
if (blockKind === "image") return VIDEO_IMAGE_ROLES;
|
|
1692
|
+
if (blockKind === "video") return VIDEO_REFERENCE_ROLES;
|
|
1693
|
+
return AUDIO_REFERENCE_ROLES;
|
|
1694
|
+
}
|
|
1695
|
+
function roleTakesName(role) {
|
|
1696
|
+
return role === "asset" || role === "style" || role === "restyle" || role === "extend";
|
|
1697
|
+
}
|
|
1698
|
+
function normalizeReferenceName(raw) {
|
|
1699
|
+
const candidate = raw.trim().replace(/^@/, "");
|
|
1700
|
+
if (!candidate) return null;
|
|
1701
|
+
return /^[A-Za-z][A-Za-z0-9_-]{0,31}$/.test(candidate) ? candidate : null;
|
|
1702
|
+
}
|
|
1703
|
+
function isReferenceRole(value) {
|
|
1704
|
+
return typeof value === "string" && value in IMAGE_ROLE_META;
|
|
1705
|
+
}
|
|
1706
|
+
function isImageReferenceRole(value) {
|
|
1707
|
+
return typeof value === "string" && ALL_IMAGE_ROLES.includes(value);
|
|
1708
|
+
}
|
|
1709
|
+
function readLimitMap(source, accept, out) {
|
|
1710
|
+
if (typeof source !== "object" || source === null || Array.isArray(source)) return;
|
|
1711
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1712
|
+
if (accept(key) && typeof value === "number" && Number.isInteger(value) && value >= 0) {
|
|
1713
|
+
out[key] = value;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
function readImageRoleLimits(raw) {
|
|
1718
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return {};
|
|
1719
|
+
const record = raw;
|
|
1720
|
+
const out = {};
|
|
1721
|
+
readLimitMap(
|
|
1722
|
+
record.image_reference_roles,
|
|
1723
|
+
(k) => isImageReferenceRole(k) || k === "total",
|
|
1724
|
+
out
|
|
1725
|
+
);
|
|
1726
|
+
readLimitMap(
|
|
1727
|
+
record.video_reference_roles,
|
|
1728
|
+
(k) => VIDEO_REFERENCE_ROLES.includes(k) || AUDIO_REFERENCE_ROLES.includes(k) || k === "named",
|
|
1729
|
+
out
|
|
1730
|
+
);
|
|
1731
|
+
return out;
|
|
1732
|
+
}
|
|
1733
|
+
function imageRoleVerdict(role, limits, modelLabel, countOfRole = 1) {
|
|
1734
|
+
const label = IMAGE_ROLE_META[role].label;
|
|
1735
|
+
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";
|
|
1736
|
+
const allowed = limits[role] ?? 0;
|
|
1737
|
+
if (allowed <= 0) {
|
|
1738
|
+
return {
|
|
1739
|
+
verdict: "refused",
|
|
1740
|
+
reason: `${modelLabel} cannot take a ${label} ${noun}. Pick another role or another model.`
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
if (countOfRole > allowed) {
|
|
1744
|
+
return {
|
|
1745
|
+
verdict: "refused",
|
|
1746
|
+
reason: `${modelLabel} takes at most ${allowed} ${label} ${noun}${allowed === 1 ? "" : "s"}; this message has ${countOfRole}.`
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
return { verdict: "ok" };
|
|
1750
|
+
}
|
|
1751
|
+
function namedReferenceVerdict(limits, modelLabel) {
|
|
1752
|
+
return (limits.named ?? 0) > 0 ? { verdict: "ok" } : {
|
|
1753
|
+
verdict: "refused",
|
|
1754
|
+
reason: `${modelLabel} cannot take named references. Clear the name, or pick a model with named elements.`
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
function variableNameOfImageUrl(url) {
|
|
1758
|
+
return variableNameOfMediaUrl(url);
|
|
1759
|
+
}
|
|
1760
|
+
function variableNameOfMediaUrl(url) {
|
|
1761
|
+
if (typeof url !== "string") return null;
|
|
1762
|
+
const match = /^\s*\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}\s*$/.exec(url);
|
|
1763
|
+
return match?.[1] ?? null;
|
|
1764
|
+
}
|
|
1765
|
+
function referenceRoleCaption(role, name) {
|
|
1766
|
+
const roleLabel = typeof role === "string" && role ? isReferenceRole(role) ? IMAGE_ROLE_META[role].ask : role : null;
|
|
1767
|
+
const refName = typeof name === "string" ? normalizeReferenceName(name) : null;
|
|
1768
|
+
if (!roleLabel && !refName) return null;
|
|
1769
|
+
return [roleLabel, refName ? `@${refName}` : null].filter(Boolean).join(" \xB7 ");
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
// variables/run-inputs.ts
|
|
1773
|
+
var MEDIA_KINDS = ["image", "video", "audio", "document", "youtube"];
|
|
1774
|
+
function isControlVariable(def) {
|
|
1775
|
+
return typeof def.control?.key === "string" && def.control.key.length > 0;
|
|
1776
|
+
}
|
|
1777
|
+
function partitionControlVariables(defs) {
|
|
1778
|
+
const content = [];
|
|
1779
|
+
const settings = [];
|
|
1780
|
+
for (const d of defs) (isControlVariable(d) ? settings : content).push(d);
|
|
1781
|
+
return { content, settings };
|
|
1782
|
+
}
|
|
1783
|
+
function orderVariablesForForm(defs) {
|
|
1784
|
+
const { content, settings } = partitionControlVariables(defs);
|
|
1785
|
+
if (settings.length === 0) return defs;
|
|
1786
|
+
const ordered = [...content, ...settings];
|
|
1787
|
+
return ordered.every((d, i) => d === defs[i]) ? defs : ordered;
|
|
1788
|
+
}
|
|
1789
|
+
function roleOf(variable) {
|
|
1790
|
+
const type = variable.customComponent?.type;
|
|
1791
|
+
const role = variable.customComponent?.imageRole;
|
|
1792
|
+
const roled = type === "image" || type === "video" || type === "audio";
|
|
1793
|
+
return roled && isReferenceRole(role) ? role : null;
|
|
1794
|
+
}
|
|
1795
|
+
function variableRunLabel(variable, formatName) {
|
|
1796
|
+
const role = roleOf(variable);
|
|
1797
|
+
return role ? IMAGE_ROLE_META[role].ask : formatName(variable.name);
|
|
1798
|
+
}
|
|
1799
|
+
function variableRunHint(variable) {
|
|
1800
|
+
if (variable.helpText) return variable.helpText;
|
|
1801
|
+
const role = roleOf(variable);
|
|
1802
|
+
return role ? IMAGE_ROLE_META[role].explanation : void 0;
|
|
1803
|
+
}
|
|
1804
|
+
function deriveRunInputs(defs, formatName) {
|
|
1805
|
+
return orderVariablesForForm([...defs ?? []]).map((variable) => {
|
|
1806
|
+
const type = variable.customComponent?.type ?? "textarea";
|
|
1807
|
+
const options = variable.customComponent?.options ?? void 0;
|
|
1808
|
+
return {
|
|
1809
|
+
name: variable.name,
|
|
1810
|
+
label: variableRunLabel(variable, formatName),
|
|
1811
|
+
hint: variableRunHint(variable),
|
|
1812
|
+
group: isControlVariable(variable) ? "settings" : "content",
|
|
1813
|
+
required: Boolean(variable.required),
|
|
1814
|
+
component: type,
|
|
1815
|
+
options: options && options.length > 0 ? options : void 0,
|
|
1816
|
+
mediaKind: MEDIA_KINDS.includes(type) ? type : null,
|
|
1817
|
+
role: roleOf(variable),
|
|
1818
|
+
controlKey: isControlVariable(variable) ? variable.control?.key ?? null : null,
|
|
1819
|
+
variable
|
|
1820
|
+
};
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1605
1823
|
export {
|
|
1824
|
+
AUDIO_REFERENCE_ROLES,
|
|
1606
1825
|
DEFAULT_MATRX_NDJSON_READ_AHEAD,
|
|
1607
1826
|
DEFAULT_WORKFLOW_PROJECTION_LIMITS,
|
|
1827
|
+
IMAGE_REFERENCE_ROLES,
|
|
1828
|
+
IMAGE_ROLE_META,
|
|
1608
1829
|
MATRX_AI_API_VERSION_DEFAULT,
|
|
1609
1830
|
MatrxApiError,
|
|
1610
1831
|
MatrxRunError,
|
|
1611
1832
|
OrganizationContextError,
|
|
1612
1833
|
TERMINAL_MATRX_RUNTIME_STATUSES,
|
|
1613
1834
|
V2_COVERED_AI_PATH_TEMPLATES,
|
|
1835
|
+
VIDEO_IMAGE_ROLES,
|
|
1836
|
+
VIDEO_REFERENCE_ROLES,
|
|
1614
1837
|
applyAiApiVersion,
|
|
1615
1838
|
applyOrganizationContextHeader,
|
|
1616
1839
|
assertOrganizationMatchesOperation,
|
|
@@ -1625,6 +1848,7 @@ export {
|
|
|
1625
1848
|
createMatrxTransport,
|
|
1626
1849
|
createOrganizationOperation,
|
|
1627
1850
|
createWorkflowNodeProjection,
|
|
1851
|
+
deriveRunInputs,
|
|
1628
1852
|
extractMatrxErrorCode,
|
|
1629
1853
|
extractMatrxErrorMessage,
|
|
1630
1854
|
fetchWithMatrxProtocolFallback,
|
|
@@ -1632,31 +1856,47 @@ export {
|
|
|
1632
1856
|
followRuntimeOperationToEnd,
|
|
1633
1857
|
getRuntimeOperationStatus,
|
|
1634
1858
|
getRuntimeOperationsByLink,
|
|
1859
|
+
imageRoleVerdict,
|
|
1860
|
+
isControlVariable,
|
|
1635
1861
|
isCoveredAiPath,
|
|
1862
|
+
isImageReferenceRole,
|
|
1863
|
+
isReferenceRole,
|
|
1636
1864
|
isV2Path,
|
|
1637
1865
|
listConversationPendingToolCalls,
|
|
1638
1866
|
listRuntimeOperationEvents,
|
|
1639
1867
|
listUserPendingToolCalls,
|
|
1640
1868
|
mintMatrxConversationId,
|
|
1869
|
+
namedReferenceVerdict,
|
|
1641
1870
|
newEphemeralConversationStart,
|
|
1642
1871
|
newStoredConversationStart,
|
|
1643
1872
|
normalizeMatrxError,
|
|
1644
1873
|
normalizeMatrxStreamEnvelope,
|
|
1874
|
+
normalizeReferenceName,
|
|
1875
|
+
orderVariablesForForm,
|
|
1645
1876
|
parseMatrxSseFrame,
|
|
1877
|
+
partitionControlVariables,
|
|
1646
1878
|
projectAgentEvent,
|
|
1647
1879
|
projectAgentEvents,
|
|
1648
1880
|
projectAgentResultForDisplay,
|
|
1649
1881
|
projectWorkflowNodeEvent,
|
|
1882
|
+
readImageRoleLimits,
|
|
1650
1883
|
readMatrxNdjsonStream,
|
|
1651
1884
|
readMatrxSseStream,
|
|
1885
|
+
referenceRoleCaption,
|
|
1652
1886
|
rejoinRuntimeOperation,
|
|
1653
1887
|
requireOrganizationContext,
|
|
1654
1888
|
resumeAgentConversation,
|
|
1889
|
+
roleTakesName,
|
|
1890
|
+
rolesFor,
|
|
1655
1891
|
runAgentToCompletion,
|
|
1656
1892
|
startAgentRun,
|
|
1657
1893
|
startMandateRun,
|
|
1658
1894
|
submitAgentToolResults,
|
|
1659
1895
|
toV1FallbackUrl,
|
|
1660
|
-
toV2Path
|
|
1896
|
+
toV2Path,
|
|
1897
|
+
variableNameOfImageUrl,
|
|
1898
|
+
variableNameOfMediaUrl,
|
|
1899
|
+
variableRunHint,
|
|
1900
|
+
variableRunLabel
|
|
1661
1901
|
};
|
|
1662
1902
|
//# sourceMappingURL=index.js.map
|