@promptbook/anthropic-claude 0.103.0-55 → 0.103.0-56

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.
@@ -0,0 +1,53 @@
1
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
3
+ /**
4
+ * USE commitment definition
5
+ *
6
+ * The USE commitment indicates that the agent should utilize specific tools or capabilities
7
+ * to access and interact with external systems when necessary.
8
+ *
9
+ * Supported USE types:
10
+ * - USE BROWSER: Enables the agent to use a web browser tool
11
+ * - USE SEARCH ENGINE (future): Enables search engine access
12
+ * - USE FILE SYSTEM (future): Enables file system operations
13
+ * - USE MCP (future): Enables MCP server connections
14
+ *
15
+ * The content following the USE commitment is ignored (similar to NOTE).
16
+ *
17
+ * Example usage in agent source:
18
+ *
19
+ * ```book
20
+ * USE BROWSER
21
+ * USE SEARCH ENGINE
22
+ * ```
23
+ *
24
+ * @private [🪔] Maybe export the commitments through some package
25
+ */
26
+ export declare class UseCommitmentDefinition extends BaseCommitmentDefinition<`USE${string}`> {
27
+ constructor();
28
+ /**
29
+ * Short one-line description of USE commitments.
30
+ */
31
+ get description(): string;
32
+ /**
33
+ * Icon for this commitment.
34
+ */
35
+ get icon(): string;
36
+ /**
37
+ * Markdown documentation for USE commitment.
38
+ */
39
+ get documentation(): string;
40
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
41
+ /**
42
+ * Extracts the tool type from the USE commitment
43
+ * This is used by the parsing logic
44
+ */
45
+ extractToolType(content: string): string | null;
46
+ /**
47
+ * Checks if this is a known USE type
48
+ */
49
+ isKnownUseType(useType: string): boolean;
50
+ }
51
+ /**
52
+ * Note: [💞] Ignore a discrepancy between file name and entity name
53
+ */
@@ -0,0 +1,38 @@
1
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
3
+ /**
4
+ * USE BROWSER commitment definition
5
+ *
6
+ * The `USE BROWSER` commitment indicates that the agent should utilize a web browser tool
7
+ * to access and retrieve up-to-date information from the internet when necessary.
8
+ *
9
+ * The content following `USE BROWSER` is ignored (similar to NOTE).
10
+ *
11
+ * Example usage in agent source:
12
+ *
13
+ * ```book
14
+ * USE BROWSER
15
+ * USE BROWSER This will be ignored
16
+ * ```
17
+ *
18
+ * @private [🪔] Maybe export the commitments through some package
19
+ */
20
+ export declare class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition<'USE BROWSER'> {
21
+ constructor();
22
+ /**
23
+ * Short one-line description of USE BROWSER.
24
+ */
25
+ get description(): string;
26
+ /**
27
+ * Icon for this commitment.
28
+ */
29
+ get icon(): string;
30
+ /**
31
+ * Markdown documentation for USE BROWSER commitment.
32
+ */
33
+ get documentation(): string;
34
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
35
+ }
36
+ /**
37
+ * Note: [💞] Ignore a discrepancy between file name and entity name
38
+ */
@@ -1,23 +1,34 @@
1
1
  import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
2
  import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
3
3
  /**
4
- * IMPORTANT co-commitment definition
4
+ * USE MCP commitment definition
5
5
  *
6
- * The IMPORTANT co-commitment modifies another commitment to emphasize its importance.
7
- * It is typically used with RULE to mark it as critical.
6
+ * The `USE MCP` commitment allows to specify an MCP server URL which the agent will connect to
7
+ * for retrieving additional instructions and actions.
8
+ *
9
+ * The content following `USE MCP` is the URL of the MCP server.
8
10
  *
9
11
  * Example usage in agent source:
10
12
  *
11
13
  * ```book
12
- * IMPORTANT RULE Never provide medical advice
14
+ * USE MCP http://mcp-server-url.com
13
15
  * ```
14
16
  *
15
17
  * @private [🪔] Maybe export the commitments through some package
16
18
  */
