@promptbook/cli 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
|
@@ -57,7 +57,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
57
57
|
* @generated
|
|
58
58
|
* @see https://github.com/webgptorg/promptbook
|
|
59
59
|
*/
|
|
60
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
60
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-22';
|
|
61
61
|
/**
|
|
62
62
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
63
63
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -26033,8 +26033,9 @@ function createTimeoutSystemMessage(extraInstructions) {
|
|
|
26033
26033
|
return spaceTrim$1((block) => `
|
|
26034
26034
|
Timeout scheduling:
|
|
26035
26035
|
- Use "set_timeout" to wake this same chat thread in the future.
|
|
26036
|
-
- Use "list_timeouts" to review
|
|
26037
|
-
- "cancel_timeout" accepts
|
|
26036
|
+
- Use "list_timeouts" to review timeout ids/details across all chats for the same user+agent scope.
|
|
26037
|
+
- "cancel_timeout" accepts either one timeout id or \`allActive: true\` to cancel all active timeouts in this same user+agent scope.
|
|
26038
|
+
- Use "update_timeout" to pause/resume, edit next run, edit recurrence, or update timeout payload details.
|
|
26038
26039
|
- 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\`.
|
|
26039
26040
|
- Do not claim a timer was set or cancelled unless the tool confirms it.
|
|
26040
26041
|
${block(extraInstructions)}
|
|
@@ -26161,9 +26162,18 @@ const parseTimeoutToolArgs = {
|
|
|
26161
26162
|
*/
|
|
26162
26163
|
cancel(args) {
|
|
26163
26164
|
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
26165
|
+
const allActive = args.allActive === true;
|
|
26166
|
+
if (timeoutId && allActive) {
|
|
26167
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26168
|
+
Timeout cancellation must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
26169
|
+
`));
|
|
26170
|
+
}
|
|
26171
|
+
if (allActive) {
|
|
26172
|
+
return { allActive: true };
|
|
26173
|
+
}
|
|
26164
26174
|
if (!timeoutId) {
|
|
26165
26175
|
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26166
|
-
Timeout \`timeoutId\` is required
|
|
26176
|
+
Timeout \`timeoutId\` is required unless you pass \`allActive: true\`.
|
|
26167
26177
|
`));
|
|
26168
26178
|
}
|
|
26169
26179
|
return { timeoutId };
|
|
@@ -26193,6 +26203,111 @@ const parseTimeoutToolArgs = {
|
|
|
26193
26203
|
limit: parsedLimit,
|
|
26194
26204
|
};
|
|
26195
26205
|
},
|
|
26206
|
+
/**
|
|
26207
|
+
* Parses `update_timeout` input.
|
|
26208
|
+
*/
|
|
26209
|
+
update(args) {
|
|
26210
|
+
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
26211
|
+
const allActive = args.allActive === true;
|
|
26212
|
+
if (timeoutId && allActive) {
|
|
26213
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26214
|
+
Timeout update must target either one \`timeoutId\` or \`allActive: true\`, not both.
|
|
26215
|
+
`));
|
|
26216
|
+
}
|
|
26217
|
+
if (!timeoutId && !allActive) {
|
|
26218
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26219
|
+
Timeout update requires one \`timeoutId\` or \`allActive: true\`.
|
|
26220
|
+
`));
|
|
26221
|
+
}
|
|
26222
|
+
const patch = {};
|
|
26223
|
+
if (typeof args.dueAt === 'string' && args.dueAt.trim().length > 0) {
|
|
26224
|
+
const normalizedDueAt = args.dueAt.trim();
|
|
26225
|
+
const dueAtTimestamp = Date.parse(normalizedDueAt);
|
|
26226
|
+
if (!Number.isFinite(dueAtTimestamp)) {
|
|
26227
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26228
|
+
Timeout \`dueAt\` must be one valid ISO timestamp.
|
|
26229
|
+
`));
|
|
26230
|
+
}
|
|
26231
|
+
patch.dueAt = new Date(dueAtTimestamp).toISOString();
|
|
26232
|
+
}
|
|
26233
|
+
if (typeof args.extendByMs === 'number') {
|
|
26234
|
+
if (!Number.isFinite(args.extendByMs) || args.extendByMs <= 0) {
|
|
26235
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26236
|
+
Timeout \`extendByMs\` must be a positive number of milliseconds.
|
|
26237
|
+
`));
|
|
26238
|
+
}
|
|
26239
|
+
patch.extendByMs = Math.floor(args.extendByMs);
|
|
26240
|
+
}
|
|
26241
|
+
if (patch.dueAt !== undefined && patch.extendByMs !== undefined) {
|
|
26242
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26243
|
+
Timeout update cannot include both \`dueAt\` and \`extendByMs\`.
|
|
26244
|
+
`));
|
|
26245
|
+
}
|
|
26246
|
+
if (args.recurrenceIntervalMs === null) {
|
|
26247
|
+
patch.recurrenceIntervalMs = null;
|
|
26248
|
+
}
|
|
26249
|
+
else if (typeof args.recurrenceIntervalMs === 'number') {
|
|
26250
|
+
if (!Number.isFinite(args.recurrenceIntervalMs) || args.recurrenceIntervalMs <= 0) {
|
|
26251
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26252
|
+
Timeout \`recurrenceIntervalMs\` must be a positive number of milliseconds or \`null\`.
|
|
26253
|
+
`));
|
|
26254
|
+
}
|
|
26255
|
+
patch.recurrenceIntervalMs = Math.floor(args.recurrenceIntervalMs);
|
|
26256
|
+
}
|
|
26257
|
+
if (args.message === null) {
|
|
26258
|
+
patch.message = null;
|
|
26259
|
+
}
|
|
26260
|
+
else if (typeof args.message === 'string') {
|
|
26261
|
+
const normalizedMessage = args.message.trim();
|
|
26262
|
+
patch.message = normalizedMessage.length > 0 ? normalizedMessage : null;
|
|
26263
|
+
}
|
|
26264
|
+
if (args.parameters !== undefined) {
|
|
26265
|
+
if (!args.parameters || typeof args.parameters !== 'object' || Array.isArray(args.parameters)) {
|
|
26266
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26267
|
+
Timeout \`parameters\` must be one JSON object.
|
|
26268
|
+
`));
|
|
26269
|
+
}
|
|
26270
|
+
patch.parameters = args.parameters;
|
|
26271
|
+
}
|
|
26272
|
+
if (typeof args.paused === 'boolean') {
|
|
26273
|
+
patch.paused = args.paused;
|
|
26274
|
+
}
|
|
26275
|
+
if (allActive) {
|
|
26276
|
+
if (patch.paused === undefined) {
|
|
26277
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26278
|
+
Bulk timeout update with \`allActive: true\` requires \`paused\` to be explicitly set.
|
|
26279
|
+
`));
|
|
26280
|
+
}
|
|
26281
|
+
const hasSingleOnlyPatch = patch.dueAt !== undefined ||
|
|
26282
|
+
patch.extendByMs !== undefined ||
|
|
26283
|
+
patch.recurrenceIntervalMs !== undefined ||
|
|
26284
|
+
patch.message !== undefined ||
|
|
26285
|
+
patch.parameters !== undefined;
|
|
26286
|
+
if (hasSingleOnlyPatch) {
|
|
26287
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26288
|
+
Bulk timeout update only supports the \`paused\` field.
|
|
26289
|
+
`));
|
|
26290
|
+
}
|
|
26291
|
+
return {
|
|
26292
|
+
allActive: true,
|
|
26293
|
+
paused: patch.paused,
|
|
26294
|
+
};
|
|
26295
|
+
}
|
|
26296
|
+
if (!timeoutId) {
|
|
26297
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26298
|
+
Timeout \`timeoutId\` is required for single-timeout updates.
|
|
26299
|
+
`));
|
|
26300
|
+
}
|
|
26301
|
+
if (Object.keys(patch).length === 0) {
|
|
26302
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
26303
|
+
Timeout update must include at least one editable field.
|
|
26304
|
+
`));
|
|
26305
|
+
}
|
|
26306
|
+
return {
|
|
26307
|
+
timeoutId,
|
|
26308
|
+
patch,
|
|
26309
|
+
};
|
|
26310
|
+
},
|
|
26196
26311
|
};
|
|
26197
26312
|
|
|
26198
26313
|
/**
|
|
@@ -26204,6 +26319,7 @@ const TimeoutToolNames = {
|
|
|
26204
26319
|
set: 'set_timeout',
|
|
26205
26320
|
cancel: 'cancel_timeout',
|
|
26206
26321
|
list: 'list_timeouts',
|
|
26322
|
+
update: 'update_timeout',
|
|
26207
26323
|
};
|
|
26208
26324
|
|
|
26209
26325
|
/**
|
|
@@ -26236,6 +26352,18 @@ function normalizePromptParameters(rawParameters) {
|
|
|
26236
26352
|
return Object.fromEntries(normalizedEntries);
|
|
26237
26353
|
}
|
|
26238
26354
|
|
|
26355
|
+
/**
|
|
26356
|
+
* Maximum number of timeout rows rendered into the assistant-visible `list_timeouts` message.
|
|
26357
|
+
*
|
|
26358
|
+
* @private internal USE TIMEOUT constant
|
|
26359
|
+
*/
|
|
26360
|
+
const MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS = 20;
|
|
26361
|
+
/**
|
|
26362
|
+
* Maximum number of timeout ids rendered in bulk-action summaries.
|
|
26363
|
+
*
|
|
26364
|
+
* @private internal USE TIMEOUT constant
|
|
26365
|
+
*/
|
|
26366
|
+
const MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS = 10;
|
|
26239
26367
|
/**
|
|
26240
26368
|
* Gets `USE TIMEOUT` tool function implementations.
|
|
26241
26369
|
*
|
|
@@ -26281,6 +26409,23 @@ function createTimeoutToolFunctions() {
|
|
|
26281
26409
|
try {
|
|
26282
26410
|
const parsedArgs = parseTimeoutToolArgs.cancel(args);
|
|
26283
26411
|
const cancelledTimeout = await adapter.cancelTimeout(parsedArgs, runtimeContext);
|
|
26412
|
+
if (cancelledTimeout.status === 'cancelled_all') {
|
|
26413
|
+
const result = {
|
|
26414
|
+
action: 'cancel',
|
|
26415
|
+
status: 'cancelled_all',
|
|
26416
|
+
cancelledCount: cancelledTimeout.cancelledCount || 0,
|
|
26417
|
+
cancelledTimeoutIds: cancelledTimeout.cancelledTimeoutIds || [],
|
|
26418
|
+
hasMore: cancelledTimeout.hasMore,
|
|
26419
|
+
};
|
|
26420
|
+
return createToolExecutionEnvelope({
|
|
26421
|
+
assistantMessage: createBulkCancelAssistantMessage({
|
|
26422
|
+
cancelledCount: result.cancelledCount || 0,
|
|
26423
|
+
cancelledTimeoutIds: result.cancelledTimeoutIds || [],
|
|
26424
|
+
hasMore: result.hasMore,
|
|
26425
|
+
}),
|
|
26426
|
+
toolResult: result,
|
|
26427
|
+
});
|
|
26428
|
+
}
|
|
26284
26429
|
const result = {
|
|
26285
26430
|
action: 'cancel',
|
|
26286
26431
|
status: cancelledTimeout.status,
|
|
@@ -26319,7 +26464,10 @@ function createTimeoutToolFunctions() {
|
|
|
26319
26464
|
total: listedTimeouts.total,
|
|
26320
26465
|
};
|
|
26321
26466
|
return createToolExecutionEnvelope({
|
|
26322
|
-
assistantMessage:
|
|
26467
|
+
assistantMessage: createListedTimeoutsAssistantMessage({
|
|
26468
|
+
total: listedTimeouts.total,
|
|
26469
|
+
items: listedTimeouts.items,
|
|
26470
|
+
}),
|
|
26323
26471
|
toolResult: result,
|
|
26324
26472
|
});
|
|
26325
26473
|
}
|
|
@@ -26332,8 +26480,155 @@ function createTimeoutToolFunctions() {
|
|
|
26332
26480
|
return JSON.stringify(result);
|
|
26333
26481
|
}
|
|
26334
26482
|
},
|
|
26483
|
+
async [TimeoutToolNames.update](args) {
|
|
26484
|
+
const runtimeContext = resolveTimeoutRuntimeContext(args);
|
|
26485
|
+
const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
|
|
26486
|
+
if (!adapter || disabledResult) {
|
|
26487
|
+
return JSON.stringify(disabledResult);
|
|
26488
|
+
}
|
|
26489
|
+
try {
|
|
26490
|
+
const parsedArgs = parseTimeoutToolArgs.update(args);
|
|
26491
|
+
const updatedTimeout = await adapter.updateTimeout(parsedArgs, runtimeContext);
|
|
26492
|
+
if (updatedTimeout.status === 'updated_all') {
|
|
26493
|
+
const result = {
|
|
26494
|
+
action: 'update',
|
|
26495
|
+
status: 'updated_all',
|
|
26496
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
26497
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
26498
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
26499
|
+
hasMore: updatedTimeout.hasMore,
|
|
26500
|
+
};
|
|
26501
|
+
return createToolExecutionEnvelope({
|
|
26502
|
+
assistantMessage: createBulkUpdateAssistantMessage({
|
|
26503
|
+
paused: 'allActive' in parsedArgs && parsedArgs.allActive ? parsedArgs.paused : false,
|
|
26504
|
+
updatedCount: updatedTimeout.updatedCount,
|
|
26505
|
+
matchedCount: updatedTimeout.matchedCount,
|
|
26506
|
+
updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
|
|
26507
|
+
hasMore: updatedTimeout.hasMore,
|
|
26508
|
+
}),
|
|
26509
|
+
toolResult: result,
|
|
26510
|
+
});
|
|
26511
|
+
}
|
|
26512
|
+
if (updatedTimeout.status === 'not_found') {
|
|
26513
|
+
const result = {
|
|
26514
|
+
action: 'update',
|
|
26515
|
+
status: 'not_found',
|
|
26516
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
26517
|
+
};
|
|
26518
|
+
return createToolExecutionEnvelope({
|
|
26519
|
+
assistantMessage: 'The timeout was not found.',
|
|
26520
|
+
toolResult: result,
|
|
26521
|
+
});
|
|
26522
|
+
}
|
|
26523
|
+
if (updatedTimeout.status === 'conflict') {
|
|
26524
|
+
const conflictMessage = updatedTimeout.reason === 'running'
|
|
26525
|
+
? 'Running timeout cannot be edited.'
|
|
26526
|
+
: 'Finished timeout cannot be edited.';
|
|
26527
|
+
const result = {
|
|
26528
|
+
action: 'update',
|
|
26529
|
+
status: 'conflict',
|
|
26530
|
+
timeoutId: updatedTimeout.timeoutId,
|
|
26531
|
+
message: conflictMessage,
|
|
26532
|
+
};
|
|
26533
|
+
return createToolExecutionEnvelope({
|
|
26534
|
+
assistantMessage: conflictMessage,
|
|
26535
|
+
toolResult: result,
|
|
26536
|
+
});
|
|
26537
|
+
}
|
|
26538
|
+
const result = {
|
|
26539
|
+
action: 'update',
|
|
26540
|
+
status: 'updated',
|
|
26541
|
+
timeoutId: updatedTimeout.timeout.timeoutId,
|
|
26542
|
+
dueAt: updatedTimeout.timeout.dueAt,
|
|
26543
|
+
paused: updatedTimeout.timeout.paused,
|
|
26544
|
+
recurrenceIntervalMs: updatedTimeout.timeout.recurrenceIntervalMs,
|
|
26545
|
+
};
|
|
26546
|
+
return createToolExecutionEnvelope({
|
|
26547
|
+
assistantMessage: `Updated timeout ${JSON.stringify(updatedTimeout.timeout.timeoutId)}.`,
|
|
26548
|
+
toolResult: result,
|
|
26549
|
+
});
|
|
26550
|
+
}
|
|
26551
|
+
catch (error) {
|
|
26552
|
+
const result = {
|
|
26553
|
+
action: 'update',
|
|
26554
|
+
status: 'error',
|
|
26555
|
+
message: error instanceof Error ? error.message : String(error),
|
|
26556
|
+
};
|
|
26557
|
+
return JSON.stringify(result);
|
|
26558
|
+
}
|
|
26559
|
+
},
|
|
26335
26560
|
};
|
|
26336
26561
|
}
|
|
26562
|
+
/**
|
|
26563
|
+
* Creates assistant-visible summary for one `list_timeouts` response.
|
|
26564
|
+
*
|
|
26565
|
+
* @private internal utility of USE TIMEOUT
|
|
26566
|
+
*/
|
|
26567
|
+
function createListedTimeoutsAssistantMessage(options) {
|
|
26568
|
+
if (options.total <= 0 || options.items.length === 0) {
|
|
26569
|
+
return 'Found 0 timeouts.';
|
|
26570
|
+
}
|
|
26571
|
+
const visibleItems = options.items.slice(0, MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS);
|
|
26572
|
+
const summaryRows = visibleItems.map((item, index) => `${index + 1}. ${formatTimeoutListRow(item)}`);
|
|
26573
|
+
const hiddenCount = Math.max(0, options.total - visibleItems.length);
|
|
26574
|
+
if (hiddenCount > 0) {
|
|
26575
|
+
summaryRows.push(`...and ${hiddenCount} more.`);
|
|
26576
|
+
}
|
|
26577
|
+
return [`Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:`, ...summaryRows].join('\n');
|
|
26578
|
+
}
|
|
26579
|
+
/**
|
|
26580
|
+
* Formats one timeout row for assistant-visible timeout listings.
|
|
26581
|
+
*
|
|
26582
|
+
* @private internal utility of USE TIMEOUT
|
|
26583
|
+
*/
|
|
26584
|
+
function formatTimeoutListRow(item) {
|
|
26585
|
+
const normalizedMessage = typeof item.message === 'string' ? item.message.trim() : '';
|
|
26586
|
+
const messageSuffix = normalizedMessage ? ` | message ${JSON.stringify(normalizedMessage)}` : '';
|
|
26587
|
+
const recurrenceSuffix = typeof item.recurrenceIntervalMs === 'number' && item.recurrenceIntervalMs > 0
|
|
26588
|
+
? ` | recurrence ${item.recurrenceIntervalMs}ms`
|
|
26589
|
+
: '';
|
|
26590
|
+
const pausedSuffix = item.paused ? ' (paused)' : '';
|
|
26591
|
+
return `${item.timeoutId} | ${item.status}${pausedSuffix} | chat ${item.chatId} | due ${item.dueAt}${recurrenceSuffix}${messageSuffix}`;
|
|
26592
|
+
}
|
|
26593
|
+
/**
|
|
26594
|
+
* Creates assistant-visible summary for bulk timeout cancellation.
|
|
26595
|
+
*
|
|
26596
|
+
* @private internal utility of USE TIMEOUT
|
|
26597
|
+
*/
|
|
26598
|
+
function createBulkCancelAssistantMessage(options) {
|
|
26599
|
+
if (options.cancelledCount <= 0) {
|
|
26600
|
+
return 'No active timeouts were found to cancel.';
|
|
26601
|
+
}
|
|
26602
|
+
const visibleTimeoutIds = options.cancelledTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
26603
|
+
const hiddenIdsCount = Math.max(0, options.cancelledTimeoutIds.length - visibleTimeoutIds.length);
|
|
26604
|
+
const hasMoreSuffix = options.hasMore ? ' Additional active timeouts may still exist.' : '';
|
|
26605
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
26606
|
+
? ` Cancelled ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
26607
|
+
: '';
|
|
26608
|
+
return `Cancelled ${options.cancelledCount} active ${options.cancelledCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${hasMoreSuffix}`;
|
|
26609
|
+
}
|
|
26610
|
+
/**
|
|
26611
|
+
* Creates assistant-visible summary for bulk timeout pause/resume updates.
|
|
26612
|
+
*
|
|
26613
|
+
* @private internal utility of USE TIMEOUT
|
|
26614
|
+
*/
|
|
26615
|
+
function createBulkUpdateAssistantMessage(options) {
|
|
26616
|
+
if (options.matchedCount <= 0) {
|
|
26617
|
+
return options.paused
|
|
26618
|
+
? 'No active queued timeouts were found to pause.'
|
|
26619
|
+
: 'No paused queued timeouts were found to resume.';
|
|
26620
|
+
}
|
|
26621
|
+
const verb = options.paused ? 'Paused' : 'Resumed';
|
|
26622
|
+
const visibleTimeoutIds = options.updatedTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
|
|
26623
|
+
const hiddenIdsCount = Math.max(0, options.updatedTimeoutIds.length - visibleTimeoutIds.length);
|
|
26624
|
+
const skippedCount = Math.max(0, options.matchedCount - options.updatedCount);
|
|
26625
|
+
const idsSuffix = visibleTimeoutIds.length > 0
|
|
26626
|
+
? ` Updated ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
|
|
26627
|
+
: '';
|
|
26628
|
+
const skippedSuffix = skippedCount > 0 ? ` Skipped ${skippedCount} due to concurrent changes.` : '';
|
|
26629
|
+
const hasMoreSuffix = options.hasMore ? ' Additional matching timeouts may still exist.' : '';
|
|
26630
|
+
return `${verb} ${options.updatedCount} ${options.updatedCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${skippedSuffix}${hasMoreSuffix}`;
|
|
26631
|
+
}
|
|
26337
26632
|
|
|
26338
26633
|
/**
|
|
26339
26634
|
* Adds `USE TIMEOUT` tool definitions while preserving already registered tools.
|
|
@@ -26365,7 +26660,7 @@ function createTimeoutTools(existingTools = []) {
|
|
|
26365
26660
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
|
|
26366
26661
|
tools.push({
|
|
26367
26662
|
name: TimeoutToolNames.cancel,
|
|
26368
|
-
description: 'Cancel one
|
|
26663
|
+
description: 'Cancel one timeout by id or cancel all active timeouts across chats for the same user+agent scope.',
|
|
26369
26664
|
parameters: {
|
|
26370
26665
|
type: 'object',
|
|
26371
26666
|
properties: {
|
|
@@ -26373,15 +26668,18 @@ function createTimeoutTools(existingTools = []) {
|
|
|
26373
26668
|
type: 'string',
|
|
26374
26669
|
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
|
|
26375
26670
|
},
|
|
26671
|
+
allActive: {
|
|
26672
|
+
type: 'boolean',
|
|
26673
|
+
description: 'When true, cancel all currently active timeouts across chats in this user+agent scope.',
|
|
26674
|
+
},
|
|
26376
26675
|
},
|
|
26377
|
-
required: ['timeoutId'],
|
|
26378
26676
|
},
|
|
26379
26677
|
});
|
|
26380
26678
|
}
|
|
26381
26679
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
|
|
26382
26680
|
tools.push({
|
|
26383
26681
|
name: TimeoutToolNames.list,
|
|
26384
|
-
description: 'List
|
|
26682
|
+
description: 'List timeout details across all chats for this same user+agent scope so they can be reviewed and managed.',
|
|
26385
26683
|
parameters: {
|
|
26386
26684
|
type: 'object',
|
|
26387
26685
|
properties: {
|
|
@@ -26397,6 +26695,49 @@ function createTimeoutTools(existingTools = []) {
|
|
|
26397
26695
|
},
|
|
26398
26696
|
});
|
|
26399
26697
|
}
|
|
26698
|
+
if (!tools.some((tool) => tool.name === TimeoutToolNames.update)) {
|
|
26699
|
+
tools.push({
|
|
26700
|
+
name: TimeoutToolNames.update,
|
|
26701
|
+
description: 'Update one timeout (pause/resume, next run, recurrence, payload) or pause/resume all active queued timeouts across chats.',
|
|
26702
|
+
parameters: {
|
|
26703
|
+
type: 'object',
|
|
26704
|
+
properties: {
|
|
26705
|
+
timeoutId: {
|
|
26706
|
+
type: 'string',
|
|
26707
|
+
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts` for one timeout update.',
|
|
26708
|
+
},
|
|
26709
|
+
allActive: {
|
|
26710
|
+
type: 'boolean',
|
|
26711
|
+
description: 'When true, run one bulk pause/resume across all active queued timeouts in this same user+agent scope.',
|
|
26712
|
+
},
|
|
26713
|
+
paused: {
|
|
26714
|
+
type: 'boolean',
|
|
26715
|
+
description: 'Pause (`true`) or resume (`false`) one timeout; with `allActive: true` this pauses/resumes all active queued timeouts.',
|
|
26716
|
+
},
|
|
26717
|
+
dueAt: {
|
|
26718
|
+
type: 'string',
|
|
26719
|
+
description: 'Set the next run timestamp (ISO string). Cannot be used with `extendByMs`.',
|
|
26720
|
+
},
|
|
26721
|
+
extendByMs: {
|
|
26722
|
+
type: 'number',
|
|
26723
|
+
description: 'Move next run by this many milliseconds. Cannot be used with `dueAt`.',
|
|
26724
|
+
},
|
|
26725
|
+
recurrenceIntervalMs: {
|
|
26726
|
+
type: 'number',
|
|
26727
|
+
description: 'Set recurrence interval in milliseconds; pass `null` to disable recurrence.',
|
|
26728
|
+
},
|
|
26729
|
+
message: {
|
|
26730
|
+
type: 'string',
|
|
26731
|
+
description: 'Set wake-up message text for this timeout; pass empty string to clear.',
|
|
26732
|
+
},
|
|
26733
|
+
parameters: {
|
|
26734
|
+
type: 'object',
|
|
26735
|
+
description: 'Replace stored JSON parameters passed back when timeout fires.',
|
|
26736
|
+
},
|
|
26737
|
+
},
|
|
26738
|
+
},
|
|
26739
|
+
});
|
|
26740
|
+
}
|
|
26400
26741
|
return tools;
|
|
26401
26742
|
}
|
|
26402
26743
|
|
|
@@ -26418,7 +26759,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
26418
26759
|
* Short one-line description of `USE TIMEOUT`.
|
|
26419
26760
|
*/
|
|
26420
26761
|
get description() {
|
|
26421
|
-
return 'Enable timeout wake-ups plus scoped timeout listing
|
|
26762
|
+
return 'Enable timeout wake-ups plus scoped timeout listing, updates, and cancellation across chats.';
|
|
26422
26763
|
}
|
|
26423
26764
|
/**
|
|
26424
26765
|
* Icon for this commitment.
|
|
@@ -26440,8 +26781,9 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
26440
26781
|
- The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
|
|
26441
26782
|
- The tool returns immediately while the timeout is stored and executed by the runtime later.
|
|
26442
26783
|
- The wake-up arrives as a new user-like timeout message in the same conversation.
|
|
26443
|
-
- The agent can inspect known
|
|
26444
|
-
- The agent can cancel
|
|
26784
|
+
- The agent can inspect known timeout details via \`list_timeouts\`.
|
|
26785
|
+
- The agent can cancel one timeout by \`timeoutId\` or cancel all active timeouts via \`cancel_timeout\`.
|
|
26786
|
+
- The agent can pause/resume and edit timeout details via \`update_timeout\`.
|
|
26445
26787
|
- Commitment content is treated as optional timeout policy instructions.
|
|
26446
26788
|
|
|
26447
26789
|
## Examples
|
|
@@ -26471,6 +26813,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
26471
26813
|
[TimeoutToolNames.set]: 'Set timer',
|
|
26472
26814
|
[TimeoutToolNames.cancel]: 'Cancel timer',
|
|
26473
26815
|
[TimeoutToolNames.list]: 'List timers',
|
|
26816
|
+
[TimeoutToolNames.update]: 'Update timer',
|
|
26474
26817
|
};
|
|
26475
26818
|
}
|
|
26476
26819
|
/**
|