@promptbook/cli 0.112.0-109 → 0.112.0-110
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/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +86 -4
- package/apps/agents-server/src/database/loadAgentsServerEnvFile.ts +29 -0
- package/apps/agents-server/src/database/migrate.ts +2 -25
- package/apps/agents-server/src/database/seedDefaultAgents.ts +2 -26
- package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +56 -0
- package/apps/agents-server/src/utils/importAgent.ts +57 -1
- package/apps/agents-server/src/utils/importAgentWithFallback.ts +10 -0
- package/apps/agents-server/src/utils/userChat/getUserChatRevision.ts +145 -0
- package/apps/agents-server/src/utils/userChat.ts +1 -0
- package/esm/index.es.js +226 -105
- package/esm/index.es.js.map +1 -1
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +17 -1
- package/esm/src/cli/cli-commands/agents-server/run.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +7 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/book-components/Chat/Chat/Chat.module.css +5 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +48 -14
- package/src/cli/cli-commands/agents-server/run.ts +103 -31
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +111 -35
- package/src/cli/cli-commands/agents-server.ts +7 -1
- package/src/other/templates/getTemplatesPipelineCollection.ts +1081 -516
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +226 -105
- package/umd/index.umd.js.map +1 -1
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +17 -1
- package/umd/src/cli/cli-commands/agents-server/run.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +7 -0
- package/umd/src/version.d.ts +1 -1
package/src/version.ts
CHANGED
|
@@ -16,11 +16,11 @@ export const BOOK_LANGUAGE_VERSION: string_semantic_version = '2.0.0';
|
|
|
16
16
|
* @generated
|
|
17
17
|
* @see https://github.com/webgptorg/promptbook
|
|
18
18
|
*/
|
|
19
|
-
export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-
|
|
19
|
+
export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-110';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Represents the version string of the Promptbook engine.
|
|
23
|
-
* It follows semantic versioning (e.g., `0.112.0-
|
|
23
|
+
* It follows semantic versioning (e.g., `0.112.0-109`).
|
|
24
24
|
*
|
|
25
25
|
* @generated
|
|
26
26
|
*/
|
package/src/versions.txt
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
* @generated
|
|
61
61
|
* @see https://github.com/webgptorg/promptbook
|
|
62
62
|
*/
|
|
63
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
63
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-110';
|
|
64
64
|
/**
|
|
65
65
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
66
66
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3204,34 +3204,54 @@
|
|
|
3204
3204
|
* @private internal utility of `ptbk agents-server`
|
|
3205
3205
|
*/
|
|
3206
3206
|
async function ensureAgentsServerBuild(options = {}) {
|
|
3207
|
-
var _a, _b, _c
|
|
3207
|
+
var _a, _b, _c;
|
|
3208
3208
|
const environment = (_a = options.environment) !== null && _a !== void 0 ? _a : process.env;
|
|
3209
|
-
const
|
|
3210
|
-
|
|
3211
|
-
const appPath = await resolveAgentsServerBuildAppPath({
|
|
3212
|
-
sourceAppPath: (_b = options.appPath) !== null && _b !== void 0 ? _b : (await resolveAgentsServerAppPath()),
|
|
3213
|
-
nodeModulesPath,
|
|
3209
|
+
const preparedRuntime = await prepareAgentsServerRuntime({
|
|
3210
|
+
appPath: options.appPath,
|
|
3214
3211
|
});
|
|
3215
|
-
const buildEnvironment = createAgentsServerRuntimeEnvironment(environment, nodeModulesPath, {
|
|
3216
|
-
isNextValidationIgnored:
|
|
3212
|
+
const buildEnvironment = createAgentsServerRuntimeEnvironment(environment, preparedRuntime.nodeModulesPath, {
|
|
3213
|
+
isNextValidationIgnored: preparedRuntime.isAppPathMaterialized,
|
|
3217
3214
|
});
|
|
3218
3215
|
if (!options.isBuildForced &&
|
|
3219
3216
|
(await isAgentsServerBuildCacheCurrent({
|
|
3220
|
-
appPath,
|
|
3217
|
+
appPath: preparedRuntime.appPath,
|
|
3221
3218
|
environment: buildEnvironment,
|
|
3222
3219
|
}))) {
|
|
3223
|
-
(
|
|
3224
|
-
return
|
|
3220
|
+
(_b = options.onBuildEvent) === null || _b === void 0 ? void 0 : _b.call(options, 'Using the cached Agents Server Next app build.');
|
|
3221
|
+
return preparedRuntime;
|
|
3225
3222
|
}
|
|
3226
|
-
(
|
|
3223
|
+
(_c = options.onBuildEvent) === null || _c === void 0 ? void 0 : _c.call(options, 'Building the Agents Server Next app.');
|
|
3227
3224
|
await runNextBuild({
|
|
3228
|
-
appPath,
|
|
3225
|
+
appPath: preparedRuntime.appPath,
|
|
3229
3226
|
environment: buildEnvironment,
|
|
3230
|
-
nextCliPath,
|
|
3227
|
+
nextCliPath: preparedRuntime.nextCliPath,
|
|
3231
3228
|
onBuildOutput: options.onBuildOutput,
|
|
3232
3229
|
});
|
|
3233
|
-
await writeAgentsServerBuildCache({
|
|
3234
|
-
|
|
3230
|
+
await writeAgentsServerBuildCache({
|
|
3231
|
+
appPath: preparedRuntime.appPath,
|
|
3232
|
+
environment: buildEnvironment,
|
|
3233
|
+
});
|
|
3234
|
+
return preparedRuntime;
|
|
3235
|
+
}
|
|
3236
|
+
/**
|
|
3237
|
+
* Resolves the runtime app and dependency paths shared by Agents Server start and dev commands.
|
|
3238
|
+
*
|
|
3239
|
+
* @private internal utility of `ptbk agents-server`
|
|
3240
|
+
*/
|
|
3241
|
+
async function prepareAgentsServerRuntime(options = {}) {
|
|
3242
|
+
var _a;
|
|
3243
|
+
const nextCliPath = resolveNextCliPath();
|
|
3244
|
+
const nodeModulesPath = resolveNodeModulesPath(nextCliPath);
|
|
3245
|
+
const appPath = await resolveAgentsServerBuildAppPath({
|
|
3246
|
+
sourceAppPath: (_a = options.appPath) !== null && _a !== void 0 ? _a : (await resolveAgentsServerAppPath()),
|
|
3247
|
+
nodeModulesPath,
|
|
3248
|
+
});
|
|
3249
|
+
return {
|
|
3250
|
+
appPath,
|
|
3251
|
+
nextCliPath,
|
|
3252
|
+
nodeModulesPath,
|
|
3253
|
+
isAppPathMaterialized: isAgentsServerAppPathMaterialized(appPath),
|
|
3254
|
+
};
|
|
3235
3255
|
}
|
|
3236
3256
|
/**
|
|
3237
3257
|
* Returns true when the production build marker and source fingerprint still match.
|
|
@@ -34171,12 +34191,16 @@
|
|
|
34171
34191
|
* Default Codex reasoning effort preserved for backwards compatibility when no CLI override is provided.
|
|
34172
34192
|
*/
|
|
34173
34193
|
const DEFAULT_CODEX_THINKING_LEVEL = 'xhigh';
|
|
34194
|
+
/**
|
|
34195
|
+
* Base delimiter used for passing large prompts through stdin.
|
|
34196
|
+
*/
|
|
34197
|
+
const CODEX_PROMPT_DELIMITER = 'CODEX_PROMPT';
|
|
34174
34198
|
/**
|
|
34175
34199
|
* Builds the shell script that runs Codex with the prompt and coding context.
|
|
34176
34200
|
*/
|
|
34177
34201
|
function buildCodexScript(options) {
|
|
34178
34202
|
var _a;
|
|
34179
|
-
const delimiter =
|
|
34203
|
+
const delimiter = resolveShellHereDocumentDelimiter(CODEX_PROMPT_DELIMITER, options.prompt);
|
|
34180
34204
|
const projectPath = toPosixPath(options.projectPath);
|
|
34181
34205
|
const loginMethodConfig = options.allowCredits
|
|
34182
34206
|
? 'CODEX_LOGIN_METHOD_ARGUMENTS=()'
|
|
@@ -34187,36 +34211,54 @@
|
|
|
34187
34211
|
fi
|
|
34188
34212
|
`);
|
|
34189
34213
|
const thinkingLevel = (_a = options.thinkingLevel) !== null && _a !== void 0 ? _a : DEFAULT_CODEX_THINKING_LEVEL;
|
|
34190
|
-
const
|
|
34191
|
-
|
|
34192
|
-
|
|
34193
|
-
|
|
34194
|
-
set
|
|
34195
|
-
|
|
34196
|
-
|
|
34197
|
-
|
|
34198
|
-
|
|
34199
|
-
${
|
|
34200
|
-
|
|
34201
|
-
|
|
34202
|
-
|
|
34203
|
-
|
|
34204
|
-
|
|
34205
|
-
|
|
34206
|
-
${
|
|
34207
|
-
|
|
34208
|
-
|
|
34209
|
-
|
|
34210
|
-
|
|
34211
|
-
|
|
34212
|
-
|
|
34213
|
-
|
|
34214
|
-
|
|
34215
|
-
|
|
34216
|
-
|
|
34217
|
-
|
|
34218
|
-
|
|
34219
|
-
|
|
34214
|
+
const lines = [
|
|
34215
|
+
'if [ -f .env ]; then',
|
|
34216
|
+
'set -a',
|
|
34217
|
+
'source .env',
|
|
34218
|
+
'set +a',
|
|
34219
|
+
'fi',
|
|
34220
|
+
'',
|
|
34221
|
+
loginMethodConfig,
|
|
34222
|
+
'',
|
|
34223
|
+
'if [ "${PTBK_OPENAI_CODEX_USE_API_KEY:-0}" != "1" ] || [ -z "${OPENAI_API_KEY:-}" ]; then',
|
|
34224
|
+
'unset OPENAI_API_KEY',
|
|
34225
|
+
'unset OPENAI_BASE_URL',
|
|
34226
|
+
'fi',
|
|
34227
|
+
'',
|
|
34228
|
+
`${options.codexCommand} \\`,
|
|
34229
|
+
' "${CODEX_LOGIN_METHOD_ARGUMENTS[@]}" \\',
|
|
34230
|
+
` -c model_reasoning_effort="${thinkingLevel}" \\`,
|
|
34231
|
+
` --ask-for-approval ${options.askForApproval} \\`,
|
|
34232
|
+
` exec --model ${options.model} \\`,
|
|
34233
|
+
' --local-provider none \\',
|
|
34234
|
+
` --sandbox ${options.sandbox} \\`,
|
|
34235
|
+
` -C ${projectPath} \\`,
|
|
34236
|
+
' --skip-git-repo-check \\',
|
|
34237
|
+
` <<'${delimiter}'`,
|
|
34238
|
+
'',
|
|
34239
|
+
options.prompt,
|
|
34240
|
+
'',
|
|
34241
|
+
delimiter,
|
|
34242
|
+
];
|
|
34243
|
+
return lines.join('\n');
|
|
34244
|
+
}
|
|
34245
|
+
/**
|
|
34246
|
+
* Resolves a here-document delimiter that cannot be confused with a line inside the prompt.
|
|
34247
|
+
*/
|
|
34248
|
+
function resolveShellHereDocumentDelimiter(baseDelimiter, content) {
|
|
34249
|
+
let delimiter = baseDelimiter;
|
|
34250
|
+
let delimiterSuffix = 0;
|
|
34251
|
+
while (isShellHereDocumentDelimiterPresent(content, delimiter)) {
|
|
34252
|
+
delimiterSuffix += 1;
|
|
34253
|
+
delimiter = `${baseDelimiter}_${delimiterSuffix}`;
|
|
34254
|
+
}
|
|
34255
|
+
return delimiter;
|
|
34256
|
+
}
|
|
34257
|
+
/**
|
|
34258
|
+
* Checks whether a prompt already contains one exact here-document closing delimiter line.
|
|
34259
|
+
*/
|
|
34260
|
+
function isShellHereDocumentDelimiterPresent(content, delimiter) {
|
|
34261
|
+
return content.replace(/\r\n/gu, '\n').split('\n').some((line) => line === delimiter);
|
|
34220
34262
|
}
|
|
34221
34263
|
|
|
34222
34264
|
/**
|
|
@@ -37263,48 +37305,30 @@
|
|
|
37263
37305
|
};
|
|
37264
37306
|
process.once('exit', processExitHandler);
|
|
37265
37307
|
try {
|
|
37266
|
-
const
|
|
37267
|
-
|
|
37268
|
-
|
|
37269
|
-
|
|
37270
|
-
|
|
37271
|
-
|
|
37272
|
-
forwardChildOutput(`${event}\n`, {
|
|
37273
|
-
label: 'next-build',
|
|
37274
|
-
logStream: logStreams.next,
|
|
37275
|
-
state,
|
|
37276
|
-
});
|
|
37277
|
-
},
|
|
37278
|
-
onBuildOutput: (chunk) => {
|
|
37279
|
-
forwardChildOutput(chunk, {
|
|
37280
|
-
label: 'next-build',
|
|
37281
|
-
logStream: logStreams.next,
|
|
37282
|
-
state,
|
|
37283
|
-
});
|
|
37284
|
-
},
|
|
37308
|
+
const preparedLaunch = await prepareAgentsServerLaunch({
|
|
37309
|
+
childEnvironment,
|
|
37310
|
+
logStreams,
|
|
37311
|
+
options,
|
|
37312
|
+
runtimePaths,
|
|
37313
|
+
state,
|
|
37285
37314
|
});
|
|
37286
|
-
const runtimeChildEnvironment = createAgentsServerRuntimeEnvironment(childEnvironment, buildArtifacts.nodeModulesPath);
|
|
37287
|
-
const builtRuntimePaths = {
|
|
37288
|
-
...runtimePaths,
|
|
37289
|
-
appPath: buildArtifacts.appPath,
|
|
37290
|
-
};
|
|
37291
37315
|
nextServerProcess = startNextServer({
|
|
37292
|
-
nextCliPath:
|
|
37316
|
+
nextCliPath: preparedLaunch.runtimeArtifacts.nextCliPath,
|
|
37293
37317
|
options,
|
|
37294
|
-
runtimePaths:
|
|
37295
|
-
childEnvironment: runtimeChildEnvironment,
|
|
37318
|
+
runtimePaths: preparedLaunch.runtimePaths,
|
|
37319
|
+
childEnvironment: preparedLaunch.runtimeChildEnvironment,
|
|
37296
37320
|
logStreams,
|
|
37297
37321
|
state,
|
|
37298
37322
|
});
|
|
37299
37323
|
const localAgentRunnerLimits = await waitForLocalAgentRunnerLimits({
|
|
37300
37324
|
port: options.port,
|
|
37301
|
-
environment: runtimeChildEnvironment,
|
|
37325
|
+
environment: preparedLaunch.runtimeChildEnvironment,
|
|
37302
37326
|
logStreams,
|
|
37303
37327
|
state,
|
|
37304
37328
|
});
|
|
37305
37329
|
stopUserChatJobWorkerPump = startUserChatJobWorkerPump({
|
|
37306
37330
|
port: options.port,
|
|
37307
|
-
environment: runtimeChildEnvironment,
|
|
37331
|
+
environment: preparedLaunch.runtimeChildEnvironment,
|
|
37308
37332
|
logStreams,
|
|
37309
37333
|
state,
|
|
37310
37334
|
});
|
|
@@ -37328,6 +37352,52 @@
|
|
|
37328
37352
|
closeAgentsServerLogStreams(logStreams);
|
|
37329
37353
|
}
|
|
37330
37354
|
}
|
|
37355
|
+
/**
|
|
37356
|
+
* Prepares the shared Next runtime for either production start or hot-reloading development mode.
|
|
37357
|
+
*/
|
|
37358
|
+
async function prepareAgentsServerLaunch(options) {
|
|
37359
|
+
const runtimeArtifacts = options.options.nextRuntimeMode === 'start'
|
|
37360
|
+
? await ensureAgentsServerBuild({
|
|
37361
|
+
appPath: options.runtimePaths.appPath,
|
|
37362
|
+
environment: options.childEnvironment,
|
|
37363
|
+
isBuildForced: options.options.isBuildForced,
|
|
37364
|
+
onBuildEvent: (event) => {
|
|
37365
|
+
logRunnerEvent(options.logStreams.runner, event);
|
|
37366
|
+
forwardChildOutput(`${event}\n`, {
|
|
37367
|
+
label: 'next-build',
|
|
37368
|
+
logStream: options.logStreams.next,
|
|
37369
|
+
state: options.state,
|
|
37370
|
+
});
|
|
37371
|
+
},
|
|
37372
|
+
onBuildOutput: (chunk) => {
|
|
37373
|
+
forwardChildOutput(chunk, {
|
|
37374
|
+
label: 'next-build',
|
|
37375
|
+
logStream: options.logStreams.next,
|
|
37376
|
+
state: options.state,
|
|
37377
|
+
});
|
|
37378
|
+
},
|
|
37379
|
+
})
|
|
37380
|
+
: await prepareAgentsServerDevelopmentRuntime(options.runtimePaths.appPath, options.logStreams.runner);
|
|
37381
|
+
return {
|
|
37382
|
+
runtimeArtifacts,
|
|
37383
|
+
runtimeChildEnvironment: createAgentsServerRuntimeEnvironment(options.childEnvironment, runtimeArtifacts.nodeModulesPath, {
|
|
37384
|
+
isNextValidationIgnored: runtimeArtifacts.isAppPathMaterialized,
|
|
37385
|
+
}),
|
|
37386
|
+
runtimePaths: {
|
|
37387
|
+
...options.runtimePaths,
|
|
37388
|
+
appPath: runtimeArtifacts.appPath,
|
|
37389
|
+
},
|
|
37390
|
+
};
|
|
37391
|
+
}
|
|
37392
|
+
/**
|
|
37393
|
+
* Resolves the hot-reloading Next runtime without running the production build step.
|
|
37394
|
+
*/
|
|
37395
|
+
async function prepareAgentsServerDevelopmentRuntime(appPath, runnerLogStream) {
|
|
37396
|
+
logRunnerEvent(runnerLogStream, 'Preparing the Agents Server Next development runtime.');
|
|
37397
|
+
return prepareAgentsServerRuntime({
|
|
37398
|
+
appPath,
|
|
37399
|
+
});
|
|
37400
|
+
}
|
|
37331
37401
|
/**
|
|
37332
37402
|
* Loads launch-directory `.env` values without overriding explicit process environment.
|
|
37333
37403
|
*
|
|
@@ -37353,12 +37423,13 @@
|
|
|
37353
37423
|
};
|
|
37354
37424
|
}
|
|
37355
37425
|
/**
|
|
37356
|
-
* Starts the
|
|
37426
|
+
* Starts the configured Next server mode and wires its logs into the foreground dashboard.
|
|
37357
37427
|
*/
|
|
37358
37428
|
function startNextServer(options) {
|
|
37359
37429
|
var _a;
|
|
37360
|
-
|
|
37361
|
-
|
|
37430
|
+
const nextRuntimeModeLabel = describeAgentsServerNextRuntimeMode(options.options.nextRuntimeMode);
|
|
37431
|
+
logRunnerEvent(options.logStreams.runner, `Starting the Agents Server Next process in ${nextRuntimeModeLabel} mode.`);
|
|
37432
|
+
const nextArguments = [options.nextCliPath, options.options.nextRuntimeMode, '--port', String(options.options.port)];
|
|
37362
37433
|
const hostname = (_a = options.childEnvironment[PTBK_HOSTNAME_ENV]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
37363
37434
|
if (hostname) {
|
|
37364
37435
|
nextArguments.push('--hostname', hostname);
|
|
@@ -37386,6 +37457,12 @@
|
|
|
37386
37457
|
});
|
|
37387
37458
|
return commandProcess;
|
|
37388
37459
|
}
|
|
37460
|
+
/**
|
|
37461
|
+
* Converts one Next runtime mode into a readable label for logs.
|
|
37462
|
+
*/
|
|
37463
|
+
function describeAgentsServerNextRuntimeMode(nextRuntimeMode) {
|
|
37464
|
+
return nextRuntimeMode === 'dev' ? 'development' : 'production';
|
|
37465
|
+
}
|
|
37389
37466
|
/**
|
|
37390
37467
|
* Connects child stdout/stderr to the persisted Next log and visible terminal output.
|
|
37391
37468
|
*/
|
|
@@ -37710,7 +37787,7 @@
|
|
|
37710
37787
|
// Note: [🟡] Code for CLI runtime [startAgentsServer](src/cli/cli-commands/agents-server/startAgentsServer.ts) should never be published outside of `@promptbook/cli`
|
|
37711
37788
|
|
|
37712
37789
|
/**
|
|
37713
|
-
* Default port used by `ptbk agents-server start`.
|
|
37790
|
+
* Default port used by `ptbk agents-server start` and `ptbk agents-server dev`.
|
|
37714
37791
|
*
|
|
37715
37792
|
* @private internal constant of `ptbk agents-server`
|
|
37716
37793
|
*/
|
|
@@ -37721,29 +37798,61 @@
|
|
|
37721
37798
|
* @private internal function of `promptbookCli`
|
|
37722
37799
|
*/
|
|
37723
37800
|
function $initializeAgentsServerStartCommand(program) {
|
|
37724
|
-
|
|
37725
|
-
|
|
37726
|
-
Start the Agents Server web app and the local coding-agent message runners
|
|
37727
|
-
|
|
37728
|
-
|
|
37729
|
-
|
|
37730
|
-
|
|
37731
|
-
|
|
37732
|
-
|
|
37733
|
-
|
|
37801
|
+
initializeAgentsServerRuntimeCommand(program, {
|
|
37802
|
+
commandName: 'start',
|
|
37803
|
+
description: createAgentsServerRuntimeCommandDescription('Start the Agents Server web app and the local coding-agent message runners'),
|
|
37804
|
+
nextRuntimeMode: 'start',
|
|
37805
|
+
isForceBuildSupported: true,
|
|
37806
|
+
});
|
|
37807
|
+
}
|
|
37808
|
+
/**
|
|
37809
|
+
* Initializes `agents-server dev` command for Promptbook CLI utilities.
|
|
37810
|
+
*
|
|
37811
|
+
* @private internal function of `promptbookCli`
|
|
37812
|
+
*/
|
|
37813
|
+
function $initializeAgentsServerDevCommand(program) {
|
|
37814
|
+
initializeAgentsServerRuntimeCommand(program, {
|
|
37815
|
+
commandName: 'dev',
|
|
37816
|
+
description: createAgentsServerRuntimeCommandDescription('Start the Agents Server web app in development mode with hot reloading and the local coding-agent message runners'),
|
|
37817
|
+
nextRuntimeMode: 'dev',
|
|
37818
|
+
isForceBuildSupported: false,
|
|
37819
|
+
});
|
|
37820
|
+
}
|
|
37821
|
+
/**
|
|
37822
|
+
* Initializes `agents-server build` command for Promptbook CLI utilities.
|
|
37823
|
+
*
|
|
37824
|
+
* @private internal function of `promptbookCli`
|
|
37825
|
+
*/
|
|
37826
|
+
function $initializeAgentsServerBuildCommand(program) {
|
|
37827
|
+
const command = program.command('build');
|
|
37828
|
+
command.description('Build the Agents Server Next app for later local startup');
|
|
37829
|
+
command.action(handleActionErrors(async () => {
|
|
37830
|
+
console.info(colors__default["default"].gray('Building Promptbook Agents Server.'));
|
|
37831
|
+
loadAgentsServerProjectEnvironment(process.cwd());
|
|
37832
|
+
await ensureAgentsServerBuild({ isBuildForced: true });
|
|
37833
|
+
}));
|
|
37834
|
+
}
|
|
37835
|
+
/**
|
|
37836
|
+
* Registers one shared Agents Server runtime command backed by either `next start` or `next dev`.
|
|
37837
|
+
*/
|
|
37838
|
+
function initializeAgentsServerRuntimeCommand(program, definition) {
|
|
37839
|
+
const command = program.command(definition.commandName);
|
|
37840
|
+
command.description(definition.description);
|
|
37734
37841
|
addPromptRunnerSelectionOptions(command);
|
|
37735
37842
|
addPromptRunnerRuntimeOptions(command);
|
|
37736
37843
|
command.addOption(new commander.Option('--port <port>', 'Port to start the Agents Server on')
|
|
37737
37844
|
.env('PORT')
|
|
37738
37845
|
.default(DEFAULT_AGENTS_SERVER_PORT));
|
|
37739
|
-
|
|
37846
|
+
if (definition.isForceBuildSupported) {
|
|
37847
|
+
command.option('--force-build', 'Rebuild the Agents Server Next app before startup', false);
|
|
37848
|
+
}
|
|
37740
37849
|
command.action(handleActionErrors(async (cliOptions) => {
|
|
37741
37850
|
const options = cliOptions;
|
|
37742
37851
|
const port = parseAgentsServerPort(options.port);
|
|
37743
37852
|
const runnerOptions = normalizePromptRunnerSelectionCliOptions(options, {
|
|
37744
37853
|
isAgentRequired: true,
|
|
37745
37854
|
});
|
|
37746
|
-
console.info(colors__default["default"].gray(
|
|
37855
|
+
console.info(colors__default["default"].gray(createAgentsServerRuntimeStartupMessage(port, definition.nextRuntimeMode)));
|
|
37747
37856
|
await startAgentsServer({
|
|
37748
37857
|
port,
|
|
37749
37858
|
agentName: runnerOptions.agentName,
|
|
@@ -37751,25 +37860,35 @@
|
|
|
37751
37860
|
noUi: runnerOptions.noUi,
|
|
37752
37861
|
thinkingLevel: runnerOptions.thinkingLevel,
|
|
37753
37862
|
allowCredits: runnerOptions.allowCredits,
|
|
37754
|
-
|
|
37863
|
+
nextRuntimeMode: definition.nextRuntimeMode,
|
|
37864
|
+
isBuildForced: definition.isForceBuildSupported && options.forceBuild === true,
|
|
37755
37865
|
});
|
|
37756
37866
|
}, {
|
|
37757
37867
|
isExitingOnSuccess: false,
|
|
37758
37868
|
}));
|
|
37759
37869
|
}
|
|
37760
37870
|
/**
|
|
37761
|
-
*
|
|
37762
|
-
*
|
|
37763
|
-
* @private internal function of `promptbookCli`
|
|
37871
|
+
* Creates the shared help description for Agents Server runtime commands.
|
|
37764
37872
|
*/
|
|
37765
|
-
function
|
|
37766
|
-
|
|
37767
|
-
|
|
37768
|
-
|
|
37769
|
-
|
|
37770
|
-
|
|
37771
|
-
|
|
37772
|
-
|
|
37873
|
+
function createAgentsServerRuntimeCommandDescription(summary) {
|
|
37874
|
+
return _spaceTrim.spaceTrim(`
|
|
37875
|
+
${summary}
|
|
37876
|
+
|
|
37877
|
+
${PROMPT_RUNNER_DESCRIPTION}
|
|
37878
|
+
|
|
37879
|
+
The current working directory stores:
|
|
37880
|
+
- Agent runner folders in \`.promptbook/agents-server/agents\`
|
|
37881
|
+
- Foreground service logs in \`.logs\`
|
|
37882
|
+
`);
|
|
37883
|
+
}
|
|
37884
|
+
/**
|
|
37885
|
+
* Creates the startup log line for one Agents Server runtime mode.
|
|
37886
|
+
*/
|
|
37887
|
+
function createAgentsServerRuntimeStartupMessage(port, nextRuntimeMode) {
|
|
37888
|
+
if (nextRuntimeMode === 'dev') {
|
|
37889
|
+
return `Starting Promptbook Agents Server on port ${port} in development mode.`;
|
|
37890
|
+
}
|
|
37891
|
+
return `Starting Promptbook Agents Server on port ${port}.`;
|
|
37773
37892
|
}
|
|
37774
37893
|
/**
|
|
37775
37894
|
* Parses and validates the user-configured Agents Server port.
|
|
@@ -37800,10 +37919,12 @@
|
|
|
37800
37919
|
|
|
37801
37920
|
Subcommands:
|
|
37802
37921
|
- build: Build the web server for later local startup
|
|
37922
|
+
- dev: Start the web server in development mode with hot reloading
|
|
37803
37923
|
- init: Initialize local web server configuration
|
|
37804
37924
|
- start: Start the web server and local coding-agent message runners
|
|
37805
37925
|
`));
|
|
37806
37926
|
$initializeAgentsServerBuildCommand(agentsServerCommand);
|
|
37927
|
+
$initializeAgentsServerDevCommand(agentsServerCommand);
|
|
37807
37928
|
$initializeAgentsServerInitCommand(agentsServerCommand);
|
|
37808
37929
|
$initializeAgentsServerStartCommand(agentsServerCommand);
|
|
37809
37930
|
agentsServerCommand.action(() => {
|