@juanbenjumea/pi-agy 0.7.6 → 0.7.8
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/CHANGELOG.md +12 -0
- package/README.md +17 -13
- package/extensions/command-info.ts +113 -0
- package/extensions/command-run.ts +199 -0
- package/extensions/commands.ts +20 -317
- package/extensions/index.ts +5 -566
- package/extensions/lib/args.ts +20 -6
- package/extensions/lib/context.ts +12 -0
- package/extensions/lib/preflight.ts +42 -15
- package/extensions/lib/provider-mcp.ts +176 -38
- package/extensions/lib/provider-prompt.ts +260 -0
- package/extensions/lib/provider-tools.ts +82 -0
- package/extensions/lib/provider.ts +33 -345
- package/extensions/lib/skills.ts +161 -0
- package/extensions/lib/verify.ts +30 -1
- package/extensions/tools.ts +558 -0
- package/package.json +9 -5
- package/skills/agy/SKILL.md +11 -94
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.8
|
|
4
|
+
|
|
5
|
+
- Improve agy provider cache behavior: stabilize prompt prefixes, cap recent resume context, key preflight and verification caches by working directory, and bucket print timeouts for identical arguments.
|
|
6
|
+
- Simplify extension guidance and modules, route steerable work through Herdr, and refresh package positioning and keywords.
|
|
7
|
+
- Full test, typecheck, and package checks pass.
|
|
8
|
+
|
|
9
|
+
## 0.7.7
|
|
10
|
+
|
|
11
|
+
- Add dynamic Pi Skills injection (`activate_skill`) to the loopback MCP server, scanning global (`~/.pi/agent/skills`, `~/.agents/skills`) and project (`.pi/skills`, `.agents/skills`) locations, presenting an enum of skills with summaries and returning `SKILL.md` markdown to agy.
|
|
12
|
+
- Add long-running tool escalation and polling (`bridge_poll_result`): tools running longer than 20s escalate with an immediate early-ack response, preventing agy client timeouts (~180s) and allowing agy to poll until the tool settles.
|
|
13
|
+
- Full 299-test gate plus typecheck and package checks pass.
|
|
14
|
+
|
|
3
15
|
## 0.7.6
|
|
4
16
|
|
|
5
17
|
- Document background tasks and the Antigravity provider in the agent-facing skill guide (usage, lifecycle, and the narrowed background-servers rule), and ignore session-local `.pi/` todo state.
|
package/README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# @juanbenjumea/pi-agy
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Antigravity (agy) provider and delegation for Pi: `/model` picker integration,
|
|
4
|
+
persistent driver with loopback MCP tool bridge, background tasks, quota awareness,
|
|
5
|
+
repo verification, and trustworthy diff summaries.
|
|
5
6
|
|
|
6
|
-
Pi
|
|
7
|
-
|
|
8
|
-
from any Pi model; choose a provider integration when you want Antigravity to be
|
|
9
|
-
your primary model for every turn.
|
|
7
|
+
Pi can delegate scoped tasks to the Antigravity CLI (`agy`) or use Antigravity
|
|
8
|
+
as the primary `/model` provider for interactive chat with a full loopback MCP tool bridge.
|
|
10
9
|
|
|
11
10
|
Enhanced fork of [`@bacnh85/pi-agy`](https://github.com/bacnh85/pi-extensions/tree/main/pi-agy).
|
|
12
11
|
|
|
@@ -34,6 +33,8 @@ Requires Node.js >= 20.3.
|
|
|
34
33
|
| Concurrency | Unlocked | Per-directory lock (in-process + filesystem, symlink-aware), lock wait counts against the timeout |
|
|
35
34
|
| Transient failures | Fatal | One retry when agy fails before doing any work |
|
|
36
35
|
| Cancellation | Direct child only | Full process-tree kill on cancel/timeout via detached process groups; a fully delivered result is preserved |
|
|
36
|
+
| Primary-model picker | None | `antigravity/*` provider with live catalog, persistent driver, MCP tool bridge, and image staging (see below) |
|
|
37
|
+
| Background runs | Blocking only | `background=true` detaches with a handle; `agy_tasks` polls, collects, and cancels under the same timeout and lock |
|
|
37
38
|
|
|
38
39
|
Auth is unchanged: existing `agy` OAuth (`~/.gemini/oauth_creds.json`).
|
|
39
40
|
|
|
@@ -73,10 +74,11 @@ timeout), so a provider turn never races `agy_execute` in the same directory.
|
|
|
73
74
|
Read-only tool bridge: provider turns also get an extra `--add-dir`
|
|
74
75
|
carrying a localhost MCP server (`pi-agy-tools`) that exposes Pi-side
|
|
75
76
|
context agy cannot see otherwise — `agy_sessions_list`, `agy_quota_report`,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
`agy_model_catalog`, and `activate_skill` (which dynamically lists and injects
|
|
78
|
+
Pi Agent Skills from `~/.pi/agent/skills`, `~/.agents/skills`, and `.pi/skills`).
|
|
79
|
+
The server binds 127.0.0.1 with a per-process shared secret, serves only reads,
|
|
80
|
+
and never touches your global agy config. Set `"providerBridge": false` in
|
|
81
|
+
`agy-config.json` to run provider turns plain.
|
|
80
82
|
|
|
81
83
|
Mutating tool bridge: agy turns can also call Pi tools directly. The bridge
|
|
82
84
|
parks the MCP call, the provider emits a real shadow `toolCall`, and Pi
|
|
@@ -84,9 +86,11 @@ executes it with normal permissions, approvals, and diff review; the next
|
|
|
84
86
|
turn's `toolResult` completes the parked call and agy continues. Only active
|
|
85
87
|
non-builtin tools are exposed (`agy_*` and `AskAntigravity` excluded — no
|
|
86
88
|
recursive delegation); the catalog refreshes per turn and the driver recycles
|
|
87
|
-
when it changes so agy always sees a fresh tool list.
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
when it changes so agy always sees a fresh tool list. Long calls over 20 seconds
|
|
90
|
+
early-ack with `STILL RUNNING` and a `callId` so agy can poll via
|
|
91
|
+
`bridge_poll_result`, completely avoiding agy's ~180-second MCP client timeout.
|
|
92
|
+
Suspended turns hold the agy child with timers off, re-arm on resume, and are
|
|
93
|
+
abandoned loudly on cancel, teardown, or a 30-minute stall cap.
|
|
90
94
|
|
|
91
95
|
Do not install `@estebanforge/pi-antigravity-bridge` alongside this package:
|
|
92
96
|
both register the `antigravity` provider id and an `/agy` command.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import {
|
|
3
|
+
checkAgyUsage,
|
|
4
|
+
formatAgyUsage,
|
|
5
|
+
inspectAgyAgents,
|
|
6
|
+
resolveAgyModelId,
|
|
7
|
+
type AgyModel,
|
|
8
|
+
} from "./lib/cli.js";
|
|
9
|
+
import { runAgyDoctor } from "./lib/doctor.js";
|
|
10
|
+
import { loadAgyConfig, saveAgyConfig } from "./lib/config.js";
|
|
11
|
+
import { describeProviderBridges, resetProviderBridges } from "./lib/provider.js";
|
|
12
|
+
|
|
13
|
+
/** `/agy doctor` — diagnose the CLI and local integration without inference. */
|
|
14
|
+
export async function showDoctor(ctx: ExtensionCommandContext): Promise<void> {
|
|
15
|
+
try {
|
|
16
|
+
await ctx.waitForIdle();
|
|
17
|
+
ctx.ui.setStatus("agy", "agy: running diagnostics…");
|
|
18
|
+
const report = await runAgyDoctor(ctx.cwd, ctx.signal);
|
|
19
|
+
const type = report.status === "error" ? "error" : report.status === "warn" ? "warning" : "info";
|
|
20
|
+
ctx.ui.notify(report.text, type);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (ctx.signal?.aborted) {
|
|
23
|
+
ctx.ui.notify("agy: doctor cancelled", "info");
|
|
24
|
+
} else {
|
|
25
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
26
|
+
ctx.ui.notify(`agy doctor failed: ${message}`, "error");
|
|
27
|
+
}
|
|
28
|
+
} finally {
|
|
29
|
+
ctx.ui.setStatus("agy", undefined);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** `/agy agents` — list configured custom agents without inference. */
|
|
34
|
+
export async function showAgents(ctx: ExtensionCommandContext): Promise<void> {
|
|
35
|
+
try {
|
|
36
|
+
await ctx.waitForIdle();
|
|
37
|
+
ctx.ui.setStatus("agy", "agy: discovering custom agents…");
|
|
38
|
+
const agents = await inspectAgyAgents(ctx.cwd, ctx.signal);
|
|
39
|
+
ctx.ui.notify(
|
|
40
|
+
agents.length ? `configured agy agents:\n${agents.map((agent) => `- ${agent}`).join("\n")}` : "No custom agy agents are configured.",
|
|
41
|
+
"info",
|
|
42
|
+
);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (ctx.signal?.aborted) ctx.ui.notify("agy: agent discovery cancelled", "info");
|
|
45
|
+
else {
|
|
46
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
47
|
+
ctx.ui.notify(`agy agent discovery failed: ${message}`, "error");
|
|
48
|
+
}
|
|
49
|
+
} finally {
|
|
50
|
+
ctx.ui.setStatus("agy", undefined);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** `/agy usage` — show model quotas without starting an agent turn. */
|
|
55
|
+
export async function showUsage(
|
|
56
|
+
ctx: ExtensionCommandContext,
|
|
57
|
+
model?: AgyModel,
|
|
58
|
+
): Promise<void> {
|
|
59
|
+
try {
|
|
60
|
+
await ctx.waitForIdle();
|
|
61
|
+
const snapshot = await checkAgyUsage(ctx.cwd, ctx.signal);
|
|
62
|
+
const report = formatAgyUsage(snapshot, model ? resolveAgyModelId(model) : undefined);
|
|
63
|
+
ctx.ui.notify(report ?? "agy quota information is unavailable in this CLI version", report ? "info" : "warning");
|
|
64
|
+
} catch (error) {
|
|
65
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
66
|
+
ctx.ui.notify(`agy usage check failed: ${message}`, "error");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** `/agy bridge [on|off|status]` — inspect or toggle the provider MCP bridge. */
|
|
71
|
+
export async function showBridge(ctx: ExtensionCommandContext, arg?: string): Promise<void> {
|
|
72
|
+
const sub = (arg ?? "status").toLowerCase();
|
|
73
|
+
if (sub !== "on" && sub !== "off" && sub !== "status") {
|
|
74
|
+
ctx.ui.notify("agy: bridge takes on, off, or no argument (status)", "error");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
await ctx.waitForIdle();
|
|
79
|
+
if (sub === "on" || sub === "off") {
|
|
80
|
+
ctx.ui.setStatus("agy", `agy: turning the provider bridge ${sub}…`);
|
|
81
|
+
await saveAgyConfig({ providerBridge: sub === "on" });
|
|
82
|
+
// Drop memoized servers so the next provider turn re-resolves;
|
|
83
|
+
// drivers recycle on the bridge-dir change by themselves.
|
|
84
|
+
await resetProviderBridges();
|
|
85
|
+
ctx.ui.notify(
|
|
86
|
+
sub === "on"
|
|
87
|
+
? "Provider bridge on: agy turns get Pi tools via localhost MCP (takes effect on the next turn)."
|
|
88
|
+
: "Provider bridge off: agy turns run plain (takes effect on the next turn).",
|
|
89
|
+
"info",
|
|
90
|
+
);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const config = await loadAgyConfig().catch(() => ({ providerBridge: true as const }));
|
|
94
|
+
const enabled = config.providerBridge !== false;
|
|
95
|
+
const bridges = describeProviderBridges();
|
|
96
|
+
const running = bridges.filter((bridge) => bridge.running);
|
|
97
|
+
const lines = [
|
|
98
|
+
`Provider bridge: ${enabled ? "on" : "off"} (agy-config.json${enabled ? "" : " — set providerBridge or run /agy bridge on"})`,
|
|
99
|
+
running.length > 0
|
|
100
|
+
? `running servers (${running.length}):\n${running.map((bridge) => `- ${bridge.dir} · ${bridge.toolCount ?? 0} tools`).join("\n")}`
|
|
101
|
+
: "no bridge servers running (one starts on the next provider turn)",
|
|
102
|
+
];
|
|
103
|
+
ctx.ui.notify(lines.join("\n"), "info");
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (ctx.signal?.aborted) ctx.ui.notify("agy: bridge check cancelled", "info");
|
|
106
|
+
else {
|
|
107
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
108
|
+
ctx.ui.notify(`agy bridge failed: ${message}`, "error");
|
|
109
|
+
}
|
|
110
|
+
} finally {
|
|
111
|
+
ctx.ui.setStatus("agy", undefined);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { isAgyModel, resolveAgyModelId, type AgyModel } from "./lib/cli.js";
|
|
3
|
+
import { buildAgyContextFromEntries, effectiveResumeContextMode, type AgyContextMode } from "./lib/context.js";
|
|
4
|
+
import { describePreRunDirt } from "./lib/postflight.js";
|
|
5
|
+
import { DEFAULT_TIMEOUT_MS } from "./lib/command-args.js";
|
|
6
|
+
import { executeAgyTask } from "./lib/execute.js";
|
|
7
|
+
import { describeWhen, truncate } from "./lib/output.js";
|
|
8
|
+
import { buildAcceptEditsConfirm } from "./lib/confirm.js";
|
|
9
|
+
import { AGY_RUN_ENTRY_TYPE, type AgyRunReceipt } from "./lib/render.js";
|
|
10
|
+
import { getHistory } from "./lib/sessions.js";
|
|
11
|
+
|
|
12
|
+
export interface InteractiveRun {
|
|
13
|
+
mode: "plan" | "accept-edits" | "sandbox";
|
|
14
|
+
model: AgyModel;
|
|
15
|
+
agent?: string;
|
|
16
|
+
prompt: string;
|
|
17
|
+
conversation_id?: string;
|
|
18
|
+
continue?: boolean;
|
|
19
|
+
timeout_ms?: number;
|
|
20
|
+
context?: AgyContextMode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const MODE_OPTIONS = [
|
|
24
|
+
"accept-edits — writes files (default)",
|
|
25
|
+
"plan — exploration, no edits",
|
|
26
|
+
"sandbox — isolated preview",
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
/** `/agy sessions` — pick a recorded conversation and resume it with a follow-up. */
|
|
30
|
+
export async function runSessionsPicker(
|
|
31
|
+
pi: ExtensionAPI,
|
|
32
|
+
ctx: ExtensionCommandContext,
|
|
33
|
+
): Promise<void> {
|
|
34
|
+
const history = await getHistory(ctx.cwd);
|
|
35
|
+
if (history.length === 0) {
|
|
36
|
+
ctx.ui.notify("agy: no recorded conversations for this directory", "info");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const options = history.map((entry, index) => {
|
|
41
|
+
const id = entry.conversation_id.slice(0, 8);
|
|
42
|
+
const model = entry.model ?? "unknown model";
|
|
43
|
+
const agent = entry.agent ? ` · agent ${entry.agent}` : "";
|
|
44
|
+
const summary = entry.summary ? `${entry.summary.slice(0, 50)} · ` : "";
|
|
45
|
+
return `${index + 1}. ${summary}${model}${agent} · ${describeWhen(entry.updated_at)} · ${id}…`;
|
|
46
|
+
});
|
|
47
|
+
const pick = await ctx.ui.select("resume agy conversation", options);
|
|
48
|
+
if (!pick) {
|
|
49
|
+
ctx.ui.notify("agy: cancelled", "info");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const entry = history[options.indexOf(pick)];
|
|
53
|
+
if (!entry) {
|
|
54
|
+
ctx.ui.notify("agy: cancelled", "info");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const modePick = await ctx.ui.select("agy mode", MODE_OPTIONS);
|
|
59
|
+
if (!modePick) {
|
|
60
|
+
ctx.ui.notify("agy: cancelled", "info");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const mode = optionKey(modePick) as InteractiveRun["mode"];
|
|
64
|
+
|
|
65
|
+
const text = await ctx.ui.editor("agy follow-up task", "");
|
|
66
|
+
if (!text?.trim()) {
|
|
67
|
+
ctx.ui.notify("agy: cancelled (empty task)", "info");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
await executeConfirmedRun(pi, ctx, {
|
|
72
|
+
mode,
|
|
73
|
+
model: isAgyModel(entry.model) ? entry.model : "flash-medium",
|
|
74
|
+
agent: entry.agent,
|
|
75
|
+
prompt: text.trim(),
|
|
76
|
+
conversation_id: entry.conversation_id,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function executeConfirmedRun(
|
|
81
|
+
pi: ExtensionAPI,
|
|
82
|
+
ctx: ExtensionCommandContext,
|
|
83
|
+
run: InteractiveRun,
|
|
84
|
+
): Promise<void> {
|
|
85
|
+
const cwd = ctx.cwd;
|
|
86
|
+
await ctx.waitForIdle();
|
|
87
|
+
const requestedContextMode = run.context ?? "none";
|
|
88
|
+
const contextMode = effectiveResumeContextMode(
|
|
89
|
+
requestedContextMode,
|
|
90
|
+
Boolean(run.conversation_id || run.continue),
|
|
91
|
+
);
|
|
92
|
+
const contextText =
|
|
93
|
+
contextMode === "none"
|
|
94
|
+
? undefined
|
|
95
|
+
: buildAgyContextFromEntries(ctx.sessionManager.buildContextEntries(), contextMode);
|
|
96
|
+
|
|
97
|
+
if (run.mode === "accept-edits") {
|
|
98
|
+
const dirt = await describePreRunDirt(cwd, ctx.signal).catch(() => null);
|
|
99
|
+
const { title, body } = buildAcceptEditsConfirm({
|
|
100
|
+
modelLabel: `${run.model} (${resolveAgyModelId(run.model)})`,
|
|
101
|
+
agent: run.agent,
|
|
102
|
+
cwd,
|
|
103
|
+
prompt: run.prompt,
|
|
104
|
+
contextMode,
|
|
105
|
+
contextText,
|
|
106
|
+
dirt,
|
|
107
|
+
});
|
|
108
|
+
const ok = await ctx.ui.confirm(title, body);
|
|
109
|
+
if (!ok) {
|
|
110
|
+
ctx.ui.notify("agy: cancelled", "info");
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Execute directly so the confirmed parameters cannot be changed by
|
|
116
|
+
// a second LLM turn and the command works even when tools are limited.
|
|
117
|
+
const status = createStatusThrottler(ctx);
|
|
118
|
+
try {
|
|
119
|
+
status(`starting (${run.model} · ${run.mode}${run.agent ? ` · agent ${run.agent}` : ""})`);
|
|
120
|
+
const result = await executeAgyTask(
|
|
121
|
+
{
|
|
122
|
+
prompt: run.prompt,
|
|
123
|
+
model: run.model,
|
|
124
|
+
agent: run.agent,
|
|
125
|
+
mode: run.mode,
|
|
126
|
+
dir: cwd,
|
|
127
|
+
timeout_ms: run.timeout_ms ?? DEFAULT_TIMEOUT_MS,
|
|
128
|
+
conversation_id: run.conversation_id,
|
|
129
|
+
continue: run.continue,
|
|
130
|
+
new_session: run.conversation_id || run.continue ? false : true,
|
|
131
|
+
stream: true,
|
|
132
|
+
context: contextMode,
|
|
133
|
+
context_text: contextText,
|
|
134
|
+
},
|
|
135
|
+
ctx.signal,
|
|
136
|
+
(progress) => status(progress),
|
|
137
|
+
);
|
|
138
|
+
status(undefined);
|
|
139
|
+
const text = truncate(result.text || "(empty response)");
|
|
140
|
+
if (typeof pi.appendEntry === "function") {
|
|
141
|
+
pi.appendEntry(AGY_RUN_ENTRY_TYPE, {
|
|
142
|
+
task: truncate(run.prompt, 500),
|
|
143
|
+
text,
|
|
144
|
+
details: result.details,
|
|
145
|
+
completed_at: new Date().toISOString(),
|
|
146
|
+
} satisfies AgyRunReceipt);
|
|
147
|
+
} else {
|
|
148
|
+
// Compatibility fallback for stripped-down hosts and test harnesses.
|
|
149
|
+
ctx.ui.notify(truncate(text, 4000), "info");
|
|
150
|
+
}
|
|
151
|
+
} catch (error) {
|
|
152
|
+
status(undefined);
|
|
153
|
+
if (ctx.signal?.aborted) {
|
|
154
|
+
ctx.ui.notify("agy: cancelled", "info");
|
|
155
|
+
} else {
|
|
156
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
157
|
+
ctx.ui.notify(`agy failed: ${message}`, "error");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Coalesce status-bar updates so per-token deltas do not churn the TUI. */
|
|
163
|
+
function createStatusThrottler(ctx: ExtensionCommandContext, intervalMs = 300) {
|
|
164
|
+
let lastEmit = 0;
|
|
165
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
166
|
+
let pending: string | undefined;
|
|
167
|
+
|
|
168
|
+
const emit = (text: string) => {
|
|
169
|
+
lastEmit = Date.now();
|
|
170
|
+
ctx.ui.setStatus("agy", text.slice(0, 200));
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
return (text: string | undefined): void => {
|
|
174
|
+
if (text === undefined) {
|
|
175
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
176
|
+
timer = undefined;
|
|
177
|
+
pending = undefined;
|
|
178
|
+
ctx.ui.setStatus("agy", undefined);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const now = Date.now();
|
|
182
|
+
if (now - lastEmit >= intervalMs) {
|
|
183
|
+
emit(text);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
pending = text;
|
|
187
|
+
if (timer === undefined) {
|
|
188
|
+
timer = setTimeout(() => {
|
|
189
|
+
timer = undefined;
|
|
190
|
+
if (pending !== undefined) emit(pending);
|
|
191
|
+
pending = undefined;
|
|
192
|
+
}, intervalMs - (now - lastEmit));
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function optionKey(option: string): string {
|
|
198
|
+
return option.split(" — ")[0];
|
|
199
|
+
}
|