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

Method nativeThreadPromotionSource

internal/daemon/native_tools.go:3064–3126  ·  view source on GitHub ↗
(
	ctx context.Context,
	scope toolspkg.Scope,
	toolID toolspkg.ToolID,
	input taskPromoteFromThreadInput,
)

Source from the content-addressed store, hash-verified

3062}
3063
3064func (n *daemonNativeTools) nativeThreadPromotionSource(
3065 ctx context.Context,
3066 scope toolspkg.Scope,
3067 toolID toolspkg.ToolID,
3068 input taskPromoteFromThreadInput,
3069) (nativeThreadPromotionSource, error) {
3070 if n.deps.NetworkStore == nil {
3071 return nativeThreadPromotionSource{}, nativeUnavailableError(toolID, "network store is unavailable")
3072 }
3073 channel, err := nativeNetworkChannel(toolID, input.Channel)
3074 if err != nil {
3075 return nativeThreadPromotionSource{}, err
3076 }
3077 threadID := strings.TrimSpace(input.ThreadID)
3078 if err := network.ValidateConversationID(threadID, "thread_id"); err != nil {
3079 return nativeThreadPromotionSource{}, nativeNetworkInputError(toolID, err)
3080 }
3081 originMessageID, err := requiredNativeString(toolID, "origin_message_id", input.OriginMessageID)
3082 if err != nil {
3083 return nativeThreadPromotionSource{}, err
3084 }
3085 workspaceID, err := n.nativeNetworkWorkspaceID(ctx, toolID, input.WorkspaceID, scope)
3086 if err != nil {
3087 return nativeThreadPromotionSource{}, err
3088 }
3089 messages, err := n.deps.NetworkStore.ListConversationMessages(
3090 ctx,
3091 store.NetworkConversationRef{
3092 WorkspaceID: workspaceID,
3093 Channel: channel,
3094 Surface: store.NetworkSurfaceThread,
3095 ThreadID: threadID,
3096 },
3097 store.NetworkConversationMessageQuery{Limit: 200},
3098 )
3099 if err != nil {
3100 return nativeThreadPromotionSource{}, nativeNetworkInputError(toolID, err)
3101 }
3102 digest, sourceMessageIDs, found := nativeNetworkThreadPromotionDigest(messages, originMessageID)
3103 if !found {
3104 return nativeThreadPromotionSource{}, nativeNetworkInputError(
3105 toolID,
3106 fmt.Errorf("origin_message_id %q is not part of thread %q", originMessageID, threadID),
3107 )
3108 }
3109 thread, err := n.deps.NetworkStore.GetThread(
3110 ctx,
3111 store.NetworkChannelRef{WorkspaceID: workspaceID, Channel: channel},
3112 threadID,
3113 )
3114 if err != nil {
3115 return nativeThreadPromotionSource{}, nativeNetworkInputError(toolID, err)
3116 }
3117 return nativeThreadPromotionSource{
3118 workspaceID: workspaceID,
3119 channel: channel,
3120 threadID: threadID,
3121 originMessageID: originMessageID,

Callers 1

taskPromoteFromThreadMethod · 0.95

Calls 9

ValidateConversationIDFunction · 0.92
nativeUnavailableErrorFunction · 0.85
nativeNetworkChannelFunction · 0.85
nativeNetworkInputErrorFunction · 0.85
requiredNativeStringFunction · 0.85
GetThreadMethod · 0.65

Tested by

no test coverage detected