mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-03-21 16:40:22 +00:00
feat(kiro): add IDC auth and endpoint improvements, redesign fingerprint system
- Add IAM Identity Center (IDC) authentication with CLI flags (--kiro-idc-login, --kiro-idc-start-url, --kiro-idc-region) and login flow - Add ProfileArn auto-fetching in Execute/ExecuteStream for imported IDC accounts - Simplify endpoint preference with map-based alias lookup and getAuthValue helper - Redesign fingerprint as global singleton with external config and per-account deterministic generation - Add StartURL and FingerprintConfig fields to Kiro config - Add AgentContinuationID/AgentTaskType support in Kiro translators - Add comprehensive tests for executor, fingerprint, SSO OIDC, and AWS helpers - Add CLI login documentation to README
This commit is contained in:
@@ -38,10 +38,12 @@ type KiroInferenceConfig struct {
|
||||
|
||||
// KiroConversationState holds the conversation context
|
||||
type KiroConversationState struct {
|
||||
ChatTriggerType string `json:"chatTriggerType"` // Required: "MANUAL" - must be first field
|
||||
ConversationID string `json:"conversationId"`
|
||||
CurrentMessage KiroCurrentMessage `json:"currentMessage"`
|
||||
History []KiroHistoryMessage `json:"history,omitempty"`
|
||||
AgentContinuationID string `json:"agentContinuationId,omitempty"`
|
||||
AgentTaskType string `json:"agentTaskType,omitempty"`
|
||||
ChatTriggerType string `json:"chatTriggerType"` // Required: "MANUAL"
|
||||
ConversationID string `json:"conversationId"`
|
||||
CurrentMessage KiroCurrentMessage `json:"currentMessage"`
|
||||
History []KiroHistoryMessage `json:"history,omitempty"`
|
||||
}
|
||||
|
||||
// KiroCurrentMessage wraps the current user message
|
||||
@@ -293,10 +295,18 @@ func BuildKiroPayload(claudeBody []byte, modelID, profileArn, origin string, isA
|
||||
}
|
||||
}
|
||||
|
||||
// Session IDs: extract from messages[].additional_kwargs (LangChain format) or random
|
||||
conversationID := extractMetadataFromMessages(messages, "conversationId")
|
||||
continuationID := extractMetadataFromMessages(messages, "continuationId")
|
||||
if conversationID == "" {
|
||||
conversationID = uuid.New().String()
|
||||
}
|
||||
|
||||
payload := KiroPayload{
|
||||
ConversationState: KiroConversationState{
|
||||
AgentTaskType: "vibe",
|
||||
ChatTriggerType: "MANUAL",
|
||||
ConversationID: uuid.New().String(),
|
||||
ConversationID: conversationID,
|
||||
CurrentMessage: currentMessage,
|
||||
History: history,
|
||||
},
|
||||
@@ -304,6 +314,11 @@ func BuildKiroPayload(claudeBody []byte, modelID, profileArn, origin string, isA
|
||||
InferenceConfig: inferenceConfig,
|
||||
}
|
||||
|
||||
// Only set AgentContinuationID if client provided
|
||||
if continuationID != "" {
|
||||
payload.ConversationState.AgentContinuationID = continuationID
|
||||
}
|
||||
|
||||
result, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
log.Debugf("kiro: failed to marshal payload: %v", err)
|
||||
@@ -329,6 +344,18 @@ func normalizeOrigin(origin string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// extractMetadataFromMessages extracts metadata from messages[].additional_kwargs (LangChain format).
|
||||
// Searches from the last message backwards, returns empty string if not found.
|
||||
func extractMetadataFromMessages(messages gjson.Result, key string) string {
|
||||
arr := messages.Array()
|
||||
for i := len(arr) - 1; i >= 0; i-- {
|
||||
if val := arr[i].Get("additional_kwargs." + key); val.Exists() && val.String() != "" {
|
||||
return val.String()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// extractSystemPrompt extracts system prompt from Claude request
|
||||
func extractSystemPrompt(claudeBody []byte) string {
|
||||
systemField := gjson.GetBytes(claudeBody, "system")
|
||||
|
||||
@@ -36,10 +36,12 @@ type KiroInferenceConfig struct {
|
||||
|
||||
// KiroConversationState holds the conversation context
|
||||
type KiroConversationState struct {
|
||||
ChatTriggerType string `json:"chatTriggerType"` // Required: "MANUAL"
|
||||
ConversationID string `json:"conversationId"`
|
||||
CurrentMessage KiroCurrentMessage `json:"currentMessage"`
|
||||
History []KiroHistoryMessage `json:"history,omitempty"`
|
||||
AgentContinuationID string `json:"agentContinuationId,omitempty"`
|
||||
AgentTaskType string `json:"agentTaskType,omitempty"`
|
||||
ChatTriggerType string `json:"chatTriggerType"` // Required: "MANUAL"
|
||||
ConversationID string `json:"conversationId"`
|
||||
CurrentMessage KiroCurrentMessage `json:"currentMessage"`
|
||||
History []KiroHistoryMessage `json:"history,omitempty"`
|
||||
}
|
||||
|
||||
// KiroCurrentMessage wraps the current user message
|
||||
@@ -297,10 +299,18 @@ func BuildKiroPayloadFromOpenAI(openaiBody []byte, modelID, profileArn, origin s
|
||||
}
|
||||
}
|
||||
|
||||
// Session IDs: extract from messages[].additional_kwargs (LangChain format) or random
|
||||
conversationID := extractMetadataFromMessages(messages, "conversationId")
|
||||
continuationID := extractMetadataFromMessages(messages, "continuationId")
|
||||
if conversationID == "" {
|
||||
conversationID = uuid.New().String()
|
||||
}
|
||||
|
||||
payload := KiroPayload{
|
||||
ConversationState: KiroConversationState{
|
||||
AgentTaskType: "vibe",
|
||||
ChatTriggerType: "MANUAL",
|
||||
ConversationID: uuid.New().String(),
|
||||
ConversationID: conversationID,
|
||||
CurrentMessage: currentMessage,
|
||||
History: history,
|
||||
},
|
||||
@@ -308,6 +318,11 @@ func BuildKiroPayloadFromOpenAI(openaiBody []byte, modelID, profileArn, origin s
|
||||
InferenceConfig: inferenceConfig,
|
||||
}
|
||||
|
||||
// Only set AgentContinuationID if client provided
|
||||
if continuationID != "" {
|
||||
payload.ConversationState.AgentContinuationID = continuationID
|
||||
}
|
||||
|
||||
result, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
log.Debugf("kiro-openai: failed to marshal payload: %v", err)
|
||||
@@ -333,6 +348,18 @@ func normalizeOrigin(origin string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// extractMetadataFromMessages extracts metadata from messages[].additional_kwargs (LangChain format).
|
||||
// Searches from the last message backwards, returns empty string if not found.
|
||||
func extractMetadataFromMessages(messages gjson.Result, key string) string {
|
||||
arr := messages.Array()
|
||||
for i := len(arr) - 1; i >= 0; i-- {
|
||||
if val := arr[i].Get("additional_kwargs." + key); val.Exists() && val.String() != "" {
|
||||
return val.String()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// extractSystemPromptFromOpenAI extracts system prompt from OpenAI messages
|
||||
func extractSystemPromptFromOpenAI(messages gjson.Result) string {
|
||||
if !messages.IsArray() {
|
||||
|
||||
Reference in New Issue
Block a user