@promptbook/wizard 0.112.0-19 → 0.112.0-21
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 +354 -11
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-components/Chat/Chat/ChatMessageMap.d.ts +0 -1
- package/esm/src/book-components/Chat/MockedChat/MockedChat.d.ts +20 -0
- package/esm/src/commitments/USE_TIMEOUT/TimeoutToolNames.d.ts +1 -0
- package/esm/src/commitments/USE_TIMEOUT/TimeoutToolRuntimeAdapter.d.ts +78 -5
- package/esm/src/commitments/USE_TIMEOUT/USE_TIMEOUT.d.ts +1 -1
- package/esm/src/commitments/USE_TIMEOUT/parseTimeoutToolArgs.d.ts +32 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +354 -11
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-components/Chat/Chat/ChatMessageMap.d.ts +0 -1
- package/umd/src/book-components/Chat/MockedChat/MockedChat.d.ts +20 -0
- package/umd/src/commitments/USE_TIMEOUT/TimeoutToolNames.d.ts +1 -0
- package/umd/src/commitments/USE_TIMEOUT/TimeoutToolRuntimeAdapter.d.ts +78 -5
- package/umd/src/commitments/USE_TIMEOUT/USE_TIMEOUT.d.ts +1 -1
- package/umd/src/commitments/USE_TIMEOUT/parseTimeoutToolArgs.d.ts +32 -1
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
38
38
|
* @generated
|
|
39
39
|
* @see https://github.com/webgptorg/promptbook
|
|
40
40
|
*/
|
|
41
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
41
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-21';
|
|
42
42
|
/**
|
|
43
43
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
44
44
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -27474,8 +27474,9 @@ function createTimeoutSystemMessage(extraInstructions) {
|
|
|
27474
27474
|
return spaceTrim$1((block) => `
|
|
27475
27475
|
Timeout scheduling:
|
|
27476
27476
|
- Use "set_timeout" to wake this same chat thread in the future.
|
|
27477
|
-
- Use "list_timeouts" to review
|
|
27478
|
-
- "cancel_timeout" accepts
|
|
27477
|
+
- Use "list_timeouts" to review timeout ids/details across all chats for the same user+agent scope.
|
|
27478
|
+
- "cancel_timeout" accepts either one timeout id or \`allActive: true\` to cancel all active timeouts in this same user+agent scope.
|
|
27479
|
+
- Use "update_timeout" to pause/resume, edit next run, edit recurrence, or update timeout payload details.
|
|
27479
27480
|
- When one timeout elapses, you will receive a new user-like message that explicitly says it is a timeout wake-up and includes the \`timeoutId\`.
|
|
27480
27481
|
- Do not claim a timer was set or cancelled unless the tool confirms it.
|
|
27481
27482
|
${block(extraInstructions)}
|
|
@@ -27553,9 +27554,18 @@ const parseTimeoutToolArgs = {
|
|
|
27553
27554
|
*/
|
|
27554
27555
|
cancel(args) {
|
|
27555
27556
|
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
27557
|
+
const allActive = args.allActive === true;
|
|
27558
|
+
if (timeoutId && allActive) {
|
|
27559
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27560
|
+
Timeout cancellation must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
27561
|
+
`));
|
|
27562
|
+
}
|
|
27563
|
+
if (allActive) {
|
|
27564
|
+
return { allActive: true };
|
|
27565
|
+
}
|
|
27556
27566
|
if (!timeoutId) {
|
|
27557
27567
|
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27558
|
-
Timeout \`timeoutId\` is required
|
|
27568
|
+
Timeout \`timeoutId\` is required unless you pass \`allActive: true\`.
|
|
27559
27569
|
`));
|
|
27560
27570
|
}
|
|
27561
27571
|
return { timeoutId };
|
|
@@ -27585,6 +27595,111 @@ const parseTimeoutToolArgs = {
|
|
|
27585
27595
|
limit: parsedLimit,
|
|
27586
27596
|
};
|
|
27587
27597
|
},
|
|
27598
|
+
/**
|
|
27599
|
+
* Parses `update_timeout` input.
|
|
27600
|
+
*/
|
|
27601
|
+
update(args) {
|
|
27602
|
+
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
27603
|
+
const allActive = args.allActive === true;
|
|
27604
|
+
if (timeoutId && allActive) {
|
|
27605
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27606
|
+
Timeout update must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
27607
|
+
`));
|
|
27608
|
+
}
|
|
27609
|
+
if (!timeoutId && !allActive) {
|
|
27610
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27611
|
+
Timeout update requires one \`timeoutId\` or \`allActive: true\`.
|
|
27612
|
+
`));
|
|
27613
|
+
}
|
|
27614
|
+
const patch = {};
|
|
27615
|
+
if (typeof args.dueAt === 'string' && args.dueAt.trim().length > 0) {
|
|
27616
|
+
const normalizedDueAt = args.dueAt.trim();
|
|
27617
|
+
const dueAtTimestamp = Date.parse(normalizedDueAt);
|
|
27618
|
+
if (!Number.isFinite(dueAtTimestamp)) {
|
|
27619
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27620
|
+
Timeout \`dueAt\` must be one valid ISO timestamp.
|
|
27621
|
+
`));
|
|
27622
|
+
}
|
|
27623
|
+
patch.dueAt = new Date(dueAtTimestamp).toISOString();
|
|
27624
|
+
}
|
|
27625
|
+
if (typeof args.extendByMs === 'number') {
|
|
27626
|
+
if (!Number.isFinite(args.extendByMs) || args.extendByMs <= 0) {
|
|
27627
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27628
|
+
Timeout \`extendByMs\` must be a positive number of milliseconds.
|
|
27629
|
+
`));
|
|
27630
|
+
}
|
|
27631
|
+
patch.extendByMs = Math.floor(args.extendByMs);
|
|
27632
|
+
}
|
|
27633
|
+
if (patch.dueAt !== undefined && patch.extendByMs !== undefined) {
|
|
27634
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27635
|
+
Timeout update cannot include both \`dueAt\` and \`extendByMs\`.
|
|
27636
|
+
`));
|
|
27637
|
+
}
|
|
27638
|
+
if (args.recurrenceIntervalMs === null) {
|
|
27639
|
+
patch.recurrenceIntervalMs = null;
|
|
27640
|
+
}
|
|
27641
|
+
else if (typeof args.recurrenceIntervalMs === 'number') {
|
|
27642
|
+
if (!Number.isFinite(args.recurrenceIntervalMs) || args.recurrenceIntervalMs <= 0) {
|
|
27643
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27644
|
+
Timeout \`recurrenceIntervalMs\` must be a positive number of milliseconds or \`null\`.
|
|
27645
|
+
`));
|
|
27646
|
+
}
|
|
27647
|
+
patch.recurrenceIntervalMs = Math.floor(args.recurrenceIntervalMs);
|
|
27648
|
+
}
|
|
27649
|
+
if (args.message === null) {
|
|
27650
|
+
patch.message = null;
|
|
27651
|
+
}
|
|
27652
|
+
else if (typeof args.message === 'string') {
|
|
27653
|
+
const normalizedMessage = args.message.trim();
|
|
27654
|
+
patch.message = normalizedMessage.length > 0 ? normalizedMessage : null;
|
|
27655
|
+
}
|
|
27656
|
+
if (args.parameters !== undefined) {
|
|
27657
|
+
if (!args.parameters || typeof args.parameters !== 'object' || Array.isArray(args.parameters)) {
|
|
27658
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27659
|
+
Timeout \`parameters\` must be one JSON object.
|
|
27660
|
+
`));
|
|
27661
|
+
}
|
|
27662
|
+
patch.parameters = args.parameters;
|
|
27663
|
+
}
|
|
27664
|
+
if (typeof args.paused === 'boolean') {
|
|
27665
|
+
patch.paused = args.paused;
|
|
27666
|
+
}
|
|
27667
|
+
if (allActive) {
|
|
27668
|
+
if (patch.paused === undefined) {
|
|
27669
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27670
|
+
Bulk timeout update with \`allActive: true\` requires \`paused\` to be explicitly set.
|
|
27671
|
+
`));
|
|
27672
|
+
}
|
|
27673
|
+
const hasSingleOnlyPatch = patch.dueAt !== undefined ||
|
|
27674
|
+
patch.extendByMs !== undefined ||
|
|
27675
|
+
patch.recurrenceIntervalMs !== undefined ||
|
|
27676
|
+
patch.message !== undefined ||
|
|
27677
|
+
patch.parameters !== undefined;
|
|
27678
|
+
if (hasSingleOnlyPatch) {
|
|
27679
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27680
|
+
Bulk timeout update only supports the \`paused\` field.
|
|
27681
|
+
`));
|
|
27682
|
+
}
|
|
27683
|
+
return {
|
|
27684
|
+
allActive: true,
|
|
27685
|
+
paused: patch.paused,
|
|
27686
|
+
};
|
|
27687
|
+
}
|
|
27688
|
+
if (!timeoutId) {
|
|
27689
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27690
|
+
Timeout \`timeoutId\` is required for single-timeout updates.
|
|
27691
|
+
`));
|
|
27692
|
+
}
|
|
27693
|
+
if (Object.keys(patch).length === 0) {
|
|
27694
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
27695
|
+
Timeout update must include at least one editable field.
|
|
27696
|
+
`));
|
|
27697
|
+
}
|
|
27698
|
+
return {
|
|
27699
|
+
timeoutId,
|
|
27700
|
+
patch,
|
|
27701
|
+
};
|
|
27702
|
+
},
|
|
27588
27703
|
};
|
|
27589
27704
|
|
|
27590
27705
|
/**
|
|
@@ -27596,6 +27711,7 @@ const TimeoutToolNames = {
|
|
|
27596
27711
|
set: 'set_timeout',
|
|
27597
27712
|
cancel: 'cancel_timeout',
|
|
27598
27713
|
list: 'list_timeouts',
|
|
27714
|
+
update: 'update_timeout',
|
|
27599
27715
|
};
|
|
27600
27716
|
|
|
27601
27717
|
/**
|
|
@@ -27628,6 +27744,18 @@ function normalizePromptParameters(rawParameters) {
|
|
|
27628
27744
|
return Object.fromEntries(normalizedEntries);
|
|
27629
27745
|
}
|
|
27630
27746
|
|
|
27747
|
+
/**
|
|
27748
|
+
* Maximum number of timeout rows rendered into the assistant-visible `list_timeouts` message.
|
|
27749
|
+
*
|
|
27750
|
+
* @private internal USE TIMEOUT constant
|
|
27751
|
+
*/
|
|
27752
|
+
const MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS = 20;
|
|
27753
|
+
/**
|
|
27754
|
+
* Maximum number of timeout ids rendered in bulk-action summaries.
|
|
27755
|
+
*
|
|
27756
|
+
* @private internal USE TIMEOUT constant
|
|
27757
|
+
*/
|
|
27758
|
+
const MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS = 10;
|
|
27631
27759
|
/**
|
|
27632
27760
|
* Gets `USE TIMEOUT` tool function implementations.
|
|
27633
27761
|
*
|
|
@@ -27673,6 +27801,23 @@ function createTimeoutToolFunctions() {
|
|
|
27673
27801
|
try {
|
|
27674
27802
|
const parsedArgs = parseTimeoutToolArgs.cancel(args);
|
|
27675
27803
|
const cancelledTimeout = await adapter.cancelTimeout(parsedArgs, runtimeContext);
|
|
27804
|
+
if (cancelledTimeout.status === 'cancelled_all') {
|
|
27805
|
+
const result = {
|
|
27806
|
+
action: 'cancel',
|
|
27807
|
+
status: 'cancelled_all',
|
|
27808
|
+
cancelledCount: cancelledTimeout.cancelledCount || 0,
|
|
27809
|
+
cancelledTimeoutIds: cancelledTimeout.cancelledTimeoutIds || [],
|
|
27810
|
+
hasMore: cancelledTimeout.hasMore,
|
|
27811
|
+
};
|
|
27812
|
+
return createToolExecutionEnvelope({
|
|
27813
|
+
assistantMessage: createBulkCancelAssistantMessage({
|
|
27814
|
+
cancelledCount: result.cancelledCount || 0,
|
|
27815
|
+
cancelledTimeoutIds: result.cancelledTimeoutIds || [],
|
|
27816
|
+
hasMore: result.hasMore,
|
|
27817
|
+
}),
|
|
27818
|
+
toolResult: result,
|
|
27819
|
+
});
|
|
27820
|
+
}
|
|
27676
27821
|
const result = {
|
|
27677
27822
|
action: 'cancel',
|
|
27678
27823
|
status: cancelledTimeout.status,
|
|
@@ -27711,7 +27856,10 @@ function createTimeoutToolFunctions() {
|
|
|
27711
27856
|
total: listedTimeouts.total,
|
|
27712
27857
|
};
|
|
27713
27858
|
return createToolExecutionEnvelope({
|
|
27714
|
-
assistantMessage:
|
|
27859
|
+
assistantMessage: createListedTimeoutsAssistantMessage({
|
|
27860
|
+
total: listedTimeouts.total,
|
|
27861
|
+
items: listedTimeouts.items,
|
|
27862
|
+
}),
|
|
27715
27863
|
toolResult: result,
|
|
27716
27864
|
});
|
|
27717
27865
|
}
|
|
@@ -27724,8 +27872,155 @@ function createTimeoutToolFunctions() {
|
|
|
27724
27872
|
return JSON.stringify(result);
|
|
27725
27873
|
}
|
|
27726
27874
|
},
|
|
27875
|
+
async [TimeoutToolNames.update](args) {
|
|
27876
|
+
const runtimeContext = resolveTimeoutRuntimeContext(args);
|
|
27877
|
+
const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
|
|
27878
|
+
if (!adapter || disabledResult) {
|
|
27879
|
+
return JSON.stringify(disabledResult);
|
|
27880
|
+
}
|
|
27881
|
+
try {
|
|
27882
|
+
const parsedArgs = parseTimeoutToolArgs.update(args);
|
|
27883
|
+
const updatedTimeout = await adapter.updateTimeout(parsedArgs, runtimeContext);
|
|
27884
|
+
if (updatedTimeout.status === 'updated_all') {
|
|
27885
|
+
const result = {
|
|
27886
|
+
action: 'update',
|
|
27887
|
+
status: 'updated_all',
|
|
27888
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
27889
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
27890
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
27891
|
+
hasMore: updatedTimeout.hasMore,
|
|
27892
|
+
};
|
|
27893
|
+
return createToolExecutionEnvelope({
|
|
27894
|
+
assistantMessage: createBulkUpdateAssistantMessage({
|
|
27895
|
+
paused: 'allActive' in parsedArgs && parsedArgs.allActive ? parsedArgs.paused : false,
|
|
27896
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
27897
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
27898
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
27899
|
+
hasMore: updatedTimeout.hasMore,
|
|
27900
|
+
}),
|
|
27901
|
+
toolResult: result,
|
|
27902
|
+
});
|
|
27903
|
+
}
|
|
27904
|
+
if (updatedTimeout.status === 'not_found') {
|
|
27905
|
+
const result = {
|
|
27906
|
+
action: 'update',
|
|
27907
|
+
status: 'not_found',
|
|
27908
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
27909
|
+
};
|
|
27910
|
+
return createToolExecutionEnvelope({
|
|
27911
|
+
assistantMessage: 'The timeout was not found.',
|
|
27912
|
+
toolResult: result,
|
|
27913
|
+
});
|
|
27914
|
+
}
|
|
27915
|
+
if (updatedTimeout.status === 'conflict') {
|
|
27916
|
+
const conflictMessage = updatedTimeout.reason === 'running'
|
|
27917
|
+
? 'Running timeout cannot be edited.'
|
|
27918
|
+
: 'Finished timeout cannot be edited.';
|
|
27919
|
+
const result = {
|
|
27920
|
+
action: 'update',
|
|
27921
|
+
status: 'conflict',
|
|
27922
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
27923
|
+
message: conflictMessage,
|
|
27924
|
+
};
|
|
27925
|
+
return createToolExecutionEnvelope({
|
|
27926
|
+
assistantMessage: conflictMessage,
|
|
27927
|
+
toolResult: result,
|
|
27928
|
+
});
|
|
27929
|
+
}
|
|
27930
|
+
const result = {
|
|
27931
|
+
action: 'update',
|
|
27932
|
+
status: 'updated',
|
|
27933
|
+
timeoutId: updatedTimeout.timeout.timeoutId,
|
|
27934
|
+
dueAt: updatedTimeout.timeout.dueAt,
|
|
27935
|
+
paused: updatedTimeout.timeout.paused,
|
|
27936
|
+
recurrenceIntervalMs: updatedTimeout.timeout.recurrenceIntervalMs,
|
|
27937
|
+
};
|
|
27938
|
+
return createToolExecutionEnvelope({
|
|
27939
|
+
assistantMessage: `Updated timeout ${JSON.stringify(updatedTimeout.timeout.timeoutId)}.`,
|
|
27940
|
+
toolResult: result,
|
|
27941
|
+
});
|
|
27942
|
+
}
|
|
27943
|
+
catch (error) {
|
|
27944
|
+
const result = {
|
|
27945
|
+
action: 'update',
|
|
27946
|
+
status: 'error',
|
|
27947
|
+
message: error instanceof Error ? error.message : String(error),
|
|
27948
|
+
};
|
|
27949
|
+
return JSON.stringify(result);
|
|
27950
|
+
}
|
|
27951
|
+
},
|
|
27727
27952
|
};
|
|
27728
27953
|
}
|
|
27954
|
+
/**
|
|
27955
|
+
* Creates assistant-visible summary for one `list_timeouts` response.
|
|
27956
|
+
*
|
|
27957
|
+
* @private internal utility of USE TIMEOUT
|
|
27958
|
+
*/
|
|
27959
|
+
function createListedTimeoutsAssistantMessage(options) {
|
|
27960
|
+
if (options.total <= 0 || options.items.length === 0) {
|
|
27961
|
+
return 'Found 0 timeouts.';
|
|
27962
|
+
}
|
|
27963
|
+
const visibleItems = options.items.slice(0, MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS);
|
|
27964
|
+
const summaryRows = visibleItems.map((item, index) => `${index + 1}. ${formatTimeoutListRow(item)}`);
|
|
27965
|
+
const hiddenCount = Math.max(0, options.total - visibleItems.length);
|
|
27966
|
+
if (hiddenCount > 0) {
|
|
27967
|
+
summaryRows.push(`...and ${hiddenCount} more.`);
|
|
27968
|
+
}
|
|
27969
|
+
return [`Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:`, ...summaryRows].join('\n');
|
|
27970
|
+
}
|
|
27971
|
+
/**
|
|
27972
|
+
* Formats one timeout row for assistant-visible timeout listings.
|
|
27973
|
+
*
|
|
27974
|
+
* @private internal utility of USE TIMEOUT
|
|
27975
|
+
*/
|
|
27976
|
+
function formatTimeoutListRow(item) {
|
|
27977
|
+
const normalizedMessage = typeof item.message === 'string' ? item.message.trim() : '';
|
|
27978
|
+
const messageSuffix = normalizedMessage ? ` | message ${JSON.stringify(normalizedMessage)}` : '';
|
|
27979
|
+
const recurrenceSuffix = typeof item.recurrenceIntervalMs === 'number' && item.recurrenceIntervalMs > 0
|
|
27980
|
+
? ` | recurrence ${item.recurrenceIntervalMs}ms`
|
|
27981
|
+
: '';
|
|
27982
|
+
const pausedSuffix = item.paused ? ' (paused)' : '';
|
|
27983
|
+
return `${item.timeoutId} | ${item.status}${pausedSuffix} | chat ${item.chatId} | due ${item.dueAt}${recurrenceSuffix}${messageSuffix}`;
|
|
27984
|
+
}
|
|
27985
|
+
/**
|
|
27986
|
+
* Creates assistant-visible summary for bulk timeout cancellation.
|
|
27987
|
+
*
|
|
27988
|
+
* @private internal utility of USE TIMEOUT
|
|
27989
|
+
*/
|
|
27990
|
+
function createBulkCancelAssistantMessage(options) {
|
|
27991
|
+
if (options.cancelledCount <= 0) {
|
|
27992
|
+
return 'No active timeouts were found to cancel.';
|
|
27993
|
+
}
|
|
27994
|
+
const visibleTimeoutIds = options.cancelledTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
27995
|
+
const hiddenIdsCount = Math.max(0, options.cancelledTimeoutIds.length - visibleTimeoutIds.length);
|
|
27996
|
+
const hasMoreSuffix = options.hasMore ? ' Additional active timeouts may still exist.' : '';
|
|
27997
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
27998
|
+
? ` Cancelled ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
27999
|
+
: '';
|
|
28000
|
+
return `Cancelled ${options.cancelledCount} active ${options.cancelledCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${hasMoreSuffix}`;
|
|
28001
|
+
}
|
|
28002
|
+
/**
|
|
28003
|
+
* Creates assistant-visible summary for bulk timeout pause/resume updates.
|
|
28004
|
+
*
|
|
28005
|
+
* @private internal utility of USE TIMEOUT
|
|
28006
|
+
*/
|
|
28007
|
+
function createBulkUpdateAssistantMessage(options) {
|
|
28008
|
+
if (options.matchedCount <= 0) {
|
|
28009
|
+
return options.paused
|
|
28010
|
+
? 'No active queued timeouts were found to pause.'
|
|
28011
|
+
: 'No paused queued timeouts were found to resume.';
|
|
28012
|
+
}
|
|
28013
|
+
const verb = options.paused ? 'Paused' : 'Resumed';
|
|
28014
|
+
const visibleTimeoutIds = options.updatedTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
28015
|
+
const hiddenIdsCount = Math.max(0, options.updatedTimeoutIds.length - visibleTimeoutIds.length);
|
|
28016
|
+
const skippedCount = Math.max(0, options.matchedCount - options.updatedCount);
|
|
28017
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
28018
|
+
? ` Updated ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
28019
|
+
: '';
|
|
28020
|
+
const skippedSuffix = skippedCount > 0 ? ` Skipped ${skippedCount} due to concurrent changes.` : '';
|
|
28021
|
+
const hasMoreSuffix = options.hasMore ? ' Additional matching timeouts may still exist.' : '';
|
|
28022
|
+
return `${verb} ${options.updatedCount} ${options.updatedCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${skippedSuffix}${hasMoreSuffix}`;
|
|
28023
|
+
}
|
|
27729
28024
|
|
|
27730
28025
|
/**
|
|
27731
28026
|
* Adds `USE TIMEOUT` tool definitions while preserving already registered tools.
|
|
@@ -27757,7 +28052,7 @@ function createTimeoutTools(existingTools = []) {
|
|
|
27757
28052
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
|
|
27758
28053
|
tools.push({
|
|
27759
28054
|
name: TimeoutToolNames.cancel,
|
|
27760
|
-
description: 'Cancel one
|
|
28055
|
+
description: 'Cancel one timeout by id or cancel all active timeouts across chats for the same user+agent scope.',
|
|
27761
28056
|
parameters: {
|
|
27762
28057
|
type: 'object',
|
|
27763
28058
|
properties: {
|
|
@@ -27765,15 +28060,18 @@ function createTimeoutTools(existingTools = []) {
|
|
|
27765
28060
|
type: 'string',
|
|
27766
28061
|
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
|
|
27767
28062
|
},
|
|
28063
|
+
allActive: {
|
|
28064
|
+
type: 'boolean',
|
|
28065
|
+
description: 'When true, cancel all currently active timeouts across chats in this user+agent scope.',
|
|
28066
|
+
},
|
|
27768
28067
|
},
|
|
27769
|
-
required: ['timeoutId'],
|
|
27770
28068
|
},
|
|
27771
28069
|
});
|
|
27772
28070
|
}
|
|
27773
28071
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
|
|
27774
28072
|
tools.push({
|
|
27775
28073
|
name: TimeoutToolNames.list,
|
|
27776
|
-
description: 'List
|
|
28074
|
+
description: 'List timeout details across all chats for this same user+agent scope so they can be reviewed and managed.',
|
|
27777
28075
|
parameters: {
|
|
27778
28076
|
type: 'object',
|
|
27779
28077
|
properties: {
|
|
@@ -27789,6 +28087,49 @@ function createTimeoutTools(existingTools = []) {
|
|
|
27789
28087
|
},
|
|
27790
28088
|
});
|
|
27791
28089
|
}
|
|
28090
|
+
if (!tools.some((tool) => tool.name === TimeoutToolNames.update)) {
|
|
28091
|
+
tools.push({
|
|
28092
|
+
name: TimeoutToolNames.update,
|
|
28093
|
+
description: 'Update one timeout (pause/resume, next run, recurrence, payload) or pause/resume all active queued timeouts across chats.',
|
|
28094
|
+
parameters: {
|
|
28095
|
+
type: 'object',
|
|
28096
|
+
properties: {
|
|
28097
|
+
timeoutId: {
|
|
28098
|
+
type: 'string',
|
|
28099
|
+
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts` for one timeout update.',
|
|
28100
|
+
},
|
|
28101
|
+
allActive: {
|
|
28102
|
+
type: 'boolean',
|
|
28103
|
+
description: 'When true, run one bulk pause/resume across all active queued timeouts in this same user+agent scope.',
|
|
28104
|
+
},
|
|
28105
|
+
paused: {
|
|
28106
|
+
type: 'boolean',
|
|
28107
|
+
description: 'Pause (`true`) or resume (`false`) one timeout; with `allActive: true` this pauses/resumes all active queued timeouts.',
|
|
28108
|
+
},
|
|
28109
|
+
dueAt: {
|
|
28110
|
+
type: 'string',
|
|
28111
|
+
description: 'Set the next run timestamp (ISO string). Cannot be used with `extendByMs`.',
|
|
28112
|
+
},
|
|
28113
|
+
extendByMs: {
|
|
28114
|
+
type: 'number',
|
|
28115
|
+
description: 'Move next run by this many milliseconds. Cannot be used with `dueAt`.',
|
|
28116
|
+
},
|
|
28117
|
+
recurrenceIntervalMs: {
|
|
28118
|
+
type: 'number',
|
|
28119
|
+
description: 'Set recurrence interval in milliseconds; pass `null` to disable recurrence.',
|
|
28120
|
+
},
|
|
28121
|
+
message: {
|
|
28122
|
+
type: 'string',
|
|
28123
|
+
description: 'Set wake-up message text for this timeout; pass empty string to clear.',
|
|
28124
|
+
},
|
|
28125
|
+
parameters: {
|
|
28126
|
+
type: 'object',
|
|
28127
|
+
description: 'Replace stored JSON parameters passed back when timeout fires.',
|
|
28128
|
+
},
|
|
28129
|
+
},
|
|
28130
|
+
},
|
|
28131
|
+
});
|
|
28132
|
+
}
|
|
27792
28133
|
return tools;
|
|
27793
28134
|
}
|
|
27794
28135
|
|
|
@@ -27810,7 +28151,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
27810
28151
|
* Short one-line description of `USE TIMEOUT`.
|
|
27811
28152
|
*/
|
|
27812
28153
|
get description() {
|
|
27813
|
-
return 'Enable timeout wake-ups plus scoped timeout listing
|
|
28154
|
+
return 'Enable timeout wake-ups plus scoped timeout listing, updates, and cancellation across chats.';
|
|
27814
28155
|
}
|
|
27815
28156
|
/**
|
|
27816
28157
|
* Icon for this commitment.
|
|
@@ -27832,8 +28173,9 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
27832
28173
|
- The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
|
|
27833
28174
|
- The tool returns immediately while the timeout is stored and executed by the runtime later.
|
|
27834
28175
|
- The wake-up arrives as a new user-like timeout message in the same conversation.
|
|
27835
|
-
- The agent can inspect known
|
|
27836
|
-
- The agent can cancel
|
|
28176
|
+
- The agent can inspect known timeout details via \`list_timeouts\`.
|
|
28177
|
+
- The agent can cancel one timeout by \`timeoutId\` or cancel all active timeouts via \`cancel_timeout\`.
|
|
28178
|
+
- The agent can pause/resume and edit timeout details via \`update_timeout\`.
|
|
27837
28179
|
- Commitment content is treated as optional timeout policy instructions.
|
|
27838
28180
|
|
|
27839
28181
|
## Examples
|
|
@@ -27863,6 +28205,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
27863
28205
|
[TimeoutToolNames.set]: 'Set timer',
|
|
27864
28206
|
[TimeoutToolNames.cancel]: 'Cancel timer',
|
|
27865
28207
|
[TimeoutToolNames.list]: 'List timers',
|
|
28208
|
+
[TimeoutToolNames.update]: 'Update timer',
|
|
27866
28209
|
};
|
|
27867
28210
|
}
|
|
27868
28211
|
/**
|