Finalize inbox artifacts and error protocol
This commit is contained in:
@@ -23,6 +23,7 @@ type sendOptions struct {
|
||||
bodyFile string
|
||||
payloadJSON string
|
||||
priority string
|
||||
artifacts artifactOptions
|
||||
}
|
||||
|
||||
func newSendCmd(root *rootOptions) *cobra.Command {
|
||||
@@ -39,16 +40,20 @@ func newSendCmd(root *rootOptions) *cobra.Command {
|
||||
from = root.agent
|
||||
}
|
||||
if from == "" {
|
||||
return fmt.Errorf("from agent is required")
|
||||
return protocol.InvalidInput("from agent is required", nil)
|
||||
}
|
||||
if opts.threadID == "" && opts.subject == "" {
|
||||
return fmt.Errorf("subject is required when creating a new thread")
|
||||
return protocol.InvalidInput("subject is required when creating a new thread", nil)
|
||||
}
|
||||
|
||||
body, err := resolveBodyValue(opts.body, opts.bodyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
artifacts, err := resolveArtifacts(opts.artifacts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sqlDB, err := db.Open(ctx, root.dbPath)
|
||||
if err != nil {
|
||||
@@ -69,6 +74,7 @@ func newSendCmd(root *rootOptions) *cobra.Command {
|
||||
Body: body,
|
||||
PayloadJSON: opts.payloadJSON,
|
||||
Priority: opts.priority,
|
||||
Artifacts: artifacts,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -104,6 +110,7 @@ func newSendCmd(root *rootOptions) *cobra.Command {
|
||||
cmd.Flags().StringVar(&opts.bodyFile, "body-file", "", "Read message body from file")
|
||||
cmd.Flags().StringVar(&opts.payloadJSON, "payload-json", "", "Structured payload JSON string")
|
||||
cmd.Flags().StringVar(&opts.priority, "priority", "normal", "Thread priority")
|
||||
addArtifactFlags(cmd, &opts.artifacts)
|
||||
|
||||
_ = cmd.MarkFlagRequired("to")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user