@promptbook/node 0.114.0-12 → 0.114.0-13
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/esm/index.es.js +154 -50
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-messages/messages/buildAgentGoalChatPromptSection.d.ts +22 -4
- package/esm/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +3 -3
- package/esm/src/book-3.0/AgentMessageRunReport.d.ts +28 -0
- package/esm/src/book-3.0/AgentPlannedMessagesSidecar.d.ts +94 -0
- package/esm/src/book-3.0/AgentPlannedMessagesSidecar.test.d.ts +1 -0
- package/esm/src/book-3.0/createAgentMessageSidecarBaseName.d.ts +13 -0
- package/esm/src/book-components/Chat/utils/agentProjectToolCall.d.ts +46 -0
- package/esm/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +24 -0
- package/esm/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.d.ts +59 -0
- package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedProjectNames.d.ts +19 -0
- package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedProjectNames.test.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +154 -50
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-messages/messages/buildAgentGoalChatPromptSection.d.ts +22 -4
- package/umd/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +3 -3
- package/umd/src/book-3.0/AgentMessageRunReport.d.ts +28 -0
- package/umd/src/book-3.0/AgentPlannedMessagesSidecar.d.ts +94 -0
- package/umd/src/book-3.0/AgentPlannedMessagesSidecar.test.d.ts +1 -0
- package/umd/src/book-3.0/createAgentMessageSidecarBaseName.d.ts +13 -0
- package/umd/src/book-components/Chat/utils/agentProjectToolCall.d.ts +46 -0
- package/umd/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +24 -0
- package/umd/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.d.ts +59 -0
- package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedProjectNames.d.ts +19 -0
- package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedProjectNames.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
- package/esm/apps/agents-server/src/utils/agentGoalChat/agentGoalChatConstants.d.ts +0 -12
- package/esm/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeConstants.d.ts +0 -40
- package/umd/apps/agents-server/src/utils/agentGoalChat/agentGoalChatConstants.d.ts +0 -12
- package/umd/apps/agents-server/src/utils/agentProjects/agentProjectRuntimeConstants.d.ts +0 -40
package/umd/index.umd.js
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
* @generated
|
|
48
48
|
* @see https://github.com/webgptorg/promptbook
|
|
49
49
|
*/
|
|
50
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
50
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-13';
|
|
51
51
|
/**
|
|
52
52
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
53
53
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -5238,7 +5238,7 @@
|
|
|
5238
5238
|
- You have 100% control over every project folder: create, read, modify, and delete files there, run scripts and commands inside it, and keep any persistent data you need between conversations.
|
|
5239
5239
|
- When the user asks you to build something (for example a website) or to do longer-term work, create a new project folder \`${AGENT_PROJECTS_DIRECTORY_PATH}/<project-name>/\` (use a short kebab-case name) and do the work inside it. Modify an existing project when the user refers to work you already did.
|
|
5240
5240
|
- A project can be a git repository — you can run \`git init\` inside a project folder and commit your work there.
|
|
5241
|
-
- Do not touch anything outside the \`${AGENT_PROJECTS_DIRECTORY_PATH}/\` directory
|
|
5241
|
+
- Do not touch anything outside the \`${AGENT_PROJECTS_DIRECTORY_PATH}/\` directory beyond the file changes allowed at the top of this prompt.
|
|
5242
5242
|
|
|
5243
5243
|
${block(buildProjectReferenceInstructions(projectsUrlPath))}
|
|
5244
5244
|
${block(buildProjectRuntimeInstructions(options.projectRuntimeApi))}
|
|
@@ -5294,63 +5294,148 @@
|
|
|
5294
5294
|
}
|
|
5295
5295
|
|
|
5296
5296
|
/**
|
|
5297
|
-
*
|
|
5297
|
+
* Milliseconds in one second.
|
|
5298
|
+
*
|
|
5299
|
+
* @private internal timeout-chat constant
|
|
5298
5300
|
*/
|
|
5301
|
+
const SECOND_IN_MILLISECONDS = 1000;
|
|
5299
5302
|
/**
|
|
5300
|
-
*
|
|
5303
|
+
* Seconds in one minute.
|
|
5304
|
+
*
|
|
5305
|
+
* @private internal timeout-chat constant
|
|
5301
5306
|
*/
|
|
5302
|
-
const
|
|
5303
|
-
|
|
5307
|
+
const MINUTE_IN_SECONDS = 60;
|
|
5308
|
+
/**
|
|
5309
|
+
* Seconds in one hour.
|
|
5310
|
+
*
|
|
5311
|
+
* @private internal timeout-chat constant
|
|
5312
|
+
*/
|
|
5313
|
+
const HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS;
|
|
5314
|
+
/**
|
|
5315
|
+
* Seconds in one day.
|
|
5316
|
+
*
|
|
5317
|
+
* @private internal timeout-chat constant
|
|
5318
|
+
*/
|
|
5319
|
+
const HOURS_IN_DAY = 24;
|
|
5304
5320
|
/**
|
|
5305
|
-
*
|
|
5321
|
+
* Seconds in one day.
|
|
5322
|
+
*
|
|
5323
|
+
* @private internal timeout-chat constant
|
|
5306
5324
|
*/
|
|
5325
|
+
const DAY_IN_SECONDS = HOURS_IN_DAY * HOUR_IN_SECONDS;
|
|
5307
5326
|
/**
|
|
5308
|
-
*
|
|
5327
|
+
* Converts timeout duration into natural language sentence fragments.
|
|
5328
|
+
*
|
|
5329
|
+
* Shared by every timeout surface: the chat chips, the goal-chat planned messages of the Agents
|
|
5330
|
+
* Server, and the planned-message prompt section of the agent-folder runner.
|
|
5331
|
+
*
|
|
5332
|
+
* @param milliseconds - Duration or repeat interval in milliseconds.
|
|
5333
|
+
* @returns Label such as `5 minutes` or `1 hour 30 minutes`.
|
|
5334
|
+
*
|
|
5335
|
+
* @private internal utility of `<Chat/>` and the Agents Server planned messages
|
|
5309
5336
|
*/
|
|
5310
|
-
|
|
5337
|
+
function formatTimeoutDurationHuman(milliseconds) {
|
|
5338
|
+
const normalizedMilliseconds = Math.max(0, Math.floor(milliseconds));
|
|
5339
|
+
const totalSeconds = Math.max(1, Math.floor(normalizedMilliseconds / SECOND_IN_MILLISECONDS));
|
|
5340
|
+
if (totalSeconds < MINUTE_IN_SECONDS) {
|
|
5341
|
+
return formatTimeoutUnit(totalSeconds, 'second');
|
|
5342
|
+
}
|
|
5343
|
+
if (totalSeconds < HOUR_IN_SECONDS) {
|
|
5344
|
+
const roundedMinutes = Math.max(1, Math.round(totalSeconds / MINUTE_IN_SECONDS));
|
|
5345
|
+
return formatTimeoutUnit(roundedMinutes, 'minute');
|
|
5346
|
+
}
|
|
5347
|
+
if (totalSeconds < DAY_IN_SECONDS) {
|
|
5348
|
+
const hours = Math.floor(totalSeconds / HOUR_IN_SECONDS);
|
|
5349
|
+
const minutes = Math.floor((totalSeconds % HOUR_IN_SECONDS) / MINUTE_IN_SECONDS);
|
|
5350
|
+
if (minutes === 0) {
|
|
5351
|
+
return formatTimeoutUnit(hours, 'hour');
|
|
5352
|
+
}
|
|
5353
|
+
return `${formatTimeoutUnit(hours, 'hour')} ${formatTimeoutUnit(minutes, 'minute')}`;
|
|
5354
|
+
}
|
|
5355
|
+
const days = Math.floor(totalSeconds / DAY_IN_SECONDS);
|
|
5356
|
+
const hours = Math.floor((totalSeconds % DAY_IN_SECONDS) / HOUR_IN_SECONDS);
|
|
5357
|
+
if (hours === 0) {
|
|
5358
|
+
return formatTimeoutUnit(days, 'day');
|
|
5359
|
+
}
|
|
5360
|
+
return `${formatTimeoutUnit(days, 'day')} ${formatTimeoutUnit(hours, 'hour')}`;
|
|
5361
|
+
}
|
|
5362
|
+
/**
|
|
5363
|
+
* Formats one pluralized timeout unit.
|
|
5364
|
+
*
|
|
5365
|
+
* @private internal timeout-chat helper
|
|
5366
|
+
*/
|
|
5367
|
+
function formatTimeoutUnit(value, unit) {
|
|
5368
|
+
return `${value} ${unit}${value === 1 ? '' : 's'}`;
|
|
5369
|
+
}
|
|
5370
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5311
5371
|
|
|
5312
5372
|
/**
|
|
5313
5373
|
* Builds the planned-message instructions available to an Agents Server-managed coding agent.
|
|
5314
5374
|
*
|
|
5315
|
-
* Planned messages always target the agent's singleton goal chat, regardless of the chat in which
|
|
5316
|
-
*
|
|
5375
|
+
* Planned messages always target the agent's singleton goal chat, regardless of the chat in which the
|
|
5376
|
+
* wake-up is planned, and they repeat like `setInterval` until they are cancelled. The sidecar file is
|
|
5377
|
+
* the only channel that changes them, so an answer that merely claims a follow-up was planned changes
|
|
5378
|
+
* nothing — and an answer that changes nothing keeps the current plan running.
|
|
5379
|
+
*
|
|
5380
|
+
* @param sidecar - Sidecar prepared by the Agents Server for the answered message.
|
|
5381
|
+
* @returns Prompt section, or an empty string outside Agents Server-managed runs.
|
|
5317
5382
|
*/
|
|
5318
|
-
function buildAgentGoalChatPromptSection(
|
|
5319
|
-
if (!
|
|
5383
|
+
function buildAgentGoalChatPromptSection(sidecar) {
|
|
5384
|
+
if (!sidecar) {
|
|
5320
5385
|
return '';
|
|
5321
5386
|
}
|
|
5322
|
-
return _spaceTrim.spaceTrim(`
|
|
5323
|
-
|
|
5387
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
5388
|
+
## Planned goal-chat messages
|
|
5324
5389
|
|
|
5325
|
-
|
|
5390
|
+
You can plan a message that repeatedly wakes you in your singleton goal chat. A planned message works like \`setInterval\`, not like \`setTimeout\`: once planned, it keeps waking you at its interval until you cancel it. This works during every Agents Server-managed chat invocation, not only while answering inside the goal chat.
|
|
5326
5391
|
|
|
5327
|
-
|
|
5328
|
-
- Use \`set_timeout\` when useful work should resume later. The delay is a positive number of milliseconds and the message should say exactly what your future invocation needs to do.
|
|
5329
|
-
- Use \`cancel_timeout\` with the returned \`timeoutId\` when a planned message is no longer useful.
|
|
5330
|
-
- A fired message appears in the goal chat and invokes you there. If more future work remains, plan the next useful message during that invocation.
|
|
5392
|
+
${block(buildCurrentPlannedMessagesLines(sidecar.currentPlannedMessages))}
|
|
5331
5393
|
|
|
5332
|
-
|
|
5394
|
+
Editing \`${sidecar.relativeSidecarPath}\` is the **only** way to change what wakes you. Writing in your answer that you scheduled something does not schedule anything.
|
|
5333
5395
|
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5396
|
+
- **Keeping your planned messages as they are is the default.** When the list above already matches your goal, leave \`commands\` empty — every listed message keeps repeating on its own, and re-planning it would only duplicate it.
|
|
5397
|
+
- When your goal needs a repeating wake-up that is not listed above, append \`{"action":"set","milliseconds":<repeat interval>,"message":"<what each future invocation must do>"}\` to the \`commands\` array of that file.
|
|
5398
|
+
- When a listed message no longer matches your goal (for example your goal now says every 10 minutes while the message repeats every 5 minutes), append \`{"action":"cancel","timeoutId":"<timeout id>"}\` and one \`set\` command with the interval your goal really requires.
|
|
5399
|
+
- When your goal no longer needs a listed message at all, cancel it without planning a replacement.
|
|
5400
|
+
- Never edit \`version\`, \`agentPermanentId\`, or \`currentPlannedMessages\`.
|
|
5401
|
+
- The Agents Server applies every command once your answer is finished, and each repetition appears in the goal chat and invokes you there.
|
|
5402
|
+
- Only mention a planned follow-up in your answer when it is really planned: either you appended the matching \`set\` command, or you kept one of the messages listed above.
|
|
5403
|
+
`);
|
|
5404
|
+
}
|
|
5405
|
+
/**
|
|
5406
|
+
* Renders the already planned messages so the agent can compare them with its goal.
|
|
5407
|
+
*
|
|
5408
|
+
* @param currentPlannedMessages - Planned messages prepared by the Agents Server.
|
|
5409
|
+
* @returns Markdown list, or a sentence stating that nothing is planned yet.
|
|
5410
|
+
*
|
|
5411
|
+
* @private function of `buildAgentGoalChatPromptSection`
|
|
5412
|
+
*/
|
|
5413
|
+
function buildCurrentPlannedMessagesLines(currentPlannedMessages) {
|
|
5414
|
+
if (currentPlannedMessages.length === 0) {
|
|
5415
|
+
return 'You currently have no planned messages waiting.';
|
|
5416
|
+
}
|
|
5417
|
+
const plannedMessageLines = currentPlannedMessages.map(createCurrentPlannedMessageLine);
|
|
5418
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
5419
|
+
These planned messages are already waiting for you, so keep them unless they stopped matching your goal:
|
|
5346
5420
|
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5421
|
+
${block(plannedMessageLines.join('\n'))}
|
|
5422
|
+
`);
|
|
5423
|
+
}
|
|
5424
|
+
/**
|
|
5425
|
+
* Renders one already planned message with the schedule the agent has to compare with its goal.
|
|
5426
|
+
*
|
|
5427
|
+
* @param plannedMessage - One planned message prepared by the Agents Server.
|
|
5428
|
+
* @returns Markdown list item.
|
|
5429
|
+
*
|
|
5430
|
+
* @private function of `buildAgentGoalChatPromptSection`
|
|
5431
|
+
*/
|
|
5432
|
+
function createCurrentPlannedMessageLine(plannedMessage) {
|
|
5433
|
+
var _a;
|
|
5434
|
+
const message = ((_a = plannedMessage.message) === null || _a === void 0 ? void 0 : _a.trim()) || 'Continue working towards the current goal.';
|
|
5435
|
+
const schedule = plannedMessage.intervalMs
|
|
5436
|
+
? `repeats every ${formatTimeoutDurationHuman(plannedMessage.intervalMs)}`
|
|
5437
|
+
: `wakes you once at ${plannedMessage.dueAt}`;
|
|
5438
|
+
return `- \`${plannedMessage.timeoutId}\` ${schedule}: ${message}`;
|
|
5354
5439
|
}
|
|
5355
5440
|
|
|
5356
5441
|
// Note: [💞] This file defines the shared TEAM workspace convention rather than one standalone entity.
|
|
@@ -5381,8 +5466,8 @@
|
|
|
5381
5466
|
return '';
|
|
5382
5467
|
}
|
|
5383
5468
|
const teammateSections = workspace.manifest.teammates.map((teammate) => {
|
|
5384
|
-
const sourcePath = toPromptPath(path.join(workspace.relativeWorkspacePath, AGENT_TEAMMATE_SOURCES_DIRECTORY_NAME, teammate.sourceFileName));
|
|
5385
|
-
const transcriptPath = toPromptPath(path.join(workspace.relativeWorkspacePath, `${teammate.permanentId}--01.book`));
|
|
5469
|
+
const sourcePath = toPromptPath$1(path.join(workspace.relativeWorkspacePath, AGENT_TEAMMATE_SOURCES_DIRECTORY_NAME, teammate.sourceFileName));
|
|
5470
|
+
const transcriptPath = toPromptPath$1(path.join(workspace.relativeWorkspacePath, `${teammate.permanentId}--01.book`));
|
|
5386
5471
|
const instructions = teammate.instructions.trim() || 'No additional TEAM instructions were provided.';
|
|
5387
5472
|
return _spaceTrim.spaceTrim(`
|
|
5388
5473
|
- ${teammate.agentName}
|
|
@@ -5400,7 +5485,7 @@
|
|
|
5400
5485
|
|
|
5401
5486
|
- The underlying coding harness is already executing this turn **exactly once**. Never start, queue, or invoke another coding harness, agent runner, or \`ptbk\` command to consult a teammate.
|
|
5402
5487
|
- The primary agent remains responsible for the final user-facing \`MESSAGE @Agent\` answer.
|
|
5403
|
-
- Teammate source files are read-only context. When a teammate consultation occurs, record the actual exchange in a new top-level \`.book\` file in \`${toPromptPath(workspace.relativeWorkspacePath)}\`.
|
|
5488
|
+
- Teammate source files are read-only context. When a teammate consultation occurs, record the actual exchange in a new top-level \`.book\` file in \`${toPromptPath$1(workspace.relativeWorkspacePath)}\`.
|
|
5404
5489
|
- Name each transcript \`<teammate permanent id>--<sequence>.book\`, for example \`${workspace.manifest.teammates[0].permanentId}--01.book\`.
|
|
5405
5490
|
- Every transcript must contain alternating \`MESSAGE @${workspace.manifest.primaryAgent.agentName}\` and \`MESSAGE @<teammate name>\` blocks. Do not create a transcript for a teammate that was not consulted.
|
|
5406
5491
|
`);
|
|
@@ -5408,7 +5493,7 @@
|
|
|
5408
5493
|
/**
|
|
5409
5494
|
* Converts a filesystem-relative path into the portable path notation used in prompts.
|
|
5410
5495
|
*/
|
|
5411
|
-
function toPromptPath(path) {
|
|
5496
|
+
function toPromptPath$1(path) {
|
|
5412
5497
|
return path.replace(/\\/gu, '/');
|
|
5413
5498
|
}
|
|
5414
5499
|
|
|
@@ -5421,7 +5506,7 @@
|
|
|
5421
5506
|
|
|
5422
5507
|
- Read \`${messageRelativePath}\` and answer the most recent \`MESSAGE\` block. In a normal chat it is from \`@User\`; in your internal goal chat it can be from \`@Agent\`.
|
|
5423
5508
|
- Only change the queued message file by appending one new \`MESSAGE @Agent\` block
|
|
5424
|
-
${block(buildAllowedFileChangesPromptLine(options
|
|
5509
|
+
${block(buildAllowedFileChangesPromptLine(options))}
|
|
5425
5510
|
|
|
5426
5511
|
## Rules for the answering
|
|
5427
5512
|
|
|
@@ -5457,7 +5542,7 @@
|
|
|
5457
5542
|
|
|
5458
5543
|
- You can use \`message\` for message that will be sent immediately after clicking the button, or \`messageDraft\` for message that will be prefilled in the input field for editing before sending.
|
|
5459
5544
|
|
|
5460
|
-
${block(buildAgentGoalChatPromptSection(options.
|
|
5545
|
+
${block(buildAgentGoalChatPromptSection(options.plannedMessagesSidecar))}
|
|
5461
5546
|
|
|
5462
5547
|
${block(buildAgentProjectsPromptSection(options))}
|
|
5463
5548
|
|
|
@@ -5471,11 +5556,30 @@
|
|
|
5471
5556
|
/**
|
|
5472
5557
|
* Explains the exact files that one coding harness may change for a user turn.
|
|
5473
5558
|
*/
|
|
5474
|
-
function buildAllowedFileChangesPromptLine(
|
|
5475
|
-
|
|
5476
|
-
|
|
5559
|
+
function buildAllowedFileChangesPromptLine(options) {
|
|
5560
|
+
const allowedFileChanges = [`files inside your own \`${AGENT_PROJECTS_DIRECTORY_PATH}/\` directory`];
|
|
5561
|
+
if (options.teamWorkspace) {
|
|
5562
|
+
allowedFileChanges.push(`new consultation transcripts inside \`${toPromptPath(options.teamWorkspace.relativeWorkspacePath)}\``);
|
|
5477
5563
|
}
|
|
5478
|
-
|
|
5564
|
+
if (options.plannedMessagesSidecar) {
|
|
5565
|
+
allowedFileChanges.push(`the \`commands\` array of \`${toPromptPath(options.plannedMessagesSidecar.relativeSidecarPath)}\``);
|
|
5566
|
+
}
|
|
5567
|
+
return `- Do not modify any other file in the repository, except ${formatAllowedFileChanges(allowedFileChanges)}`;
|
|
5568
|
+
}
|
|
5569
|
+
/**
|
|
5570
|
+
* Joins the allowed file-change phrases into one readable enumeration.
|
|
5571
|
+
*/
|
|
5572
|
+
function formatAllowedFileChanges(allowedFileChanges) {
|
|
5573
|
+
if (allowedFileChanges.length === 1) {
|
|
5574
|
+
return allowedFileChanges[0];
|
|
5575
|
+
}
|
|
5576
|
+
return `${allowedFileChanges.slice(0, -1).join(', ')} and ${allowedFileChanges[allowedFileChanges.length - 1]}`;
|
|
5577
|
+
}
|
|
5578
|
+
/**
|
|
5579
|
+
* Converts a filesystem-relative path into the portable path notation used in prompts.
|
|
5580
|
+
*/
|
|
5581
|
+
function toPromptPath(path) {
|
|
5582
|
+
return path.replace(/\\/gu, '/');
|
|
5479
5583
|
}
|
|
5480
5584
|
|
|
5481
5585
|
/**
|