@super_studio/ecforce-ai-agent-server 0.2.0-canary.4 → 1.0.0-canary.7
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/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectWithoutProperties.cjs +15 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectWithoutProperties.mjs +15 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectWithoutPropertiesLoose.cjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectWithoutPropertiesLoose.mjs +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs +18 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -531
- package/dist/lib/constants.cjs +6 -0
- package/dist/lib/constants.mjs +6 -0
- package/dist/lib/constants.mjs.map +1 -0
- package/dist/lib/jwt.cjs +64 -0
- package/dist/lib/jwt.mjs +64 -0
- package/dist/lib/jwt.mjs.map +1 -0
- package/dist/mcp-auth.cjs +52 -0
- package/dist/mcp-auth.d.cts +38 -0
- package/dist/mcp-auth.d.cts.map +1 -0
- package/dist/mcp-auth.d.mts +38 -0
- package/dist/mcp-auth.d.mts.map +1 -0
- package/dist/mcp-auth.mjs +44 -129
- package/dist/mcp-auth.mjs.map +1 -0
- package/dist/sdk/__generated__/index.cjs +524 -0
- package/dist/sdk/__generated__/index.d.cts +1648 -0
- package/dist/sdk/__generated__/index.d.cts.map +1 -0
- package/dist/sdk/__generated__/index.d.mts +1648 -0
- package/dist/sdk/__generated__/index.d.mts.map +1 -0
- package/dist/sdk/__generated__/index.mjs +523 -0
- package/dist/sdk/__generated__/index.mjs.map +1 -0
- package/dist/sdk/index.cjs +21 -0
- package/dist/sdk/index.d.cts +22 -0
- package/dist/sdk/index.d.cts.map +1 -0
- package/dist/sdk/index.d.mts +22 -0
- package/dist/sdk/index.d.mts.map +1 -0
- package/dist/sdk/index.mjs +22 -0
- package/dist/sdk/index.mjs.map +1 -0
- package/package.json +14 -20
- package/src/sdk/__generated__/index.ts +2194 -532
- package/src/sdk/generate.ts +21 -1
- package/dist/chunk-FWCSY2DS.mjs +0 -37
- package/dist/chunk-ORMEWXMH.js +0 -37
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -532
- package/dist/lib/constants.d.ts +0 -2
- package/dist/lib/constants.d.ts.map +0 -1
- package/dist/lib/jwt.d.ts +0 -37
- package/dist/lib/jwt.d.ts.map +0 -1
- package/dist/mcp-auth.d.ts +0 -35
- package/dist/mcp-auth.d.ts.map +0 -1
- package/dist/mcp-auth.js +0 -136
- package/dist/sdk/__generated__/index.d.ts +0 -637
- package/dist/sdk/__generated__/index.d.ts.map +0 -1
- package/dist/sdk/generate.d.ts +0 -2
- package/dist/sdk/generate.d.ts.map +0 -1
- package/dist/sdk/index.d.ts +0 -19
- package/dist/sdk/index.d.ts.map +0 -1
- package/src/.tmp/test-script.ts +0 -18
package/dist/index.mjs
CHANGED
|
@@ -1,532 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
__spreadProps,
|
|
4
|
-
__spreadValues
|
|
5
|
-
} from "./chunk-FWCSY2DS.mjs";
|
|
1
|
+
import { Api, ContentType, HttpClient } from "./sdk/__generated__/index.mjs";
|
|
2
|
+
import { createClient } from "./sdk/index.mjs";
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
var API_ENDPOINT = "http://localhost:4043";
|
|
9
|
-
|
|
10
|
-
// src/sdk/__generated__/index.ts
|
|
11
|
-
var ContentType = /* @__PURE__ */ ((ContentType2) => {
|
|
12
|
-
ContentType2["Json"] = "application/json";
|
|
13
|
-
ContentType2["JsonApi"] = "application/vnd.api+json";
|
|
14
|
-
ContentType2["FormData"] = "multipart/form-data";
|
|
15
|
-
ContentType2["UrlEncoded"] = "application/x-www-form-urlencoded";
|
|
16
|
-
ContentType2["Text"] = "text/plain";
|
|
17
|
-
return ContentType2;
|
|
18
|
-
})(ContentType || {});
|
|
19
|
-
var HttpClient = class {
|
|
20
|
-
constructor(apiConfig = {}) {
|
|
21
|
-
this.baseUrl = "/api";
|
|
22
|
-
this.securityData = null;
|
|
23
|
-
this.abortControllers = /* @__PURE__ */ new Map();
|
|
24
|
-
this.customFetch = (...fetchParams) => fetch(...fetchParams);
|
|
25
|
-
this.baseApiParams = {
|
|
26
|
-
credentials: "same-origin",
|
|
27
|
-
headers: {},
|
|
28
|
-
redirect: "follow",
|
|
29
|
-
referrerPolicy: "no-referrer"
|
|
30
|
-
};
|
|
31
|
-
this.setSecurityData = (data) => {
|
|
32
|
-
this.securityData = data;
|
|
33
|
-
};
|
|
34
|
-
this.contentFormatters = {
|
|
35
|
-
["application/json" /* Json */]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
|
|
36
|
-
["application/vnd.api+json" /* JsonApi */]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
|
|
37
|
-
["text/plain" /* Text */]: (input) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
|
|
38
|
-
["multipart/form-data" /* FormData */]: (input) => {
|
|
39
|
-
if (input instanceof FormData) {
|
|
40
|
-
return input;
|
|
41
|
-
}
|
|
42
|
-
return Object.keys(input || {}).reduce((formData, key) => {
|
|
43
|
-
const property = input[key];
|
|
44
|
-
formData.append(
|
|
45
|
-
key,
|
|
46
|
-
property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON.stringify(property) : `${property}`
|
|
47
|
-
);
|
|
48
|
-
return formData;
|
|
49
|
-
}, new FormData());
|
|
50
|
-
},
|
|
51
|
-
["application/x-www-form-urlencoded" /* UrlEncoded */]: (input) => this.toQueryString(input)
|
|
52
|
-
};
|
|
53
|
-
this.createAbortSignal = (cancelToken) => {
|
|
54
|
-
if (this.abortControllers.has(cancelToken)) {
|
|
55
|
-
const abortController2 = this.abortControllers.get(cancelToken);
|
|
56
|
-
if (abortController2) {
|
|
57
|
-
return abortController2.signal;
|
|
58
|
-
}
|
|
59
|
-
return void 0;
|
|
60
|
-
}
|
|
61
|
-
const abortController = new AbortController();
|
|
62
|
-
this.abortControllers.set(cancelToken, abortController);
|
|
63
|
-
return abortController.signal;
|
|
64
|
-
};
|
|
65
|
-
this.abortRequest = (cancelToken) => {
|
|
66
|
-
const abortController = this.abortControllers.get(cancelToken);
|
|
67
|
-
if (abortController) {
|
|
68
|
-
abortController.abort();
|
|
69
|
-
this.abortControllers.delete(cancelToken);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
this.request = async (_a) => {
|
|
73
|
-
var _b = _a, {
|
|
74
|
-
body,
|
|
75
|
-
secure,
|
|
76
|
-
path,
|
|
77
|
-
type,
|
|
78
|
-
query,
|
|
79
|
-
format,
|
|
80
|
-
baseUrl,
|
|
81
|
-
cancelToken
|
|
82
|
-
} = _b, params = __objRest(_b, [
|
|
83
|
-
"body",
|
|
84
|
-
"secure",
|
|
85
|
-
"path",
|
|
86
|
-
"type",
|
|
87
|
-
"query",
|
|
88
|
-
"format",
|
|
89
|
-
"baseUrl",
|
|
90
|
-
"cancelToken"
|
|
91
|
-
]);
|
|
92
|
-
const secureParams = (typeof secure === "boolean" ? secure : this.baseApiParams.secure) && this.securityWorker && await this.securityWorker(this.securityData) || {};
|
|
93
|
-
const requestParams = this.mergeRequestParams(params, secureParams);
|
|
94
|
-
const queryString = query && this.toQueryString(query);
|
|
95
|
-
const payloadFormatter = this.contentFormatters[type || "application/json" /* Json */];
|
|
96
|
-
const responseFormat = format || requestParams.format;
|
|
97
|
-
return this.customFetch(
|
|
98
|
-
`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`,
|
|
99
|
-
__spreadProps(__spreadValues({}, requestParams), {
|
|
100
|
-
headers: __spreadValues(__spreadValues({}, requestParams.headers || {}), type && type !== "multipart/form-data" /* FormData */ ? { "Content-Type": type } : {}),
|
|
101
|
-
signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null,
|
|
102
|
-
body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
|
|
103
|
-
})
|
|
104
|
-
).then(async (response) => {
|
|
105
|
-
const r = response;
|
|
106
|
-
r.data = null;
|
|
107
|
-
r.error = null;
|
|
108
|
-
const data = !responseFormat ? r : await response[responseFormat]().then((data2) => {
|
|
109
|
-
if (r.ok) {
|
|
110
|
-
r.data = data2;
|
|
111
|
-
} else {
|
|
112
|
-
r.error = data2;
|
|
113
|
-
}
|
|
114
|
-
return r;
|
|
115
|
-
}).catch((e) => {
|
|
116
|
-
r.error = e;
|
|
117
|
-
return r;
|
|
118
|
-
});
|
|
119
|
-
if (cancelToken) {
|
|
120
|
-
this.abortControllers.delete(cancelToken);
|
|
121
|
-
}
|
|
122
|
-
if (!response.ok) throw data;
|
|
123
|
-
return data.data;
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
Object.assign(this, apiConfig);
|
|
127
|
-
}
|
|
128
|
-
encodeQueryParam(key, value) {
|
|
129
|
-
const encodedKey = encodeURIComponent(key);
|
|
130
|
-
return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
|
|
131
|
-
}
|
|
132
|
-
addQueryParam(query, key) {
|
|
133
|
-
return this.encodeQueryParam(key, query[key]);
|
|
134
|
-
}
|
|
135
|
-
addArrayQueryParam(query, key) {
|
|
136
|
-
const value = query[key];
|
|
137
|
-
return value.map((v) => this.encodeQueryParam(key, v)).join("&");
|
|
138
|
-
}
|
|
139
|
-
toQueryString(rawQuery) {
|
|
140
|
-
const query = rawQuery || {};
|
|
141
|
-
const keys = Object.keys(query).filter(
|
|
142
|
-
(key) => "undefined" !== typeof query[key]
|
|
143
|
-
);
|
|
144
|
-
return keys.map(
|
|
145
|
-
(key) => Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)
|
|
146
|
-
).join("&");
|
|
147
|
-
}
|
|
148
|
-
addQueryParams(rawQuery) {
|
|
149
|
-
const queryString = this.toQueryString(rawQuery);
|
|
150
|
-
return queryString ? `?${queryString}` : "";
|
|
151
|
-
}
|
|
152
|
-
mergeRequestParams(params1, params2) {
|
|
153
|
-
return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, this.baseApiParams), params1), params2 || {}), {
|
|
154
|
-
headers: __spreadValues(__spreadValues(__spreadValues({}, this.baseApiParams.headers || {}), params1.headers || {}), params2 && params2.headers || {})
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
var Api = class extends HttpClient {
|
|
159
|
-
constructor() {
|
|
160
|
-
super(...arguments);
|
|
161
|
-
this.version = {
|
|
162
|
-
/**
|
|
163
|
-
* @description バージョンを取得する
|
|
164
|
-
*
|
|
165
|
-
* @tags meta
|
|
166
|
-
* @name GetVersion
|
|
167
|
-
* @summary getVersion
|
|
168
|
-
* @request GET:/v1/version
|
|
169
|
-
* @secure
|
|
170
|
-
*/
|
|
171
|
-
getVersion: (params = {}) => this.request(__spreadValues({
|
|
172
|
-
path: `/v1/version`,
|
|
173
|
-
method: "GET",
|
|
174
|
-
secure: true,
|
|
175
|
-
format: "json"
|
|
176
|
-
}, params))
|
|
177
|
-
};
|
|
178
|
-
this.internal = {
|
|
179
|
-
/**
|
|
180
|
-
* @description ユーザーのセッションを作成してトークンを返す
|
|
181
|
-
*
|
|
182
|
-
* @tags internal
|
|
183
|
-
* @name CreateSession
|
|
184
|
-
* @summary createSession
|
|
185
|
-
* @request POST:/v1/internal/create-session
|
|
186
|
-
* @secure
|
|
187
|
-
*/
|
|
188
|
-
createSession: (data, params = {}) => this.request(__spreadValues({
|
|
189
|
-
path: `/v1/internal/create-session`,
|
|
190
|
-
method: "POST",
|
|
191
|
-
body: data,
|
|
192
|
-
secure: true,
|
|
193
|
-
type: "application/json" /* Json */,
|
|
194
|
-
format: "json"
|
|
195
|
-
}, params))
|
|
196
|
-
};
|
|
197
|
-
this.agent = {
|
|
198
|
-
/**
|
|
199
|
-
* @description エージェント一覧を取得する
|
|
200
|
-
*
|
|
201
|
-
* @tags agent
|
|
202
|
-
* @name List
|
|
203
|
-
* @summary list
|
|
204
|
-
* @request GET:/v1/agent
|
|
205
|
-
* @secure
|
|
206
|
-
*/
|
|
207
|
-
list: (params = {}) => this.request(__spreadValues({
|
|
208
|
-
path: `/v1/agent`,
|
|
209
|
-
method: "GET",
|
|
210
|
-
secure: true,
|
|
211
|
-
format: "json"
|
|
212
|
-
}, params)),
|
|
213
|
-
/**
|
|
214
|
-
* @description エージェントを作成する
|
|
215
|
-
*
|
|
216
|
-
* @tags agent
|
|
217
|
-
* @name Create
|
|
218
|
-
* @summary create
|
|
219
|
-
* @request POST:/v1/agent
|
|
220
|
-
* @secure
|
|
221
|
-
*/
|
|
222
|
-
create: (data, params = {}) => this.request(__spreadValues({
|
|
223
|
-
path: `/v1/agent`,
|
|
224
|
-
method: "POST",
|
|
225
|
-
body: data,
|
|
226
|
-
secure: true,
|
|
227
|
-
type: "application/json" /* Json */,
|
|
228
|
-
format: "json"
|
|
229
|
-
}, params)),
|
|
230
|
-
/**
|
|
231
|
-
* @description エージェント詳細を取得する
|
|
232
|
-
*
|
|
233
|
-
* @tags agent
|
|
234
|
-
* @name Get
|
|
235
|
-
* @summary get
|
|
236
|
-
* @request GET:/v1/agent/{id}
|
|
237
|
-
* @secure
|
|
238
|
-
*/
|
|
239
|
-
get: (id, params = {}) => this.request(__spreadValues({
|
|
240
|
-
path: `/v1/agent/${id}`,
|
|
241
|
-
method: "GET",
|
|
242
|
-
secure: true,
|
|
243
|
-
format: "json"
|
|
244
|
-
}, params)),
|
|
245
|
-
/**
|
|
246
|
-
* @description エージェントを更新する
|
|
247
|
-
*
|
|
248
|
-
* @tags agent
|
|
249
|
-
* @name Update
|
|
250
|
-
* @summary update
|
|
251
|
-
* @request PUT:/v1/agent/{id}
|
|
252
|
-
* @secure
|
|
253
|
-
*/
|
|
254
|
-
update: (id, data, params = {}) => this.request(__spreadValues({
|
|
255
|
-
path: `/v1/agent/${id}`,
|
|
256
|
-
method: "PUT",
|
|
257
|
-
body: data,
|
|
258
|
-
secure: true,
|
|
259
|
-
type: "application/json" /* Json */,
|
|
260
|
-
format: "json"
|
|
261
|
-
}, params)),
|
|
262
|
-
/**
|
|
263
|
-
* @description エージェントを削除する
|
|
264
|
-
*
|
|
265
|
-
* @tags agent
|
|
266
|
-
* @name Delete
|
|
267
|
-
* @summary delete
|
|
268
|
-
* @request DELETE:/v1/agent/{id}
|
|
269
|
-
* @secure
|
|
270
|
-
*/
|
|
271
|
-
delete: (id, data, params = {}) => this.request(__spreadValues({
|
|
272
|
-
path: `/v1/agent/${id}`,
|
|
273
|
-
method: "DELETE",
|
|
274
|
-
body: data,
|
|
275
|
-
secure: true,
|
|
276
|
-
type: "application/json" /* Json */,
|
|
277
|
-
format: "json"
|
|
278
|
-
}, params)),
|
|
279
|
-
/**
|
|
280
|
-
* @description エージェントのUI機能設定を取得する(公開)
|
|
281
|
-
*
|
|
282
|
-
* @tags agent
|
|
283
|
-
* @name GetInterfaceFeatures
|
|
284
|
-
* @summary getInterfaceFeatures
|
|
285
|
-
* @request GET:/v1/agent/{id}/interface-features
|
|
286
|
-
* @secure
|
|
287
|
-
*/
|
|
288
|
-
getInterfaceFeatures: (id, params = {}) => this.request(__spreadValues({
|
|
289
|
-
path: `/v1/agent/${id}/interface-features`,
|
|
290
|
-
method: "GET",
|
|
291
|
-
secure: true,
|
|
292
|
-
format: "json"
|
|
293
|
-
}, params)),
|
|
294
|
-
/**
|
|
295
|
-
* @description エージェントのツール設定を取得する(公開)
|
|
296
|
-
*
|
|
297
|
-
* @tags agent
|
|
298
|
-
* @name GetToolSettings
|
|
299
|
-
* @summary getToolSettings
|
|
300
|
-
* @request POST:/v1/agent/tool-settings
|
|
301
|
-
* @secure
|
|
302
|
-
*/
|
|
303
|
-
getToolSettings: (data, params = {}) => this.request(__spreadValues({
|
|
304
|
-
path: `/v1/agent/tool-settings`,
|
|
305
|
-
method: "POST",
|
|
306
|
-
body: data,
|
|
307
|
-
secure: true,
|
|
308
|
-
type: "application/json" /* Json */,
|
|
309
|
-
format: "json"
|
|
310
|
-
}, params))
|
|
311
|
-
};
|
|
312
|
-
this.account = {
|
|
313
|
-
/**
|
|
314
|
-
* @description 所属するアカウント一覧を取得する
|
|
315
|
-
*
|
|
316
|
-
* @tags account
|
|
317
|
-
* @name List
|
|
318
|
-
* @summary list
|
|
319
|
-
* @request GET:/v1/account
|
|
320
|
-
* @secure
|
|
321
|
-
*/
|
|
322
|
-
list: (params = {}) => this.request(__spreadValues({
|
|
323
|
-
path: `/v1/account`,
|
|
324
|
-
method: "GET",
|
|
325
|
-
secure: true,
|
|
326
|
-
format: "json"
|
|
327
|
-
}, params)),
|
|
328
|
-
/**
|
|
329
|
-
* @description アカウント詳細を取得する
|
|
330
|
-
*
|
|
331
|
-
* @tags account
|
|
332
|
-
* @name Get
|
|
333
|
-
* @summary get
|
|
334
|
-
* @request GET:/v1/account/{projectId}
|
|
335
|
-
* @secure
|
|
336
|
-
*/
|
|
337
|
-
get: (projectId, params = {}) => this.request(__spreadValues({
|
|
338
|
-
path: `/v1/account/${projectId}`,
|
|
339
|
-
method: "GET",
|
|
340
|
-
secure: true,
|
|
341
|
-
format: "json"
|
|
342
|
-
}, params))
|
|
343
|
-
};
|
|
344
|
-
this.apiKeys = {
|
|
345
|
-
/**
|
|
346
|
-
* @description APIキー一覧を取得する
|
|
347
|
-
*
|
|
348
|
-
* @tags apiKey
|
|
349
|
-
* @name List
|
|
350
|
-
* @summary list
|
|
351
|
-
* @request GET:/v1/api-keys/{type}
|
|
352
|
-
* @secure
|
|
353
|
-
*/
|
|
354
|
-
list: (type, params = {}) => this.request(__spreadValues({
|
|
355
|
-
path: `/v1/api-keys/${type}`,
|
|
356
|
-
method: "GET",
|
|
357
|
-
secure: true,
|
|
358
|
-
format: "json"
|
|
359
|
-
}, params)),
|
|
360
|
-
/**
|
|
361
|
-
* @description APIキーを作成する
|
|
362
|
-
*
|
|
363
|
-
* @tags apiKey
|
|
364
|
-
* @name Create
|
|
365
|
-
* @summary create
|
|
366
|
-
* @request POST:/v1/api-keys
|
|
367
|
-
* @secure
|
|
368
|
-
*/
|
|
369
|
-
create: (data, params = {}) => this.request(__spreadValues({
|
|
370
|
-
path: `/v1/api-keys`,
|
|
371
|
-
method: "POST",
|
|
372
|
-
body: data,
|
|
373
|
-
secure: true,
|
|
374
|
-
type: "application/json" /* Json */,
|
|
375
|
-
format: "json"
|
|
376
|
-
}, params)),
|
|
377
|
-
/**
|
|
378
|
-
* @description APIキーを更新する
|
|
379
|
-
*
|
|
380
|
-
* @tags apiKey
|
|
381
|
-
* @name Update
|
|
382
|
-
* @summary update
|
|
383
|
-
* @request PATCH:/v1/api-keys/{id}
|
|
384
|
-
* @secure
|
|
385
|
-
*/
|
|
386
|
-
update: (id, data, params = {}) => this.request(__spreadValues({
|
|
387
|
-
path: `/v1/api-keys/${id}`,
|
|
388
|
-
method: "PATCH",
|
|
389
|
-
body: data,
|
|
390
|
-
secure: true,
|
|
391
|
-
type: "application/json" /* Json */,
|
|
392
|
-
format: "json"
|
|
393
|
-
}, params)),
|
|
394
|
-
/**
|
|
395
|
-
* @description APIキーを削除する
|
|
396
|
-
*
|
|
397
|
-
* @tags apiKey
|
|
398
|
-
* @name Delete
|
|
399
|
-
* @summary delete
|
|
400
|
-
* @request DELETE:/v1/api-keys/{id}
|
|
401
|
-
* @secure
|
|
402
|
-
*/
|
|
403
|
-
delete: (id, data, params = {}) => this.request(__spreadValues({
|
|
404
|
-
path: `/v1/api-keys/${id}`,
|
|
405
|
-
method: "DELETE",
|
|
406
|
-
body: data,
|
|
407
|
-
secure: true,
|
|
408
|
-
type: "application/json" /* Json */,
|
|
409
|
-
format: "json"
|
|
410
|
-
}, params))
|
|
411
|
-
};
|
|
412
|
-
this.chat = {
|
|
413
|
-
/**
|
|
414
|
-
* @description ユーザーのチャットメッセージ一覧を返す
|
|
415
|
-
*
|
|
416
|
-
* @tags chat
|
|
417
|
-
* @name ListMessages
|
|
418
|
-
* @summary listMessages
|
|
419
|
-
* @request POST:/v1/chat/list-messages
|
|
420
|
-
* @secure
|
|
421
|
-
*/
|
|
422
|
-
listMessages: (data, params = {}) => this.request(__spreadValues({
|
|
423
|
-
path: `/v1/chat/list-messages`,
|
|
424
|
-
method: "POST",
|
|
425
|
-
body: data,
|
|
426
|
-
secure: true,
|
|
427
|
-
type: "application/json" /* Json */,
|
|
428
|
-
format: "json"
|
|
429
|
-
}, params)),
|
|
430
|
-
/**
|
|
431
|
-
* @description ユーザーのチャット一覧を返す
|
|
432
|
-
*
|
|
433
|
-
* @tags chat
|
|
434
|
-
* @name MyList
|
|
435
|
-
* @summary myList
|
|
436
|
-
* @request POST:/v1/chat/my-list
|
|
437
|
-
* @secure
|
|
438
|
-
*/
|
|
439
|
-
myList: (data, params = {}) => this.request(__spreadValues({
|
|
440
|
-
path: `/v1/chat/my-list`,
|
|
441
|
-
method: "POST",
|
|
442
|
-
body: data,
|
|
443
|
-
secure: true,
|
|
444
|
-
type: "application/json" /* Json */,
|
|
445
|
-
format: "json"
|
|
446
|
-
}, params)),
|
|
447
|
-
/**
|
|
448
|
-
* @description ユーザーのチャットのタイトルを返す
|
|
449
|
-
*
|
|
450
|
-
* @tags chat
|
|
451
|
-
* @name GetTitle
|
|
452
|
-
* @summary getTitle
|
|
453
|
-
* @request POST:/v1/chat/get-title
|
|
454
|
-
* @secure
|
|
455
|
-
*/
|
|
456
|
-
getTitle: (data, params = {}) => this.request(__spreadValues({
|
|
457
|
-
path: `/v1/chat/get-title`,
|
|
458
|
-
method: "POST",
|
|
459
|
-
body: data,
|
|
460
|
-
secure: true,
|
|
461
|
-
type: "application/json" /* Json */,
|
|
462
|
-
format: "json"
|
|
463
|
-
}, params)),
|
|
464
|
-
/**
|
|
465
|
-
* @description メッセージに対する評価を送信する
|
|
466
|
-
*
|
|
467
|
-
* @tags chat
|
|
468
|
-
* @name SubmitFeedback
|
|
469
|
-
* @summary submitFeedback
|
|
470
|
-
* @request POST:/v1/chat/submit-feedback
|
|
471
|
-
* @secure
|
|
472
|
-
*/
|
|
473
|
-
submitFeedback: (data, params = {}) => this.request(__spreadValues({
|
|
474
|
-
path: `/v1/chat/submit-feedback`,
|
|
475
|
-
method: "POST",
|
|
476
|
-
body: data,
|
|
477
|
-
secure: true,
|
|
478
|
-
type: "application/json" /* Json */,
|
|
479
|
-
format: "json"
|
|
480
|
-
}, params)),
|
|
481
|
-
/**
|
|
482
|
-
* @description メッセージの評価を削除する
|
|
483
|
-
*
|
|
484
|
-
* @tags chat
|
|
485
|
-
* @name DeleteFeedback
|
|
486
|
-
* @summary deleteFeedback
|
|
487
|
-
* @request POST:/v1/chat/delete-feedback
|
|
488
|
-
* @secure
|
|
489
|
-
*/
|
|
490
|
-
deleteFeedback: (data, params = {}) => this.request(__spreadValues({
|
|
491
|
-
path: `/v1/chat/delete-feedback`,
|
|
492
|
-
method: "POST",
|
|
493
|
-
body: data,
|
|
494
|
-
secure: true,
|
|
495
|
-
type: "application/json" /* Json */,
|
|
496
|
-
format: "json"
|
|
497
|
-
}, params))
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
// src/sdk/index.ts
|
|
503
|
-
function createClient(params) {
|
|
504
|
-
var _a, _b, _c;
|
|
505
|
-
const baseUrl = `${(_b = (_a = params == null ? void 0 : params.baseUrl) != null ? _a : process.env.AI_AGENT_API_ENDPOINT) != null ? _b : API_ENDPOINT}/api`;
|
|
506
|
-
const apiKey = (_c = params == null ? void 0 : params.apiKey) != null ? _c : process.env.AI_AGENT_API_KEY;
|
|
507
|
-
if (!apiKey) {
|
|
508
|
-
throw new Error("API\u30AD\u30FC\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002");
|
|
509
|
-
}
|
|
510
|
-
if (!baseUrl) {
|
|
511
|
-
throw new Error("API\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002");
|
|
512
|
-
}
|
|
513
|
-
return new Api({
|
|
514
|
-
baseUrl,
|
|
515
|
-
baseApiParams: {
|
|
516
|
-
secure: true
|
|
517
|
-
},
|
|
518
|
-
async securityWorker() {
|
|
519
|
-
return {
|
|
520
|
-
headers: {
|
|
521
|
-
Authorization: `Bearer ${apiKey}`
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
export {
|
|
528
|
-
Api,
|
|
529
|
-
ContentType,
|
|
530
|
-
HttpClient,
|
|
531
|
-
createClient
|
|
532
|
-
};
|
|
4
|
+
export { Api, ContentType, HttpClient, createClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/lib/constants.ts"],"sourcesContent":["export const API_ENDPOINT = \"http://localhost:4043\";\n"],"mappings":";AAAA,MAAa,eAAe"}
|
package/dist/lib/jwt.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
let _panva_hkdf = require("@panva/hkdf");
|
|
2
|
+
let jose = require("jose");
|
|
3
|
+
|
|
4
|
+
//#region src/lib/jwt.ts
|
|
5
|
+
/**
|
|
6
|
+
* このロジックは最新(@auth/core@0.37.2)のAuth.jsのjwt.tsからコピーされました。
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_MAX_AGE = 720 * 60 * 60;
|
|
9
|
+
const now = () => Date.now() / 1e3 | 0;
|
|
10
|
+
const alg = "dir";
|
|
11
|
+
const enc = "A256CBC-HS512";
|
|
12
|
+
/** Issues a JWT. By default, the JWT is encrypted using "A256CBC-HS512". */
|
|
13
|
+
async function encode(params) {
|
|
14
|
+
const { token = {}, secret, maxAge = DEFAULT_MAX_AGE, salt } = params;
|
|
15
|
+
const encryptionSecret = await getDerivedEncryptionKey(enc, (Array.isArray(secret) ? secret : [secret])[0], salt);
|
|
16
|
+
const thumbprint = await (0, jose.calculateJwkThumbprint)({
|
|
17
|
+
kty: "oct",
|
|
18
|
+
k: jose.base64url.encode(encryptionSecret)
|
|
19
|
+
}, `sha${encryptionSecret.byteLength << 3}`);
|
|
20
|
+
return await new jose.EncryptJWT(token).setProtectedHeader({
|
|
21
|
+
alg,
|
|
22
|
+
enc,
|
|
23
|
+
kid: thumbprint
|
|
24
|
+
}).setIssuedAt().setExpirationTime(now() + maxAge).setJti(crypto.randomUUID()).encrypt(encryptionSecret);
|
|
25
|
+
}
|
|
26
|
+
/** Decodes an Auth.js issued JWT. */
|
|
27
|
+
async function decode(params) {
|
|
28
|
+
const { token, secret, salt } = params;
|
|
29
|
+
const secrets = Array.isArray(secret) ? secret : [secret];
|
|
30
|
+
if (!token) return null;
|
|
31
|
+
const { payload } = await (0, jose.jwtDecrypt)(token, async ({ kid, enc: enc$1 }) => {
|
|
32
|
+
for (const secret$1 of secrets) {
|
|
33
|
+
const encryptionSecret = await getDerivedEncryptionKey(enc$1, secret$1, salt);
|
|
34
|
+
if (kid === void 0) return encryptionSecret;
|
|
35
|
+
if (kid === await (0, jose.calculateJwkThumbprint)({
|
|
36
|
+
kty: "oct",
|
|
37
|
+
k: jose.base64url.encode(encryptionSecret)
|
|
38
|
+
}, `sha${encryptionSecret.byteLength << 3}`)) return encryptionSecret;
|
|
39
|
+
}
|
|
40
|
+
throw new Error("no matching decryption secret");
|
|
41
|
+
}, {
|
|
42
|
+
clockTolerance: 15,
|
|
43
|
+
keyManagementAlgorithms: [alg],
|
|
44
|
+
contentEncryptionAlgorithms: [enc, "A256GCM"]
|
|
45
|
+
});
|
|
46
|
+
return payload;
|
|
47
|
+
}
|
|
48
|
+
async function getDerivedEncryptionKey(enc$1, keyMaterial, salt) {
|
|
49
|
+
let length;
|
|
50
|
+
switch (enc$1) {
|
|
51
|
+
case "A256CBC-HS512":
|
|
52
|
+
length = 64;
|
|
53
|
+
break;
|
|
54
|
+
case "A256GCM":
|
|
55
|
+
length = 32;
|
|
56
|
+
break;
|
|
57
|
+
default: throw new Error("Unsupported JWT Content Encryption Algorithm");
|
|
58
|
+
}
|
|
59
|
+
return await (0, _panva_hkdf.hkdf)("sha256", keyMaterial, salt, `Auth.js Generated Encryption Key (${salt})`, length);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.decode = decode;
|
|
64
|
+
exports.encode = encode;
|
package/dist/lib/jwt.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { hkdf } from "@panva/hkdf";
|
|
2
|
+
import { EncryptJWT, base64url, calculateJwkThumbprint, jwtDecrypt } from "jose";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/jwt.ts
|
|
5
|
+
/**
|
|
6
|
+
* このロジックは最新(@auth/core@0.37.2)のAuth.jsのjwt.tsからコピーされました。
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_MAX_AGE = 720 * 60 * 60;
|
|
9
|
+
const now = () => Date.now() / 1e3 | 0;
|
|
10
|
+
const alg = "dir";
|
|
11
|
+
const enc = "A256CBC-HS512";
|
|
12
|
+
/** Issues a JWT. By default, the JWT is encrypted using "A256CBC-HS512". */
|
|
13
|
+
async function encode(params) {
|
|
14
|
+
const { token = {}, secret, maxAge = DEFAULT_MAX_AGE, salt } = params;
|
|
15
|
+
const encryptionSecret = await getDerivedEncryptionKey(enc, (Array.isArray(secret) ? secret : [secret])[0], salt);
|
|
16
|
+
const thumbprint = await calculateJwkThumbprint({
|
|
17
|
+
kty: "oct",
|
|
18
|
+
k: base64url.encode(encryptionSecret)
|
|
19
|
+
}, `sha${encryptionSecret.byteLength << 3}`);
|
|
20
|
+
return await new EncryptJWT(token).setProtectedHeader({
|
|
21
|
+
alg,
|
|
22
|
+
enc,
|
|
23
|
+
kid: thumbprint
|
|
24
|
+
}).setIssuedAt().setExpirationTime(now() + maxAge).setJti(crypto.randomUUID()).encrypt(encryptionSecret);
|
|
25
|
+
}
|
|
26
|
+
/** Decodes an Auth.js issued JWT. */
|
|
27
|
+
async function decode(params) {
|
|
28
|
+
const { token, secret, salt } = params;
|
|
29
|
+
const secrets = Array.isArray(secret) ? secret : [secret];
|
|
30
|
+
if (!token) return null;
|
|
31
|
+
const { payload } = await jwtDecrypt(token, async ({ kid, enc: enc$1 }) => {
|
|
32
|
+
for (const secret$1 of secrets) {
|
|
33
|
+
const encryptionSecret = await getDerivedEncryptionKey(enc$1, secret$1, salt);
|
|
34
|
+
if (kid === void 0) return encryptionSecret;
|
|
35
|
+
if (kid === await calculateJwkThumbprint({
|
|
36
|
+
kty: "oct",
|
|
37
|
+
k: base64url.encode(encryptionSecret)
|
|
38
|
+
}, `sha${encryptionSecret.byteLength << 3}`)) return encryptionSecret;
|
|
39
|
+
}
|
|
40
|
+
throw new Error("no matching decryption secret");
|
|
41
|
+
}, {
|
|
42
|
+
clockTolerance: 15,
|
|
43
|
+
keyManagementAlgorithms: [alg],
|
|
44
|
+
contentEncryptionAlgorithms: [enc, "A256GCM"]
|
|
45
|
+
});
|
|
46
|
+
return payload;
|
|
47
|
+
}
|
|
48
|
+
async function getDerivedEncryptionKey(enc$1, keyMaterial, salt) {
|
|
49
|
+
let length;
|
|
50
|
+
switch (enc$1) {
|
|
51
|
+
case "A256CBC-HS512":
|
|
52
|
+
length = 64;
|
|
53
|
+
break;
|
|
54
|
+
case "A256GCM":
|
|
55
|
+
length = 32;
|
|
56
|
+
break;
|
|
57
|
+
default: throw new Error("Unsupported JWT Content Encryption Algorithm");
|
|
58
|
+
}
|
|
59
|
+
return await hkdf("sha256", keyMaterial, salt, `Auth.js Generated Encryption Key (${salt})`, length);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { decode, encode };
|
|
64
|
+
//# sourceMappingURL=jwt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.mjs","names":["secret","enc","length: number"],"sources":["../../src/lib/jwt.ts"],"sourcesContent":["/**\n * このロジックは最新(@auth/core@0.37.2)のAuth.jsのjwt.tsからコピーされました。\n */\n\nimport { hkdf } from \"@panva/hkdf\";\nimport {\n base64url,\n calculateJwkThumbprint,\n EncryptJWT,\n jwtDecrypt,\n} from \"jose\";\n\nconst DEFAULT_MAX_AGE = 30 * 24 * 60 * 60; // 30 days\n\nconst now = () => (Date.now() / 1000) | 0;\n\nconst alg = \"dir\";\nconst enc = \"A256CBC-HS512\";\ntype Digest = Parameters<typeof calculateJwkThumbprint>[1];\n\n/** Issues a JWT. By default, the JWT is encrypted using \"A256CBC-HS512\". */\nexport async function encode<Payload = object>(\n params: JWTEncodeParams<Payload>,\n) {\n const { token = {}, secret, maxAge = DEFAULT_MAX_AGE, salt } = params;\n const secrets = Array.isArray(secret) ? secret : [secret];\n const encryptionSecret = await getDerivedEncryptionKey(\n enc,\n secrets[0]!,\n salt,\n );\n\n const thumbprint = await calculateJwkThumbprint(\n { kty: \"oct\", k: base64url.encode(encryptionSecret) },\n `sha${encryptionSecret.byteLength << 3}` as Digest,\n );\n // @ts-expect-error `jose` allows any object as payload.\n return await new EncryptJWT(token)\n .setProtectedHeader({ alg, enc, kid: thumbprint })\n .setIssuedAt()\n .setExpirationTime(now() + maxAge)\n .setJti(crypto.randomUUID())\n .encrypt(encryptionSecret);\n}\n\n/** Decodes an Auth.js issued JWT. */\nexport async function decode<Payload = object>(\n params: JWTDecodeParams,\n): Promise<Payload | null> {\n const { token, secret, salt } = params;\n const secrets = Array.isArray(secret) ? secret : [secret];\n if (!token) {\n return null;\n }\n const { payload } = await jwtDecrypt(\n token,\n async ({ kid, enc }) => {\n for (const secret of secrets) {\n const encryptionSecret = await getDerivedEncryptionKey(\n enc,\n secret,\n salt,\n );\n if (kid === undefined) {\n return encryptionSecret;\n }\n\n const thumbprint = await calculateJwkThumbprint(\n { kty: \"oct\", k: base64url.encode(encryptionSecret) },\n `sha${encryptionSecret.byteLength << 3}` as Digest,\n );\n if (kid === thumbprint) {\n return encryptionSecret;\n }\n }\n\n throw new Error(\"no matching decryption secret\");\n },\n {\n clockTolerance: 15,\n keyManagementAlgorithms: [alg],\n contentEncryptionAlgorithms: [enc, \"A256GCM\"],\n },\n );\n return payload as Payload;\n}\n\nasync function getDerivedEncryptionKey(\n enc: string,\n keyMaterial: Parameters<typeof hkdf>[1],\n salt: Parameters<typeof hkdf>[2],\n) {\n let length: number;\n switch (enc) {\n case \"A256CBC-HS512\":\n length = 64;\n break;\n case \"A256GCM\":\n length = 32;\n break;\n default:\n throw new Error(\"Unsupported JWT Content Encryption Algorithm\");\n }\n return await hkdf(\n \"sha256\",\n keyMaterial,\n salt,\n `Auth.js Generated Encryption Key (${salt})`,\n length,\n );\n}\n\nexport interface JWTEncodeParams<Payload = object> {\n /**\n * The maximum age of the Auth.js issued JWT in seconds.\n *\n * @default 30 * 24 * 60 * 60 // 30 days\n */\n maxAge?: number;\n /** Used in combination with `secret`, to derive the encryption secret for JWTs. */\n salt: string;\n /** Used in combination with `salt`, to derive the encryption secret for JWTs. */\n secret: string | string[];\n /** The JWT payload. */\n token?: Payload;\n}\n\nexport interface JWTDecodeParams {\n /** Used in combination with `secret`, to derive the encryption secret for JWTs. */\n salt: string;\n /**\n * Used in combination with `salt`, to derive the encryption secret for JWTs.\n *\n * @note\n * You can also pass an array of secrets, in which case the first secret that successfully\n * decrypts the JWT will be used. This is useful for rotating secrets without invalidating existing sessions.\n * The newer secret should be added to the start of the array, which will be used for all new sessions.\n */\n secret: string | string[];\n /** The Auth.js issued JWT to be decoded */\n token?: string;\n}\n"],"mappings":";;;;;;;AAYA,MAAM,kBAAkB,MAAU,KAAK;AAEvC,MAAM,YAAa,KAAK,KAAK,GAAG,MAAQ;AAExC,MAAM,MAAM;AACZ,MAAM,MAAM;;AAIZ,eAAsB,OACpB,QACA;CACA,MAAM,EAAE,QAAQ,EAAE,EAAE,QAAQ,SAAS,iBAAiB,SAAS;CAE/D,MAAM,mBAAmB,MAAM,wBAC7B,MAFc,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO,EAG/C,IACR,KACD;CAED,MAAM,aAAa,MAAM,uBACvB;EAAE,KAAK;EAAO,GAAG,UAAU,OAAO,iBAAiB;EAAE,EACrD,MAAM,iBAAiB,cAAc,IACtC;AAED,QAAO,MAAM,IAAI,WAAW,MAAM,CAC/B,mBAAmB;EAAE;EAAK;EAAK,KAAK;EAAY,CAAC,CACjD,aAAa,CACb,kBAAkB,KAAK,GAAG,OAAO,CACjC,OAAO,OAAO,YAAY,CAAC,CAC3B,QAAQ,iBAAiB;;;AAI9B,eAAsB,OACpB,QACyB;CACzB,MAAM,EAAE,OAAO,QAAQ,SAAS;CAChC,MAAM,UAAU,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;AACzD,KAAI,CAAC,MACH,QAAO;CAET,MAAM,EAAE,YAAY,MAAM,WACxB,OACA,OAAO,EAAE,KAAK,iBAAU;AACtB,OAAK,MAAMA,YAAU,SAAS;GAC5B,MAAM,mBAAmB,MAAM,wBAC7BC,OACAD,UACA,KACD;AACD,OAAI,QAAQ,OACV,QAAO;AAOT,OAAI,QAJe,MAAM,uBACvB;IAAE,KAAK;IAAO,GAAG,UAAU,OAAO,iBAAiB;IAAE,EACrD,MAAM,iBAAiB,cAAc,IACtC,CAEC,QAAO;;AAIX,QAAM,IAAI,MAAM,gCAAgC;IAElD;EACE,gBAAgB;EAChB,yBAAyB,CAAC,IAAI;EAC9B,6BAA6B,CAAC,KAAK,UAAU;EAC9C,CACF;AACD,QAAO;;AAGT,eAAe,wBACb,OACA,aACA,MACA;CACA,IAAIE;AACJ,SAAQD,OAAR;EACE,KAAK;AACH,YAAS;AACT;EACF,KAAK;AACH,YAAS;AACT;EACF,QACE,OAAM,IAAI,MAAM,+CAA+C;;AAEnE,QAAO,MAAM,KACX,UACA,aACA,MACA,qCAAqC,KAAK,IAC1C,OACD"}
|