@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,220 @@
1
+ /**
2
+ * Tool Types
3
+ *
4
+ * Platform-independent types for tool calling.
5
+ * Used by both backend (@agentick/core) and frontend (@agentick/client).
6
+ */
7
+ import type { ContentBlock } from "./blocks";
8
+ /**
9
+ * Tool execution type determines how and where the tool is CONFIGURED to execute.
10
+ * This is the tool's definition - where it SHOULD run.
11
+ */
12
+ export declare enum ToolExecutionType {
13
+ /**
14
+ * Server-executed: Tool runs on the engine server (default).
15
+ * Tool has a `run` method that executes synchronously.
16
+ */
17
+ SERVER = "server",
18
+ /**
19
+ * Client-executed: Tool call is delegated to client/3rd party.
20
+ * May or may not require feedback before continuing execution.
21
+ */
22
+ CLIENT = "client",
23
+ /**
24
+ * Provider-executed: Tool is executed by the model provider (e.g., Google grounding).
25
+ * Tool results come directly from provider, bypassing ToolExecutor.
26
+ */
27
+ PROVIDER = "provider",
28
+ /**
29
+ * MCP-executed: Tool is executed by an MCP (Model Context Protocol) server.
30
+ * Engine acts as MCP client, forwarding calls to external MCP servers.
31
+ */
32
+ MCP = "mcp",
33
+ /**
34
+ * Output tool: Emits structured data without returning to the model.
35
+ * The tool's input (validated against schema) is collected in result.outputs.
36
+ * No tool_result is sent back to the model - the data flows out of the app.
37
+ * Use for extracting structured data from the model's reasoning.
38
+ */
39
+ OUTPUT = "output"
40
+ }
41
+ /**
42
+ * Tool executor identifies WHO actually executed a tool.
43
+ *
44
+ * Different from ToolExecutionType which is WHERE the tool is configured to run.
45
+ * A SERVER-type tool can be executed by either the engine or an adapter library.
46
+ */
47
+ export type ToolExecutor =
48
+ /** Executed by Agentick engine's ToolExecutor */
49
+ "engine"
50
+ /** Executed by adapter library (e.g., AI SDK with maxSteps) */
51
+ | "adapter"
52
+ /** Executed by the AI provider (e.g., OpenAI code interpreter, Google grounding) */
53
+ | "provider"
54
+ /** Executed by the client (browser/frontend) */
55
+ | "client";
56
+ /**
57
+ * Tool intent describes WHAT the tool does, independent of WHERE it runs.
58
+ * Used by clients to determine how to render/handle tool calls.
59
+ */
60
+ export declare enum ToolIntent {
61
+ /**
62
+ * Renders UI in the client (form, chart, document, code output).
63
+ * The tool_use block becomes renderable content.
64
+ */
65
+ RENDER = "render",
66
+ /**
67
+ * Performs an action (navigate, clipboard, notification, native feature).
68
+ * Side-effect focused, may not produce visible output.
69
+ */
70
+ ACTION = "action",
71
+ /**
72
+ * Computes/transforms data (default for most tools).
73
+ * Returns data that becomes part of the conversation.
74
+ */
75
+ COMPUTE = "compute"
76
+ }
77
+ /**
78
+ * Tool call - represents a tool call made by the model.
79
+ *
80
+ * Used in streaming, execution tracking, and message content.
81
+ */
82
+ export interface ToolCall {
83
+ /** Unique ID for this tool call (correlates with tool_result) */
84
+ id: string;
85
+ /** Tool name */
86
+ name: string;
87
+ /** Tool input parameters */
88
+ input: Record<string, unknown>;
89
+ /** Result of tool execution (present after execution) */
90
+ result?: ToolResult;
91
+ }
92
+ /**
93
+ * Tool result - represents the result of a tool execution.
94
+ *
95
+ * Used in stream events and execution tracking.
96
+ */
97
+ export interface ToolResult {
98
+ /** Optional unique ID for the result itself */
99
+ id?: string;
100
+ /** ID of the tool call this result is for (matches ToolCall.id) */
101
+ toolUseId: string;
102
+ /** Tool name */
103
+ name: string;
104
+ /** Whether execution succeeded */
105
+ success: boolean;
106
+ /** Result content (tool results are ContentBlock[] for rich output) */
107
+ content: ContentBlock[];
108
+ /** Error message if success is false */
109
+ error?: string;
110
+ /** Who executed this tool */
111
+ executedBy?: ToolExecutor;
112
+ /**
113
+ * Execution metadata for observability.
114
+ */
115
+ metadata?: {
116
+ executionTimeMs?: number;
117
+ retryCount?: number;
118
+ cacheHit?: boolean;
119
+ [key: string]: unknown;
120
+ };
121
+ }
122
+ /**
123
+ * Simplified tool definition - platform-independent base structure.
124
+ * Used for direct tool execution from clients.
125
+ *
126
+ * Backend extends this with providerOptions, libraryOptions, mcpConfig.
127
+ */
128
+ export interface ToolDefinition {
129
+ /** Tool name */
130
+ name: string;
131
+ /** Tool description for the model */
132
+ description: string;
133
+ /** JSON Schema for tool input */
134
+ input: Record<string, unknown>;
135
+ /** Optional JSON Schema for tool output (for validation/documentation) */
136
+ output?: Record<string, unknown>;
137
+ /**
138
+ * Tool execution type. Determines how the tool is executed.
139
+ * Default: SERVER (engine executes tool.run on server).
140
+ */
141
+ type?: ToolExecutionType;
142
+ /**
143
+ * Tool intent describes what the tool does (render, action, compute).
144
+ * Used by clients to determine how to render/handle tool calls.
145
+ * Default: COMPUTE
146
+ */
147
+ intent?: ToolIntent;
148
+ /**
149
+ * Whether execution should wait for client response.
150
+ * Only applicable for CLIENT type tools.
151
+ * - true: Server pauses and waits for tool_result from client (e.g., forms)
152
+ * - false: Server continues immediately with defaultResult (e.g., charts)
153
+ * Default: false
154
+ */
155
+ requiresResponse?: boolean;
156
+ /**
157
+ * Timeout in milliseconds when waiting for client response.
158
+ * Only applicable when requiresResponse is true.
159
+ * Default: 30000 (30 seconds)
160
+ */
161
+ timeout?: number;
162
+ /**
163
+ * Default result to use when requiresResponse is false.
164
+ * Returned immediately for render tools that don't need client feedback.
165
+ * Default: [{ type: 'text', text: '[{name} rendered on client]' }]
166
+ */
167
+ defaultResult?: ContentBlock[];
168
+ }
169
+ /**
170
+ * Client tool definition - sent by clients to declare available tools.
171
+ * Simplified interface for client-provided tools.
172
+ *
173
+ * Note: This is the platform-independent structure. Backend-specific
174
+ * fields (like providerOptions) are added when converting to ToolDefinition.
175
+ */
176
+ export interface ClientToolDefinition {
177
+ /** Tool name */
178
+ name: string;
179
+ /** Tool description for the model */
180
+ description: string;
181
+ /** JSON Schema for tool input */
182
+ input: Record<string, unknown>;
183
+ /** Optional JSON Schema for tool output (for validation/documentation) */
184
+ output?: Record<string, unknown>;
185
+ /**
186
+ * Tool intent (render, action, compute).
187
+ * Default: RENDER (most client tools render UI)
188
+ */
189
+ intent?: ToolIntent;
190
+ /**
191
+ * Whether server should wait for client response.
192
+ * Default: false (render tools return default result immediately)
193
+ */
194
+ requiresResponse?: boolean;
195
+ /**
196
+ * Timeout in ms when waiting for response.
197
+ * Default: 30000
198
+ */
199
+ timeout?: number;
200
+ /**
201
+ * Default result when requiresResponse is false.
202
+ * Default: [{ type: 'text', text: '[{name} rendered on client]' }]
203
+ */
204
+ defaultResult?: ContentBlock[];
205
+ }
206
+ /**
207
+ * Result of a tool confirmation, includes tool metadata for hooks/events.
208
+ * Used internally and in stream events.
209
+ */
210
+ export interface ToolConfirmationResult {
211
+ /** ID of the tool call */
212
+ toolUseId: string;
213
+ /** Name of the tool */
214
+ toolName: string;
215
+ /** Whether the tool execution was allowed */
216
+ confirmed: boolean;
217
+ /** Whether this is a persistent preference */
218
+ always: boolean;
219
+ }
220
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;GAGG;AACH,oBAAY,iBAAiB;IAC3B;;;OAGG;IACH,MAAM,WAAW;IAEjB;;;OAGG;IACH,MAAM,WAAW;IAEjB;;;OAGG;IACH,QAAQ,aAAa;IAErB;;;OAGG;IACH,GAAG,QAAQ;IAEX;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY;AACtB,iDAAiD;AAC/C,QAAQ;AACV,+DAA+D;GAC7D,SAAS;AACX,oFAAoF;GAClF,UAAU;AACZ,gDAAgD;GAC9C,QAAQ,CAAC;AAEb;;;GAGG;AACH,oBAAY,UAAU;IACpB;;;OAGG;IACH,MAAM,WAAW;IAEjB;;;OAGG;IACH,MAAM,WAAW;IAEjB;;;OAGG;IACH,OAAO,YAAY;CACpB;AAMD;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,iEAAiE;IACjE,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,yDAAyD;IACzD,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAChC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAChC;AASD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,MAAM,EAAE,OAAO,CAAC;CACjB"}
package/dist/tools.js ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Tool Types
3
+ *
4
+ * Platform-independent types for tool calling.
5
+ * Used by both backend (@agentick/core) and frontend (@agentick/client).
6
+ */
7
+ /**
8
+ * Tool execution type determines how and where the tool is CONFIGURED to execute.
9
+ * This is the tool's definition - where it SHOULD run.
10
+ */
11
+ export var ToolExecutionType;
12
+ (function (ToolExecutionType) {
13
+ /**
14
+ * Server-executed: Tool runs on the engine server (default).
15
+ * Tool has a `run` method that executes synchronously.
16
+ */
17
+ ToolExecutionType["SERVER"] = "server";
18
+ /**
19
+ * Client-executed: Tool call is delegated to client/3rd party.
20
+ * May or may not require feedback before continuing execution.
21
+ */
22
+ ToolExecutionType["CLIENT"] = "client";
23
+ /**
24
+ * Provider-executed: Tool is executed by the model provider (e.g., Google grounding).
25
+ * Tool results come directly from provider, bypassing ToolExecutor.
26
+ */
27
+ ToolExecutionType["PROVIDER"] = "provider";
28
+ /**
29
+ * MCP-executed: Tool is executed by an MCP (Model Context Protocol) server.
30
+ * Engine acts as MCP client, forwarding calls to external MCP servers.
31
+ */
32
+ ToolExecutionType["MCP"] = "mcp";
33
+ /**
34
+ * Output tool: Emits structured data without returning to the model.
35
+ * The tool's input (validated against schema) is collected in result.outputs.
36
+ * No tool_result is sent back to the model - the data flows out of the app.
37
+ * Use for extracting structured data from the model's reasoning.
38
+ */
39
+ ToolExecutionType["OUTPUT"] = "output";
40
+ })(ToolExecutionType || (ToolExecutionType = {}));
41
+ /**
42
+ * Tool intent describes WHAT the tool does, independent of WHERE it runs.
43
+ * Used by clients to determine how to render/handle tool calls.
44
+ */
45
+ export var ToolIntent;
46
+ (function (ToolIntent) {
47
+ /**
48
+ * Renders UI in the client (form, chart, document, code output).
49
+ * The tool_use block becomes renderable content.
50
+ */
51
+ ToolIntent["RENDER"] = "render";
52
+ /**
53
+ * Performs an action (navigate, clipboard, notification, native feature).
54
+ * Side-effect focused, may not produce visible output.
55
+ */
56
+ ToolIntent["ACTION"] = "action";
57
+ /**
58
+ * Computes/transforms data (default for most tools).
59
+ * Returns data that becomes part of the conversation.
60
+ */
61
+ ToolIntent["COMPUTE"] = "compute";
62
+ })(ToolIntent || (ToolIntent = {}));
63
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,MAAM,CAAN,IAAY,iBAgCX;AAhCD,WAAY,iBAAiB;IAC3B;;;OAGG;IACH,sCAAiB,CAAA;IAEjB;;;OAGG;IACH,sCAAiB,CAAA;IAEjB;;;OAGG;IACH,0CAAqB,CAAA;IAErB;;;OAGG;IACH,gCAAW,CAAA;IAEX;;;;;OAKG;IACH,sCAAiB,CAAA;AACnB,CAAC,EAhCW,iBAAiB,KAAjB,iBAAiB,QAgC5B;AAkBD;;;GAGG;AACH,MAAM,CAAN,IAAY,UAkBX;AAlBD,WAAY,UAAU;IACpB;;;OAGG;IACH,+BAAiB,CAAA;IAEjB;;;OAGG;IACH,+BAAiB,CAAA;IAEjB;;;OAGG;IACH,iCAAmB,CAAA;AACrB,CAAC,EAlBW,UAAU,KAAV,UAAU,QAkBrB"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * ID generation utilities for streaming events
3
+ *
4
+ * Format: <prefix>_<hex>
5
+ * - Messages: msg_a1b2c3d4e5f6g7h8
6
+ * - Content blocks: blk_a1b2c3d4e5f6g7h8
7
+ * - Tool calls: tool_a1b2c3d4e5f6g7h8
8
+ * - Tool results: result_a1b2c3d4e5f6g7h8
9
+ */
10
+ /**
11
+ * Generate a unique message ID
12
+ */
13
+ export declare function generateMessageId(): string;
14
+ /**
15
+ * Generate a unique content block ID
16
+ */
17
+ export declare function generateContentId(): string;
18
+ /**
19
+ * Generate a unique tool call ID
20
+ */
21
+ export declare function generateToolCallId(): string;
22
+ /**
23
+ * Generate a unique tool result ID
24
+ */
25
+ export declare function generateToolResultId(): string;
26
+ //# sourceMappingURL=entity-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-ids.d.ts","sourceRoot":"","sources":["../../src/utils/entity-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * ID generation utilities for streaming events
3
+ *
4
+ * Format: <prefix>_<hex>
5
+ * - Messages: msg_a1b2c3d4e5f6g7h8
6
+ * - Content blocks: blk_a1b2c3d4e5f6g7h8
7
+ * - Tool calls: tool_a1b2c3d4e5f6g7h8
8
+ * - Tool results: result_a1b2c3d4e5f6g7h8
9
+ */
10
+ /**
11
+ * Generate a cryptographically secure random ID with prefix.
12
+ * Uses Web Crypto API (works in both Node.js 15+ and browsers).
13
+ */
14
+ function generateRandomId(prefix) {
15
+ const bytes = new Uint8Array(8);
16
+ globalThis.crypto.getRandomValues(bytes);
17
+ const randomHex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
18
+ return `${prefix}_${randomHex}`;
19
+ }
20
+ /**
21
+ * Generate a unique message ID
22
+ */
23
+ export function generateMessageId() {
24
+ return generateRandomId("msg");
25
+ }
26
+ /**
27
+ * Generate a unique content block ID
28
+ */
29
+ export function generateContentId() {
30
+ return generateRandomId("blk");
31
+ }
32
+ /**
33
+ * Generate a unique tool call ID
34
+ */
35
+ export function generateToolCallId() {
36
+ return generateRandomId("tool");
37
+ }
38
+ /**
39
+ * Generate a unique tool result ID
40
+ */
41
+ export function generateToolResultId() {
42
+ return generateRandomId("result");
43
+ }
44
+ //# sourceMappingURL=entity-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-ids.js","sourceRoot":"","sources":["../../src/utils/entity-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,SAAS,gBAAgB,CAAC,MAAc;IACtC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAChC,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrF,OAAO,GAAG,MAAM,IAAI,SAAS,EAAE,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./entity-ids";
2
+ export * from "./merge-deep";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./entity-ids";
2
+ export * from "./merge-deep";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Deep merge utility function that recursively merges objects.
3
+ * Arrays are replaced, not merged.
4
+ *
5
+ * @param target - The target object to merge into
6
+ * @param sources - Source objects to merge from
7
+ * @returns The merged object
8
+ */
9
+ export declare function mergeDeep<T extends Record<string, any>>(target: T, ...sources: Array<Partial<T> | undefined>): T;
10
+ //# sourceMappingURL=merge-deep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-deep.d.ts","sourceRoot":"","sources":["../../src/utils/merge-deep.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrD,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,GACxC,CAAC,CAgBH"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Deep merge utility function that recursively merges objects.
3
+ * Arrays are replaced, not merged.
4
+ *
5
+ * @param target - The target object to merge into
6
+ * @param sources - Source objects to merge from
7
+ * @returns The merged object
8
+ */
9
+ export function mergeDeep(target, ...sources) {
10
+ if (!sources.length)
11
+ return target;
12
+ const source = sources.shift();
13
+ if (isObject(target) && isObject(source)) {
14
+ for (const key in source) {
15
+ if (isObject(source[key])) {
16
+ if (!target[key])
17
+ Object.assign(target, { [key]: {} });
18
+ mergeDeep(target[key], source[key]);
19
+ }
20
+ else {
21
+ Object.assign(target, { [key]: source[key] });
22
+ }
23
+ }
24
+ }
25
+ return mergeDeep(target, ...sources);
26
+ }
27
+ /**
28
+ * Check if a value is a plain object (not array, null, or other types)
29
+ */
30
+ function isObject(item) {
31
+ return item && typeof item === "object" && !Array.isArray(item);
32
+ }
33
+ //# sourceMappingURL=merge-deep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-deep.js","sourceRoot":"","sources":["../../src/utils/merge-deep.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,MAAS,EACT,GAAG,OAAsC;IAEzC,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAE/B,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;oBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACvD,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAS,QAAQ,CAAC,IAAS;IACzB,OAAO,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@agentick/shared",
3
+ "version": "0.0.1",
4
+ "description": "Shared types and utilities for Agentick",
5
+ "keywords": [
6
+ "agent",
7
+ "ai",
8
+ "types"
9
+ ],
10
+ "license": "ISC",
11
+ "author": "Ryan Lindgren",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ },
22
+ "./blocks": {
23
+ "types": "./dist/blocks.d.ts",
24
+ "import": "./dist/blocks.js"
25
+ },
26
+ "./block-types": {
27
+ "types": "./dist/block-types.d.ts",
28
+ "import": "./dist/block-types.js"
29
+ },
30
+ "./tools": {
31
+ "types": "./dist/tools.d.ts",
32
+ "import": "./dist/tools.js"
33
+ },
34
+ "./input": {
35
+ "types": "./dist/input.d.ts",
36
+ "import": "./dist/input.js"
37
+ },
38
+ "./messages": {
39
+ "types": "./dist/messages.d.ts",
40
+ "import": "./dist/messages.js"
41
+ },
42
+ "./streaming": {
43
+ "types": "./dist/streaming.d.ts",
44
+ "import": "./dist/streaming.js"
45
+ },
46
+ "./models": {
47
+ "types": "./dist/models.d.ts",
48
+ "import": "./dist/models.js"
49
+ },
50
+ "./timeline": {
51
+ "types": "./dist/timeline.d.ts",
52
+ "import": "./dist/timeline.js"
53
+ },
54
+ "./errors": {
55
+ "types": "./dist/errors.d.ts",
56
+ "import": "./dist/errors.js"
57
+ },
58
+ "./identity": {
59
+ "types": "./dist/identity.d.ts",
60
+ "import": "./dist/identity.js"
61
+ },
62
+ "./testing": {
63
+ "types": "./dist/testing/index.d.ts",
64
+ "import": "./dist/testing/index.js"
65
+ },
66
+ "./utils": {
67
+ "types": "./dist/utils/index.d.ts",
68
+ "import": "./dist/utils/index.js"
69
+ }
70
+ },
71
+ "publishConfig": {
72
+ "access": "public"
73
+ },
74
+ "scripts": {
75
+ "build": "tsc -p tsconfig.build.json",
76
+ "test": "echo \"Tests run from workspace root\"",
77
+ "typecheck": "tsc -p tsconfig.build.json --noEmit",
78
+ "lint": "oxlint src/",
79
+ "format:check": "oxfmt --check src/",
80
+ "clean": "rm -rf dist",
81
+ "dev": "tsc --watch"
82
+ },
83
+ "types": "./dist/index.d.ts"
84
+ }