@promptbook/core 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
@@ -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-12';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-13';
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,9 +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
- - Timers are thread-scoped, not global for the whole agent.
19798
+ - Use "list_timeouts" to review timeouts across all chats for the same user+agent scope.
19799
+ - "cancel_timeout" accepts a timeout id from any chat in this same user+agent scope.
19799
19800
  - 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\`.
19800
- - Use "cancel_timeout" when a previously scheduled timeout is no longer relevant.
19801
19801
  - Do not claim a timer was set or cancelled unless the tool confirms it.
19802
19802
  ${block(extraInstructions)}
19803
19803
  `);
@@ -19858,13 +19858,6 @@ function parseToolExecutionEnvelope(rawValue) {
19858
19858
  * @private internal utility of USE TIMEOUT
19859
19859
  */
19860
19860
  function createDisabledTimeoutResult(action, message) {
19861
- if (action === 'set') {
19862
- return {
19863
- action,
19864
- status: 'disabled',
19865
- message,
19866
- };
19867
- }
19868
19861
  return {
19869
19862
  action,
19870
19863
  status: 'disabled',
@@ -19891,6 +19884,18 @@ function getTimeoutToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
19891
19884
  }
19892
19885
  }
19893
19886
 
19887
+ /**
19888
+ * Default number of rows returned by `list_timeouts`.
19889
+ *
19890
+ * @private internal USE TIMEOUT constant
19891
+ */
19892
+ const DEFAULT_LIST_TIMEOUTS_LIMIT = 20;
19893
+ /**
19894
+ * Hard cap for `list_timeouts` page size.
19895
+ *
19896
+ * @private internal USE TIMEOUT constant
19897
+ */
19898
+ const MAX_LIST_TIMEOUTS_LIMIT = 100;
19894
19899
  /**
19895
19900
  * Parses and validates `USE TIMEOUT` tool arguments.
19896
19901
  *
@@ -19925,6 +19930,31 @@ const parseTimeoutToolArgs = {
19925
19930
  }
19926
19931
  return { timeoutId };
19927
19932
  },
19933
+ /**
19934
+ * Parses `list_timeouts` input.
19935
+ */
19936
+ list(args) {
19937
+ if (args.includeFinished !== undefined && typeof args.includeFinished !== 'boolean') {
19938
+ throw new PipelineExecutionError(spaceTrim$1(`
19939
+ Timeout \`includeFinished\` must be a boolean when provided.
19940
+ `));
19941
+ }
19942
+ const parsedLimit = args.limit === undefined ? DEFAULT_LIST_TIMEOUTS_LIMIT : Math.floor(Number(args.limit));
19943
+ if (!Number.isFinite(parsedLimit) || parsedLimit <= 0) {
19944
+ throw new PipelineExecutionError(spaceTrim$1(`
19945
+ Timeout \`limit\` must be a positive number.
19946
+ `));
19947
+ }
19948
+ if (parsedLimit > MAX_LIST_TIMEOUTS_LIMIT) {
19949
+ throw new PipelineExecutionError(spaceTrim$1(`
19950
+ Timeout \`limit\` must be at most \`${MAX_LIST_TIMEOUTS_LIMIT}\`.
19951
+ `));
19952
+ }
19953
+ return {
19954
+ includeFinished: args.includeFinished === true,
19955
+ limit: parsedLimit,
19956
+ };
19957
+ },
19928
19958
  };
19929
19959
 
