@super_studio/ecforce-ai-agent-server 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.
@@ -0,0 +1,2 @@
1
+ export * from "./sdk";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,471 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // src/lib/constants.ts
34
+ var API_ENDPOINT = "https://agent.ec-force.com";
35
+
36
+ // src/sdk/__generated__/index.ts
37
+ var ContentType = /* @__PURE__ */ ((ContentType2) => {
38
+ ContentType2["Json"] = "application/json";
39
+ ContentType2["JsonApi"] = "application/vnd.api+json";
40
+ ContentType2["FormData"] = "multipart/form-data";
41
+ ContentType2["UrlEncoded"] = "application/x-www-form-urlencoded";
42
+ ContentType2["Text"] = "text/plain";
43
+ return ContentType2;
44
+ })(ContentType || {});
45
+ var HttpClient = class {
46
+ constructor(apiConfig = {}) {
47
+ this.baseUrl = "/api";
48
+ this.securityData = null;
49
+ this.abortControllers = /* @__PURE__ */ new Map();
50
+ this.customFetch = (...fetchParams) => fetch(...fetchParams);
51
+ this.baseApiParams = {
52
+ credentials: "same-origin",
53
+ headers: {},
54
+ redirect: "follow",
55
+ referrerPolicy: "no-referrer"
56
+ };
57
+ this.setSecurityData = (data) => {
58
+ this.securityData = data;
59
+ };
60
+ this.contentFormatters = {
61
+ ["application/json" /* Json */]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
62
+ ["application/vnd.api+json" /* JsonApi */]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
63
+ ["text/plain" /* Text */]: (input) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
64
+ ["multipart/form-data" /* FormData */]: (input) => {
65
+ if (input instanceof FormData) {
66
+ return input;
67
+ }
68
+ return Object.keys(input || {}).reduce((formData, key) => {
69
+ const property = input[key];
70
+ formData.append(
71
+ key,
72
+ property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON.stringify(property) : `${property}`
73
+ );
74
+ return formData;
75
+ }, new FormData());
76
+ },
77
+ ["application/x-www-form-urlencoded" /* UrlEncoded */]: (input) => this.toQueryString(input)
78
+ };
79
+ this.createAbortSignal = (cancelToken) => {
80
+ if (this.abortControllers.has(cancelToken)) {
81
+ const abortController2 = this.abortControllers.get(cancelToken);
82
+ if (abortController2) {
83
+ return abortController2.signal;
84
+ }
85
+ return void 0;
86
+ }
87
+ const abortController = new AbortController();
88
+ this.abortControllers.set(cancelToken, abortController);
89
+ return abortController.signal;
90
+ };
91
+ this.abortRequest = (cancelToken) => {
92
+ const abortController = this.abortControllers.get(cancelToken);
93
+ if (abortController) {
94
+ abortController.abort();
95
+ this.abortControllers.delete(cancelToken);
96
+ }
97
+ };
98
+ this.request = async (_a) => {
99
+ var _b = _a, {
100
+ body,
101
+ secure,
102
+ path,
103
+ type,
104
+ query,
105
+ format,
106
+ baseUrl,
107
+ cancelToken
108
+ } = _b, params = __objRest(_b, [
109
+ "body",
110
+ "secure",
111
+ "path",
112
+ "type",
113
+ "query",
114
+ "format",
115
+ "baseUrl",
116
+ "cancelToken"
117
+ ]);
118
+ const secureParams = (typeof secure === "boolean" ? secure : this.baseApiParams.secure) && this.securityWorker && await this.securityWorker(this.securityData) || {};
119
+ const requestParams = this.mergeRequestParams(params, secureParams);
120
+ const queryString = query && this.toQueryString(query);
121
+ const payloadFormatter = this.contentFormatters[type || "application/json" /* Json */];
122
+ const responseFormat = format || requestParams.format;
123
+ return this.customFetch(
124
+ `${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`,
125
+ __spreadProps(__spreadValues({}, requestParams), {
126
+ headers: __spreadValues(__spreadValues({}, requestParams.headers || {}), type && type !== "multipart/form-data" /* FormData */ ? { "Content-Type": type } : {}),
127
+ signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null,
128
+ body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
129
+ })
130
+ ).then(async (response) => {
131
+ const r = response;
132
+ r.data = null;
133
+ r.error = null;
134
+ const data = !responseFormat ? r : await response[responseFormat]().then((data2) => {
135
+ if (r.ok) {
136
+ r.data = data2;
137
+ } else {
138
+ r.error = data2;
139
+ }
140
+ return r;
141
+ }).catch((e) => {
142
+ r.error = e;
143
+ return r;
144
+ });
145
+ if (cancelToken) {
146
+ this.abortControllers.delete(cancelToken);
147
+ }
148
+ if (!response.ok) throw data;
149
+ return data.data;
150
+ });
151
+ };
152
+ Object.assign(this, apiConfig);
153
+ }
154
+ encodeQueryParam(key, value) {
155
+ const encodedKey = encodeURIComponent(key);
156
+ return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
157
+ }
158
+ addQueryParam(query, key) {
159
+ return this.encodeQueryParam(key, query[key]);
160
+ }
161
+ addArrayQueryParam(query, key) {
162
+ const value = query[key];
163
+ return value.map((v) => this.encodeQueryParam(key, v)).join("&");
164
+ }
165
+ toQueryString(rawQuery) {
166
+ const query = rawQuery || {};
167
+ const keys = Object.keys(query).filter(
168
+ (key) => "undefined" !== typeof query[key]
169
+ );
170
+ return keys.map(
171
+ (key) => Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)
172
+ ).join("&");
173
+ }
174
+ addQueryParams(rawQuery) {
175
+ const queryString = this.toQueryString(rawQuery);
176
+ return queryString ? `?${queryString}` : "";
177
+ }
178
+ mergeRequestParams(params1, params2) {
179
+ return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, this.baseApiParams), params1), params2 || {}), {
180
+ headers: __spreadValues(__spreadValues(__spreadValues({}, this.baseApiParams.headers || {}), params1.headers || {}), params2 && params2.headers || {})
181
+ });
182
+ }
183
+ };
184
+ var Api = class extends HttpClient {
185
+ constructor() {
186
+ super(...arguments);
187
+ this.version = {
188
+ /**
189
+ * @description バージョンを取得する
190
+ *
191
+ * @tags meta
192
+ * @name GetVersion
193
+ * @summary getVersion
194
+ * @request GET:/v1/version
195
+ * @secure
196
+ */
197
+ getVersion: (params = {}) => this.request(__spreadValues({
198
+ path: `/v1/version`,
199
+ method: "GET",
200
+ secure: true,
201
+ format: "json"
202
+ }, params))
203
+ };
204
+ this.agent = {
205
+ /**
206
+ * @description エージェント一覧を取得する
207
+ *
208
+ * @tags agent
209
+ * @name List
210
+ * @summary list
211
+ * @request GET:/v1/agent
212
+ * @secure
213
+ */
214
+ list: (params = {}) => this.request(__spreadValues({
215
+ path: `/v1/agent`,
216
+ method: "GET",
217
+ secure: true,
218
+ format: "json"
219
+ }, params)),
220
+ /**
221
+ * @description エージェントを作成する
222
+ *
223
+ * @tags agent
224
+ * @name Create
225
+ * @summary create
226
+ * @request POST:/v1/agent
227
+ * @secure
228
+ */
229
+ create: (data, params = {}) => this.request(__spreadValues({
230
+ path: `/v1/agent`,
231
+ method: "POST",
232
+ body: data,
233
+ secure: true,
234
+ type: "application/json" /* Json */,
235
+ format: "json"
236
+ }, params)),
237
+ /**
238
+ * @description エージェント詳細を取得する
239
+ *
240
+ * @tags agent
241
+ * @name Get
242
+ * @summary get
243
+ * @request GET:/v1/agent/{id}
244
+ * @secure
245
+ */
246
+ get: (id, params = {}) => this.request(__spreadValues({
247
+ path: `/v1/agent/${id}`,
248
+ method: "GET",
249
+ secure: true,
250
+ format: "json"
251
+ }, params)),
252
+ /**
253
+ * @description エージェントを更新する
254
+ *
255
+ * @tags agent
256
+ * @name Update
257
+ * @summary update
258
+ * @request PUT:/v1/agent/{id}
259
+ * @secure
260
+ */
261
+ update: (id, data, params = {}) => this.request(__spreadValues({
262
+ path: `/v1/agent/${id}`,
263
+ method: "PUT",
264
+ body: data,
265
+ secure: true,
266
+ type: "application/json" /* Json */,
267
+ format: "json"
268
+ }, params)),
269
+ /**
270
+ * @description エージェントを削除する
271
+ *
272
+ * @tags agent
273
+ * @name Delete
274
+ * @summary delete
275
+ * @request DELETE:/v1/agent/{id}
276
+ * @secure
277
+ */
278
+ delete: (id, data, params = {}) => this.request(__spreadValues({
279
+ path: `/v1/agent/${id}`,
280
+ method: "DELETE",
281
+ body: data,
282
+ secure: true,
283
+ type: "application/json" /* Json */,
284
+ format: "json"
285
+ }, params)),
286
+ /**
287
+ * @description エージェントのUI機能設定を取得する(公開)
288
+ *
289
+ * @tags agent
290
+ * @name GetInterfaceFeatures
291
+ * @summary getInterfaceFeatures
292
+ * @request GET:/v1/agent/{id}/interface-features
293
+ * @secure
294
+ */
295
+ getInterfaceFeatures: (id, params = {}) => this.request(__spreadValues({
296
+ path: `/v1/agent/${id}/interface-features`,
297
+ method: "GET",
298
+ secure: true,
299
+ format: "json"
300
+ }, params)),
301
+ /**
302
+ * @description エージェントのツール設定を取得する(公開)
303
+ *
304
+ * @tags agent
305
+ * @name GetToolSettings
306
+ * @summary getToolSettings
307
+ * @request POST:/v1/agent/tool-settings
308
+ * @secure
309
+ */
310
+ getToolSettings: (data, params = {}) => this.request(__spreadValues({
311
+ path: `/v1/agent/tool-settings`,
312
+ method: "POST",
313
+ body: data,
314
+ secure: true,
315
+ type: "application/json" /* Json */,
316
+ format: "json"
317
+ }, params))
318
+ };
319
+ this.org = {
320
+ /**
321
+ * @description 所属する組織一覧を取得する
322
+ *
323
+ * @tags org
324
+ * @name List
325
+ * @summary list
326
+ * @request GET:/v1/org
327
+ * @secure
328
+ */
329
+ list: (params = {}) => this.request(__spreadValues({
330
+ path: `/v1/org`,
331
+ method: "GET",
332
+ secure: true,
333
+ format: "json"
334
+ }, params)),
335
+ /**
336
+ * @description 組織詳細を取得する
337
+ *
338
+ * @tags org
339
+ * @name Get
340
+ * @summary get
341
+ * @request GET:/v1/org/{slug}
342
+ * @secure
343
+ */
344
+ get: (slug, params = {}) => this.request(__spreadValues({
345
+ path: `/v1/org/${slug}`,
346
+ method: "GET",
347
+ secure: true,
348
+ format: "json"
349
+ }, params))
350
+ };
351
+ this.apiKeys = {
352
+ /**
353
+ * @description APIキー一覧を取得する
354
+ *
355
+ * @tags apiKey
356
+ * @name List
357
+ * @summary list
358
+ * @request GET:/v1/api-keys/{type}
359
+ * @secure
360
+ */
361
+ list: (type, params = {}) => this.request(__spreadValues({
362
+ path: `/v1/api-keys/${type}`,
363
+ method: "GET",
364
+ secure: true,
365
+ format: "json"
366
+ }, params)),
367
+ /**
368
+ * @description APIキーを作成する
369
+ *
370
+ * @tags apiKey
371
+ * @name Create
372
+ * @summary create
373
+ * @request POST:/v1/api-keys
374
+ * @secure
375
+ */
376
+ create: (data, params = {}) => this.request(__spreadValues({
377
+ path: `/v1/api-keys`,
378
+ method: "POST",
379
+ body: data,
380
+ secure: true,
381
+ type: "application/json" /* Json */,
382
+ format: "json"
383
+ }, params)),
384
+ /**
385
+ * @description APIキーを更新する
386
+ *
387
+ * @tags apiKey
388
+ * @name Update
389
+ * @summary update
390
+ * @request PATCH:/v1/api-keys/{id}
391
+ * @secure
392
+ */
393
+ update: (id, data, params = {}) => this.request(__spreadValues({
394
+ path: `/v1/api-keys/${id}`,
395
+ method: "PATCH",
396
+ body: data,
397
+ secure: true,
398
+ type: "application/json" /* Json */,
399
+ format: "json"
400
+ }, params)),
401
+ /**
402
+ * @description APIキーを削除する
403
+ *
404
+ * @tags apiKey
405
+ * @name Delete
406
+ * @summary delete
407
+ * @request DELETE:/v1/api-keys/{id}
408
+ * @secure
409
+ */
410
+ delete: (id, data, params = {}) => this.request(__spreadValues({
411
+ path: `/v1/api-keys/${id}`,
412
+ method: "DELETE",
413
+ body: data,
414
+ secure: true,
415
+ type: "application/json" /* Json */,
416
+ format: "json"
417
+ }, params))
418
+ };
419
+ this.chat = {
420
+ /**
421
+ * @description 新しいチャットセッションを開始してトークンを返す
422
+ *
423
+ * @tags chat
424
+ * @name StartSession
425
+ * @summary startSession
426
+ * @request POST:/v1/chat/start-session
427
+ * @secure
428
+ */
429
+ startSession: (data, params = {}) => this.request(__spreadValues({
430
+ path: `/v1/chat/start-session`,
431
+ method: "POST",
432
+ body: data,
433
+ secure: true,
434
+ type: "application/json" /* Json */,
435
+ format: "json"
436
+ }, params))
437
+ };
438
+ }
439
+ };
440
+
441
+ // src/sdk/index.ts
442
+ function createClient(params) {
443
+ var _a, _b, _c;
444
+ const baseUrl = (_b = (_a = params == null ? void 0 : params.baseUrl) != null ? _a : process.env.AI_AGENT_API_ENDPOINT) != null ? _b : API_ENDPOINT;
445
+ const apiKey = (_c = params == null ? void 0 : params.apiKey) != null ? _c : process.env.AI_AGENT_API_KEY;
446
+ if (!apiKey) {
447
+ throw new Error("API\u30AD\u30FC\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002");
448
+ }
449
+ if (!baseUrl) {
450
+ throw new Error("API\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002");
451
+ }
452
+ return new Api({
453
+ baseUrl,
454
+ baseApiParams: {
455
+ secure: true
456
+ },
457
+ async securityWorker() {
458
+ return {
459
+ headers: {
460
+ Authorization: `Bearer ${apiKey}`
461
+ }
462
+ };
463
+ }
464
+ });
465
+ }
466
+
467
+
468
+
469
+
470
+
471
+ exports.Api = Api; exports.ContentType = ContentType; exports.HttpClient = HttpClient; exports.createClient = createClient;