@agentxjs/types 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.
package/dist/index.js ADDED
@@ -0,0 +1,151 @@
1
+ // src/common/logger/LogLevel.ts
2
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
3
+ LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
4
+ LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
5
+ LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
6
+ LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
7
+ LogLevel2[LogLevel2["SILENT"] = 4] = "SILENT";
8
+ return LogLevel2;
9
+ })(LogLevel || {});
10
+
11
+ // src/llm/StopReason.ts
12
+ function isStopReason(value) {
13
+ return [
14
+ "end_turn",
15
+ "max_tokens",
16
+ "tool_use",
17
+ "stop_sequence",
18
+ "content_filter",
19
+ "error",
20
+ "other"
21
+ ].includes(value);
22
+ }
23
+
24
+ // src/mcp/McpProtocol.ts
25
+ var LATEST_PROTOCOL_VERSION = "2025-06-18";
26
+ var SUPPORTED_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
27
+
28
+ // src/guards/MessageGuards.ts
29
+ function isUserMessage(message) {
30
+ return message.subtype === "user";
31
+ }
32
+ function isAssistantMessage(message) {
33
+ return message.subtype === "assistant";
34
+ }
35
+ function isSystemMessage(message) {
36
+ return message.subtype === "system";
37
+ }
38
+ function isToolCallMessage(message) {
39
+ return message.subtype === "tool-call";
40
+ }
41
+ function isToolResultMessage(message) {
42
+ return message.subtype === "tool-result";
43
+ }
44
+
45
+ // src/guards/ContentPartGuards.ts
46
+ function isTextPart(part) {
47
+ return part.type === "text";
48
+ }
49
+ function isThinkingPart(part) {
50
+ return part.type === "thinking";
51
+ }
52
+ function isImagePart(part) {
53
+ return part.type === "image";
54
+ }
55
+ function isFilePart(part) {
56
+ return part.type === "file";
57
+ }
58
+ function isToolCallPart(part) {
59
+ return part.type === "tool-call";
60
+ }
61
+ function isToolResultPart(part) {
62
+ return part.type === "tool-result";
63
+ }
64
+
65
+ // src/guards/EventGuards.ts
66
+ var STATE_EVENT_TYPE_NAMES = [
67
+ "agent_initializing",
68
+ "agent_ready",
69
+ "agent_destroyed",
70
+ "conversation_queued",
71
+ "conversation_start",
72
+ "conversation_thinking",
73
+ "conversation_responding",
74
+ "conversation_end",
75
+ "conversation_interrupted",
76
+ "tool_planned",
77
+ "tool_executing",
78
+ "tool_completed",
79
+ "tool_failed",
80
+ "error_occurred"
81
+ ];
82
+ var STATE_EVENT_TYPES = new Set(STATE_EVENT_TYPE_NAMES);
83
+ var MESSAGE_EVENT_TYPE_NAMES = [
84
+ "user_message",
85
+ "assistant_message",
86
+ "tool_call_message",
87
+ "tool_result_message"
88
+ ];
89
+ var MESSAGE_EVENT_TYPES = new Set(MESSAGE_EVENT_TYPE_NAMES);
90
+ var ERROR_EVENT_TYPE_NAMES = ["error"];
91
+ var ERROR_EVENT_TYPES = new Set(ERROR_EVENT_TYPE_NAMES);
92
+ var TURN_EVENT_TYPE_NAMES = ["turn_request", "turn_response"];
93
+ var TURN_EVENT_TYPES = new Set(TURN_EVENT_TYPE_NAMES);
94
+ var STREAM_EVENT_TYPE_NAMES = [
95
+ "message_start",
96
+ "message_delta",
97
+ "message_stop",
98
+ "text_content_block_start",
99
+ "text_delta",
100
+ "text_content_block_stop",
101
+ "tool_use_content_block_start",
102
+ "input_json_delta",
103
+ "tool_use_content_block_stop",
104
+ "tool_call",
105
+ "tool_result",
106
+ "interrupted"
107
+ ];
108
+ var STREAM_EVENT_TYPES = new Set(STREAM_EVENT_TYPE_NAMES);
109
+ function isStateEvent(event) {
110
+ return "type" in event && STATE_EVENT_TYPES.has(event.type);
111
+ }
112
+ function isMessageEvent(event) {
113
+ return "type" in event && MESSAGE_EVENT_TYPES.has(event.type);
114
+ }
115
+ function isTurnEvent(event) {
116
+ return "type" in event && TURN_EVENT_TYPES.has(event.type);
117
+ }
118
+ function isStreamEvent(event) {
119
+ return "type" in event && STREAM_EVENT_TYPES.has(event.type);
120
+ }
121
+ function isErrorEvent(event) {
122
+ return "type" in event && ERROR_EVENT_TYPES.has(event.type);
123
+ }
124
+ export {
125
+ ERROR_EVENT_TYPE_NAMES,
126
+ LATEST_PROTOCOL_VERSION,
127
+ LogLevel,
128
+ MESSAGE_EVENT_TYPE_NAMES,
129
+ STATE_EVENT_TYPE_NAMES,
130
+ STREAM_EVENT_TYPE_NAMES,
131
+ SUPPORTED_PROTOCOL_VERSIONS,
132
+ TURN_EVENT_TYPE_NAMES,
133
+ isAssistantMessage,
134
+ isErrorEvent,
135
+ isFilePart,
136
+ isImagePart,
137
+ isMessageEvent,
138
+ isStateEvent,
139
+ isStopReason,
140
+ isStreamEvent,
141
+ isSystemMessage,
142
+ isTextPart,
143
+ isThinkingPart,
144
+ isToolCallMessage,
145
+ isToolCallPart,
146
+ isToolResultMessage,
147
+ isToolResultPart,
148
+ isTurnEvent,
149
+ isUserMessage
150
+ };
151
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/common/logger/LogLevel.ts","../src/llm/StopReason.ts","../src/mcp/McpProtocol.ts","../src/guards/MessageGuards.ts","../src/guards/ContentPartGuards.ts","../src/guards/EventGuards.ts"],"sourcesContent":["/**\n * LogLevel - Standard log level enumeration\n *\n * Defines the severity levels for logging.\n */\n\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n SILENT = 4,\n}\n","/**\n * Reason why the LLM stopped generating\n *\n * Based on common stop reasons across multiple LLM providers:\n * - Anthropic Claude: end_turn, max_tokens, tool_use, stop_sequence\n * - OpenAI: stop, length, tool_calls, content_filter\n * - Vercel AI SDK: stop, length, tool-calls, content-filter, error, other\n */\nexport type StopReason =\n /**\n * Natural completion - model decided to stop\n */\n | \"end_turn\"\n\n /**\n * Reached maximum token limit\n */\n | \"max_tokens\"\n\n /**\n * Model requested tool usage\n */\n | \"tool_use\"\n\n /**\n * Encountered a custom stop sequence\n */\n | \"stop_sequence\"\n\n /**\n * Content filter triggered\n */\n | \"content_filter\"\n\n /**\n * Error occurred during generation\n */\n | \"error\"\n\n /**\n * Other/unknown reason\n */\n | \"other\";\n\n/**\n * Type guard to check if a string is a valid StopReason\n */\nexport function isStopReason(value: string): value is StopReason {\n return [\n \"end_turn\",\n \"max_tokens\",\n \"tool_use\",\n \"stop_sequence\",\n \"content_filter\",\n \"error\",\n \"other\",\n ].includes(value);\n}\n","/**\n * MCP Protocol Version\n *\n * Model Context Protocol version constants.\n * Based on the official MCP specification.\n */\nexport const LATEST_PROTOCOL_VERSION = \"2025-06-18\" as const;\n\nexport const SUPPORTED_PROTOCOL_VERSIONS = [\"2025-06-18\", \"2025-03-26\", \"2024-11-05\"] as const;\n\nexport type McpProtocolVersion = (typeof SUPPORTED_PROTOCOL_VERSIONS)[number];\n","import type { Message } from \"~/message/Message\";\nimport type { UserMessage } from \"~/message/UserMessage\";\nimport type { AssistantMessage } from \"~/message/AssistantMessage\";\nimport type { SystemMessage } from \"~/message/SystemMessage\";\nimport type { ToolCallMessage } from \"~/message/ToolCallMessage\";\nimport type { ToolResultMessage } from \"~/message/ToolResultMessage\";\n\n/**\n * Type guard for UserMessage\n */\nexport function isUserMessage(message: Message): message is UserMessage {\n return message.subtype === \"user\";\n}\n\n/**\n * Type guard for AssistantMessage (text response, not tool call)\n */\nexport function isAssistantMessage(message: Message): message is AssistantMessage {\n return message.subtype === \"assistant\";\n}\n\n/**\n * Type guard for SystemMessage\n */\nexport function isSystemMessage(message: Message): message is SystemMessage {\n return message.subtype === \"system\";\n}\n\n/**\n * Type guard for ToolCallMessage\n */\nexport function isToolCallMessage(message: Message): message is ToolCallMessage {\n return message.subtype === \"tool-call\";\n}\n\n/**\n * Type guard for ToolResultMessage\n */\nexport function isToolResultMessage(message: Message): message is ToolResultMessage {\n return message.subtype === \"tool-result\";\n}\n","import type { ContentPart } from \"~/message/parts/ContentPart\";\nimport type { TextPart } from \"~/message/parts/TextPart\";\nimport type { ThinkingPart } from \"~/message/parts/ThinkingPart\";\nimport type { ImagePart } from \"~/message/parts/ImagePart\";\nimport type { FilePart } from \"~/message/parts/FilePart\";\nimport type { ToolCallPart } from \"~/message/parts/ToolCallPart\";\nimport type { ToolResultPart } from \"~/message/parts/ToolResultPart\";\n\n/**\n * Type guard for TextPart\n */\nexport function isTextPart(part: ContentPart): part is TextPart {\n return part.type === \"text\";\n}\n\n/**\n * Type guard for ThinkingPart\n */\nexport function isThinkingPart(part: ContentPart): part is ThinkingPart {\n return part.type === \"thinking\";\n}\n\n/**\n * Type guard for ImagePart\n */\nexport function isImagePart(part: ContentPart): part is ImagePart {\n return part.type === \"image\";\n}\n\n/**\n * Type guard for FilePart\n */\nexport function isFilePart(part: ContentPart): part is FilePart {\n return part.type === \"file\";\n}\n\n/**\n * Type guard for ToolCallPart\n */\nexport function isToolCallPart(part: ContentPart): part is ToolCallPart {\n return part.type === \"tool-call\";\n}\n\n/**\n * Type guard for ToolResultPart\n */\nexport function isToolResultPart(part: ContentPart): part is ToolResultPart {\n return part.type === \"tool-result\";\n}\n","/**\n * Event Type Guards\n *\n * Runtime type guards for event classification.\n */\n\nimport type { AgentOutput } from \"~/agent/AgentOutput\";\nimport type { StateEventType } from \"~/event/state\";\nimport type { StreamEventType } from \"~/event/stream\";\nimport type { MessageEventType } from \"~/event/message\";\nimport type { TurnEventType } from \"~/event/turn\";\nimport type { ErrorEvent } from \"~/event/error\";\n\n/**\n * State event type names (single source of truth)\n */\nexport const STATE_EVENT_TYPE_NAMES = [\n \"agent_initializing\",\n \"agent_ready\",\n \"agent_destroyed\",\n \"conversation_queued\",\n \"conversation_start\",\n \"conversation_thinking\",\n \"conversation_responding\",\n \"conversation_end\",\n \"conversation_interrupted\",\n \"tool_planned\",\n \"tool_executing\",\n \"tool_completed\",\n \"tool_failed\",\n \"error_occurred\",\n] as const;\n\nconst STATE_EVENT_TYPES = new Set<string>(STATE_EVENT_TYPE_NAMES);\n\n/**\n * Message event type names (single source of truth)\n */\nexport const MESSAGE_EVENT_TYPE_NAMES = [\n \"user_message\",\n \"assistant_message\",\n \"tool_call_message\",\n \"tool_result_message\",\n] as const;\n\nconst MESSAGE_EVENT_TYPES = new Set<string>(MESSAGE_EVENT_TYPE_NAMES);\n\n/**\n * Error event type names (single source of truth)\n * Error is independent from 4-layer hierarchy, transportable via SSE\n */\nexport const ERROR_EVENT_TYPE_NAMES = [\"error\"] as const;\n\nconst ERROR_EVENT_TYPES = new Set<string>(ERROR_EVENT_TYPE_NAMES);\n\n/**\n * Turn event type names (single source of truth)\n */\nexport const TURN_EVENT_TYPE_NAMES = [\"turn_request\", \"turn_response\"] as const;\n\nconst TURN_EVENT_TYPES = new Set<string>(TURN_EVENT_TYPE_NAMES);\n\n/**\n * Stream event type names (single source of truth)\n */\nexport const STREAM_EVENT_TYPE_NAMES = [\n \"message_start\",\n \"message_delta\",\n \"message_stop\",\n \"text_content_block_start\",\n \"text_delta\",\n \"text_content_block_stop\",\n \"tool_use_content_block_start\",\n \"input_json_delta\",\n \"tool_use_content_block_stop\",\n \"tool_call\",\n \"tool_result\",\n \"interrupted\",\n] as const;\n\nconst STREAM_EVENT_TYPES = new Set<string>(STREAM_EVENT_TYPE_NAMES);\n\n/**\n * Check if event is a StateEvent\n */\nexport function isStateEvent(event: AgentOutput): event is StateEventType {\n return \"type\" in event && STATE_EVENT_TYPES.has(event.type);\n}\n\n/**\n * Check if event is a MessageEvent\n */\nexport function isMessageEvent(event: AgentOutput): event is MessageEventType {\n return \"type\" in event && MESSAGE_EVENT_TYPES.has(event.type);\n}\n\n/**\n * Check if event is a TurnEvent\n */\nexport function isTurnEvent(event: AgentOutput): event is TurnEventType {\n return \"type\" in event && TURN_EVENT_TYPES.has(event.type);\n}\n\n/**\n * Check if event is a StreamEvent\n */\nexport function isStreamEvent(event: AgentOutput): event is StreamEventType {\n return \"type\" in event && STREAM_EVENT_TYPES.has(event.type);\n}\n\n/**\n * Check if event is an ErrorEvent\n */\nexport function isErrorEvent(event: AgentOutput): event is ErrorEvent {\n return \"type\" in event && ERROR_EVENT_TYPES.has(event.type);\n}\n"],"mappings":";AAMO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,oBAAA,WAAQ,KAAR;AACA,EAAAA,oBAAA,UAAO,KAAP;AACA,EAAAA,oBAAA,UAAO,KAAP;AACA,EAAAA,oBAAA,WAAQ,KAAR;AACA,EAAAA,oBAAA,YAAS,KAAT;AALU,SAAAA;AAAA,GAAA;;;ACyCL,SAAS,aAAa,OAAoC;AAC/D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,SAAS,KAAK;AAClB;;;ACnDO,IAAM,0BAA0B;AAEhC,IAAM,8BAA8B,CAAC,cAAc,cAAc,YAAY;;;ACE7E,SAAS,cAAc,SAA0C;AACtE,SAAO,QAAQ,YAAY;AAC7B;AAKO,SAAS,mBAAmB,SAA+C;AAChF,SAAO,QAAQ,YAAY;AAC7B;AAKO,SAAS,gBAAgB,SAA4C;AAC1E,SAAO,QAAQ,YAAY;AAC7B;AAKO,SAAS,kBAAkB,SAA8C;AAC9E,SAAO,QAAQ,YAAY;AAC7B;AAKO,SAAS,oBAAoB,SAAgD;AAClF,SAAO,QAAQ,YAAY;AAC7B;;;AC7BO,SAAS,WAAW,MAAqC;AAC9D,SAAO,KAAK,SAAS;AACvB;AAKO,SAAS,eAAe,MAAyC;AACtE,SAAO,KAAK,SAAS;AACvB;AAKO,SAAS,YAAY,MAAsC;AAChE,SAAO,KAAK,SAAS;AACvB;AAKO,SAAS,WAAW,MAAqC;AAC9D,SAAO,KAAK,SAAS;AACvB;AAKO,SAAS,eAAe,MAAyC;AACtE,SAAO,KAAK,SAAS;AACvB;AAKO,SAAS,iBAAiB,MAA2C;AAC1E,SAAO,KAAK,SAAS;AACvB;;;AChCO,IAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,oBAAoB,IAAI,IAAY,sBAAsB;AAKzD,IAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,sBAAsB,IAAI,IAAY,wBAAwB;AAM7D,IAAM,yBAAyB,CAAC,OAAO;AAE9C,IAAM,oBAAoB,IAAI,IAAY,sBAAsB;AAKzD,IAAM,wBAAwB,CAAC,gBAAgB,eAAe;AAErE,IAAM,mBAAmB,IAAI,IAAY,qBAAqB;AAKvD,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,qBAAqB,IAAI,IAAY,uBAAuB;AAK3D,SAAS,aAAa,OAA6C;AACxE,SAAO,UAAU,SAAS,kBAAkB,IAAI,MAAM,IAAI;AAC5D;AAKO,SAAS,eAAe,OAA+C;AAC5E,SAAO,UAAU,SAAS,oBAAoB,IAAI,MAAM,IAAI;AAC9D;AAKO,SAAS,YAAY,OAA4C;AACtE,SAAO,UAAU,SAAS,iBAAiB,IAAI,MAAM,IAAI;AAC3D;AAKO,SAAS,cAAc,OAA8C;AAC1E,SAAO,UAAU,SAAS,mBAAmB,IAAI,MAAM,IAAI;AAC7D;AAKO,SAAS,aAAa,OAAyC;AACpE,SAAO,UAAU,SAAS,kBAAkB,IAAI,MAAM,IAAI;AAC5D;","names":["LogLevel"]}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@agentxjs/types",
3
+ "version": "0.0.1",
4
+ "description": "Type definitions for Deepractice AgentX ecosystem",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.mjs",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "keywords": [
20
+ "agentx",
21
+ "agent",
22
+ "types",
23
+ "typescript",
24
+ "deepractice"
25
+ ],
26
+ "author": "Deepractice AI",
27
+ "license": "MIT",
28
+ "devDependencies": {
29
+ "tsup": "^8.0.1",
30
+ "typescript": "^5.3.3"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "clean": "rm -rf dist",
38
+ "lint": "eslint .",
39
+ "typecheck": "tsc --noEmit",
40
+ "dev": "tsup --watch"
41
+ }
42
+ }