Support string Codex request IDs
This commit is contained in:
@@ -1134,7 +1134,7 @@ func (b *Bot) handleApprovalCallback(ctx context.Context, callback *CallbackQuer
|
||||
if approval.Status != "pending" {
|
||||
return b.tg.AnswerCallbackQuery(ctx, callback.ID, "Already resolved.")
|
||||
}
|
||||
requestID, err := strconv.ParseInt(approval.CodexRequestID, 10, 64)
|
||||
requestID, err := codexapp.ParseRequestIDKey(approval.CodexRequestID)
|
||||
if err != nil {
|
||||
return b.tg.AnswerCallbackQuery(ctx, callback.ID, "Invalid request id.")
|
||||
}
|
||||
@@ -1169,6 +1169,9 @@ func (b *Bot) handleCodexEvents(ctx context.Context) {
|
||||
if event.ServerRequest {
|
||||
if err := b.handleCodexServerRequest(ctx, event); err != nil {
|
||||
b.logger.Printf("server request %s: %v", event.Method, err)
|
||||
if event.ID != nil {
|
||||
_ = b.codex.RespondServerRequestError(ctx, *event.ID, -32603, err.Error())
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
@@ -1710,14 +1713,13 @@ func (b *Bot) syncThreadWorkspaceFromCWD(ctx context.Context, codexThreadID, cwd
|
||||
|
||||
func (b *Bot) handleCodexServerRequest(ctx context.Context, event codexapp.Event) error {
|
||||
if event.ID == nil {
|
||||
return nil
|
||||
return errors.New("server request missing id")
|
||||
}
|
||||
switch event.Method {
|
||||
case "item/commandExecution/requestApproval", "item/fileChange/requestApproval", "item/permissions/requestApproval":
|
||||
case "execCommandApproval", "applyPatchApproval":
|
||||
default:
|
||||
b.logger.Printf("unhandled server request: %s", event.Method)
|
||||
return nil
|
||||
return fmt.Errorf("unsupported Codex server request: %s", event.Method)
|
||||
}
|
||||
var params struct {
|
||||
ThreadID string `json:"threadId"`
|
||||
@@ -1747,7 +1749,7 @@ func (b *Bot) handleCodexServerRequest(ctx context.Context, event codexapp.Event
|
||||
kind := event.Method
|
||||
approval, err := b.store.UpsertPendingApproval(ctx, store.PendingApproval{
|
||||
TelegramUserID: thread.TelegramUserID,
|
||||
CodexRequestID: strconv.FormatInt(*event.ID, 10),
|
||||
CodexRequestID: event.ID.Key(),
|
||||
CodexThreadID: threadID,
|
||||
TurnID: params.TurnID,
|
||||
ItemID: itemID,
|
||||
|
||||
Reference in New Issue
Block a user