19930
19960
  /**
@@ -19935,6 +19965,7 @@ const parseTimeoutToolArgs = {
19935
19965
  const TimeoutToolNames = {
19936
19966
  set: 'set_timeout',
19937
19967
  cancel: 'cancel_timeout',
19968
+ list: 'list_timeouts',
19938
19969
  };
19939
19970
 
19940
19971
  /**
@@ -20034,6 +20065,35 @@ function createTimeoutToolFunctions() {
20034
20065
  return JSON.stringify(result);
20035
20066
  }
20036
20067
  },
20068
+ async [TimeoutToolNames.list](args) {
20069
+ const runtimeContext = resolveTimeoutRuntimeContext(args);
20070
+ const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('list', runtimeContext);
20071
+ if (!adapter || disabledResult) {
20072
+ return JSON.stringify(disabledResult);
20073
+ }
20074
+ try {
20075
+ const parsedArgs = parseTimeoutToolArgs.list(args);
20076
+ const listedTimeouts = await adapter.listTimeouts(parsedArgs, runtimeContext);
20077
+ const result = {
20078
+ action: 'list',
20079
+ status: 'listed',
20080
+ items: listedTimeouts.items,
20081
+ total: listedTimeouts.total,
20082
+ };
20083
+ return createToolExecutionEnvelope({
20084
+ assistantMessage: listedTimeouts.total === 1 ? 'Found 1 timeout.' : `Found ${listedTimeouts.total} timeouts.`,
20085
+ toolResult: result,
20086
+ });
20087
+ }
20088
+ catch (error) {
20089
+ const result = {
20090
+ action: 'list',
20091
+ status: 'error',
20092
+ message: error instanceof Error ? error.message : String(error),
20093
+ };
20094
+ return JSON.stringify(result);
20095
+ }
20096
+ },
20037
20097
  };
20038
20098
  }
20039
20099
 
@@ -20067,26 +20127,45 @@ function createTimeoutTools(existingTools = []) {
20067
20127
  if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
20068
20128
  tools.push({
20069
20129
  name: TimeoutToolNames.cancel,
20070
- description: 'Cancel one previously scheduled timeout in the current chat thread.',
20130
+ description: 'Cancel one previously scheduled timeout within the same user+agent scope, even if it was set in another chat.',
20071
20131
  parameters: {
20072
20132
  type: 'object',
20073
20133
  properties: {
20074
20134
  timeoutId: {
20075
20135
  type: 'string',
20076
- description: 'Identifier returned earlier by `set_timeout`.',
20136
+ description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
20077
20137
  },
20078
20138
  },
20079
20139
  required: ['timeoutId'],
20080
20140
  },
20081
20141
  });
20082
20142
  }
20143
+ if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
20144
+ tools.push({
20145
+ name: TimeoutToolNames.list,
20146
+ description: 'List scheduled timeouts across all chats for this same user+agent scope so they can be reviewed or cancelled.',
20147
+ parameters: {
20148
+ type: 'object',
20149
+ properties: {
20150
+ includeFinished: {
20151
+ type: 'boolean',
20152
+ description: 'When true, include completed, failed, and cancelled rows in addition to active timeouts.',
20153
+ },
20154
+ limit: {
20155
+ type: 'number',
20156
+ description: 'Maximum number of rows to return (default 20, max 100).',
20157
+ },
20158
+ },
20159
+ },
20160
+ });
20161
+ }
20083
20162
  return tools;
20084
20163
  }
20085
20164
 
20086
20165
  /**
20087
20166
  * `USE TIMEOUT` commitment definition.
20088
20167
  *
20089
- * The `USE TIMEOUT` commitment enables thread-scoped timers that wake the same chat later.
20168
+ * The `USE TIMEOUT` commitment enables timeout wake-ups and scoped timeout management.
20090
20169
  *
20091
20170
  * @private [🪔] Maybe export the commitments through some package
20092
20171
  */
@@ -20101,7 +20180,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
20101
20180
  * Short one-line description of `USE TIMEOUT`.
20102
20181
  */
20103
20182
  get description() {
20104
- return 'Enable thread-scoped timers that can wake the same chat in the future.';
20183
+ return 'Enable timeout wake-ups plus scoped timeout listing/cancellation across chats.';
20105
20184
  }
20106
20185
  /**
20107
20186
  * Icon for this commitment.
@@ -20116,14 +20195,15 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
20116
20195
  return spaceTrim$1(`
20117
20196
  # USE TIMEOUT
20118
20197
 
20119
- Enables the agent to schedule thread-scoped timeout wake-ups.
20198
+ Enables timeout wake-ups and timeout management for the same user+agent scope.
20120
20199
 
20121
20200
  ## Key aspects
20122
20201
 
20123
20202
  - The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
20124
20203
  - The tool returns immediately while the timeout is stored and executed by the runtime later.
20125
20204
  - The wake-up arrives as a new user-like timeout message in the same conversation.
20126
- - The agent can cancel an existing timeout by \`timeoutId\` via \`cancel_timeout\`.
20205
+ - The agent can inspect known timeouts via \`list_timeouts\`.
20206
+ - The agent can cancel an existing timeout by \`timeoutId\` via \`cancel_timeout\`, including timeouts created in another chat.
20127
20207
  - Commitment content is treated as optional timeout policy instructions.
20128
20208
 
20129
20209
  ## Examples
@@ -20152,6 +20232,7 @@ class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
20152
20232
  return {
20153
20233
  [TimeoutToolNames.set]: 'Set timer',
20154
20234
  [TimeoutToolNames.cancel]: 'Cancel timer',
20235
+ [TimeoutToolNames.list]: 'List timers',
20155
20236
  };
20156
20237
  }
20157
20238
  /**