MCPcopy Create free account
hub / github.com/compozy/agh / memoryStoreFor

Method memoryStoreFor

internal/daemon/native_tools.go:5228–5270  ·  view source on GitHub ↗
(
	ctx context.Context,
	callerScope toolspkg.Scope,
	id toolspkg.ToolID,
	selector memoryToolSelector,
	defaultScope memcontract.Scope,
)

Source from the content-addressed store, hash-verified

5226}
5227
5228func (n *daemonNativeTools) memoryStoreFor(
5229 ctx context.Context,
5230 callerScope toolspkg.Scope,
5231 id toolspkg.ToolID,
5232 selector memoryToolSelector,
5233 defaultScope memcontract.Scope,
5234) (memoryToolLocation, error) {
5235 scope, err := core.ParseOptionalMemoryScope(selector.Scope)
5236 if err != nil {
5237 return memoryToolLocation{}, err
5238 }
5239 if scope == "" {
5240 scope = defaultScope.Normalize()
5241 }
5242 if scope == "" {
5243 scope = memcontract.ScopeGlobal
5244 }
5245 workspaceRef := firstNonEmpty(selector.Workspace, callerScope.WorkspaceID)
5246 switch scope.Normalize() {
5247 case memcontract.ScopeGlobal:
5248 return memoryToolLocation{Store: n.deps.MemoryStore, Scope: memcontract.ScopeGlobal}, nil
5249 case memcontract.ScopeWorkspace:
5250 workspaceID, workspace, err := n.memoryWorkspaceIdentity(ctx, workspaceRef)
5251 if err != nil {
5252 return memoryToolLocation{}, err
5253 }
5254 if workspace == "" {
5255 return memoryToolLocation{}, core.NewMemoryValidationError(
5256 errors.New("workspace is required for workspace memory scope"),
5257 )
5258 }
5259 return memoryToolLocation{
5260 Store: n.deps.MemoryStore.ForWorkspace(workspace),
5261 Scope: memcontract.ScopeWorkspace,
5262 Workspace: workspace,
5263 WorkspaceID: workspaceID,
5264 }, nil
5265 case memcontract.ScopeAgent:
5266 return n.agentMemoryStoreFor(ctx, callerScope, id, selector, workspaceRef)
5267 default:
5268 return memoryToolLocation{}, core.NewMemoryValidationError(fmt.Errorf("unsupported scope %q", scope))
5269 }
5270}
5271
5272func (n *daemonNativeTools) memoryRecallStore(
5273 ctx context.Context,

Callers 5

memoryAdminLocationMethod · 0.95
memoryHeaderPayloadsMethod · 0.95
resolveMemoryLocationMethod · 0.95
memoryRecallStoreMethod · 0.95
memoryWriteStoreMethod · 0.95

Calls 7

agentMemoryStoreForMethod · 0.95
ParseOptionalMemoryScopeFunction · 0.92
NewMemoryValidationErrorFunction · 0.92
firstNonEmptyFunction · 0.70
ForWorkspaceMethod · 0.65
NormalizeMethod · 0.45

Tested by

no test coverage detected