@cogitator-ai/types 0.1.0
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/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/agent.d.ts +41 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +5 -0
- package/dist/agent.js.map +1 -0
- package/dist/errors.d.ts +108 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +179 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/llm.d.ts +55 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/llm.js +5 -0
- package/dist/llm.js.map +1 -0
- package/dist/memory.d.ts +207 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +5 -0
- package/dist/memory.js.map +1 -0
- package/dist/message.d.ts +33 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +5 -0
- package/dist/message.js.map +1 -0
- package/dist/runtime.d.ts +106 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -0
- package/dist/sandbox.d.ts +120 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +5 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/swarm.d.ts +362 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +5 -0
- package/dist/swarm.js.map +1 -0
- package/dist/tool.d.ts +43 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +5 -0
- package/dist/tool.js.map +1 -0
- package/dist/workflow.d.ts +678 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +16 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Cogitator Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @cogitator-ai/types
|
|
2
|
+
|
|
3
|
+
Shared TypeScript types for the Cogitator AI agent runtime.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @cogitator-ai/types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import type { Agent, Tool, Message, RunResult } from '@cogitator-ai/types';
|
|
15
|
+
|
|
16
|
+
const agent: Agent = {
|
|
17
|
+
name: 'my-agent',
|
|
18
|
+
instructions: 'You are a helpful assistant',
|
|
19
|
+
model: 'ollama/llama3.2:3b',
|
|
20
|
+
};
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Types
|
|
24
|
+
|
|
25
|
+
- **Agent** - Agent configuration
|
|
26
|
+
- **Tool** - Tool definition with Zod schemas
|
|
27
|
+
- **Message** - Chat messages (user, assistant, tool)
|
|
28
|
+
- **RunResult** - Execution results with usage stats
|
|
29
|
+
- **Workflow** - DAG workflow definitions
|
|
30
|
+
- **Swarm** - Multi-agent swarm configurations
|
|
31
|
+
- **Memory** - Memory adapters and context builders
|
|
32
|
+
|
|
33
|
+
## Documentation
|
|
34
|
+
|
|
35
|
+
See the [Cogitator documentation](https://github.com/eL1fe/cogitator) for full API reference.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent types
|
|
3
|
+
*/
|
|
4
|
+
import type { Tool } from './tool';
|
|
5
|
+
import type { ZodType } from 'zod';
|
|
6
|
+
export interface AgentConfig {
|
|
7
|
+
id?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
model: string;
|
|
11
|
+
instructions: string;
|
|
12
|
+
tools?: Tool[];
|
|
13
|
+
temperature?: number;
|
|
14
|
+
topP?: number;
|
|
15
|
+
maxTokens?: number;
|
|
16
|
+
stopSequences?: string[];
|
|
17
|
+
responseFormat?: ResponseFormat;
|
|
18
|
+
maxIterations?: number;
|
|
19
|
+
timeout?: number;
|
|
20
|
+
}
|
|
21
|
+
export type ResponseFormat = {
|
|
22
|
+
type: 'text';
|
|
23
|
+
} | {
|
|
24
|
+
type: 'json';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'json_schema';
|
|
27
|
+
schema: ZodType;
|
|
28
|
+
};
|
|
29
|
+
export interface Agent {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly config: AgentConfig;
|
|
33
|
+
/** Model accessor (shortcut to config.model) */
|
|
34
|
+
readonly model: string;
|
|
35
|
+
/** Instructions accessor (shortcut to config.instructions) */
|
|
36
|
+
readonly instructions: string;
|
|
37
|
+
/** Tools accessor (shortcut to config.tools) */
|
|
38
|
+
readonly tools: Tool[];
|
|
39
|
+
clone(overrides: Partial<AgentConfig>): Agent;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,MAAM,WAAW,WAAW;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7C,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;IACvB,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;CAC/C"}
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error types for Cogitator
|
|
3
|
+
*
|
|
4
|
+
* Provides a comprehensive error system with:
|
|
5
|
+
* - Typed error codes for programmatic handling
|
|
6
|
+
* - HTTP status codes for API responses
|
|
7
|
+
* - Error details for debugging
|
|
8
|
+
* - Cause chaining for root cause analysis
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Error codes organized by domain
|
|
12
|
+
*/
|
|
13
|
+
export declare enum ErrorCode {
|
|
14
|
+
LLM_UNAVAILABLE = "LLM_UNAVAILABLE",
|
|
15
|
+
LLM_RATE_LIMITED = "LLM_RATE_LIMITED",
|
|
16
|
+
LLM_TIMEOUT = "LLM_TIMEOUT",
|
|
17
|
+
LLM_INVALID_RESPONSE = "LLM_INVALID_RESPONSE",
|
|
18
|
+
LLM_CONTEXT_LENGTH_EXCEEDED = "LLM_CONTEXT_LENGTH_EXCEEDED",
|
|
19
|
+
LLM_CONTENT_FILTERED = "LLM_CONTENT_FILTERED",
|
|
20
|
+
SANDBOX_UNAVAILABLE = "SANDBOX_UNAVAILABLE",
|
|
21
|
+
SANDBOX_TIMEOUT = "SANDBOX_TIMEOUT",
|
|
22
|
+
SANDBOX_OOM = "SANDBOX_OOM",
|
|
23
|
+
SANDBOX_EXECUTION_FAILED = "SANDBOX_EXECUTION_FAILED",
|
|
24
|
+
SANDBOX_INVALID_MODULE = "SANDBOX_INVALID_MODULE",
|
|
25
|
+
TOOL_NOT_FOUND = "TOOL_NOT_FOUND",
|
|
26
|
+
TOOL_INVALID_ARGS = "TOOL_INVALID_ARGS",
|
|
27
|
+
TOOL_EXECUTION_FAILED = "TOOL_EXECUTION_FAILED",
|
|
28
|
+
TOOL_TIMEOUT = "TOOL_TIMEOUT",
|
|
29
|
+
MEMORY_UNAVAILABLE = "MEMORY_UNAVAILABLE",
|
|
30
|
+
MEMORY_WRITE_FAILED = "MEMORY_WRITE_FAILED",
|
|
31
|
+
MEMORY_READ_FAILED = "MEMORY_READ_FAILED",
|
|
32
|
+
AGENT_NOT_FOUND = "AGENT_NOT_FOUND",
|
|
33
|
+
AGENT_ALREADY_RUNNING = "AGENT_ALREADY_RUNNING",
|
|
34
|
+
AGENT_MAX_ITERATIONS = "AGENT_MAX_ITERATIONS",
|
|
35
|
+
WORKFLOW_NOT_FOUND = "WORKFLOW_NOT_FOUND",
|
|
36
|
+
WORKFLOW_STEP_FAILED = "WORKFLOW_STEP_FAILED",
|
|
37
|
+
WORKFLOW_CYCLE_DETECTED = "WORKFLOW_CYCLE_DETECTED",
|
|
38
|
+
SWARM_NO_WORKERS = "SWARM_NO_WORKERS",
|
|
39
|
+
SWARM_CONSENSUS_FAILED = "SWARM_CONSENSUS_FAILED",
|
|
40
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
41
|
+
CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
|
|
42
|
+
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
43
|
+
NOT_IMPLEMENTED = "NOT_IMPLEMENTED",
|
|
44
|
+
CIRCUIT_OPEN = "CIRCUIT_OPEN"
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Maps error codes to HTTP status codes
|
|
48
|
+
*/
|
|
49
|
+
export declare const ERROR_STATUS_CODES: Record<ErrorCode, number>;
|
|
50
|
+
/**
|
|
51
|
+
* Error details for additional context
|
|
52
|
+
*/
|
|
53
|
+
export type ErrorDetails = Record<string, unknown>;
|
|
54
|
+
/**
|
|
55
|
+
* Options for creating a CogitatorError
|
|
56
|
+
*/
|
|
57
|
+
export interface CogitatorErrorOptions {
|
|
58
|
+
message: string;
|
|
59
|
+
code: ErrorCode;
|
|
60
|
+
statusCode?: number;
|
|
61
|
+
details?: ErrorDetails;
|
|
62
|
+
cause?: Error;
|
|
63
|
+
retryable?: boolean;
|
|
64
|
+
retryAfter?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Base error class for all Cogitator errors
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* throw new CogitatorError({
|
|
72
|
+
* message: 'LLM backend unavailable',
|
|
73
|
+
* code: ErrorCode.LLM_UNAVAILABLE,
|
|
74
|
+
* details: { backend: 'ollama', endpoint: 'http://localhost:11434' },
|
|
75
|
+
* retryable: true,
|
|
76
|
+
* retryAfter: 5000,
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare class CogitatorError extends Error {
|
|
81
|
+
readonly code: ErrorCode;
|
|
82
|
+
readonly statusCode: number;
|
|
83
|
+
readonly details?: ErrorDetails;
|
|
84
|
+
readonly retryable: boolean;
|
|
85
|
+
readonly retryAfter?: number;
|
|
86
|
+
constructor(options: CogitatorErrorOptions);
|
|
87
|
+
/**
|
|
88
|
+
* Create a JSON representation for API responses
|
|
89
|
+
*/
|
|
90
|
+
toJSON(): Record<string, unknown>;
|
|
91
|
+
/**
|
|
92
|
+
* Check if an error is a CogitatorError
|
|
93
|
+
*/
|
|
94
|
+
static isCogitatorError(error: unknown): error is CogitatorError;
|
|
95
|
+
/**
|
|
96
|
+
* Wrap any error as a CogitatorError
|
|
97
|
+
*/
|
|
98
|
+
static wrap(error: unknown, code?: ErrorCode): CogitatorError;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Check if an error is retryable
|
|
102
|
+
*/
|
|
103
|
+
export declare function isRetryableError(error: unknown): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Get retry delay from an error
|
|
106
|
+
*/
|
|
107
|
+
export declare function getRetryDelay(error: unknown, defaultDelay?: number): number;
|
|
108
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,oBAAY,SAAS;IAEnB,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;IACrC,WAAW,gBAAgB;IAC3B,oBAAoB,yBAAyB;IAC7C,2BAA2B,gCAAgC;IAC3D,oBAAoB,yBAAyB;IAE7C,mBAAmB,wBAAwB;IAC3C,eAAe,oBAAoB;IACnC,WAAW,gBAAgB;IAC3B,wBAAwB,6BAA6B;IACrD,sBAAsB,2BAA2B;IAEjD,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,qBAAqB,0BAA0B;IAC/C,YAAY,iBAAiB;IAE7B,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;IAEzC,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,oBAAoB,yBAAyB;IAE7C,kBAAkB,uBAAuB;IACzC,oBAAoB,yBAAyB;IAC7C,uBAAuB,4BAA4B;IAEnD,gBAAgB,qBAAqB;IACrC,sBAAsB,2BAA2B;IAEjD,gBAAgB,qBAAqB;IACrC,mBAAmB,wBAAwB;IAC3C,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;CAC9B;AAED;;G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 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error types for Cogitator
|
|
3
|
+
*
|
|
4
|
+
* Provides a comprehensive error system with:
|
|
5
|
+
* - Typed error codes for programmatic handling
|
|
6
|
+
* - HTTP status codes for API responses
|
|
7
|
+
* - Error details for debugging
|
|
8
|
+
* - Cause chaining for root cause analysis
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Error codes organized by domain
|
|
12
|
+
*/
|
|
13
|
+
export var ErrorCode;
|
|
14
|
+
(function (ErrorCode) {
|
|
15
|
+
ErrorCode["LLM_UNAVAILABLE"] = "LLM_UNAVAILABLE";
|
|
16
|
+
ErrorCode["LLM_RATE_LIMITED"] = "LLM_RATE_LIMITED";
|
|
17
|
+
ErrorCode["LLM_TIMEOUT"] = "LLM_TIMEOUT";
|
|
18
|
+
ErrorCode["LLM_INVALID_RESPONSE"] = "LLM_INVALID_RESPONSE";
|
|
19
|
+
ErrorCode["LLM_CONTEXT_LENGTH_EXCEEDED"] = "LLM_CONTEXT_LENGTH_EXCEEDED";
|
|
20
|
+
ErrorCode["LLM_CONTENT_FILTERED"] = "LLM_CONTENT_FILTERED";
|
|
21
|
+
ErrorCode["SANDBOX_UNAVAILABLE"] = "SANDBOX_UNAVAILABLE";
|
|
22
|
+
ErrorCode["SANDBOX_TIMEOUT"] = "SANDBOX_TIMEOUT";
|
|
23
|
+
ErrorCode["SANDBOX_OOM"] = "SANDBOX_OOM";
|
|
24
|
+
ErrorCode["SANDBOX_EXECUTION_FAILED"] = "SANDBOX_EXECUTION_FAILED";
|
|
25
|
+
ErrorCode["SANDBOX_INVALID_MODULE"] = "SANDBOX_INVALID_MODULE";
|
|
26
|
+
ErrorCode["TOOL_NOT_FOUND"] = "TOOL_NOT_FOUND";
|
|
27
|
+
ErrorCode["TOOL_INVALID_ARGS"] = "TOOL_INVALID_ARGS";
|
|
28
|
+
ErrorCode["TOOL_EXECUTION_FAILED"] = "TOOL_EXECUTION_FAILED";
|
|
29
|
+
ErrorCode["TOOL_TIMEOUT"] = "TOOL_TIMEOUT";
|
|
30
|
+
ErrorCode["MEMORY_UNAVAILABLE"] = "MEMORY_UNAVAILABLE";
|
|
31
|
+
ErrorCode["MEMORY_WRITE_FAILED"] = "MEMORY_WRITE_FAILED";
|
|
32
|
+
ErrorCode["MEMORY_READ_FAILED"] = "MEMORY_READ_FAILED";
|
|
33
|
+
ErrorCode["AGENT_NOT_FOUND"] = "AGENT_NOT_FOUND";
|
|
34
|
+
ErrorCode["AGENT_ALREADY_RUNNING"] = "AGENT_ALREADY_RUNNING";
|
|
35
|
+
ErrorCode["AGENT_MAX_ITERATIONS"] = "AGENT_MAX_ITERATIONS";
|
|
36
|
+
ErrorCode["WORKFLOW_NOT_FOUND"] = "WORKFLOW_NOT_FOUND";
|
|
37
|
+
ErrorCode["WORKFLOW_STEP_FAILED"] = "WORKFLOW_STEP_FAILED";
|
|
38
|
+
ErrorCode["WORKFLOW_CYCLE_DETECTED"] = "WORKFLOW_CYCLE_DETECTED";
|
|
39
|
+
ErrorCode["SWARM_NO_WORKERS"] = "SWARM_NO_WORKERS";
|
|
40
|
+
ErrorCode["SWARM_CONSENSUS_FAILED"] = "SWARM_CONSENSUS_FAILED";
|
|
41
|
+
ErrorCode["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
42
|
+
ErrorCode["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
|
|
43
|
+
ErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
44
|
+
ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
|
|
45
|
+
ErrorCode["CIRCUIT_OPEN"] = "CIRCUIT_OPEN";
|
|
46
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
47
|
+
/**
|
|
48
|
+
* Maps error codes to HTTP status codes
|
|
49
|
+
*/
|
|
50
|
+
export const ERROR_STATUS_CODES = {
|
|
51
|
+
[ErrorCode.LLM_UNAVAILABLE]: 503,
|
|
52
|
+
[ErrorCode.LLM_RATE_LIMITED]: 429,
|
|
53
|
+
[ErrorCode.LLM_TIMEOUT]: 504,
|
|
54
|
+
[ErrorCode.LLM_INVALID_RESPONSE]: 502,
|
|
55
|
+
[ErrorCode.LLM_CONTEXT_LENGTH_EXCEEDED]: 400,
|
|
56
|
+
[ErrorCode.LLM_CONTENT_FILTERED]: 400,
|
|
57
|
+
[ErrorCode.SANDBOX_UNAVAILABLE]: 503,
|
|
58
|
+
[ErrorCode.SANDBOX_TIMEOUT]: 504,
|
|
59
|
+
[ErrorCode.SANDBOX_OOM]: 507,
|
|
60
|
+
[ErrorCode.SANDBOX_EXECUTION_FAILED]: 500,
|
|
61
|
+
[ErrorCode.SANDBOX_INVALID_MODULE]: 400,
|
|
62
|
+
[ErrorCode.TOOL_NOT_FOUND]: 404,
|
|
63
|
+
[ErrorCode.TOOL_INVALID_ARGS]: 400,
|
|
64
|
+
[ErrorCode.TOOL_EXECUTION_FAILED]: 500,
|
|
65
|
+
[ErrorCode.TOOL_TIMEOUT]: 504,
|
|
66
|
+
[ErrorCode.MEMORY_UNAVAILABLE]: 503,
|
|
67
|
+
[ErrorCode.MEMORY_WRITE_FAILED]: 500,
|
|
68
|
+
[ErrorCode.MEMORY_READ_FAILED]: 500,
|
|
69
|
+
[ErrorCode.AGENT_NOT_FOUND]: 404,
|
|
70
|
+
[ErrorCode.AGENT_ALREADY_RUNNING]: 409,
|
|
71
|
+
[ErrorCode.AGENT_MAX_ITERATIONS]: 400,
|
|
72
|
+
[ErrorCode.WORKFLOW_NOT_FOUND]: 404,
|
|
73
|
+
[ErrorCode.WORKFLOW_STEP_FAILED]: 500,
|
|
74
|
+
[ErrorCode.WORKFLOW_CYCLE_DETECTED]: 400,
|
|
75
|
+
[ErrorCode.SWARM_NO_WORKERS]: 503,
|
|
76
|
+
[ErrorCode.SWARM_CONSENSUS_FAILED]: 500,
|
|
77
|
+
[ErrorCode.VALIDATION_ERROR]: 400,
|
|
78
|
+
[ErrorCode.CONFIGURATION_ERROR]: 500,
|
|
79
|
+
[ErrorCode.INTERNAL_ERROR]: 500,
|
|
80
|
+
[ErrorCode.NOT_IMPLEMENTED]: 501,
|
|
81
|
+
[ErrorCode.CIRCUIT_OPEN]: 503,
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Base error class for all Cogitator errors
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* throw new CogitatorError({
|
|
89
|
+
* message: 'LLM backend unavailable',
|
|
90
|
+
* code: ErrorCode.LLM_UNAVAILABLE,
|
|
91
|
+
* details: { backend: 'ollama', endpoint: 'http://localhost:11434' },
|
|
92
|
+
* retryable: true,
|
|
93
|
+
* retryAfter: 5000,
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export class CogitatorError extends Error {
|
|
98
|
+
code;
|
|
99
|
+
statusCode;
|
|
100
|
+
details;
|
|
101
|
+
retryable;
|
|
102
|
+
retryAfter;
|
|
103
|
+
constructor(options) {
|
|
104
|
+
super(options.message);
|
|
105
|
+
this.name = 'CogitatorError';
|
|
106
|
+
this.code = options.code;
|
|
107
|
+
this.statusCode = options.statusCode ?? ERROR_STATUS_CODES[options.code];
|
|
108
|
+
this.details = options.details;
|
|
109
|
+
this.cause = options.cause;
|
|
110
|
+
this.retryable = options.retryable ?? false;
|
|
111
|
+
this.retryAfter = options.retryAfter;
|
|
112
|
+
if (Error.captureStackTrace) {
|
|
113
|
+
Error.captureStackTrace(this, CogitatorError);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Create a JSON representation for API responses
|
|
118
|
+
*/
|
|
119
|
+
toJSON() {
|
|
120
|
+
return {
|
|
121
|
+
name: this.name,
|
|
122
|
+
message: this.message,
|
|
123
|
+
code: this.code,
|
|
124
|
+
statusCode: this.statusCode,
|
|
125
|
+
details: this.details,
|
|
126
|
+
retryable: this.retryable,
|
|
127
|
+
retryAfter: this.retryAfter,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Check if an error is a CogitatorError
|
|
132
|
+
*/
|
|
133
|
+
static isCogitatorError(error) {
|
|
134
|
+
return error instanceof CogitatorError;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Wrap any error as a CogitatorError
|
|
138
|
+
*/
|
|
139
|
+
static wrap(error, code = ErrorCode.INTERNAL_ERROR) {
|
|
140
|
+
if (error instanceof CogitatorError) {
|
|
141
|
+
return error;
|
|
142
|
+
}
|
|
143
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
144
|
+
const cause = error instanceof Error ? error : undefined;
|
|
145
|
+
return new CogitatorError({
|
|
146
|
+
message,
|
|
147
|
+
code,
|
|
148
|
+
cause,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Check if an error is retryable
|
|
154
|
+
*/
|
|
155
|
+
export function isRetryableError(error) {
|
|
156
|
+
if (error instanceof CogitatorError) {
|
|
157
|
+
return error.retryable;
|
|
158
|
+
}
|
|
159
|
+
if (error instanceof Error) {
|
|
160
|
+
const message = error.message.toLowerCase();
|
|
161
|
+
return (message.includes('timeout') ||
|
|
162
|
+
message.includes('econnrefused') ||
|
|
163
|
+
message.includes('econnreset') ||
|
|
164
|
+
message.includes('rate limit') ||
|
|
165
|
+
message.includes('503') ||
|
|
166
|
+
message.includes('429'));
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get retry delay from an error
|
|
172
|
+
*/
|
|
173
|
+
export function getRetryDelay(error, defaultDelay = 1000) {
|
|
174
|
+
if (error instanceof CogitatorError && error.retryAfter) {
|
|
175
|
+
return error.retryAfter;
|
|
176
|
+
}
|
|
177
|
+
return defaultDelay;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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AACtB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cogitator-ai/types
|
|
3
|
+
*
|
|
4
|
+
* Shared TypeScript types for Cogitator
|
|
5
|
+
*/
|
|
6
|
+
export * from './message';
|
|
7
|
+
export * from './tool';
|
|
8
|
+
export * from './agent';
|
|
9
|
+
export * from './llm';
|
|
10
|
+
export * from './runtime';
|
|
11
|
+
export * from './memory';
|
|
12
|
+
export * from './sandbox';
|
|
13
|
+
export * from './workflow';
|
|
14
|
+
export * from './swarm';
|
|
15
|
+
export * from './errors';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cogitator-ai/types
|
|
3
|
+
*
|
|
4
|
+
* Shared TypeScript types for Cogitator
|
|
5
|
+
*/
|
|
6
|
+
export * from './message';
|
|
7
|
+
export * from './tool';
|
|
8
|
+
export * from './agent';
|
|
9
|
+
export * from './llm';
|
|
10
|
+
export * from './runtime';
|
|
11
|
+
export * from './memory';
|
|
12
|
+
export * from './sandbox';
|
|
13
|
+
export * from './workflow';
|
|
14
|
+
export * from './swarm';
|
|
15
|
+
export * from './errors';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/dist/llm.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Backend types
|
|
3
|
+
*/
|
|
4
|
+
import type { Message, ToolCall } from './message';
|
|
5
|
+
import type { ToolSchema } from './tool';
|
|
6
|
+
export type LLMProvider = 'ollama' | 'openai' | 'anthropic' | 'google' | 'vllm';
|
|
7
|
+
export interface LLMConfig {
|
|
8
|
+
provider: LLMProvider;
|
|
9
|
+
model: string;
|
|
10
|
+
temperature?: number;
|
|
11
|
+
topP?: number;
|
|
12
|
+
maxTokens?: number;
|
|
13
|
+
stopSequences?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface ChatRequest {
|
|
16
|
+
model: string;
|
|
17
|
+
messages: Message[];
|
|
18
|
+
tools?: ToolSchema[];
|
|
19
|
+
temperature?: number;
|
|
20
|
+
topP?: number;
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
stop?: string[];
|
|
23
|
+
stream?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ChatResponse {
|
|
26
|
+
id: string;
|
|
27
|
+
content: string;
|
|
28
|
+
toolCalls?: ToolCall[];
|
|
29
|
+
finishReason: 'stop' | 'tool_calls' | 'length' | 'error';
|
|
30
|
+
usage: {
|
|
31
|
+
inputTokens: number;
|
|
32
|
+
outputTokens: number;
|
|
33
|
+
totalTokens: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface ChatStreamChunk {
|
|
37
|
+
id: string;
|
|
38
|
+
delta: {
|
|
39
|
+
content?: string;
|
|
40
|
+
toolCalls?: Partial<ToolCall>[];
|
|
41
|
+
};
|
|
42
|
+
finishReason?: 'stop' | 'tool_calls' | 'length' | 'error';
|
|
43
|
+
/** Usage data, typically included only in the final chunk */
|
|
44
|
+
usage?: {
|
|
45
|
+
inputTokens: number;
|
|
46
|
+
outputTokens: number;
|
|
47
|
+
totalTokens: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface LLMBackend {
|
|
51
|
+
readonly provider: LLMProvider;
|
|
52
|
+
chat(request: ChatRequest): Promise<ChatResponse>;
|
|
53
|
+
chatStream(request: ChatRequest): AsyncGenerator<ChatStreamChunk>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEhF,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC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