lumiverse-spindle-types 0.6.44 → 0.6.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -3333,7 +3333,7 @@ export interface ProviderManager {
3333
3333
  key: ProviderKeyDTO;
3334
3334
  }) => void): () => void;
3335
3335
  }
3336
- export type WorkerToHost = import("./file-transfers.js").FileTransferWorkerMessage | import("./desktop-capture.js").DesktopCaptureWorkerMessage | {
3336
+ export type WorkerToHost = import("./decisions.js").DecisionWorkerMessage | import("./file-transfers.js").FileTransferWorkerMessage | import("./desktop-capture.js").DesktopCaptureWorkerMessage | {
3337
3337
  type: "subscribe_event";
3338
3338
  event: string;
3339
3339
  } | {
@@ -0,0 +1,143 @@
1
+ /** Native typed Decision API. Requires decisions permission and decisions-v1 host capability. */
2
+ export type DecisionJsonValue = null | boolean | number | string | DecisionJsonValue[] | {
3
+ [key: string]: DecisionJsonValue;
4
+ };
5
+ export type DecisionDescription = string | DecisionJsonValue[] | {
6
+ [key: string]: DecisionJsonValue;
7
+ };
8
+ export type DecisionState = DecisionDescription;
9
+ export type DecisionQuestion = {
10
+ type: "choice";
11
+ instructions: DecisionDescription;
12
+ criteria: Record<string, DecisionDescription | null>;
13
+ } | {
14
+ type: "score";
15
+ instructions: DecisionDescription;
16
+ criteria: DecisionDescription[];
17
+ } | {
18
+ type: "noul";
19
+ instructions: DecisionDescription;
20
+ criteria?: {
21
+ true: DecisionDescription;
22
+ false: DecisionDescription;
23
+ };
24
+ };
25
+ export type DecisionAnswer = {
26
+ type: "choice";
27
+ choice: string;
28
+ probabilities: Record<string, number>;
29
+ confidence: number;
30
+ } | {
31
+ type: "score";
32
+ score: number;
33
+ probabilities: Record<string, number>;
34
+ confidence: number;
35
+ legend: Record<string, DecisionDescription>;
36
+ } | {
37
+ type: "noul";
38
+ noul: number;
39
+ };
40
+ export type DecisionAnswerFor<Q extends DecisionQuestion> = Q extends {
41
+ type: "choice";
42
+ criteria: infer C;
43
+ } ? Omit<Extract<DecisionAnswer, {
44
+ type: "choice";
45
+ }>, "choice" | "probabilities"> & {
46
+ choice: Extract<keyof C, string>;
47
+ probabilities: Record<Extract<keyof C, string>, number>;
48
+ } : Q extends {
49
+ type: "score";
50
+ } ? Extract<DecisionAnswer, {
51
+ type: "score";
52
+ }> : Extract<DecisionAnswer, {
53
+ type: "noul";
54
+ }>;
55
+ export type DecisionAnswers<Q extends Record<string, DecisionQuestion>> = {
56
+ [K in keyof Q]: DecisionAnswerFor<Q[K]>;
57
+ };
58
+ export interface DecisionResult<Q extends Record<string, DecisionQuestion> = Record<string, DecisionQuestion>> {
59
+ model: string;
60
+ answers: DecisionAnswers<Q>;
61
+ usage?: {
62
+ input_tokens?: number | null;
63
+ output_tokens?: number | null;
64
+ cost?: number | null;
65
+ [key: string]: unknown;
66
+ };
67
+ id?: string;
68
+ provider?: string;
69
+ }
70
+ export interface DecisionEvaluationInput<Q extends Record<string, DecisionQuestion> = Record<string, DecisionQuestion>> {
71
+ connection_id?: string;
72
+ model?: string;
73
+ state: DecisionState;
74
+ questions: Q;
75
+ userId?: string;
76
+ }
77
+ export interface DecisionConnectionProfileDTO {
78
+ id: string;
79
+ name: string;
80
+ provider: string;
81
+ api_url: string;
82
+ model: string;
83
+ is_default: boolean;
84
+ has_api_key: boolean;
85
+ default_parameters: Record<string, unknown>;
86
+ metadata: Record<string, unknown>;
87
+ created_at: number;
88
+ updated_at: number;
89
+ }
90
+ export interface DecisionModelDTO {
91
+ id: string;
92
+ label: string;
93
+ description?: string;
94
+ input_modalities?: string[];
95
+ output_modalities?: string[];
96
+ context_length?: number;
97
+ pricing?: Record<string, string>;
98
+ protocol: "supported" | "unsupported" | "unverified";
99
+ }
100
+ export interface DecisionProviderDTO {
101
+ id: string;
102
+ name: string;
103
+ capabilities: {
104
+ apiKeyRequired: boolean;
105
+ defaultUrl: string;
106
+ suggestedModel: string;
107
+ modelListStyle: "dynamic";
108
+ };
109
+ }
110
+ export interface SpindleDecisionsAPI {
111
+ listProviders(options?: {
112
+ userId?: string;
113
+ }): Promise<DecisionProviderDTO[]>;
114
+ listConnections(options?: {
115
+ userId?: string;
116
+ }): Promise<DecisionConnectionProfileDTO[]>;
117
+ getConnection(id: string, options?: {
118
+ userId?: string;
119
+ }): Promise<DecisionConnectionProfileDTO | null>;
120
+ getModels(id: string, options?: {
121
+ userId?: string;
122
+ }): Promise<DecisionModelDTO[]>;
123
+ evaluate<const Q extends Record<string, DecisionQuestion>>(input: DecisionEvaluationInput<Q>, options?: {
124
+ signal?: AbortSignal;
125
+ }): Promise<DecisionResult<Q>>;
126
+ }
127
+ export type DecisionWorkerMessage = {
128
+ type: "decisions_providers" | "decisions_connections_list";
129
+ requestId: string;
130
+ userId?: string;
131
+ } | {
132
+ type: "decisions_connection_get" | "decisions_models";
133
+ requestId: string;
134
+ connectionId: string;
135
+ userId?: string;
136
+ } | {
137
+ type: "decisions_evaluate";
138
+ requestId: string;
139
+ input: DecisionEvaluationInput;
140
+ } | {
141
+ type: "decisions_cancel";
142
+ requestId: string;
143
+ };
@@ -0,0 +1 @@
1
+ export {};
package/dist/host.js CHANGED
@@ -11,6 +11,7 @@ export const SPINDLE_HOST_CAPABILITIES = Object.freeze({
11
11
  "frontend-extensibility-v2": 1,
12
12
  "frontend-runtime-capabilities-v1": 1,
13
13
  "mcp-servers-v1": 1,
14
+ "decisions-v1": 1,
14
15
  "file-transfers-v1": 1,
15
16
  });
16
17
  /** Structured error code returned when host compatibility validation fails. */
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export type { DecisionJsonValue, DecisionDescription, DecisionState, DecisionQuestion, DecisionAnswer, DecisionAnswerFor, DecisionAnswers, DecisionResult, DecisionEvaluationInput, DecisionConnectionProfileDTO, DecisionModelDTO, DecisionProviderDTO, SpindleDecisionsAPI, DecisionWorkerMessage } from "./decisions.js";
1
2
  export type { SpindleManifest, SpindlePermission, SpindleCapability, } from "./manifest.js";
2
3
  export { IDENTIFIER_PATTERN, validateIdentifier, } from "./manifest.js";
3
4
  export type { SpindleHostDescriptorV1, SpindleHostLocale, SpindleHostLocaleAPI, } from "./host.js";
@@ -27,5 +28,5 @@ export type { CouncilMember, CouncilMemberContext, SidecarConfig, CouncilSidecar
27
28
  export { SIDECAR_DEFAULTS, COUNCIL_SIDECAR_DEFAULTS, COUNCIL_TOOLS_DEFAULTS, COUNCIL_SETTINGS_DEFAULTS, } from "./council.js";
28
29
  export type { SpindleSTTProvider, SpindleSTTProviderOption, SpindleSTTStatus, SpindleSTTResult, SpindleSTTAudioFrame, SpindleSTTTranscript, SpindleSTTPcmAudio, SpindleSTTOptions, SpindleSTTStartOptions, SpindleSTTSession, SpindleSTTAPI, } from "./speech-to-text.js";
29
30
  export { SPINDLE_STT_HOST_CAPABILITIES } from "./speech-to-text.js";
30
- export type { SpindleSystemAudioUnavailableReason, SpindleSystemAudioAvailability, SpindleSystemAudioFrame, SpindleSystemAudioEndReason, SpindleSystemAudioStartOptions, SpindleSystemAudioSession, SpindleSystemAudioAPI, } from "./system-audio.js";
31
+ export type { SpindleSystemAudioUnavailableReason, SpindleSystemAudioAvailability, SpindleSystemAudioFrame, SpindleSystemAudioChannelFrame, SpindleSystemAudioEndReason, SpindleSystemAudioStartOptions, SpindleSystemAudioSession, SpindleSystemAudioAPI, } from "./system-audio.js";
31
32
  export { SPINDLE_SYSTEM_AUDIO_HOST_CAPABILITIES } from "./system-audio.js";
@@ -4,6 +4,7 @@
4
4
  * Free tier (no declaration needed): events, storage, macros, dom, variables
5
5
  *
6
6
  * Gated tier (must declare):
7
+ * - "decisions" — inspect and invoke saved Decision model connections
7
8
  * - "generation" — fire generations on behalf of user
8
9
  * - "interceptor" — pre-generation prompt modification
9
10
  * - "tools" — register LLM tools
@@ -41,6 +42,6 @@
41
42
  * device is playing (never samples), desktop client only. Privileged;
42
43
  * the host asks the user on every start.
43
44
  */
44
- export type SpindlePermission = "screen_capture" | "screen_recording" | "system_audio" | "generation" | "interceptor" | "tools" | "cors_proxy" | "context_handler" | "ephemeral_storage" | "chat_mutation" | "event_tracking" | "ui_panels" | "app_manipulation" | "oauth" | "characters" | "chats" | "presets" | "world_books" | "regex_scripts" | "regex_scripts_unrestricted" | "databanks" | "memories" | "media" | "personas" | "push_notification" | "image_gen" | "images" | "generation_parameters" | "macro_interceptor" | "web_search" | "unsafe_eval" | "final_response" | "providers.embedding.register" | "providers.tts.register" | "providers.stt.register" | "providers.sidecar.register" | "mcp_servers" | "mcp_servers.create";
45
+ export type SpindlePermission = "screen_capture" | "screen_recording" | "system_audio" | "generation" | "interceptor" | "tools" | "cors_proxy" | "context_handler" | "ephemeral_storage" | "chat_mutation" | "event_tracking" | "ui_panels" | "app_manipulation" | "oauth" | "characters" | "chats" | "presets" | "world_books" | "regex_scripts" | "regex_scripts_unrestricted" | "databanks" | "memories" | "media" | "personas" | "push_notification" | "decisions" | "image_gen" | "images" | "generation_parameters" | "macro_interceptor" | "web_search" | "unsafe_eval" | "final_response" | "providers.embedding.register" | "providers.tts.register" | "providers.stt.register" | "providers.sidecar.register" | "mcp_servers" | "mcp_servers.create";
45
46
  export declare const ALL_PERMISSIONS: readonly SpindlePermission[];
46
47
  export declare function isValidPermission(p: string): p is SpindlePermission;
@@ -24,6 +24,7 @@ export const ALL_PERMISSIONS = [
24
24
  "media",
25
25
  "personas",
26
26
  "push_notification",
27
+ "decisions",
27
28
  "image_gen",
28
29
  "images",
29
30
  "generation_parameters",
@@ -134,6 +134,8 @@ export interface SpindleConnectionsAPI {
134
134
  }
135
135
  /** The global `spindle` object available in backend extension workers */
136
136
  export interface SpindleAPI {
137
+ /** Typed Decision models (permission: decisions; host capability: decisions-v1). */
138
+ decisions: import("./decisions.js").SpindleDecisionsAPI;
137
139
  /** Disk-backed downloads and bounded reads/writes. Available with file-transfers-v1. */
138
140
  readonly files: SpindleFilesAPI;
139
141
  /** Streaming ZIP64 creation and validated disk-backed extraction. */
@@ -14,9 +14,11 @@ export type SpindleSystemAudioUnavailableReason =
14
14
  export interface SpindleSystemAudioAvailability {
15
15
  available: boolean;
16
16
  unavailableReason?: SpindleSystemAudioUnavailableReason;
17
+ /** The native adapter supports stereo analysis. Missing means an older or unsupported client. */
18
+ stereoSupported?: boolean;
17
19
  }
18
- /** One analysis frame. Every number is normalised to 0 – 1. */
19
- export interface SpindleSystemAudioFrame {
20
+ /** One channel's analysis. Every number is normalised to 0 – 1. */
21
+ export interface SpindleSystemAudioChannelFrame {
20
22
  /** Overall level (RMS). */
21
23
  amplitude: number;
22
24
  /** Loudest recent level. */
@@ -24,6 +26,13 @@ export interface SpindleSystemAudioFrame {
24
26
  /** `bands` log-spaced magnitudes from about 40 Hz up to about 14 kHz, lowest first. */
25
27
  frequencies: number[];
26
28
  }
29
+ /** Combined analysis, with optional independent channels when stereo was requested. Never contains samples. */
30
+ export interface SpindleSystemAudioFrame extends SpindleSystemAudioChannelFrame {
31
+ stereo?: {
32
+ left: SpindleSystemAudioChannelFrame;
33
+ right: SpindleSystemAudioChannelFrame;
34
+ };
35
+ }
27
36
  /** Why a session ended without the extension calling `stop()`. */
28
37
  export type SpindleSystemAudioEndReason = 'revoked' | 'user-stopped' | 'source-lost' | 'host-disabled';
29
38
  export interface SpindleSystemAudioStartOptions {
@@ -31,6 +40,8 @@ export interface SpindleSystemAudioStartOptions {
31
40
  bands?: number;
32
41
  /** Most frames per second, 1 – 30 (default 30). The host clamps out-of-range values. */
33
42
  maxFps?: number;
43
+ /** Add independent left/right analysis. Default false. Requires stereoSupported; otherwise ready rejects with NotSupportedError. */
44
+ stereo?: boolean;
34
45
  signal?: AbortSignal;
35
46
  onFrame(frame: SpindleSystemAudioFrame): void;
36
47
  /** Called once if the host ends the session (permission revoked, the user pressed Stop on the host's indicator, the device went away). */
@@ -38,7 +49,7 @@ export interface SpindleSystemAudioStartOptions {
38
49
  }
39
50
  export interface SpindleSystemAudioSession {
40
51
  /**
41
- * Resolves when the user has approved the host's prompt and analysis has begun. Rejects with a `NotAllowedError`
52
+ * Resolves when the host has verified explicit or remembered approval and analysis has begun. Rejects with a `NotAllowedError`
42
53
  * `DOMException` if the user declines, `NotSupportedError` if unavailable, and `AbortError` if cancelled first.
43
54
  */
44
55
  readonly ready: Promise<void>;
@@ -50,11 +61,12 @@ export interface SpindleSystemAudioAPI {
50
61
  /** Free. Never prompts, and never opens anything. */
51
62
  isAvailable(): SpindleSystemAudioAvailability;
52
63
  /**
53
- * Requires `system_audio`. Call directly from a user gesture. The host asks the user for approval on every
54
- * start and shows an indicator for as long as analysis runs. One session per extension at a time.
64
+ * Requires `system_audio`. Call the first start from a user gesture. The host checks explicit or remembered
65
+ * approval and shows an indicator for as long as analysis runs. One session per extension at a time.
55
66
  */
56
67
  start(options: SpindleSystemAudioStartOptions): SpindleSystemAudioSession;
57
68
  }
58
69
  export declare const SPINDLE_SYSTEM_AUDIO_HOST_CAPABILITIES: Readonly<{
59
70
  'system-audio-v1': 1;
71
+ 'system-audio-stereo-v1': 1;
60
72
  }>;
@@ -5,4 +5,4 @@
5
5
  * `MediaStream`, or anything else from which what was played could be reconstructed. Available only where the host
6
6
  * has a native adapter (the desktop client); feature-detect `system-audio-v1` and call `isAvailable()`.
7
7
  */
8
- export const SPINDLE_SYSTEM_AUDIO_HOST_CAPABILITIES = Object.freeze({ 'system-audio-v1': 1 });
8
+ export const SPINDLE_SYSTEM_AUDIO_HOST_CAPABILITIES = Object.freeze({ 'system-audio-v1': 1, 'system-audio-stereo-v1': 1 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.6.44",
3
+ "version": "0.6.46",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "keywords": [
@@ -26,6 +26,7 @@
26
26
  }
27
27
  },
28
28
  "scripts": {
29
+ "prepack": "npm run build",
29
30
  "build": "tsc -p tsconfig.json",
30
31
  "build:consumer": "tsc -p tsconfig.consumer.json --noEmit && node test/scripts/verify-packed-consumer.mjs",
31
32
  "test": "bun test"