@promptbook/remote-server 0.105.0-23 → 0.105.0-26

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.
@@ -9,6 +9,7 @@ import { isValidCsvString } from '../formats/csv/utils/isValidCsvString';
9
9
  import { isValidJsonString } from '../formats/json/utils/isValidJsonString';
10
10
  import { jsonParse } from '../formats/json/utils/jsonParse';
11
11
  import { isValidXmlString } from '../formats/xml/utils/isValidXmlString';
12
+ import { PromptString } from '../pipeline/prompt-notation';
12
13
  import { prompt } from '../pipeline/prompt-notation';
13
14
  import { promptTemplate } from '../pipeline/prompt-notation';
14
15
  import { $detectRuntimeEnvironment } from '../utils/environment/$detectRuntimeEnvironment';
@@ -99,6 +100,7 @@ export { isValidCsvString };
99
100
  export { isValidJsonString };
100
101
  export { jsonParse };
101
102
  export { isValidXmlString };
103
+ export { PromptString };
102
104
  export { prompt };
103
105
  export { promptTemplate };
104
106
  export { $detectRuntimeEnvironment };
@@ -43,12 +43,7 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'> & {
43
43
  * Optional metadata about teammates for team tool calls
44
44
  * Maps tool name to agent information
45
45
  */
46
- teammates?: Record<string, {
47
- url: string;
48
- label?: string;
49
- instructions?: string;
50
- toolName: string;
51
- }>;
46
+ teammates?: TeammatesMap;
52
47
  /**
53
48
  * Called when a tool call chiplet is clicked.
54
49
  */
@@ -58,6 +53,19 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'> & {
58
53
  */
59
54
  onCitationClick?: (citation: ParsedCitation) => void;
60
55
  };
56
+ /**
57
+ * Metadata for a teammate agent tool.
58
+ */
59
+ type TeammateMetadata = {
60
+ url: string;
61
+ label?: string;
62
+ instructions?: string;
63
+ toolName: string;
64
+ };
65
+ /**
66
+ * Lookup map of teammate metadata by tool name.
67
+ */
68
+ type TeammatesMap = Record<string, TeammateMetadata>;
61
69
  /**
62
70
  * Renders a single chat message item with avatar, content, buttons, and rating.
63
71
  *
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Builds a TEAM tool name from a teammate agent URL.
3
+ *
4
+ * @private utility of chat components
5
+ */
6
+ export declare function createTeamToolNameFromUrl(url: string): string;
7
+ /**
8
+ * Checks whether a tool name belongs to a TEAM tool.
9
+ *
10
+ * @private utility of chat components
11
+ */
12
+ export declare function isTeamToolName(name: string): boolean;
@@ -0,0 +1,69 @@
1
+ import type { string_url, string_url_image } from '../../../types/typeAliases';
2
+ /**
3
+ * Input data for resolving agent profiles.
4
+ * @private
5
+ */
6
+ export type AgentProfileInput = {
7
+ url: string_url;
8
+ label?: string;
9
+ imageUrl?: string_url_image;
10
+ publicUrl?: string_url;
11
+ };
12
+ /**
13
+ * Resolved agent profile data for UI usage.
14
+ * @private
15
+ */
16
+ export type AgentProfileData = {
17
+ label: string;
18
+ imageUrl: string_url_image | null;
19
+ };
20
+ /**
21
+ * Extracts agent name from URL.
22
+ * @private
23
+ */
24
+ export declare function extractAgentNameFromUrl(url: string): string;
25
+ /**
26
+ * Determines whether a label looks like an autogenerated identifier.
27
+ * @private
28
+ */
29
+ export declare function isLikelyGeneratedId(label: string): boolean;
30
+ /**
31
+ * Resolves the initial label for an agent without exposing generated IDs.
32
+ * @private
33
+ */
34
+ export declare function resolveInitialAgentLabel(agent: AgentProfileInput): string;
35
+ /**
36
+ * Picks the best available label from profile data without exposing IDs.
37
+ * @private
38
+ */
39
+ export declare function resolvePreferredAgentLabel(candidates: Array<string | undefined>, fallback: string): string;
40
+ /**
41
+ * Resolves the agents server base URL from the agent URL or provided public URL.
42
+ * @private
43
+ */
44
+ export declare function resolveAgentsServerUrl(agentUrl: string, publicUrl?: string_url): string | null;
45
+ /**
46
+ * Resolves the profile image URL, handling relative URLs when needed.
47
+ * @private
48
+ */
49
+ export declare function resolveProfileImageUrl(profileImageUrl: string_url_image | undefined, agentUrl: string_url, publicUrl?: string_url): string_url_image | null;
50
+ /**
51
+ * Builds a placeholder image URL for the agent when no profile image is available.
52
+ * @private
53
+ */
54
+ export declare function resolvePlaceholderImageUrl(agent: AgentProfileInput): string_url_image | null;
55
+ /**
56
+ * Returns true when a profile fetch would likely improve the label or image.
57
+ * @private
58
+ */
59
+ export declare function shouldFetchAgentProfile(agent: AgentProfileInput): boolean;
60
+ /**
61
+ * Resolves fallback profile data without fetching remote metadata.
62
+ * @private
63
+ */
64
+ export declare function resolveAgentProfileFallback(agent: AgentProfileInput): AgentProfileData;
65
+ /**
66
+ * Loads agent profile data from the agent profile endpoint when needed.
67
+ * @private
68
+ */
69
+ export declare function loadAgentProfile(agent: AgentProfileInput): Promise<AgentProfileData>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Props for the EmailIcon component.
3
+ */
4
+ type EmailIconProps = {
5
+ size?: number;
6
+ color?: string;
7
+ };
8
+ /**
9
+ * Renders an email/envelope icon.
10
+ *
11
+ * @param props - SVG properties augmented with an optional `size`
12
+ * @private internal subcomponent used by various components
13
+ */
14
+ export declare function EmailIcon({ size, color }: EmailIconProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -38,7 +38,8 @@ export declare class UseEmailCommitmentDefinition extends BaseCommitmentDefiniti
38
38
  getToolTitles(): Record<string_javascript_name, string>;
39
39
  /**
40
40
  * Gets the `send_email` tool function implementation.
41
- * Note: This is a placeholder - the actual implementation is provided by the agent server.
41
+ *
42
+ * Note: [??] This function has implementation both for browser and node, this is the proxied one for browser.
42
43
  */
43
44
  getToolFunctions(): Record<string_javascript_name, ToolFunction>;
44
45
  }
