cc-pets 2.5.0 → 2.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CC_BRIDGE.md +47 -5
- package/CC_BRIDGE.zh-CN.md +42 -5
- package/CONTRIBUTING.md +1 -1
- package/CONTRIBUTING.zh-CN.md +1 -1
- package/README.md +48 -19
- package/README.zh-CN.md +46 -17
- package/Resources/AgentIcons/antigravity.icns +0 -0
- package/Resources/zh-Hans.lproj/Localizable.strings +64 -15
- package/Sources/CCPets/App/CCPetsAppDelegate+AgentEvents.m +7 -3
- package/Sources/CCPets/App/CCPetsAppDelegate+AgentStatus.m +11 -3
- package/Sources/CCPets/App/CCPetsAppDelegate+Bridge.m +16 -5
- package/Sources/CCPets/App/CCPetsAppDelegate+Private.h +11 -1
- package/Sources/CCPets/App/CCPetsAppDelegate+Profiles.m +21 -11
- package/Sources/CCPets/App/CCPetsAppDelegate+Quota.m +27 -16
- package/Sources/CCPets/App/CCPetsAppDelegate+Settings.m +43 -7
- package/Sources/CCPets/App/CCPetsAppDelegate+Speech.m +2 -1
- package/Sources/CCPets/App/CCPetsAppDelegate+Update.m +3 -3
- package/Sources/CCPets/App/CCPetsAppDelegate+Workbench.m +20 -22
- package/Sources/CCPets/App/CCPetsAppDelegate.m +14 -6
- package/Sources/CCPets/App/CCPetsVersion.h +4 -0
- package/Sources/CCPets/App/CCPetsVersion.m +34 -0
- package/Sources/CCPets/App/main.m +11 -0
- package/Sources/CCPets/Bridge/CCPetsBridge.m +7 -5
- package/Sources/CCPets/Bridge/CCPetsBridgeAntigravityApp.h +4 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeAntigravityApp.m +119 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeCLI.h +3 -1
- package/Sources/CCPets/Bridge/CCPetsBridgeCLI.m +172 -17
- package/Sources/CCPets/Bridge/CCPetsBridgeCore.m +25 -7
- package/Sources/CCPets/Bridge/CCPetsBridgeSetup.m +17 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeStore.h +7 -2
- package/Sources/CCPets/Bridge/CCPetsBridgeStore.m +92 -11
- package/Sources/CCPets/Bridge/CCPetsBridgeTerminalTitle.h +12 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeTerminalTitle.m +105 -0
- package/Sources/CCPets/Integrations/CCPetsAntigravityConfig.h +17 -0
- package/Sources/CCPets/Integrations/CCPetsAntigravityConfig.m +462 -0
- package/Sources/CCPets/Integrations/CCPetsAntigravityEvents.h +5 -0
- package/Sources/CCPets/Integrations/CCPetsAntigravityEvents.m +180 -0
- package/Sources/CCPets/Integrations/CCPetsBridgeTitleRelay.h +3 -0
- package/Sources/CCPets/Integrations/CCPetsBridgeTitleRelay.m +463 -0
- package/Sources/CCPets/Integrations/CCPetsIntegrations.h +1 -1
- package/Sources/CCPets/Integrations/CCPetsIntegrations.m +37 -7
- package/Sources/CCPets/Integrations/CCPetsLaunchPreflight.m +15 -5
- package/Sources/CCPets/Integrations/CCPetsProfiles.h +2 -1
- package/Sources/CCPets/Integrations/CCPetsProfiles.m +112 -81
- package/Sources/CCPets/Integrations/CCPetsTerminalFocus.h +5 -1
- package/Sources/CCPets/Integrations/CCPetsTerminalFocus.m +163 -40
- package/Sources/CCPets/Pet/CCPetsPreviews.m +16 -8
- package/Sources/CCPets/Pet/PetView+Menu.m +56 -5
- package/Sources/CCPets/Support/CCPetsDoctor.m +126 -37
- package/Sources/CCPets/Support/CCPetsPaths.h +5 -0
- package/Sources/CCPets/Support/CCPetsPaths.m +15 -0
- package/Sources/CCPets/Support/CCPetsPreferences.h +4 -1
- package/Sources/CCPets/Support/CCPetsPreferences.m +18 -0
- package/Sources/CCPets/UI/CCPetsMenuBarPanel.m +10 -5
- package/Sources/CCPets/UI/CCPetsMenuBarSummary.m +9 -6
- package/Sources/CCPets/UI/CCPetsSettingsPage.h +3 -0
- package/Sources/CCPets/UI/CCPetsSettingsPage.m +189 -8
- package/Sources/CCPets/UI/CCPetsUIStyle.m +3 -1
- package/Sources/CCPets/UI/CCPetsUsagePage.h +4 -3
- package/Sources/CCPets/UI/CCPetsUsagePage.m +69 -43
- package/Sources/CCPets/UI/CCPetsUsageStore.m +11 -1
- package/Sources/CCPets/UI/CCPetsWorkbenchPages.m +1 -1
- package/Sources/CCPets/Usage/CCPetsAntigravityQuota.m +115 -0
- package/Sources/CCPets/Usage/CCPetsNormalizedUsage.h +5 -0
- package/Sources/CCPets/Usage/CCPetsNormalizedUsage.m +43 -0
- package/Sources/CCPets/Usage/CCPetsProviderRegistry+Testing.h +13 -0
- package/Sources/CCPets/Usage/CCPetsProviderRegistry.h +25 -0
- package/Sources/CCPets/Usage/CCPetsProviderRegistry.m +94 -0
- package/Sources/CCPets/Usage/CCPetsQuotaHistory.h +1 -1
- package/Sources/CCPets/Usage/CCPetsQuotaHistory.m +11 -8
- package/Sources/CCPets/Usage/CCPetsUsage+Internal.h +2 -0
- package/Sources/CCPets/Usage/CCPetsUsage+Models.m +206 -14
- package/Sources/CCPets/Usage/CCPetsUsage+TokenTotals.m +4 -4
- package/Sources/CCPets/Usage/CCPetsUsage.h +7 -2
- package/Sources/CCPets/Usage/CCPetsUsageMode.h +2 -0
- package/Sources/CCPets/Usage/CCPetsUsageMode.m +29 -4
- package/Sources/CCPets/Usage/CCPetsUsageMonitor.h +4 -4
- package/Sources/CCPets/Usage/CCPetsUsageMonitor.m +90 -7
- package/Sources/CCPets/Usage/QuotaDashboardView+CompactRow.m +81 -0
- package/Sources/CCPets/Usage/QuotaDashboardView+Primitives.m +5 -8
- package/Sources/CCPets/Usage/QuotaDashboardView+Private.h +26 -4
- package/Sources/CCPets/Usage/QuotaDashboardView+Rendering.m +99 -99
- package/Sources/CCPets/Usage/QuotaDashboardView.h +9 -10
- package/Sources/CCPets/Usage/QuotaDashboardView.m +232 -79
- package/THIRD_PARTY_NOTICES.md +5 -4
- package/THIRD_PARTY_NOTICES.zh-CN.md +6 -5
- package/bin/agy-with-pet +82 -0
- package/bin/cc-pets +1 -1
- package/bin/claude-with-pet +15 -0
- package/bin/codex-with-pet +17 -2
- package/package.json +5 -3
- package/scripts/install-shell-integration.sh +5 -0
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
#import "QuotaDashboardView+Private.h"
|
|
2
|
+
#import "CCPetsPreferences.h"
|
|
3
|
+
#import "CCPetsProfiles.h"
|
|
4
|
+
|
|
5
|
+
static NSString *const SummaryCarousel = @"summary";
|
|
2
6
|
|
|
3
7
|
const CGFloat QuotaLogicalWidth = 760;
|
|
4
8
|
const CGFloat QuotaLogicalHeight = 590;
|
|
@@ -76,6 +80,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
76
80
|
if (resourcePath.length > 0) [paths addObject:resourcePath];
|
|
77
81
|
}
|
|
78
82
|
NSString *applicationName = [bundleIdentifier containsString:@"anthropic"] ? @"Claude.app" : @"ChatGPT.app";
|
|
83
|
+
if ([bundleIdentifier isEqualToString:@"com.google.antigravity"]) applicationName = @"Antigravity.app";
|
|
79
84
|
[paths addObject:[@"/Applications" stringByAppendingPathComponent:
|
|
80
85
|
[applicationName stringByAppendingPathComponent:[@"Contents/Resources" stringByAppendingPathComponent:resourceName]]]];
|
|
81
86
|
[paths addObject:[[NSHomeDirectory() stringByAppendingPathComponent:@"Applications"] stringByAppendingPathComponent:
|
|
@@ -89,8 +94,11 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
89
94
|
if (image) return NormalizedAgentIcon(image);
|
|
90
95
|
}
|
|
91
96
|
// 没装官方桌面端(例如只装 CLI)时,从发布包读取备用图标。
|
|
92
|
-
NSString *fallback =
|
|
93
|
-
|
|
97
|
+
NSString *fallback = @{
|
|
98
|
+
@"com.anthropic.claudefordesktop": @"claude.png",
|
|
99
|
+
@"com.openai.codex": @"codex.icns",
|
|
100
|
+
@"com.google.antigravity": @"antigravity.icns"
|
|
101
|
+
}[bundleIdentifier];
|
|
94
102
|
if (!fallback) return nil;
|
|
95
103
|
NSArray<NSString *> *directories = @[
|
|
96
104
|
NSBundle.mainBundle.resourcePath ?: @"",
|
|
@@ -114,7 +122,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
114
122
|
self.accessibilityElement = YES;
|
|
115
123
|
self.accessibilityRole = NSAccessibilityGroupRole;
|
|
116
124
|
self.accessibilityLabel = L(@"Agent usage account cards");
|
|
117
|
-
self.accessibilityHelp = L(@"
|
|
125
|
+
self.accessibilityHelp = L(@"Use the arrows, page dots, or horizontal swipes to switch usage pages or accounts. Use the button below the cards to show more or fewer.");
|
|
118
126
|
NSTrackingArea *tracking = [[NSTrackingArea alloc] initWithRect:NSZeroRect
|
|
119
127
|
options:NSTrackingMouseEnteredAndExited |
|
|
120
128
|
NSTrackingActiveAlways | NSTrackingInVisibleRect
|
|
@@ -131,23 +139,76 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
131
139
|
- (void)mouseExited:(NSEvent *)event {
|
|
132
140
|
if (self.hoverChanged) self.hoverChanged(NO);
|
|
133
141
|
}
|
|
134
|
-
//
|
|
135
|
-
// 拿不到时宁可多画一张卡,也不要让有额度的用户看不到自己的卡片。
|
|
142
|
+
// 探测还未完成时保留旧版 Codex / Claude 布局。已有账号或用量的 Antigravity 也可以显示。
|
|
136
143
|
- (NSArray<NSString *> *)visibleProviders {
|
|
137
|
-
NSArray<NSString *> *order = @[@"Codex", @"Claude"];
|
|
138
|
-
if (!self.detectedProviders) return order;
|
|
139
144
|
NSMutableArray<NSString *> *visible = [NSMutableArray array];
|
|
140
|
-
for (
|
|
141
|
-
|
|
145
|
+
for (CCPetsProviderDescriptor *provider in CCPetsProviderDescriptors()) {
|
|
146
|
+
BOOL detected = [self.detectedProviders containsObject:provider.name];
|
|
147
|
+
if (!self.detectedProviders) {
|
|
148
|
+
detected = ![provider.profileProvider isEqualToString:CCPetsProfileProviderAntigravity] ||
|
|
149
|
+
[self profilesForProvider:provider.name].count > 0 || self.usageByProvider[provider.name].count > 0;
|
|
150
|
+
}
|
|
151
|
+
if (detected) {
|
|
152
|
+
[visible addObject:provider.name];
|
|
153
|
+
}
|
|
142
154
|
}
|
|
143
155
|
return visible;
|
|
144
156
|
}
|
|
157
|
+
- (NSArray<NSString *> *)orderedCardProviders {
|
|
158
|
+
NSArray<NSString *> *available = [self visibleProviders];
|
|
159
|
+
if (self.animatingCardOrder && [[NSSet setWithArray:self.animatingCardOrder] isEqualToSet:[NSSet setWithArray:available]]) {
|
|
160
|
+
return self.animatingCardOrder;
|
|
161
|
+
}
|
|
162
|
+
NSArray<NSString *> *manual = CCPetsQuotaCardOrder();
|
|
163
|
+
NSMutableDictionary<NSString *, NSNumber *> *weeklyUsed = [NSMutableDictionary dictionary];
|
|
164
|
+
NSTimeInterval now = NSDate.date.timeIntervalSince1970;
|
|
165
|
+
for (NSString *name in available) {
|
|
166
|
+
CCPetsProviderDescriptor *descriptor = CCPetsProviderForName(name);
|
|
167
|
+
NSDictionary *week = [self quota:[self usageForProvider:name] key:@"week"];
|
|
168
|
+
NSNumber *used = [week[descriptor.usedKey] isKindOfClass:NSNumber.class] ? week[descriptor.usedKey] : nil;
|
|
169
|
+
NSNumber *reset = [week[@"resets_at"] isKindOfClass:NSNumber.class] ? week[@"resets_at"] : nil;
|
|
170
|
+
if (used && isfinite(used.doubleValue) && (!reset || reset.doubleValue > now)) weeklyUsed[name] = used;
|
|
171
|
+
}
|
|
172
|
+
return [available sortedArrayWithOptions:NSSortStable usingComparator:^NSComparisonResult(NSString *left, NSString *right) {
|
|
173
|
+
NSUInteger leftIndex = [manual indexOfObject:CCPetsProviderForName(left).key];
|
|
174
|
+
NSUInteger rightIndex = [manual indexOfObject:CCPetsProviderForName(right).key];
|
|
175
|
+
if (leftIndex != rightIndex) return leftIndex < rightIndex ? NSOrderedAscending : NSOrderedDescending;
|
|
176
|
+
NSNumber *leftUsed = weeklyUsed[left], *rightUsed = weeklyUsed[right];
|
|
177
|
+
if (leftUsed && rightUsed) return [rightUsed compare:leftUsed];
|
|
178
|
+
if (leftUsed == rightUsed) return NSOrderedSame;
|
|
179
|
+
return leftUsed ? NSOrderedAscending : NSOrderedDescending;
|
|
180
|
+
}];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
- (NSArray<NSString *> *)orderedQuotaProviderKeys {
|
|
184
|
+
NSMutableArray<NSString *> *keys = [NSMutableArray array];
|
|
185
|
+
for (NSString *name in [self orderedCardProviders]) [keys addObject:CCPetsProviderForName(name).key];
|
|
186
|
+
return keys;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
- (NSArray<NSString *> *)displayedCardProviders {
|
|
190
|
+
NSArray<NSString *> *providers = [self orderedCardProviders];
|
|
191
|
+
if (!self.quotaCardsExpanded && providers.count > QuotaCollapsedCardCount) {
|
|
192
|
+
return [providers subarrayWithRange:NSMakeRange(0, QuotaCollapsedCardCount)];
|
|
193
|
+
}
|
|
194
|
+
return providers;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
- (BOOL)areQuotaCardsExpanded { return self.quotaCardsExpanded; }
|
|
198
|
+
|
|
145
199
|
- (CGFloat)logicalHeight {
|
|
146
|
-
|
|
200
|
+
NSUInteger available = [self visibleProviders].count;
|
|
201
|
+
NSUInteger shown = self.quotaCardsExpanded ? available : MIN(available, QuotaCollapsedCardCount);
|
|
202
|
+
return QuotaLogicalHeightForProviderCount(shown);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
- (void)refreshQuotaCardLayout {
|
|
206
|
+
[self updateTrackingAreas];
|
|
207
|
+
self.needsDisplay = YES;
|
|
147
208
|
}
|
|
148
209
|
|
|
149
210
|
- (NSString *)profileProviderForName:(NSString *)name {
|
|
150
|
-
return name.
|
|
211
|
+
return CCPetsProviderForName(name).profileProvider;
|
|
151
212
|
}
|
|
152
213
|
|
|
153
214
|
- (NSArray<NSDictionary *> *)profilesForProvider:(NSString *)name {
|
|
@@ -185,7 +246,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
185
246
|
- (NSDictionary *)usageForProvider:(NSString *)name {
|
|
186
247
|
NSDictionary *profile = [self selectedProfileForProvider:name];
|
|
187
248
|
if (profile) return self.profileUsages[profile[@"id"]] ?: @{};
|
|
188
|
-
return [name
|
|
249
|
+
return self.usageByProvider[name] ?: @{};
|
|
189
250
|
}
|
|
190
251
|
|
|
191
252
|
- (NSDictionary *)summedTokenBucket:(NSArray<NSDictionary *> *)buckets {
|
|
@@ -219,6 +280,17 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
219
280
|
}};
|
|
220
281
|
}
|
|
221
282
|
|
|
283
|
+
- (NSDictionary *)summaryUsageForAntigravityApp {
|
|
284
|
+
NSArray<NSDictionary *> *profiles = [self profilesForProvider:@"Antigravity"];
|
|
285
|
+
// App 的本机记录仅归属默认 Gemini Home,没有第二份账号额度或自定义 CLI Home 的份额。
|
|
286
|
+
for (NSDictionary *profile in profiles) {
|
|
287
|
+
NSDictionary *tokens = [self quota:self.profileUsages[profile[@"id"]] key:@"appTokenUsage"];
|
|
288
|
+
if (tokens) return @{@"tokenUsage": tokens};
|
|
289
|
+
}
|
|
290
|
+
NSDictionary *tokens = [self quota:self.usageByProvider[@"Antigravity"] key:@"appTokenUsage"];
|
|
291
|
+
return tokens ? @{@"tokenUsage": tokens} : @{};
|
|
292
|
+
}
|
|
293
|
+
|
|
222
294
|
- (NSString *)displayNameForProvider:(NSString *)name {
|
|
223
295
|
NSDictionary *profile = [self selectedProfileForProvider:name];
|
|
224
296
|
NSString *displayName = [profile[@"displayName"] isKindOfClass:NSString.class]
|
|
@@ -241,7 +313,15 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
241
313
|
NSInteger index = (NSInteger)[self selectedIndexForProvider:name];
|
|
242
314
|
NSInteger count = (NSInteger)profiles.count;
|
|
243
315
|
NSInteger next = (index + (direction > 0 ? 1 : -1) + count) % count;
|
|
244
|
-
|
|
316
|
+
[self selectProfileIndex:(NSUInteger)next forProvider:name direction:direction];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
- (void)selectProfileIndex:(NSUInteger)index forProvider:(NSString *)name direction:(NSInteger)direction {
|
|
320
|
+
NSArray<NSDictionary *> *profiles = [self profilesForProvider:name];
|
|
321
|
+
if (index >= profiles.count || index == [self selectedIndexForProvider:name]) return;
|
|
322
|
+
NSString *profileID = profiles[index][@"id"];
|
|
323
|
+
// Keep the card in place through the account animation. Reapply quota order when it completes.
|
|
324
|
+
self.animatingCardOrder = [self orderedCardProviders];
|
|
245
325
|
self.animatingCarouselProvider = name;
|
|
246
326
|
self.carouselAnimationDirection = direction > 0 ? 1 : -1;
|
|
247
327
|
self.carouselAnimationStartedAt = NSDate.date.timeIntervalSince1970;
|
|
@@ -258,6 +338,8 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
258
338
|
self.needsDisplay = YES;
|
|
259
339
|
if (NSDate.date.timeIntervalSince1970 - self.carouselAnimationStartedAt >= 0.20) {
|
|
260
340
|
self.animatingCarouselProvider = nil;
|
|
341
|
+
self.animatingCardOrder = nil;
|
|
342
|
+
[self refreshQuotaCardLayout];
|
|
261
343
|
return;
|
|
262
344
|
}
|
|
263
345
|
[NSObject cancelPreviousPerformRequestsWithTarget:self
|
|
@@ -267,7 +349,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
267
349
|
|
|
268
350
|
- (NSRect)logicalCardRectForProvider:(NSString *)target {
|
|
269
351
|
CGFloat cardTop = [self logicalHeight] - QuotaHeaderHeight - QuotaSummaryHeight;
|
|
270
|
-
NSArray<NSString *> *providers = [self
|
|
352
|
+
NSArray<NSString *> *providers = [self displayedCardProviders];
|
|
271
353
|
CGFloat cardHeight = QuotaCardHeightForProviderCount(providers.count);
|
|
272
354
|
for (NSString *name in providers) {
|
|
273
355
|
cardTop -= QuotaBlockGap;
|
|
@@ -288,7 +370,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
288
370
|
- (void)updateTrackingAreas {
|
|
289
371
|
[super updateTrackingAreas];
|
|
290
372
|
[self removeAllToolTips];
|
|
291
|
-
for (NSString *provider in [self
|
|
373
|
+
for (NSString *provider in [self displayedCardProviders]) {
|
|
292
374
|
NSRect rect = [self logicalTrendRectForProvider:provider];
|
|
293
375
|
rect.origin.x *= QuotaScale;
|
|
294
376
|
rect.origin.y *= QuotaScale;
|
|
@@ -303,14 +385,13 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
303
385
|
// 在显示时读取当前账号,轮播或刷新数据后不会留下上一账号的统计。
|
|
304
386
|
if (self.animatingCarouselProvider.length > 0) return nil;
|
|
305
387
|
NSPoint logicalPoint = NSMakePoint(point.x / QuotaScale, point.y / QuotaScale);
|
|
306
|
-
for (NSString *provider in [self
|
|
388
|
+
for (NSString *provider in [self displayedCardProviders]) {
|
|
307
389
|
if (!NSPointInRect(logicalPoint, [self logicalTrendRectForProvider:provider])) continue;
|
|
308
390
|
NSDictionary *usage = [self usageForProvider:provider];
|
|
309
|
-
NSDictionary *
|
|
391
|
+
NSDictionary *normalized = [self normalizedUsageForProvider:provider
|
|
310
392
|
profile:[self selectedProfileForProvider:provider] usage:usage];
|
|
311
|
-
if (
|
|
312
|
-
NSDictionary *tokenUsage = [
|
|
313
|
-
? usage[@"tokenUsage"] : nil;
|
|
393
|
+
if ([normalized[@"billing"] isEqualToString:@"subscription"]) return nil;
|
|
394
|
+
NSDictionary *tokenUsage = normalized[@"tokens"];
|
|
314
395
|
NSArray<NSDictionary *> *days = [tokenUsage[@"monthDaily"] isKindOfClass:NSArray.class]
|
|
315
396
|
? tokenUsage[@"monthDaily"] : @[];
|
|
316
397
|
NSTimeInterval now = NSDate.date.timeIntervalSince1970;
|
|
@@ -332,23 +413,42 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
332
413
|
return nil;
|
|
333
414
|
}
|
|
334
415
|
|
|
335
|
-
- (
|
|
336
|
-
logicalPoint:(NSPoint *)outPoint {
|
|
416
|
+
- (NSPoint)logicalPointForEvent:(NSEvent *)event {
|
|
337
417
|
NSPoint point = [self convertPoint:event.locationInWindow fromView:nil];
|
|
338
|
-
point.x
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
418
|
+
return NSMakePoint(point.x / QuotaScale, point.y / QuotaScale);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
- (NSString *)carouselAtPoint:(NSPoint)point {
|
|
422
|
+
if ([self summaryPageCount] > 1) {
|
|
423
|
+
NSRect summary = [self logicalSummaryRect];
|
|
424
|
+
summary.origin.x = 0;
|
|
425
|
+
summary.size.width = QuotaLogicalWidth;
|
|
426
|
+
if (NSPointInRect(point, summary)) return SummaryCarousel;
|
|
427
|
+
}
|
|
428
|
+
for (NSString *name in [self displayedCardProviders]) {
|
|
342
429
|
NSRect hit = [self logicalCardRectForProvider:name];
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
hit.size.width = QuotaLogicalWidth;
|
|
346
|
-
}
|
|
430
|
+
hit.origin.x = 0;
|
|
431
|
+
hit.size.width = QuotaLogicalWidth;
|
|
347
432
|
if (NSPointInRect(point, hit)) return name;
|
|
348
433
|
}
|
|
349
434
|
return nil;
|
|
350
435
|
}
|
|
351
436
|
|
|
437
|
+
- (NSUInteger)pageCountForCarousel:(NSString *)target {
|
|
438
|
+
return [target isEqualToString:SummaryCarousel] ? [self summaryPageCount] : [self profilesForProvider:target].count;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
- (void)moveCarousel:(NSString *)target direction:(NSInteger)direction {
|
|
442
|
+
if (![target isEqualToString:SummaryCarousel]) {
|
|
443
|
+
[self moveProfileForProvider:target direction:direction];
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
NSInteger count = (NSInteger)[self summaryPageCount];
|
|
447
|
+
if (count < 2 || direction == 0) return;
|
|
448
|
+
self.selectedSummaryPage = (NSUInteger)(((NSInteger)[self summaryPageIndex] + (direction > 0 ? 1 : -1) + count) % count);
|
|
449
|
+
self.needsDisplay = YES;
|
|
450
|
+
}
|
|
451
|
+
|
|
352
452
|
- (NSRect)previousArrowHitRectForCard:(NSRect)card {
|
|
353
453
|
return NSMakeRect(0, NSMidY(card) - 34, NSMinX(card) + 32, 68);
|
|
354
454
|
}
|
|
@@ -373,41 +473,50 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
373
473
|
|
|
374
474
|
NSInteger oldIndex = (NSInteger)[self selectedIndexForProvider:provider];
|
|
375
475
|
if (index == oldIndex) return YES;
|
|
376
|
-
|
|
377
|
-
self.animatingCarouselProvider = provider;
|
|
378
|
-
self.carouselAnimationDirection = index > oldIndex ? 1 : -1;
|
|
379
|
-
self.carouselAnimationStartedAt = NSDate.date.timeIntervalSince1970;
|
|
380
|
-
self.selectedProfileIDs[provider] = profileID;
|
|
381
|
-
[NSUserDefaults.standardUserDefaults setObject:profileID
|
|
382
|
-
forKey:[self selectionDefaultsKeyForProvider:provider]];
|
|
383
|
-
self.activeCarouselProvider = provider;
|
|
384
|
-
self.needsDisplay = YES;
|
|
385
|
-
[self advanceCarouselAnimation];
|
|
476
|
+
[self selectProfileIndex:(NSUInteger)index forProvider:provider direction:index > oldIndex ? 1 : -1];
|
|
386
477
|
return YES;
|
|
387
478
|
}
|
|
388
479
|
|
|
389
480
|
- (void)mouseDown:(NSEvent *)event {
|
|
390
|
-
NSPoint point;
|
|
391
|
-
|
|
392
|
-
|
|
481
|
+
NSPoint point = [self logicalPointForEvent:event];
|
|
482
|
+
if (NSPointInRect(point, [self logicalCardsDisclosureRect])) {
|
|
483
|
+
self.quotaCardsExpanded = !self.quotaCardsExpanded;
|
|
484
|
+
if (self.layoutChanged) self.layoutChanged();
|
|
485
|
+
else [self refreshQuotaCardLayout];
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
NSString *target = [self carouselAtPoint:point];
|
|
489
|
+
if (!target || [self pageCountForCarousel:target] < 2) {
|
|
393
490
|
[super mouseDown:event];
|
|
394
491
|
return;
|
|
395
492
|
}
|
|
396
493
|
[self.window makeFirstResponder:self];
|
|
397
|
-
self.activeCarouselProvider =
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
494
|
+
self.activeCarouselProvider = target;
|
|
495
|
+
BOOL summary = [target isEqualToString:SummaryCarousel];
|
|
496
|
+
NSRect card = summary ? NSZeroRect : [self logicalCardRectForProvider:target];
|
|
497
|
+
NSRect previous = summary ? NSInsetRect([self logicalSummaryPageArrowRectForDirection:-1], -8, 0)
|
|
498
|
+
: [self previousArrowHitRectForCard:card];
|
|
499
|
+
NSRect next = summary ? NSInsetRect([self logicalSummaryPageArrowRectForDirection:1], -8, 0)
|
|
500
|
+
: [self nextArrowHitRectForCard:card];
|
|
501
|
+
if (NSPointInRect(point, previous)) {
|
|
502
|
+
[self moveCarousel:target direction:-1];
|
|
401
503
|
return;
|
|
402
504
|
}
|
|
403
|
-
if (NSPointInRect(point,
|
|
404
|
-
[self
|
|
505
|
+
if (NSPointInRect(point, next)) {
|
|
506
|
+
[self moveCarousel:target direction:1];
|
|
405
507
|
return;
|
|
406
508
|
}
|
|
407
|
-
if (
|
|
509
|
+
if (summary) {
|
|
510
|
+
for (NSUInteger index = 0; index < [self summaryPageCount]; index++) {
|
|
511
|
+
if (!NSPointInRect(point, NSInsetRect([self logicalSummaryPageDotRectAtIndex:index], -4, -3))) continue;
|
|
512
|
+
self.selectedSummaryPage = index;
|
|
513
|
+
self.needsDisplay = YES;
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
} else if ([self selectProfileDotAtPoint:point provider:target card:card]) return;
|
|
408
517
|
|
|
409
518
|
// 卡片其余区域允许按住左右拖动;超过阈值后每次拖动只切换一次。
|
|
410
|
-
self.dragCarouselProvider =
|
|
519
|
+
self.dragCarouselProvider = target;
|
|
411
520
|
self.dragCarouselStartPoint = point;
|
|
412
521
|
self.dragCarouselDidSwitch = NO;
|
|
413
522
|
}
|
|
@@ -418,12 +527,11 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
418
527
|
return;
|
|
419
528
|
}
|
|
420
529
|
if (self.dragCarouselDidSwitch) return;
|
|
421
|
-
NSPoint point;
|
|
422
|
-
[self providerAtEvent:event includeArrowGutters:YES logicalPoint:&point];
|
|
530
|
+
NSPoint point = [self logicalPointForEvent:event];
|
|
423
531
|
CGFloat deltaX = point.x - self.dragCarouselStartPoint.x;
|
|
424
532
|
if (fabs(deltaX) < 36) return;
|
|
425
533
|
self.dragCarouselDidSwitch = YES;
|
|
426
|
-
[self
|
|
534
|
+
[self moveCarousel:self.dragCarouselProvider direction:deltaX < 0 ? 1 : -1];
|
|
427
535
|
}
|
|
428
536
|
|
|
429
537
|
- (void)mouseUp:(NSEvent *)event {
|
|
@@ -432,10 +540,10 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
432
540
|
}
|
|
433
541
|
|
|
434
542
|
- (void)scrollWheel:(NSEvent *)event {
|
|
435
|
-
NSString *provider = [self
|
|
543
|
+
NSString *provider = [self carouselAtPoint:[self logicalPointForEvent:event]];
|
|
436
544
|
CGFloat delta = fabs(event.scrollingDeltaX) >= fabs(event.scrollingDeltaY)
|
|
437
545
|
? event.scrollingDeltaX : (event.modifierFlags & NSEventModifierFlagShift ? event.scrollingDeltaY : 0);
|
|
438
|
-
if (provider && delta != 0 && [self
|
|
546
|
+
if (provider && delta != 0 && [self pageCountForCarousel:provider] > 1) {
|
|
439
547
|
// 惯性阶段不再继续翻页,避免一次触控板滑动跳过多个账号。
|
|
440
548
|
if (event.momentumPhase != NSEventPhaseNone) return;
|
|
441
549
|
BOOL phasedGesture = event.phase != NSEventPhaseNone;
|
|
@@ -450,7 +558,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
450
558
|
CGFloat threshold = event.hasPreciseScrollingDeltas ? 12 : 1;
|
|
451
559
|
if (!self.scrollCarouselDidSwitch && fabs(self.scrollCarouselAccumulator) >= threshold) {
|
|
452
560
|
self.scrollCarouselDidSwitch = YES;
|
|
453
|
-
[self
|
|
561
|
+
[self moveCarousel:provider
|
|
454
562
|
direction:self.scrollCarouselAccumulator > 0 ? 1 : -1];
|
|
455
563
|
}
|
|
456
564
|
if ((event.phase & (NSEventPhaseEnded | NSEventPhaseCancelled)) != 0) {
|
|
@@ -465,19 +573,56 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
465
573
|
NSTimeInterval now = NSDate.date.timeIntervalSince1970;
|
|
466
574
|
if (now - self.lastCarouselSwitchAt < 0.22) return;
|
|
467
575
|
self.lastCarouselSwitchAt = now;
|
|
468
|
-
[self
|
|
576
|
+
[self moveCarousel:provider direction:delta > 0 ? 1 : -1];
|
|
469
577
|
return;
|
|
470
578
|
}
|
|
471
579
|
[super scrollWheel:event];
|
|
472
580
|
}
|
|
473
581
|
|
|
474
582
|
- (void)keyDown:(NSEvent *)event {
|
|
475
|
-
|
|
476
|
-
|
|
583
|
+
NSString *target = self.activeCarouselProvider;
|
|
584
|
+
if (target.length > 0 && (event.keyCode == 123 || event.keyCode == 124) &&
|
|
585
|
+
([target isEqualToString:SummaryCarousel] || [[self displayedCardProviders] containsObject:target]) &&
|
|
586
|
+
[self pageCountForCarousel:target] > 1) {
|
|
587
|
+
[self moveCarousel:target direction:event.keyCode == 123 ? -1 : 1];
|
|
477
588
|
return;
|
|
478
589
|
}
|
|
479
590
|
[super keyDown:event];
|
|
480
591
|
}
|
|
592
|
+
- (NSUInteger)summaryPageCount {
|
|
593
|
+
NSArray<NSString *> *providers = [self visibleProviders];
|
|
594
|
+
NSUInteger rowCount = providers.count + ([providers containsObject:@"Antigravity"] ? 1 : 0);
|
|
595
|
+
return (rowCount + QuotaSummaryRowsPerPage - 1) / QuotaSummaryRowsPerPage;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
- (NSUInteger)summaryPageIndex {
|
|
599
|
+
NSUInteger count = [self summaryPageCount];
|
|
600
|
+
return count > 0 ? MIN(self.selectedSummaryPage, count - 1) : 0;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
- (NSRect)logicalSummaryPageArrowRectForDirection:(NSInteger)direction {
|
|
604
|
+
if ([self summaryPageCount] < 2) return NSZeroRect;
|
|
605
|
+
NSRect summary = [self logicalSummaryRect];
|
|
606
|
+
CGFloat x = direction < 0 ? 0 : NSMaxX(summary);
|
|
607
|
+
return NSMakeRect(x, NSMidY(summary) - 25, NSMinX(summary), 50);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
- (NSRect)logicalSummaryPageDotRectAtIndex:(NSUInteger)index {
|
|
611
|
+
NSUInteger count = [self summaryPageCount];
|
|
612
|
+
if (count < 2 || index >= count) return NSZeroRect;
|
|
613
|
+
NSRect summary = [self logicalSummaryRect];
|
|
614
|
+
CGFloat width = (count - 1) * QuotaCarouselDotGap + QuotaCarouselDotDiameter;
|
|
615
|
+
CGFloat x = NSMidX(summary) - width / 2 + index * QuotaCarouselDotGap;
|
|
616
|
+
return NSMakeRect(x, NSMinY(summary) + 3, QuotaCarouselDotDiameter, QuotaCarouselDotDiameter);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
- (NSRect)logicalCardsDisclosureRect {
|
|
620
|
+
if ([self visibleProviders].count <= QuotaCollapsedCardCount) return NSZeroRect;
|
|
621
|
+
NSRect card = [self logicalCardRectForProvider:[self displayedCardProviders].lastObject];
|
|
622
|
+
CGFloat width = 128;
|
|
623
|
+
return NSMakeRect(NSMidX(card) - width / 2, NSMinY(card) + 3, width, QuotaCardsDisclosureHeight);
|
|
624
|
+
}
|
|
625
|
+
|
|
481
626
|
- (NSRect)logicalSummaryRect {
|
|
482
627
|
return NSMakeRect(20, [self logicalHeight] - QuotaHeaderHeight - QuotaSummaryHeight,
|
|
483
628
|
QuotaLogicalWidth - 40, QuotaSummaryHeight + 1 / QuotaScale);
|
|
@@ -557,7 +702,8 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
557
702
|
// 再按同一规则(含今天在内的 7 个自然日)现场计算,避免界面暂时退回到没有起期。
|
|
558
703
|
- (NSString *)recentWeekUsageLabel {
|
|
559
704
|
NSNumber *start = nil;
|
|
560
|
-
for (
|
|
705
|
+
for (CCPetsProviderDescriptor *provider in CCPetsProviderDescriptors()) {
|
|
706
|
+
NSDictionary *usage = self.usageByProvider[provider.name];
|
|
561
707
|
NSDictionary *tokenUsage = [usage[@"tokenUsage"] isKindOfClass:NSDictionary.class]
|
|
562
708
|
? usage[@"tokenUsage"] : nil;
|
|
563
709
|
if ([tokenUsage[@"recentWeekStartsAt"] isKindOfClass:NSNumber.class]) {
|
|
@@ -605,27 +751,33 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
605
751
|
}
|
|
606
752
|
return [self.liveProviders containsObject:name] || self.hasUnlabeledClient;
|
|
607
753
|
}
|
|
608
|
-
- (NSDictionary *)
|
|
609
|
-
BOOL api = profile ? CCPetsProfileShowsAPIUsage(profile)
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
BOOL
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
[self tokenTotals:usage key:@"fiveHour"] || [self tokenTotals:usage key:@"week"] || exhausted);
|
|
754
|
+
- (NSDictionary *)normalizedUsageForProvider:(NSString *)name profile:(NSDictionary *)profile usage:(NSDictionary *)usage {
|
|
755
|
+
BOOL api = profile ? CCPetsProfileShowsAPIUsage(profile) : [self.showsAPIUsageByProvider[name] boolValue];
|
|
756
|
+
return CCPetsNormalizedUsage(CCPetsProviderForName(name), usage, api);
|
|
757
|
+
}
|
|
758
|
+
- (NSDictionary *)accountStateForProvider:(NSString *)name profile:(NSDictionary *)profile normalized:(NSDictionary *)normalized {
|
|
759
|
+
BOOL api = ![normalized[@"billing"] isEqualToString:@"subscription"];
|
|
760
|
+
BOOL exhausted = [normalized[@"exhausted"] boolValue];
|
|
761
|
+
BOOL hasData = [normalized[@"hasData"] boolValue];
|
|
617
762
|
BOOL online = [self isProfileOnline:profile provider:name];
|
|
618
763
|
NSString *state = !api && exhausted ? @"limited" : (!hasData ? @"waiting" : (online ? @"online" : @"offline"));
|
|
619
764
|
NSString *text = !api && exhausted ? L(@"Rate limited")
|
|
620
765
|
: (!hasData ? L(@"Waiting for data") : (online ? L(@"● Online") : L(@"Offline")));
|
|
621
766
|
return @{@"apiMode": @(api), @"online": @(online), @"hasData": @(hasData), @"state": state, @"status": text};
|
|
622
767
|
}
|
|
768
|
+
- (NSColor *)statusColorForState:(NSDictionary *)state {
|
|
769
|
+
if ([state[@"state"] isEqualToString:@"limited"]) return NSColor.systemOrangeColor;
|
|
770
|
+
if ([state[@"state"] isEqualToString:@"online"]) return NSColor.systemGreenColor;
|
|
771
|
+
return self.secondaryColor;
|
|
772
|
+
}
|
|
623
773
|
- (NSDictionary *)accountSnapshotForProvider:(NSString *)name profile:(NSDictionary *)profile {
|
|
624
774
|
NSString *profileID = profile[@"id"];
|
|
625
775
|
NSDictionary *usage = profile ? (self.profileUsages[profileID] ?: @{}) : [self usageForProvider:name];
|
|
626
776
|
NSArray *history = profile ? (self.profileHistories[profileID] ?: @[])
|
|
627
|
-
:
|
|
628
|
-
|
|
777
|
+
: self.historyByProvider[name];
|
|
778
|
+
NSDictionary *normalized = [self normalizedUsageForProvider:name profile:profile usage:usage];
|
|
779
|
+
NSMutableDictionary *snapshot = [[self accountStateForProvider:name profile:profile normalized:normalized] mutableCopy];
|
|
780
|
+
snapshot[@"normalized"] = normalized;
|
|
629
781
|
snapshot[@"provider"] = name;
|
|
630
782
|
snapshot[@"usage"] = usage ?: @{};
|
|
631
783
|
snapshot[@"history"] = history ?: @[];
|
|
@@ -636,8 +788,9 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
636
788
|
}
|
|
637
789
|
return snapshot;
|
|
638
790
|
}
|
|
639
|
-
- (NSDictionary *)
|
|
640
|
-
|
|
791
|
+
- (NSDictionary *)paceStatusForWindow:(NSDictionary *)window color:(NSColor *)providerColor {
|
|
792
|
+
NSDictionary *quota = window[@"quota"];
|
|
793
|
+
NSNumber *currentUsed = window[@"used"];
|
|
641
794
|
if (!currentUsed) {
|
|
642
795
|
return @{@"label": L(@"Not enough data"), @"tip": L(@"Waiting for data"),
|
|
643
796
|
@"color": self.secondaryColor};
|
|
@@ -645,19 +798,19 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
645
798
|
NSNumber *reset = [quota[@"resets_at"] isKindOfClass:NSNumber.class]
|
|
646
799
|
? quota[@"resets_at"] : nil;
|
|
647
800
|
NSTimeInterval now = NSDate.date.timeIntervalSince1970;
|
|
648
|
-
|
|
649
|
-
NSTimeInterval start = reset ? reset.doubleValue -
|
|
801
|
+
NSTimeInterval windowSeconds = [window[@"minutes"] doubleValue] * 60;
|
|
802
|
+
NSTimeInterval start = reset ? reset.doubleValue - windowSeconds : 0;
|
|
650
803
|
NSTimeInterval elapsed = now - start;
|
|
651
804
|
double projectedRemaining = NAN;
|
|
652
|
-
|
|
805
|
+
NSTimeInterval paceObservationSeconds = windowSeconds / 7.0;
|
|
653
806
|
// 满 24 小时就全额外推的话,放大倍数还有 7 倍:窗口第 25 小时,任何已用超过 14.3%
|
|
654
807
|
// 的用户都会被判成"重置前用尽"。更糟的是两家的窗口起点差几个小时,就会出现一家
|
|
655
808
|
// 已外推、另一家还没到门槛的断层——剩 80% 的报高风险,剩 61% 的却显示平稳。
|
|
656
809
|
// 因此在 24 小时到窗口 1/3(56 小时)之间按观测时长加权,从"按当前已用"平滑过渡
|
|
657
810
|
// 到"完全信任外推",门槛处不再有跳变。
|
|
658
|
-
const NSTimeInterval paceFullTrustSeconds =
|
|
811
|
+
const NSTimeInterval paceFullTrustSeconds = windowSeconds / 3.0;
|
|
659
812
|
if (reset && reset.doubleValue > now && elapsed >= paceObservationSeconds) {
|
|
660
|
-
double linearUsed = currentUsed.doubleValue *
|
|
813
|
+
double linearUsed = currentUsed.doubleValue * windowSeconds / elapsed;
|
|
661
814
|
double confidence = fmin(1.0, (elapsed - paceObservationSeconds) /
|
|
662
815
|
(paceFullTrustSeconds - paceObservationSeconds));
|
|
663
816
|
double projectedUsed = currentUsed.doubleValue +
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -7,14 +7,15 @@ The built-in `ByteMochi.webp` is an original default asset created for this proj
|
|
|
7
7
|
is unrelated to any existing anime, game, or commercial mascot and is distributed
|
|
8
8
|
with the project code under the MIT License.
|
|
9
9
|
|
|
10
|
-
At runtime, the app may read locally installed Codex/ChatGPT and
|
|
10
|
+
At runtime, the app may read locally installed Codex/ChatGPT, Claude, and Antigravity application
|
|
11
11
|
icons for interface identification. If unavailable, it uses bundled fallback assets
|
|
12
|
-
in `Resources/AgentIcons
|
|
13
|
-
|
|
12
|
+
in `Resources/AgentIcons`. The source of `claude.png` is https://claude.ai/apple-touch-icon.png.
|
|
13
|
+
The `codex.icns` and `antigravity.icns` assets come from the locally installed
|
|
14
|
+
ChatGPT.app resource `icon-chatgpt.icns` and Antigravity.app resource `icon.icns`, respectively.
|
|
14
15
|
These assets retain their respective owners' copyrights and trademarks; they are
|
|
15
16
|
not original CC Pets artwork and are not covered by this project's MIT License.
|
|
16
17
|
Attribution does not grant redistribution permission or imply endorsement by
|
|
17
|
-
Anthropic or
|
|
18
|
+
Anthropic, OpenAI, or Google. Distribution must comply with the rights holders' terms.
|
|
18
19
|
|
|
19
20
|
Assets installed by users from PetDex or other sources are managed by those users
|
|
20
21
|
and are not part of this project distribution. Follow the applicable author,
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
CC Pets 发布包不捆绑 PetDex 下载的角色素材。内置的 `ByteMochi.webp` 是专为本项目创建的
|
|
6
6
|
原创默认素材,与任何现有动漫、游戏或商业吉祥物无关,并与项目代码一同按 MIT License 分发。
|
|
7
7
|
|
|
8
|
-
程序会在运行时尝试读取用户本机已安装的 Codex/ChatGPT 和
|
|
9
|
-
读取失败时使用 `Resources/AgentIcons`
|
|
8
|
+
程序会在运行时尝试读取用户本机已安装的 Codex/ChatGPT、Claude 和 Antigravity 应用图标,用于界面识别。
|
|
9
|
+
读取失败时使用 `Resources/AgentIcons` 中随包分发的备用素材。`claude.png` 来自
|
|
10
10
|
https://claude.ai/apple-touch-icon.png,`codex.icns` 来自本机 ChatGPT.app 的
|
|
11
|
-
`icon-chatgpt.icns`
|
|
12
|
-
|
|
13
|
-
OpenAI
|
|
11
|
+
`icon-chatgpt.icns` 资源,`antigravity.icns` 来自本机 Antigravity.app 的 `icon.icns` 资源。
|
|
12
|
+
这些素材的商标和版权归各自权利人所有,不是 CC Pets 原创素材,
|
|
13
|
+
也不适用本项目的 MIT License。标注来源不代表获得再分发授权,也不代表 Anthropic、OpenAI 或
|
|
14
|
+
Google 为本项目背书。分发时仍须遵守权利人的使用条款。
|
|
14
15
|
|
|
15
16
|
用户通过 PetDex 或其他来源安装的素材由用户自行管理,不属于本项目发布内容。使用和再分发
|
|
16
17
|
此类素材时,请遵守对应作者、平台和权利人的许可证及使用条款。
|
package/bin/agy-with-pet
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/bin/zsh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="${0:A:h}"
|
|
5
|
+
PROJECT_DIR="${SCRIPT_DIR:h}"
|
|
6
|
+
source "${PROJECT_DIR}/scripts/i18n.zsh"
|
|
7
|
+
PET_BIN="${PROJECT_DIR}/.build/release/cc-pets"
|
|
8
|
+
BUILD_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
|
|
9
|
+
INSTALLED_APP="${CC_PETS_APPLICATIONS_DIR:-${HOME}/Applications}/CC Pets.app"
|
|
10
|
+
REAL_AGY="${AGY_REAL_BIN:-}"
|
|
11
|
+
SELF="${0:A}"
|
|
12
|
+
SHIM_DIR="${CC_PETS_SHIM_DIR:-${HOME}/.cc-pets/shims}"
|
|
13
|
+
|
|
14
|
+
if [[ -z "${REAL_AGY}" ]]; then
|
|
15
|
+
typeset -a candidates
|
|
16
|
+
candidates=(${(f)"$(whence -ap agy 2>/dev/null || true)"})
|
|
17
|
+
for candidate in "${candidates[@]}"; do
|
|
18
|
+
[[ -n "${candidate}" && -x "${candidate}" ]] || continue
|
|
19
|
+
[[ "${candidate:A}" == "${SELF}" || "${candidate:A:h}" == "${SHIM_DIR:A}" ]] && continue
|
|
20
|
+
REAL_AGY="${candidate}"
|
|
21
|
+
break
|
|
22
|
+
done
|
|
23
|
+
fi
|
|
24
|
+
if [[ -z "${REAL_AGY}" || ! -x "${REAL_AGY}" || "${REAL_AGY:A}" == "${SELF}" ]]; then
|
|
25
|
+
print -u2 "$(cc_pets_t "No executable Antigravity CLI found. Install agy, or set AGY_REAL_BIN to its real path.")"
|
|
26
|
+
exit 127
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
typeset -a agy_arguments=("$@")
|
|
30
|
+
AGY_PROFILE_HOME="${CC_PETS_ANTIGRAVITY_HOME:-${HOME}/.gemini}"
|
|
31
|
+
explicit_root=0
|
|
32
|
+
for (( index = 1; index <= ${#agy_arguments[@]}; index++ )); do
|
|
33
|
+
case "${agy_arguments[index]}" in
|
|
34
|
+
--gemini_dir)
|
|
35
|
+
explicit_root=1
|
|
36
|
+
(( index < ${#agy_arguments[@]} )) && AGY_PROFILE_HOME="${agy_arguments[index + 1]}"
|
|
37
|
+
break
|
|
38
|
+
;;
|
|
39
|
+
--gemini_dir=*)
|
|
40
|
+
explicit_root=1
|
|
41
|
+
AGY_PROFILE_HOME="${agy_arguments[index]#--gemini_dir=}"
|
|
42
|
+
break
|
|
43
|
+
;;
|
|
44
|
+
--) break ;;
|
|
45
|
+
esac
|
|
46
|
+
done
|
|
47
|
+
if [[ -n "${CC_PETS_ANTIGRAVITY_HOME:-}" ]] && (( !explicit_root )); then
|
|
48
|
+
agy_arguments=(--gemini_dir "${AGY_PROFILE_HOME:A}" "${agy_arguments[@]}")
|
|
49
|
+
fi
|
|
50
|
+
export CC_PETS_ANTIGRAVITY_HOME="${AGY_PROFILE_HOME}"
|
|
51
|
+
|
|
52
|
+
# Commands that use agy as a subprocess keep its normal stdin/stdout behavior.
|
|
53
|
+
if [[ ! -t 0 || ! -t 1 ]]; then
|
|
54
|
+
exec "${REAL_AGY}" "${agy_arguments[@]}"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
if [[ ! -x "${PET_BIN}" || ! -d "${BUILD_APP}" ]]; then
|
|
58
|
+
"${PROJECT_DIR}/scripts/build.sh" >/dev/null
|
|
59
|
+
fi
|
|
60
|
+
PET_APP="${BUILD_APP}"
|
|
61
|
+
"${PET_BIN}" --launch-preflight agy "${agy_arguments[@]}" || exit $?
|
|
62
|
+
[[ -d "${INSTALLED_APP}" ]] && PET_APP="${INSTALLED_APP}"
|
|
63
|
+
|
|
64
|
+
export CC_PETS_TERMINAL_TTY="${TTY:-}"
|
|
65
|
+
export CC_PETS_TERMINAL_PROGRAM="${TERM_PROGRAM:-}"
|
|
66
|
+
export CC_PETS_TERMINAL_SESSION="${TERM_SESSION_ID:-${ITERM_SESSION_ID:-}}"
|
|
67
|
+
export CC_PETS_TERMINAL_BUNDLE_ID="$("${PET_BIN}" --frontmost-bundle-id 2>/dev/null || true)"
|
|
68
|
+
unset CC_PETS_PROFILE_ID CC_PETS_PROFILE_NAME CC_PETS_PROFILE_HOME
|
|
69
|
+
CC_PETS_PROFILE_ID="$("${PET_BIN}" profile resolve --provider antigravity --home "${AGY_PROFILE_HOME}" 2>/dev/null || true)"
|
|
70
|
+
if [[ -n "${CC_PETS_PROFILE_ID}" ]]; then
|
|
71
|
+
export CC_PETS_PROFILE_ID
|
|
72
|
+
export CC_PETS_PROFILE_HOME="${AGY_PROFILE_HOME}"
|
|
73
|
+
CC_PETS_PROFILE_NAME="$("${PET_BIN}" profile resolve --provider antigravity --home "${AGY_PROFILE_HOME}" --field name 2>/dev/null || true)"
|
|
74
|
+
[[ -n "${CC_PETS_PROFILE_NAME}" ]] && export CC_PETS_PROFILE_NAME
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
"${PET_BIN}" --agy-launch >/dev/null 2>&1 || true
|
|
78
|
+
print -rn -- '{"schemaVersion":1,"provider":"Antigravity","state":"starting"}' | \
|
|
79
|
+
"${PET_BIN}" --provider-event >/dev/null 2>&1 || true
|
|
80
|
+
env -u CC_PETS_PROFILE_ID -u CC_PETS_PROFILE_NAME -u CC_PETS_PROFILE_HOME -u CC_PETS_ANTIGRAVITY_HOME \
|
|
81
|
+
open -g "${PET_APP}" --args --managed >/dev/null 2>&1 || true
|
|
82
|
+
exec "${REAL_AGY}" "${agy_arguments[@]}"
|