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