API Structure
This page describes the current ss-protocol shape, with emphasis on envelopes, resource models, and session semantics.
1. Transport Model
The backend currently uses:
- JSON-RPC 2.0 on
POST /rpc - SSE for streaming responses
- binary file transfer on
/upload/{resource_id}/{file_id}and/download/{resource_id}/{file_id}
1.1 Request
1.2 Unary Response
1.3 Stream Response
session.run_turn returns a unary ack first, then sends message events.
Frame types:
startedeventcompletedfailed
1.4 Binary File Transfer
- upload and download routes do not use JSON-RPC
- public file identity is
resource_id + file_id - built-in resource files include:
character:{character_id}/covercharacter:{character_id}/archivepackage_import:{import_id}/archivepackage_export:{export_id}/archive
2. Core Resource Model
2.1 Connection and Prompt Configuration
api: one reusable connection definitionapi_group: per-agentapi_idbindingspreset: generation parameters plus modular prompt configuration
The runtime binding model uses api_group_id + preset_id.
2.2 State and Supporting Resources
schema: standalone schema resourcelorebook: reusable lore bundleplayer_profile: standalone player setupresource_file: transport-neutral binary file identity
2.3 Creative Resources
character: character card content plus cover metadatastory_resources: editable pre-generation input bundle withdisplay_name, concept, cast, and schema seedsstory: final graph plus schema bindingssession: story runtime snapshot and transcript
3. Method Families
Current protocol families:
- binary file routes
api.*api_group.*preset.*schema.*lorebook.*lorebook_entry.*player_profile.*character.*story_resources.*story.*story_draft.*session.*session_character.*session_message.*config.*dashboard.getdata_package.*
4. Session Semantics
4.1 Starting a Session
story.start_session accepts:
story_id- optional
display_name - optional
player_profile_id - optional
api_group_id - optional
preset_id
If either binding id is omitted and resources exist, the backend uses the first available sorted id.
4.2 Draft Story Generation
story_draft.* is the preferred path for larger stories:
story_draft.startstory_draft.update_graphstory_draft.continuestory_draft.finalize
The server keeps partial_graph inside the draft object, so clients do not need to resend generated nodes.
4.3 Variable Panels
story.common_variables can be combined with session.get_variables or the runtime snapshot to render pinned variable panels.
4.4 Session Variable Updates
session.update_variables accepts variable ops only:
SetStateRemoveStateSetPlayerStateRemovePlayerStateSetCharacterStateRemoveCharacterState
Scene-control ops such as SetCurrentNode are rejected.