@promptbook/browser 0.112.0-12 → 0.112.0-13

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 CHANGED
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
29
29
  * @generated
30
30
  * @see https://github.com/webgptorg/promptbook
31
31
  */
32
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-12';
32
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-13';
33
33
  /**
34
34
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
35
35
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -15041,9 +15041,9 @@ function createTimeoutSystemMessage(extraInstructions) {
15041
15041
  return spaceTrim$1((block) => `
15042
15042
  Timeout scheduling:
15043
15043
  - Use "set_timeout" to wake this same chat thread in the future.
15044
- - Timers are thread-scoped, not global for the whole agent.
15044
+ - Use "list_timeouts" to review timeouts across all chats for the same user+agent scope.
15045
+ - "cancel_timeout" accepts a timeout id from any chat in this same user+agent scope.
15045
15046
  - 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\`.
15046
- - Use "cancel_timeout" when a previously scheduled timeout is no longer relevant.
15047
15047
  - Do not claim a timer was set or cancelled unless the tool confirms it.
15048
15048
  ${block(extraInstructions)}
15049
15049
  `);
@@ -15104,13 +15104,6 @@ function parseToolExecutionEnvelope(rawValue) {
15104
15104
  * @private internal utility of USE TIMEOUT
15105
15105
  */
15106
15106
  function createDisabledTimeoutResult(action, message) {
15107
- if (action === 'set') {
15108
- return {
15109
- action,
15110
- status: 'disabled',
15111
- message,
15112
- };
15113
- }
15114
15107
  return {
15115
15108
  action,
15116
15109
  status: 'disabled',
@@ -15137,6 +15130,18 @@ function getTimeoutToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
15137
15130
  }
15138
15131
  }
15139
15132
 
15133
+ /**
15134
+ * Default number of rows returned by `list_timeouts`.
15135
+ *
15136
+ * @private internal USE TIMEOUT constant
15137
+ */
15138
+ const DEFAULT_LIST_TIMEOUTS_LIMIT = 20;
15139
+ /**
15140
+ * Hard cap for `list_timeouts` page size.
15141
+ *
15142
+ * @private internal USE TIMEOUT constant
15143
+ */
15144
+ const MAX_LIST_TIMEOUTS_LIMIT = 100;
15140
15145
  /**
15141
15146
  * Parses and validates `USE TIMEOUT` tool arguments.
15142
15147
  *
@@ -15171,6 +15176,31 @@ const parseTimeoutToolArgs = {
15171
15176
  }
15172
15177
  return { timeoutId };
15173
15178
  },
15179
+ /**
15180
+ * Parses `list_timeouts` input.
15181
+ */
15182
+ list(args) {
15183
+ if (args.includeFinished !== undefined && typeof args.includeFinished !== 'boolean') {
15184
+ throw new PipelineExecutionError(spaceTrim$1(`
15185
+ Timeout \`includeFinished\` must be a boolean when provided.
15186
+ `));
15187
+ }
15188
+ const parsedLimit = args.limit === undefined ? DEFAULT_LIST_TIMEOUTS_LIMIT : Math.floor(Number(args.limit));
15189
+ if (!Number.isFinite(parsedLimit) || parsedLimit <= 0) {
15190
+ throw new PipelineExecutionError(spaceTrim$1(`
15191
+ Timeout \`limit\` must be a positive number.
15192
+ `));
15193
+ }
15194
+ if (parsedLimit > MAX_LIST_TIMEOUTS_LIMIT) {
15195
+ throw new PipelineExecutionError(spaceTrim$1(`
15196
+ Timeout \`limit\` must be at most \`${MAX_LIST_TIMEOUTS_LIMIT}\`.
15197
+ `));
15198
+ }
15199
+ return {
15200
+ includeFinished: args.includeFinished === true,
15201
+ limit: parsedLimit,
15202
+ };
15203
+ },
15174
15204
  };
15175
15205
 
