@nimiplatform/app-tools 0.7.5 → 0.12.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 +59 -5
- package/bin/nimi-app.mjs +11 -3
- package/lib/app-access-declaration.mjs +1 -0
- package/lib/app-dependency-combinations.mjs +16 -28
- package/lib/app-doctor-update.mjs +66 -7
- package/lib/app-info.mjs +8 -1
- package/lib/app-project-lifecycle.mjs +82 -9
- package/lib/app-scaffold-capabilities.mjs +3 -3
- package/lib/app-scaffold-profiles.mjs +96 -26
- package/lib/app-scaffold.mjs +54 -7
- package/lib/canonical-capability-ids.generated.mjs +4 -0
- package/package.json +26 -25
- package/scripts/dev-shell.mjs +61 -17
- package/skills/nimi-app-lifecycle/references/acceptance.md +1 -1
- package/skills/nimi-app-lifecycle/references/adapt.md +2 -2
- package/skills/nimi-app-lifecycle/references/release.md +1 -1
- package/skills/nimi-app-lifecycle/references/upgrade-platform.md +14 -0
- package/templates/app-source/src/ai-studio-core/ai-config.ts +17 -3
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +40 -3
- package/templates/app-source/src/ai-studio-core/audio-separation-request.ts +24 -0
- package/templates/app-source/src/ai-studio-core/contexts.tsx +4 -0
- package/templates/app-source/src/ai-studio-core/history-policy.ts +395 -41
- package/templates/app-source/src/ai-studio-core/history.ts +262 -10
- package/templates/app-source/src/ai-studio-core/host-context.tsx +15 -2
- package/templates/app-source/src/ai-studio-core/index.ts +15 -4
- package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +105 -0
- package/templates/app-source/src/ai-studio-core/job-recovery.ts +224 -0
- package/templates/app-source/src/ai-studio-core/managed-result-references.ts +79 -0
- package/templates/app-source/src/ai-studio-core/messages/en.json +185 -10
- package/templates/app-source/src/ai-studio-core/messages/zh.json +185 -10
- package/templates/app-source/src/ai-studio-core/module-registration.ts +9 -1
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +81 -2
- package/templates/app-source/src/ai-studio-core/parameters.ts +34 -1
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +124 -8
- package/templates/app-source/src/ai-studio-core/runtime.ts +218 -20
- package/templates/app-source/src/ai-studio-core/section-ai-testing-annotation-result.tsx +123 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-artifact-preview.ts +3 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-audio-separation-result.tsx +26 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +14 -7
- package/templates/app-source/src/ai-studio-core/section-ai-testing-decision-result.tsx +76 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +71 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +20 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +29 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-music-result.tsx +45 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +132 -10
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +122 -38
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +4 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +66 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +100 -22
- package/templates/app-source/src/ai-studio-core/section-ai-testing-surface.tsx +6 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcript-result.tsx +45 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +106 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +23 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-asset-actions.tsx +40 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-conversion-result.tsx +20 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +219 -35
- package/templates/app-source/src/ai-studio-core/text-annotation-document.ts +50 -0
- package/templates/app-source/src/ai-studio-core/text-media-replay.ts +51 -0
- package/templates/app-source/src/ai-studio-core/voice-assets.ts +17 -0
- package/templates/app-source/src/ai-studio-core/workspace.tsx +48 -6
- package/templates/app-source/src/studio-modules/studio-create/descriptors.ts +1 -1
- package/templates/app-source/src/studio-modules/studio-create/messages/en.json +13 -1
- package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +13 -1
- package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
- package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -2
- package/templates/app-source/src/studio-modules/studio-create/registration.ts +2 -2
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +121 -3
- package/templates/app-source/src/studio-modules/studio-media/audio-separate-parameters.tsx +72 -0
- package/templates/app-source/src/studio-modules/studio-media/audio-separate-runtime.ts +90 -0
- package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +16 -1
- package/templates/app-source/src/studio-modules/studio-media/index.ts +2 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +225 -7
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +225 -7
- package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +85 -0
- package/templates/app-source/src/studio-modules/studio-media/music-transcription-parameters.tsx +85 -0
- package/templates/app-source/src/studio-modules/studio-media/music-transcription-runtime.ts +64 -0
- package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +9 -26
- package/templates/app-source/src/studio-modules/studio-media/parameters.ts +170 -6
- package/templates/app-source/src/studio-modules/studio-media/registration.ts +29 -1
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +90 -6
- package/templates/app-source/src/studio-modules/studio-media/vision-parameters.tsx +1 -0
- package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +23 -5
- package/templates/app-source/src/studio-modules/studio-media/voice-convert-parameters.tsx +132 -0
- package/templates/app-source/src/studio-modules/studio-media/voice-convert-runtime.ts +120 -0
- package/templates/app-source/src/studio-modules/studio-voice/audio-url.ts +25 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +4 -4
- package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +4 -4
- package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +28 -0
- package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +66 -30
- package/templates/app-source/src/workbench-core/index.ts +2 -0
- package/templates/app-source/src/workbench-core/runtime-gate.tsx +102 -6
- package/templates/app-source/src/workbench-core/workbench-core.css +42 -0
- package/templates/app-source/src/workbench-core/workbench-core.tsx +69 -18
- package/templates/app-source.manifest.json +100 -0
- package/templates/default-starter/README.md +2 -1
- package/templates/default-starter/src/shell/workbench-target-adapter.ts +102 -12
- package/templates/default-starter.manifest.json +0 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NIMI_CHATGPT_PLAN_USAGE_URL } from '@nimiplatform/sdk/runtime';
|
|
1
2
|
import type {
|
|
2
3
|
StudioNonSuccess,
|
|
3
4
|
StudioNonSuccessDiagnostics,
|
|
@@ -25,19 +26,97 @@ function reasonKeySegment(reason: string): string {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
// A direct call or text-turn stream has no Job whose final state could still
|
|
30
|
+
// arrive: Stop ends the wait and a later result is discarded, unlike a
|
|
31
|
+
// submitted Job whose cancellation may be pending. Whether the provider also
|
|
32
|
+
// stopped computing is not known here, so the copy never claims it.
|
|
33
|
+
const DIRECT_CALL_CAPABILITIES: ReadonlySet<string> = new Set(['text.decide', 'text.generate', 'text.tools', 'chat.stream']);
|
|
34
|
+
|
|
35
|
+
export function isStoppedDirectCall(reason: string, capabilityId?: string): boolean {
|
|
36
|
+
return reason === 'operation-aborted' && capabilityId !== undefined && DIRECT_CALL_CAPABILITIES.has(capabilityId);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function studioNonSuccessReasonTitle(reason: StudioNonSuccessReason, translate: StudioTranslate, capabilityId?: string): string {
|
|
40
|
+
if (isStoppedDirectCall(reason, capabilityId)) return translate('NonSuccess.title.stoppedDirectCall');
|
|
29
41
|
return translate(`NonSuccess.title.${reasonKeySegment(reason)}`);
|
|
30
42
|
}
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
// A valid input that the configured implementation cannot encode completely
|
|
45
|
+
// is neither a malformed request nor a retryable failure.
|
|
46
|
+
const INPUT_LIMIT_EXCEEDED_REASON_CODE = 'AI_INPUT_LIMIT_EXCEEDED';
|
|
47
|
+
const TEXT_BEHAVIOR_UNSUPPORTED_REASON_CODE = 'AI_TEXT_BEHAVIOR_UNSUPPORTED';
|
|
48
|
+
const MEDIA_OPTION_UNSUPPORTED_REASON_CODE = 'AI_MEDIA_OPTION_UNSUPPORTED';
|
|
49
|
+
const MODALITY_UNSUPPORTED_REASON_CODE = 'AI_MODALITY_NOT_SUPPORTED';
|
|
50
|
+
const MEDIA_CODEC_UNAVAILABLE_REASON_CODE = 'AI_MEDIA_CODEC_UNAVAILABLE';
|
|
51
|
+
const LOCAL_LOAD_FAILED_REASON_CODE = 'AI_LOCAL_EXECUTION_LOAD_FAILED';
|
|
52
|
+
const VOICE_INPUT_INVALID_REASON_CODE = 'AI_VOICE_INPUT_INVALID';
|
|
53
|
+
const VOICE_TARGET_MISMATCH_REASON_CODE = 'AI_VOICE_TARGET_MODEL_MISMATCH';
|
|
54
|
+
const UNAVAILABLE_VOICE_REASON_CODES: ReadonlySet<string> = new Set(['AI_VOICE_ASSET_NOT_FOUND', 'AI_VOICE_ASSET_EXPIRED']);
|
|
55
|
+
// The cloud service refused the request under its rate or usage limit, which
|
|
56
|
+
// for a ChatGPT plan Connector is the plan's usage limit for this app.
|
|
57
|
+
const PROVIDER_RATE_LIMITED_REASON_CODE = 'AI_PROVIDER_RATE_LIMITED';
|
|
58
|
+
|
|
59
|
+
// A committed target that Runtime can no longer run is recovered by choosing a
|
|
60
|
+
// target again (or repairing its Connector in Desktop), never by retrying the
|
|
61
|
+
// same request.
|
|
62
|
+
const TARGET_RESELECTION_KEY_SEGMENTS: ReadonlyMap<string, string> = new Map([
|
|
63
|
+
['AI_REMOTE_MODEL_CATALOG_STALE', 'catalogStale'],
|
|
64
|
+
['CAPABILITY_CATALOG_MISMATCH', 'catalogMismatch'],
|
|
65
|
+
['AI_CONNECTOR_DISABLED', 'connectorDisabled'],
|
|
66
|
+
['AI_CONNECTOR_CREDENTIAL_MISSING', 'connectorCredentialMissing'],
|
|
67
|
+
['AI_CONNECTOR_NOT_FOUND', 'connectorNotFound'],
|
|
68
|
+
['AI_CONFIG_INVALID', 'configInvalid'],
|
|
69
|
+
['AI_MODEL_NOT_FOUND', 'modelNotFound'],
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
function targetReselectionKeySegment(diagnostics?: StudioNonSuccessDiagnostics): string {
|
|
73
|
+
return diagnostics ? TARGET_RESELECTION_KEY_SEGMENTS.get(diagnostics.reasonCode) ?? '' : '';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function studioNonSuccessNeedsTargetReselection(diagnostics?: StudioNonSuccessDiagnostics): boolean {
|
|
77
|
+
return targetReselectionKeySegment(diagnostics) !== '';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function studioNonSuccessReasonUserMessage(reason: string, translate: StudioTranslate, capabilityId?: string, diagnostics?: StudioNonSuccessDiagnostics, appInputMessage?: string): string {
|
|
81
|
+
if (capabilityId === 'audio.synthesize' && diagnostics && UNAVAILABLE_VOICE_REASON_CODES.has(diagnostics.reasonCode)) return translate('NonSuccess.message.voiceUnavailable');
|
|
82
|
+
if (reason === 'input-invalid' && capabilityId === 'video.generate' && !diagnostics && appInputMessage) return appInputMessage;
|
|
83
|
+
if (reason === 'input-invalid' && capabilityId === 'audio.transcribe') return translate('NonSuccess.message.transcriptionInputInvalid');
|
|
84
|
+
if (capabilityId === 'audio.synthesize' && diagnostics?.reasonCode === VOICE_INPUT_INVALID_REASON_CODE) return translate('NonSuccess.message.voiceInputRequired');
|
|
85
|
+
if (capabilityId === 'audio.synthesize' && diagnostics?.reasonCode === VOICE_TARGET_MISMATCH_REASON_CODE) return translate('NonSuccess.message.voiceTargetMismatch');
|
|
33
86
|
if (capabilityId === 'vision.locate' && diagnostics?.reasonCode === 'AI_LOCAL_SELECTION_NOT_FOUND') return translate('VisionLocate.modelSelectionRequired');
|
|
87
|
+
if (isStoppedDirectCall(reason, capabilityId)) return translate('NonSuccess.message.stoppedDirectCall');
|
|
88
|
+
if (diagnostics?.reasonCode === INPUT_LIMIT_EXCEEDED_REASON_CODE) return translate('NonSuccess.message.inputLimitExceeded');
|
|
89
|
+
if (diagnostics?.reasonCode === TEXT_BEHAVIOR_UNSUPPORTED_REASON_CODE) return translate('NonSuccess.message.textBehaviorUnsupported');
|
|
90
|
+
if (diagnostics?.reasonCode === MEDIA_CODEC_UNAVAILABLE_REASON_CODE) return translate('NonSuccess.message.mediaCodecUnavailable');
|
|
91
|
+
if (diagnostics?.reasonCode === LOCAL_LOAD_FAILED_REASON_CODE) return translate('NonSuccess.message.localLoadFailed');
|
|
92
|
+
if (capabilityId === 'vision.locate' && diagnostics?.reasonCode === MEDIA_OPTION_UNSUPPORTED_REASON_CODE) return translate('VisionLocate.geometryUnsupported');
|
|
93
|
+
if (diagnostics?.reasonCode === MEDIA_OPTION_UNSUPPORTED_REASON_CODE) return translate('NonSuccess.message.mediaOptionUnsupported');
|
|
94
|
+
if (diagnostics?.reasonCode === MODALITY_UNSUPPORTED_REASON_CODE) return translate('NonSuccess.message.modalityUnsupported');
|
|
95
|
+
if (diagnostics?.reasonCode === PROVIDER_RATE_LIMITED_REASON_CODE) return translate('NonSuccess.message.providerRateLimited');
|
|
96
|
+
const reselection = targetReselectionKeySegment(diagnostics);
|
|
97
|
+
if (reselection) return translate(`NonSuccess.message.${reselection}`);
|
|
34
98
|
if (reason === 'input-invalid' && capabilityId === 'vision.locate') return translate('VisionLocate.invalidInput');
|
|
35
99
|
const segment = reasonKeySegment(reason);
|
|
36
100
|
return translate(segment ? `NonSuccess.message.${segment}` : 'NonSuccess.message.fallback');
|
|
37
101
|
}
|
|
38
102
|
|
|
39
103
|
export function studioNonSuccessReasonUserAction(reason: string, translate: StudioTranslate, capabilityId?: string, diagnostics?: StudioNonSuccessDiagnostics): string {
|
|
104
|
+
if (capabilityId === 'audio.synthesize' && diagnostics && UNAVAILABLE_VOICE_REASON_CODES.has(diagnostics.reasonCode)) return translate('NonSuccess.action.voiceUnavailable');
|
|
105
|
+
if (reason === 'input-invalid' && capabilityId === 'audio.transcribe') return translate('NonSuccess.action.transcriptionInputInvalid');
|
|
106
|
+
if (capabilityId === 'audio.synthesize' && diagnostics?.reasonCode === VOICE_INPUT_INVALID_REASON_CODE) return translate('NonSuccess.action.voiceInputRequired');
|
|
107
|
+
if (capabilityId === 'audio.synthesize' && diagnostics?.reasonCode === VOICE_TARGET_MISMATCH_REASON_CODE) return translate('NonSuccess.action.voiceTargetMismatch');
|
|
40
108
|
if (capabilityId === 'vision.locate' && diagnostics?.reasonCode === 'AI_LOCAL_SELECTION_NOT_FOUND') return translate('VisionLocate.selectModelAction');
|
|
109
|
+
if (isStoppedDirectCall(reason, capabilityId)) return translate('NonSuccess.action.stoppedDirectCall');
|
|
110
|
+
if (diagnostics?.reasonCode === INPUT_LIMIT_EXCEEDED_REASON_CODE) return translate('NonSuccess.action.inputLimitExceeded');
|
|
111
|
+
if (diagnostics?.reasonCode === TEXT_BEHAVIOR_UNSUPPORTED_REASON_CODE) return translate('NonSuccess.action.textBehaviorUnsupported');
|
|
112
|
+
if (diagnostics?.reasonCode === MEDIA_CODEC_UNAVAILABLE_REASON_CODE) return translate('NonSuccess.action.mediaCodecUnavailable');
|
|
113
|
+
if (diagnostics?.reasonCode === LOCAL_LOAD_FAILED_REASON_CODE) return translate('NonSuccess.action.localLoadFailed');
|
|
114
|
+
if (capabilityId === 'vision.locate' && diagnostics?.reasonCode === MEDIA_OPTION_UNSUPPORTED_REASON_CODE) return translate('VisionLocate.chooseSupportedGeometry');
|
|
115
|
+
if (diagnostics?.reasonCode === MEDIA_OPTION_UNSUPPORTED_REASON_CODE) return translate('NonSuccess.action.mediaOptionUnsupported');
|
|
116
|
+
if (diagnostics?.reasonCode === MODALITY_UNSUPPORTED_REASON_CODE) return translate('NonSuccess.action.modalityUnsupported');
|
|
117
|
+
if (diagnostics?.reasonCode === PROVIDER_RATE_LIMITED_REASON_CODE) return translate('NonSuccess.action.providerRateLimited', { usageUrl: NIMI_CHATGPT_PLAN_USAGE_URL });
|
|
118
|
+
const reselection = targetReselectionKeySegment(diagnostics);
|
|
119
|
+
if (reselection) return translate(`NonSuccess.action.${reselection}`);
|
|
41
120
|
if (reason === 'input-invalid' && capabilityId === 'vision.locate') return translate('VisionLocate.correctInput');
|
|
42
121
|
const segment = reasonKeySegment(reason);
|
|
43
122
|
return translate(segment ? `NonSuccess.action.${segment}` : 'NonSuccess.action.fallback');
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { StudioRunHistoryResultSnapshot } from './history.js';
|
|
2
|
+
|
|
1
3
|
export type StudioRunTargetSource = 'local' | 'cloud' | 'unknown';
|
|
2
4
|
|
|
3
5
|
export type StudioParameterRouteState =
|
|
@@ -19,12 +21,27 @@ export type StudioParameterRouteMatrix = Readonly<Record<
|
|
|
19
21
|
Readonly<Record<'local' | 'cloud', StudioParameterRouteState>>
|
|
20
22
|
>>;
|
|
21
23
|
|
|
24
|
+
// For a capability whose whole request input lives in its parameters: the
|
|
25
|
+
// exact text recorded as a run's input (history bounds and marks it like any
|
|
26
|
+
// prompt), and the parameter fields rebuilt from such a record, or null when
|
|
27
|
+
// the record cannot be restored. Fields the record does not carry keep their
|
|
28
|
+
// current value.
|
|
29
|
+
export type StudioRecordedParameterInput = {
|
|
30
|
+
readonly encode: (parameters: StudioParameterValue) => string;
|
|
31
|
+
readonly decode: (recorded: string) => StudioParameterValue | null;
|
|
32
|
+
};
|
|
33
|
+
|
|
22
34
|
export type StudioParameterContract = {
|
|
23
35
|
readonly initial: () => StudioParameterValue;
|
|
24
36
|
readonly summarize: (parameters: StudioParameterValue) => Readonly<Record<string, unknown>>;
|
|
25
37
|
readonly hasAlternativeInput: (parameters: StudioParameterValue) => boolean;
|
|
26
38
|
readonly presentation: (source: StudioRunTargetSource) => readonly StudioParameterPresentation[];
|
|
27
39
|
readonly project: (source: StudioRunTargetSource, parameters: StudioParameterValue) => StudioParameterValue;
|
|
40
|
+
readonly recordedInput?: StudioRecordedParameterInput;
|
|
41
|
+
// Undefined means the saved request context is missing; {} means it was
|
|
42
|
+
// explicitly saved empty. Rebuild only a complete request from saved facts,
|
|
43
|
+
// without borrowing omitted controls or input from the live draft.
|
|
44
|
+
readonly restoreRecordedParameters?: (snapshot: Readonly<Record<string, unknown>> | undefined, result?: StudioRunHistoryResultSnapshot, recordedPrompt?: string) => StudioParameterValue | null;
|
|
28
45
|
};
|
|
29
46
|
|
|
30
47
|
export type TypedStudioParameterContract<TParameters extends object> = {
|
|
@@ -32,6 +49,11 @@ export type TypedStudioParameterContract<TParameters extends object> = {
|
|
|
32
49
|
readonly summarize?: (parameters: TParameters) => Readonly<Record<string, unknown>>;
|
|
33
50
|
readonly hasAlternativeInput?: (parameters: TParameters) => boolean;
|
|
34
51
|
readonly routeMatrix: StudioParameterRouteMatrix;
|
|
52
|
+
readonly recordedInput?: {
|
|
53
|
+
readonly encode: (parameters: TParameters) => string;
|
|
54
|
+
readonly decode: (recorded: string) => Partial<TParameters> | null;
|
|
55
|
+
};
|
|
56
|
+
readonly restoreRecordedParameters?: (snapshot: Readonly<Record<string, unknown>> | undefined, result?: StudioRunHistoryResultSnapshot, recordedPrompt?: string) => TParameters | null;
|
|
35
57
|
};
|
|
36
58
|
|
|
37
59
|
export const SUPPORTED_STUDIO_PARAMETER = Object.freeze({ kind: 'supported' } as const);
|
|
@@ -65,7 +87,18 @@ export function defineStudioParameters<TParameters extends object>(
|
|
|
65
87
|
const project = (source: StudioRunTargetSource, parameters: StudioParameterValue) => (
|
|
66
88
|
projectStudioParameters(typed.routeMatrix, source, parameters)
|
|
67
89
|
);
|
|
68
|
-
|
|
90
|
+
const recorded = typed.recordedInput;
|
|
91
|
+
const recordedInput: StudioRecordedParameterInput | undefined = recorded
|
|
92
|
+
? Object.freeze({
|
|
93
|
+
encode: (parameters: StudioParameterValue) => recorded.encode(parameters as TParameters),
|
|
94
|
+
decode: (value: string) => recorded.decode(value) as StudioParameterValue | null,
|
|
95
|
+
})
|
|
96
|
+
: undefined;
|
|
97
|
+
return Object.freeze({
|
|
98
|
+
initial, summarize, hasAlternativeInput, presentation, project,
|
|
99
|
+
...(recordedInput ? { recordedInput } : {}),
|
|
100
|
+
...(typed.restoreRecordedParameters ? { restoreRecordedParameters: (snapshot: Readonly<Record<string, unknown>> | undefined, result?: StudioRunHistoryResultSnapshot, recordedPrompt?: string) => typed.restoreRecordedParameters!(snapshot, result, recordedPrompt) as StudioParameterValue | null } : {}),
|
|
101
|
+
});
|
|
69
102
|
}
|
|
70
103
|
|
|
71
104
|
export const EMPTY_STUDIO_PARAMETERS = defineStudioParameters({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { BrowserDataUrlAttachment } from '@nimiplatform/kit/features/chat/headless';
|
|
2
2
|
import type { StudioParameterValue } from './parameters.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { StudioRunConfigSnapshot, StudioRunHistoryRecord } from './history.js';
|
|
4
|
+
import type { NimiLocalAppAudioInstrumentPartKind, NimiLocalAppVisionLocateResult, NimiLocalAppMusicGeneration, NimiLocalAppMusicTranscription, NimiLocalAppSpeechTranscript, NimiLocalAppTextAnnotationResult, NimiLocalAppVideoFaceSwapSummary, NimiLocalAppVoiceConversion } from '@nimiplatform/sdk/app';
|
|
5
|
+
import type { NimiRuntimeScenarioJob, NimiRuntimeScenarioArtifact } from '@nimiplatform/sdk/runtime';
|
|
5
6
|
|
|
6
7
|
export type StudioRuntimeCapabilityDescriptor = {
|
|
7
8
|
readonly id: string;
|
|
@@ -20,18 +21,124 @@ export type StudioManagedArtifact = {
|
|
|
20
21
|
readonly sha256: string;
|
|
21
22
|
readonly displayName?: string;
|
|
22
23
|
readonly previewSource: 'managed-asset';
|
|
24
|
+
readonly speechAlignment?: NimiRuntimeScenarioArtifact['speechAlignment'];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type StudioMusicGeneration = Pick<NimiLocalAppMusicGeneration, 'termination' | 'actualSeed' | 'audioInfo'> & {
|
|
28
|
+
readonly mixRelativePath: string;
|
|
29
|
+
readonly generatedScore?: {
|
|
30
|
+
readonly relativePath: string;
|
|
31
|
+
readonly format: 'abc' | 'midi';
|
|
32
|
+
readonly origin: 'generated-plan' | 'transcribed-estimate';
|
|
33
|
+
readonly truncated: boolean;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type StudioMusicTranscription = Pick<NimiLocalAppMusicTranscription, 'sourceInfo' | 'inputRange' | 'completeness' | 'origin'> & {
|
|
38
|
+
readonly sourceAudio: StudioManagedArtifact;
|
|
39
|
+
readonly scores: readonly { readonly relativePath: string; readonly format: 'abc' | 'midi'; readonly part: string }[];
|
|
40
|
+
readonly timelineRelativePath?: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type StudioVoiceConversion = Pick<NimiLocalAppVoiceConversion, 'sourceInfo' | 'inputRange' | 'vocalInfo' | 'lengthRelation' | 'durationDeltaMs'> & {
|
|
44
|
+
readonly sourceVocal: StudioManagedArtifact;
|
|
45
|
+
readonly targetVoice?: StudioManagedArtifact;
|
|
46
|
+
readonly vocal: StudioManagedArtifact;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type StudioAudioSeparationInstrumentPart = {
|
|
50
|
+
readonly kind: NimiLocalAppAudioInstrumentPartKind;
|
|
51
|
+
readonly artifact: StudioManagedArtifact;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type StudioAudioSeparationRequest =
|
|
55
|
+
| { readonly kind: 'full-source' }
|
|
56
|
+
| { readonly kind: 'range'; readonly startSeconds: number; readonly endSeconds?: number };
|
|
57
|
+
|
|
58
|
+
export type StudioAudioSeparation = {
|
|
59
|
+
readonly request?: StudioAudioSeparationRequest;
|
|
60
|
+
readonly sourceAudio: StudioManagedArtifact;
|
|
61
|
+
readonly vocals: StudioManagedArtifact;
|
|
62
|
+
readonly background: StudioManagedArtifact;
|
|
63
|
+
readonly instrumentParts?: readonly StudioAudioSeparationInstrumentPart[];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Input facts recorded per role. The bytes themselves are never retained, so a
|
|
67
|
+
// rerun requires choosing the media again.
|
|
68
|
+
export type StudioFaceSwapInputRole = 'reference-image' | 'target-image' | 'target-video';
|
|
69
|
+
|
|
70
|
+
export type StudioFaceSwapInput = {
|
|
71
|
+
readonly role: StudioFaceSwapInputRole;
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly mediaType: string;
|
|
74
|
+
readonly sizeBytes: number;
|
|
75
|
+
readonly sha256: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type StudioFaceSwap = {
|
|
79
|
+
readonly inputs: readonly StudioFaceSwapInput[];
|
|
80
|
+
readonly noFacePolicy?: 'fail' | 'preserve-frame';
|
|
81
|
+
readonly video?: NimiLocalAppVideoFaceSwapSummary;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type StudioJsonValue = null | boolean | number | string | readonly StudioJsonValue[] | { readonly [key: string]: StudioJsonValue };
|
|
85
|
+
|
|
86
|
+
// One ordered text model step, or the tool results the App returned for it.
|
|
87
|
+
export type StudioTextExchangeItem =
|
|
88
|
+
| { readonly type: 'reasoning-summary'; readonly text: string }
|
|
89
|
+
| { readonly type: 'text'; readonly text: string }
|
|
90
|
+
| { readonly type: 'reasoning-continuity'; readonly carrierKind: string; readonly version: number; readonly payloadBytes: number }
|
|
91
|
+
| { readonly type: 'tool-call'; readonly toolCallId: string; readonly toolName: string; readonly arguments: StudioJsonValue }
|
|
92
|
+
| { readonly type: 'tool-result'; readonly toolCallId: string; readonly toolName: string; readonly result: StudioJsonValue; readonly isError: boolean };
|
|
93
|
+
|
|
94
|
+
export type StudioTextExchangeStep = {
|
|
95
|
+
readonly origin: 'model' | 'app';
|
|
96
|
+
readonly finishReason?: string;
|
|
97
|
+
readonly traceId?: string;
|
|
98
|
+
readonly items: readonly StudioTextExchangeItem[];
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// One answer per submitted question, in submitted order. A choice keeps the
|
|
102
|
+
// selected candidate and the probability of every submitted candidate in
|
|
103
|
+
// submitted order; a yes/no question keeps only the probability that its true
|
|
104
|
+
// criterion holds.
|
|
105
|
+
export type StudioTextDecisionProbability = {
|
|
106
|
+
readonly candidateId: string;
|
|
107
|
+
readonly probability: number;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type StudioTextDecisionAnswer =
|
|
111
|
+
| { readonly questionId: string; readonly kind: 'choice'; readonly selectedCandidateId: string; readonly probabilities: readonly StudioTextDecisionProbability[] }
|
|
112
|
+
| { readonly questionId: string; readonly kind: 'boolean'; readonly trueProbability: number };
|
|
113
|
+
|
|
114
|
+
export type StudioSessionSummary = {
|
|
115
|
+
readonly capabilityContract: string;
|
|
116
|
+
readonly startedAt: string;
|
|
117
|
+
readonly endedAt: string;
|
|
118
|
+
readonly ending: 'closed' | 'terminated';
|
|
119
|
+
readonly terminalReason: string;
|
|
120
|
+
readonly observed: Readonly<Record<string, number>>;
|
|
23
121
|
};
|
|
24
122
|
|
|
25
123
|
export type StudioTypedOutput =
|
|
26
|
-
| { readonly kind: '
|
|
27
|
-
| { readonly kind: '
|
|
28
|
-
| { readonly kind: '
|
|
29
|
-
|
|
30
|
-
| { readonly kind: '
|
|
31
|
-
| { readonly kind: '
|
|
124
|
+
| { readonly kind: 'speaker-embedding'; readonly jobId: string; readonly spaceId: string; readonly vector: readonly number[] }
|
|
125
|
+
| { readonly kind: 'vision-locate'; readonly jobId: string; readonly result: NimiLocalAppVisionLocateResult; readonly sourceImage?: StudioManagedArtifact; readonly imagePreviewUrl?: string }
|
|
126
|
+
| { readonly kind: 'text'; readonly text: string; readonly finishReason: string; readonly inputTokens?: number; readonly outputTokens?: number; readonly totalTokens?: number; readonly streamed: boolean; readonly sourceImage?: StudioManagedArtifact }
|
|
127
|
+
// spaceId is absent only on records saved before the result retained it.
|
|
128
|
+
| { readonly kind: 'embedding'; readonly vectorCount: number; readonly dimensions: number; readonly spaceId?: string; readonly sample: number[]; readonly totalTokens?: number }
|
|
129
|
+
| { readonly kind: 'artifacts'; readonly sourceImage?: StudioManagedArtifact; readonly musicGeneration?: StudioMusicGeneration; readonly musicTranscription?: StudioMusicTranscription; readonly voiceConversion?: StudioVoiceConversion; readonly audioSeparation?: StudioAudioSeparation; readonly faceSwap?: StudioFaceSwap; readonly jobId: string; readonly jobState: string; readonly artifactCount: number; readonly artifacts: StudioManagedArtifact[]; readonly firstArtifact?: StudioManagedArtifact }
|
|
130
|
+
// The complete annotation lives in the saved document; it is attached only
|
|
131
|
+
// after the current run or a verified read of that document.
|
|
132
|
+
| { readonly kind: 'text-annotation'; readonly jobId: string; readonly jobState: string; readonly language: string; readonly documentCount: number; readonly tokenCount: number; readonly sentenceCount: number; readonly document: StudioManagedArtifact; readonly annotation?: NimiLocalAppTextAnnotationResult }
|
|
133
|
+
| { readonly kind: 'text-exchange'; readonly scenario: 'tool-call' | 'structured-output'; readonly steps: readonly StudioTextExchangeStep[]; readonly text: string; readonly structured?: StudioJsonValue }
|
|
134
|
+
| { readonly kind: 'text-decision'; readonly answers: readonly StudioTextDecisionAnswer[] }
|
|
135
|
+
| ({ readonly kind: 'session' } & StudioSessionSummary)
|
|
136
|
+
| { readonly kind: 'transcript'; readonly text: string; readonly jobId: string; readonly jobState: string; readonly artifactCount: number; readonly transcription?: NimiLocalAppSpeechTranscript }
|
|
137
|
+
| { readonly kind: 'voice-asset'; readonly preview?: StudioManagedArtifact; readonly expiresAt?: string; readonly inputTokens?: number; readonly outputTokens?: number; readonly jobId: string; readonly jobState: string; readonly voiceAssetId: string; readonly creationSource: 'reference-audio' | 'text-description'; readonly assetStatus: string; readonly voiceReference: { readonly kind: 'voice_asset_id'; readonly voiceAssetId: string } }
|
|
32
138
|
| { readonly kind: 'voice-catalog'; readonly voiceCount: number; readonly sample: Array<{ readonly voiceId: string; readonly creationSource: string; readonly status: string }> };
|
|
33
139
|
|
|
34
140
|
export type StudioTypedSuccess = {
|
|
141
|
+
readonly recordedHistory?: StudioRunHistoryRecord;
|
|
35
142
|
readonly ok: true;
|
|
36
143
|
readonly capabilityId: string;
|
|
37
144
|
readonly capabilityLabel: string;
|
|
@@ -60,6 +167,7 @@ export type StudioNonSuccessDiagnostics = {
|
|
|
60
167
|
};
|
|
61
168
|
|
|
62
169
|
export type StudioNonSuccess = {
|
|
170
|
+
readonly recordedHistory?: StudioRunHistoryRecord;
|
|
63
171
|
readonly ok: false;
|
|
64
172
|
readonly capabilityId: string;
|
|
65
173
|
readonly reason: StudioNonSuccessReason;
|
|
@@ -67,6 +175,8 @@ export type StudioNonSuccess = {
|
|
|
67
175
|
readonly actionHint: string;
|
|
68
176
|
readonly missingSurface?: string;
|
|
69
177
|
readonly diagnostics?: StudioNonSuccessDiagnostics;
|
|
178
|
+
// Present only when the owner had already issued the Job before it ended.
|
|
179
|
+
readonly jobId?: string;
|
|
70
180
|
};
|
|
71
181
|
|
|
72
182
|
export type StudioCapabilityRunResult = StudioTypedSuccess | StudioNonSuccess;
|
|
@@ -78,10 +188,16 @@ export type StudioRuntimeInspection = {
|
|
|
78
188
|
};
|
|
79
189
|
|
|
80
190
|
export type StudioCapabilityRunInput = {
|
|
191
|
+
readonly recordedRunConfig?: StudioRunConfigSnapshot;
|
|
192
|
+
readonly recordedCreatedAt?: string;
|
|
193
|
+
readonly recordedPrompt?: string;
|
|
81
194
|
readonly capabilityId: string;
|
|
82
195
|
readonly prompt: string;
|
|
83
196
|
readonly scenarioId?: string;
|
|
197
|
+
/** Explicit user cancellation; observationSignal only detaches the view. */
|
|
84
198
|
readonly signal?: AbortSignal;
|
|
199
|
+
readonly observationSignal?: AbortSignal;
|
|
200
|
+
readonly onObservation?: (response: import("@nimiplatform/sdk/runtime").NimiRuntimeScenarioJobObservation) => void;
|
|
85
201
|
readonly onPartial?: (accumulatedText: string) => void;
|
|
86
202
|
readonly onJobUpdate?: (job: NimiRuntimeScenarioJob) => void;
|
|
87
203
|
readonly attachments?: BrowserDataUrlAttachment[];
|