@lovelace_lol/polymer 0.0.6 → 0.0.8

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.
Files changed (95) hide show
  1. package/README.md +434 -12
  2. package/dist/index.d.ts +1945 -244
  3. package/dist/index.js +1686 -1017
  4. package/dist/vision/face-worker.js +296 -0
  5. package/dist/vision/face_landmarker.task +0 -0
  6. package/dist/vision/manifest.edn +1 -0
  7. package/dist/vision/vision_bundle.js +2 -0
  8. package/dist/vision/wasm/vision_wasm_internal.js +8841 -0
  9. package/dist/vision/wasm/vision_wasm_internal.wasm +0 -0
  10. package/dist/vision/wasm/vision_wasm_module_internal.js +8837 -0
  11. package/dist/vision/wasm/vision_wasm_module_internal.wasm +0 -0
  12. package/dist/vision/wasm/vision_wasm_nosimd_internal.js +8832 -0
  13. package/dist/vision/wasm/vision_wasm_nosimd_internal.wasm +0 -0
  14. package/dist/worker/agency-worker.js +1276 -962
  15. package/dist/worker/manifest.edn +1 -1
  16. package/package.json +33 -20
  17. package/dist/test.cjs +0 -1519
  18. package/shadow-cljs.edn +0 -173
  19. package/src/polymer/animation/agency.cljs +0 -84
  20. package/src/polymer/animation/domain.cljs +0 -110
  21. package/src/polymer/animation/planner.cljs +0 -88
  22. package/src/polymer/animation/runtime.cljs +0 -137
  23. package/src/polymer/animation/scheduler.cljs +0 -178
  24. package/src/polymer/animation/service.cljs +0 -981
  25. package/src/polymer/animation/state.cljs +0 -112
  26. package/src/polymer/blink/agency.cljs +0 -131
  27. package/src/polymer/blink/planner.cljs +0 -115
  28. package/src/polymer/blink/scheduler.cljs +0 -90
  29. package/src/polymer/blink/snippet.cljs +0 -50
  30. package/src/polymer/blink/state.cljs +0 -102
  31. package/src/polymer/camera_context/agency.cljs +0 -132
  32. package/src/polymer/camera_context/domain.cljs +0 -186
  33. package/src/polymer/camera_context/planner.cljs +0 -50
  34. package/src/polymer/camera_context/scheduler.cljs +0 -113
  35. package/src/polymer/camera_context/state.cljs +0 -121
  36. package/src/polymer/character.cljs +0 -403
  37. package/src/polymer/conversation/agency.cljs +0 -83
  38. package/src/polymer/conversation/domain.cljs +0 -35
  39. package/src/polymer/conversation/effector.cljs +0 -130
  40. package/src/polymer/conversation/planner.cljs +0 -178
  41. package/src/polymer/conversation/scheduler.cljs +0 -202
  42. package/src/polymer/conversation/service.cljs +0 -329
  43. package/src/polymer/conversation/state.cljs +0 -186
  44. package/src/polymer/core.cljs +0 -172
  45. package/src/polymer/eye_head/agency.cljs +0 -75
  46. package/src/polymer/eye_head/domain.cljs +0 -133
  47. package/src/polymer/eye_head/goap.cljs +0 -106
  48. package/src/polymer/eye_head/scheduler.cljs +0 -176
  49. package/src/polymer/eye_head/service.cljs +0 -259
  50. package/src/polymer/eye_head/snippet.cljs +0 -92
  51. package/src/polymer/eye_head/state.cljs +0 -167
  52. package/src/polymer/gaze/agency.cljs +0 -85
  53. package/src/polymer/gaze/domain.cljs +0 -211
  54. package/src/polymer/gaze/goap.cljs +0 -208
  55. package/src/polymer/gaze/scheduler.cljs +0 -184
  56. package/src/polymer/gaze/state.cljs +0 -202
  57. package/src/polymer/gesture/agency.cljs +0 -185
  58. package/src/polymer/gesture/goap.cljs +0 -461
  59. package/src/polymer/gesture/scheduler.cljs +0 -122
  60. package/src/polymer/gesture/snippet.cljs +0 -198
  61. package/src/polymer/gesture/state.cljs +0 -273
  62. package/src/polymer/lipsync/agency.cljs +0 -593
  63. package/src/polymer/lipsync/articulation/jaw.cljs +0 -258
  64. package/src/polymer/lipsync/articulation/snippet.cljs +0 -605
  65. package/src/polymer/lipsync/articulation/tongue.cljs +0 -418
  66. package/src/polymer/lipsync/articulation/visemes.cljs +0 -429
  67. package/src/polymer/lipsync/goap.cljs +0 -132
  68. package/src/polymer/lipsync/pronunciation/effector.cljs +0 -51
  69. package/src/polymer/lipsync/scheduler.cljs +0 -302
  70. package/src/polymer/lipsync/state.cljs +0 -202
  71. package/src/polymer/nlp/phonemes.cljs +0 -164
  72. package/src/polymer/prosodic/agency.cljs +0 -196
  73. package/src/polymer/prosodic/goap.cljs +0 -122
  74. package/src/polymer/prosodic/scheduler.cljs +0 -99
  75. package/src/polymer/prosodic/snippet.cljs +0 -106
  76. package/src/polymer/prosodic/state.cljs +0 -139
  77. package/src/polymer/runtime/embody.cljs +0 -117
  78. package/src/polymer/runtime/embody_wasm.cljs +0 -177
  79. package/src/polymer/runtime/rust_embody_host.cljs +0 -647
  80. package/src/polymer/society.cljs +0 -253
  81. package/src/polymer/stream.cljs +0 -130
  82. package/src/polymer/transcription/agency.cljs +0 -69
  83. package/src/polymer/transcription/domain.cljs +0 -68
  84. package/src/polymer/transcription/effector.cljs +0 -611
  85. package/src/polymer/transcription/planner.cljs +0 -203
  86. package/src/polymer/transcription/scheduler.cljs +0 -225
  87. package/src/polymer/transcription/service.cljs +0 -209
  88. package/src/polymer/transcription/state.cljs +0 -239
  89. package/src/polymer/tts/agency.cljs +0 -503
  90. package/src/polymer/tts/azure.cljs +0 -290
  91. package/src/polymer/tts/planner.cljs +0 -178
  92. package/src/polymer/tts/runtime.cljs +0 -624
  93. package/src/polymer/tts/scheduler.cljs +0 -162
  94. package/src/polymer/tts/state.cljs +0 -191
  95. package/src/polymer/worker.cljs +0 -81
