-
Notifications
You must be signed in to change notification settings - Fork 485
Update Shade Agent docs after shade-agent-framework 2.0 release #2968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
106d544
API docs updated, most of CLI updated
PiVortex c8b6ac5
finish cli
PiVortex dea1854
progress on agent-contract reference doc
PiVortex 5823343
do agent-contract docs
PiVortex 27994a1
working on terminology
PiVortex b8d81f2
update shade intro roughly
PiVortex f51d292
spell check stuff
PiVortex 814c570
add article
PiVortex f0abd89
attempt fix broken links
PiVortex cb0b9a6
fix broken link
PiVortex 29edc1a
Apply suggestions from code review
gagdiez d51f2b1
remove hosted example and move quickstart snippets to main
PiVortex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| --- | ||
| title: Shade Agent Framework 2.0 | ||
| authors: [pivortex] | ||
| slug: shade-agent-framework-2.0 | ||
| tags: [updates, ai, shade-agents] | ||
| hide_table_of_contents: true | ||
| --- | ||
|
|
||
| The biggest update to the Shade Agent Framework has been released since launch. It aims to enable more production-ready builds and a more flexible developer experience and it comes with significant architectural, and breaking changes. | ||
|
|
||
| :::danger Upgrade immediately | ||
| The previous version of the Shade Agent Framework has **known critical vulnerabilities**. You should upgrade your agent to 2.0 as soon as possible. | ||
| ::: | ||
|
|
||
| <!-- truncate --> | ||
|
|
||
| ## A Shift in Mental Model | ||
|
|
||
| Shade Agent 2.0 is not a small iteration. It reflects a different way of building and deploying Shade Agents. | ||
|
|
||
| **Previously**, the framework leaned on global, abstract agent contracts and a separate API service. That made early development straightforward but made production use harder: you had less control over contract behavior, deployment was split across env vars and flags, and the API lived in its own Docker image. | ||
|
gagdiez marked this conversation as resolved.
Outdated
|
||
|
|
||
| **In Shade Agent Framework 2.0**, the **Shade Agent API** is a single TypeScript library that runs **inside your agent’s codebase** instead of a separate service. The **agent contract** is included in your repo so you can change and extend it for your use case. The **CLI** is built around one config file and built-in credential management, so deploy and whitelist flows are predictable and easier to script. | ||
|
gagdiez marked this conversation as resolved.
Outdated
|
||
|
|
||
| The result is a framework that’s easier to reason about, easier to customize, and better suited to production. Below is a summary of the main changes for the API, CLI, and agent contract, with links to the docs so you can get started. | ||
|
|
||
| --- | ||
|
|
||
| ## Shade Agent API | ||
|
|
||
| The Shade Agent API no longer offers multi-language support. It has been consolidated into a single **TypeScript/JavaScript** library (`@neardefi/shade-agent-js`) that runs within your agent’s codebase instead of a separate Docker image. | ||
|
|
||
| ### How the API Has Changed | ||
|
|
||
| Previously, the API was a separate Docker image (and HTTP service); you called standalone functions that talked to that service. In 2.0, you create a client in your code and use it for everything. Registration and funding now explicit methods instead of automatic on boot. | ||
|
|
||
| **Before (1.x):** No client—you installed the package and called functions that hit the API internally (or HTTP in other languages): | ||
|
|
||
| ```ts | ||
| import { agentAccountId, agent, agentCall, agentView } from '@neardefi/shade-agent-js'; | ||
| // API assumed to be running (Docker / localhost:3140); env vars for config | ||
| ``` | ||
|
|
||
| **After (2.0):** One client, created once with your config: | ||
|
|
||
| ```ts | ||
| import { ShadeClient } from "@neardefi/shade-agent-js"; | ||
|
|
||
| const agent = await ShadeClient.create({ | ||
| networkId: "testnet", | ||
| agentContractId: process.env.AGENT_CONTRACT_ID, | ||
| sponsor: { accountId: process.env.SPONSOR_ACCOUNT_ID, privateKey: process.env.SPONSOR_PRIVATE_KEY }, | ||
| rpc: provider, | ||
| }); | ||
| // Then: await agent.register(), await agent.fund(0.3), etc. | ||
| ``` | ||
|
|
||
| **Account ID:** Same idea, different shape, you now use the client instance and get the value directly (no response object). | ||
|
|
||
| ```ts | ||
| // Before: const res = await agentAccountId(); const accountId = res.accountId | ||
| const accountId = agent.accountId(); | ||
| ``` | ||
|
|
||
| **Balance:** Balance is now a method on the client and returns human-readable NEAR (e.g. `1` = one NEAR), not yoctoNEAR. | ||
|
|
||
| ```ts | ||
| // Before: const res = await agent("getBalance"); const balance = res.balance // yoctoNEAR | ||
| const balance = await agent.balance(); // human-readable, e.g. 0.3 | ||
| ``` | ||
|
|
||
| **Call and view:** Call and view have stayed the same but are accessible via the client instance instead of a standalone function. | ||
|
|
||
| ```ts | ||
| // Before: agentCall({ methodName, args, gas }) / agentView({ methodName, args }) | ||
| const result = await agent.call({ | ||
| methodName: "example_call_function", | ||
| args: { arg1: "value1", arg2: "value2" }, | ||
| gas: BigInt("300000000000000"), | ||
| deposit: "0", | ||
| }); | ||
| const viewResult = await agent.view({ | ||
| methodName: "example_view_function", | ||
| args: { arg1: "value1" }, | ||
| }); | ||
| ``` | ||
|
|
||
| **Request signature:** The old API had a dedicated `requestSignature({ path, payload, keyType })` helper. In 2.0, this has been deprecated, now if you want to call a function of the contract called `request_signature`, call it like any other function: | ||
|
|
||
| ```ts | ||
| // Before: requestSignature({ path, payload, keyType }) | ||
| const result = await agent.call({ | ||
| methodName: "request_signature", | ||
| args: { path, payload, key_type }, | ||
| deposit: "1", | ||
| }); | ||
| ``` | ||
|
|
||
| New methods include `agent.register()`, `agent.fund()`, `agent.isWhitelisted()`, and `agent.getAttestation()` for explicit control over registration, funding, and attestation; see the API reference for details. | ||
|
|
||
| To learn how to install, configure, and use the API, see the **[Shade Agent API reference](/ai/shade-agents/reference/api)**. | ||
|
|
||
| --- | ||
|
|
||
| ## Shade Agent CLI | ||
|
|
||
| The Shade Agent CLI has had a **total revamp**. Instead of being configured with a mix of environment variables and flags, it now centers on a **single `deployment.yaml` file**, with built-in credential management and command routing, taking inspiration from the NEAR CLI. | ||
|
gagdiez marked this conversation as resolved.
Outdated
|
||
|
|
||
| You run `shade auth` to configure NEAR and Phala credentials, then use the commands `shade deploy` to deploy your Shade Agent, `shade plan` to preview the deployment, and `shade whitelist` to whitelist an agent's account ID. The `deployment.yaml` file drives contract deployment (including from source or WASM), measurement and PPID approval, Docker image build and publish, and deployment to Phala Cloud, so all deployment options live in one place. | ||
|
|
||
| To learn how to install the CLI, use each command, and configure `deployment.yaml`, see the **[Shade Agent CLI reference](/ai/shade-agents/reference/cli)**. | ||
|
|
||
| --- | ||
|
|
||
| ## Agent Contract | ||
|
|
||
| Previously, the framework used **global agent contracts** that were abstract and easy to start with, but made production development and customization difficult. In 2.0, by default, a reference agent contract is included in the `shade-agent-template` repo, so you can edit and extend it to your needs (e.g. custom agent-gated functions, guardrails, and initialization). | ||
|
|
||
| The reference agent contract also now uses a more robust external library for attestation verification (the [shade-attestation crate](https://github.com/NearDeFi/shade-agent-framework/tree/main/shade-attestation)). Instead of approving the codehash of a single Docker image, the contract now requires you to approve a set of measurements for more in-depth verification and a list of PPIDs that set the physical hardware the agent can run on. Local mode now requires you to whitelist the account ID of the agent you want to run locally, blocking any other account ID from controlling the contract for more consistent behavior when testing. | ||
|
|
||
| To walk through the contract flow, initialization, attestation verification, and how to add your own agent-gated functions, see the **[Agent Contract reference](/ai/shade-agents/reference/agent-contract)**. | ||
|
|
||
| --- | ||
|
|
||
| ## Next Steps | ||
|
|
||
| Start your migration by **cloning the template** in the [quickstart](/ai/shade-agents/getting-started/quickstart/deploying) to explore the new setup. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.