@agentsgot/agent-kit 0.0.0-stage → 1.0.1
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/ARCHITECTURE.md +5 -0
- package/README.md +13 -2
- package/dist/a2a.d.ts +35 -0
- package/dist/a2a.d.ts.map +1 -0
- package/dist/a2a.js +109 -0
- package/dist/a2a.js.map +1 -0
- package/dist/cli/binding.d.ts +24 -0
- package/dist/cli/binding.d.ts.map +1 -0
- package/dist/cli/binding.js +52 -0
- package/dist/cli/binding.js.map +1 -0
- package/dist/cli/commands.d.ts +18 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +191 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/context.d.ts +61 -0
- package/dist/cli/context.d.ts.map +1 -0
- package/dist/cli/context.js +147 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/doctor.d.ts +34 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +109 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/home.d.ts +37 -0
- package/dist/cli/home.d.ts.map +1 -0
- package/dist/cli/home.js +77 -0
- package/dist/cli/home.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +120 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/install.d.ts +19 -0
- package/dist/cli/install.d.ts.map +1 -0
- package/dist/cli/install.js +64 -0
- package/dist/cli/install.js.map +1 -0
- package/dist/cli/keystore.d.ts +25 -0
- package/dist/cli/keystore.d.ts.map +1 -0
- package/dist/cli/keystore.js +57 -0
- package/dist/cli/keystore.js.map +1 -0
- package/dist/cli/mcp.d.ts +7 -0
- package/dist/cli/mcp.d.ts.map +1 -0
- package/dist/cli/mcp.js +28 -0
- package/dist/cli/mcp.js.map +1 -0
- package/dist/cli/prompt.d.ts +10 -0
- package/dist/cli/prompt.d.ts.map +1 -0
- package/dist/cli/prompt.js +71 -0
- package/dist/cli/prompt.js.map +1 -0
- package/dist/cli/reports.d.ts +42 -0
- package/dist/cli/reports.d.ts.map +1 -0
- package/dist/cli/reports.js +121 -0
- package/dist/cli/reports.js.map +1 -0
- package/dist/cli/run.d.ts +21 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +125 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/wallet.d.ts +19 -0
- package/dist/cli/wallet.d.ts.map +1 -0
- package/dist/cli/wallet.js +58 -0
- package/dist/cli/wallet.js.map +1 -0
- package/dist/guides.d.ts +7 -0
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +94 -0
- package/dist/guides.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/llm.d.ts +16 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/llm.js +30 -0
- package/dist/llm.js.map +1 -0
- package/dist/mcp/cli.d.ts +3 -0
- package/dist/mcp/cli.d.ts.map +1 -0
- package/dist/mcp/cli.js +6 -0
- package/dist/mcp/cli.js.map +1 -0
- package/dist/mcp/server.d.ts +38 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +693 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/ports.d.ts +123 -0
- package/dist/ports.d.ts.map +1 -0
- package/dist/ports.js +134 -0
- package/dist/ports.js.map +1 -0
- package/dist/roles.d.ts +16 -0
- package/dist/roles.d.ts.map +1 -0
- package/dist/roles.js +49 -0
- package/dist/roles.js.map +1 -0
- package/dist/runner.d.ts +126 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +292 -0
- package/dist/runner.js.map +1 -0
- package/dist/schedules.d.ts +34 -0
- package/dist/schedules.d.ts.map +1 -0
- package/dist/schedules.js +116 -0
- package/dist/schedules.js.map +1 -0
- package/dist/sdk/base64.d.ts +4 -0
- package/dist/sdk/base64.d.ts.map +1 -0
- package/dist/sdk/base64.js +15 -0
- package/dist/sdk/base64.js.map +1 -0
- package/dist/sdk/client.d.ts +198 -0
- package/dist/sdk/client.d.ts.map +1 -0
- package/dist/sdk/client.js +413 -0
- package/dist/sdk/client.js.map +1 -0
- package/dist/security.d.ts +10 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +24 -0
- package/dist/security.js.map +1 -0
- package/dist/skills.d.ts +21 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +93 -0
- package/dist/skills.js.map +1 -0
- package/dist/workers.d.ts +64 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +127 -0
- package/dist/workers.js.map +1 -0
- package/dist/zip.d.ts +8 -0
- package/dist/zip.d.ts.map +1 -0
- package/dist/zip.js +80 -0
- package/dist/zip.js.map +1 -0
- package/docs/README.md +25 -0
- package/docs/architecture.md +18 -0
- package/docs/deployment.md +35 -0
- package/docs/reference/01-RULES.md +822 -0
- package/docs/reference/02-INTERFACES.md +487 -0
- package/docs/reference/03-STAKING-PENALTY-SPEC.md +739 -0
- package/docs/updates.md +65 -0
- package/docs/verification.md +72 -0
- package/package.json +88 -4
- package/skills/dist/agent-skills.json +68 -0
- package/skills/dist/arbitrator/SKILL.md +186 -0
- package/skills/dist/executor/SKILL.md +219 -0
- package/skills/dist/publisher/SKILL.md +172 -0
- package/skills/dist/tester/SKILL.md +198 -0
- package/vendor/shared/ARCHITECTURE.md +97 -0
- package/vendor/shared/README.md +5 -0
- package/vendor/shared/abi/index.js +2 -0
- package/vendor/shared/abi/index.ts +2 -0
- package/vendor/shared/abi/protocol/AgentRegistry.js +1623 -0
- package/vendor/shared/abi/protocol/AgentRegistry.json +1623 -0
- package/vendor/shared/abi/protocol/AgentRegistry.ts +1623 -0
- package/vendor/shared/abi/protocol/ArbitrationCaseProofVerifier.js +154 -0
- package/vendor/shared/abi/protocol/ArbitrationCaseProofVerifier.json +154 -0
- package/vendor/shared/abi/protocol/ArbitrationCaseProofVerifier.ts +154 -0
- package/vendor/shared/abi/protocol/ArbitrationCourt.js +1550 -0
- package/vendor/shared/abi/protocol/ArbitrationCourt.json +1550 -0
- package/vendor/shared/abi/protocol/ArbitrationCourt.ts +1550 -0
- package/vendor/shared/abi/protocol/ArbitrationPool.js +509 -0
- package/vendor/shared/abi/protocol/ArbitrationPool.json +509 -0
- package/vendor/shared/abi/protocol/ArbitrationPool.ts +509 -0
- package/vendor/shared/abi/protocol/ArbitrationProgressor.js +44 -0
- package/vendor/shared/abi/protocol/ArbitrationProgressor.json +44 -0
- package/vendor/shared/abi/protocol/ArbitrationProgressor.ts +44 -0
- package/vendor/shared/abi/protocol/ArbitrationSelection.js +1153 -0
- package/vendor/shared/abi/protocol/ArbitrationSelection.json +1153 -0
- package/vendor/shared/abi/protocol/ArbitrationSelection.ts +1153 -0
- package/vendor/shared/abi/protocol/ArbitrationSettlement.js +956 -0
- package/vendor/shared/abi/protocol/ArbitrationSettlement.json +956 -0
- package/vendor/shared/abi/protocol/ArbitrationSettlement.ts +956 -0
- package/vendor/shared/abi/protocol/ArbitrationStream.js +964 -0
- package/vendor/shared/abi/protocol/ArbitrationStream.json +964 -0
- package/vendor/shared/abi/protocol/ArbitrationStream.ts +964 -0
- package/vendor/shared/abi/protocol/EmissionController.js +1436 -0
- package/vendor/shared/abi/protocol/EmissionController.json +1436 -0
- package/vendor/shared/abi/protocol/EmissionController.ts +1436 -0
- package/vendor/shared/abi/protocol/HourlyAnchor.js +611 -0
- package/vendor/shared/abi/protocol/HourlyAnchor.json +611 -0
- package/vendor/shared/abi/protocol/HourlyAnchor.ts +611 -0
- package/vendor/shared/abi/protocol/IncentiveVault.js +480 -0
- package/vendor/shared/abi/protocol/IncentiveVault.json +480 -0
- package/vendor/shared/abi/protocol/IncentiveVault.ts +480 -0
- package/vendor/shared/abi/protocol/ParamRegistry.js +814 -0
- package/vendor/shared/abi/protocol/ParamRegistry.json +814 -0
- package/vendor/shared/abi/protocol/ParamRegistry.ts +814 -0
- package/vendor/shared/abi/protocol/PlatformTreasury.js +553 -0
- package/vendor/shared/abi/protocol/PlatformTreasury.json +553 -0
- package/vendor/shared/abi/protocol/PlatformTreasury.ts +553 -0
- package/vendor/shared/abi/protocol/ProtocolProof.js +1171 -0
- package/vendor/shared/abi/protocol/ProtocolProof.json +1171 -0
- package/vendor/shared/abi/protocol/ProtocolProof.ts +1171 -0
- package/vendor/shared/abi/protocol/PublisherStaking.js +1227 -0
- package/vendor/shared/abi/protocol/PublisherStaking.json +1227 -0
- package/vendor/shared/abi/protocol/PublisherStaking.ts +1227 -0
- package/vendor/shared/abi/protocol/RewardVesting.js +1027 -0
- package/vendor/shared/abi/protocol/RewardVesting.json +1027 -0
- package/vendor/shared/abi/protocol/RewardVesting.ts +1027 -0
- package/vendor/shared/abi/protocol/TaskEscrow.js +2219 -0
- package/vendor/shared/abi/protocol/TaskEscrow.json +2219 -0
- package/vendor/shared/abi/protocol/TaskEscrow.ts +2219 -0
- package/vendor/shared/abi/protocol/TesterAssignment.js +1375 -0
- package/vendor/shared/abi/protocol/TesterAssignment.json +1375 -0
- package/vendor/shared/abi/protocol/TesterAssignment.ts +1375 -0
- package/vendor/shared/abi/protocol/ValidatorStaking.js +1614 -0
- package/vendor/shared/abi/protocol/ValidatorStaking.json +1614 -0
- package/vendor/shared/abi/protocol/ValidatorStaking.ts +1614 -0
- package/vendor/shared/abi/protocol/index.js +19 -0
- package/vendor/shared/abi/protocol/index.ts +19 -0
- package/vendor/shared/abi/token/AGTToken.js +1018 -0
- package/vendor/shared/abi/token/AGTToken.json +1018 -0
- package/vendor/shared/abi/token/AGTToken.ts +1018 -0
- package/vendor/shared/abi/token/GenesisDistributor.js +242 -0
- package/vendor/shared/abi/token/GenesisDistributor.json +242 -0
- package/vendor/shared/abi/token/GenesisDistributor.ts +242 -0
- package/vendor/shared/abi/token/LPLocker.js +21 -0
- package/vendor/shared/abi/token/LPLocker.json +21 -0
- package/vendor/shared/abi/token/LPLocker.ts +21 -0
- package/vendor/shared/abi/token/LaunchLiquidity.js +335 -0
- package/vendor/shared/abi/token/LaunchLiquidity.json +335 -0
- package/vendor/shared/abi/token/LaunchLiquidity.ts +335 -0
- package/vendor/shared/abi/token/LiquidityAdder.js +228 -0
- package/vendor/shared/abi/token/LiquidityAdder.json +228 -0
- package/vendor/shared/abi/token/LiquidityAdder.ts +228 -0
- package/vendor/shared/abi/token/TaxDistributor.js +235 -0
- package/vendor/shared/abi/token/TaxDistributor.json +235 -0
- package/vendor/shared/abi/token/TaxDistributor.ts +235 -0
- package/vendor/shared/abi/token/TestFaucet.js +214 -0
- package/vendor/shared/abi/token/TestFaucet.json +214 -0
- package/vendor/shared/abi/token/TestFaucet.ts +214 -0
- package/vendor/shared/abi/token/index.js +7 -0
- package/vendor/shared/abi/token/index.ts +7 -0
- package/vendor/shared/dist/abi/index.d.ts +3 -0
- package/vendor/shared/dist/abi/index.d.ts.map +1 -0
- package/vendor/shared/dist/abi/index.js +3 -0
- package/vendor/shared/dist/abi/index.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/AgentRegistry.d.ts +1249 -0
- package/vendor/shared/dist/abi/protocol/AgentRegistry.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/AgentRegistry.js +1624 -0
- package/vendor/shared/dist/abi/protocol/AgentRegistry.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationCaseProofVerifier.d.ts +119 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationCaseProofVerifier.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationCaseProofVerifier.js +155 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationCaseProofVerifier.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationCourt.d.ts +1205 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationCourt.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationCourt.js +1551 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationCourt.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationPool.d.ts +391 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationPool.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationPool.js +510 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationPool.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationProgressor.d.ts +34 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationProgressor.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationProgressor.js +45 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationProgressor.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationSelection.d.ts +885 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationSelection.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationSelection.js +1154 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationSelection.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationSettlement.d.ts +742 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationSettlement.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationSettlement.js +957 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationSettlement.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationStream.d.ts +741 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationStream.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationStream.js +965 -0
- package/vendor/shared/dist/abi/protocol/ArbitrationStream.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/EmissionController.d.ts +1110 -0
- package/vendor/shared/dist/abi/protocol/EmissionController.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/EmissionController.js +1437 -0
- package/vendor/shared/dist/abi/protocol/EmissionController.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/HourlyAnchor.d.ts +467 -0
- package/vendor/shared/dist/abi/protocol/HourlyAnchor.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/HourlyAnchor.js +612 -0
- package/vendor/shared/dist/abi/protocol/HourlyAnchor.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/IncentiveVault.d.ts +369 -0
- package/vendor/shared/dist/abi/protocol/IncentiveVault.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/IncentiveVault.js +481 -0
- package/vendor/shared/dist/abi/protocol/IncentiveVault.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ParamRegistry.d.ts +628 -0
- package/vendor/shared/dist/abi/protocol/ParamRegistry.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ParamRegistry.js +815 -0
- package/vendor/shared/dist/abi/protocol/ParamRegistry.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/PlatformTreasury.d.ts +426 -0
- package/vendor/shared/dist/abi/protocol/PlatformTreasury.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/PlatformTreasury.js +554 -0
- package/vendor/shared/dist/abi/protocol/PlatformTreasury.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ProtocolProof.d.ts +903 -0
- package/vendor/shared/dist/abi/protocol/ProtocolProof.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ProtocolProof.js +1172 -0
- package/vendor/shared/dist/abi/protocol/ProtocolProof.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/PublisherStaking.d.ts +947 -0
- package/vendor/shared/dist/abi/protocol/PublisherStaking.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/PublisherStaking.js +1228 -0
- package/vendor/shared/dist/abi/protocol/PublisherStaking.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/RewardVesting.d.ts +793 -0
- package/vendor/shared/dist/abi/protocol/RewardVesting.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/RewardVesting.js +1028 -0
- package/vendor/shared/dist/abi/protocol/RewardVesting.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/TaskEscrow.d.ts +1725 -0
- package/vendor/shared/dist/abi/protocol/TaskEscrow.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/TaskEscrow.js +2220 -0
- package/vendor/shared/dist/abi/protocol/TaskEscrow.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/TesterAssignment.d.ts +1058 -0
- package/vendor/shared/dist/abi/protocol/TesterAssignment.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/TesterAssignment.js +1376 -0
- package/vendor/shared/dist/abi/protocol/TesterAssignment.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/ValidatorStaking.d.ts +1236 -0
- package/vendor/shared/dist/abi/protocol/ValidatorStaking.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/ValidatorStaking.js +1615 -0
- package/vendor/shared/dist/abi/protocol/ValidatorStaking.js.map +1 -0
- package/vendor/shared/dist/abi/protocol/index.d.ts +20 -0
- package/vendor/shared/dist/abi/protocol/index.d.ts.map +1 -0
- package/vendor/shared/dist/abi/protocol/index.js +20 -0
- package/vendor/shared/dist/abi/protocol/index.js.map +1 -0
- package/vendor/shared/dist/abi/token/AGTToken.d.ts +786 -0
- package/vendor/shared/dist/abi/token/AGTToken.d.ts.map +1 -0
- package/vendor/shared/dist/abi/token/AGTToken.js +1019 -0
- package/vendor/shared/dist/abi/token/AGTToken.js.map +1 -0
- package/vendor/shared/dist/abi/token/GenesisDistributor.d.ts +187 -0
- package/vendor/shared/dist/abi/token/GenesisDistributor.d.ts.map +1 -0
- package/vendor/shared/dist/abi/token/GenesisDistributor.js +243 -0
- package/vendor/shared/dist/abi/token/GenesisDistributor.js.map +1 -0
- package/vendor/shared/dist/abi/token/LPLocker.d.ts +16 -0
- package/vendor/shared/dist/abi/token/LPLocker.d.ts.map +1 -0
- package/vendor/shared/dist/abi/token/LPLocker.js +22 -0
- package/vendor/shared/dist/abi/token/LPLocker.js.map +1 -0
- package/vendor/shared/dist/abi/token/LaunchLiquidity.d.ts +260 -0
- package/vendor/shared/dist/abi/token/LaunchLiquidity.d.ts.map +1 -0
- package/vendor/shared/dist/abi/token/LaunchLiquidity.js +336 -0
- package/vendor/shared/dist/abi/token/LaunchLiquidity.js.map +1 -0
- package/vendor/shared/dist/abi/token/LiquidityAdder.d.ts +176 -0
- package/vendor/shared/dist/abi/token/LiquidityAdder.d.ts.map +1 -0
- package/vendor/shared/dist/abi/token/LiquidityAdder.js +229 -0
- package/vendor/shared/dist/abi/token/LiquidityAdder.js.map +1 -0
- package/vendor/shared/dist/abi/token/TaxDistributor.d.ts +182 -0
- package/vendor/shared/dist/abi/token/TaxDistributor.d.ts.map +1 -0
- package/vendor/shared/dist/abi/token/TaxDistributor.js +236 -0
- package/vendor/shared/dist/abi/token/TaxDistributor.js.map +1 -0
- package/vendor/shared/dist/abi/token/TestFaucet.d.ts +164 -0
- package/vendor/shared/dist/abi/token/TestFaucet.d.ts.map +1 -0
- package/vendor/shared/dist/abi/token/TestFaucet.js +215 -0
- package/vendor/shared/dist/abi/token/TestFaucet.js.map +1 -0
- package/vendor/shared/dist/abi/token/index.d.ts +8 -0
- package/vendor/shared/dist/abi/token/index.d.ts.map +1 -0
- package/vendor/shared/dist/abi/token/index.js +8 -0
- package/vendor/shared/dist/abi/token/index.js.map +1 -0
- package/vendor/shared/dist/emission-schedule.d.ts +51 -0
- package/vendor/shared/dist/emission-schedule.d.ts.map +1 -0
- package/vendor/shared/dist/emission-schedule.js +116 -0
- package/vendor/shared/dist/emission-schedule.js.map +1 -0
- package/vendor/shared/dist/index.d.ts +7 -0
- package/vendor/shared/dist/index.d.ts.map +1 -0
- package/vendor/shared/dist/index.js +7 -0
- package/vendor/shared/dist/index.js.map +1 -0
- package/vendor/shared/dist/params/index.d.ts +6 -0
- package/vendor/shared/dist/params/index.d.ts.map +1 -0
- package/vendor/shared/dist/params/index.js +84 -0
- package/vendor/shared/dist/params/index.js.map +1 -0
- package/vendor/shared/dist/protocol-proofs.d.ts +267 -0
- package/vendor/shared/dist/protocol-proofs.d.ts.map +1 -0
- package/vendor/shared/dist/protocol-proofs.js +205 -0
- package/vendor/shared/dist/protocol-proofs.js.map +1 -0
- package/vendor/shared/dist/rules/index.d.ts +204 -0
- package/vendor/shared/dist/rules/index.d.ts.map +1 -0
- package/vendor/shared/dist/rules/index.js +802 -0
- package/vendor/shared/dist/rules/index.js.map +1 -0
- package/vendor/shared/dist/rules/spec-content.d.ts +21 -0
- package/vendor/shared/dist/rules/spec-content.d.ts.map +1 -0
- package/vendor/shared/dist/rules/spec-content.js +90 -0
- package/vendor/shared/dist/rules/spec-content.js.map +1 -0
- package/vendor/shared/dist/rules/task-risk.d.ts +35 -0
- package/vendor/shared/dist/rules/task-risk.d.ts.map +1 -0
- package/vendor/shared/dist/rules/task-risk.js +438 -0
- package/vendor/shared/dist/rules/task-risk.js.map +1 -0
- package/vendor/shared/dist/schemas/domain.d.ts +195 -0
- package/vendor/shared/dist/schemas/domain.d.ts.map +1 -0
- package/vendor/shared/dist/schemas/domain.js +158 -0
- package/vendor/shared/dist/schemas/domain.js.map +1 -0
- package/vendor/shared/dist/schemas/draft.d.ts +730 -0
- package/vendor/shared/dist/schemas/draft.d.ts.map +1 -0
- package/vendor/shared/dist/schemas/draft.js +110 -0
- package/vendor/shared/dist/schemas/draft.js.map +1 -0
- package/vendor/shared/dist/schemas/enums.d.ts +130 -0
- package/vendor/shared/dist/schemas/enums.d.ts.map +1 -0
- package/vendor/shared/dist/schemas/enums.js +63 -0
- package/vendor/shared/dist/schemas/enums.js.map +1 -0
- package/vendor/shared/dist/schemas/index.d.ts +4 -0
- package/vendor/shared/dist/schemas/index.d.ts.map +1 -0
- package/vendor/shared/dist/schemas/index.js +4 -0
- package/vendor/shared/dist/schemas/index.js.map +1 -0
- package/vendor/shared/dist/units.d.ts +10 -0
- package/vendor/shared/dist/units.d.ts.map +1 -0
- package/vendor/shared/dist/units.js +44 -0
- package/vendor/shared/dist/units.js.map +1 -0
- package/vendor/shared/openapi.json +78754 -0
- package/vendor/shared/package.json +43 -0
- package/vendor/shared/params/params.json +152 -0
- package/vendor/shared/params/ranges.json +574 -0
- package/vendor/shared/src/emission-schedule.ts +151 -0
- package/vendor/shared/src/index.ts +6 -0
- package/vendor/shared/src/params/index.ts +139 -0
- package/vendor/shared/src/protocol-proofs.ts +235 -0
- package/vendor/shared/src/rules/index.ts +1081 -0
- package/vendor/shared/src/rules/spec-content.ts +120 -0
- package/vendor/shared/src/rules/task-risk.ts +550 -0
- package/vendor/shared/src/schemas/domain.ts +187 -0
- package/vendor/shared/src/schemas/draft.ts +141 -0
- package/vendor/shared/src/schemas/enums.ts +73 -0
- package/vendor/shared/src/schemas/index.ts +3 -0
- package/vendor/shared/src/units.ts +43 -0
- package/vendor/shared/test/emission-schedule.test.ts +115 -0
- package/vendor/shared/test/fixtures/emission-vectors.json +1055 -0
- package/vendor/shared/test/fixtures.ts +65 -0
- package/vendor/shared/test/params.test.ts +48 -0
- package/vendor/shared/test/properties.test.ts +136 -0
- package/vendor/shared/test/protocol-proofs.test.ts +88 -0
- package/vendor/shared/test/rules.test.ts +474 -0
- package/vendor/shared/test/schemas.test.ts +130 -0
- package/vendor/shared/test/task-risk.test.ts +489 -0
- package/vendor/shared/tsconfig.abi.json +11 -0
- package/vendor/shared/tsconfig.json +23 -0
- package/vendor/shared/types/api/index.d.ts +303 -0
- package/vendor/shared/vitest.config.ts +8 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import rawDefaults from "../../params/params.json" with { type: "json" };
|
|
4
|
+
import rawRanges from "../../params/ranges.json" with { type: "json" };
|
|
5
|
+
|
|
6
|
+
export type Params = typeof rawDefaults;
|
|
7
|
+
export type RuleParams = Params;
|
|
8
|
+
|
|
9
|
+
type Range = { fixed?: boolean; min?: number; max?: number; maxKey?: keyof Params };
|
|
10
|
+
|
|
11
|
+
const parameterRecordSchema = z.record(z.string(), z.number().finite().nullable());
|
|
12
|
+
const parameterKeys = Object.keys(rawDefaults) as (keyof Params)[];
|
|
13
|
+
const ranges = rawRanges as Record<keyof Params, Range>;
|
|
14
|
+
|
|
15
|
+
function assertInvariant(condition: boolean, message: string): asserts condition {
|
|
16
|
+
if (!condition) throw new Error(`Invalid rule parameters: ${message}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function validateParams(candidate: unknown): Params {
|
|
20
|
+
const values = parameterRecordSchema.parse(candidate) as Record<string, number | null>;
|
|
21
|
+
assertInvariant(
|
|
22
|
+
Object.keys(values).length === parameterKeys.length,
|
|
23
|
+
"parameter key count differs from params.json",
|
|
24
|
+
);
|
|
25
|
+
for (const key of parameterKeys) {
|
|
26
|
+
assertInvariant(Object.hasOwn(values, key), `missing ${key}`);
|
|
27
|
+
const value = values[key];
|
|
28
|
+
const range = ranges[key];
|
|
29
|
+
if (value === undefined || range === undefined)
|
|
30
|
+
throw new Error(`Invalid rule parameters: missing ${key}`);
|
|
31
|
+
if (value === null) {
|
|
32
|
+
assertInvariant(rawDefaults[key] === null, `${key} may not be null`);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (range.min !== undefined)
|
|
36
|
+
assertInvariant(value >= range.min, `${key} is below ${range.min}`);
|
|
37
|
+
const maximum = range.maxKey === undefined ? range.max : values[range.maxKey];
|
|
38
|
+
if (maximum !== undefined && maximum !== null) {
|
|
39
|
+
assertInvariant(value <= maximum, `${key} is above ${maximum}`);
|
|
40
|
+
}
|
|
41
|
+
if (range.fixed === true) assertInvariant(value === rawDefaults[key], `${key} is fixed`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const get = (key: keyof Params) => {
|
|
45
|
+
const value = values[key];
|
|
46
|
+
if (value === null || value === undefined) throw new Error(`Expected numeric parameter ${key}`);
|
|
47
|
+
return value;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
assertInvariant(
|
|
51
|
+
get("deductionExecBps") +
|
|
52
|
+
get("deductionTestBps") +
|
|
53
|
+
get("deductionRevBps") +
|
|
54
|
+
get("deductionPlatBps") ===
|
|
55
|
+
10_000,
|
|
56
|
+
"legacy deduction shares must total 10000 bps",
|
|
57
|
+
);
|
|
58
|
+
assertInvariant(
|
|
59
|
+
get("emissionPlatformBps") +
|
|
60
|
+
get("emissionExecBps") +
|
|
61
|
+
get("emissionTestBps") +
|
|
62
|
+
get("emissionArbBps") ===
|
|
63
|
+
10_000,
|
|
64
|
+
"emission shares must total 10000 bps",
|
|
65
|
+
);
|
|
66
|
+
assertInvariant(
|
|
67
|
+
get("vestingT0Bps") + get("vestingT1Bps") + (10_000 - get("vestingT0Bps") - get("vestingT1Bps")) ===
|
|
68
|
+
10_000,
|
|
69
|
+
"vesting shares must total 10000 bps",
|
|
70
|
+
);
|
|
71
|
+
assertInvariant(
|
|
72
|
+
get("tradeTaxBurnShareBps") +
|
|
73
|
+
get("tradeTaxPlatformShareBps") +
|
|
74
|
+
get("tradeTaxLiquidityShareBps") ===
|
|
75
|
+
10_000,
|
|
76
|
+
"trade tax shares must total 10000 bps",
|
|
77
|
+
);
|
|
78
|
+
assertInvariant(
|
|
79
|
+
get("caseFeeMajorityShareBps") + get("caseFeeWinnerShareBps") + get("caseFeePlatformShareBps") ===
|
|
80
|
+
10_000,
|
|
81
|
+
"case fee shares must total 10000 bps",
|
|
82
|
+
);
|
|
83
|
+
assertInvariant(
|
|
84
|
+
get("overturnPlatformShareBps") + get("overturnRighteousShareBps") === 10_000,
|
|
85
|
+
"overturn shares must total 10000 bps",
|
|
86
|
+
);
|
|
87
|
+
assertInvariant(
|
|
88
|
+
get("testerMinStakeAgt") <= get("arbitratorMinStakeAgt") &&
|
|
89
|
+
get("arbitratorMinStakeAgt") <= get("validatorStakeAgt.voluntaryMax"),
|
|
90
|
+
"role thresholds must satisfy tester <= arbitrator <= voluntary maximum",
|
|
91
|
+
);
|
|
92
|
+
assertInvariant(
|
|
93
|
+
get("testerWeightCapAgt") >= get("testerMinStakeAgt") &&
|
|
94
|
+
get("arbitratorWeightCapAgt") >= get("arbitratorMinStakeAgt"),
|
|
95
|
+
"weight caps must not be below their role thresholds",
|
|
96
|
+
);
|
|
97
|
+
assertInvariant(
|
|
98
|
+
get("collusionReporterRewardBps") + get("collusionArbPoolShareBps") === 10_000,
|
|
99
|
+
"collusion shares must total 10000 bps",
|
|
100
|
+
);
|
|
101
|
+
assertInvariant(
|
|
102
|
+
get("tierDailyFee.T1") < get("tierDailyFee.T2") &&
|
|
103
|
+
get("tierDailyFee.T2") < get("tierDailyFee.T3") &&
|
|
104
|
+
get("tierDailyFee.T3") < get("tierDailyFee.T4") &&
|
|
105
|
+
get("tierDailyFee.T4") < get("tierDailyFee.T5"),
|
|
106
|
+
"tier daily fees must be strictly increasing",
|
|
107
|
+
);
|
|
108
|
+
for (const tier of ["T1", "T2", "T3", "T4", "T5"] as const) {
|
|
109
|
+
assertInvariant(
|
|
110
|
+
get(`tierDaysMin.${tier}` as keyof Params) <= get(`tierDaysMax.${tier}` as keyof Params),
|
|
111
|
+
`tierDaysMin.${tier} must not exceed tierDaysMax.${tier}`,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
assertInvariant(
|
|
115
|
+
get("passingThresholdMin") <= get("passingThresholdDefault") &&
|
|
116
|
+
get("passingThresholdDefault") <= get("passingThresholdMax"),
|
|
117
|
+
"passing threshold default must be within min–max range",
|
|
118
|
+
);
|
|
119
|
+
assertInvariant(
|
|
120
|
+
get("junkThreshold") < get("passingThresholdMin"),
|
|
121
|
+
"junk threshold must be below passing threshold min",
|
|
122
|
+
);
|
|
123
|
+
assertInvariant(
|
|
124
|
+
get("participantsMin") <= get("participantsDefault") &&
|
|
125
|
+
get("participantsDefault") <= get("participantsWarning") &&
|
|
126
|
+
get("participantsWarning") <= get("participantsMax"),
|
|
127
|
+
"participant limits must satisfy min <= default <= warning <= max",
|
|
128
|
+
);
|
|
129
|
+
// unrecoverableCostBps is deprecated in economic model v3 and retained for
|
|
130
|
+
// historical rule compatibility; computeTaskDailyEmission uses a fixed rho of 0.8.
|
|
131
|
+
|
|
132
|
+
return values as Params;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export const defaultParams: Params = Object.freeze(validateParams(rawDefaults));
|
|
136
|
+
|
|
137
|
+
export function loadParams(overrides: Partial<Params> = {}): Params {
|
|
138
|
+
return Object.freeze(validateParams({ ...rawDefaults, ...overrides }));
|
|
139
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const Hex32Schema = z.string().regex(/^0x[0-9a-fA-F]{64}$/u);
|
|
4
|
+
const AddressSchema = z.string().regex(/^0x[0-9a-fA-F]{40}$/u);
|
|
5
|
+
const SignatureSchema = z.string().regex(/^0x[0-9a-fA-F]{130}$/u);
|
|
6
|
+
const UintStringSchema = z.string().regex(/^(0|[1-9][0-9]*)$/u);
|
|
7
|
+
|
|
8
|
+
export const CidV1Schema = z.string().regex(/^b[a-z2-7]{10,}$/u);
|
|
9
|
+
|
|
10
|
+
export const ProtocolProofDomainSchema = z.object({
|
|
11
|
+
name: z.literal("AgentGrid Protocol"),
|
|
12
|
+
version: z.literal("1"),
|
|
13
|
+
chainId: z.number().int().positive(),
|
|
14
|
+
verifyingContract: AddressSchema,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const ExecutorDeliverySchema = z.object({
|
|
18
|
+
taskId: Hex32Schema,
|
|
19
|
+
cidHash: Hex32Schema,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const TesterAssignmentSchema = z.object({
|
|
23
|
+
taskId: Hex32Schema,
|
|
24
|
+
executor: AddressSchema,
|
|
25
|
+
testersHash: Hex32Schema,
|
|
26
|
+
seedCommitment: Hex32Schema,
|
|
27
|
+
executorTier: z.number().int().min(0).max(3),
|
|
28
|
+
nonce: UintStringSchema,
|
|
29
|
+
deadline: UintStringSchema,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const TestReportProofSchema = z.object({
|
|
33
|
+
taskId: Hex32Schema,
|
|
34
|
+
cidHash: Hex32Schema,
|
|
35
|
+
executor: AddressSchema,
|
|
36
|
+
conclusionsHash: Hex32Schema,
|
|
37
|
+
approved: z.boolean(),
|
|
38
|
+
signature: SignatureSchema.optional(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const AssignmentVoucherSchema = z.object({
|
|
42
|
+
taskId: Hex32Schema,
|
|
43
|
+
executor: AddressSchema,
|
|
44
|
+
issuedAt: UintStringSchema,
|
|
45
|
+
expiresAt: UintStringSchema,
|
|
46
|
+
nonce: UintStringSchema,
|
|
47
|
+
signature: SignatureSchema.optional(),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const PublisherProfileProofSchema = z.object({
|
|
51
|
+
publisher: AddressSchema,
|
|
52
|
+
completedTasks: z.number().int().min(0).max(0xffff_ffff),
|
|
53
|
+
reputation: z.number().int().min(0).max(2),
|
|
54
|
+
nonce: UintStringSchema,
|
|
55
|
+
deadline: UintStringSchema,
|
|
56
|
+
signature: SignatureSchema.optional(),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const TesterTimeoutProofSchema = z.object({
|
|
60
|
+
taskId: Hex32Schema,
|
|
61
|
+
tester: AddressSchema,
|
|
62
|
+
nonce: UintStringSchema,
|
|
63
|
+
deadline: UintStringSchema,
|
|
64
|
+
signature: SignatureSchema.optional(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const ArbitrationCaseProofSchema = z.object({
|
|
68
|
+
caseId: Hex32Schema,
|
|
69
|
+
taskId: Hex32Schema,
|
|
70
|
+
criteriaHash: Hex32Schema,
|
|
71
|
+
evidenceHash: Hex32Schema,
|
|
72
|
+
nonce: UintStringSchema,
|
|
73
|
+
deadline: UintStringSchema,
|
|
74
|
+
signature: SignatureSchema.optional(),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const CollusionReportProofSchema = z.object({
|
|
78
|
+
juror: AddressSchema,
|
|
79
|
+
reporter: AddressSchema,
|
|
80
|
+
evidenceHash: Hex32Schema,
|
|
81
|
+
nonce: UintStringSchema,
|
|
82
|
+
deadline: UintStringSchema,
|
|
83
|
+
signature: SignatureSchema.optional(),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export const HourlyAnchorProofSchema = z.object({
|
|
87
|
+
hourId: UintStringSchema,
|
|
88
|
+
recordsRoot: Hex32Schema,
|
|
89
|
+
poolSnapshotRoot: Hex32Schema,
|
|
90
|
+
seatSnapshotRoot: Hex32Schema,
|
|
91
|
+
nonce: UintStringSchema,
|
|
92
|
+
deadline: UintStringSchema,
|
|
93
|
+
signature: SignatureSchema.optional(),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const PROTOCOL_PROOF_TYPES = {
|
|
97
|
+
ExecutorDelivery: [
|
|
98
|
+
{ name: "taskId", type: "bytes32" },
|
|
99
|
+
{ name: "cidHash", type: "bytes32" },
|
|
100
|
+
],
|
|
101
|
+
TesterAssignment: [
|
|
102
|
+
{ name: "taskId", type: "bytes32" },
|
|
103
|
+
{ name: "executor", type: "address" },
|
|
104
|
+
{ name: "testersHash", type: "bytes32" },
|
|
105
|
+
{ name: "seedCommitment", type: "bytes32" },
|
|
106
|
+
{ name: "executorTier", type: "uint8" },
|
|
107
|
+
{ name: "nonce", type: "uint256" },
|
|
108
|
+
{ name: "deadline", type: "uint64" },
|
|
109
|
+
],
|
|
110
|
+
TestReport: [
|
|
111
|
+
{ name: "taskId", type: "bytes32" },
|
|
112
|
+
{ name: "cidHash", type: "bytes32" },
|
|
113
|
+
{ name: "executor", type: "address" },
|
|
114
|
+
{ name: "conclusionsHash", type: "bytes32" },
|
|
115
|
+
{ name: "approved", type: "bool" },
|
|
116
|
+
],
|
|
117
|
+
AssignmentVoucher: [
|
|
118
|
+
{ name: "taskId", type: "bytes32" },
|
|
119
|
+
{ name: "executor", type: "address" },
|
|
120
|
+
{ name: "issuedAt", type: "uint64" },
|
|
121
|
+
{ name: "expiresAt", type: "uint64" },
|
|
122
|
+
{ name: "nonce", type: "uint256" },
|
|
123
|
+
],
|
|
124
|
+
PublisherProfile: [
|
|
125
|
+
{ name: "publisher", type: "address" },
|
|
126
|
+
{ name: "completedTasks", type: "uint64" },
|
|
127
|
+
{ name: "reputation", type: "uint8" },
|
|
128
|
+
{ name: "nonce", type: "uint256" },
|
|
129
|
+
{ name: "deadline", type: "uint64" },
|
|
130
|
+
],
|
|
131
|
+
TesterTimeout: [
|
|
132
|
+
{ name: "taskId", type: "bytes32" },
|
|
133
|
+
{ name: "tester", type: "address" },
|
|
134
|
+
{ name: "nonce", type: "uint256" },
|
|
135
|
+
{ name: "deadline", type: "uint64" },
|
|
136
|
+
],
|
|
137
|
+
ArbitrationCase: [
|
|
138
|
+
{ name: "caseId", type: "bytes32" },
|
|
139
|
+
{ name: "taskId", type: "bytes32" },
|
|
140
|
+
{ name: "criteriaHash", type: "bytes32" },
|
|
141
|
+
{ name: "evidenceHash", type: "bytes32" },
|
|
142
|
+
{ name: "nonce", type: "uint256" },
|
|
143
|
+
{ name: "deadline", type: "uint64" },
|
|
144
|
+
],
|
|
145
|
+
CollusionReport: [
|
|
146
|
+
{ name: "juror", type: "address" },
|
|
147
|
+
{ name: "reporter", type: "address" },
|
|
148
|
+
{ name: "evidenceHash", type: "bytes32" },
|
|
149
|
+
{ name: "nonce", type: "uint256" },
|
|
150
|
+
{ name: "deadline", type: "uint64" },
|
|
151
|
+
],
|
|
152
|
+
EmissionHours: [
|
|
153
|
+
{ name: "fromHour", type: "uint64" },
|
|
154
|
+
{ name: "toHour", type: "uint64" },
|
|
155
|
+
{ name: "hoursHash", type: "bytes32" },
|
|
156
|
+
{ name: "nonce", type: "uint256" },
|
|
157
|
+
{ name: "deadline", type: "uint64" },
|
|
158
|
+
],
|
|
159
|
+
Settlement: [
|
|
160
|
+
{ name: "taskId", type: "bytes32" },
|
|
161
|
+
{ name: "resultsHash", type: "bytes32" },
|
|
162
|
+
{ name: "lockedTier", type: "uint8" },
|
|
163
|
+
{ name: "lockedAt", type: "uint64" },
|
|
164
|
+
{ name: "billedUntil", type: "uint64" },
|
|
165
|
+
{ name: "deductionAgt", type: "uint256" },
|
|
166
|
+
{ name: "executorPoolPi", type: "uint256" },
|
|
167
|
+
{ name: "hourId", type: "uint64" },
|
|
168
|
+
{ name: "nonce", type: "uint256" },
|
|
169
|
+
{ name: "deadline", type: "uint64" },
|
|
170
|
+
],
|
|
171
|
+
} as const;
|
|
172
|
+
|
|
173
|
+
export function assertProtocolProofBounds(
|
|
174
|
+
input:
|
|
175
|
+
| { kind: "PUBLISHER_PROFILE"; completedTasks: number; reputation: number }
|
|
176
|
+
| {
|
|
177
|
+
kind: "ARBITRATION_CASE";
|
|
178
|
+
criterionCount: number;
|
|
179
|
+
excludedCount: number;
|
|
180
|
+
sourceCount: number;
|
|
181
|
+
weightBps: readonly number[];
|
|
182
|
+
},
|
|
183
|
+
): void {
|
|
184
|
+
if (input.kind === "PUBLISHER_PROFILE") {
|
|
185
|
+
if (
|
|
186
|
+
!Number.isInteger(input.completedTasks) ||
|
|
187
|
+
input.completedTasks < 0 ||
|
|
188
|
+
input.completedTasks > 0xffff_ffff ||
|
|
189
|
+
!Number.isInteger(input.reputation) ||
|
|
190
|
+
input.reputation < 0 ||
|
|
191
|
+
input.reputation > 2
|
|
192
|
+
)
|
|
193
|
+
throw new RangeError("PUBLISHER_PROFILE_OUT_OF_BOUNDS");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const weightTotal = input.weightBps.reduce((sum, value) => sum + value, 0);
|
|
198
|
+
if (
|
|
199
|
+
input.criterionCount < 1 ||
|
|
200
|
+
input.criterionCount > 64 ||
|
|
201
|
+
input.excludedCount > 256 ||
|
|
202
|
+
input.sourceCount > 256 ||
|
|
203
|
+
input.weightBps.length !== input.criterionCount ||
|
|
204
|
+
weightTotal !== 10_000
|
|
205
|
+
)
|
|
206
|
+
throw new RangeError("ARBITRATION_CASE_OUT_OF_BOUNDS");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const BASE32 = "abcdefghijklmnopqrstuvwxyz234567";
|
|
210
|
+
|
|
211
|
+
export function base32Lower(bytes: Uint8Array): string {
|
|
212
|
+
let result = "";
|
|
213
|
+
let buffer = 0;
|
|
214
|
+
let bits = 0;
|
|
215
|
+
for (const byte of bytes) {
|
|
216
|
+
buffer = (buffer << 8) | byte;
|
|
217
|
+
bits += 8;
|
|
218
|
+
while (bits >= 5) {
|
|
219
|
+
bits -= 5;
|
|
220
|
+
result += BASE32[(buffer >>> bits) & 31];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (bits > 0) result += BASE32[(buffer << (5 - bits)) & 31];
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** CIDv1 for a raw block using sha2-256, matching Kubo block/put with format=raw. */
|
|
228
|
+
export async function rawCidV1(content: Uint8Array): Promise<string> {
|
|
229
|
+
const copy = Uint8Array.from(content);
|
|
230
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", copy.buffer));
|
|
231
|
+
const cid = new Uint8Array(4 + digest.length);
|
|
232
|
+
cid.set([0x01, 0x55, 0x12, 0x20]);
|
|
233
|
+
cid.set(digest, 4);
|
|
234
|
+
return `b${base32Lower(cid)}`;
|
|
235
|
+
}
|