@obelyzk/sdk 1.4.0 → 1.5.0

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/index.js CHANGED
@@ -85,10 +85,10 @@ __export(index_exports, {
85
85
  createMiningClient: () => createMiningClient,
86
86
  createPaymentsClient: () => createPaymentsClient,
87
87
  createPrivacyClient: () => createPrivacyClient,
88
- createProverClient: () => createProverClient,
88
+ createProverClient: () => createStwoProverClient,
89
89
  createStakingClient: () => createStakingClient,
90
90
  createStwoClient: () => createStwoClient,
91
- createStwoProverClient: () => createStwoProverClient2,
91
+ createStwoProverClient: () => createStwoProverClient,
92
92
  createTeeClient: () => createTeeClient,
93
93
  createTransferProof: () => createTransferProof,
94
94
  createWebSocketClient: () => createWebSocketClient,
@@ -6513,7 +6513,7 @@ var StwoProverClient = class {
6513
6513
  return new Promise((resolve) => setTimeout(resolve, ms));
6514
6514
  }
6515
6515
  };
6516
- function createStwoProverClient2(config) {
6516
+ function createStwoProverClient(config) {
6517
6517
  return new StwoProverClient(config ?? {});
6518
6518
  }
6519
6519
  StwoProverClient.prototype.listZkmlModels = async function() {
@@ -6786,6 +6786,124 @@ var AgentFirewallSDK = class {
6786
6786
  );
6787
6787
  return contract.is_trusted(agentId);
6788
6788
  }
6789
+ /** Get the decision for an action (0=pending, 1=approved, 2=escalated, 3=blocked). */
6790
+ async getActionDecision(actionId) {
6791
+ const contract = new import_starknet.Contract(
6792
+ FIREWALL_ABI,
6793
+ this.config.firewallContract,
6794
+ this.provider
6795
+ );
6796
+ return Number(await contract.get_action_decision(actionId));
6797
+ }
6798
+ /** Get the threat score for a resolved action. */
6799
+ async getActionThreatScore(actionId) {
6800
+ const contract = new import_starknet.Contract(
6801
+ FIREWALL_ABI,
6802
+ this.config.firewallContract,
6803
+ this.provider
6804
+ );
6805
+ return Number(await contract.get_action_threat_score(actionId));
6806
+ }
6807
+ /** Get the IO commitment for an action. */
6808
+ async getActionIoCommitment(actionId) {
6809
+ const contract = new import_starknet.Contract(
6810
+ FIREWALL_ABI,
6811
+ this.config.firewallContract,
6812
+ this.provider
6813
+ );
6814
+ const result = await contract.get_action_io_commitment(actionId);
6815
+ return `0x${BigInt(result).toString(16)}`;
6816
+ }
6817
+ // ── On-Chain Actions ────────────────────────────────────────────────
6818
+ /**
6819
+ * Submit a pending action to the firewall contract.
6820
+ * Returns the action_id assigned by the contract.
6821
+ */
6822
+ async submitAction(agentId, target, value, selector, ioCommitment) {
6823
+ this.requireAccount();
6824
+ const tx = await this.config.account.execute({
6825
+ contractAddress: this.config.firewallContract,
6826
+ entrypoint: "submit_action",
6827
+ calldata: import_starknet.CallData.compile({
6828
+ agent_id: agentId,
6829
+ target,
6830
+ value,
6831
+ selector,
6832
+ io_commitment: ioCommitment
6833
+ })
6834
+ });
6835
+ const receipt = await this.provider.waitForTransaction(tx.transaction_hash);
6836
+ let actionId = 0;
6837
+ const events = receipt.events;
6838
+ if (Array.isArray(events)) {
6839
+ for (const event of events) {
6840
+ if (event.data && event.data.length >= 2) {
6841
+ const candidateId = Number(BigInt(event.data[0]));
6842
+ if (candidateId > 0) {
6843
+ actionId = candidateId;
6844
+ break;
6845
+ }
6846
+ }
6847
+ }
6848
+ }
6849
+ return { actionId, txHash: tx.transaction_hash };
6850
+ }
6851
+ /**
6852
+ * Resolve a pending action with a verified ZKML proof.
6853
+ * The proof must already be verified on the ObelyskVerifier contract.
6854
+ */
6855
+ async resolveAction(actionId, proofHash, originalIoLen, packedRawIo) {
6856
+ this.requireAccount();
6857
+ const tx = await this.config.account.execute({
6858
+ contractAddress: this.config.firewallContract,
6859
+ entrypoint: "resolve_action_with_proof",
6860
+ calldata: import_starknet.CallData.compile({
6861
+ action_id: actionId,
6862
+ proof_hash: proofHash,
6863
+ original_io_len: originalIoLen,
6864
+ packed_raw_io: packedRawIo
6865
+ })
6866
+ });
6867
+ const receipt = await this.provider.waitForTransaction(tx.transaction_hash);
6868
+ let decision = "approve";
6869
+ let threatScore = 0;
6870
+ const resolveEvents = receipt.events;
6871
+ if (Array.isArray(resolveEvents)) {
6872
+ for (const event of resolveEvents) {
6873
+ if (event.data && event.data.length >= 4) {
6874
+ const decisionCode = Number(BigInt(event.data[2]));
6875
+ threatScore = Number(BigInt(event.data[3]));
6876
+ if (decisionCode === 1) decision = "approve";
6877
+ else if (decisionCode === 2) decision = "escalate";
6878
+ else if (decisionCode === 3) decision = "block";
6879
+ break;
6880
+ }
6881
+ }
6882
+ }
6883
+ return { decision, threatScore, txHash: tx.transaction_hash };
6884
+ }
6885
+ /** Approve an escalated action (human-in-the-loop). */
6886
+ async approveEscalated(actionId) {
6887
+ this.requireAccount();
6888
+ const tx = await this.config.account.execute({
6889
+ contractAddress: this.config.firewallContract,
6890
+ entrypoint: "approve_escalated",
6891
+ calldata: import_starknet.CallData.compile({ action_id: actionId })
6892
+ });
6893
+ await this.provider.waitForTransaction(tx.transaction_hash);
6894
+ return tx.transaction_hash;
6895
+ }
6896
+ /** Reject an escalated action and add a strike. */
6897
+ async rejectEscalated(actionId) {
6898
+ this.requireAccount();
6899
+ const tx = await this.config.account.execute({
6900
+ contractAddress: this.config.firewallContract,
6901
+ entrypoint: "reject_escalated",
6902
+ calldata: import_starknet.CallData.compile({ action_id: actionId })
6903
+ });
6904
+ await this.provider.waitForTransaction(tx.transaction_hash);
6905
+ return tx.transaction_hash;
6906
+ }
6789
6907
  // ── Helpers ────────────────────────────────────────────────────────
6790
6908
  requireAccount() {
6791
6909
  if (!this.config.account) {
@@ -6844,6 +6962,69 @@ var FIREWALL_ABI = [
6844
6962
  inputs: [{ name: "action_id", type: "felt" }],
6845
6963
  outputs: [{ type: "felt" }],
6846
6964
  state_mutability: "view"
6965
+ },
6966
+ {
6967
+ name: "get_action_threat_score",
6968
+ type: "function",
6969
+ inputs: [{ name: "action_id", type: "felt" }],
6970
+ outputs: [{ type: "felt" }],
6971
+ state_mutability: "view"
6972
+ },
6973
+ {
6974
+ name: "get_action_io_commitment",
6975
+ type: "function",
6976
+ inputs: [{ name: "action_id", type: "felt" }],
6977
+ outputs: [{ type: "felt" }],
6978
+ state_mutability: "view"
6979
+ },
6980
+ {
6981
+ name: "get_owner",
6982
+ type: "function",
6983
+ inputs: [],
6984
+ outputs: [{ type: "felt" }],
6985
+ state_mutability: "view"
6986
+ },
6987
+ {
6988
+ name: "get_verifier",
6989
+ type: "function",
6990
+ inputs: [],
6991
+ outputs: [{ type: "felt" }],
6992
+ state_mutability: "view"
6993
+ },
6994
+ {
6995
+ name: "get_classifier_model_id",
6996
+ type: "function",
6997
+ inputs: [],
6998
+ outputs: [{ type: "felt" }],
6999
+ state_mutability: "view"
7000
+ },
7001
+ {
7002
+ name: "get_thresholds",
7003
+ type: "function",
7004
+ inputs: [],
7005
+ outputs: [{ type: "felt" }, { type: "felt" }, { type: "felt" }],
7006
+ state_mutability: "view"
7007
+ },
7008
+ {
7009
+ name: "get_agent_owner",
7010
+ type: "function",
7011
+ inputs: [{ name: "agent_id", type: "felt" }],
7012
+ outputs: [{ type: "felt" }],
7013
+ state_mutability: "view"
7014
+ },
7015
+ {
7016
+ name: "get_action_agent",
7017
+ type: "function",
7018
+ inputs: [{ name: "action_id", type: "felt" }],
7019
+ outputs: [{ type: "felt" }],
7020
+ state_mutability: "view"
7021
+ },
7022
+ {
7023
+ name: "is_paused",
7024
+ type: "function",
7025
+ inputs: [],
7026
+ outputs: [{ type: "felt" }],
7027
+ state_mutability: "view"
6847
7028
  }
6848
7029
  ];
6849
7030
 
@@ -7584,9 +7765,6 @@ var ConfidentialSwapClient = class {
7584
7765
  };
7585
7766
  }
7586
7767
  };
7587
-
7588
- // src/index.ts
7589
- var createProverClient = createStwoProverClient;
7590
7768
  // Annotate the CommonJS export names for ESM import in node:
7591
7769
  0 && (module.exports = {
7592
7770
  AgentFirewallSDK,
package/dist/index.mjs CHANGED
@@ -1,6 +1,3 @@
1
- import {
2
- AgentFirewallSDK
3
- } from "./chunk-BHUXKNDT.mjs";
4
1
  import {
5
2
  BatchClient,
6
3
  BitSageClient,
@@ -68,6 +65,10 @@ import {
68
65
  toFelt,
69
66
  verifyTransferProof
70
67
  } from "./chunk-LXJT3QK6.mjs";
68
+ import "./chunk-DGYMDV5X.mjs";
69
+ import {
70
+ AgentFirewallSDK
71
+ } from "./chunk-Y4PBMUWM.mjs";
71
72
  import {
72
73
  AssetId,
73
74
  CURVE_ORDER,
@@ -87,8 +88,8 @@ import {
87
88
  powMod,
88
89
  randomScalar,
89
90
  subMod
90
- } from "./chunk-MDF4P52S.mjs";
91
- import "./chunk-Y6FXYEAI.mjs";
91
+ } from "./chunk-GK4FKSZ4.mjs";
92
+ import "./chunk-XGB3TDIC.mjs";
92
93
 
93
94
  // src/types.ts
94
95
  function getMinStake(tier) {
@@ -594,7 +595,7 @@ var StwoProverClient = class {
594
595
  return new Promise((resolve) => setTimeout(resolve, ms));
595
596
  }
596
597
  };
597
- function createStwoProverClient2(config) {
598
+ function createStwoProverClient(config) {
598
599
  return new StwoProverClient(config ?? {});
599
600
  }
600
601
  StwoProverClient.prototype.listZkmlModels = async function() {
@@ -792,9 +793,6 @@ function getVersionBanner(version) {
792
793
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
793
794
  `;
794
795
  }
795
-
796
- // src/index.ts
797
- var createProverClient = createStwoProverClient;
798
796
  export {
799
797
  AgentFirewallSDK,
800
798
  AssetId,
@@ -861,10 +859,10 @@ export {
861
859
  createMiningClient,
862
860
  createPaymentsClient,
863
861
  createPrivacyClient,
864
- createProverClient,
862
+ createStwoProverClient as createProverClient,
865
863
  createStakingClient,
866
864
  createStwoClient,
867
- createStwoProverClient2 as createStwoProverClient,
865
+ createStwoProverClient,
868
866
  createTeeClient,
869
867
  createTransferProof,
870
868
  createWebSocketClient,
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node