tirtc-devtools-cli 0.0.10 → 0.0.12

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 (116) hide show
  1. package/README.md +17 -11
  2. package/USAGE.md +148 -41
  3. package/bin/tirtc-devtools-cli.js +1 -1
  4. package/dist/cli/src/bootstrap_flows.d.ts +46 -0
  5. package/dist/cli/src/bootstrap_flows.js +249 -0
  6. package/dist/{devtools/cli → cli}/src/config.d.ts +4 -15
  7. package/dist/{devtools/cli → cli}/src/config.js +8 -8
  8. package/dist/cli/src/default_paths.d.ts +3 -0
  9. package/dist/cli/src/default_paths.js +23 -0
  10. package/dist/{devtools/cli → cli}/src/embedded_paths.d.ts +1 -0
  11. package/dist/{devtools/cli → cli}/src/embedded_paths.js +18 -1
  12. package/dist/{devtools/cli → cli}/src/facade.d.ts +41 -235
  13. package/dist/{devtools/cli → cli}/src/facade.js +8 -27
  14. package/dist/cli/src/guide.js +47 -0
  15. package/dist/{devtools/cli → cli}/src/index.js +67 -153
  16. package/dist/{devtools/cli → cli}/src/session_manager.js +9 -11
  17. package/dist/{devtools/cli → cli}/src/token_command.js +80 -16
  18. package/dist/cli/src/token_tool.d.ts +55 -0
  19. package/dist/{devtools/cli → cli}/src/token_tool.js +143 -47
  20. package/dist/{devtools/cli → cli}/src/transport.d.ts +1 -1
  21. package/package.json +6 -2
  22. package/script/ensure_ffmpeg.sh +1 -1
  23. package/vendor/app-server/bin/native/linux-x64/credential_napi.node +0 -0
  24. package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
  25. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/credential.h +34 -0
  26. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/error.h +13 -0
  27. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/foundation/build_info.h +27 -0
  28. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/http.h +57 -0
  29. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/logging.h +3 -1
  30. package/vendor/app-server/bin/runtime/linux-x64/lib/libcrypto.a +0 -0
  31. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_credential.a +0 -0
  32. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_http.a +0 -0
  33. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  34. package/vendor/app-server/bin/runtime/linux-x64/lib/libssl.a +0 -0
  35. package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +2 -32
  36. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +44 -305
  37. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +52 -372
  38. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +2 -0
  39. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_downlink.h +6 -0
  40. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/transport.h +58 -133
  41. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +56 -511
  42. package/vendor/app-server/bin/runtime/macos-arm64/lib/libTGTRP.a +0 -0
  43. package/vendor/app-server/bin/runtime/macos-arm64/lib/libTiRTC.a +0 -0
  44. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
  45. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
  46. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  47. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
  48. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  49. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  50. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  51. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  52. package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +19 -15
  53. package/vendor/app-server/dist/host/HostCommandCoordinator.d.ts +19 -0
  54. package/vendor/app-server/dist/host/HostCommandCoordinator.js +196 -0
  55. package/vendor/app-server/dist/host/HostProtocol.d.ts +1 -11
  56. package/vendor/app-server/dist/host/HostProtocol.js +3 -37
  57. package/vendor/app-server/dist/host/HostServer.d.ts +1 -4
  58. package/vendor/app-server/dist/host/HostServer.js +16 -152
  59. package/vendor/app-server/dist/host/RuntimeAdapter.js +2 -2
  60. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +3 -3
  61. package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +4 -4
  62. package/vendor/app-server/dist/host/runtime_backed_preflight.js +2 -2
  63. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +1 -1
  64. package/vendor/app-server/dist/protocol/contract.d.ts +5 -64
  65. package/vendor/app-server/dist/protocol/contract.js +3 -12
  66. package/dist/devtools/cli/src/guide.js +0 -50
  67. package/dist/devtools/cli/src/token_tool.d.ts +0 -38
  68. package/dist/dummy.d.ts +0 -0
  69. package/dist/dummy.js +0 -1
  70. package/dist/index.d.ts +0 -1
  71. package/dist/index.js +0 -48
  72. package/vendor/app-server/bin/native/macos-arm64/libcrypto.dylib +0 -0
  73. package/vendor/app-server/bin/native/macos-arm64/libssl.dylib +0 -0
  74. package/vendor/app-server/bin/native/macos-arm64/runtime_host_napi.node +0 -0
  75. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_codec.h +0 -23
  76. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_frame.h +0 -36
  77. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io.h +0 -56
  78. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_android.h +0 -19
  79. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_apple.h +0 -19
  80. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_harmony.h +0 -19
  81. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_windows.h +0 -19
  82. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_processing.h +0 -56
  83. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_sample_rate.h +0 -18
  84. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_codec.h +0 -21
  85. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_downlink.h +0 -89
  86. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_uplink.h +0 -115
  87. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/runtime.h +0 -236
  88. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_codec.h +0 -57
  89. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_frame.h +0 -55
  90. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io.h +0 -46
  91. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_android.h +0 -32
  92. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_apple.h +0 -34
  93. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_harmony.h +0 -32
  94. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_windows.h +0 -26
  95. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_processing.h +0 -34
  96. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_audio.a +0 -0
  97. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_facade.a +0 -0
  98. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_media.a +0 -0
  99. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_video.a +0 -0
  100. package/vendor/app-server/bin/runtime/linux-x64/lib/libwebrtc_apm.a +0 -0
  101. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.d.ts +0 -30
  102. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.js +0 -224
  103. /package/dist/{devtools/cli → cli}/src/dummy.d.ts +0 -0
  104. /package/dist/{devtools/cli → cli}/src/dummy.js +0 -0
  105. /package/dist/{devtools/cli → cli}/src/ffmpeg_tool.d.ts +0 -0
  106. /package/dist/{devtools/cli → cli}/src/ffmpeg_tool.js +0 -0
  107. /package/dist/{devtools/cli → cli}/src/guide.d.ts +0 -0
  108. /package/dist/{devtools/cli → cli}/src/index.d.ts +0 -0
  109. /package/dist/{devtools/cli → cli}/src/media_assets.d.ts +0 -0
  110. /package/dist/{devtools/cli → cli}/src/media_assets.js +0 -0
  111. /package/dist/{devtools/cli → cli}/src/progress.d.ts +0 -0
  112. /package/dist/{devtools/cli → cli}/src/progress.js +0 -0
  113. /package/dist/{devtools/cli → cli}/src/session_manager.d.ts +0 -0
  114. /package/dist/{devtools/cli → cli}/src/token_command.d.ts +0 -0
  115. /package/dist/{devtools/cli → cli}/src/transport.js +0 -0
  116. /package/vendor/app-server/bin/{native/macos-arm64 → runtime/macos-arm64/lib}/libtgrtc.dylib +0 -0
