agentbnb 6.0.0 → 7.0.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 +245 -39
- package/dist/{card-REW7BSWW.js → card-EX2EYGCZ.js} +1 -1
- package/dist/{chunk-C6KPAFCC.js → chunk-3LWBH7P3.js} +94 -3
- package/dist/{chunk-YRRVFTDR.js → chunk-5AAFG2V2.js} +3 -3
- package/dist/{chunk-C2T4BMRW.js → chunk-5GME4KJZ.js} +8 -6
- package/dist/{chunk-VPQ44XKE.js → chunk-64AK4FJM.js} +2 -2
- package/dist/{chunk-2TLZ6G2B.js → chunk-7EF3HYVZ.js} +158 -18
- package/dist/{chunk-JR6TJDIF.js → chunk-ALX4WS3A.js} +9 -4
- package/dist/{chunk-7XHDSWRD.js → chunk-B2VJTKO5.js} +2 -2
- package/dist/{chunk-TR6UZDNX.js → chunk-C537SFHV.js} +8 -6
- package/dist/{chunk-F53QQIM2.js → chunk-CUONY5TO.js} +1 -1
- package/dist/chunk-D6RKW2XG.js +395 -0
- package/dist/{chunk-NYV3NE5Z.js → chunk-E2OKP5CY.js} +4 -4
- package/dist/{chunk-TQDV254A.js → chunk-FTZTEHYG.js} +117 -117
- package/dist/{chunk-Y7T6IMM3.js → chunk-GKVTD4EZ.js} +1 -1
- package/dist/{chunk-VMH2YS2I.js → chunk-KF3TZHA5.js} +1 -1
- package/dist/{chunk-574W3HHE.js → chunk-LJM7FHPM.js} +1 -1
- package/dist/chunk-NWIQJ2CL.js +108 -0
- package/dist/{chunk-KA2VIEGM.js → chunk-O2OYBAVR.js} +1 -1
- package/dist/{chunk-NQTE577Q.js → chunk-OCSU2S6W.js} +9 -0
- package/dist/{chunk-PSQHUZ7X.js → chunk-OH7BP5NP.js} +1 -1
- package/dist/chunk-SSK653A6.js +169 -0
- package/dist/{chunk-BP3L2TET.js → chunk-TBJ3FZKZ.js} +2 -2
- package/dist/{chunk-3CIMVISQ.js → chunk-WVY2W7AA.js} +4 -0
- package/dist/{chunk-OZXCRLP3.js → chunk-X32NE6V4.js} +5 -2
- package/dist/{chunk-7YLFLC5C.js → chunk-YHY7OG6S.js} +5 -5
- package/dist/{chunk-JOY533UH.js → chunk-Z4MCGKTL.js} +6 -2
- package/dist/cli/index.js +530 -269
- package/dist/{client-HRYRJKSA.js → client-HKV3QWZ3.js} +3 -3
- package/dist/{conduct-LF6FYPLD.js → conduct-W6XF6DJW.js} +14 -13
- package/dist/conduct-YB64OHI6.js +22 -0
- package/dist/{conductor-mode-NUDQLZFM.js → conductor-mode-2GSLHVN6.js} +7 -4
- package/dist/{conductor-mode-YQ6QSPPT.js → conductor-mode-AKREGDIU.js} +11 -10
- package/dist/execute-AYQWORVH.js +15 -0
- package/dist/{execute-ITHIYYOX.js → execute-EPE6MZLT.js} +4 -3
- package/dist/index.d.ts +502 -12
- package/dist/index.js +706 -53
- package/dist/{process-guard-QCCBGILS.js → process-guard-GH5LRNWO.js} +1 -1
- package/dist/{publish-capability-TS6CNR5G.js → publish-capability-AH2HDW54.js} +3 -3
- package/dist/reliability-metrics-QG7WC5QK.js +18 -0
- package/dist/{request-P6QCTCCG.js → request-HCCXSKAY.js} +15 -14
- package/dist/{serve-skill-EZOL7UYN.js → serve-skill-SZAQT5T5.js} +9 -8
- package/dist/{server-3G6ZTASA.js → server-MHMAYXWZ.js} +12 -11
- package/dist/{service-coordinator-CRSE4GWC.js → service-coordinator-WGH6B2VT.js} +572 -68
- package/dist/{skill-config-4W5W5O6T.js → skill-config-FETXPNVP.js} +1 -1
- package/dist/skills/agentbnb/bootstrap.js +594 -73
- package/dist/{websocket-client-WRN3HO73.js → websocket-client-4Z5P54RU.js} +1 -1
- package/dist/websocket-client-QOVARTRN.js +7 -0
- package/openclaw.plugin.json +2 -2
- package/package.json +18 -11
- package/skills/agentbnb/bootstrap.test.ts +9 -0
- package/skills/agentbnb/bootstrap.ts +51 -26
- package/skills/agentbnb/install.sh +0 -0
- package/dist/chunk-QT7TEVNV.js +0 -82
- package/dist/chunk-RVYQSC6L.js +0 -212
- package/dist/conduct-QAFZIEY6.js +0 -21
- package/dist/execute-PNJFABVJ.js +0 -14
- package/dist/websocket-client-6IIDGXKB.js +0 -7
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureReliabilityTable,
|
|
3
|
+
recordSuccessfulHire
|
|
4
|
+
} from "./chunk-NWIQJ2CL.js";
|
|
1
5
|
import {
|
|
2
6
|
AgentBnBError,
|
|
3
7
|
AnyCardSchema,
|
|
4
8
|
CapabilityCardSchema
|
|
5
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WVY2W7AA.js";
|
|
6
10
|
|
|
7
11
|
// src/registry/request-log.ts
|
|
8
12
|
var SINCE_MS = {
|
|
@@ -735,6 +739,28 @@ function getCardsBySkillCapability(db, capabilityType) {
|
|
|
735
739
|
// src/credit/ledger.ts
|
|
736
740
|
import Database2 from "better-sqlite3";
|
|
737
741
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
742
|
+
|
|
743
|
+
// src/identity/agent-identity.ts
|
|
744
|
+
var AGENTS_SCHEMA = `
|
|
745
|
+
CREATE TABLE IF NOT EXISTS agents (
|
|
746
|
+
agent_id TEXT PRIMARY KEY,
|
|
747
|
+
display_name TEXT NOT NULL,
|
|
748
|
+
public_key TEXT NOT NULL,
|
|
749
|
+
operator_id TEXT,
|
|
750
|
+
server_id TEXT,
|
|
751
|
+
legacy_owner TEXT,
|
|
752
|
+
created_at TEXT NOT NULL,
|
|
753
|
+
updated_at TEXT NOT NULL
|
|
754
|
+
);
|
|
755
|
+
|
|
756
|
+
CREATE INDEX IF NOT EXISTS idx_agents_operator ON agents(operator_id);
|
|
757
|
+
CREATE INDEX IF NOT EXISTS idx_agents_legacy_owner ON agents(legacy_owner);
|
|
758
|
+
`;
|
|
759
|
+
function ensureAgentsTable(db) {
|
|
760
|
+
db.exec(AGENTS_SCHEMA);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// src/credit/ledger.ts
|
|
738
764
|
var CREDIT_SCHEMA = `
|
|
739
765
|
CREATE TABLE IF NOT EXISTS credit_balances (
|
|
740
766
|
owner TEXT PRIMARY KEY,
|
|
@@ -761,6 +787,22 @@ var CREDIT_SCHEMA = `
|
|
|
761
787
|
settled_at TEXT
|
|
762
788
|
);
|
|
763
789
|
|
|
790
|
+
CREATE TABLE IF NOT EXISTS provider_registry (
|
|
791
|
+
owner TEXT PRIMARY KEY,
|
|
792
|
+
provider_number INTEGER NOT NULL,
|
|
793
|
+
registered_at TEXT NOT NULL
|
|
794
|
+
);
|
|
795
|
+
|
|
796
|
+
CREATE TABLE IF NOT EXISTS demand_vouchers (
|
|
797
|
+
id TEXT PRIMARY KEY,
|
|
798
|
+
owner TEXT NOT NULL,
|
|
799
|
+
amount INTEGER NOT NULL,
|
|
800
|
+
remaining INTEGER NOT NULL,
|
|
801
|
+
created_at TEXT NOT NULL,
|
|
802
|
+
expires_at TEXT NOT NULL,
|
|
803
|
+
is_active INTEGER NOT NULL DEFAULT 1
|
|
804
|
+
);
|
|
805
|
+
|
|
764
806
|
CREATE INDEX IF NOT EXISTS idx_transactions_owner ON credit_transactions(owner, created_at);
|
|
765
807
|
CREATE INDEX IF NOT EXISTS idx_escrow_owner ON credit_escrow(owner);
|
|
766
808
|
`;
|
|
@@ -769,18 +811,29 @@ function openCreditDb(path = ":memory:") {
|
|
|
769
811
|
db.pragma("journal_mode = WAL");
|
|
770
812
|
db.pragma("foreign_keys = ON");
|
|
771
813
|
db.exec(CREDIT_SCHEMA);
|
|
814
|
+
try {
|
|
815
|
+
db.exec("ALTER TABLE credit_escrow ADD COLUMN funding_source TEXT NOT NULL DEFAULT 'balance'");
|
|
816
|
+
} catch {
|
|
817
|
+
}
|
|
818
|
+
ensureReliabilityTable(db);
|
|
819
|
+
ensureAgentsTable(db);
|
|
772
820
|
return db;
|
|
773
821
|
}
|
|
774
822
|
function bootstrapAgent(db, owner, amount = 100) {
|
|
775
823
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
824
|
+
let isNew = false;
|
|
776
825
|
db.transaction(() => {
|
|
777
826
|
const result = db.prepare("INSERT OR IGNORE INTO credit_balances (owner, balance, updated_at) VALUES (?, ?, ?)").run(owner, amount, now);
|
|
778
827
|
if (result.changes > 0) {
|
|
828
|
+
isNew = true;
|
|
779
829
|
db.prepare(
|
|
780
830
|
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
781
831
|
).run(randomUUID3(), owner, amount, "bootstrap", null, now);
|
|
782
832
|
}
|
|
783
833
|
})();
|
|
834
|
+
if (isNew) {
|
|
835
|
+
issueVoucher(db, owner, 50, 30);
|
|
836
|
+
}
|
|
784
837
|
}
|
|
785
838
|
function getBalance(db, owner) {
|
|
786
839
|
const row = db.prepare("SELECT balance FROM credit_balances WHERE owner = ?").get(owner);
|
|
@@ -791,6 +844,44 @@ function getTransactions(db, owner, limit = 100) {
|
|
|
791
844
|
"SELECT id, owner, amount, reason, reference_id, created_at FROM credit_transactions WHERE owner = ? ORDER BY created_at DESC LIMIT ?"
|
|
792
845
|
).all(owner, limit);
|
|
793
846
|
}
|
|
847
|
+
function registerProvider(db, owner) {
|
|
848
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
849
|
+
const maxRow = db.prepare("SELECT MAX(provider_number) as maxNum FROM provider_registry").get();
|
|
850
|
+
const nextNum = (maxRow?.maxNum ?? 0) + 1;
|
|
851
|
+
db.prepare("INSERT OR IGNORE INTO provider_registry (owner, provider_number, registered_at) VALUES (?, ?, ?)").run(owner, nextNum, now);
|
|
852
|
+
const row = db.prepare("SELECT provider_number FROM provider_registry WHERE owner = ?").get(owner);
|
|
853
|
+
return row.provider_number;
|
|
854
|
+
}
|
|
855
|
+
function getProviderNumber(db, owner) {
|
|
856
|
+
const row = db.prepare("SELECT provider_number FROM provider_registry WHERE owner = ?").get(owner);
|
|
857
|
+
return row?.provider_number ?? null;
|
|
858
|
+
}
|
|
859
|
+
function getProviderBonus(providerNumber) {
|
|
860
|
+
if (providerNumber <= 50) return 2;
|
|
861
|
+
if (providerNumber <= 200) return 1.5;
|
|
862
|
+
return 1;
|
|
863
|
+
}
|
|
864
|
+
function issueVoucher(db, owner, amount = 50, daysValid = 30) {
|
|
865
|
+
const id = randomUUID3();
|
|
866
|
+
const now = /* @__PURE__ */ new Date();
|
|
867
|
+
const expiresAt = new Date(now.getTime() + daysValid * 24 * 60 * 60 * 1e3);
|
|
868
|
+
db.prepare(
|
|
869
|
+
"INSERT INTO demand_vouchers (id, owner, amount, remaining, created_at, expires_at, is_active) VALUES (?, ?, ?, ?, ?, ?, 1)"
|
|
870
|
+
).run(id, owner, amount, amount, now.toISOString(), expiresAt.toISOString());
|
|
871
|
+
return id;
|
|
872
|
+
}
|
|
873
|
+
function getActiveVoucher(db, owner) {
|
|
874
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
875
|
+
const row = db.prepare(
|
|
876
|
+
"SELECT id, remaining, expires_at FROM demand_vouchers WHERE owner = ? AND is_active = 1 AND remaining > 0 AND expires_at > ? ORDER BY created_at ASC LIMIT 1"
|
|
877
|
+
).get(owner, now);
|
|
878
|
+
return row ?? null;
|
|
879
|
+
}
|
|
880
|
+
function consumeVoucher(db, voucherId, amount) {
|
|
881
|
+
db.prepare(
|
|
882
|
+
"UPDATE demand_vouchers SET remaining = remaining - ? WHERE id = ? AND remaining >= ?"
|
|
883
|
+
).run(amount, voucherId, amount);
|
|
884
|
+
}
|
|
794
885
|
function recordEarning(db, owner, amount, _cardId, receiptNonce) {
|
|
795
886
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
796
887
|
db.transaction(() => {
|
|
@@ -831,23 +922,35 @@ function migrateOwner(db, oldOwner, newOwner) {
|
|
|
831
922
|
|
|
832
923
|
// src/credit/escrow.ts
|
|
833
924
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
925
|
+
var NETWORK_FEE_RATE = 0.05;
|
|
834
926
|
function holdEscrow(db, owner, amount, cardId) {
|
|
835
927
|
const escrowId = randomUUID4();
|
|
836
928
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
837
929
|
const hold = db.transaction(() => {
|
|
838
|
-
const
|
|
839
|
-
if (
|
|
840
|
-
|
|
930
|
+
const voucher = getActiveVoucher(db, owner);
|
|
931
|
+
if (voucher && voucher.remaining >= amount) {
|
|
932
|
+
consumeVoucher(db, voucher.id, amount);
|
|
933
|
+
db.prepare(
|
|
934
|
+
"INSERT INTO credit_escrow (id, owner, amount, card_id, status, created_at, funding_source) VALUES (?, ?, ?, ?, ?, ?, ?)"
|
|
935
|
+
).run(escrowId, owner, amount, cardId, "held", now, "voucher");
|
|
936
|
+
db.prepare(
|
|
937
|
+
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
938
|
+
).run(randomUUID4(), owner, -amount, "voucher_hold", escrowId, now);
|
|
939
|
+
} else {
|
|
940
|
+
const row = db.prepare("SELECT balance FROM credit_balances WHERE owner = ?").get(owner);
|
|
941
|
+
if (!row || row.balance < amount) {
|
|
942
|
+
throw new AgentBnBError("Insufficient credits", "INSUFFICIENT_CREDITS");
|
|
943
|
+
}
|
|
944
|
+
db.prepare(
|
|
945
|
+
"UPDATE credit_balances SET balance = balance - ?, updated_at = ? WHERE owner = ? AND balance >= ?"
|
|
946
|
+
).run(amount, now, owner, amount);
|
|
947
|
+
db.prepare(
|
|
948
|
+
"INSERT INTO credit_escrow (id, owner, amount, card_id, status, created_at, funding_source) VALUES (?, ?, ?, ?, ?, ?, ?)"
|
|
949
|
+
).run(escrowId, owner, amount, cardId, "held", now, "balance");
|
|
950
|
+
db.prepare(
|
|
951
|
+
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
952
|
+
).run(randomUUID4(), owner, -amount, "escrow_hold", escrowId, now);
|
|
841
953
|
}
|
|
842
|
-
db.prepare(
|
|
843
|
-
"UPDATE credit_balances SET balance = balance - ?, updated_at = ? WHERE owner = ? AND balance >= ?"
|
|
844
|
-
).run(amount, now, owner, amount);
|
|
845
|
-
db.prepare(
|
|
846
|
-
"INSERT INTO credit_escrow (id, owner, amount, card_id, status, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
847
|
-
).run(escrowId, owner, amount, cardId, "held", now);
|
|
848
|
-
db.prepare(
|
|
849
|
-
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
850
|
-
).run(randomUUID4(), owner, -amount, "escrow_hold", escrowId, now);
|
|
851
954
|
});
|
|
852
955
|
hold();
|
|
853
956
|
return escrowId;
|
|
@@ -855,7 +958,7 @@ function holdEscrow(db, owner, amount, cardId) {
|
|
|
855
958
|
function settleEscrow(db, escrowId, recipientOwner) {
|
|
856
959
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
857
960
|
const settle = db.transaction(() => {
|
|
858
|
-
const escrow = db.prepare("SELECT id, owner, amount, status FROM credit_escrow WHERE id = ?").get(escrowId);
|
|
961
|
+
const escrow = db.prepare("SELECT id, owner, amount, status, funding_source FROM credit_escrow WHERE id = ?").get(escrowId);
|
|
859
962
|
if (!escrow) {
|
|
860
963
|
throw new AgentBnBError(`Escrow not found: ${escrowId}`, "ESCROW_NOT_FOUND");
|
|
861
964
|
}
|
|
@@ -865,25 +968,61 @@ function settleEscrow(db, escrowId, recipientOwner) {
|
|
|
865
968
|
"ESCROW_ALREADY_SETTLED"
|
|
866
969
|
);
|
|
867
970
|
}
|
|
971
|
+
const feeAmount = Math.floor(escrow.amount * NETWORK_FEE_RATE);
|
|
972
|
+
const providerAmount = escrow.amount - feeAmount;
|
|
868
973
|
db.prepare(
|
|
869
974
|
"INSERT OR IGNORE INTO credit_balances (owner, balance, updated_at) VALUES (?, 0, ?)"
|
|
870
975
|
).run(recipientOwner, now);
|
|
871
976
|
db.prepare(
|
|
872
977
|
"UPDATE credit_balances SET balance = balance + ?, updated_at = ? WHERE owner = ?"
|
|
873
|
-
).run(
|
|
978
|
+
).run(providerAmount, now, recipientOwner);
|
|
979
|
+
if (feeAmount > 0) {
|
|
980
|
+
db.prepare(
|
|
981
|
+
"INSERT OR IGNORE INTO credit_balances (owner, balance, updated_at) VALUES (?, 0, ?)"
|
|
982
|
+
).run("platform_treasury", now);
|
|
983
|
+
db.prepare(
|
|
984
|
+
"UPDATE credit_balances SET balance = balance + ?, updated_at = ? WHERE owner = ?"
|
|
985
|
+
).run(feeAmount, now, "platform_treasury");
|
|
986
|
+
db.prepare(
|
|
987
|
+
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
988
|
+
).run(randomUUID4(), "platform_treasury", feeAmount, "network_fee", escrowId, now);
|
|
989
|
+
}
|
|
874
990
|
db.prepare(
|
|
875
991
|
"UPDATE credit_escrow SET status = ?, settled_at = ? WHERE id = ?"
|
|
876
992
|
).run("settled", now, escrowId);
|
|
877
993
|
db.prepare(
|
|
878
994
|
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
879
|
-
).run(randomUUID4(), recipientOwner,
|
|
995
|
+
).run(randomUUID4(), recipientOwner, providerAmount, "settlement", escrowId, now);
|
|
996
|
+
let providerNum = getProviderNumber(db, recipientOwner);
|
|
997
|
+
if (providerNum === null) {
|
|
998
|
+
providerNum = registerProvider(db, recipientOwner);
|
|
999
|
+
}
|
|
1000
|
+
const bonus = getProviderBonus(providerNum);
|
|
1001
|
+
if (bonus > 1) {
|
|
1002
|
+
const bonusAmount = Math.floor(providerAmount * (bonus - 1));
|
|
1003
|
+
if (bonusAmount > 0) {
|
|
1004
|
+
db.prepare(
|
|
1005
|
+
"INSERT OR IGNORE INTO credit_balances (owner, balance, updated_at) VALUES (?, 0, ?)"
|
|
1006
|
+
).run("platform_treasury", now);
|
|
1007
|
+
db.prepare(
|
|
1008
|
+
"UPDATE credit_balances SET balance = balance + ?, updated_at = ? WHERE owner = ?"
|
|
1009
|
+
).run(bonusAmount, now, recipientOwner);
|
|
1010
|
+
db.prepare(
|
|
1011
|
+
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
1012
|
+
).run(randomUUID4(), recipientOwner, bonusAmount, "provider_bonus", escrowId, now);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
try {
|
|
1016
|
+
recordSuccessfulHire(db, recipientOwner, escrow.owner);
|
|
1017
|
+
} catch {
|
|
1018
|
+
}
|
|
880
1019
|
});
|
|
881
1020
|
settle();
|
|
882
1021
|
}
|
|
883
1022
|
function releaseEscrow(db, escrowId) {
|
|
884
1023
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
885
1024
|
const release = db.transaction(() => {
|
|
886
|
-
const escrow = db.prepare("SELECT id, owner, amount, status FROM credit_escrow WHERE id = ?").get(escrowId);
|
|
1025
|
+
const escrow = db.prepare("SELECT id, owner, amount, status, funding_source FROM credit_escrow WHERE id = ?").get(escrowId);
|
|
887
1026
|
if (!escrow) {
|
|
888
1027
|
throw new AgentBnBError(`Escrow not found: ${escrowId}`, "ESCROW_NOT_FOUND");
|
|
889
1028
|
}
|
|
@@ -908,7 +1047,7 @@ function releaseEscrow(db, escrowId) {
|
|
|
908
1047
|
function confirmEscrowDebit(db, escrowId) {
|
|
909
1048
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
910
1049
|
const confirm = db.transaction(() => {
|
|
911
|
-
const escrow = db.prepare("SELECT id, owner, amount, status FROM credit_escrow WHERE id = ?").get(escrowId);
|
|
1050
|
+
const escrow = db.prepare("SELECT id, owner, amount, status, funding_source FROM credit_escrow WHERE id = ?").get(escrowId);
|
|
912
1051
|
if (!escrow) {
|
|
913
1052
|
throw new AgentBnBError(`Escrow not found: ${escrowId}`, "ESCROW_NOT_FOUND");
|
|
914
1053
|
}
|
|
@@ -1007,6 +1146,7 @@ export {
|
|
|
1007
1146
|
getTransactions,
|
|
1008
1147
|
recordEarning,
|
|
1009
1148
|
migrateOwner,
|
|
1149
|
+
NETWORK_FEE_RATE,
|
|
1010
1150
|
holdEscrow,
|
|
1011
1151
|
settleEscrow,
|
|
1012
1152
|
releaseEscrow,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
NETWORK_FEE_RATE,
|
|
2
3
|
confirmEscrowDebit,
|
|
3
4
|
getBalance,
|
|
4
5
|
getCard,
|
|
@@ -9,23 +10,25 @@ import {
|
|
|
9
10
|
settleEscrow,
|
|
10
11
|
updateReputation,
|
|
11
12
|
verifyEscrowReceipt
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7EF3HYVZ.js";
|
|
13
14
|
import {
|
|
14
15
|
loadConfig
|
|
15
16
|
} from "./chunk-IVOYM3WG.js";
|
|
16
17
|
import {
|
|
17
18
|
AgentBnBError
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-WVY2W7AA.js";
|
|
19
20
|
|
|
20
21
|
// src/gateway/execute.ts
|
|
21
22
|
import { randomUUID } from "crypto";
|
|
22
23
|
|
|
23
24
|
// src/credit/settlement.ts
|
|
24
25
|
function settleProviderEarning(providerDb, providerOwner, receipt) {
|
|
26
|
+
const feeAmount = Math.floor(receipt.amount * NETWORK_FEE_RATE);
|
|
27
|
+
const providerAmount = receipt.amount - feeAmount;
|
|
25
28
|
recordEarning(
|
|
26
29
|
providerDb,
|
|
27
30
|
providerOwner,
|
|
28
|
-
|
|
31
|
+
providerAmount,
|
|
29
32
|
receipt.card_id,
|
|
30
33
|
receipt.nonce
|
|
31
34
|
);
|
|
@@ -150,7 +153,9 @@ async function executeCapabilityRequest(opts) {
|
|
|
150
153
|
const receiptData = isRemoteEscrow ? { receipt_released: true } : void 0;
|
|
151
154
|
const handleFailure = (status, latencyMs, message, failureReason = "bad_execution") => {
|
|
152
155
|
if (!isRemoteEscrow && escrowId) releaseEscrow(creditDb, escrowId);
|
|
153
|
-
|
|
156
|
+
if (failureReason === "bad_execution" || failureReason === "auth_error") {
|
|
157
|
+
updateReputation(registryDb, cardId, false, latencyMs);
|
|
158
|
+
}
|
|
154
159
|
try {
|
|
155
160
|
insertRequestLog(registryDb, {
|
|
156
161
|
id: randomUUID(),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getFeedbackForProvider,
|
|
3
3
|
signEscrowReceipt
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7EF3HYVZ.js";
|
|
5
5
|
import {
|
|
6
6
|
AgentBnBError
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WVY2W7AA.js";
|
|
8
8
|
|
|
9
9
|
// src/gateway/client.ts
|
|
10
10
|
import { randomUUID } from "crypto";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
settleProviderEarning
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X32NE6V4.js";
|
|
4
4
|
import {
|
|
5
5
|
getBalance,
|
|
6
6
|
holdEscrow,
|
|
7
7
|
releaseEscrow,
|
|
8
8
|
settleEscrow
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-D6RKW2XG.js";
|
|
10
10
|
import {
|
|
11
11
|
verifyEscrowReceipt
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CUONY5TO.js";
|
|
13
13
|
import {
|
|
14
14
|
loadConfig
|
|
15
15
|
} from "./chunk-75OC6E4F.js";
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
getCard,
|
|
18
18
|
insertRequestLog,
|
|
19
19
|
updateReputation
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-O2OYBAVR.js";
|
|
21
21
|
import {
|
|
22
22
|
AgentBnBError
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-WVY2W7AA.js";
|
|
24
24
|
|
|
25
25
|
// src/gateway/execute.ts
|
|
26
26
|
import { randomUUID } from "crypto";
|
|
@@ -135,7 +135,9 @@ async function executeCapabilityRequest(opts) {
|
|
|
135
135
|
const receiptData = isRemoteEscrow ? { receipt_released: true } : void 0;
|
|
136
136
|
const handleFailure = (status, latencyMs, message, failureReason = "bad_execution") => {
|
|
137
137
|
if (!isRemoteEscrow && escrowId) releaseEscrow(creditDb, escrowId);
|
|
138
|
-
|
|
138
|
+
if (failureReason === "bad_execution" || failureReason === "auth_error") {
|
|
139
|
+
updateReputation(registryDb, cardId, false, latencyMs);
|
|
140
|
+
}
|
|
139
141
|
try {
|
|
140
142
|
insertRequestLog(registryDb, {
|
|
141
143
|
id: randomUUID(),
|