@livekit/agents 0.1.0 → 0.3.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +47 -0
- package/LICENSE +201 -0
- package/dist/audio.d.ts +9 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/audio.js +54 -0
- package/dist/audio.js.map +1 -0
- package/dist/cli.d.ts +12 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +102 -19
- package/dist/cli.js.map +1 -1
- package/dist/generator.d.ts +17 -6
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +20 -3
- package/dist/generator.js.map +1 -1
- package/dist/http_server.d.ts +1 -1
- package/dist/http_server.d.ts.map +1 -1
- package/dist/http_server.js +5 -3
- package/dist/http_server.js.map +1 -1
- package/dist/index.d.ts +14 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/ipc/job_executor.d.ts +19 -0
- package/dist/ipc/job_executor.d.ts.map +1 -0
- package/dist/ipc/job_executor.js +8 -0
- package/dist/ipc/job_executor.js.map +1 -0
- package/dist/ipc/job_main.d.ts +7 -4
- package/dist/ipc/job_main.d.ts.map +1 -1
- package/dist/ipc/job_main.js +102 -59
- package/dist/ipc/job_main.js.map +1 -1
- package/dist/ipc/message.d.ts +41 -0
- package/dist/ipc/message.d.ts.map +1 -0
- package/dist/ipc/message.js +2 -0
- package/dist/ipc/message.js.map +1 -0
- package/dist/ipc/proc_job_executor.d.ts +15 -0
- package/dist/ipc/proc_job_executor.d.ts.map +1 -0
- package/dist/ipc/proc_job_executor.js +150 -0
- package/dist/ipc/proc_job_executor.js.map +1 -0
- package/dist/ipc/proc_pool.d.ts +26 -0
- package/dist/ipc/proc_pool.d.ts.map +1 -0
- package/dist/ipc/proc_pool.js +83 -0
- package/dist/ipc/proc_pool.js.map +1 -0
- package/dist/job.d.ts +100 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +213 -0
- package/dist/job.js.map +1 -0
- package/dist/llm/function_context.d.ts +20 -0
- package/dist/llm/function_context.d.ts.map +1 -0
- package/dist/llm/function_context.js +37 -0
- package/dist/llm/function_context.js.map +1 -0
- package/dist/llm/index.d.ts +3 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +6 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/log.d.ts +12 -1
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +28 -11
- package/dist/log.js.map +1 -1
- package/dist/multimodal/agent_playout.d.ts +34 -0
- package/dist/multimodal/agent_playout.d.ts.map +1 -0
- package/dist/multimodal/agent_playout.js +221 -0
- package/dist/multimodal/agent_playout.js.map +1 -0
- package/dist/multimodal/index.d.ts +3 -0
- package/dist/multimodal/index.d.ts.map +1 -0
- package/dist/multimodal/index.js +6 -0
- package/dist/multimodal/index.js.map +1 -0
- package/dist/multimodal/multimodal_agent.d.ts +47 -0
- package/dist/multimodal/multimodal_agent.d.ts.map +1 -0
- package/dist/multimodal/multimodal_agent.js +331 -0
- package/dist/multimodal/multimodal_agent.js.map +1 -0
- package/dist/plugin.js +20 -7
- package/dist/plugin.js.map +1 -1
- package/dist/stt/index.d.ts +1 -1
- package/dist/stt/index.d.ts.map +1 -1
- package/dist/stt/index.js.map +1 -1
- package/dist/stt/stream_adapter.d.ts +2 -11
- package/dist/stt/stream_adapter.d.ts.map +1 -1
- package/dist/stt/stream_adapter.js +47 -33
- package/dist/stt/stream_adapter.js.map +1 -1
- package/dist/stt/stt.d.ts +27 -0
- package/dist/stt/stt.d.ts.map +1 -1
- package/dist/stt/stt.js +32 -5
- package/dist/stt/stt.js.map +1 -1
- package/dist/transcription.d.ts +22 -0
- package/dist/transcription.d.ts.map +1 -0
- package/dist/transcription.js +111 -0
- package/dist/transcription.js.map +1 -0
- package/dist/tts/stream_adapter.d.ts +4 -11
- package/dist/tts/stream_adapter.d.ts.map +1 -1
- package/dist/tts/stream_adapter.js +66 -32
- package/dist/tts/stream_adapter.js.map +1 -1
- package/dist/tts/tts.d.ts +10 -0
- package/dist/tts/tts.d.ts.map +1 -1
- package/dist/tts/tts.js +48 -7
- package/dist/tts/tts.js.map +1 -1
- package/dist/utils.d.ts +59 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +212 -6
- package/dist/utils.js.map +1 -1
- package/dist/vad.d.ts +29 -0
- package/dist/vad.d.ts.map +1 -1
- package/dist/vad.js.map +1 -1
- package/dist/worker.d.ts +69 -50
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +414 -213
- package/dist/worker.js.map +1 -1
- package/package.json +12 -10
- package/src/audio.ts +62 -0
- package/src/cli.ts +108 -20
- package/src/generator.ts +27 -7
- package/src/http_server.ts +5 -0
- package/src/index.ts +15 -3
- package/src/ipc/job_executor.ts +25 -0
- package/src/ipc/job_main.ts +141 -61
- package/src/ipc/message.ts +39 -0
- package/src/ipc/proc_job_executor.ts +162 -0
- package/src/ipc/proc_pool.ts +109 -0
- package/src/job.ts +278 -0
- package/src/llm/function_context.ts +61 -0
- package/src/llm/index.ts +11 -0
- package/src/log.ts +40 -8
- package/src/multimodal/agent_playout.ts +254 -0
- package/src/multimodal/index.ts +5 -0
- package/src/multimodal/multimodal_agent.ts +428 -0
- package/src/stt/index.ts +1 -1
- package/src/stt/stream_adapter.ts +32 -32
- package/src/stt/stt.ts +27 -0
- package/src/transcription.ts +128 -0
- package/src/tts/stream_adapter.ts +32 -31
- package/src/tts/tts.ts +10 -0
- package/src/utils.ts +257 -3
- package/src/vad.ts +29 -0
- package/src/worker.ts +465 -172
- package/tsconfig.json +7 -1
- package/dist/ipc/job_process.d.ts +0 -22
- package/dist/ipc/job_process.d.ts.map +0 -1
- package/dist/ipc/job_process.js +0 -73
- package/dist/ipc/job_process.js.map +0 -1
- package/dist/ipc/protocol.d.ts +0 -40
- package/dist/ipc/protocol.d.ts.map +0 -1
- package/dist/ipc/protocol.js +0 -14
- package/dist/ipc/protocol.js.map +0 -1
- package/dist/job_context.d.ts +0 -16
- package/dist/job_context.d.ts.map +0 -1
- package/dist/job_context.js +0 -31
- package/dist/job_context.js.map +0 -1
- package/dist/job_request.d.ts +0 -42
- package/dist/job_request.d.ts.map +0 -1
- package/dist/job_request.js +0 -79
- package/dist/job_request.js.map +0 -1
- package/src/ipc/job_process.ts +0 -96
- package/src/ipc/protocol.ts +0 -51
- package/src/job_context.ts +0 -49
- package/src/job_request.ts +0 -118
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @livekit/agents
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Rename to MultimodalAgent, move to main package - [#74](https://github.com/livekit/agents-js/pull/74) ([@bcherry](https://github.com/bcherry))
|
|
8
|
+
|
|
9
|
+
- add waitForParticipant - [#73](https://github.com/livekit/agents-js/pull/73) ([@nbsp](https://github.com/nbsp))
|
|
10
|
+
|
|
11
|
+
- omniassistant overhaul - [#65](https://github.com/livekit/agents-js/pull/65) ([@nbsp](https://github.com/nbsp))
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- update rtc-node to 0.9.0 - [#73](https://github.com/livekit/agents-js/pull/73) ([@nbsp](https://github.com/nbsp))
|
|
16
|
+
|
|
17
|
+
- improve dev mode default parameters - [#70](https://github.com/livekit/agents-js/pull/70) ([@nbsp](https://github.com/nbsp))
|
|
18
|
+
|
|
19
|
+
- throw friendly error on --participant-identity err - [#61](https://github.com/livekit/agents-js/pull/61) ([@nbsp](https://github.com/nbsp))
|
|
20
|
+
|
|
21
|
+
- shut everything down correctly - [#62](https://github.com/livekit/agents-js/pull/62) ([@nbsp](https://github.com/nbsp))
|
|
22
|
+
|
|
23
|
+
- Maximize self-import compatibility - [#69](https://github.com/livekit/agents-js/pull/69) ([@bcherry](https://github.com/bcherry))
|
|
24
|
+
|
|
25
|
+
- automatically no-op on CLI if executor is job_main - [#64](https://github.com/livekit/agents-js/pull/64) ([@nbsp](https://github.com/nbsp))
|
|
26
|
+
|
|
27
|
+
- Allow passing required params in WorkerOptions - [#68](https://github.com/livekit/agents-js/pull/68) ([@bcherry](https://github.com/bcherry))
|
|
28
|
+
|
|
29
|
+
## 0.2.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- bump underlying dependencies - [`be7160d39ea57239a51fbf6ad2cbea1342cc1889`](https://github.com/livekit/agents-js/commit/be7160d39ea57239a51fbf6ad2cbea1342cc1889) ([@bcherry](https://github.com/bcherry))
|
|
34
|
+
fix load calculation
|
|
35
|
+
report worker status
|
|
36
|
+
|
|
37
|
+
- cli: add runHeadless function - [`36c553a60fef7621b9c4232b5c79555b2f83aad8`](https://github.com/livekit/agents-js/commit/36c553a60fef7621b9c4232b5c79555b2f83aad8) ([@nbsp](https://github.com/nbsp))
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- worker: JT\_{PUBLISHER => ROOM} - [`1c8caf04c148dfa57af4e844b6538d97d6be652a`](https://github.com/livekit/agents-js/commit/1c8caf04c148dfa57af4e844b6538d97d6be652a) ([@nbsp](https://github.com/nbsp))
|
|
42
|
+
|
|
43
|
+
- Pass api key and secret to RoomServiceClient - [#58](https://github.com/livekit/agents-js/pull/58) ([@bcherry](https://github.com/bcherry))
|
|
44
|
+
|
|
45
|
+
- Let defineAgent accept agent type - [`24a4f58a23d4a3aad8620fcccabdab5d2e1152c7`](https://github.com/livekit/agents-js/commit/24a4f58a23d4a3aad8620fcccabdab5d2e1152c7) ([@lukasIO](https://github.com/lukasIO))
|
|
46
|
+
|
|
47
|
+
- Add transcript support to realtime voice assistant - [`1063d2a25c4a01022948699e673d267d04c1ec05`](https://github.com/livekit/agents-js/commit/1063d2a25c4a01022948699e673d267d04c1ec05) ([@bcherry](https://github.com/bcherry))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/audio.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AudioFrame } from '@livekit/rtc-node';
|
|
2
|
+
/** AudioByteStream translates between LiveKit AudioFrame packets and raw byte data. */
|
|
3
|
+
export declare class AudioByteStream {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(sampleRate: number, numChannels: number, samplesPerChannel?: number | null);
|
|
6
|
+
write(data: ArrayBuffer): AudioFrame[];
|
|
7
|
+
flush(): AudioFrame[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=audio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../src/audio.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,uFAAuF;AACvF,qBAAa,eAAe;;gBAMd,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,GAAE,MAAM,GAAG,IAAW;IAY5F,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,EAAE;IAqBtC,KAAK,IAAI,UAAU,EAAE;CAetB"}
|
package/dist/audio.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _AudioByteStream_sampleRate, _AudioByteStream_numChannels, _AudioByteStream_bytesPerFrame, _AudioByteStream_buf;
|
|
13
|
+
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
import { AudioFrame } from '@livekit/rtc-node';
|
|
17
|
+
import { log } from './log.js';
|
|
18
|
+
/** AudioByteStream translates between LiveKit AudioFrame packets and raw byte data. */
|
|
19
|
+
export class AudioByteStream {
|
|
20
|
+
constructor(sampleRate, numChannels, samplesPerChannel = null) {
|
|
21
|
+
_AudioByteStream_sampleRate.set(this, void 0);
|
|
22
|
+
_AudioByteStream_numChannels.set(this, void 0);
|
|
23
|
+
_AudioByteStream_bytesPerFrame.set(this, void 0);
|
|
24
|
+
_AudioByteStream_buf.set(this, void 0);
|
|
25
|
+
__classPrivateFieldSet(this, _AudioByteStream_sampleRate, sampleRate, "f");
|
|
26
|
+
__classPrivateFieldSet(this, _AudioByteStream_numChannels, numChannels, "f");
|
|
27
|
+
if (samplesPerChannel === null) {
|
|
28
|
+
samplesPerChannel = Math.floor(sampleRate / 50); // 20ms by default
|
|
29
|
+
}
|
|
30
|
+
__classPrivateFieldSet(this, _AudioByteStream_bytesPerFrame, numChannels * samplesPerChannel * 2, "f"); // 2 bytes per sample (Int16)
|
|
31
|
+
__classPrivateFieldSet(this, _AudioByteStream_buf, new Int8Array(), "f");
|
|
32
|
+
}
|
|
33
|
+
write(data) {
|
|
34
|
+
__classPrivateFieldSet(this, _AudioByteStream_buf, new Int8Array([...__classPrivateFieldGet(this, _AudioByteStream_buf, "f"), ...new Int8Array(data)]), "f");
|
|
35
|
+
const frames = [];
|
|
36
|
+
while (__classPrivateFieldGet(this, _AudioByteStream_buf, "f").length >= __classPrivateFieldGet(this, _AudioByteStream_bytesPerFrame, "f")) {
|
|
37
|
+
const frameData = __classPrivateFieldGet(this, _AudioByteStream_buf, "f").slice(0, __classPrivateFieldGet(this, _AudioByteStream_bytesPerFrame, "f"));
|
|
38
|
+
__classPrivateFieldSet(this, _AudioByteStream_buf, __classPrivateFieldGet(this, _AudioByteStream_buf, "f").slice(__classPrivateFieldGet(this, _AudioByteStream_bytesPerFrame, "f")), "f");
|
|
39
|
+
frames.push(new AudioFrame(new Int16Array(frameData.buffer), __classPrivateFieldGet(this, _AudioByteStream_sampleRate, "f"), __classPrivateFieldGet(this, _AudioByteStream_numChannels, "f"), frameData.length / 2));
|
|
40
|
+
}
|
|
41
|
+
return frames;
|
|
42
|
+
}
|
|
43
|
+
flush() {
|
|
44
|
+
if (__classPrivateFieldGet(this, _AudioByteStream_buf, "f").length % (2 * __classPrivateFieldGet(this, _AudioByteStream_numChannels, "f")) !== 0) {
|
|
45
|
+
log().warn('AudioByteStream: incomplete frame during flush, dropping');
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return [
|
|
49
|
+
new AudioFrame(new Int16Array(__classPrivateFieldGet(this, _AudioByteStream_buf, "f").buffer), __classPrivateFieldGet(this, _AudioByteStream_sampleRate, "f"), __classPrivateFieldGet(this, _AudioByteStream_numChannels, "f"), __classPrivateFieldGet(this, _AudioByteStream_buf, "f").length / 2),
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
_AudioByteStream_sampleRate = new WeakMap(), _AudioByteStream_numChannels = new WeakMap(), _AudioByteStream_bytesPerFrame = new WeakMap(), _AudioByteStream_buf = new WeakMap();
|
|
54
|
+
//# sourceMappingURL=audio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio.js","sourceRoot":"","sources":["../src/audio.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,uFAAuF;AACvF,MAAM,OAAO,eAAe;IAM1B,YAAY,UAAkB,EAAE,WAAmB,EAAE,oBAAmC,IAAI;QAL5F,8CAAoB;QACpB,+CAAqB;QACrB,iDAAuB;QACvB,uCAAgB;QAGd,uBAAA,IAAI,+BAAe,UAAU,MAAA,CAAC;QAC9B,uBAAA,IAAI,gCAAgB,WAAW,MAAA,CAAC;QAEhC,IAAI,iBAAiB,KAAK,IAAI,EAAE,CAAC;YAC/B,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,kBAAkB;QACrE,CAAC;QAED,uBAAA,IAAI,kCAAkB,WAAW,GAAG,iBAAiB,GAAG,CAAC,MAAA,CAAC,CAAC,6BAA6B;QACxF,uBAAA,IAAI,wBAAQ,IAAI,SAAS,EAAE,MAAA,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,IAAiB;QACrB,uBAAA,IAAI,wBAAQ,IAAI,SAAS,CAAC,CAAC,GAAG,uBAAA,IAAI,4BAAK,EAAE,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAA,CAAC;QAElE,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,OAAO,uBAAA,IAAI,4BAAK,CAAC,MAAM,IAAI,uBAAA,IAAI,sCAAe,EAAE,CAAC;YAC/C,MAAM,SAAS,GAAG,uBAAA,IAAI,4BAAK,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAA,IAAI,sCAAe,CAAC,CAAC;YAC1D,uBAAA,IAAI,wBAAQ,uBAAA,IAAI,4BAAK,CAAC,KAAK,CAAC,uBAAA,IAAI,sCAAe,CAAC,MAAA,CAAC;YAEjD,MAAM,CAAC,IAAI,CACT,IAAI,UAAU,CACZ,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,EAChC,uBAAA,IAAI,mCAAY,EAChB,uBAAA,IAAI,oCAAa,EACjB,SAAS,CAAC,MAAM,GAAG,CAAC,CACrB,CACF,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK;QACH,IAAI,uBAAA,IAAI,4BAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,uBAAA,IAAI,oCAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACrD,GAAG,EAAE,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;YACvE,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL,IAAI,UAAU,CACZ,IAAI,UAAU,CAAC,uBAAA,IAAI,4BAAK,CAAC,MAAM,CAAC,EAChC,uBAAA,IAAI,mCAAY,EAChB,uBAAA,IAAI,oCAAa,EACjB,uBAAA,IAAI,4BAAK,CAAC,MAAM,GAAG,CAAC,CACrB;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkerOptions } from './worker.js';
|
|
2
|
+
/**
|
|
3
|
+
* Exposes a CLI for creating a new worker, in development or production mode.
|
|
4
|
+
*
|
|
5
|
+
* @param opts - Options to launch the worker with
|
|
6
|
+
* @example
|
|
7
|
+
* ```
|
|
8
|
+
* if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
9
|
+
* cli.runApp(new WorkerOptions({ agent: import.meta.filename }));
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
2
13
|
export declare const runApp: (opts: WorkerOptions) => void;
|
|
3
14
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAOA,OAAO,EAAU,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAOA,OAAO,EAAU,aAAa,EAAE,MAAM,aAAa,CAAC;AA+CpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,SAAU,aAAa,SAqGzC,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,26 +1,64 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
13
|
//
|
|
3
14
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
15
|
import { Command, Option } from 'commander';
|
|
5
|
-
import { log } from './log.js';
|
|
16
|
+
import { initializeLogger, log } from './log.js';
|
|
6
17
|
import { version } from './version.js';
|
|
7
|
-
import { Worker } from './worker.js';
|
|
18
|
+
import { Worker, WorkerOptions } from './worker.js';
|
|
8
19
|
const runWorker = async (args) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
20
|
+
initializeLogger({ pretty: !args.production, level: args.opts.logLevel });
|
|
21
|
+
// though `production` is defined in WorkerOptions, it will always be overriddden by CLI.
|
|
22
|
+
const _a = args.opts, { production: _ } = _a, opts = __rest(_a, ["production"]); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
23
|
+
const worker = new Worker(new WorkerOptions(Object.assign({ production: args.production }, opts)));
|
|
24
|
+
if (args.room) {
|
|
25
|
+
worker.event.once('worker_registered', () => {
|
|
26
|
+
log().info(`connecting to room ${args.room}`);
|
|
27
|
+
worker.simulateJob(args.room, args.participantIdentity);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
process.once('SIGINT', async () => {
|
|
31
|
+
// allow C-c C-c for force interrupt
|
|
32
|
+
process.once('SIGINT', () => {
|
|
33
|
+
log().info('worker closed forcefully');
|
|
34
|
+
process.exit(130); // SIGINT exit code
|
|
35
|
+
});
|
|
36
|
+
if (args.production) {
|
|
37
|
+
await worker.drain();
|
|
38
|
+
}
|
|
12
39
|
await worker.close();
|
|
13
|
-
log.info('worker closed');
|
|
40
|
+
log().info('worker closed');
|
|
14
41
|
process.exit(130); // SIGINT exit code
|
|
15
42
|
});
|
|
16
43
|
try {
|
|
17
44
|
await worker.run();
|
|
18
45
|
}
|
|
19
|
-
catch {
|
|
20
|
-
log.fatal('worker failed');
|
|
46
|
+
catch (_b) {
|
|
47
|
+
log().fatal('worker failed');
|
|
21
48
|
process.exit(1);
|
|
22
49
|
}
|
|
23
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Exposes a CLI for creating a new worker, in development or production mode.
|
|
53
|
+
*
|
|
54
|
+
* @param opts - Options to launch the worker with
|
|
55
|
+
* @example
|
|
56
|
+
* ```
|
|
57
|
+
* if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
58
|
+
* cli.runApp(new WorkerOptions({ agent: import.meta.filename }));
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
24
62
|
export const runApp = (opts) => {
|
|
25
63
|
const program = new Command()
|
|
26
64
|
.name('agents')
|
|
@@ -28,16 +66,19 @@ export const runApp = (opts) => {
|
|
|
28
66
|
.version(version)
|
|
29
67
|
.addOption(new Option('--log-level <level>', 'Set the logging level')
|
|
30
68
|
.choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])
|
|
31
|
-
.default('
|
|
32
|
-
.
|
|
33
|
-
.
|
|
34
|
-
.env('
|
|
35
|
-
.addOption(new Option('--api-
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
69
|
+
.default('info')
|
|
70
|
+
.env('LOG_LEVEL'))
|
|
71
|
+
.addOption(new Option('--url <string>', 'LiveKit server or Cloud project websocket URL').env('LIVEKIT_URL'))
|
|
72
|
+
.addOption(new Option('--api-key <string>', "LiveKit server or Cloud project's API key").env('LIVEKIT_API_KEY'))
|
|
73
|
+
.addOption(new Option('--api-secret <string>', "LiveKit server or Cloud project's API secret").env('LIVEKIT_API_SECRET'))
|
|
74
|
+
.action(() => {
|
|
75
|
+
if (
|
|
76
|
+
// do not run CLI if origin file is agents/ipc/job_main.js
|
|
77
|
+
process.argv[1] !== new URL('ipc/job_main.js', import.meta.url).pathname ||
|
|
78
|
+
process.argv.length < 3) {
|
|
79
|
+
program.help();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
41
82
|
program
|
|
42
83
|
.command('start')
|
|
43
84
|
.description('Start the worker in production mode')
|
|
@@ -46,11 +87,53 @@ export const runApp = (opts) => {
|
|
|
46
87
|
opts.wsURL = options.url || opts.wsURL;
|
|
47
88
|
opts.apiKey = options.apiKey || opts.apiKey;
|
|
48
89
|
opts.apiSecret = options.apiSecret || opts.apiSecret;
|
|
90
|
+
opts.logLevel = options.logLevel || opts.logLevel;
|
|
49
91
|
runWorker({
|
|
50
92
|
opts,
|
|
51
93
|
production: true,
|
|
52
94
|
watch: false,
|
|
53
|
-
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
program
|
|
98
|
+
.command('dev')
|
|
99
|
+
.description('Start the worker in development mode')
|
|
100
|
+
.addOption(new Option('--log-level <level>', 'Set the logging level')
|
|
101
|
+
.choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])
|
|
102
|
+
.default('debug')
|
|
103
|
+
.env('LOG_LEVEL'))
|
|
104
|
+
.action(() => {
|
|
105
|
+
const options = program.optsWithGlobals();
|
|
106
|
+
opts.wsURL = options.url || opts.wsURL;
|
|
107
|
+
opts.apiKey = options.apiKey || opts.apiKey;
|
|
108
|
+
opts.apiSecret = options.apiSecret || opts.apiSecret;
|
|
109
|
+
opts.logLevel = options.logLevel || opts.logLevel;
|
|
110
|
+
runWorker({
|
|
111
|
+
opts,
|
|
112
|
+
production: false,
|
|
113
|
+
watch: false,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
program
|
|
117
|
+
.command('connect')
|
|
118
|
+
.description('Connect to a specific room')
|
|
119
|
+
.requiredOption('--room <string>', 'Room name to connect to')
|
|
120
|
+
.option('--participant-identity <string>', 'Identity of user to listen to')
|
|
121
|
+
.addOption(new Option('--log-level <level>', 'Set the logging level')
|
|
122
|
+
.choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])
|
|
123
|
+
.default('debug')
|
|
124
|
+
.env('LOG_LEVEL'))
|
|
125
|
+
.action((...[, command]) => {
|
|
126
|
+
const options = command.optsWithGlobals();
|
|
127
|
+
opts.wsURL = options.url || opts.wsURL;
|
|
128
|
+
opts.apiKey = options.apiKey || opts.apiKey;
|
|
129
|
+
opts.apiSecret = options.apiSecret || opts.apiSecret;
|
|
130
|
+
opts.logLevel = options.logLevel || opts.logLevel;
|
|
131
|
+
runWorker({
|
|
132
|
+
opts,
|
|
133
|
+
production: false,
|
|
134
|
+
watch: false,
|
|
135
|
+
room: options.room,
|
|
136
|
+
participantIdentity: options.participantIdentity,
|
|
54
137
|
});
|
|
55
138
|
});
|
|
56
139
|
program.parse();
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAWpD,MAAM,SAAS,GAAG,KAAK,EAAE,IAAa,EAAE,EAAE;IACxC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE1E,yFAAyF;IACzF,MAAM,KAA6B,IAAI,CAAC,IAAI,EAAtC,EAAE,UAAU,EAAE,CAAC,OAAuB,EAAlB,IAAI,cAAxB,cAA0B,CAAY,CAAC,CAAC,wDAAwD;IACtG,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,aAAa,iBAAG,UAAU,EAAE,IAAI,CAAC,UAAU,IAAK,IAAI,EAAG,CAAC,CAAC;IAEvF,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAmB,EAAE,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AAC;SACvD,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D,OAAO,CAAC,OAAO,CAAC;SAChB,GAAG,CAAC,WAAW,CAAC,CACpB;SACA,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACrD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;QAClD,SAAS,CAAC;YACR,IAAI;YACJ,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;SACjD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEL,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC,CAAC"}
|
package/dist/generator.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import type { JobContext } from './
|
|
2
|
-
|
|
1
|
+
import type { JobContext, JobProcess } from './job.js';
|
|
2
|
+
/** @see {@link defineAgent} */
|
|
3
3
|
export interface Agent {
|
|
4
|
-
entry:
|
|
4
|
+
entry: (ctx: JobContext) => Promise<void>;
|
|
5
|
+
prewarm?: (proc: JobProcess) => unknown;
|
|
5
6
|
}
|
|
7
|
+
/** Helper to check if an object is an agent before running it.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function isAgent(obj: unknown): obj is Agent;
|
|
6
12
|
/**
|
|
7
13
|
* Helper to define an agent according to the required interface.
|
|
8
|
-
* @example
|
|
14
|
+
* @example A basic agent with entry and prewarm functions
|
|
15
|
+
* ```
|
|
16
|
+
* export default defineAgent({
|
|
17
|
+
* entry: async (ctx: JobContext) => { ... },
|
|
18
|
+
* prewarm: (proc: JobProcess) => { ... },
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
9
21
|
*/
|
|
10
|
-
export declare function defineAgent(
|
|
11
|
-
export {};
|
|
22
|
+
export declare function defineAgent(agent: Agent): Agent;
|
|
12
23
|
//# sourceMappingURL=generator.d.ts.map
|
package/dist/generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEvD,+BAA+B;AAC/B,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,KAAK,CAQlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAE/C"}
|
package/dist/generator.js
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
+
/** Helper to check if an object is an agent before running it.
|
|
2
|
+
*
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export function isAgent(obj) {
|
|
6
|
+
return (typeof obj === 'object' &&
|
|
7
|
+
obj !== null &&
|
|
8
|
+
'entry' in obj &&
|
|
9
|
+
typeof obj.entry === 'function' &&
|
|
10
|
+
(('prewarm' in obj && typeof obj.prewarm === 'function') || !('prewarm' in obj)));
|
|
11
|
+
}
|
|
1
12
|
/**
|
|
2
13
|
* Helper to define an agent according to the required interface.
|
|
3
|
-
* @example
|
|
14
|
+
* @example A basic agent with entry and prewarm functions
|
|
15
|
+
* ```
|
|
16
|
+
* export default defineAgent({
|
|
17
|
+
* entry: async (ctx: JobContext) => { ... },
|
|
18
|
+
* prewarm: (proc: JobProcess) => { ... },
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
4
21
|
*/
|
|
5
|
-
export function defineAgent(
|
|
6
|
-
return
|
|
22
|
+
export function defineAgent(agent) {
|
|
23
|
+
return agent;
|
|
7
24
|
}
|
|
8
25
|
//# sourceMappingURL=generator.js.map
|
package/dist/generator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAY;IAClC,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,OAAO,IAAI,GAAG;QACd,OAAQ,GAAa,CAAC,KAAK,KAAK,UAAU;QAC1C,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,OAAQ,GAAa,CAAC,OAAO,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,CAC5F,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/http_server.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http_server.d.ts","sourceRoot":"","sources":["../src/http_server.ts"],"names":[],"mappings":";AAGA,OAAO,EAAwB,KAAK,MAAM,EAAqC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"http_server.d.ts","sourceRoot":"","sources":["../src/http_server.ts"],"names":[],"mappings":";AAGA,OAAO,EAAwB,KAAK,MAAM,EAAqC,MAAM,MAAM,CAAC;AAQ5F,qBAAa,UAAU;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;gBAEA,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAchC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAapB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ7B"}
|
package/dist/http_server.js
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { createServer } from 'http';
|
|
5
|
+
import { log } from './log.js';
|
|
5
6
|
const healthCheck = async (res) => {
|
|
6
7
|
res.writeHead(200);
|
|
7
8
|
res.end('OK');
|
|
8
9
|
};
|
|
9
10
|
export class HTTPServer {
|
|
10
|
-
host;
|
|
11
|
-
port;
|
|
12
|
-
app;
|
|
13
11
|
constructor(host, port) {
|
|
14
12
|
this.host = host;
|
|
15
13
|
this.port = port;
|
|
@@ -28,6 +26,10 @@ export class HTTPServer {
|
|
|
28
26
|
this.app.listen(this.port, this.host, (err) => {
|
|
29
27
|
if (err)
|
|
30
28
|
reject(err);
|
|
29
|
+
const address = this.app.address();
|
|
30
|
+
if (typeof address !== 'string') {
|
|
31
|
+
log().info(`Server is listening on port ${address.port}`);
|
|
32
|
+
}
|
|
31
33
|
resolve();
|
|
32
34
|
});
|
|
33
35
|
});
|