( ctx context.Context, callerScope toolspkg.Scope, id toolspkg.ToolID, selector memoryToolSelector, workspaceRef string, )
| 5392 | } |
| 5393 | |
| 5394 | func (n *daemonNativeTools) agentMemoryStoreFor( |
| 5395 | ctx context.Context, |
| 5396 | callerScope toolspkg.Scope, |
| 5397 | id toolspkg.ToolID, |
| 5398 | selector memoryToolSelector, |
| 5399 | workspaceRef string, |
| 5400 | ) (memoryToolLocation, error) { |
| 5401 | agentName := strings.TrimSpace(firstNonEmpty(selector.AgentName, callerScope.AgentName)) |
| 5402 | if agentName == "" { |
| 5403 | return memoryToolLocation{}, nativeRequiredInputError(id, "agent_name") |
| 5404 | } |
| 5405 | tier, err := parseNativeOptionalAgentTier(id, selector.AgentTier, memcontract.AgentTierWorkspace) |
| 5406 | if err != nil { |
| 5407 | return memoryToolLocation{}, err |
| 5408 | } |
| 5409 | base := n.deps.MemoryStore |
| 5410 | location := memoryToolLocation{ |
| 5411 | Scope: memcontract.ScopeAgent, |
| 5412 | AgentName: agentName, |
| 5413 | AgentTier: tier, |
| 5414 | } |
| 5415 | if tier == memcontract.AgentTierWorkspace { |
| 5416 | workspaceID, workspace, err := n.memoryWorkspaceIdentity(ctx, workspaceRef) |
| 5417 | if err != nil { |
| 5418 | return memoryToolLocation{}, err |
| 5419 | } |
| 5420 | if workspace == "" { |
| 5421 | return memoryToolLocation{}, core.NewMemoryValidationError( |
| 5422 | errors.New("workspace is required for workspace-tier agent memory"), |
| 5423 | ) |
| 5424 | } |
| 5425 | base = base.ForWorkspace(workspace) |
| 5426 | location.Workspace = workspace |
| 5427 | location.WorkspaceID = workspaceID |
| 5428 | } |
| 5429 | location.Store = base.ForAgent(location.WorkspaceID, agentName, tier) |
| 5430 | return location, nil |
| 5431 | } |
| 5432 | |
| 5433 | func parseNativeOptionalAgentTier( |
| 5434 | id toolspkg.ToolID, |
no test coverage detected