@obelyzk/sdk 1.3.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/README.md +3 -3
- package/dist/chunk-ASKP7TIW.mjs +153 -0
- package/dist/chunk-DGYMDV5X.mjs +153 -0
- package/dist/chunk-EHI6MQFS.mjs +566 -0
- package/dist/chunk-G3GLKFP5.mjs +0 -0
- package/dist/chunk-GK4FKSZ4.mjs +697 -0
- package/dist/chunk-NQ4E7ULF.mjs +338 -0
- package/dist/chunk-XGB3TDIC.mjs +42 -0
- package/dist/chunk-Y4PBMUWM.mjs +533 -0
- package/dist/client-DFxKbDns.d.mts +199 -0
- package/dist/client-DFxKbDns.d.ts +199 -0
- package/dist/firewall/index.d.mts +236 -130
- package/dist/firewall/index.d.ts +236 -130
- package/dist/firewall/index.js +479 -2
- package/dist/firewall/index.mjs +12 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +183 -0
- package/dist/index.mjs +7 -5
- package/dist/mcp-policy/index.d.mts +1 -0
- package/dist/mcp-policy/index.d.ts +1 -0
- package/dist/mcp-policy/index.js +27903 -0
- package/dist/mcp-policy/index.mjs +27351 -0
- package/dist/obelysk/index.mjs +2 -2
- package/dist/privacy/index.mjs +2 -2
- package/dist/react/index.mjs +2 -2
- package/examples/.claude/rules/starknet.md +17 -0
- package/examples/CLAUDE.md +59 -0
- package/examples/claude-settings.json +52 -0
- package/examples/test_confidential_swap_api.ts +313 -0
- package/package.json +12 -4
- package/src/hooks/post-tool-use.sh +116 -0
- package/src/hooks/pre-tool-use.sh +112 -0
- package/src/hooks/session-start.sh +50 -0
package/dist/index.js
CHANGED
|
@@ -85,6 +85,7 @@ __export(index_exports, {
|
|
|
85
85
|
createMiningClient: () => createMiningClient,
|
|
86
86
|
createPaymentsClient: () => createPaymentsClient,
|
|
87
87
|
createPrivacyClient: () => createPrivacyClient,
|
|
88
|
+
createProverClient: () => createStwoProverClient,
|
|
88
89
|
createStakingClient: () => createStakingClient,
|
|
89
90
|
createStwoClient: () => createStwoClient,
|
|
90
91
|
createStwoProverClient: () => createStwoProverClient,
|
|
@@ -6785,6 +6786,124 @@ var AgentFirewallSDK = class {
|
|
|
6785
6786
|
);
|
|
6786
6787
|
return contract.is_trusted(agentId);
|
|
6787
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
|
+
}
|
|
6788
6907
|
// ── Helpers ────────────────────────────────────────────────────────
|
|
6789
6908
|
requireAccount() {
|
|
6790
6909
|
if (!this.config.account) {
|
|
@@ -6843,6 +6962,69 @@ var FIREWALL_ABI = [
|
|
|
6843
6962
|
inputs: [{ name: "action_id", type: "felt" }],
|
|
6844
6963
|
outputs: [{ type: "felt" }],
|
|
6845
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"
|
|
6846
7028
|
}
|
|
6847
7029
|
];
|
|
6848
7030
|
|
|
@@ -7650,6 +7832,7 @@ var ConfidentialSwapClient = class {
|
|
|
7650
7832
|
createMiningClient,
|
|
7651
7833
|
createPaymentsClient,
|
|
7652
7834
|
createPrivacyClient,
|
|
7835
|
+
createProverClient,
|
|
7653
7836
|
createStakingClient,
|
|
7654
7837
|
createStwoClient,
|
|
7655
7838
|
createStwoProverClient,
|
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-
|
|
91
|
-
import "./chunk-
|
|
91
|
+
} from "./chunk-GK4FKSZ4.mjs";
|
|
92
|
+
import "./chunk-XGB3TDIC.mjs";
|
|
92
93
|
|
|
93
94
|
// src/types.ts
|
|
94
95
|
function getMinStake(tier) {
|
|
@@ -858,6 +859,7 @@ export {
|
|
|
858
859
|
createMiningClient,
|
|
859
860
|
createPaymentsClient,
|
|
860
861
|
createPrivacyClient,
|
|
862
|
+
createStwoProverClient as createProverClient,
|
|
861
863
|
createStakingClient,
|
|
862
864
|
createStwoClient,
|
|
863
865
|
createStwoProverClient,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|