@@ -1,239 +0,0 @@
1
- (ns polymer.transcription.state
2
- (:require [clojure.string :as str]
3
- [polymer.transcription.domain :as domain]))
4
-
5
- ;; Transcription state tracks recognition session lifecycle and ordered transcript
6
- ;; facts. Browser APIs such as Web Speech and microphone access are handled by
7
- ;; the agency's effector, outside these pure transitions.
8
-
9
- (def default-config
10
- {:provider "webSpeech"
11
- :lang "en-US"
12
- :continuous true
13
- :interimResults true
14
- :maxAlternatives 1
15
- :maxRetries 2
16
- :retryDelayMs 100
17
- :minConfidence 0
18
- :agentFilteringEnabled true
19
- :interruptDetectionEnabled true
20
- :requireAgentReferenceForInterruption true
21
- :interruptionDebugLogging false
22
- :interruptionVolumeThreshold 0.035
23
- :interruptionReferenceScale 0.45
24
- :interruptionReferenceOffset 0.015
25
- :interruptionHoldMs 150})
26
-
27
- (defn finite-number?
28
- [value]
29
- (and (number? value) (js/isFinite value)))
30
-
31
- (defn number-or
32
- [value fallback]
33
- (if (finite-number? value) value fallback))
34
-
35
- (defn clamp
36
- [lo hi value]
37
- (min hi (max lo value)))
38
-
39
- (defn normalize-config
40
- [config]
41
- (let [input (merge default-config (domain/data-map config))]
42
- {:provider (domain/text-or (:provider input) (:provider default-config))
43
- :lang (domain/text-or (:lang input) (:lang default-config))
44
- :continuous (boolean (:continuous input))
45
- :interimResults (boolean (:interimResults input))
46
- :maxAlternatives (int (clamp 1 10 (number-or (:maxAlternatives input)
47
- (:maxAlternatives default-config))))
48
- :maxRetries (int (clamp 0 10 (number-or (:maxRetries input)
49
- (:maxRetries default-config))))
50
- :retryDelayMs (int (clamp 0 5000 (number-or (:retryDelayMs input)
51
- (:retryDelayMs default-config))))
52
- :minConfidence (clamp 0 1 (number-or (:minConfidence input)
53
- (:minConfidence default-config)))
54
- :agentFilteringEnabled (boolean (:agentFilteringEnabled input))
55
- :interruptDetectionEnabled (boolean (:interruptDetectionEnabled input))
56
- :requireAgentReferenceForInterruption (boolean (:requireAgentReferenceForInterruption input))
57
- :interruptionDebugLogging (boolean (:interruptionDebugLogging input))
58
- :interruptionVolumeThreshold (clamp 0 1 (number-or (:interruptionVolumeThreshold input)
59
- (:interruptionVolumeThreshold default-config)))
60
- :interruptionReferenceScale (clamp 0 4 (number-or (:interruptionReferenceScale input)
61
- (:interruptionReferenceScale default-config)))
62
- :interruptionReferenceOffset (clamp 0 1 (number-or (:interruptionReferenceOffset input)
63
- (:interruptionReferenceOffset default-config)))
64
- :interruptionHoldMs (int (clamp 0 2000 (number-or (:interruptionHoldMs input)
65
- (:interruptionHoldMs default-config))))}))
66
-
67
- (defn default-state
68
- [config]
69
- {:agency "transcription"
70
- :status "idle"
71
- :active false
72
- :sessionId nil
73
- :sequence 0
74
- :currentTranscript nil
75
- :isFinal false
76
- :lastPartial nil
77
- :lastFinal nil
78
- :lastError nil
79
- :lastTtsEvent nil
80
- :agentSpeaking false
81
- :agentSpeechStatus "idle"
82
- :agentWords #{}
83
- :agentScript ""
84
- :lastEvent nil
85
- :retryCount 0
86
- :startedCount 0
87
- :stoppedCount 0
88
- :partialCount 0
89
- :finalCount 0
90
- :errorCount 0
91
- :ignoredCount 0
92
- :interruptionCount 0
93
- :config (normalize-config config)})
94
-
95
- (defn config->state
96
- [config]
97
- (default-state config))
98
-
99
- (defn visible-state
100
- [state]
101
- (clj->js state))
102
-
103
- (defn configure
104
- [state config]
105
- (assoc state :config (normalize-config (merge (:config state)
106
- (domain/data-map config)))))
107
-
108
- (defn reset-state
109
- [state]
110
- (default-state (:config state)))
111
-
112
- (defn next-session-id
113
- []
114
- (str "transcription:" (.now js/Date) ":" (rand-int 1000000)))
115
-
116
- (defn start-session
117
- [state now-ms]
118
- (-> state
119
- (assoc :active true
120
- :status "starting"
121
- :sessionId (next-session-id)
122
- :lastError nil
123
- :retryCount 0
124
- :lastEvent {:type "transcription.status"
125
- :status "starting"
126
- :at now-ms})
127
- (update :startedCount inc)))
128
-
129
- (defn provider-started
130
- [state now-ms]
131
- (assoc state
132
- :status "listening"
133
- :lastError nil
134
- :lastEvent {:type "transcription.status"
135
- :status "listening"
136
- :reason "provider-started"
137
- :at now-ms}))
138
-
139
- (defn stop-session
140
- [state now-ms reason]
141
- (-> state
142
- (assoc :active false
143
- :status "idle"
144
- :currentTranscript nil
145
- :isFinal false
146
- :lastEvent {:type "transcription.status"
147
- :status "idle"
148
- :reason reason
149
- :at now-ms})
150
- (update :stoppedCount inc)))
151
-
152
- (defn next-sequence
153
- [state]
154
- (inc (:sequence state)))
155
-
156
- (defn record-partial
157
- [state fact]
158
- (-> state
159
- (assoc :status "listening"
160
- :sequence (:sequence fact)
161
- :currentTranscript (:text fact)
162
- :isFinal false
163
- :lastPartial fact
164
- :lastEvent fact)
165
- (update :partialCount inc)))
166
-
167
- (defn record-final
168
- [state fact]
169
- (-> state
170
- (assoc :status "listening"
171
- :sequence (:sequence fact)
172
- :currentTranscript (:text fact)
173
- :isFinal true
174
- :lastPartial nil
175
- :lastFinal fact
176
- :lastEvent fact
177
- :retryCount 0)
178
- (update :finalCount inc)))
179
-
180
- (defn record-error
181
- [state error now-ms retrying?]
182
- (-> state
183
- (assoc :status (if retrying? "retrying" "error")
184
- :lastError error
185
- :lastEvent {:type "transcription.error"
186
- :message error
187
- :retrying retrying?
188
- :at now-ms})
189
- (update :errorCount inc)
190
- (update :retryCount (fn [count] (if retrying? (inc count) count)))))
191
-
192
- (defn record-ignored
193
- [state ignored]
194
- (-> state
195
- (assoc :lastEvent ignored)
196
- (update :ignoredCount inc)))
197
-
198
- (defn record-interruption
199
- [state fact]
200
- (-> state
201
- (assoc :lastEvent fact)
202
- (update :interruptionCount inc)))
203
-
204
- (defn record-tts-status
205
- [state fact]
206
- (let [speaking? (boolean (:speaking fact))
207
- phrase (or (:phrase fact) (:text fact))
208
- words (or (some-> phrase domain/word-set)
209
- (some->> (:words fact) (map str/lower-case) set))]
210
- (cond-> (assoc state
211
- :agentSpeaking speaking?
212
- :agentSpeechStatus (:status fact)
213
- :lastTtsEvent fact
214
- :lastEvent fact)
215
- words (assoc :agentWords words
216
- :agentScript (str/lower-case (or phrase
217
- (str/join " " (:words fact)))))
218
- (not speaking?) (assoc :agentWords #{}
219
- :agentScript ""))))
220
-
221
- (defn prepare-agent-speech
222
- [state text append?]
223
- (let [script (str/lower-case (or text ""))
224
- words (domain/word-set script)]
225
- (assoc state
226
- :agentSpeaking true
227
- :agentSpeechStatus "speaking"
228
- :agentScript (if append?
229
- (str/trim (str (:agentScript state) " " script))
230
- script)
231
- :agentWords (if append?
232
- (into (:agentWords state) words)
233
- words))))
234
-
235
- (defn record-agent-word
236
- [state word]
237
- (let [token (str/lower-case (or word ""))]
238
- (cond-> state
239
- (seq token) (update :agentWords conj token))))