adding task id to request headers (#2555)

* adding task id to request headers

* changeset
This commit is contained in:
pashpashpash
2025-03-30 05:57:26 -07:00
committed by GitHub
parent 669286bb8e
commit a80022795e
4 changed files with 26 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": minor
---
adding task id to request headers
+5
View File
@@ -17,6 +17,11 @@ export class ClineHandler implements ApiHandler {
this.client = new OpenAI({
baseURL: "https://api.cline.bot/v1",
apiKey: this.options.clineApiKey || "",
defaultHeaders: {
"HTTP-Referer": "https://cline.bot", // Optional, for including your app on cline.bot rankings.
"X-Title": "Cline", // Optional. Shows in rankings on cline.bot.
"X-Task-ID": this.options.taskId || "", // Include the task ID in the request headers
},
})
}
+15 -3
View File
@@ -142,7 +142,6 @@ export class Cline {
})
this.providerRef = new WeakRef(provider)
this.apiProvider = apiConfiguration.apiProvider
this.api = buildApiHandler(apiConfiguration)
this.terminalManager = new TerminalManager()
this.urlContentFetcher = new UrlContentFetcher(provider.context)
this.browserSession = new BrowserSession(provider.context, browserSettings)
@@ -152,17 +151,30 @@ export class Cline {
this.autoApprovalSettings = autoApprovalSettings
this.browserSettings = browserSettings
this.chatSettings = chatSettings
// Initialize taskId first
if (historyItem) {
this.taskId = historyItem.id
this.conversationHistoryDeletedRange = historyItem.conversationHistoryDeletedRange
this.resumeTaskFromHistory()
} else if (task || images) {
this.taskId = Date.now().toString()
this.startTask(task, images)
} else {
throw new Error("Either historyItem or task/images must be provided")
}
// Now that taskId is initialized, we can build the API handler
this.api = buildApiHandler({
...apiConfiguration,
taskId: this.taskId,
})
// Continue with task initialization
if (historyItem) {
this.resumeTaskFromHistory()
} else if (task || images) {
this.startTask(task, images)
}
if (historyItem) {
// Open task from history
telemetryService.captureTaskRestarted(this.taskId, this.apiProvider)
+1
View File
@@ -24,6 +24,7 @@ export interface ApiHandlerOptions {
apiModelId?: string
apiKey?: string // anthropic
clineApiKey?: string
taskId?: string // Used to identify the task in API requests
liteLlmBaseUrl?: string
liteLlmModelId?: string
liteLlmApiKey?: string