@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,178 +0,0 @@
1
- (ns polymer.conversation.planner
2
- (:require [polymer.conversation.domain :as domain]))
3
-
4
- ;; Conversation planning stays agency-local. It decides what this agency wants
5
- ;; to do with a transcript, provider result, or interruption, then hands ordered
6
- ;; action data to the scheduler. It never calls a backend, TTS provider, or peer
7
- ;; agency function directly.
8
-
9
- (def supported-command-types
10
- #{"configure"
11
- "start"
12
- "stop"
13
- "reset"
14
- "cancel"
15
- "interrupt"
16
- "transcript.final"
17
- "transcriptFinal"
18
- "userUtterance"
19
- "agentUtterance"
20
- "responseReady"
21
- "providerError"
22
- "tts.status"})
23
-
24
- (defn command-type
25
- [command]
26
- (:type command))
27
-
28
- (defn request-id
29
- [prefix now-ms]
30
- (str prefix ":" now-ms ":" (rand-int 1000000)))
31
-
32
- (defn stale-response?
33
- [command state]
34
- (or (:interrupted state)
35
- (nil? (:pendingResponse state))
36
- (and (:turnId command)
37
- (not= (:turnId command) (:turnId state)))
38
- (and (:requestId command)
39
- (not= (:requestId command)
40
- (:requestId (:pendingResponse state))))))
41
-
42
- (defn failure-step
43
- [command]
44
- (cond
45
- (not (contains? supported-command-types (command-type command)))
46
- {:op "fail"
47
- :reason "unsupported-command"
48
- :commandType (command-type command)}
49
-
50
- (and (#{"transcript.final" "transcriptFinal" "userUtterance"} (command-type command))
51
- (not (domain/user-text command)))
52
- {:op "fail"
53
- :reason "missing-user-text"
54
- :commandType (command-type command)}
55
-
56
- (and (#{"agentUtterance" "responseReady"} (command-type command))
57
- (not (domain/agent-text command)))
58
- {:op "fail"
59
- :reason "missing-agent-text"
60
- :commandType (command-type command)}))
61
-
62
- (defn transcript-steps
63
- [command state now-ms]
64
- (let [text (domain/user-text command)
65
- source (or (:source command) "transcription")
66
- pending-request-id (get-in state [:pendingResponse :requestId])
67
- response-text (domain/clean-text (or (:responseText command) (:agentText command)))
68
- response-request {:requestId (request-id "conversation:response" now-ms)
69
- :text text
70
- :source source
71
- :turnId (:turnId state)
72
- :history (:history state)
73
- :requestedAt now-ms}]
74
- (cond-> [{:op "record-user-utterance"
75
- :text text
76
- :source source}
77
- {:op "emit-user-utterance"
78
- :text text
79
- :source source}]
80
- (and (get-in state [:config :autoRespond])
81
- pending-request-id)
82
- (conj {:op "cancel-provider"
83
- :requestId pending-request-id
84
- :reason "superseded"})
85
-
86
- (get-in state [:config :autoRespond])
87
- (conj {:op "request-response"
88
- :request response-request}
89
- {:op "invoke-provider"
90
- :request response-request})
91
-
92
- response-text
93
- (conj {:op "record-agent-utterance"
94
- :text response-text
95
- :source "response"}
96
- {:op "request-tts"
97
- :text response-text
98
- :source "response"
99
- :requestId (request-id "conversation:tts" now-ms)}))))
100
-
101
- (defn agent-utterance-steps
102
- [command state now-ms]
103
- (let [text (domain/agent-text command)]
104
- (if (and (= "responseReady" (:type command))
105
- (stale-response? command state))
106
- [{:op "ignore-stale-response"
107
- :reason "stale-response"
108
- :requestId (:requestId command)
109
- :turnId (:turnId command)}]
110
- [{:op "record-agent-utterance"
111
- :text text
112
- :source (or (:source command) "conversation")}
113
- {:op "request-tts"
114
- :text text
115
- :source (or (:source command) "conversation")
116
- :requestId (request-id "conversation:tts" now-ms)}])))
117
-
118
- (defn provider-error-steps
119
- [command state]
120
- (if (stale-response? command state)
121
- [{:op "ignore-stale-response"
122
- :reason "stale-provider-error"
123
- :requestId (:requestId command)
124
- :turnId (:turnId command)}]
125
- [{:op "record-provider-error"
126
- :requestId (:requestId command)
127
- :turnId (:turnId command)
128
- :message (or (:message command) "conversation-provider-error")}
129
- {:op "publish-provider-error"
130
- :requestId (:requestId command)
131
- :turnId (:turnId command)
132
- :message (or (:message command) "conversation-provider-error")}]))
133
-
134
- (defn command-steps
135
- [command state now-ms]
136
- (if-let [failure (failure-step command)]
137
- [failure]
138
- (case (command-type command)
139
- "configure" [{:op "apply-config"}
140
- {:op "publish-status" :status (:status state)}]
141
- "start" [{:op "start-session"}
142
- {:op "publish-status" :status "listening"}]
143
- "stop" [{:op "cancel-provider"
144
- :requestId (get-in state [:pendingResponse :requestId])
145
- :reason (or (:reason command) "stopped")}
146
- {:op "stop-session" :reason (or (:reason command) "stopped")}
147
- {:op "publish-status" :status "idle"}]
148
- "reset" [{:op "cancel-provider"
149
- :requestId (get-in state [:pendingResponse :requestId])
150
- :reason "reset"}
151
- {:op "reset-state"}
152
- {:op "publish-status" :status "idle"}]
153
- ("cancel" "interrupt") [{:op "cancel-provider"
154
- :requestId (get-in state [:pendingResponse :requestId])
155
- :reason (or (:reason command) (command-type command))}
156
- {:op "cancel-turn"
157
- :reason (or (:reason command) (command-type command))}
158
- {:op "publish-cancel"
159
- :reason (or (:reason command) (command-type command))}
160
- {:op "publish-status" :status "interrupted"}]
161
- ("transcript.final" "transcriptFinal" "userUtterance")
162
- (transcript-steps command state now-ms)
163
- ("agentUtterance" "responseReady")
164
- (agent-utterance-steps command state now-ms)
165
- "providerError"
166
- (provider-error-steps command state)
167
- "tts.status" [{:op "record-tts-status"
168
- :status (:status command)}
169
- {:op "publish-status" :status (:status command)}])))
170
-
171
- (defn plan-command
172
- [command state now-ms]
173
- (let [steps (command-steps command state now-ms)]
174
- {:agency "conversation"
175
- :commandType (command-type command)
176
- :createdAt now-ms
177
- :ok (not= "fail" (:op (first steps)))
178
- :steps steps}))
@@ -1,202 +0,0 @@
1
- (ns polymer.conversation.scheduler
2
- (:require [polymer.conversation.state :as state]))
3
-
4
- ;; The Conversation scheduler is the ordered work boundary for the agency. This
5
- ;; first slice executes immediately, but it still records every planned step in
6
- ;; a queue so future backend/provider sequencing, retries, and cancellation can
7
- ;; extend the same architecture without moving logic into host UI code.
8
-
9
- (defn now-ms
10
- []
11
- (.now js/Date))
12
-
13
- (defn queue-entry
14
- [step index plan]
15
- (assoc step
16
- :agency "conversation"
17
- :queueIndex index
18
- :commandType (:commandType plan)
19
- :queuedAt (now-ms)))
20
-
21
- (defn emit-status!
22
- [emit-event state-atom status reason]
23
- (emit-event (cond-> {:type "conversation.status"
24
- :agency "conversation"
25
- :status status
26
- :turnId (:turnId @state-atom)
27
- :at (now-ms)}
28
- reason (assoc :reason reason))))
29
-
30
- (defn create-scheduler
31
- [{:keys [state-atom emit-event dispatch-command provider-effector]}]
32
- (let [queue (atom [])
33
- disposed? (atom false)]
34
- (letfn [(enqueue! [step plan]
35
- (let [entry (queue-entry step (count @queue) plan)]
36
- (swap! queue conj entry)
37
- entry))
38
-
39
- (request-tts! [step requested-at]
40
- (let [request {:type "tts.requestSpeak"
41
- :agency "conversation"
42
- :targetAgency (get-in @state-atom [:config :ttsAgency])
43
- :requestId (:requestId step)
44
- :text (:text step)
45
- :source (:source step)
46
- :turnId (:turnId @state-atom)
47
- :requestedAt requested-at
48
- :command {:type "speak"
49
- :text (:text step)
50
- :source "conversation"}}]
51
- (swap! state-atom state/record-tts-request request)
52
- (emit-event request)))
53
-
54
- (invoke-provider! [request]
55
- (when (:available? provider-effector)
56
- ((:invoke provider-effector)
57
- request
58
- (fn [response]
59
- (dispatch-command
60
- {:type "responseReady"
61
- :requestId (:requestId request)
62
- :turnId (:turnId request)
63
- :text (or (:text response)
64
- (:responseText response)
65
- (:agentText response))
66
- :source (or (:source response)
67
- (get-in @state-atom [:config :responseSource]))}))
68
- (fn [error]
69
- (dispatch-command
70
- {:type "providerError"
71
- :requestId (:requestId request)
72
- :turnId (:turnId request)
73
- :message (:message error)})))))
74
-
75
- (execute-step! [step command plan]
76
- (let [now (now-ms)]
77
- (enqueue! step plan)
78
- (case (:op step)
79
- "apply-config"
80
- (do
81
- (swap! state-atom state/configure (:config command))
82
- (emit-status! emit-event state-atom (:status @state-atom) "configured"))
83
-
84
- "start-session"
85
- (do
86
- (swap! state-atom state/mark-started now)
87
- (emit-status! emit-event state-atom "listening" nil))
88
-
89
- "stop-session"
90
- (do
91
- (swap! state-atom state/mark-stopped now (:reason step))
92
- (emit-status! emit-event state-atom "idle" (:reason step)))
93
-
94
- "reset-state"
95
- (do
96
- (swap! state-atom state/reset-state)
97
- (emit-status! emit-event state-atom "idle" "reset"))
98
-
99
- "record-user-utterance"
100
- (swap! state-atom state/record-user-utterance (:text step) now (:source step))
101
-
102
- "emit-user-utterance"
103
- (emit-event {:type "conversation.userUtterance"
104
- :agency "conversation"
105
- :text (:text step)
106
- :source (:source step)
107
- :turnId (:turnId @state-atom)
108
- :at now})
109
-
110
- "request-response"
111
- (let [request (:request step)]
112
- (swap! state-atom state/record-response-request request)
113
- (emit-event (assoc request
114
- :type "conversation.requestResponse"
115
- :agency "conversation"
116
- :targetAgency "conversation-provider")))
117
-
118
- "invoke-provider"
119
- (invoke-provider! (:request step))
120
-
121
- "cancel-provider"
122
- (when-let [request-id (:requestId step)]
123
- ((:cancel provider-effector) request-id))
124
-
125
- "record-agent-utterance"
126
- (do
127
- (swap! state-atom state/record-agent-utterance (:text step) now (:source step))
128
- (emit-event {:type "conversation.agentUtterance"
129
- :agency "conversation"
130
- :text (:text step)
131
- :source (:source step)
132
- :turnId (:turnId @state-atom)
133
- :at now}))
134
-
135
- "request-tts"
136
- (request-tts! step now)
137
-
138
- "record-provider-error"
139
- (swap! state-atom state/record-provider-error
140
- (:requestId step)
141
- (:message step)
142
- now)
143
-
144
- "publish-provider-error"
145
- (emit-event {:type "conversation.providerError"
146
- :agency "conversation"
147
- :requestId (:requestId step)
148
- :turnId (:turnId step)
149
- :message (:message step)
150
- :at now})
151
-
152
- "cancel-turn"
153
- (swap! state-atom state/record-cancel now (:reason step))
154
-
155
- "publish-cancel"
156
- (emit-event {:type "conversation.cancelRequested"
157
- :agency "conversation"
158
- :targetAgency (get-in @state-atom [:config :ttsAgency])
159
- :reason (:reason step)
160
- :turnId (:turnId @state-atom)
161
- :at now})
162
-
163
- "ignore-stale-response"
164
- (emit-event {:type "conversation.ignored"
165
- :agency "conversation"
166
- :reason (:reason step)
167
- :requestId (:requestId step)
168
- :turnId (:turnId step)
169
- :at now})
170
-
171
- "record-tts-status"
172
- (swap! state-atom assoc
173
- :status (or (:status step) (:status @state-atom))
174
- :lastEvent {:type "conversation.ttsStatus"
175
- :status (:status step)
176
- :at now})
177
-
178
- "publish-status"
179
- (emit-status! emit-event state-atom (:status step) (:reason step))
180
-
181
- "fail"
182
- (emit-event {:type "error"
183
- :agency "conversation"
184
- :message (:reason step)
185
- :commandType (:commandType step)})
186
-
187
- nil)))]
188
- {:schedule
189
- (fn [command plan]
190
- (when-not @disposed?
191
- (doseq [step (:steps plan)]
192
- (execute-step! step command plan))))
193
-
194
- :queue
195
- (fn []
196
- @queue)
197
-
198
- :dispose
199
- (fn []
200
- (reset! disposed? true)
201
- ((:dispose provider-effector))
202
- (reset! queue []))})))