@jameslovespancakes/pi-plus 1.0.0 → 1.0.1

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.
Files changed (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +190 -190
  3. package/config/pi-plus.example.json +60 -60
  4. package/config/skills/model-routing/SKILL.md +86 -86
  5. package/images/pi-plus.svg +10 -10
  6. package/package.json +67 -67
  7. package/server/board-server.mjs +641 -641
  8. package/server/package.json +17 -17
  9. package/src/core/accounts/registry.ts +93 -93
  10. package/src/core/anthropic/client-identity.ts +241 -241
  11. package/src/core/catalog/quality.ts +314 -314
  12. package/src/core/config.ts +169 -169
  13. package/src/core/env.ts +58 -58
  14. package/src/core/exec/process.ts +146 -146
  15. package/src/core/exec/ssh-config.ts +157 -157
  16. package/src/core/policy/policy.ts +183 -183
  17. package/src/core/quota/pool.ts +64 -64
  18. package/src/core/quota/usage-source.ts +289 -289
  19. package/src/core/store.ts +43 -43
  20. package/src/domains/agents/board-setup.ts +409 -409
  21. package/src/domains/agents/index.ts +462 -462
  22. package/src/domains/models/catalog-tool.ts +361 -361
  23. package/src/domains/models/index.ts +14 -14
  24. package/src/domains/models/policy-gate.ts +169 -169
  25. package/src/domains/models/provider-picker.ts +207 -207
  26. package/src/domains/remote/config-path.ts +41 -41
  27. package/src/domains/remote/index.ts +866 -866
  28. package/src/domains/remote/setup.ts +425 -425
  29. package/src/domains/setup/index.ts +220 -220
  30. package/src/domains/subscriptions/accounts.ts +242 -242
  31. package/src/domains/subscriptions/footer.ts +182 -182
  32. package/src/domains/subscriptions/index.ts +42 -42
  33. package/src/domains/subscriptions/provider.ts +219 -219
  34. package/src/domains/subscriptions/providers/anthropic.ts +149 -149
  35. package/src/domains/subscriptions/providers/codex.ts +148 -148
  36. package/src/domains/subscriptions/routing.ts +72 -72
  37. package/src/services/usage-service.ts +186 -186
  38. package/src/ui/format.ts +73 -73
  39. package/src/ui/usage-bars.ts +154 -154
  40. package/src/vendor/anthropic.ts +109 -109
@@ -1,17 +1,17 @@
1
- {
2
- "name": "pi-plus-board-server",
3
- "version": "1.0.0",
4
- "private": true,
5
- "type": "module",
6
- "description": "Agent board server for pi-plus",
7
- "main": "board-server.mjs",
8
- "scripts": {
9
- "start": "node board-server.mjs"
10
- },
11
- "dependencies": {
12
- "ws": "^8.18.3"
13
- },
14
- "engines": {
15
- "node": ">=22.5.0"
16
- }
17
- }
1
+ {
2
+ "name": "pi-plus-board-server",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "description": "Agent board server for pi-plus",
7
+ "main": "board-server.mjs",
8
+ "scripts": {
9
+ "start": "node board-server.mjs"
10
+ },
11
+ "dependencies": {
12
+ "ws": "^8.18.3"
13
+ },
14
+ "engines": {
15
+ "node": ">=22.5.0"
16
+ }
17
+ }
@@ -1,93 +1,93 @@
1
- /**
2
- * Provider-agnostic subscription accounts.
3
- *
4
- * Today only Anthropic implements this, through
5
- * `domains/subscriptions/providers/anthropic.ts`. The point of the indirection
6
- * is that `/account` and `/routing` contain no provider-specific logic, so a
7
- * second provider is a new adapter rather than a new command surface.
8
- *
9
- * Structural types only; nothing here imports pi.
10
- */
11
-
12
- export interface ManagedAccount {
13
- id: string;
14
- label: string;
15
- /** False when the account is configured but deliberately skipped. */
16
- enabled: boolean;
17
- /** OAuth expiry, when the provider exposes one. */
18
- expiresAt?: number;
19
- /** True for the account pi itself is authenticated as. */
20
- primary?: boolean;
21
- }
22
-
23
- /**
24
- * `standard` uses the main account first and falls back only when it is
25
- * exhausted. `optimal` balances across accounts by remaining quota and time to
26
- * reset, keeping session caches sticky.
27
- */
28
- export type RoutingMode = "standard" | "optimal";
29
-
30
- export interface AccountUi {
31
- input(title: string, placeholder?: string): Promise<string | undefined>;
32
- confirm(title: string, message: string): Promise<boolean>;
33
- notify(message: string, type?: "info" | "warning" | "error"): void;
34
- }
35
-
36
- export interface AccountContext {
37
- ui: AccountUi;
38
- hasUI: boolean;
39
- /** Opens a URL in the user's browser, for OAuth flows. */
40
- openBrowser(url: string): Promise<void>;
41
- }
42
-
43
- export interface RoutingSupport {
44
- get(): Promise<RoutingMode>;
45
- set(mode: RoutingMode): Promise<RoutingMode>;
46
- describe(mode: RoutingMode): string;
47
- }
48
-
49
- export interface AccountProvider {
50
- /** Matches the pi provider id, e.g. "anthropic". */
51
- id: string;
52
- /** Human name, e.g. "Claude". */
53
- label: string;
54
- list(): Promise<ManagedAccount[]>;
55
- /** Returns the label of the account that was added. */
56
- add(ctx: AccountContext, label: string): Promise<string | undefined>;
57
- /** Returns the label of the account that was reauthorized. */
58
- reauth(ctx: AccountContext, accountId: string): Promise<string | undefined>;
59
- /**
60
- * Enables or disables one account without removing its credentials.
61
- * Optional: a provider that cannot suspend accounts simply omits it.
62
- */
63
- setEnabled?(accountId: string, enabled: boolean): Promise<void>;
64
- /**
65
- * Changes an account's display label. Credentials are untouched, so this is
66
- * purely cosmetic and never needs a re-authorization.
67
- */
68
- rename?(accountId: string, label: string): Promise<void>;
69
- routing?: RoutingSupport;
70
- }
71
-
72
- const providers = new Map<string, AccountProvider>();
73
-
74
- export function registerAccountProvider(provider: AccountProvider): void {
75
- providers.set(provider.id, provider);
76
- }
77
-
78
- export function accountProviders(): AccountProvider[] {
79
- return [...providers.values()].sort((a, b) => a.id.localeCompare(b.id));
80
- }
81
-
82
- export function accountProvider(id: string): AccountProvider | undefined {
83
- return providers.get(id.toLowerCase());
84
- }
85
-
86
- /** Providers that can balance across more than one account. */
87
- export function routableProviders(): AccountProvider[] {
88
- return accountProviders().filter((provider) => provider.routing !== undefined);
89
- }
90
-
91
- export function resetAccountProviders(): void {
92
- providers.clear();
93
- }
1
+ /**
2
+ * Provider-agnostic subscription accounts.
3
+ *
4
+ * Today only Anthropic implements this, through
5
+ * `domains/subscriptions/providers/anthropic.ts`. The point of the indirection
6
+ * is that `/account` and `/routing` contain no provider-specific logic, so a
7
+ * second provider is a new adapter rather than a new command surface.
8
+ *
9
+ * Structural types only; nothing here imports pi.
10
+ */
11
+
12
+ export interface ManagedAccount {
13
+ id: string;
14
+ label: string;
15
+ /** False when the account is configured but deliberately skipped. */
16
+ enabled: boolean;
17
+ /** OAuth expiry, when the provider exposes one. */
18
+ expiresAt?: number;
19
+ /** True for the account pi itself is authenticated as. */
20
+ primary?: boolean;
21
+ }
22
+
23
+ /**
24
+ * `standard` uses the main account first and falls back only when it is
25
+ * exhausted. `optimal` balances across accounts by remaining quota and time to
26
+ * reset, keeping session caches sticky.
27
+ */
28
+ export type RoutingMode = "standard" | "optimal";
29
+
30
+ export interface AccountUi {
31
+ input(title: string, placeholder?: string): Promise<string | undefined>;
32
+ confirm(title: string, message: string): Promise<boolean>;
33
+ notify(message: string, type?: "info" | "warning" | "error"): void;
34
+ }
35
+
36
+ export interface AccountContext {
37
+ ui: AccountUi;
38
+ hasUI: boolean;
39
+ /** Opens a URL in the user's browser, for OAuth flows. */
40
+ openBrowser(url: string): Promise<void>;
41
+ }
42
+
43
+ export interface RoutingSupport {
44
+ get(): Promise<RoutingMode>;
45
+ set(mode: RoutingMode): Promise<RoutingMode>;
46
+ describe(mode: RoutingMode): string;
47
+ }
48
+
49
+ export interface AccountProvider {
50
+ /** Matches the pi provider id, e.g. "anthropic". */
51
+ id: string;
52
+ /** Human name, e.g. "Claude". */
53
+ label: string;
54
+ list(): Promise<ManagedAccount[]>;
55
+ /** Returns the label of the account that was added. */
56
+ add(ctx: AccountContext, label: string): Promise<string | undefined>;
57
+ /** Returns the label of the account that was reauthorized. */
58
+ reauth(ctx: AccountContext, accountId: string): Promise<string | undefined>;
59
+ /**
60
+ * Enables or disables one account without removing its credentials.
61
+ * Optional: a provider that cannot suspend accounts simply omits it.
62
+ */
63
+ setEnabled?(accountId: string, enabled: boolean): Promise<void>;
64
+ /**
65
+ * Changes an account's display label. Credentials are untouched, so this is
66
+ * purely cosmetic and never needs a re-authorization.
67
+ */
68
+ rename?(accountId: string, label: string): Promise<void>;
69
+ routing?: RoutingSupport;
70
+ }
71
+
72
+ const providers = new Map<string, AccountProvider>();
73
+
74
+ export function registerAccountProvider(provider: AccountProvider): void {
75
+ providers.set(provider.id, provider);
76
+ }
77
+
78
+ export function accountProviders(): AccountProvider[] {
79
+ return [...providers.values()].sort((a, b) => a.id.localeCompare(b.id));
80
+ }
81
+
82
+ export function accountProvider(id: string): AccountProvider | undefined {
83
+ return providers.get(id.toLowerCase());
84
+ }
85
+
86
+ /** Providers that can balance across more than one account. */
87
+ export function routableProviders(): AccountProvider[] {
88
+ return accountProviders().filter((provider) => provider.routing !== undefined);
89
+ }
90
+
91
+ export function resetAccountProviders(): void {
92
+ providers.clear();
93
+ }