nolo-cli 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agentRunCommand.ts +104 -0
- package/commandRegistry.ts +2 -0
- package/index.ts +12 -4
- package/package.json +2 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { DEFAULT_NOLO_SERVER_URL } from "./defaultServer";
|
|
2
|
+
import { runAgentTurn, type RunAgentTurnResult } from "./client/agentRun";
|
|
3
|
+
import type { AgentRuntimeRequestedMode } from "./agentRuntimeLocal";
|
|
4
|
+
|
|
5
|
+
type EnvLike = Record<string, string | undefined>;
|
|
6
|
+
|
|
7
|
+
type OutputLike = {
|
|
8
|
+
write(chunk: string): unknown;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type AgentRunCommandDeps = {
|
|
12
|
+
env?: EnvLike;
|
|
13
|
+
scriptDir: string;
|
|
14
|
+
output?: OutputLike;
|
|
15
|
+
runner?: typeof runAgentTurn;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type ParsedAgentRunArgs = {
|
|
19
|
+
agentKey: string;
|
|
20
|
+
message: string;
|
|
21
|
+
runtimeMode?: AgentRuntimeRequestedMode;
|
|
22
|
+
continueDialogId?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function readFlagValue(args: string[], flag: string) {
|
|
26
|
+
const index = args.indexOf(flag);
|
|
27
|
+
if (index < 0) return undefined;
|
|
28
|
+
return args[index + 1];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function runtimeModeFromArgs(args: string[]): AgentRuntimeRequestedMode | undefined {
|
|
32
|
+
if (args.includes("--local")) return "local";
|
|
33
|
+
if (args.includes("--server")) return "server";
|
|
34
|
+
if (args.includes("--auto")) return "auto";
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function positionalArgs(args: string[]) {
|
|
39
|
+
const values: string[] = [];
|
|
40
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
41
|
+
const arg = args[index];
|
|
42
|
+
if (arg === "--local" || arg === "--server" || arg === "--auto") continue;
|
|
43
|
+
if (arg.startsWith("--")) {
|
|
44
|
+
index += 1;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
values.push(arg);
|
|
48
|
+
}
|
|
49
|
+
return values;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function parseAgentRunArgs(args: string[]): ParsedAgentRunArgs | null {
|
|
53
|
+
const agentKey = readFlagValue(args, "--agent") ?? positionalArgs(args)[0];
|
|
54
|
+
const explicitMsg = readFlagValue(args, "--msg");
|
|
55
|
+
const message = explicitMsg ?? positionalArgs(args).slice(1).join(" ");
|
|
56
|
+
if (!agentKey || !message.trim()) return null;
|
|
57
|
+
const runtimeMode = runtimeModeFromArgs(args);
|
|
58
|
+
const continueDialogId = readFlagValue(args, "--continue") ?? readFlagValue(args, "--dialog");
|
|
59
|
+
return {
|
|
60
|
+
agentKey,
|
|
61
|
+
message: message.trim(),
|
|
62
|
+
...(runtimeMode ? { runtimeMode } : {}),
|
|
63
|
+
...(continueDialogId ? { continueDialogId } : {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function resolveServerUrl(env: EnvLike) {
|
|
68
|
+
return (env.NOLO_SERVER || env.BASE_URL || DEFAULT_NOLO_SERVER_URL).replace(/\/+$/, "");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function writeUsage(output: OutputLike) {
|
|
72
|
+
output.write(
|
|
73
|
+
"Usage: nolo agent run <agent> <message> [--local|--server|--auto] [--continue <dialogId>]\n" +
|
|
74
|
+
" nolo agent run --agent <agent> --msg <message> [--local|--server|--auto]\n"
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function runAgentRunCommand(args: string[], deps: AgentRunCommandDeps) {
|
|
79
|
+
const env = deps.env ?? process.env;
|
|
80
|
+
const output = deps.output ?? process.stdout;
|
|
81
|
+
const parsed = parseAgentRunArgs(args);
|
|
82
|
+
if (!parsed) {
|
|
83
|
+
writeUsage(output);
|
|
84
|
+
return 1;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const runner = deps.runner ?? runAgentTurn;
|
|
88
|
+
const result: RunAgentTurnResult = await runner({
|
|
89
|
+
agentName: parsed.agentKey,
|
|
90
|
+
agentKey: parsed.agentKey,
|
|
91
|
+
serverUrl: resolveServerUrl(env),
|
|
92
|
+
message: parsed.message,
|
|
93
|
+
scriptDir: deps.scriptDir,
|
|
94
|
+
env,
|
|
95
|
+
output,
|
|
96
|
+
...(parsed.runtimeMode ? { runtimeMode: parsed.runtimeMode } : {}),
|
|
97
|
+
...(parsed.continueDialogId ? { continueDialogId: parsed.continueDialogId } : {}),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (result.dialogId) {
|
|
101
|
+
output.write(`\n[nolo] dialog ${result.dialogId}\n`);
|
|
102
|
+
}
|
|
103
|
+
return result.exitCode;
|
|
104
|
+
}
|
package/commandRegistry.ts
CHANGED
|
@@ -29,6 +29,7 @@ export const COMMANDS: CommandEntry[] = [
|
|
|
29
29
|
|
|
30
30
|
{ path: ["agent", "list"], script: "listMyAgents.ts", description: "List owned agents" },
|
|
31
31
|
{ path: ["agent", "read"], script: "readAgent.ts", description: "Read a single agent" },
|
|
32
|
+
{ path: ["agent", "run"], script: "", description: "Run an agent" },
|
|
32
33
|
{ path: ["agent", "update"], script: "updateAgent.ts", description: "Update agent fields" },
|
|
33
34
|
{ path: ["agent", "bind-current"], script: "", description: "Bind an agent to this machine" },
|
|
34
35
|
{ path: ["agent", "smoke-current"], script: "", description: "Smoke test a bound agent through this machine" },
|
|
@@ -94,6 +95,7 @@ export function renderHelpText() {
|
|
|
94
95
|
' nolo skill-doc create --title "Agent Query Skill" --description "Inspect recent agent dialogs" --sync local,main,us',
|
|
95
96
|
" nolo agent list --json",
|
|
96
97
|
" nolo agent read agent-pub-01APPBUILDER00000001YAII3I",
|
|
98
|
+
' nolo agent run frontend-implementer --msg "polish notifications" --local',
|
|
97
99
|
" nolo agent bind-current agent-user-1-agent-1",
|
|
98
100
|
" nolo agent runtime-doctor agent-user-1-agent-1",
|
|
99
101
|
' nolo agent smoke-current agent-user-1-agent-1 --msg "ping"',
|
package/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
runAgentSmokeCurrentCommand,
|
|
12
12
|
runDoctorRuntimeCommand,
|
|
13
13
|
} from "./agentRuntimeCommands";
|
|
14
|
+
import { runAgentRunCommand } from "./agentRunCommand";
|
|
14
15
|
import { buildEnvFromProfile, loadProfileConfig } from "./client/profileConfig";
|
|
15
16
|
import { resolveTuiLaunchMode } from "./runtimeModeArgs";
|
|
16
17
|
import {
|
|
@@ -118,10 +119,17 @@ if (args[0] === "agent" && args[1] === "bind-current") {
|
|
|
118
119
|
process.exit(await runAgentBindCurrentCommand(args.slice(2), { env: runtimeEnv }));
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
if (args[0] === "agent" && args[1] === "smoke-current") {
|
|
122
|
-
process.exit(await runAgentSmokeCurrentCommand(args.slice(2), { env: runtimeEnv }));
|
|
123
|
-
}
|
|
124
|
-
|
|
122
|
+
if (args[0] === "agent" && args[1] === "smoke-current") {
|
|
123
|
+
process.exit(await runAgentSmokeCurrentCommand(args.slice(2), { env: runtimeEnv }));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (args[0] === "agent" && args[1] === "run") {
|
|
127
|
+
process.exit(await runAgentRunCommand(args.slice(2), {
|
|
128
|
+
env: runtimeEnv,
|
|
129
|
+
scriptDir: SCRIPT_DIR,
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
|
|
125
133
|
if (args[0] === "agent" && args[1] === "runtime-doctor") {
|
|
126
134
|
process.exit(await runAgentRuntimeDoctorCommand(args.slice(2), { env: runtimeEnv }));
|
|
127
135
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nolo-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Agent-first terminal workspace for Nolo",
|
|
6
6
|
"bin": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"agentRuntimeLocal.ts",
|
|
13
13
|
"localRuntimeDb.ts",
|
|
14
14
|
"agentRuntimeCommands.ts",
|
|
15
|
+
"agentRunCommand.ts",
|
|
15
16
|
"authCommands.ts",
|
|
16
17
|
"commandRegistry.ts",
|
|
17
18
|
"connectorWebSocketTarget.ts",
|