@promptbook/remote-server 0.112.0-20 → 0.112.0-22
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/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/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
|
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
40
40
|
* @generated
|
|
41
41
|
* @see https://github.com/webgptorg/promptbook
|
|
42
42
|
*/
|
|
43
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
43
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-22';
|
|
44
44
|
/**
|
|
45
45
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
46
46
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -20584,8 +20584,9 @@ function createTimeoutSystemMessage(extraInstructions) {
|
|
|
20584
20584
|
return spaceTrim$1((block) => `
|
|
20585
20585
|
Timeout scheduling:
|
|
20586
20586
|
- Use "set_timeout" to wake this same chat thread in the future.
|
|
20587
|
-
- Use "list_timeouts" to review
|
|
20588
|
-
- "cancel_timeout" accepts
|
|
20587
|
+
- Use "list_timeouts" to review timeout ids/details across all chats for the same user+agent scope.
|
|
20588
|
+
- "cancel_timeout" accepts either one timeout id or \`allActive: true\` to cancel all active timeouts in this same user+agent scope.
|
|
20589
|
+
- Use "update_timeout" to pause/resume, edit next run, edit recurrence, or update timeout payload details.
|
|
20589
20590
|
- 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\`.
|
|
20590
20591
|
- Do not claim a timer was set or cancelled unless the tool confirms it.
|
|
20591
20592
|
${block(extraInstructions)}
|
|
@@ -20712,9 +20713,18 @@ const parseTimeoutToolArgs = {
|
|
|
20712
20713
|
*/
|
|
20713
20714
|
cancel(args) {
|
|
20714
20715
|
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
20716
|
+
const allActive = args.allActive === true;
|
|
20717
|
+
if (timeoutId && allActive) {
|
|
20718
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20719
|
+
Timeout cancellation must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
20720
|
+
`));
|
|
20721
|
+
}
|
|
20722
|
+
if (allActive) {
|
|
20723
|
+
return { allActive: true };
|
|
20724
|
+
}
|
|
20715
20725
|
if (!timeoutId) {
|
|
20716
20726
|
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20717
|
-
Timeout \`timeoutId\` is required
|
|
20727
|
+
Timeout \`timeoutId\` is required unless you pass \`allActive: true\`.
|
|
20718
20728
|
`));
|
|
20719
20729
|
}
|
|
20720
20730
|
return { timeoutId };
|
|
@@ -20744,6 +20754,111 @@ const parseTimeoutToolArgs = {
|
|
|
20744
20754
|
limit: parsedLimit,
|
|
20745
20755
|
};
|
|
20746
20756
|
},
|
|
20757
|
+
/**
|
|
20758
|
+
* Parses `update_timeout` input.
|
|
20759
|
+
*/
|
|
20760
|
+
update(args) {
|
|
20761
|
+
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
20762
|
+
const allActive = args.allActive === true;
|
|
20763
|
+
if (timeoutId && allActive) {
|
|
20764
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20765
|
+
Timeout update must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
20766
|
+
`));
|
|
20767
|
+
}
|
|
20768
|
+
if (!timeoutId && !allActive) {
|
|
20769
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20770
|
+
Timeout update requires one \`timeoutId\` or \`allActive: true\`.
|
|
20771
|
+
`));
|
|
20772
|
+
}
|
|
20773
|
+
const patch = {};
|
|
20774
|
+
if (typeof args.dueAt === 'string' && args.dueAt.trim().length > 0) {
|
|
20775
|
+
const normalizedDueAt = args.dueAt.trim();
|
|
20776
|
+
const dueAtTimestamp = Date.parse(normalizedDueAt);
|
|
20777
|
+
if (!Number.isFinite(dueAtTimestamp)) {
|
|
20778
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20779
|
+
Timeout \`dueAt\` must be one valid ISO timestamp.
|
|
20780
|
+
`));
|
|
20781
|
+
}
|
|
20782
|
+
patch.dueAt = new Date(dueAtTimestamp).toISOString();
|
|
20783
|
+
}
|
|
20784
|
+
if (typeof args.extendByMs === 'number') {
|
|
20785
|
+
if (!Number.isFinite(args.extendByMs) || args.extendByMs <= 0) {
|
|
20786
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20787
|
+
Timeout \`extendByMs\` must be a positive number of milliseconds.
|
|
20788
|
+
`));
|
|
20789
|
+
}
|
|
20790
|
+
patch.extendByMs = Math.floor(args.extendByMs);
|
|
20791
|
+
}
|
|
20792
|
+
if (patch.dueAt !== undefined && patch.extendByMs !== undefined) {
|
|
20793
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20794
|
+
Timeout update cannot include both \`dueAt\` and \`extendByMs\`.
|
|
20795
|
+
`));
|
|
20796
|
+
}
|
|
20797
|
+
if (args.recurrenceIntervalMs === null) {
|
|
20798
|
+
patch.recurrenceIntervalMs = null;
|
|
20799
|
+
}
|
|
20800
|
+
else if (typeof args.recurrenceIntervalMs === 'number') {
|
|
20801
|
+
if (!Number.isFinite(args.recurrenceIntervalMs) || args.recurrenceIntervalMs <= 0) {
|
|
20802
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20803
|
+
Timeout \`recurrenceIntervalMs\` must be a positive number of milliseconds or \`null\`.
|
|
20804
|
+
`));
|
|
20805
|
+
}
|
|
20806
|
+
patch.recurrenceIntervalMs = Math.floor(args.recurrenceIntervalMs);
|
|
20807
|
+
}
|
|
20808
|
+
if (args.message === null) {
|
|
20809
|
+
patch.message = null;
|
|
20810
|
+
}
|
|
20811
|
+
else if (typeof args.message === 'string') {
|
|
20812
|
+
const normalizedMessage = args.message.trim();
|
|
20813
|
+
patch.message = normalizedMessage.length > 0 ? normalizedMessage : null;
|
|
20814
|
+
}
|
|
20815
|
+
if (args.parameters !== undefined) {
|
|
20816
|
+
if (!args.parameters || typeof args.parameters !== 'object' || Array.isArray(args.parameters)) {
|
|
20817
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20818
|
+
Timeout \`parameters\` must be one JSON object.
|
|
20819
|
+
`));
|
|
20820
|
+
}
|
|
20821
|
+
patch.parameters = args.parameters;
|
|
20822
|
+
}
|
|
20823
|
+
if (typeof args.paused === 'boolean') {
|
|
20824
|
+
patch.paused = args.paused;
|
|
20825
|
+
}
|
|
20826
|
+
if (allActive) {
|
|
20827
|
+
if (patch.paused === undefined) {
|
|
20828
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20829
|
+
Bulk timeout update with \`allActive: true\` requires \`paused\` to be explicitly set.
|
|
20830
|
+
`));
|
|
20831
|
+
}
|
|
20832
|
+
const hasSingleOnlyPatch = patch.dueAt !== undefined ||
|
|
20833
|
+
patch.extendByMs !== undefined ||
|
|
20834
|
+
patch.recurrenceIntervalMs !== undefined ||
|
|
20835
|
+
patch.message !== undefined ||
|
|
20836
|
+
patch.parameters !== undefined;
|
|
20837
|
+
if (hasSingleOnlyPatch) {
|
|
20838
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20839
|
+
Bulk timeout update only supports the \`paused\` field.
|
|
20840
|
+
`));
|
|
20841
|
+
}
|
|
20842
|
+
return {
|
|
20843
|
+
allActive: true,
|
|
20844
|
+
paused: patch.paused,
|
|
20845
|
+
};
|
|
20846
|
+
}
|
|
20847
|
+
if (!timeoutId) {
|
|
20848
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20849
|
+
Timeout \`timeoutId\` is required for single-timeout updates.
|
|
20850
|
+
`));
|
|
20851
|
+
}
|
|
20852
|
+
if (Object.keys(patch).length === 0) {
|
|
20853
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20854
|
+
Timeout update must include at least one editable field.
|
|
20855
|
+
`));
|
|
20856
|
+
}
|
|
20857
|
+
return {
|
|
20858
|
+
timeoutId,
|
|
20859
|
+
patch,
|
|
20860
|
+
};
|
|
20861
|
+
},
|
|
20747
20862
|
};
|
|
20748
20863
|
|
|
20749
20864
|
/**
|
|
@@ -20755,6 +20870,7 @@ const TimeoutToolNames = {
|
|
|
20755
20870
|
set: 'set_timeout',
|
|
20756
20871
|
cancel: 'cancel_timeout',
|
|
20757
20872
|
list: 'list_timeouts',
|
|
20873
|
+
update: 'update_timeout',
|
|
20758
20874
|
};
|
|
20759
20875
|
|
|
20760
20876
|
/**
|
|
@@ -20787,6 +20903,18 @@ function normalizePromptParameters(rawParameters) {
|
|
|
20787
20903
|
return Object.fromEntries(normalizedEntries);
|
|
20788
20904
|
}
|
|
20789
20905
|
|
|
20906
|
+
/**
|
|
20907
|
+
* Maximum number of timeout rows rendered into the assistant-visible `list_timeouts` message.
|
|
20908
|
+
*
|
|
20909
|
+
* @private internal USE TIMEOUT constant
|
|
20910
|
+
*/
|
|
20911
|
+
const MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS = 20;
|
|
20912
|
+
/**
|
|
20913
|
+
* Maximum number of timeout ids rendered in bulk-action summaries.
|
|
20914
|
+
*
|
|
20915
|
+
* @private internal USE TIMEOUT constant
|
|
20916
|
+
*/
|
|
20917
|
+
const MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS = 10;
|
|
20790
20918
|
/**
|
|
20791
20919
|
* Gets `USE TIMEOUT` tool function implementations.
|
|
20792
20920
|
*
|
|
@@ -20832,6 +20960,23 @@ function createTimeoutToolFunctions() {
|
|
|
20832
20960
|
try {
|
|
20833
20961
|
const parsedArgs = parseTimeoutToolArgs.cancel(args);
|
|
20834
20962
|
const cancelledTimeout = await adapter.cancelTimeout(parsedArgs, runtimeContext);
|
|
20963
|
+
if (cancelledTimeout.status === 'cancelled_all') {
|
|
20964
|
+
const result = {
|
|
20965
|
+
action: 'cancel',
|
|
20966
|
+
status: 'cancelled_all',
|
|
20967
|
+
cancelledCount: cancelledTimeout.cancelledCount || 0,
|
|
20968
|
+
cancelledTimeoutIds: cancelledTimeout.cancelledTimeoutIds || [],
|
|
20969
|
+
hasMore: cancelledTimeout.hasMore,
|
|
20970
|
+
};
|
|
20971
|
+
return createToolExecutionEnvelope({
|
|
20972
|
+
assistantMessage: createBulkCancelAssistantMessage({
|
|
20973
|
+
cancelledCount: result.cancelledCount || 0,
|
|
20974
|
+
cancelledTimeoutIds: result.cancelledTimeoutIds || [],
|
|
20975
|
+
hasMore: result.hasMore,
|
|
20976
|
+
}),
|
|
20977
|
+
toolResult: result,
|
|
20978
|
+
});
|
|
20979
|
+
}
|
|
20835
20980
|
const result = {
|
|
20836
20981
|
action: 'cancel',
|
|
20837
20982
|
status: cancelledTimeout.status,
|
|
@@ -20870,7 +21015,10 @@ function createTimeoutToolFunctions() {
|
|
|
20870
21015
|
total: listedTimeouts.total,
|
|
20871
21016
|
};
|
|
20872
21017
|
return createToolExecutionEnvelope({
|
|
20873
|
-
assistantMessage:
|
|
21018
|
+
assistantMessage: createListedTimeoutsAssistantMessage({
|
|
21019
|
+
total: listedTimeouts.total,
|
|
21020
|
+
items: listedTimeouts.items,
|
|
21021
|
+
}),
|
|
20874
21022
|
toolResult: result,
|
|
20875
21023
|
});
|
|
20876
21024
|
}
|
|
@@ -20883,8 +21031,155 @@ function createTimeoutToolFunctions() {
|
|
|
20883
21031
|
return JSON.stringify(result);
|
|
20884
21032
|
}
|
|
20885
21033
|
},
|
|
21034
|
+
async [TimeoutToolNames.update](args) {
|
|
21035
|
+
const runtimeContext = resolveTimeoutRuntimeContext(args);
|
|
21036
|
+
const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
|
|
21037
|
+
if (!adapter || disabledResult) {
|
|
21038
|
+
return JSON.stringify(disabledResult);
|
|
21039
|
+
}
|
|
21040
|
+
try {
|
|
21041
|
+
const parsedArgs = parseTimeoutToolArgs.update(args);
|
|
21042
|
+
const updatedTimeout = await adapter.updateTimeout(parsedArgs, runtimeContext);
|
|
21043
|
+
if (updatedTimeout.status === 'updated_all') {
|
|
21044
|
+
const result = {
|
|
21045
|
+
action: 'update',
|
|
21046
|
+
status: 'updated_all',
|
|
21047
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
21048
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
21049
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
21050
|
+
hasMore: updatedTimeout.hasMore,
|
|
21051
|
+
};
|
|
21052
|
+
return createToolExecutionEnvelope({
|
|
21053
|
+
assistantMessage: createBulkUpdateAssistantMessage({
|
|
21054
|
+
paused: 'allActive' in parsedArgs && parsedArgs.allActive ? parsedArgs.paused : false,
|
|
21055
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
21056
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
21057
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
21058
|
+
hasMore: updatedTimeout.hasMore,
|
|
21059
|
+
}),
|
|
21060
|
+
toolResult: result,
|
|
21061
|
+
});
|
|
21062
|
+
}
|
|
21063
|
+
if (updatedTimeout.status === 'not_found') {
|
|
21064
|
+
const result = {
|
|
21065
|
+
action: 'update',
|
|
21066
|
+
status: 'not_found',
|
|
21067
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
21068
|
+
};
|
|
21069
|
+
return createToolExecutionEnvelope({
|
|
21070
|
+
assistantMessage: 'The timeout was not found.',
|
|
21071
|
+
toolResult: result,
|
|
21072
|
+
});
|
|
21073
|
+
}
|
|
21074
|
+
if (updatedTimeout.status === 'conflict') {
|
|
21075
|
+
const conflictMessage = updatedTimeout.reason === 'running'
|
|
21076
|
+
? 'Running timeout cannot be edited.'
|
|
21077
|
+
: 'Finished timeout cannot be edited.';
|
|
21078
|
+
const result = {
|
|
21079
|
+
action: 'update',
|
|
21080
|
+
status: 'conflict',
|
|
21081
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
21082
|
+
message: conflictMessage,
|
|
21083
|
+
};
|
|
21084
|
+
return createToolExecutionEnvelope({
|
|
21085
|
+
assistantMessage: conflictMessage,
|
|
21086
|
+
toolResult: result,
|
|
21087
|
+
});
|
|
21088
|
+
}
|
|
21089
|
+
const result = {
|
|
21090
|
+
action: 'update',
|
|
21091
|
+
status: 'updated',
|
|
21092
|
+
timeoutId: updatedTimeout.timeout.timeoutId,
|
|
21093
|
+
dueAt: updatedTimeout.timeout.dueAt,
|
|
21094
|
+
paused: updatedTimeout.timeout.paused,
|
|
21095
|
+
recurrenceIntervalMs: updatedTimeout.timeout.recurrenceIntervalMs,
|
|
21096
|
+
};
|
|
21097
|
+
return createToolExecutionEnvelope({
|
|
21098
|
+
assistantMessage: `Updated timeout ${JSON.stringify(updatedTimeout.timeout.timeoutId)}.`,
|
|
21099
|
+
toolResult: result,
|
|
21100
|
+
});
|
|
21101
|
+
}
|
|
21102
|
+
catch (error) {
|
|
21103
|
+
const result = {
|
|
21104
|
+
action: 'update',
|
|
21105
|
+
status: 'error',
|
|
21106
|
+
message: error instanceof Error ? error.message : String(error),
|
|
21107
|
+
};
|
|
21108
|
+
return JSON.stringify(result);
|
|
21109
|
+
}
|
|
21110
|
+
},
|
|
20886
21111
|
};
|
|
20887
21112
|
}
|
|
21113
|
+
/**
|
|
21114
|
+
* Creates assistant-visible summary for one `list_timeouts` response.
|
|
21115
|
+
*
|
|
21116
|
+
* @private internal utility of USE TIMEOUT
|
|
21117
|
+
*/
|
|
21118
|
+
function createListedTimeoutsAssistantMessage(options) {
|
|
21119
|
+
if (options.total <= 0 || options.items.length === 0) {
|
|
21120
|
+
return 'Found 0 timeouts.';
|
|
21121
|
+
}
|
|
21122
|
+
const visibleItems = options.items.slice(0, MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS);
|
|
21123
|
+
const summaryRows = visibleItems.map((item, index) => `${index + 1}. ${formatTimeoutListRow(item)}`);
|
|
21124
|
+
const hiddenCount = Math.max(0, options.total - visibleItems.length);
|
|
21125
|
+
if (hiddenCount > 0) {
|
|
21126
|
+
summaryRows.push(`...and ${hiddenCount} more.`);
|
|
21127
|
+
}
|
|
21128
|
+
return [`Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:`, ...summaryRows].join('\n');
|
|
21129
|
+
}
|
|
21130
|
+
/**
|
|
21131
|
+
* Formats one timeout row for assistant-visible timeout listings.
|
|
21132
|
+
*
|
|
21133
|
+
* @private internal utility of USE TIMEOUT
|
|
21134
|
+
*/
|
|
21135
|
+
function formatTimeoutListRow(item) {
|
|
21136
|
+
const normalizedMessage = typeof item.message === 'string' ? item.message.trim() : '';
|
|
21137
|
+
const messageSuffix = normalizedMessage ? ` | message ${JSON.stringify(normalizedMessage)}` : '';
|
|
21138
|
+
const recurrenceSuffix = typeof item.recurrenceIntervalMs === 'number' && item.recurrenceIntervalMs > 0
|
|
21139
|
+
? ` | recurrence ${item.recurrenceIntervalMs}ms`
|
|
21140
|
+
: '';
|
|
21141
|
+
const pausedSuffix = item.paused ? ' (paused)' : '';
|
|
21142
|
+
return `${item.timeoutId} | ${item.status}${pausedSuffix} | chat ${item.chatId} | due ${item.dueAt}${recurrenceSuffix}${messageSuffix}`;
|
|
21143
|
+
}
|
|
21144
|
+
/**
|
|
21145
|
+
* Creates assistant-visible summary for bulk timeout cancellation.
|
|
21146
|
+
*
|
|
21147
|
+
* @private internal utility of USE TIMEOUT
|
|
21148
|
+
*/
|
|
21149
|
+
function createBulkCancelAssistantMessage(options) {
|
|
21150
|
+
if (options.cancelledCount <= 0) {
|
|
21151
|
+
return 'No active timeouts were found to cancel.';
|
|
21152
|
+
}
|
|
21153
|
+
const visibleTimeoutIds = options.cancelledTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
21154
|
+
const hiddenIdsCount = Math.max(0, options.cancelledTimeoutIds.length - visibleTimeoutIds.length);
|
|
21155
|
+
const hasMoreSuffix = options.hasMore ? ' Additional active timeouts may still exist.' : '';
|
|
21156
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
21157
|
+
? ` Cancelled ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
21158
|
+
: '';
|
|
21159
|
+
return `Cancelled ${options.cancelledCount} active ${options.cancelledCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${hasMoreSuffix}`;
|
|
21160
|
+
}
|
|
21161
|
+
/**
|
|
21162
|
+
* Creates assistant-visible summary for bulk timeout pause/resume updates.
|
|
21163
|
+
*
|
|
21164
|
+
* @private internal utility of USE TIMEOUT
|
|
21165
|
+
*/
|
|
21166
|
+
function createBulkUpdateAssistantMessage(options) {
|
|
21167
|
+
if (options.matchedCount <= 0) {
|
|
21168
|
+
return options.paused
|
|
21169
|
+
? 'No active queued timeouts were found to pause.'
|
|
21170
|
+
: 'No paused queued timeouts were found to resume.';
|
|
21171
|
+
}
|
|
21172
|
+
const verb = options.paused ? 'Paused' : 'Resumed';
|
|
21173
|
+
const visibleTimeoutIds = options.updatedTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
21174
|
+
const hiddenIdsCount = Math.max(0, options.updatedTimeoutIds.length - visibleTimeoutIds.length);
|
|
21175
|
+
const skippedCount = Math.max(0, options.matchedCount - options.updatedCount);
|
|
21176
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
21177
|
+
? ` Updated ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
21178
|
+
: '';
|
|
21179
|
+
const skippedSuffix = skippedCount > 0 ? ` Skipped ${skippedCount} due to concurrent changes.` : '';
|
|
21180
|
+
const hasMoreSuffix = options.hasMore ? ' Additional matching timeouts may still exist.' : '';
|
|
21181
|
+
return `${verb} ${options.updatedCount} ${options.updatedCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${skippedSuffix}${hasMoreSuffix}`;
|
|
21182
|
+
}
|
|
20888
21183
|
|
|
20889
21184
|
/**
|
|
20890
21185
|
* Adds `USE TIMEOUT` tool definitions while preserving already registered tools.
|
|
@@ -20916,7 +21211,7 @@ function createTimeoutTools(existingTools = []) {
|
|
|
20916
21211
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
|
|
20917
21212
|
tools.push({
|
|
20918
21213
|
name: TimeoutToolNames.cancel,
|
|
20919
|
-
description: 'Cancel one
|
|
21214
|
+
description: 'Cancel one timeout by id or cancel all active timeouts across chats for the same user+agent scope.',
|
|
20920
21215
|
parameters: {
|
|
20921
21216
|
type: 'object',
|
|
20922
21217
|
properties: {
|
|
@@ -20924,15 +21219,18 @@ function createTimeoutTools(existingTools = []) {
|
|
|
20924
21219
|
type: 'string',
|
|
20925
21220
|
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
|
|
20926
21221
|
},
|
|
21222
|
+
allActive: {
|
|
21223
|
+
type: 'boolean',
|
|
21224
|
+
description: 'When true, cancel all currently active timeouts across chats in this user+agent scope.',
|
|
21225
|
+
},
|
|
20927
21226
|
},
|
|
20928
|
-
required: ['timeoutId'],
|
|
20929
21227
|
},
|
|
20930
21228
|
});
|
|
20931
21229
|
}
|
|
20932
21230
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
|
|
20933
21231
|
tools.push({
|
|
20934
21232
|
name: TimeoutToolNames.list,
|
|
20935
|
-
description: 'List
|
|
21233
|
+
description: 'List timeout details across all chats for this same user+agent scope so they can be reviewed and managed.',
|
|
20936
21234
|
parameters: {
|
|
20937
21235
|
type: 'object',
|
|
20938
21236
|
properties: {
|
|
@@ -20948,6 +21246,49 @@ function createTimeoutTools(existingTools = []) {
|
|
|
20948
21246
|
},
|
|
20949
21247
|
});
|
|
20950
21248
|
}
|
|
21249
|
+
if (!tools.some((tool) => tool.name === TimeoutToolNames.update)) {
|
|
21250
|
+
tools.push({
|
|
21251
|
+
name: TimeoutToolNames.update,
|
|
21252
|
+
description: 'Update one timeout (pause/resume, next run, recurrence, payload) or pause/resume all active queued timeouts across chats.',
|
|
21253
|
+
parameters: {
|
|
21254
|
+
type: 'object',
|
|
21255
|
+
properties: {
|
|
21256
|
+
timeoutId: {
|
|
21257
|
+
type: 'string',
|
|
21258
|
+
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts` for one timeout update.',
|
|
21259
|
+
},
|
|
21260
|
+
allActive: {
|
|
21261
|
+
type: 'boolean',
|
|
21262
|
+
description: 'When true, run one bulk pause/resume across all active queued timeouts in this same user+agent scope.',
|
|
21263
|
+
},
|
|
21264
|
+
paused: {
|
|
21265
|
+
type: 'boolean',
|
|
21266
|
+
description: 'Pause (`true`) or resume (`false`) one timeout; with `allActive: true` this pauses/resumes all active queued timeouts.',
|
|
21267
|
+
},
|
|
21268
|
+
dueAt: {
|
|
21269
|
+
type: 'string',
|
|
21270
|
+
description: 'Set the next run timestamp (ISO string). Cannot be used with `extendByMs`.',
|
|
21271
|
+
},
|
|
21272
|
+
extendByMs: {
|
|
21273
|
+
type: 'number',
|
|
21274
|
+
description: 'Move next run by this many milliseconds. Cannot be used with `dueAt`.',
|
|
21275
|
+
},
|
|
21276
|
+
recurrenceIntervalMs: {
|
|
21277
|
+
type: 'number',
|
|
21278
|
+
description: 'Set recurrence interval in milliseconds; pass `null` to disable recurrence.',
|
|
21279
|
+
},
|
|
21280
|
+
message: {
|
|
21281
|
+
type: 'string',
|
|
21282
|
+
description: 'Set wake-up message text for this timeout; pass empty string to clear.',
|
|
21283
|
+
},
|
|
21284
|
+
parameters: {
|
|
21285
|
+
type: 'object',
|
|
21286
|
+
description: 'Replace stored JSON parameters passed back when timeout fires.',
|
|
21287
|
+
},
|
|
21288
|
+
},
|
|
21289
|
+
},
|
|
21290
|
+
});
|
|
21291
|
+
}
|
|
20951
21292
|
return tools;
|
|
20952
21293
|
}
|
|
20953
21294
|
|
|
@@ -20969,7 +21310,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
20969
21310
|
* Short one-line description of `USE TIMEOUT`.
|
|
20970
21311
|
*/
|
|
20971
21312
|
get description() {
|
|
20972
|
-
return 'Enable timeout wake-ups plus scoped timeout listing
|
|
21313
|
+
return 'Enable timeout wake-ups plus scoped timeout listing, updates, and cancellation across chats.';
|
|
20973
21314
|
}
|
|
20974
21315
|
/**
|
|
20975
21316
|
* Icon for this commitment.
|
|
@@ -20991,8 +21332,9 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
20991
21332
|
- The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
|
|
20992
21333
|
- The tool returns immediately while the timeout is stored and executed by the runtime later.
|
|
20993
21334
|
- The wake-up arrives as a new user-like timeout message in the same conversation.
|
|
20994
|
-
- The agent can inspect known
|
|
20995
|
-
- The agent can cancel
|
|
21335
|
+
- The agent can inspect known timeout details via \`list_timeouts\`.
|
|
21336
|
+
- The agent can cancel one timeout by \`timeoutId\` or cancel all active timeouts via \`cancel_timeout\`.
|
|
21337
|
+
- The agent can pause/resume and edit timeout details via \`update_timeout\`.
|
|
20996
21338
|
- Commitment content is treated as optional timeout policy instructions.
|
|
20997
21339
|
|
|
20998
21340
|
## Examples
|
|
@@ -21022,6 +21364,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21022
21364
|
[TimeoutToolNames.set]: 'Set timer',
|
|
21023
21365
|
[TimeoutToolNames.cancel]: 'Cancel timer',
|
|
21024
21366
|
[TimeoutToolNames.list]: 'List timers',
|
|
21367
|
+
[TimeoutToolNames.update]: 'Update timer',
|
|
21025
21368
|
};
|
|
21026
21369
|
}
|
|
21027
21370
|
/**
|