@aliou/pi-linkup 0.2.0 → 0.3.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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/commands/balance.ts +6 -4
- package/src/components/balance-renderer.ts +45 -0
- package/src/components/index.ts +6 -0
- package/src/index.ts +4 -0
- package/src/types.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @aliou/pi-linkup
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e57f6fe: Enhanced balance command to show remaining requests per operation type (standard search, deep search, fetch with/without JS) using a themed custom message renderer instead of a transient notification.
|
|
8
|
+
|
|
3
9
|
## 0.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/package.json
CHANGED
package/src/commands/balance.ts
CHANGED
|
@@ -9,10 +9,12 @@ export function registerBalanceCommand(pi: ExtensionAPI) {
|
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
11
|
const response = await client.getBalance();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
pi.sendMessage({
|
|
13
|
+
customType: "linkup-balance",
|
|
14
|
+
content: `Linkup Balance: ${response.balance.toFixed(2)} credits`,
|
|
15
|
+
display: true,
|
|
16
|
+
details: { balance: response.balance },
|
|
17
|
+
});
|
|
16
18
|
} catch (error) {
|
|
17
19
|
const message =
|
|
18
20
|
error instanceof Error ? error.message : "Unknown error";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { Box, Text } from "@mariozechner/pi-tui";
|
|
3
|
+
import { LINKUP_PRICING } from "../types";
|
|
4
|
+
|
|
5
|
+
export function registerBalanceRenderer(pi: ExtensionAPI) {
|
|
6
|
+
pi.registerMessageRenderer("linkup-balance", (message, _options, theme) => {
|
|
7
|
+
const details = message.details as { balance: number };
|
|
8
|
+
const balance = details.balance;
|
|
9
|
+
|
|
10
|
+
// Build header line
|
|
11
|
+
const header = [
|
|
12
|
+
theme.fg("accent", "Linkup"),
|
|
13
|
+
theme.fg("muted", " · "),
|
|
14
|
+
theme.fg("muted", `${balance} credits`),
|
|
15
|
+
].join("");
|
|
16
|
+
|
|
17
|
+
// Calculate remaining requests for each operation type
|
|
18
|
+
const remaining = {
|
|
19
|
+
standardSearch: Math.floor(balance / LINKUP_PRICING.standardSearch),
|
|
20
|
+
deepSearch: Math.floor(balance / LINKUP_PRICING.deepSearch),
|
|
21
|
+
fetchNoJs: Math.floor(balance / LINKUP_PRICING.fetchNoJs),
|
|
22
|
+
fetchWithJs: Math.floor(balance / LINKUP_PRICING.fetchWithJs),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Format number with locale string and ~ prefix
|
|
26
|
+
const fmt = (num: number): string => `~${num.toLocaleString()}`;
|
|
27
|
+
|
|
28
|
+
// Table rows with right-aligned numbers (padded to 7 chars)
|
|
29
|
+
const row = (num: number, label: string) =>
|
|
30
|
+
`${theme.fg("accent", fmt(num).padStart(7))} ${theme.fg("dim", label)}`;
|
|
31
|
+
|
|
32
|
+
const lines = [
|
|
33
|
+
header,
|
|
34
|
+
"",
|
|
35
|
+
row(remaining.standardSearch, "standard searches"),
|
|
36
|
+
row(remaining.deepSearch, "deep searches"),
|
|
37
|
+
row(remaining.fetchNoJs, "fetches (no JS)"),
|
|
38
|
+
row(remaining.fetchWithJs, "fetches (with JS)"),
|
|
39
|
+
].join("\n");
|
|
40
|
+
|
|
41
|
+
const box = new Box(1, 1, (t) => theme.bg("customMessageBg", t));
|
|
42
|
+
box.addChild(new Text(lines, 0, 0));
|
|
43
|
+
return box;
|
|
44
|
+
});
|
|
45
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
2
|
import { registerBalanceCommand } from "./commands/balance";
|
|
3
|
+
import { registerRenderers } from "./components";
|
|
3
4
|
import { registerWebAnswerTool } from "./tools/web-answer";
|
|
4
5
|
import { registerWebFetchTool } from "./tools/web-fetch";
|
|
5
6
|
import { registerWebSearchTool } from "./tools/web-search";
|
|
@@ -30,4 +31,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
30
31
|
|
|
31
32
|
// Register commands
|
|
32
33
|
registerBalanceCommand(pi);
|
|
34
|
+
|
|
35
|
+
// Register renderers
|
|
36
|
+
registerRenderers(pi);
|
|
33
37
|
}
|
package/src/types.ts
CHANGED
|
@@ -32,3 +32,14 @@ export interface LinkupErrorResponse {
|
|
|
32
32
|
message?: string;
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Credit cost per request by operation type.
|
|
38
|
+
* Source: https://docs.linkup.so/pages/documentation/development/pricing
|
|
39
|
+
*/
|
|
40
|
+
export const LINKUP_PRICING = {
|
|
41
|
+
standardSearch: 0.005,
|
|
42
|
+
deepSearch: 0.05,
|
|
43
|
+
fetchNoJs: 0.001,
|
|
44
|
+
fetchWithJs: 0.005,
|
|
45
|
+
} as const;
|