@@ -1,8 +1,9 @@
1
1
  platform=macos-arm64
2
- staged_at_utc=2026-04-10T04:27:48Z
2
+ profile=credential
3
+ staged_at_utc=2026-04-21T13:44:23Z
3
4
  source_sdk=/Users/allenfeng/Development/Repositories/tirtc-nexus/tirtc-matrix/.build/sdk/macos-arm64
4
5
 
5
- dcca0b7ab8055d84e5bcfab7f1dde56df9037c40ddb99e9ca924ef2e867d8309 include/tirtc/audio.h
6
+ bfea7c19fdc3f25680946a575db9b3e60e8cd2b3fe1ddde8c7c93b57a6a3902c include/tirtc/audio.h
6
7
  6d972ccfe150a3b4f2d7f18fa92b3ade9210c1c8bb754d061ac6b7997b59e2cb include/tirtc/audio_codec.h
7
8
  7bacbdb2d8bb10d6444036a8fef42f2a8e3ea34dfc38e165ee678d61f189db41 include/tirtc/audio_frame.h
8
9
  84f1bbe67efa15ab3b2d995d661025aac43e2fe547a14a012a24d89cfe3cb859 include/tirtc/audio_io.h
@@ -12,20 +13,20 @@ c2e1f31dcc75be461c577d18b1cebe32774f212d51cb4dd2a5b5a9bfe62b693e include/tirtc/
12
13
  51cbc911fe9f9834046f0e0a1a7cdd814a8e194a615894a8b4d11f9e5f095610 include/tirtc/audio_io_windows.h
