@nimiplatform/sdk 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/README.md +161 -433
- package/dist/core/ai/embeddings.d.ts +1 -0
- package/dist/core/ai/embeddings.d.ts.map +1 -1
- package/dist/core/ai/embeddings.js +3 -0
- package/dist/core/ai/embeddings.js.map +1 -1
- package/dist/core/app/desktop-open.d.ts +8 -5
- package/dist/core/app/desktop-open.d.ts.map +1 -1
- package/dist/core/app/desktop-open.js +20 -16
- package/dist/core/app/desktop-open.js.map +1 -1
- package/dist/core/app/index.d.ts +4 -2
- package/dist/core/app/index.d.ts.map +1 -1
- package/dist/core/app/index.js +1 -1
- package/dist/core/app/index.js.map +1 -1
- package/dist/core/app/local-app-agent-introduction.d.ts +3 -0
- package/dist/core/app/local-app-agent-introduction.d.ts.map +1 -1
- package/dist/core/app/local-app-agent-introduction.js +35 -5
- package/dist/core/app/local-app-agent-introduction.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-activity-view.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-activity-view.js +4 -2
- package/dist/core/app/local-app-runtime-platform-activity-view.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-activity.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-activity.js +5 -1
- package/dist/core/app/local-app-runtime-platform-activity.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-configure.d.ts +38 -4
- package/dist/core/app/local-app-runtime-platform-configure.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-configure.js +121 -19
- package/dist/core/app/local-app-runtime-platform-configure.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-conversation.d.ts +67 -6
- package/dist/core/app/local-app-runtime-platform-conversation.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-conversation.js +162 -20
- package/dist/core/app/local-app-runtime-platform-conversation.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-conversation.d.ts +4 -1
- package/dist/core/app/local-app-runtime-platform-direct-conversation.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-conversation.js +58 -5
- package/dist/core/app/local-app-runtime-platform-direct-conversation.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-realm-realtime.d.ts +2 -0
- package/dist/core/app/local-app-runtime-platform-direct-realm-realtime.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-realm-realtime.js +10 -2
- package/dist/core/app/local-app-runtime-platform-direct-realm-realtime.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-life.d.ts +33 -0
- package/dist/core/app/local-app-runtime-platform-life.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-life.js +59 -0
- package/dist/core/app/local-app-runtime-platform-life.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-proactive.d.ts +28 -0
- package/dist/core/app/local-app-runtime-platform-proactive.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-proactive.js +42 -0
- package/dist/core/app/local-app-runtime-platform-proactive.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-realm-realtime.d.ts +6 -2
- package/dist/core/app/local-app-runtime-platform-realm-realtime.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-realm-realtime.js +15 -4
- package/dist/core/app/local-app-runtime-platform-realm-realtime.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform.d.ts +3 -2
- package/dist/core/app/local-app-runtime-platform.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform.js +5 -2
- package/dist/core/app/local-app-runtime-platform.js.map +1 -1
- package/dist/core/app/runtime-account-realm-source-readiness.generated.d.ts +2 -2
- package/dist/core/app/runtime-account-realm-source-readiness.generated.d.ts.map +1 -1
- package/dist/core/app/runtime-account-realm-source-readiness.generated.js +12 -9
- package/dist/core/app/runtime-account-realm-source-readiness.generated.js.map +1 -1
- package/dist/core-generated/realm-client.d.ts.map +1 -1
- package/dist/core-generated/realm-client.js +33 -99
- package/dist/core-generated/realm-client.js.map +1 -1
- package/dist/core-generated/realm-typed-client.d.ts +257 -432
- package/dist/core-generated/realm-typed-client.d.ts.map +1 -1
- package/dist/core-generated/realm-typed-client.js +55 -202
- package/dist/core-generated/realm-typed-client.js.map +1 -1
- package/dist/core-generated/runtime-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-client.js +80 -16
- package/dist/core-generated/runtime-client.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/google/protobuf/field_mask.d.ts +16 -18
- package/dist/core-generated/runtime-protobuf/google/protobuf/field_mask.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/google/protobuf/field_mask.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/google/protobuf/struct.d.ts +33 -22
- package/dist/core-generated/runtime-protobuf/google/protobuf/struct.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/google/protobuf/struct.js +8 -3
- package/dist/core-generated/runtime-protobuf/google/protobuf/struct.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/google/protobuf/timestamp.d.ts +3 -3
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.d.ts +10 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.js +9 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_configure.d.ts +147 -4
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_configure.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_configure.js +327 -14
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_configure.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_life.d.ts +167 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_life.d.ts.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_life.js +312 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_life.js.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.d.ts +448 -147
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.js +1078 -466
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_source_materialization.d.ts +5 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_source_materialization.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_source_materialization.js +4 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_source_materialization.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/audit.d.ts +712 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/audit.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/audit.js +1461 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/audit.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.d.ts +92 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.js +204 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/cognition_memory.d.ts +67 -4
- package/dist/core-generated/runtime-protobuf/runtime/v1/cognition_memory.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/cognition_memory.js +101 -10
- package/dist/core-generated/runtime-protobuf/runtime/v1/cognition_memory.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.d.ts +5 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.js +4 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.d.ts +38 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.js +79 -2
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/realm_realtime.d.ts +181 -8
- package/dist/core-generated/runtime-protobuf/runtime/v1/realm_realtime.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/realm_realtime.js +402 -18
- package/dist/core-generated/runtime-protobuf/runtime/v1/realm_realtime.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.d.ts +41 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.js +93 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.js.map +1 -1
- package/dist/core-generated/runtime-public-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-client.js +72 -16
- package/dist/core-generated/runtime-public-client.js.map +1 -1
- package/dist/core-generated/runtime-public-rpc-auth-posture.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-rpc-auth-posture.js +9 -2
- package/dist/core-generated/runtime-public-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.d.ts +13 -6
- package/dist/core-generated/runtime-public-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.js +13 -6
- package/dist/core-generated/runtime-public-wire-codecs.js.map +1 -1
- package/dist/core-generated/runtime-rpc-auth-posture.d.ts.map +1 -1
- package/dist/core-generated/runtime-rpc-auth-posture.js +10 -2
- package/dist/core-generated/runtime-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-typed-client.d.ts +26 -16
- package/dist/core-generated/runtime-typed-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-typed-client.js +97 -16
- package/dist/core-generated/runtime-typed-client.js.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.d.ts +15 -7
- package/dist/core-generated/runtime-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.js +16 -8
- package/dist/core-generated/runtime-wire-codecs.js.map +1 -1
- package/dist/realm/account-settings.d.ts +5 -3
- package/dist/realm/account-settings.d.ts.map +1 -1
- package/dist/realm/account-settings.js +3 -3
- package/dist/realm/account-settings.js.map +1 -1
- package/dist/realm/generated.d.ts +1 -1
- package/dist/realm/generated.d.ts.map +1 -1
- package/dist/realm/generated.js.map +1 -1
- package/dist/realm/index.d.ts +4 -4
- package/dist/realm/index.d.ts.map +1 -1
- package/dist/realm/index.js +5 -15
- package/dist/realm/index.js.map +1 -1
- package/dist/realm/media-delivery.d.ts +4 -0
- package/dist/realm/media-delivery.d.ts.map +1 -0
- package/dist/realm/media-delivery.js +65 -0
- package/dist/realm/media-delivery.js.map +1 -0
- package/dist/realm/resource-upload.d.ts +12 -3
- package/dist/realm/resource-upload.d.ts.map +1 -1
- package/dist/realm/resource-upload.js +93 -241
- package/dist/realm/resource-upload.js.map +1 -1
- package/dist/realm/social-types.d.ts +1 -15
- package/dist/realm/social-types.d.ts.map +1 -1
- package/dist/realm/social.d.ts +3 -17
- package/dist/realm/social.d.ts.map +1 -1
- package/dist/realm/social.js +0 -175
- package/dist/realm/social.js.map +1 -1
- package/dist/runtime/config-projections.d.ts +10 -0
- package/dist/runtime/config-projections.d.ts.map +1 -1
- package/dist/runtime/config-projections.js +8 -3
- package/dist/runtime/config-projections.js.map +1 -1
- package/dist/runtime/connector-inventory.d.ts +9 -2
- package/dist/runtime/connector-inventory.d.ts.map +1 -1
- package/dist/runtime/connector-inventory.js +67 -24
- package/dist/runtime/connector-inventory.js.map +1 -1
- package/dist/runtime/desktop-first-party-runtime.d.ts +8 -1
- package/dist/runtime/desktop-first-party-runtime.d.ts.map +1 -1
- package/dist/runtime/desktop-first-party-runtime.js +80 -2
- package/dist/runtime/desktop-first-party-runtime.js.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts +46 -10
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.js +13 -4
- package/dist/runtime/first-party-protected-runtime-profiles.generated.js.map +1 -1
- package/dist/runtime/generated.d.ts +2 -2
- package/dist/runtime/generated.d.ts.map +1 -1
- package/dist/runtime/generated.js +1 -1
- package/dist/runtime/generated.js.map +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +11 -10
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/node-grpc.d.ts.map +1 -1
- package/dist/runtime/node-grpc.js +24 -4
- package/dist/runtime/node-grpc.js.map +1 -1
- package/dist/runtime/reason-messages.d.ts +3 -0
- package/dist/runtime/reason-messages.d.ts.map +1 -1
- package/dist/runtime/reason-messages.js +6 -0
- package/dist/runtime/reason-messages.js.map +1 -1
- package/dist/runtime/runtime-agent-inspect-projection.d.ts +2 -3
- package/dist/runtime/runtime-agent-inspect-projection.d.ts.map +1 -1
- package/dist/runtime/runtime-agent-inspect-projection.js +2 -27
- package/dist/runtime/runtime-agent-inspect-projection.js.map +1 -1
- package/dist/runtime/runtime-agent-inspect-types.d.ts +4 -32
- package/dist/runtime/runtime-agent-inspect-types.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client-types.d.ts +6 -1
- package/dist/runtime/runtime-local-environment-client-types.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client.js +20 -2
- package/dist/runtime/runtime-local-environment-client.js.map +1 -1
- package/dist/runtime/runtime-method-modules.d.ts +1 -1
- package/dist/runtime/runtime-method-modules.d.ts.map +1 -1
- package/dist/runtime/runtime-method-modules.js +4 -2
- package/dist/runtime/runtime-method-modules.js.map +1 -1
- package/dist/runtime/wire-types/agent-participation-enums.d.ts +2 -1
- package/dist/runtime/wire-types/agent-participation-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/agent-participation-enums.js +2 -1
- package/dist/runtime/wire-types/agent-participation-enums.js.map +1 -1
- package/dist/runtime/wire-types/agent-participation-types.d.ts +6 -4
- package/dist/runtime/wire-types/agent-participation-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts +18 -0
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.js +21 -0
- package/dist/runtime/wire-types/ai-scenario-enums.js.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-types.d.ts +4 -4
- package/dist/runtime/wire-types/ai-scenario-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/identity-app-types.d.ts +4 -4
- package/dist/runtime/wire-types/identity-app-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/local-memory-enums.d.ts +9 -0
- package/dist/runtime/wire-types/local-memory-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/local-memory-enums.js +10 -0
- package/dist/runtime/wire-types/local-memory-enums.js.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts +2 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.js +1 -0
- package/dist/runtime/wire-types/reason-code-enums.js.map +1 -1
- package/dist/types/sha256.d.ts +6 -1
- package/dist/types/sha256.d.ts.map +1 -1
- package/dist/types/sha256.js +60 -25
- package/dist/types/sha256.js.map +1 -1
- package/package.json +3 -3
- package/dist/realm/feed.d.ts +0 -4
- package/dist/realm/feed.d.ts.map +0 -1
- package/dist/realm/feed.js +0 -10
- package/dist/realm/feed.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,129 +1,80 @@
|
|
|
1
1
|
# @nimiplatform/sdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
The package includes runnable JavaScript and TypeScript declarations under
|
|
5
|
-
`dist/`; use the public exports instead of importing Runtime internals.
|
|
3
|
+
The official TypeScript SDK for the Nimi Platform.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
`@nimiplatform/sdk` provides strongly-typed clients, capability contracts, and runtime interfaces for building privacy-preserving, AI-native desktop applications. Through a unified capability-intent architecture, applications can seamlessly harness both on-device local models and cloud AI providers without managing API keys or low-level transport protocols.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
`nimi-app --help` prints its location before initialization. Select the matched
|
|
11
|
-
SDK/Kit versions from that package's `nimiScaffoldVersions` and retain the
|
|
12
|
-
project lockfile. See [migration notes](CHANGELOG.md) before upgrading.
|
|
7
|
+
---
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
## 1. Core Architecture & Mental Model
|
|
10
|
+
|
|
11
|
+
### The Host-Bound Client
|
|
12
|
+
Standard Nimi Apps run inside a desktop host supervised by Nimi Desktop (the current host of Nimi Home). Instead of requiring applications to manage secrets or connect directly to local ports, the host injects a secure IPC bridge.
|
|
17
13
|
|
|
18
14
|
```ts
|
|
19
15
|
import { createNimiClient, type NimiLocalAppClient } from '@nimiplatform/sdk';
|
|
20
16
|
import { createNimiLocalAppStandardShellSurface } from '@nimiplatform/kit/shell/renderer/bridge';
|
|
21
17
|
|
|
18
|
+
// Scaffolded apps export this singleton from src/shell/auth/local-app-client.ts
|
|
22
19
|
const client: NimiLocalAppClient = createNimiClient({
|
|
23
20
|
localApp: { standardShell: createNimiLocalAppStandardShellSurface() },
|
|
24
21
|
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- **Host-managed credentials**: No API tokens, account IDs, or private network addresses are embedded in your frontend code.
|
|
25
|
+
- **Dynamic Routing**: The local Runtime resolves whether an action is fulfilled by a selected local model or a supported cloud provider based on user preference.
|
|
26
|
+
- **Fail-Closed Boundaries**: Direct standalone clients (`createNimiClient({ appId, runtime })`) are reserved for external server daemons or test scripts; Runtime strictly rejects app-scoped operations from unverified gRPC origins.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. Quickstart: Text Generation
|
|
31
|
+
|
|
32
|
+
### Single-Turn Text Generation
|
|
33
|
+
The simplest way to generate text using the user's preferred model:
|
|
25
34
|
|
|
35
|
+
```ts
|
|
26
36
|
const { text } = await client.ai.text.generateCandidate({
|
|
27
|
-
messages: [
|
|
37
|
+
messages: [
|
|
38
|
+
{ role: 'user', text: 'Summarize the core tenets of local-first computing.' }
|
|
39
|
+
],
|
|
28
40
|
});
|
|
41
|
+
console.log(text);
|
|
29
42
|
```
|
|
30
43
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
or a provider/model override to these protected calls. A direct client created
|
|
34
|
-
with `createNimiClient({ appId, runtime })` is for programs outside a Nimi App;
|
|
35
|
-
Runtime rejects App-scoped operations such as AI execution and App storage
|
|
36
|
-
from it.
|
|
37
|
-
|
|
38
|
-
For a multi-step tool loop, JSON output or image input, bind the common model
|
|
39
|
-
interface to the same client:
|
|
44
|
+
### Multi-Step Tool Loops & Structured Output
|
|
45
|
+
For multi-turn tool calling, structured JSON output, or multimodal inputs, bind the local app text model:
|
|
40
46
|
|
|
41
47
|
```ts
|
|
42
48
|
import type { NimiLocalAppClient } from '@nimiplatform/sdk/app';
|
|
43
49
|
import { createNimiLocalAppTextModel } from '@nimiplatform/sdk/ai';
|
|
44
50
|
|
|
45
|
-
export async function
|
|
51
|
+
export async function answerWithTools(
|
|
46
52
|
client: NimiLocalAppClient,
|
|
47
53
|
question: string,
|
|
48
54
|
signal: AbortSignal,
|
|
49
55
|
) {
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
const model = createNimiLocalAppTextModel(client.ai);
|
|
57
|
+
|
|
58
|
+
return await model.generateText({
|
|
59
|
+
messages: [
|
|
60
|
+
{ role: 'user', content: [{ type: 'text', text: question }] }
|
|
61
|
+
],
|
|
62
|
+
responseFormat: { type: 'json-object' },
|
|
52
63
|
signal,
|
|
53
64
|
});
|
|
54
65
|
}
|
|
55
66
|
```
|
|
56
67
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
and
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
moving instructions to the beginning or changing their role. The initial exact
|
|
68
|
-
DeepSeek Chat Completions v3 slice preserves these inputs in synchronous and
|
|
69
|
-
streaming plain text, function-tool or JSON-object calls. Other combinations
|
|
70
|
-
remain separately admitted. This does not relax the 128-message/1-MiB bounds,
|
|
71
|
-
or the user-only media boundary.
|
|
72
|
-
|
|
73
|
-
App-owned initiation or continuation can submit nonempty system/assistant
|
|
74
|
-
context without a user-role message. The carrier does not add a filler user
|
|
75
|
-
turn or rewrite roles. Empty and opaque-only input still fails, and exact
|
|
76
|
-
Driver input support remains required. If an App's budget planner drops needed
|
|
77
|
-
history, the App must report that loss rather than treating it as intentional
|
|
78
|
-
userless generation. The narrow text candidate method is unchanged.
|
|
79
|
-
|
|
80
|
-
The current Local App binding (SDK 0.21.0 / Kit/native 0.18.0 with matching
|
|
81
|
-
Runtime) supports function tools, tool choice, structured `responseFormat`,
|
|
82
|
-
and admitted user image parts. HTTP(S) image file
|
|
83
|
-
parts and owned image `artifact-ref` parts preserve their order with text.
|
|
84
|
-
Upload local image bytes through `client.ai.artifacts.upload`; do not put file
|
|
85
|
-
paths or data URLs in model requests. Other media methods have separate contracts, and each
|
|
86
|
-
selected execution configuration must support the requested modality and
|
|
87
|
-
controls.
|
|
88
|
-
|
|
89
|
-
The matching development cohort also carries owned WAV, MPEG audio and MP4
|
|
90
|
-
video Artifact references in user text-generation messages. Upload the media
|
|
91
|
-
through the App's artifact API; direct audio/video URLs and inline data remain
|
|
92
|
-
invalid App inputs. The exact Gemini 3.8 Flash native base adapter admits this
|
|
93
|
-
media in plain-text synchronous and streaming calls. Its tool and schema modes
|
|
94
|
-
remain separate synchronous combinations and do not admit audio/video input.
|
|
95
|
-
Preserving multiple system-message boundaries is a separate Driver behavior;
|
|
96
|
-
media support does not imply that combination is supported.
|
|
97
|
-
|
|
98
|
-
## Local App speech support boundaries
|
|
99
|
-
|
|
100
|
-
The current matched package combination carries a typed
|
|
101
|
-
`job.transcription` on completed `speech-transcribe` jobs. It contains `status`
|
|
102
|
-
(`transcribed` or `no-speech`), original `text`, model-reported `language` and
|
|
103
|
-
ordered `words` with `text`, `startSeconds` and `endSeconds`. Plain transcription
|
|
104
|
-
resources can leave language and words empty. Aligned results also leave
|
|
105
|
-
`language` empty when recognition did not report it; real words and timestamps
|
|
106
|
-
can still be present. Requesting `timestamps: true`
|
|
107
|
-
requires a resource with actual alignment support; unsupported requests fail.
|
|
108
|
-
The request's `language` is an input hint, not a detected-language result.
|
|
109
|
-
|
|
110
|
-
DashScope's `qwen-audio-3.0-asr-flash-streaming` and admitted
|
|
111
|
-
`fun-asr-realtime` models also execute finite `speech-transcribe` Jobs. The
|
|
112
|
-
matching Runtime accepts mono PCM WAV up to 300 seconds and 32 MiB, waits for
|
|
113
|
-
the provider's successful terminal event, and publishes its final text and
|
|
114
|
-
actual word times. Partial hypotheses are not completed results. Detected
|
|
115
|
-
language remains empty because this protocol does not report it; empty output
|
|
116
|
-
is an error, not an inferred `no-speech`. Prompt, response-format and diarization
|
|
117
|
-
controls are unsupported. The provider's WebSocket transport does not turn
|
|
118
|
-
these Jobs into public realtime sessions. Longer audio remains App chunking.
|
|
119
|
-
|
|
120
|
-
For the local Qwen3 aligned recipe, an explicit supported input language can
|
|
121
|
-
guide the aligner when recognition returns text without a language label.
|
|
122
|
-
That hint is never copied into the result's `language`. Without a reported
|
|
123
|
-
language or an explicit supported hint, alignment fails; an unsupported
|
|
124
|
-
reported language is not overridden by the hint. Apps can use their selected
|
|
125
|
-
source language for downstream processing while retaining missing detection
|
|
126
|
-
as unknown.
|
|
68
|
+
- **Tool Execution & Turn History**: The application owns tool handlers and subsequent conversation turns. Preserve ordered `outputItems` as `turnItems` on the next tool step, along with matching tool results.
|
|
69
|
+
- **Reasoning Continuity**: Preserve opaque `reasoning-continuity` payloads byte-for-byte in their original order. Do not decode or display them.
|
|
70
|
+
- **Validation**: Treat a response as complete only after successful completion—check the finish reason and validate the returned JSON against your business schema.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 3. Advanced Capabilities
|
|
75
|
+
|
|
76
|
+
### Audio Transcription (`audio.transcribe`)
|
|
77
|
+
Read completed speech-to-text results. Word timing is available only when the selected resource supports alignment:
|
|
127
78
|
|
|
128
79
|
```ts
|
|
129
80
|
const { job } = await client.ai.scenarioJobs.get(jobId);
|
|
@@ -131,368 +82,145 @@ if (job.status === 'completed' && job.scenarioType === 'speech-transcribe') {
|
|
|
131
82
|
const transcript = job.transcription;
|
|
132
83
|
if (transcript?.status === 'transcribed') {
|
|
133
84
|
for (const word of transcript.words) {
|
|
134
|
-
console.log(word.text
|
|
85
|
+
console.log(`${word.text} [${word.startSeconds}s - ${word.endSeconds}s]`);
|
|
135
86
|
}
|
|
136
87
|
}
|
|
137
88
|
}
|
|
138
89
|
```
|
|
139
90
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
seconds per request and supports zh/en/yue/fr/de/it/ja/ko/pt/ru/es. Times are
|
|
148
|
-
actual model alignment relative to the submitted audio's zero point, with
|
|
149
|
-
pauses retained. The current aligner has 80 ms resolution. Units can be CJK
|
|
150
|
-
characters; they are not guaranteed to be linguistic words. Text retains
|
|
151
|
-
punctuation. For longer media, the App splits input and adds each source chunk
|
|
152
|
-
offset exactly once; Runtime does not own App chunking or subtitle assembly.
|
|
153
|
-
This route does not provide diarization, speaker counts, or a standalone
|
|
154
|
-
alignment operation for caller-supplied transcripts.
|
|
155
|
-
|
|
156
|
-
The local Faster Whisper recipe instead captures a CTranslate2 Whisper model
|
|
157
|
-
and a Silero ONNX voice activity detector. It also accepts up to 300 seconds
|
|
158
|
-
and returns real word times on the original input timeline; it does not offer
|
|
159
|
-
diarization or prompts. A caller-specified language is a hint, not detected
|
|
160
|
-
language, so that result field stays empty when the request fixes the language.
|
|
161
|
-
The recognizer receives the full audio: VAD alone cannot discard weak or
|
|
162
|
-
synthetic speech. No-speech requires both no recognized segments and no speech
|
|
163
|
-
detected by the captured VAD. Empty recognition after detected speech fails.
|
|
164
|
-
Neither recipe guarantees error-free subtitles; retain source timing and use
|
|
165
|
-
the App's proofreading workflow when recognition or alignment is inaccurate.
|
|
166
|
-
|
|
167
|
-
Select the intended Loadout for `audio.transcribe` in Nimi's model configuration first.
|
|
168
|
-
The App's AIConfig Local intent is the route marker `local: {}` and carries no
|
|
169
|
-
Loadout reference; the machine's current selection is captured at new Job
|
|
170
|
-
admission. `listOptions({ kind: 'local-loadouts', capabilityContract:
|
|
171
|
-
'audio.transcribe' })` exposes that current selection, not every saved Loadout.
|
|
172
|
-
|
|
173
|
-
Local `audio-separate` jobs consume `mimeType` and the same bytes/HTTPS URI
|
|
174
|
-
`audioSource` shape as transcription. Choose the Demucs separation Loadout for
|
|
175
|
-
`audio.separate` in Nimi, then declare that capability's `local: {}` App intent.
|
|
176
|
-
The initial Driver accepts at most 300 seconds and 32 MiB per input. Split longer
|
|
177
|
-
sources in the App while retaining their offsets and complete timeline.
|
|
178
|
-
|
|
179
|
-
A completed Job's `audioSeparation` names `vocalsArtifactId` and
|
|
180
|
-
`backgroundArtifactId`. Both refer to that Job's audio artifacts and preserve
|
|
181
|
-
the input zero point, duration and pauses; background is the model's summed
|
|
182
|
-
non-vocal sources. Read sample rate and channel count from the artifact records.
|
|
183
|
-
The current Driver produces float WAV audio, which can exceed inline limits.
|
|
184
|
-
Receive it through `client.storage.assets.adoptArtifact`. Use the returned
|
|
185
|
-
record's `relativePath` for reads, previews and removal: Runtime normalizes the
|
|
186
|
-
filename extension to the actual artifact media type, so the requested path is
|
|
187
|
-
not necessarily the stored path. For example, requesting `transfers/result`
|
|
188
|
-
for a WAV artifact returns `transfers/result.wav`.
|
|
91
|
+
- **Supported Engines**: Supports local Qwen3 aligned recipes (with 80ms resolution across CJK and European languages) and Faster Whisper with Silero VAD.
|
|
92
|
+
- **Resource Limits & Semantics**: Local Qwen3 aligned and Demucs routes accept bounded audio up to 300 seconds, though exact limits and available controls depend on the selected resource. Note that Qwen3 alignment units may be individual CJK characters rather than linguistic words, and a language hint is not a detected-language result.
|
|
93
|
+
|
|
94
|
+
For the local Qwen3 aligned recipe, supported language hints are `zh`, `en`, `yue`, `fr`, `de`, `it`, `ja`, `ko`, `pt`, `ru`, and `es`. Alignment uses the input audio timeline; keep pauses and add chunk offsets exactly once when assembling longer media. The complete transcription result is bounded to 1 MiB and 16,384 alignment units. An absent detected language remains unknown, even when a language hint was supplied.
|
|
95
|
+
|
|
96
|
+
### Audio Separation (`audio.separate`)
|
|
97
|
+
Separate vocals and accompaniment using local Demucs models:
|
|
189
98
|
|
|
190
99
|
```ts
|
|
191
|
-
|
|
192
|
-
const
|
|
100
|
+
// Submit separation job
|
|
101
|
+
const { job } = await client.ai.scenarioJobs.submit({
|
|
102
|
+
type: 'audio-separate',
|
|
103
|
+
mimeType: 'audio/wav',
|
|
104
|
+
audioSource: { type: 'bytes', bytes: audioBuffer },
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Save job.jobId. Once observation reports completion, read the final result.
|
|
108
|
+
const { job: completed } = await client.ai.scenarioJobs.get(job.jobId);
|
|
109
|
+
if (completed.status === 'completed' && completed.audioSeparation) {
|
|
110
|
+
const vocals = await client.storage.assets.adoptArtifact({
|
|
111
|
+
artifactId: completed.audioSeparation.vocalsArtifactId,
|
|
112
|
+
relativePath: 'audio/vocals.wav',
|
|
113
|
+
});
|
|
114
|
+
// Use vocals.relativePath: the stored extension may be normalized.
|
|
115
|
+
console.log(vocals.relativePath);
|
|
116
|
+
}
|
|
193
117
|
```
|
|
194
118
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
When `textMode` is `unsupported`, pass `text: ''` in the SDK's reference-audio
|
|
235
|
-
spec and keep any transcript in App storage. When optional, send the actual
|
|
236
|
-
reference transcript if available; when required, request one before creating
|
|
237
|
-
the voice. Do not select these behaviors by provider/model name. Local Qwen3
|
|
238
|
-
reference workflows accept both public URI and bytes with optional text; the
|
|
239
|
-
Runtime captures a URI into private bytes and empty text uses the model's
|
|
240
|
-
reference-only mode. Choosing URI input never uploads an existing local file.
|
|
241
|
-
|
|
242
|
-
Submit `voice-create` through `client.ai.scenarioJobs` with exactly one
|
|
243
|
-
`creationSource`: `reference-audio` (audio bytes or HTTPS URI, MIME type and
|
|
244
|
-
optional reference transcript in `text`) or `text-description` (instruction and
|
|
245
|
-
preview text). Read the completed Job with `get(jobId)` to obtain `asset` and
|
|
246
|
-
`voiceReference`. For synthesis, pass the returned asset identity as
|
|
247
|
-
`voiceRef: { type: 'voice-asset', id: asset.voiceAssetId }` in a
|
|
248
|
-
`speech-synthesize` Job. Creation success is not proof that playable audio was
|
|
249
|
-
generated; the local Qwen3 creation paths return a voice handle and
|
|
250
|
-
requires a synthesis Job to produce the preview audio.
|
|
251
|
-
|
|
252
|
-
Both operations use their own committed capability configuration. The selected
|
|
253
|
-
`voice.create` implementation must support `input.audio` or `input.text` for the
|
|
254
|
-
requested source. Separate local Qwen3 clone and design recipes require their
|
|
255
|
-
respective Loadouts; synthesis also needs a compatible selected Loadout. A source
|
|
256
|
-
field does not switch a model or route. Expose unmet configuration to the user instead
|
|
257
|
-
of retrying through a different engine. Existing engine-specific seed, sampling
|
|
258
|
-
or guidance controls must not be silently mapped to unrelated public fields.
|
|
259
|
-
|
|
260
|
-
For DashScope Qwen-Audio 3.0 voices, select the same current TTS model for
|
|
261
|
-
`voice.create` and `audio.synthesize`. Both Plus and Flash use the provider's
|
|
262
|
-
voice-enrollment and SpeechSynthesizer protocols. Reference-audio creation
|
|
263
|
-
requires a publicly reachable HTTP(S) URI; inline bytes and a local file path
|
|
264
|
-
are not supported by this provider workflow. Nimi does not publish an App's
|
|
265
|
-
private audio to obtain a URL. Preserve the user's reference URI explicitly,
|
|
266
|
-
or select a configuration that accepts bytes. A cloned voice's target model
|
|
267
|
-
must match later synthesis. The current provider accepts 16-bit WAV, MP3 or
|
|
268
|
-
M4A, at least 16 kHz, at most 60 seconds and 10 MB; it recommends 10–20 seconds
|
|
269
|
-
with at least five seconds of continuous clear speech. Stereo uses the first
|
|
270
|
-
channel. The reference transcript is unsupported for this workflow; retain it
|
|
271
|
-
as business metadata rather than submitting it as a model prompt. Check the
|
|
272
|
-
[provider's reference requirements](https://help.aliyun.com/zh/model-studio/voice-cloning-user-guide)
|
|
273
|
-
when preparing a new sample. Voice design accepts an English or Chinese
|
|
274
|
-
description of at most 500 characters and a preview of 15–200 characters in
|
|
275
|
-
the same supported language. Synthesis supports additional languages,
|
|
276
|
-
including Spanish; that does not expand the design preview's language range.
|
|
277
|
-
The App keeps voice metadata and audition/export files in its business storage.
|
|
278
|
-
|
|
279
|
-
The current local Qwen3 synthesis Driver accepts WAV output and no timing mode
|
|
280
|
-
beyond `none`. It rejects supplied `speed`, `pitch`, `volume`, `sampleRateHz` and
|
|
281
|
-
`voiceRenderHints`, including explicit neutral values such as `speed: 1`. Omit
|
|
282
|
-
those fields. When the product's playback speed or delivery format is a
|
|
283
|
-
deterministic media-editing operation, preserve it in the App after generation
|
|
284
|
-
(for example, FFmpeg tempo conversion), using the actual decoded audio format.
|
|
285
|
-
That post-processing is distinct from a model's acoustic generation control.
|
|
286
|
-
|
|
287
|
-
Qwen3 Base reference-voice synthesis does not provide per-utterance style or
|
|
288
|
-
emotion instructions. The CustomVoice preset path maps `emotion` to its own
|
|
289
|
-
natural-language instruction; this does not establish support for Base voice
|
|
290
|
-
assets. A `voice-create` design instruction describes the voice being created,
|
|
291
|
-
not a later utterance's prosody. Other engines' inline expression tokens, such
|
|
292
|
-
as OmniVoice's `[laughter]` or `[question-en]`, have no defined Qwen3 mapping.
|
|
293
|
-
Keep unsupported model-specific controls explicit instead of silently mapping
|
|
294
|
-
them to another field or assuming literal text will produce the intended effect.
|
|
295
|
-
|
|
296
|
-
For a library that mixes cloned and designed voices, select the explicit
|
|
297
|
-
**Qwen3 design and reference voice library** recipe for `voice.create`. Bind its
|
|
298
|
-
Base and VoiceDesign models independently, and select that same Base ModelAsset
|
|
299
|
-
for `audio.synthesize`. The library admits both source features in one captured
|
|
300
|
-
configuration. A `text-description` Job requires nonempty `previewText`, runs
|
|
301
|
-
VoiceDesign to create real reference audio, then returns a Base-compatible voice
|
|
302
|
-
asset containing that reference. Reference-audio creation uses the supplied
|
|
303
|
-
audio. Both kinds of asset subsequently synthesize with Base, so a story or
|
|
304
|
-
batch can mix them without changing the machine selection. Wait for creation to
|
|
305
|
-
complete before requesting audition audio; design creation now includes model
|
|
306
|
-
execution and follows the ordinary Job timeout and cancellation lifecycle.
|
|
307
|
-
|
|
308
|
-
Keep business voice names, descriptions, original reference audio and transcript,
|
|
309
|
-
and saved previews in App storage. A Runtime VoiceAsset is not the App's voice
|
|
310
|
-
library record or a permanent audio backup. Save the `voiceAssetId` actually
|
|
311
|
-
used for an approved take and reuse it to synthesize with that same voice;
|
|
312
|
-
there is no requirement to clone every audition again. Runtime revalidates its
|
|
313
|
-
owner, status and target compatibility. An expired or incompatible asset fails
|
|
314
|
-
explicitly rather than causing hidden recreation, upload or route switching.
|
|
315
|
-
This retains the voice identity, not identical audio or prosody on every take.
|
|
316
|
-
|
|
317
|
-
If the user instead chooses actual sample audio as a new reference, or edits,
|
|
318
|
-
denoises or replaces the reference, invalidate the previous reference/asset
|
|
319
|
-
association and use `reference-audio` creation for that new input. A cached
|
|
320
|
-
source VoiceAsset does not represent edited output audio. Preserve the actual
|
|
321
|
-
chosen audio and transcript in either workflow, distinguish the two actions in
|
|
322
|
-
the product, and apply normal resource eligibility and configuration checks.
|
|
323
|
-
|
|
324
|
-
## Persisting results and resuming jobs
|
|
325
|
-
|
|
326
|
-
Runtime Job storage is bounded execution state, not the App's project database.
|
|
327
|
-
The current Runtime retains terminal Jobs for up to 30 minutes and applies a
|
|
328
|
-
count limit. Save complete validated results in App-managed storage while the
|
|
329
|
-
Job is available; adopt output artifacts when the project needs to retain them.
|
|
330
|
-
Persisting only a Job ID does not preserve its result or artifact bytes.
|
|
331
|
-
|
|
332
|
-
When resuming a project, reuse complete App-owned results. If a step has only
|
|
333
|
-
an old Job ID, and the normal public Job read explicitly returns `not-found`,
|
|
334
|
-
record that reference as unavailable. An explicit continue/retry action may
|
|
335
|
-
then submit that unfinished step again from its original input and save the new
|
|
336
|
-
ID. Do not poll a missing Job indefinitely, mark it completed, or rerun already
|
|
337
|
-
completed project steps. Permission, session and transport errors are different
|
|
338
|
-
failures and must not trigger the missing-Job recovery path.
|
|
339
|
-
|
|
340
|
-
## Structured text
|
|
341
|
-
|
|
342
|
-
`createNimiLocalAppTextModel(client.ai)` binds text generation to an installed
|
|
343
|
-
App's protected session. Its name does not restrict execution to a local model:
|
|
344
|
-
the App's committed AI configuration chooses Local or Cloud.
|
|
345
|
-
|
|
346
|
-
Request JSON with `responseFormat: { type: 'json-object' }` and consume it only
|
|
347
|
-
after `generateText` completes. A configured route is not proof that every text
|
|
348
|
-
behavior is available; unsupported behavior fails before dispatch, and malformed
|
|
349
|
-
model output remains a failure. Do not extract a plausible JSON fragment or
|
|
350
|
-
change providers automatically to turn that failure into success.
|
|
351
|
-
|
|
352
|
-
The matching development Runtime admits DeepSeek `deepseek-flash` (currently
|
|
353
|
-
served by V4.1 Flash), `deepseek-v4-flash` and `deepseek-v4-pro`. These provider
|
|
354
|
-
API names are not immutable weight-version pins. Record the exact configured
|
|
355
|
-
target and test date when comparing results; prefer the current `deepseek-flash`
|
|
356
|
-
name for new Flash selections.
|
|
357
|
-
|
|
358
|
-
The exact adapters support JSON-object output or native function-tool calls,
|
|
359
|
-
including streamed completion, complete tool arguments and tool-result turns.
|
|
360
|
-
These are separate admitted combinations: do not combine tools and JSON output.
|
|
361
|
-
Thinking is disabled; requested reasoning, JSON Schema, media input, `topK` and
|
|
362
|
-
`seed` are not admitted by this slice. The App still uses the same model interface
|
|
363
|
-
and AI configuration; it never calls DeepSeek directly or executes a model's
|
|
364
|
-
tool request inside Runtime.
|
|
365
|
-
|
|
366
|
-
## Language analysis
|
|
367
|
-
|
|
368
|
-
Use the `text.annotate` AI configuration capability and submit an asynchronous
|
|
369
|
-
`text-annotate` Job through the existing scenario Job API:
|
|
119
|
+
When handling separation outputs:
|
|
120
|
+
- Adopt both separation outputs before presenting a complete pair.
|
|
121
|
+
- Read sample rate and channel count from the artifact records, and retain the source timeline when splitting longer audio.
|
|
122
|
+
- Treat failed or canceled Jobs as incomplete—never present them as a partial success.
|
|
123
|
+
|
|
124
|
+
### Custom Voice Creation & Synthesis (`voice.create` & `audio.synthesize`)
|
|
125
|
+
Clone a voice from reference audio or design a new persona via natural language:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
// Create a voice persona from audio reference
|
|
129
|
+
const { job } = await client.ai.scenarioJobs.submit({
|
|
130
|
+
type: 'voice-create',
|
|
131
|
+
creationSource: 'reference-audio',
|
|
132
|
+
referenceAudio: { type: 'bytes', bytes: sampleAudioBytes },
|
|
133
|
+
referenceAudioMime: 'audio/wav',
|
|
134
|
+
languageHints: [],
|
|
135
|
+
preferredName: 'My voice',
|
|
136
|
+
text: '', // Follow the selected resource’s referenceAudioInput.textMode.
|
|
137
|
+
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// After observing completion, retrieve the voice asset separately from the Job.
|
|
141
|
+
const result = await client.ai.scenarioJobs.get(job.jobId);
|
|
142
|
+
if (result.job.status === 'completed' && result.asset?.status === 'active') {
|
|
143
|
+
await client.ai.scenarioJobs.submit({
|
|
144
|
+
type: 'speech-synthesize',
|
|
145
|
+
text: 'Hello world, speaking in the newly created voice!',
|
|
146
|
+
language: '', audioFormat: 'wav', emotion: '',
|
|
147
|
+
voiceRef: { type: 'voice-asset', id: result.asset.voiceAssetId },
|
|
148
|
+
timingMode: 'none', voiceRenderHints: null,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Before building your form, inspect `referenceAudioInput` on the selected `voice.create` resource: it declares the supported input forms and whether reference text is required, optional, or unsupported (the example above passes empty text, so choose a resource that admits it). Also ensure that voice creation and synthesis use compatible selected resources—a created asset does not guarantee that every synthesis route can render it.
|
|
154
|
+
|
|
155
|
+
### Language Analysis (`text.annotate`)
|
|
156
|
+
Perform part-of-speech tagging, lemmatization, and syntactic dependency parsing:
|
|
370
157
|
|
|
371
158
|
```ts
|
|
372
159
|
const { job } = await client.ai.scenarioJobs.submit({
|
|
373
160
|
type: 'text-annotate',
|
|
374
161
|
language: 'en',
|
|
375
|
-
texts: ['
|
|
162
|
+
texts: ['Nimi puts personal sovereignty at the center of modern computing.'],
|
|
376
163
|
});
|
|
377
|
-
|
|
378
|
-
//
|
|
164
|
+
|
|
165
|
+
// Completed job contains structured token annotations with exact Unicode scalar offsets
|
|
379
166
|
```
|
|
380
167
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
The completed Job's `textAnnotation.documents` preserves that batch order and
|
|
384
|
-
the exact original text and whitespace. Each document contains:
|
|
385
|
-
|
|
386
|
-
- `text`, `language` and an ordered `tokens` array.
|
|
387
|
-
- Each token's `text`, `start`, `end`, `headIndex`, `partOfSpeech`, `dependency`
|
|
388
|
-
and `isPunctuation`.
|
|
389
|
-
- `sentences`, each with `startToken` and exclusive `endToken`.
|
|
390
|
-
|
|
391
|
-
Token `start`/`end` count **Unicode scalar values**, not UTF-8 bytes or JavaScript
|
|
392
|
-
UTF-16 code units. Python can slice its original string directly; JavaScript can
|
|
393
|
-
use `Array.from(document.text).slice(start, end).join('')`. Token array positions
|
|
394
|
-
are their indices, heads are document-local, and a span's original text extends
|
|
395
|
-
from its first token's start to its last token's end. Sentence spans partition
|
|
396
|
-
the token array. Empty documents have no tokens or sentences.
|
|
397
|
-
|
|
398
|
-
The initial local spaCy implementation uses the original md 3.8.0 pipelines for
|
|
399
|
-
en/de/es/fr/it/ru/zh/ja. The active Nimi model configuration must contain the
|
|
400
|
-
pipeline for the requested language. `language` validates that choice; it does
|
|
401
|
-
not override machine selection. Model installation and dependency preparation
|
|
402
|
-
belong to Nimi, and inference never downloads a model in the App. A batch is
|
|
403
|
-
bounded to 65536 tokens and a 16 MiB normalized result; oversized or failed analysis
|
|
404
|
-
returns failure rather than partial annotations. Keep subtitle splitting rules,
|
|
405
|
-
translation, time matching, project state and repeated analysis in the App.
|
|
406
|
-
These annotations contain no audio timestamps or generated replacement text.
|
|
407
|
-
|
|
408
|
-
This addition requires a matching development Runtime, SDK, Kit and native
|
|
409
|
-
package set. Keep using the documented local tarball workflow during iteration;
|
|
410
|
-
package publication is not a development prerequisite.
|
|
411
|
-
|
|
412
|
-
## Text decisions
|
|
413
|
-
|
|
414
|
-
Use the `text.decide` AI configuration capability and the synchronous
|
|
415
|
-
`text-decide` execute variant to score App-authored questions about one state:
|
|
168
|
+
### Structured Text Decisions (`text.decide`)
|
|
169
|
+
Score probability distributions over state-dependent choices or boolean hypotheses:
|
|
416
170
|
|
|
417
171
|
```ts
|
|
418
|
-
const
|
|
419
|
-
const { output, traceId } = await client.ai.scenario.execute({
|
|
172
|
+
const { output } = await client.ai.scenario.execute({
|
|
420
173
|
type: 'text-decide',
|
|
421
|
-
state: { json: {
|
|
174
|
+
state: { json: { gameRound: 3, playerChips: 450 } },
|
|
422
175
|
questions: [
|
|
423
|
-
{
|
|
424
|
-
|
|
425
|
-
|
|
176
|
+
{
|
|
177
|
+
id: 'next_action',
|
|
178
|
+
instructions: { text: 'Choose the optimal next action.' },
|
|
179
|
+
kind: 'choice',
|
|
180
|
+
candidates: [{ id: 'raise' }, { id: 'call' }, { id: 'fold' }],
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: 'opponent_bluffing',
|
|
184
|
+
instructions: { text: 'Is the opponent likely bluffing?' },
|
|
185
|
+
kind: 'boolean',
|
|
186
|
+
},
|
|
426
187
|
],
|
|
427
|
-
}, {
|
|
428
|
-
// output.type === 'text-decide'; output.answers follow the submitted order.
|
|
188
|
+
}, { timeoutMs: 10_000 });
|
|
429
189
|
```
|
|
430
190
|
|
|
431
|
-
|
|
432
|
-
levels); 1–64 questions with unique IDs; instructions at most 32 KiB; a choice has
|
|
433
|
-
2–255 unique candidates; descriptions and boolean criteria are optional and at most
|
|
434
|
-
8 KiB; IDs are 1–64 bytes without surrounding whitespace or control characters; the
|
|
435
|
-
complete request is at most 1 MiB. JSON content is sent as its `JSON.stringify`
|
|
436
|
-
text, so key insertion order is kept. Invalid input fails before transport.
|
|
437
|
-
|
|
438
|
-
Each choice answer carries the selected candidate and one probability per submitted
|
|
439
|
-
candidate in submitted order; each boolean answer carries `trueProbability`. There is
|
|
440
|
-
no confidence, usage, provider or model field. Thresholds, grouping and actions stay
|
|
441
|
-
in the App. Input that is valid but cannot be encoded completely by the configured
|
|
442
|
-
implementation fails with `ai-input-limit-exceeded` (`AI_INPUT_LIMIT_EXCEEDED`).
|
|
443
|
-
|
|
444
|
-
Every execute variant accepts per-call options. Aborting settles the call at once
|
|
445
|
-
with `OPERATION_ABORTED`; an elapsed `timeoutMs` (1–120000) settles it with
|
|
446
|
-
`OPERATION_TIMEOUT`. Either failure cancels the pending Runtime call, never returns a
|
|
447
|
-
late result and leaves the protected App session valid.
|
|
448
|
-
|
|
449
|
-
## Public entry points
|
|
450
|
-
|
|
451
|
-
| Import | Purpose |
|
|
452
|
-
| --- | --- |
|
|
453
|
-
| `@nimiplatform/sdk/app` | Host-bound App client, standard shell contracts and typed App operations. |
|
|
454
|
-
| `@nimiplatform/sdk/ai` | Model interfaces and the Local App text model binding. |
|
|
455
|
-
| `@nimiplatform/sdk/contracts` | Shared messages, content parts, tool and ordered result values. |
|
|
456
|
-
| `@nimiplatform/sdk/ai-runner` | External-host execution helpers; they do not move App workflow state into Runtime. |
|
|
457
|
-
| `@nimiplatform/sdk/runtime` | Public Runtime clients for their explicitly supported consumer contexts. This is not a Local App authorization bypass. |
|
|
458
|
-
| `@nimiplatform/sdk/realm` | Public Realm clients for their supported contexts; App Realm operations use the App client. |
|
|
459
|
-
|
|
460
|
-
The installed package's `exports` and `.d.ts` files define the exact callable
|
|
461
|
-
surface. Framework adapters are separate packages; do not infer that an
|
|
462
|
-
adapter is publicly available from a source-workspace directory.
|
|
463
|
-
|
|
464
|
-
For Vercel AI SDK 6 Apps, the separate `@nimiplatform/sdk-adapter-vercel-ai`
|
|
465
|
-
package provides `createNimiLocalAppVercelLanguageModel({ ai: client.ai })` for
|
|
466
|
-
`streamText` and the existing UI/tool-loop protocol. Adapter 0.3.0 pairs with
|
|
467
|
-
SDK 0.19.0 and Kit/native 0.16.0; the earlier adapter 0.1.0 declares SDK
|
|
468
|
-
`^0.13.0` and does not accept a later SDK minor. Read its package README before
|
|
469
|
-
mapping images or conversation history, and preserve text/tool provider
|
|
470
|
-
metadata for opaque continuity.
|
|
471
|
-
|
|
472
|
-
Source and issue reporting: [nimiplatform/nimi](https://github.com/nimiplatform/nimi).
|
|
473
|
-
Include the selected SDK, Kit, App Tools and Runtime versions, the actual App
|
|
474
|
-
operation, expected/observed behavior, and a bounded reproduction.
|
|
191
|
+
---
|
|
475
192
|
|
|
476
|
-
|
|
193
|
+
## 4. Public Subpaths & Modules
|
|
477
194
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
`
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
195
|
+
| Subpath | Description |
|
|
196
|
+
| :--- | :--- |
|
|
197
|
+
| `@nimiplatform/sdk` | Core entry point; exports `createNimiClient` |
|
|
198
|
+
| `@nimiplatform/sdk/app` | Host-bound app client types, shell contracts, and app operations |
|
|
199
|
+
| `@nimiplatform/sdk/ai` | AI model interfaces, text model bindings, and artifact utilities |
|
|
200
|
+
| `@nimiplatform/sdk/contracts` | Common message schemas, content parts, and tool definitions |
|
|
201
|
+
| `@nimiplatform/sdk/runtime` | Strongly-typed Runtime client for authorized external processes |
|
|
202
|
+
| `@nimiplatform/sdk/realm` | Standalone Realm client for user identities, worlds, and characters |
|
|
203
|
+
| `@nimiplatform/sdk/types` | Portable TypeScript types, schemas, and standardized error codes |
|
|
204
|
+
| `@nimiplatform/sdk-adapter-vercel-ai` | Separate adapter package for Vercel AI SDK 7 integration |
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## 5. Protected Conversation Quotation and Source Reads
|
|
209
|
+
|
|
210
|
+
For LocalAgent chat, use `client.conversation.readMessage({ agentHandle, conversationAnchorId, messageId })` to prepare a quote or navigate to a canonical source in the current authorized Conversation. A readable stable text message returns `quoteText` and `quoteFormat`; other message kinds return both as `null`. The bounded `window` and its `readWatermark` are navigation data, not a replacement live snapshot.
|
|
211
|
+
|
|
212
|
+
Send the user’s own text or attachment parts with an optional `quote` containing only `sourceMessageId`, the returned format, and a half-open UTF-8 byte range. Runtime supplies the confirmed author, partial state and excerpt. A quote does not replace required input parts, permit cross-Conversation access, or alter regeneration inputs. Preserve the entire original request envelope when reconciling an uncertain submission. See the current migration notes for the matching source carrier requirement.
|
|
213
|
+
|
|
214
|
+
## 6. Async Job Observation & Cancellation
|
|
215
|
+
|
|
216
|
+
Long-running generation tasks (audio transcription, separation, voice cloning) are managed as asynchronous scenario jobs:
|
|
217
|
+
|
|
218
|
+
- **Polling & Events**: Observe jobs with `client.ai.scenarioJobs.get(jobId)` or stream progress via observers.
|
|
219
|
+
- **Cancellation**: Call `client.ai.scenarioJobs.cancel(jobId)` to cancel an asynchronous Job, or pass an `AbortSignal` to control supported synchronous calls and model steps. Always inspect the returned state—a cancellation request does not guarantee that a remote provider has stopped computing or billing.
|
|
220
|
+
- **Artifact Custody**: Execution artifacts are temporary. Adopt completed outputs with `client.storage.assets.adoptArtifact` and use its returned path. While recovery-enabled Jobs expose `recoveryExpiresAt`, retention windows vary—persist durable App assets for later reopening rather than assuming every Job shares the same retention period.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
Licensed under [Apache-2.0](LICENSE).
|