@agentick/shared 0.0.1

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.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +322 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/.tsbuildinfo.build +1 -0
  5. package/dist/block-types.d.ts +85 -0
  6. package/dist/block-types.d.ts.map +1 -0
  7. package/dist/block-types.js +98 -0
  8. package/dist/block-types.js.map +1 -0
  9. package/dist/blocks.d.ts +396 -0
  10. package/dist/blocks.d.ts.map +1 -0
  11. package/dist/blocks.js +209 -0
  12. package/dist/blocks.js.map +1 -0
  13. package/dist/devtools.d.ts +672 -0
  14. package/dist/devtools.d.ts.map +1 -0
  15. package/dist/devtools.js +445 -0
  16. package/dist/devtools.js.map +1 -0
  17. package/dist/errors.d.ts +335 -0
  18. package/dist/errors.d.ts.map +1 -0
  19. package/dist/errors.js +529 -0
  20. package/dist/errors.js.map +1 -0
  21. package/dist/identity.d.ts +99 -0
  22. package/dist/identity.d.ts.map +1 -0
  23. package/dist/identity.js +116 -0
  24. package/dist/identity.js.map +1 -0
  25. package/dist/index.d.ts +56 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +56 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/input.d.ts +55 -0
  30. package/dist/input.d.ts.map +1 -0
  31. package/dist/input.js +83 -0
  32. package/dist/input.js.map +1 -0
  33. package/dist/messages.d.ts +98 -0
  34. package/dist/messages.d.ts.map +1 -0
  35. package/dist/messages.js +81 -0
  36. package/dist/messages.js.map +1 -0
  37. package/dist/model-catalog.d.ts +144 -0
  38. package/dist/model-catalog.d.ts.map +1 -0
  39. package/dist/model-catalog.js +861 -0
  40. package/dist/model-catalog.js.map +1 -0
  41. package/dist/models.d.ts +173 -0
  42. package/dist/models.d.ts.map +1 -0
  43. package/dist/models.js +10 -0
  44. package/dist/models.js.map +1 -0
  45. package/dist/protocol.d.ts +257 -0
  46. package/dist/protocol.d.ts.map +1 -0
  47. package/dist/protocol.js +41 -0
  48. package/dist/protocol.js.map +1 -0
  49. package/dist/streaming.d.ts +635 -0
  50. package/dist/streaming.d.ts.map +1 -0
  51. package/dist/streaming.js +134 -0
  52. package/dist/streaming.js.map +1 -0
  53. package/dist/testing/fixtures.d.ts +250 -0
  54. package/dist/testing/fixtures.d.ts.map +1 -0
  55. package/dist/testing/fixtures.js +827 -0
  56. package/dist/testing/fixtures.js.map +1 -0
  57. package/dist/testing/helpers.d.ts +95 -0
  58. package/dist/testing/helpers.d.ts.map +1 -0
  59. package/dist/testing/helpers.js +271 -0
  60. package/dist/testing/helpers.js.map +1 -0
  61. package/dist/testing/index.d.ts +42 -0
  62. package/dist/testing/index.d.ts.map +1 -0
  63. package/dist/testing/index.js +70 -0
  64. package/dist/testing/index.js.map +1 -0
  65. package/dist/timeline.d.ts +59 -0
  66. package/dist/timeline.d.ts.map +1 -0
  67. package/dist/timeline.js +11 -0
  68. package/dist/timeline.js.map +1 -0
  69. package/dist/tools.d.ts +220 -0
  70. package/dist/tools.d.ts.map +1 -0
  71. package/dist/tools.js +63 -0
  72. package/dist/tools.js.map +1 -0
  73. package/dist/utils/entity-ids.d.ts +26 -0
  74. package/dist/utils/entity-ids.d.ts.map +1 -0
  75. package/dist/utils/entity-ids.js +44 -0
  76. package/dist/utils/entity-ids.js.map +1 -0
  77. package/dist/utils/index.d.ts +3 -0
  78. package/dist/utils/index.d.ts.map +1 -0
  79. package/dist/utils/index.js +3 -0
  80. package/dist/utils/index.js.map +1 -0
  81. package/dist/utils/merge-deep.d.ts +10 -0
  82. package/dist/utils/merge-deep.d.ts.map +1 -0
  83. package/dist/utils/merge-deep.js +33 -0
  84. package/dist/utils/merge-deep.js.map +1 -0
  85. package/package.json +84 -0
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Symbol-based identity utilities for minification-safe type checking.
3
+ *
4
+ * Functions can be marked with symbols to identify them even after minification
5
+ * where function names are mangled.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Define a symbol for your component type
10
+ * const MY_COMPONENT_SYMBOL = Symbol.for('agentick.myComponent');
11
+ *
12
+ * // Mark the component
13
+ * export const MyComponent = markWithSymbol(MY_COMPONENT_SYMBOL, (props) => {
14
+ * return createElement(MyComponent, props);
15
+ * });
16
+ *
17
+ * // Check identity (minification-safe)
18
+ * if (hasSymbol(someFunction, MY_COMPONENT_SYMBOL)) {
19
+ * // It's a MyComponent
20
+ * }
21
+ * ```
22
+ */
23
+ /**
24
+ * Symbol used to mark host primitive components.
25
+ * These are structural primitives that should be handled by the renderer,
26
+ * not executed as functions.
27
+ */
28
+ export const HOST_PRIMITIVE_SYMBOL = Symbol.for("agentick.hostPrimitive");
29
+ /**
30
+ * Symbol used to mark semantic components.
31
+ */
32
+ export const SEMANTIC_COMPONENT_SYMBOL = Symbol.for("agentick.semanticComponent");
33
+ /**
34
+ * Symbol used to mark content components.
35
+ */
36
+ export const CONTENT_COMPONENT_SYMBOL = Symbol.for("agentick.contentComponent");
37
+ /**
38
+ * Check if a value has a specific symbol marker.
39
+ *
40
+ * @param value - The value to check
41
+ * @param symbol - The symbol to look for
42
+ * @returns True if the value has the symbol marker
43
+ */
44
+ export function hasSymbol(value, symbol) {
45
+ return (typeof value === "function" && value[symbol] === true);
46
+ }
47
+ /**
48
+ * Mark a function with a symbol for identity checking.
49
+ * Returns the same function with the symbol attached.
50
+ *
51
+ * @param symbol - The symbol to attach
52
+ * @param fn - The function to mark
53
+ * @returns The same function with the symbol attached
54
+ */
55
+ export function markWithSymbol(symbol, fn) {
56
+ fn[symbol] = true;
57
+ return fn;
58
+ }
59
+ /**
60
+ * Mark a function as a host primitive.
61
+ * Host primitives are structural components that should be handled by the
62
+ * renderer directly, not executed as functions.
63
+ *
64
+ * @param fn - The function to mark as a host primitive
65
+ * @returns The same function marked as a host primitive
66
+ */
67
+ export function markAsHostPrimitive(fn) {
68
+ return markWithSymbol(HOST_PRIMITIVE_SYMBOL, fn);
69
+ }
70
+ /**
71
+ * Check if a value is a host primitive component.
72
+ * Minification-safe - uses symbol identity, not function name.
73
+ *
74
+ * @param value - The value to check
75
+ * @returns True if it's a host primitive
76
+ */
77
+ export function isHostPrimitive(value) {
78
+ return hasSymbol(value, HOST_PRIMITIVE_SYMBOL);
79
+ }
80
+ /**
81
+ * Mark a function as a semantic component.
82
+ *
83
+ * @param fn - The function to mark
84
+ * @returns The same function marked as a semantic component
85
+ */
86
+ export function markAsSemanticComponent(fn) {
87
+ return markWithSymbol(SEMANTIC_COMPONENT_SYMBOL, fn);
88
+ }
89
+ /**
90
+ * Check if a value is a semantic component.
91
+ *
92
+ * @param value - The value to check
93
+ * @returns True if it's a semantic component
94
+ */
95
+ export function isSemanticComponent(value) {
96
+ return hasSymbol(value, SEMANTIC_COMPONENT_SYMBOL);
97
+ }
98
+ /**
99
+ * Mark a function as a content component.
100
+ *
101
+ * @param fn - The function to mark
102
+ * @returns The same function marked as a content component
103
+ */
104
+ export function markAsContentComponent(fn) {
105
+ return markWithSymbol(CONTENT_COMPONENT_SYMBOL, fn);
106
+ }
107
+ /**
108
+ * Check if a value is a content component.
109
+ *
110
+ * @param value - The value to check
111
+ * @returns True if it's a content component
112
+ */
113
+ export function isContentComponent(value) {
114
+ return hasSymbol(value, CONTENT_COMPONENT_SYMBOL);
115
+ }
116
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AAE1E;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAElF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAEhF;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,MAAc;IACtD,OAAO,CACL,OAAO,KAAK,KAAK,UAAU,IAAK,KAA4C,CAAC,MAAM,CAAC,KAAK,IAAI,CAC9F,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAqB,MAAc,EAAE,EAAK;IACrE,EAA8B,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC/C,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAqB,EAAK;IAC3D,OAAO,cAAc,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,SAAS,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;AACjD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAqB,EAAK;IAC/D,OAAO,cAAc,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,SAAS,CAAC,KAAK,EAAE,yBAAyB,CAAC,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAqB,EAAK;IAC9D,OAAO,cAAc,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,SAAS,CAAC,KAAK,EAAE,wBAAwB,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * # Agentick Shared Types
3
+ *
4
+ * Platform-independent type definitions shared across all Agentick packages.
5
+ * These types define the core data structures for messages, content blocks,
6
+ * tools, and streaming.
7
+ *
8
+ * ## Content Blocks
9
+ *
10
+ * Content blocks are discriminated unions representing all content types:
11
+ *
12
+ * - **Text** - Plain text content
13
+ * - **Image/Audio/Video** - Media content with base64 or URL sources
14
+ * - **ToolUse/ToolResult** - Tool call requests and responses
15
+ * - **Code** - Executable code blocks
16
+ *
17
+ * ## Messages
18
+ *
19
+ * Messages represent conversation entries with roles:
20
+ *
21
+ * - `user` - Human input
22
+ * - `assistant` - Model responses
23
+ * - `system` - System prompts
24
+ * - `tool_result` - Tool execution results
25
+ *
26
+ * ## Usage
27
+ *
28
+ * ```typescript
29
+ * import type { Message, ContentBlock, ToolDefinition } from '@agentick/shared';
30
+ *
31
+ * const message: Message = {
32
+ * role: 'user',
33
+ * content: [{ type: 'text', text: 'Hello!' }]
34
+ * };
35
+ * ```
36
+ *
37
+ * @see {@link ContentBlock} - All content block types
38
+ * @see {@link Message} - Conversation message structure
39
+ * @see {@link ToolDefinition} - Tool schema definition
40
+ *
41
+ * @module @agentick/shared
42
+ */
43
+ export * from "./block-types";
44
+ export * from "./blocks";
45
+ export * from "./messages";
46
+ export * from "./streaming";
47
+ export * from "./tools";
48
+ export * from "./models";
49
+ export * from "./input";
50
+ export * from "./timeline";
51
+ export * from "./errors";
52
+ export * from "./identity";
53
+ export * from "./devtools";
54
+ export * from "./protocol";
55
+ export * from "./model-catalog";
56
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ /**
2
+ * # Agentick Shared Types
3
+ *
4
+ * Platform-independent type definitions shared across all Agentick packages.
5
+ * These types define the core data structures for messages, content blocks,
6
+ * tools, and streaming.
7
+ *
8
+ * ## Content Blocks
9
+ *
10
+ * Content blocks are discriminated unions representing all content types:
11
+ *
12
+ * - **Text** - Plain text content
13
+ * - **Image/Audio/Video** - Media content with base64 or URL sources
14
+ * - **ToolUse/ToolResult** - Tool call requests and responses
15
+ * - **Code** - Executable code blocks
16
+ *
17
+ * ## Messages
18
+ *
19
+ * Messages represent conversation entries with roles:
20
+ *
21
+ * - `user` - Human input
22
+ * - `assistant` - Model responses
23
+ * - `system` - System prompts
24
+ * - `tool_result` - Tool execution results
25
+ *
26
+ * ## Usage
27
+ *
28
+ * ```typescript
29
+ * import type { Message, ContentBlock, ToolDefinition } from '@agentick/shared';
30
+ *
31
+ * const message: Message = {
32
+ * role: 'user',
33
+ * content: [{ type: 'text', text: 'Hello!' }]
34
+ * };
35
+ * ```
36
+ *
37
+ * @see {@link ContentBlock} - All content block types
38
+ * @see {@link Message} - Conversation message structure
39
+ * @see {@link ToolDefinition} - Tool schema definition
40
+ *
41
+ * @module @agentick/shared
42
+ */
43
+ export * from "./block-types";
44
+ export * from "./blocks";
45
+ export * from "./messages";
46
+ export * from "./streaming";
47
+ export * from "./tools";
48
+ export * from "./models";
49
+ export * from "./input";
50
+ export * from "./timeline";
51
+ export * from "./errors";
52
+ export * from "./identity";
53
+ export * from "./devtools";
54
+ export * from "./protocol";
55
+ export * from "./model-catalog";
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Input Normalization Types
3
+ *
4
+ * Platform-independent types for flexible input handling.
5
+ * Used by both backend (@agentick/core) and frontend (@agentick/client) for
6
+ * normalizing various input formats into standardized structures.
7
+ */
8
+ import type { ContentBlock } from "./blocks";
9
+ import type { Message } from "./messages";
10
+ /**
11
+ * Flexible content input - accepts string or ContentBlock
12
+ */
13
+ export type ContentInput = ContentBlock | string;
14
+ /**
15
+ * Flexible content array input - accepts single or array of ContentInput
16
+ */
17
+ export type ContentInputArray = ContentInput | ContentInput[];
18
+ /**
19
+ * Flexible message input - accepts various message formats
20
+ *
21
+ * Can be:
22
+ * - Single string
23
+ * - Array of strings
24
+ * - Single Message
25
+ * - Array of Messages
26
+ * - Single ContentBlock
27
+ * - Array of ContentBlocks
28
+ * - Mixed ContentInputArray
29
+ */
30
+ export type MessageInput = ContentInputArray | Message | Message[];
31
+ /**
32
+ * Check if value is a ContentBlock.
33
+ * Validates that `type` is a known block type, not just any object with a type property.
34
+ */
35
+ export declare function isContentBlock(value: unknown): value is ContentBlock;
36
+ /**
37
+ * Check if value is a Message
38
+ */
39
+ export declare function isMessage(value: unknown): value is Message;
40
+ /**
41
+ * Normalize ContentInput to ContentBlock
42
+ */
43
+ export declare function normalizeContentInput(input: ContentInput): ContentBlock;
44
+ /**
45
+ * Normalize ContentInputArray to ContentBlock[]
46
+ */
47
+ export declare function normalizeContentArray(input: ContentInputArray): ContentBlock[];
48
+ /**
49
+ * Normalize MessageInput to Message[]
50
+ *
51
+ * @param input - Flexible message input
52
+ * @param role - Default role if input is not already a Message (default: 'user')
53
+ */
54
+ export declare function normalizeMessageInput(input: MessageInput, role?: Message["role"]): Message[];
55
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAM1C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,MAAM,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,YAAY,EAAE,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,OAAO,GAAG,OAAO,EAAE,CAAC;AAgCnE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAMpE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAMD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAEvE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,EAAE,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,IAAI,GAAE,OAAO,CAAC,MAAM,CAAU,GAC7B,OAAO,EAAE,CAQX"}
package/dist/input.js ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Input Normalization Types
3
+ *
4
+ * Platform-independent types for flexible input handling.
5
+ * Used by both backend (@agentick/core) and frontend (@agentick/client) for
6
+ * normalizing various input formats into standardized structures.
7
+ */
8
+ // ============================================================================
9
+ // Type Guards
10
+ // ============================================================================
11
+ /**
12
+ * Valid content block types
13
+ */
14
+ const VALID_BLOCK_TYPES = new Set([
15
+ "text",
16
+ "image",
17
+ "document",
18
+ "audio",
19
+ "video",
20
+ "tool_use",
21
+ "tool_result",
22
+ "reasoning",
23
+ "json",
24
+ "xml",
25
+ "csv",
26
+ "html",
27
+ "code",
28
+ "generated_image",
29
+ "generated_file",
30
+ "executable_code",
31
+ "code_execution_result",
32
+ "user_action",
33
+ "system_event",
34
+ "state_change",
35
+ ]);
36
+ /**
37
+ * Check if value is a ContentBlock.
38
+ * Validates that `type` is a known block type, not just any object with a type property.
39
+ */
40
+ export function isContentBlock(value) {
41
+ if (typeof value !== "object" || value === null) {
42
+ return false;
43
+ }
44
+ const obj = value;
45
+ return typeof obj["type"] === "string" && VALID_BLOCK_TYPES.has(obj["type"]);
46
+ }
47
+ /**
48
+ * Check if value is a Message
49
+ */
50
+ export function isMessage(value) {
51
+ return typeof value === "object" && value !== null && "role" in value && "content" in value;
52
+ }
53
+ // ============================================================================
54
+ // Normalization Functions
55
+ // ============================================================================
56
+ /**
57
+ * Normalize ContentInput to ContentBlock
58
+ */
59
+ export function normalizeContentInput(input) {
60
+ return typeof input === "string" ? { type: "text", text: input } : input;
61
+ }
62
+ /**
63
+ * Normalize ContentInputArray to ContentBlock[]
64
+ */
65
+ export function normalizeContentArray(input) {
66
+ return Array.isArray(input) ? input.map(normalizeContentInput) : [normalizeContentInput(input)];
67
+ }
68
+ /**
69
+ * Normalize MessageInput to Message[]
70
+ *
71
+ * @param input - Flexible message input
72
+ * @param role - Default role if input is not already a Message (default: 'user')
73
+ */
74
+ export function normalizeMessageInput(input, role = "user") {
75
+ if (Array.isArray(input) && input.length > 0 && isMessage(input[0])) {
76
+ return input;
77
+ }
78
+ if (isMessage(input)) {
79
+ return [input];
80
+ }
81
+ return [{ role, content: normalizeContentArray(input) }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,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAwB;IAC5D,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;AAClG,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAmB,EACnB,OAAwB,MAAM;IAE9B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,OAAO,KAAkB,CAAC;IAC5B,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,qBAAqB,CAAC,KAA0B,CAAC,EAAE,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Message types for model input/output.
3
+ *
4
+ * Messages represent conversation entries with specific roles:
5
+ * - `user` - Human input messages
6
+ * - `assistant` - Model-generated responses
7
+ * - `system` - System/behavioral instructions
8
+ * - `tool` - Tool/function call results
9
+ * - `event` - Application events (user actions, system events, state changes)
10
+ *
11
+ * @example Creating messages
12
+ * ```typescript
13
+ * const userMsg = createUserMessage('Hello!');
14
+ * const systemMsg = createSystemMessage('You are a helpful assistant.');
15
+ * const assistantMsg: AssistantMessage = {
16
+ * role: 'assistant',
17
+ * content: [{ type: 'text', text: 'Hi there!' }]
18
+ * };
19
+ * ```
20
+ *
21
+ * @see {@link Message} - Base message interface
22
+ * @see {@link ContentBlock} - Content block types
23
+ *
24
+ * @module
25
+ */
26
+ import type { MessageRoles } from "./block-types";
27
+ import type { ContentBlock, EventAllowedBlock } from "./blocks";
28
+ /**
29
+ * Base message interface for all message types.
30
+ *
31
+ * Messages are the fundamental unit of conversation in Agentick.
32
+ * Each message has a role indicating its source and an array
33
+ * of content blocks.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const message: Message = {
38
+ * id: 'msg-123',
39
+ * role: 'user',
40
+ * content: [{ type: 'text', text: 'Hello!' }],
41
+ * metadata: { source: 'web' }
42
+ * };
43
+ * ```
44
+ *
45
+ * @see {@link UserMessage}, {@link AssistantMessage}, {@link SystemMessage}
46
+ */
47
+ export interface Message {
48
+ /** Unique message identifier */
49
+ readonly id?: string;
50
+ /** Message role (user, assistant, system, tool, event) */
51
+ readonly role: MessageRoles;
52
+ /** Array of content blocks */
53
+ readonly content: ContentBlock[];
54
+ /** Additional metadata */
55
+ readonly metadata?: Record<string, any>;
56
+ /** When the message was created */
57
+ readonly createdAt?: string | Date;
58
+ /** When the message was last updated */
59
+ readonly updatedAt?: string | Date;
60
+ }
61
+ export interface ModelMessage extends Message {
62
+ }
63
+ /** Message from a user/human */
64
+ export interface UserMessage extends Message {
65
+ readonly role: "user";
66
+ }
67
+ /** Message from the AI assistant/model */
68
+ export interface AssistantMessage extends Message {
69
+ readonly role: "assistant";
70
+ }
71
+ /** System instruction message (typically at conversation start) */
72
+ export interface SystemMessage extends Message {
73
+ readonly role: "system";
74
+ }
75
+ /** Tool/function execution result message */
76
+ export interface ToolMessage extends Message {
77
+ readonly role: "tool";
78
+ /** ID of the tool call this result is for */
79
+ readonly toolCallId?: string;
80
+ }
81
+ /** Application event message (user actions, system events, state changes) */
82
+ export interface EventMessage extends Message {
83
+ readonly role: "event";
84
+ readonly content: EventAllowedBlock[];
85
+ /** Categorization of the event type */
86
+ readonly eventType?: string;
87
+ }
88
+ export declare function createUserMessage(content: ContentBlock[] | string, metadata?: Record<string, any>): UserMessage;
89
+ export declare function createAssistantMessage(content: ContentBlock[] | string, metadata?: Record<string, any>): AssistantMessage;
90
+ export declare function createSystemMessage(content: ContentBlock[] | string, metadata?: Record<string, any>): SystemMessage;
91
+ export declare function isUserMessage(message: Message): message is UserMessage;
92
+ export declare function isAssistantMessage(message: Message): message is AssistantMessage;
93
+ export declare function isSystemMessage(message: Message): message is SystemMessage;
94
+ export declare function isToolMessage(message: Message): message is ToolMessage;
95
+ export declare function isEventMessage(message: Message): message is EventMessage;
96
+ export declare function createToolMessage(content: ContentBlock[] | string, toolCallId?: string, metadata?: Record<string, any>): ToolMessage;
97
+ export declare function createEventMessage(content: EventAllowedBlock[] | string, eventType?: string, metadata?: Record<string, any>): EventMessage;
98
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAMhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,OAAO;IACtB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC;IACjC,0BAA0B;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,mCAAmC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,wCAAwC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,YAAa,SAAQ,OAAO;CAAG;AAEhD,gCAAgC;AAChC,MAAM,WAAW,WAAY,SAAQ,OAAO;I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AEhF;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,aAAa,CAE1E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,WAAW,CAEtE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,YAAY,CAExE;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,EAChC,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,WAAW,CAOb;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,iBAAiB,EAAE,GAAG,MAAM,EACrC,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,YAAY,CAOd"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Message types for model input/output.
3
+ *
4
+ * Messages represent conversation entries with specific roles:
5
+ * - `user` - Human input messages
6
+ * - `assistant` - Model-generated responses
7
+ * - `system` - System/behavioral instructions
8
+ * - `tool` - Tool/function call results
9
+ * - `event` - Application events (user actions, system events, state changes)
10
+ *
11
+ * @example Creating messages
12
+ * ```typescript
13
+ * const userMsg = createUserMessage('Hello!');
14
+ * const systemMsg = createSystemMessage('You are a helpful assistant.');
15
+ * const assistantMsg: AssistantMessage = {
16
+ * role: 'assistant',
17
+ * content: [{ type: 'text', text: 'Hi there!' }]
18
+ * };
19
+ * ```
20
+ *
21
+ * @see {@link Message} - Base message interface
22
+ * @see {@link ContentBlock} - Content block types
23
+ *
24
+ * @module
25
+ */
26
+ // ============================================================================
27
+ // Message Helpers
28
+ // ============================================================================
29
+ export function createUserMessage(content, metadata) {
30
+ return {
31
+ role: "user",
32
+ content: typeof content === "string" ? [{ type: "text", text: content }] : content,
33
+ metadata,
34
+ };
35
+ }
36
+ export function createAssistantMessage(content, metadata) {
37
+ return {
38
+ role: "assistant",
39
+ content: typeof content === "string" ? [{ type: "text", text: content }] : content,
40
+ metadata,
41
+ };
42
+ }
43
+ export function createSystemMessage(content, metadata) {
44
+ return {
45
+ role: "system",
46
+ content: typeof content === "string" ? [{ type: "text", text: content }] : content,
47
+ metadata,
48
+ };
49
+ }
50
+ export function isUserMessage(message) {
51
+ return message.role === "user";
52
+ }
53
+ export function isAssistantMessage(message) {
54
+ return message.role === "assistant";
55
+ }
56
+ export function isSystemMessage(message) {
57
+ return message.role === "system";
58
+ }
59
+ export function isToolMessage(message) {
60
+ return message.role === "tool";
61
+ }
62
+ export function isEventMessage(message) {
63
+ return message.role === "event";
64
+ }
65
+ export function createToolMessage(content, toolCallId, metadata) {
66
+ return {
67
+ role: "tool",
68
+ content: typeof content === "string" ? [{ type: "text", text: content }] : content,
69
+ toolCallId,
70
+ metadata,
71
+ };
72
+ }
73
+ export function createEventMessage(content, eventType, metadata) {
74
+ return {
75
+ role: "event",
76
+ content: typeof content === "string" ? [{ type: "text", text: content }] : content,
77
+ eventType,
78
+ metadata,
79
+ };
80
+ }
81
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA2EH,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,MAAM,UAAU,iBAAiB,CAC/B,OAAgC,EAChC,QAA8B;IAE9B,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;QAClF,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,OAAgC,EAChC,QAA8B;IAE9B,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