@@ -0,0 +1,11 @@
1
+ import type { ToolFunction } from '../../_packages/types.index';
2
+ /**
3
+ * Resolves the server-side implementation of the send_email tool for Node.js environments.
4
+ *
5
+ * This uses a lazy require so the core package can still load even if the Agents Server
6
+ * module is unavailable. When the server tool cannot be resolved, a fallback implementation
7
+ * throws a helpful error message.
8
+ *
9
+ * @private internal utility for USE EMAIL commitment
10
+ */
11
+ export declare function resolveSendEmailToolForNode(): ToolFunction;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Client-side safe wrapper for sending emails.
3
+ *
4
+ * This function proxies requests to the Agents Server API endpoint for email queuing,
5
+ * making it safe to use in browser environments.
6
+ *
7
+ * @param args Email payload containing recipients, subject, and body
8
+ * @param agentsServerUrl The base URL of the agents server (defaults to current origin)
9
+ * @returns Result string from the server-side send_email tool
10
+ *
11
+ * @private internal utility for USE EMAIL commitment
12
+ */
13
+ export declare function sendEmailViaBrowser(args: {
14
+ to: string[];
15
+ cc?: string[];
16
+ subject: string;
17
+ body: string;
18
+ }, agentsServerUrl?: string): Promise<string>;
@@ -0,0 +1,26 @@
1
+ import { ToolFunction } from '../../_packages/types.index';
2
+ import { string_javascript_name } from '../../types/typeAliases';
3
+ /**
4
+ * Map of tool functions keyed by function name.
5
+ *
6
+ * @private internal helper for commitment tool registry
7
+ */
8
+ export type CommitmentToolFunctions = Record<string_javascript_name, ToolFunction>;
9
+ /**
10
+ * Collects tool functions from all commitment definitions.
11
+ *
12
+ * @returns Map of tool function implementations.
13
+ * @private internal helper for commitment tool registry
14
+ */
15
+ export declare function collectCommitmentToolFunctions(): CommitmentToolFunctions;
16
+ /**
17
+ * Creates a proxy that resolves tool functions on demand.
18
+ *
19
+ * @param getFunctions - Provider of current tool functions.
20
+ * @returns Proxy exposing tool functions as properties.
21
+ * @private internal helper for commitment tool registry
22
+ */
23
+ export declare function createToolFunctionsProxy(getFunctions: () => CommitmentToolFunctions): CommitmentToolFunctions;
24
+ /**
25
+ * Note: [💞] Ignore a discrepancy between file name and entity name
26
+ */
@@ -1,5 +1,4 @@
1
- import { ToolFunction } from '../../_packages/types.index';
2
- import { string_javascript_name } from '../../types/typeAliases';
1
+ import type { CommitmentToolFunctions } from './commitmentToolFunctions';
3
2
  /**
4
3
  * Gets all function implementations provided by all commitments
5
4
  *
@@ -7,4 +6,4 @@ import { string_javascript_name } from '../../types/typeAliases';
7
6
  *
8
7
  * @public exported from `@promptbook/browser`
9
8
  */
