-
Notifications
You must be signed in to change notification settings - Fork 818
feat: add Manus provider #700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hhh2210
wants to merge
4
commits into
steipete:main
Choose a base branch
from
hhh2210:manus-provider-main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
28d4e95
Add Manus credits provider
hhh2210 21cb6c0
fix: address Copilot and Codex review feedback for Manus provider
hhh2210 2505c1b
Merge remote-tracking branch 'origin/main' into manus-provider-main
hhh2210 03d7547
Address Codex review on Manus provider
hhh2210 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
Sources/CodexBar/Providers/Manus/ManusProviderImplementation.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| import AppKit | ||
| import CodexBarCore | ||
| import CodexBarMacroSupport | ||
| import Foundation | ||
| import SwiftUI | ||
|
|
||
| @ProviderImplementationRegistration | ||
| struct ManusProviderImplementation: ProviderImplementation { | ||
| let id: UsageProvider = .manus | ||
| let supportsLoginFlow: Bool = true | ||
|
|
||
| @MainActor | ||
| func presentation(context _: ProviderPresentationContext) -> ProviderPresentation { | ||
| ProviderPresentation { _ in "web" } | ||
| } | ||
|
|
||
| @MainActor | ||
| func runLoginFlow(context _: ProviderLoginContext) async -> Bool { | ||
| if let url = URL(string: "https://manus.im") { | ||
| NSWorkspace.shared.open(url) | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| @MainActor | ||
| func observeSettings(_ settings: SettingsStore) { | ||
| _ = settings.manusCookieSource | ||
| _ = settings.manusManualCookieHeader | ||
| } | ||
|
|
||
| @MainActor | ||
| func settingsSnapshot(context: ProviderSettingsSnapshotContext) -> ProviderSettingsSnapshotContribution? { | ||
| .manus(context.settings.manusSettingsSnapshot(tokenOverride: context.tokenOverride)) | ||
| } | ||
|
Comment on lines
+24
to
+34
|
||
|
|
||
| @MainActor | ||
| func tokenAccountsVisibility(context: ProviderSettingsContext, support: TokenAccountSupport) -> Bool { | ||
| guard support.requiresManualCookieSource else { return true } | ||
| if !context.settings.tokenAccounts(for: context.provider).isEmpty { return true } | ||
| return context.settings.manusCookieSource == .manual | ||
| } | ||
|
|
||
| @MainActor | ||
| func applyTokenAccountCookieSource(settings: SettingsStore) { | ||
| if settings.manusCookieSource != .manual { | ||
| settings.manusCookieSource = .manual | ||
| } | ||
| } | ||
|
|
||
| @MainActor | ||
| func settingsPickers(context: ProviderSettingsContext) -> [ProviderSettingsPickerDescriptor] { | ||
| let cookieBinding = Binding( | ||
| get: { context.settings.manusCookieSource.rawValue }, | ||
| set: { raw in | ||
| context.settings.manusCookieSource = ProviderCookieSource(rawValue: raw) ?? .auto | ||
| }) | ||
| let options = ProviderCookieSourceUI.options( | ||
| allowsOff: true, | ||
| keychainDisabled: context.settings.debugDisableKeychainAccess) | ||
|
|
||
| let subtitle: () -> String? = { | ||
| ProviderCookieSourceUI.subtitle( | ||
| source: context.settings.manusCookieSource, | ||
| keychainDisabled: context.settings.debugDisableKeychainAccess, | ||
| auto: "Automatically imports browser session cookies.", | ||
| manual: "Paste the session_id value or a full Cookie header.", | ||
| off: "Manus cookies are disabled.") | ||
| } | ||
|
|
||
| return [ | ||
| ProviderSettingsPickerDescriptor( | ||
| id: "manus-cookie-source", | ||
| title: "Cookie source", | ||
| subtitle: "Automatically imports browser session cookies.", | ||
| dynamicSubtitle: subtitle, | ||
| binding: cookieBinding, | ||
| options: options, | ||
| isVisible: nil, | ||
| onChange: nil), | ||
| ] | ||
| } | ||
|
|
||
| @MainActor | ||
| func settingsFields(context: ProviderSettingsContext) -> [ProviderSettingsFieldDescriptor] { | ||
| [ | ||
| ProviderSettingsFieldDescriptor( | ||
| id: "manus-cookie", | ||
| title: "", | ||
| subtitle: "", | ||
| kind: .secure, | ||
| placeholder: "session_id=...\n\nor paste just the session_id value", | ||
| binding: context.stringBinding(\.manusManualCookieHeader), | ||
| actions: [ | ||
| ProviderSettingsActionDescriptor( | ||
| id: "manus-open-dashboard", | ||
| title: "Open Manus", | ||
| style: .link, | ||
| isVisible: nil, | ||
| perform: { | ||
| if let url = URL(string: "https://manus.im") { | ||
| NSWorkspace.shared.open(url) | ||
| } | ||
| }), | ||
| ], | ||
| isVisible: { context.settings.manusCookieSource == .manual }, | ||
| onActivate: nil), | ||
| ] | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import CodexBarCore | ||
| import Foundation | ||
|
|
||
| extension SettingsStore { | ||
| var manusManualCookieHeader: String { | ||
| get { self.configSnapshot.providerConfig(for: .manus)?.sanitizedCookieHeader ?? "" } | ||
| set { | ||
| self.updateProviderConfig(provider: .manus) { entry in | ||
| entry.cookieHeader = self.normalizedConfigValue(newValue) | ||
| } | ||
| self.logSecretUpdate(provider: .manus, field: "cookieHeader", value: newValue) | ||
| } | ||
| } | ||
|
|
||
| var manusCookieSource: ProviderCookieSource { | ||
| get { self.resolvedCookieSource(provider: .manus, fallback: .auto) } | ||
| set { | ||
| self.updateProviderConfig(provider: .manus) { entry in | ||
| entry.cookieSource = newValue | ||
| } | ||
| self.logProviderModeChange(provider: .manus, field: "cookieSource", value: newValue.rawValue) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| extension SettingsStore { | ||
| func manusSettingsSnapshot(tokenOverride: TokenAccountOverride?) -> ProviderSettingsSnapshot.ManusProviderSettings { | ||
| ProviderSettingsSnapshot.ManusProviderSettings( | ||
| cookieSource: self.manusSnapshotCookieSource(tokenOverride: tokenOverride), | ||
| manualCookieHeader: self.manusSnapshotCookieHeader(tokenOverride: tokenOverride)) | ||
| } | ||
|
|
||
| private func manusSnapshotCookieHeader(tokenOverride: TokenAccountOverride?) -> String { | ||
| let fallback = self.manusManualCookieHeader | ||
| guard let support = TokenAccountSupportCatalog.support(for: .manus), | ||
| case .cookieHeader = support.injection | ||
| else { | ||
| return fallback | ||
| } | ||
| guard let account = ProviderTokenAccountSelection.selectedAccount( | ||
| provider: .manus, | ||
| settings: self, | ||
| override: tokenOverride) | ||
| else { | ||
| return fallback | ||
| } | ||
| return TokenAccountSupportCatalog.normalizedCookieHeader(account.token, support: support) | ||
| } | ||
|
|
||
| private func manusSnapshotCookieSource(tokenOverride: TokenAccountOverride?) -> ProviderCookieSource { | ||
| let fallback = self.manusCookieSource | ||
| guard let support = TokenAccountSupportCatalog.support(for: .manus), | ||
| support.requiresManualCookieSource | ||
| else { | ||
| return fallback | ||
| } | ||
| if self.tokenAccounts(for: .manus).isEmpty { return fallback } | ||
| return .manual | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new README entry links to
docs/manus.md, but that file is not present in the repository, so the provider documentation link is broken for readers. Point this link to an existing page (or add the missing docs file) to avoid dead navigation from the main project page.Useful? React with 👍 / 👎.