tirtc-devtools-cli 0.0.13 → 0.0.15

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 (137) hide show
  1. package/README.md +42 -46
  2. package/USAGE.md +87 -312
  3. package/dist/cli/src/embedded_paths.d.ts +0 -2
  4. package/dist/cli/src/embedded_paths.js +3 -25
  5. package/dist/cli/src/index.js +82 -584
  6. package/dist/cli/src/role_driver.d.ts +33 -0
  7. package/dist/cli/src/role_driver.js +500 -0
  8. package/dist/cli/src/token_command.js +4 -2
  9. package/dist/cli/src/token_issue.d.ts +9 -0
  10. package/dist/cli/src/token_issue.js +138 -0
  11. package/dist/cli/src/token_tool.d.ts +2 -4
  12. package/dist/cli/src/token_tool.js +12 -186
  13. package/package.json +3 -2
  14. package/vendor/devtools/driver/macos-arm64/devtools_driver_probe +0 -0
  15. package/vendor/devtools/driver/macos-arm64/runtime_validation_client_bin +0 -0
  16. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio.h +56 -2
  17. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io.h +9 -0
  18. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/av.h +52 -0
  19. package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/error.h +11 -0
  20. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/media_downlink.h +11 -5
  21. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/media_uplink.h +4 -0
  22. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/transport.h +52 -15
  23. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/trp.h +7 -5
  24. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_codec.h +41 -0
  25. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io.h +7 -0
  26. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_android.h +2 -0
  27. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
  28. package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  29. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
  30. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  31. package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  32. package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  33. package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  34. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/manifest.txt +20 -25
  35. package/vendor/runtime/script/prepare_runtime_media_dataset.sh +308 -12
  36. package/dist/app-server/protocol-client/index.d.ts +0 -25
  37. package/dist/app-server/protocol-client/index.js +0 -114
  38. package/dist/cli/src/bootstrap_flows.d.ts +0 -46
  39. package/dist/cli/src/bootstrap_flows.js +0 -249
  40. package/dist/cli/src/config.d.ts +0 -26
  41. package/dist/cli/src/config.js +0 -62
  42. package/dist/cli/src/facade.d.ts +0 -430
  43. package/dist/cli/src/facade.js +0 -170
  44. package/dist/cli/src/guide.d.ts +0 -1
  45. package/dist/cli/src/guide.js +0 -48
  46. package/dist/cli/src/session_manager.d.ts +0 -25
  47. package/dist/cli/src/session_manager.js +0 -391
  48. package/dist/cli/src/transport.d.ts +0 -30
  49. package/dist/cli/src/transport.js +0 -84
  50. package/vendor/app-server/bin/native/linux-x64/credential_napi.node +0 -0
  51. package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
  52. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/credential.h +0 -34
  53. package/vendor/app-server/bin/runtime/linux-x64/lib/libcrypto.a +0 -0
  54. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_credential.a +0 -0
  55. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_http.a +0 -0
  56. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  57. package/vendor/app-server/bin/runtime/linux-x64/lib/libssl.a +0 -0
  58. package/vendor/app-server/bin/runtime/linux-x64/lib/libxlog.a +0 -0
  59. package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +0 -4
  60. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/credential.h +0 -34
  61. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +0 -52
  62. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/foundation/build_info.h +0 -27
  63. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/http.h +0 -57
  64. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/logging.h +0 -55
  65. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_av_sync.h +0 -61
  66. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_source.h +0 -77
  67. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_live_source.h +0 -71
  68. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
  69. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  70. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  71. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  72. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  73. package/vendor/app-server/bin/tirtc-devtool-host.js +0 -2
  74. package/vendor/app-server/dist/host/ArtifactManager.d.ts +0 -18
  75. package/vendor/app-server/dist/host/ArtifactManager.js +0 -98
  76. package/vendor/app-server/dist/host/HostCommandCoordinator.d.ts +0 -19
  77. package/vendor/app-server/dist/host/HostCommandCoordinator.js +0 -196
  78. package/vendor/app-server/dist/host/HostProtocol.d.ts +0 -103
  79. package/vendor/app-server/dist/host/HostProtocol.js +0 -239
  80. package/vendor/app-server/dist/host/HostServer.d.ts +0 -52
  81. package/vendor/app-server/dist/host/HostServer.js +0 -727
  82. package/vendor/app-server/dist/host/HostState.d.ts +0 -69
  83. package/vendor/app-server/dist/host/HostState.js +0 -19
  84. package/vendor/app-server/dist/host/RuntimeAdapter.d.ts +0 -95
  85. package/vendor/app-server/dist/host/RuntimeAdapter.js +0 -636
  86. package/vendor/app-server/dist/host/RuntimeReceiveWorker.d.ts +0 -37
  87. package/vendor/app-server/dist/host/RuntimeReceiveWorker.js +0 -186
  88. package/vendor/app-server/dist/host/RuntimeSendWorker.d.ts +0 -58
  89. package/vendor/app-server/dist/host/RuntimeSendWorker.js +0 -438
  90. package/vendor/app-server/dist/host/TokenTool.d.ts +0 -15
  91. package/vendor/app-server/dist/host/TokenTool.js +0 -84
  92. package/vendor/app-server/dist/host/WebPreviewGateway.d.ts +0 -28
  93. package/vendor/app-server/dist/host/WebPreviewGateway.js +0 -815
  94. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.d.ts +0 -23
  95. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +0 -115
  96. package/vendor/app-server/dist/host/native/RuntimeHostBridge.d.ts +0 -32
  97. package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +0 -157
  98. package/vendor/app-server/dist/host/runtime_backed_preflight.d.ts +0 -10
  99. package/vendor/app-server/dist/host/runtime_backed_preflight.js +0 -78
  100. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.d.ts +0 -28
  101. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.js +0 -85
  102. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.d.ts +0 -10
  103. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +0 -41
  104. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.d.ts +0 -11
  105. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.js +0 -32
  106. package/vendor/app-server/dist/protocol/contract.d.ts +0 -1128
  107. package/vendor/app-server/dist/protocol/contract.js +0 -217
  108. package/vendor/app-server/dist/protocol-client/index.d.ts +0 -25
  109. package/vendor/app-server/dist/protocol-client/index.js +0 -114
  110. package/vendor/app-server/dist/src/index.d.ts +0 -1
  111. package/vendor/app-server/dist/src/index.js +0 -294
  112. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_codec.h +0 -0
  113. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_frame.h +0 -0
  114. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_android.h +0 -0
  115. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_apple.h +0 -0
  116. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_harmony.h +0 -0
  117. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_windows.h +0 -0
  118. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_processing.h +0 -0
  119. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_sample_rate.h +0 -0
  120. /package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/foundation/build_info.h +0 -0
  121. /package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/http.h +0 -0
  122. /package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/logging.h +0 -0
  123. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/media_codec.h +0 -0
  124. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_frame.h +0 -0
  125. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_apple.h +0 -0
  126. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_harmony.h +0 -0
  127. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_windows.h +0 -0
  128. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_processing.h +0 -0
  129. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libTGTRP.a +0 -0
  130. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libTiRTC.a +0 -0
  131. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libcrypto.a +0 -0
  132. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libcrypto.dylib +0 -0
  133. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libssl.a +0 -0
  134. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libssl.dylib +0 -0
  135. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libtgrtc.dylib +0 -0
  136. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libwebrtc_apm.a +0 -0
  137. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libxlog.a +0 -0
