@waiaas/daemon 2.10.0-rc.10 → 2.10.0-rc.12
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/api/routes/admin-actions.d.ts +46 -0
- package/dist/api/routes/admin-actions.d.ts.map +1 -0
- package/dist/api/routes/admin-actions.js +317 -0
- package/dist/api/routes/admin-actions.js.map +1 -0
- package/dist/api/routes/admin.js +1 -1
- package/dist/api/routes/admin.js.map +1 -1
- package/dist/api/routes/connect-info.js +1 -1
- package/dist/api/routes/connect-info.js.map +1 -1
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +24 -0
- package/dist/api/server.js.map +1 -1
- package/dist/infrastructure/database/migrate.d.ts +1 -1
- package/dist/infrastructure/database/migrate.d.ts.map +1 -1
- package/dist/infrastructure/database/migrate.js +27 -1
- package/dist/infrastructure/database/migrate.js.map +1 -1
- package/dist/infrastructure/settings/setting-keys.d.ts.map +1 -1
- package/dist/infrastructure/settings/setting-keys.js +6 -4
- package/dist/infrastructure/settings/setting-keys.js.map +1 -1
- package/dist/infrastructure/smart-account/index.d.ts +1 -1
- package/dist/infrastructure/smart-account/index.d.ts.map +1 -1
- package/dist/infrastructure/smart-account/index.js +1 -1
- package/dist/infrastructure/smart-account/index.js.map +1 -1
- package/dist/infrastructure/smart-account/smart-account-clients.d.ts +10 -2
- package/dist/infrastructure/smart-account/smart-account-clients.d.ts.map +1 -1
- package/dist/infrastructure/smart-account/smart-account-clients.js +36 -9
- package/dist/infrastructure/smart-account/smart-account-clients.js.map +1 -1
- package/dist/infrastructure/telegram/telegram-bot-service.js +1 -1
- package/dist/infrastructure/telegram/telegram-bot-service.js.map +1 -1
- package/dist/infrastructure/token-registry/builtin-tokens.d.ts.map +1 -1
- package/dist/infrastructure/token-registry/builtin-tokens.js +3 -0
- package/dist/infrastructure/token-registry/builtin-tokens.js.map +1 -1
- package/dist/lifecycle/daemon.d.ts.map +1 -1
- package/dist/lifecycle/daemon.js +4 -19
- package/dist/lifecycle/daemon.js.map +1 -1
- package/dist/pipeline/stages.d.ts.map +1 -1
- package/dist/pipeline/stages.js +1 -0
- package/dist/pipeline/stages.js.map +1 -1
- package/dist/services/admin-stats-service.js +1 -1
- package/dist/services/admin-stats-service.js.map +1 -1
- package/package.json +5 -5
- package/public/admin/assets/index-CH8-QTAw.js +3 -0
- package/public/admin/index.html +1 -1
- package/public/admin/assets/index-BSDfUSGo.js +0 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin action routes: POST /v1/admin/actions/:provider/:action.
|
|
3
|
+
*
|
|
4
|
+
* Separate from `/v1/actions/*` (sessionAuth) to allow Admin UI (masterAuth)
|
|
5
|
+
* to execute actions directly. Admin context bypasses session_wallets access
|
|
6
|
+
* check since admin has full wallet access.
|
|
7
|
+
*
|
|
8
|
+
* @see #273 — Admin UI ERC-8004 에이전트 등록 시 sessionAuth 인증 실패
|
|
9
|
+
*/
|
|
10
|
+
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
11
|
+
import type { IPolicyEngine } from '@waiaas/core';
|
|
12
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
13
|
+
import type { Database as SQLiteDatabase } from 'better-sqlite3';
|
|
14
|
+
import type { ActionProviderRegistry } from '../../infrastructure/action/action-provider-registry.js';
|
|
15
|
+
import type { AdapterPool } from '../../infrastructure/adapter-pool.js';
|
|
16
|
+
import type { MasterPasswordRef } from '../middleware/master-auth.js';
|
|
17
|
+
import type { DaemonConfig } from '../../infrastructure/config/loader.js';
|
|
18
|
+
import type { LocalKeyStore } from '../../infrastructure/keystore/keystore.js';
|
|
19
|
+
import type * as schema from '../../infrastructure/database/schema.js';
|
|
20
|
+
import type { ApprovalWorkflow } from '../../workflow/approval-workflow.js';
|
|
21
|
+
import type { DelayQueue } from '../../workflow/delay-queue.js';
|
|
22
|
+
import type { NotificationService } from '../../notifications/notification-service.js';
|
|
23
|
+
import type { IPriceOracle } from '@waiaas/core';
|
|
24
|
+
import type { SettingsService } from '../../infrastructure/settings/settings-service.js';
|
|
25
|
+
export interface AdminActionRouteDeps {
|
|
26
|
+
registry: ActionProviderRegistry;
|
|
27
|
+
db: BetterSQLite3Database<typeof schema>;
|
|
28
|
+
adapterPool: AdapterPool;
|
|
29
|
+
config: DaemonConfig;
|
|
30
|
+
keyStore: LocalKeyStore;
|
|
31
|
+
policyEngine: IPolicyEngine;
|
|
32
|
+
masterPassword: string;
|
|
33
|
+
passwordRef?: MasterPasswordRef;
|
|
34
|
+
approvalWorkflow?: ApprovalWorkflow;
|
|
35
|
+
delayQueue?: DelayQueue;
|
|
36
|
+
sqlite?: SQLiteDatabase;
|
|
37
|
+
notificationService?: NotificationService;
|
|
38
|
+
priceOracle?: IPriceOracle;
|
|
39
|
+
settingsService: SettingsService;
|
|
40
|
+
wcSigningBridgeRef?: import('../../services/wc-signing-bridge.js').WcSigningBridgeRef;
|
|
41
|
+
approvalChannelRouter?: import('../../services/signing-sdk/approval-channel-router.js').ApprovalChannelRouter;
|
|
42
|
+
eventBus?: import('@waiaas/core').EventBus;
|
|
43
|
+
reputationCache?: import('../../services/erc8004/reputation-cache-service.js').ReputationCacheService;
|
|
44
|
+
}
|
|
45
|
+
export declare function adminActionRoutes(deps: AdminActionRouteDeps): OpenAPIHono;
|
|
46
|
+
//# sourceMappingURL=admin-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-actions.d.ts","sourceRoot":"","sources":["../../../src/api/routes/admin-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAGhE,OAAO,KAAK,EAA2C,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,gBA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IACtF,qBAAqB,CAAC,EAAE,OAAO,uDAAuD,EAAE,qBAAqB,CAAC;IAC9G,QAAQ,CAAC,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;IAC3C,eAAe,CAAC,EAAE,OAAO,oDAAoD,EAAE,sBAAsB,CAAC;CACvG;AA6ED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,oBAAoB,GAAG,WAAW,CA4RzE"}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin action routes: POST /v1/admin/actions/:provider/:action.
|
|
3
|
+
*
|
|
4
|
+
* Separate from `/v1/actions/*` (sessionAuth) to allow Admin UI (masterAuth)
|
|
5
|
+
* to execute actions directly. Admin context bypasses session_wallets access
|
|
6
|
+
* check since admin has full wallet access.
|
|
7
|
+
*
|
|
8
|
+
* @see #273 — Admin UI ERC-8004 에이전트 등록 시 sessionAuth 인증 실패
|
|
9
|
+
*/
|
|
10
|
+
import { OpenAPIHono, createRoute, z } from '@hono/zod-openapi';
|
|
11
|
+
import { eq } from 'drizzle-orm';
|
|
12
|
+
import { WAIaaSError } from '@waiaas/core';
|
|
13
|
+
import { resolveRpcUrl } from '../../infrastructure/adapter-pool.js';
|
|
14
|
+
import { wallets, transactions } from '../../infrastructure/database/schema.js';
|
|
15
|
+
import { stage1Validate, stage2Auth, stage3Policy, stage3_5GasCondition, stage4Wait, stage5Execute, stage6Confirm, getRequestTo, } from '../../pipeline/stages.js';
|
|
16
|
+
import { resolveNetwork } from '../../pipeline/network-resolver.js';
|
|
17
|
+
import { TxSendResponseSchema, buildErrorResponses, openApiValidationHook, } from './openapi-schemas.js';
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Schemas
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
const AdminActionExecuteRequestSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
params: z.record(z.unknown()).optional().default({}),
|
|
24
|
+
network: z.string().optional(),
|
|
25
|
+
walletId: z.string().uuid().describe('Target wallet ID (required for admin context)'),
|
|
26
|
+
})
|
|
27
|
+
.openapi('AdminActionExecuteRequest');
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Route definitions
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
const adminExecuteActionRoute = createRoute({
|
|
32
|
+
method: 'post',
|
|
33
|
+
path: '/admin/actions/{provider}/{action}',
|
|
34
|
+
tags: ['Admin', 'Actions'],
|
|
35
|
+
summary: 'Execute an action via provider (admin context)',
|
|
36
|
+
description: 'Admin-only action execution. Bypasses session-based wallet access check. Requires masterAuth.',
|
|
37
|
+
request: {
|
|
38
|
+
params: z.object({
|
|
39
|
+
provider: z.string(),
|
|
40
|
+
action: z.string(),
|
|
41
|
+
}),
|
|
42
|
+
body: {
|
|
43
|
+
content: {
|
|
44
|
+
'application/json': { schema: AdminActionExecuteRequestSchema },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
responses: {
|
|
49
|
+
201: {
|
|
50
|
+
description: 'Action submitted to pipeline',
|
|
51
|
+
content: { 'application/json': { schema: TxSendResponseSchema } },
|
|
52
|
+
},
|
|
53
|
+
...buildErrorResponses([
|
|
54
|
+
'ACTION_NOT_FOUND',
|
|
55
|
+
'API_KEY_REQUIRED',
|
|
56
|
+
'ACTION_VALIDATION_FAILED',
|
|
57
|
+
'ACTION_RESOLVE_FAILED',
|
|
58
|
+
'ACTION_RETURN_INVALID',
|
|
59
|
+
'WALLET_NOT_FOUND',
|
|
60
|
+
]),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// Helper: resolve EVM chainId from network identifier
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
function resolveChainId(network) {
|
|
67
|
+
const CHAIN_IDS = {
|
|
68
|
+
'ethereum-mainnet': 1,
|
|
69
|
+
'ethereum-sepolia': 11155111,
|
|
70
|
+
'ethereum-goerli': 5,
|
|
71
|
+
'polygon-mainnet': 137,
|
|
72
|
+
'polygon-mumbai': 80001,
|
|
73
|
+
'arbitrum-mainnet': 42161,
|
|
74
|
+
'arbitrum-sepolia': 421614,
|
|
75
|
+
'optimism-mainnet': 10,
|
|
76
|
+
'optimism-sepolia': 11155420,
|
|
77
|
+
'base-mainnet': 8453,
|
|
78
|
+
'base-sepolia': 84532,
|
|
79
|
+
};
|
|
80
|
+
return CHAIN_IDS[network] ?? 1;
|
|
81
|
+
}
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Route factory
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
export function adminActionRoutes(deps) {
|
|
86
|
+
const router = new OpenAPIHono({ defaultHook: openApiValidationHook });
|
|
87
|
+
router.openapi(adminExecuteActionRoute, async (c) => {
|
|
88
|
+
const { provider, action } = c.req.valid('param');
|
|
89
|
+
const body = c.req.valid('json');
|
|
90
|
+
const actionKey = `${provider}/${action}`;
|
|
91
|
+
// 1. Look up action entry
|
|
92
|
+
const entry = deps.registry.getAction(actionKey);
|
|
93
|
+
if (!entry) {
|
|
94
|
+
throw new WAIaaSError('ACTION_NOT_FOUND', {
|
|
95
|
+
message: `Action '${actionKey}' not found`,
|
|
96
|
+
details: { provider, action },
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
// 2. Admin context: walletId is required from body (no session resolution)
|
|
100
|
+
const walletId = body.walletId;
|
|
101
|
+
// 3. Check API key requirement
|
|
102
|
+
if (entry.provider.metadata.requiresApiKey) {
|
|
103
|
+
if (!deps.settingsService.hasApiKey(entry.provider.metadata.name)) {
|
|
104
|
+
throw new WAIaaSError('API_KEY_REQUIRED', {
|
|
105
|
+
message: `Admin > Settings에서 ${entry.provider.metadata.name} API 키를 설정하세요`,
|
|
106
|
+
details: { provider: entry.provider.metadata.name },
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// 4. Look up wallet
|
|
111
|
+
const wallet = await deps.db.select().from(wallets).where(eq(wallets.id, walletId)).get();
|
|
112
|
+
if (!wallet) {
|
|
113
|
+
throw new WAIaaSError('WALLET_NOT_FOUND', {
|
|
114
|
+
message: `Wallet '${walletId}' not found`,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (wallet.status === 'TERMINATED') {
|
|
118
|
+
throw new WAIaaSError('WALLET_TERMINATED');
|
|
119
|
+
}
|
|
120
|
+
// 5. Build ActionContext (sessionId is null for admin context)
|
|
121
|
+
const actionContext = {
|
|
122
|
+
walletAddress: wallet.publicKey,
|
|
123
|
+
chain: wallet.chain,
|
|
124
|
+
walletId,
|
|
125
|
+
sessionId: undefined,
|
|
126
|
+
};
|
|
127
|
+
// 6. Execute resolve via registry
|
|
128
|
+
let contractCalls;
|
|
129
|
+
try {
|
|
130
|
+
contractCalls = await deps.registry.executeResolve(actionKey, body.params ?? {}, actionContext);
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
if (err instanceof WAIaaSError)
|
|
134
|
+
throw err;
|
|
135
|
+
throw new WAIaaSError('ACTION_RESOLVE_FAILED', {
|
|
136
|
+
message: `Action resolve failed: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
|
137
|
+
details: { actionKey },
|
|
138
|
+
cause: err instanceof Error ? err : undefined,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// 7. Resolve network
|
|
142
|
+
let resolvedNetwork;
|
|
143
|
+
try {
|
|
144
|
+
resolvedNetwork = resolveNetwork(body.network, wallet.environment, wallet.chain);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
if (err instanceof Error && err.message.includes('environment')) {
|
|
148
|
+
throw new WAIaaSError('ENVIRONMENT_NETWORK_MISMATCH', {
|
|
149
|
+
message: err.message,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
throw new WAIaaSError('ACTION_VALIDATION_FAILED', {
|
|
153
|
+
message: err instanceof Error ? err.message : 'Network validation failed',
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
// 8. Resolve adapter from pool
|
|
157
|
+
const rpcUrl = resolveRpcUrl(deps.config.rpc, wallet.chain, resolvedNetwork);
|
|
158
|
+
const adapter = await deps.adapterPool.resolve(wallet.chain, resolvedNetwork, rpcUrl);
|
|
159
|
+
// 9. Pipeline execution
|
|
160
|
+
const walletData = {
|
|
161
|
+
publicKey: wallet.publicKey,
|
|
162
|
+
chain: wallet.chain,
|
|
163
|
+
environment: wallet.environment,
|
|
164
|
+
accountType: wallet.accountType,
|
|
165
|
+
aaProvider: wallet.aaProvider,
|
|
166
|
+
aaProviderApiKeyEncrypted: wallet.aaProviderApiKeyEncrypted,
|
|
167
|
+
aaBundlerUrl: wallet.aaBundlerUrl,
|
|
168
|
+
aaPaymasterUrl: wallet.aaPaymasterUrl,
|
|
169
|
+
aaPaymasterPolicyId: wallet.aaPaymasterPolicyId,
|
|
170
|
+
};
|
|
171
|
+
const pipelineConfig = {
|
|
172
|
+
policy_defaults_delay_seconds: deps.config.security.policy_defaults_delay_seconds,
|
|
173
|
+
policy_defaults_approval_timeout: deps.config.security.policy_defaults_approval_timeout,
|
|
174
|
+
};
|
|
175
|
+
const pipelineResults = [];
|
|
176
|
+
for (const contractCall of contractCalls) {
|
|
177
|
+
// Extract EIP-712 metadata from resolve result
|
|
178
|
+
const eip712 = contractCall.eip712;
|
|
179
|
+
let eip712Metadata;
|
|
180
|
+
if (eip712) {
|
|
181
|
+
const ownerAddress = wallet.ownerAddress || '0x0000000000000000000000000000000000000000';
|
|
182
|
+
const typedData = JSON.parse(eip712.typedDataJson);
|
|
183
|
+
typedData.message.owner = ownerAddress;
|
|
184
|
+
typedData.domain.chainId = resolveChainId(resolvedNetwork);
|
|
185
|
+
eip712Metadata = {
|
|
186
|
+
approvalType: 'EIP712',
|
|
187
|
+
typedDataJson: JSON.stringify(typedData),
|
|
188
|
+
agentId: eip712.agentId,
|
|
189
|
+
newWallet: eip712.newWallet,
|
|
190
|
+
deadline: eip712.deadline,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const ctx = {
|
|
194
|
+
db: deps.db,
|
|
195
|
+
adapter,
|
|
196
|
+
keyStore: deps.keyStore,
|
|
197
|
+
policyEngine: deps.policyEngine,
|
|
198
|
+
masterPassword: deps.passwordRef?.password ?? deps.masterPassword,
|
|
199
|
+
walletId,
|
|
200
|
+
wallet: walletData,
|
|
201
|
+
resolvedNetwork,
|
|
202
|
+
resolvedRpcUrl: rpcUrl,
|
|
203
|
+
request: contractCall,
|
|
204
|
+
txId: '',
|
|
205
|
+
sessionId: undefined, // Admin context -- no session
|
|
206
|
+
sqlite: deps.sqlite,
|
|
207
|
+
delayQueue: deps.delayQueue,
|
|
208
|
+
approvalWorkflow: deps.approvalWorkflow,
|
|
209
|
+
config: pipelineConfig,
|
|
210
|
+
notificationService: deps.notificationService,
|
|
211
|
+
priceOracle: deps.priceOracle,
|
|
212
|
+
settingsService: deps.settingsService,
|
|
213
|
+
eip712Metadata,
|
|
214
|
+
wcSigningBridge: deps.wcSigningBridgeRef?.current ?? undefined,
|
|
215
|
+
approvalChannelRouter: deps.approvalChannelRouter,
|
|
216
|
+
eventBus: deps.eventBus,
|
|
217
|
+
actionProviderKey: provider,
|
|
218
|
+
actionName: action,
|
|
219
|
+
actionDefaultTier: entry.action.defaultTier,
|
|
220
|
+
};
|
|
221
|
+
await stage1Validate(ctx);
|
|
222
|
+
// Persist action provider metadata
|
|
223
|
+
const existingTx = await deps.db
|
|
224
|
+
.select({ metadata: transactions.metadata })
|
|
225
|
+
.from(transactions)
|
|
226
|
+
.where(eq(transactions.id, ctx.txId))
|
|
227
|
+
.get();
|
|
228
|
+
const existingMeta = existingTx?.metadata ? JSON.parse(existingTx.metadata) : {};
|
|
229
|
+
await deps.db
|
|
230
|
+
.update(transactions)
|
|
231
|
+
.set({
|
|
232
|
+
metadata: JSON.stringify({ ...existingMeta, provider, action }),
|
|
233
|
+
})
|
|
234
|
+
.where(eq(transactions.id, ctx.txId));
|
|
235
|
+
pipelineResults.push({ id: ctx.txId, status: 'PENDING' });
|
|
236
|
+
// Stages 2-6 run asynchronously
|
|
237
|
+
void (async () => {
|
|
238
|
+
try {
|
|
239
|
+
await stage2Auth(ctx);
|
|
240
|
+
await stage3Policy(ctx);
|
|
241
|
+
await stage3_5GasCondition(ctx);
|
|
242
|
+
await stage4Wait(ctx);
|
|
243
|
+
await stage5Execute(ctx);
|
|
244
|
+
await stage6Confirm(ctx);
|
|
245
|
+
// ERC-8004 notification events
|
|
246
|
+
if (provider === 'erc8004_agent' && deps.notificationService) {
|
|
247
|
+
const params = body.params ?? {};
|
|
248
|
+
const registryAddress = getRequestTo(ctx.request);
|
|
249
|
+
const erc8004NotifMap = {
|
|
250
|
+
register_agent: {
|
|
251
|
+
event: 'AGENT_REGISTERED',
|
|
252
|
+
vars: {
|
|
253
|
+
chainAgentId: String(params.agentId ?? ctx.txId),
|
|
254
|
+
registryAddress,
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
set_agent_wallet: {
|
|
258
|
+
event: 'AGENT_WALLET_LINKED',
|
|
259
|
+
vars: { registryAddress },
|
|
260
|
+
},
|
|
261
|
+
unset_agent_wallet: {
|
|
262
|
+
event: 'AGENT_WALLET_UNLINKED',
|
|
263
|
+
vars: { registryAddress },
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
const notifEntry = erc8004NotifMap[action];
|
|
267
|
+
if (notifEntry) {
|
|
268
|
+
void deps.notificationService.notify(notifEntry.event, walletId, notifEntry.vars, { txId: ctx.txId });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// Invalidate reputation cache after feedback actions
|
|
272
|
+
if (provider === 'erc8004_agent' &&
|
|
273
|
+
(action === 'give_feedback' || action === 'revoke_feedback') &&
|
|
274
|
+
deps.reputationCache) {
|
|
275
|
+
const targetAgentId = String((body.params ?? {}).agentId ?? '');
|
|
276
|
+
if (targetAgentId) {
|
|
277
|
+
deps.reputationCache.invalidate(targetAgentId);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
if (error instanceof WAIaaSError && error.code === 'PIPELINE_HALTED') {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
try {
|
|
286
|
+
const tx = await deps.db
|
|
287
|
+
.select()
|
|
288
|
+
.from(transactions)
|
|
289
|
+
.where(eq(transactions.id, ctx.txId))
|
|
290
|
+
.get();
|
|
291
|
+
if (tx && tx.status !== 'CONFIRMED' && tx.status !== 'FAILED' && tx.status !== 'CANCELLED') {
|
|
292
|
+
const errorMessage = error instanceof Error ? error.message : 'Pipeline execution failed';
|
|
293
|
+
await deps.db
|
|
294
|
+
.update(transactions)
|
|
295
|
+
.set({ status: 'FAILED', error: errorMessage })
|
|
296
|
+
.where(eq(transactions.id, ctx.txId));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
// Swallow DB update errors in background
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
})();
|
|
304
|
+
}
|
|
305
|
+
const lastResult = pipelineResults[pipelineResults.length - 1];
|
|
306
|
+
if (pipelineResults.length === 1) {
|
|
307
|
+
return c.json({ id: lastResult.id, status: lastResult.status }, 201);
|
|
308
|
+
}
|
|
309
|
+
return c.json({
|
|
310
|
+
id: lastResult.id,
|
|
311
|
+
status: lastResult.status,
|
|
312
|
+
pipeline: pipelineResults,
|
|
313
|
+
}, 201);
|
|
314
|
+
});
|
|
315
|
+
return router;
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=admin-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-actions.js","sourceRoot":"","sources":["../../../src/api/routes/admin-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MA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yC;oBAC3C,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;QACP,CAAC;QAED,MAAM,UAAU,GAAG,eAAe,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;QAEhE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,CAAC,IAAI,CACX,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,EAChD,GAAG,CACJ,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,CAAC,IAAI,CACX;YACE,EAAE,EAAE,UAAU,CAAC,EAAE;YACjB,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,QAAQ,EAAE,eAAe;SAC1B,EACD,GAAG,CACJ,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/api/routes/admin.js
CHANGED
|
@@ -805,7 +805,7 @@ export function adminRoutes(deps) {
|
|
|
805
805
|
const activeSessionResult = deps.db
|
|
806
806
|
.select({ count: sql `count(*)` })
|
|
807
807
|
.from(sessions)
|
|
808
|
-
.where(sql `${sessions.revokedAt} IS NULL AND ${sessions.expiresAt} > ${nowSec}`)
|
|
808
|
+
.where(sql `${sessions.revokedAt} IS NULL AND (${sessions.expiresAt} = 0 OR ${sessions.expiresAt} > ${nowSec})`)
|
|
809
809
|
.get();
|
|
810
810
|
const activeSessionCount = activeSessionResult?.count ?? 0;
|
|
811
811
|
// Count policies
|