@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.
@@ -2,7 +2,7 @@ import type { ToolFunction } from '../../_packages/types.index';
2
2
  /**
3
3
  * Resolves the server-side implementation of the `run_browser` tool for Node.js environments.
4
4
  *
5
- * This uses lazy `require` to keep the core package decoupled from Agents Server internals.
5
+ * This uses fully lazy resolution to keep CLI startup independent from optional browser tooling.
6
6
  * When the server tool cannot be resolved, the fallback implementation throws a helpful error.
7
7
  *
8
8
  * @private internal utility for USE BROWSER commitment
@@ -6,4 +6,5 @@
6
6
  export declare const TimeoutToolNames: {
7
7
  readonly set: string;
8
8
  readonly cancel: string;
9
+ readonly list: string;
9
10
  };
@@ -18,6 +18,16 @@ export type CancelTimeoutToolArgs = {
18
18
  timeoutId?: string;
19
19
  [key: string]: TODO_any;
20
20
  };
21
+ /**
22
+ * Tool arguments for listing scoped timeouts.
23
+ *
24
+ * @private type of UseTimeoutCommitmentDefinition
25
+ */
26
+ export type ListTimeoutsToolArgs = {
27
+ includeFinished?: boolean;
28
+ limit?: number;
29
+ [key: string]: TODO_any;
30
+ };
21
31
  /**
22
32
  * Runtime context available to `USE TIMEOUT` tools.
23
33
  *
@@ -31,6 +41,26 @@ export type TimeoutToolRuntimeContext = {
31
41
  readonly agentName?: string;
32
42
  readonly promptParameters: Record<string, string>;
33
43
  };
44
+ /**
45
+ * Lifecycle status exposed by `list_timeouts`.
46
+ *
47
+ * @private type of UseTimeoutCommitmentDefinition
48
+ */
49
+ export type TimeoutToolListItemStatus = 'QUEUED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
50
+ /**
51
+ * One timeout row exposed by `list_timeouts`.
52
+ *
53
+ * @private type of UseTimeoutCommitmentDefinition
54
+ */
55
+ export type TimeoutToolListItem = {
56
+ timeoutId: string;
57
+ chatId: string;
58
+ status: TimeoutToolListItemStatus;
59
+ dueAt: string;
60
+ paused: boolean;
61
+ message?: string | null;
62
+ recurrenceIntervalMs?: number | null;
63
+ };
34
64
  /**
35
65
  * Result payload returned by `set_timeout`.
36
66
  *
@@ -55,18 +85,30 @@ export type CancelTimeoutToolResult = {
55
85
  dueAt?: string;
56
86
  message?: string;
57
87
  };
88
+ /**
89
+ * Result payload returned by `list_timeouts`.
90
+ *
91
+ * @private type of UseTimeoutCommitmentDefinition
92
+ */
93
+ export type ListTimeoutsToolResult = {
94
+ action: 'list';
95
+ status: 'listed' | 'disabled' | 'error';
96
+ items?: Array<TimeoutToolListItem>;
97
+ total?: number;
98
+ message?: string;
99
+ };
58
100
  /**
59
101
  * Union of all `USE TIMEOUT` tool actions.
60
102
  *
61
103
  * @private type of UseTimeoutCommitmentDefinition
62
104
  */
63
- export type TimeoutToolAction = SetTimeoutToolResult['action'] | CancelTimeoutToolResult['action'];
105
+ export type TimeoutToolAction = SetTimeoutToolResult['action'] | CancelTimeoutToolResult['action'] | ListTimeoutsToolResult['action'];
64
106
  /**
65
107
  * Union of all `USE TIMEOUT` tool results.
66
108
  *
67
109
  * @private type of UseTimeoutCommitmentDefinition
68
110
  */
