X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/6c7859cfea123479aba046614ee81028651ddaf5..f4509310b5abe5012cb83bed3960404e8fa92217:/notify.go?ds=sidebyside diff --git a/notify.go b/notify.go index 2071ce6..d4e4e7a 100644 --- a/notify.go +++ b/notify.go @@ -37,15 +37,18 @@ const ( // time. notifyTimeout = 10 * time.Second - notifyUsage = `Usage: onechat notify --source SOURCE --id ID --text TEXT + notifyUsage = `Usage: onechat notify [--agent-id ID] --source SOURCE --id ID --text TEXT -Send untrusted external data to the root agent at its next turn boundary. +Send untrusted external data at the selected agent's next turn boundary. +Omit --agent-id for root. An explicit ID must identify the root or a permanent +child, not a task worker. Names are not accepted. Success means durably accepted, not processed. Retry with the same source, -ID, and text after an uncertain result. Changed text for an existing key fails. +ID, target identity, and text after an uncertain result. A changed target or +text for an existing key fails. Text is limited to 32768 bytes. Source and ID are 1 to 128 ASCII letters, digits, dots, underscores, or hyphens. The local test interface keeps up to 1024 receipts without expiry and rejects new keys when full. -Child targets, receipt expiry, and processing status are not supported. +Receipt expiry and processing status are not supported. ` ) @@ -171,9 +174,10 @@ func notifyParse(args []string) (NotifyInput, error) { var input NotifyInput fields := map[string]*string{ - "--source": &input.Source, - "--id": &input.ID, - "--text": &input.Text, + "--agent-id": &input.AgentID, + "--source": &input.Source, + "--id": &input.ID, + "--text": &input.Text, } seen := make(map[string]bool) @@ -197,6 +201,10 @@ func notifyParse(args []string) (NotifyInput, error) { *field = value } + if seen["--agent-id"] && input.AgentID == "" { + return input, errors.New("notification agent ID must not be empty") + } + err := notifyValidate(input) if err != nil { return input, fmt.Errorf("validate notification: %w", err)