@teamlearners/clawops 0.3.1 → 0.4.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/dist/agent/index.cjs +7 -7
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-JNSHMKDI.cjs → chunk-6IQN5RQD.cjs} +11 -2
- package/dist/chunk-6IQN5RQD.cjs.map +1 -0
- package/dist/{chunk-UKAT24I6.js → chunk-7S2OEBS6.js} +11 -3
- package/dist/chunk-7S2OEBS6.js.map +1 -0
- package/dist/index.cjs +36 -32
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-JNSHMKDI.cjs.map +0 -1
- package/dist/chunk-UKAT24I6.js.map +0 -1
package/dist/agent/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6IQN5RQD_cjs = require('../chunk-6IQN5RQD.cjs');
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
|
|
@@ -1167,7 +1167,7 @@ var ClawOpsAgent = class {
|
|
|
1167
1167
|
constructor(options) {
|
|
1168
1168
|
this._apiKey = options.apiKey ?? process.env["CLAWOPS_API_KEY"] ?? "";
|
|
1169
1169
|
this._accountId = options.accountId ?? process.env["CLAWOPS_ACCOUNT_ID"] ?? "";
|
|
1170
|
-
this._baseUrl = options.baseUrl ??
|
|
1170
|
+
this._baseUrl = options.baseUrl ?? chunk6IQN5RQD_cjs.DEFAULT_BASE_URL;
|
|
1171
1171
|
this._fromNumber = options.from;
|
|
1172
1172
|
this._session = options.session;
|
|
1173
1173
|
this._recording = options.recording ?? false;
|
|
@@ -1187,7 +1187,7 @@ var ClawOpsAgent = class {
|
|
|
1187
1187
|
tool(nameOrTool, description, parameters, handler) {
|
|
1188
1188
|
if (typeof nameOrTool === "string") {
|
|
1189
1189
|
if (!description || !parameters || !handler) {
|
|
1190
|
-
throw new
|
|
1190
|
+
throw new chunk6IQN5RQD_cjs.AgentError("tool(name, description, parameters, handler) requires all arguments.");
|
|
1191
1191
|
}
|
|
1192
1192
|
this._tools.register({
|
|
1193
1193
|
name: nameOrTool,
|
|
@@ -1220,10 +1220,10 @@ var ClawOpsAgent = class {
|
|
|
1220
1220
|
/** Connect to the ClawOps platform and start listening for calls. */
|
|
1221
1221
|
async connect() {
|
|
1222
1222
|
if (!this._apiKey) {
|
|
1223
|
-
throw new
|
|
1223
|
+
throw new chunk6IQN5RQD_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
|
|
1224
1224
|
}
|
|
1225
1225
|
if (!this._accountId) {
|
|
1226
|
-
throw new
|
|
1226
|
+
throw new chunk6IQN5RQD_cjs.AgentError("Account ID is required. Set CLAWOPS_ACCOUNT_ID or pass accountId option.");
|
|
1227
1227
|
}
|
|
1228
1228
|
this._controlWs = new ControlWebSocket({
|
|
1229
1229
|
baseUrl: this._baseUrl,
|
|
@@ -1240,7 +1240,7 @@ var ClawOpsAgent = class {
|
|
|
1240
1240
|
await this._controlWs.connect();
|
|
1241
1241
|
await this._controlWs.waitConnected();
|
|
1242
1242
|
} catch (err) {
|
|
1243
|
-
throw new
|
|
1243
|
+
throw new chunk6IQN5RQD_cjs.AgentConnectionError(
|
|
1244
1244
|
`Failed to connect to ClawOps: ${err instanceof Error ? err.message : String(err)}`
|
|
1245
1245
|
);
|
|
1246
1246
|
}
|
|
@@ -1290,7 +1290,7 @@ var ClawOpsAgent = class {
|
|
|
1290
1290
|
});
|
|
1291
1291
|
if (resp.status !== 201) {
|
|
1292
1292
|
const error = await resp.json();
|
|
1293
|
-
throw new
|
|
1293
|
+
throw new chunk6IQN5RQD_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
|
|
1294
1294
|
}
|
|
1295
1295
|
const data = await resp.json();
|
|
1296
1296
|
const callSession = new CallSession({
|
package/dist/agent/index.js
CHANGED
|
@@ -69,6 +69,13 @@ var UnprocessableEntityError = class extends APIStatusError {
|
|
|
69
69
|
this.name = "UnprocessableEntityError";
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
var RateLimitError = class extends APIStatusError {
|
|
73
|
+
status = 429;
|
|
74
|
+
constructor(message, response, body, request) {
|
|
75
|
+
super(message, response, body, request);
|
|
76
|
+
this.name = "RateLimitError";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
72
79
|
var InternalServerError = class extends APIStatusError {
|
|
73
80
|
status = 500;
|
|
74
81
|
constructor(message, response, body, request) {
|
|
@@ -122,6 +129,7 @@ var STATUS_CODE_TO_ERROR = {
|
|
|
122
129
|
404: NotFoundError,
|
|
123
130
|
409: ConflictError,
|
|
124
131
|
422: UnprocessableEntityError,
|
|
132
|
+
429: RateLimitError,
|
|
125
133
|
500: InternalServerError,
|
|
126
134
|
503: ServiceUnavailableError
|
|
127
135
|
};
|
|
@@ -168,8 +176,9 @@ exports.InternalServerError = InternalServerError;
|
|
|
168
176
|
exports.MAX_RETRY_DELAY = MAX_RETRY_DELAY;
|
|
169
177
|
exports.NotFoundError = NotFoundError;
|
|
170
178
|
exports.PermissionDeniedError = PermissionDeniedError;
|
|
179
|
+
exports.RateLimitError = RateLimitError;
|
|
171
180
|
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
172
181
|
exports.UnprocessableEntityError = UnprocessableEntityError;
|
|
173
182
|
exports.makeStatusError = makeStatusError;
|
|
174
|
-
//# sourceMappingURL=chunk-
|
|
175
|
-
//# sourceMappingURL=chunk-
|
|
183
|
+
//# sourceMappingURL=chunk-6IQN5RQD.cjs.map
|
|
184
|
+
//# sourceMappingURL=chunk-6IQN5RQD.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error.ts","../src/constants.ts"],"names":[],"mappings":";;;AAAO,IAAM,YAAA,GAAN,cAA2B,KAAA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AI,WAAW,OAAA,EAAS,EAAE,QAAQ,OAAA,EAAQ,EAAG,MAAM,OAAO,CAAA;AAAA,EACnE;AACA,EAAA,IAAI,UAAU,GAAA,EAAK;AACjB,IAAA,OAAO,IAAI,oBAAoB,OAAA,EAAS,EAAE,QAAQ,OAAA,EAAQ,EAAG,MAAM,OAAO,CAAA;AAAA,EAC5E;AACA,EAAA,OAAO,IAAI,eAAe,OAAA,EAAS,EAAE,QAAQ,OAAA,EAAQ,EAAG,MAAM,OAAO,CAAA;AACvE;;;AC9OO,IAAM,gBAAA,GAAmB;AACzB,IAAM,mBAAA,GAAsB;AAC5B,IAAM,eAAA,GAAkB;AACxB,IAAM,mBAAA,GAAsB;AAC5B,IAAM,eAAA,GAAkB","file":"chunk-6IQN5RQD.cjs","sourcesContent":["export class ClawOpsError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ClawOpsError';\n }\n}\n\nexport class APIError extends ClawOpsError {\n readonly request: { method: string; url: string };\n\n constructor(message: string, request: { method: string; url: string }) {\n super(message);\n this.name = 'APIError';\n this.request = request;\n }\n}\n\nexport class APIStatusError extends APIError {\n readonly status: number;\n readonly body: unknown;\n readonly headers: Headers | undefined;\n\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, request);\n this.name = 'APIStatusError';\n this.status = response.status;\n this.body = body;\n this.headers = response.headers;\n }\n}\n\nexport class BadRequestError extends APIStatusError {\n override readonly status = 400 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'BadRequestError';\n }\n}\n\nexport class AuthenticationError extends APIStatusError {\n override readonly status = 401 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class PermissionDeniedError extends APIStatusError {\n override readonly status = 403 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'PermissionDeniedError';\n }\n}\n\nexport class NotFoundError extends APIStatusError {\n override readonly status = 404 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'NotFoundError';\n }\n}\n\nexport class ConflictError extends APIStatusError {\n override readonly status = 409 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'ConflictError';\n }\n}\n\nexport class UnprocessableEntityError extends APIStatusError {\n override readonly status = 422 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'UnprocessableEntityError';\n }\n}\n\n/**\n * HTTP 429 Too Many Requests.\n *\n * 동시 통화 한도 초과 등 일시적 제한. SDK는 자동 재시도(최대 2회, 지수 backoff)를 수행한다.\n * 즉각 피드백이 필요하면 client 생성 시 maxRetries: 0으로 재시도를 비활성화하라.\n */\nexport class RateLimitError extends APIStatusError {\n override readonly status = 429 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'RateLimitError';\n }\n}\n\nexport class InternalServerError extends APIStatusError {\n override readonly status = 500 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'InternalServerError';\n }\n}\n\nexport class ServiceUnavailableError extends APIStatusError {\n override readonly status = 503 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'ServiceUnavailableError';\n }\n}\n\nexport class APIConnectionError extends APIError {\n constructor(request: { method: string; url: string }, message = 'Connection error.') {\n super(message, request);\n this.name = 'APIConnectionError';\n }\n}\n\nexport class APITimeoutError extends APIConnectionError {\n constructor(request: { method: string; url: string }) {\n super(request, 'Request timed out.');\n this.name = 'APITimeoutError';\n }\n}\n\nexport class APIResponseValidationError extends APIError {\n readonly status: number;\n\n constructor(response: { status: number }, request: { method: string; url: string }) {\n super('API response validation failed.', request);\n this.name = 'APIResponseValidationError';\n this.status = response.status;\n }\n}\n\nexport class AgentError extends ClawOpsError {\n constructor(message: string) {\n super(message);\n this.name = 'AgentError';\n }\n}\n\nexport class AgentConnectionError extends AgentError {\n constructor(message = 'Agent WebSocket connection failed.') {\n super(message);\n this.name = 'AgentConnectionError';\n }\n}\n\nconst STATUS_CODE_TO_ERROR: Record<\n number,\n new (\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) => APIStatusError\n> = {\n 400: BadRequestError,\n 401: AuthenticationError,\n 403: PermissionDeniedError,\n 404: NotFoundError,\n 409: ConflictError,\n 422: UnprocessableEntityError,\n 429: RateLimitError,\n 500: InternalServerError,\n 503: ServiceUnavailableError,\n};\n\nexport function makeStatusError(\n status: number,\n body: unknown,\n headers: Headers | undefined,\n request: { method: string; url: string },\n): APIStatusError {\n let message = '';\n if (body && typeof body === 'object' && 'error' in body) {\n message = (body as { error: string }).error;\n } else {\n message = `HTTP ${status}`;\n }\n\n const ErrorClass = STATUS_CODE_TO_ERROR[status];\n if (ErrorClass) {\n return new ErrorClass(message, { status, headers }, body, request);\n }\n if (status >= 500) {\n return new InternalServerError(message, { status, headers }, body, request);\n }\n return new APIStatusError(message, { status, headers }, body, request);\n}\n","export const DEFAULT_BASE_URL = 'https://api.claw-ops.com';\nexport const DEFAULT_MAX_RETRIES = 2;\nexport const DEFAULT_TIMEOUT = 600_000; // ms\nexport const INITIAL_RETRY_DELAY = 500; // ms\nexport const MAX_RETRY_DELAY = 8_000; // ms\n"]}
|
|
@@ -67,6 +67,13 @@ var UnprocessableEntityError = class extends APIStatusError {
|
|
|
67
67
|
this.name = "UnprocessableEntityError";
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
+
var RateLimitError = class extends APIStatusError {
|
|
71
|
+
status = 429;
|
|
72
|
+
constructor(message, response, body, request) {
|
|
73
|
+
super(message, response, body, request);
|
|
74
|
+
this.name = "RateLimitError";
|
|
75
|
+
}
|
|
76
|
+
};
|
|
70
77
|
var InternalServerError = class extends APIStatusError {
|
|
71
78
|
status = 500;
|
|
72
79
|
constructor(message, response, body, request) {
|
|
@@ -120,6 +127,7 @@ var STATUS_CODE_TO_ERROR = {
|
|
|
120
127
|
404: NotFoundError,
|
|
121
128
|
409: ConflictError,
|
|
122
129
|
422: UnprocessableEntityError,
|
|
130
|
+
429: RateLimitError,
|
|
123
131
|
500: InternalServerError,
|
|
124
132
|
503: ServiceUnavailableError
|
|
125
133
|
};
|
|
@@ -147,6 +155,6 @@ var DEFAULT_TIMEOUT = 6e5;
|
|
|
147
155
|
var INITIAL_RETRY_DELAY = 500;
|
|
148
156
|
var MAX_RETRY_DELAY = 8e3;
|
|
149
157
|
|
|
150
|
-
export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, ClawOpsError, ConflictError, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, INITIAL_RETRY_DELAY, InternalServerError, MAX_RETRY_DELAY, NotFoundError, PermissionDeniedError, ServiceUnavailableError, UnprocessableEntityError, makeStatusError };
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
152
|
-
//# sourceMappingURL=chunk-
|
|
158
|
+
export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, ClawOpsError, ConflictError, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, INITIAL_RETRY_DELAY, InternalServerError, MAX_RETRY_DELAY, NotFoundError, PermissionDeniedError, RateLimitError, ServiceUnavailableError, UnprocessableEntityError, makeStatusError };
|
|
159
|
+
//# sourceMappingURL=chunk-7S2OEBS6.js.map
|
|
160
|
+
//# sourceMappingURL=chunk-7S2OEBS6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error.ts","../src/constants.ts"],"names":[],"mappings":";AAAO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACtC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EACd;AACF;AAEO,IAAM,QAAA,GAAN,cAAuB,YAAA,CAAa;AAAA,EAChC,OAAA;AAAA,EAET,WAAA,CAAY,SAAiB,OAAA,EAA0C;AACrE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AACF;AAEO,IAAM,cAAA,GAAN,cAA6B,QAAA,CAAS;AAAA,EAClC,MAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CACE,OAAA,EACA,QAAA,EACA,IAAA,EACA,OAAA,EACA;AACA,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AACZ,IAAA,IAAA,CAAK,SAAS,QAAA,CAAS,MAAA;AACvB,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,UAAU,QAAA,CAAS,OAAA;AAAA,EAC1B;AACF;AAEO,IAAM,eAAA,GAAN,cAA8B,cAAA,CAAe;AAAA,EAChC,MAAA,GAAS,GAAA;AAAA,EAC3B,WAAA,CACE,OAAA,EACA,QAAA,EACA,IAAA,EACA,OAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAA,EAAS,QAAA,EAAU,IAAA,EAAM,OAAO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IAAY,WAAW,IAAA,EAAM;AACvD,IAAA,OAAA,GAAW,IAAA,CAA2B,KAAA;AAAA,EACxC,CAAA,MAAO;AACL,IAAA,OAAA,GAAU,QAAQ,MAAM,CAAA,CAAA;AAAA,EAC1B;AAEA,EAAA,MAAM,UAAA,GAAa,qBAAqB,MAAM,CAAA;AAC9C,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,OAAO,IAAI,WAAW,OAAA,EAAS,EAAE,QAAQ,OAAA,EAAQ,EAAG,MAAM,OAAO,CAAA;AAAA,EACnE;AACA,EAAA,IAAI,UAAU,GAAA,EAAK;AACjB,IAAA,OAAO,IAAI,oBAAoB,OAAA,EAAS,EAAE,QAAQ,OAAA,EAAQ,EAAG,MAAM,OAAO,CAAA;AAAA,EAC5E;AACA,EAAA,OAAO,IAAI,eAAe,OAAA,EAAS,EAAE,QAAQ,OAAA,EAAQ,EAAG,MAAM,OAAO,CAAA;AACvE;;;AC9OO,IAAM,gBAAA,GAAmB;AACzB,IAAM,mBAAA,GAAsB;AAC5B,IAAM,eAAA,GAAkB;AACxB,IAAM,mBAAA,GAAsB;AAC5B,IAAM,eAAA,GAAkB","file":"chunk-7S2OEBS6.js","sourcesContent":["export class ClawOpsError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ClawOpsError';\n }\n}\n\nexport class APIError extends ClawOpsError {\n readonly request: { method: string; url: string };\n\n constructor(message: string, request: { method: string; url: string }) {\n super(message);\n this.name = 'APIError';\n this.request = request;\n }\n}\n\nexport class APIStatusError extends APIError {\n readonly status: number;\n readonly body: unknown;\n readonly headers: Headers | undefined;\n\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, request);\n this.name = 'APIStatusError';\n this.status = response.status;\n this.body = body;\n this.headers = response.headers;\n }\n}\n\nexport class BadRequestError extends APIStatusError {\n override readonly status = 400 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'BadRequestError';\n }\n}\n\nexport class AuthenticationError extends APIStatusError {\n override readonly status = 401 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class PermissionDeniedError extends APIStatusError {\n override readonly status = 403 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'PermissionDeniedError';\n }\n}\n\nexport class NotFoundError extends APIStatusError {\n override readonly status = 404 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'NotFoundError';\n }\n}\n\nexport class ConflictError extends APIStatusError {\n override readonly status = 409 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'ConflictError';\n }\n}\n\nexport class UnprocessableEntityError extends APIStatusError {\n override readonly status = 422 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'UnprocessableEntityError';\n }\n}\n\n/**\n * HTTP 429 Too Many Requests.\n *\n * 동시 통화 한도 초과 등 일시적 제한. SDK는 자동 재시도(최대 2회, 지수 backoff)를 수행한다.\n * 즉각 피드백이 필요하면 client 생성 시 maxRetries: 0으로 재시도를 비활성화하라.\n */\nexport class RateLimitError extends APIStatusError {\n override readonly status = 429 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'RateLimitError';\n }\n}\n\nexport class InternalServerError extends APIStatusError {\n override readonly status = 500 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'InternalServerError';\n }\n}\n\nexport class ServiceUnavailableError extends APIStatusError {\n override readonly status = 503 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'ServiceUnavailableError';\n }\n}\n\nexport class APIConnectionError extends APIError {\n constructor(request: { method: string; url: string }, message = 'Connection error.') {\n super(message, request);\n this.name = 'APIConnectionError';\n }\n}\n\nexport class APITimeoutError extends APIConnectionError {\n constructor(request: { method: string; url: string }) {\n super(request, 'Request timed out.');\n this.name = 'APITimeoutError';\n }\n}\n\nexport class APIResponseValidationError extends APIError {\n readonly status: number;\n\n constructor(response: { status: number }, request: { method: string; url: string }) {\n super('API response validation failed.', request);\n this.name = 'APIResponseValidationError';\n this.status = response.status;\n }\n}\n\nexport class AgentError extends ClawOpsError {\n constructor(message: string) {\n super(message);\n this.name = 'AgentError';\n }\n}\n\nexport class AgentConnectionError extends AgentError {\n constructor(message = 'Agent WebSocket connection failed.') {\n super(message);\n this.name = 'AgentConnectionError';\n }\n}\n\nconst STATUS_CODE_TO_ERROR: Record<\n number,\n new (\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) => APIStatusError\n> = {\n 400: BadRequestError,\n 401: AuthenticationError,\n 403: PermissionDeniedError,\n 404: NotFoundError,\n 409: ConflictError,\n 422: UnprocessableEntityError,\n 429: RateLimitError,\n 500: InternalServerError,\n 503: ServiceUnavailableError,\n};\n\nexport function makeStatusError(\n status: number,\n body: unknown,\n headers: Headers | undefined,\n request: { method: string; url: string },\n): APIStatusError {\n let message = '';\n if (body && typeof body === 'object' && 'error' in body) {\n message = (body as { error: string }).error;\n } else {\n message = `HTTP ${status}`;\n }\n\n const ErrorClass = STATUS_CODE_TO_ERROR[status];\n if (ErrorClass) {\n return new ErrorClass(message, { status, headers }, body, request);\n }\n if (status >= 500) {\n return new InternalServerError(message, { status, headers }, body, request);\n }\n return new APIStatusError(message, { status, headers }, body, request);\n}\n","export const DEFAULT_BASE_URL = 'https://api.claw-ops.com';\nexport const DEFAULT_MAX_RETRIES = 2;\nexport const DEFAULT_TIMEOUT = 600_000; // ms\nexport const INITIAL_RETRY_DELAY = 500; // ms\nexport const MAX_RETRY_DELAY = 8_000; // ms\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var chunk6IQN5RQD_cjs = require('./chunk-6IQN5RQD.cjs');
|
|
6
6
|
var zod = require('zod');
|
|
7
7
|
var crypto = require('crypto');
|
|
8
8
|
|
|
@@ -16,11 +16,11 @@ function validateBaseUrl(url) {
|
|
|
16
16
|
try {
|
|
17
17
|
parsed = new URL(url);
|
|
18
18
|
} catch {
|
|
19
|
-
throw new
|
|
19
|
+
throw new chunk6IQN5RQD_cjs.ClawOpsError(`Invalid base_url: ${url}`);
|
|
20
20
|
}
|
|
21
21
|
if (parsed.protocol === "https:") return url;
|
|
22
22
|
if (parsed.protocol === "http:" && LOCALHOST_HOSTS.has(parsed.hostname)) return url;
|
|
23
|
-
throw new
|
|
23
|
+
throw new chunk6IQN5RQD_cjs.ClawOpsError(
|
|
24
24
|
`base_url\uC740 HTTPS\uB97C \uC0AC\uC6A9\uD574\uC57C \uD569\uB2C8\uB2E4 (\uBC1B\uC740 \uAC12: '${url}'). \uB85C\uCEEC \uAC1C\uBC1C \uC2DC\uC5D0\uB294 http://localhost\uB97C \uC0AC\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`
|
|
25
25
|
);
|
|
26
26
|
}
|
|
@@ -33,9 +33,9 @@ var APIClient = class {
|
|
|
33
33
|
_defaultHeaders;
|
|
34
34
|
constructor(options) {
|
|
35
35
|
this._apiKey = options.apiKey;
|
|
36
|
-
this._baseURL = validateBaseUrl((options.baseURL ??
|
|
37
|
-
this._maxRetries = options.maxRetries ??
|
|
38
|
-
this._timeout = options.timeout ??
|
|
36
|
+
this._baseURL = validateBaseUrl((options.baseURL ?? chunk6IQN5RQD_cjs.DEFAULT_BASE_URL).replace(/\/+$/, ""));
|
|
37
|
+
this._maxRetries = options.maxRetries ?? chunk6IQN5RQD_cjs.DEFAULT_MAX_RETRIES;
|
|
38
|
+
this._timeout = options.timeout ?? chunk6IQN5RQD_cjs.DEFAULT_TIMEOUT;
|
|
39
39
|
this._fetch = options.fetch ?? globalThis.fetch;
|
|
40
40
|
this._defaultHeaders = options.defaultHeaders ?? {};
|
|
41
41
|
}
|
|
@@ -80,14 +80,14 @@ var APIClient = class {
|
|
|
80
80
|
await this._sleep(this._retryDelay(this._maxRetries - retriesLeft));
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
|
-
throw new
|
|
83
|
+
throw new chunk6IQN5RQD_cjs.APITimeoutError({ method: method2, url });
|
|
84
84
|
}
|
|
85
85
|
if (retriesLeft > 0) {
|
|
86
86
|
retriesLeft--;
|
|
87
87
|
await this._sleep(this._retryDelay(this._maxRetries - retriesLeft));
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
|
-
throw new
|
|
90
|
+
throw new chunk6IQN5RQD_cjs.APIConnectionError({ method: method2, url });
|
|
91
91
|
} finally {
|
|
92
92
|
clearTimeout(timeoutId);
|
|
93
93
|
}
|
|
@@ -99,11 +99,11 @@ var APIClient = class {
|
|
|
99
99
|
try {
|
|
100
100
|
json = await response.json();
|
|
101
101
|
} catch {
|
|
102
|
-
throw new
|
|
102
|
+
throw new chunk6IQN5RQD_cjs.APIResponseValidationError({ status: response.status }, { method: method2, url });
|
|
103
103
|
}
|
|
104
104
|
const parsed = options.castTo.safeParse(json);
|
|
105
105
|
if (!parsed.success) {
|
|
106
|
-
throw new
|
|
106
|
+
throw new chunk6IQN5RQD_cjs.APIResponseValidationError({ status: response.status }, { method: method2, url });
|
|
107
107
|
}
|
|
108
108
|
return parsed.data;
|
|
109
109
|
}
|
|
@@ -118,14 +118,14 @@ var APIClient = class {
|
|
|
118
118
|
} catch {
|
|
119
119
|
body = null;
|
|
120
120
|
}
|
|
121
|
-
throw
|
|
121
|
+
throw chunk6IQN5RQD_cjs.makeStatusError(response.status, body, response.headers, { method: method2, url });
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
_shouldRetry(status) {
|
|
125
125
|
return status === 408 || status === 409 || status === 429 || status >= 500;
|
|
126
126
|
}
|
|
127
127
|
_retryDelay(retriesTaken) {
|
|
128
|
-
const delay = Math.min(
|
|
128
|
+
const delay = Math.min(chunk6IQN5RQD_cjs.INITIAL_RETRY_DELAY * 2 ** retriesTaken, chunk6IQN5RQD_cjs.MAX_RETRY_DELAY);
|
|
129
129
|
return delay * (1 + Math.random());
|
|
130
130
|
}
|
|
131
131
|
_sleep(ms) {
|
|
@@ -454,7 +454,7 @@ var AccountContext = class {
|
|
|
454
454
|
return new WebhookLogs(this._client, this._accountId);
|
|
455
455
|
}
|
|
456
456
|
};
|
|
457
|
-
var WebhookVerificationError = class extends
|
|
457
|
+
var WebhookVerificationError = class extends chunk6IQN5RQD_cjs.ClawOpsError {
|
|
458
458
|
constructor(message = "Webhook \uC11C\uBA85\uC774 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.") {
|
|
459
459
|
super(message);
|
|
460
460
|
this.name = "WebhookVerificationError";
|
|
@@ -484,13 +484,13 @@ var ClawOps = class extends APIClient {
|
|
|
484
484
|
constructor(options = {}) {
|
|
485
485
|
let apiKey = options.apiKey ?? process.env.CLAWOPS_API_KEY;
|
|
486
486
|
if (!apiKey) {
|
|
487
|
-
throw new
|
|
487
|
+
throw new chunk6IQN5RQD_cjs.ClawOpsError("apiKey\uB97C \uC9C0\uC815\uD558\uAC70\uB098 CLAWOPS_API_KEY \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694.");
|
|
488
488
|
}
|
|
489
489
|
let accountId = options.accountId ?? process.env.CLAWOPS_ACCOUNT_ID;
|
|
490
490
|
if (!accountId) {
|
|
491
|
-
throw new
|
|
491
|
+
throw new chunk6IQN5RQD_cjs.ClawOpsError("accountId\uB97C \uC9C0\uC815\uD558\uAC70\uB098 CLAWOPS_ACCOUNT_ID \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694.");
|
|
492
492
|
}
|
|
493
|
-
const baseURL = options.baseURL ?? process.env.CLAWOPS_BASE_URL ??
|
|
493
|
+
const baseURL = options.baseURL ?? process.env.CLAWOPS_BASE_URL ?? chunk6IQN5RQD_cjs.DEFAULT_BASE_URL;
|
|
494
494
|
super({
|
|
495
495
|
apiKey,
|
|
496
496
|
baseURL,
|
|
@@ -526,67 +526,71 @@ var client_default_default = ClawOps;
|
|
|
526
526
|
|
|
527
527
|
Object.defineProperty(exports, "APIConnectionError", {
|
|
528
528
|
enumerable: true,
|
|
529
|
-
get: function () { return
|
|
529
|
+
get: function () { return chunk6IQN5RQD_cjs.APIConnectionError; }
|
|
530
530
|
});
|
|
531
531
|
Object.defineProperty(exports, "APIError", {
|
|
532
532
|
enumerable: true,
|
|
533
|
-
get: function () { return
|
|
533
|
+
get: function () { return chunk6IQN5RQD_cjs.APIError; }
|
|
534
534
|
});
|
|
535
535
|
Object.defineProperty(exports, "APIResponseValidationError", {
|
|
536
536
|
enumerable: true,
|
|
537
|
-
get: function () { return
|
|
537
|
+
get: function () { return chunk6IQN5RQD_cjs.APIResponseValidationError; }
|
|
538
538
|
});
|
|
539
539
|
Object.defineProperty(exports, "APIStatusError", {
|
|
540
540
|
enumerable: true,
|
|
541
|
-
get: function () { return
|
|
541
|
+
get: function () { return chunk6IQN5RQD_cjs.APIStatusError; }
|
|
542
542
|
});
|
|
543
543
|
Object.defineProperty(exports, "APITimeoutError", {
|
|
544
544
|
enumerable: true,
|
|
545
|
-
get: function () { return
|
|
545
|
+
get: function () { return chunk6IQN5RQD_cjs.APITimeoutError; }
|
|
546
546
|
});
|
|
547
547
|
Object.defineProperty(exports, "AgentConnectionError", {
|
|
548
548
|
enumerable: true,
|
|
549
|
-
get: function () { return
|
|
549
|
+
get: function () { return chunk6IQN5RQD_cjs.AgentConnectionError; }
|
|
550
550
|
});
|
|
551
551
|
Object.defineProperty(exports, "AgentError", {
|
|
552
552
|
enumerable: true,
|
|
553
|
-
get: function () { return
|
|
553
|
+
get: function () { return chunk6IQN5RQD_cjs.AgentError; }
|
|
554
554
|
});
|
|
555
555
|
Object.defineProperty(exports, "AuthenticationError", {
|
|
556
556
|
enumerable: true,
|
|
557
|
-
get: function () { return
|
|
557
|
+
get: function () { return chunk6IQN5RQD_cjs.AuthenticationError; }
|
|
558
558
|
});
|
|
559
559
|
Object.defineProperty(exports, "BadRequestError", {
|
|
560
560
|
enumerable: true,
|
|
561
|
-
get: function () { return
|
|
561
|
+
get: function () { return chunk6IQN5RQD_cjs.BadRequestError; }
|
|
562
562
|
});
|
|
563
563
|
Object.defineProperty(exports, "ClawOpsError", {
|
|
564
564
|
enumerable: true,
|
|
565
|
-
get: function () { return
|
|
565
|
+
get: function () { return chunk6IQN5RQD_cjs.ClawOpsError; }
|
|
566
566
|
});
|
|
567
567
|
Object.defineProperty(exports, "ConflictError", {
|
|
568
568
|
enumerable: true,
|
|
569
|
-
get: function () { return
|
|
569
|
+
get: function () { return chunk6IQN5RQD_cjs.ConflictError; }
|
|
570
570
|
});
|
|
571
571
|
Object.defineProperty(exports, "InternalServerError", {
|
|
572
572
|
enumerable: true,
|
|
573
|
-
get: function () { return
|
|
573
|
+
get: function () { return chunk6IQN5RQD_cjs.InternalServerError; }
|
|
574
574
|
});
|
|
575
575
|
Object.defineProperty(exports, "NotFoundError", {
|
|
576
576
|
enumerable: true,
|
|
577
|
-
get: function () { return
|
|
577
|
+
get: function () { return chunk6IQN5RQD_cjs.NotFoundError; }
|
|
578
578
|
});
|
|
579
579
|
Object.defineProperty(exports, "PermissionDeniedError", {
|
|
580
580
|
enumerable: true,
|
|
581
|
-
get: function () { return
|
|
581
|
+
get: function () { return chunk6IQN5RQD_cjs.PermissionDeniedError; }
|
|
582
|
+
});
|
|
583
|
+
Object.defineProperty(exports, "RateLimitError", {
|
|
584
|
+
enumerable: true,
|
|
585
|
+
get: function () { return chunk6IQN5RQD_cjs.RateLimitError; }
|
|
582
586
|
});
|
|
583
587
|
Object.defineProperty(exports, "ServiceUnavailableError", {
|
|
584
588
|
enumerable: true,
|
|
585
|
-
get: function () { return
|
|
589
|
+
get: function () { return chunk6IQN5RQD_cjs.ServiceUnavailableError; }
|
|
586
590
|
});
|
|
587
591
|
Object.defineProperty(exports, "UnprocessableEntityError", {
|
|
588
592
|
enumerable: true,
|
|
589
|
-
get: function () { return
|
|
593
|
+
get: function () { return chunk6IQN5RQD_cjs.UnprocessableEntityError; }
|
|
590
594
|
});
|
|
591
595
|
exports.APIClient = APIClient;
|
|
592
596
|
exports.AccountContext = AccountContext;
|
package/dist/index.d.cts
CHANGED
|
@@ -447,6 +447,22 @@ declare class UnprocessableEntityError extends APIStatusError {
|
|
|
447
447
|
url: string;
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* HTTP 429 Too Many Requests.
|
|
452
|
+
*
|
|
453
|
+
* 동시 통화 한도 초과 등 일시적 제한. SDK는 자동 재시도(최대 2회, 지수 backoff)를 수행한다.
|
|
454
|
+
* 즉각 피드백이 필요하면 client 생성 시 maxRetries: 0으로 재시도를 비활성화하라.
|
|
455
|
+
*/
|
|
456
|
+
declare class RateLimitError extends APIStatusError {
|
|
457
|
+
readonly status: 429;
|
|
458
|
+
constructor(message: string, response: {
|
|
459
|
+
status: number;
|
|
460
|
+
headers?: Headers;
|
|
461
|
+
}, body: unknown, request: {
|
|
462
|
+
method: string;
|
|
463
|
+
url: string;
|
|
464
|
+
});
|
|
465
|
+
}
|
|
450
466
|
declare class InternalServerError extends APIStatusError {
|
|
451
467
|
readonly status: 500;
|
|
452
468
|
constructor(message: string, response: {
|
|
@@ -553,4 +569,4 @@ interface NumberUpdateParams {
|
|
|
553
569
|
webhookMethod?: 'POST' | 'GET';
|
|
554
570
|
}
|
|
555
571
|
|
|
556
|
-
export { APIClient, type APIClientOptions, APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AccountContext, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, type Call, type CallControlResponse, type CallCreateParams, type CallListParams, type CallUpdateParams, Calls, ClawOps, ClawOpsError, type ClawOpsOptions, ConflictError, InternalServerError, type Message, type MessageCreateParams, type MessageListParams, Messages, NotFoundError, type NumberCreateParams, type NumberListItem, type NumberUpdateParams, type NumberUpdateResponse, Numbers, Page, type PaginationMeta, PermissionDeniedError, type PhoneNumber, ServiceUnavailableError, UnprocessableEntityError, VERSION, type WebhookLog, WebhookLogs, WebhookVerificationError, Webhooks, ClawOps as default };
|
|
572
|
+
export { APIClient, type APIClientOptions, APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AccountContext, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, type Call, type CallControlResponse, type CallCreateParams, type CallListParams, type CallUpdateParams, Calls, ClawOps, ClawOpsError, type ClawOpsOptions, ConflictError, InternalServerError, type Message, type MessageCreateParams, type MessageListParams, Messages, NotFoundError, type NumberCreateParams, type NumberListItem, type NumberUpdateParams, type NumberUpdateResponse, Numbers, Page, type PaginationMeta, PermissionDeniedError, type PhoneNumber, RateLimitError, ServiceUnavailableError, UnprocessableEntityError, VERSION, type WebhookLog, WebhookLogs, WebhookVerificationError, Webhooks, ClawOps as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -447,6 +447,22 @@ declare class UnprocessableEntityError extends APIStatusError {
|
|
|
447
447
|
url: string;
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* HTTP 429 Too Many Requests.
|
|
452
|
+
*
|
|
453
|
+
* 동시 통화 한도 초과 등 일시적 제한. SDK는 자동 재시도(최대 2회, 지수 backoff)를 수행한다.
|
|
454
|
+
* 즉각 피드백이 필요하면 client 생성 시 maxRetries: 0으로 재시도를 비활성화하라.
|
|
455
|
+
*/
|
|
456
|
+
declare class RateLimitError extends APIStatusError {
|
|
457
|
+
readonly status: 429;
|
|
458
|
+
constructor(message: string, response: {
|
|
459
|
+
status: number;
|
|
460
|
+
headers?: Headers;
|
|
461
|
+
}, body: unknown, request: {
|
|
462
|
+
method: string;
|
|
463
|
+
url: string;
|
|
464
|
+
});
|
|
465
|
+
}
|
|
450
466
|
declare class InternalServerError extends APIStatusError {
|
|
451
467
|
readonly status: 500;
|
|
452
468
|
constructor(message: string, response: {
|
|
@@ -553,4 +569,4 @@ interface NumberUpdateParams {
|
|
|
553
569
|
webhookMethod?: 'POST' | 'GET';
|
|
554
570
|
}
|
|
555
571
|
|
|
556
|
-
export { APIClient, type APIClientOptions, APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AccountContext, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, type Call, type CallControlResponse, type CallCreateParams, type CallListParams, type CallUpdateParams, Calls, ClawOps, ClawOpsError, type ClawOpsOptions, ConflictError, InternalServerError, type Message, type MessageCreateParams, type MessageListParams, Messages, NotFoundError, type NumberCreateParams, type NumberListItem, type NumberUpdateParams, type NumberUpdateResponse, Numbers, Page, type PaginationMeta, PermissionDeniedError, type PhoneNumber, ServiceUnavailableError, UnprocessableEntityError, VERSION, type WebhookLog, WebhookLogs, WebhookVerificationError, Webhooks, ClawOps as default };
|
|
572
|
+
export { APIClient, type APIClientOptions, APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AccountContext, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, type Call, type CallControlResponse, type CallCreateParams, type CallListParams, type CallUpdateParams, Calls, ClawOps, ClawOpsError, type ClawOpsOptions, ConflictError, InternalServerError, type Message, type MessageCreateParams, type MessageListParams, Messages, NotFoundError, type NumberCreateParams, type NumberListItem, type NumberUpdateParams, type NumberUpdateResponse, Numbers, Page, type PaginationMeta, PermissionDeniedError, type PhoneNumber, RateLimitError, ServiceUnavailableError, UnprocessableEntityError, VERSION, type WebhookLog, WebhookLogs, WebhookVerificationError, Webhooks, ClawOps as default };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, APITimeoutError, APIConnectionError, APIResponseValidationError, makeStatusError, ClawOpsError, INITIAL_RETRY_DELAY, MAX_RETRY_DELAY } from './chunk-
|
|
2
|
-
export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, ClawOpsError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, ServiceUnavailableError, UnprocessableEntityError } from './chunk-
|
|
1
|
+
import { DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, APITimeoutError, APIConnectionError, APIResponseValidationError, makeStatusError, ClawOpsError, INITIAL_RETRY_DELAY, MAX_RETRY_DELAY } from './chunk-7S2OEBS6.js';
|
|
2
|
+
export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, ClawOpsError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, ServiceUnavailableError, UnprocessableEntityError } from './chunk-7S2OEBS6.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { timingSafeEqual, createHmac } from 'crypto';
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error.ts","../src/constants.ts"],"names":[],"mappings":";;;AAAO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACtC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EACd;AACF;AAEO,IAAM,Q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,eAAA,GAAkB","file":"chunk-JNSHMKDI.cjs","sourcesContent":["export class ClawOpsError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ClawOpsError';\n }\n}\n\nexport class APIError extends ClawOpsError {\n readonly request: { method: string; url: string };\n\n constructor(message: string, request: { method: string; url: string }) {\n super(message);\n this.name = 'APIError';\n this.request = request;\n }\n}\n\nexport class APIStatusError extends APIError {\n readonly status: number;\n readonly body: unknown;\n readonly headers: Headers | undefined;\n\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, request);\n this.name = 'APIStatusError';\n this.status = response.status;\n this.body = body;\n this.headers = response.headers;\n }\n}\n\nexport class BadRequestError extends APIStatusError {\n override readonly status = 400 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'BadRequestError';\n }\n}\n\nexport class AuthenticationError extends APIStatusError {\n override readonly status = 401 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class PermissionDeniedError extends APIStatusError {\n override readonly status = 403 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'PermissionDeniedError';\n }\n}\n\nexport class NotFoundError extends APIStatusError {\n override readonly status = 404 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'NotFoundError';\n }\n}\n\nexport class ConflictError extends APIStatusError {\n override readonly status = 409 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'ConflictError';\n }\n}\n\nexport class UnprocessableEntityError extends APIStatusError {\n override readonly status = 422 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'UnprocessableEntityError';\n }\n}\n\nexport class InternalServerError extends APIStatusError {\n override readonly status = 500 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'InternalServerError';\n }\n}\n\nexport class ServiceUnavailableError extends APIStatusError {\n override readonly status = 503 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'ServiceUnavailableError';\n }\n}\n\nexport class APIConnectionError extends APIError {\n constructor(request: { method: string; url: string }, message = 'Connection error.') {\n super(message, request);\n this.name = 'APIConnectionError';\n }\n}\n\nexport class APITimeoutError extends APIConnectionError {\n constructor(request: { method: string; url: string }) {\n super(request, 'Request timed out.');\n this.name = 'APITimeoutError';\n }\n}\n\nexport class APIResponseValidationError extends APIError {\n readonly status: number;\n\n constructor(response: { status: number }, request: { method: string; url: string }) {\n super('API response validation failed.', request);\n this.name = 'APIResponseValidationError';\n this.status = response.status;\n }\n}\n\nexport class AgentError extends ClawOpsError {\n constructor(message: string) {\n super(message);\n this.name = 'AgentError';\n }\n}\n\nexport class AgentConnectionError extends AgentError {\n constructor(message = 'Agent WebSocket connection failed.') {\n super(message);\n this.name = 'AgentConnectionError';\n }\n}\n\nconst STATUS_CODE_TO_ERROR: Record<\n number,\n new (\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) => APIStatusError\n> = {\n 400: BadRequestError,\n 401: AuthenticationError,\n 403: PermissionDeniedError,\n 404: NotFoundError,\n 409: ConflictError,\n 422: UnprocessableEntityError,\n 500: InternalServerError,\n 503: ServiceUnavailableError,\n};\n\nexport function makeStatusError(\n status: number,\n body: unknown,\n headers: Headers | undefined,\n request: { method: string; url: string },\n): APIStatusError {\n let message = '';\n if (body && typeof body === 'object' && 'error' in body) {\n message = (body as { error: string }).error;\n } else {\n message = `HTTP ${status}`;\n }\n\n const ErrorClass = STATUS_CODE_TO_ERROR[status];\n if (ErrorClass) {\n return new ErrorClass(message, { status, headers }, body, request);\n }\n if (status >= 500) {\n return new InternalServerError(message, { status, headers }, body, request);\n }\n return new APIStatusError(message, { status, headers }, body, request);\n}\n","export const DEFAULT_BASE_URL = 'https://api.claw-ops.com';\nexport const DEFAULT_MAX_RETRIES = 2;\nexport const DEFAULT_TIMEOUT = 600_000; // ms\nexport const INITIAL_RETRY_DELAY = 500; // ms\nexport const MAX_RETRY_DELAY = 8_000; // ms\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error.ts","../src/constants.ts"],"names":[],"mappings":";AAAO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACtC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EACd;AACF;AAEO,IAAM,QAAA,GAAN,cAAuB,YAAA,CAAa;AAAA,EAChC,OAAA;AAAA,EAET,WAAA,CAAY,SAAiB,OAAA,EAA0C;AACrE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AACF;AAEO,IAAM,cAAA,GAAN,cAA6B,QAAA,CAAS;AAAA,EAClC,MAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CACE,OAAA,EACA,QAAA,EACA,IAAA,EACA,OAAA,EACA;AACA,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AACZ,IAAA,IAAA,CAAK,SAAS,QAAA,CAAS,MAAA;AACvB,IAAA,IAAA,CAAK,IAAA,GAAO,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AACvD,IAAA,OAAA,GAAW,IAAA,CAA2B,KAAA;AAAA,EACxC,CAAA,MAAO;AACL,IAAA,OAAA,GAAU,QAAQ,MAAM,CAAA,CAAA;AAAA,EAC1B;AAEA,EAAA,MAAM,UAAA,GAAa,qBAAqB,MAAM,CAAA;AAC9C,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,OAAO,IAAI,WAAW,OAAA,EAAS,EAAE,QAAQ,OAAA,EAAQ,EAAG,MAAM,OAAO,CAAA;AAAA,EACnE;AACA,EAAA,IAAI,UAAU,GAAA,EAAK;AACjB,IAAA,OAAO,IAAI,oBAAoB,OAAA,EAAS,EAAE,QAAQ,OAAA,EAAQ,EAAG,MAAM,OAAO,CAAA;AAAA,EAC5E;AACA,EAAA,OAAO,IAAI,eAAe,OAAA,EAAS,EAAE,QAAQ,OAAA,EAAQ,EAAG,MAAM,OAAO,CAAA;AACvE;;;AC1NO,IAAM,gBAAA,GAAmB;AACzB,IAAM,mBAAA,GAAsB;AAC5B,IAAM,eAAA,GAAkB;AACxB,IAAM,mBAAA,GAAsB;AAC5B,IAAM,eAAA,GAAkB","file":"chunk-UKAT24I6.js","sourcesContent":["export class ClawOpsError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ClawOpsError';\n }\n}\n\nexport class APIError extends ClawOpsError {\n readonly request: { method: string; url: string };\n\n constructor(message: string, request: { method: string; url: string }) {\n super(message);\n this.name = 'APIError';\n this.request = request;\n }\n}\n\nexport class APIStatusError extends APIError {\n readonly status: number;\n readonly body: unknown;\n readonly headers: Headers | undefined;\n\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, request);\n this.name = 'APIStatusError';\n this.status = response.status;\n this.body = body;\n this.headers = response.headers;\n }\n}\n\nexport class BadRequestError extends APIStatusError {\n override readonly status = 400 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'BadRequestError';\n }\n}\n\nexport class AuthenticationError extends APIStatusError {\n override readonly status = 401 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class PermissionDeniedError extends APIStatusError {\n override readonly status = 403 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'PermissionDeniedError';\n }\n}\n\nexport class NotFoundError extends APIStatusError {\n override readonly status = 404 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'NotFoundError';\n }\n}\n\nexport class ConflictError extends APIStatusError {\n override readonly status = 409 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'ConflictError';\n }\n}\n\nexport class UnprocessableEntityError extends APIStatusError {\n override readonly status = 422 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'UnprocessableEntityError';\n }\n}\n\nexport class InternalServerError extends APIStatusError {\n override readonly status = 500 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'InternalServerError';\n }\n}\n\nexport class ServiceUnavailableError extends APIStatusError {\n override readonly status = 503 as const;\n constructor(\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) {\n super(message, response, body, request);\n this.name = 'ServiceUnavailableError';\n }\n}\n\nexport class APIConnectionError extends APIError {\n constructor(request: { method: string; url: string }, message = 'Connection error.') {\n super(message, request);\n this.name = 'APIConnectionError';\n }\n}\n\nexport class APITimeoutError extends APIConnectionError {\n constructor(request: { method: string; url: string }) {\n super(request, 'Request timed out.');\n this.name = 'APITimeoutError';\n }\n}\n\nexport class APIResponseValidationError extends APIError {\n readonly status: number;\n\n constructor(response: { status: number }, request: { method: string; url: string }) {\n super('API response validation failed.', request);\n this.name = 'APIResponseValidationError';\n this.status = response.status;\n }\n}\n\nexport class AgentError extends ClawOpsError {\n constructor(message: string) {\n super(message);\n this.name = 'AgentError';\n }\n}\n\nexport class AgentConnectionError extends AgentError {\n constructor(message = 'Agent WebSocket connection failed.') {\n super(message);\n this.name = 'AgentConnectionError';\n }\n}\n\nconst STATUS_CODE_TO_ERROR: Record<\n number,\n new (\n message: string,\n response: { status: number; headers?: Headers },\n body: unknown,\n request: { method: string; url: string },\n ) => APIStatusError\n> = {\n 400: BadRequestError,\n 401: AuthenticationError,\n 403: PermissionDeniedError,\n 404: NotFoundError,\n 409: ConflictError,\n 422: UnprocessableEntityError,\n 500: InternalServerError,\n 503: ServiceUnavailableError,\n};\n\nexport function makeStatusError(\n status: number,\n body: unknown,\n headers: Headers | undefined,\n request: { method: string; url: string },\n): APIStatusError {\n let message = '';\n if (body && typeof body === 'object' && 'error' in body) {\n message = (body as { error: string }).error;\n } else {\n message = `HTTP ${status}`;\n }\n\n const ErrorClass = STATUS_CODE_TO_ERROR[status];\n if (ErrorClass) {\n return new ErrorClass(message, { status, headers }, body, request);\n }\n if (status >= 500) {\n return new InternalServerError(message, { status, headers }, body, request);\n }\n return new APIStatusError(message, { status, headers }, body, request);\n}\n","export const DEFAULT_BASE_URL = 'https://api.claw-ops.com';\nexport const DEFAULT_MAX_RETRIES = 2;\nexport const DEFAULT_TIMEOUT = 600_000; // ms\nexport const INITIAL_RETRY_DELAY = 500; // ms\nexport const MAX_RETRY_DELAY = 8_000; // ms\n"]}
|