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