( ctx context.Context, callerScope toolspkg.Scope, selector memoryToolSelector, )
| 5069 | } |
| 5070 | |
| 5071 | func (n *daemonNativeTools) memoryHeaderPayloads( |
| 5072 | ctx context.Context, |
| 5073 | callerScope toolspkg.Scope, |
| 5074 | selector memoryToolSelector, |
| 5075 | ) ([]memoryHeaderPayload, error) { |
| 5076 | scope, err := core.ParseOptionalMemoryScope(selector.Scope) |
| 5077 | if err != nil { |
| 5078 | return nil, err |
| 5079 | } |
| 5080 | locations := []memoryToolLocation{{Store: n.deps.MemoryStore, Scope: memcontract.ScopeGlobal}} |
| 5081 | switch scope { |
| 5082 | case memcontract.ScopeGlobal: |
| 5083 | locations = locations[:1] |
| 5084 | case memcontract.ScopeWorkspace: |
| 5085 | location, err := n.memoryStoreFor( |
| 5086 | ctx, |
| 5087 | callerScope, |
| 5088 | toolspkg.ToolIDMemoryList, |
| 5089 | selector, |
| 5090 | memcontract.ScopeWorkspace, |
| 5091 | ) |
| 5092 | if err != nil { |
| 5093 | return nil, err |
| 5094 | } |
| 5095 | locations = []memoryToolLocation{location} |
| 5096 | case memcontract.ScopeAgent: |
| 5097 | location, err := n.memoryStoreFor(ctx, callerScope, toolspkg.ToolIDMemoryList, selector, memcontract.ScopeAgent) |
| 5098 | if err != nil { |
| 5099 | return nil, err |
| 5100 | } |
| 5101 | locations = []memoryToolLocation{location} |
| 5102 | default: |
| 5103 | if strings.TrimSpace(firstNonEmpty(selector.Workspace, callerScope.WorkspaceID)) != "" { |
| 5104 | workspaceSelector := selector |
| 5105 | workspaceSelector.Scope = string(memcontract.ScopeWorkspace) |
| 5106 | location, err := n.memoryStoreFor( |
| 5107 | ctx, |
| 5108 | callerScope, |
| 5109 | toolspkg.ToolIDMemoryList, |
| 5110 | workspaceSelector, |
| 5111 | memcontract.ScopeWorkspace, |
| 5112 | ) |
| 5113 | if err != nil { |
| 5114 | return nil, err |
| 5115 | } |
| 5116 | locations = append(locations, location) |
| 5117 | } |
| 5118 | if strings.TrimSpace(firstNonEmpty(selector.AgentName, callerScope.AgentName)) != "" { |
| 5119 | agentSelector := selector |
| 5120 | agentSelector.Scope = string(memcontract.ScopeAgent) |
| 5121 | location, err := n.memoryStoreFor( |
| 5122 | ctx, |
| 5123 | callerScope, |
| 5124 | toolspkg.ToolIDMemoryList, |
| 5125 | agentSelector, |
| 5126 | memcontract.ScopeAgent, |
| 5127 | ) |
| 5128 | if err != nil { |
no test coverage detected