@teamlearners/clawops 0.29.0 → 0.31.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/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var chunkSBK45525_cjs = require('./chunk-SBK45525.cjs');
5
+ var chunkKHEU4DKD_cjs = require('./chunk-KHEU4DKD.cjs');
6
6
  var zod = require('zod');
7
7
  var crypto = require('crypto');
8
8
 
@@ -13,11 +13,11 @@ function validateBaseUrl(url) {
13
13
  try {
14
14
  parsed = new URL(url);
15
15
  } catch {
16
- throw new chunkSBK45525_cjs.ClawOpsError(`Invalid base_url: ${url}`);
16
+ throw new chunkKHEU4DKD_cjs.ClawOpsError(`Invalid base_url: ${url}`);
17
17
  }
18
18
  if (parsed.protocol === "https:") return url;
19
19
  if (parsed.protocol === "http:" && LOCALHOST_HOSTS.has(parsed.hostname)) return url;
20
- throw new chunkSBK45525_cjs.ClawOpsError(
20
+ throw new chunkKHEU4DKD_cjs.ClawOpsError(
21
21
  `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.`
22
22
  );
23
23
  }
@@ -30,9 +30,9 @@ var APIClient = class {
30
30
  _defaultHeaders;
31
31
  constructor(options) {
32
32
  this._apiKey = options.apiKey;
33
- this._baseURL = validateBaseUrl((options.baseURL ?? chunkSBK45525_cjs.DEFAULT_BASE_URL).replace(/\/+$/, ""));
34
- this._maxRetries = options.maxRetries ?? chunkSBK45525_cjs.DEFAULT_MAX_RETRIES;
35
- this._timeout = options.timeout ?? chunkSBK45525_cjs.DEFAULT_TIMEOUT;
33
+ this._baseURL = validateBaseUrl((options.baseURL ?? chunkKHEU4DKD_cjs.DEFAULT_BASE_URL).replace(/\/+$/, ""));
34
+ this._maxRetries = options.maxRetries ?? chunkKHEU4DKD_cjs.DEFAULT_MAX_RETRIES;
35
+ this._timeout = options.timeout ?? chunkKHEU4DKD_cjs.DEFAULT_TIMEOUT;
36
36
  this._fetch = options.fetch ?? globalThis.fetch;
37
37
  this._defaultHeaders = options.defaultHeaders ?? {};
38
38
  }
@@ -41,7 +41,7 @@ var APIClient = class {
41
41
  Authorization: `Bearer ${this._apiKey}`,
42
42
  "Content-Type": "application/json",
43
43
  Accept: "application/json",
44
- "User-Agent": `claw-ops-node/${chunkSBK45525_cjs.VERSION}`,
44
+ "User-Agent": `claw-ops-node/${chunkKHEU4DKD_cjs.VERSION}`,
45
45
  ...this._defaultHeaders
46
46
  };
47
47
  if (extra) Object.assign(headers, extra);
@@ -77,14 +77,14 @@ var APIClient = class {
77
77
  await this._sleep(this._retryDelay(this._maxRetries - retriesLeft));
78
78
  continue;
79
79
  }
80
- throw new chunkSBK45525_cjs.APITimeoutError({ method: method2, url });
80
+ throw new chunkKHEU4DKD_cjs.APITimeoutError({ method: method2, url });
81
81
  }
82
82
  if (retriesLeft > 0) {
83
83
  retriesLeft--;
84
84
  await this._sleep(this._retryDelay(this._maxRetries - retriesLeft));
85
85
  continue;
86
86
  }
87
- throw new chunkSBK45525_cjs.APIConnectionError({ method: method2, url });
87
+ throw new chunkKHEU4DKD_cjs.APIConnectionError({ method: method2, url });
88
88
  } finally {
89
89
  clearTimeout(timeoutId);
90
90
  }
@@ -100,7 +100,7 @@ var APIClient = class {
100
100
  } catch {
101
101
  body = null;
102
102
  }
103
- throw chunkSBK45525_cjs.makeStatusError(response.status, body, response.headers, { method: method2, url });
103
+ throw chunkKHEU4DKD_cjs.makeStatusError(response.status, body, response.headers, { method: method2, url });
104
104
  }
105
105
  }