17
- export declare class ImportantCommitmentDefinition extends BaseCommitmentDefinition<'IMPORTANT'> {
19
+ export declare class UseMcpCommitmentDefinition extends BaseCommitmentDefinition<'USE MCP'> {
18
20
  constructor();
21
+ /**
22
+ * Short one-line description of USE MCP.
23
+ */
19
24
  get description(): string;
25
+ /**
26
+ * Icon for this commitment.
27
+ */
20
28
  get icon(): string;
29
+ /**
30
+ * Markdown documentation for USE MCP commitment.
31
+ */
21
32
  get documentation(): string;
22
33
  applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
23
34
  }
@@ -0,0 +1,38 @@
1
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
3
+ /**
4
+ * USE SEARCH ENGINE commitment definition
5
+ *
6
+ * The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
7
+ * to access and retrieve up-to-date information from the internet when necessary.
8
+ *
9
+ * The content following `USE SEARCH ENGINE` is ignored (similar to NOTE).
10
+ *
11
+ * Example usage in agent source:
12
+ *
13
+ * ```book
14
+ * USE SEARCH ENGINE
15
+ * USE SEARCH ENGINE This will be ignored
16
+ * ```
17
+ *
18
+ * @private [🪔] Maybe export the commitments through some package
19
+ */
20
+ export declare class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition<'USE SEARCH ENGINE'> {
21
+ constructor();
22
+ /**
23
+ * Short one-line description of USE SEARCH ENGINE.
24
+ */
25
+ get description(): string;
26
+ /**
27
+ * Icon for this commitment.
28
+ */
29
+ get icon(): string;
30
+ /**
31
+ * Markdown documentation for USE SEARCH ENGINE commitment.
32
+ */
33
+ get documentation(): string;
34
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
35
+ }
36
+ /**
37
+ * Note: [💞] Ignore a discrepancy between file name and entity name
38
+ */
@@ -1 +1,93 @@
1
- export * from './registry';
1
+ import type { BookCommitment } from './_base/BookCommitment';
2
+ import type { CommitmentDefinition } from './_base/CommitmentDefinition';
3
+ import { ActionCommitmentDefinition } from './ACTION/ACTION';
4
+ import { ClosedCommitmentDefinition } from './CLOSED/CLOSED';
5
+ import { ComponentCommitmentDefinition } from './COMPONENT/COMPONENT';
6
+ import { DeleteCommitmentDefinition } from './DELETE/DELETE';
7
+ import { FormatCommitmentDefinition } from './FORMAT/FORMAT';
8
+ import { FromCommitmentDefinition } from './FROM/FROM';
9
+ import { GoalCommitmentDefinition } from './GOAL/GOAL';
10
+ import { KnowledgeCommitmentDefinition } from './KNOWLEDGE/KNOWLEDGE';
11
+ import { LanguageCommitmentDefinition } from './LANGUAGE/LANGUAGE';
12
+ import { MemoryCommitmentDefinition } from './MEMORY/MEMORY';
13
+ import { AgentMessageCommitmentDefinition } from './MESSAGE/AgentMessageCommitmentDefinition';
14
+ import { InitialMessageCommitmentDefinition } from './MESSAGE/InitialMessageCommitmentDefinition';
15
+ import { MessageCommitmentDefinition } from './MESSAGE/MESSAGE';
16
+ import { UserMessageCommitmentDefinition } from './MESSAGE/UserMessageCommitmentDefinition';
17
+ import { MetaCommitmentDefinition } from './META/META';
18
+ import { MetaColorCommitmentDefinition } from './META_COLOR/META_COLOR';
19
+ import { MetaFontCommitmentDefinition } from './META_FONT/META_FONT';
20
+ import { MetaImageCommitmentDefinition } from './META_IMAGE/META_IMAGE';
21
+ import { MetaLinkCommitmentDefinition } from './META_LINK/META_LINK';
22
+ import { ModelCommitmentDefinition } from './MODEL/MODEL';
23
+ import { NoteCommitmentDefinition } from './NOTE/NOTE';
24
+ import { OpenCommitmentDefinition } from './OPEN/OPEN';
25
+ import { PersonaCommitmentDefinition } from './PERSONA/PERSONA';
26
+ import { RuleCommitmentDefinition } from './RULE/RULE';
27
+ import { SampleCommitmentDefinition } from './SAMPLE/SAMPLE';
28
+ import { ScenarioCommitmentDefinition } from './SCENARIO/SCENARIO';
29
+ import { StyleCommitmentDefinition } from './STYLE/STYLE';
30
+ import { UseCommitmentDefinition } from './USE/USE';
31
+ import { UseBrowserCommitmentDefinition } from './USE_BROWSER/USE_BROWSER';
32
+ import { UseMcpCommitmentDefinition } from './USE_MCP/USE_MCP';
33
+ import { UseSearchEngineCommitmentDefinition } from './USE_SEARCH_ENGINE/USE_SEARCH_ENGINE';
34
+ import { NotYetImplementedCommitmentDefinition } from './_base/NotYetImplementedCommitmentDefinition';
35
+ /**
36
+ * Registry of all available commitment definitions
37
+ * This array contains instances of all commitment definitions
38
+ * This is the single source of truth for all commitments in the system
39
+ *
40
+ * @private Use functions to access commitments instead of this array directly
41
+ */
42
+ export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, LanguageCommitmentDefinition, LanguageCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, FromCommitmentDefinition, ModelCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, ActionCommitmentDefinition, ComponentCommitmentDefinition, MetaImageCommitmentDefinition, MetaColorCommitmentDefinition, MetaFontCommitmentDefinition, MetaLinkCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, GoalCommitmentDefinition, InitialMessageCommitmentDefinition, UserMessageCommitmentDefinition, AgentMessageCommitmentDefinition, MessageCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, OpenCommitmentDefinition, ClosedCommitmentDefinition, UseBrowserCommitmentDefinition, UseSearchEngineCommitmentDefinition, UseMcpCommitmentDefinition, UseCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
43
+ /**
44
+ * Gets a commitment definition by its type
45
+ * @param type The commitment type to look up
46
+ * @returns The commitment definition or null if not found
47
+ *
48
+ * @public exported from `@promptbook/core`
49
+ */
50
+ export declare function getCommitmentDefinition(type: BookCommitment): CommitmentDefinition | null;
51
+ /**
52
+ * Gets all available commitment definitions
53
+ * @returns Array of all commitment definitions
54
+ *
55
+ * @public exported from `@promptbook/core`
56
+ */
57
+ export declare function getAllCommitmentDefinitions(): ReadonlyArray<CommitmentDefinition>;
58
+ /**
59
+ * Gets all available commitment types
60
+ * @returns Array of all commitment types
61
+ *
62
+ * @public exported from `@promptbook/core`
63
+ */
64
+ export declare function getAllCommitmentTypes(): ReadonlyArray<BookCommitment>;
65
+ /**
66
+ * Checks if a commitment type is supported
67
+ * @param type The commitment type to check
68
+ * @returns True if the commitment type is supported
69
+ *
70
+ * @public exported from `@promptbook/core`
71
+ */
72
+ export declare function isCommitmentSupported(type: BookCommitment): boolean;
73
+ /**
74
+ * Grouped commitment definition
75
+ *
76
+ * @public exported from `@promptbook/core`
77
+ */
78
+ export type GroupedCommitmentDefinition = {
79
+ primary: CommitmentDefinition;
80
+ aliases: string[];
81
+ };
82
+ /**
83
+ * Gets all commitment definitions grouped by their aliases
84
+ *
85
+ * @returns Array of grouped commitment definitions
86
+ *
87
+ * @public exported from `@promptbook/core`
88
+ */
89
+ export declare function getGroupedCommitmentDefinitions(): ReadonlyArray<GroupedCommitmentDefinition>;
90
+ /**
91
+ * TODO: [🧠] Maybe create through standardized $register
92
+ * Note: [💞] Ignore a discrepancy between file name and entity name
93
+ */
@@ -1,2 +1,5 @@
1
1
  #!/usr/bin/env ts-node
2
2
  export {};
3
+ /**
4
+ * Note: [⚫] Code in this file should never be published in any package
5
+ */
@@ -24,6 +24,14 @@ export declare class Color {
24
24
  * @returns Color object
25
25
  */
26
26
  static from(color: string_color | Color): WithTake<Color>;
27
+ /**
28
+ * Creates a new Color instance from miscellaneous formats
29
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
30
+ *
31
+ * @param color
32
+ * @returns Color object
33
+ */
34
+ static fromSafe(color: string_color | Color): WithTake<Color>;
27
35
  /**
28
36
  * Creates a new Color instance from miscellaneous string formats
29
37
  *
@@ -4,6 +4,7 @@
4
4
  * @public exported from `@promptbook/color`
5
5
  */
6
6
  export declare const CSS_COLORS: {
7
+ readonly promptbook: "#79EAFD";
7
8
  readonly transparent: "rgba(0,0,0,0)";
8
9
  readonly aliceblue: "#f0f8ff";
9
10
  readonly antiquewhite: "#faebd7";
@@ -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.103.0-54`).
18
+ * It follows semantic versioning (e.g., `0.103.0-55`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/anthropic-claude",
3
- "version": "0.103.0-55",
3
+ "version": "0.103.0-56",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -97,7 +97,7 @@
97
97
  "module": "./esm/index.es.js",
98
98
  "typings": "./esm/typings/src/_packages/anthropic-claude.index.d.ts",
99
99
  "peerDependencies": {
100
- "@promptbook/core": "0.103.0-55"
100
+ "@promptbook/core": "0.103.0-56"
101
101
  },
102
102
  "dependencies": {
103
103
  "@anthropic-ai/sdk": "0.68.0",
package/umd/index.umd.js CHANGED
@@ -1,12 +1,12 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('@anthropic-ai/sdk'), require('bottleneck'), require('colors'), require('crypto'), require('socket.io-client')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', '@anthropic-ai/sdk', 'bottleneck', 'colors', 'crypto', 'socket.io-client'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-anthropic-claude"] = {}, global.spaceTrim, global.Anthropic, global.Bottleneck, global.colors, global.crypto, global.socket_ioClient));
5
- })(this, (function (exports, spaceTrim, Anthropic, Bottleneck, colors, crypto, socket_ioClient) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-anthropic-claude"] = {}, global.spaceTrim$1, global.Anthropic, global.Bottleneck, global.colors, global.crypto, global.socket_ioClient));
5
+ })(this, (function (exports, spaceTrim$1, Anthropic, Bottleneck, colors, crypto, socket_ioClient) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
9
+ var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
10
10
  var Anthropic__default = /*#__PURE__*/_interopDefaultLegacy(Anthropic);
11
11
  var Bottleneck__default = /*#__PURE__*/_interopDefaultLegacy(Bottleneck);
12
12
  var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
@@ -25,7 +25,7 @@
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-55';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -73,6 +73,17 @@
73
73
  * TODO: [🧠] Is there a way how to meaningfully test this utility
74
74
  */
75
75
 
76
+ /**
77
+ * Trims string from all 4 sides
78
+ *
79
+ * Note: This is a re-exported function from the `spacetrim` package which is
80
+ * Developed by same author @hejny as this package
81
+ *
82
+ * @public exported from `@promptbook/utils`
83
+ * @see https://github.com/hejny/spacetrim#usage
84
+ */
85
+ const spaceTrim = spaceTrim$1.spaceTrim;
86
+
76
87
  /**
77
88
  * @private util of `@promptbook/color`
78
89
  * @de
@@ -121,6 +132,7 @@
121
132
  * @public exported from `@promptbook/color`
122
133
  */
123
134
  const CSS_COLORS = {
135
+ promptbook: '#79EAFD',
124
136
  transparent: 'rgba(0,0,0,0)',
125
137
  aliceblue: '#f0f8ff',
126
138
  antiquewhite: '#faebd7',
@@ -336,6 +348,28 @@
336
348
  throw new Error(`Can not create color from given object`);
337
349
  }
338
350
  }
351
+ /**
352
+ * Creates a new Color instance from miscellaneous formats
353
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
354
+ *
355
+ * @param color
356
+ * @returns Color object
357
+ */
358
+ static fromSafe(color) {
359
+ try {
360
+ return Color.from(color);
361
+ }
362
+ catch (error) {
363
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
364
+ console.warn(spaceTrim((block) => `
365
+ Color.fromSafe error:
366
+ ${block(error.message)}
367
+
368
+ Returning default PROMPTBOOK_COLOR.
369
+ `));
370
+ return Color.fromString('promptbook');
371
+ }
372
+ }
339
373
  /**
340
374
  * Creates a new Color instance from miscellaneous string formats
341
375
  *
@@ -925,7 +959,7 @@
925
959
  *
926
960
  * @public exported from `@promptbook/core`
927
961
  */
928
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
962
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
929
963
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
930
964
  /**
931
965
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1083,7 +1117,7 @@
1083
1117
  */
1084
1118
  class UnexpectedError extends Error {
1085
1119
  constructor(message) {
1086
- super(spaceTrim.spaceTrim((block) => `
1120
+ super(spaceTrim$1.spaceTrim((block) => `
1087
1121
  ${block(message)}
1088
1122
 
1089
1123
  Note: This error should not happen.
@@ -1109,7 +1143,7 @@
1109
1143
  constructor(whatWasThrown) {
1110
1144
  const tag = `[🤮]`;
1111
1145
  console.error(tag, whatWasThrown);
1112
- super(spaceTrim.spaceTrim(`
1146
+ super(spaceTrim$1.spaceTrim(`
1113
1147
  Non-Error object was thrown
1114
1148
 
1115
1149
  Note: Look for ${tag} in the console for more details
@@ -2643,7 +2677,7 @@
2643
2677
  */
2644
2678
  class MissingToolsError extends Error {
2645
2679
  constructor(message) {
2646
- super(spaceTrim.spaceTrim((block) => `
2680
+ super(spaceTrim$1.spaceTrim((block) => `
2647
2681
  ${block(message)}
2648
2682
 
2649
2683
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -2687,7 +2721,7 @@
2687
2721
  */
2688
2722
  class NotYetImplementedError extends Error {
2689
2723
  constructor(message) {
2690
- super(spaceTrim.spaceTrim((block) => `
2724
+ super(spaceTrim$1.spaceTrim((block) => `
2691
2725
  ${block(message)}
2692
2726
 
2693
2727
  Note: This feature is not implemented yet but it will be soon.