Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 32 additions & 26 deletions nexus-next/TAP/default-tap.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ The Default TAP is a useful helper component for Nexus agent developers. It serv
The Default TAP implements the [Nexus Interface V1](../packages/nexus-interface.md#v1) specification, which defines the required functionality for any Talus Agent Package to integrate with the Nexus workflow engine. Key interface requirements include:

1. **Version Management**

- Must declare and maintain interface version compatibility.
- Must support version checking for backward compatibility.

1. **Workflow Management**

- Must handle worksheet management and state tracking.
- Must support tool evaluation confirmation.

Expand All @@ -23,8 +25,9 @@ The Default TAP implements the [Nexus Interface V1](../packages/nexus-interface.
For detailed interface requirements, see the [Nexus Interface Documentation](../packages/nexus-interface.md).

<!-- Gitbook syntax -->

{% hint style="info" %}
In the code snippets below, we reference some Sui Move patterns (e.g. hot potato), please refer to the [primitives package doc](../packages/primitives.md) for more information on the approach taken here.
In the code snippets below, we reference some Sui Move patterns (e.g. hot potato), please refer to the [primitives package doc](../packages/primitives.md) for more information on the approach taken here.
{% endhint %}

### DefaultTAP Structure
Expand All @@ -50,7 +53,7 @@ public struct DefaultTAP has key {
/// so we need to always create a new type and query it from the type via
/// its type name.
witness: Bag,
/// Clients can search the smart agent shared object for this type to
/// Clients can search the talus agent shared object for this type to
/// determine what interface to expect.
iv: InterfaceVersion,
}
Expand All @@ -72,26 +75,26 @@ use sui::object::UID;
use sui::transfer::share_object;

public(package) fun new(ctx: &mut TxContext) {
let default_sap = DefaultSAP {
let default_tap = DefaultTAP {
id: object::new(ctx),
witness: {
let mut b = bag::new(ctx);
b.add(b"witness", DefaultSAPV1Witness { id: object::new(ctx) });
b.add(b"witness", DefaultTAPV1Witness { id: object::new(ctx) });
b
},
iv: version::v(1),
};

announce_interface_package(
default_sap.get_witness(),
vector[object::id(&default_sap)],
default_tap.get_witness(),
vector[object::id(&default_tap)],
);

share_object(default_sap);
share_object(default_tap);
}

/// with...
public struct DefaultSAPV1Witness has key, store {
public struct DefaultTAPV1Witness has key, store {
id: UID,
}
```
Expand All @@ -108,7 +111,7 @@ The worksheet function is a core requirement of the Nexus Interface V1 specifica
use nexus_interface::version::InterfaceVersion;
use nexus_primitives::proof_of_uid::{Self, ProofOfUID};

public fun worksheet(self: &DefaultSAP): ProofOfUID {
public fun worksheet(self: &DefaultTAP): ProofOfUID {
self.iv.expect_v(1);
proof_of_uid::new_with_type(&self.get_witness().id, self.get_witness())
}
Expand All @@ -126,15 +129,15 @@ The `confirm_tool_eval_for_walk` function is another core requirement of the Nex
use nexus_interface::version::InterfaceVersion

public fun confirm_tool_eval_for_walk(
self: &mut DefaultSAP,
self: &mut DefaultTAP,
worksheet: ProofOfUID,
) {
self.iv.expect_v(1);
worksheet.consume(&self.get_witness().id);
}

/// with...
fun get_witness(self: &DefaultSAP): &DefaultSAPV1Witness {
fun get_witness(self: &DefaultTAP): &DefaultTAPV1Witness {
self.witness.borrow(b"witness")
}
```
Expand All @@ -144,11 +147,13 @@ fun get_witness(self: &DefaultSAP): &DefaultSAPV1Witness {
The Default TAP works in conjunction with the Nexus workflow engine, which provides:

1. **DAG Implementation**

- Directed Acyclic Graph data structure for modeling complex workflows.
- Support for vertices, edges, and input/output ports.
- Entry group management for workflow initiation.

1. **Tool Registry**

- Registration and management of available tools.

1. **Tool Invocation**
Expand Down Expand Up @@ -177,7 +182,7 @@ use nexus_workflow::dag::{DAG, Vertex, InputPort, EntryGroup};
/// Invokes the provided entry vertex on a DAG with the provided input data for
/// each input port.
public fun begin_dag_execution(
self: &mut DefaultSAP,
self: &mut DefaultTAP,
dag: &DAG,
network: ID,
entry_group: EntryGroup,
Expand Down Expand Up @@ -225,14 +230,15 @@ For a broader security analysis of Nexus, refer to the [whitepaper section 4.4](
## Full Module Code

Toggle to see the full module code for the default TAP:

<details>

<summary>Toggle code</summary>

```rust
module nexus_workflow::default_sap;
module nexus_workflow::default_tap;

//! Module defining a default smart agent package with no added logic but
//! Module defining a default talus agent package with no added logic but
//! executing the provided DAG. This can be used for examples, tests or to run
//! JSON-defined DAGs from the CLI or via other means.

Expand All @@ -246,7 +252,7 @@ use sui::transfer::{share_object, public_share_object};
use sui::vec_map::{VecMap};

/// Shared object.
public struct DefaultSAP has key {
public struct DefaultTAP has key {
id: UID,
/// On package upgrade, we'll want to replace the previous witness with a
/// new one that identifies the new package.
Expand All @@ -255,7 +261,7 @@ public struct DefaultSAP has key {
/// so we need to always create a new type and query it from the type via
/// its type name.
witness: Bag,
/// Clients can search the smart agent shared object for this type to
/// Clients can search the talus agent shared object for this type to
/// determine what interface to expect.
iv: InterfaceVersion,
}
Expand All @@ -264,27 +270,27 @@ public struct DefaultSAP has key {
///
/// Will also serve as authorization token to change list of shared objects for
/// nexus interface v1.
public struct DefaultSAPV1Witness has key, store {
public struct DefaultTAPV1Witness has key, store {
id: UID,
}

public(package) fun new(ctx: &mut TxContext) {
let default_sap = DefaultSAP {
let default_tap = DefaultTAP {
id: object::new(ctx),
witness: {
let mut b = bag::new(ctx);
b.add(b"witness", DefaultSAPV1Witness { id: object::new(ctx) });
b.add(b"witness", DefaultTAPV1Witness { id: object::new(ctx) });
b
},
iv: nexus_interface::version::v(1),
};

nexus_interface::v1::announce_interface_package(
default_sap.get_witness(),
vector[object::id(&default_sap)],
default_tap.get_witness(),
vector[object::id(&default_tap)],
);

share_object(default_sap);
share_object(default_tap);
}

// === Client entry ===
Expand All @@ -293,7 +299,7 @@ public(package) fun new(ctx: &mut TxContext) {
/// each input port.
#[allow(lint(share_owned))]
public fun begin_dag_execution(
self: &mut DefaultSAP,
self: &mut DefaultTAP,
dag: &DAG,
network: ID,
entry_group: EntryGroup,
Expand Down Expand Up @@ -331,23 +337,23 @@ public fun begin_dag_execution(
// === Nexus interface v1 ===

/// Nexus resources can prove that they did a thing.
public fun worksheet(self: &DefaultSAP): ProofOfUID {
public fun worksheet(self: &DefaultTAP): ProofOfUID {
self.iv.expect_v(1);

proof_of_uid::new_with_type(&self.get_witness().id, self.get_witness())
}

/// One calls this after workflow contract is done with advancing the DAG.
public fun confirm_tool_eval_for_walk(
self: &mut DefaultSAP,
self: &mut DefaultTAP,
worksheet: ProofOfUID,
) {
self.iv.expect_v(1);

worksheet.consume(&self.get_witness().id);
}

fun get_witness(self: &DefaultSAP): &DefaultSAPV1Witness {
fun get_witness(self: &DefaultTAP): &DefaultTAPV1Witness {
self.witness.borrow(b"witness")
}

Expand Down
4 changes: 2 additions & 2 deletions nexus-next/packages/reference/nexus_workflow/dag.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ vertices and following the edges.
<code>worksheet_from_type: <a href="../dependencies/std/type_name.md#std_type_name_TypeName">std::type_name::TypeName</a></code>
</dt>
<dd>
The off-chain realm can determine the Smart Agent Package to invoke
The off-chain realm can determine the Talus Agent Package to invoke
thanks to the package address and module name from this field.
</dd>
<dt>
Expand Down Expand Up @@ -910,7 +910,7 @@ for more information.
<code>worksheet_from_type: <a href="../dependencies/std/type_name.md#std_type_name_TypeName">std::type_name::TypeName</a></code>
</dt>
<dd>
The off-chain realm can determine the Smart Agent Package to invoke
The off-chain realm can determine the Talus Agent Package to invoke
thanks to the package address and module name from this field.
</dd>
</dl>
Expand Down
Loading