omniagent 0.1.9 → 0.1.12
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/dist/claude-Blr7YqBx.js +395 -0
- package/dist/cli.js +3 -3
- package/dist/{codex-D1RuzsY6.js → codex-0b2YLh_8.js} +256 -0
- package/dist/gemini-BVRg6OMO.js +437 -0
- package/package.json +1 -1
- package/dist/claude-Dmv_YFKX.js +0 -146
- package/dist/gemini-CskI3Qjp.js +0 -168
package/dist/gemini-CskI3Qjp.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { c as cleanControlOutput, m as makeUsageLimit, a as compactLines } from "./cli.js";
|
|
2
|
-
import { r as runPtyScenario, t as typeTextSteps, e as enterKey, a as escapeKey } from "./pty-CZBSAJzE.js";
|
|
3
|
-
const TIER_MODEL_IDS = /* @__PURE__ */ new Map([
|
|
4
|
-
["Flash", "flash"],
|
|
5
|
-
["Flash Lite", "flash-lite"],
|
|
6
|
-
["Pro", "pro"]
|
|
7
|
-
]);
|
|
8
|
-
async function extractGeminiUsage(context) {
|
|
9
|
-
const command = context.command ?? context.launch?.command ?? "gemini";
|
|
10
|
-
const ptyResult = await runPtyScenario({
|
|
11
|
-
command,
|
|
12
|
-
args: context.launch?.args ?? ["--skip-trust"],
|
|
13
|
-
cwd: context.repoRoot,
|
|
14
|
-
cols: 110,
|
|
15
|
-
rows: 42,
|
|
16
|
-
timeoutMs: context.launch?.timeoutMs ?? 7e4,
|
|
17
|
-
signal: context.signal,
|
|
18
|
-
debug: context.debug,
|
|
19
|
-
steps: [
|
|
20
|
-
{ waitFor: isGeminiPromptReady, waitForTimeoutMs: 12e3 },
|
|
21
|
-
...typeTextSteps("/model", 20),
|
|
22
|
-
{ waitMs: 150, write: enterKey() },
|
|
23
|
-
{
|
|
24
|
-
waitFor: hasGeminiModelUsage,
|
|
25
|
-
waitForTimeoutMs: 15e3,
|
|
26
|
-
capture: "model",
|
|
27
|
-
captureWaitMs: 500
|
|
28
|
-
},
|
|
29
|
-
{ write: escapeKey() },
|
|
30
|
-
{ waitMs: 500 },
|
|
31
|
-
...typeTextSteps("/quit", 20),
|
|
32
|
-
{ waitMs: 150, write: enterKey() },
|
|
33
|
-
{ waitMs: 500 }
|
|
34
|
-
]
|
|
35
|
-
});
|
|
36
|
-
const modelSnapshot = ptyResult.snapshots.model ?? ptyResult;
|
|
37
|
-
const cleanedOutput = cleanControlOutput(modelSnapshot.raw);
|
|
38
|
-
const parsed = parseGeminiModelDialog(modelSnapshot.screen, cleanedOutput);
|
|
39
|
-
if (parsed.usage.length === 0) {
|
|
40
|
-
throw new Error("Gemini usage output did not include model usage rows.");
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
targetId: context.targetId,
|
|
44
|
-
displayName: context.displayName,
|
|
45
|
-
command,
|
|
46
|
-
limits: parsed.usage.map((row) => {
|
|
47
|
-
const modelId = resolveModelId(row.name, parsed.availableModels);
|
|
48
|
-
return makeUsageLimit({
|
|
49
|
-
targetId: context.targetId,
|
|
50
|
-
scope: modelScope(modelId),
|
|
51
|
-
window: "model",
|
|
52
|
-
label: row.name,
|
|
53
|
-
modelId,
|
|
54
|
-
modelLabel: row.name,
|
|
55
|
-
percentUsed: row.percentUsed,
|
|
56
|
-
percentRemaining: 100 - row.percentUsed,
|
|
57
|
-
resetText: row.resetText,
|
|
58
|
-
raw: row.raw,
|
|
59
|
-
now: context.now
|
|
60
|
-
});
|
|
61
|
-
}),
|
|
62
|
-
debug: ptyResult.debug.length > 0 ? ptyResult.debug : void 0
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function isGeminiPromptReady(snapshot) {
|
|
66
|
-
const screen = snapshot.screen || cleanControlOutput(snapshot.raw);
|
|
67
|
-
return /Type your message|quota/i.test(screen);
|
|
68
|
-
}
|
|
69
|
-
function hasGeminiModelUsage(snapshot) {
|
|
70
|
-
const parsed = parseGeminiModelDialog(snapshot.screen, cleanControlOutput(snapshot.raw));
|
|
71
|
-
return parsed.usage.length > 0;
|
|
72
|
-
}
|
|
73
|
-
function parseGeminiModelDialog(screen, cleanedOutput = "") {
|
|
74
|
-
const fromScreen = parseGeminiLines(compactLines(screen));
|
|
75
|
-
if (fromScreen.usage.length > 0) {
|
|
76
|
-
return fromScreen;
|
|
77
|
-
}
|
|
78
|
-
return parseGeminiLines(compactLines(cleanedOutput));
|
|
79
|
-
}
|
|
80
|
-
function parseGeminiLines(lines) {
|
|
81
|
-
const availableModels = [];
|
|
82
|
-
const usage = [];
|
|
83
|
-
let selectedModel = "";
|
|
84
|
-
let inUsage = false;
|
|
85
|
-
for (const line of lines) {
|
|
86
|
-
const content = stripGeminiFrame(line);
|
|
87
|
-
if (!content) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
const model = parseAvailableModel(content);
|
|
91
|
-
if (model != null) {
|
|
92
|
-
availableModels.push(model.id);
|
|
93
|
-
if (model.selected) {
|
|
94
|
-
selectedModel = model.id;
|
|
95
|
-
}
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (content === "Model usage") {
|
|
99
|
-
inUsage = true;
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (!inUsage) {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
if (content.startsWith("(")) {
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
const row = parseUsageRow(content);
|
|
109
|
-
if (row != null) {
|
|
110
|
-
usage.push(row);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
selectedModel,
|
|
115
|
-
availableModels,
|
|
116
|
-
usage
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function parseAvailableModel(line) {
|
|
120
|
-
const match = /^(\u25cf)?\s*(\d+)\.\s+(\S+)$/u.exec(line);
|
|
121
|
-
if (match == null) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
selected: match[1] != null,
|
|
126
|
-
index: Number(match[2]),
|
|
127
|
-
id: match[3]
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function parseUsageRow(line) {
|
|
131
|
-
const match = /^(.*?)\s+(\d{1,3})%\s*(?:Resets:\s*(.*?))?$/u.exec(line);
|
|
132
|
-
if (match == null) {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
name: stripUsageBar(match[1]),
|
|
137
|
-
percentUsed: Number(match[2]),
|
|
138
|
-
resetText: (match[3] ?? "").trim(),
|
|
139
|
-
raw: line
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function stripUsageBar(value) {
|
|
143
|
-
return value.replace(/[\s#=\-_\u2500-\u257F\u2580-\u259F\u25AC]+$/giu, "").trim();
|
|
144
|
-
}
|
|
145
|
-
function resolveModelId(name, availableModels) {
|
|
146
|
-
const tierModelId = TIER_MODEL_IDS.get(name);
|
|
147
|
-
if (tierModelId != null) {
|
|
148
|
-
return tierModelId;
|
|
149
|
-
}
|
|
150
|
-
const truncatedPrefix = name.endsWith("...") ? name.slice(0, -3) : name.endsWith("…") ? name.slice(0, -1) : null;
|
|
151
|
-
if (truncatedPrefix) {
|
|
152
|
-
const match = availableModels.find((model) => model.startsWith(truncatedPrefix));
|
|
153
|
-
if (match != null) {
|
|
154
|
-
return match;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return name;
|
|
158
|
-
}
|
|
159
|
-
function modelScope(modelId) {
|
|
160
|
-
return modelId.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
161
|
-
}
|
|
162
|
-
function stripGeminiFrame(line) {
|
|
163
|
-
return line.replace(/^\s*\u2502\s?/u, "").replace(/\s*\u2502\s*$/u, "").trim();
|
|
164
|
-
}
|
|
165
|
-
export {
|
|
166
|
-
extractGeminiUsage,
|
|
167
|
-
parseGeminiModelDialog
|
|
168
|
-
};
|