codemie-sdk 0.1.340 → 0.1.342
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.cjs +161 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +173 -1
- package/dist/index.d.ts +173 -1
- package/dist/index.js +149 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -46,7 +46,12 @@ __export(index_exports, {
|
|
|
46
46
|
CredentialTypes: () => CredentialTypes,
|
|
47
47
|
DataSourceStatus: () => DataSourceStatus,
|
|
48
48
|
DataSourceType: () => DataSourceType,
|
|
49
|
+
ERROR_MESSAGE_PATTERNS: () => ERROR_MESSAGE_PATTERNS,
|
|
50
|
+
ErrorCategory: () => ErrorCategory,
|
|
51
|
+
ErrorCode: () => ErrorCode,
|
|
52
|
+
ErrorDetailLevel: () => ErrorDetailLevel,
|
|
49
53
|
ExecutionStatus: () => ExecutionStatus,
|
|
54
|
+
HTTP_STATUS_TO_ERROR_CODE: () => HTTP_STATUS_TO_ERROR_CODE,
|
|
50
55
|
IntegrationCreateParamsSchema: () => IntegrationCreateParamsSchema,
|
|
51
56
|
IntegrationGetByAliasParamsSchema: () => IntegrationGetByAliasParamsSchema,
|
|
52
57
|
IntegrationGetParamsSchema: () => IntegrationGetParamsSchema,
|
|
@@ -62,7 +67,13 @@ __export(index_exports, {
|
|
|
62
67
|
WorkflowListParamsSchema: () => WorkflowListParamsSchema,
|
|
63
68
|
WorkflowMode: () => WorkflowMode,
|
|
64
69
|
WorkflowUpdateParamsSchema: () => WorkflowUpdateParamsSchema,
|
|
65
|
-
|
|
70
|
+
classifyHttpError: () => classifyHttpError,
|
|
71
|
+
formatCookies: () => formatCookies,
|
|
72
|
+
formatToolErrorForLevel: () => formatToolErrorForLevel,
|
|
73
|
+
formatToolErrorFull: () => formatToolErrorFull,
|
|
74
|
+
formatToolErrorMinimal: () => formatToolErrorMinimal,
|
|
75
|
+
formatToolErrorStandard: () => formatToolErrorStandard,
|
|
76
|
+
isRecoverableError: () => isRecoverableError
|
|
66
77
|
});
|
|
67
78
|
module.exports = __toCommonJS(index_exports);
|
|
68
79
|
|
|
@@ -1638,6 +1649,143 @@ var ChatRole = /* @__PURE__ */ ((ChatRole2) => {
|
|
|
1638
1649
|
return ChatRole2;
|
|
1639
1650
|
})(ChatRole || {});
|
|
1640
1651
|
|
|
1652
|
+
// src/models/errors.ts
|
|
1653
|
+
var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => {
|
|
1654
|
+
ErrorCategory2["AGENT"] = "agent";
|
|
1655
|
+
ErrorCategory2["TOOL"] = "tool";
|
|
1656
|
+
ErrorCategory2["LLM"] = "llm";
|
|
1657
|
+
ErrorCategory2["VALIDATION"] = "validation";
|
|
1658
|
+
return ErrorCategory2;
|
|
1659
|
+
})(ErrorCategory || {});
|
|
1660
|
+
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
1661
|
+
ErrorCode2["AGENT_TIMEOUT"] = "agent_timeout";
|
|
1662
|
+
ErrorCode2["AGENT_TOKEN_LIMIT"] = "agent_token_limit";
|
|
1663
|
+
ErrorCode2["AGENT_BUDGET_EXCEEDED"] = "agent_budget_exceeded";
|
|
1664
|
+
ErrorCode2["AGENT_CALLBACK_FAILURE"] = "agent_callback_failure";
|
|
1665
|
+
ErrorCode2["AGENT_NETWORK_ERROR"] = "agent_network_error";
|
|
1666
|
+
ErrorCode2["AGENT_CONFIGURATION_ERROR"] = "agent_configuration_error";
|
|
1667
|
+
ErrorCode2["AGENT_INTERNAL_ERROR"] = "agent_internal_error";
|
|
1668
|
+
ErrorCode2["TOOL_AUTHENTICATION"] = "tool_authentication";
|
|
1669
|
+
ErrorCode2["TOOL_AUTHORIZATION"] = "tool_authorization";
|
|
1670
|
+
ErrorCode2["TOOL_NOT_FOUND"] = "tool_not_found";
|
|
1671
|
+
ErrorCode2["TOOL_CONFLICT"] = "tool_conflict";
|
|
1672
|
+
ErrorCode2["TOOL_RATE_LIMITED"] = "tool_rate_limited";
|
|
1673
|
+
ErrorCode2["TOOL_SERVER_ERROR"] = "tool_server_error";
|
|
1674
|
+
ErrorCode2["TOOL_TIMEOUT"] = "tool_timeout";
|
|
1675
|
+
ErrorCode2["TOOL_VALIDATION"] = "tool_validation";
|
|
1676
|
+
ErrorCode2["TOOL_NETWORK_ERROR"] = "tool_network_error";
|
|
1677
|
+
ErrorCode2["TOOL_EXECUTION_FAILED"] = "tool_execution_failed";
|
|
1678
|
+
ErrorCode2["LLM_CONTENT_POLICY"] = "llm_content_policy";
|
|
1679
|
+
ErrorCode2["LLM_CONTEXT_LENGTH"] = "llm_context_length";
|
|
1680
|
+
ErrorCode2["LLM_UNAVAILABLE"] = "llm_unavailable";
|
|
1681
|
+
ErrorCode2["LLM_RATE_LIMITED"] = "llm_rate_limited";
|
|
1682
|
+
ErrorCode2["LLM_INVALID_REQUEST"] = "llm_invalid_request";
|
|
1683
|
+
ErrorCode2["VALIDATION_INPUT"] = "validation_input";
|
|
1684
|
+
ErrorCode2["VALIDATION_OUTPUT"] = "validation_output";
|
|
1685
|
+
ErrorCode2["VALIDATION_SCHEMA"] = "validation_schema";
|
|
1686
|
+
return ErrorCode2;
|
|
1687
|
+
})(ErrorCode || {});
|
|
1688
|
+
var ErrorDetailLevel = /* @__PURE__ */ ((ErrorDetailLevel2) => {
|
|
1689
|
+
ErrorDetailLevel2["Minimal"] = "minimal";
|
|
1690
|
+
ErrorDetailLevel2["Standard"] = "standard";
|
|
1691
|
+
ErrorDetailLevel2["Full"] = "full";
|
|
1692
|
+
return ErrorDetailLevel2;
|
|
1693
|
+
})(ErrorDetailLevel || {});
|
|
1694
|
+
function formatToolErrorMinimal(error) {
|
|
1695
|
+
return {
|
|
1696
|
+
tool_name: error.tool_name,
|
|
1697
|
+
error_code: error.error_code,
|
|
1698
|
+
message: error.message
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
function formatToolErrorStandard(error) {
|
|
1702
|
+
return {
|
|
1703
|
+
tool_name: error.tool_name,
|
|
1704
|
+
tool_call_id: error.tool_call_id,
|
|
1705
|
+
error_code: error.error_code,
|
|
1706
|
+
message: error.message,
|
|
1707
|
+
http_status: error.http_status
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
function formatToolErrorFull(error) {
|
|
1711
|
+
return { ...error };
|
|
1712
|
+
}
|
|
1713
|
+
function formatToolErrorForLevel(error, level) {
|
|
1714
|
+
switch (level) {
|
|
1715
|
+
case "minimal" /* Minimal */:
|
|
1716
|
+
return formatToolErrorMinimal(error);
|
|
1717
|
+
case "standard" /* Standard */:
|
|
1718
|
+
return formatToolErrorStandard(error);
|
|
1719
|
+
case "full" /* Full */:
|
|
1720
|
+
return formatToolErrorFull(error);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
var HTTP_STATUS_TO_ERROR_CODE = {
|
|
1724
|
+
// Client errors (4xx)
|
|
1725
|
+
401: "tool_authentication" /* TOOL_AUTHENTICATION */,
|
|
1726
|
+
403: "tool_authorization" /* TOOL_AUTHORIZATION */,
|
|
1727
|
+
404: "tool_not_found" /* TOOL_NOT_FOUND */,
|
|
1728
|
+
409: "tool_conflict" /* TOOL_CONFLICT */,
|
|
1729
|
+
429: "tool_rate_limited" /* TOOL_RATE_LIMITED */,
|
|
1730
|
+
// Server errors (5xx)
|
|
1731
|
+
500: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1732
|
+
501: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1733
|
+
502: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1734
|
+
503: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1735
|
+
504: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1736
|
+
505: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1737
|
+
506: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1738
|
+
507: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1739
|
+
508: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1740
|
+
509: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1741
|
+
510: "tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1742
|
+
511: "tool_server_error" /* TOOL_SERVER_ERROR */
|
|
1743
|
+
};
|
|
1744
|
+
var ERROR_MESSAGE_PATTERNS = {
|
|
1745
|
+
timeout: "tool_timeout" /* TOOL_TIMEOUT */,
|
|
1746
|
+
network: "tool_network_error" /* TOOL_NETWORK_ERROR */,
|
|
1747
|
+
connection: "tool_network_error" /* TOOL_NETWORK_ERROR */,
|
|
1748
|
+
validation: "tool_validation" /* TOOL_VALIDATION */,
|
|
1749
|
+
invalid: "tool_validation" /* TOOL_VALIDATION */
|
|
1750
|
+
};
|
|
1751
|
+
function classifyByHttpStatus(statusCode) {
|
|
1752
|
+
if (statusCode in HTTP_STATUS_TO_ERROR_CODE) {
|
|
1753
|
+
return HTTP_STATUS_TO_ERROR_CODE[statusCode];
|
|
1754
|
+
}
|
|
1755
|
+
if (statusCode >= 500 && statusCode < 600) {
|
|
1756
|
+
return "tool_server_error" /* TOOL_SERVER_ERROR */;
|
|
1757
|
+
}
|
|
1758
|
+
return "tool_execution_failed" /* TOOL_EXECUTION_FAILED */;
|
|
1759
|
+
}
|
|
1760
|
+
function classifyByMessage(errorMessage) {
|
|
1761
|
+
const errorLower = errorMessage.toLowerCase();
|
|
1762
|
+
for (const [keyword, errorCode] of Object.entries(ERROR_MESSAGE_PATTERNS)) {
|
|
1763
|
+
if (errorLower.includes(keyword)) {
|
|
1764
|
+
return errorCode;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
return "tool_execution_failed" /* TOOL_EXECUTION_FAILED */;
|
|
1768
|
+
}
|
|
1769
|
+
function classifyHttpError(statusCode, errorMessage = "") {
|
|
1770
|
+
let errorCode = classifyByHttpStatus(statusCode);
|
|
1771
|
+
if (errorCode === "tool_execution_failed" /* TOOL_EXECUTION_FAILED */ && errorMessage) {
|
|
1772
|
+
errorCode = classifyByMessage(errorMessage);
|
|
1773
|
+
}
|
|
1774
|
+
return errorCode;
|
|
1775
|
+
}
|
|
1776
|
+
function isRecoverableError(errorCode) {
|
|
1777
|
+
const recoverableErrors = /* @__PURE__ */ new Set([
|
|
1778
|
+
"tool_timeout" /* TOOL_TIMEOUT */,
|
|
1779
|
+
"tool_rate_limited" /* TOOL_RATE_LIMITED */,
|
|
1780
|
+
"tool_server_error" /* TOOL_SERVER_ERROR */,
|
|
1781
|
+
"tool_network_error" /* TOOL_NETWORK_ERROR */,
|
|
1782
|
+
"agent_network_error" /* AGENT_NETWORK_ERROR */,
|
|
1783
|
+
"llm_rate_limited" /* LLM_RATE_LIMITED */,
|
|
1784
|
+
"llm_unavailable" /* LLM_UNAVAILABLE */
|
|
1785
|
+
]);
|
|
1786
|
+
return recoverableErrors.has(errorCode);
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1641
1789
|
// src/models/llm.ts
|
|
1642
1790
|
var LLMProvider = {
|
|
1643
1791
|
AZURE_OPENAI: "azure_openai",
|
|
@@ -1669,7 +1817,12 @@ var BackgroundTaskStatus = {
|
|
|
1669
1817
|
CredentialTypes,
|
|
1670
1818
|
DataSourceStatus,
|
|
1671
1819
|
DataSourceType,
|
|
1820
|
+
ERROR_MESSAGE_PATTERNS,
|
|
1821
|
+
ErrorCategory,
|
|
1822
|
+
ErrorCode,
|
|
1823
|
+
ErrorDetailLevel,
|
|
1672
1824
|
ExecutionStatus,
|
|
1825
|
+
HTTP_STATUS_TO_ERROR_CODE,
|
|
1673
1826
|
IntegrationCreateParamsSchema,
|
|
1674
1827
|
IntegrationGetByAliasParamsSchema,
|
|
1675
1828
|
IntegrationGetParamsSchema,
|
|
@@ -1685,6 +1838,12 @@ var BackgroundTaskStatus = {
|
|
|
1685
1838
|
WorkflowListParamsSchema,
|
|
1686
1839
|
WorkflowMode,
|
|
1687
1840
|
WorkflowUpdateParamsSchema,
|
|
1688
|
-
|
|
1841
|
+
classifyHttpError,
|
|
1842
|
+
formatCookies,
|
|
1843
|
+
formatToolErrorForLevel,
|
|
1844
|
+
formatToolErrorFull,
|
|
1845
|
+
formatToolErrorMinimal,
|
|
1846
|
+
formatToolErrorStandard,
|
|
1847
|
+
isRecoverableError
|
|
1689
1848
|
});
|
|
1690
1849
|
//# sourceMappingURL=index.cjs.map
|