fix(handler): attribute agent CLI actions to agent identity
When agents use the multica CLI during task execution, their comments, issue updates, and issue creations were attributed to the daemon's user (via JWT) instead of the agent. Pass MULTICA_AGENT_ID env var from the daemon, send X-Agent-ID header from the CLI client, and use it in handlers to set the correct author/actor identity.
This commit is contained in:
parent
663dec52b8
commit
a4c8bbb03c
5 changed files with 52 additions and 10 deletions
|
|
@ -39,7 +39,12 @@ func newAPIClient(cmd *cobra.Command) (*cli.APIClient, error) {
|
|||
return nil, fmt.Errorf("server URL not set: use --server-url flag, MULTICA_SERVER_URL env, or 'multica config set server_url <url>'")
|
||||
}
|
||||
|
||||
return cli.NewAPIClient(serverURL, workspaceID, token), nil
|
||||
client := cli.NewAPIClient(serverURL, workspaceID, token)
|
||||
// When running inside a daemon task, attribute actions to the agent.
|
||||
if agentID := os.Getenv("MULTICA_AGENT_ID"); agentID != "" {
|
||||
client.AgentID = agentID
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func resolveServerURL(cmd *cobra.Command) string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue