@alpic80/rivet-cli 1.24.0-aidon.10 → 1.24.0-aidon.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/bin/commands/serve.js +20 -19
- package/dist/types/commands/serve.d.ts +8 -8
- package/package.json +1 -1
package/bin/commands/serve.js
CHANGED
|
@@ -19,13 +19,11 @@ export function makeCommand(y) {
|
|
|
19
19
|
})
|
|
20
20
|
.option('port', {
|
|
21
21
|
describe: 'The port to serve on',
|
|
22
|
-
type: 'number'
|
|
23
|
-
default: 3000,
|
|
22
|
+
type: 'number'
|
|
24
23
|
})
|
|
25
24
|
.option('dev', {
|
|
26
25
|
describe: 'Run in development mode: rereads the project file on each request',
|
|
27
|
-
type: 'boolean'
|
|
28
|
-
default: false,
|
|
26
|
+
type: 'boolean'
|
|
29
27
|
})
|
|
30
28
|
.option('graph', {
|
|
31
29
|
describe: 'The ID or name of the graph to run. If omitted, the main graph is used.',
|
|
@@ -34,8 +32,7 @@ export function makeCommand(y) {
|
|
|
34
32
|
})
|
|
35
33
|
.option('allow-specifying-graph-id', {
|
|
36
34
|
describe: 'Allow specifying the graph ID in the URL path',
|
|
37
|
-
type: 'boolean'
|
|
38
|
-
default: false,
|
|
35
|
+
type: 'boolean'
|
|
39
36
|
})
|
|
40
37
|
.option('openai-api-key', {
|
|
41
38
|
describe: 'The OpenAI API key to use for the project. If omitted, the environment variable OPENAI_API_KEY is used.',
|
|
@@ -54,13 +51,11 @@ export function makeCommand(y) {
|
|
|
54
51
|
})
|
|
55
52
|
.option('expose-cost', {
|
|
56
53
|
describe: 'Expose the cost of the graph run in the response',
|
|
57
|
-
type: 'boolean'
|
|
58
|
-
default: false,
|
|
54
|
+
type: 'boolean'
|
|
59
55
|
})
|
|
60
56
|
.option('expose-usage', {
|
|
61
57
|
describe: 'Expose the token usage of the graph run in the response',
|
|
62
|
-
type: 'boolean'
|
|
63
|
-
default: false,
|
|
58
|
+
type: 'boolean'
|
|
64
59
|
})
|
|
65
60
|
.option('stream', {
|
|
66
61
|
describe: 'Turns on streaming mode. Rivet events will be sent to the client using SSE (Server-Sent Events). If this is set to a Node ID or node title, only events for that node will be sent.',
|
|
@@ -74,18 +69,15 @@ export function makeCommand(y) {
|
|
|
74
69
|
})
|
|
75
70
|
.option('log-requests', {
|
|
76
71
|
describe: 'Determines if all requests (except health checks) will be logged via Hono logger',
|
|
77
|
-
type: 'boolean'
|
|
78
|
-
default: false,
|
|
72
|
+
type: 'boolean'
|
|
79
73
|
})
|
|
80
74
|
.option('log-activity', {
|
|
81
75
|
describe: 'Determines if basic activity should be logging during processing',
|
|
82
|
-
type: 'boolean'
|
|
83
|
-
default: false,
|
|
76
|
+
type: 'boolean'
|
|
84
77
|
})
|
|
85
78
|
.option('log-trace', {
|
|
86
79
|
describe: 'Determines if includeTrace should be turned on during graph processing',
|
|
87
|
-
type: 'boolean'
|
|
88
|
-
default: false,
|
|
80
|
+
type: 'boolean'
|
|
89
81
|
})
|
|
90
82
|
.option('projects-root-dir', {
|
|
91
83
|
describe: 'Specifies the root directory where project files are located. If specified, a projectFile argument will be a relative path to this directory',
|
|
@@ -113,8 +105,8 @@ export async function serve(cliArgs = {}) {
|
|
|
113
105
|
debugger;
|
|
114
106
|
const pluginSettings = await setupPlugins(Rivet);
|
|
115
107
|
const args = {
|
|
116
|
-
hostname: cliArgs.hostname ?? process.env.
|
|
117
|
-
port: Number(cliArgs.port ?? process.env.
|
|
108
|
+
hostname: cliArgs.hostname ?? process.env.SERVE_HOSTNAME ?? '127.0.0.1',
|
|
109
|
+
port: Number(cliArgs.port ?? process.env.SERVE_PORT ?? 3000),
|
|
118
110
|
projectFile: cliArgs.projectFile ?? process.env.PROJECT_FILE,
|
|
119
111
|
dev: cliArgs.dev ?? process.env.NODE_ENV === 'development',
|
|
120
112
|
graph: cliArgs.graph ?? process.env.GRAPH,
|
|
@@ -150,7 +142,7 @@ export async function serve(cliArgs = {}) {
|
|
|
150
142
|
throwIfNoMainGraph(initialProject, args.graph, projectFilePath);
|
|
151
143
|
throwIfInvalidGraph(initialProject, args.graph);
|
|
152
144
|
}
|
|
153
|
-
console.log(chalk.green('Server running version
|
|
145
|
+
console.log(chalk.green('Server running version 11'));
|
|
154
146
|
if (args.logActivity) {
|
|
155
147
|
const logInfo = [
|
|
156
148
|
args.hostname && `Hostname:${chalk.bold.white(args.hostname)}`,
|
|
@@ -166,6 +158,9 @@ export async function serve(cliArgs = {}) {
|
|
|
166
158
|
app.get('/health', async (c) => c.text('Healthy like Popeye'));
|
|
167
159
|
app.post('/', async (c) => {
|
|
168
160
|
if (args.projectsRootDir) {
|
|
161
|
+
if (args.logActivity) {
|
|
162
|
+
console.error(chalk.red('Status 400 - Configured with projects-root-dir which requires a project file to be specified in URL,'));
|
|
163
|
+
}
|
|
169
164
|
return c.text('Configured with projects-root-dir which requires a project file to be specified in URL', 400);
|
|
170
165
|
}
|
|
171
166
|
const project = args.dev ? await loadProjectFromFile(projectFilePath) : initialProject;
|
|
@@ -194,10 +189,16 @@ export async function serve(cliArgs = {}) {
|
|
|
194
189
|
let project;
|
|
195
190
|
if (args.projectsRootDir) {
|
|
196
191
|
if (!graphFile) {
|
|
192
|
+
if (args.logActivity) {
|
|
193
|
+
console.error(chalk.red('Status 400 - A graphFile is required when specifying projects-root-dir,'));
|
|
194
|
+
}
|
|
197
195
|
return c.text('A graphFile is required when specifying projects-root-dir', 400);
|
|
198
196
|
}
|
|
199
197
|
const fileMissing = await testIfMissingFile(path.join(args.projectsRootDir, graphFile));
|
|
200
198
|
if (fileMissing) {
|
|
199
|
+
if (args.logActivity) {
|
|
200
|
+
console.error(chalk.red(`GraphFile ${graphFile} not found in root directory (${args.projectsRootDir})`));
|
|
201
|
+
}
|
|
201
202
|
return c.text(`GraphFile ${graphFile} not found in root directory (${args.projectsRootDir})`, 400);
|
|
202
203
|
}
|
|
203
204
|
project = await loadProjectFromFile(path.join(args.projectsRootDir, graphFile));
|
|
@@ -2,13 +2,13 @@ import type * as yargs from 'yargs';
|
|
|
2
2
|
export declare function makeCommand<T>(y: yargs.Argv<T>): yargs.Argv<T & {
|
|
3
3
|
hostname: string | undefined;
|
|
4
4
|
} & {
|
|
5
|
-
port: number;
|
|
5
|
+
port: number | undefined;
|
|
6
6
|
} & {
|
|
7
|
-
dev: boolean;
|
|
7
|
+
dev: boolean | undefined;
|
|
8
8
|
} & {
|
|
9
9
|
graph: string | undefined;
|
|
10
10
|
} & {
|
|
11
|
-
"allow-specifying-graph-id": boolean;
|
|
11
|
+
"allow-specifying-graph-id": boolean | undefined;
|
|
12
12
|
} & {
|
|
13
13
|
"openai-api-key": string | undefined;
|
|
14
14
|
} & {
|
|
@@ -16,19 +16,19 @@ export declare function makeCommand<T>(y: yargs.Argv<T>): yargs.Argv<T & {
|
|
|
16
16
|
} & {
|
|
17
17
|
"openai-organization": string | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
"expose-cost": boolean;
|
|
19
|
+
"expose-cost": boolean | undefined;
|
|
20
20
|
} & {
|
|
21
|
-
"expose-usage": boolean;
|
|
21
|
+
"expose-usage": boolean | undefined;
|
|
22
22
|
} & {
|
|
23
23
|
stream: string | undefined;
|
|
24
24
|
} & {
|
|
25
25
|
"stream-node": string | undefined;
|
|
26
26
|
} & {
|
|
27
|
-
"log-requests": boolean;
|
|
27
|
+
"log-requests": boolean | undefined;
|
|
28
28
|
} & {
|
|
29
|
-
"log-activity": boolean;
|
|
29
|
+
"log-activity": boolean | undefined;
|
|
30
30
|
} & {
|
|
31
|
-
"log-trace": boolean;
|
|
31
|
+
"log-trace": boolean | undefined;
|
|
32
32
|
} & {
|
|
33
33
|
"projects-root-dir": string | undefined;
|
|
34
34
|
} & {
|