@@ -1,217 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DebugTokenQrcodeResultSchema = exports.DebugTokenQrcodeRequestSchema = exports.EventsSubscribeRequestSchema = exports.CommandSendRequestSchema = exports.OutputAttachRequestSchema = exports.StreamMessageSendRequestSchema = exports.StreamSendStartRequestSchema = exports.ConnectionConnectRequestSchema = exports.ServiceStartRequestSchema = exports.ArtifactExportResultSchema = exports.ReportDocumentSchema = exports.ErrorSummarySchema = exports.CommandPendingListResultSchema = exports.CommandPendingListRequestSchema = exports.CommandReplyResultSchema = exports.CommandReplyRequestSchema = exports.CommandSendResultSchema = exports.CommandPendingEntrySchema = exports.CommandPendingConnectionSchema = exports.CommandResponseSchema = exports.OutputAttachmentSchema = exports.HostStatusSchema = exports.ArtifactPathsSchema = exports.StreamSnapshotSchema = exports.StreamSourceSchema = exports.StreamLocalAssetsSchema = exports.ConnectionSnapshotSchema = exports.ServiceSnapshotSchema = exports.EventEnvelopeSchema = exports.ErrorResponseSchema = exports.InitializedNotificationSchema = exports.InitializeResultSchema = exports.InitializeRequestSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.InitializeRequestSchema = zod_1.z.object({
6
- protocolVersion: zod_1.z.string(),
7
- clientInfo: zod_1.z.object({
8
- name: zod_1.z.string(),
9
- version: zod_1.z.string(),
10
- title: zod_1.z.string().optional()
11
- }),
12
- capabilities: zod_1.z.object({
13
- experimentalApi: zod_1.z.boolean().optional(),
14
- optOutNotificationMethods: zod_1.z.array(zod_1.z.string()).optional()
15
- }).optional()
16
- });
17
- exports.InitializeResultSchema = zod_1.z.object({
18
- serverInfo: zod_1.z.object({
19
- name: zod_1.z.string(),
20
- version: zod_1.z.string()
21
- }),
22
- protocolVersion: zod_1.z.string(),
23
- runtimeTarget: zod_1.z.string(),
24
- hostEndpoint: zod_1.z.string(),
25
- capabilities: zod_1.z.record(zod_1.z.any())
26
- });
27
- exports.InitializedNotificationSchema = zod_1.z.object({});
28
- exports.ErrorResponseSchema = zod_1.z.object({
29
- reasonCode: zod_1.z.string(),
30
- message: zod_1.z.string(),
31
- retryable: zod_1.z.boolean()
32
- });
33
- exports.EventEnvelopeSchema = zod_1.z.object({
34
- eventId: zod_1.z.string(),
35
- timestamp: zod_1.z.string(),
36
- family: zod_1.z.string(),
37
- kind: zod_1.z.string(),
38
- payload: zod_1.z.record(zod_1.z.any())
39
- });
40
- exports.ServiceSnapshotSchema = zod_1.z.object({
41
- state: zod_1.z.string(),
42
- serviceEntry: zod_1.z.string().optional(),
43
- localEndpoint: zod_1.z.string().optional(),
44
- startedAt: zod_1.z.string().optional(),
45
- stoppedAt: zod_1.z.string().optional(),
46
- reasonCode: zod_1.z.string().optional()
47
- });
48
- exports.ConnectionSnapshotSchema = zod_1.z.object({
49
- state: zod_1.z.string(),
50
- direction: zod_1.z.string().optional(),
51
- peerId: zod_1.z.string().optional(),
52
- connectedAt: zod_1.z.string().optional(),
53
- disconnectedAt: zod_1.z.string().optional(),
54
- reasonCode: zod_1.z.string().optional()
55
- });
56
- exports.StreamLocalAssetsSchema = zod_1.z.object({
57
- assets_dir: zod_1.z.string(),
58
- });
59
- exports.StreamSourceSchema = zod_1.z.object({
60
- mode: zod_1.z.literal('local_assets'),
61
- local_assets: exports.StreamLocalAssetsSchema,
62
- });
63
- exports.StreamSnapshotSchema = zod_1.z.object({
64
- streamId: zod_1.z.number().int(),
65
- media: zod_1.z.string(),
66
- direction: zod_1.z.string(),
67
- state: zod_1.z.string(),
68
- source: exports.StreamSourceSchema.optional(),
69
- updatedAt: zod_1.z.string()
70
- });
71
- exports.ArtifactPathsSchema = zod_1.z.object({
72
- rootPath: zod_1.z.string(),
73
- reportPath: zod_1.z.string(),
74
- logsPath: zod_1.z.string(),
75
- eventsPath: zod_1.z.string(),
76
- receivedMediaPath: zod_1.z.string(),
77
- prepareCachePath: zod_1.z.string()
78
- });
79
- exports.HostStatusSchema = zod_1.z.object({
80
- hostEndpoint: zod_1.z.string(),
81
- serverVersion: zod_1.z.string(),
82
- protocolVersion: zod_1.z.string(),
83
- runtimeTarget: zod_1.z.string(),
84
- startedAt: zod_1.z.string(),
85
- service: exports.ServiceSnapshotSchema,
86
- connection: exports.ConnectionSnapshotSchema,
87
- artifactPaths: exports.ArtifactPathsSchema
88
- });
89
- exports.OutputAttachmentSchema = zod_1.z.object({
90
- outputId: zod_1.z.string(),
91
- streamId: zod_1.z.number().int(),
92
- consumer: zod_1.z.string(),
93
- mediaView: zod_1.z.string(),
94
- format: zod_1.z.string(),
95
- delivery: zod_1.z.string(),
96
- target: zod_1.z.string(),
97
- attachedAt: zod_1.z.string(),
98
- preview: zod_1.z.object({
99
- url: zod_1.z.string(),
100
- token: zod_1.z.string(),
101
- endpoint: zod_1.z.string(),
102
- }).optional(),
103
- });
104
- exports.CommandResponseSchema = zod_1.z.object({
105
- sequenceNumber: zod_1.z.number().int(),
106
- payloadEncoding: zod_1.z.string(),
107
- payload: zod_1.z.string()
108
- });
109
- exports.CommandPendingConnectionSchema = zod_1.z.object({
110
- state: zod_1.z.string(),
111
- direction: zod_1.z.string().optional(),
112
- peerId: zod_1.z.string().optional(),
113
- });
114
- exports.CommandPendingEntrySchema = zod_1.z.object({
115
- remoteRequestId: zod_1.z.number().int(),
116
- commandId: zod_1.z.number().int(),
117
- payloadEncoding: zod_1.z.string(),
118
- payload: zod_1.z.string(),
119
- receivedAt: zod_1.z.string(),
120
- connection: exports.CommandPendingConnectionSchema,
121
- });
122
- exports.CommandSendResultSchema = zod_1.z.object({
123
- sequenceNumber: zod_1.z.number().int(),
124
- commandId: zod_1.z.number().int(),
125
- acceptedAt: zod_1.z.string(),
126
- response: exports.CommandResponseSchema.optional()
127
- });
128
- exports.CommandReplyRequestSchema = zod_1.z.object({
129
- remoteRequestId: zod_1.z.number().int(),
130
- commandId: zod_1.z.number().int(),
131
- payloadEncoding: zod_1.z.string(),
132
- payload: zod_1.z.string(),
133
- });
134
- exports.CommandReplyResultSchema = zod_1.z.object({
135
- remoteRequestId: zod_1.z.number().int(),
136
- commandId: zod_1.z.number().int(),
137
- repliedAt: zod_1.z.string(),
138
- });
139
- exports.CommandPendingListRequestSchema = zod_1.z.object({}).passthrough();
140
- exports.CommandPendingListResultSchema = zod_1.z.object({
141
- items: zod_1.z.array(exports.CommandPendingEntrySchema),
142
- listedAt: zod_1.z.string(),
143
- });
144
- exports.ErrorSummarySchema = zod_1.z.object({
145
- reasonCode: zod_1.z.string(),
146
- message: zod_1.z.string(),
147
- retryable: zod_1.z.boolean()
148
- });
149
- exports.ReportDocumentSchema = zod_1.z.object({
150
- status: zod_1.z.string(),
151
- reasonCode: zod_1.z.string(),
152
- summary: zod_1.z.string(),
153
- service: exports.ServiceSnapshotSchema,
154
- connection: exports.ConnectionSnapshotSchema,
155
- streams: zod_1.z.array(exports.StreamSnapshotSchema),
156
- artifacts: exports.ArtifactPathsSchema,
157
- lastError: exports.ErrorSummarySchema.optional()
158
- });
159
- exports.ArtifactExportResultSchema = zod_1.z.object({
160
- outputPath: zod_1.z.string(),
161
- exportedAt: zod_1.z.string()
162
- });
163
- exports.ServiceStartRequestSchema = zod_1.z.object({
164
- serviceEntry: zod_1.z.string().optional(),
165
- license: zod_1.z.string(),
166
- timeoutMs: zod_1.z.number().int(),
167
- bootstrapSendStreams: zod_1.z.array(zod_1.z.object({
168
- streamId: zod_1.z.number().int(),
169
- media: zod_1.z.enum(['audio', 'video']),
170
- source: exports.StreamSourceSchema,
171
- })).optional(),
172
- });
173
- exports.ConnectionConnectRequestSchema = zod_1.z.object({
174
- serviceEntry: zod_1.z.string().optional(),
175
- peerId: zod_1.z.string(),
176
- token: zod_1.z.string().min(1),
177
- timeoutMs: zod_1.z.number().int()
178
- }).refine((value) => value.token.trim().length > 0, {
179
- message: "token is required",
180
- });
181
- exports.StreamSendStartRequestSchema = zod_1.z.object({
182
- streamId: zod_1.z.number().int(),
183
- media: zod_1.z.string(),
184
- source: exports.StreamSourceSchema,
185
- });
186
- exports.StreamMessageSendRequestSchema = zod_1.z.object({
187
- streamId: zod_1.z.number().int(),
188
- payload: zod_1.z.string(),
189
- });
190
- exports.OutputAttachRequestSchema = zod_1.z.object({
191
- streamId: zod_1.z.number().int(),
192
- consumer: zod_1.z.string(),
193
- mediaView: zod_1.z.string(),
194
- format: zod_1.z.string(),
195
- delivery: zod_1.z.string(),
196
- targetPath: zod_1.z.string().optional(),
197
- maxFiles: zod_1.z.number().int().optional()
198
- });
199
- exports.CommandSendRequestSchema = zod_1.z.object({
200
- commandId: zod_1.z.number().int(),
201
- payloadEncoding: zod_1.z.string(),
202
- payload: zod_1.z.string(),
203
- timeoutMs: zod_1.z.number().int().optional()
204
- });
205
- exports.EventsSubscribeRequestSchema = zod_1.z.object({
206
- families: zod_1.z.array(zod_1.z.string())
207
- });
208
- exports.DebugTokenQrcodeRequestSchema = zod_1.z.object({
209
- payload: zod_1.z.string(),
210
- outputStem: zod_1.z.string().optional()
211
- });
212
- exports.DebugTokenQrcodeResultSchema = zod_1.z.object({
213
- payload: zod_1.z.string(),
214
- qrAsciiPath: zod_1.z.string(),
215
- qrPngPath: zod_1.z.string(),
216
- generatedAt: zod_1.z.string()
217
- });
@@ -1,25 +0,0 @@
1
- import { EventEmitter } from 'events';
2
- export interface Transport {
3
- send(data: string): void;
4
- onMessage(handler: (data: string) => void): void;
5
- onClose(handler: () => void): void;
6
- onError(handler: (error: Error) => void): void;
7
- }
8
- export declare class AppServerClient extends EventEmitter {
9
- private transport;
10
- private pendingRequests;
11
- initialized: boolean;
12
- private buffer;
13
- constructor(transport: Transport);
14
- private rejectAllPending;
15
- private handleData;
16
- private handleMessage;
17
- sendRequest(method: string, params?: unknown, timeoutMs?: number): Promise<unknown>;
18
- sendNotification(method: string, params?: unknown): void;
19
- initialize(clientInfo: {
20
- name: string;
21
- version: string;
22
- title?: string;
23
- }, capabilities?: unknown): Promise<unknown>;
24
- subscribeEvents(families: string[]): Promise<unknown>;
25
- }
@@ -1,114 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppServerClient = void 0;
4
- const events_1 = require("events");
5
- const crypto_1 = require("crypto");
6
- class AppServerClient extends events_1.EventEmitter {
7
- transport;
8
- pendingRequests;
9
- initialized = false;
10
- buffer = '';
11
- constructor(transport) {
12
- super();
13
- this.transport = transport;
14
- this.pendingRequests = new Map();
15
- this.transport.onMessage((data) => this.handleData(data));
16
- this.transport.onError((error) => {
17
- this.emit('error', error);
18
- this.rejectAllPending(error);
19
- });
20
- this.transport.onClose(() => {
21
- const error = new Error('transport closed');
22
- this.emit('close');
23
- this.rejectAllPending(error);
24
- });
25
- }
26
- rejectAllPending(error) {
27
- for (const [id, req] of this.pendingRequests.entries()) {
28
- this.pendingRequests.delete(id);
29
- if (req.timeoutTimer) {
30
- clearTimeout(req.timeoutTimer);
31
- }
32
- req.reject(error);
33
- }
34
- }
35
- handleData(chunk) {
36
- this.buffer += chunk;
37
- const lines = this.buffer.split('\n');
38
- this.buffer = lines.pop() || '';
39
- for (const line of lines) {
40
- if (!line.trim()) {
41
- continue;
42
- }
43
- try {
44
- const msg = JSON.parse(line);
45
- this.handleMessage(msg);
46
- }
47
- catch {
48
- this.emit('error', new Error(`Failed to parse message: ${line}`));
49
- }
50
- }
51
- }
52
- handleMessage(msg) {
53
- if (msg.id !== undefined && (msg.result !== undefined || msg.error !== undefined)) {
54
- const req = this.pendingRequests.get(msg.id);
55
- if (req) {
56
- this.pendingRequests.delete(msg.id);
57
- if (req.timeoutTimer) {
58
- clearTimeout(req.timeoutTimer);
59
- }
60
- if (msg.error !== undefined) {
61
- req.reject(msg.error);
62
- }
63
- else {
64
- req.resolve(msg.result);
65
- }
66
- }
67
- return;
68
- }
69
- if (msg.method !== undefined && msg.id === undefined) {
70
- this.emit('notification', msg.method, msg.params);
71
- if (msg.method === 'events/event') {
72
- this.emit('event', msg.params);
73
- }
74
- }
75
- }
76
- async sendRequest(method, params, timeoutMs = 30_000) {
77
- const id = (0, crypto_1.randomUUID)();
78
- return await new Promise((resolve, reject) => {
79
- const pending = { resolve, reject };
80
- pending.timeoutTimer = setTimeout(() => {
81
- this.pendingRequests.delete(id);
82
- reject(new Error(`request timeout after ${timeoutMs}ms: ${method}`));
83
- }, timeoutMs);
84
- this.pendingRequests.set(id, pending);
85
- const payload = JSON.stringify({
86
- id,
87
- method,
88
- params,
89
- });
90
- this.transport.send(`${payload}\n`);
91
- });
92
- }
93
- sendNotification(method, params) {
94
- const payload = JSON.stringify({
95
- method,
96
- params
97
- });
98
- this.transport.send(`${payload}\n`);
99
- }
100
- async initialize(clientInfo, capabilities) {
101
- const result = await this.sendRequest('initialize', {
102
- protocolVersion: '1.0.0',
103
- clientInfo,
104
- capabilities
105
- });
106
- this.sendNotification('initialized');
107
- this.initialized = true;
108
- return result;
109
- }
110
- async subscribeEvents(families) {
111
- return await this.sendRequest('events/subscribe', { families });
112
- }
113
- }
114
- exports.AppServerClient = AppServerClient;
@@ -1 +0,0 @@
1
- export {};
@@ -1,294 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const fs = __importStar(require("fs"));
37
- const net = __importStar(require("net"));
38
- const os = __importStar(require("os"));
39
- const path = __importStar(require("path"));
40
- const readline = __importStar(require("readline"));
41
- const ArtifactManager_1 = require("../host/ArtifactManager");
42
- const HostServer_1 = require("../host/HostServer");
43
- const RuntimeAdapter_1 = require("../host/RuntimeAdapter");
44
- const HOST_VERSION = '1.0.0';
45
- const PROTOCOL_VERSION = '1.0.0';
46
- const args = process.argv.slice(2);
47
- const kSessionLoggingEventIntervalMs = 500;
48
- if (args.includes('--version') || args.includes('-v')) {
49
- console.log('Host Version: ' + HOST_VERSION);
50
- console.log('Protocol Version: ' + PROTOCOL_VERSION);
51
- process.exit(0);
52
- }
53
- function readFlagValue(flag) {
54
- const idx = args.indexOf(flag);
55
- if (idx < 0) {
56
- return undefined;
57
- }
58
- const value = args[idx + 1];
59
- if (!value || value.startsWith('-')) {
60
- throw new Error(`Missing value for ${flag}`);
61
- }
62
- return value;
63
- }
64
- function resolveRuntimePlatform() {
65
- const raw = process.env.TIRTC_RUNTIME_PLATFORM;
66
- if (raw && raw.trim().length > 0) {
67
- return raw.trim();
68
- }
69
- if (os.platform() === 'darwin' && os.arch() === 'arm64') {
70
- return 'macos-arm64';
71
- }
72
- return 'linux-x64';
73
- }
74
- function resolveRuntimeBundleRoot(platform) {
75
- const explicit = process.env.TIRTC_RUNTIME_BUNDLE_ROOT;
76
- if (explicit && explicit.trim().length > 0) {
77
- return explicit.trim();
78
- }
79
- const appServerRoot = process.env.TIRTC_APP_SERVER_ROOT;
80
- const candidates = [
81
- appServerRoot ? path.resolve(appServerRoot, 'bin/runtime', platform) : '',
82
- path.resolve(__dirname, '../bin/runtime', platform),
83
- path.resolve(__dirname, '../../bin/runtime', platform),
84
- path.resolve(process.cwd(), 'bin/runtime', platform),
85
- path.resolve(process.cwd(), '../bin/runtime', platform),
86
- ].filter((entry) => entry.length > 0);
87
- for (const candidate of candidates) {
88
- const manifest = path.join(candidate, 'manifest.txt');
89
- if (fs.existsSync(manifest)) {
90
- return candidate;
91
- }
92
- }
93
- return candidates[0];
94
- }
95
- function resolveArtifactRoot() {
96
- const explicit = process.env.TIRTC_HOST_ARTIFACT_DIR;
97
- if (explicit && explicit.trim().length > 0) {
98
- return explicit.trim();
99
- }
100
- return path.join(os.tmpdir(), 'tirtc-artifacts');
101
- }
102
- function resolveHostLogDir() {
103
- const explicit = process.env.TIRTC_HOST_LOG_DIR;
104
- if (explicit && explicit.trim().length > 0) {
105
- return explicit.trim();
106
- }
107
- return path.join(resolveArtifactRoot(), 'logs');
108
- }
109
- function resolveConsoleMirrorEnabled() {
110
- const raw = process.env.TIRTC_HOST_LOG_STDOUT_MIRROR;
111
- if (!raw || raw.trim().length === 0) {
112
- return true;
113
- }
114
- const normalized = raw.trim().toLowerCase();
115
- return normalized !== '0' && normalized !== 'false' && normalized !== 'off' && normalized !== 'no';
116
- }
117
- function ensureArtifactRoot(dir) {
118
- if (!fs.existsSync(dir)) {
119
- fs.mkdirSync(dir, { recursive: true });
120
- }
121
- }
122
- function createRuntimeAdapter() {
123
- const platform = resolveRuntimePlatform();
124
- const runtimeBundleRoot = resolveRuntimeBundleRoot(platform);
125
- return new RuntimeAdapter_1.RuntimeBackedAdapter({
126
- platform,
127
- runtimeBundleRoot,
128
- });
129
- }
130
- function resolveHostEndpoint(socketPath) {
131
- const explicit = process.env.TIRTC_HOST_ENDPOINT;
132
- if (explicit && explicit.trim().length > 0) {
133
- return explicit.trim();
134
- }
135
- if (socketPath && socketPath.trim().length > 0) {
136
- return `ipc://${socketPath}`;
137
- }
138
- return 'stdio://runtime-backed';
139
- }
140
- function createSessionLogger(hostServer, logDir, mirrorToConsole) {
141
- if (!fs.existsSync(logDir)) {
142
- fs.mkdirSync(logDir, { recursive: true });
143
- }
144
- const runtimeLogPath = path.join(logDir, 'runtime.host.log');
145
- let pending = [];
146
- const flushTimer = setInterval(() => {
147
- if (pending.length === 0) {
148
- return;
149
- }
150
- const chunk = pending.join('');
151
- pending = [];
152
- try {
153
- fs.appendFileSync(runtimeLogPath, chunk);
154
- }
155
- catch {
156
- // no-op
157
- }
158
- }, kSessionLoggingEventIntervalMs);
159
- const append = (level, message) => {
160
- const line = `[${new Date().toISOString()}][${level}] ${message}`;
161
- pending.push(line.endsWith('\n') ? line : line + '\n');
162
- hostServer.appendHostLog(line);
163
- if (mirrorToConsole) {
164
- if (level === 'error') {
165
- console.error(message);
166
- }
167
- else {
168
- console.log(message);
169
- }
170
- }
171
- };
172
- return {
173
- info: (message) => append('info', message),
174
- error: (message) => append('error', message),
175
- stop: () => {
176
- clearInterval(flushTimer);
177
- if (pending.length > 0) {
178
- try {
179
- fs.appendFileSync(runtimeLogPath, pending.join(''));
180
- }
181
- catch {
182
- // no-op
183
- }
184
- }
185
- pending = [];
186
- },
187
- };
188
- }
189
- function bindLineProtocol(input, output, hostServer, onClose) {
190
- const rl = readline.createInterface({
191
- input,
192
- terminal: false,
193
- });
194
- rl.on('line', async (line) => {
195
- if (!line.trim()) {
196
- return;
197
- }
198
- const response = await hostServer.handleMessage(line);
199
- if (response) {
200
- output.write(response + '\n');
201
- }
202
- });
203
- rl.on('close', () => {
204
- if (onClose) {
205
- onClose();
206
- }
207
- });
208
- }
209
- function startStdio(hostServer, runtimeTarget) {
210
- bindLineProtocol(process.stdin, process.stdout, hostServer);
211
- console.error('TiRTC App Server Host v' +
212
- HOST_VERSION +
213
- ' (Protocol v' +
214
- PROTOCOL_VERSION +
215
- ') started on stdio [runtimeTarget=' +
216
- runtimeTarget +
217
- ']');
218
- }
219
- function startSocket(socketPath, hostServer, runtimeTarget) {
220
- if (fs.existsSync(socketPath)) {
221
- fs.unlinkSync(socketPath);
222
- }
223
- const server = net.createServer((socket) => {
224
- const sink = (event) => {
225
- if (socket.destroyed) {
226
- return;
227
- }
228
- socket.write(JSON.stringify({ method: 'events/event', params: event }) + '\n');
229
- };
230
- hostServer.addEventSink(sink);
231
- bindLineProtocol(socket, socket, hostServer, () => {
232
- hostServer.removeEventSink(sink);
233
- });
234
- socket.on('close', () => {
235
- hostServer.removeEventSink(sink);
236
- });
237
- socket.on('error', () => {
238
- hostServer.removeEventSink(sink);
239
- });
240
- });
241
- server.listen(socketPath, () => {
242
- console.error('TiRTC App Server Host v' +
243
- HOST_VERSION +
244
- ' (Protocol v' +
245
- PROTOCOL_VERSION +
246
- ') started on ipc://' +
247
- socketPath +
248
- ' [runtimeTarget=' +
249
- runtimeTarget +
250
- ']');
251
- });
252
- const cleanup = () => {
253
- server.close();
254
- if (fs.existsSync(socketPath)) {
255
- fs.unlinkSync(socketPath);
256
- }
257
- };
258
- process.on('SIGINT', cleanup);
259
- process.on('SIGTERM', cleanup);
260
- }
261
- const socketPath = readFlagValue('--socket');
262
- const artifactRoot = resolveArtifactRoot();
263
- ensureArtifactRoot(artifactRoot);
264
- const runtimeAdapter = createRuntimeAdapter();
265
- const artifactManager = new ArtifactManager_1.ArtifactManager(artifactRoot);
266
- artifactManager.setupLayout();
267
- const hostEndpoint = resolveHostEndpoint(socketPath);
268
- const hostServer = new HostServer_1.HostServer(artifactManager, runtimeAdapter, hostEndpoint);
269
- const hostLogDir = resolveHostLogDir();
270
- const sessionLogger = createSessionLogger(hostServer, hostLogDir, resolveConsoleMirrorEnabled());
271
- sessionLogger.info('TiRTC App Server Host v' +
272
- HOST_VERSION +
273
- ' (Protocol v' +
274
- PROTOCOL_VERSION +
275
- ') booting [runtimeTarget=' +
276
- runtimeAdapter.runtimeTarget +
277
- ']');
278
- process.on('uncaughtException', (error) => {
279
- sessionLogger.error('uncaughtException: ' + (error instanceof Error ? error.stack ?? error.message : String(error)));
280
- });
281
- process.on('unhandledRejection', (reason) => {
282
- sessionLogger.error('unhandledRejection: ' + (reason instanceof Error ? reason.stack ?? reason.message : String(reason)));
283
- });
284
- process.on('exit', () => {
285
- sessionLogger.stop();
286
- });
287
- if (socketPath) {
288
- startSocket(socketPath, hostServer, runtimeAdapter.runtimeTarget);
289
- sessionLogger.info('listening on ipc://' + socketPath);
290
- }
291
- else {
292
- startStdio(hostServer, runtimeAdapter.runtimeTarget);
293
- sessionLogger.info('listening on stdio');
294
- }