10
- export declare function getAllCommitmentsToolFunctionsForBrowser(): Record<string_javascript_name, ToolFunction>;
9
+ export declare function getAllCommitmentsToolFunctionsForBrowser(): CommitmentToolFunctions;
@@ -1,5 +1,4 @@
1
- import { ToolFunction } from '../../_packages/types.index';
2
- import { string_javascript_name } from '../../types/typeAliases';
1
+ import { type CommitmentToolFunctions } from './commitmentToolFunctions';
3
2
  /**
4
3
  * Gets all function implementations provided by all commitments
5
4
  *
@@ -7,8 +6,8 @@ import { string_javascript_name } from '../../types/typeAliases';
7
6
  *
8
7
  * @public exported from `@promptbook/node`
9
8
  */
10
- export declare function getAllCommitmentsToolFunctionsForNode(): Record<string_javascript_name, ToolFunction>;
9
+ export declare function getAllCommitmentsToolFunctionsForNode(): CommitmentToolFunctions;
11
10
  /**
12
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
13
- * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
11
+ * Note: [??] Code in this file should never be never released in packages that could be imported into browser environment
12
+ * TODO: [??] Unite `xxxForServer` and `xxxForNode` naming
14
13
  */
@@ -116,6 +116,10 @@ export declare const LIMITS: {
116
116
  * @public exported from `@promptbook/core`
117
117
  */
118
118
  export declare const TIME_INTERVALS: {
119
+ /**
120
+ * Hundred milliseconds
121
+ */
122
+ readonly HUNDRED_MILLISECONDS: 100;
119
123
  /**
120
124
  * One second in milliseconds
121
125
  */
@@ -1,4 +1,28 @@
1
1
  import type { string_prompt } from '../types/typeAliases';
2
+ import type { really_unknown } from '../utils/organization/really_unknown';
3
+ /**
4
+ * Prompt string wrapper to retain prompt context across interpolations.
5
+ *
6
+ * @public exported from `@promptbook/utils`
7
+ */
8
+ export declare class PromptString extends String {
9
+ /**
10
+ * @param value Prompt content.
11
+ */
12
+ constructor(value: string_prompt);
13
+ /**
14
+ * Returns the prompt as a primitive string.
15
+ */
16
+ toString(): string_prompt;
17
+ /**
18
+ * Returns the prompt as a primitive string for implicit coercion.
19
+ */
20
+ valueOf(): string_prompt;
21
+ /**
22
+ * Ensures template literal coercion returns the raw string.
23
+ */
24
+ [Symbol.toPrimitive](): string_prompt;
25
+ }
2
26
  /**
3
27
  * Tag function for notating a prompt as template literal
4
28
  *
@@ -9,10 +33,10 @@ import type { string_prompt } from '../types/typeAliases';
9
33
  *
10
34
  * @param strings
11
35
  * @param values
12
- * @returns the prompt string
36
+ * @returns prompt content wrapped as a PromptString
13
37
  * @public exported from `@promptbook/utils`
14
38
  */
15
- export declare function prompt(strings: TemplateStringsArray, ...values: Array<string>): string_prompt;
39
+ export declare function prompt(strings: TemplateStringsArray, ...values: Array<really_unknown>): PromptString;
16
40
  /**
17
41
  * Tag function for notating a prompt as template literal
18
42
  *
@@ -26,6 +50,7 @@ export declare function prompt(strings: TemplateStringsArray, ...values: Array<s
26
50
  */
27
51
  export declare const promptTemplate: typeof prompt;
28
52
  /**
53
+ * TODO: Maybe split into multiple files
29
54
  * TODO: [🧠][🈴] Where is the best location for this file
30
55
  * Note: [💞] Ignore a discrepancy between file name and entity name
31
56
  */
@@ -1,4 +1,4 @@
1
1
  export {};
2
2
  /**
3
- * TODO: [🧠][🈴] Where is the best location for this file
3
+ * TODO: [??][??] Where is the best location for this file
4
4
  */
@@ -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.105.0-22`).
18
+ * It follows semantic versioning (e.g., `0.105.0-25`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.105.0-23",
3
+ "version": "0.105.0-26",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -95,10 +95,11 @@
95
95
  "module": "./esm/index.es.js",
96
96
  "typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
97
97
  "peerDependencies": {
98
- "@promptbook/core": "0.105.0-23"
98
+ "@promptbook/core": "0.105.0-26"
99
99
  },
100
100
  "dependencies": {
101
101
  "@mozilla/readability": "0.6.0",
102
+ "bottleneck": "2.19.5",
102
103
  "colors": "1.4.0",
103
104
  "crypto": "1.0.1",
104
105
  "crypto-js": "4.2.0",
@@ -106,6 +107,7 @@
106
107
  "express-openapi-validator": "5.4.9",
107
108
  "jsdom": "25.0.1",
108
109
  "moment": "2.30.1",
110
+ "openai": "4.63.0",
109
111
  "papaparse": "5.4.1",
110
112
  "react": "18.2.0",
111
113
  "rxjs": "7.8.2",