106
106
  async _request(method2, path, options = {}) {
@@ -111,11 +111,11 @@ var APIClient = class {
111
111
  try {
112
112
  json = await response.json();
113
113
  } catch {
114
- throw new chunkSBK45525_cjs.APIResponseValidationError({ status: response.status }, { method: method2, url });
114
+ throw new chunkKHEU4DKD_cjs.APIResponseValidationError({ status: response.status }, { method: method2, url });
115
115
  }
116
116
  const parsed = options.castTo.safeParse(json);
117
117
  if (!parsed.success) {
118
- throw new chunkSBK45525_cjs.APIResponseValidationError({ status: response.status }, { method: method2, url });
118
+ throw new chunkKHEU4DKD_cjs.APIResponseValidationError({ status: response.status }, { method: method2, url });
119
119
  }
120
120
  return parsed.data;
121
121
  }
@@ -123,7 +123,7 @@ var APIClient = class {
123
123
  return status === 408 || status === 409 || status === 429 || status >= 500;
124
124
  }
125
125
  _retryDelay(retriesTaken) {
126
- const delay = Math.min(chunkSBK45525_cjs.INITIAL_RETRY_DELAY * 2 ** retriesTaken, chunkSBK45525_cjs.MAX_RETRY_DELAY);
126
+ const delay = Math.min(chunkKHEU4DKD_cjs.INITIAL_RETRY_DELAY * 2 ** retriesTaken, chunkKHEU4DKD_cjs.MAX_RETRY_DELAY);
127
127
  return delay * (1 + Math.random());
128
128
  }
129
129
  _sleep(ms) {
@@ -519,12 +519,22 @@ var SummaryStatusSchema = zod.z.object({
519
519
  }).passthrough();
520
520
 
521
521
  // src/resources/calls.ts
522
+ function callContextBody(ctx) {
523
+ if (!ctx) return void 0;
524
+ const body = { Instruction: ctx.instruction };
525
+ if (ctx.variables !== void 0) body.Variables = ctx.variables;
526
+ return body;
527
+ }
522
528
  var Calls = class extends APIResource {
523
529
  async create(params, options = {}) {
524
530
  const body = stripNotGiven({
525
531
  To: params.to,
526
532
  From: params.from,
527
533
  Url: params.url,
534
+ AgentId: params.agentId,
535
+ CallContext: callContextBody(params.callContext),
536
+ CallFlowId: params.callFlowId,
537
+ Variables: params.variables,
528
538
  StatusCallback: params.statusCallback,
529
539
  StatusCallbackEvent: params.statusCallbackEvent,
530
540
  Timeout: params.timeout,
@@ -947,7 +957,7 @@ var AccountContext = class {
947
957
  return new BlockedRecipients(this._client, this._accountId);
948
958
  }
949
959
  };
950
- var WebhookVerificationError = class extends chunkSBK45525_cjs.ClawOpsError {
960
+ var WebhookVerificationError = class extends chunkKHEU4DKD_cjs.ClawOpsError {
951
961
  constructor(message = "Webhook \uC11C\uBA85\uC774 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.") {
952
962
  super(message);
953
963
  this.name = "WebhookVerificationError";
@@ -977,13 +987,13 @@ var ClawOps = class extends APIClient {
977
987
  constructor(options = {}) {
978
988
  let apiKey = options.apiKey ?? process.env.CLAWOPS_API_KEY;
979
989
  if (!apiKey) {
980
- throw new chunkSBK45525_cjs.ClawOpsError("apiKey\uB97C \uC9C0\uC815\uD558\uAC70\uB098 CLAWOPS_API_KEY \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694.");
990
+ throw new chunkKHEU4DKD_cjs.ClawOpsError("apiKey\uB97C \uC9C0\uC815\uD558\uAC70\uB098 CLAWOPS_API_KEY \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694.");
981
991
  }
982
992
  let accountId = options.accountId ?? process.env.CLAWOPS_ACCOUNT_ID;
983
993
  if (!accountId) {
984
- throw new chunkSBK45525_cjs.ClawOpsError("accountId\uB97C \uC9C0\uC815\uD558\uAC70\uB098 CLAWOPS_ACCOUNT_ID \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694.");
994
+ throw new chunkKHEU4DKD_cjs.ClawOpsError("accountId\uB97C \uC9C0\uC815\uD558\uAC70\uB098 CLAWOPS_ACCOUNT_ID \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694.");
985
995
  }
986
- const baseURL = options.baseURL ?? process.env.CLAWOPS_BASE_URL ?? chunkSBK45525_cjs.DEFAULT_BASE_URL;
996
+ const baseURL = options.baseURL ?? process.env.CLAWOPS_BASE_URL ?? chunkKHEU4DKD_cjs.DEFAULT_BASE_URL;
987
997
  super({
988
998
  apiKey,
989
999
  baseURL,
@@ -1034,75 +1044,75 @@ var client_default_default = ClawOps;
1034
1044
 
1035
1045
  Object.defineProperty(exports, "APIConnectionError", {
1036
1046
  enumerable: true,
1037
- get: function () { return chunkSBK45525_cjs.APIConnectionError; }
1047
+ get: function () { return chunkKHEU4DKD_cjs.APIConnectionError; }
1038
1048
  });
1039
1049
  Object.defineProperty(exports, "APIError", {
1040
1050
  enumerable: true,
1041
- get: function () { return chunkSBK45525_cjs.APIError; }
1051
+ get: function () { return chunkKHEU4DKD_cjs.APIError; }
1042
1052
  });
1043
1053
  Object.defineProperty(exports, "APIResponseValidationError", {
1044
1054
  enumerable: true,
1045
- get: function () { return chunkSBK45525_cjs.APIResponseValidationError; }
1055
+ get: function () { return chunkKHEU4DKD_cjs.APIResponseValidationError; }
1046
1056
  });
1047
1057
  Object.defineProperty(exports, "APIStatusError", {
1048
1058
  enumerable: true,
1049
- get: function () { return chunkSBK45525_cjs.APIStatusError; }
1059
+ get: function () { return chunkKHEU4DKD_cjs.APIStatusError; }
1050
1060
  });
1051
1061
  Object.defineProperty(exports, "APITimeoutError", {
1052
1062
  enumerable: true,
1053
- get: function () { return chunkSBK45525_cjs.APITimeoutError; }
1063
+ get: function () { return chunkKHEU4DKD_cjs.APITimeoutError; }
1054
1064
  });
1055
1065
  Object.defineProperty(exports, "AgentConnectionError", {
1056
1066
  enumerable: true,
1057
- get: function () { return chunkSBK45525_cjs.AgentConnectionError; }
1067
+ get: function () { return chunkKHEU4DKD_cjs.AgentConnectionError; }
1058
1068
  });
1059
1069
  Object.defineProperty(exports, "AgentError", {
1060
1070
  enumerable: true,
1061
- get: function () { return chunkSBK45525_cjs.AgentError; }
1071
+ get: function () { return chunkKHEU4DKD_cjs.AgentError; }
1062
1072
  });
1063
1073
  Object.defineProperty(exports, "AuthenticationError", {
1064
1074
  enumerable: true,
1065
- get: function () { return chunkSBK45525_cjs.AuthenticationError; }
1075
+ get: function () { return chunkKHEU4DKD_cjs.AuthenticationError; }
1066
1076
  });
1067
1077
  Object.defineProperty(exports, "BadRequestError", {
1068
1078
  enumerable: true,
1069
- get: function () { return chunkSBK45525_cjs.BadRequestError; }
1079
+ get: function () { return chunkKHEU4DKD_cjs.BadRequestError; }
1070
1080
  });
1071
1081
  Object.defineProperty(exports, "ClawOpsError", {
1072
1082
  enumerable: true,
1073
- get: function () { return chunkSBK45525_cjs.ClawOpsError; }
1083
+ get: function () { return chunkKHEU4DKD_cjs.ClawOpsError; }
1074
1084
  });
1075
1085
  Object.defineProperty(exports, "ConflictError", {
1076
1086
  enumerable: true,
1077
- get: function () { return chunkSBK45525_cjs.ConflictError; }
1087
+ get: function () { return chunkKHEU4DKD_cjs.ConflictError; }
1078
1088
  });
1079
1089
  Object.defineProperty(exports, "InternalServerError", {
1080
1090
  enumerable: true,
1081
- get: function () { return chunkSBK45525_cjs.InternalServerError; }
1091
+ get: function () { return chunkKHEU4DKD_cjs.InternalServerError; }
1082
1092
  });
1083
1093
  Object.defineProperty(exports, "NotFoundError", {
1084
1094
  enumerable: true,
1085
- get: function () { return chunkSBK45525_cjs.NotFoundError; }
1095
+ get: function () { return chunkKHEU4DKD_cjs.NotFoundError; }
1086
1096
  });
1087
1097
  Object.defineProperty(exports, "PermissionDeniedError", {
1088
1098
  enumerable: true,
1089
- get: function () { return chunkSBK45525_cjs.PermissionDeniedError; }
1099
+ get: function () { return chunkKHEU4DKD_cjs.PermissionDeniedError; }
1090
1100
  });
1091
1101
  Object.defineProperty(exports, "RateLimitError", {
1092
1102
  enumerable: true,
1093
- get: function () { return chunkSBK45525_cjs.RateLimitError; }
1103
+ get: function () { return chunkKHEU4DKD_cjs.RateLimitError; }
1094
1104
  });
1095
1105
  Object.defineProperty(exports, "ServiceUnavailableError", {
1096
1106
  enumerable: true,
1097
- get: function () { return chunkSBK45525_cjs.ServiceUnavailableError; }
1107
+ get: function () { return chunkKHEU4DKD_cjs.ServiceUnavailableError; }
1098
1108
  });
1099
1109
  Object.defineProperty(exports, "UnprocessableEntityError", {
1100
1110
  enumerable: true,
1101
- get: function () { return chunkSBK45525_cjs.UnprocessableEntityError; }
1111
+ get: function () { return chunkKHEU4DKD_cjs.UnprocessableEntityError; }
1102
1112
  });
1103
1113
  Object.defineProperty(exports, "VERSION", {
1104
1114
  enumerable: true,
1105
- get: function () { return chunkSBK45525_cjs.VERSION; }
1115
+ get: function () { return chunkKHEU4DKD_cjs.VERSION; }
1106
1116
  });
1107
1117
  exports.APIClient = APIClient;
1108
1118
  exports.AccountContext = AccountContext;