@nimiplatform/sdk 0.15.0 → 0.21.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 +430 -1
- package/README.md +125 -18
- package/dist/core/ai/capability-configuration.d.ts +15 -0
- package/dist/core/ai/capability-configuration.d.ts.map +1 -1
- package/dist/core/ai/capability-configuration.js +36 -0
- package/dist/core/ai/capability-configuration.js.map +1 -1
- package/dist/core/ai/embeddings.d.ts +5 -0
- package/dist/core/ai/embeddings.d.ts.map +1 -1
- package/dist/core/ai/embeddings.js +30 -4
- package/dist/core/ai/embeddings.js.map +1 -1
- package/dist/core/ai/index.d.ts +4 -0
- package/dist/core/ai/index.d.ts.map +1 -1
- package/dist/core/ai/index.js +3 -0
- package/dist/core/ai/index.js.map +1 -1
- package/dist/core/ai/local-app-model.d.ts +15 -4
- package/dist/core/ai/local-app-model.d.ts.map +1 -1
- package/dist/core/ai/local-app-model.js +57 -18
- package/dist/core/ai/local-app-model.js.map +1 -1
- package/dist/core/ai/music-input-wire.d.ts +4 -0
- package/dist/core/ai/music-input-wire.d.ts.map +1 -0
- package/dist/core/ai/music-input-wire.js +9 -0
- package/dist/core/ai/music-input-wire.js.map +1 -0
- package/dist/core/ai/music-input.d.ts +44 -0
- package/dist/core/ai/music-input.d.ts.map +1 -0
- package/dist/core/ai/music-input.js +69 -0
- package/dist/core/ai/music-input.js.map +1 -0
- package/dist/core/ai/reasoning.d.ts +32 -0
- package/dist/core/ai/reasoning.d.ts.map +1 -0
- package/dist/core/ai/reasoning.js +74 -0
- package/dist/core/ai/reasoning.js.map +1 -0
- package/dist/core/ai/runtime-model.d.ts +2 -19
- package/dist/core/ai/runtime-model.d.ts.map +1 -1
- package/dist/core/ai/runtime-model.js +3 -47
- package/dist/core/ai/runtime-model.js.map +1 -1
- package/dist/core/ai/speech-input.d.ts +9 -0
- package/dist/core/ai/speech-input.d.ts.map +1 -0
- package/dist/core/ai/speech-input.js +16 -0
- package/dist/core/ai/speech-input.js.map +1 -0
- package/dist/core/ai/text-runner.js +11 -4
- package/dist/core/ai/text-runner.js.map +1 -1
- package/dist/core/app/desktop-open.d.ts +4 -1
- package/dist/core/app/desktop-open.d.ts.map +1 -1
- package/dist/core/app/desktop-open.js +5 -1
- package/dist/core/app/desktop-open.js.map +1 -1
- package/dist/core/app/index.d.ts +29 -4
- package/dist/core/app/index.d.ts.map +1 -1
- package/dist/core/app/index.js +18 -0
- package/dist/core/app/index.js.map +1 -1
- package/dist/core/app/local-app-agent-introduction.d.ts +30 -0
- package/dist/core/app/local-app-agent-introduction.d.ts.map +1 -0
- package/dist/core/app/local-app-agent-introduction.js +64 -0
- package/dist/core/app/local-app-agent-introduction.js.map +1 -0
- package/dist/core/app/local-app-agent-work-input.d.ts +24 -0
- package/dist/core/app/local-app-agent-work-input.d.ts.map +1 -0
- package/dist/core/app/local-app-agent-work-input.js +50 -0
- package/dist/core/app/local-app-agent-work-input.js.map +1 -0
- package/dist/core/app/local-app-audio-separation.d.ts +9 -0
- package/dist/core/app/local-app-audio-separation.d.ts.map +1 -1
- package/dist/core/app/local-app-audio-separation.js +64 -3
- package/dist/core/app/local-app-audio-separation.js.map +1 -1
- package/dist/core/app/local-app-bytes.d.ts +10 -0
- package/dist/core/app/local-app-bytes.d.ts.map +1 -0
- package/dist/core/app/local-app-bytes.js +27 -0
- package/dist/core/app/local-app-bytes.js.map +1 -0
- package/dist/core/app/local-app-music-transcription.d.ts +43 -0
- package/dist/core/app/local-app-music-transcription.d.ts.map +1 -0
- package/dist/core/app/local-app-music-transcription.js +94 -0
- package/dist/core/app/local-app-music-transcription.js.map +1 -0
- package/dist/core/app/local-app-music.d.ts +50 -0
- package/dist/core/app/local-app-music.d.ts.map +1 -0
- package/dist/core/app/local-app-music.js +135 -0
- package/dist/core/app/local-app-music.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.d.ts +59 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.js +283 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-activity.d.ts +219 -0
- package/dist/core/app/local-app-runtime-platform-activity.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-activity.js +749 -0
- package/dist/core/app/local-app-runtime-platform-activity.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-agent-references.d.ts +4 -0
- package/dist/core/app/local-app-runtime-platform-agent-references.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-agent-references.js +21 -9
- package/dist/core/app/local-app-runtime-platform-agent-references.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-agent-work.d.ts +88 -0
- package/dist/core/app/local-app-runtime-platform-agent-work.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-agent-work.js +165 -0
- package/dist/core/app/local-app-runtime-platform-agent-work.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-ai-config.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai-config.js +55 -1
- package/dist/core/app/local-app-runtime-platform-ai-config.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai.d.ts +154 -36
- package/dist/core/app/local-app-runtime-platform-ai.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai.js +738 -121
- package/dist/core/app/local-app-runtime-platform-ai.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-assets.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-assets.js +37 -12
- package/dist/core/app/local-app-runtime-platform-assets.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-configure.d.ts +1 -1
- package/dist/core/app/local-app-runtime-platform-configure.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-configure.js +10 -10
- package/dist/core/app/local-app-runtime-platform-configure.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-conversation.d.ts +7 -4
- package/dist/core/app/local-app-runtime-platform-conversation.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-conversation.js +15 -10
- package/dist/core/app/local-app-runtime-platform-conversation.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-agent-work.d.ts +5 -0
- package/dist/core/app/local-app-runtime-platform-direct-agent-work.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-direct-agent-work.js +38 -0
- package/dist/core/app/local-app-runtime-platform-direct-agent-work.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-direct-conversation.js +6 -6
- package/dist/core/app/local-app-runtime-platform-direct-conversation.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-integration.d.ts +128 -0
- package/dist/core/app/local-app-runtime-platform-integration.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-integration.js +263 -0
- package/dist/core/app/local-app-runtime-platform-integration.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-validation.d.ts +2 -0
- package/dist/core/app/local-app-runtime-platform-validation.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-validation.js +42 -3
- package/dist/core/app/local-app-runtime-platform-validation.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-vision.d.ts +1 -1
- package/dist/core/app/local-app-runtime-platform-vision.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-vision.js +5 -5
- package/dist/core/app/local-app-runtime-platform-vision.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform.d.ts +19 -15
- package/dist/core/app/local-app-runtime-platform.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform.js +17 -6
- package/dist/core/app/local-app-runtime-platform.js.map +1 -1
- package/dist/core/app/local-app-speaker-embedding.d.ts +6 -0
- package/dist/core/app/local-app-speaker-embedding.d.ts.map +1 -0
- package/dist/core/app/local-app-speaker-embedding.js +14 -0
- package/dist/core/app/local-app-speaker-embedding.js.map +1 -0
- package/dist/core/app/local-app-text-decision.d.ts +114 -0
- package/dist/core/app/local-app-text-decision.d.ts.map +1 -0
- package/dist/core/app/local-app-text-decision.js +444 -0
- package/dist/core/app/local-app-text-decision.js.map +1 -0
- package/dist/core/app/local-app-text.d.ts +7 -1
- package/dist/core/app/local-app-text.d.ts.map +1 -1
- package/dist/core/app/local-app-text.js +16 -15
- package/dist/core/app/local-app-text.js.map +1 -1
- package/dist/core/app/local-app-transcription.d.ts +11 -0
- package/dist/core/app/local-app-transcription.d.ts.map +1 -1
- package/dist/core/app/local-app-transcription.js +22 -2
- package/dist/core/app/local-app-transcription.js.map +1 -1
- package/dist/core/app/local-app-voice-convert.d.ts +61 -0
- package/dist/core/app/local-app-voice-convert.d.ts.map +1 -0
- package/dist/core/app/local-app-voice-convert.js +133 -0
- package/dist/core/app/local-app-voice-convert.js.map +1 -0
- 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 +5 -3
- package/dist/core/app/runtime-account-realm-source-readiness.generated.js.map +1 -1
- package/dist/core/text-stream-cleanup.d.ts +3 -0
- package/dist/core/text-stream-cleanup.d.ts.map +1 -0
- package/dist/core/text-stream-cleanup.js +19 -0
- package/dist/core/text-stream-cleanup.js.map +1 -0
- package/dist/core-generated/realm-client.d.ts.map +1 -1
- package/dist/core-generated/realm-client.js +10 -4
- package/dist/core-generated/realm-client.js.map +1 -1
- package/dist/core-generated/realm-typed-client.d.ts +86 -29
- package/dist/core-generated/realm-typed-client.d.ts.map +1 -1
- package/dist/core-generated/realm-typed-client.js +19 -8
- 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 +312 -0
- package/dist/core-generated/runtime-client.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.d.ts +21 -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 +41 -5
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.d.ts +158 -1
- 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 +299 -2
- 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/agent_work.d.ts +625 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_work.d.ts.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_work.js +1369 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_work.js.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.d.ts +1872 -106
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.js +4718 -1513
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.d.ts +40 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.js +72 -3
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app_activity.d.ts +859 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/app_activity.d.ts.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/app_activity.js +1663 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/app_activity.js.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.d.ts +20 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.js +38 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.d.ts +456 -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 +869 -6
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.d.ts +146 -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 +145 -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 +43 -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 +88 -4
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/development.d.ts +53 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/development.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/development.js +118 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/development.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.d.ts +1293 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.d.ts.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.js +2898 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.js.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.d.ts +166 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.js +217 -4
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.d.ts +8 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.js +9 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.d.ts +69 -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 +120 -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 +296 -8
- 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 +37 -1
- package/dist/core-generated/runtime-public-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.d.ts +44 -5
- package/dist/core-generated/runtime-public-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.js +44 -5
- 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 +39 -0
- package/dist/core-generated/runtime-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-typed-client.d.ts +66 -16
- package/dist/core-generated/runtime-typed-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-typed-client.js +398 -3
- package/dist/core-generated/runtime-typed-client.js.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.d.ts +47 -5
- package/dist/core-generated/runtime-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.js +47 -5
- package/dist/core-generated/runtime-wire-codecs.js.map +1 -1
- package/dist/features/generation/index.d.ts +14 -2
- package/dist/features/generation/index.d.ts.map +1 -1
- package/dist/features/generation/index.js +14 -1
- package/dist/features/generation/index.js.map +1 -1
- package/dist/features/generation/media-params.d.ts +0 -3
- package/dist/features/generation/media-params.d.ts.map +1 -1
- package/dist/features/generation/media-params.js +8 -6
- package/dist/features/generation/media-params.js.map +1 -1
- package/dist/features/generation/runtime-generation-build.d.ts +0 -1
- package/dist/features/generation/runtime-generation-build.d.ts.map +1 -1
- package/dist/features/generation/runtime-generation-build.js +6 -1
- package/dist/features/generation/runtime-generation-build.js.map +1 -1
- package/dist/features/generation/runtime-image-generation.d.ts +5 -1
- package/dist/features/generation/runtime-image-generation.d.ts.map +1 -1
- package/dist/features/generation/runtime-image-generation.js +4 -0
- package/dist/features/generation/runtime-image-generation.js.map +1 -1
- package/dist/features/generation/runtime-job-builders.d.ts +0 -1
- package/dist/features/generation/runtime-job-builders.d.ts.map +1 -1
- package/dist/features/generation/runtime-job-builders.js +8 -10
- package/dist/features/generation/runtime-job-builders.js.map +1 -1
- package/dist/realm/index.d.ts +1 -1
- package/dist/realm/index.d.ts.map +1 -1
- package/dist/realm/index.js +3 -2
- package/dist/realm/index.js.map +1 -1
- package/dist/runtime/chatgpt-plan.d.ts +7 -0
- package/dist/runtime/chatgpt-plan.d.ts.map +1 -0
- package/dist/runtime/chatgpt-plan.js +15 -0
- package/dist/runtime/chatgpt-plan.js.map +1 -0
- package/dist/runtime/config-projections.d.ts +2 -0
- package/dist/runtime/config-projections.d.ts.map +1 -1
- package/dist/runtime/config-projections.js +3 -0
- package/dist/runtime/config-projections.js.map +1 -1
- package/dist/runtime/connector-auth-acquisition-client.d.ts +3 -6
- package/dist/runtime/connector-auth-acquisition-client.d.ts.map +1 -1
- package/dist/runtime/connector-auth-acquisition-client.js +18 -11
- package/dist/runtime/connector-auth-acquisition-client.js.map +1 -1
- package/dist/runtime/connector-auth-acquisition-profiles.generated.d.ts +10 -11
- package/dist/runtime/connector-auth-acquisition-profiles.generated.d.ts.map +1 -1
- package/dist/runtime/connector-auth-acquisition-profiles.generated.js +13 -14
- package/dist/runtime/connector-auth-acquisition-profiles.generated.js.map +1 -1
- package/dist/runtime/connector-auth-acquisition.d.ts +26 -19
- package/dist/runtime/connector-auth-acquisition.d.ts.map +1 -1
- package/dist/runtime/connector-auth-acquisition.js +352 -269
- package/dist/runtime/connector-auth-acquisition.js.map +1 -1
- package/dist/runtime/connector-auth-profiles.generated.d.ts +1 -1
- package/dist/runtime/connector-auth-profiles.generated.d.ts.map +1 -1
- package/dist/runtime/connector-auth-profiles.generated.js +4 -4
- package/dist/runtime/connector-auth-profiles.generated.js.map +1 -1
- package/dist/runtime/connector-inventory.d.ts +11 -2
- package/dist/runtime/connector-inventory.d.ts.map +1 -1
- package/dist/runtime/connector-inventory.js +10 -1
- package/dist/runtime/connector-inventory.js.map +1 -1
- package/dist/runtime/desktop-audit.js +4 -1
- package/dist/runtime/desktop-audit.js.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts +130 -2
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.js +34 -2
- 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/host.d.ts +3 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/host.js +4 -0
- package/dist/runtime/host.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/machine-loadouts.d.ts +18 -0
- package/dist/runtime/machine-loadouts.d.ts.map +1 -1
- package/dist/runtime/machine-loadouts.js +26 -0
- package/dist/runtime/machine-loadouts.js.map +1 -1
- package/dist/runtime/node-grpc-errors.js +3 -3
- package/dist/runtime/node-grpc-errors.js.map +1 -1
- package/dist/runtime/product-control-projection.d.ts.map +1 -1
- package/dist/runtime/product-control-projection.js +11 -2
- package/dist/runtime/product-control-projection.js.map +1 -1
- package/dist/runtime/product-control-types.d.ts +13 -2
- package/dist/runtime/product-control-types.d.ts.map +1 -1
- package/dist/runtime/product-control-types.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 +11 -2
- package/dist/runtime/reason-messages.js.map +1 -1
- package/dist/runtime/runtime-local-environment-client-projections.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client-projections.js +19 -19
- package/dist/runtime/runtime-local-environment-client-projections.js.map +1 -1
- package/dist/runtime/runtime-local-environment-client-types.d.ts +42 -20
- package/dist/runtime/runtime-local-environment-client-types.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client-values.d.ts +3 -1
- package/dist/runtime/runtime-local-environment-client-values.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client-values.js +43 -0
- package/dist/runtime/runtime-local-environment-client-values.js.map +1 -1
- package/dist/runtime/runtime-local-environment-client.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client.js +7 -2
- package/dist/runtime/runtime-local-environment-client.js.map +1 -1
- package/dist/runtime/runtime-local-recommendation-types.d.ts +3 -0
- package/dist/runtime/runtime-local-recommendation-types.d.ts.map +1 -1
- package/dist/runtime/runtime-local-recommendation.d.ts.map +1 -1
- package/dist/runtime/runtime-local-recommendation.js +1 -0
- package/dist/runtime/runtime-local-recommendation.js.map +1 -1
- package/dist/runtime/scenario-jobs.d.ts +23 -1
- package/dist/runtime/scenario-jobs.d.ts.map +1 -1
- package/dist/runtime/scenario-jobs.js +227 -264
- package/dist/runtime/scenario-jobs.js.map +1 -1
- package/dist/runtime/shared-local-agent-ai-config.d.ts.map +1 -1
- package/dist/runtime/shared-local-agent-ai-config.js +3 -0
- package/dist/runtime/shared-local-agent-ai-config.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 +4 -2
- package/dist/runtime/wire-types/agent-participation-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts +112 -3
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.js +128 -0
- package/dist/runtime/wire-types/ai-scenario-enums.js.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-types.d.ts +8 -6
- package/dist/runtime/wire-types/ai-scenario-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/identity-app-enums.d.ts +47 -0
- package/dist/runtime/wire-types/identity-app-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/identity-app-enums.js +55 -0
- package/dist/runtime/wire-types/identity-app-enums.js.map +1 -1
- package/dist/runtime/wire-types/identity-app-types.d.ts +6 -4
- package/dist/runtime/wire-types/identity-app-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/local-memory-enums.d.ts +31 -1
- package/dist/runtime/wire-types/local-memory-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/local-memory-enums.js +34 -0
- package/dist/runtime/wire-types/local-memory-enums.js.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts +28 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.js +27 -0
- package/dist/runtime/wire-types/reason-code-enums.js.map +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +2 -2
- package/dist/types/errors.js.map +1 -1
- package/dist/types/reason-code.d.ts +2 -0
- package/dist/types/reason-code.d.ts.map +1 -1
- package/dist/types/reason-code.js +2 -0
- package/dist/types/reason-code.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
import { AppActivityChangeKind, AppActivityKind, AppActivityOpenCompletion, AppActivityOpenOutcome, AppActivityOpenReason, AppActivitySourceKind, AppActivityTodoState, } from '../../core-generated/runtime-protobuf/runtime/v1/app_activity.js';
|
|
2
|
+
import { validateAgentHandle } from './local-app-runtime-platform-conversation.js';
|
|
3
|
+
import { asRecord, assertExactKeys, assertExactMethodNamespace, assertExactProjectionKeys, assertNoAuthorityMaterial, assertSafeProjection, decimalCursor, localAppError, localAppProjectionError, projectTimestamp, } from './local-app-runtime-platform-validation.js';
|
|
4
|
+
// Contract bounds mirrored from the Runtime App activity owner.
|
|
5
|
+
const MAX_KEY_BYTES = 256;
|
|
6
|
+
const MAX_TITLE_BYTES = 512;
|
|
7
|
+
const MAX_SUMMARY_BYTES = 4096;
|
|
8
|
+
const MAX_DATA_JSON_BYTES = 32 * 1024;
|
|
9
|
+
const MAX_PAGE_SIZE = 100;
|
|
10
|
+
const OBJECT_REF_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:~+=-]{0,255}$/u;
|
|
11
|
+
const ACTIVITY_TYPE_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+\.v[1-9][0-9]{0,5}$/u;
|
|
12
|
+
const RESERVED_RUNTIME_TYPE_PREFIX = 'nimi.runtime.';
|
|
13
|
+
export const NIMI_APP_ACTIVITY_RUNTIME_TURN_TYPE = 'nimi.runtime.agent-conversation.turn-completed.v1';
|
|
14
|
+
export function assertNimiLocalAppActivityShell(value) {
|
|
15
|
+
const record = asRecord(value);
|
|
16
|
+
if (!record || Object.keys(record).sort().join('|') !== ['list', 'markRead', 'open', 'openRequests', 'put', 'subscribe'].join('|')) {
|
|
17
|
+
localAppError('Host-injected local-app standardShell activity namespace is invalid.', 'SDK_LOCAL_APP_CARRIER_REQUIRED', 'use_host_injected_standard_shell');
|
|
18
|
+
}
|
|
19
|
+
for (const method of ['put', 'list', 'subscribe', 'markRead', 'open']) {
|
|
20
|
+
if (typeof record[method] !== 'function') {
|
|
21
|
+
localAppError('Host-injected local-app standardShell activity namespace is invalid.', 'SDK_LOCAL_APP_CARRIER_REQUIRED', 'use_host_injected_standard_shell');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
assertExactMethodNamespace(record.openRequests, ['subscribe', 'complete'], 'activity.openRequests');
|
|
25
|
+
}
|
|
26
|
+
// @nimi-authority: rule.nimi.sdks.feature-clients.r113
|
|
27
|
+
// @nimi-authority: rule.nimi.platform.core-protocol.p-actv-002
|
|
28
|
+
export function createNimiLocalAppActivityClient(shell) {
|
|
29
|
+
assertNimiLocalAppActivityShell(shell);
|
|
30
|
+
return Object.freeze({
|
|
31
|
+
put: async (input) => projectPutResult(await shell.put(validatePutInput(input))),
|
|
32
|
+
list: async (input) => projectPage(await shell.list(validateListInput(input ?? {}))),
|
|
33
|
+
subscribe: async (input) => {
|
|
34
|
+
assertExactKeys(input, ['afterChangeSeq'], 'App activity subscribe input');
|
|
35
|
+
const subscription = await shell.subscribe({ afterChangeSeq: decimalCursor(input.afterChangeSeq, 'afterChangeSeq') });
|
|
36
|
+
const projected = {
|
|
37
|
+
async *[Symbol.asyncIterator]() {
|
|
38
|
+
for await (const event of subscription.events)
|
|
39
|
+
yield projectChange(event);
|
|
40
|
+
},
|
|
41
|
+
cancel: async () => subscription.cancel(),
|
|
42
|
+
};
|
|
43
|
+
return Object.freeze(projected);
|
|
44
|
+
},
|
|
45
|
+
markRead: async (input) => {
|
|
46
|
+
assertExactKeys(input, ['activityId', 'displayedRevision'], 'App activity markRead input');
|
|
47
|
+
return projectRecord(await shell.markRead({
|
|
48
|
+
activityId: activityId(input.activityId),
|
|
49
|
+
displayedRevision: positiveRevision(input.displayedRevision, 'displayedRevision'),
|
|
50
|
+
}));
|
|
51
|
+
},
|
|
52
|
+
open: async (input) => {
|
|
53
|
+
assertExactKeys(input, ['activityId'], 'App activity open input');
|
|
54
|
+
return projectOpenResult(await shell.open({ activityId: activityId(input.activityId) }));
|
|
55
|
+
},
|
|
56
|
+
onOpenRequest: (handler) => registerOpenHandler(shell, handler),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function validatePutInput(input) {
|
|
60
|
+
assertExactKeys(input, [
|
|
61
|
+
'key', 'revision', 'kind', 'todoState', 'attention', 'title', 'summary', 'objectRef', 'type', 'data',
|
|
62
|
+
'occurredAt', 'agentHandle',
|
|
63
|
+
], 'App activity put input');
|
|
64
|
+
assertNoAuthorityMaterial({ ...input, data: undefined });
|
|
65
|
+
const kind = input.kind;
|
|
66
|
+
if (kind !== 'activity' && kind !== 'todo')
|
|
67
|
+
invalidInput('kind');
|
|
68
|
+
if (kind === 'todo') {
|
|
69
|
+
if (!isTodoState(input.todoState))
|
|
70
|
+
invalidInput('todoState');
|
|
71
|
+
if (input.objectRef === undefined)
|
|
72
|
+
invalidInput('objectRef is required for a todo');
|
|
73
|
+
}
|
|
74
|
+
else if (input.todoState !== undefined) {
|
|
75
|
+
invalidInput('todoState is only valid for a todo');
|
|
76
|
+
}
|
|
77
|
+
if (typeof input.attention !== 'boolean')
|
|
78
|
+
invalidInput('attention');
|
|
79
|
+
const payload = {
|
|
80
|
+
key: line(input.key, 'key', MAX_KEY_BYTES),
|
|
81
|
+
revision: positiveRevision(input.revision, 'revision'),
|
|
82
|
+
kind,
|
|
83
|
+
todoState: kind === 'todo' ? input.todoState : null,
|
|
84
|
+
attention: input.attention,
|
|
85
|
+
title: line(input.title, 'title', MAX_TITLE_BYTES),
|
|
86
|
+
summary: input.summary === undefined ? null : text(input.summary, 'summary', MAX_SUMMARY_BYTES),
|
|
87
|
+
objectRef: input.objectRef === undefined ? null : objectRef(input.objectRef),
|
|
88
|
+
type: activityType(input.type),
|
|
89
|
+
dataJson: input.data === undefined ? null : dataJson(input.data),
|
|
90
|
+
occurredAt: occurredAt(input.occurredAt),
|
|
91
|
+
agentHandle: input.agentHandle === undefined ? null : validateAgentHandle(input.agentHandle),
|
|
92
|
+
};
|
|
93
|
+
return payload;
|
|
94
|
+
}
|
|
95
|
+
function validateListInput(input) {
|
|
96
|
+
assertExactKeys(input, ['filter', 'pageSize', 'pageToken'], 'App activity list input');
|
|
97
|
+
const filter = input.filter ?? {};
|
|
98
|
+
assertExactKeys(filter, ['sourceRef', 'kind', 'todoStates', 'agentRef', 'occurredAfter', 'occurredBefore'], 'App activity filter');
|
|
99
|
+
if (filter.kind !== undefined && filter.kind !== 'activity' && filter.kind !== 'todo')
|
|
100
|
+
invalidInput('filter.kind');
|
|
101
|
+
const todoStates = filter.todoStates === undefined ? [] : [...filter.todoStates];
|
|
102
|
+
if (todoStates.some((state) => !isTodoState(state)) || new Set(todoStates).size !== todoStates.length) {
|
|
103
|
+
invalidInput('filter.todoStates');
|
|
104
|
+
}
|
|
105
|
+
const pageSize = input.pageSize ?? 50;
|
|
106
|
+
if (!Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > MAX_PAGE_SIZE)
|
|
107
|
+
invalidInput('pageSize');
|
|
108
|
+
return {
|
|
109
|
+
filter: {
|
|
110
|
+
sourceRef: filter.sourceRef === undefined ? null : prefixedRef(filter.sourceRef, 'src_', 'filter.sourceRef'),
|
|
111
|
+
kind: filter.kind ?? null,
|
|
112
|
+
todoStates,
|
|
113
|
+
agentRef: filter.agentRef === undefined ? null : prefixedRef(filter.agentRef, 'agr_', 'filter.agentRef'),
|
|
114
|
+
occurredAfter: filter.occurredAfter === undefined ? null : isoTimestamp(filter.occurredAfter, 'filter.occurredAfter'),
|
|
115
|
+
occurredBefore: filter.occurredBefore === undefined ? null : isoTimestamp(filter.occurredBefore, 'filter.occurredBefore'),
|
|
116
|
+
},
|
|
117
|
+
pageSize,
|
|
118
|
+
pageToken: input.pageToken === undefined ? null : line(input.pageToken, 'pageToken', 512),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function registerOpenHandler(shell, handler) {
|
|
122
|
+
if (typeof handler !== 'function')
|
|
123
|
+
invalidInput('open handler');
|
|
124
|
+
let stopped = false;
|
|
125
|
+
let current;
|
|
126
|
+
let wake;
|
|
127
|
+
const pause = (ms) => new Promise((resolve) => {
|
|
128
|
+
const timer = setTimeout(resolve, ms);
|
|
129
|
+
wake = () => {
|
|
130
|
+
clearTimeout(timer);
|
|
131
|
+
resolve();
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
const loop = async () => {
|
|
135
|
+
let backoff = 250;
|
|
136
|
+
while (!stopped) {
|
|
137
|
+
try {
|
|
138
|
+
const subscription = await shell.openRequests.subscribe();
|
|
139
|
+
current = subscription;
|
|
140
|
+
if (stopped) {
|
|
141
|
+
await subscription.cancel();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
backoff = 250;
|
|
145
|
+
for await (const raw of subscription.events) {
|
|
146
|
+
const request = projectOpenRequest(raw);
|
|
147
|
+
let completion;
|
|
148
|
+
try {
|
|
149
|
+
completion = await handler(request.request);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// A failed navigation is never confirmed; the consumer receives
|
|
153
|
+
// the Runtime deadline result instead of opened.
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (completion !== 'opened' && completion !== 'object-unavailable')
|
|
157
|
+
continue;
|
|
158
|
+
if (stopped)
|
|
159
|
+
return;
|
|
160
|
+
await shell.openRequests.complete({ deliveryId: request.deliveryId, completion }).catch(() => undefined);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// A new subscription accepts only fresh or never-delivered requests;
|
|
165
|
+
// Runtime cancels requests assigned to a lost source session.
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
current = undefined;
|
|
169
|
+
}
|
|
170
|
+
if (stopped)
|
|
171
|
+
return;
|
|
172
|
+
await pause(backoff);
|
|
173
|
+
backoff = Math.min(backoff * 2, 5_000);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
void loop();
|
|
177
|
+
return Object.freeze({
|
|
178
|
+
stop: async () => {
|
|
179
|
+
stopped = true;
|
|
180
|
+
wake?.();
|
|
181
|
+
await current?.cancel().catch(() => undefined);
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function projectPutResult(value) {
|
|
186
|
+
assertSafeProjection(value);
|
|
187
|
+
const record = asRecord(value);
|
|
188
|
+
assertExactProjectionKeys(record, ['record', 'changed'], 'App activity put result');
|
|
189
|
+
if (typeof record.changed !== 'boolean')
|
|
190
|
+
return localAppProjectionError('App activity put changed');
|
|
191
|
+
return Object.freeze({ record: projectRecord(record.record), changed: record.changed });
|
|
192
|
+
}
|
|
193
|
+
function projectPage(value) {
|
|
194
|
+
assertSafeProjection(value);
|
|
195
|
+
const record = asRecord(value);
|
|
196
|
+
assertExactProjectionKeys(record, ['records', 'nextPageToken', 'baselineChangeSeq'], 'App activity page');
|
|
197
|
+
if (!Array.isArray(record.records) || record.records.length > MAX_PAGE_SIZE) {
|
|
198
|
+
return localAppProjectionError('App activity page records');
|
|
199
|
+
}
|
|
200
|
+
const nextPageToken = record.nextPageToken === null ? null : projectionLine(record.nextPageToken, 'App activity page token', 512);
|
|
201
|
+
return Object.freeze({
|
|
202
|
+
records: Object.freeze(record.records.map(projectRecord)),
|
|
203
|
+
nextPageToken,
|
|
204
|
+
baselineChangeSeq: decimalCursor(record.baselineChangeSeq, 'baselineChangeSeq'),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function projectChange(value) {
|
|
208
|
+
assertSafeProjection(value);
|
|
209
|
+
const record = asRecord(value);
|
|
210
|
+
if (record?.kind === 'remove') {
|
|
211
|
+
assertExactProjectionKeys(record, ['changeSeq', 'kind', 'activityId'], 'App activity remove change');
|
|
212
|
+
return Object.freeze({
|
|
213
|
+
changeSeq: positiveCursor(record.changeSeq, 'changeSeq'),
|
|
214
|
+
kind: 'remove',
|
|
215
|
+
activityId: projectionActivityId(record.activityId),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
assertExactProjectionKeys(record, ['changeSeq', 'kind', 'activityId', 'record'], 'App activity upsert change');
|
|
219
|
+
if (record.kind !== 'upsert')
|
|
220
|
+
return localAppProjectionError('App activity change kind');
|
|
221
|
+
const projected = projectRecord(record.record);
|
|
222
|
+
const changeSeq = positiveCursor(record.changeSeq, 'changeSeq');
|
|
223
|
+
if (projected.activityId !== record.activityId || projected.changeSeq !== changeSeq) {
|
|
224
|
+
return localAppProjectionError('App activity change binding');
|
|
225
|
+
}
|
|
226
|
+
return Object.freeze({ changeSeq, kind: 'upsert', activityId: projected.activityId, record: projected });
|
|
227
|
+
}
|
|
228
|
+
export function projectNimiAppActivityRecord(value) {
|
|
229
|
+
return projectRecord(value);
|
|
230
|
+
}
|
|
231
|
+
function projectRecord(value) {
|
|
232
|
+
const record = asRecord(value);
|
|
233
|
+
assertExactProjectionKeys(record, [
|
|
234
|
+
'activityId', 'source', 'key', 'revision', 'kind', 'todoState', 'attention', 'title', 'summary', 'objectRef',
|
|
235
|
+
'type', 'dataJson', 'agent', 'occurredAt', 'publishedAt', 'updatedAt', 'changeSeq', 'userView',
|
|
236
|
+
], 'App activity record');
|
|
237
|
+
const { dataJson, ...frame } = record;
|
|
238
|
+
assertSafeProjection(frame);
|
|
239
|
+
const kind = record.kind;
|
|
240
|
+
if (kind !== 'activity' && kind !== 'todo')
|
|
241
|
+
return localAppProjectionError('App activity kind');
|
|
242
|
+
const todoState = record.todoState === null ? null : record.todoState;
|
|
243
|
+
if ((kind === 'todo') !== (todoState !== null) || (todoState !== null && !isTodoState(todoState))) {
|
|
244
|
+
return localAppProjectionError('App activity todo state');
|
|
245
|
+
}
|
|
246
|
+
if (typeof record.attention !== 'boolean')
|
|
247
|
+
return localAppProjectionError('App activity attention');
|
|
248
|
+
const revision = projectionRevision(record.revision, 'revision');
|
|
249
|
+
const objectRefValue = record.objectRef === null ? null : projectionObjectRef(record.objectRef);
|
|
250
|
+
if (kind === 'todo' && objectRefValue === null)
|
|
251
|
+
return localAppProjectionError('App activity todo object');
|
|
252
|
+
return Object.freeze({
|
|
253
|
+
activityId: projectionActivityId(record.activityId),
|
|
254
|
+
source: projectSource(record.source),
|
|
255
|
+
key: projectionLine(record.key, 'App activity key', MAX_KEY_BYTES),
|
|
256
|
+
revision,
|
|
257
|
+
kind,
|
|
258
|
+
todoState: todoState,
|
|
259
|
+
attention: record.attention,
|
|
260
|
+
title: projectionLine(record.title, 'App activity title', MAX_TITLE_BYTES),
|
|
261
|
+
summary: record.summary === null ? null : projectionText(record.summary, 'App activity summary', MAX_SUMMARY_BYTES),
|
|
262
|
+
objectRef: objectRefValue,
|
|
263
|
+
type: projectionType(record.type),
|
|
264
|
+
data: dataJson === null ? null : projectData(dataJson),
|
|
265
|
+
agent: record.agent === null ? null : projectAgent(record.agent),
|
|
266
|
+
occurredAt: projectInstant(record.occurredAt, 'occurredAt'),
|
|
267
|
+
publishedAt: projectInstant(record.publishedAt, 'publishedAt'),
|
|
268
|
+
updatedAt: projectInstant(record.updatedAt, 'updatedAt'),
|
|
269
|
+
changeSeq: positiveCursor(record.changeSeq, 'changeSeq'),
|
|
270
|
+
userView: projectUserView(record.userView, revision),
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function projectSource(value) {
|
|
274
|
+
const record = asRecord(value);
|
|
275
|
+
assertExactProjectionKeys(record, ['kind', 'sourceRef', 'appId', 'displayName', 'available'], 'App activity source');
|
|
276
|
+
if (record.kind !== 'app' && record.kind !== 'runtime-agent')
|
|
277
|
+
return localAppProjectionError('App activity source kind');
|
|
278
|
+
if (typeof record.available !== 'boolean')
|
|
279
|
+
return localAppProjectionError('App activity source availability');
|
|
280
|
+
const appId = record.appId === null ? null : projectionLine(record.appId, 'App activity source appId', 160);
|
|
281
|
+
const displayName = record.displayName === null ? null : projectionLine(record.displayName, 'App activity source name', 256);
|
|
282
|
+
if (record.kind === 'runtime-agent' && (appId !== null || displayName !== null)) {
|
|
283
|
+
return localAppProjectionError('App activity Runtime source');
|
|
284
|
+
}
|
|
285
|
+
return Object.freeze({
|
|
286
|
+
kind: record.kind,
|
|
287
|
+
sourceRef: projectionPrefixedRef(record.sourceRef, 'src_', 'App activity sourceRef'),
|
|
288
|
+
appId,
|
|
289
|
+
displayName,
|
|
290
|
+
available: record.available,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
function projectAgent(value) {
|
|
294
|
+
const record = asRecord(value);
|
|
295
|
+
assertExactProjectionKeys(record, ['agentRef', 'displayName'], 'App activity Agent association');
|
|
296
|
+
return Object.freeze({
|
|
297
|
+
agentRef: projectionPrefixedRef(record.agentRef, 'agr_', 'App activity agentRef'),
|
|
298
|
+
displayName: projectionLine(record.displayName, 'App activity Agent name', 256),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function projectUserView(value, revision) {
|
|
302
|
+
const record = asRecord(value);
|
|
303
|
+
assertExactProjectionKeys(record, ['readThroughRevision', 'unread', 'needsAttention'], 'App activity user view');
|
|
304
|
+
const readThroughRevision = record.readThroughRevision;
|
|
305
|
+
if (typeof readThroughRevision !== 'number' || !Number.isSafeInteger(readThroughRevision) || readThroughRevision < 0 ||
|
|
306
|
+
readThroughRevision > revision || typeof record.unread !== 'boolean' || typeof record.needsAttention !== 'boolean' ||
|
|
307
|
+
record.unread !== (revision > readThroughRevision) || (record.needsAttention && !record.unread)) {
|
|
308
|
+
return localAppProjectionError('App activity user view');
|
|
309
|
+
}
|
|
310
|
+
return Object.freeze({ readThroughRevision, unread: record.unread, needsAttention: record.needsAttention });
|
|
311
|
+
}
|
|
312
|
+
function projectOpenResult(value) {
|
|
313
|
+
assertSafeProjection(value);
|
|
314
|
+
const record = asRecord(value);
|
|
315
|
+
assertExactProjectionKeys(record, ['outcome', 'reason'], 'App activity open result');
|
|
316
|
+
const outcome = record.outcome;
|
|
317
|
+
const reason = record.reason;
|
|
318
|
+
const reasons = {
|
|
319
|
+
opened: ['opened'],
|
|
320
|
+
unavailable: ['not-openable', 'activity-unavailable', 'source-unavailable', 'object-unavailable', 'host-unavailable'],
|
|
321
|
+
failed: ['source-not-ready', 'canceled', 'launch-failed'],
|
|
322
|
+
};
|
|
323
|
+
if (typeof outcome !== 'string' || !reasons[outcome] || !reasons[outcome].includes(reason)) {
|
|
324
|
+
return localAppProjectionError('App activity open result');
|
|
325
|
+
}
|
|
326
|
+
return Object.freeze({ outcome: outcome, reason: reason });
|
|
327
|
+
}
|
|
328
|
+
function projectOpenRequest(value) {
|
|
329
|
+
assertSafeProjection(value);
|
|
330
|
+
const record = asRecord(value);
|
|
331
|
+
assertExactProjectionKeys(record, ['deliveryId', 'activityId', 'objectRef', 'type'], 'App activity open request');
|
|
332
|
+
return {
|
|
333
|
+
deliveryId: projectionPrefixedRef(record.deliveryId, 'aod_', 'App activity delivery'),
|
|
334
|
+
request: Object.freeze({
|
|
335
|
+
activityId: projectionActivityId(record.activityId),
|
|
336
|
+
objectRef: projectionObjectRef(record.objectRef),
|
|
337
|
+
type: projectionType(record.type),
|
|
338
|
+
}),
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function projectData(value) {
|
|
342
|
+
if (typeof value !== 'string' || value.length === 0 || new TextEncoder().encode(value).byteLength > MAX_DATA_JSON_BYTES) {
|
|
343
|
+
return localAppProjectionError('App activity data');
|
|
344
|
+
}
|
|
345
|
+
let parsed;
|
|
346
|
+
try {
|
|
347
|
+
parsed = JSON.parse(value);
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
return localAppProjectionError('App activity data');
|
|
351
|
+
}
|
|
352
|
+
if (!asRecord(parsed))
|
|
353
|
+
return localAppProjectionError('App activity data');
|
|
354
|
+
// Publisher data is product content: its keys are not authority fields.
|
|
355
|
+
assertSafeProjection(parsed, new Set(), true);
|
|
356
|
+
return deepFreeze(parsed);
|
|
357
|
+
}
|
|
358
|
+
function deepFreeze(value) {
|
|
359
|
+
if (value && typeof value === 'object') {
|
|
360
|
+
for (const entry of Object.values(value))
|
|
361
|
+
deepFreeze(entry);
|
|
362
|
+
Object.freeze(value);
|
|
363
|
+
}
|
|
364
|
+
return value;
|
|
365
|
+
}
|
|
366
|
+
function projectInstant(value, field) {
|
|
367
|
+
const timestamp = projectTimestamp(value, `App activity ${field}`);
|
|
368
|
+
if (!timestamp)
|
|
369
|
+
return localAppProjectionError(`App activity ${field}`);
|
|
370
|
+
const millis = Number(timestamp.seconds) * 1000 + Math.floor(timestamp.nanos / 1_000_000);
|
|
371
|
+
if (!Number.isSafeInteger(millis))
|
|
372
|
+
return localAppProjectionError(`App activity ${field}`);
|
|
373
|
+
return new Date(millis).toISOString();
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Builds the JSON shell projection from the typed Runtime client. Kit Hosts
|
|
377
|
+
* that reach Runtime through the SDK typed client use this; native carriers
|
|
378
|
+
* produce the identical JSON projection.
|
|
379
|
+
*/
|
|
380
|
+
export function createNimiLocalAppActivityRuntimeShell(runtime, launch) {
|
|
381
|
+
return {
|
|
382
|
+
put: async (input) => {
|
|
383
|
+
const payload = asRecord(input) ?? {};
|
|
384
|
+
const response = await runtime.putAppActivity(runtimePutRequest(payload));
|
|
385
|
+
if (!response.record)
|
|
386
|
+
return localAppProjectionError('Runtime App activity put');
|
|
387
|
+
return { record: runtimeActivityRecordJson(response.record), changed: response.changed };
|
|
388
|
+
},
|
|
389
|
+
list: async (input) => {
|
|
390
|
+
const payload = asRecord(input) ?? {};
|
|
391
|
+
const response = await runtime.listAppActivities(runtimeListRequest(payload));
|
|
392
|
+
return {
|
|
393
|
+
records: response.records.map(runtimeActivityRecordJson),
|
|
394
|
+
nextPageToken: response.nextPageToken || null,
|
|
395
|
+
baselineChangeSeq: response.baselineChangeSeq,
|
|
396
|
+
};
|
|
397
|
+
},
|
|
398
|
+
subscribe: async (input) => {
|
|
399
|
+
const controller = new AbortController();
|
|
400
|
+
const source = runtime.subscribeAppActivityChanges({ afterChangeSeq: input.afterChangeSeq }, { signal: controller.signal });
|
|
401
|
+
return {
|
|
402
|
+
events: (async function* () {
|
|
403
|
+
for await (const change of source)
|
|
404
|
+
yield runtimeActivityChangeJson(change);
|
|
405
|
+
})(),
|
|
406
|
+
cancel: async () => controller.abort(),
|
|
407
|
+
};
|
|
408
|
+
},
|
|
409
|
+
markRead: async (input) => {
|
|
410
|
+
const response = await runtime.markAppActivityRead({
|
|
411
|
+
activityId: input.activityId, displayedRevision: String(input.displayedRevision),
|
|
412
|
+
});
|
|
413
|
+
if (!response.record)
|
|
414
|
+
return localAppProjectionError('Runtime App activity markRead');
|
|
415
|
+
return runtimeActivityRecordJson(response.record);
|
|
416
|
+
},
|
|
417
|
+
open: async (input) => runNimiLocalAppActivityOpen(runtime, launch, input.activityId),
|
|
418
|
+
openRequests: {
|
|
419
|
+
subscribe: async () => {
|
|
420
|
+
const controller = new AbortController();
|
|
421
|
+
const source = runtime.subscribeAppActivityOpenRequests({}, { signal: controller.signal });
|
|
422
|
+
return {
|
|
423
|
+
events: (async function* () {
|
|
424
|
+
for await (const request of source) {
|
|
425
|
+
yield {
|
|
426
|
+
deliveryId: request.deliveryId, activityId: request.activityId,
|
|
427
|
+
objectRef: request.objectRef, type: request.activityType,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
})(),
|
|
431
|
+
cancel: async () => controller.abort(),
|
|
432
|
+
};
|
|
433
|
+
},
|
|
434
|
+
complete: async (input) => {
|
|
435
|
+
const response = await runtime.completeAppActivityOpenRequest({
|
|
436
|
+
deliveryId: input.deliveryId,
|
|
437
|
+
completion: input.completion === 'opened'
|
|
438
|
+
? AppActivityOpenCompletion.OPENED
|
|
439
|
+
: AppActivityOpenCompletion.OBJECT_UNAVAILABLE,
|
|
440
|
+
});
|
|
441
|
+
return { accepted: response.accepted };
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Consumer-side open orchestration shared by typed-client Hosts: the pending
|
|
448
|
+
* event triggers the Desktop launch, and only the Runtime result reports the
|
|
449
|
+
* source App's confirmation.
|
|
450
|
+
*/
|
|
451
|
+
/**
|
|
452
|
+
* After the Desktop launch or focus fails, a source App that is already
|
|
453
|
+
* running may still confirm the object; the Host waits this long for the
|
|
454
|
+
* Runtime result before reporting the launch failure.
|
|
455
|
+
*/
|
|
456
|
+
export const NIMI_APP_ACTIVITY_LAUNCH_FAILURE_GRACE_MS = 5_000;
|
|
457
|
+
export async function runNimiLocalAppActivityOpen(runtime, launch, activityIdValue, launchFailureGraceMs = NIMI_APP_ACTIVITY_LAUNCH_FAILURE_GRACE_MS) {
|
|
458
|
+
const controller = new AbortController();
|
|
459
|
+
const iterator = runtime.openAppActivity({ activityId: activityIdValue }, { signal: controller.signal })[Symbol.asyncIterator]();
|
|
460
|
+
let launchFailure;
|
|
461
|
+
let graceTimer;
|
|
462
|
+
let graceElapsed;
|
|
463
|
+
let launching;
|
|
464
|
+
let pending = iterator.next().then(value => ({ kind: 'stream', value }));
|
|
465
|
+
try {
|
|
466
|
+
while (true) {
|
|
467
|
+
// Keep reading Runtime while Desktop starts the source. A slow launch
|
|
468
|
+
// acknowledgement must not hide the source confirmation or owner deadline.
|
|
469
|
+
const outcome = await Promise.race([pending, ...(launching ? [launching] : []), ...(graceElapsed ? [graceElapsed] : [])]);
|
|
470
|
+
if (outcome.kind === 'grace')
|
|
471
|
+
return launchFailure;
|
|
472
|
+
if (outcome.kind === 'launch') {
|
|
473
|
+
launching = undefined;
|
|
474
|
+
if (outcome.value.status !== 'requested') {
|
|
475
|
+
launchFailure = { outcome: outcome.value.status, reason: outcome.value.reason };
|
|
476
|
+
graceElapsed = new Promise(resolve => {
|
|
477
|
+
graceTimer = setTimeout(() => resolve({ kind: 'grace' }), launchFailureGraceMs);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
const next = outcome.value;
|
|
483
|
+
if (next.done)
|
|
484
|
+
return launchFailure ?? { outcome: 'failed', reason: 'source-not-ready' };
|
|
485
|
+
const event = next.value.event;
|
|
486
|
+
if (event.oneofKind === 'openRequestId') {
|
|
487
|
+
launching = launch(event.openRequestId)
|
|
488
|
+
.catch(() => ({ status: 'failed', reason: 'launch-failed' }))
|
|
489
|
+
.then(value => ({ kind: 'launch', value }));
|
|
490
|
+
pending = iterator.next().then(value => ({ kind: 'stream', value }));
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
if (event.oneofKind === 'result' && event.result)
|
|
494
|
+
return runtimeOpenResultJson(event.result.outcome, event.result.reason);
|
|
495
|
+
return localAppProjectionError('Runtime App activity open event');
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
finally {
|
|
499
|
+
if (graceTimer !== undefined)
|
|
500
|
+
clearTimeout(graceTimer);
|
|
501
|
+
controller.abort();
|
|
502
|
+
pending.catch(() => undefined);
|
|
503
|
+
// Generator cancellation must not delay the already authoritative result.
|
|
504
|
+
void Promise.resolve(iterator.return?.()).catch(() => undefined);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function runtimePutRequest(payload) {
|
|
508
|
+
const kind = payload.kind === 'todo' ? AppActivityKind.TODO : AppActivityKind.ACTIVITY;
|
|
509
|
+
const occurredAt = typeof payload.occurredAt === 'string' ? Date.parse(payload.occurredAt) : Number.NaN;
|
|
510
|
+
if (!Number.isFinite(occurredAt))
|
|
511
|
+
return invalidInput('occurredAt');
|
|
512
|
+
return {
|
|
513
|
+
key: String(payload.key ?? ''),
|
|
514
|
+
revision: String(payload.revision ?? '0'),
|
|
515
|
+
kind,
|
|
516
|
+
todoState: todoStateEnum(payload.todoState),
|
|
517
|
+
attention: payload.attention === true,
|
|
518
|
+
title: String(payload.title ?? ''),
|
|
519
|
+
summary: typeof payload.summary === 'string' ? payload.summary : '',
|
|
520
|
+
objectRef: typeof payload.objectRef === 'string' ? payload.objectRef : '',
|
|
521
|
+
activityType: String(payload.type ?? ''),
|
|
522
|
+
dataJson: typeof payload.dataJson === 'string' ? payload.dataJson : '',
|
|
523
|
+
occurredAt: { seconds: String(Math.floor(occurredAt / 1000)), nanos: (occurredAt % 1000) * 1_000_000 },
|
|
524
|
+
agentHandle: typeof payload.agentHandle === 'string' ? payload.agentHandle : '',
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
function runtimeListRequest(payload) {
|
|
528
|
+
const filter = asRecord(payload.filter) ?? {};
|
|
529
|
+
const timestamp = (value) => {
|
|
530
|
+
if (typeof value !== 'string')
|
|
531
|
+
return undefined;
|
|
532
|
+
const millis = Date.parse(value);
|
|
533
|
+
return Number.isFinite(millis) ? { seconds: String(Math.floor(millis / 1000)), nanos: (millis % 1000) * 1_000_000 } : undefined;
|
|
534
|
+
};
|
|
535
|
+
return {
|
|
536
|
+
filter: {
|
|
537
|
+
sourceRef: typeof filter.sourceRef === 'string' ? filter.sourceRef : '',
|
|
538
|
+
kind: filter.kind === 'todo' ? AppActivityKind.TODO : filter.kind === 'activity' ? AppActivityKind.ACTIVITY : AppActivityKind.UNSPECIFIED,
|
|
539
|
+
todoStates: Array.isArray(filter.todoStates) ? filter.todoStates.map(todoStateEnum) : [],
|
|
540
|
+
agentRef: typeof filter.agentRef === 'string' ? filter.agentRef : '',
|
|
541
|
+
occurredAfter: timestamp(filter.occurredAfter),
|
|
542
|
+
occurredBefore: timestamp(filter.occurredBefore),
|
|
543
|
+
},
|
|
544
|
+
pageSize: typeof payload.pageSize === 'number' ? payload.pageSize : 0,
|
|
545
|
+
pageToken: typeof payload.pageToken === 'string' ? payload.pageToken : '',
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function todoStateEnum(value) {
|
|
549
|
+
switch (value) {
|
|
550
|
+
case 'open': return AppActivityTodoState.OPEN;
|
|
551
|
+
case 'completed': return AppActivityTodoState.COMPLETED;
|
|
552
|
+
case 'cancelled': return AppActivityTodoState.CANCELLED;
|
|
553
|
+
default: return AppActivityTodoState.UNSPECIFIED;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
/** Converts one Runtime record into the shared JSON shell projection. */
|
|
557
|
+
export function runtimeActivityRecordJson(record) {
|
|
558
|
+
const source = record.source;
|
|
559
|
+
const todoStates = {
|
|
560
|
+
[AppActivityTodoState.OPEN]: 'open',
|
|
561
|
+
[AppActivityTodoState.COMPLETED]: 'completed',
|
|
562
|
+
[AppActivityTodoState.CANCELLED]: 'cancelled',
|
|
563
|
+
};
|
|
564
|
+
const timestamp = (value) => (value ? { seconds: value.seconds, nanos: value.nanos } : null);
|
|
565
|
+
return {
|
|
566
|
+
activityId: record.activityId,
|
|
567
|
+
source: source ? {
|
|
568
|
+
kind: source.kind === AppActivitySourceKind.RUNTIME_AGENT ? 'runtime-agent' : source.kind === AppActivitySourceKind.APP ? 'app' : 'unknown',
|
|
569
|
+
sourceRef: source.sourceRef,
|
|
570
|
+
appId: source.appId || null,
|
|
571
|
+
displayName: source.displayName || null,
|
|
572
|
+
available: source.available,
|
|
573
|
+
} : null,
|
|
574
|
+
key: record.key,
|
|
575
|
+
revision: Number(record.revision),
|
|
576
|
+
kind: record.kind === AppActivityKind.TODO ? 'todo' : record.kind === AppActivityKind.ACTIVITY ? 'activity' : 'unknown',
|
|
577
|
+
todoState: todoStates[record.todoState] ?? null,
|
|
578
|
+
attention: record.attention,
|
|
579
|
+
title: record.title,
|
|
580
|
+
summary: record.summary || null,
|
|
581
|
+
objectRef: record.objectRef || null,
|
|
582
|
+
type: record.activityType,
|
|
583
|
+
dataJson: record.dataJson || null,
|
|
584
|
+
agent: record.agent ? { agentRef: record.agent.agentRef, displayName: record.agent.displayName } : null,
|
|
585
|
+
occurredAt: timestamp(record.occurredAt),
|
|
586
|
+
publishedAt: timestamp(record.publishedAt),
|
|
587
|
+
updatedAt: timestamp(record.updatedAt),
|
|
588
|
+
changeSeq: record.changeSeq,
|
|
589
|
+
userView: {
|
|
590
|
+
readThroughRevision: Number(record.userView?.readThroughRevision ?? '0'),
|
|
591
|
+
unread: record.userView?.unread ?? false,
|
|
592
|
+
needsAttention: record.userView?.needsAttention ?? false,
|
|
593
|
+
},
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
export function runtimeActivityChangeJson(change) {
|
|
597
|
+
if (change.kind === AppActivityChangeKind.REMOVE) {
|
|
598
|
+
return { changeSeq: change.changeSeq, kind: 'remove', activityId: change.activityId };
|
|
599
|
+
}
|
|
600
|
+
if (change.kind !== AppActivityChangeKind.UPSERT || !change.record) {
|
|
601
|
+
return localAppProjectionError('Runtime App activity change');
|
|
602
|
+
}
|
|
603
|
+
return {
|
|
604
|
+
changeSeq: change.changeSeq, kind: 'upsert', activityId: change.activityId,
|
|
605
|
+
record: runtimeActivityRecordJson(change.record),
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
export function runtimeOpenResultJson(outcome, reason) {
|
|
609
|
+
const outcomes = {
|
|
610
|
+
[AppActivityOpenOutcome.OPENED]: 'opened',
|
|
611
|
+
[AppActivityOpenOutcome.UNAVAILABLE]: 'unavailable',
|
|
612
|
+
[AppActivityOpenOutcome.FAILED]: 'failed',
|
|
613
|
+
};
|
|
614
|
+
const reasons = {
|
|
615
|
+
[AppActivityOpenReason.OPENED]: 'opened',
|
|
616
|
+
[AppActivityOpenReason.NOT_OPENABLE]: 'not-openable',
|
|
617
|
+
[AppActivityOpenReason.SOURCE_UNAVAILABLE]: 'source-unavailable',
|
|
618
|
+
[AppActivityOpenReason.OBJECT_UNAVAILABLE]: 'object-unavailable',
|
|
619
|
+
[AppActivityOpenReason.SOURCE_NOT_READY]: 'source-not-ready',
|
|
620
|
+
[AppActivityOpenReason.CANCELED]: 'canceled',
|
|
621
|
+
[AppActivityOpenReason.ACTIVITY_UNAVAILABLE]: 'activity-unavailable',
|
|
622
|
+
};
|
|
623
|
+
const outcomeText = outcomes[outcome];
|
|
624
|
+
const reasonText = reasons[reason];
|
|
625
|
+
if (!outcomeText || !reasonText)
|
|
626
|
+
return localAppProjectionError('Runtime App activity open result');
|
|
627
|
+
return { outcome: outcomeText, reason: reasonText };
|
|
628
|
+
}
|
|
629
|
+
// ----- validation helpers -----
|
|
630
|
+
function invalidInput(field) {
|
|
631
|
+
return localAppError(`App activity input is invalid: ${field}.`, 'SDK_LOCAL_APP_INPUT_INVALID', 'provide_valid_app_activity_input');
|
|
632
|
+
}
|
|
633
|
+
function byteLength(value) {
|
|
634
|
+
return new TextEncoder().encode(value).byteLength;
|
|
635
|
+
}
|
|
636
|
+
function line(value, field, maxBytes) {
|
|
637
|
+
if (typeof value !== 'string' || value.length === 0 || value !== value.trim() || byteLength(value) > maxBytes ||
|
|
638
|
+
/[\u0000-\u001f\u007f]/u.test(value))
|
|
639
|
+
invalidInput(field);
|
|
640
|
+
return value;
|
|
641
|
+
}
|
|
642
|
+
function text(value, field, maxBytes) {
|
|
643
|
+
if (typeof value !== 'string' || value.length === 0 || value !== value.trim() || byteLength(value) > maxBytes ||
|
|
644
|
+
/[\u0000-\u0008\u000b-\u001f\u007f]/u.test(value))
|
|
645
|
+
invalidInput(field);
|
|
646
|
+
return value;
|
|
647
|
+
}
|
|
648
|
+
function projectionLine(value, field, maxBytes) {
|
|
649
|
+
if (typeof value !== 'string' || value.length === 0 || value !== value.trim() || byteLength(value) > maxBytes ||
|
|
650
|
+
/[\u0000-\u001f\u007f]/u.test(value))
|
|
651
|
+
return localAppProjectionError(field);
|
|
652
|
+
return value;
|
|
653
|
+
}
|
|
654
|
+
function projectionText(value, field, maxBytes) {
|
|
655
|
+
if (typeof value !== 'string' || value.length === 0 || value !== value.trim() || byteLength(value) > maxBytes ||
|
|
656
|
+
/[\u0000-\u0008\u000b-\u001f\u007f]/u.test(value))
|
|
657
|
+
return localAppProjectionError(field);
|
|
658
|
+
return value;
|
|
659
|
+
}
|
|
660
|
+
function positiveRevision(value, field) {
|
|
661
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1)
|
|
662
|
+
invalidInput(field);
|
|
663
|
+
return value;
|
|
664
|
+
}
|
|
665
|
+
function projectionRevision(value, field) {
|
|
666
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1)
|
|
667
|
+
return localAppProjectionError(`App activity ${field}`);
|
|
668
|
+
return value;
|
|
669
|
+
}
|
|
670
|
+
function positiveCursor(value, field) {
|
|
671
|
+
const cursor = decimalCursor(value, field);
|
|
672
|
+
if (cursor === '0')
|
|
673
|
+
return localAppProjectionError(field);
|
|
674
|
+
return cursor;
|
|
675
|
+
}
|
|
676
|
+
function isTodoState(value) {
|
|
677
|
+
return value === 'open' || value === 'completed' || value === 'cancelled';
|
|
678
|
+
}
|
|
679
|
+
function objectRef(value) {
|
|
680
|
+
if (typeof value !== 'string' || !OBJECT_REF_PATTERN.test(value))
|
|
681
|
+
invalidInput('objectRef');
|
|
682
|
+
return value;
|
|
683
|
+
}
|
|
684
|
+
function projectionObjectRef(value) {
|
|
685
|
+
if (typeof value !== 'string' || !OBJECT_REF_PATTERN.test(value))
|
|
686
|
+
return localAppProjectionError('App activity objectRef');
|
|
687
|
+
return value;
|
|
688
|
+
}
|
|
689
|
+
function activityType(value) {
|
|
690
|
+
if (typeof value !== 'string' || value.length > 128 || !ACTIVITY_TYPE_PATTERN.test(value) ||
|
|
691
|
+
value.startsWith(RESERVED_RUNTIME_TYPE_PREFIX))
|
|
692
|
+
invalidInput('type');
|
|
693
|
+
return value;
|
|
694
|
+
}
|
|
695
|
+
function projectionType(value) {
|
|
696
|
+
if (typeof value !== 'string' || value.length > 128 || !ACTIVITY_TYPE_PATTERN.test(value)) {
|
|
697
|
+
return localAppProjectionError('App activity type');
|
|
698
|
+
}
|
|
699
|
+
return value;
|
|
700
|
+
}
|
|
701
|
+
function dataJson(value) {
|
|
702
|
+
if (!asRecord(value))
|
|
703
|
+
invalidInput('data must be a plain JSON object');
|
|
704
|
+
let encoded;
|
|
705
|
+
try {
|
|
706
|
+
encoded = JSON.stringify(value);
|
|
707
|
+
}
|
|
708
|
+
catch {
|
|
709
|
+
return invalidInput('data');
|
|
710
|
+
}
|
|
711
|
+
if (byteLength(encoded) > MAX_DATA_JSON_BYTES)
|
|
712
|
+
invalidInput('data exceeds 32 KiB');
|
|
713
|
+
return encoded;
|
|
714
|
+
}
|
|
715
|
+
function occurredAt(value) {
|
|
716
|
+
const millis = value instanceof Date ? value.getTime() : typeof value === 'string' ? Date.parse(value) : Number.NaN;
|
|
717
|
+
if (!Number.isFinite(millis))
|
|
718
|
+
invalidInput('occurredAt');
|
|
719
|
+
return new Date(millis).toISOString();
|
|
720
|
+
}
|
|
721
|
+
function isoTimestamp(value, field) {
|
|
722
|
+
const millis = typeof value === 'string' ? Date.parse(value) : Number.NaN;
|
|
723
|
+
if (!Number.isFinite(millis))
|
|
724
|
+
invalidInput(field);
|
|
725
|
+
return new Date(millis).toISOString();
|
|
726
|
+
}
|
|
727
|
+
function prefixedRef(value, prefix, field) {
|
|
728
|
+
if (typeof value !== 'string' || !value.startsWith(prefix) || value.length > 64 || !/^[A-Za-z0-9_-]+$/u.test(value)) {
|
|
729
|
+
invalidInput(field);
|
|
730
|
+
}
|
|
731
|
+
return value;
|
|
732
|
+
}
|
|
733
|
+
function projectionPrefixedRef(value, prefix, field) {
|
|
734
|
+
if (typeof value !== 'string' || !value.startsWith(prefix) || value.length > 64 || !/^[A-Za-z0-9_-]+$/u.test(value)) {
|
|
735
|
+
return localAppProjectionError(field);
|
|
736
|
+
}
|
|
737
|
+
return value;
|
|
738
|
+
}
|
|
739
|
+
function activityId(value) {
|
|
740
|
+
if (typeof value !== 'string' || !/^act_[0-9A-Z]{26}$/u.test(value))
|
|
741
|
+
invalidInput('activityId');
|
|
742
|
+
return value;
|
|
743
|
+
}
|
|
744
|
+
function projectionActivityId(value) {
|
|
745
|
+
if (typeof value !== 'string' || !/^act_[0-9A-Z]{26}$/u.test(value))
|
|
746
|
+
return localAppProjectionError('App activity activityId');
|
|
747
|
+
return value;
|
|
748
|
+
}
|
|
749
|
+
//# sourceMappingURL=local-app-runtime-platform-activity.js.map
|