13
14
  21f60729117260a44af22c1af986ef17d22673b102b7b7a035f492d0665cce16 include/tirtc/audio_processing.h
14
15
  0ca7c3c630b1242f51a0fd8154097c0a332b4c816a5707090e4381719852998c include/tirtc/audio_sample_rate.h
15
- 59b7df33fdc2ad92b3142299ffab832443179ef895784ad51a2f6544c5b02766 include/tirtc/av.h
16
+ 339508d784d3114dd3cbf14ad90dd6345d633ec647ca0f9bb8942eb1b83533b2 include/tirtc/av.h
16
17
  4198c95c48ae579d1c782635b00fa5c9009d0c56ba466e6e3873e8298faae029 include/tirtc/credential.h
17
- 78625b8d9f1f29bf2f35a89a8ad8a3f68f3f6ff75455d4682f5514c6c0ad7738 include/tirtc/error.h
18
+ d29f24fc665d01ab45f993c06c09fccca2bd5c844250ddbdc3c9d8d0c8548803 include/tirtc/error.h
18
19
  ae805545a9515edc9b94262e72ad2c7b7d649288166f4daeb450d8a55e82ae0b include/tirtc/foundation/build_info.h
19
20
  7cf8b372a3d48d4de4a65a04c7f102281a7b42cebb9ec247853d3c53afb63b6a include/tirtc/http.h
20
21
  70bbf93b84d9d1a85f376d9986de570c1f658319e1e5ab6d621f7a4d41033f5c include/tirtc/logging.h
21
22
  7e2f7f81afe37e22f5414d9db32438edd948ff775230c3a0a17ff9ac1a0b560e include/tirtc/media_codec.h
22
- 71eab7553274dee4cc6ea3cbaf345a9858e2bf73fe7e928a1a23851d431f3b4d include/tirtc/media_downlink.h
23
+ 3fa1d5fe3c3c2644d134e13678cbf5562440a2c5d4a652dc24bf9f124731509a include/tirtc/media_downlink.h
23
24
  21ef53b4d120aab600168c4082e7622c791ab4929fb20b3fb31f73ed01eee02a include/tirtc/media_fixture_av_sync.h
24
25
  037d9a581cef71afe9233456b1f4ef866c3739150532f3c30a67d361e8af9eef include/tirtc/media_fixture_source.h
25
26
  a4f8ab44c1a20ad37f250363a403a9d4d007e61ddb2426c7966dbc05f6a04b4f include/tirtc/media_live_source.h
26
27
  1b3be6954e547f91a047866438bff1820c8406afaf91cef68ddee29a6ac70234 include/tirtc/media_uplink.h
27
- 97ab19361d22a723af589ebae8bb08b5a7ccd8ca3aff0b85aa9ffd577252b6fc include/tirtc/transport.h
28
- 137729c534213cb161c0853a8d4d38fcdc397c41a7fd8c813fbe0e80083ec931 include/tirtc/trp.h
28
+ 26b831c7b8bd69b7699017427f3243cd22393c90c9518a820f5eb87eb3792483 include/tirtc/transport.h
29
+ 185183a736774cdf737504c091e4648d7f476c16abf18ee8c8ac0da2eb9a5c79 include/tirtc/trp.h
29
30
  dff5b0a0ac4a40ad17c93e1e56b3c416371c81ab365e287ea8cd6ce37ccbed3b include/tirtc/video_codec.h
30
31
  e51379666c199588cc33279ccf52248035d1cae3d1d468b1615ebf29f0b39c9c include/tirtc/video_frame.h
