@okrlinkhub/fly-agents 0.1.1 → 0.1.2
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/component/_generated/component.d.ts +23 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/lib.d.ts +23 -0
- package/dist/component/lib.d.ts.map +1 -1
- package/dist/component/lib.js +122 -62
- package/dist/component/lib.js.map +1 -1
- package/package.json +1 -1
- package/src/component/_generated/component.ts +39 -4
- package/src/component/lib.ts +133 -63
|
@@ -27,8 +27,10 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
27
27
|
telegramPairingCode: string;
|
|
28
28
|
}, null, Name>;
|
|
29
29
|
approveTelegramPairingWithStoredSecrets: FunctionReference<"action", "internal", {
|
|
30
|
+
flyApiToken?: string;
|
|
30
31
|
flyAppName: string;
|
|
31
32
|
machineDocId: string;
|
|
33
|
+
secretsEncryptionKey: string;
|
|
32
34
|
telegramPairingCode: string;
|
|
33
35
|
}, null, Name>;
|
|
34
36
|
clearAgentSecrets: FunctionReference<"mutation", "internal", {
|
|
@@ -44,8 +46,10 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
44
46
|
snapshotId: string;
|
|
45
47
|
}, Name>;
|
|
46
48
|
createAgentSnapshotWithStoredSecrets: FunctionReference<"action", "internal", {
|
|
49
|
+
flyApiToken?: string;
|
|
47
50
|
flyAppName: string;
|
|
48
51
|
machineDocId: string;
|
|
52
|
+
secretsEncryptionKey: string;
|
|
49
53
|
}, {
|
|
50
54
|
flyVolumeSnapshotId?: string;
|
|
51
55
|
snapshotId: string;
|
|
@@ -56,8 +60,10 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
56
60
|
machineDocId: string;
|
|
57
61
|
}, null, Name>;
|
|
58
62
|
deprovisionAgentMachineWithStoredSecrets: FunctionReference<"action", "internal", {
|
|
63
|
+
flyApiToken?: string;
|
|
59
64
|
flyAppName: string;
|
|
60
65
|
machineDocId: string;
|
|
66
|
+
secretsEncryptionKey: string;
|
|
61
67
|
}, null, Name>;
|
|
62
68
|
getAgentMachine: FunctionReference<"query", "internal", {
|
|
63
69
|
machineDocId: string;
|
|
@@ -148,14 +154,20 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
148
154
|
allowedSkillsJson?: string;
|
|
149
155
|
appKey?: string;
|
|
150
156
|
bridgeUrl?: string;
|
|
157
|
+
flyApiToken?: string;
|
|
151
158
|
flyAppName: string;
|
|
152
159
|
image?: string;
|
|
160
|
+
llmApiKey?: string;
|
|
153
161
|
llmModel?: string;
|
|
154
162
|
memoryMB?: number;
|
|
163
|
+
openaiApiKey?: string;
|
|
164
|
+
openclawGatewayToken?: string;
|
|
155
165
|
region?: string;
|
|
156
166
|
restoreFromLatestSnapshot?: boolean;
|
|
167
|
+
secretsEncryptionKey: string;
|
|
157
168
|
serviceId?: string;
|
|
158
169
|
serviceKey?: string;
|
|
170
|
+
telegramBotToken?: string;
|
|
159
171
|
tenantId: string;
|
|
160
172
|
userId: string;
|
|
161
173
|
}, {
|
|
@@ -192,13 +204,19 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
192
204
|
allowedSkillsJson?: string;
|
|
193
205
|
appKey?: string;
|
|
194
206
|
bridgeUrl?: string;
|
|
207
|
+
flyApiToken?: string;
|
|
195
208
|
flyAppName: string;
|
|
196
209
|
image?: string;
|
|
210
|
+
llmApiKey?: string;
|
|
197
211
|
llmModel?: string;
|
|
198
212
|
memoryMB?: number;
|
|
213
|
+
openaiApiKey?: string;
|
|
214
|
+
openclawGatewayToken?: string;
|
|
199
215
|
region?: string;
|
|
216
|
+
secretsEncryptionKey: string;
|
|
200
217
|
serviceId?: string;
|
|
201
218
|
serviceKey?: string;
|
|
219
|
+
telegramBotToken?: string;
|
|
202
220
|
tenantId: string;
|
|
203
221
|
userId: string;
|
|
204
222
|
}, {
|
|
@@ -212,8 +230,10 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
212
230
|
machineDocId: string;
|
|
213
231
|
}, null, Name>;
|
|
214
232
|
startAgentMachineWithStoredSecrets: FunctionReference<"action", "internal", {
|
|
233
|
+
flyApiToken?: string;
|
|
215
234
|
flyAppName: string;
|
|
216
235
|
machineDocId: string;
|
|
236
|
+
secretsEncryptionKey: string;
|
|
217
237
|
}, null, Name>;
|
|
218
238
|
stopAgentMachine: FunctionReference<"action", "internal", {
|
|
219
239
|
flyApiToken: string;
|
|
@@ -221,8 +241,10 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
221
241
|
machineDocId: string;
|
|
222
242
|
}, null, Name>;
|
|
223
243
|
stopAgentMachineWithStoredSecrets: FunctionReference<"action", "internal", {
|
|
244
|
+
flyApiToken?: string;
|
|
224
245
|
flyAppName: string;
|
|
225
246
|
machineDocId: string;
|
|
247
|
+
secretsEncryptionKey: string;
|
|
226
248
|
}, null, Name>;
|
|
227
249
|
touchAgentActivity: FunctionReference<"mutation", "internal", {
|
|
228
250
|
machineDocId: string;
|
|
@@ -236,6 +258,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
236
258
|
llmApiKey?: string;
|
|
237
259
|
openaiApiKey?: string;
|
|
238
260
|
openclawGatewayToken?: string;
|
|
261
|
+
secretsEncryptionKey: string;
|
|
239
262
|
telegramBotToken?: string;
|
|
240
263
|
tenantId: string;
|
|
241
264
|
userId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/component.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3E;IACE,GAAG,EAAE;QACH,sBAAsB,EAAE,iBAAiB,CACvC,QAAQ,EACR,UAAU,EACV;YACE,WAAW,EAAE,MAAM,CAAC;YACpB,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;YACrB,mBAAmB,EAAE,MAAM,CAAC;SAC7B,EACD,IAAI,EACJ,IAAI,CACL,CAAC;QACF,uCAAuC,EAAE,iBAAiB,CACxD,QAAQ,EACR,UAAU,EACV;YACE,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;YACrB,mBAAmB,EAAE,MAAM,CAAC;SAC7B,EACD,IAAI,EACJ,IAAI,CACL,CAAC;QACF,iBAAiB,EAAE,iBAAiB,CAClC,UAAU,EACV,UAAU,EACV;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EACpC,IAAI,EACJ,IAAI,CACL,CAAC;QACF,mBAAmB,EAAE,iBAAiB,CACpC,QAAQ,EACR,UAAU,EACV;YAAE,WAAW,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAC;YAAC,YAAY,EAAE,MAAM,CAAA;SAAE,EACjE;YAAE,mBAAmB,CAAC,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,EACpD,IAAI,CACL,CAAC;QACF,oCAAoC,EAAE,iBAAiB,CACrD,QAAQ,EACR,UAAU,EACV;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/component.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3E;IACE,GAAG,EAAE;QACH,sBAAsB,EAAE,iBAAiB,CACvC,QAAQ,EACR,UAAU,EACV;YACE,WAAW,EAAE,MAAM,CAAC;YACpB,UAAU,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AC;YACxB,YAAY,EAAE,OAAO,CAAC;YACtB,eAAe,EAAE,OAAO,CAAC;YACzB,uBAAuB,EAAE,OAAO,CAAC;YACjC,mBAAmB,EAAE,OAAO,CAAC;YAC7B,QAAQ,EAAE,MAAM,CAAC;YACjB,SAAS,EAAE,MAAM,CAAC;YAClB,MAAM,EAAE,MAAM,CAAC;SAChB,EACD,IAAI,CACL,CAAC;KACH,CAAC;CACH,CAAC"}
|
package/dist/component/lib.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export declare const upsertAgentSecrets: import("convex/server").RegisteredMutat
|
|
|
73
73
|
openclawGatewayToken?: string | undefined;
|
|
74
74
|
userId: string;
|
|
75
75
|
tenantId: string;
|
|
76
|
+
secretsEncryptionKey: string;
|
|
76
77
|
}, Promise<{
|
|
77
78
|
tenantId: string;
|
|
78
79
|
userId: string;
|
|
@@ -151,7 +152,9 @@ export declare const approveTelegramPairing: import("convex/server").RegisteredA
|
|
|
151
152
|
telegramPairingCode: string;
|
|
152
153
|
}, Promise<null>>;
|
|
153
154
|
export declare const approveTelegramPairingWithStoredSecrets: import("convex/server").RegisteredAction<"public", {
|
|
155
|
+
flyApiToken?: string | undefined;
|
|
154
156
|
machineDocId: import("convex/values").GenericId<"agentMachines">;
|
|
157
|
+
secretsEncryptionKey: string;
|
|
155
158
|
flyAppName: string;
|
|
156
159
|
telegramPairingCode: string;
|
|
157
160
|
}, Promise<null>>;
|
|
@@ -165,10 +168,16 @@ export declare const provisionAgentMachineWithStoredSecrets: import("convex/serv
|
|
|
165
168
|
region?: string | undefined;
|
|
166
169
|
image?: string | undefined;
|
|
167
170
|
llmModel?: string | undefined;
|
|
171
|
+
flyApiToken?: string | undefined;
|
|
172
|
+
llmApiKey?: string | undefined;
|
|
173
|
+
openaiApiKey?: string | undefined;
|
|
174
|
+
telegramBotToken?: string | undefined;
|
|
175
|
+
openclawGatewayToken?: string | undefined;
|
|
168
176
|
allowedSkillsJson?: string | undefined;
|
|
169
177
|
restoreFromLatestSnapshot?: boolean | undefined;
|
|
170
178
|
userId: string;
|
|
171
179
|
tenantId: string;
|
|
180
|
+
secretsEncryptionKey: string;
|
|
172
181
|
flyAppName: string;
|
|
173
182
|
}, Promise<{
|
|
174
183
|
machineDocId: Id<"agentMachines">;
|
|
@@ -185,9 +194,15 @@ export declare const recreateAgentFromLatestSnapshotWithStoredSecrets: import("c
|
|
|
185
194
|
region?: string | undefined;
|
|
186
195
|
image?: string | undefined;
|
|
187
196
|
llmModel?: string | undefined;
|
|
197
|
+
flyApiToken?: string | undefined;
|
|
198
|
+
llmApiKey?: string | undefined;
|
|
199
|
+
openaiApiKey?: string | undefined;
|
|
200
|
+
telegramBotToken?: string | undefined;
|
|
201
|
+
openclawGatewayToken?: string | undefined;
|
|
188
202
|
allowedSkillsJson?: string | undefined;
|
|
189
203
|
userId: string;
|
|
190
204
|
tenantId: string;
|
|
205
|
+
secretsEncryptionKey: string;
|
|
191
206
|
flyAppName: string;
|
|
192
207
|
}, Promise<{
|
|
193
208
|
machineDocId: any;
|
|
@@ -210,19 +225,27 @@ export declare const deprovisionAgentMachine: import("convex/server").Registered
|
|
|
210
225
|
flyAppName: string;
|
|
211
226
|
}, Promise<null>>;
|
|
212
227
|
export declare const startAgentMachineWithStoredSecrets: import("convex/server").RegisteredAction<"public", {
|
|
228
|
+
flyApiToken?: string | undefined;
|
|
213
229
|
machineDocId: import("convex/values").GenericId<"agentMachines">;
|
|
230
|
+
secretsEncryptionKey: string;
|
|
214
231
|
flyAppName: string;
|
|
215
232
|
}, Promise<null>>;
|
|
216
233
|
export declare const stopAgentMachineWithStoredSecrets: import("convex/server").RegisteredAction<"public", {
|
|
234
|
+
flyApiToken?: string | undefined;
|
|
217
235
|
machineDocId: import("convex/values").GenericId<"agentMachines">;
|
|
236
|
+
secretsEncryptionKey: string;
|
|
218
237
|
flyAppName: string;
|
|
219
238
|
}, Promise<null>>;
|
|
220
239
|
export declare const deprovisionAgentMachineWithStoredSecrets: import("convex/server").RegisteredAction<"public", {
|
|
240
|
+
flyApiToken?: string | undefined;
|
|
221
241
|
machineDocId: import("convex/values").GenericId<"agentMachines">;
|
|
242
|
+
secretsEncryptionKey: string;
|
|
222
243
|
flyAppName: string;
|
|
223
244
|
}, Promise<null>>;
|
|
224
245
|
export declare const createAgentSnapshotWithStoredSecrets: import("convex/server").RegisteredAction<"public", {
|
|
246
|
+
flyApiToken?: string | undefined;
|
|
225
247
|
machineDocId: import("convex/values").GenericId<"agentMachines">;
|
|
248
|
+
secretsEncryptionKey: string;
|
|
226
249
|
flyAppName: string;
|
|
227
250
|
}, Promise<{
|
|
228
251
|
snapshotId: Id<"agentSnapshots">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/component/lib.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/component/lib.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAmRpD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;KAUpC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;UAM1B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;iBAc9B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;iBAa7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;UAuB9B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;GAqE7B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;iBAW5B,CAAC;AAoPH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;kBA4BhB,EAAE,CAAC,eAAe,CAAC;eACtB,MAAM;cACP,MAAM;GAIlB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;gBAWhB,EAAE,CAAC,gBAAgB,CAAC;0BACV,MAAM;GAI9B,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;kBA2B1B,EAAE,CAAC,eAAe,CAAC;eACtB,MAAM;cACP,MAAM;GAkBlB,CAAC;AA4BH,eAAO,MAAM,sBAAsB;;;;;iBA6BjC,CAAC;AAEH,eAAO,MAAM,uCAAuC;;;;;;iBAuClD,CAAC;AAEH,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;kBAnXnC,EAAE,CAAC,eAAe,CAAC;eACtB,MAAM;cACP,MAAM;GAiahB,CAAC;AAEH,eAAO,MAAM,gDAAgD;;;;;;;;;;;;;;;;;;;;;;;;GA2D3D,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;iBA+B5B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;iBA6B3B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;iBAqClC,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;iBAyC7C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;iBAuC5C,CAAC;AAEH,eAAO,MAAM,wCAAwC;;;;;iBA4CnD,CAAC;AAEH,eAAO,MAAM,oCAAoC;;;;;;gBA/wBvB,EAAE,CAAC,gBAAgB,CAAC;0BAAwB,MAAM;GAgzB1E,CAAC"}
|
package/dist/component/lib.js
CHANGED
|
@@ -36,14 +36,30 @@ async function flyRequest(args) {
|
|
|
36
36
|
function agentKeyFor(userId, tenantId) {
|
|
37
37
|
return `${tenantId}:${userId}`;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (!value || !value.trim()) {
|
|
44
|
-
throw new Error(`Missing required value: ${name}`);
|
|
39
|
+
function requiredArg(name, value) {
|
|
40
|
+
const normalized = value?.trim();
|
|
41
|
+
if (!normalized) {
|
|
42
|
+
throw new Error(`Missing required argument: ${name}`);
|
|
45
43
|
}
|
|
46
|
-
return
|
|
44
|
+
return normalized;
|
|
45
|
+
}
|
|
46
|
+
function requiredValue(name, value, fallback) {
|
|
47
|
+
const normalizedValue = value?.trim();
|
|
48
|
+
if (normalizedValue) {
|
|
49
|
+
return normalizedValue;
|
|
50
|
+
}
|
|
51
|
+
const normalizedFallback = fallback?.trim();
|
|
52
|
+
if (normalizedFallback) {
|
|
53
|
+
return normalizedFallback;
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`Missing required value: ${name}`);
|
|
56
|
+
}
|
|
57
|
+
function optionalValue(value) {
|
|
58
|
+
const normalized = value?.trim();
|
|
59
|
+
return normalized ? normalized : undefined;
|
|
60
|
+
}
|
|
61
|
+
function defaultedValue(value, fallback) {
|
|
62
|
+
return optionalValue(value) ?? fallback.trim();
|
|
47
63
|
}
|
|
48
64
|
function parseAllowedSkillsJson(raw) {
|
|
49
65
|
if (!raw?.trim()) {
|
|
@@ -72,8 +88,7 @@ function assertAllowedModel(model) {
|
|
|
72
88
|
const DEFAULT_LLM_MODEL = "openai/gpt-4.1-mini";
|
|
73
89
|
const MODEL_SET_RETRY_ATTEMPTS = 30;
|
|
74
90
|
const MODEL_SET_RETRY_DELAY_MS = 5_000;
|
|
75
|
-
const
|
|
76
|
-
let cachedCryptoKey = null;
|
|
91
|
+
const cachedCryptoKeys = new Map();
|
|
77
92
|
function sleep(ms) {
|
|
78
93
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
79
94
|
}
|
|
@@ -98,25 +113,32 @@ function fromBase64(value) {
|
|
|
98
113
|
function toArrayBuffer(bytes) {
|
|
99
114
|
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
100
115
|
}
|
|
101
|
-
async function getSecretsCryptoKey() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return await crypto.subtle.importKey("raw", hash, "AES-GCM", false, ["encrypt", "decrypt"]);
|
|
107
|
-
})();
|
|
116
|
+
async function getSecretsCryptoKey(secretsEncryptionKey) {
|
|
117
|
+
const secret = requiredArg("secretsEncryptionKey", secretsEncryptionKey);
|
|
118
|
+
const cached = cachedCryptoKeys.get(secret);
|
|
119
|
+
if (cached) {
|
|
120
|
+
return await cached;
|
|
108
121
|
}
|
|
109
|
-
|
|
122
|
+
const keyPromise = (async () => {
|
|
123
|
+
const hash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(secret));
|
|
124
|
+
return await crypto.subtle.importKey("raw", hash, "AES-GCM", false, ["encrypt", "decrypt"]);
|
|
125
|
+
})();
|
|
126
|
+
cachedCryptoKeys.set(secret, keyPromise);
|
|
127
|
+
return await keyPromise;
|
|
110
128
|
}
|
|
111
|
-
async function encryptSecret(plaintext) {
|
|
112
|
-
const key = await getSecretsCryptoKey();
|
|
129
|
+
async function encryptSecret(plaintext, secretsEncryptionKey) {
|
|
130
|
+
const key = await getSecretsCryptoKey(secretsEncryptionKey);
|
|
113
131
|
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
114
132
|
const encrypted = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, key, new TextEncoder().encode(plaintext));
|
|
115
133
|
return `${toBase64(iv)}.${toBase64(new Uint8Array(encrypted))}`;
|
|
116
134
|
}
|
|
117
|
-
async function decryptSecret(ciphertext) {
|
|
118
|
-
const key = await getSecretsCryptoKey();
|
|
119
|
-
const
|
|
135
|
+
async function decryptSecret(ciphertext, secretsEncryptionKey) {
|
|
136
|
+
const key = await getSecretsCryptoKey(secretsEncryptionKey);
|
|
137
|
+
const parts = ciphertext.split(".");
|
|
138
|
+
if (parts.length !== 2) {
|
|
139
|
+
throw new Error("Invalid encrypted secret format");
|
|
140
|
+
}
|
|
141
|
+
const [ivEncoded, payloadEncoded] = parts;
|
|
120
142
|
if (!ivEncoded || !payloadEncoded) {
|
|
121
143
|
throw new Error("Invalid encrypted secret format");
|
|
122
144
|
}
|
|
@@ -164,19 +186,19 @@ async function getSecretsForAgent(ctx, args) {
|
|
|
164
186
|
}
|
|
165
187
|
const decrypted = {};
|
|
166
188
|
if (record.flyApiTokenEnc) {
|
|
167
|
-
decrypted.flyApiToken = await decryptSecret(record.flyApiTokenEnc);
|
|
189
|
+
decrypted.flyApiToken = await decryptSecret(record.flyApiTokenEnc, args.secretsEncryptionKey);
|
|
168
190
|
}
|
|
169
191
|
if (record.llmApiKeyEnc) {
|
|
170
|
-
decrypted.llmApiKey = await decryptSecret(record.llmApiKeyEnc);
|
|
192
|
+
decrypted.llmApiKey = await decryptSecret(record.llmApiKeyEnc, args.secretsEncryptionKey);
|
|
171
193
|
}
|
|
172
194
|
if (record.openaiApiKeyEnc) {
|
|
173
|
-
decrypted.openaiApiKey = await decryptSecret(record.openaiApiKeyEnc);
|
|
195
|
+
decrypted.openaiApiKey = await decryptSecret(record.openaiApiKeyEnc, args.secretsEncryptionKey);
|
|
174
196
|
}
|
|
175
197
|
if (record.telegramBotTokenEnc) {
|
|
176
|
-
decrypted.telegramBotToken = await decryptSecret(record.telegramBotTokenEnc);
|
|
198
|
+
decrypted.telegramBotToken = await decryptSecret(record.telegramBotTokenEnc, args.secretsEncryptionKey);
|
|
177
199
|
}
|
|
178
200
|
if (record.openclawGatewayTokenEnc) {
|
|
179
|
-
decrypted.openclawGatewayToken = await decryptSecret(record.openclawGatewayTokenEnc);
|
|
201
|
+
decrypted.openclawGatewayToken = await decryptSecret(record.openclawGatewayTokenEnc, args.secretsEncryptionKey);
|
|
180
202
|
}
|
|
181
203
|
return decrypted;
|
|
182
204
|
}
|
|
@@ -255,6 +277,7 @@ export const upsertAgentSecrets = mutation({
|
|
|
255
277
|
args: {
|
|
256
278
|
tenantId: v.string(),
|
|
257
279
|
userId: v.string(),
|
|
280
|
+
secretsEncryptionKey: v.string(),
|
|
258
281
|
flyApiToken: v.optional(v.string()),
|
|
259
282
|
llmApiKey: v.optional(v.string()),
|
|
260
283
|
openaiApiKey: v.optional(v.string()),
|
|
@@ -273,17 +296,19 @@ export const upsertAgentSecrets = mutation({
|
|
|
273
296
|
openclawGatewayToken: normalizeOptionalSecret(args.openclawGatewayToken),
|
|
274
297
|
};
|
|
275
298
|
const flyApiTokenEnc = next.flyApiToken !== undefined
|
|
276
|
-
? await encryptSecret(next.flyApiToken)
|
|
299
|
+
? await encryptSecret(next.flyApiToken, args.secretsEncryptionKey)
|
|
277
300
|
: existing?.flyApiTokenEnc;
|
|
278
|
-
const llmApiKeyEnc = next.llmApiKey !== undefined
|
|
301
|
+
const llmApiKeyEnc = next.llmApiKey !== undefined
|
|
302
|
+
? await encryptSecret(next.llmApiKey, args.secretsEncryptionKey)
|
|
303
|
+
: existing?.llmApiKeyEnc;
|
|
279
304
|
const openaiApiKeyEnc = next.openaiApiKey !== undefined
|
|
280
|
-
? await encryptSecret(next.openaiApiKey)
|
|
305
|
+
? await encryptSecret(next.openaiApiKey, args.secretsEncryptionKey)
|
|
281
306
|
: existing?.openaiApiKeyEnc;
|
|
282
307
|
const telegramBotTokenEnc = next.telegramBotToken !== undefined
|
|
283
|
-
? await encryptSecret(next.telegramBotToken)
|
|
308
|
+
? await encryptSecret(next.telegramBotToken, args.secretsEncryptionKey)
|
|
284
309
|
: existing?.telegramBotTokenEnc;
|
|
285
310
|
const openclawGatewayTokenEnc = next.openclawGatewayToken !== undefined
|
|
286
|
-
? await encryptSecret(next.openclawGatewayToken)
|
|
311
|
+
? await encryptSecret(next.openclawGatewayToken, args.secretsEncryptionKey)
|
|
287
312
|
: existing?.openclawGatewayTokenEnc;
|
|
288
313
|
const updatedAt = Date.now();
|
|
289
314
|
await ctx.runMutation(internal.storage.upsertAgentSecretsRecord, {
|
|
@@ -379,15 +404,15 @@ async function createBackupSnapshotForMachine(ctx, args) {
|
|
|
379
404
|
}
|
|
380
405
|
async function provisionMachine(ctx, args) {
|
|
381
406
|
const allowedSkills = parseAllowedSkillsJson(args.allowedSkillsJson) ?? args.allowedSkills ?? ["linkhub-bridge"];
|
|
382
|
-
const bridgeUrl =
|
|
383
|
-
const llmApiKey =
|
|
384
|
-
const openaiApiKey =
|
|
385
|
-
const llmModel =
|
|
407
|
+
const bridgeUrl = requiredArg("bridgeUrl", args.bridgeUrl);
|
|
408
|
+
const llmApiKey = requiredValue("llmApiKey or openaiApiKey", args.llmApiKey, args.openaiApiKey);
|
|
409
|
+
const openaiApiKey = requiredValue("openaiApiKey or llmApiKey", args.openaiApiKey, llmApiKey);
|
|
410
|
+
const llmModel = defaultedValue(args.llmModel, DEFAULT_LLM_MODEL);
|
|
386
411
|
assertAllowedModel(llmModel);
|
|
387
|
-
const telegramBotToken =
|
|
388
|
-
const serviceId =
|
|
389
|
-
const serviceKey =
|
|
390
|
-
const openclawGatewayToken =
|
|
412
|
+
const telegramBotToken = requiredArg("telegramBotToken", args.telegramBotToken);
|
|
413
|
+
const serviceId = requiredArg("serviceId", args.serviceId);
|
|
414
|
+
const serviceKey = requiredArg("serviceKey", args.serviceKey);
|
|
415
|
+
const openclawGatewayToken = requiredArg("openclawGatewayToken", args.openclawGatewayToken);
|
|
391
416
|
const appKey = args.appKey?.trim() || "linkhub-w4";
|
|
392
417
|
const memoryMB = args.memoryMB ?? 2048;
|
|
393
418
|
const region = args.region ?? "iad";
|
|
@@ -674,6 +699,8 @@ export const approveTelegramPairingWithStoredSecrets = action({
|
|
|
674
699
|
machineDocId: v.id("agentMachines"),
|
|
675
700
|
flyAppName: v.string(),
|
|
676
701
|
telegramPairingCode: v.string(),
|
|
702
|
+
secretsEncryptionKey: v.string(),
|
|
703
|
+
flyApiToken: v.optional(v.string()),
|
|
677
704
|
},
|
|
678
705
|
returns: v.null(),
|
|
679
706
|
handler: async (ctx, args) => {
|
|
@@ -686,8 +713,9 @@ export const approveTelegramPairingWithStoredSecrets = action({
|
|
|
686
713
|
const secrets = await getSecretsForAgent(ctx, {
|
|
687
714
|
tenantId: machine.tenantId,
|
|
688
715
|
userId: machine.userId,
|
|
716
|
+
secretsEncryptionKey: args.secretsEncryptionKey,
|
|
689
717
|
});
|
|
690
|
-
const flyApiToken = secrets?.flyApiToken;
|
|
718
|
+
const flyApiToken = optionalValue(secrets?.flyApiToken) ?? optionalValue(args.flyApiToken);
|
|
691
719
|
if (!flyApiToken) {
|
|
692
720
|
throw new Error("Stored flyApiToken not found for this agent");
|
|
693
721
|
}
|
|
@@ -711,10 +739,16 @@ export const provisionAgentMachineWithStoredSecrets = action({
|
|
|
711
739
|
userId: v.string(),
|
|
712
740
|
tenantId: v.string(),
|
|
713
741
|
flyAppName: v.string(),
|
|
742
|
+
secretsEncryptionKey: v.string(),
|
|
743
|
+
flyApiToken: v.optional(v.string()),
|
|
714
744
|
image: v.optional(v.string()),
|
|
715
745
|
region: v.optional(v.string()),
|
|
716
746
|
memoryMB: v.optional(v.number()),
|
|
717
747
|
bridgeUrl: v.optional(v.string()),
|
|
748
|
+
llmApiKey: v.optional(v.string()),
|
|
749
|
+
openaiApiKey: v.optional(v.string()),
|
|
750
|
+
telegramBotToken: v.optional(v.string()),
|
|
751
|
+
openclawGatewayToken: v.optional(v.string()),
|
|
718
752
|
llmModel: v.optional(v.string()),
|
|
719
753
|
serviceId: v.optional(v.string()),
|
|
720
754
|
serviceKey: v.optional(v.string()),
|
|
@@ -732,17 +766,19 @@ export const provisionAgentMachineWithStoredSecrets = action({
|
|
|
732
766
|
const secrets = await getSecretsForAgent(ctx, {
|
|
733
767
|
tenantId: args.tenantId,
|
|
734
768
|
userId: args.userId,
|
|
769
|
+
secretsEncryptionKey: args.secretsEncryptionKey,
|
|
735
770
|
});
|
|
736
|
-
|
|
771
|
+
const flyApiToken = optionalValue(secrets?.flyApiToken) ?? optionalValue(args.flyApiToken);
|
|
772
|
+
if (!flyApiToken) {
|
|
737
773
|
throw new Error("Stored flyApiToken not found for this agent");
|
|
738
774
|
}
|
|
739
775
|
return await provisionMachine(ctx, {
|
|
740
776
|
...args,
|
|
741
|
-
flyApiToken
|
|
742
|
-
llmApiKey: secrets.llmApiKey,
|
|
743
|
-
openaiApiKey: secrets.openaiApiKey,
|
|
744
|
-
telegramBotToken: secrets.telegramBotToken,
|
|
745
|
-
openclawGatewayToken: secrets.openclawGatewayToken,
|
|
777
|
+
flyApiToken,
|
|
778
|
+
llmApiKey: optionalValue(secrets?.llmApiKey) ?? optionalValue(args.llmApiKey),
|
|
779
|
+
openaiApiKey: optionalValue(secrets?.openaiApiKey) ?? optionalValue(args.openaiApiKey),
|
|
780
|
+
telegramBotToken: optionalValue(secrets?.telegramBotToken) ?? optionalValue(args.telegramBotToken),
|
|
781
|
+
openclawGatewayToken: optionalValue(secrets?.openclawGatewayToken) ?? optionalValue(args.openclawGatewayToken),
|
|
746
782
|
});
|
|
747
783
|
},
|
|
748
784
|
});
|
|
@@ -751,10 +787,16 @@ export const recreateAgentFromLatestSnapshotWithStoredSecrets = action({
|
|
|
751
787
|
userId: v.string(),
|
|
752
788
|
tenantId: v.string(),
|
|
753
789
|
flyAppName: v.string(),
|
|
790
|
+
secretsEncryptionKey: v.string(),
|
|
791
|
+
flyApiToken: v.optional(v.string()),
|
|
754
792
|
image: v.optional(v.string()),
|
|
755
793
|
region: v.optional(v.string()),
|
|
756
794
|
memoryMB: v.optional(v.number()),
|
|
757
795
|
bridgeUrl: v.optional(v.string()),
|
|
796
|
+
llmApiKey: v.optional(v.string()),
|
|
797
|
+
openaiApiKey: v.optional(v.string()),
|
|
798
|
+
telegramBotToken: v.optional(v.string()),
|
|
799
|
+
openclawGatewayToken: v.optional(v.string()),
|
|
758
800
|
llmModel: v.optional(v.string()),
|
|
759
801
|
serviceId: v.optional(v.string()),
|
|
760
802
|
serviceKey: v.optional(v.string()),
|
|
@@ -771,8 +813,10 @@ export const recreateAgentFromLatestSnapshotWithStoredSecrets = action({
|
|
|
771
813
|
const secrets = await getSecretsForAgent(ctx, {
|
|
772
814
|
tenantId: args.tenantId,
|
|
773
815
|
userId: args.userId,
|
|
816
|
+
secretsEncryptionKey: args.secretsEncryptionKey,
|
|
774
817
|
});
|
|
775
|
-
|
|
818
|
+
const flyApiToken = optionalValue(secrets?.flyApiToken) ?? optionalValue(args.flyApiToken);
|
|
819
|
+
if (!flyApiToken) {
|
|
776
820
|
throw new Error("Stored flyApiToken not found for this agent");
|
|
777
821
|
}
|
|
778
822
|
const latest = await ctx.runQuery(internal.storage.getLatestMachineByUserTenant, {
|
|
@@ -788,11 +832,11 @@ export const recreateAgentFromLatestSnapshotWithStoredSecrets = action({
|
|
|
788
832
|
}
|
|
789
833
|
return await provisionMachine(ctx, {
|
|
790
834
|
...args,
|
|
791
|
-
flyApiToken
|
|
792
|
-
llmApiKey: secrets.llmApiKey,
|
|
793
|
-
openaiApiKey: secrets.openaiApiKey,
|
|
794
|
-
telegramBotToken: secrets.telegramBotToken,
|
|
795
|
-
openclawGatewayToken: secrets.openclawGatewayToken,
|
|
835
|
+
flyApiToken,
|
|
836
|
+
llmApiKey: optionalValue(secrets?.llmApiKey) ?? optionalValue(args.llmApiKey),
|
|
837
|
+
openaiApiKey: optionalValue(secrets?.openaiApiKey) ?? optionalValue(args.openaiApiKey),
|
|
838
|
+
telegramBotToken: optionalValue(secrets?.telegramBotToken) ?? optionalValue(args.telegramBotToken),
|
|
839
|
+
openclawGatewayToken: optionalValue(secrets?.openclawGatewayToken) ?? optionalValue(args.openclawGatewayToken),
|
|
796
840
|
restoreFromLatestSnapshot: true,
|
|
797
841
|
});
|
|
798
842
|
},
|
|
@@ -892,6 +936,8 @@ export const startAgentMachineWithStoredSecrets = action({
|
|
|
892
936
|
args: {
|
|
893
937
|
machineDocId: v.id("agentMachines"),
|
|
894
938
|
flyAppName: v.string(),
|
|
939
|
+
secretsEncryptionKey: v.string(),
|
|
940
|
+
flyApiToken: v.optional(v.string()),
|
|
895
941
|
},
|
|
896
942
|
returns: v.null(),
|
|
897
943
|
handler: async (ctx, args) => {
|
|
@@ -904,8 +950,10 @@ export const startAgentMachineWithStoredSecrets = action({
|
|
|
904
950
|
const secrets = await getSecretsForAgent(ctx, {
|
|
905
951
|
tenantId: machine.tenantId,
|
|
906
952
|
userId: machine.userId,
|
|
953
|
+
secretsEncryptionKey: args.secretsEncryptionKey,
|
|
907
954
|
});
|
|
908
|
-
|
|
955
|
+
const flyApiToken = optionalValue(secrets?.flyApiToken) ?? optionalValue(args.flyApiToken);
|
|
956
|
+
if (!flyApiToken) {
|
|
909
957
|
throw new Error("Stored flyApiToken not found for this agent");
|
|
910
958
|
}
|
|
911
959
|
if (!machine?.machineId) {
|
|
@@ -913,7 +961,7 @@ export const startAgentMachineWithStoredSecrets = action({
|
|
|
913
961
|
}
|
|
914
962
|
await flyRequest({
|
|
915
963
|
endpoint: `/apps/${args.flyAppName}/machines/${machine.machineId}/start`,
|
|
916
|
-
token:
|
|
964
|
+
token: flyApiToken,
|
|
917
965
|
method: "POST",
|
|
918
966
|
});
|
|
919
967
|
await ctx.runMutation(internal.storage.patchMachineRecord, {
|
|
@@ -930,6 +978,8 @@ export const stopAgentMachineWithStoredSecrets = action({
|
|
|
930
978
|
args: {
|
|
931
979
|
machineDocId: v.id("agentMachines"),
|
|
932
980
|
flyAppName: v.string(),
|
|
981
|
+
secretsEncryptionKey: v.string(),
|
|
982
|
+
flyApiToken: v.optional(v.string()),
|
|
933
983
|
},
|
|
934
984
|
returns: v.null(),
|
|
935
985
|
handler: async (ctx, args) => {
|
|
@@ -942,8 +992,10 @@ export const stopAgentMachineWithStoredSecrets = action({
|
|
|
942
992
|
const secrets = await getSecretsForAgent(ctx, {
|
|
943
993
|
tenantId: machine.tenantId,
|
|
944
994
|
userId: machine.userId,
|
|
995
|
+
secretsEncryptionKey: args.secretsEncryptionKey,
|
|
945
996
|
});
|
|
946
|
-
|
|
997
|
+
const flyApiToken = optionalValue(secrets?.flyApiToken) ?? optionalValue(args.flyApiToken);
|
|
998
|
+
if (!flyApiToken) {
|
|
947
999
|
throw new Error("Stored flyApiToken not found for this agent");
|
|
948
1000
|
}
|
|
949
1001
|
if (!machine?.machineId) {
|
|
@@ -951,7 +1003,7 @@ export const stopAgentMachineWithStoredSecrets = action({
|
|
|
951
1003
|
}
|
|
952
1004
|
await flyRequest({
|
|
953
1005
|
endpoint: `/apps/${args.flyAppName}/machines/${machine.machineId}/stop`,
|
|
954
|
-
token:
|
|
1006
|
+
token: flyApiToken,
|
|
955
1007
|
method: "POST",
|
|
956
1008
|
});
|
|
957
1009
|
await ctx.runMutation(internal.storage.patchMachineRecord, {
|
|
@@ -966,6 +1018,8 @@ export const deprovisionAgentMachineWithStoredSecrets = action({
|
|
|
966
1018
|
args: {
|
|
967
1019
|
machineDocId: v.id("agentMachines"),
|
|
968
1020
|
flyAppName: v.string(),
|
|
1021
|
+
secretsEncryptionKey: v.string(),
|
|
1022
|
+
flyApiToken: v.optional(v.string()),
|
|
969
1023
|
},
|
|
970
1024
|
returns: v.null(),
|
|
971
1025
|
handler: async (ctx, args) => {
|
|
@@ -978,21 +1032,23 @@ export const deprovisionAgentMachineWithStoredSecrets = action({
|
|
|
978
1032
|
const secrets = await getSecretsForAgent(ctx, {
|
|
979
1033
|
tenantId: machine.tenantId,
|
|
980
1034
|
userId: machine.userId,
|
|
1035
|
+
secretsEncryptionKey: args.secretsEncryptionKey,
|
|
981
1036
|
});
|
|
982
|
-
|
|
1037
|
+
const flyApiToken = optionalValue(secrets?.flyApiToken) ?? optionalValue(args.flyApiToken);
|
|
1038
|
+
if (!flyApiToken) {
|
|
983
1039
|
throw new Error("Stored flyApiToken not found for this agent");
|
|
984
1040
|
}
|
|
985
1041
|
if (machine.machineId) {
|
|
986
1042
|
await flyRequest({
|
|
987
1043
|
endpoint: `/apps/${args.flyAppName}/machines/${machine.machineId}`,
|
|
988
|
-
token:
|
|
1044
|
+
token: flyApiToken,
|
|
989
1045
|
method: "DELETE",
|
|
990
1046
|
});
|
|
991
1047
|
}
|
|
992
1048
|
if (machine.flyVolumeId) {
|
|
993
1049
|
await flyRequest({
|
|
994
1050
|
endpoint: `/apps/${args.flyAppName}/volumes/${machine.flyVolumeId}`,
|
|
995
|
-
token:
|
|
1051
|
+
token: flyApiToken,
|
|
996
1052
|
method: "DELETE",
|
|
997
1053
|
});
|
|
998
1054
|
}
|
|
@@ -1007,6 +1063,8 @@ export const createAgentSnapshotWithStoredSecrets = action({
|
|
|
1007
1063
|
args: {
|
|
1008
1064
|
machineDocId: v.id("agentMachines"),
|
|
1009
1065
|
flyAppName: v.string(),
|
|
1066
|
+
secretsEncryptionKey: v.string(),
|
|
1067
|
+
flyApiToken: v.optional(v.string()),
|
|
1010
1068
|
},
|
|
1011
1069
|
returns: v.object({
|
|
1012
1070
|
snapshotId: v.id("agentSnapshots"),
|
|
@@ -1022,13 +1080,15 @@ export const createAgentSnapshotWithStoredSecrets = action({
|
|
|
1022
1080
|
const secrets = await getSecretsForAgent(ctx, {
|
|
1023
1081
|
tenantId: machine.tenantId,
|
|
1024
1082
|
userId: machine.userId,
|
|
1083
|
+
secretsEncryptionKey: args.secretsEncryptionKey,
|
|
1025
1084
|
});
|
|
1026
|
-
|
|
1085
|
+
const flyApiToken = optionalValue(secrets?.flyApiToken) ?? optionalValue(args.flyApiToken);
|
|
1086
|
+
if (!flyApiToken) {
|
|
1027
1087
|
throw new Error("Stored flyApiToken not found for this agent");
|
|
1028
1088
|
}
|
|
1029
1089
|
return await createBackupSnapshotForMachine(ctx, {
|
|
1030
1090
|
machineDocId: args.machineDocId,
|
|
1031
|
-
flyApiToken
|
|
1091
|
+
flyApiToken,
|
|
1032
1092
|
flyAppName: args.flyAppName,
|
|
1033
1093
|
});
|
|
1034
1094
|
},
|