add: aip, a story resource

This commit is contained in:
2026-03-24 22:49:44 -07:00
parent 622eca78cb
commit 4e111c7f6d
9 changed files with 13325 additions and 1208 deletions
+152 -119
View File
@@ -2,137 +2,170 @@ syntax = "proto3";
package webstory.v1;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
option go_package = "git.tipsy.codes/charles/webstory/pkg/api";
// Story represents the current state of an interactive fiction session
message Story {
string session_id = 1; // Unique identifier for this story session
string current_scene = 2; // Current scene/location identifier
string status = 3; // Current story status (playing, paused, completed)
}
// Visualization represents an image or visual element to display
message Visualization {
string type = 1; // Type of visualization: portrait, scene, map, etc.
string url = 2; // URL or path to the visualization
string description = 3; // Description of what should be shown
}
// Choice represents an option the user can select
message Choice {
string label = 1; // Text displayed on the button
string action = 2; // Action to trigger when selected
map<string, string> metadata = 3; // Additional metadata (optional)
}
// Message represents a communication between client and server
message Message {
string id = 1; // Unique message identifier
string type = 2; // Message type: user_input, story_text, system, etc.
string content = 3; // Message content
repeated Choice choices = 4; // Available choices (if any)
Visualization visualization = 5; // Associated visualization (if any)
google.protobuf.Timestamp created_at = 6; // Timestamp when message was created
google.protobuf.Timestamp updated_at = 7; // Timestamp when message was last updated
}
// ChatHistory represents the conversation history
message ChatHistory {
string session_id = 1;
repeated Message messages = 2;
google.protobuf.Timestamp created_at = 3; // Timestamp when chat history was created
google.protobuf.Timestamp updated_at = 4; // Timestamp when chat history was last updated
}
// Request for starting a new story
message StartStoryRequest {
string session_id = 1; // Optional: client-provided session ID
string initial_scene = 2; // Starting scene or scenario prompt
string story_genre = 3; // Genre preferences (fantasy, sci-fi, etc.)
map<string, string> options = 4; // Additional configuration options
google.protobuf.Timestamp created_at = 5; // Timestamp when request was created
}
// Response for starting a story
message StartStoryResponse {
string session_id = 1;
string status = 2;
Message initial_message = 3;
map<string, string> metadata = 4;
google.protobuf.Timestamp created_at = 5; // Timestamp when response was created
}
// Request for continuing the story
message ContinueStoryRequest {
string session_id = 1;
string action = 2; // User's choice or input
string choice_id = 3; // If selecting a specific choice
map<string, string> options = 4; // Optional parameters
google.protobuf.Timestamp created_at = 5; // Timestamp when request was created
}
// Response for continuing the story
message ContinueStoryResponse {
string session_id = 1;
string status = 2;
Message response_message = 3;
map<string, string> metadata = 4;
}
// Request to get story state
message GetStoryRequest {
string session_id = 1;
}
// Response with current story state
message GetStoryResponse {
string session_id = 1;
Story story = 2;
repeated Message recent_messages = 3;
}
// Request to reset/stop a story
message ResetStoryRequest {
string session_id = 1;
}
message ResetStoryResponse {
string session_id = 1;
string status = 2;
}
// WebstoryService defines the RPC methods for the interactive fiction service
service WebstoryService {
// Start a new story session
rpc StartStory(StartStoryRequest) returns (StartStoryResponse);
// GetStory retrieves a story by its resource name.
rpc GetStory(GetStoryRequest) returns (Story) {
option (google.api.http) = {get: "/v1/{name=stories/*}"};
option (google.api.method_signature) = "name";
}
// Continue the story with user input or choice
rpc ContinueStory(ContinueStoryRequest) returns (ContinueStoryResponse);
// ListStories returns a list of stories.
rpc ListStories(ListStoriesRequest) returns (ListStoriesResponse) {
option (google.api.http) = {get: "/v1/stories"};
option (google.api.method_signature) = "";
}
// Get the current state of a story
rpc GetStory(GetStoryRequest) returns (GetStoryResponse);
// CreateStory creates a new story.
rpc CreateStory(CreateStoryRequest) returns (Story) {
option (google.api.http) = {
post: "/v1/stories"
body: "story"
};
option (google.api.method_signature) = "story_id,story";
}
// Reset or terminate a story session
rpc ResetStory(ResetStoryRequest) returns (ResetStoryResponse);
// UpdateStory updates an existing story.
rpc UpdateStory(UpdateStoryRequest) returns (Story) {
option (google.api.http) = {
put: "/v1/{story.name}"
body: "story"
};
option (google.api.method_signature) = "story";
}
// Stream story responses in real-time
rpc StreamStory(StreamStoryRequest) returns (stream StreamStoryResponse);
// DeleteStory deletes a story.
rpc DeleteStory(DeleteStoryRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/v1/{name=stories/*}"};
option (google.api.method_signature) = "name";
}
}
// Request for streaming story responses
message StreamStoryRequest {
string session_id = 1;
string action = 2;
string choice_id = 3;
map<string, string> options = 4;
// Story represents a story resource in the webstory service.
message Story {
option (google.api.resource) = {
type: "webstory.googleapis.com/Story"
pattern: "stories/{story}"
};
// The resource name of the story.
// Format: stories/{story}
string name = 1 [
(google.api.field_behavior) = OUTPUT_ONLY,
(google.api.field_behavior) = IDENTIFIER
];
// The ID of the story, used as the final component of the resource name.
string story_id = 2 [(google.api.field_behavior) = REQUIRED];
// The title of the story.
string title = 3 [(google.api.field_behavior) = REQUIRED];
// The content of the story.
string content = 4;
// The description or summary of the story.
string description = 5;
// Labels for organizing and categorizing the story.
repeated string labels = 6;
// Output only. The time when the story was created.
google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. The time when the story was last updated.
google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. The version of the story for concurrency control.
string etag = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
}
// Response for streaming story responses
message StreamStoryResponse {
string session_id = 1;
Message partial_message = 2; // Partial message being built
Message complete_message = 3; // Complete message when finalized
bool is_final = 4; // Indicates if this is the final chunk
// GetStoryRequest is the request message for GetStory RPC.
message GetStoryRequest {
// The resource name of the story to retrieve.
// Format: stories/{story}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "webstory.googleapis.com/Story"}
];
}
// ListStoriesRequest is the request message for ListStories RPC.
message ListStoriesRequest {
// The maximum number of stories to return. The service may return fewer than
// this value. If unspecified, at most 50 stories will be returned.
// The maximum value is 1000; values above 1000 will be coerced to 1000.
int32 page_size = 1;
// A page token, received from a previous ListStories call.
// Provide this to retrieve the subsequent page.
// When paginating, all other parameters provided to ListStories must match
// the call that provided the page token.
string page_token = 2;
// Optional. A filter expression that filters the stories listed in the response.
// Supported fields: title, labels.
// Example: labels:"fiction" AND title:"adventure"
string filter = 3;
// Optional. The field to order the results by.
// Supported fields: create_time, title.
// Default: create_time (descending order).
string order_by = 4;
}
// ListStoriesResponse is the response message for ListStories RPC.
message ListStoriesResponse {
// The list of stories.
repeated Story stories = 1;
// A token, which can be sent as page_token to retrieve the next page.
// If this field is omitted, there are no subsequent pages.
string next_page_token = 2;
// The total number of stories matching the filter.
// This value may be an estimate.
int32 total_size = 3;
}
// CreateStoryRequest is the request message for CreateStory RPC.
message CreateStoryRequest {
// The ID to use for the story, which will become the final component of
// the story's resource name.
// This value should be 4-63 characters, and valid characters are
// /[a-z][0-9]-/.
string story_id = 1 [(google.api.field_behavior) = REQUIRED];
// The story to create.
Story story = 2 [(google.api.field_behavior) = REQUIRED];
}
// UpdateStoryRequest is the request message for UpdateStory RPC.
message UpdateStoryRequest {
// The story to update.
// The story's name field is used to specify the resource to update.
Story story = 1 [(google.api.field_behavior) = REQUIRED];
// The list of fields to update.
google.protobuf.FieldMask update_mask = 2;
}
// DeleteStoryRequest is the request message for DeleteStory RPC.
message DeleteStoryRequest {
// The resource name of the story to delete.
// Format: stories/{story}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "webstory.googleapis.com/Story"}
];
}