31
32
  d920afad955b9f206b02b19ca152315190fa84ab6f24e895a5b24c3ab9ffd701 include/tirtc/video_io.h
@@ -34,17 +35,20 @@ d920afad955b9f206b02b19ca152315190fa84ab6f24e895a5b24c3ab9ffd701 include/tirtc/
34
35
  cae0bbeb884e5466a56da15182c78cc22baab6c743f349a58d3595f623333585 include/tirtc/video_io_harmony.h
35
36
  65b5d24fe3a6bc2a299a2220148a153ba4eb0955a49c1c3baabf1fdfed8aabdd include/tirtc/video_io_windows.h
36
37
  8cd6b66bea14890a665cc317f8572429b2c3e4463773f8b77c1e4dc30a4a8747 include/tirtc/video_processing.h
38
+ 5052a464a34508f117fec46aa6b836871014229d4290d7d8caac862e0165ae8f lib/libTGTRP.a
39
+ 8db86d6714264047e8fd4086ddd7315722d675749719e6175f89eb5a636b48a1 lib/libTiRTC.a
37
40
  b39daee6a3d39bf0ca20c45084601133c4198de8dca848dcff6dd9c70ae99016 lib/libcrypto.a
38
41
  c052857ef315e3d61db9c862cad10709a3a6b2487dc41799cbe4d74a805de875 lib/libcrypto.dylib
39
- 17545a8539f86995500b7fcaee3d1f1e5684e8f11e6094558aee46c6a9cc74a8 lib/libmatrix_runtime_audio.a
40
- bf00c3fcccbfc29696a2ee4ff6ff55e510672a2337af6c975c83d295a970a85f lib/libmatrix_runtime_credential.a
41
- 33ce400a5dfd7a234a4391bc5dd531a9a0401f6d27252246898797d8d0dcf4ed lib/libmatrix_runtime_facade.a
42
- 525c15bd4e23642c1e9939b8114828ec47d7381fb6cf30cb9c66be3181b9c70c lib/libmatrix_runtime_foundation_http.a
43
- d7cf5cd5723bbfcd3bef9191570870413303b0b67c8644c9a5bf30e194fdd487 lib/libmatrix_runtime_foundation_logging.a
44
- fefdbe0acc0dc73dd0b48fb0cd927875c5e43674e163c7ba33f57e59d2f0b178 lib/libmatrix_runtime_media.a
45
- 9361b2a4784b3068a8796033fa36f1969297bbcd4ae59f96da1725e0a27fb481 lib/libmatrix_runtime_transport.a
46
- 7e6f54cf23ad2a59f08e274e63fc25ae74f9f9b687dff08f73091789d647a94c lib/libmatrix_runtime_video.a
42
+ a3cbd2372889b96346fb211846de94edb5ec7f5d15af02a150c3c24efb999187 lib/libmatrix_runtime_audio.a
43
+ 012cf0bd9aaa49fe42a43de19edddb01b654df741a0f5782568c52f0d3c8dfbb lib/libmatrix_runtime_credential.a
44
+ 75554a31b1c99be83d22f168de91584f19dc9ee69a13fe8b62d5dfdab6baf016 lib/libmatrix_runtime_facade.a
45
+ a5235f14059d7807968353b32cefcddbebec2cc5808912898078a6c6cf9bdd50 lib/libmatrix_runtime_foundation_http.a
46
+ dcb14497951c566352cf4b14a7b870872069824d6a2a067bfe5b421fc6500216 lib/libmatrix_runtime_foundation_logging.a
47
+ 1b1b7980f498b603132bf11dce7d24f60bdc8a11d6a0ac916c4454dde4ebbc3f lib/libmatrix_runtime_media.a
48
+ 6d6bf7d07cc35df568582218193487235452ef47dd736f36d7de3c95ac1bde18 lib/libmatrix_runtime_transport.a
49
+ 0abee197077a906f6af3f5e05c72bcfe5b874478b65ad454b3013ab9df398af1 lib/libmatrix_runtime_video.a
47
50
  c11c65d373a127028350c41fa58cd2d1223f2b5d70a84e13b115d90daaba25ca lib/libssl.a
