@wowok/agent-mcp 2.3.12 → 2.3.14
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/harness/checkpoint.d.ts +8 -0
- package/dist/harness/checkpoint.js +129 -0
- package/dist/harness/index.d.ts +33 -0
- package/dist/harness/index.js +75 -0
- package/dist/harness/plan.d.ts +18 -0
- package/dist/harness/plan.js +252 -0
- package/dist/harness/recover.d.ts +17 -0
- package/dist/harness/recover.js +139 -0
- package/dist/harness/types.d.ts +137 -0
- package/dist/harness/types.js +1 -0
- package/dist/harness/verify.d.ts +42 -0
- package/dist/harness/verify.js +237 -0
- package/dist/index.js +134 -52
- package/dist/loop-engineering/aggregate.d.ts +50 -0
- package/dist/loop-engineering/aggregate.js +132 -0
- package/dist/loop-engineering/diagnose.d.ts +21 -0
- package/dist/loop-engineering/diagnose.js +179 -0
- package/dist/loop-engineering/improve.d.ts +26 -0
- package/dist/loop-engineering/improve.js +178 -0
- package/dist/loop-engineering/index.d.ts +4 -0
- package/dist/loop-engineering/index.js +4 -0
- package/dist/loop-engineering/pipeline.d.ts +17 -0
- package/dist/loop-engineering/pipeline.js +56 -0
- package/dist/mode-market/index.d.ts +3 -0
- package/dist/mode-market/index.js +3 -0
- package/dist/mode-market/registry.d.ts +53 -0
- package/dist/mode-market/registry.js +124 -0
- package/dist/mode-market/review.d.ts +27 -0
- package/dist/mode-market/review.js +214 -0
- package/dist/mode-market/submission.d.ts +25 -0
- package/dist/mode-market/submission.js +85 -0
- package/dist/schema/call/allocation.d.ts +40 -40
- package/dist/schema/call/arbitration.d.ts +90 -90
- package/dist/schema/call/base.d.ts +1054 -0
- package/dist/schema/call/base.js +100 -22
- package/dist/schema/call/bridge-handler.js +36 -18
- package/dist/schema/call/bridge.d.ts +115 -115
- package/dist/schema/call/handler.d.ts +2 -1
- package/dist/schema/call/handler.js +94 -3
- package/dist/schema/call/index.d.ts +1 -0
- package/dist/schema/call/index.js +1 -0
- package/dist/schema/call/machine.d.ts +144 -144
- package/dist/schema/call/order.d.ts +12 -12
- package/dist/schema/call/progress.d.ts +6 -6
- package/dist/schema/call/proof.js +7 -6
- package/dist/schema/call/reward.d.ts +6 -6
- package/dist/schema/call/semantic.d.ts +23 -0
- package/dist/schema/call/semantic.js +764 -0
- package/dist/schema/call/service.d.ts +142 -142
- package/dist/schema/call/treasury.d.ts +204 -204
- package/dist/schema/local/index.d.ts +113 -2
- package/dist/schema/local/index.js +11 -1
- package/dist/schema/messenger/index.d.ts +435 -95
- package/dist/schema/messenger/index.js +20 -8
- package/dist/schema/operations.d.ts +988 -495
- package/dist/schema/operations.js +14 -3
- package/dist/schema/query/index.d.ts +346 -342
- package/dist/schema/query/index.js +4 -1
- package/dist/schemas/account_operation.output.json +3 -0
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/local_info_operation.output.json +3 -0
- package/dist/schemas/local_mark_operation.output.json +3 -0
- package/dist/schemas/messenger_operation.output.json +21 -0
- package/dist/schemas/messenger_operation.schema.json +43 -8
- package/dist/schemas/onchain_events.output.json +3 -0
- package/dist/schemas/onchain_operations.output.json +464 -21
- package/dist/schemas/onchain_operations.schema.json +21 -17
- package/dist/schemas/onchain_operations_allocation.schema.json +11 -9
- package/dist/schemas/onchain_operations_arbitration.schema.json +11 -9
- package/dist/schemas/onchain_operations_contact.schema.json +11 -9
- package/dist/schemas/onchain_operations_demand.schema.json +11 -9
- package/dist/schemas/onchain_operations_gen_passport.schema.json +21 -17
- package/dist/schemas/onchain_operations_guard.schema.json +11 -9
- package/dist/schemas/onchain_operations_machine.schema.json +11 -9
- package/dist/schemas/onchain_operations_order.schema.json +11 -9
- package/dist/schemas/onchain_operations_payment.schema.json +11 -9
- package/dist/schemas/onchain_operations_permission.schema.json +11 -9
- package/dist/schemas/onchain_operations_personal.schema.json +11 -9
- package/dist/schemas/onchain_operations_progress.schema.json +11 -9
- package/dist/schemas/onchain_operations_repository.schema.json +11 -9
- package/dist/schemas/onchain_operations_reward.schema.json +11 -9
- package/dist/schemas/onchain_operations_service.schema.json +11 -9
- package/dist/schemas/onchain_operations_treasury.schema.json +11 -9
- package/dist/schemas/onchain_table_data.output.json +3 -0
- package/dist/schemas/query_toolkit.schema.json +5 -1
- package/dist/telemetry/index.d.ts +19 -0
- package/dist/telemetry/index.js +112 -0
- package/dist/telemetry/redact.d.ts +2 -0
- package/dist/telemetry/redact.js +23 -0
- package/dist/telemetry/storage.d.ts +8 -0
- package/dist/telemetry/storage.js +80 -0
- package/package.json +6 -3
|
@@ -909,7 +909,7 @@
|
|
|
909
909
|
"type": {
|
|
910
910
|
"type": "string",
|
|
911
911
|
"const": "submission",
|
|
912
|
-
"description": "
|
|
912
|
+
"description": "Discriminator for this result variant. Constraint: always 'submission'. Example: 'submission'"
|
|
913
913
|
},
|
|
914
914
|
"guard": {
|
|
915
915
|
"type": "array",
|
|
@@ -918,11 +918,11 @@
|
|
|
918
918
|
"properties": {
|
|
919
919
|
"object": {
|
|
920
920
|
"type": "string",
|
|
921
|
-
"description": "Guard object name or ID."
|
|
921
|
+
"description": "Guard object name or ID to verify against. Example: 'my-delivery-guard' or '0x123...'"
|
|
922
922
|
},
|
|
923
923
|
"impack": {
|
|
924
924
|
"type": "boolean",
|
|
925
|
-
"description": "Whether
|
|
925
|
+
"description": "Whether this Guard's verification result participates in the final logic. Constraint: if false, the Guard is checked but does not block the operation. Example: true"
|
|
926
926
|
}
|
|
927
927
|
},
|
|
928
928
|
"required": [
|
|
@@ -930,7 +930,8 @@
|
|
|
930
930
|
"impack"
|
|
931
931
|
],
|
|
932
932
|
"additionalProperties": false
|
|
933
|
-
}
|
|
933
|
+
},
|
|
934
|
+
"description": "Array of Guard objects to verify. Relation: each entry corresponds to a Guard bound to the operation."
|
|
934
935
|
},
|
|
935
936
|
"submission": {
|
|
936
937
|
"type": "array",
|
|
@@ -939,7 +940,7 @@
|
|
|
939
940
|
"properties": {
|
|
940
941
|
"guard": {
|
|
941
942
|
"$ref": "#/definitions/submission/properties/guard/items/properties/object",
|
|
942
|
-
"description": "Guard object name or ID."
|
|
943
|
+
"description": "Guard object name or ID that requires submission data. Example: 'my-delivery-guard'"
|
|
943
944
|
},
|
|
944
945
|
"submission": {
|
|
945
946
|
"type": "array",
|
|
@@ -1391,7 +1392,7 @@
|
|
|
1391
1392
|
"additionalProperties": false,
|
|
1392
1393
|
"description": "Guard table item"
|
|
1393
1394
|
},
|
|
1394
|
-
"description": "User-submitted data required
|
|
1395
|
+
"description": "User-submitted data matching the Guard's required fields. Relation: structure must match the Guard table's column definitions. Example: [{field:'delivery_proof', value:'Qm...'}]"
|
|
1395
1396
|
}
|
|
1396
1397
|
},
|
|
1397
1398
|
"required": [
|
|
@@ -1399,8 +1400,9 @@
|
|
|
1399
1400
|
"submission"
|
|
1400
1401
|
],
|
|
1401
1402
|
"additionalProperties": false,
|
|
1402
|
-
"description": "
|
|
1403
|
-
}
|
|
1403
|
+
"description": "One Guard's submission data: the Guard to verify plus the user-provided data that satisfies its requirements."
|
|
1404
|
+
},
|
|
1405
|
+
"description": "User-submitted data for each Guard. Relation: one entry per Guard in the guard array; fill submission fields and resubmit via call_with_submission."
|
|
1404
1406
|
}
|
|
1405
1407
|
},
|
|
1406
1408
|
"required": [
|
|
@@ -1409,7 +1411,7 @@
|
|
|
1409
1411
|
"submission"
|
|
1410
1412
|
],
|
|
1411
1413
|
"additionalProperties": false,
|
|
1412
|
-
"description": "Guard verification
|
|
1414
|
+
"description": "Guard verification required. The operation was blocked because one or more Guards require user-submitted data. Fill the submission array and resubmit. Semantic status is 'pending_input'."
|
|
1413
1415
|
}
|
|
1414
1416
|
}
|
|
1415
1417
|
}
|
|
@@ -650,7 +650,7 @@
|
|
|
650
650
|
"type": {
|
|
651
651
|
"type": "string",
|
|
652
652
|
"const": "submission",
|
|
653
|
-
"description": "
|
|
653
|
+
"description": "Discriminator for this result variant. Constraint: always 'submission'. Example: 'submission'"
|
|
654
654
|
},
|
|
655
655
|
"guard": {
|
|
656
656
|
"type": "array",
|
|
@@ -659,11 +659,11 @@
|
|
|
659
659
|
"properties": {
|
|
660
660
|
"object": {
|
|
661
661
|
"type": "string",
|
|
662
|
-
"description": "Guard object name or ID."
|
|
662
|
+
"description": "Guard object name or ID to verify against. Example: 'my-delivery-guard' or '0x123...'"
|
|
663
663
|
},
|
|
664
664
|
"impack": {
|
|
665
665
|
"type": "boolean",
|
|
666
|
-
"description": "Whether
|
|
666
|
+
"description": "Whether this Guard's verification result participates in the final logic. Constraint: if false, the Guard is checked but does not block the operation. Example: true"
|
|
667
667
|
}
|
|
668
668
|
},
|
|
669
669
|
"required": [
|
|
@@ -671,7 +671,8 @@
|
|
|
671
671
|
"impack"
|
|
672
672
|
],
|
|
673
673
|
"additionalProperties": false
|
|
674
|
-
}
|
|
674
|
+
},
|
|
675
|
+
"description": "Array of Guard objects to verify. Relation: each entry corresponds to a Guard bound to the operation."
|
|
675
676
|
},
|
|
676
677
|
"submission": {
|
|
677
678
|
"type": "array",
|
|
@@ -680,7 +681,7 @@
|
|
|
680
681
|
"properties": {
|
|
681
682
|
"guard": {
|
|
682
683
|
"$ref": "#/definitions/submission/properties/guard/items/properties/object",
|
|
683
|
-
"description": "Guard object name or ID."
|
|
684
|
+
"description": "Guard object name or ID that requires submission data. Example: 'my-delivery-guard'"
|
|
684
685
|
},
|
|
685
686
|
"submission": {
|
|
686
687
|
"type": "array",
|
|
@@ -1132,7 +1133,7 @@
|
|
|
1132
1133
|
"additionalProperties": false,
|
|
1133
1134
|
"description": "Guard table item"
|
|
1134
1135
|
},
|
|
1135
|
-
"description": "User-submitted data required
|
|
1136
|
+
"description": "User-submitted data matching the Guard's required fields. Relation: structure must match the Guard table's column definitions. Example: [{field:'delivery_proof', value:'Qm...'}]"
|
|
1136
1137
|
}
|
|
1137
1138
|
},
|
|
1138
1139
|
"required": [
|
|
@@ -1140,8 +1141,9 @@
|
|
|
1140
1141
|
"submission"
|
|
1141
1142
|
],
|
|
1142
1143
|
"additionalProperties": false,
|
|
1143
|
-
"description": "
|
|
1144
|
-
}
|
|
1144
|
+
"description": "One Guard's submission data: the Guard to verify plus the user-provided data that satisfies its requirements."
|
|
1145
|
+
},
|
|
1146
|
+
"description": "User-submitted data for each Guard. Relation: one entry per Guard in the guard array; fill submission fields and resubmit via call_with_submission."
|
|
1145
1147
|
}
|
|
1146
1148
|
},
|
|
1147
1149
|
"required": [
|
|
@@ -1150,7 +1152,7 @@
|
|
|
1150
1152
|
"submission"
|
|
1151
1153
|
],
|
|
1152
1154
|
"additionalProperties": false,
|
|
1153
|
-
"description": "Guard verification
|
|
1155
|
+
"description": "Guard verification required. The operation was blocked because one or more Guards require user-submitted data. Fill the submission array and resubmit. Semantic status is 'pending_input'."
|
|
1154
1156
|
}
|
|
1155
1157
|
}
|
|
1156
1158
|
}
|
|
@@ -134,6 +134,10 @@
|
|
|
134
134
|
},
|
|
135
135
|
"additionalProperties": false,
|
|
136
136
|
"description": "Filter by update time range"
|
|
137
|
+
},
|
|
138
|
+
"includePubkey": {
|
|
139
|
+
"type": "boolean",
|
|
140
|
+
"description": "Include pubkey in results (default: false). Pubkey is large (~900 bytes), omit unless needed"
|
|
137
141
|
}
|
|
138
142
|
},
|
|
139
143
|
"additionalProperties": false,
|
|
@@ -144,7 +148,7 @@
|
|
|
144
148
|
"query_type"
|
|
145
149
|
],
|
|
146
150
|
"additionalProperties": false,
|
|
147
|
-
"description": "Query your LOCAL accounts — view all accounts stored on this device (addresses,
|
|
151
|
+
"description": "Query your LOCAL accounts — view all accounts stored on this device (addresses, messenger status, suspension state). Use filter.includePubkey=true to also include public keys (~900 bytes each, omitted by default). Returns: AccountData[] (name, address, pubkey?, suspended, messenger, timestamps)"
|
|
148
152
|
},
|
|
149
153
|
{
|
|
150
154
|
"type": "object",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CallOutput } from "../schema/call/base.js";
|
|
2
|
+
export interface TelemetryEvent {
|
|
3
|
+
timestamp: string;
|
|
4
|
+
tool_name: string;
|
|
5
|
+
operation_type: string;
|
|
6
|
+
intent?: string;
|
|
7
|
+
status?: "success" | "partial" | "failed" | "pending_input";
|
|
8
|
+
error_code?: string;
|
|
9
|
+
duration_ms: number;
|
|
10
|
+
semantic_hit: boolean;
|
|
11
|
+
error_message?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function setTelemetryEnabled(enabled: boolean): void;
|
|
14
|
+
export declare function isTelemetryEnabled(): boolean;
|
|
15
|
+
export declare function captureTelemetry(toolName: string, structuredContent: CallOutput | undefined, durationMs: number, operationTypeHint?: string): Promise<void>;
|
|
16
|
+
export declare function captureTelemetryError(toolName: string, error: any, durationMs: number, operationTypeHint?: string): Promise<void>;
|
|
17
|
+
export declare function withTelemetry<TArgs, TOutput extends {
|
|
18
|
+
structuredContent?: CallOutput;
|
|
19
|
+
}>(toolName: string, handler: (args: TArgs) => Promise<TOutput>): (args: TArgs) => Promise<TOutput>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { getStorage } from "./storage.js";
|
|
2
|
+
import { redactObject } from "./redact.js";
|
|
3
|
+
let _enabled = true;
|
|
4
|
+
export function setTelemetryEnabled(enabled) {
|
|
5
|
+
_enabled = enabled;
|
|
6
|
+
}
|
|
7
|
+
export function isTelemetryEnabled() {
|
|
8
|
+
return _enabled;
|
|
9
|
+
}
|
|
10
|
+
function extractFromOutput(structuredContent, toolName, operationTypeHint) {
|
|
11
|
+
if (!structuredContent) {
|
|
12
|
+
return { tool_name: toolName, semantic_hit: false };
|
|
13
|
+
}
|
|
14
|
+
const semantic = structuredContent.semantic;
|
|
15
|
+
const result = structuredContent.result;
|
|
16
|
+
const event = {
|
|
17
|
+
tool_name: toolName,
|
|
18
|
+
semantic_hit: !!semantic,
|
|
19
|
+
};
|
|
20
|
+
if (semantic) {
|
|
21
|
+
event.intent = semantic.intent;
|
|
22
|
+
event.status = semantic.status;
|
|
23
|
+
}
|
|
24
|
+
if (result?.type === "error") {
|
|
25
|
+
event.status = event.status || "failed";
|
|
26
|
+
event.error_code = result.error_code;
|
|
27
|
+
if (result.error) {
|
|
28
|
+
const truncated = String(result.error).slice(0, 500);
|
|
29
|
+
event.error_message = redactObject(truncated);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (operationTypeHint) {
|
|
33
|
+
event.operation_type = operationTypeHint;
|
|
34
|
+
}
|
|
35
|
+
else if (semantic?.intent) {
|
|
36
|
+
event.operation_type = "unknown";
|
|
37
|
+
}
|
|
38
|
+
return event;
|
|
39
|
+
}
|
|
40
|
+
export async function captureTelemetry(toolName, structuredContent, durationMs, operationTypeHint) {
|
|
41
|
+
if (!_enabled)
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
const extracted = extractFromOutput(structuredContent, toolName, operationTypeHint);
|
|
45
|
+
const event = {
|
|
46
|
+
timestamp: new Date().toISOString(),
|
|
47
|
+
tool_name: extracted.tool_name || toolName,
|
|
48
|
+
operation_type: extracted.operation_type || "unknown",
|
|
49
|
+
intent: extracted.intent,
|
|
50
|
+
status: extracted.status,
|
|
51
|
+
error_code: extracted.error_code,
|
|
52
|
+
duration_ms: durationMs,
|
|
53
|
+
semantic_hit: extracted.semantic_hit ?? false,
|
|
54
|
+
error_message: extracted.error_message,
|
|
55
|
+
};
|
|
56
|
+
await getStorage().append(event);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export async function captureTelemetryError(toolName, error, durationMs, operationTypeHint) {
|
|
62
|
+
if (!_enabled)
|
|
63
|
+
return;
|
|
64
|
+
try {
|
|
65
|
+
const errorMsg = String(error?.message ?? error).slice(0, 500);
|
|
66
|
+
const event = {
|
|
67
|
+
timestamp: new Date().toISOString(),
|
|
68
|
+
tool_name: toolName,
|
|
69
|
+
operation_type: operationTypeHint || "unknown",
|
|
70
|
+
status: "failed",
|
|
71
|
+
duration_ms: durationMs,
|
|
72
|
+
semantic_hit: false,
|
|
73
|
+
error_message: redactObject(errorMsg),
|
|
74
|
+
};
|
|
75
|
+
await getStorage().append(event);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function withTelemetry(toolName, handler) {
|
|
81
|
+
return async (args) => {
|
|
82
|
+
const start = Date.now();
|
|
83
|
+
let output;
|
|
84
|
+
try {
|
|
85
|
+
output = await handler(args);
|
|
86
|
+
return output;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
await captureTelemetryError(toolName, error, Date.now() - start, extractOperationType(args));
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
if (output) {
|
|
94
|
+
await captureTelemetry(toolName, output?.structuredContent, Date.now() - start, extractOperationType(args));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function extractOperationType(args) {
|
|
100
|
+
if (!args || typeof args !== "object")
|
|
101
|
+
return undefined;
|
|
102
|
+
if (typeof args.operation_type === "string") {
|
|
103
|
+
if (args.operation_type.startsWith("cross_chain") || args.operation_type.startsWith("claim") ||
|
|
104
|
+
args.operation_type.startsWith("withdraw") || args.operation_type.startsWith("query_")) {
|
|
105
|
+
return "bridge_" + args.operation_type;
|
|
106
|
+
}
|
|
107
|
+
return args.operation_type;
|
|
108
|
+
}
|
|
109
|
+
if (args.data?.operation_type)
|
|
110
|
+
return args.data.operation_type;
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createHash } from "crypto";
|
|
2
|
+
const ADDRESS_PATTERN = /^0x[0-9a-fA-F]{40,}$/;
|
|
3
|
+
export function redactAddress(value) {
|
|
4
|
+
if (typeof value !== "string")
|
|
5
|
+
return value;
|
|
6
|
+
if (!ADDRESS_PATTERN.test(value))
|
|
7
|
+
return value;
|
|
8
|
+
const hash = createHash("sha256").update(value.toLowerCase()).digest("hex");
|
|
9
|
+
return "0x" + hash.slice(0, 16);
|
|
10
|
+
}
|
|
11
|
+
export function redactObject(obj) {
|
|
12
|
+
if (typeof obj === "string")
|
|
13
|
+
return redactAddress(obj);
|
|
14
|
+
if (Array.isArray(obj))
|
|
15
|
+
return obj.map(redactObject);
|
|
16
|
+
if (obj && typeof obj === "object" && obj.constructor === Object) {
|
|
17
|
+
const out = {};
|
|
18
|
+
for (const k of Object.keys(obj))
|
|
19
|
+
out[k] = redactObject(obj[k]);
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface TelemetryStorage {
|
|
2
|
+
append(event: Record<string, unknown>): Promise<void>;
|
|
3
|
+
query(filter: Partial<Record<string, unknown>>): Promise<Record<string, unknown>[]>;
|
|
4
|
+
rotate(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare function getStorage(): TelemetryStorage;
|
|
7
|
+
export declare function setStorage(storage: TelemetryStorage): void;
|
|
8
|
+
export declare function getTelemetryFilePath(): string;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { mkdir, appendFile, stat, rename } from "fs/promises";
|
|
2
|
+
import { dirname, join } from "path";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
const MAX_SIZE_BYTES = 10 * 1024 * 1024;
|
|
5
|
+
const DATA_DIR = join(homedir(), ".wowok", "data");
|
|
6
|
+
const TELEMETRY_FILE = join(DATA_DIR, "telemetry.jsonl");
|
|
7
|
+
const ROTATED_FILE = join(DATA_DIR, "telemetry.jsonl.1");
|
|
8
|
+
class JsonlStorage {
|
|
9
|
+
filePath;
|
|
10
|
+
rotatedPath;
|
|
11
|
+
writeQueue = Promise.resolve();
|
|
12
|
+
constructor(filePath = TELEMETRY_FILE, rotatedPath = ROTATED_FILE) {
|
|
13
|
+
this.filePath = filePath;
|
|
14
|
+
this.rotatedPath = rotatedPath;
|
|
15
|
+
}
|
|
16
|
+
async append(event) {
|
|
17
|
+
this.writeQueue = this.writeQueue.then(async () => {
|
|
18
|
+
try {
|
|
19
|
+
await mkdir(dirname(this.filePath), { recursive: true });
|
|
20
|
+
const line = JSON.stringify(event) + "\n";
|
|
21
|
+
await appendFile(this.filePath, line, "utf8");
|
|
22
|
+
await this.maybeRotate();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return this.writeQueue;
|
|
28
|
+
}
|
|
29
|
+
async query(filter) {
|
|
30
|
+
try {
|
|
31
|
+
const { readFile } = await import("fs/promises");
|
|
32
|
+
const content = await readFile(this.filePath, "utf8");
|
|
33
|
+
const lines = content.split("\n").filter((l) => l.trim());
|
|
34
|
+
const events = lines.map((l) => {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(l);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}).filter((e) => e !== null);
|
|
42
|
+
return events.filter((e) => {
|
|
43
|
+
return Object.entries(filter).every(([k, v]) => e[k] === v);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async rotate() {
|
|
51
|
+
try {
|
|
52
|
+
await rename(this.filePath, this.rotatedPath).catch(() => { });
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async maybeRotate() {
|
|
58
|
+
try {
|
|
59
|
+
const stats = await stat(this.filePath);
|
|
60
|
+
if (stats.size >= MAX_SIZE_BYTES) {
|
|
61
|
+
await this.rotate();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let _storage = null;
|
|
69
|
+
export function getStorage() {
|
|
70
|
+
if (!_storage) {
|
|
71
|
+
_storage = new JsonlStorage();
|
|
72
|
+
}
|
|
73
|
+
return _storage;
|
|
74
|
+
}
|
|
75
|
+
export function setStorage(storage) {
|
|
76
|
+
_storage = storage;
|
|
77
|
+
}
|
|
78
|
+
export function getTelemetryFilePath() {
|
|
79
|
+
return TELEMETRY_FILE;
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wowok/agent-mcp",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.14",
|
|
4
4
|
"description": "Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
39
|
-
"@wowok/wowok": "2.3.
|
|
39
|
+
"@wowok/wowok": "2.3.14",
|
|
40
40
|
"lodash": "^4.18.1",
|
|
41
41
|
"zod": "^3.25.76"
|
|
42
42
|
},
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"@types/node": "^22.19.19",
|
|
45
45
|
"tsx": "^4.21.0",
|
|
46
46
|
"typescript": "^5.8.2",
|
|
47
|
+
"vitest": "^2.1.0",
|
|
47
48
|
"zod-to-json-schema": "^3.25.2"
|
|
48
49
|
},
|
|
49
50
|
"scripts": {
|
|
@@ -51,6 +52,8 @@
|
|
|
51
52
|
"build": "tsc && pnpm generate:schemas",
|
|
52
53
|
"watch": "tsc --watch",
|
|
53
54
|
"start": "tsx src/index.ts",
|
|
54
|
-
"generate:schemas": "tsx scripts/generate-json-schemas.ts"
|
|
55
|
+
"generate:schemas": "tsx scripts/generate-json-schemas.ts",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:watch": "vitest"
|
|
55
58
|
}
|
|
56
59
|
}
|