@promptbook/cli 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/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +7 -4
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatPlannedMessages.tsx +23 -8
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +14 -3
- package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +2 -20
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +2 -1
- package/apps/agents-server/src/app/agents/[agentName]/projectReferenceActions.ts +61 -0
- package/apps/agents-server/src/components/AgentProjects/resolveLatestCompletedAgentMessageKey.ts +32 -0
- package/apps/agents-server/src/components/AgentProjects/useAgentProjectMarkdownReferences.ts +124 -2
- package/apps/agents-server/src/languages/ServerTranslationKeys.ts +3 -0
- package/apps/agents-server/src/languages/translations/czech.yaml +3 -0
- package/apps/agents-server/src/languages/translations/english.yaml +3 -0
- package/apps/agents-server/src/tools/agentGoalChatTimeoutToolFunctions.ts +24 -2
- package/apps/agents-server/src/tools/agentGoalChatTimeoutTools.ts +5 -4
- package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatPlannedMessageActions.ts +38 -9
- package/apps/agents-server/src/utils/agentGoalChat/createAgentGoalChatNoteContent.ts +15 -6
- package/apps/agents-server/src/utils/agentProjects/listAgentProjectNames.ts +35 -0
- package/apps/agents-server/src/utils/agentProjects/listAgentProjects.ts +6 -23
- package/apps/agents-server/src/utils/agentProjects/resolveAgentChatProjectReferences.ts +25 -0
- package/apps/agents-server/src/utils/chatMessageChips/createAnsweredMessageChipToolCalls.ts +37 -0
- package/apps/agents-server/src/utils/chatMessageChips/createPlannedMessageChipToolCalls.ts +39 -0
- package/apps/agents-server/src/utils/chatMessageChips/createTouchedProjectChipToolCalls.ts +75 -0
- package/apps/agents-server/src/utils/localChatRunner/applyLocalAgentPlannedMessageCommands.ts +212 -0
- package/apps/agents-server/src/utils/localChatRunner/prepareLocalAgentPlannedMessagesSidecar.ts +66 -0
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +110 -22
- package/apps/agents-server/src/utils/userChat/persistUserChatJobTerminalState.ts +5 -0
- package/apps/agents-server/src/utils/userChat/userChatJobRunReport.ts +30 -0
- package/apps/agents-server/src/utils/userChatTimeout/createTimeoutWakeUpMessage.ts +9 -1
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/repeatFiredUserChatTimeout.ts +74 -0
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore.ts +1 -0
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +63 -54
- package/esm/index.es.js +639 -80
- 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/scripts/run-agent-messages/messages/loadAgentPlannedMessagesSidecar.d.ts +10 -0
- package/esm/scripts/run-agent-messages/messages/resolveTouchedAgentProjects.d.ts +15 -0
- 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 +1 -1
- package/src/book-3.0/AgentMessageRunReport.ts +76 -0
- package/src/book-3.0/AgentPlannedMessagesSidecar.ts +229 -0
- package/src/book-3.0/AgentTeamConversationWorkspace.ts +3 -5
- package/src/book-3.0/createAgentMessageSidecarBaseName.ts +20 -0
- package/src/book-components/Chat/Chat/Chat.module.css +6 -1
- package/src/book-components/Chat/Chat/renderToolCallDetails.tsx +1 -12
- package/src/book-components/Chat/utils/agentProjectToolCall.ts +74 -0
- package/src/book-components/Chat/utils/getToolCallChipletInfo.ts +28 -0
- package/src/book-components/Chat/utils/timeoutToolCallPresentation.ts +23 -3
- package/src/other/templates/getTemplatesPipelineCollection.ts +784 -738
- package/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.ts +105 -0
- package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +6 -54
- package/src/utils/agent-message-runtime/resolveAgentMessageTouchedProjectNames.ts +147 -0
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +639 -80
- 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/scripts/run-agent-messages/messages/loadAgentPlannedMessagesSidecar.d.ts +10 -0
- package/umd/scripts/run-agent-messages/messages/resolveTouchedAgentProjects.d.ts +15 -0
- 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/umd/apps/agents-server/src/utils/agentGoalChat/agentGoalChatConstants.d.ts +0 -12
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
markUserChatTimeoutCompleted,
|
|
31
31
|
markUserChatTimeoutFailed,
|
|
32
32
|
recoverExpiredRunningUserChatTimeouts,
|
|
33
|
+
repeatFiredUserChatTimeout,
|
|
33
34
|
} from './userChatTimeoutStore';
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -172,6 +173,7 @@ async function recordAgentGoalChatPlannedMessageNote(timeout: UserChatTimeoutRec
|
|
|
172
173
|
content: createAgentGoalChatPlannedMessageNoteContent({
|
|
173
174
|
timeoutId: timeout.timeoutId,
|
|
174
175
|
dueAt: timeout.dueAt,
|
|
176
|
+
intervalMs: timeout.recurrenceIntervalMs,
|
|
175
177
|
message: timeout.message,
|
|
176
178
|
}),
|
|
177
179
|
}).catch((error) => {
|
|
@@ -331,7 +333,7 @@ async function processClaimedUserChatTimeout(timeout: UserChatTimeoutRecord): Pr
|
|
|
331
333
|
return;
|
|
332
334
|
}
|
|
333
335
|
|
|
334
|
-
const timeoutClientMessageId = createTimeoutClientMessageId(latestTimeout
|
|
336
|
+
const timeoutClientMessageId = createTimeoutClientMessageId(latestTimeout);
|
|
335
337
|
let queuedJob = await getUserChatJobByClientMessageId({
|
|
336
338
|
userId: latestTimeout.userId,
|
|
337
339
|
agentPermanentId: latestTimeout.agentPermanentId,
|
|
@@ -349,6 +351,7 @@ async function processClaimedUserChatTimeout(timeout: UserChatTimeoutRecord): Pr
|
|
|
349
351
|
messageContent: createTimeoutWakeUpMessage({
|
|
350
352
|
timeoutId: latestTimeout.timeoutId,
|
|
351
353
|
durationMs: latestTimeout.durationMs,
|
|
354
|
+
intervalMs: latestTimeout.recurrenceIntervalMs,
|
|
352
355
|
message: latestTimeout.message,
|
|
353
356
|
}),
|
|
354
357
|
messageSender: isAgentGoalChatId(latestTimeout.chatId) ? 'AGENT' : 'USER',
|
|
@@ -391,42 +394,19 @@ async function processClaimedUserChatTimeout(timeout: UserChatTimeoutRecord): Pr
|
|
|
391
394
|
return;
|
|
392
395
|
}
|
|
393
396
|
|
|
394
|
-
const completedTimeout = await markUserChatTimeoutCompleted(latestTimeout.timeoutId);
|
|
395
|
-
|
|
396
|
-
if (!completedTimeout || completedTimeout.status !== 'COMPLETED') {
|
|
397
|
-
console.info('[user-chat-timeout]', 'skip_recurrence_non_completed', {
|
|
398
|
-
chatId: latestTimeout.chatId,
|
|
399
|
-
timeoutId: latestTimeout.timeoutId,
|
|
400
|
-
resultingStatus: completedTimeout?.status || null,
|
|
401
|
-
});
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
397
|
try {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
chatId: recurringTimeout.chatId,
|
|
411
|
-
previousTimeoutId: latestTimeout.timeoutId,
|
|
412
|
-
timeoutId: recurringTimeout.timeoutId,
|
|
413
|
-
dueAt: recurringTimeout.dueAt,
|
|
414
|
-
recurrenceIntervalMs: recurringTimeout.recurrenceIntervalMs,
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
} catch (recurrenceError) {
|
|
418
|
-
const recurrenceReason =
|
|
419
|
-
recurrenceError instanceof Error
|
|
420
|
-
? recurrenceError.message
|
|
421
|
-
: 'Failed to schedule recurring timeout.';
|
|
398
|
+
await finishFiredUserChatTimeout(latestTimeout);
|
|
399
|
+
} catch (repetitionError) {
|
|
400
|
+
const repetitionReason =
|
|
401
|
+
repetitionError instanceof Error ? repetitionError.message : 'Failed to repeat the planned message.';
|
|
422
402
|
await appendUserChatTimeoutWarningMessage(
|
|
423
403
|
latestTimeout,
|
|
424
|
-
`
|
|
404
|
+
`Repeating schedule failed: ${repetitionReason}`,
|
|
425
405
|
).catch(() => undefined);
|
|
426
|
-
console.error('[user-chat-timeout]', '
|
|
406
|
+
console.error('[user-chat-timeout]', 'repeat_failed', {
|
|
427
407
|
chatId: latestTimeout.chatId,
|
|
428
408
|
timeoutId: latestTimeout.timeoutId,
|
|
429
|
-
error: serializeError(
|
|
409
|
+
error: serializeError(repetitionError as Error),
|
|
430
410
|
});
|
|
431
411
|
}
|
|
432
412
|
|
|
@@ -553,33 +533,50 @@ function clearUserChatTimeoutLocalWakeup(timeoutId: string): void {
|
|
|
553
533
|
}
|
|
554
534
|
|
|
555
535
|
/**
|
|
556
|
-
*
|
|
536
|
+
* Closes one fired timeout, keeping a repeating planned message armed for its next interval.
|
|
537
|
+
*
|
|
538
|
+
* A repeating timeout is the durable counterpart of `setInterval`, so it is re-armed in place
|
|
539
|
+
* instead of being completed: it keeps one row, one identity, and one cancellation point. A
|
|
540
|
+
* timeout that does not repeat, or one that was cancelled while it was firing, becomes terminal.
|
|
541
|
+
*
|
|
542
|
+
* @param firedTimeout - Timeout whose wake-up turn was just queued.
|
|
557
543
|
*
|
|
558
544
|
* @private internal utility of userChatTimeout
|
|
559
545
|
*/
|
|
560
|
-
async function
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
546
|
+
async function finishFiredUserChatTimeout(firedTimeout: UserChatTimeoutRecord): Promise<void> {
|
|
547
|
+
if (firedTimeout.recurrenceIntervalMs) {
|
|
548
|
+
const repeatedTimeout = await repeatFiredUserChatTimeout(firedTimeout.timeoutId);
|
|
549
|
+
|
|
550
|
+
if (repeatedTimeout?.status === 'QUEUED') {
|
|
551
|
+
console.info('[user-chat-timeout]', 'repeated', {
|
|
552
|
+
chatId: repeatedTimeout.chatId,
|
|
553
|
+
timeoutId: repeatedTimeout.timeoutId,
|
|
554
|
+
dueAt: repeatedTimeout.dueAt,
|
|
555
|
+
recurrenceIntervalMs: repeatedTimeout.recurrenceIntervalMs,
|
|
556
|
+
runCount: repeatedTimeout.runCount,
|
|
557
|
+
});
|
|
558
|
+
scheduleUserChatTimeoutLocalWakeup(repeatedTimeout);
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
564
561
|
|
|
565
|
-
|
|
566
|
-
|
|
562
|
+
// Note: A planned message that could not be re-armed, for example because it was cancelled while
|
|
563
|
+
// it was firing, stops repeating and is closed like a timeout that never repeated
|
|
564
|
+
console.info('[user-chat-timeout]', 'skip_repeat', {
|
|
565
|
+
chatId: firedTimeout.chatId,
|
|
566
|
+
timeoutId: firedTimeout.timeoutId,
|
|
567
|
+
resultingStatus: repeatedTimeout?.status || null,
|
|
568
|
+
});
|
|
567
569
|
}
|
|
568
570
|
|
|
569
|
-
const
|
|
570
|
-
const nextTimeout = await createUserChatTimeout({
|
|
571
|
-
userId: completedTimeout.userId,
|
|
572
|
-
agentPermanentId: completedTimeout.agentPermanentId,
|
|
573
|
-
chatId: completedTimeout.chatId,
|
|
574
|
-
durationMs: Math.floor(recurrenceIntervalMs),
|
|
575
|
-
recurrenceIntervalMs: Math.floor(recurrenceIntervalMs),
|
|
576
|
-
dueAt: nextDueAtIso,
|
|
577
|
-
message: completedTimeout.message || undefined,
|
|
578
|
-
parameters: completedTimeout.parameters,
|
|
579
|
-
});
|
|
571
|
+
const completedTimeout = await markUserChatTimeoutCompleted(firedTimeout.timeoutId);
|
|
580
572
|
|
|
581
|
-
|
|
582
|
-
|
|
573
|
+
if (!completedTimeout || completedTimeout.status !== 'COMPLETED') {
|
|
574
|
+
console.info('[user-chat-timeout]', 'skip_completion_non_completed', {
|
|
575
|
+
chatId: firedTimeout.chatId,
|
|
576
|
+
timeoutId: firedTimeout.timeoutId,
|
|
577
|
+
resultingStatus: completedTimeout?.status || null,
|
|
578
|
+
});
|
|
579
|
+
}
|
|
583
580
|
}
|
|
584
581
|
|
|
585
582
|
/**
|
|
@@ -600,12 +597,24 @@ function shouldDisableBackgroundWorkerLoop(): boolean {
|
|
|
600
597
|
}
|
|
601
598
|
|
|
602
599
|
/**
|
|
603
|
-
* Builds the synthetic client message id used for timeout wake-
|
|
600
|
+
* Builds the synthetic client message id used for one timeout wake-up.
|
|
601
|
+
*
|
|
602
|
+
* A repeating timeout keeps its identity across firings, so the id also carries how many times it
|
|
603
|
+
* already fired: retrying the very same firing stays idempotent, while the next repetition still
|
|
604
|
+
* queues its own wake-up turn.
|
|
605
|
+
*
|
|
606
|
+
* @param timeout - Timeout that is firing.
|
|
607
|
+
* @returns Client message id of this wake-up.
|
|
604
608
|
*
|
|
605
609
|
* @private internal utility of userChatTimeout
|
|
606
610
|
*/
|
|
607
|
-
function createTimeoutClientMessageId(
|
|
608
|
-
|
|
611
|
+
function createTimeoutClientMessageId(timeout: Pick<UserChatTimeoutRecord, 'timeoutId' | 'runCount'>): string {
|
|
612
|
+
// Note: The first firing keeps the historical id, so wake-ups queued before repeating support stay deduplicated
|
|
613
|
+
if (timeout.runCount === 0) {
|
|
614
|
+
return `${USER_CHAT_TIMEOUT_CLIENT_MESSAGE_ID_PREFIX}${timeout.timeoutId}`;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return `${USER_CHAT_TIMEOUT_CLIENT_MESSAGE_ID_PREFIX}${timeout.timeoutId}:${timeout.runCount}`;
|
|
609
618
|
}
|
|
610
619
|
|
|
611
620
|
/**
|