@silvana-one/agent 1.0.37 → 1.0.39
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/node/grpc.d.ts +39 -2
- package/dist/node/grpc.js +115 -1
- package/dist/node/grpc.js.map +1 -1
- package/dist/node/index.cjs +145 -31
- package/dist/node/proto/silvana/coordinator/v1/coordinator_pb.d.ts +201 -1
- package/dist/node/proto/silvana/coordinator/v1/coordinator_pb.js +153 -61
- package/dist/node/proto/silvana/coordinator/v1/coordinator_pb.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsconfig.web.tsbuildinfo +1 -1
- package/dist/web/grpc.d.ts +39 -2
- package/dist/web/grpc.js +115 -1
- package/dist/web/grpc.js.map +1 -1
- package/dist/web/proto/silvana/coordinator/v1/coordinator_pb.d.ts +201 -1
- package/dist/web/proto/silvana/coordinator/v1/coordinator_pb.js +153 -61
- package/dist/web/proto/silvana/coordinator/v1/coordinator_pb.js.map +1 -1
- package/package.json +2 -7
- package/src/grpc.ts +150 -0
- package/src/proto/silvana/coordinator/v1/coordinator_pb.ts +303 -62
- package/dist/node/proto/proto/coordinator/v1/coordinator_pb.d.ts +0 -1990
- package/dist/node/proto/proto/coordinator/v1/coordinator_pb.js +0 -424
- package/dist/node/proto/proto/coordinator/v1/coordinator_pb.js.map +0 -1
- package/dist/web/proto/proto/coordinator/v1/coordinator_pb.d.ts +0 -1990
- package/dist/web/proto/proto/coordinator/v1/coordinator_pb.js +0 -424
- package/dist/web/proto/proto/coordinator/v1/coordinator_pb.js.map +0 -1
- package/src/proto/proto/coordinator/v1/coordinator_pb.ts +0 -2481
package/src/grpc.ts
CHANGED
|
@@ -28,6 +28,10 @@ import {
|
|
|
28
28
|
UpdateBlockSettlementTxIncludedInBlockRequestSchema,
|
|
29
29
|
CreateAppJobRequestSchema,
|
|
30
30
|
RejectProofRequestSchema,
|
|
31
|
+
ProofEventRequestSchema,
|
|
32
|
+
AgentMessageRequestSchema,
|
|
33
|
+
LogLevel,
|
|
34
|
+
ProofEventType,
|
|
31
35
|
type GetJobResponse,
|
|
32
36
|
type CompleteJobResponse,
|
|
33
37
|
type FailJobResponse,
|
|
@@ -57,6 +61,8 @@ import {
|
|
|
57
61
|
type UpdateBlockSettlementTxIncludedInBlockResponse,
|
|
58
62
|
type CreateAppJobResponse,
|
|
59
63
|
type RejectProofResponse,
|
|
64
|
+
type ProofEventResponse,
|
|
65
|
+
type AgentMessageResponse,
|
|
60
66
|
} from "./proto/silvana/coordinator/v1/coordinator_pb.js";
|
|
61
67
|
import { create } from "@bufbuild/protobuf";
|
|
62
68
|
|
|
@@ -748,6 +754,145 @@ export async function updateBlockSettlement(
|
|
|
748
754
|
return await client.updateBlockSettlement(request);
|
|
749
755
|
}
|
|
750
756
|
|
|
757
|
+
/**
|
|
758
|
+
* Sends a proof event to the coordinator
|
|
759
|
+
*/
|
|
760
|
+
export async function proofEvent(params: {
|
|
761
|
+
dataAvailability: string;
|
|
762
|
+
blockNumber: bigint;
|
|
763
|
+
proofEventType: ProofEventType;
|
|
764
|
+
sequences: bigint[];
|
|
765
|
+
blockProof?: boolean;
|
|
766
|
+
mergedSequences1?: bigint[];
|
|
767
|
+
mergedSequences2?: bigint[];
|
|
768
|
+
}): Promise<ProofEventResponse> {
|
|
769
|
+
if (!jobId) {
|
|
770
|
+
throw new Error("Call getJob() first");
|
|
771
|
+
}
|
|
772
|
+
const { client, sessionId } = getCoordinatorClient();
|
|
773
|
+
|
|
774
|
+
const request = create(ProofEventRequestSchema, {
|
|
775
|
+
sessionId,
|
|
776
|
+
jobId,
|
|
777
|
+
dataAvailability: params.dataAvailability,
|
|
778
|
+
blockNumber: params.blockNumber,
|
|
779
|
+
proofEventType: params.proofEventType,
|
|
780
|
+
sequences: params.sequences,
|
|
781
|
+
blockProof: params.blockProof,
|
|
782
|
+
mergedSequences1: params.mergedSequences1 || [],
|
|
783
|
+
mergedSequences2: params.mergedSequences2 || [],
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
return await client.proofEvent(request);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Sends an agent message to the coordinator with a specific log level
|
|
791
|
+
*/
|
|
792
|
+
export async function agentMessage(
|
|
793
|
+
level: LogLevel,
|
|
794
|
+
message: string
|
|
795
|
+
): Promise<AgentMessageResponse> {
|
|
796
|
+
if (!jobId) {
|
|
797
|
+
throw new Error("Call getJob() first");
|
|
798
|
+
}
|
|
799
|
+
const { client, sessionId } = getCoordinatorClient();
|
|
800
|
+
|
|
801
|
+
const request = create(AgentMessageRequestSchema, {
|
|
802
|
+
sessionId,
|
|
803
|
+
jobId,
|
|
804
|
+
level,
|
|
805
|
+
message,
|
|
806
|
+
});
|
|
807
|
+
|
|
808
|
+
return await client.agentMessage(request);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Logs a debug message to the coordinator and console
|
|
813
|
+
*/
|
|
814
|
+
export async function debug(...args: any[]): Promise<void> {
|
|
815
|
+
const message = args
|
|
816
|
+
.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg)))
|
|
817
|
+
.join(" ");
|
|
818
|
+
|
|
819
|
+
console.log(...args);
|
|
820
|
+
|
|
821
|
+
try {
|
|
822
|
+
await agentMessage(LogLevel.DEBUG, message);
|
|
823
|
+
} catch (error) {
|
|
824
|
+
console.error("Failed to send debug message to coordinator:", error);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Logs an info message to the coordinator and console
|
|
830
|
+
*/
|
|
831
|
+
export async function info(...args: any[]): Promise<void> {
|
|
832
|
+
const message = args
|
|
833
|
+
.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg)))
|
|
834
|
+
.join(" ");
|
|
835
|
+
|
|
836
|
+
console.log(...args);
|
|
837
|
+
|
|
838
|
+
try {
|
|
839
|
+
await agentMessage(LogLevel.INFO, message);
|
|
840
|
+
} catch (error) {
|
|
841
|
+
console.error("Failed to send info message to coordinator:", error);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Logs a warning message to the coordinator and console
|
|
847
|
+
*/
|
|
848
|
+
export async function warn(...args: any[]): Promise<void> {
|
|
849
|
+
const message = args
|
|
850
|
+
.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg)))
|
|
851
|
+
.join(" ");
|
|
852
|
+
|
|
853
|
+
console.warn(...args);
|
|
854
|
+
|
|
855
|
+
try {
|
|
856
|
+
await agentMessage(LogLevel.WARN, message);
|
|
857
|
+
} catch (error) {
|
|
858
|
+
console.error("Failed to send warn message to coordinator:", error);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Logs an error message to the coordinator and console
|
|
864
|
+
*/
|
|
865
|
+
export async function error(...args: any[]): Promise<void> {
|
|
866
|
+
const message = args
|
|
867
|
+
.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg)))
|
|
868
|
+
.join(" ");
|
|
869
|
+
|
|
870
|
+
console.error(...args);
|
|
871
|
+
|
|
872
|
+
try {
|
|
873
|
+
await agentMessage(LogLevel.ERROR, message);
|
|
874
|
+
} catch (error) {
|
|
875
|
+
console.error("Failed to send error message to coordinator:", error);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Logs a fatal message to the coordinator and console
|
|
881
|
+
*/
|
|
882
|
+
export async function fatal(...args: any[]): Promise<void> {
|
|
883
|
+
const message = args
|
|
884
|
+
.map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : String(arg)))
|
|
885
|
+
.join(" ");
|
|
886
|
+
|
|
887
|
+
console.error(...args);
|
|
888
|
+
|
|
889
|
+
try {
|
|
890
|
+
await agentMessage(LogLevel.FATAL, message);
|
|
891
|
+
} catch (error) {
|
|
892
|
+
console.error("Failed to send fatal message to coordinator:", error);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
751
896
|
// Re-export types for users to access
|
|
752
897
|
export type {
|
|
753
898
|
Block,
|
|
@@ -759,4 +904,9 @@ export type {
|
|
|
759
904
|
GetBlockSettlementResponse,
|
|
760
905
|
UpdateBlockSettlementResponse,
|
|
761
906
|
RejectProofResponse,
|
|
907
|
+
ProofEventResponse,
|
|
908
|
+
AgentMessageResponse,
|
|
762
909
|
};
|
|
910
|
+
|
|
911
|
+
// Re-export enums
|
|
912
|
+
export { LogLevel, ProofEventType };
|