48
51
  ef1c1104bbdd2528ed7b958fb7252bd6249875f92300b0c9577d6c4bd6c0d88a lib/libssl.dylib
52
+ e14e846e43d64e240fa0e5745bf4e702b79d0f2442e7f768beb990610735c71b lib/libtgrtc.dylib
49
53
  dc3e0e6ded26e90fd59c166933a5289d57f4cf25fbe6246b6b83c86fe898e63d lib/libwebrtc_apm.a
50
54
  6b1b182cb43ad0b81b19d10f4762b137ee7571a527d0b500f31a227e5e162cb1 lib/libxlog.a
@@ -0,0 +1,19 @@
1
+ import { CommandPendingConnectionSummary, HostState } from './HostState';
2
+ import { RuntimeAdapter } from './RuntimeAdapter';
3
+ import { CommandReplyParams, CommandSendParams } from './HostProtocol';
4
+ type WriteEvent = (family: string, kind: string, payload: Record<string, unknown>) => void;
5
+ type NoteIncomingConnection = (payload: Record<string, unknown>) => void;
6
+ export declare class HostCommandCoordinator {
7
+ private readonly state;
8
+ private readonly runtimeAdapter;
9
+ private readonly writeEvent;
10
+ private readonly snapshotPendingConnectionSummary;
11
+ private readonly noteIncomingConnection;
12
+ constructor(state: HostState, runtimeAdapter: RuntimeAdapter, writeEvent: WriteEvent, snapshotPendingConnectionSummary: () => CommandPendingConnectionSummary, noteIncomingConnection: NoteIncomingConnection);
13
+ handleInboundRemoteCommandRequest(payload: Record<string, unknown>): void;
14
+ clearPendingRemoteCommands(reason: string): void;
15
+ handleCommandSend(params: CommandSendParams, nextSequenceNumber: number): Promise<unknown>;
16
+ handleCommandReply(params: CommandReplyParams): Promise<unknown>;
17
+ handleCommandPendingList(): Promise<unknown>;
18
+ }
19
+ export {};
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HostCommandCoordinator = void 0;
4
+ const HostProtocol_1 = require("./HostProtocol");
5
+ function normalizeCommandPayload(payload) {
6
+ if (typeof payload === 'string') {
7
+ return {
8
+ payloadEncoding: 'utf8',
9
+ payload,
10
+ };
11
+ }
12
+ if (payload instanceof Uint8Array) {
13
+ return {
14
+ payloadEncoding: 'base64',
15
+ payload: Buffer.from(payload).toString('base64'),
16
+ };
17
+ }
18
+ if (Array.isArray(payload) && payload.every((value) => typeof value === 'number')) {
19
+ return {
20
+ payloadEncoding: 'base64',
21
+ payload: Buffer.from(payload).toString('base64'),
22
+ };
23
+ }
24
+ if (typeof payload === 'object' && payload !== null && 'type' in payload && payload.type === 'Buffer') {
25
+ const data = payload.data;
26
+ if (Array.isArray(data) && data.every((value) => typeof value === 'number')) {
27
+ return {
28
+ payloadEncoding: 'base64',
29
+ payload: Buffer.from(data).toString('base64'),
30
+ };
31
+ }
32
+ }
33
+ return {
34
+ payloadEncoding: 'utf8',
35
+ payload: '',
36
+ };
37
+ }
38
+ class HostCommandCoordinator {
39
+ state;
40
+ runtimeAdapter;
41
+ writeEvent;
42
+ snapshotPendingConnectionSummary;
43
+ noteIncomingConnection;
44
+ constructor(state, runtimeAdapter, writeEvent, snapshotPendingConnectionSummary, noteIncomingConnection) {
45
+ this.state = state;
46
+ this.runtimeAdapter = runtimeAdapter;
47
+ this.writeEvent = writeEvent;
48
+ this.snapshotPendingConnectionSummary = snapshotPendingConnectionSummary;
49
+ this.noteIncomingConnection = noteIncomingConnection;
50
+ }
51
+ handleInboundRemoteCommandRequest(payload) {
52
+ const remoteRequestId = Number(payload.remoteRequestId);
53
+ const commandId = Number(payload.commandId);
54
+ if (!Number.isInteger(remoteRequestId) || remoteRequestId <= 0 || !Number.isInteger(commandId)) {
55
+ return;
56
+ }
57
+ this.noteIncomingConnection(payload);
58
+ const normalizedPayload = normalizeCommandPayload(payload.payload);
59
+ const entry = {
60
+ remoteRequestId,
61
+ commandId,
62
+ payloadEncoding: normalizedPayload.payloadEncoding,
63
+ payload: normalizedPayload.payload,
64
+ receivedAt: new Date().toISOString(),
65
+ connection: this.snapshotPendingConnectionSummary(),
66
+ };
67
+ this.state.pendingRemoteCommands.set(remoteRequestId, entry);
68
+ this.writeEvent('command', 'command.remote.requested', {
69
+ ...entry,
70
+ });
71
+ }
72
+ clearPendingRemoteCommands(reason) {
73
+ if (this.state.pendingRemoteCommands.size === 0) {
74
+ return;
75
+ }
76
+ const clearedAt = new Date().toISOString();
77
+ for (const entry of this.state.pendingRemoteCommands.values()) {
78
+ this.writeEvent('command', 'command.remote.cleared', {
79
+ remoteRequestId: entry.remoteRequestId,
80
+ commandId: entry.commandId,
81
+ payloadEncoding: entry.payloadEncoding,
82
+ payload: entry.payload,
83
+ receivedAt: entry.receivedAt,
84
+ connection: entry.connection,
85
+ reason,
86
+ clearedAt,
87
+ });
88
+ }
89
+ this.state.pendingRemoteCommands.clear();
90
+ }
91
+ async handleCommandSend(params, nextSequenceNumber) {
92
+ const response = await this.runtimeAdapter.sendCommand(params.commandId, params.payloadEncoding, params.payload, params.timeoutMs);
93
+ return {
94
+ sequenceNumber: nextSequenceNumber,
95
+ commandId: params.commandId,
96
+ acceptedAt: new Date().toISOString(),
97
+ response,
98
+ };
99
+ }
100
+ async handleCommandReply(params) {
101
+ const requestedAt = new Date().toISOString();
102
+ this.writeEvent('command', 'reply.requested', {
103
+ remoteRequestId: params.remoteRequestId,
104
+ commandId: params.commandId,
105
+ payloadEncoding: params.payloadEncoding,
106
+ payloadLength: params.payload.length,
107
+ pendingCount: this.state.pendingRemoteCommands.size,
108
+ connectionState: this.state.connection.state,
109
+ at: requestedAt,
110
+ });
111
+ const entry = this.state.pendingRemoteCommands.get(params.remoteRequestId);
112
+ if (!entry) {
113
+ this.writeEvent('command', 'reply.rejected', {
114
+ remoteRequestId: params.remoteRequestId,
115
+ commandId: params.commandId,
116
+ reason: 'remote_request_not_pending',
117
+ pendingCount: this.state.pendingRemoteCommands.size,
118
+ connectionState: this.state.connection.state,
119
+ at: new Date().toISOString(),
120
+ });
121
+ throw new HostProtocol_1.HostProtocolError('invalid_request', `remoteRequestId ${params.remoteRequestId} is not pending`, false);
122
+ }
123
+ if (entry.commandId !== params.commandId) {
124
+ this.writeEvent('command', 'reply.rejected', {
125
+ remoteRequestId: params.remoteRequestId,
126
+ commandId: params.commandId,
127
+ expectedCommandId: entry.commandId,
128
+ reason: 'command_id_mismatch',
129
+ pendingCount: this.state.pendingRemoteCommands.size,
130
+ connectionState: this.state.connection.state,
131
+ at: new Date().toISOString(),
132
+ });
133
+ throw new HostProtocol_1.HostProtocolError('invalid_request', 'commandId does not match pending entry', false);
134
+ }
135
+ if (this.state.connection.state !== 'connected') {
136
+ this.writeEvent('command', 'reply.rejected', {
137
+ remoteRequestId: params.remoteRequestId,
138
+ commandId: params.commandId,
139
+ reason: 'connection_not_ready',
140
+ pendingCount: this.state.pendingRemoteCommands.size,
141
+ connectionState: this.state.connection.state,
142
+ at: new Date().toISOString(),
143
+ });
144
+ throw new HostProtocol_1.HostProtocolError('connection_not_ready', 'connection is not established', true);
145
+ }
146
+ try {
147
+ await this.runtimeAdapter.replyRemoteCommand(params.remoteRequestId, params.commandId, params.payloadEncoding, params.payload);
148
+ }
149
+ catch (error) {
150
+ const message = error instanceof Error ? error.message : String(error);
151
+ this.writeEvent('command', 'reply.failed', {
152
+ remoteRequestId: params.remoteRequestId,
153
+ commandId: params.commandId,
154
+ reason: 'runtime_adapter_error',
155
+ message,
156
+ pendingCount: this.state.pendingRemoteCommands.size,
157
+ connectionState: this.state.connection.state,
158
+ at: new Date().toISOString(),
159
+ });
160
+ throw error;
161
+ }
162
+ this.state.pendingRemoteCommands.delete(params.remoteRequestId);
163
+ const repliedAt = new Date().toISOString();
164
+ this.writeEvent('command', 'command.remote.replied', {
165
+ remoteRequestId: params.remoteRequestId,
166
+ commandId: params.commandId,
167
+ payloadEncoding: entry.payloadEncoding,
168
+ payload: entry.payload,
169
+ receivedAt: entry.receivedAt,
170
+ connection: entry.connection,
171
+ repliedAt,
172
+ });
173
+ return {
174
+ remoteRequestId: params.remoteRequestId,
175
+ commandId: params.commandId,
176
+ repliedAt,
177
+ };
178
+ }
179
+ async handleCommandPendingList() {
180
+ const items = Array.from(this.state.pendingRemoteCommands.values())
181
+ .sort((left, right) => left.receivedAt.localeCompare(right.receivedAt));
182
+ const listedAt = new Date().toISOString();
183
+ this.writeEvent('command', 'pending.listed', {
184
+ count: items.length,
185
+ remoteRequestIds: items.map((item) => item.remoteRequestId),
186
+ commandIds: items.map((item) => item.commandId),
187
+ connectionState: this.state.connection.state,
188
+ listedAt,
189
+ });
190
+ return {
191
+ items,
192
+ listedAt,
193
+ };
194
+ }
195
+ }
196
+ exports.HostCommandCoordinator = HostCommandCoordinator;
@@ -24,20 +24,10 @@ export type ServiceStartParams = {
24
24
  timeoutMs: number;
25
25
  bootstrapSendStreams?: StreamSendStartParams[];
26
26
  };