15176
15206
  /**
@@ -15181,6 +15211,7 @@ const parseTimeoutToolArgs = {
15181
15211
  const TimeoutToolNames = {
15182
15212
  set: 'set_timeout',
15183
15213
  cancel: 'cancel_timeout',
15214
+ list: 'list_timeouts',
15184
15215
  };
15185
15216
 
15186
15217
  /**
@@ -15280,6 +15311,35 @@ function createTimeoutToolFunctions() {
15280
15311
  return JSON.stringify(result);
15281
15312
  }
15282
15313
  },
15314
+ async [TimeoutToolNames.list](args) {
15315
+ const runtimeContext = resolveTimeoutRuntimeContext(args);
15316
+ const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('list', runtimeContext);
15317
+ if (!adapter || disabledResult) {
15318
+ return JSON.stringify(disabledResult);
15319
+ }
15320
+ try {
15321
+ const parsedArgs = parseTimeoutToolArgs.list(args);
15322
+ const listedTimeouts = await adapter.listTimeouts(parsedArgs, runtimeContext);
15323
+ const result = {
15324
+ action: 'list',
15325
+ status: 'listed',
15326
+ items: listedTimeouts.items,
15327
+ total: listedTimeouts.total,
15328
+ };
15329
+ return createToolExecutionEnvelope({
15330
+ assistantMessage: listedTimeouts.total === 1 ? 'Found 1 timeout.' : `Found ${listedTimeouts.total} timeouts.`,
15331
+ toolResult: result,
15332
+ });
15333
+ }
15334
+ catch (error) {
15335
+ const result = {
15336
+ action: 'list',
15337
+ status: 'error',
15338
+ message: error instanceof Error ? error.message : String(error),
15339
+ };
15340
+ return JSON.stringify(result);
15341
+ }
15342
+ },
15283
15343
  };
15284
15344
  }
15285
15345
 
@@ -15313,26 +15373,45 @@ function createTimeoutTools(existingTools = []) {
15313
15373
  if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
15314
15374
  tools.push({
15315
15375
  name: TimeoutToolNames.cancel,
15316
- description: 'Cancel one previously scheduled timeout in the current chat thread.',
15376
+ description: 'Cancel one previously scheduled timeout within the same user+agent scope, even if it was set in another chat.',
15317
15377
  parameters: {
15318
15378
  type: 'object',
15319
15379
  properties: {
15320
15380
  timeoutId: {
15321
15381
  type: 'string',
15322
- description: 'Identifier returned earlier by `set_timeout`.',
15382
+ description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
15323
15383
  },
15324
15384
  },
15325
15385
  required: ['timeoutId'],
15326
15386
  },
15327
15387
  });
15328
15388
  }
15389
+ if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
15390
+ tools.push({
15391
+ name: TimeoutToolNames.list,
15392
+ description: 'List scheduled timeouts across all chats for this same user+agent scope so they can be reviewed or cancelled.',
15393
+ parameters: {
15394
+ type: 'object',
15395
+ properties: {
15396
+ includeFinished: {
15397
+ type: 'boolean',
15398
+ description: 'When true, include completed, failed, and cancelled rows in addition to active timeouts.',
15399
+ },
15400
+ limit: {
15401
+ type: 'number',
15402
+ description: 'Maximum number of rows to return (default 20, max 100).',
15403
+ },
15404
+ },
15405
+ },
15406
+ });
15407
+ }
15329
15408
  return tools;
15330
15409
  }
15331
15410
 
15332
15411
  /**
15333
15412
  * `USE TIMEOUT` commitment definition.
15334
15413
  *
15335
- * The `USE TIMEOUT` commitment enables thread-scoped timers that wake the same chat later.
15414
+ * The `USE TIMEOUT` commitment enables timeout wake-ups and scoped timeout management.
15336
15415
  *
15337
15416
  * @private [🪔] Maybe export the commitments through some package
15338
15417
  */
@@ -15347,7 +15426,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
15347
15426
  * Short one-line description of `USE TIMEOUT`.
15348
15427
  */
15349
15428
  get description() {
15350
- return 'Enable thread-scoped timers that can wake the same chat in the future.';
15429
+ return 'Enable timeout wake-ups plus scoped timeout listing/cancellation across chats.';
15351
15430
  }
15352
15431
  /**
15353
15432
  * Icon for this commitment.
@@ -15362,14 +15441,15 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
15362
15441
  return spaceTrim$1(`
15363
15442
  # USE TIMEOUT
15364
15443
 
15365
- Enables the agent to schedule thread-scoped timeout wake-ups.
15444
+ Enables timeout wake-ups and timeout management for the same user+agent scope.
15366
15445
 
15367
15446
  ## Key aspects
15368
15447
 
15369
15448
  - The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
15370
15449
  - The tool returns immediately while the timeout is stored and executed by the runtime later.
15371
15450
  - The wake-up arrives as a new user-like timeout message in the same conversation.
15372
- - The agent can cancel an existing timeout by \`timeoutId\` via \`cancel_timeout\`.
15451
+ - The agent can inspect known timeouts via \`list_timeouts\`.
15452
+ - The agent can cancel an existing timeout by \`timeoutId\` via \`cancel_timeout\`, including timeouts created in another chat.
15373
15453
  - Commitment content is treated as optional timeout policy instructions.
15374
15454
 
15375
15455
  ## Examples
@@ -15398,6 +15478,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
15398
15478
  return {
15399
15479
  [TimeoutToolNames.set]: 'Set timer',
15400
15480
  [TimeoutToolNames.cancel]: 'Cancel timer',
15481
+ [TimeoutToolNames.list]: 'List timers',
15401
15482
  };
15402
15483
  }
15403
15484
  /**