@promptbook/components 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
@@ -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-12';
43
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-13';
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
@@ -15543,9 +15543,9 @@ function createTimeoutSystemMessage(extraInstructions) {
15543
15543
  return spaceTrim$1((block) => `
15544
15544
  Timeout scheduling:
15545
15545
  - Use "set_timeout" to wake this same chat thread in the future.
15546
- - Timers are thread-scoped, not global for the whole agent.
15546
+ - Use "list_timeouts" to review timeouts across all chats for the same user+agent scope.
15547
+ - "cancel_timeout" accepts a timeout id from any chat in this same user+agent scope.
15547
15548
  - 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\`.
15548
- - Use "cancel_timeout" when a previously scheduled timeout is no longer relevant.
15549
15549
  - Do not claim a timer was set or cancelled unless the tool confirms it.
15550
15550
  ${block(extraInstructions)}
15551
15551
  `);
@@ -15606,13 +15606,6 @@ function parseToolExecutionEnvelope(rawValue) {
15606
15606
  * @private internal utility of USE TIMEOUT
15607
15607
  */
15608
15608
  function createDisabledTimeoutResult(action, message) {
15609
- if (action === 'set') {
15610
- return {
15611
- action,
15612
- status: 'disabled',
15613
- message,
15614
- };
15615
- }
15616
15609
  return {
15617
15610
  action,
15618
15611
  status: 'disabled',
@@ -15639,6 +15632,18 @@ function getTimeoutToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
15639
15632
  }
15640
15633
  }
15641
15634
 
15635
+ /**
15636
+ * Default number of rows returned by `list_timeouts`.
15637
+ *
15638
+ * @private internal USE TIMEOUT constant
15639
+ */
15640
+ const DEFAULT_LIST_TIMEOUTS_LIMIT = 20;
15641
+ /**
15642
+ * Hard cap for `list_timeouts` page size.
15643
+ *
15644
+ * @private internal USE TIMEOUT constant
15645
+ */
15646
+ const MAX_LIST_TIMEOUTS_LIMIT = 100;
15642
15647
  /**
15643
15648
  * Parses and validates `USE TIMEOUT` tool arguments.
15644
15649
  *
@@ -15673,6 +15678,31 @@ const parseTimeoutToolArgs = {
15673
15678
  }
15674
15679
  return { timeoutId };
15675
15680
  },
15681
+ /**
15682
+ * Parses `list_timeouts` input.
15683
+ */
15684
+ list(args) {
15685
+ if (args.includeFinished !== undefined && typeof args.includeFinished !== 'boolean') {
15686
+ throw new PipelineExecutionError(spaceTrim$1(`
15687
+ Timeout \`includeFinished\` must be a boolean when provided.
15688
+ `));
15689
+ }
15690
+ const parsedLimit = args.limit === undefined ? DEFAULT_LIST_TIMEOUTS_LIMIT : Math.floor(Number(args.limit));
15691
+ if (!Number.isFinite(parsedLimit) || parsedLimit <= 0) {
15692
+ throw new PipelineExecutionError(spaceTrim$1(`
15693
+ Timeout \`limit\` must be a positive number.
15694
+ `));
15695
+ }
15696
+ if (parsedLimit > MAX_LIST_TIMEOUTS_LIMIT) {
15697
+ throw new PipelineExecutionError(spaceTrim$1(`
15698
+ Timeout \`limit\` must be at most \`${MAX_LIST_TIMEOUTS_LIMIT}\`.
15699
+ `));
15700
+ }
15701
+ return {
15702
+ includeFinished: args.includeFinished === true,
15703
+ limit: parsedLimit,
15704
+ };
15705
+ },
15676
15706
  };
15677
15707
 
15678
15708
  /**
@@ -15683,6 +15713,7 @@ const parseTimeoutToolArgs = {
15683
15713
  const TimeoutToolNames = {
15684
15714
  set: 'set_timeout',
15685
15715
  cancel: 'cancel_timeout',
15716
+ list: 'list_timeouts',
15686
15717
  };
15687
15718
 
15688
15719
  /**
@@ -15782,6 +15813,35 @@ function createTimeoutToolFunctions() {
15782
15813
  return JSON.stringify(result);
15783
15814
  }
15784
15815
  },
15816
+ async [TimeoutToolNames.list](args) {
15817
+ const runtimeContext = resolveTimeoutRuntimeContext(args);
15818
+ const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('list', runtimeContext);
15819
+ if (!adapter || disabledResult) {
15820
+ return JSON.stringify(disabledResult);
15821
+ }
15822
+ try {
15823
+ const parsedArgs = parseTimeoutToolArgs.list(args);
15824
+ const listedTimeouts = await adapter.listTimeouts(parsedArgs, runtimeContext);
15825
+ const result = {
15826
+ action: 'list',
15827
+ status: 'listed',
15828
+ items: listedTimeouts.items,
15829
+ total: listedTimeouts.total,
15830
+ };
15831
+ return createToolExecutionEnvelope({
15832
+ assistantMessage: listedTimeouts.total === 1 ? 'Found 1 timeout.' : `Found ${listedTimeouts.total} timeouts.`,
15833
+ toolResult: result,
15834
+ });
15835
+ }
15836
+ catch (error) {
15837
+ const result = {
15838
+ action: 'list',
15839
+ status: 'error',
15840
+ message: error instanceof Error ? error.message : String(error),
15841
+ };
15842
+ return JSON.stringify(result);
15843
+ }
15844
+ },
15785
15845
  };
15786
15846
  }
15787
15847
 
@@ -15815,26 +15875,45 @@ function createTimeoutTools(existingTools = []) {
15815
15875
  if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
15816
15876
  tools.push({
15817
15877
  name: TimeoutToolNames.cancel,
15818
- description: 'Cancel one previously scheduled timeout in the current chat thread.',
15878
+ description: 'Cancel one previously scheduled timeout within the same user+agent scope, even if it was set in another chat.',
15819
15879
  parameters: {
15820
15880
  type: 'object',
15821
15881
  properties: {
15822
15882
  timeoutId: {
15823
15883
  type: 'string',
15824
- description: 'Identifier returned earlier by `set_timeout`.',
15884
+ description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
15825
15885
  },
15826
15886
  },
15827
15887
  required: ['timeoutId'],
15828
15888
  },
15829
15889
  });
15830
15890
  }
15891
+ if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
15892
+ tools.push({
15893
+ name: TimeoutToolNames.list,
15894
+ description: 'List scheduled timeouts across all chats for this same user+agent scope so they can be reviewed or cancelled.',
15895
+ parameters: {
15896
+ type: 'object',
15897
+ properties: {
15898
+ includeFinished: {
15899
+ type: 'boolean',
15900
+ description: 'When true, include completed, failed, and cancelled rows in addition to active timeouts.',
15901
+ },
15902
+ limit: {
15903
+ type: 'number',
15904
+ description: 'Maximum number of rows to return (default 20, max 100).',
15905
+ },
15906
+ },
15907
+ },
15908
+ });
15909
+ }
15831
15910
  return tools;
15832
15911
  }
15833
15912
 
15834
15913
  /**
15835
15914
  * `USE TIMEOUT` commitment definition.
15836
15915
  *
15837
- * The `USE TIMEOUT` commitment enables thread-scoped timers that wake the same chat later.
15916
+ * The `USE TIMEOUT` commitment enables timeout wake-ups and scoped timeout management.
15838
15917
  *
15839
15918
  * @private [🪔] Maybe export the commitments through some package
15840
15919
  */
@@ -15849,7 +15928,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
15849
15928
  * Short one-line description of `USE TIMEOUT`.
15850
15929
  */
15851
15930
  get description() {
15852
- return 'Enable thread-scoped timers that can wake the same chat in the future.';
15931
+ return 'Enable timeout wake-ups plus scoped timeout listing/cancellation across chats.';
15853
15932
  }
15854
15933
  /**
15855
15934
  * Icon for this commitment.
@@ -15864,14 +15943,15 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
15864
15943
  return spaceTrim$1(`
15865
15944
  # USE TIMEOUT
15866
15945
 
15867
- Enables the agent to schedule thread-scoped timeout wake-ups.
15946
+ Enables timeout wake-ups and timeout management for the same user+agent scope.
15868
15947
 
15869
15948
  ## Key aspects
15870
15949
 
15871
15950
  - The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
15872
15951
  - The tool returns immediately while the timeout is stored and executed by the runtime later.
15873
15952
  - The wake-up arrives as a new user-like timeout message in the same conversation.
15874
- - The agent can cancel an existing timeout by \`timeoutId\` via \`cancel_timeout\`.
15953
+ - The agent can inspect known timeouts via \`list_timeouts\`.
15954
+ - The agent can cancel an existing timeout by \`timeoutId\` via \`cancel_timeout\`, including timeouts created in another chat.
15875
15955
  - Commitment content is treated as optional timeout policy instructions.
15876
15956
 
15877
15957
  ## Examples
@@ -15900,6 +15980,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
15900
15980
  return {
15901
15981
  [TimeoutToolNames.set]: 'Set timer',
15902
15982
  [TimeoutToolNames.cancel]: 'Cancel timer',
15983
+ [TimeoutToolNames.list]: 'List timers',
15903
15984
  };
15904
15985
  }
15905
15986
  /**
@@ -38141,6 +38222,7 @@ const TOOL_TITLES = {
38141
38222
  useTime: { title: 'Checking time', emoji: '🕒' },
38142
38223
  set_timeout: { title: 'Setting timer', emoji: '⏱️' },
38143
38224
  cancel_timeout: { title: 'Cancelling timer', emoji: '⏱️' },
38225
+ list_timeouts: { title: 'Listing timers', emoji: '⏱️' },
38144
38226
  get_user_location: { title: 'Checking location', emoji: '📍' },
38145
38227
  send_email: { title: 'Sending email', emoji: '📧' },
38146
38228
  useEmail: { title: 'Sending email', emoji: '📧' },