Skip to content

Commit f8de543

Browse files
committed
feat: add agent_view manifest types
Adds AgentView and AgentViewAction structs and an AgentView field on AppFeatures so manifests using the new agent_view property survive JSON/YAML round-trips through the CLI. Mirrors AssistantView and reuses the existing SuggestedPrompts type.
1 parent 0fcc9e6 commit f8de543

2 files changed

Lines changed: 94 additions & 0 deletions

File tree

internal/shared/types/app_manifest.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type DisplayInformation struct {
7070

7171
type AppFeatures struct {
7272
AppHome ManifestAppHome `json:"app_home,omitempty" yaml:"app_home,flow,omitempty"`
73+
AgentView *AgentView `json:"agent_view,omitempty" yaml:"agent_view,omitempty"`
7374
AssistantView *AssistantView `json:"assistant_view,omitempty" yaml:"assistant_view,omitempty"`
7475
BotUser BotUser `json:"bot_user,omitempty" yaml:"bot_user,flow,omitempty"`
7576
WorkflowSteps []WorkflowStep `json:"workflow_steps,omitempty" yaml:"workflow_steps,flow,omitempty"`
@@ -95,6 +96,17 @@ type SuggestedPrompts struct {
9596
Message string `json:"message,omitempty" yaml:"message,omitempty"`
9697
}
9798

99+
type AgentView struct {
100+
AgentDescription string `json:"agent_description,omitempty" yaml:"agent_description,omitempty"`
101+
SuggestedPrompts []SuggestedPrompts `json:"suggested_prompts,omitempty" yaml:"suggested_prompts,flow,omitempty"`
102+
Actions []AgentViewAction `json:"actions,omitempty" yaml:"actions,flow,omitempty"`
103+
}
104+
105+
type AgentViewAction struct {
106+
Name string `json:"name,omitempty" yaml:"name,omitempty"`
107+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
108+
}
109+
98110
type OAuthConfig struct {
99111
RedirectURLs []string `json:"redirect_urls,omitempty" yaml:"redirect_urls,flow,omitempty"`
100112
Scopes *ManifestScopes `json:"scopes,omitempty" yaml:"scopes,flow,omitempty"`

internal/shared/types/app_manifest_test.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,40 @@ func Test_AppManifest_AppFeatures(t *testing.T) {
192192
},
193193
want: `{"app_home":{},"assistant_view":{"assistant_description":"magic","suggested_prompts":[{"title":"visit the beach","message":"what is glass"}]},"bot_user":{"display_name":"einstein"}}`,
194194
},
195+
"includes agent view when provided": {
196+
features: AppFeatures{
197+
AgentView: &AgentView{
198+
AgentDescription: "summarizes threads",
199+
SuggestedPrompts: []SuggestedPrompts{
200+
{
201+
Title: "summarize this thread",
202+
Message: "please summarize the conversation",
203+
},
204+
},
205+
Actions: []AgentViewAction{
206+
{
207+
Name: "open_settings",
208+
Description: "Open the agent settings panel.",
209+
},
210+
},
211+
},
212+
BotUser: BotUser{
213+
DisplayName: "agent_smith",
214+
},
215+
},
216+
want: `{"app_home":{},"agent_view":{"agent_description":"summarizes threads","suggested_prompts":[{"title":"summarize this thread","message":"please summarize the conversation"}],"actions":[{"name":"open_settings","description":"Open the agent settings panel."}]},"bot_user":{"display_name":"agent_smith"}}`,
217+
},
218+
"omits agent view fields when empty": {
219+
features: AppFeatures{
220+
AgentView: &AgentView{
221+
AgentDescription: "minimal",
222+
},
223+
BotUser: BotUser{
224+
DisplayName: "agent_smith",
225+
},
226+
},
227+
want: `{"app_home":{},"agent_view":{"agent_description":"minimal"},"bot_user":{"display_name":"agent_smith"}}`,
228+
},
195229
"includes search when provided": {
196230
features: AppFeatures{
197231
BotUser: BotUser{
@@ -226,6 +260,54 @@ func Test_AppManifest_AppFeatures(t *testing.T) {
226260
}
227261
}
228262

263+
func Test_AppManifest_AgentView_RoundTrip(t *testing.T) {
264+
original := AppManifest{
265+
DisplayInformation: DisplayInformation{Name: "agent_smith"},
266+
Features: &AppFeatures{
267+
AgentView: &AgentView{
268+
AgentDescription: "summarizes threads",
269+
SuggestedPrompts: []SuggestedPrompts{
270+
{Title: "summarize", Message: "please summarize"},
271+
},
272+
Actions: []AgentViewAction{
273+
{Name: "open_settings", Description: "Open the agent settings panel."},
274+
},
275+
},
276+
},
277+
}
278+
279+
t.Run("JSON round-trip preserves agent_view", func(t *testing.T) {
280+
blob, err := json.Marshal(original)
281+
require.NoError(t, err)
282+
assert.Contains(t, string(blob), `"agent_view":{`)
283+
284+
var got AppManifest
285+
require.NoError(t, json.Unmarshal(blob, &got))
286+
assert.Equal(t, original.Features.AgentView, got.Features.AgentView)
287+
})
288+
289+
t.Run("YAML round-trip preserves agent_view", func(t *testing.T) {
290+
blob, err := yaml.Marshal(original)
291+
require.NoError(t, err)
292+
assert.Contains(t, string(blob), "agent_view:")
293+
assert.Contains(t, string(blob), "agent_description: summarizes threads")
294+
295+
var got AppManifest
296+
require.NoError(t, yaml.Unmarshal(blob, &got))
297+
assert.Equal(t, original.Features.AgentView, got.Features.AgentView)
298+
})
299+
300+
t.Run("nil agent_view is omitted from JSON", func(t *testing.T) {
301+
manifest := AppManifest{
302+
DisplayInformation: DisplayInformation{Name: "no_agent"},
303+
Features: &AppFeatures{BotUser: BotUser{DisplayName: "no_agent"}},
304+
}
305+
blob, err := json.Marshal(manifest)
306+
require.NoError(t, err)
307+
assert.NotContains(t, string(blob), "agent_view")
308+
})
309+
}
310+
229311
func Test_AppManifest_AppSettings_SiwsLinks(t *testing.T) {
230312
expectedSiws := SiwsLinks{
231313
InitiateURI: "an initiate uri",

0 commit comments

Comments
 (0)