newmark-agent 0.3.10 → 0.3.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.
- package/config.example.json +6 -0
- package/dist/cli-commands.d.ts +7 -0
- package/dist/cli-commands.js +206 -15
- package/dist/cli-discovery.d.ts +15 -0
- package/dist/cli-discovery.js +182 -0
- package/dist/cli-help.d.ts +4 -0
- package/dist/cli-help.js +46 -0
- package/dist/conversation-utility-host.bundle.cjs +548 -137
- package/dist/core/agent.d.ts +18 -3
- package/dist/core/agent.js +236 -34
- package/dist/core/agentKernelRunner.js +72 -10
- package/dist/core/browserControl.d.ts +8 -0
- package/dist/core/browserUsePageAdapter.d.ts +3 -0
- package/dist/core/browserUsePageAdapter.js +19 -2
- package/dist/core/computerUseSession.d.ts +44 -0
- package/dist/core/computerUseSession.js +105 -0
- package/dist/core/config.d.ts +7 -2
- package/dist/core/config.js +24 -6
- package/dist/core/conversationKernel.d.ts +1 -0
- package/dist/core/conversationKernel.js +39 -1
- package/dist/core/electronBrowserUseHost.js +7 -0
- package/dist/core/electronUtilityAgentClient.js +84 -2
- package/dist/core/electronUtilityRuntimePool.d.ts +11 -0
- package/dist/core/electronUtilityRuntimePool.js +62 -0
- package/dist/core/flow-runner.js +1 -1
- package/dist/core/modelValidationStore.d.ts +4 -1
- package/dist/core/modelValidationStore.js +7 -1
- package/dist/core/utilityHostToolRouter.d.ts +7 -0
- package/dist/core/utilityHostToolRouter.js +25 -33
- package/dist/core/workspace.d.ts +6 -0
- package/dist/core/workspace.js +14 -0
- package/dist/core/wslAgentRuntimePool.d.ts +4 -0
- package/dist/core/wslAgentRuntimePool.js +56 -0
- package/dist/launcher.js +51 -10
- package/dist/llm/provider.d.ts +8 -5
- package/dist/llm/provider.js +85 -33
- package/dist/main.js +297 -61
- package/dist/preload.js +10 -2
- package/dist/providers/chat-completions.adapter.js +1 -5
- package/dist/providers/provider-events.d.ts +7 -0
- package/dist/providers/provider-events.js +44 -0
- package/dist/providers/responses.adapter.js +1 -3
- package/dist/tools/index.js +36 -49
- package/dist/tui/src/adapters/core-runtime-adapter.js +40 -3
- package/dist/tui/src/app.js +47 -13
- package/dist/tui/src/render.js +23 -7
- package/dist/tui/src/state.js +61 -9
- package/dist/ui/index.html +545 -122
- package/dist/wsl-agent-host.bundle.cjs +548 -137
- package/package.json +14 -5
package/config.example.json
CHANGED
package/dist/cli-commands.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export declare const CLI_COMMANDS: readonly ["state", "tool", "send", "validate-models", "fuzzy-inject", "skills-market", "memory-lab", "install-update", "compat", "compat-tool"];
|
|
2
|
+
/**
|
|
3
|
+
* Compatibility discovery reads third-party metadata outside the selected
|
|
4
|
+
* Newmark root. Those manifests can contain provider options, so structured
|
|
5
|
+
* compatibility output must not become a credential exfiltration path.
|
|
6
|
+
*/
|
|
7
|
+
export declare function redactCliSecrets<T>(value: T, seen?: WeakSet<object>): T;
|
|
2
8
|
export declare function runCliCommand(root: string, args: string[]): Promise<boolean>;
|
|
9
|
+
export declare function cliCommandHelp(command: string): string;
|
|
3
10
|
export declare function cliCommandUsage(): string;
|
|
4
11
|
//# sourceMappingURL=cli-commands.d.ts.map
|
package/dist/cli-commands.js
CHANGED
|
@@ -34,7 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.CLI_COMMANDS = void 0;
|
|
37
|
+
exports.redactCliSecrets = redactCliSecrets;
|
|
37
38
|
exports.runCliCommand = runCliCommand;
|
|
39
|
+
exports.cliCommandHelp = cliCommandHelp;
|
|
38
40
|
exports.cliCommandUsage = cliCommandUsage;
|
|
39
41
|
const path = __importStar(require("path"));
|
|
40
42
|
const fs = __importStar(require("fs"));
|
|
@@ -46,6 +48,97 @@ const compat_1 = require("./core/compat");
|
|
|
46
48
|
const memoryLab_1 = require("./core/memoryLab");
|
|
47
49
|
const installUpdate_1 = require("./core/installUpdate");
|
|
48
50
|
exports.CLI_COMMANDS = ['state', 'tool', 'send', 'validate-models', 'fuzzy-inject', 'skills-market', 'memory-lab', 'install-update', 'compat', 'compat-tool'];
|
|
51
|
+
const CLI_COMMAND_HELP = {
|
|
52
|
+
state: [
|
|
53
|
+
'Usage: Newmark.exe state [--root <dir>]',
|
|
54
|
+
'Read the current local state as JSON and exit without a model request.',
|
|
55
|
+
],
|
|
56
|
+
tool: [
|
|
57
|
+
'Usage: Newmark.exe tool <tool-name> [json-args | key=value ... | --args-file path] [--mode build|plan|goal|flow] [--root <dir>]',
|
|
58
|
+
'Execute one policy-checked tool and return its JSON envelope.',
|
|
59
|
+
],
|
|
60
|
+
send: [
|
|
61
|
+
'Usage: Newmark.exe send <prompt> [--input-env ENV|--input-file path] [--mode build|plan|goal|flow] [--model <model>] [--language auto|en|zh] [--conversation <id>] [--agent-only] [--root <dir>]',
|
|
62
|
+
'Send one non-interactive prompt through the selected local model.',
|
|
63
|
+
],
|
|
64
|
+
'validate-models': [
|
|
65
|
+
'Usage: Newmark.exe validate-models [--selected provider/model,model] [--persist] [--root <dir>]',
|
|
66
|
+
'Validate configured model deployments without changing config by default; --persist writes validation metadata intentionally.',
|
|
67
|
+
'An explicit selection with no configured matches prints [] and exits with status 1.',
|
|
68
|
+
],
|
|
69
|
+
'fuzzy-inject': [
|
|
70
|
+
'Usage: Newmark.exe fuzzy-inject [--name <provider>] [--env-file <file>|--env-file-env <ENV>] [--endpoint-env <ENV>] [--key-env <ENV>] [--protocol openai|anthropic] [--preview-only] [--root <dir>]',
|
|
71
|
+
'Discover or import a provider; --preview-only keeps the operation local and read-only.',
|
|
72
|
+
],
|
|
73
|
+
'skills-market': [
|
|
74
|
+
'Usage: Newmark.exe skills-market [--query <text>|--sources|--add-source --name <name> (--url <url>|--path <path>)|--remove-source <id>|--enable-source <id>|--disable-source <id>] [--root <dir>]',
|
|
75
|
+
'Search or manage local skill-market sources.',
|
|
76
|
+
],
|
|
77
|
+
'memory-lab': [
|
|
78
|
+
'Usage: Newmark.exe memory-lab [--read|--component <name>|--update ...|--reindex] [--root <dir>]',
|
|
79
|
+
'Read or update the local Memory Lab index and components.',
|
|
80
|
+
],
|
|
81
|
+
'install-update': [
|
|
82
|
+
'Usage: Newmark.exe install-update (--source <path>|--check-github|--from-github) [options] [--root <dir>]',
|
|
83
|
+
'Inspect or apply a local/GitHub update using the selected install target.',
|
|
84
|
+
],
|
|
85
|
+
compat: [
|
|
86
|
+
'Usage: Newmark.exe compat [--target all|tools|plugins|marketplaces|skills|agents|subagents] [--root <dir>]',
|
|
87
|
+
'Discover compatible local agent, plugin, marketplace, and skill metadata.',
|
|
88
|
+
],
|
|
89
|
+
'compat-tool': [
|
|
90
|
+
'Usage: Newmark.exe compat-tool --list | --name <opencode-tool> [json-args | --args-file path] [--root <dir>]',
|
|
91
|
+
'List or run one compatible OpenCode tool.',
|
|
92
|
+
],
|
|
93
|
+
};
|
|
94
|
+
function cliHelpRequested(args) {
|
|
95
|
+
return args.some(arg => ['--help', '-h'].includes(String(arg).toLowerCase()));
|
|
96
|
+
}
|
|
97
|
+
const CLI_VALUE_FLAGS = new Set([
|
|
98
|
+
'--root', '--input', '--input-env', '--input-file', '--mode', '--model', '--language', '--conversation',
|
|
99
|
+
'--args', '--args-file', '--selected', '--models', '--name', '--url', '--key', '--api-key', '--endpoint',
|
|
100
|
+
'--endpoint-env', '--url-env', '--key-env', '--api-key-env', '--env-file', '--env-file-env',
|
|
101
|
+
'--claude-env-file', '--claude-env-file-env', '--anthropic-env-file', '--anthropic-env-file-env',
|
|
102
|
+
'--candidate-models', '--protocol', '--query', '--type', '--path', '--component', '--source-id',
|
|
103
|
+
'--remove-source', '--enable-source', '--disable-source', '--source', '--target', '--target-file',
|
|
104
|
+
'--expected-version', '--preserve', '--repo', '--tag', '--asset', '--version', '--content-file',
|
|
105
|
+
'--content', '--description', '--tags',
|
|
106
|
+
]);
|
|
107
|
+
const CLI_BOOLEAN_FLAGS = new Set([
|
|
108
|
+
'--persist', '--agent-only', '--list', '--preview-only', '--sources', '--add-source', '--check-github',
|
|
109
|
+
'--from-github', '--dry-run', '--read', '--index', '--reindex', '--update', '--version', '--folder', '--help', '-h',
|
|
110
|
+
]);
|
|
111
|
+
function invalidCliCommandArgument(args) {
|
|
112
|
+
let skipNext = false;
|
|
113
|
+
for (let index = 0; index < args.length; index++) {
|
|
114
|
+
const arg = String(args[index] || '');
|
|
115
|
+
if (skipNext) {
|
|
116
|
+
skipNext = false;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (!arg || arg === '--' || !arg.startsWith('-'))
|
|
120
|
+
continue;
|
|
121
|
+
const name = arg.includes('=') ? arg.slice(0, arg.indexOf('=')) : arg;
|
|
122
|
+
const hasInlineValue = arg.includes('=');
|
|
123
|
+
if (CLI_BOOLEAN_FLAGS.has(name))
|
|
124
|
+
continue;
|
|
125
|
+
if (CLI_VALUE_FLAGS.has(name)) {
|
|
126
|
+
if (hasInlineValue) {
|
|
127
|
+
if (!arg.slice(name.length + 1))
|
|
128
|
+
return `${name} requires a value`;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
const next = args[index + 1];
|
|
132
|
+
if (!next || String(next).startsWith('-'))
|
|
133
|
+
return `${name} requires a value`;
|
|
134
|
+
skipNext = true;
|
|
135
|
+
}
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
return arg;
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
49
142
|
function argValue(args, key) {
|
|
50
143
|
const idx = args.indexOf(key);
|
|
51
144
|
return idx >= 0 ? args[idx + 1] : undefined;
|
|
@@ -228,6 +321,9 @@ function classifyCliToolOutput(tool, output) {
|
|
|
228
321
|
const unavailableHostCapability = tool === 'computer_use' || tool.startsWith('browser_');
|
|
229
322
|
return { envelope: { ok: false, tool, error: firstLine, route: 'direct' }, exitCode: unavailableHostCapability ? 3 : 2 };
|
|
230
323
|
}
|
|
324
|
+
if (/^\[(?:context_compress|context_history_manage)]/i.test(firstLine)) {
|
|
325
|
+
return { envelope: { ok: false, tool, error: firstLine, route: 'direct' }, exitCode: 4 };
|
|
326
|
+
}
|
|
231
327
|
if (/^\[(?:tool disabled|permission|Subagent sandbox)]/i.test(firstLine)) {
|
|
232
328
|
return { envelope: { ok: false, tool, error: firstLine, route: 'direct' }, exitCode: 3 };
|
|
233
329
|
}
|
|
@@ -382,6 +478,35 @@ function parseFuzzyEnvFile(filePath) {
|
|
|
382
478
|
function redactUrlSecret(value) {
|
|
383
479
|
return value.replace(/([?&](?:key|token|api_key|auth)=)[^&]+/gi, '$1<redacted>');
|
|
384
480
|
}
|
|
481
|
+
const CLI_SENSITIVE_FIELD = /(?:api.?key|authorization|access.?token|refresh.?token|secret|password|credential|cookie)/i;
|
|
482
|
+
/**
|
|
483
|
+
* Compatibility discovery reads third-party metadata outside the selected
|
|
484
|
+
* Newmark root. Those manifests can contain provider options, so structured
|
|
485
|
+
* compatibility output must not become a credential exfiltration path.
|
|
486
|
+
*/
|
|
487
|
+
function redactCliSecrets(value, seen = new WeakSet()) {
|
|
488
|
+
const walk = (current) => {
|
|
489
|
+
if (typeof current === 'string') {
|
|
490
|
+
return current
|
|
491
|
+
.replace(/\bsk-[A-Za-z0-9_.-]{8,}\b/gi, 'sk-***REDACTED***')
|
|
492
|
+
.replace(/\bBearer\s+[A-Za-z0-9_.=:/+_-]{8,}/gi, 'Bearer <redacted>')
|
|
493
|
+
.replace(/([?&](?:key|token|api_key|auth)=)[^&\s]+/gi, '$1<redacted>');
|
|
494
|
+
}
|
|
495
|
+
if (current === null || typeof current !== 'object')
|
|
496
|
+
return current;
|
|
497
|
+
if (seen.has(current))
|
|
498
|
+
return '[CIRCULAR]';
|
|
499
|
+
seen.add(current);
|
|
500
|
+
if (Array.isArray(current))
|
|
501
|
+
return current.map(item => walk(item));
|
|
502
|
+
const output = {};
|
|
503
|
+
for (const [key, nested] of Object.entries(current)) {
|
|
504
|
+
output[key] = CLI_SENSITIVE_FIELD.test(key) ? '[REDACTED]' : walk(nested);
|
|
505
|
+
}
|
|
506
|
+
return output;
|
|
507
|
+
};
|
|
508
|
+
return walk(value);
|
|
509
|
+
}
|
|
385
510
|
function filterSkillMarket(items, query) {
|
|
386
511
|
const q = (query || '').trim().toLowerCase();
|
|
387
512
|
if (!q)
|
|
@@ -539,11 +664,22 @@ async function runCliFuzzyInject(agent, name, url, key, protocol, preferredModel
|
|
|
539
664
|
};
|
|
540
665
|
}
|
|
541
666
|
async function runCliCommand(root, args) {
|
|
542
|
-
installCliPipeGuards();
|
|
543
667
|
const command = args.find(a => exports.CLI_COMMANDS.includes(a));
|
|
544
668
|
if (!command)
|
|
545
669
|
return false;
|
|
546
|
-
|
|
670
|
+
installCliPipeGuards();
|
|
671
|
+
const invalidArgument = invalidCliCommandArgument(args);
|
|
672
|
+
if (invalidArgument) {
|
|
673
|
+
safeStderr(`Invalid Newmark argument: ${invalidArgument}\n`);
|
|
674
|
+
process.exitCode = 2;
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
if (cliHelpRequested(args)) {
|
|
678
|
+
safeStdout(cliCommandHelp(command));
|
|
679
|
+
return true;
|
|
680
|
+
}
|
|
681
|
+
const readOnlyValidation = command === 'validate-models' && !args.includes('--persist');
|
|
682
|
+
const agent = new agent_1.Agent(root, { agentOnly: args.includes('--agent-only'), readOnlyConfig: readOnlyValidation });
|
|
547
683
|
agent.tools.setHostProfile({
|
|
548
684
|
kind: 'cli',
|
|
549
685
|
platform: process.platform,
|
|
@@ -599,11 +735,19 @@ async function runCliCommand(root, args) {
|
|
|
599
735
|
const toolArgs = parsedArgs.value;
|
|
600
736
|
const wsDir = agent.workspace.current?.path || root;
|
|
601
737
|
try {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
738
|
+
// Context management is an Agent-owned capability. Keep the direct CLI
|
|
739
|
+
// route on the same handler as model-dispatched calls instead of sending
|
|
740
|
+
// it through the generic filesystem/native ToolExecutor switch, which
|
|
741
|
+
// intentionally has no access to conversation history.
|
|
742
|
+
const result = toolName === 'context_compress'
|
|
743
|
+
? (await agent.handleContextCompress(JSON.stringify(toolArgs))).output
|
|
744
|
+
: toolName === 'context_history_manage'
|
|
745
|
+
? agent.handleContextHistoryManage(JSON.stringify(toolArgs)).output
|
|
746
|
+
: await agent.tools.execute(toolName, JSON.stringify(toolArgs), wsDir, {
|
|
747
|
+
mode: agent.mode,
|
|
748
|
+
workspacePath: wsDir,
|
|
749
|
+
invocation: 'cli',
|
|
750
|
+
});
|
|
607
751
|
const classified = classifyCliToolOutput(toolName, result);
|
|
608
752
|
emitCliToolEnvelope(classified.envelope, classified.exitCode);
|
|
609
753
|
}
|
|
@@ -623,17 +767,50 @@ async function runCliCommand(root, args) {
|
|
|
623
767
|
return true;
|
|
624
768
|
}
|
|
625
769
|
const model = argValue(args, '--model');
|
|
626
|
-
if (model)
|
|
770
|
+
if (model) {
|
|
627
771
|
agent.setModel(model);
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
772
|
+
// Reject a bad explicit selection before Agent.process creates a user
|
|
773
|
+
// message/work-run or reaches the provider transport. Qualified
|
|
774
|
+
// provider/model values are normalized by Agent.setModel first.
|
|
775
|
+
if (model !== 'auto' && !agent.activeModelConfig()) {
|
|
776
|
+
safeStdout(`[Error] Model '${model}' is unavailable or not configured. Select a configured model or enable a valid provider before sending.`);
|
|
777
|
+
safeStdout('\n');
|
|
778
|
+
process.exitCode = 1;
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
try {
|
|
783
|
+
const tokens = await agent.process(prompt);
|
|
784
|
+
const output = tokens.map(t => t.text || '').join('');
|
|
785
|
+
safeStdout(output);
|
|
786
|
+
safeStdout('\n');
|
|
787
|
+
// Keep the diagnostic in stdout for pipes, but make the non-interactive
|
|
788
|
+
// command fail when Agent returned a structured error token.
|
|
789
|
+
if (tokens.some(token => {
|
|
790
|
+
const text = String(token.text || '');
|
|
791
|
+
return agent.isLlmErrorText(text) || /^\s*\[(?:Workspace required|Attachment rejected)\]/i.test(text);
|
|
792
|
+
}))
|
|
793
|
+
process.exitCode = 1;
|
|
794
|
+
}
|
|
795
|
+
catch (error) {
|
|
796
|
+
// The shared GUI/TUI kernel must throw real terminal failures so it
|
|
797
|
+
// cannot synthesize a completed WorkRun. Preserve the CLI's stable
|
|
798
|
+
// stdout diagnostic and non-zero exit contract at this boundary.
|
|
799
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
800
|
+
safeStdout(message.startsWith('[') ? message : `[Error] ${message}`);
|
|
801
|
+
safeStdout('\n');
|
|
802
|
+
process.exitCode = 1;
|
|
803
|
+
}
|
|
631
804
|
return true;
|
|
632
805
|
}
|
|
633
806
|
if (command === 'validate-models') {
|
|
634
807
|
const selected = splitList(pathArgValue(args, '--selected') || pathArgValue(args, '--models'));
|
|
635
|
-
const result = await agent.validateModels(selected.length ? selected : undefined);
|
|
808
|
+
const result = await agent.validateModels(selected.length ? selected : undefined, { persist: args.includes('--persist') });
|
|
636
809
|
printJson(result);
|
|
810
|
+
if (selected.length && result.length === 0) {
|
|
811
|
+
safeStderr(`No configured model deployments matched --selected: ${selected.join(', ')}\n`);
|
|
812
|
+
process.exitCode = 1;
|
|
813
|
+
}
|
|
637
814
|
return true;
|
|
638
815
|
}
|
|
639
816
|
if (command === 'fuzzy-inject') {
|
|
@@ -846,12 +1023,12 @@ async function runCliCommand(root, args) {
|
|
|
846
1023
|
};
|
|
847
1024
|
payload.subagents = agent.subagents.listAll().map(s => agent.subagents.toRecord(s.id));
|
|
848
1025
|
}
|
|
849
|
-
printJson(payload);
|
|
1026
|
+
printJson(redactCliSecrets(payload));
|
|
850
1027
|
return true;
|
|
851
1028
|
}
|
|
852
1029
|
if (command === 'compat-tool') {
|
|
853
1030
|
if (args.includes('--list')) {
|
|
854
|
-
printJson({ ok: true, tools: (0, compat_1.discoverOpenCodeTools)(root) });
|
|
1031
|
+
printJson(redactCliSecrets({ ok: true, tools: (0, compat_1.discoverOpenCodeTools)(root) }));
|
|
855
1032
|
return true;
|
|
856
1033
|
}
|
|
857
1034
|
const positional = positionalAfter(args, 'compat-tool');
|
|
@@ -867,11 +1044,25 @@ async function runCliCommand(root, args) {
|
|
|
867
1044
|
process.exitCode = 1;
|
|
868
1045
|
return true;
|
|
869
1046
|
}
|
|
870
|
-
printJson(await (0, compat_1.runOpenCodeTool)(root, name, parsedArgs.value));
|
|
1047
|
+
printJson(redactCliSecrets(await (0, compat_1.runOpenCodeTool)(root, name, parsedArgs.value)));
|
|
871
1048
|
return true;
|
|
872
1049
|
}
|
|
873
1050
|
return false;
|
|
874
1051
|
}
|
|
1052
|
+
function cliCommandHelp(command) {
|
|
1053
|
+
const key = command;
|
|
1054
|
+
const lines = CLI_COMMAND_HELP[key];
|
|
1055
|
+
if (!lines)
|
|
1056
|
+
return `${cliCommandUsage()}\n`;
|
|
1057
|
+
return [
|
|
1058
|
+
`Newmark CLI command: ${command}`,
|
|
1059
|
+
'',
|
|
1060
|
+
...lines,
|
|
1061
|
+
'',
|
|
1062
|
+
'Flags:',
|
|
1063
|
+
' --help, -h Show this command help and exit without network or model work.',
|
|
1064
|
+
].join('\n') + '\n';
|
|
1065
|
+
}
|
|
875
1066
|
function cliCommandUsage() {
|
|
876
1067
|
return [
|
|
877
1068
|
'Newmark CLI non-interactive commands:',
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Public version spellings accepted by every Newmark entrypoint. */
|
|
2
|
+
export declare function isVersionArgument(args: string[]): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Validate arguments that are interpreted before a command-specific parser is
|
|
5
|
+
* entered. This keeps malformed launch probes from silently starting a GUI or
|
|
6
|
+
* falling back to the default user root.
|
|
7
|
+
*/
|
|
8
|
+
export declare function invalidTopLevelArgument(args: string[]): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Return the first unknown positional top-level token without validating a
|
|
11
|
+
* command's own arguments. Values belonging to documented flags are skipped,
|
|
12
|
+
* so a space-containing --root or --input cannot be mistaken for a command.
|
|
13
|
+
*/
|
|
14
|
+
export declare function unknownTopLevelCommand(args: string[]): string | undefined;
|
|
15
|
+
//# sourceMappingURL=cli-discovery.d.ts.map
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isVersionArgument = isVersionArgument;
|
|
4
|
+
exports.invalidTopLevelArgument = invalidTopLevelArgument;
|
|
5
|
+
exports.unknownTopLevelCommand = unknownTopLevelCommand;
|
|
6
|
+
const cli_commands_1 = require("./cli-commands");
|
|
7
|
+
const TOP_LEVEL_COMMANDS = new Set([...cli_commands_1.CLI_COMMANDS, 'flow', 'edit', 'help']);
|
|
8
|
+
const VALUE_FLAGS = new Set([
|
|
9
|
+
'--root',
|
|
10
|
+
'--input',
|
|
11
|
+
'--input-env',
|
|
12
|
+
'--input-file',
|
|
13
|
+
'--mode',
|
|
14
|
+
'--model',
|
|
15
|
+
'--language',
|
|
16
|
+
'--conversation',
|
|
17
|
+
'--args',
|
|
18
|
+
'--args-file',
|
|
19
|
+
'--selected',
|
|
20
|
+
'--models',
|
|
21
|
+
'--name',
|
|
22
|
+
'--url',
|
|
23
|
+
'--key',
|
|
24
|
+
'--api-key',
|
|
25
|
+
'--protocol',
|
|
26
|
+
'--endpoint',
|
|
27
|
+
'--endpoint-env',
|
|
28
|
+
'--url-env',
|
|
29
|
+
'--key-env',
|
|
30
|
+
'--api-key-env',
|
|
31
|
+
'--env-file',
|
|
32
|
+
'--env-file-env',
|
|
33
|
+
'--claude-env-file',
|
|
34
|
+
'--claude-env-file-env',
|
|
35
|
+
'--anthropic-env-file',
|
|
36
|
+
'--anthropic-env-file-env',
|
|
37
|
+
'--candidate-models',
|
|
38
|
+
'--query',
|
|
39
|
+
'--type',
|
|
40
|
+
'--target',
|
|
41
|
+
'--source',
|
|
42
|
+
'--source-id',
|
|
43
|
+
'--remove-source',
|
|
44
|
+
'--enable-source',
|
|
45
|
+
'--disable-source',
|
|
46
|
+
'--target-file',
|
|
47
|
+
'--expected-version',
|
|
48
|
+
'--preserve',
|
|
49
|
+
'--repo',
|
|
50
|
+
'--tag',
|
|
51
|
+
'--asset',
|
|
52
|
+
'--path',
|
|
53
|
+
'--component',
|
|
54
|
+
'--content-file',
|
|
55
|
+
'--content',
|
|
56
|
+
'--description',
|
|
57
|
+
'--tags',
|
|
58
|
+
'--workspace',
|
|
59
|
+
'--remote-debugging-port',
|
|
60
|
+
'--user-data-dir',
|
|
61
|
+
'--disable-features',
|
|
62
|
+
'--enable-features',
|
|
63
|
+
'--remote-debugging-address',
|
|
64
|
+
'--inspect-port',
|
|
65
|
+
'--js-flags',
|
|
66
|
+
'--viewer-request',
|
|
67
|
+
]);
|
|
68
|
+
const BOOLEAN_FLAGS = new Set([
|
|
69
|
+
'--tui',
|
|
70
|
+
'--gui',
|
|
71
|
+
'--cli',
|
|
72
|
+
'--server',
|
|
73
|
+
'--help',
|
|
74
|
+
'-h',
|
|
75
|
+
'--version',
|
|
76
|
+
'-v',
|
|
77
|
+
'-version',
|
|
78
|
+
'--automation-wake',
|
|
79
|
+
'--newmark-viewer',
|
|
80
|
+
'--allow-multiple-instances',
|
|
81
|
+
'--disable-gpu',
|
|
82
|
+
'--no-sandbox',
|
|
83
|
+
'--no-devtools',
|
|
84
|
+
'--demo',
|
|
85
|
+
'--persist',
|
|
86
|
+
'--agent-only',
|
|
87
|
+
'--list',
|
|
88
|
+
'--preview-only',
|
|
89
|
+
'--sources',
|
|
90
|
+
'--add-source',
|
|
91
|
+
'--check-github',
|
|
92
|
+
'--from-github',
|
|
93
|
+
'--dry-run',
|
|
94
|
+
'--read',
|
|
95
|
+
'--index',
|
|
96
|
+
'--reindex',
|
|
97
|
+
'--update',
|
|
98
|
+
'--folder',
|
|
99
|
+
'--quiet',
|
|
100
|
+
'--json',
|
|
101
|
+
'--limit',
|
|
102
|
+
'--scopes',
|
|
103
|
+
'--web',
|
|
104
|
+
]);
|
|
105
|
+
/** Public version spellings accepted by every Newmark entrypoint. */
|
|
106
|
+
function isVersionArgument(args) {
|
|
107
|
+
return args.some(arg => ['--version', '-v', '-version'].includes(String(arg).toLowerCase()));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Validate arguments that are interpreted before a command-specific parser is
|
|
111
|
+
* entered. This keeps malformed launch probes from silently starting a GUI or
|
|
112
|
+
* falling back to the default user root.
|
|
113
|
+
*/
|
|
114
|
+
function invalidTopLevelArgument(args) {
|
|
115
|
+
let skipNext = false;
|
|
116
|
+
for (let index = 0; index < args.length; index++) {
|
|
117
|
+
const raw = args[index];
|
|
118
|
+
const arg = String(raw || '');
|
|
119
|
+
if (skipNext) {
|
|
120
|
+
skipNext = false;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (!arg || arg === '--')
|
|
124
|
+
continue;
|
|
125
|
+
if (!arg.startsWith('-'))
|
|
126
|
+
continue;
|
|
127
|
+
const name = (arg.includes('=') ? arg.slice(0, arg.indexOf('=')) : arg).toLowerCase();
|
|
128
|
+
const hasInlineValue = arg.includes('=');
|
|
129
|
+
if (BOOLEAN_FLAGS.has(name))
|
|
130
|
+
continue;
|
|
131
|
+
if (VALUE_FLAGS.has(name)) {
|
|
132
|
+
if (!hasInlineValue) {
|
|
133
|
+
const next = args[index + 1];
|
|
134
|
+
if (!next || String(next).startsWith('-'))
|
|
135
|
+
return `${name} requires a value`;
|
|
136
|
+
skipNext = true;
|
|
137
|
+
}
|
|
138
|
+
else if (!arg.slice(name.length + 1)) {
|
|
139
|
+
return `${name} requires a value`;
|
|
140
|
+
}
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
return arg;
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Return the first unknown positional top-level token without validating a
|
|
149
|
+
* command's own arguments. Values belonging to documented flags are skipped,
|
|
150
|
+
* so a space-containing --root or --input cannot be mistaken for a command.
|
|
151
|
+
*/
|
|
152
|
+
function unknownTopLevelCommand(args) {
|
|
153
|
+
let skipNext = false;
|
|
154
|
+
for (let index = 0; index < args.length; index++) {
|
|
155
|
+
const raw = args[index];
|
|
156
|
+
const arg = String(raw || '');
|
|
157
|
+
if (skipNext) {
|
|
158
|
+
skipNext = false;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (!arg)
|
|
162
|
+
continue;
|
|
163
|
+
if (arg.startsWith('--')) {
|
|
164
|
+
const name = (arg.includes('=') ? arg.slice(0, arg.indexOf('=')) : arg).toLowerCase();
|
|
165
|
+
if (VALUE_FLAGS.has(name) && !arg.includes('='))
|
|
166
|
+
skipNext = true;
|
|
167
|
+
else if (!VALUE_FLAGS.has(name) && !BOOLEAN_FLAGS.has(name))
|
|
168
|
+
return arg;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (arg.startsWith('-')) {
|
|
172
|
+
if (!BOOLEAN_FLAGS.has(arg))
|
|
173
|
+
return arg;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (TOP_LEVEL_COMMANDS.has(arg.toLowerCase()))
|
|
177
|
+
return undefined;
|
|
178
|
+
return arg;
|
|
179
|
+
}
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=cli-discovery.js.map
|
package/dist/cli-help.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newmarkFlowHelpText = newmarkFlowHelpText;
|
|
4
|
+
exports.newmarkEditHelpText = newmarkEditHelpText;
|
|
5
|
+
exports.newmarkHelpText = newmarkHelpText;
|
|
6
|
+
const cli_commands_1 = require("./cli-commands");
|
|
7
|
+
function newmarkFlowHelpText() {
|
|
8
|
+
return [
|
|
9
|
+
'Newmark Flow command:',
|
|
10
|
+
'',
|
|
11
|
+
'Usage: Newmark.exe flow <workflow-name> [start-pc] [--input "text"] [--root <dir>]',
|
|
12
|
+
'Run a saved Flow workflow from the selected local runtime root.',
|
|
13
|
+
'',
|
|
14
|
+
'Flags:',
|
|
15
|
+
' --help, -h Show this Flow help and exit without runtime or model work.',
|
|
16
|
+
].join('\n') + '\n';
|
|
17
|
+
}
|
|
18
|
+
function newmarkEditHelpText() {
|
|
19
|
+
return [
|
|
20
|
+
'Newmark editor command:',
|
|
21
|
+
'',
|
|
22
|
+
'Usage: Newmark.exe edit <file.txt|.json|.tex|.md>',
|
|
23
|
+
'Open a supported text file in the terminal editor.',
|
|
24
|
+
'',
|
|
25
|
+
'Flags:',
|
|
26
|
+
' --help, -h Show this editor help and exit without opening a file.',
|
|
27
|
+
].join('\n') + '\n';
|
|
28
|
+
}
|
|
29
|
+
function newmarkHelpText(version) {
|
|
30
|
+
return [
|
|
31
|
+
`Newmark Agent ${version}`,
|
|
32
|
+
'',
|
|
33
|
+
'Usage:',
|
|
34
|
+
' Newmark Agent.exe [--gui|--TUI|--cli] [--root <dir>]',
|
|
35
|
+
' Newmark.exe <command> ...',
|
|
36
|
+
' Newmark.exe flow <workflow-name> [start-pc] [--input "text"] [--root <dir>]',
|
|
37
|
+
' Newmark.exe edit <file.txt|.json|.tex|.md>',
|
|
38
|
+
'',
|
|
39
|
+
(0, cli_commands_1.cliCommandUsage)(),
|
|
40
|
+
'',
|
|
41
|
+
'Flags:',
|
|
42
|
+
' --help, -h Show this help and exit.',
|
|
43
|
+
' --version, -v, -version Show the installed version and exit.',
|
|
44
|
+
].join('\n');
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=cli-help.js.map
|