27
- export type ConnectionAutoTokenConfig = {
28
- openapiEntry?: string;
29
- accessId: string;
30
- secretKey: string;
31
- localId?: string;
32
- userTtlSeconds?: number;
33
- channelTtlSeconds?: number;
34
- };
35
27
  export type ConnectionConnectParams = {
36
28
  serviceEntry?: string;
37
29
  peerId: string;
38
- token?: string;
39
- tokenMode?: 'manual' | 'auto';
40
- autoToken?: ConnectionAutoTokenConfig;
30
+ token: string;
41
31
  timeoutMs: number;
42
32
  };
43
33
  export type StreamSendStartParams = {
@@ -89,16 +89,6 @@ function getOptionalNumber(params, key) {
89
89
  }
90
90
  return value;
91
91
  }
92
- function getOptionalBoolean(params, key) {
93
- const value = params[key];
94
- if (value === undefined) {
95
- return undefined;
96
- }
97
- if (typeof value !== 'boolean') {
98
- throw new HostProtocolError('invalid_request', `Invalid ${key}`, false);
99
- }
100
- return value;
101
- }
102
92
  function getRecord(params, key) {
103
93
  const value = params[key];
104
94
  if (!isRecord(value)) {
@@ -144,38 +134,14 @@ function parseServiceStartParams(params) {
144
134
  };
145
135
  }
146
136
  function parseConnectionConnectParams(params) {
147
- const token = getOptionalString(params, 'token');
148
- const rawTokenMode = getOptionalString(params, 'tokenMode');
149
- const tokenMode = rawTokenMode === undefined ? undefined : (() => {
150
- if (rawTokenMode !== 'manual' && rawTokenMode !== 'auto') {
151
- throw new HostProtocolError('invalid_request', 'Invalid tokenMode', false);
152
- }
153
- return rawTokenMode;
154
- })();
155
- const autoTokenRaw = params.autoToken;
156
- let autoToken;
157
- if (autoTokenRaw !== undefined) {
158
- if (!isRecord(autoTokenRaw)) {
159
- throw new HostProtocolError('invalid_request', 'Invalid autoToken', false);
160
- }
161
- autoToken = {
162
- openapiEntry: getOptionalString(autoTokenRaw, 'openapiEntry'),
163
- accessId: getString(autoTokenRaw, 'accessId'),
164
- secretKey: getString(autoTokenRaw, 'secretKey'),
165
- localId: getOptionalString(autoTokenRaw, 'localId'),
166
- userTtlSeconds: getOptionalNumber(autoTokenRaw, 'userTtlSeconds'),
167
- channelTtlSeconds: getOptionalNumber(autoTokenRaw, 'channelTtlSeconds'),
168
- };
169
- }
170
- if (!token && !autoToken) {
171
- throw new HostProtocolError('invalid_request', 'connection/connect requires token or autoToken', false);
137
+ const token = getString(params, 'token').trim();
138
+ if (token.length === 0) {
139
+ throw new HostProtocolError('invalid_request', 'connection/connect requires non-empty token', false);
172
140
  }
173
141
  return {
174
142
  serviceEntry: getOptionalString(params, 'serviceEntry'),
175
143
  peerId: getString(params, 'peerId'),
176
144
  token,
177
- tokenMode,
178
- autoToken,
179
145
  timeoutMs: getNumber(params, 'timeoutMs'),
180
146
  };
181
147
  }
@@ -4,11 +4,11 @@ export declare class HostServer {
4
4
  private state;
5
5
  private artifactManager;
6
6
  private runtimeAdapter;
7
+ private commandCoordinator;
7
8
  private isInitialized;
8
9
  private eventCounter;
9
10
  private commandSequence;
10
11
  private tokenTool;
11
- private runtimeCredentialTokenIssuer;
12
12
  private eventSinks;
13
13
  constructor(artifactManager: ArtifactManager, runtimeAdapter: RuntimeAdapter, hostEndpoint?: string);
14
14
  handleMessage(message: string): Promise<string | undefined>;
@@ -19,8 +19,6 @@ export declare class HostServer {
19
19
  appendHostLog(line: string): void;
20
20
  private handleRuntimeEvent;
21
21
  private snapshotPendingConnectionSummary;
22
- private handleInboundRemoteCommandRequest;
23
- private clearPendingRemoteCommands;
24
22
  private noteIncomingConnection;
25
23
  private handleIncomingConnectionDisconnected;
26
24
  private maybeAutoStartStreamFromRemoteDemand;
@@ -31,7 +29,6 @@ export declare class HostServer {
31
29
  private handleServiceStart;
32
30
  private handleServiceStop;
33
31
  private handleConnectionGet;
34
- private resolveConnectionToken;
35
32
  private handleConnectionConnect;
36
33
  private startDeferredSendStreamsOnConnected;
37
34
  private activatePendingStreamsOnConnected;