@senpi/runtime 1.0.95-dev.runtime-phase-2-api.20260505163136 → 1.0.95-dev.runtime-phase-2.20260506193916
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/README.md +0 -13
- package/dist/dsl/events/handlers.d.ts +2 -1
- package/dist/dsl/events/handlers.d.ts.map +1 -1
- package/dist/dsl/events/handlers.js +3 -0
- package/dist/dsl/events/handlers.js.map +1 -1
- package/dist/dsl/plugin/index.d.ts +1 -1
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +90 -161
- package/dist/index.js.map +1 -1
- package/dist/runtime/auto-update/coordinator.d.ts +8 -12
- package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +17 -18
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/runtime/auto-update/gateway-restart.d.ts +2 -9
- package/dist/runtime/auto-update/gateway-restart.d.ts.map +1 -1
- package/dist/runtime/auto-update/gateway-restart.js +13 -23
- package/dist/runtime/auto-update/gateway-restart.js.map +1 -1
- package/dist/runtime/create-actions.d.ts.map +1 -1
- package/dist/runtime/create-actions.js +2 -13
- package/dist/runtime/create-actions.js.map +1 -1
- package/dist/runtime/run.d.ts +1 -47
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +0 -9
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime.d.ts +3 -58
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +7 -172
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/senpi/client.d.ts +2 -92
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +8 -181
- package/dist/senpi/client.js.map +1 -1
- package/dist/tracking/constants.d.ts.map +1 -1
- package/dist/tracking/constants.js +4 -0
- package/dist/tracking/constants.js.map +1 -1
- package/dist/tracking/index.d.ts +1 -0
- package/dist/tracking/index.d.ts.map +1 -1
- package/dist/tracking/index.js +1 -0
- package/dist/tracking/index.js.map +1 -1
- package/dist/tracking/plugin-event-tracker.d.ts +13 -0
- package/dist/tracking/plugin-event-tracker.d.ts.map +1 -0
- package/dist/tracking/plugin-event-tracker.js +27 -0
- package/dist/tracking/plugin-event-tracker.js.map +1 -0
- package/openclaw.plugin.json +0 -24
- package/package.json +2 -6
- package/dist/runtime/audit-query.types.d.ts +0 -113
- package/dist/runtime/audit-query.types.d.ts.map +0 -1
- package/dist/runtime/audit-query.types.js +0 -35
- package/dist/runtime/audit-query.types.js.map +0 -1
- package/dist/runtime-api/config.d.ts +0 -47
- package/dist/runtime-api/config.d.ts.map +0 -1
- package/dist/runtime-api/config.js +0 -74
- package/dist/runtime-api/config.js.map +0 -1
- package/dist/runtime-api/handlers/audit.d.ts +0 -76
- package/dist/runtime-api/handlers/audit.d.ts.map +0 -1
- package/dist/runtime-api/handlers/audit.js +0 -63
- package/dist/runtime-api/handlers/audit.js.map +0 -1
- package/dist/runtime-api/handlers/group-by-scanner.d.ts +0 -43
- package/dist/runtime-api/handlers/group-by-scanner.d.ts.map +0 -1
- package/dist/runtime-api/handlers/group-by-scanner.js +0 -43
- package/dist/runtime-api/handlers/group-by-scanner.js.map +0 -1
- package/dist/runtime-api/handlers/ingest-signals.d.ts +0 -54
- package/dist/runtime-api/handlers/ingest-signals.d.ts.map +0 -1
- package/dist/runtime-api/handlers/ingest-signals.js +0 -134
- package/dist/runtime-api/handlers/ingest-signals.js.map +0 -1
- package/dist/runtime-api/handlers/lookup.d.ts +0 -36
- package/dist/runtime-api/handlers/lookup.d.ts.map +0 -1
- package/dist/runtime-api/handlers/lookup.js +0 -31
- package/dist/runtime-api/handlers/lookup.js.map +0 -1
- package/dist/runtime-api/handlers/types.d.ts +0 -80
- package/dist/runtime-api/handlers/types.d.ts.map +0 -1
- package/dist/runtime-api/handlers/types.js +0 -8
- package/dist/runtime-api/handlers/types.js.map +0 -1
- package/dist/runtime-api/lifecycle.d.ts +0 -98
- package/dist/runtime-api/lifecycle.d.ts.map +0 -1
- package/dist/runtime-api/lifecycle.js +0 -137
- package/dist/runtime-api/lifecycle.js.map +0 -1
- package/dist/runtime-api/readiness.d.ts +0 -37
- package/dist/runtime-api/readiness.d.ts.map +0 -1
- package/dist/runtime-api/readiness.js +0 -35
- package/dist/runtime-api/readiness.js.map +0 -1
- package/dist/runtime-api/routes/audit.d.ts +0 -40
- package/dist/runtime-api/routes/audit.d.ts.map +0 -1
- package/dist/runtime-api/routes/audit.js +0 -82
- package/dist/runtime-api/routes/audit.js.map +0 -1
- package/dist/runtime-api/routes/audit.schema.d.ts +0 -75
- package/dist/runtime-api/routes/audit.schema.d.ts.map +0 -1
- package/dist/runtime-api/routes/audit.schema.js +0 -78
- package/dist/runtime-api/routes/audit.schema.js.map +0 -1
- package/dist/runtime-api/routes/health.d.ts +0 -53
- package/dist/runtime-api/routes/health.d.ts.map +0 -1
- package/dist/runtime-api/routes/health.js +0 -48
- package/dist/runtime-api/routes/health.js.map +0 -1
- package/dist/runtime-api/routes/signals.d.ts +0 -50
- package/dist/runtime-api/routes/signals.d.ts.map +0 -1
- package/dist/runtime-api/routes/signals.js +0 -65
- package/dist/runtime-api/routes/signals.js.map +0 -1
- package/dist/runtime-api/routes/signals.schema.d.ts +0 -94
- package/dist/runtime-api/routes/signals.schema.d.ts.map +0 -1
- package/dist/runtime-api/routes/signals.schema.js +0 -58
- package/dist/runtime-api/routes/signals.schema.js.map +0 -1
- package/dist/runtime-api/server.d.ts +0 -79
- package/dist/runtime-api/server.d.ts.map +0 -1
- package/dist/runtime-api/server.js +0 -105
- package/dist/runtime-api/server.js.map +0 -1
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the `RuntimeHandle.auditQuery` public method.
|
|
3
|
-
*
|
|
4
|
-
* These mirror the MCP `audit_query` tool contract (defined in
|
|
5
|
-
* senpi-hyperliquid-mcp/src/tools/audit.tools.ts) but expressed as plain
|
|
6
|
-
* TypeScript interfaces — Zod stays inside MCP, TypeBox stays inside
|
|
7
|
-
* runtime-api. Anything new added to the MCP zod schema must be reflected
|
|
8
|
-
* here as well.
|
|
9
|
-
*
|
|
10
|
-
* The implementation owns four MCP arguments and silently overrides any
|
|
11
|
-
* caller-supplied values — these are intentionally absent from
|
|
12
|
-
* {@link AuditQueryArgs}:
|
|
13
|
-
* - `resource_type` (always `"strategy"`)
|
|
14
|
-
* - `resource_id` (resolved wallet → strategyId)
|
|
15
|
-
* - `user_ids` (server-controlled — the MCP API key user)
|
|
16
|
-
* - `usernames` (server-controlled — same)
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Caller-controlled subset of MCP `audit_query` parameters.
|
|
20
|
-
*
|
|
21
|
-
* Every field is optional. Field names match the MCP schema verbatim so
|
|
22
|
-
* pass-through to the underlying tool stays drift-free.
|
|
23
|
-
*
|
|
24
|
-
* @see senpi-hyperliquid-mcp/src/tools/audit.tools.ts (`auditQueryInputSchema`)
|
|
25
|
-
*/
|
|
26
|
-
export interface AuditQueryArgs {
|
|
27
|
-
/** Filter by exact tool name (e.g. `create_position`). */
|
|
28
|
-
tool_name?: string;
|
|
29
|
-
/** Filter by action classification. */
|
|
30
|
-
action_type?: "read" | "create" | "update" | "delete";
|
|
31
|
-
/** Filter by success/failure. */
|
|
32
|
-
success?: boolean;
|
|
33
|
-
/** ISO 8601 inclusive lower bound on `requested_at`. */
|
|
34
|
-
start_time?: string;
|
|
35
|
-
/** ISO 8601 inclusive upper bound on `requested_at`. */
|
|
36
|
-
end_time?: string;
|
|
37
|
-
/** Minimum end-to-end duration in ms (find slow operations). */
|
|
38
|
-
min_duration_ms?: number;
|
|
39
|
-
/** Maximum end-to-end duration in ms (find fast operations). */
|
|
40
|
-
max_duration_ms?: number;
|
|
41
|
-
/** Page size; MCP defaults to 100, max 1000. */
|
|
42
|
-
limit?: number;
|
|
43
|
-
/** Offset-based pagination skip count; MCP default 0. */
|
|
44
|
-
offset?: number;
|
|
45
|
-
/** Cursor timestamp for keyset pagination (must pair with `cursor_id`). */
|
|
46
|
-
cursor_requested_at?: string;
|
|
47
|
-
/** Cursor id (UUID) for keyset pagination (must pair with `cursor_requested_at`). */
|
|
48
|
-
cursor_id?: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Single audit-log entry as returned by MCP `audit_query`.
|
|
52
|
-
*
|
|
53
|
-
* @see senpi-hyperliquid-mcp/src/tools/audit.tools.ts (JSDoc on `handleAuditQuery`)
|
|
54
|
-
*/
|
|
55
|
-
export interface AuditEntry {
|
|
56
|
-
/** Unique audit-entry identifier. */
|
|
57
|
-
id: string;
|
|
58
|
-
/** Request identifier; correlates to MCP request id. */
|
|
59
|
-
request_id: string;
|
|
60
|
-
/** When the tool was invoked (ISO 8601). */
|
|
61
|
-
timestamp: string;
|
|
62
|
-
/** When execution finished (ISO 8601); may be absent on in-flight or partial entries. */
|
|
63
|
-
completed_at: string | null;
|
|
64
|
-
/** End-to-end execution time in milliseconds, including downstream latency. */
|
|
65
|
-
duration_ms: number | null;
|
|
66
|
-
/** Authenticated Senpi user id who performed the action. */
|
|
67
|
-
user_id: string;
|
|
68
|
-
/** Exact tool name invoked. */
|
|
69
|
-
tool: string;
|
|
70
|
-
/** Action classification. */
|
|
71
|
-
action_type: "read" | "create" | "update" | "delete";
|
|
72
|
-
/** AI-generated reasoning string; null for read tools. */
|
|
73
|
-
ai_reasoning: string | null;
|
|
74
|
-
/** Boolean indicating successful completion. */
|
|
75
|
-
success: boolean;
|
|
76
|
-
/** Error code when `success === false`. */
|
|
77
|
-
error_code: string | null;
|
|
78
|
-
/** Failure details when `success === false`. */
|
|
79
|
-
error_message: string | null;
|
|
80
|
-
/** Resources touched by the action (each `{ type, id }`). */
|
|
81
|
-
affected_resources: Array<{
|
|
82
|
-
type: string;
|
|
83
|
-
id: string;
|
|
84
|
-
}>;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Pass-through MCP `audit_query` response payload (the `.data` portion of
|
|
88
|
-
* the MCP envelope, after `unwrapEnvelope` strips `success`/`meta`).
|
|
89
|
-
*/
|
|
90
|
-
export interface AuditQueryResult {
|
|
91
|
-
/** Audit entries on the current page. */
|
|
92
|
-
entries: AuditEntry[];
|
|
93
|
-
/** Number of entries on the current page. */
|
|
94
|
-
count: number;
|
|
95
|
-
/** Approximate total matching entries (exact for small sets). */
|
|
96
|
-
total: number;
|
|
97
|
-
/** Whether further results exist beyond the current page. */
|
|
98
|
-
has_more: boolean;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Discriminated error class thrown by {@link RuntimeHandle.auditQuery}.
|
|
102
|
-
*
|
|
103
|
-
* Codes:
|
|
104
|
-
* - `NOT_FOUND` — `listStrategies` returned 0 matches for the runtime's
|
|
105
|
-
* wallet (the wallet does not belong to the API-key user).
|
|
106
|
-
* - `UPSTREAM` — MCP returned an error (network, auth, schema).
|
|
107
|
-
* - `ABORTED` — caller aborted via `opts.signal` before MCP responded.
|
|
108
|
-
*/
|
|
109
|
-
export declare class AuditQueryError extends Error {
|
|
110
|
-
readonly code: "NOT_FOUND" | "UPSTREAM" | "ABORTED";
|
|
111
|
-
constructor(code: "NOT_FOUND" | "UPSTREAM" | "ABORTED", message: string);
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=audit-query.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit-query.types.d.ts","sourceRoot":"","sources":["../../src/runtime/audit-query.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACtD,iCAAiC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,+EAA+E;IAC/E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACrD,0DAA0D;IAC1D,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,6DAA6D;IAC7D,kBAAkB,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzD;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;gBAE/C,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM;CAKxE"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the `RuntimeHandle.auditQuery` public method.
|
|
3
|
-
*
|
|
4
|
-
* These mirror the MCP `audit_query` tool contract (defined in
|
|
5
|
-
* senpi-hyperliquid-mcp/src/tools/audit.tools.ts) but expressed as plain
|
|
6
|
-
* TypeScript interfaces — Zod stays inside MCP, TypeBox stays inside
|
|
7
|
-
* runtime-api. Anything new added to the MCP zod schema must be reflected
|
|
8
|
-
* here as well.
|
|
9
|
-
*
|
|
10
|
-
* The implementation owns four MCP arguments and silently overrides any
|
|
11
|
-
* caller-supplied values — these are intentionally absent from
|
|
12
|
-
* {@link AuditQueryArgs}:
|
|
13
|
-
* - `resource_type` (always `"strategy"`)
|
|
14
|
-
* - `resource_id` (resolved wallet → strategyId)
|
|
15
|
-
* - `user_ids` (server-controlled — the MCP API key user)
|
|
16
|
-
* - `usernames` (server-controlled — same)
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Discriminated error class thrown by {@link RuntimeHandle.auditQuery}.
|
|
20
|
-
*
|
|
21
|
-
* Codes:
|
|
22
|
-
* - `NOT_FOUND` — `listStrategies` returned 0 matches for the runtime's
|
|
23
|
-
* wallet (the wallet does not belong to the API-key user).
|
|
24
|
-
* - `UPSTREAM` — MCP returned an error (network, auth, schema).
|
|
25
|
-
* - `ABORTED` — caller aborted via `opts.signal` before MCP responded.
|
|
26
|
-
*/
|
|
27
|
-
export class AuditQueryError extends Error {
|
|
28
|
-
code;
|
|
29
|
-
constructor(code, message) {
|
|
30
|
-
super(message);
|
|
31
|
-
this.name = "AuditQueryError";
|
|
32
|
-
this.code = code;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=audit-query.types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit-query.types.js","sourceRoot":"","sources":["../../src/runtime/audit-query.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAoFH;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxB,IAAI,CAAuC;IAE3D,YAAY,IAA0C,EAAE,OAAe;QACrE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeBox schema and loader for the `api` block in the openclaw plugin config.
|
|
3
|
-
*
|
|
4
|
-
* The `api` block is an optional top-level property inside `openclaw.json`
|
|
5
|
-
* `plugins[*].config`. If the operator omits it entirely — or omits individual
|
|
6
|
-
* fields — this module fills in the documented defaults so the rest of the
|
|
7
|
-
* runtime-api code can rely on a fully-typed, always-present value.
|
|
8
|
-
*/
|
|
9
|
-
import { type Static } from "@sinclair/typebox";
|
|
10
|
-
/** TypeBox schema for the `api` config block. Mirrors openclaw.plugin.json. */
|
|
11
|
-
export declare const ApiConfigSchema: import("@sinclair/typebox").TObject<{
|
|
12
|
-
/**
|
|
13
|
-
* Bind interface for the HTTP server inside the openclaw container.
|
|
14
|
-
* Default `127.0.0.1` — container loopback only (most secure).
|
|
15
|
-
* Set to `0.0.0.0` to enable Docker port mapping for Postman testing.
|
|
16
|
-
* A boot-time warning is logged when this is not `127.0.0.1`.
|
|
17
|
-
*/
|
|
18
|
-
host: import("@sinclair/typebox").TString;
|
|
19
|
-
/**
|
|
20
|
-
* TCP port the HTTP server listens on.
|
|
21
|
-
* Default `8787`. Must be in [1, 65535].
|
|
22
|
-
*/
|
|
23
|
-
port: import("@sinclair/typebox").TInteger;
|
|
24
|
-
/**
|
|
25
|
-
* Maximum number of items allowed in a single `POST /signals` request body.
|
|
26
|
-
* Conservative default of `10` — operators raise it deliberately when
|
|
27
|
-
* broadcasting to many wallets at once.
|
|
28
|
-
*/
|
|
29
|
-
maxItemsPerSignalsRequest: import("@sinclair/typebox").TInteger;
|
|
30
|
-
}>;
|
|
31
|
-
/** Typed `api` config block derived from the TypeBox schema. */
|
|
32
|
-
export type ApiConfig = Static<typeof ApiConfigSchema>;
|
|
33
|
-
/**
|
|
34
|
-
* Load and validate the `api` config block from the full plugin config object.
|
|
35
|
-
*
|
|
36
|
-
* Merges operator-supplied values over the defaults, then validates the result
|
|
37
|
-
* against {@link ApiConfigSchema}. Throws if any field is out of range or the
|
|
38
|
-
* wrong type (e.g. a port value of 99999).
|
|
39
|
-
*
|
|
40
|
-
* @param pluginConfig - The entire plugin config object as passed by openclaw to
|
|
41
|
-
* `register(api)`. May be `undefined`, `null`, or a plain object. The function
|
|
42
|
-
* reads only the `api` sub-key; all other keys are ignored.
|
|
43
|
-
* @returns A fully-typed {@link ApiConfig} with all defaults applied.
|
|
44
|
-
* @throws {Error} If the merged config fails TypeBox validation (e.g. port out of range).
|
|
45
|
-
*/
|
|
46
|
-
export declare function loadApiConfig(pluginConfig: unknown): ApiConfig;
|
|
47
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/runtime-api/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGtD,+EAA+E;AAC/E,eAAO,MAAM,eAAe;IAExB;;;;;OAKG;;IAGH;;;OAGG;;IAGH;;;;OAIG;;EAQN,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AASvD;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,OAAO,GAAG,SAAS,CAsB9D"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeBox schema and loader for the `api` block in the openclaw plugin config.
|
|
3
|
-
*
|
|
4
|
-
* The `api` block is an optional top-level property inside `openclaw.json`
|
|
5
|
-
* `plugins[*].config`. If the operator omits it entirely — or omits individual
|
|
6
|
-
* fields — this module fills in the documented defaults so the rest of the
|
|
7
|
-
* runtime-api code can rely on a fully-typed, always-present value.
|
|
8
|
-
*/
|
|
9
|
-
import { Type } from "@sinclair/typebox";
|
|
10
|
-
import { Value } from "@sinclair/typebox/value";
|
|
11
|
-
/** TypeBox schema for the `api` config block. Mirrors openclaw.plugin.json. */
|
|
12
|
-
export const ApiConfigSchema = Type.Object({
|
|
13
|
-
/**
|
|
14
|
-
* Bind interface for the HTTP server inside the openclaw container.
|
|
15
|
-
* Default `127.0.0.1` — container loopback only (most secure).
|
|
16
|
-
* Set to `0.0.0.0` to enable Docker port mapping for Postman testing.
|
|
17
|
-
* A boot-time warning is logged when this is not `127.0.0.1`.
|
|
18
|
-
*/
|
|
19
|
-
host: Type.String({ default: "127.0.0.1" }),
|
|
20
|
-
/**
|
|
21
|
-
* TCP port the HTTP server listens on.
|
|
22
|
-
* Default `8787`. Must be in [1, 65535].
|
|
23
|
-
*/
|
|
24
|
-
port: Type.Integer({ minimum: 1, maximum: 65535, default: 8787 }),
|
|
25
|
-
/**
|
|
26
|
-
* Maximum number of items allowed in a single `POST /signals` request body.
|
|
27
|
-
* Conservative default of `10` — operators raise it deliberately when
|
|
28
|
-
* broadcasting to many wallets at once.
|
|
29
|
-
*/
|
|
30
|
-
maxItemsPerSignalsRequest: Type.Integer({
|
|
31
|
-
minimum: 1,
|
|
32
|
-
maximum: 1000,
|
|
33
|
-
default: 10,
|
|
34
|
-
}),
|
|
35
|
-
}, { additionalProperties: false });
|
|
36
|
-
/** Default values applied when the operator omits the `api` block or individual fields. */
|
|
37
|
-
const API_CONFIG_DEFAULTS = {
|
|
38
|
-
host: "127.0.0.1",
|
|
39
|
-
port: 8787,
|
|
40
|
-
maxItemsPerSignalsRequest: 10,
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Load and validate the `api` config block from the full plugin config object.
|
|
44
|
-
*
|
|
45
|
-
* Merges operator-supplied values over the defaults, then validates the result
|
|
46
|
-
* against {@link ApiConfigSchema}. Throws if any field is out of range or the
|
|
47
|
-
* wrong type (e.g. a port value of 99999).
|
|
48
|
-
*
|
|
49
|
-
* @param pluginConfig - The entire plugin config object as passed by openclaw to
|
|
50
|
-
* `register(api)`. May be `undefined`, `null`, or a plain object. The function
|
|
51
|
-
* reads only the `api` sub-key; all other keys are ignored.
|
|
52
|
-
* @returns A fully-typed {@link ApiConfig} with all defaults applied.
|
|
53
|
-
* @throws {Error} If the merged config fails TypeBox validation (e.g. port out of range).
|
|
54
|
-
*/
|
|
55
|
-
export function loadApiConfig(pluginConfig) {
|
|
56
|
-
const raw = pluginConfig !== null &&
|
|
57
|
-
typeof pluginConfig === "object" &&
|
|
58
|
-
"api" in pluginConfig
|
|
59
|
-
? pluginConfig["api"]
|
|
60
|
-
: undefined;
|
|
61
|
-
const merged = {
|
|
62
|
-
...API_CONFIG_DEFAULTS,
|
|
63
|
-
...(raw !== null && typeof raw === "object" ? raw : {}),
|
|
64
|
-
};
|
|
65
|
-
if (!Value.Check(ApiConfigSchema, merged)) {
|
|
66
|
-
const firstError = Value.Errors(ApiConfigSchema, merged).First();
|
|
67
|
-
const detail = firstError
|
|
68
|
-
? `${firstError.path}: ${firstError.message}`
|
|
69
|
-
: "unknown validation error";
|
|
70
|
-
throw new Error(`Invalid runtime api config — ${detail}`);
|
|
71
|
-
}
|
|
72
|
-
return merged;
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/runtime-api/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CACxC;IACE;;;;;OAKG;IACH,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAE3C;;;OAGG;IACH,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAEjE;;;;OAIG;IACH,yBAAyB,EAAE,IAAI,CAAC,OAAO,CAAC;QACtC,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,EAAE;KACZ,CAAC;CACH,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAChC,CAAC;AAKF,2FAA2F;AAC3F,MAAM,mBAAmB,GAAc;IACrC,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,IAAI;IACV,yBAAyB,EAAE,EAAE;CAC9B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,YAAqB;IACjD,MAAM,GAAG,GACP,YAAY,KAAK,IAAI;QACrB,OAAO,YAAY,KAAK,QAAQ;QAChC,KAAK,IAAK,YAAwC;QAChD,CAAC,CAAE,YAAwC,CAAC,KAAK,CAAC;QAClD,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,MAAM,GAAc;QACxB,GAAG,mBAAmB;QACtB,GAAG,CAAC,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAE,GAA0B,CAAC,CAAC,CAAC,EAAE,CAAC;KAChF,CAAC;IAEF,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,EAAE,MAAM,CAAC,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;QACjE,MAAM,MAAM,GAAG,UAAU;YACvB,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE;YAC7C,CAAC,CAAC,0BAA0B,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared audit handler for `GET /audit`.
|
|
3
|
-
*
|
|
4
|
-
* Delegates to `RuntimeHandle.auditQuery` and translates `AuditQueryError`
|
|
5
|
-
* codes into the HTTP-layer result shape. Called by the Fastify route (S4).
|
|
6
|
-
*
|
|
7
|
-
* Note: this handler uses `ok` (not `success`) because it is a single-resource
|
|
8
|
-
* response, not a per-item fan-out array. Keep `ok` and `success` distinct —
|
|
9
|
-
* the `POST /signals` shape uses `success` (Section 5 plan).
|
|
10
|
-
*/
|
|
11
|
-
import type { AuditQueryArgs, AuditQueryResult } from "../../runtime/audit-query.types.js";
|
|
12
|
-
import type { RuntimeHandle } from "../../runtime/run.js";
|
|
13
|
-
import type { Logger } from "../../utils/logger.js";
|
|
14
|
-
/**
|
|
15
|
-
* Dependencies injected into {@link auditHandler}.
|
|
16
|
-
*/
|
|
17
|
-
export interface AuditDeps {
|
|
18
|
-
/** Live runtime handles maintained by the plugin. */
|
|
19
|
-
runtimeHandles: Map<string, RuntimeHandle>;
|
|
20
|
-
/** Logger instance — unexpected errors logged at `error` level. */
|
|
21
|
-
logger: Logger;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Result returned by {@link auditHandler}.
|
|
25
|
-
*
|
|
26
|
-
* Discriminated on `ok`:
|
|
27
|
-
* - `true` → audit query succeeded; `address`, `strategyId`, and `result` are present.
|
|
28
|
-
* - `false` → failure; `code` is one of `NOT_FOUND | UPSTREAM | ABORTED`.
|
|
29
|
-
*
|
|
30
|
-
* `NOT_FOUND` — no running runtime for the given address, or `listStrategies`
|
|
31
|
-
* returned 0 matches (wallet not owned by the API-key user).
|
|
32
|
-
* `UPSTREAM` — MCP returned an error (network, auth, schema mismatch, runtime
|
|
33
|
-
* not started).
|
|
34
|
-
* `ABORTED` — caller cancelled via `AbortSignal` before MCP responded.
|
|
35
|
-
*/
|
|
36
|
-
export type AuditHandlerResult = {
|
|
37
|
-
ok: true;
|
|
38
|
-
/** Lowercased wallet address. */
|
|
39
|
-
address: string;
|
|
40
|
-
/**
|
|
41
|
-
* Strategy UUID resolved from the wallet by `listStrategies`.
|
|
42
|
-
* May be `null` on the first successful call in the unlikely window
|
|
43
|
-
* between `auditQuery` resolving and `getStrategyId()` being read —
|
|
44
|
-
* in practice the cache is populated synchronously before the
|
|
45
|
-
* Promise resolves.
|
|
46
|
-
*/
|
|
47
|
-
strategyId: string | null;
|
|
48
|
-
/** Pass-through `audit_query` response payload. */
|
|
49
|
-
result: AuditQueryResult;
|
|
50
|
-
} | {
|
|
51
|
-
ok: false;
|
|
52
|
-
code: "NOT_FOUND" | "UPSTREAM" | "ABORTED";
|
|
53
|
-
message: string;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Execute an audit query for one wallet via its runtime handle.
|
|
57
|
-
*
|
|
58
|
-
* Steps:
|
|
59
|
-
* 1. Resolve the runtime handle by `address` (case-insensitive lookup).
|
|
60
|
-
* Returns `NOT_FOUND` on miss.
|
|
61
|
-
* 2. Call `handle.auditQuery(args, { signal })`.
|
|
62
|
-
* 3. Read `handle.getStrategyId()` after a successful call — the id is cached
|
|
63
|
-
* on the runtime instance from step 2's `listStrategies` resolution.
|
|
64
|
-
* 4. On `AuditQueryError`: map `code` straight through to the result.
|
|
65
|
-
* 5. On any other throw: log + return `UPSTREAM`.
|
|
66
|
-
*
|
|
67
|
-
* @param address Wallet address to audit (normalised to lowercase internally).
|
|
68
|
-
* @param args Audit query filters forwarded to `RuntimeHandle.auditQuery`.
|
|
69
|
-
* @param deps Injected dependencies.
|
|
70
|
-
* @param signal Optional `AbortSignal` tied to the Fastify request lifetime.
|
|
71
|
-
* Threads through to the underlying MCP call so the runtime
|
|
72
|
-
* can cancel in-flight work when the HTTP client disconnects.
|
|
73
|
-
* @returns A resolved `AuditHandlerResult` — never rejects.
|
|
74
|
-
*/
|
|
75
|
-
export declare function auditHandler(address: string, args: AuditQueryArgs, deps: AuditDeps, signal?: AbortSignal): Promise<AuditHandlerResult>;
|
|
76
|
-
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../../src/runtime-api/handlers/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,qDAAqD;IACrD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3C,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IACE,EAAE,EAAE,IAAI,CAAC;IACT,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,mDAAmD;IACnD,MAAM,EAAE,gBAAgB,CAAC;CAC1B,GACD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,SAAS,EACf,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,kBAAkB,CAAC,CAsC7B"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared audit handler for `GET /audit`.
|
|
3
|
-
*
|
|
4
|
-
* Delegates to `RuntimeHandle.auditQuery` and translates `AuditQueryError`
|
|
5
|
-
* codes into the HTTP-layer result shape. Called by the Fastify route (S4).
|
|
6
|
-
*
|
|
7
|
-
* Note: this handler uses `ok` (not `success`) because it is a single-resource
|
|
8
|
-
* response, not a per-item fan-out array. Keep `ok` and `success` distinct —
|
|
9
|
-
* the `POST /signals` shape uses `success` (Section 5 plan).
|
|
10
|
-
*/
|
|
11
|
-
import { findRuntimeHandleByAddress } from "./lookup.js";
|
|
12
|
-
import { AuditQueryError } from "../../runtime/audit-query.types.js";
|
|
13
|
-
/**
|
|
14
|
-
* Execute an audit query for one wallet via its runtime handle.
|
|
15
|
-
*
|
|
16
|
-
* Steps:
|
|
17
|
-
* 1. Resolve the runtime handle by `address` (case-insensitive lookup).
|
|
18
|
-
* Returns `NOT_FOUND` on miss.
|
|
19
|
-
* 2. Call `handle.auditQuery(args, { signal })`.
|
|
20
|
-
* 3. Read `handle.getStrategyId()` after a successful call — the id is cached
|
|
21
|
-
* on the runtime instance from step 2's `listStrategies` resolution.
|
|
22
|
-
* 4. On `AuditQueryError`: map `code` straight through to the result.
|
|
23
|
-
* 5. On any other throw: log + return `UPSTREAM`.
|
|
24
|
-
*
|
|
25
|
-
* @param address Wallet address to audit (normalised to lowercase internally).
|
|
26
|
-
* @param args Audit query filters forwarded to `RuntimeHandle.auditQuery`.
|
|
27
|
-
* @param deps Injected dependencies.
|
|
28
|
-
* @param signal Optional `AbortSignal` tied to the Fastify request lifetime.
|
|
29
|
-
* Threads through to the underlying MCP call so the runtime
|
|
30
|
-
* can cancel in-flight work when the HTTP client disconnects.
|
|
31
|
-
* @returns A resolved `AuditHandlerResult` — never rejects.
|
|
32
|
-
*/
|
|
33
|
-
export async function auditHandler(address, args, deps, signal) {
|
|
34
|
-
const normalizedAddress = address.toLowerCase();
|
|
35
|
-
const lookup = findRuntimeHandleByAddress(deps.runtimeHandles, normalizedAddress);
|
|
36
|
-
if (!lookup.found) {
|
|
37
|
-
return { ok: false, code: "NOT_FOUND", message: lookup.message };
|
|
38
|
-
}
|
|
39
|
-
const { handle } = lookup;
|
|
40
|
-
try {
|
|
41
|
-
const result = await handle.auditQuery(args, { signal });
|
|
42
|
-
// getStrategyId() is synchronous — the cache is populated by auditQuery
|
|
43
|
-
// before the awaited Promise resolves, so this is always set on success.
|
|
44
|
-
const strategyId = handle.getStrategyId();
|
|
45
|
-
return {
|
|
46
|
-
ok: true,
|
|
47
|
-
address: normalizedAddress,
|
|
48
|
-
strategyId,
|
|
49
|
-
result,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
if (err instanceof AuditQueryError) {
|
|
54
|
-
return { ok: false, code: err.code, message: err.message };
|
|
55
|
-
}
|
|
56
|
-
const message = err instanceof Error
|
|
57
|
-
? err.message
|
|
58
|
-
: `Unexpected audit error: ${String(err)}`;
|
|
59
|
-
deps.logger.error("[senpi-core][runtime-api][audit] Unexpected error during audit query", { address: normalizedAddress, err });
|
|
60
|
-
return { ok: false, code: "UPSTREAM", message };
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=audit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../src/runtime-api/handlers/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAqDrE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAe,EACf,IAAoB,EACpB,IAAe,EACf,MAAoB;IAEpB,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAEhD,MAAM,MAAM,GAAG,0BAA0B,CAAC,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;IAClF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IACnE,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAE1B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAEzD,wEAAwE;QACxE,yEAAyE;QACzE,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QAE1C,OAAO;YACL,EAAE,EAAE,IAAI;YACR,OAAO,EAAE,iBAAiB;YAC1B,UAAU;YACV,MAAM;SACP,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,eAAe,EAAE,CAAC;YACnC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QAC7D,CAAC;QAED,MAAM,OAAO,GACX,GAAG,YAAY,KAAK;YAClB,CAAC,CAAC,GAAG,CAAC,OAAO;YACb,CAAC,CAAC,2BAA2B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,sEAAsE,EACtE,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAE,CACpC,CAAC;QACF,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;IAClD,CAAC;AACH,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure helper that groups a flat `SignalItem[]` by `(address, scanner)` so
|
|
3
|
-
* the route handler can fan-out groups in parallel while keeping items within
|
|
4
|
-
* a group sequential — dodging the per-(address, scanner) ingest lock held by
|
|
5
|
-
* `ScannerEngine` during async ingest
|
|
6
|
-
* (`src/scanners/engine/engine.ts:282-287`).
|
|
7
|
-
*/
|
|
8
|
-
import type { SignalItem } from "./types.js";
|
|
9
|
-
/**
|
|
10
|
-
* A `SignalItem` paired with its original zero-based index in the input array.
|
|
11
|
-
* The index is used to re-flatten grouped results back into the caller's
|
|
12
|
-
* requested order after `Promise.all` group settlement.
|
|
13
|
-
*/
|
|
14
|
-
export interface IndexedSignalItem {
|
|
15
|
-
/** Zero-based position in the original input array. */
|
|
16
|
-
index: number;
|
|
17
|
-
/** The original signal item. */
|
|
18
|
-
item: SignalItem;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* A sequence of items that share the same `(lowercased address, scanner)` key
|
|
22
|
-
* and must be processed sequentially to avoid the per-(address, scanner) lock.
|
|
23
|
-
*/
|
|
24
|
-
export type SignalGroup = IndexedSignalItem[];
|
|
25
|
-
/**
|
|
26
|
-
* Group signal items by `(lowercased address, scanner)`.
|
|
27
|
-
*
|
|
28
|
-
* Items within a group must be processed sequentially — the runtime's scanner
|
|
29
|
-
* engine holds a per-(address, scanner) mutex during the full async ingest
|
|
30
|
-
* chain and throws `UNAVAILABLE` on concurrent calls for the same key.
|
|
31
|
-
*
|
|
32
|
-
* Groups with different keys (different address or different scanner) can be
|
|
33
|
-
* processed in parallel — they do not share the lock.
|
|
34
|
-
*
|
|
35
|
-
* Each item carries its original index so the route handler can sort results
|
|
36
|
-
* back to input order after `Promise.all` resolves.
|
|
37
|
-
*
|
|
38
|
-
* @param items Flat array of signal items as received in the request body.
|
|
39
|
-
* @returns Array of groups; order of groups is not guaranteed, but item
|
|
40
|
-
* order within each group is preserved.
|
|
41
|
-
*/
|
|
42
|
-
export declare function groupByAddressScanner(items: SignalItem[]): SignalGroup[];
|
|
43
|
-
//# sourceMappingURL=group-by-scanner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group-by-scanner.d.ts","sourceRoot":"","sources":["../../../src/runtime-api/handlers/group-by-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,iBAAiB,EAAE,CAAC;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,WAAW,EAAE,CAkBxE"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure helper that groups a flat `SignalItem[]` by `(address, scanner)` so
|
|
3
|
-
* the route handler can fan-out groups in parallel while keeping items within
|
|
4
|
-
* a group sequential — dodging the per-(address, scanner) ingest lock held by
|
|
5
|
-
* `ScannerEngine` during async ingest
|
|
6
|
-
* (`src/scanners/engine/engine.ts:282-287`).
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Group signal items by `(lowercased address, scanner)`.
|
|
10
|
-
*
|
|
11
|
-
* Items within a group must be processed sequentially — the runtime's scanner
|
|
12
|
-
* engine holds a per-(address, scanner) mutex during the full async ingest
|
|
13
|
-
* chain and throws `UNAVAILABLE` on concurrent calls for the same key.
|
|
14
|
-
*
|
|
15
|
-
* Groups with different keys (different address or different scanner) can be
|
|
16
|
-
* processed in parallel — they do not share the lock.
|
|
17
|
-
*
|
|
18
|
-
* Each item carries its original index so the route handler can sort results
|
|
19
|
-
* back to input order after `Promise.all` resolves.
|
|
20
|
-
*
|
|
21
|
-
* @param items Flat array of signal items as received in the request body.
|
|
22
|
-
* @returns Array of groups; order of groups is not guaranteed, but item
|
|
23
|
-
* order within each group is preserved.
|
|
24
|
-
*/
|
|
25
|
-
export function groupByAddressScanner(items) {
|
|
26
|
-
const grouped = new Map();
|
|
27
|
-
for (let index = 0; index < items.length; index++) {
|
|
28
|
-
const item = items[index];
|
|
29
|
-
// item is always defined inside bounds; the cast avoids a superfluous
|
|
30
|
-
// non-null assertion in strict mode.
|
|
31
|
-
const safeItem = item;
|
|
32
|
-
const key = `${safeItem.address.toLowerCase()}::${safeItem.scanner}`;
|
|
33
|
-
const existing = grouped.get(key);
|
|
34
|
-
if (existing !== undefined) {
|
|
35
|
-
existing.push({ index, item: safeItem });
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
grouped.set(key, [{ index, item: safeItem }]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return Array.from(grouped.values());
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=group-by-scanner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group-by-scanner.js","sourceRoot":"","sources":["../../../src/runtime-api/handlers/group-by-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsBH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAmB;IACvD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE/C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,sEAAsE;QACtE,qCAAqC;QACrC,MAAM,QAAQ,GAAG,IAAkB,CAAC;QACpC,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared ingest handler for `POST /signals`.
|
|
3
|
-
*
|
|
4
|
-
* Called by the HTTP route (S4) and the gateway-method shim (S6). Contains
|
|
5
|
-
* all business logic for one ingest item — lookup, validation, execution, and
|
|
6
|
-
* error translation — so neither transport duplicates logic.
|
|
7
|
-
*/
|
|
8
|
-
import type { SignalItem, SignalResult } from "./types.js";
|
|
9
|
-
import type { RuntimeHandle } from "../../runtime/run.js";
|
|
10
|
-
import type { Logger } from "../../utils/logger.js";
|
|
11
|
-
/**
|
|
12
|
-
* Dependencies injected into {@link ingestSignalsHandler}.
|
|
13
|
-
*
|
|
14
|
-
* Keeping deps explicit (rather than closing over module-level state) makes
|
|
15
|
-
* unit-testing straightforward and keeps the function pure with respect to
|
|
16
|
-
* side effects outside the deps object.
|
|
17
|
-
*/
|
|
18
|
-
export interface IngestSignalsDeps {
|
|
19
|
-
/** Live runtime handles maintained by the plugin. */
|
|
20
|
-
runtimeHandles: Map<string, RuntimeHandle>;
|
|
21
|
-
/** Logger instance — errors logged at `error`, unexpected throws at `error`. */
|
|
22
|
-
logger: Logger;
|
|
23
|
-
/**
|
|
24
|
-
* Transport tag forwarded to future tracking events so the telemetry
|
|
25
|
-
* pipeline can distinguish HTTP-originated ingests from gateway-shim
|
|
26
|
-
* ingests on the migration dashboard.
|
|
27
|
-
*/
|
|
28
|
-
transport: "http" | "gateway";
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Ingest one signal item.
|
|
32
|
-
*
|
|
33
|
-
* Looks up the runtime by address, validates handler-level constraints, calls
|
|
34
|
-
* `RuntimeHandle.ingestExternalScannerData`, and translates all error shapes
|
|
35
|
-
* into the uniform `{ success: false, code, message }` discriminant. Never
|
|
36
|
-
* throws — all error paths return a `SignalResult`.
|
|
37
|
-
*
|
|
38
|
-
* Validation rules (beyond TypeBox):
|
|
39
|
-
* - At least one of `asset`, `data`, or `signals` must be present; an item
|
|
40
|
-
* with none of those fields has nothing to ingest → `INVALID_REQUEST`.
|
|
41
|
-
* - `data` and `signals` are mutually exclusive → `INVALID_REQUEST`.
|
|
42
|
-
* (The runtime also enforces this, but we check early to surface a clear
|
|
43
|
-
* message before the engine lock is acquired.)
|
|
44
|
-
*
|
|
45
|
-
* Per-(address, scanner) ingest lock is the engine's concern; callers should
|
|
46
|
-
* use {@link groupByAddressScanner} or nest multiple signals in `signals[]`
|
|
47
|
-
* rather than submitting concurrent top-level items for the same key.
|
|
48
|
-
*
|
|
49
|
-
* @param item A single element from the `POST /signals` request body.
|
|
50
|
-
* @param deps Injected dependencies.
|
|
51
|
-
* @returns A resolved `SignalResult` — never rejects.
|
|
52
|
-
*/
|
|
53
|
-
export declare function ingestSignalsHandler(item: SignalItem, deps: IngestSignalsDeps): Promise<SignalResult>;
|
|
54
|
-
//# sourceMappingURL=ingest-signals.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ingest-signals.d.ts","sourceRoot":"","sources":["../../../src/runtime-api/handlers/ingest-signals.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3C,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,YAAY,CAAC,CAiIvB"}
|