@promptbook/node 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
|
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
35
35
|
* @generated
|
|
36
36
|
* @see https://github.com/webgptorg/promptbook
|
|
37
37
|
*/
|
|
38
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
38
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-21';
|
|
39
39
|
/**
|
|
40
40
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
41
41
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -23519,8 +23519,9 @@ function createTimeoutSystemMessage(extraInstructions) {
|
|
|
23519
23519
|
return spaceTrim$1((block) => `
|
|
23520
23520
|
Timeout scheduling:
|
|
23521
23521
|
- Use "set_timeout" to wake this same chat thread in the future.
|
|
23522
|
-
- Use "list_timeouts" to review
|
|
23523
|
-
- "cancel_timeout" accepts
|
|
23522
|
+
- Use "list_timeouts" to review timeout ids/details across all chats for the same user+agent scope.
|
|
23523
|
+
- "cancel_timeout" accepts either one timeout id or \`allActive: true\` to cancel all active timeouts in this same user+agent scope.
|
|
23524
|
+
- Use "update_timeout" to pause/resume, edit next run, edit recurrence, or update timeout payload details.
|
|
23524
23525
|
- 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\`.
|
|
23525
23526
|
- Do not claim a timer was set or cancelled unless the tool confirms it.
|
|
23526
23527
|
${block(extraInstructions)}
|
|
@@ -23647,9 +23648,18 @@ const parseTimeoutToolArgs = {
|
|
|
23647
23648
|
*/
|
|
23648
23649
|
cancel(args) {
|
|
23649
23650
|
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
23651
|
+
const allActive = args.allActive === true;
|
|
23652
|
+
if (timeoutId && allActive) {
|
|
23653
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23654
|
+
Timeout cancellation must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
23655
|
+
`));
|
|
23656
|
+
}
|
|
23657
|
+
if (allActive) {
|
|
23658
|
+
return { allActive: true };
|
|
23659
|
+
}
|
|
23650
23660
|
if (!timeoutId) {
|
|
23651
23661
|
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23652
|
-
Timeout \`timeoutId\` is required
|
|
23662
|
+
Timeout \`timeoutId\` is required unless you pass \`allActive: true\`.
|
|
23653
23663
|
`));
|
|
23654
23664
|
}
|
|
23655
23665
|
return { timeoutId };
|
|
@@ -23679,6 +23689,111 @@ const parseTimeoutToolArgs = {
|
|
|
23679
23689
|
limit: parsedLimit,
|
|
23680
23690
|
};
|
|
23681
23691
|
},
|
|
23692
|
+
/**
|
|
23693
|
+
* Parses `update_timeout` input.
|
|
23694
|
+
*/
|
|
23695
|
+
update(args) {
|
|
23696
|
+
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
23697
|
+
const allActive = args.allActive === true;
|
|
23698
|
+
if (timeoutId && allActive) {
|
|
23699
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23700
|
+
Timeout update must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
23701
|
+
`));
|
|
23702
|
+
}
|
|
23703
|
+
if (!timeoutId && !allActive) {
|
|
23704
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23705
|
+
Timeout update requires one \`timeoutId\` or \`allActive: true\`.
|
|
23706
|
+
`));
|
|
23707
|
+
}
|
|
23708
|
+
const patch = {};
|
|
23709
|
+
if (typeof args.dueAt === 'string' && args.dueAt.trim().length > 0) {
|
|
23710
|
+
const normalizedDueAt = args.dueAt.trim();
|
|
23711
|
+
const dueAtTimestamp = Date.parse(normalizedDueAt);
|
|
23712
|
+
if (!Number.isFinite(dueAtTimestamp)) {
|
|
23713
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23714
|
+
Timeout \`dueAt\` must be one valid ISO timestamp.
|
|
23715
|
+
`));
|
|
23716
|
+
}
|
|
23717
|
+
patch.dueAt = new Date(dueAtTimestamp).toISOString();
|
|
23718
|
+
}
|
|
23719
|
+
if (typeof args.extendByMs === 'number') {
|
|
23720
|
+
if (!Number.isFinite(args.extendByMs) || args.extendByMs <= 0) {
|
|
23721
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23722
|
+
Timeout \`extendByMs\` must be a positive number of milliseconds.
|
|
23723
|
+
`));
|
|
23724
|
+
}
|
|
23725
|
+
patch.extendByMs = Math.floor(args.extendByMs);
|
|
23726
|
+
}
|
|
23727
|
+
if (patch.dueAt !== undefined && patch.extendByMs !== undefined) {
|
|
23728
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23729
|
+
Timeout update cannot include both \`dueAt\` and \`extendByMs\`.
|
|
23730
|
+
`));
|
|
23731
|
+
}
|
|
23732
|
+
if (args.recurrenceIntervalMs === null) {
|
|
23733
|
+
patch.recurrenceIntervalMs = null;
|
|
23734
|
+
}
|
|
23735
|
+
else if (typeof args.recurrenceIntervalMs === 'number') {
|
|
23736
|
+
if (!Number.isFinite(args.recurrenceIntervalMs) || args.recurrenceIntervalMs <= 0) {
|
|
23737
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23738
|
+
Timeout \`recurrenceIntervalMs\` must be a positive number of milliseconds or \`null\`.
|
|
23739
|
+
`));
|
|
23740
|
+
}
|
|
23741
|
+
patch.recurrenceIntervalMs = Math.floor(args.recurrenceIntervalMs);
|
|
23742
|
+
}
|
|
23743
|
+
if (args.message === null) {
|
|
23744
|
+
patch.message = null;
|
|
23745
|
+
}
|
|
23746
|
+
else if (typeof args.message === 'string') {
|
|
23747
|
+
const normalizedMessage = args.message.trim();
|
|
23748
|
+
patch.message = normalizedMessage.length > 0 ? normalizedMessage : null;
|
|
23749
|
+
}
|
|
23750
|
+
if (args.parameters !== undefined) {
|
|
23751
|
+
if (!args.parameters || typeof args.parameters !== 'object' || Array.isArray(args.parameters)) {
|
|
23752
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23753
|
+
Timeout \`parameters\` must be one JSON object.
|
|
23754
|
+
`));
|
|
23755
|
+
}
|
|
23756
|
+
patch.parameters = args.parameters;
|
|
23757
|
+
}
|
|
23758
|
+
if (typeof args.paused === 'boolean') {
|
|
23759
|
+
patch.paused = args.paused;
|
|
23760
|
+
}
|
|
23761
|
+
if (allActive) {
|
|
23762
|
+
if (patch.paused === undefined) {
|
|
23763
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23764
|
+
Bulk timeout update with \`allActive: true\` requires \`paused\` to be explicitly set.
|
|
23765
|
+
`));
|
|
23766
|
+
}
|
|
23767
|
+
const hasSingleOnlyPatch = patch.dueAt !== undefined ||
|
|
23768
|
+
patch.extendByMs !== undefined ||
|
|
23769
|
+
patch.recurrenceIntervalMs !== undefined ||
|
|
23770
|
+
patch.message !== undefined ||
|
|
23771
|
+
patch.parameters !== undefined;
|
|
23772
|
+
if (hasSingleOnlyPatch) {
|
|
23773
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23774
|
+
Bulk timeout update only supports the \`paused\` field.
|
|
23775
|
+
`));
|
|
23776
|
+
}
|
|
23777
|
+
return {
|
|
23778
|
+
allActive: true,
|
|
23779
|
+
paused: patch.paused,
|
|
23780
|
+
};
|
|
23781
|
+
}
|
|
23782
|
+
if (!timeoutId) {
|
|
23783
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23784
|
+
Timeout \`timeoutId\` is required for single-timeout updates.
|
|
23785
|
+
`));
|
|
23786
|
+
}
|
|
23787
|
+
if (Object.keys(patch).length === 0) {
|
|
23788
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
23789
|
+
Timeout update must include at least one editable field.
|
|
23790
|
+
`));
|
|
23791
|
+
}
|
|
23792
|
+
return {
|
|
23793
|
+
timeoutId,
|
|
23794
|
+
patch,
|
|
23795
|
+
};
|
|
23796
|
+
},
|
|
23682
23797
|
};
|
|
23683
23798
|
|
|
23684
23799
|
/**
|
|
@@ -23690,6 +23805,7 @@ const TimeoutToolNames = {
|
|
|
23690
23805
|
set: 'set_timeout',
|
|
23691
23806
|
cancel: 'cancel_timeout',
|
|
23692
23807
|
list: 'list_timeouts',
|
|
23808
|
+
update: 'update_timeout',
|
|
23693
23809
|
};
|
|
23694
23810
|
|
|
23695
23811
|
/**
|
|
@@ -23722,6 +23838,18 @@ function normalizePromptParameters(rawParameters) {
|
|
|
23722
23838
|
return Object.fromEntries(normalizedEntries);
|
|
23723
23839
|
}
|
|
23724
23840
|
|
|
23841
|
+
/**
|
|
23842
|
+
* Maximum number of timeout rows rendered into the assistant-visible `list_timeouts` message.
|
|
23843
|
+
*
|
|
23844
|
+
* @private internal USE TIMEOUT constant
|
|
23845
|
+
*/
|
|
23846
|
+
const MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS = 20;
|
|
23847
|
+
/**
|
|
23848
|
+
* Maximum number of timeout ids rendered in bulk-action summaries.
|
|
23849
|
+
*
|
|
23850
|
+
* @private internal USE TIMEOUT constant
|
|
23851
|
+
*/
|
|
23852
|
+
const MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS = 10;
|
|
23725
23853
|
/**
|
|
23726
23854
|
* Gets `USE TIMEOUT` tool function implementations.
|
|
23727
23855
|
*
|
|
@@ -23767,6 +23895,23 @@ function createTimeoutToolFunctions() {
|
|
|
23767
23895
|
try {
|
|
23768
23896
|
const parsedArgs = parseTimeoutToolArgs.cancel(args);
|
|
23769
23897
|
const cancelledTimeout = await adapter.cancelTimeout(parsedArgs, runtimeContext);
|
|
23898
|
+
if (cancelledTimeout.status === 'cancelled_all') {
|
|
23899
|
+
const result = {
|
|
23900
|
+
action: 'cancel',
|
|
23901
|
+
status: 'cancelled_all',
|
|
23902
|
+
cancelledCount: cancelledTimeout.cancelledCount || 0,
|
|
23903
|
+
cancelledTimeoutIds: cancelledTimeout.cancelledTimeoutIds || [],
|
|
23904
|
+
hasMore: cancelledTimeout.hasMore,
|
|
23905
|
+
};
|
|
23906
|
+
return createToolExecutionEnvelope({
|
|
23907
|
+
assistantMessage: createBulkCancelAssistantMessage({
|
|
23908
|
+
cancelledCount: result.cancelledCount || 0,
|
|
23909
|
+
cancelledTimeoutIds: result.cancelledTimeoutIds || [],
|
|
23910
|
+
hasMore: result.hasMore,
|
|
23911
|
+
}),
|
|
23912
|
+
toolResult: result,
|
|
23913
|
+
});
|
|
23914
|
+
}
|
|
23770
23915
|
const result = {
|
|
23771
23916
|
action: 'cancel',
|
|
23772
23917
|
status: cancelledTimeout.status,
|
|
@@ -23805,7 +23950,10 @@ function createTimeoutToolFunctions() {
|
|
|
23805
23950
|
total: listedTimeouts.total,
|
|
23806
23951
|
};
|
|
23807
23952
|
return createToolExecutionEnvelope({
|
|
23808
|
-
assistantMessage:
|
|
23953
|
+
assistantMessage: createListedTimeoutsAssistantMessage({
|
|
23954
|
+
total: listedTimeouts.total,
|
|
23955
|
+
items: listedTimeouts.items,
|
|
23956
|
+
}),
|
|
23809
23957
|
toolResult: result,
|
|
23810
23958
|
});
|
|
23811
23959
|
}
|
|
@@ -23818,8 +23966,155 @@ function createTimeoutToolFunctions() {
|
|
|
23818
23966
|
return JSON.stringify(result);
|
|
23819
23967
|
}
|
|
23820
23968
|
},
|
|
23969
|
+
async [TimeoutToolNames.update](args) {
|
|
23970
|
+
const runtimeContext = resolveTimeoutRuntimeContext(args);
|
|
23971
|
+
const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
|
|
23972
|
+
if (!adapter || disabledResult) {
|
|
23973
|
+
return JSON.stringify(disabledResult);
|
|
23974
|
+
}
|
|
23975
|
+
try {
|
|
23976
|
+
const parsedArgs = parseTimeoutToolArgs.update(args);
|
|
23977
|
+
const updatedTimeout = await adapter.updateTimeout(parsedArgs, runtimeContext);
|
|
23978
|
+
if (updatedTimeout.status === 'updated_all') {
|
|
23979
|
+
const result = {
|
|
23980
|
+
action: 'update',
|
|
23981
|
+
status: 'updated_all',
|
|
23982
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
23983
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
23984
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
23985
|
+
hasMore: updatedTimeout.hasMore,
|
|
23986
|
+
};
|
|
23987
|
+
return createToolExecutionEnvelope({
|
|
23988
|
+
assistantMessage: createBulkUpdateAssistantMessage({
|
|
23989
|
+
paused: 'allActive' in parsedArgs && parsedArgs.allActive ? parsedArgs.paused : false,
|
|
23990
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
23991
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
23992
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
23993
|
+
hasMore: updatedTimeout.hasMore,
|
|
23994
|
+
}),
|
|
23995
|
+
toolResult: result,
|
|
23996
|
+
});
|
|
23997
|
+
}
|
|
23998
|
+
if (updatedTimeout.status === 'not_found') {
|
|
23999
|
+
const result = {
|
|
24000
|
+
action: 'update',
|
|
24001
|
+
status: 'not_found',
|
|
24002
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
24003
|
+
};
|
|
24004
|
+
return createToolExecutionEnvelope({
|
|
24005
|
+
assistantMessage: 'The timeout was not found.',
|
|
24006
|
+
toolResult: result,
|
|
24007
|
+
});
|
|
24008
|
+
}
|
|
24009
|
+
if (updatedTimeout.status === 'conflict') {
|
|
24010
|
+
const conflictMessage = updatedTimeout.reason === 'running'
|
|
24011
|
+
? 'Running timeout cannot be edited.'
|
|
24012
|
+
: 'Finished timeout cannot be edited.';
|
|
24013
|
+
const result = {
|
|
24014
|
+
action: 'update',
|
|
24015
|
+
status: 'conflict',
|
|
24016
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
24017
|
+
message: conflictMessage,
|
|
24018
|
+
};
|
|
24019
|
+
return createToolExecutionEnvelope({
|
|
24020
|
+
assistantMessage: conflictMessage,
|
|
24021
|
+
toolResult: result,
|
|
24022
|
+
});
|
|
24023
|
+
}
|
|
24024
|
+
const result = {
|
|
24025
|
+
action: 'update',
|
|
24026
|
+
status: 'updated',
|
|
24027
|
+
timeoutId: updatedTimeout.timeout.timeoutId,
|
|
24028
|
+
dueAt: updatedTimeout.timeout.dueAt,
|
|
24029
|
+
paused: updatedTimeout.timeout.paused,
|
|
24030
|
+
recurrenceIntervalMs: updatedTimeout.timeout.recurrenceIntervalMs,
|
|
24031
|
+
};
|
|
24032
|
+
return createToolExecutionEnvelope({
|
|
24033
|
+
assistantMessage: `Updated timeout ${JSON.stringify(updatedTimeout.timeout.timeoutId)}.`,
|
|
24034
|
+
toolResult: result,
|
|
24035
|
+
});
|
|
24036
|
+
}
|
|
24037
|
+
catch (error) {
|
|
24038
|
+
const result = {
|
|
24039
|
+
action: 'update',
|
|
24040
|
+
status: 'error',
|
|
24041
|
+
message: error instanceof Error ? error.message : String(error),
|
|
24042
|
+
};
|
|
24043
|
+
return JSON.stringify(result);
|
|
24044
|
+
}
|
|
24045
|
+
},
|
|
23821
24046
|
};
|
|
23822
24047
|
}
|
|
24048
|
+
/**
|
|
24049
|
+
* Creates assistant-visible summary for one `list_timeouts` response.
|
|
24050
|
+
*
|
|
24051
|
+
* @private internal utility of USE TIMEOUT
|
|
24052
|
+
*/
|
|
24053
|
+
function createListedTimeoutsAssistantMessage(options) {
|
|
24054
|
+
if (options.total <= 0 || options.items.length === 0) {
|
|
24055
|
+
return 'Found 0 timeouts.';
|
|
24056
|
+
}
|
|
24057
|
+
const visibleItems = options.items.slice(0, MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS);
|
|
24058
|
+
const summaryRows = visibleItems.map((item, index) => `${index + 1}. ${formatTimeoutListRow(item)}`);
|
|
24059
|
+
const hiddenCount = Math.max(0, options.total - visibleItems.length);
|
|
24060
|
+
if (hiddenCount > 0) {
|
|
24061
|
+
summaryRows.push(`...and ${hiddenCount} more.`);
|
|
24062
|
+
}
|
|
24063
|
+
return [`Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:`, ...summaryRows].join('\n');
|
|
24064
|
+
}
|
|
24065
|
+
/**
|
|
24066
|
+
* Formats one timeout row for assistant-visible timeout listings.
|
|
24067
|
+
*
|
|
24068
|
+
* @private internal utility of USE TIMEOUT
|
|
24069
|
+
*/
|
|
24070
|
+
function formatTimeoutListRow(item) {
|
|
24071
|
+
const normalizedMessage = typeof item.message === 'string' ? item.message.trim() : '';
|
|
24072
|
+
const messageSuffix = normalizedMessage ? ` | message ${JSON.stringify(normalizedMessage)}` : '';
|
|
24073
|
+
const recurrenceSuffix = typeof item.recurrenceIntervalMs === 'number' && item.recurrenceIntervalMs > 0
|
|
24074
|
+
? ` | recurrence ${item.recurrenceIntervalMs}ms`
|
|
24075
|
+
: '';
|
|
24076
|
+
const pausedSuffix = item.paused ? ' (paused)' : '';
|
|
24077
|
+
return `${item.timeoutId} | ${item.status}${pausedSuffix} | chat ${item.chatId} | due ${item.dueAt}${recurrenceSuffix}${messageSuffix}`;
|
|
24078
|
+
}
|
|
24079
|
+
/**
|
|
24080
|
+
* Creates assistant-visible summary for bulk timeout cancellation.
|
|
24081
|
+
*
|
|
24082
|
+
* @private internal utility of USE TIMEOUT
|
|
24083
|
+
*/
|
|
24084
|
+
function createBulkCancelAssistantMessage(options) {
|
|
24085
|
+
if (options.cancelledCount <= 0) {
|
|
24086
|
+
return 'No active timeouts were found to cancel.';
|
|
24087
|
+
}
|
|
24088
|
+
const visibleTimeoutIds = options.cancelledTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
24089
|
+
const hiddenIdsCount = Math.max(0, options.cancelledTimeoutIds.length - visibleTimeoutIds.length);
|
|
24090
|
+
const hasMoreSuffix = options.hasMore ? ' Additional active timeouts may still exist.' : '';
|
|
24091
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
24092
|
+
? ` Cancelled ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
24093
|
+
: '';
|
|
24094
|
+
return `Cancelled ${options.cancelledCount} active ${options.cancelledCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${hasMoreSuffix}`;
|
|
24095
|
+
}
|
|
24096
|
+
/**
|
|
24097
|
+
* Creates assistant-visible summary for bulk timeout pause/resume updates.
|
|
24098
|
+
*
|
|
24099
|
+
* @private internal utility of USE TIMEOUT
|
|
24100
|
+
*/
|
|
24101
|
+
function createBulkUpdateAssistantMessage(options) {
|
|
24102
|
+
if (options.matchedCount <= 0) {
|
|
24103
|
+
return options.paused
|
|
24104
|
+
? 'No active queued timeouts were found to pause.'
|
|
24105
|
+
: 'No paused queued timeouts were found to resume.';
|
|
24106
|
+
}
|
|
24107
|
+
const verb = options.paused ? 'Paused' : 'Resumed';
|
|
24108
|
+
const visibleTimeoutIds = options.updatedTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
24109
|
+
const hiddenIdsCount = Math.max(0, options.updatedTimeoutIds.length - visibleTimeoutIds.length);
|
|
24110
|
+
const skippedCount = Math.max(0, options.matchedCount - options.updatedCount);
|
|
24111
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
24112
|
+
? ` Updated ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
24113
|
+
: '';
|
|
24114
|
+
const skippedSuffix = skippedCount > 0 ? ` Skipped ${skippedCount} due to concurrent changes.` : '';
|
|
24115
|
+
const hasMoreSuffix = options.hasMore ? ' Additional matching timeouts may still exist.' : '';
|
|
24116
|
+
return `${verb} ${options.updatedCount} ${options.updatedCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${skippedSuffix}${hasMoreSuffix}`;
|
|
24117
|
+
}
|
|
23823
24118
|
|
|
23824
24119
|
/**
|
|
23825
24120
|
* Adds `USE TIMEOUT` tool definitions while preserving already registered tools.
|
|
@@ -23851,7 +24146,7 @@ function createTimeoutTools(existingTools = []) {
|
|
|
23851
24146
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
|
|
23852
24147
|
tools.push({
|
|
23853
24148
|
name: TimeoutToolNames.cancel,
|
|
23854
|
-
description: 'Cancel one
|
|
24149
|
+
description: 'Cancel one timeout by id or cancel all active timeouts across chats for the same user+agent scope.',
|
|
23855
24150
|
parameters: {
|
|
23856
24151
|
type: 'object',
|
|
23857
24152
|
properties: {
|
|
@@ -23859,15 +24154,18 @@ function createTimeoutTools(existingTools = []) {
|
|
|
23859
24154
|
type: 'string',
|
|
23860
24155
|
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
|
|
23861
24156
|
},
|
|
24157
|
+
allActive: {
|
|
24158
|
+
type: 'boolean',
|
|
24159
|
+
description: 'When true, cancel all currently active timeouts across chats in this user+agent scope.',
|
|
24160
|
+
},
|
|
23862
24161
|
},
|
|
23863
|
-
required: ['timeoutId'],
|
|
23864
24162
|
},
|
|
23865
24163
|
});
|
|
23866
24164
|
}
|
|
23867
24165
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
|
|
23868
24166
|
tools.push({
|
|
23869
24167
|
name: TimeoutToolNames.list,
|
|
23870
|
-
description: 'List
|
|
24168
|
+
description: 'List timeout details across all chats for this same user+agent scope so they can be reviewed and managed.',
|
|
23871
24169
|
parameters: {
|
|
23872
24170
|
type: 'object',
|
|
23873
24171
|
properties: {
|
|
@@ -23883,6 +24181,49 @@ function createTimeoutTools(existingTools = []) {
|
|
|
23883
24181
|
},
|
|
23884
24182
|
});
|
|
23885
24183
|
}
|
|
24184
|
+
if (!tools.some((tool) => tool.name === TimeoutToolNames.update)) {
|
|
24185
|
+
tools.push({
|
|
24186
|
+
name: TimeoutToolNames.update,
|
|
24187
|
+
description: 'Update one timeout (pause/resume, next run, recurrence, payload) or pause/resume all active queued timeouts across chats.',
|
|
24188
|
+
parameters: {
|
|
24189
|
+
type: 'object',
|
|
24190
|
+
properties: {
|
|
24191
|
+
timeoutId: {
|
|
24192
|
+
type: 'string',
|
|
24193
|
+
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts` for one timeout update.',
|
|
24194
|
+
},
|
|
24195
|
+
allActive: {
|
|
24196
|
+
type: 'boolean',
|
|
24197
|
+
description: 'When true, run one bulk pause/resume across all active queued timeouts in this same user+agent scope.',
|
|
24198
|
+
},
|
|
24199
|
+
paused: {
|
|
24200
|
+
type: 'boolean',
|
|
24201
|
+
description: 'Pause (`true`) or resume (`false`) one timeout; with `allActive: true` this pauses/resumes all active queued timeouts.',
|
|
24202
|
+
},
|
|
24203
|
+
dueAt: {
|
|
24204
|
+
type: 'string',
|
|
24205
|
+
description: 'Set the next run timestamp (ISO string). Cannot be used with `extendByMs`.',
|
|
24206
|
+
},
|
|
24207
|
+
extendByMs: {
|
|
24208
|
+
type: 'number',
|
|
24209
|
+
description: 'Move next run by this many milliseconds. Cannot be used with `dueAt`.',
|
|
24210
|
+
},
|
|
24211
|
+
recurrenceIntervalMs: {
|
|
24212
|
+
type: 'number',
|
|
24213
|
+
description: 'Set recurrence interval in milliseconds; pass `null` to disable recurrence.',
|
|
24214
|
+
},
|
|
24215
|
+
message: {
|
|
24216
|
+
type: 'string',
|
|
24217
|
+
description: 'Set wake-up message text for this timeout; pass empty string to clear.',
|
|
24218
|
+
},
|
|
24219
|
+
parameters: {
|
|
24220
|
+
type: 'object',
|
|
24221
|
+
description: 'Replace stored JSON parameters passed back when timeout fires.',
|
|
24222
|
+
},
|
|
24223
|
+
},
|
|
24224
|
+
},
|
|
24225
|
+
});
|
|
24226
|
+
}
|
|
23886
24227
|
return tools;
|
|
23887
24228
|
}
|
|
23888
24229
|
|
|
@@ -23904,7 +24245,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
23904
24245
|
* Short one-line description of `USE TIMEOUT`.
|
|
23905
24246
|
*/
|
|
23906
24247
|
get description() {
|
|
23907
|
-
return 'Enable timeout wake-ups plus scoped timeout listing
|
|
24248
|
+
return 'Enable timeout wake-ups plus scoped timeout listing, updates, and cancellation across chats.';
|
|
23908
24249
|
}
|
|
23909
24250
|
/**
|
|
23910
24251
|
* Icon for this commitment.
|
|
@@ -23926,8 +24267,9 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
23926
24267
|
- The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
|
|
23927
24268
|
- The tool returns immediately while the timeout is stored and executed by the runtime later.
|
|
23928
24269
|
- The wake-up arrives as a new user-like timeout message in the same conversation.
|
|
23929
|
-
- The agent can inspect known
|
|
23930
|
-
- The agent can cancel
|
|
24270
|
+
- The agent can inspect known timeout details via \`list_timeouts\`.
|
|
24271
|
+
- The agent can cancel one timeout by \`timeoutId\` or cancel all active timeouts via \`cancel_timeout\`.
|
|
24272
|
+
- The agent can pause/resume and edit timeout details via \`update_timeout\`.
|
|
23931
24273
|
- Commitment content is treated as optional timeout policy instructions.
|
|
23932
24274
|
|
|
23933
24275
|
## Examples
|
|
@@ -23957,6 +24299,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
23957
24299
|
[TimeoutToolNames.set]: 'Set timer',
|
|
23958
24300
|
[TimeoutToolNames.cancel]: 'Cancel timer',
|
|
23959
24301
|
[TimeoutToolNames.list]: 'List timers',
|
|
24302
|
+
[TimeoutToolNames.update]: 'Update timer',
|
|
23960
24303
|
};
|
|
23961
24304
|
}
|
|
23962
24305
|
/**
|