@@ -16,11 +16,7 @@ import type { DynamicAgentTemplate } from '@codebuff/common/types/dynamic-agent-
1616/**
1717 * Handle the publish command to upload agent templates to the backend
1818 * @param agentId The id of the agent to publish (required)
19- * @param publisherId The id of the publisher to use (optional)
20- */ export async function handlePublish (
21- agentIds : string [ ] ,
22- publisherId ?: string ,
23- ) : Promise < void > {
19+ */ export async function handlePublish ( agentIds : string [ ] ) : Promise < void > {
2420 const user = getUserCredentials ( )
2521
2622 if ( ! user ) {
@@ -95,7 +91,6 @@ import type { DynamicAgentTemplate } from '@codebuff/common/types/dynamic-agent-
9591 const result = await publishAgentTemplates (
9692 Object . values ( matchingTemplates ) ,
9793 user . authToken ! ,
98- publisherId ,
9994 )
10095
10196 if ( result . success ) {
@@ -111,73 +106,27 @@ import type { DynamicAgentTemplate } from '@codebuff/common/types/dynamic-agent-
111106 }
112107
113108 console . log ( red ( `❌ Failed to publish agents: ${ result . error } ` ) )
114- if ( result . statusCode !== 403 ) {
115- return
116- }
117109
118- // Check if this is a "no publisher" error vs "multiple publishers" error
119- if ( result . error ?. includes ( 'No publisher associated with user' ) ) {
120- console . log ( )
121- console . log (
122- cyan ( 'Please visit the website to create your publisher profile:' ) ,
123- )
124- console . log ( yellow ( `${ websiteUrl } /publishers` ) )
110+ // Show helpful guidance based on error type
111+ if ( result . error ?. includes ( 'Publisher field required' ) ) {
125112 console . log ( )
126- console . log ( 'A publisher profile allows you to:' )
127- console . log ( ' • Publish and manage your agents' )
128- console . log ( ' • Build your reputation in the community' )
129- console . log ( ' • Organize agents under your name or organization' )
113+ console . log ( cyan ( 'Add a "publisher" field to your agent templates:' ) )
114+ console . log ( yellow ( ' "publisher": "<publisher-id>"' ) )
130115 console . log ( )
131116 } else if (
132- result . availablePublishers &&
133- result . availablePublishers . length > 0
117+ result . error ?. includes ( 'Publisher not found or not accessible' )
134118 ) {
135- // Show available publishers
119+ console . log ( )
136120 console . log (
137121 cyan (
138- 'You have access to multiple publishers. Please specify which one to use: ' ,
122+ 'Check that the publisher ID is correct and you have access to it. ' ,
139123 ) ,
140124 )
141125 console . log ( )
142- console . log ( cyan ( 'Available publishers:' ) )
143- result . availablePublishers . forEach ( ( publisher ) => {
144- const orgInfo = publisher . organizationName
145- ? ` (${ publisher . organizationName } )`
146- : ''
147- const typeInfo =
148- publisher . ownershipType === 'organization'
149- ? ' [Organization]'
150- : ' [Personal]'
151- console . log (
152- ` • ${ yellow ( publisher . id ) } - ${ publisher . name } ${ orgInfo } ${ typeInfo } ` ,
153- )
154- } )
155- console . log ( )
156- console . log ( 'Run one of these commands:' )
157- result . availablePublishers . forEach ( ( publisher ) => {
158- console . log (
159- yellow (
160- ` codebuff publish ${ agentIds . join ( ' ' ) } --publisher ${ publisher . id } ` ,
161- ) ,
162- )
163- } )
164- console . log ( )
165- console . log ( cyan ( 'Or visit the website to manage your publishers:' ) )
166- console . log ( yellow ( `${ websiteUrl } /publishers` ) )
167- console . log ( )
168- } else {
169- // Generic 403 error
170- console . log ( cyan ( 'You may need to specify which publisher to use.' ) )
171- console . log ( )
172- console . log ( 'Try running:' )
173- console . log (
174- yellow ( ` publish ${ agentIds . join ( ' ' ) } --publisher <publisher-id>` ) ,
175- )
176- console . log ( )
177- console . log ( cyan ( 'Visit the website to see your available publishers:' ) )
178- console . log ( yellow ( `${ websiteUrl } /publishers` ) )
179- console . log ( )
180126 }
127+
128+ console . log ( cyan ( 'Visit the website to manage your publishers:' ) )
129+ console . log ( yellow ( `${ websiteUrl } /publishers` ) )
181130 } catch ( error ) {
182131 console . log (
183132 red (
@@ -204,7 +153,6 @@ import type { DynamicAgentTemplate } from '@codebuff/common/types/dynamic-agent-
204153async function publishAgentTemplates (
205154 data : DynamicAgentTemplate [ ] ,
206155 authToken : string ,
207- publisherId ?: string ,
208156) : Promise < PublishAgentsResponse & { statusCode ?: number } > {
209157 try {
210158 const response = await fetch ( `${ websiteUrl } /api/agents/publish` , {
@@ -215,7 +163,6 @@ async function publishAgentTemplates(
215163 body : JSON . stringify ( {
216164 data,
217165 authToken,
218- ...( publisherId && { publisherId } ) ,
219166 } ) ,
220167 } )
221168
0 commit comments