@eum-agent/llm-capability-image 0.0.0-stage → 1.1.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/dist/index.js +1323 -0
- package/package.json +56 -3
- package/ui/ui.js +228 -0
- package/README.md +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eum-agent/llm-capability-image",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
"displayName": {
|
|
4
|
+
"en-US": "Image Model Capability",
|
|
5
|
+
"zh-CN": "图像模型能力"
|
|
6
|
+
},
|
|
7
|
+
"version": "1.1.0",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"description": "Image Model Capability",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"ui"
|
|
19
|
+
],
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@eum-agent/plugin": "1.1.0",
|
|
22
|
+
"@types/react": "^19.2.18",
|
|
23
|
+
"@types/react-dom": "^19.2.5",
|
|
24
|
+
"@testing-library/react": "^16.3.3",
|
|
25
|
+
"@testing-library/user-event": "^14.6.6",
|
|
26
|
+
"jsdom": "^30.0.1",
|
|
27
|
+
"vite": "^8.2.2",
|
|
28
|
+
"@eum-agent/kernel": "1.0.0",
|
|
29
|
+
"@eum-agent/protocol": "1.0.0",
|
|
30
|
+
"sharp": "0.34.5",
|
|
31
|
+
"react": "^19.2.0",
|
|
32
|
+
"react-dom": "^19.2.0",
|
|
33
|
+
"lucide-react": "^1.40.0",
|
|
34
|
+
"ajv": "8.20.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"zod": "^4.4.3",
|
|
38
|
+
"gpt-tokenizer": "4.0.0"
|
|
39
|
+
},
|
|
40
|
+
"yaoguang": {
|
|
41
|
+
"description": {
|
|
42
|
+
"en-US": "Image Model Capability",
|
|
43
|
+
"zh-CN": "图像模型能力"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@eum-agent/llm-management": "1.1.0"
|
|
47
|
+
},
|
|
48
|
+
"kind": "extension",
|
|
49
|
+
"foundationDependencies": {
|
|
50
|
+
"@eum-agent/infra-local": "1.0.1",
|
|
51
|
+
"@eum-agent/storage-sqlite": "1.1.0"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsdown && vite build",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.ui.json"
|
|
58
|
+
}
|
|
6
59
|
}
|
package/ui/ui.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { useBrowserService } from "@eum-agent/host/framework";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region ui-src/metadata.ts
|
|
4
|
+
var TOOL_NAMES = ["model_image_generate"];
|
|
5
|
+
var labels = {
|
|
6
|
+
"en-US": {
|
|
7
|
+
model_list: "List models",
|
|
8
|
+
model_image_generate: "Generate image",
|
|
9
|
+
group: "Models",
|
|
10
|
+
section: "Built-in plugins"
|
|
11
|
+
},
|
|
12
|
+
"zh-CN": {
|
|
13
|
+
model_list: "查看模型",
|
|
14
|
+
model_image_generate: "生成图像",
|
|
15
|
+
group: "模型",
|
|
16
|
+
section: "内置插件"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function imageTarget(result) {
|
|
20
|
+
if (!result) return void 0;
|
|
21
|
+
try {
|
|
22
|
+
const parsed = JSON.parse(result.content);
|
|
23
|
+
if (!parsed || typeof parsed !== "object" || !("target" in parsed)) return void 0;
|
|
24
|
+
const target = parsed.target;
|
|
25
|
+
if (!target || typeof target !== "object" || !("providerId" in target) || !("model" in target) || typeof target.providerId !== "string" || typeof target.model !== "string") return void 0;
|
|
26
|
+
return `${target.providerId} / ${target.model}`;
|
|
27
|
+
} catch {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Registers model tool presentation with this browser activation's lifetime. */
|
|
32
|
+
function registerMetadata(ctx) {
|
|
33
|
+
ctx.i18n.register(labels, "en-US");
|
|
34
|
+
ctx.i18n.contribute(Object.fromEntries(Object.entries(labels).map(([language, catalogue]) => [language, Object.fromEntries(TOOL_NAMES.map((name) => [`transcript.actions.${name}`, catalogue[name]]))])), "en-US");
|
|
35
|
+
ctx.slots.register("chat.tool.presentation", {
|
|
36
|
+
id: "model-tool-metadata",
|
|
37
|
+
describe: ({ call, result }) => call.name === "model_image_generate" ? {
|
|
38
|
+
label: ctx.i18n.t("model_image_generate"),
|
|
39
|
+
icon: "image",
|
|
40
|
+
summary: imageTarget(result)
|
|
41
|
+
} : void 0
|
|
42
|
+
});
|
|
43
|
+
ctx.slots.register("chat.transcript.tool", {
|
|
44
|
+
id: "image",
|
|
45
|
+
tool: "model_image_generate",
|
|
46
|
+
label: () => ctx.i18n.t("model_image_generate"),
|
|
47
|
+
icon: "image"
|
|
48
|
+
});
|
|
49
|
+
ctx.slots.register("shell.tools.group", {
|
|
50
|
+
id: "model-tools-group",
|
|
51
|
+
describe: (tool) => tool.plugin === ctx.plugin ? {
|
|
52
|
+
key: `plugin:${ctx.plugin}`,
|
|
53
|
+
label: ctx.i18n.t("group"),
|
|
54
|
+
source: ctx.plugin,
|
|
55
|
+
sectionLabel: ctx.i18n.t("section"),
|
|
56
|
+
sectionOrder: 1,
|
|
57
|
+
order: 8
|
|
58
|
+
} : void 0
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region ui-src/offer-presentation.ts
|
|
63
|
+
/** Presents generation and editing only when the active Image adapter declares those operations. */
|
|
64
|
+
function createImageOfferPresentation(t) {
|
|
65
|
+
return {
|
|
66
|
+
facets: [{
|
|
67
|
+
id: "imageGeneration",
|
|
68
|
+
label: t("create"),
|
|
69
|
+
icon: "image"
|
|
70
|
+
}, {
|
|
71
|
+
id: "imageEdit",
|
|
72
|
+
label: t("edit"),
|
|
73
|
+
icon: "pencil"
|
|
74
|
+
}],
|
|
75
|
+
facetsOf({ descriptor }) {
|
|
76
|
+
const operations = descriptor.operations;
|
|
77
|
+
if (!Array.isArray(operations)) return [];
|
|
78
|
+
return ["create", "edit"].filter((id) => operations.some((operation) => !!operation && typeof operation === "object" && "id" in operation && operation.id === id)).map((id) => id === "create" ? "imageGeneration" : "imageEdit");
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region ui-src/parameters.tsx
|
|
84
|
+
/** Renders compact per-operation defaults and shared fields without changing invocation parameters. */
|
|
85
|
+
function ImageParameterFields({ ui, translate, Fields, ...props }) {
|
|
86
|
+
const operations = props.descriptor.operations;
|
|
87
|
+
const labels = /* @__PURE__ */ new Set([
|
|
88
|
+
"create",
|
|
89
|
+
"edit",
|
|
90
|
+
"size",
|
|
91
|
+
"quality",
|
|
92
|
+
"background",
|
|
93
|
+
"output_format",
|
|
94
|
+
"outputFormat",
|
|
95
|
+
"mimeType",
|
|
96
|
+
"mime_type",
|
|
97
|
+
"output_compression",
|
|
98
|
+
"aspectRatio",
|
|
99
|
+
"imageSize",
|
|
100
|
+
"n"
|
|
101
|
+
]);
|
|
102
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
103
|
+
className: "pf-image-parameters",
|
|
104
|
+
children: [operations?.map((operation) => {
|
|
105
|
+
const properties = operation.parameterSchema.properties;
|
|
106
|
+
const schema = properties ? {
|
|
107
|
+
...operation.parameterSchema,
|
|
108
|
+
properties: Object.fromEntries(Object.entries(properties).map(([key, field]) => [key, {
|
|
109
|
+
...field,
|
|
110
|
+
...labels.has(key) ? { title: translate(key) } : {}
|
|
111
|
+
}]))
|
|
112
|
+
} : operation.parameterSchema;
|
|
113
|
+
const value = props.params[operation.id];
|
|
114
|
+
return /* @__PURE__ */ jsxs(ui.Disclosure, {
|
|
115
|
+
className: "pf-image-operation",
|
|
116
|
+
open: true,
|
|
117
|
+
children: [/* @__PURE__ */ jsx(ui.DisclosureSummary, { children: labels.has(operation.id) ? translate(operation.id) : operation.id }), /* @__PURE__ */ jsx("div", {
|
|
118
|
+
className: "ui-panel pf-more-settings-panel",
|
|
119
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
120
|
+
className: "pf-parameter-fields",
|
|
121
|
+
children: /* @__PURE__ */ jsx(Fields, {
|
|
122
|
+
size: "sm",
|
|
123
|
+
schema,
|
|
124
|
+
value: value && typeof value === "object" && !Array.isArray(value) ? value : {},
|
|
125
|
+
disabled: props.disabled,
|
|
126
|
+
onChange: (value) => props.onChange({
|
|
127
|
+
...props.params,
|
|
128
|
+
[operation.id]: value
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
})]
|
|
133
|
+
}, operation.id);
|
|
134
|
+
}), props.advancedFields && /* @__PURE__ */ jsxs(ui.Disclosure, {
|
|
135
|
+
className: "pf-model-more-settings pf-image-more-settings",
|
|
136
|
+
children: [/* @__PURE__ */ jsx(ui.DisclosureSummary, {
|
|
137
|
+
className: "text-xs text-muted-foreground",
|
|
138
|
+
children: translate("moreSettings")
|
|
139
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
140
|
+
className: "ui-panel pf-more-settings-panel",
|
|
141
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
142
|
+
className: "pf-parameter-fields",
|
|
143
|
+
children: props.advancedFields
|
|
144
|
+
})
|
|
145
|
+
})]
|
|
146
|
+
})]
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region ui-src/styles.css?raw
|
|
151
|
+
var styles_default = ".pf-image-parameters {\n display: flex;\n min-width: 0;\n flex-direction: column;\n gap: 1rem;\n}\n.pf-image-operation > summary {\n font-size: 0.8125rem;\n font-weight: 500;\n}\n.pf-image-parameters .pf-more-settings-panel {\n margin-top: 0.75rem;\n padding: 1rem;\n border: 0;\n background: var(--muted);\n font-size: 0.875rem;\n}\n.pf-image-parameters .pf-parameter-fields {\n display: flex;\n min-width: 0;\n flex-direction: column;\n gap: 0.75rem;\n}\n.pf-image-parameters .settings-field-row > header h3 {\n font-size: 0.8125rem;\n}\n.pf-image-parameters [data-slot=\"input\"] {\n background: var(--background);\n font-size: 0.8125rem;\n}\n.pf-image-more-settings {\n margin-top: 0.25rem;\n border-top: 1px solid var(--border);\n padding-top: 0.75rem;\n}\n";
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region ui-src/index.tsx
|
|
154
|
+
/** Image model configuration is registered and withdrawn with the Image capability. */
|
|
155
|
+
/** Browser contract level shared with the product. */
|
|
156
|
+
var runtimeVersion = 5;
|
|
157
|
+
/** Capability forms mount only while their generic management renderer is available. */
|
|
158
|
+
var requires = ["model-management-ui"];
|
|
159
|
+
/** Adds the Image model tab without changing a host capability list. */
|
|
160
|
+
var register = (ctx) => {
|
|
161
|
+
registerMetadata(ctx);
|
|
162
|
+
ctx.styles.add(styles_default, { layer: "unlayered" });
|
|
163
|
+
ctx.i18n.register({
|
|
164
|
+
"en-US": {
|
|
165
|
+
models: "Image models",
|
|
166
|
+
moreSettings: "More settings",
|
|
167
|
+
create: "Image generation",
|
|
168
|
+
edit: "Image editing",
|
|
169
|
+
size: "Size",
|
|
170
|
+
quality: "Quality",
|
|
171
|
+
background: "Background",
|
|
172
|
+
output_format: "Output format",
|
|
173
|
+
outputFormat: "Output format",
|
|
174
|
+
mimeType: "File format",
|
|
175
|
+
mime_type: "File format",
|
|
176
|
+
output_compression: "Compression",
|
|
177
|
+
aspectRatio: "Aspect ratio",
|
|
178
|
+
imageSize: "Image resolution",
|
|
179
|
+
n: "Images"
|
|
180
|
+
},
|
|
181
|
+
"zh-CN": {
|
|
182
|
+
models: "图像模型",
|
|
183
|
+
moreSettings: "更多设置",
|
|
184
|
+
create: "图像生成",
|
|
185
|
+
edit: "图像编辑",
|
|
186
|
+
size: "尺寸",
|
|
187
|
+
quality: "画质",
|
|
188
|
+
background: "背景",
|
|
189
|
+
output_format: "输出格式",
|
|
190
|
+
outputFormat: "输出格式",
|
|
191
|
+
mimeType: "文件格式",
|
|
192
|
+
mime_type: "文件格式",
|
|
193
|
+
output_compression: "压缩质量",
|
|
194
|
+
aspectRatio: "宽高比",
|
|
195
|
+
imageSize: "分辨率",
|
|
196
|
+
n: "数量"
|
|
197
|
+
}
|
|
198
|
+
}, "en-US");
|
|
199
|
+
function ImageParameters(props) {
|
|
200
|
+
const renderer = useBrowserService("model-management-ui");
|
|
201
|
+
if (!renderer) return null;
|
|
202
|
+
return /* @__PURE__ */ jsx(ImageParameterFields, {
|
|
203
|
+
...props,
|
|
204
|
+
ui: ctx.ui,
|
|
205
|
+
translate: (key) => ctx.i18n.t(key),
|
|
206
|
+
Fields: renderer.schemaFields
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function ImageModels(props) {
|
|
210
|
+
const renderer = useBrowserService("model-management-ui");
|
|
211
|
+
if (!renderer) return null;
|
|
212
|
+
const Panel = renderer.component;
|
|
213
|
+
return /* @__PURE__ */ jsx(Panel, {
|
|
214
|
+
...props,
|
|
215
|
+
parameterEditor: ImageParameters,
|
|
216
|
+
offerPresentation: createImageOfferPresentation(ctx.i18n.t)
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
ctx.slots.register("model.settings.capability", {
|
|
220
|
+
id: "image-models",
|
|
221
|
+
capabilityId: "image",
|
|
222
|
+
label: () => ctx.i18n.t("models"),
|
|
223
|
+
order: 20,
|
|
224
|
+
component: ImageModels
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
//#endregion
|
|
228
|
+
export { register, requires, runtimeVersion };
|
package/README.md
DELETED