@flop-labs/sdk 0.4.0 → 0.5.2
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/CHANGELOG.md +95 -0
- package/README.md +152 -101
- package/dist/a2a/agent-card.d.ts +51 -1
- package/dist/a2a/agent-card.d.ts.map +1 -1
- package/dist/a2a/agent-card.js +20 -0
- package/dist/a2a/agent-card.js.map +1 -1
- package/dist/a2a/index.d.ts +1 -1
- package/dist/a2a/index.d.ts.map +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a-cjs/agent-card.js +22 -0
- package/dist/a2a-cjs/agent-card.js.map +1 -1
- package/dist/a2a-cjs/index.js +3 -1
- package/dist/a2a-cjs/index.js.map +1 -1
- package/dist/agent/task-delegation.d.ts +1 -1
- package/dist/agent/task-delegation.d.ts.map +1 -1
- package/dist/agent/task-delegation.js +17 -48
- package/dist/agent/task-delegation.js.map +1 -1
- package/dist/agent-wallet.d.ts.map +1 -1
- package/dist/agent-wallet.js +1 -18
- package/dist/agent-wallet.js.map +1 -1
- package/dist/bundle/index.esm.js +1 -1
- package/dist/bundle/index.esm.js.map +1 -1
- package/dist/bundle/index.umd.cjs +1 -1
- package/dist/bundle/index.umd.cjs.map +1 -1
- package/dist/chain-text.d.ts +3 -0
- package/dist/chain-text.d.ts.map +1 -0
- package/dist/chain-text.js +27 -0
- package/dist/chain-text.js.map +1 -0
- package/dist/client.d.ts +16 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +76 -69
- package/dist/client.js.map +1 -1
- package/dist/compute-channel/agent-driver.d.ts.map +1 -1
- package/dist/compute-channel/agent-driver.js +3 -16
- package/dist/compute-channel/agent-driver.js.map +1 -1
- package/dist/compute-channel/direct-session-chain.d.ts.map +1 -1
- package/dist/compute-channel/direct-session-chain.js +63 -37
- package/dist/compute-channel/direct-session-chain.js.map +1 -1
- package/dist/compute-channel/direct-session.d.ts +1 -1
- package/dist/compute-channel/direct-session.d.ts.map +1 -1
- package/dist/compute-channel/direct-session.js +39 -6
- package/dist/compute-channel/direct-session.js.map +1 -1
- package/dist/compute-channel/fcu-admission.d.ts +37 -0
- package/dist/compute-channel/fcu-admission.d.ts.map +1 -0
- package/dist/compute-channel/fcu-admission.js +53 -0
- package/dist/compute-channel/fcu-admission.js.map +1 -0
- package/dist/compute-channel/fcu-agent.d.ts +27 -0
- package/dist/compute-channel/fcu-agent.d.ts.map +1 -0
- package/dist/compute-channel/fcu-agent.js +35 -0
- package/dist/compute-channel/fcu-agent.js.map +1 -0
- package/dist/compute-channel/fcu-policy.d.ts +67 -0
- package/dist/compute-channel/fcu-policy.d.ts.map +1 -0
- package/dist/compute-channel/fcu-policy.js +121 -0
- package/dist/compute-channel/fcu-policy.js.map +1 -0
- package/dist/compute-channel/fcu-profile.d.ts +56 -0
- package/dist/compute-channel/fcu-profile.d.ts.map +1 -0
- package/dist/compute-channel/fcu-profile.js +100 -0
- package/dist/compute-channel/fcu-profile.js.map +1 -0
- package/dist/compute-channel/fcu-serving.d.ts +146 -0
- package/dist/compute-channel/fcu-serving.d.ts.map +1 -0
- package/dist/compute-channel/fcu-serving.js +350 -0
- package/dist/compute-channel/fcu-serving.js.map +1 -0
- package/dist/compute-channel/fcu-sla.d.ts +88 -0
- package/dist/compute-channel/fcu-sla.d.ts.map +1 -0
- package/dist/compute-channel/fcu-sla.js +154 -0
- package/dist/compute-channel/fcu-sla.js.map +1 -0
- package/dist/compute-channel/fcu-store-node.d.ts +10 -0
- package/dist/compute-channel/fcu-store-node.d.ts.map +1 -0
- package/dist/compute-channel/fcu-store-node.js +98 -0
- package/dist/compute-channel/fcu-store-node.js.map +1 -0
- package/dist/compute-channel/fcu-timing.d.ts +34 -0
- package/dist/compute-channel/fcu-timing.d.ts.map +1 -0
- package/dist/compute-channel/fcu-timing.js +79 -0
- package/dist/compute-channel/fcu-timing.js.map +1 -0
- package/dist/compute-channel/flop-submitter.d.ts +1 -1
- package/dist/compute-channel/flop-submitter.d.ts.map +1 -1
- package/dist/compute-channel/flop-submitter.js +10 -20
- package/dist/compute-channel/flop-submitter.js.map +1 -1
- package/dist/compute-channel/index.d.ts +8 -0
- package/dist/compute-channel/index.d.ts.map +1 -1
- package/dist/compute-channel/index.js +8 -0
- package/dist/compute-channel/index.js.map +1 -1
- package/dist/compute-channel/peer-info.d.ts +15 -0
- package/dist/compute-channel/peer-info.d.ts.map +1 -0
- package/dist/compute-channel/peer-info.js +33 -0
- package/dist/compute-channel/peer-info.js.map +1 -0
- package/dist/compute-channel/transport-http.d.ts +18 -4
- package/dist/compute-channel/transport-http.d.ts.map +1 -1
- package/dist/compute-channel/transport-http.js +69 -18
- package/dist/compute-channel/transport-http.js.map +1 -1
- package/dist/connect.d.ts +4 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/connect.js +24 -0
- package/dist/connect.js.map +1 -0
- package/dist/coordination.d.ts.map +1 -1
- package/dist/coordination.js +5 -3
- package/dist/coordination.js.map +1 -1
- package/dist/discovery/discovery-service.d.ts.map +1 -1
- package/dist/discovery/discovery-service.js +19 -28
- package/dist/discovery/discovery-service.js.map +1 -1
- package/dist/faucet.d.ts +7 -2
- package/dist/faucet.d.ts.map +1 -1
- package/dist/faucet.js +39 -51
- package/dist/faucet.js.map +1 -1
- package/dist/htlc-appraisal.d.ts +4 -0
- package/dist/htlc-appraisal.d.ts.map +1 -0
- package/dist/htlc-appraisal.js +25 -0
- package/dist/htlc-appraisal.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/inference-purchase.d.ts +40 -0
- package/dist/inference-purchase.d.ts.map +1 -0
- package/dist/inference-purchase.js +43 -0
- package/dist/inference-purchase.js.map +1 -0
- package/dist/miner-admission.d.ts +124 -0
- package/dist/miner-admission.d.ts.map +1 -0
- package/dist/miner-admission.js +259 -0
- package/dist/miner-admission.js.map +1 -0
- package/dist/model-loader/image-stream.d.ts +29 -0
- package/dist/model-loader/image-stream.d.ts.map +1 -0
- package/dist/model-loader/image-stream.js +71 -0
- package/dist/model-loader/image-stream.js.map +1 -0
- package/dist/model-loader/index.d.ts +1 -0
- package/dist/model-loader/index.d.ts.map +1 -1
- package/dist/model-loader/index.js +1 -0
- package/dist/model-loader/index.js.map +1 -1
- package/dist/model-loader/registry.d.ts.map +1 -1
- package/dist/model-loader/registry.js +2 -8
- package/dist/model-loader/registry.js.map +1 -1
- package/dist/runtime-compatibility.d.ts +1 -1
- package/dist/runtime-compatibility.d.ts.map +1 -1
- package/dist/runtime-compatibility.js +5 -2
- package/dist/runtime-compatibility.js.map +1 -1
- package/dist/submit-tx.d.ts +1 -1
- package/dist/submit-tx.d.ts.map +1 -1
- package/dist/submit-tx.js +5 -13
- package/dist/submit-tx.js.map +1 -1
- package/dist/watch-transaction.d.ts +26 -0
- package/dist/watch-transaction.d.ts.map +1 -0
- package/dist/watch-transaction.js +91 -0
- package/dist/watch-transaction.js.map +1 -0
- package/dist/x402.d.ts +3 -1
- package/dist/x402.d.ts.map +1 -1
- package/dist/x402.js +16 -4
- package/dist/x402.js.map +1 -1
- package/package.json +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,101 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.5.2] - 2026-11-09
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Resolve `flopSessionKeys` and `FlopSessionKeys` in session-bound HTLC creation,
|
|
15
|
+
retaining legacy aliases, spending prechecks, signer-specific nonce and wrapper errors.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `packedImageChunks` / `packedImageStream` / `packedImageSize` emit a checkpoint
|
|
20
|
+
directory's canonical packed image as a stream, holding every file to the
|
|
21
|
+
`(path, size, sha256)` table as it is read, so a DA commitment can be taken over the
|
|
22
|
+
image without materializing it. `normalizeRoot` is now exported from the package root.
|
|
23
|
+
|
|
24
|
+
## [0.5.1] - 2026-11-08
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- `MinerTurnError`: `HttpSessionTransport` raises it when a miner's turn stream ends with a
|
|
29
|
+
`{"type":"error"}` line, carrying the miner's reason (newlines removed, at most 300
|
|
30
|
+
characters). The reason is unsigned and diagnostic only. A stream that stops without one
|
|
31
|
+
still fails with "missing terminal receipt".
|
|
32
|
+
|
|
33
|
+
- An explicit Pi Durable A2A card profile for authenticated text tasks, with unsupported
|
|
34
|
+
payment rails and optional capabilities omitted; generic card defaults remain unchanged.
|
|
35
|
+
|
|
36
|
+
- Authenticated prior-finalization and terminal compute/receipt/fence checkpoints
|
|
37
|
+
for FCU claim ordering and miner capacity release, with rejecting conformance cases.
|
|
38
|
+
|
|
39
|
+
- FCU verified late/missing-timing delivery accounting and finalized-only SLA claim
|
|
40
|
+
transitions with original-beneficiary snapshots, reserve encumbrance and atomic
|
|
41
|
+
settlement ports. Native reserve funding and production adapters remain gated.
|
|
42
|
+
|
|
43
|
+
- Ratified FCU admission/cutoff/finality checks, immutable qualification policy,
|
|
44
|
+
miner-wide CAS capacity ledger and conservative two-operator timing verification.
|
|
45
|
+
These require authenticated adapters and leave activation off.
|
|
46
|
+
|
|
47
|
+
- Fresh enclave info-proof and channel-authentication helpers, with injected peer transports,
|
|
48
|
+
redirect refusal, bounded responses and explicit miner readiness.
|
|
49
|
+
|
|
50
|
+
- FCU calendar delivery series D+1 through D+14 at noon UTC, with D+7 default,
|
|
51
|
+
capacity-based quantities and separate scheduled/delivering/window-ended display.
|
|
52
|
+
Calendar dates replace the provisional elapsed-time booking cap; window expiry
|
|
53
|
+
does not settle financial claims or roll old rights into a new series.
|
|
54
|
+
|
|
55
|
+
- Activation-gated FCU service-profile commitments and signed bounded admission,
|
|
56
|
+
holder coordination with durable pending-work accounting, independent timing
|
|
57
|
+
verification ports, pause/drain controls and an agent request client. New primary
|
|
58
|
+
delivery uses the fourteen UTC-calendar noon series; duration remains separate.
|
|
59
|
+
- Node-only `FcuFileStore` for local qualification journals and CPU agent/session
|
|
60
|
+
conformance tests. These additions do not qualify a GPU, supply a production
|
|
61
|
+
registry/clock adapter or activate FCU.
|
|
62
|
+
|
|
63
|
+
### Fixed
|
|
64
|
+
|
|
65
|
+
- Reconcile direct-session cooperative settlement using finalized matching claims;
|
|
66
|
+
preserve payment HTTP failures, faucet refusals, and local delegation outcomes.
|
|
67
|
+
- Route package bug reports to the public network issue forms.
|
|
68
|
+
|
|
69
|
+
- Distinguish exact finalized dispatch failures from unconfirmed transaction
|
|
70
|
+
outcomes, retaining transaction/block/call identity for safe miner recovery.
|
|
71
|
+
- Align README onboarding connection, HTLC, wallet creation/funding and settlement
|
|
72
|
+
examples with the public API, and typecheck the actual onboarding snippets against it.
|
|
73
|
+
|
|
74
|
+
- Clarify and test `FaucetClient.healthCheck()` as HTTP readiness, including false
|
|
75
|
+
for an unchecked caller classification on a live faucet; it is not a funding gate.
|
|
76
|
+
|
|
77
|
+
- Bound initial RPC connections and transaction watches; report terminal watch
|
|
78
|
+
statuses as unconfirmed, release subscriptions and preserve finalized-state recovery.
|
|
79
|
+
- Decode registry text as strict UTF-8 while retaining hash identities and surface lookup errors.
|
|
80
|
+
- Preserve faucet 503 status, refusal reason and server retry timing.
|
|
81
|
+
|
|
82
|
+
- Serve qualified retired FCU profiles through the ratified registry contract,
|
|
83
|
+
reject unqualified/emergency-paused execution, and require authenticated sold
|
|
84
|
+
history bounds that fit the complete quota and serving store before initialization.
|
|
85
|
+
- Verify FCU execution before pinning late or inconclusive output. Retain absolute
|
|
86
|
+
timing bounds and verified work across restart, reject contradictory refinements,
|
|
87
|
+
and preserve reservations and receipt checkpoints when verification fails.
|
|
88
|
+
|
|
89
|
+
### Changed
|
|
90
|
+
|
|
91
|
+
- Admit runtime spec 1014014 (built from b451ae9a2, PR #3744: `max_active_reservations_base` 4 to 400,
|
|
92
|
+
D-0540; call, storage and receipt encodings unchanged). Devnet has run it since block 3,105,608,
|
|
93
|
+
where every SDK client stopped with `RUNTIME_INCOMPATIBLE`; the exported range now ends at
|
|
94
|
+
1014014 and still admits only the listed versions.
|
|
95
|
+
|
|
96
|
+
- `buyInferenceSession` now requires a persisted purchase intent or an awaited
|
|
97
|
+
`onPrepared` callback. `prepareInferenceSession` exposes the channel nonce, identity
|
|
98
|
+
and receipt key before submission. Retries retain that identity and stop on an
|
|
99
|
+
existing finalized channel instead of replaying off-chain turns. This API tightening
|
|
100
|
+
requires a breaking-change release; do not republish the existing version.
|
|
101
|
+
|
|
102
|
+
- Qualify candidate runtime 1,014,013 additive native FCU profile/status calls with
|
|
103
|
+
actual metadata codec checks; keep unsupported future versions rejected.
|
|
104
|
+
|
|
10
105
|
## [0.4.0] - 2026-10-28
|
|
11
106
|
|
|
12
107
|
### Added
|
package/README.md
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
# @flop-labs/sdk
|
|
2
2
|
|
|
3
|
+
`FaucetClient.healthCheck()` reports the faucet's HTTP readiness as a boolean.
|
|
4
|
+
It returns `false` for HTTP 503 or a request failure, including a live faucet
|
|
5
|
+
whose caller IP classification has not been checked. This is not a process-liveness
|
|
6
|
+
or grant-eligibility test. The health GET does not request funds or classify the IP.
|
|
7
|
+
An explicit `requestFaucetFunding()` attempt performs admission and returns the
|
|
8
|
+
refusal reason and `retryAfterSeconds`; respect that delay before retrying.
|
|
9
|
+
Do not gate a user's explicit funding request solely on `healthCheck()`.
|
|
10
|
+
|
|
3
11
|
Ordinary HTLC creation requires a registered EconomicCritical appraisal profile.
|
|
4
12
|
Supply `tee_requirements` / `teeRequirements` as `{profile: {profile_id, version}, model_hash, measurement_hash}` (32-byte hex hashes), or its canonical 100-byte SCALE hex.
|
|
5
13
|
The runtime checks that the registered profile and immutable commitments match its policy; there is no simulator default.
|
|
6
14
|
For the examples, set `FLOP_HTLC_TEE_REQUIREMENTS` to that canonical hex from your network's registered profile.
|
|
7
15
|
|
|
8
|
-
TypeScript SDK for the FLOP Network — HTLC workflows,
|
|
16
|
+
TypeScript SDK for the FLOP Network — HTLC workflows, PoI proofs, and account management.
|
|
9
17
|
|
|
10
|
-
`SUPPORTED_SPEC_VERSIONS` admits exactly `1013000`, `1014000`, `1014001`, `1014002`, `1014003`, `1014004`, `1014005`
|
|
18
|
+
`SUPPORTED_SPEC_VERSIONS` in this source admits exactly `1013000`, `1014000`, `1014001`, `1014002`, `1014003`, `1014004`, `1014005`, `1014007`, `1014008`, `1014009`, `1014010`, `1014011`, `1014012`, `1014013`, `1014014`.
|
|
11
19
|
`SUPPORTED_SPEC_VERSION_RANGE` retains its exported shape as the envelope
|
|
12
|
-
`1013000..
|
|
20
|
+
`1013000..1014014`; admission requires exact membership (including no `1014006`). The published `0.4.0` executable stops at `1014011` and also excludes `1014006`;
|
|
21
|
+
its bundled README has stale connection and HTLC examples. These source corrections
|
|
22
|
+
are unreleased: installing `@latest` does not deliver them until a new version is
|
|
23
|
+
published. The examples below describe this source candidate. Qualification covers
|
|
13
24
|
runtime `1013000` at `44a5fedc88614b9a6e8c97605c2ec943faf47d9d`, the
|
|
14
25
|
registrar runtime `1014000` at `e4f01cc849fa6c768d5c0f9c111dffb450ea4fa9`
|
|
15
26
|
(PR #2726), runtime `1014001` at `de4e2779dbf6f8d25348953ce0992ef8e89756bd`
|
|
@@ -18,8 +29,8 @@ registrar runtime `1014000` at `e4f01cc849fa6c768d5c0f9c111dffb450ea4fa9`
|
|
|
18
29
|
`1014004` (1.14.4, PR #3006) has source compatibility coverage for uploader-funded
|
|
19
30
|
qualification. Candidate runtime `1014005` (1.14.5) has source compatibility coverage for the
|
|
20
31
|
preactivation FCU name replacement; this does not qualify physical latency or deployment.
|
|
21
|
-
Candidate
|
|
22
|
-
|
|
32
|
+
Candidate specs beyond `1014003` have source compatibility coverage; acceptance by
|
|
33
|
+
the SDK does not establish deployment or end-to-end inference qualification.
|
|
23
34
|
Other versions require separate qualification.
|
|
24
35
|
Every `FlopClient` connection path checks it. Unsupported runtime upgrades detected
|
|
25
36
|
by polkadot.js metadata events disconnect the API and make subsequent SDK operations
|
|
@@ -44,22 +55,61 @@ npm install @flop-labs/sdk react # Optional: for React integration
|
|
|
44
55
|
|
|
45
56
|
## Quick Start
|
|
46
57
|
|
|
58
|
+
The live devnet was checked at finalized block 2,764,673 on 3 November 2026:
|
|
59
|
+
spec `1014003`, with an empty `attest.profiles` registry. The HTLC example below
|
|
60
|
+
cannot run there until authorized governance registers its exact EconomicCritical
|
|
61
|
+
appraisal policy, verifier set and version. Neither simulator mode nor an arbitrary
|
|
62
|
+
profile ID supplies that prerequisite. Use `assertHtlcAppraisalProfile(api, hex)`
|
|
63
|
+
before signing; the runtime independently enforces the policy and commitments.
|
|
64
|
+
The three exported ghost/TOPLOC/DA profile references are not HTLC profiles.
|
|
65
|
+
|
|
66
|
+
For a direct compute-channel purchase, prepare and persist the original intent:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { FlopClient } from '@flop-labs/sdk';
|
|
70
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
71
|
+
|
|
72
|
+
const client = await FlopClient.createWithKeypair('wss://rpc.devnet.flop.network', keypair);
|
|
73
|
+
try {
|
|
74
|
+
// Run preparation once, in a private directory. The intent contains a session seed.
|
|
75
|
+
const intent = await client.prepareInferenceSession({ minerUrl, escrowFlop: 0.01, maxTurns: 1 });
|
|
76
|
+
await writeFile('purchase.json', JSON.stringify(intent), { flag: 'wx', mode: 0o600 });
|
|
77
|
+
const saved = JSON.parse(await readFile('purchase.json', 'utf8'));
|
|
78
|
+
const result = await client.buyInferenceSession({ intent: saved, prompt: 'Hello' });
|
|
79
|
+
console.log(result.channelId, result.status);
|
|
80
|
+
} finally { await client.disconnect(); }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
On restart, read the existing file and pass that intent; never run preparation
|
|
84
|
+
again for the same purchase. Hold exclusive ownership of the file while using it.
|
|
85
|
+
Alternatively, `buyInferenceSession` accepts an awaited `onPrepared` persistence
|
|
86
|
+
callback. Calls without an intent or callback stop before signing. This tightens
|
|
87
|
+
the former convenience API and needs a breaking-change release.
|
|
88
|
+
The SDK reads finalized state before submitting. A missing record is still an
|
|
89
|
+
unconfirmed outcome; resubmission retains the original channel nonce and key.
|
|
90
|
+
An existing channel stops with `INFERENCE_PURCHASE_UNCONFIRMED` and its public ID.
|
|
91
|
+
Even `Open` may have streamed off-chain turns: do not replay them with fresh counters.
|
|
92
|
+
Inspect settlement or recover the retained transcript; if an undelivered Open
|
|
93
|
+
channel exceeds its SLA, use the permissionless timeout path after confirming
|
|
94
|
+
eligibility. Retain the intent until recovery and settlement/refund are finalized.
|
|
95
|
+
Repeated extrinsics may still pay fees. `settlement_posted` opens a challenge
|
|
96
|
+
window and does not establish a finalized miner payment.
|
|
97
|
+
|
|
47
98
|
```typescript
|
|
48
99
|
import { FlopClient, createAgentWallet } from '@flop-labs/sdk';
|
|
49
100
|
|
|
50
101
|
// Connect to FLOP node
|
|
51
|
-
const client =
|
|
52
|
-
rpcUrl: 'http://127.0.0.1:16111/rpc'
|
|
53
|
-
});
|
|
102
|
+
const client = await FlopClient.create({ endpoint: 'ws://127.0.0.1:9944', signer: '//Alice' });
|
|
54
103
|
|
|
55
104
|
// Check node health
|
|
56
105
|
const health = await client.health();
|
|
57
106
|
console.log('Node healthy:', health);
|
|
58
107
|
|
|
59
108
|
// Create an agent wallet
|
|
60
|
-
const wallet = await createAgentWallet(client, {
|
|
61
|
-
|
|
62
|
-
|
|
109
|
+
const wallet = await createAgentWallet(client.api, client.signer, {
|
|
110
|
+
agent: client.address,
|
|
111
|
+
dailyCap: 100n * 10n ** 18n,
|
|
112
|
+
perTxLimit: 5n * 10n ** 18n,
|
|
63
113
|
});
|
|
64
114
|
|
|
65
115
|
// Create HTLC for inference purchase
|
|
@@ -70,7 +120,7 @@ const htlc = await client.createHtlc({
|
|
|
70
120
|
prompt: 'Hello, world!',
|
|
71
121
|
tee_requirements: process.env.FLOP_HTLC_TEE_REQUIREMENTS
|
|
72
122
|
},
|
|
73
|
-
|
|
123
|
+
rewardFlop: 5.0,
|
|
74
124
|
timeoutBlocks: 60
|
|
75
125
|
});
|
|
76
126
|
|
|
@@ -87,15 +137,16 @@ console.log('Settlement:', status);
|
|
|
87
137
|
|
|
88
138
|
Main client for interacting with the FLOP Network.
|
|
89
139
|
|
|
90
|
-
####
|
|
140
|
+
#### Connection factories
|
|
91
141
|
|
|
92
142
|
```typescript
|
|
93
|
-
|
|
143
|
+
await FlopClient.create(options?: FlopClientOptions)
|
|
94
144
|
```
|
|
95
145
|
|
|
96
146
|
**Options:**
|
|
97
|
-
- `
|
|
98
|
-
- `
|
|
147
|
+
- `endpoint` (string, optional): RPC endpoint URL. Default: `ws://127.0.0.1:9944`
|
|
148
|
+
- `signer` (string, optional): local signer URI; the `//Alice` default is for disposable local development only.
|
|
149
|
+
- `createWithKeypair(endpoint, keypair)`: connect using an existing decoded keypair.
|
|
99
150
|
|
|
100
151
|
#### Methods
|
|
101
152
|
|
|
@@ -116,7 +167,7 @@ Create a Hash Time Lock Contract for atomic inference purchase.
|
|
|
116
167
|
await client.createHtlc({
|
|
117
168
|
agent: string,
|
|
118
169
|
task: ComputeTask,
|
|
119
|
-
|
|
170
|
+
rewardFlop: number,
|
|
120
171
|
timeoutBlocks: number,
|
|
121
172
|
hashLock?: string // Auto-generated if not provided
|
|
122
173
|
});
|
|
@@ -128,7 +179,7 @@ await client.createHtlc({
|
|
|
128
179
|
htlcId: string;
|
|
129
180
|
hashLock: string;
|
|
130
181
|
preImage: string;
|
|
131
|
-
|
|
182
|
+
txHash: string;
|
|
132
183
|
}
|
|
133
184
|
```
|
|
134
185
|
|
|
@@ -158,30 +209,31 @@ Query HTLC status by hash lock.
|
|
|
158
209
|
|
|
159
210
|
```typescript
|
|
160
211
|
await client.checkHtlcStatus('0x...');
|
|
161
|
-
// Returns:
|
|
212
|
+
// Returns: HtlcInfo | null (RPC fields include reward_amount and timeout_block)
|
|
162
213
|
```
|
|
163
214
|
|
|
164
|
-
##### `waitForSettlement(hashLock,
|
|
215
|
+
##### `waitForSettlement(hashLock, timeoutMs?, pollIntervalMs?)`
|
|
165
216
|
|
|
166
217
|
Poll HTLC until settled or timeout.
|
|
167
218
|
|
|
168
219
|
```typescript
|
|
169
|
-
await client.waitForSettlement('0x...',
|
|
170
|
-
// Returns:
|
|
220
|
+
await client.waitForSettlement('0x...', 30_000, 1_000);
|
|
221
|
+
// Returns: HtlcInfo with status SETTLED or REFUNDED, or null on polling timeout.
|
|
222
|
+
// null does not refund funds; reconcile the original HTLC before retrying.
|
|
171
223
|
```
|
|
172
224
|
|
|
173
|
-
##### `getBalance(address)`
|
|
225
|
+
##### `getBalance(address?)`
|
|
174
226
|
|
|
175
227
|
Get account balance in FLOP tokens.
|
|
176
228
|
|
|
177
229
|
```typescript
|
|
178
|
-
await client.getBalance(
|
|
179
|
-
// Returns:
|
|
230
|
+
await client.getBalance(); // Defaults to the connected account's SS58 address.
|
|
231
|
+
// Returns: string (human-readable FLOP, preserving decimal precision)
|
|
180
232
|
```
|
|
181
233
|
|
|
182
234
|
##### `submitPoUI(proofs, gnWeight, taskHash)`
|
|
183
235
|
|
|
184
|
-
Submit TEE-verified
|
|
236
|
+
Submit TEE-verified PoI proof batch.
|
|
185
237
|
|
|
186
238
|
```typescript
|
|
187
239
|
await client.submitPoUI(proofs, 1450, '0x...');
|
|
@@ -215,28 +267,29 @@ await client.getTeeQuote({ model: 'llama-3-8b', prompt: '...' });
|
|
|
215
267
|
|
|
216
268
|
Create and manage agent wallets with session keys.
|
|
217
269
|
|
|
218
|
-
#### `createAgentWallet(
|
|
270
|
+
#### `createAgentWallet(api, signer, options)`
|
|
219
271
|
|
|
220
272
|
Create a new agent wallet.
|
|
221
273
|
|
|
222
274
|
```typescript
|
|
223
275
|
import { createAgentWallet } from '@flop-labs/sdk';
|
|
224
276
|
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
277
|
+
const walletTxHash = await createAgentWallet(client.api, client.signer, {
|
|
278
|
+
agent: agentAddress, // Existing agent SS58 account, distinct from the owner.
|
|
279
|
+
dailyCap: 100n * 10n ** 18n,
|
|
280
|
+
perTxLimit: 5n * 10n ** 18n,
|
|
229
281
|
});
|
|
282
|
+
// Returns the transaction hash, not a wallet object.
|
|
230
283
|
```
|
|
231
284
|
|
|
232
|
-
#### `fundAgentWallet(
|
|
285
|
+
#### `fundAgentWallet(api, signer, agent, amountRaw)`
|
|
233
286
|
|
|
234
287
|
Fund an agent wallet from owner account.
|
|
235
288
|
|
|
236
289
|
```typescript
|
|
237
290
|
import { fundAgentWallet } from '@flop-labs/sdk';
|
|
238
291
|
|
|
239
|
-
await fundAgentWallet(client,
|
|
292
|
+
await fundAgentWallet(client.api, client.signer, agentAddress, 50n * 10n ** 18n);
|
|
240
293
|
```
|
|
241
294
|
|
|
242
295
|
#### `agentTransfer(client, fromWallet, toAddress, amount)`
|
|
@@ -326,7 +379,11 @@ in the chat envelope bound by the verified receipt. Inspect `receipts[0].finishR
|
|
|
326
379
|
`completionTokens` for truncation. The 60-second turn deadline remains in force;
|
|
327
380
|
larger token budgets do not extend it. Settlement separately waits for the channel's
|
|
328
381
|
finalized calibration allowance before submitting payment. Cooperative delivery and
|
|
329
|
-
finalized-event discovery
|
|
382
|
+
finalized-event discovery each have a bounded 60-second window. Expired channels use
|
|
383
|
+
timeout recovery. If the result is unknown, retain the channel ID and inspect finalized
|
|
384
|
+
channel state and terminal events before retrying; a closed channel alone does not prove
|
|
385
|
+
successful settlement. A zero-turn force-open can be expired after its acknowledgement
|
|
386
|
+
deadline, and an open channel can be timed out after its lifetime.
|
|
330
387
|
|
|
331
388
|
### Session Estimation (compute channel)
|
|
332
389
|
|
|
@@ -363,13 +420,7 @@ interface ComputeTask {
|
|
|
363
420
|
temperature?: number;
|
|
364
421
|
}
|
|
365
422
|
|
|
366
|
-
|
|
367
|
-
htlcId: string;
|
|
368
|
-
hashLock: string;
|
|
369
|
-
rewardAmount: number;
|
|
370
|
-
timeoutBlock: number;
|
|
371
|
-
status: 'CREATED' | 'SETTLED' | 'REFUNDED';
|
|
372
|
-
}
|
|
423
|
+
type HtlcInfo = import('@flop-labs/sdk').HtlcInfo;
|
|
373
424
|
|
|
374
425
|
interface PoUISubmission {
|
|
375
426
|
proofHash: string;
|
|
@@ -390,78 +441,78 @@ interface WalletInfo {
|
|
|
390
441
|
## Error Handling
|
|
391
442
|
|
|
392
443
|
```typescript
|
|
393
|
-
import { FlopClient } from '@flop-labs/sdk';
|
|
394
|
-
|
|
395
|
-
const client = new FlopClient();
|
|
444
|
+
import { FlopClient, FlopError } from '@flop-labs/sdk';
|
|
396
445
|
|
|
446
|
+
let client: FlopClient | undefined;
|
|
397
447
|
try {
|
|
398
|
-
await
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
console.error(
|
|
448
|
+
client = await FlopClient.create({ endpoint: 'ws://127.0.0.1:9944', signer: '//Alice' });
|
|
449
|
+
console.log(await client.health());
|
|
450
|
+
} catch (error: unknown) {
|
|
451
|
+
if (error instanceof FlopError) {
|
|
452
|
+
// Includes RUNTIME_INCOMPATIBLE raised while awaiting the connection factory.
|
|
453
|
+
console.error(error.code, error.message);
|
|
454
|
+
} else if (error instanceof Error) {
|
|
455
|
+
console.error(error.message);
|
|
404
456
|
} else {
|
|
405
|
-
console.error('
|
|
457
|
+
console.error('Unexpected error:', error);
|
|
406
458
|
}
|
|
459
|
+
} finally {
|
|
460
|
+
await client?.disconnect();
|
|
407
461
|
}
|
|
408
462
|
```
|
|
409
463
|
|
|
410
464
|
## Complete Example
|
|
411
465
|
|
|
466
|
+
This source example uses the public, well-known `//Alice` key only on a disposable
|
|
467
|
+
local chain. Set `FLOP_AGENT_ADDRESS` to the agent's SS58 account and
|
|
468
|
+
`FLOP_HTLC_TEE_REQUIREMENTS` to the registered appraisal requirements matching
|
|
469
|
+
the model used below. Use a private working directory. The HTLC recovery file is created exclusively before
|
|
470
|
+
transactions; retain it on errors and reconcile its original hash lock before
|
|
471
|
+
resuming, rather than rerunning this one-time setup. Never log its pre-image.
|
|
472
|
+
|
|
412
473
|
```typescript
|
|
413
|
-
import {
|
|
474
|
+
import { writeFile } from 'node:fs/promises';
|
|
475
|
+
import { FlopClient, assertHtlcAppraisalProfile, createAgentWallet, fundAgentWallet } from '@flop-labs/sdk';
|
|
414
476
|
|
|
415
477
|
async function main() {
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
console.log('✓ HTLC created:', htlc.htlcId);
|
|
455
|
-
|
|
456
|
-
// Wait for miner to settle
|
|
457
|
-
console.log('Waiting for settlement...');
|
|
458
|
-
const settlement = await client.waitForSettlement(hashLock, 30);
|
|
459
|
-
|
|
460
|
-
if (settlement) {
|
|
461
|
-
console.log('✓ Settled by miner:', settlement.miner);
|
|
462
|
-
console.log('✓ Compute used:', settlement.gnUsed, 'G_n');
|
|
463
|
-
} else {
|
|
464
|
-
console.log('⚠ Timeout - funds refunded');
|
|
478
|
+
const agentAddress = process.env.FLOP_AGENT_ADDRESS;
|
|
479
|
+
const teeRequirements = process.env.FLOP_HTLC_TEE_REQUIREMENTS;
|
|
480
|
+
if (!agentAddress || !teeRequirements) throw new Error('Set the agent address and registered HTLC appraisal requirements');
|
|
481
|
+
const client = await FlopClient.create({ endpoint: 'ws://127.0.0.1:9944', signer: '//Alice' });
|
|
482
|
+
try {
|
|
483
|
+
await assertHtlcAppraisalProfile(client.api, teeRequirements);
|
|
484
|
+
const { preImage, hashLock } = FlopClient.generateSecrets();
|
|
485
|
+
await writeFile('htlc-purchase.json', JSON.stringify({ preImage, hashLock }) + '\n', { flag: 'wx', mode: 0o600 });
|
|
486
|
+
|
|
487
|
+
const FLOP = 10n ** 18n;
|
|
488
|
+
const walletTxHash = await createAgentWallet(client.api, client.signer, {
|
|
489
|
+
agent: agentAddress,
|
|
490
|
+
dailyCap: 100n * FLOP,
|
|
491
|
+
perTxLimit: 5n * FLOP,
|
|
492
|
+
});
|
|
493
|
+
console.log('Wallet creation transaction:', walletTxHash);
|
|
494
|
+
await fundAgentWallet(client.api, client.signer, agentAddress, 50n * FLOP);
|
|
495
|
+
|
|
496
|
+
// This direct HTLC uses the owner's balance, separately from the agent wallet.
|
|
497
|
+
const htlc = await client.createHtlc({
|
|
498
|
+
agent: agentAddress,
|
|
499
|
+
task: { model: 'llama-3-8b', prompt: 'Analyze BTC price trend', tee_requirements: teeRequirements },
|
|
500
|
+
rewardFlop: 5.0,
|
|
501
|
+
timeoutBlocks: 60,
|
|
502
|
+
hashLock,
|
|
503
|
+
});
|
|
504
|
+
console.log('HTLC created:', htlc.htlcId);
|
|
505
|
+
|
|
506
|
+
const settlement = await client.waitForSettlement(hashLock, 30_000, 1_000);
|
|
507
|
+
if (settlement?.status === 'SETTLED') {
|
|
508
|
+
console.log('Node reports settlement:', settlement.miner, settlement.gn_used);
|
|
509
|
+
} else if (settlement?.status === 'REFUNDED') {
|
|
510
|
+
console.log('Node reports a refund; confirm finality before treating it as complete');
|
|
511
|
+
} else {
|
|
512
|
+
console.log('Unconfirmed: polling timed out without a refund. Keep the original intent and reconcile chain state');
|
|
513
|
+
}
|
|
514
|
+
} finally {
|
|
515
|
+
await client.disconnect();
|
|
465
516
|
}
|
|
466
517
|
}
|
|
467
518
|
|
package/dist/a2a/agent-card.d.ts
CHANGED
|
@@ -5,7 +5,28 @@
|
|
|
5
5
|
* Agent Card. Pure + deterministic — no chain I/O — so it is trivially
|
|
6
6
|
* testable and reusable by the MCP server and the x402 gateway.
|
|
7
7
|
*/
|
|
8
|
-
import type { AgentCard, FlopAgentExtension } from "./types.js";
|
|
8
|
+
import type { AgentCard, AgentSkill, FlopAgentExtension } from "./types.js";
|
|
9
|
+
/** The opt-in Pi endpoint implements authenticated text tasks, not a payment transport. */
|
|
10
|
+
export declare const PI_DURABLE_A2A_PROFILE: {
|
|
11
|
+
readonly protocolVersion: "0.3.0";
|
|
12
|
+
readonly preferredTransport: "JSONRPC";
|
|
13
|
+
readonly capabilities: {
|
|
14
|
+
readonly streaming: false;
|
|
15
|
+
readonly pushNotifications: false;
|
|
16
|
+
readonly stateTransitionHistory: false;
|
|
17
|
+
};
|
|
18
|
+
readonly defaultInputModes: readonly ["text/plain"];
|
|
19
|
+
readonly defaultOutputModes: readonly ["text/plain"];
|
|
20
|
+
readonly securitySchemes: {
|
|
21
|
+
readonly hostBearer: {
|
|
22
|
+
readonly type: "http";
|
|
23
|
+
readonly scheme: "bearer";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
readonly security: readonly [{
|
|
27
|
+
readonly hostBearer: readonly [];
|
|
28
|
+
}];
|
|
29
|
+
};
|
|
9
30
|
/**
|
|
10
31
|
* Clean TS view of a `pallet-agent-identity` `AgentIdentityEntry`. The chain
|
|
11
32
|
* decodes to a Codec; {@link fromCodec} normalizes that into this shape.
|
|
@@ -51,6 +72,35 @@ export interface ToAgentCardOptions {
|
|
|
51
72
|
* rather than emit an undiscoverable card.
|
|
52
73
|
*/
|
|
53
74
|
export declare function toAgentCard(entry: OnChainAgentIdentity, opts?: ToAgentCardOptions): AgentCard;
|
|
75
|
+
/** Explicit service profile; generic Agent Card defaults remain unchanged. */
|
|
76
|
+
export declare function toPiDurableAgentCard(entry: OnChainAgentIdentity): {
|
|
77
|
+
name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
url: string;
|
|
80
|
+
version: string;
|
|
81
|
+
provider?: import("./types.js").AgentProvider;
|
|
82
|
+
skills: AgentSkill[];
|
|
83
|
+
documentationUrl?: string;
|
|
84
|
+
"x-flop": FlopAgentExtension;
|
|
85
|
+
protocolVersion: "0.3.0";
|
|
86
|
+
preferredTransport: "JSONRPC";
|
|
87
|
+
capabilities: {
|
|
88
|
+
readonly streaming: false;
|
|
89
|
+
readonly pushNotifications: false;
|
|
90
|
+
readonly stateTransitionHistory: false;
|
|
91
|
+
};
|
|
92
|
+
defaultInputModes: readonly ["text/plain"];
|
|
93
|
+
defaultOutputModes: readonly ["text/plain"];
|
|
94
|
+
securitySchemes: {
|
|
95
|
+
readonly hostBearer: {
|
|
96
|
+
readonly type: "http";
|
|
97
|
+
readonly scheme: "bearer";
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
security: readonly [{
|
|
101
|
+
readonly hostBearer: readonly [];
|
|
102
|
+
}];
|
|
103
|
+
};
|
|
54
104
|
/** Normalize a pallet capability variant (`{ TextGeneration: null }` or `{ Custom: "x" }`) to a canonical id. */
|
|
55
105
|
export declare function capabilityIdFromVariant(variant: string, customName?: string): string;
|
|
56
106
|
//# sourceMappingURL=agent-card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-card.d.ts","sourceRoot":"","sources":["../../src/a2a/agent-card.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"agent-card.d.ts","sourceRoot":"","sources":["../../src/a2a/agent-card.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAG5E,2FAA2F;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AgB,WAAW,CAAC,KAAK,EAAE,oBAAoB,EAAE,IAAI,GAAE,kBAAuB,GAAG,SAAS,CA4CjG;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,oBAAoB;;;;;;;;;;wBAlI1C,SAAS;;iBACb,SAAS;iBAAS,iBAAiB;iBAAS,sBAAsB;;iCAC9D,YAAY;kCACX,YAAY;;iBACd,UAAU;qBAAI,IAAI,EAAE,MAAM;qBAAE,MAAM,EAAE,QAAQ;;;;iBAClD,UAAU;;EAqIxB;AAuBD,iHAAiH;AACjH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAGpF"}
|
package/dist/a2a/agent-card.js
CHANGED
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
* testable and reusable by the MCP server and the x402 gateway.
|
|
7
7
|
*/
|
|
8
8
|
import { A2A_PROTOCOL_VERSION, X402_A2A_EXTENSION_URI } from "./types.js";
|
|
9
|
+
/** The opt-in Pi endpoint implements authenticated text tasks, not a payment transport. */
|
|
10
|
+
export const PI_DURABLE_A2A_PROFILE = {
|
|
11
|
+
protocolVersion: A2A_PROTOCOL_VERSION,
|
|
12
|
+
preferredTransport: "JSONRPC",
|
|
13
|
+
capabilities: { streaming: false, pushNotifications: false, stateTransitionHistory: false },
|
|
14
|
+
defaultInputModes: ["text/plain"],
|
|
15
|
+
defaultOutputModes: ["text/plain"],
|
|
16
|
+
securitySchemes: { hostBearer: { type: "http", scheme: "bearer" } },
|
|
17
|
+
security: [{ hostBearer: [] }],
|
|
18
|
+
};
|
|
9
19
|
/** Catalog of known capability ids → A2A skill descriptor. */
|
|
10
20
|
const SKILL_CATALOG = {
|
|
11
21
|
"text-generation": { name: "Text Generation", description: "Generate natural-language text.", tags: ["text", "generation"] },
|
|
@@ -82,6 +92,16 @@ export function toAgentCard(entry, opts = {}) {
|
|
|
82
92
|
"x-flop": ext,
|
|
83
93
|
};
|
|
84
94
|
}
|
|
95
|
+
/** Explicit service profile; generic Agent Card defaults remain unchanged. */
|
|
96
|
+
export function toPiDurableAgentCard(entry) {
|
|
97
|
+
if (!entry.capabilities.includes("text-generation")) {
|
|
98
|
+
throw new Error("Pi Durable requires registered text-generation capability");
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
...toAgentCard({ ...entry, capabilities: ["text-generation"] }, { settlement: [] }),
|
|
102
|
+
...PI_DURABLE_A2A_PROFILE,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
85
105
|
/** Pallet `AgentCapability` variant name → canonical kebab-case capability id. */
|
|
86
106
|
const VARIANT_TO_ID = {
|
|
87
107
|
TextGeneration: "text-generation",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-card.js","sourceRoot":"","sources":["../../src/a2a/agent-card.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-card.js","sourceRoot":"","sources":["../../src/a2a/agent-card.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE1E,2FAA2F;AAC3F,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,eAAe,EAAE,oBAAoB;IACrC,kBAAkB,EAAE,SAAS;IAC7B,YAAY,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE;IAC3F,iBAAiB,EAAE,CAAC,YAAY,CAAC;IACjC,kBAAkB,EAAE,CAAC,YAAY,CAAC;IAClC,eAAe,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;IACnE,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE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AAC;AAED,kFAAkF;AAClF,MAAM,aAAa,GAA2B;IAC5C,cAAc,EAAE,iBAAiB;IACjC,cAAc,EAAE,iBAAiB;IACjC,UAAU,EAAE,aAAa;IACzB,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,eAAe;IAC9B,iBAAiB,EAAE,oBAAoB;IACvC,qBAAqB,EAAE,wBAAwB;IAC/C,gBAAgB,EAAE,mBAAmB;IACrC,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,UAAU;IACnB,eAAe,EAAE,kBAAkB;IACnC,kBAAkB,EAAE,qBAAqB;IACzC,eAAe,EAAE,kBAAkB;IACnC,kBAAkB,EAAE,qBAAqB;IACzC,UAAU,EAAE,YAAY;IACxB,eAAe,EAAE,kBAAkB;IACnC,gBAAgB,EAAE,mBAAmB;CACtC,CAAC;AAEF,iHAAiH;AACjH,MAAM,UAAU,uBAAuB,CAAC,OAAe,EAAE,UAAmB;IAC1E,IAAI,OAAO,KAAK,QAAQ,IAAI,UAAU;QAAE,OAAO,UAAU,UAAU,EAAE,CAAC;IACtE,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,UAAU,OAAO,EAAE,CAAC;AACvD,CAAC"}
|
package/dist/a2a/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* MCP+A2A ecosystem can discover and drive FLOP agents without bespoke code.
|
|
7
7
|
*/
|
|
8
8
|
export { A2A_PROTOCOL_VERSION, X402_A2A_EXTENSION_URI, A2A_TERMINAL_STATES, type A2ATaskState, type AgentCard, type AgentSkill, type AgentCapabilities, type AgentExtension, type AgentProvider, type FlopAgentExtension, } from "./types.js";
|
|
9
|
-
export { toAgentCard, capabilityIdFromVariant, type OnChainAgentIdentity, type ToAgentCardOptions, } from "./agent-card.js";
|
|
9
|
+
export { toAgentCard, toPiDurableAgentCard, PI_DURABLE_A2A_PROFILE, capabilityIdFromVariant, type OnChainAgentIdentity, type ToAgentCardOptions, } from "./agent-card.js";
|
|
10
10
|
export { flopStateToA2A, toA2ATask, type FlopSourceState, type A2ATask, } from "./task-lifecycle.js";
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/a2a/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/a2a/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,OAAO,GACb,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/a2a/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,OAAO,GACb,MAAM,qBAAqB,CAAC"}
|