69
- export type TimeoutToolResult = SetTimeoutToolResult | CancelTimeoutToolResult;
111
+ export type TimeoutToolResult = SetTimeoutToolResult | CancelTimeoutToolResult | ListTimeoutsToolResult;
70
112
  /**
71
113
  * Runtime adapter used by `USE TIMEOUT` tools.
72
114
  *
@@ -87,4 +129,11 @@ export type TimeoutToolRuntimeAdapter = {
87
129
  dueAt?: string;
88
130
  status: 'cancelled' | 'not_found';
89
131
  }>;
132
+ listTimeouts(args: {
133
+ includeFinished: boolean;
134
+ limit: number;
135
+ }, runtimeContext: TimeoutToolRuntimeContext): Promise<{
136
+ items: Array<TimeoutToolListItem>;
137
+ total: number;
138
+ }>;
90
139
  };
@@ -3,11 +3,11 @@ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentMo
3
3
  import type { ToolFunction } from '../../scripting/javascript/JavascriptExecutionToolsOptions';
4
4
  import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
5
5
  export { setTimeoutToolRuntimeAdapter } from './setTimeoutToolRuntimeAdapter';
6
- export type { CancelTimeoutToolResult, SetTimeoutToolResult, TimeoutToolRuntimeAdapter, TimeoutToolRuntimeContext, } from './TimeoutToolRuntimeAdapter';
6
+ export type { CancelTimeoutToolResult, ListTimeoutsToolResult, SetTimeoutToolResult, TimeoutToolListItem, TimeoutToolRuntimeAdapter, TimeoutToolRuntimeContext, } from './TimeoutToolRuntimeAdapter';
7
7
  /**
8
8
  * `USE TIMEOUT` commitment definition.
9
9
  *
10
- * The `USE TIMEOUT` commitment enables thread-scoped timers that wake the same chat later.
10
+ * The `USE TIMEOUT` commitment enables timeout wake-ups and scoped timeout management.
11
11
  *
12
12
  * @private [🪔] Maybe export the commitments through some package
13
13
  */
@@ -1,4 +1,4 @@
1
- import type { CancelTimeoutToolResult, SetTimeoutToolResult, TimeoutToolAction, TimeoutToolRuntimeAdapter, TimeoutToolRuntimeContext } from './TimeoutToolRuntimeAdapter';
1
+ import type { TimeoutToolAction, TimeoutToolResult, TimeoutToolRuntimeAdapter, TimeoutToolRuntimeContext } from './TimeoutToolRuntimeAdapter';
2
2
  /**
3
3
  * Return type of timeout adapter resolution helper.
4
4
  *
@@ -6,7 +6,7 @@ import type { CancelTimeoutToolResult, SetTimeoutToolResult, TimeoutToolAction,
6
6
  */
7
7
  type TimeoutToolRuntimeAdapterResolution = {
8
8
  adapter: TimeoutToolRuntimeAdapter | null;
9
- disabledResult: SetTimeoutToolResult | CancelTimeoutToolResult | null;
9
+ disabledResult: TimeoutToolResult | null;
10
10
  };
11
11
  /**
12
12
  * Resolves the runtime adapter for timeout tools or returns disabled payload when unavailable.
@@ -1,4 +1,4 @@
1
- import type { CancelTimeoutToolArgs, SetTimeoutToolArgs } from './TimeoutToolRuntimeAdapter';
1
+ import type { CancelTimeoutToolArgs, ListTimeoutsToolArgs, SetTimeoutToolArgs } from './TimeoutToolRuntimeAdapter';
2
2
  /**
3
3
  * Parsed arguments for `set_timeout`.
4
4
  *
@@ -16,6 +16,15 @@ type ParsedSetTimeoutToolArgs = {
16
16
  type ParsedCancelTimeoutToolArgs = {
17
17
  timeoutId: string;
18
18
  };
19
+ /**
20
+ * Parsed arguments for `list_timeouts`.
21
+ *
22
+ * @private type of UseTimeoutCommitmentDefinition
23
+ */
24
+ type ParsedListTimeoutsToolArgs = {
25
+ includeFinished: boolean;
26
+ limit: number;
27
+ };
19
28
  /**
20
29
  * Parses and validates `USE TIMEOUT` tool arguments.
21
30
  *
@@ -30,5 +39,9 @@ export declare const parseTimeoutToolArgs: {
30
39
  * Parses `cancel_timeout` input.
31
40
  */
32
41
  cancel(args: CancelTimeoutToolArgs): ParsedCancelTimeoutToolArgs;
42
+ /**
43
+ * Parses `list_timeouts` input.
44
+ */
45
+ list(args: ListTimeoutsToolArgs): ParsedListTimeoutsToolArgs;
33
46
  };
34
47
  export {};
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.112.0-11`).
18
+ * It follows semantic versioning (e.g., `0.112.0-12`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.112.0-12",
3
+ "version": "0.112.0-13",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -28,7 +28,7 @@
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 @@
19795
19795
  return spaceTrim$1.spaceTrim((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 @@
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 @@
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 @@
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.spaceTrim(`
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.spaceTrim(`
19945
+ Timeout \`limit\` must be a positive number.
19946
+ `));
19947
+ }
19948
+ if (parsedLimit > MAX_LIST_TIMEOUTS_LIMIT) {
19949
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim(`
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 @@
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 @@
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 @@
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 @@
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 @@
20116
20195
  return spaceTrim$1.spaceTrim(`
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 @@
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
  /**