@nimiplatform/app-tools 0.2.8 → 0.3.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/README.md +113 -5
- package/bin/nimi-app.mjs +4 -0
- package/lib/app-doctor-update.mjs +7 -1
- package/lib/app-pack.mjs +33 -11
- package/lib/app-project-lifecycle.mjs +1 -0
- package/lib/app-scaffold-profiles.mjs +29 -14
- package/lib/app-scaffold.mjs +53 -7
- package/lib/macos-native.mjs +96 -0
- package/lib/payload-links.mjs +41 -0
- package/package.json +7 -7
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +31 -0
- package/templates/app-source/src/ai-studio-core/history-policy.ts +23 -1
- package/templates/app-source/src/ai-studio-core/history.ts +7 -1
- package/templates/app-source/src/ai-studio-core/messages/en.json +1 -0
- package/templates/app-source/src/ai-studio-core/messages/zh.json +1 -0
- package/templates/app-source/src/ai-studio-core/module-registration.ts +2 -2
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +6 -2
- package/templates/app-source/src/ai-studio-core/run-target.ts +1 -1
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +4 -0
- package/templates/app-source/src/ai-studio-core/runtime.ts +13 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-admission.ts +3 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +41 -13
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +1 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +1 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +26 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +14 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +3 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +12 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-input.tsx +56 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +22 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +54 -29
- package/templates/app-source/src/product-modules/agent-realtime/index.tsx +2 -2
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +1 -0
- package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +6 -1
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +19 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +19 -0
- package/templates/app-source/src/studio-modules/studio-media/registration.ts +10 -1
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +2 -0
- package/templates/app-source/src/studio-modules/studio-media/vision-parameters.tsx +18 -0
- package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +58 -0
- package/templates/app-source/src/workbench-core/workbench-core.css +5 -0
- package/templates/app-source.manifest.json +16 -0
- package/templates/default-starter/README.md +25 -1
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
+
"VisionLocate": {
|
|
3
|
+
"chooseImage": "选择图片",
|
|
4
|
+
"replaceImage": "更换图片",
|
|
5
|
+
"draftImage": "待定位的图片",
|
|
6
|
+
"imageHint": "一张静态图片 · PNG、JPEG、WebP 或 GIF · 不超过 32 MiB",
|
|
7
|
+
"queryLabel": "描述目标",
|
|
8
|
+
"modelSelectionRequired": "尚未选择图像定位的模型配置。",
|
|
9
|
+
"selectModelAction": "在 Nimi Desktop 的“运行时 → 模型配置”中选择图像定位配置,然后重新定位。",
|
|
10
|
+
"invalidInput": "图片或目标描述不符合定位要求。",
|
|
11
|
+
"correctInput": "请使用一张能正常打开的静态 JPEG、PNG、WebP 或 GIF(不支持多帧图片),不超过 32 MiB、约 6700 万像素。填写非空的目标描述,UTF-8 编码不超过 8 KiB,然后重新定位。",
|
|
12
|
+
"historySummaryOnly": "此定位结果较大,历史仅保留摘要和任务编号。完整坐标请在当次运行中导出。",
|
|
13
|
+
"stoppedBeforeSubmit": "定位请求已停止,尚未提交任务。",
|
|
14
|
+
"geometry": "结果形态", "box": "边界框", "point": "定位点", "localOnly": "使用本地图像定位,可通过下方配置入口选择模型。",
|
|
15
|
+
"inputRequired": "请附上一张静态图片,并描述要定位的目标。", "imageTooLarge": "请选择不超过 32 MiB 的静态图片。", "resultMissing": "Runtime 未返回完整的定位结果。",
|
|
16
|
+
"found": "找到 {{count}} 个匹配目标", "noMatch": "未找到匹配目标", "sourceImage": "本次任务使用的图片", "overlay": "任务图片上的定位结果", "target": "目标 {{index}}",
|
|
17
|
+
"previewUnavailable": "输入图片的预览已不可用。下方坐标仍对应记录中的原图。", "coordinates": "图片标识与坐标", "matches": "匹配目标", "queued": "正在排队等待定位…", "running": "正在加载模型或定位目标…"
|
|
18
|
+
},
|
|
2
19
|
"Capabilities": {
|
|
20
|
+
"visionLocate": { "label": "图像定位", "summary": "描述单张图片中的物体或控件,获取边界框或定位点。" },
|
|
3
21
|
"imageGenerate": {
|
|
4
22
|
"label": "图像生成",
|
|
5
23
|
"summary": "提示词 → image.generate 场景任务 → 类型化产物预览结果。"
|
|
@@ -15,6 +33,7 @@
|
|
|
15
33
|
},
|
|
16
34
|
"Studio": {
|
|
17
35
|
"profiles": {
|
|
36
|
+
"visionLocate": { "inputTitle": "测试图像定位", "inputPlaceholder": "例如:右上角的搜索按钮,或桌上的红色杯子…", "primaryLabel": "定位目标", "primaryRunningLabel": "正在定位…", "emptyTitle": "定位图片中的物体或控件", "emptyHint": "选择一张静态图片,描述目标,再选择边界框或定位点。", "footnote": "坐标以应用方向后的完整原图为基准。" },
|
|
18
37
|
"imageGenerate": {
|
|
19
38
|
"inputTitle": "测试图像生成",
|
|
20
39
|
"inputPlaceholder": "描述你希望 Runtime 渲染的图像…",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Image as ImageIcon, Music2, Video } from 'lucide-react';
|
|
1
|
+
import { Image as ImageIcon, Music2, Video, ScanSearch } from 'lucide-react';
|
|
2
|
+
import { StudioVisionParameterPanel, studioVisionLocateParameters } from './vision-parameters.js';
|
|
2
3
|
import type { AIStudioModuleRegistration } from '../../ai-studio-core/module-registration.js';
|
|
3
4
|
import { studioMediaDescriptors, type StudioMediaCapabilityId } from './descriptors.js';
|
|
4
5
|
import { studioImageGenerateParameters, studioMusicGenerateParameters, studioVideoGenerateParameters } from './parameters.js';
|
|
@@ -7,6 +8,14 @@ import { StudioMediaParameterPanel } from './parameter-panel.js';
|
|
|
7
8
|
export const studioMediaModule = Object.freeze({
|
|
8
9
|
id: 'studio-media', navigationLabel: 'Media', order: 20,
|
|
9
10
|
capabilities: [
|
|
11
|
+
{
|
|
12
|
+
descriptor: studioMediaDescriptors[3], icon: ScanSearch,
|
|
13
|
+
profile: {
|
|
14
|
+
studioTag: 'Vision', inputTitleKey: 'Studio.profiles.visionLocate.inputTitle', inputPlaceholderKey: 'Studio.profiles.visionLocate.inputPlaceholder', inputKind: 'prompt', supportsAttachments: true, controls: [], primaryLabelKey: 'Studio.profiles.visionLocate.primaryLabel', primaryRunningLabelKey: 'Studio.profiles.visionLocate.primaryRunningLabel', resultTitle: 'Locations', emptyTitleKey: 'Studio.profiles.visionLocate.emptyTitle', emptyHintKey: 'Studio.profiles.visionLocate.emptyHint', resultKind: 'vision-locate', footnoteKey: 'Studio.profiles.visionLocate.footnote',
|
|
15
|
+
},
|
|
16
|
+
preset: { id: 'locate-object', label: 'Locate an object', prompt: '' },
|
|
17
|
+
runtimeMethod: 'runtime.ai.submitScenarioJob:vision_locate', parameters: studioVisionLocateParameters, parameterPanel: StudioVisionParameterPanel,
|
|
18
|
+
},
|
|
10
19
|
{
|
|
11
20
|
descriptor: studioMediaDescriptors[0],
|
|
12
21
|
icon: ImageIcon,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StudioCapabilityRuntimeHandlers } from '../../ai-studio-core/runtime-dispatcher.js';
|
|
2
|
+
import { runVisionLocate } from './vision-runtime.js';
|
|
2
3
|
import {
|
|
3
4
|
createStudioScenarioJobClient,
|
|
4
5
|
projectStudioArtifactRunnerResult,
|
|
@@ -13,6 +14,7 @@ import type {
|
|
|
13
14
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-019c
|
|
14
15
|
|
|
15
16
|
export const studioMediaRuntimeHandlers: StudioCapabilityRuntimeHandlers = Object.freeze({
|
|
17
|
+
'vision.locate': runVisionLocate,
|
|
16
18
|
'image.generate': runImageGenerate,
|
|
17
19
|
'video.generate': runVideoGenerate,
|
|
18
20
|
'music.generate': runMusicGenerate,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SelectField } from '@nimiplatform/kit/ui';
|
|
2
|
+
import { defineStudioParameters, LOCAL_ONLY_STUDIO_PARAMETER } from '../../ai-studio-core/parameters.js';
|
|
3
|
+
import { StudioParameterField, type StudioParameterPanelProps } from '../../ai-studio-core/parameter-fields.js';
|
|
4
|
+
import { useAIStudioHost } from '../../ai-studio-core/host-context.js';
|
|
5
|
+
|
|
6
|
+
export const studioVisionLocateParameters = defineStudioParameters<{ geometry: 'box' | 'point' }>({
|
|
7
|
+
initial: () => ({ geometry: 'box' }), routeMatrix: { geometry: LOCAL_ONLY_STUDIO_PARAMETER },
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export function StudioVisionParameterPanel(props: StudioParameterPanelProps) {
|
|
11
|
+
const { translate: t } = useAIStudioHost();
|
|
12
|
+
return <div className="studio-parameters">
|
|
13
|
+
<StudioParameterField label={t('VisionLocate.geometry')}>
|
|
14
|
+
<SelectField value={props.parameters.geometry === 'point' ? 'point' : 'box'} disabled={props.disabled || props.source === 'cloud'} onChange={event => props.onChange({ geometry: event.currentTarget.value })} options={[{value:'box',label:t('VisionLocate.box')},{value:'point',label:t('VisionLocate.point')}]} />
|
|
15
|
+
</StudioParameterField>
|
|
16
|
+
<p>{t('VisionLocate.localOnly')}</p>
|
|
17
|
+
</div>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { runNimiRuntimeScenarioJob } from '@nimiplatform/sdk/runtime';
|
|
2
|
+
import { ExecutionMode, ScenarioType, VisionLocateGeometry, type VisionLocateResult } from '@nimiplatform/sdk/runtime/generated';
|
|
3
|
+
import type { NimiLocalAppArtifactImageMime, NimiLocalAppVisionLocateResult } from '@nimiplatform/sdk/app';
|
|
4
|
+
import { createStudioScenarioJobClient, type StudioCapabilityRuntimeContext } from '../../ai-studio-core/runtime.js';
|
|
5
|
+
|
|
6
|
+
function localVisionResult(result: VisionLocateResult): NimiLocalAppVisionLocateResult {
|
|
7
|
+
return { imageArtifactId: result.imageArtifactId, width: result.width, height: result.height,
|
|
8
|
+
locations: result.locations.map(location => {
|
|
9
|
+
const label = location.label === undefined ? {} : { label: location.label };
|
|
10
|
+
const geometry = location.geometry;
|
|
11
|
+
if (geometry.oneofKind === 'box' && 'box' in geometry) return { type: 'box', ...geometry.box, ...label };
|
|
12
|
+
if (geometry.oneofKind === 'point' && 'point' in geometry) return { type: 'point', ...geometry.point, ...label };
|
|
13
|
+
throw new Error('Locate result geometry is missing');
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// @nimi-authority: rule.nimi.sdks.feature-clients.r102
|
|
19
|
+
export async function runVisionLocate(context: StudioCapabilityRuntimeContext) {
|
|
20
|
+
const t = context.host.translate;
|
|
21
|
+
const abortedBeforeSubmit = () => context.host.nonSuccess(context.capability, 'operation-aborted', t('VisionLocate.stoppedBeforeSubmit'));
|
|
22
|
+
const images = context.input.attachments ?? [];
|
|
23
|
+
const image = images[0];
|
|
24
|
+
if (!context.prompt || images.length !== 1 || !image || image.kind !== 'image' || !['image/png','image/jpeg','image/webp','image/gif'].includes(image.mimeType)) {
|
|
25
|
+
return context.host.nonSuccess(context.capability, 'input-invalid', t('VisionLocate.inputRequired'));
|
|
26
|
+
}
|
|
27
|
+
const prefix = `data:${image.mimeType};base64,`;
|
|
28
|
+
if (!image.dataUrl.startsWith(prefix) || image.dataUrl.length > 4 * Math.ceil(32 * 1024 * 1024 / 3) + prefix.length) {
|
|
29
|
+
return context.host.nonSuccess(context.capability, 'input-invalid', t('VisionLocate.imageTooLarge'));
|
|
30
|
+
}
|
|
31
|
+
if (context.input.signal?.aborted) return abortedBeforeSubmit();
|
|
32
|
+
const bytes = Uint8Array.from(atob(image.dataUrl.slice(prefix.length)), char => char.charCodeAt(0));
|
|
33
|
+
let upload;
|
|
34
|
+
try {
|
|
35
|
+
upload = await context.host.client.ai.artifacts.upload({ bytes, mimeType: image.mimeType as NimiLocalAppArtifactImageMime });
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (context.input.signal?.aborted) return abortedBeforeSubmit();
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
if (context.input.signal?.aborted) return abortedBeforeSubmit();
|
|
41
|
+
const result = await runNimiRuntimeScenarioJob({
|
|
42
|
+
ai: createStudioScenarioJobClient(context),
|
|
43
|
+
request: {
|
|
44
|
+
head: { appId: context.host.appId, subjectUserId: '', timeoutMs: 0 }, scenarioType: ScenarioType.VISION_LOCATE, executionMode: ExecutionMode.ASYNC_JOB,
|
|
45
|
+
spec: { spec: { oneofKind: 'visionLocate', visionLocate: { imageArtifactId: upload.artifactId, query: context.prompt, geometry: context.input.parameters?.geometry === 'point' ? VisionLocateGeometry.POINT : VisionLocateGeometry.BOX } } },
|
|
46
|
+
requestId: '', idempotencyKey: '', labels: {}, extensions: [],
|
|
47
|
+
},
|
|
48
|
+
signal: context.input.signal, abortReason: context.host.abortReason, onJobUpdate: context.input.onJobUpdate,
|
|
49
|
+
});
|
|
50
|
+
if (!result.visionLocate) throw new Error(t('VisionLocate.resultMissing'));
|
|
51
|
+
const locate = localVisionResult(result.visionLocate);
|
|
52
|
+
return {
|
|
53
|
+
ok: true as const, capabilityId: context.capability.id, capabilityLabel: context.capability.label,
|
|
54
|
+
message: t(locate.locations.length ? 'VisionLocate.found' : 'VisionLocate.noMatch', { count: locate.locations.length }),
|
|
55
|
+
output: { kind: 'vision-locate' as const, jobId: result.job.jobId, result: locate, imagePreviewUrl: image.dataUrl },
|
|
56
|
+
trace: { traceId: result.traceId },
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
.workbench__body {
|
|
45
45
|
display: grid;
|
|
46
46
|
grid-template-columns: 72px minmax(0, 1fr);
|
|
47
|
+
grid-template-rows: minmax(0, 1fr);
|
|
47
48
|
height: 100%;
|
|
48
49
|
min-height: 0;
|
|
49
50
|
}
|
|
@@ -71,6 +72,10 @@
|
|
|
71
72
|
justify-items: center;
|
|
72
73
|
width: 72px;
|
|
73
74
|
min-width: 72px;
|
|
75
|
+
min-height: 0;
|
|
76
|
+
overflow-y: auto;
|
|
77
|
+
overflow-x: hidden;
|
|
78
|
+
scrollbar-width: thin;
|
|
74
79
|
padding: 24px 14px 18px;
|
|
75
80
|
}
|
|
76
81
|
|
|
@@ -153,6 +153,14 @@
|
|
|
153
153
|
"path": "src/ai-studio-core/section-ai-testing-surface.tsx",
|
|
154
154
|
"class": "app-owned product code"
|
|
155
155
|
},
|
|
156
|
+
{
|
|
157
|
+
"path": "src/ai-studio-core/section-ai-testing-vision-input.tsx",
|
|
158
|
+
"class": "app-owned product code"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"path": "src/ai-studio-core/section-ai-testing-vision-result.tsx",
|
|
162
|
+
"class": "app-owned product code"
|
|
163
|
+
},
|
|
156
164
|
{
|
|
157
165
|
"path": "src/ai-studio-core/section-ai-testing.tsx",
|
|
158
166
|
"class": "app-owned product code"
|
|
@@ -273,6 +281,14 @@
|
|
|
273
281
|
"path": "src/studio-modules/studio-media/runtime.ts",
|
|
274
282
|
"class": "app-owned product code"
|
|
275
283
|
},
|
|
284
|
+
{
|
|
285
|
+
"path": "src/studio-modules/studio-media/vision-parameters.tsx",
|
|
286
|
+
"class": "app-owned product code"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"path": "src/studio-modules/studio-media/vision-runtime.ts",
|
|
290
|
+
"class": "app-owned product code"
|
|
291
|
+
},
|
|
276
292
|
{
|
|
277
293
|
"path": "src/studio-modules/studio-voice/descriptors.ts",
|
|
278
294
|
"class": "app-owned product code"
|
|
@@ -24,7 +24,7 @@ pnpm run app:build -- --target windows-x86_64
|
|
|
24
24
|
pnpm dev
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
After a real target build, `pnpm run pack -- --target <target-id>` uses app-tools as the only package owner.
|
|
27
|
+
After a real target build, `pnpm run pack -- --target <target-id>` uses app-tools as the only package owner. App Tools has no local `publish` command. A protected version tag runs the managed GitHub Release workflow; submit the resulting immutable Release through the separate Registry pull-request and human-review flow.
|
|
28
28
|
|
|
29
29
|
Before production, the public GitHub repository must enable a protected `v*` tag ruleset and immutable releases and provide a read-only repository-admin token for checking those settings. On Windows, the tag-only production build runs the App-declared build owner without a Nimi signing step. A publisher may sign the exact declared Host through its own build or signing custody; production pack records either verified Authenticode or explicit unsigned posture and rejects invalid or unresolved signatures. Manual workflow dispatch runs only the non-production path. The resulting GitHub Release remains independent from registry admission, Runtime installation, Desktop launch, and Nimi Access.
|
|
30
30
|
|
|
@@ -36,6 +36,30 @@ The default `windows-x86_64` build creates a fresh non-installer Electron direct
|
|
|
36
36
|
|
|
37
37
|
Runtime, Realm, registry admission, installed state and process truth remain with their canonical owners. This repository stores no Runtime credentials or protected session material.
|
|
38
38
|
|
|
39
|
+
## Publish with GitHub
|
|
40
|
+
|
|
41
|
+
Before pushing a release tag, complete these one-time repository steps:
|
|
42
|
+
|
|
43
|
+
1. **Settings → General → Releases:** enable Release immutability.
|
|
44
|
+
2. **Settings → Rules → Rulesets:** create an active tag ruleset for `v*`
|
|
45
|
+
that restricts updates and deletions.
|
|
46
|
+
3. [Create a fine-grained token](https://github.com/settings/personal-access-tokens/new)
|
|
47
|
+
for this repository's owner and only this repository, with **Administration:
|
|
48
|
+
Read-only**. Complete organization approval if required.
|
|
49
|
+
4. **Settings → Secrets and variables → Actions → New repository secret:**
|
|
50
|
+
save the token value under the exact name `NIMI_REPOSITORY_ADMIN_TOKEN`.
|
|
51
|
+
|
|
52
|
+
See the [step-by-step publishing guide](https://github.com/nimiplatform/nimi/blob/main/app-tools/README.md#publishing-on-github)
|
|
53
|
+
for repository setup, permission details, version tagging, and
|
|
54
|
+
recovery from setup errors. Local checks do not verify GitHub secrets.
|
|
55
|
+
|
|
56
|
+
Run `pnpm exec nimi-app check --production`, then the real production build
|
|
57
|
+
and pack. Commit the release on the repository's default branch and push an
|
|
58
|
+
annotated `v<package.json version>` tag. Watch **Actions → nimi-app-release**.
|
|
59
|
+
If a repository setting or secret is missing, fix it and **Re-run failed jobs**;
|
|
60
|
+
keep the existing tag. Registry admission is a separate human review after
|
|
61
|
+
the immutable Release exists.
|
|
62
|
+
|
|
39
63
|
## Support
|
|
40
64
|
|
|
41
65
|
Report startup or Runtime issues through this repository's issue tracker. Diagnostics must exclude credentials and other private data.
|