@promptbook/core 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 +1 -1
- 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
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-22';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -19795,8 +19795,9 @@ function createTimeoutSystemMessage(extraInstructions) {
|
|
|
19795
19795
|
return spaceTrim$1((block) => `
|
|
19796
19796
|
Timeout scheduling:
|
|
19797
19797
|
- Use "set_timeout" to wake this same chat thread in the future.
|
|
19798
|
-
- Use "list_timeouts" to review
|
|
19799
|
-
- "cancel_timeout" accepts
|
|
19798
|
+
- Use "list_timeouts" to review timeout ids/details across all chats for the same user+agent scope.
|
|
19799
|
+
- "cancel_timeout" accepts either one timeout id or \`allActive: true\` to cancel all active timeouts in this same user+agent scope.
|
|
19800
|
+
- Use "update_timeout" to pause/resume, edit next run, edit recurrence, or update timeout payload details.
|
|
19800
19801
|
- 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\`.
|
|
19801
19802
|
- Do not claim a timer was set or cancelled unless the tool confirms it.
|
|
19802
19803
|
${block(extraInstructions)}
|
|
@@ -19923,9 +19924,18 @@ const parseTimeoutToolArgs = {
|
|
|
19923
19924
|
*/
|
|
19924
19925
|
cancel(args) {
|
|
19925
19926
|
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
19927
|
+
const allActive = args.allActive === true;
|
|
19928
|
+
if (timeoutId && allActive) {
|
|
19929
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
19930
|
+
Timeout cancellation must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
19931
|
+
`));
|
|
19932
|
+
}
|
|
19933
|
+
if (allActive) {
|
|
19934
|
+
return { allActive: true };
|
|
19935
|
+
}
|
|
19926
19936
|
if (!timeoutId) {
|
|
19927
19937
|
throw new PipelineExecutionError(spaceTrim$1(`
|
|
19928
|
-
Timeout \`timeoutId\` is required
|
|
19938
|
+
Timeout \`timeoutId\` is required unless you pass \`allActive: true\`.
|
|
19929
19939
|
`));
|
|
19930
19940
|
}
|
|
19931
19941
|
return { timeoutId };
|
|
@@ -19955,6 +19965,111 @@ const parseTimeoutToolArgs = {
|
|
|
19955
19965
|
limit: parsedLimit,
|
|
19956
19966
|
};
|
|
19957
19967
|
},
|
|
19968
|
+
/**
|
|
19969
|
+
* Parses `update_timeout` input.
|
|
19970
|
+
*/
|
|
19971
|
+
update(args) {
|
|
19972
|
+
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
19973
|
+
const allActive = args.allActive === true;
|
|
19974
|
+
if (timeoutId && allActive) {
|
|
19975
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
19976
|
+
Timeout update must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
19977
|
+
`));
|
|
19978
|
+
}
|
|
19979
|
+
if (!timeoutId && !allActive) {
|
|
19980
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
19981
|
+
Timeout update requires one \`timeoutId\` or \`allActive: true\`.
|
|
19982
|
+
`));
|
|
19983
|
+
}
|
|
19984
|
+
const patch = {};
|
|
19985
|
+
if (typeof args.dueAt === 'string' && args.dueAt.trim().length > 0) {
|
|
19986
|
+
const normalizedDueAt = args.dueAt.trim();
|
|
19987
|
+
const dueAtTimestamp = Date.parse(normalizedDueAt);
|
|
19988
|
+
if (!Number.isFinite(dueAtTimestamp)) {
|
|
19989
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
19990
|
+
Timeout \`dueAt\` must be one valid ISO timestamp.
|
|
19991
|
+
`));
|
|
19992
|
+
}
|
|
19993
|
+
patch.dueAt = new Date(dueAtTimestamp).toISOString();
|
|
19994
|
+
}
|
|
19995
|
+
if (typeof args.extendByMs === 'number') {
|
|
19996
|
+
if (!Number.isFinite(args.extendByMs) || args.extendByMs <= 0) {
|
|
19997
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
19998
|
+
Timeout \`extendByMs\` must be a positive number of milliseconds.
|
|
19999
|
+
`));
|
|
20000
|
+
}
|
|
20001
|
+
patch.extendByMs = Math.floor(args.extendByMs);
|
|
20002
|
+
}
|
|
20003
|
+
if (patch.dueAt !== undefined && patch.extendByMs !== undefined) {
|
|
20004
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20005
|
+
Timeout update cannot include both \`dueAt\` and \`extendByMs\`.
|
|
20006
|
+
`));
|
|
20007
|
+
}
|
|
20008
|
+
if (args.recurrenceIntervalMs === null) {
|
|
20009
|
+
patch.recurrenceIntervalMs = null;
|
|
20010
|
+
}
|
|
20011
|
+
else if (typeof args.recurrenceIntervalMs === 'number') {
|
|
20012
|
+
if (!Number.isFinite(args.recurrenceIntervalMs) || args.recurrenceIntervalMs <= 0) {
|
|
20013
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20014
|
+
Timeout \`recurrenceIntervalMs\` must be a positive number of milliseconds or \`null\`.
|
|
20015
|
+
`));
|
|
20016
|
+
}
|
|
20017
|
+
patch.recurrenceIntervalMs = Math.floor(args.recurrenceIntervalMs);
|
|
20018
|
+
}
|
|
20019
|
+
if (args.message === null) {
|
|
20020
|
+
patch.message = null;
|
|
20021
|
+
}
|
|
20022
|
+
else if (typeof args.message === 'string') {
|
|
20023
|
+
const normalizedMessage = args.message.trim();
|
|
20024
|
+
patch.message = normalizedMessage.length > 0 ? normalizedMessage : null;
|
|
20025
|
+
}
|
|
20026
|
+
if (args.parameters !== undefined) {
|
|
20027
|
+
if (!args.parameters || typeof args.parameters !== 'object' || Array.isArray(args.parameters)) {
|
|
20028
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20029
|
+
Timeout \`parameters\` must be one JSON object.
|
|
20030
|
+
`));
|
|
20031
|
+
}
|
|
20032
|
+
patch.parameters = args.parameters;
|
|
20033
|
+
}
|
|
20034
|
+
if (typeof args.paused === 'boolean') {
|
|
20035
|
+
patch.paused = args.paused;
|
|
20036
|
+
}
|
|
20037
|
+
if (allActive) {
|
|
20038
|
+
if (patch.paused === undefined) {
|
|
20039
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20040
|
+
Bulk timeout update with \`allActive: true\` requires \`paused\` to be explicitly set.
|
|
20041
|
+
`));
|
|
20042
|
+
}
|
|
20043
|
+
const hasSingleOnlyPatch = patch.dueAt !== undefined ||
|
|
20044
|
+
patch.extendByMs !== undefined ||
|
|
20045
|
+
patch.recurrenceIntervalMs !== undefined ||
|
|
20046
|
+
patch.message !== undefined ||
|
|
20047
|
+
patch.parameters !== undefined;
|
|
20048
|
+
if (hasSingleOnlyPatch) {
|
|
20049
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20050
|
+
Bulk timeout update only supports the \`paused\` field.
|
|
20051
|
+
`));
|
|
20052
|
+
}
|
|
20053
|
+
return {
|
|
20054
|
+
allActive: true,
|
|
20055
|
+
paused: patch.paused,
|
|
20056
|
+
};
|
|
20057
|
+
}
|
|
20058
|
+
if (!timeoutId) {
|
|
20059
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20060
|
+
Timeout \`timeoutId\` is required for single-timeout updates.
|
|
20061
|
+
`));
|
|
20062
|
+
}
|
|
20063
|
+
if (Object.keys(patch).length === 0) {
|
|
20064
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
20065
|
+
Timeout update must include at least one editable field.
|
|
20066
|
+
`));
|
|
20067
|
+
}
|
|
20068
|
+
return {
|
|
20069
|
+
timeoutId,
|
|
20070
|
+
patch,
|
|
20071
|
+
};
|
|
20072
|
+
},
|
|
19958
20073
|
};
|
|
19959
20074
|
|
|
19960
20075
|
/**
|
|
@@ -19966,6 +20081,7 @@ const TimeoutToolNames = {
|
|
|
19966
20081
|
set: 'set_timeout',
|
|
19967
20082
|
cancel: 'cancel_timeout',
|
|
19968
20083
|
list: 'list_timeouts',
|
|
20084
|
+
update: 'update_timeout',
|
|
19969
20085
|
};
|
|
19970
20086
|
|
|
19971
20087
|
/**
|
|
@@ -19998,6 +20114,18 @@ function normalizePromptParameters(rawParameters) {
|
|
|
19998
20114
|
return Object.fromEntries(normalizedEntries);
|
|
19999
20115
|
}
|
|
20000
20116
|
|
|
20117
|
+
/**
|
|
20118
|
+
* Maximum number of timeout rows rendered into the assistant-visible `list_timeouts` message.
|
|
20119
|
+
*
|
|
20120
|
+
* @private internal USE TIMEOUT constant
|
|
20121
|
+
*/
|
|
20122
|
+
const MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS = 20;
|
|
20123
|
+
/**
|
|
20124
|
+
* Maximum number of timeout ids rendered in bulk-action summaries.
|
|
20125
|
+
*
|
|
20126
|
+
* @private internal USE TIMEOUT constant
|
|
20127
|
+
*/
|
|
20128
|
+
const MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS = 10;
|
|
20001
20129
|
/**
|
|
20002
20130
|
* Gets `USE TIMEOUT` tool function implementations.
|
|
20003
20131
|
*
|
|
@@ -20043,6 +20171,23 @@ function createTimeoutToolFunctions() {
|
|
|
20043
20171
|
try {
|
|
20044
20172
|
const parsedArgs = parseTimeoutToolArgs.cancel(args);
|
|
20045
20173
|
const cancelledTimeout = await adapter.cancelTimeout(parsedArgs, runtimeContext);
|
|
20174
|
+
if (cancelledTimeout.status === 'cancelled_all') {
|
|
20175
|
+
const result = {
|
|
20176
|
+
action: 'cancel',
|
|
20177
|
+
status: 'cancelled_all',
|
|
20178
|
+
cancelledCount: cancelledTimeout.cancelledCount || 0,
|
|
20179
|
+
cancelledTimeoutIds: cancelledTimeout.cancelledTimeoutIds || [],
|
|
20180
|
+
hasMore: cancelledTimeout.hasMore,
|
|
20181
|
+
};
|
|
20182
|
+
return createToolExecutionEnvelope({
|
|
20183
|
+
assistantMessage: createBulkCancelAssistantMessage({
|
|
20184
|
+
cancelledCount: result.cancelledCount || 0,
|
|
20185
|
+
cancelledTimeoutIds: result.cancelledTimeoutIds || [],
|
|
20186
|
+
hasMore: result.hasMore,
|
|
20187
|
+
}),
|
|
20188
|
+
toolResult: result,
|
|
20189
|
+
});
|
|
20190
|
+
}
|
|
20046
20191
|
const result = {
|
|
20047
20192
|
action: 'cancel',
|
|
20048
20193
|
status: cancelledTimeout.status,
|
|
@@ -20081,7 +20226,10 @@ function createTimeoutToolFunctions() {
|
|
|
20081
20226
|
total: listedTimeouts.total,
|
|
20082
20227
|
};
|
|
20083
20228
|
return createToolExecutionEnvelope({
|
|
20084
|
-
assistantMessage:
|
|
20229
|
+
assistantMessage: createListedTimeoutsAssistantMessage({
|
|
20230
|
+
total: listedTimeouts.total,
|
|
20231
|
+
items: listedTimeouts.items,
|
|
20232
|
+
}),
|
|
20085
20233
|
toolResult: result,
|
|
20086
20234
|
});
|
|
20087
20235
|
}
|
|
@@ -20094,8 +20242,155 @@ function createTimeoutToolFunctions() {
|
|
|
20094
20242
|
return JSON.stringify(result);
|
|
20095
20243
|
}
|
|
20096
20244
|
},
|
|
20245
|
+
async [TimeoutToolNames.update](args) {
|
|
20246
|
+
const runtimeContext = resolveTimeoutRuntimeContext(args);
|
|
20247
|
+
const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
|
|
20248
|
+
if (!adapter || disabledResult) {
|
|
20249
|
+
return JSON.stringify(disabledResult);
|
|
20250
|
+
}
|
|
20251
|
+
try {
|
|
20252
|
+
const parsedArgs = parseTimeoutToolArgs.update(args);
|
|
20253
|
+
const updatedTimeout = await adapter.updateTimeout(parsedArgs, runtimeContext);
|
|
20254
|
+
if (updatedTimeout.status === 'updated_all') {
|
|
20255
|
+
const result = {
|
|
20256
|
+
action: 'update',
|
|
20257
|
+
status: 'updated_all',
|
|
20258
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
20259
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
20260
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
20261
|
+
hasMore: updatedTimeout.hasMore,
|
|
20262
|
+
};
|
|
20263
|
+
return createToolExecutionEnvelope({
|
|
20264
|
+
assistantMessage: createBulkUpdateAssistantMessage({
|
|
20265
|
+
paused: 'allActive' in parsedArgs && parsedArgs.allActive ? parsedArgs.paused : false,
|
|
20266
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
20267
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
20268
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
20269
|
+
hasMore: updatedTimeout.hasMore,
|
|
20270
|
+
}),
|
|
20271
|
+
toolResult: result,
|
|
20272
|
+
});
|
|
20273
|
+
}
|
|
20274
|
+
if (updatedTimeout.status === 'not_found') {
|
|
20275
|
+
const result = {
|
|
20276
|
+
action: 'update',
|
|
20277
|
+
status: 'not_found',
|
|
20278
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
20279
|
+
};
|
|
20280
|
+
return createToolExecutionEnvelope({
|
|
20281
|
+
assistantMessage: 'The timeout was not found.',
|
|
20282
|
+
toolResult: result,
|
|
20283
|
+
});
|
|
20284
|
+
}
|
|
20285
|
+
if (updatedTimeout.status === 'conflict') {
|
|
20286
|
+
const conflictMessage = updatedTimeout.reason === 'running'
|
|
20287
|
+
? 'Running timeout cannot be edited.'
|
|
20288
|
+
: 'Finished timeout cannot be edited.';
|
|
20289
|
+
const result = {
|
|
20290
|
+
action: 'update',
|
|
20291
|
+
status: 'conflict',
|
|
20292
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
20293
|
+
message: conflictMessage,
|
|
20294
|
+
};
|
|
20295
|
+
return createToolExecutionEnvelope({
|
|
20296
|
+
assistantMessage: conflictMessage,
|
|
20297
|
+
toolResult: result,
|
|
20298
|
+
});
|
|
20299
|
+
}
|
|
20300
|
+
const result = {
|
|
20301
|
+
action: 'update',
|
|
20302
|
+
status: 'updated',
|
|
20303
|
+
timeoutId: updatedTimeout.timeout.timeoutId,
|
|
20304
|
+
dueAt: updatedTimeout.timeout.dueAt,
|
|
20305
|
+
paused: updatedTimeout.timeout.paused,
|
|
20306
|
+
recurrenceIntervalMs: updatedTimeout.timeout.recurrenceIntervalMs,
|
|
20307
|
+
};
|
|
20308
|
+
return createToolExecutionEnvelope({
|
|
20309
|
+
assistantMessage: `Updated timeout ${JSON.stringify(updatedTimeout.timeout.timeoutId)}.`,
|
|
20310
|
+
toolResult: result,
|
|
20311
|
+
});
|
|
20312
|
+
}
|
|
20313
|
+
catch (error) {
|
|
20314
|
+
const result = {
|
|
20315
|
+
action: 'update',
|
|
20316
|
+
status: 'error',
|
|
20317
|
+
message: error instanceof Error ? error.message : String(error),
|
|
20318
|
+
};
|
|
20319
|
+
return JSON.stringify(result);
|
|
20320
|
+
}
|
|
20321
|
+
},
|
|
20097
20322
|
};
|
|
20098
20323
|
}
|
|
20324
|
+
/**
|
|
20325
|
+
* Creates assistant-visible summary for one `list_timeouts` response.
|
|
20326
|
+
*
|
|
20327
|
+
* @private internal utility of USE TIMEOUT
|
|
20328
|
+
*/
|
|
20329
|
+
function createListedTimeoutsAssistantMessage(options) {
|
|
20330
|
+
if (options.total <= 0 || options.items.length === 0) {
|
|
20331
|
+
return 'Found 0 timeouts.';
|
|
20332
|
+
}
|
|
20333
|
+
const visibleItems = options.items.slice(0, MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS);
|
|
20334
|
+
const summaryRows = visibleItems.map((item, index) => `${index + 1}. ${formatTimeoutListRow(item)}`);
|
|
20335
|
+
const hiddenCount = Math.max(0, options.total - visibleItems.length);
|
|
20336
|
+
if (hiddenCount > 0) {
|
|
20337
|
+
summaryRows.push(`...and ${hiddenCount} more.`);
|
|
20338
|
+
}
|
|
20339
|
+
return [`Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:`, ...summaryRows].join('\n');
|
|
20340
|
+
}
|
|
20341
|
+
/**
|
|
20342
|
+
* Formats one timeout row for assistant-visible timeout listings.
|
|
20343
|
+
*
|
|
20344
|
+
* @private internal utility of USE TIMEOUT
|
|
20345
|
+
*/
|
|
20346
|
+
function formatTimeoutListRow(item) {
|
|
20347
|
+
const normalizedMessage = typeof item.message === 'string' ? item.message.trim() : '';
|
|
20348
|
+
const messageSuffix = normalizedMessage ? ` | message ${JSON.stringify(normalizedMessage)}` : '';
|
|
20349
|
+
const recurrenceSuffix = typeof item.recurrenceIntervalMs === 'number' && item.recurrenceIntervalMs > 0
|
|
20350
|
+
? ` | recurrence ${item.recurrenceIntervalMs}ms`
|
|
20351
|
+
: '';
|
|
20352
|
+
const pausedSuffix = item.paused ? ' (paused)' : '';
|
|
20353
|
+
return `${item.timeoutId} | ${item.status}${pausedSuffix} | chat ${item.chatId} | due ${item.dueAt}${recurrenceSuffix}${messageSuffix}`;
|
|
20354
|
+
}
|
|
20355
|
+
/**
|
|
20356
|
+
* Creates assistant-visible summary for bulk timeout cancellation.
|
|
20357
|
+
*
|
|
20358
|
+
* @private internal utility of USE TIMEOUT
|
|
20359
|
+
*/
|
|
20360
|
+
function createBulkCancelAssistantMessage(options) {
|
|
20361
|
+
if (options.cancelledCount <= 0) {
|
|
20362
|
+
return 'No active timeouts were found to cancel.';
|
|
20363
|
+
}
|
|
20364
|
+
const visibleTimeoutIds = options.cancelledTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
20365
|
+
const hiddenIdsCount = Math.max(0, options.cancelledTimeoutIds.length - visibleTimeoutIds.length);
|
|
20366
|
+
const hasMoreSuffix = options.hasMore ? ' Additional active timeouts may still exist.' : '';
|
|
20367
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
20368
|
+
? ` Cancelled ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
20369
|
+
: '';
|
|
20370
|
+
return `Cancelled ${options.cancelledCount} active ${options.cancelledCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${hasMoreSuffix}`;
|
|
20371
|
+
}
|
|
20372
|
+
/**
|
|
20373
|
+
* Creates assistant-visible summary for bulk timeout pause/resume updates.
|
|
20374
|
+
*
|
|
20375
|
+
* @private internal utility of USE TIMEOUT
|
|
20376
|
+
*/
|
|
20377
|
+
function createBulkUpdateAssistantMessage(options) {
|
|
20378
|
+
if (options.matchedCount <= 0) {
|
|
20379
|
+
return options.paused
|
|
20380
|
+
? 'No active queued timeouts were found to pause.'
|
|
20381
|
+
: 'No paused queued timeouts were found to resume.';
|
|
20382
|
+
}
|
|
20383
|
+
const verb = options.paused ? 'Paused' : 'Resumed';
|
|
20384
|
+
const visibleTimeoutIds = options.updatedTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
20385
|
+
const hiddenIdsCount = Math.max(0, options.updatedTimeoutIds.length - visibleTimeoutIds.length);
|
|
20386
|
+
const skippedCount = Math.max(0, options.matchedCount - options.updatedCount);
|
|
20387
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
20388
|
+
? ` Updated ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
20389
|
+
: '';
|
|
20390
|
+
const skippedSuffix = skippedCount > 0 ? ` Skipped ${skippedCount} due to concurrent changes.` : '';
|
|
20391
|
+
const hasMoreSuffix = options.hasMore ? ' Additional matching timeouts may still exist.' : '';
|
|
20392
|
+
return `${verb} ${options.updatedCount} ${options.updatedCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${skippedSuffix}${hasMoreSuffix}`;
|
|
20393
|
+
}
|
|
20099
20394
|
|
|
20100
20395
|
/**
|
|
20101
20396
|
* Adds `USE TIMEOUT` tool definitions while preserving already registered tools.
|
|
@@ -20127,7 +20422,7 @@ function createTimeoutTools(existingTools = []) {
|
|
|
20127
20422
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
|
|
20128
20423
|
tools.push({
|
|
20129
20424
|
name: TimeoutToolNames.cancel,
|
|
20130
|
-
description: 'Cancel one
|
|
20425
|
+
description: 'Cancel one timeout by id or cancel all active timeouts across chats for the same user+agent scope.',
|
|
20131
20426
|
parameters: {
|
|
20132
20427
|
type: 'object',
|
|
20133
20428
|
properties: {
|
|
@@ -20135,15 +20430,18 @@ function createTimeoutTools(existingTools = []) {
|
|
|
20135
20430
|
type: 'string',
|
|
20136
20431
|
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
|
|
20137
20432
|
},
|
|
20433
|
+
allActive: {
|
|
20434
|
+
type: 'boolean',
|
|
20435
|
+
description: 'When true, cancel all currently active timeouts across chats in this user+agent scope.',
|
|
20436
|
+
},
|
|
20138
20437
|
},
|
|
20139
|
-
required: ['timeoutId'],
|
|
20140
20438
|
},
|
|
20141
20439
|
});
|
|
20142
20440
|
}
|
|
20143
20441
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
|
|
20144
20442
|
tools.push({
|
|
20145
20443
|
name: TimeoutToolNames.list,
|
|
20146
|
-
description: 'List
|
|
20444
|
+
description: 'List timeout details across all chats for this same user+agent scope so they can be reviewed and managed.',
|
|
20147
20445
|
parameters: {
|
|
20148
20446
|
type: 'object',
|
|
20149
20447
|
properties: {
|
|
@@ -20159,6 +20457,49 @@ function createTimeoutTools(existingTools = []) {
|
|
|
20159
20457
|
},
|
|
20160
20458
|
});
|
|
20161
20459
|
}
|
|
20460
|
+
if (!tools.some((tool) => tool.name === TimeoutToolNames.update)) {
|
|
20461
|
+
tools.push({
|
|
20462
|
+
name: TimeoutToolNames.update,
|
|
20463
|
+
description: 'Update one timeout (pause/resume, next run, recurrence, payload) or pause/resume all active queued timeouts across chats.',
|
|
20464
|
+
parameters: {
|
|
20465
|
+
type: 'object',
|
|
20466
|
+
properties: {
|
|
20467
|
+
timeoutId: {
|
|
20468
|
+
type: 'string',
|
|
20469
|
+
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts` for one timeout update.',
|
|
20470
|
+
},
|
|
20471
|
+
allActive: {
|
|
20472
|
+
type: 'boolean',
|
|
20473
|
+
description: 'When true, run one bulk pause/resume across all active queued timeouts in this same user+agent scope.',
|
|
20474
|
+
},
|
|
20475
|
+
paused: {
|
|
20476
|
+
type: 'boolean',
|
|
20477
|
+
description: 'Pause (`true`) or resume (`false`) one timeout; with `allActive: true` this pauses/resumes all active queued timeouts.',
|
|
20478
|
+
},
|
|
20479
|
+
dueAt: {
|
|
20480
|
+
type: 'string',
|
|
20481
|
+
description: 'Set the next run timestamp (ISO string). Cannot be used with `extendByMs`.',
|
|
20482
|
+
},
|
|
20483
|
+
extendByMs: {
|
|
20484
|
+
type: 'number',
|
|
20485
|
+
description: 'Move next run by this many milliseconds. Cannot be used with `dueAt`.',
|
|
20486
|
+
},
|
|
20487
|
+
recurrenceIntervalMs: {
|
|
20488
|
+
type: 'number',
|
|
20489
|
+
description: 'Set recurrence interval in milliseconds; pass `null` to disable recurrence.',
|
|
20490
|
+
},
|
|
20491
|
+
message: {
|
|
20492
|
+
type: 'string',
|
|
20493
|
+
description: 'Set wake-up message text for this timeout; pass empty string to clear.',
|
|
20494
|
+
},
|
|
20495
|
+
parameters: {
|
|
20496
|
+
type: 'object',
|
|
20497
|
+
description: 'Replace stored JSON parameters passed back when timeout fires.',
|
|
20498
|
+
},
|
|
20499
|
+
},
|
|
20500
|
+
},
|
|
20501
|
+
});
|
|
20502
|
+
}
|
|
20162
20503
|
return tools;
|
|
20163
20504
|
}
|
|
20164
20505
|
|
|
@@ -20180,7 +20521,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
20180
20521
|
* Short one-line description of `USE TIMEOUT`.
|
|
20181
20522
|
*/
|
|
20182
20523
|
get description() {
|
|
20183
|
-
return 'Enable timeout wake-ups plus scoped timeout listing
|
|
20524
|
+
return 'Enable timeout wake-ups plus scoped timeout listing, updates, and cancellation across chats.';
|
|
20184
20525
|
}
|
|
20185
20526
|
/**
|
|
20186
20527
|
* Icon for this commitment.
|
|
@@ -20202,8 +20543,9 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
20202
20543
|
- The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
|
|
20203
20544
|
- The tool returns immediately while the timeout is stored and executed by the runtime later.
|
|
20204
20545
|
- The wake-up arrives as a new user-like timeout message in the same conversation.
|
|
20205
|
-
- The agent can inspect known
|
|
20206
|
-
- The agent can cancel
|
|
20546
|
+
- The agent can inspect known timeout details via \`list_timeouts\`.
|
|
20547
|
+
- The agent can cancel one timeout by \`timeoutId\` or cancel all active timeouts via \`cancel_timeout\`.
|
|
20548
|
+
- The agent can pause/resume and edit timeout details via \`update_timeout\`.
|
|
20207
20549
|
- Commitment content is treated as optional timeout policy instructions.
|
|
20208
20550
|
|
|
20209
20551
|
## Examples
|
|
@@ -20233,6 +20575,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
20233
20575
|
[TimeoutToolNames.set]: 'Set timer',
|
|
20234
20576
|
[TimeoutToolNames.cancel]: 'Cancel timer',
|
|
20235
20577
|
[TimeoutToolNames.list]: 'List timers',
|
|
20578
|
+
[TimeoutToolNames.update]: 'Update timer',
|
|
20236
20579
|
};
|
|
20237
20580
|
}
|
|
20238
20581
|
/**
|