@myagentroam/node 0.12.0 → 0.12.1

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 (132) hide show
  1. package/dist/code-navigation/index.js +2 -0
  2. package/dist/code-navigation/languages/c-family.js +9 -0
  3. package/dist/code-navigation/languages/c-preprocessor.js +30 -0
  4. package/dist/code-navigation/languages/c.js +8 -0
  5. package/dist/code-navigation/languages/cpp.js +10 -0
  6. package/dist/code-navigation/languages/csharp.js +18 -0
  7. package/dist/code-navigation/languages/css.js +7 -0
  8. package/dist/code-navigation/languages/ecmascript.js +44 -0
  9. package/dist/code-navigation/languages/file-target.js +9 -0
  10. package/dist/code-navigation/languages/go.js +32 -0
  11. package/dist/code-navigation/languages/html.js +7 -0
  12. package/dist/code-navigation/languages/jvm.js +17 -0
  13. package/dist/code-navigation/languages/less.js +7 -0
  14. package/dist/code-navigation/languages/markdown.js +113 -0
  15. package/dist/code-navigation/languages/markup-reference.js +27 -0
  16. package/dist/code-navigation/languages/objective-c.js +11 -0
  17. package/dist/code-navigation/languages/objective-cpp.js +10 -0
  18. package/dist/code-navigation/languages/python.js +17 -0
  19. package/dist/code-navigation/languages/rust.js +18 -0
  20. package/dist/code-navigation/languages/sass.js +7 -0
  21. package/dist/code-navigation/languages/scss.js +7 -0
  22. package/dist/code-navigation/languages/stylesheet-reference.js +37 -0
  23. package/dist/code-navigation/languages/vue.js +75 -0
  24. package/dist/code-navigation/registry.js +72 -0
  25. package/dist/code-navigation/source-ranges.js +17 -0
  26. package/dist/code-navigation/symbol-maps.js +257 -0
  27. package/dist/code-navigation/symbol-matcher.js +48 -0
  28. package/dist/code-navigation/symbol-navigation.js +1 -0
  29. package/dist/code-navigation/types.js +1 -0
  30. package/dist/ctags-binary.js +3 -3
  31. package/dist/marctl/bin/marctl.mjs +6 -0
  32. package/dist/marctl/bin/marnodes.mjs +6 -0
  33. package/dist/marctl/bin/marscp.mjs +6 -0
  34. package/dist/marctl/bin/marssh.mjs +6 -0
  35. package/dist/marctl/package.json +1 -0
  36. package/dist/marctl/src/cli.mjs +271 -0
  37. package/dist/marctl/src/client.mjs +291 -0
  38. package/dist/marctl/src/config.mjs +46 -0
  39. package/dist/marctl/src/direct-control.mjs +225 -0
  40. package/dist/marctl/src/direct-errors.mjs +48 -0
  41. package/dist/marctl/src/direct-process.mjs +374 -0
  42. package/dist/marctl/src/direct-transport.mjs +235 -0
  43. package/dist/marctl/src/direct.mjs +421 -0
  44. package/dist/marctl/src/errors.mjs +11 -0
  45. package/dist/marctl/src/i18n/en-US.mjs +285 -0
  46. package/dist/marctl/src/i18n/index.mjs +20 -0
  47. package/dist/marctl/src/i18n/zh-CN.mjs +269 -0
  48. package/dist/marctl/src/scp-channel.mjs +99 -0
  49. package/dist/marctl/src/scp-copy.mjs +46 -0
  50. package/dist/marctl/src/scp-endpoint.mjs +29 -0
  51. package/dist/marctl/src/scp-protocol.mjs +2 -0
  52. package/dist/marctl/src/scp-worker.cjs +266 -0
  53. package/dist/marctl/src/scp-workers.mjs +179 -0
  54. package/dist/marctl/src/scp.mjs +64 -0
  55. package/dist/marctl/src/session-args.mjs +233 -0
  56. package/dist/marctl/src/session-input.mjs +43 -0
  57. package/dist/marctl/src/session-prepare.mjs +87 -0
  58. package/dist/marctl/src/session-target.mjs +26 -0
  59. package/dist/marctl/src/session-wait.mjs +232 -0
  60. package/dist/marctl/src/sessions.mjs +93 -0
  61. package/dist/marctl/src/terminal-frame.mjs +48 -0
  62. package/dist/marctl/src/terminal-interaction.mjs +177 -0
  63. package/dist/marctl/src/terminal-race.mjs +117 -0
  64. package/dist/marctl/src/terminal-relay-sender.mjs +129 -0
  65. package/dist/marctl/src/terminal-relay.mjs +305 -0
  66. package/dist/marctl/src/terminal.mjs +152 -0
  67. package/dist/marctl.js +1 -1
  68. package/dist/marnodes.js +1 -1
  69. package/dist/marscp.js +1 -1
  70. package/dist/marssh.js +1 -1
  71. package/dist/ripgrep-binary.js +3 -3
  72. package/dist/runner/mar-agent/agent-operation-presentation.js +22 -10
  73. package/dist/service/code-navigation/file-reference-parser.js +1 -1
  74. package/dist/service/node-terminal-channel.js +1 -1
  75. package/dist/session/session-catalog-service.js +4 -1
  76. package/dist/workspace/workspace-code-navigation-service.js +2 -2
  77. package/package.json +11 -9
  78. package/vendor/ctags/NOTICE +0 -22
  79. package/vendor/ctags/darwin-arm64/ctags +0 -0
  80. package/vendor/ctags/darwin-x64/ctags +0 -0
  81. package/vendor/ctags/licenses/COPYING +0 -340
  82. package/vendor/ctags/licenses/COPYING.MinGW-w64-runtime.txt +0 -240
  83. package/vendor/ctags/licenses/LICENSE.janssen +0 -19
  84. package/vendor/ctags/licenses/LICENSE.libyaml +0 -19
  85. package/vendor/ctags/licenses/official-snapshot/darwin-arm64/COPYING +0 -340
  86. package/vendor/ctags/licenses/official-snapshot/darwin-arm64/RECEIPT.yml +0 -27
  87. package/vendor/ctags/licenses/official-snapshot/darwin-arm64/dependencies/libiconv.yml +0 -24
  88. package/vendor/ctags/licenses/official-snapshot/darwin-arm64/dependencies/libjansson.yml +0 -19
  89. package/vendor/ctags/licenses/official-snapshot/darwin-arm64/dependencies/libxml2.yml +0 -20
  90. package/vendor/ctags/licenses/official-snapshot/darwin-arm64/dependencies/libyaml.yml +0 -7
  91. package/vendor/ctags/licenses/official-snapshot/darwin-arm64/dependencies/libz.yml +0 -13
  92. package/vendor/ctags/licenses/official-snapshot/darwin-x64/COPYING +0 -340
  93. package/vendor/ctags/licenses/official-snapshot/darwin-x64/RECEIPT.yml +0 -27
  94. package/vendor/ctags/licenses/official-snapshot/darwin-x64/dependencies/libiconv.yml +0 -24
  95. package/vendor/ctags/licenses/official-snapshot/darwin-x64/dependencies/libjansson.yml +0 -19
  96. package/vendor/ctags/licenses/official-snapshot/darwin-x64/dependencies/libxml2.yml +0 -20
  97. package/vendor/ctags/licenses/official-snapshot/darwin-x64/dependencies/libyaml.yml +0 -7
  98. package/vendor/ctags/licenses/official-snapshot/darwin-x64/dependencies/libz.yml +0 -13
  99. package/vendor/ctags/licenses/official-snapshot/linux-arm64/COPYING +0 -340
  100. package/vendor/ctags/licenses/official-snapshot/linux-arm64/RECEIPT.yml +0 -27
  101. package/vendor/ctags/licenses/official-snapshot/linux-arm64/dependencies/libiconv.yml +0 -24
  102. package/vendor/ctags/licenses/official-snapshot/linux-arm64/dependencies/libjansson.yml +0 -19
  103. package/vendor/ctags/licenses/official-snapshot/linux-arm64/dependencies/libxml2.yml +0 -20
  104. package/vendor/ctags/licenses/official-snapshot/linux-arm64/dependencies/libyaml.yml +0 -7
  105. package/vendor/ctags/licenses/official-snapshot/linux-arm64/dependencies/libz.yml +0 -13
  106. package/vendor/ctags/licenses/official-snapshot/linux-x64/COPYING +0 -340
  107. package/vendor/ctags/licenses/official-snapshot/linux-x64/RECEIPT.yml +0 -27
  108. package/vendor/ctags/licenses/official-snapshot/linux-x64/dependencies/libiconv.yml +0 -24
  109. package/vendor/ctags/licenses/official-snapshot/linux-x64/dependencies/libjansson.yml +0 -19
  110. package/vendor/ctags/licenses/official-snapshot/linux-x64/dependencies/libxml2.yml +0 -20
  111. package/vendor/ctags/licenses/official-snapshot/linux-x64/dependencies/libyaml.yml +0 -7
  112. package/vendor/ctags/licenses/official-snapshot/linux-x64/dependencies/libz.yml +0 -13
  113. package/vendor/ctags/licenses/win32-x64/COPYING +0 -340
  114. package/vendor/ctags/licenses/win32-x64/COPYING.MinGW-w64-runtime.txt +0 -240
  115. package/vendor/ctags/licenses/win32-x64/Copyright.libxml2 +0 -23
  116. package/vendor/ctags/licenses/win32-x64/LICENCE.pcre2 +0 -94
  117. package/vendor/ctags/licenses/win32-x64/LICENSE.janssen +0 -19
  118. package/vendor/ctags/licenses/win32-x64/LICENSE.libyaml +0 -19
  119. package/vendor/ctags/linux-arm64/ctags +0 -0
  120. package/vendor/ctags/linux-x64/ctags +0 -0
  121. package/vendor/ctags/manifest.json +0 -42
  122. package/vendor/ctags/source/universal-ctags-ab95af198f8eaeb6d50dc96e3adf52e769d3e5f0.tar.gz +0 -0
  123. package/vendor/ctags/win32-x64/ctags.exe +0 -0
  124. package/vendor/ripgrep/LICENSE-MIT +0 -21
  125. package/vendor/ripgrep/UNLICENSE +0 -24
  126. package/vendor/ripgrep/darwin-arm64/rg +0 -0
  127. package/vendor/ripgrep/darwin-x64/rg +0 -0
  128. package/vendor/ripgrep/linux-arm64/rg +0 -0
  129. package/vendor/ripgrep/linux-x64/rg +0 -0
  130. package/vendor/ripgrep/manifest.json +0 -42
  131. package/vendor/ripgrep/win32-arm64/rg.exe +0 -0
  132. package/vendor/ripgrep/win32-x64/rg.exe +0 -0
