TuoniNote

Notes attach to commands through the server’s v2 command-notes endpoints. Create or retrieve them through tuoni.TuoniCommand using add_note(), load_note(), and load_notes(). Callers with agent and command identifiers can use tuoni.TuoniC2 methods add_command_note(), load_command_note(), and load_command_notes().

With an existing command object:

note = command.add_note("review", "Checked the command output.")
note.content = "Reviewed and complete."
note.update()
note.reload()
note.archive()
archived = command.load_note(note.note_id)

Set the note’s attributes and call update() to save both label and content. Mutation methods refresh the object from the server response and return None. Archiving is permanent and can be repeated. Archived notes remain readable and retain their identifier, but cannot be edited or restored.

Collection methods return one page as a list, oldest first. Defaults are page=0, pageSize=100, and include_archived=False. The maximum page size is 1,000; label is an optional exact, case-sensitive filter. Increment page to fetch more results. Pagination metadata is not returned.

The server requires nonblank labels and content. Labels are trimmed and limited to 128 characters; content is limited to 2,000 characters and retains whitespace and line breaks. Reads require VIEW_RESOURCES and writes require SEND_COMMANDS. Editing or archiving requires the creator’s username, or MANAGE_USERS to override ownership in addition to SEND_COMMANDS.

Server errors propagate through the existing request exceptions: 400 for invalid input, 403 for permissions or ownership, 404 for an unavailable command or mismatched note, and 409 for archived-note updates or concurrent changes.

Use tuoni.TuoniWebSocket.on_note() for change notifications. Callbacks receive raw event dictionaries; they do not update existing note objects.

class tuoni.TuoniNote(conf, c2)[source]

A note attached to a command, including its audit events.

Edit label or content, then call update() to save both fields. The server trims labels and preserves content whitespace. Archiving is permanent, but archived notes remain readable.

note_id

The note’s UUID.

Type:

str

target

Command target with targetType, commandId and an href identifying the command. Requests always use this client’s server, including when the server returns absolute links.

Type:

dict

label

Nonblank label, limited to 128 characters by the server.

Type:

str

content

Nonblank content, limited to 2,000 characters.

Type:

str

status

ACTIVE or ARCHIVED.

Type:

str

createEvent

Note creation event.

Type:

TuoniEvent

lastUpdateEvent

Most recent update or archive event.

Type:

TuoniEvent

archiveEvent

Archive event, if archived.

Type:

TuoniEvent | None

archive()[source]

Permanently archive this note and refresh its status and events.

Requires SEND_COMMANDS and ownership or a MANAGE_USERS ownership override. Repeated archiving is supported. The identifier is retained so the note can still be reloaded. Returns None.

reload()[source]

Reload this note, including an archived note, from the server.

Requires VIEW_RESOURCES. Replaces local fields and returns None.

update()[source]

Save the current label and content, then refresh local fields.

Requires SEND_COMMANDS and note ownership, unless MANAGE_USERS grants an ownership override. The server rejects invalid fields with HTTP 400 and archived or concurrently changed notes with HTTP 409. Request failures use the existing Tuoni request exceptions; local fields are refreshed only on success. Returns None.

Examples

>>> note.content = "Reviewed the command output."
>>> note.update()