@@ -0,0 +1,285 @@
1
+ const configurationHelp = `Authorization:
2
+ Node access is available only in MAR-launched terminals and Workspace Agent Runs;
3
+ scheduled runs use the task owner. MAR supplies short-lived user credentials.
4
+ External terminals and persistent administrator keys are not supported.`;
5
+
6
+ export default Object.freeze({
7
+ help: `marctl — MyAgentRoam command-line interface
8
+
9
+ Usage:
10
+ marctl [options] <command> [arguments]
11
+ marctl help [command]
12
+
13
+ Commands:
14
+ agents Inspect and coordinate Sessions in the current Workspace.
15
+ nodes List accessible Nodes and their connection status.
16
+ ssh Open a Node terminal or execute a remote command.
17
+ scp Copy a regular file between this machine and Nodes, or between Nodes.
18
+ version Print the installed CLI package version.
19
+ help Show help for the CLI or a command.
20
+
21
+ Options:
22
+ -h, --help Show help and exit.
23
+ -V, --version Print the CLI package version and exit.
24
+
25
+ Examples:
26
+ marctl nodes
27
+ marctl ssh <node> uname -a
28
+ marctl scp ./artifact.bin <node>:///tmp/artifact.bin
29
+ marctl --version
30
+ marctl help ssh
31
+
32
+ Aliases:
33
+ marnodes Equivalent to the nodes command.
34
+ marssh Equivalent to the ssh command.
35
+ marscp Equivalent to the scp command.
36
+
37
+ ${configurationHelp}
38
+
39
+ Notes:
40
+ Help and version work offline without configuration or authorization.
41
+ Put local help/version options before a Node or file endpoint.
42
+ Each alias shows only its own command help. Use marctl help <command> for details.
43
+ Remote access uses authorized Node Terminal transport, not system SSH or SCP.`,
44
+ commandHelp: Object.freeze({
45
+ agents: `{program} — Coordinate Agents in the current MAR Workspace
46
+
47
+ Usage:
48
+ {program} start [-m <text> | --message-file <file|->]
49
+ [--runner <runner>] [--parent <id>] [--model-id <id>] [--effort <value>]
50
+ [--title <name>] [--goal <objective> | --clear-goal]
51
+ [--client-message-id <id>] [--json]
52
+ {program} send <id> [-m <text> | --message-file <file|->]
53
+ [--steer | --queue] [--goal <objective> | --clear-goal]
54
+ [--approval <id> --decision <approve|reject>]
55
+ [--client-message-id <id>] [--json]
56
+ {program} wait [<id>] [--agent <id> ...] [--mode any|all]
57
+ [--wait-for message|completion] [--timeout <duration>] [--json]
58
+ {program} stop <id> [--json]
59
+ {program} list [--scope tree|active] [--query <title>]
60
+ [--limit <1..100>] [--json]
61
+ {program} view [<id>] [--json]
62
+
63
+ Management:
64
+ {program} config [<id>] [--model-id <id>] [--effort <value>] [--json]
65
+ {program} rename [<id>] --title <name> [--json]
66
+ {program} prompt get|clear [<id>] [--json]
67
+ {program} prompt set [<id>] (-m <text> | --message-file <file|->) [--json]
68
+ {program} schedule list [--cursor <cursor>] [--limit <1..100>] [--json]
69
+ {program} schedule get [<id>] [--json]
70
+ {program} schedule create [<id>] --cron <cron>
71
+ (-m <text> | --message-file <file|->) [--json]
72
+ {program} schedule update [<id>] --expected-revision <revision>
73
+ [--cron <cron>] [-m <text> | --message-file <file|->] [--json]
74
+ {program} approval decide <id> --run <run-id> --approval <approval-id>
75
+ --decision <approve|reject> [--json]
76
+ {program} wait <id> --run <run-id> [--until approval] --timeout <duration>
77
+ {program} goal get|clear <id> [--json]
78
+ {program} goal set <id> (-m <text> | --message-file <file|->) [--json]
79
+ {program} current | show [<id>] | graph [<id>]
80
+ {program} history [<id>] [--cursor <cursor>] [--limit <1..100>] [--json]
81
+
82
+ Input and results:
83
+ Start defaults to the current Session Runner; a terminal without a current
84
+ Session must specify --runner or --parent. Start returns without waiting.
85
+ Send appends by default; --steer provides timely input and --queue defers.
86
+ --goal sets or replaces a Goal; --clear-goal clears it. Send can update a Goal
87
+ without text; omitted Goal is unchanged. Stop targets the current execution
88
+ and clears the target Session Goal.
89
+ Wait defaults to direct-child completion and 30s; 0ms is a snapshot.
90
+ Positive timeouts use the requested duration; maximum is 5m.
91
+ Waiting does not stop the task.
92
+ -m and --message-file are exclusive; files use UTF-8 and - reads stdin.
93
+ List defaults to the containing tree, including idle Sessions. Without a
94
+ current Session it defaults to active; explicit tree requires a Session.
95
+ Active includes running and sleeping Sessions in the current Workspace.
96
+ List returns currentAgentId (null without a Session), flat sessions and
97
+ truncated. Limit defaults to 10, maximum 100; no cursor or pagination.
98
+ Active Sessions come first, then recent activity descending.
99
+ Configuration and prompt changes apply to future executions.
100
+ Prefer --steer for timely communication or course correction.
101
+ Reserve --queue for explicitly requested deferred input: it is consumed after
102
+ current work and earlier queued inputs finish. With an active Goal it is
103
+ not consumed until that Goal exits.
104
+ Acceptance does not guarantee immediate processing.
105
+ An accepted message normally needs no separate acknowledgment or receipt
106
+ check.
107
+ While children run, prefer meaningful, non-overlapping work; wait when needed
108
+ to unblock or finish and no other meaningful local task work remains.
109
+
110
+ show --json includes session.status, session.modelId, session.effort,
111
+ session.title, session.runId, session.recentTools, session.queuedCount and
112
+ session.latestMessage. List entries have id, parentSessionId, title and
113
+ status; wait may include progress. View omits Run and Execution IDs.
114
+ Status is RUNNING/IDLE/SLEEPING. In history, segments[].items[] with
115
+ kind === "assistant_message" expose payload.text.
116
+
117
+ Exit codes: 1 failure, 2 input, 3 authorization, 4 unsupported, 5 timeout,
118
+ 6 unknown outcome, 130 cancelled wait. --json prints one result or error.`,
119
+ nodes: `{program} — List accessible Nodes
120
+
121
+ Usage:
122
+ {program} [options]
123
+
124
+ Options:
125
+ -h, --help Show help and exit.
126
+ -V, --version Print the CLI package version and exit.
127
+
128
+ Examples:
129
+ {program}
130
+
131
+ Output:
132
+ Tab-separated columns: ID, NAME, STATUS, PLATFORM.
133
+ Includes offline Nodes for which the current user has terminal permission.
134
+
135
+ ${configurationHelp}`,
136
+ ssh: `{program} — Open a terminal or execute a remote command
137
+
138
+ Usage:
139
+ {program} [options] <node> [command [arg...]]
140
+
141
+ Arguments:
142
+ <node> An authorized Node ID or an exact, unique Node name.
143
+ [command ...] A command for the remote shell; omit it for an interactive shell.
144
+
145
+ Options (before <node>):
146
+ -h, --help Show help and exit.
147
+ -V, --version Print the CLI package version and exit.
148
+
149
+ Examples:
150
+ {program} ubuntu-develop
151
+ {program} ubuntu-develop uname -a
152
+ {program} ubuntu-develop "echo hello && whoami"
153
+
154
+ Notes:
155
+ Names must be unique across accessible Nodes, including offline Nodes; use an ID on conflict.
156
+ Remote arguments are joined with spaces. Quote shell expressions for your local shell.
157
+ Remote --help, -h, and --version are not local options. The remote exit code is preserved.
158
+ Commands run as the Node service account; login accounts, privilege escalation, and SSH
159
+ connection options such as -t, -p, and -i are unsupported. No SSH port is required.
160
+ Connection setup has a timeout, but attached commands have no runtime or output-idle timeout.
161
+ Commands are not retried. Exit or unrecoverable disconnection closes the terminal;
162
+ this is not a background-job service.
163
+
164
+ ${configurationHelp}`,
165
+ scp: `{program} — Copy a regular file
166
+
167
+ Usage:
168
+ {program} [options] <source> <destination>
169
+
170
+ Arguments:
171
+ <source> A local file or an authorized Node file endpoint.
172
+ <destination> A local file/directory or an authorized Node endpoint.
173
+ Node endpoints: <node>://<absolute-path> or <node>:<absolute-path>.
174
+ <node> is an ID or an exact, unique name, including offline Nodes.
175
+ At least one endpoint must be a Node. Linux and Windows paths are supported.
176
+
177
+ Options:
178
+ -p Preserve source permissions and access/modification times.
179
+ -q Suppress progress output (already the default).
180
+ -h, --help Show help and exit; place before the first endpoint.
181
+ -V, --version Print the CLI package version and exit; place before the first endpoint.
182
+ -- Treat remaining arguments as literal paths.
183
+
184
+ Examples:
185
+ {program} ./artifact.bin ubuntu-develop:///tmp/artifact.bin
186
+ {program} ubuntu-develop:///tmp/artifact.bin ./
187
+ {program} -p linux:///tmp/artifact.bin "windows://C:/Artifacts/"
188
+
189
+ Notes:
190
+ Existing directories receive the source filename; directory paths must already exist.
191
+ Existing regular files are overwritten, retaining their permissions unless -p is used.
192
+ Directory sources, symlinks, invalid destination filenames, and directory final targets
193
+ are rejected. Recursive -r, multiple sources, and SSH connection options are unsupported.
194
+ Both Server and Node must support binary Terminal pipes; this is not system SCP.
195
+ File access uses the Node service account's permissions. Checksums are verified before
196
+ atomic publication; failed transfers leave the original unchanged. Forced termination
197
+ may leave a temporary file. Transfers are not retried.
198
+
199
+ ${configurationHelp}`,
200
+ version: `marctl — MyAgentRoam CLI version
201
+
202
+ Usage:
203
+ {program} [options]
204
+ marctl --version
205
+ marctl -V
206
+
207
+ Options:
208
+ -h, --help Show help and exit.
209
+ -V, --version Print the CLI package version and exit.
210
+
211
+ Examples:
212
+ {program}
213
+ marctl --version
214
+
215
+ Output:
216
+ marctl <version>
217
+
218
+ Prints the installed Node package version on one line, followed by a newline.
219
+ No configuration, authorization, or Server connection is required.`
220
+ }),
221
+ nodesHeader: 'ID\tNAME\tSTATUS\tPLATFORM',
222
+ connected: 'connected',
223
+ disconnected: 'disconnected',
224
+ errors: Object.freeze({
225
+ sessionOutcomeUnknown:
226
+ 'The delivery outcome is unknown. Inspect Session state/history before retrying.',
227
+ sessionMessageInvalid:
228
+ 'The message must be non-empty and within the length limit; input files must be readable UTF-8.',
229
+ sessionWaitUnknown: 'The specified Run could not be confirmed. Inspect Session state/history.',
230
+ sessionWaitCancelled: 'Waiting was cancelled; the target Run was not stopped.',
231
+ sessionWaitTimeout: 'Waiting timed out; the target Run was not stopped.',
232
+ sessionApprovalUnsupported: 'This Node does not provide pending approval observations.',
233
+
234
+ userContextUnavailable: 'This Node session has no valid marctl user authorization.',
235
+ sessionContextRequired: 'No current Session is available; specify a Session ID explicitly.',
236
+ serverUrlInvalid: 'MAR_CTL_SERVER_URL is invalid.',
237
+ serverUrlTransport: 'MAR_CTL_SERVER_URL must use HTTPS or loopback HTTP.',
238
+ serverUrlOrigin: 'MAR_CTL_SERVER_URL must be an origin without credentials or query data.',
239
+ fetchUnavailable: 'Fetch is unavailable in this Node.js runtime.',
240
+ serverInvalidNodes: 'The server returned an invalid node list.',
241
+ serverInvalidManifest: 'The server returned an invalid node manifest.',
242
+ terminalCommandInvalid: 'The terminal command is invalid.',
243
+ terminalSequenceInvalid: 'The terminal sequence is invalid.',
244
+ terminalTicketInvalid: 'The terminal ticket is invalid.',
245
+ terminalIdInvalid: 'The terminal identifier is invalid.',
246
+ nodeIdInvalid: 'The node identifier is invalid.',
247
+ nodeNameAmbiguous: 'Multiple accessible nodes share that name; use a node ID.',
248
+ nodeNotFound: 'No accessible node matches this ID or name.',
249
+ terminalSizeInvalid: 'The terminal size is invalid.',
250
+ serverInvalidTerminalId: 'The server returned an invalid terminal identifier.',
251
+ serverInvalidTicket: 'The server returned an invalid terminal ticket.',
252
+ serverInvalidJson: 'The server returned invalid JSON.',
253
+ serverTimeout: 'The marctl server did not respond before the control request timeout.',
254
+ serverUnreachable: 'The marctl server could not be reached.',
255
+ serverRejected: 'The marctl server rejected the request.',
256
+ terminalConnectionStart: 'The terminal connection could not be started.',
257
+ terminalConnectionOpen: 'The terminal connection could not be opened.',
258
+ terminalAttachTimeout: 'The terminal did not attach before the connection setup timeout.',
259
+ terminalAttachConnection: 'The terminal connection failed during attachment.',
260
+ terminalAttachLost: 'The terminal connection was lost during attachment.',
261
+ terminalRemoteError: 'The remote terminal reported an error.',
262
+ terminalClosedBeforeAttach: 'The remote terminal closed before attachment.',
263
+ terminalFrameInvalid: 'The terminal frame was invalid.',
264
+ terminalInvalidJson: 'The terminal sent invalid JSON.',
265
+ terminalBinaryFrame: 'The terminal sent an invalid binary frame.',
266
+ terminalBinaryUnavailable:
267
+ 'Binary copy requires a Server and Node that support pipe terminals.',
268
+ terminalConnectionFailed: 'The terminal connection failed.',
269
+ terminalConnectionLost: 'The terminal connection was lost.',
270
+ terminalUnexpectedFrame: 'The remote terminal sent an unexpected frame.',
271
+ terminalInputFailed: 'The terminal input could not be sent.',
272
+ terminalResizeFailed: 'The terminal resize could not be sent.',
273
+ terminalInteractiveRequired: 'An interactive terminal is required.',
274
+ terminalInteractiveInit: 'The interactive terminal could not be initialized.',
275
+ terminalCloseFailed: 'The remote terminal could not be closed.',
276
+ terminalSessionFailed: 'The terminal session failed.',
277
+ terminalDirectUnsafeFallback:
278
+ 'Direct terminal setup could not be safely canceled after OPEN; relay fallback was skipped.',
279
+ invalidArguments: 'Invalid command arguments.',
280
+ sessionDeliveryRequired: 'Send requires exactly one of --steer or --queue, even when idle.',
281
+ sshOptionsUnsupported: 'SSH options are not supported; use marssh <host>.',
282
+ scpOptionsUnsupported: 'This SCP option is not supported by the Node Terminal transport.',
283
+ commandFailed: 'The command failed.'
284
+ })
285
+ });
@@ -0,0 +1,20 @@
1
+ import enUS from './en-US.mjs';
2
+ import zhCN from './zh-CN.mjs';
3
+
4
+ export function localeFromEnv(env = process.env) {
5
+ const value = String(env.LC_ALL || env.LANG || '').toLowerCase();
6
+ return value.startsWith('zh_') || value.startsWith('zh-') || value === 'zh' ? 'zh-CN' : 'en-US';
7
+ }
8
+
9
+ export function createTranslator(env = process.env) {
10
+ const locale = localeFromEnv(env);
11
+ const resource = locale === 'zh-CN' ? zhCN : enUS;
12
+ const translate = (key, params = {}) => {
13
+ const value = key.split('.').reduce((current, part) => current?.[part], resource);
14
+ if (typeof value === 'function') return value(params);
15
+ if (typeof value !== 'string') return key;
16
+ return value.replace(/\{(\w+)\}/gu, (_match, name) => String(params[name] ?? ''));
17
+ };
18
+ translate.locale = locale;
19
+ return translate;
20
+ }
@@ -0,0 +1,269 @@
1
+ const configurationHelp = `授权:
2
+ 仅 MAR 打开的终端和普通 Workspace Agent Run 可访问节点,定时任务使用任务 owner 的权限。
3
+ MAR 自动提供短期用户凭证;不支持外部终端或持久管理员密钥。`;
4
+
5
+ export default Object.freeze({
6
+ help: `marctl — MyAgentRoam 命令行工具
7
+
8
+ 用法:
9
+ marctl [选项] <子命令> [参数]
10
+ marctl help [子命令]
11
+
12
+ 子命令:
13
+ agents 查看和协调当前工作区中的会话。
14
+ nodes 列出有权限的节点及连接状态。
15
+ ssh 打开节点终端或执行远程命令。
16
+ scp 在当前机器与节点之间、节点之间复制普通文件。
17
+ version 显示已安装的 CLI 包版本。
18
+ help 显示工具或指定子命令的帮助。
19
+
20
+ 选项:
21
+ -h, --help 显示帮助后退出。
22
+ -V, --version 显示 CLI 包版本后退出。
23
+
24
+ 示例:
25
+ marctl nodes
26
+ marctl ssh <节点> uname -a
27
+ marctl scp ./artifact.bin <节点>:///tmp/artifact.bin
28
+ marctl --version
29
+ marctl help ssh
30
+
31
+ 快捷命令:
32
+ marnodes 等价于 nodes 子命令。
33
+ marssh 等价于 ssh 子命令。
34
+ marscp 等价于 scp 子命令。
35
+
36
+ ${configurationHelp}
37
+
38
+ 说明:
39
+ 帮助和版本查询离线可用,无需配置或授权。
40
+ 本机帮助、版本选项须放在节点或文件端点前。
41
+ 快捷命令仅显示对应操作的帮助。用 marctl help <子命令> 查看详细说明。
42
+ 远程访问使用授权的 Node Terminal 传输,不是系统 SSH 或 SCP 协议。`,
43
+ commandHelp: Object.freeze({
44
+ agents: `{program} — 协调当前 MAR 工作区中的 Agent
45
+
46
+ 用法:
47
+ {program} start [-m <text> | --message-file <file|->]
48
+ [--runner <runner>] [--parent <id>] [--model-id <id>] [--effort <value>]
49
+ [--title <name>] [--goal <objective> | --clear-goal]
50
+ [--client-message-id <id>] [--json]
51
+ {program} send <id> [-m <text> | --message-file <file|->]
52
+ [--steer | --queue] [--goal <objective> | --clear-goal]
53
+ [--approval <id> --decision <approve|reject>]
54
+ [--client-message-id <id>] [--json]
55
+ {program} wait [<id>] [--agent <id> ...] [--mode any|all]
56
+ [--wait-for message|completion] [--timeout <duration>] [--json]
57
+ {program} stop <id> [--json]
58
+ {program} list [--scope tree|active] [--query <title>]
59
+ [--limit <1..100>] [--json]
60
+ {program} view [<id>] [--json]
61
+
62
+ 管理:
63
+ {program} config [<id>] [--model-id <id>] [--effort <value>] [--json]
64
+ {program} rename [<id>] --title <name> [--json]
65
+ {program} prompt get|clear [<id>] [--json]
66
+ {program} prompt set [<id>] (-m <text> | --message-file <file|->) [--json]
67
+ {program} schedule list [--cursor <cursor>] [--limit <1..100>] [--json]
68
+ {program} schedule get [<id>] [--json]
69
+ {program} schedule create [<id>] --cron <cron>
70
+ (-m <text> | --message-file <file|->) [--json]
71
+ {program} schedule update [<id>] --expected-revision <revision>
72
+ [--cron <cron>] [-m <text> | --message-file <file|->] [--json]
73
+ {program} approval decide <id> --run <run-id> --approval <approval-id>
74
+ --decision <approve|reject> [--json]
75
+ {program} wait <id> --run <run-id> [--until approval] --timeout <duration>
76
+ {program} goal get|clear <id> [--json]
77
+ {program} goal set <id> (-m <text> | --message-file <file|->) [--json]
78
+ {program} current | show [<id>] | graph [<id>]
79
+ {program} history [<id>] [--cursor <cursor>] [--limit <1..100>] [--json]
80
+
81
+ 输入与结果:
82
+ start 默认当前会话的 Runner;没有当前会话的终端须指定 --runner 或
83
+ --parent。start 不等待。
84
+ send 默认追加;--steer 优先补充,--queue 排队。--goal 设置或替换目标,
85
+ --clear-goal 清除目标;send 可仅更新目标,省略则不修改。
86
+ stop 停止目标当前执行并清除 Goal。wait 默认等待直接子会话终态 30 秒,
87
+ 0ms 为快照;正数按传入时长等待,最多 5 分钟。等待不会停止任务。
88
+ -m 与 --message-file 互斥;文件使用 UTF-8,- 从 stdin 读取。
89
+ list 默认查询所在会话树,包含空闲会话;
90
+ 没有当前会话时默认 active,显式 tree 须有会话上下文。active 包含当前
91
+ Workspace 中运行及睡眠的会话。返回 currentAgentId(无会话时为 null)、
92
+ 扁平 sessions 和 truncated。limit 默认 10、上限 100,无 cursor 或分页。
93
+ 活跃会话优先,其后按最近活动时间倒序。
94
+ 配置和持久提示从后续执行生效。
95
+ 即时沟通或纠偏优先使用 --steer。
96
+ 建议仅将 --queue 用于明确要求延后的输入:当前工作及前面的队列项结束后才消费,
97
+ 有活动 Goal 时,必须等到该 Goal 退出才消费。已接收不保证立即处理。
98
+ 消息被接受后,通常无需另行确认收悉或立即查看是否收到。
99
+ 子会话运行时建议并行推进有意义且不重叠的工作;无其他本地工作可做,且需
100
+ 结果解除阻塞或收尾时,再考虑等待。
101
+
102
+ show --json 包含 session.status、session.modelId、session.effort、
103
+ session.title、session.runId、session.recentTools、session.queuedCount 和
104
+ session.latestMessage。list 每项仅含 id、parentSessionId、title 和 status;
105
+ wait 可能包含 progress;view 不公开 Run 或 Execution ID。
106
+ 状态为 RUNNING/IDLE/SLEEPING。历史中 segments[].items[] 的
107
+ kind === "assistant_message" 包含 payload.text。
108
+
109
+ 退出码:1 失败,2 参数,3 授权,4 不支持,5 超时,6 结果未知,
110
+ 130 取消等待。--json 输出单个结果或错误对象。`,
111
+ nodes: `{program} — 列出有权限的节点
112
+
113
+ 用法:
114
+ {program} [选项]
115
+
116
+ 选项:
117
+ -h, --help 显示帮助后退出。
118
+ -V, --version 显示 CLI 包版本后退出。
119
+
120
+ 示例:
121
+ {program}
122
+
123
+ 输出:
124
+ 以制表符分隔的节点 ID、名称、状态、平台列。
125
+ 包含当前用户有终端使用权的离线节点。
126
+
127
+ ${configurationHelp}`,
128
+ ssh: `{program} — 打开终端或执行远程命令
129
+
130
+ 用法:
131
+ {program} [选项] <节点> [command [arg...]]
132
+
133
+ 参数:
134
+ <节点> 有权限的节点 ID,或精确、唯一的节点名称。
135
+ [command ...] 交给远端 Shell 的命令;省略时打开交互 Shell。
136
+
137
+ 选项(放在节点前):
138
+ -h, --help 显示帮助后退出。
139
+ -V, --version 显示 CLI 包版本后退出。
140
+
141
+ 示例:
142
+ {program} ubuntu-develop
143
+ {program} ubuntu-develop uname -a
144
+ {program} ubuntu-develop "echo hello && whoami"
145
+
146
+ 说明:
147
+ 名称须在可访问节点中唯一(包括离线节点),重名时使用 ID。
148
+ 远程参数以空格拼接;Shell 表达式须按本机 Shell 语法引用。
149
+ 远端 --help、-h、--version 不作为本机选项处理;保留远程命令的真实退出码。
150
+ 命令以 Node 服务账号运行,不支持登录账号、提权及 -t、-p、-i 等 SSH 连接选项;无需 SSH 端口。
151
+ 建连有超时,附着后的命令没有运行时长或输出空闲超时。命令不自动重试。
152
+ 退出或连接无法恢复时关闭终端,不提供后台任务托管。
153
+
154
+ ${configurationHelp}`,
155
+ scp: `{program} — 复制普通文件
156
+
157
+ 用法:
158
+ {program} [选项] <源> <目标>
159
+
160
+ 参数:
161
+ <源> 本机文件或有权限的节点文件端点。
162
+ <目标> 本机文件、目录或有权限的节点端点。
163
+ 节点端点:<节点>://<绝对路径> 或 <节点>:<绝对路径>。
164
+ 节点须使用 ID 或精确、唯一的名称(包括离线节点)。
165
+ 至少一端必须为节点,支持 Linux 和 Windows 路径。
166
+
167
+ 选项:
168
+ -p 保留源文件权限及访问、修改时间。
169
+ -q 不显示进度(默认已不显示)。
170
+ -h, --help 显示帮助后退出,须放在第一个文件端点前。
171
+ -V, --version 显示 CLI 包版本后退出,须放在第一个文件端点前。
172
+ -- 后续参数按字面路径处理。
173
+
174
+ 示例:
175
+ {program} ./artifact.bin ubuntu-develop:///tmp/artifact.bin
176
+ {program} ubuntu-develop:///tmp/artifact.bin ./
177
+ {program} -p linux:///tmp/artifact.bin "windows://C:/Artifacts/"
178
+
179
+ 说明:
180
+ 已有目标目录自动追加源文件名;目录路径必须已存在。
181
+ 已有普通文件默认覆盖,未使用 -p 时保留其权限。
182
+ 拒绝源目录、符号链接、接收平台不合法的文件名及最终目标目录;不支持递归 -r、多源及 SSH 连接选项。
183
+ Server 和 Node 均须支持二进制 Terminal pipe;这不是系统 SCP。
184
+ 文件访问遵循 Node 服务账号权限。完整校验后原子发布,失败不替换原文件;
185
+ 强制终止可能留下临时文件,传输不自动重试。
186
+
187
+ ${configurationHelp}`,
188
+ version: `marctl — MyAgentRoam CLI 版本
189
+
190
+ 用法:
191
+ {program} [选项]
192
+ marctl --version
193
+ marctl -V
194
+
195
+ 选项:
196
+ -h, --help 显示帮助后退出。
197
+ -V, --version 显示 CLI 包版本后退出。
198
+
199
+ 示例:
200
+ {program}
201
+ marctl --version
202
+
203
+ 输出:
204
+ marctl <version>
205
+
206
+ 读取已安装的 Node 包版本,输出单行并以换行符结尾。
207
+ 无需配置、授权或连接 Server。`
208
+ }),
209
+ nodesHeader: '节点 ID\t名称\t状态\t平台',
210
+ connected: '在线',
211
+ disconnected: '离线',
212
+ errors: Object.freeze({
213
+ sessionOutcomeUnknown: '投递结果未知,请先查看会话状态和历史,不要盲目重试。',
214
+ sessionMessageInvalid: '消息不能为空或超过长度限制;输入文件必须是可读取的 UTF-8 文本。',
215
+ sessionWaitUnknown: '无法确认指定 Run,请查看会话状态和历史。',
216
+ sessionWaitCancelled: '已取消等待,未停止目标 Run。',
217
+ sessionWaitTimeout: '等待超时,未停止目标 Run。',
218
+ sessionApprovalUnsupported: '此 Node 不支持待审批状态观察。',
219
+
220
+ userContextUnavailable: '此 Node 会话没有有效的 marctl 用户授权。',
221
+ sessionContextRequired: '当前上下文没有会话,请显式指定会话 ID。',
222
+ serverUrlInvalid: 'MAR_CTL_SERVER_URL 无效。',
223
+ serverUrlTransport: 'MAR_CTL_SERVER_URL 必须使用 HTTPS 或回环 HTTP。',
224
+ serverUrlOrigin: 'MAR_CTL_SERVER_URL 必须是不含凭据或查询参数的 Origin。',
225
+ fetchUnavailable: '当前 Node.js 运行时没有 Fetch。',
226
+ serverInvalidNodes: 'Server 返回的节点列表无效。',
227
+ serverInvalidManifest: 'Server 返回的节点清单无效。',
228
+ terminalCommandInvalid: '终端命令无效。',
229
+ terminalSequenceInvalid: '终端序列无效。',
230
+ terminalTicketInvalid: '终端票据无效。',
231
+ terminalIdInvalid: '终端标识无效。',
232
+ nodeIdInvalid: '节点标识无效。',
233
+ nodeNameAmbiguous: '多个可访问节点同名,请使用节点 ID。',
234
+ nodeNotFound: '没有与该 ID 或名称匹配的可访问节点。',
235
+ terminalSizeInvalid: '终端尺寸无效。',
236
+ serverInvalidTerminalId: 'Server 返回的终端标识无效。',
237
+ serverInvalidTicket: 'Server 返回的终端票据无效。',
238
+ serverInvalidJson: 'Server 返回的 JSON 无效。',
239
+ serverTimeout: 'marctl Server 未能在控制面请求超时前响应。',
240
+ serverUnreachable: '无法连接 marctl Server。',
241
+ serverRejected: 'marctl Server 拒绝了请求。',
242
+ terminalConnectionStart: '无法启动终端连接。',
243
+ terminalConnectionOpen: '无法打开终端连接。',
244
+ terminalAttachTimeout: '终端未能在连接建立超时前完成附着。',
245
+ terminalAttachConnection: '终端附着期间连接失败。',
246
+ terminalAttachLost: '终端附着期间连接断开。',
247
+ terminalRemoteError: '远程终端返回错误。',
248
+ terminalClosedBeforeAttach: '远程终端在附着前关闭。',
249
+ terminalFrameInvalid: '终端帧无效。',
250
+ terminalInvalidJson: '终端返回了无效 JSON。',
251
+ terminalBinaryFrame: '终端返回了无效二进制帧。',
252
+ terminalConnectionFailed: '终端连接失败。',
253
+ terminalConnectionLost: '终端连接断开。',
254
+ terminalUnexpectedFrame: '远程终端返回了意外帧。',
255
+ terminalInputFailed: '无法发送终端输入。',
256
+ terminalResizeFailed: '无法发送终端尺寸。',
257
+ terminalInteractiveRequired: '需要交互式终端。',
258
+ terminalInteractiveInit: '无法初始化交互式终端。',
259
+ terminalCloseFailed: '无法关闭远程终端。',
260
+ terminalSessionFailed: '终端会话失败。',
261
+ terminalDirectUnsafeFallback: 'OPEN 后无法安全取消直连终端,已跳过 relay 回退。',
262
+ invalidArguments: '命令参数无效。',
263
+ sessionDeliveryRequired: 'send 必须且只能选择 --steer 或 --queue,即使目标空闲也需指定。',
264
+ sshOptionsUnsupported: '不支持 SSH 选项,请使用 marssh <节点>。',
265
+ scpOptionsUnsupported: 'Node Terminal 传输不支持此 SCP 选项。',
266
+ terminalBinaryUnavailable: '二进制复制需要支持 pipe 终端的 Server 与 Node。',
267
+ commandFailed: '命令执行失败。'
268
+ })
269
+ });
@@ -0,0 +1,99 @@
1
+ import { MarctlError } from './errors.mjs';
2
+ import { CHUNK, WINDOW } from './scp-protocol.mjs';
3
+
4
+ const MAX_BUFFERED_BYTES = WINDOW * (CHUNK + 4) + 64;
5
+
6
+ export class ByteChannel {
7
+ #buffer = Buffer.alloc(0);
8
+ #waiting = [];
9
+ #sending = new Map();
10
+ #ended;
11
+ #failure;
12
+ #controller;
13
+
14
+ constructor(send, controller) {
15
+ this.#controller = controller;
16
+ const signal = controller.signal;
17
+ this.send = (bytes) => {
18
+ if (this.#failure) throw this.#failure;
19
+ if (this.#ended !== undefined) throw new MarctlError('Copy stream ended unexpectedly.');
20
+ return new Promise((resolve, reject) => {
21
+ this.#sending.set(reject, resolve);
22
+ const settle = (complete, value) => {
23
+ this.#sending.delete(reject);
24
+ complete(value);
25
+ };
26
+ try {
27
+ Promise.resolve(send(bytes)).then(
28
+ (value) => settle(resolve, value),
29
+ (error) => settle(reject, error)
30
+ );
31
+ } catch (error) {
32
+ settle(reject, error);
33
+ }
34
+ });
35
+ };
36
+ if (signal) {
37
+ if (signal.aborted) this.fail(signal.reason);
38
+ else
39
+ signal.addEventListener('abort', () => this.fail(signal.reason), {
40
+ once: true
41
+ });
42
+ }
43
+ }
44
+
45
+ feed(bytes) {
46
+ if (this.#failure) return;
47
+ this.#buffer = Buffer.concat([this.#buffer, bytes]);
48
+ if (this.#buffer.length > MAX_BUFFERED_BYTES)
49
+ return this.fail(new MarctlError('Copy output exceeded the bounded window.'));
50
+ this.#wake();
51
+ }
52
+
53
+ finish(code) {
54
+ this.#ended = code;
55
+ if (code !== 0) return this.fail(new MarctlError('Remote copy command failed.'));
56
+ // A successful exit confirms the worker consumed its final protocol input.
57
+ for (const resolve of this.#sending.values()) resolve();
58
+ this.#sending.clear();
59
+ this.#wake();
60
+ }
61
+
62
+ connectionEnded(error) {
63
+ if (this.#ended === undefined) this.fail(error);
64
+ }
65
+
66
+ fail(error) {
67
+ if (this.#failure !== undefined) return;
68
+ this.#failure = error;
69
+ for (const reject of this.#sending.keys()) reject(this.#failure);
70
+ this.#sending.clear();
71
+ this.#wake();
72
+ // Any endpoint failure must wake reads and writes across the entire copy.
73
+ this.#controller.abort(error);
74
+ }
75
+
76
+ #wake() {
77
+ for (const resolve of this.#waiting.splice(0)) resolve();
78
+ }
79
+
80
+ async read(length) {
81
+ if (this.#failure) throw this.#failure;
82
+ while (this.#buffer.length < length) {
83
+ if (this.#failure) throw this.#failure;
84
+ if (this.#ended !== undefined) throw new MarctlError('Copy stream ended unexpectedly.');
85
+ await new Promise((resolve) => this.#waiting.push(resolve));
86
+ }
87
+ const bytes = this.#buffer.subarray(0, length);
88
+ this.#buffer = this.#buffer.subarray(length);
89
+ return bytes;
90
+ }
91
+
92
+ async done() {
93
+ if (this.#failure) throw this.#failure;
94
+ while (this.#ended === undefined && this.#failure === undefined)
95
+ await new Promise((resolve) => this.#waiting.push(resolve));
96
+ if (this.#failure) throw this.#failure;
97
+ if (this.#ended !== 0) throw new MarctlError('Remote copy command failed.');
98
+ }
99
+ }