@getpaseo/plugin 0.11.0-beta.2 → 0.11.0-beta.4

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.
@@ -103,6 +103,11 @@ interface PluginClientContextAliases {
103
103
  addSidebarItem(contribution: PluginSidebarContribution): PluginCleanup;
104
104
  }
105
105
  export interface PluginClientContext extends PluginCommandCapabilities, PluginClientContextAliases {
106
+ /** Play a base64-encoded audio file on this client; resolves when playback ends. */
107
+ playAudio(source: {
108
+ base64: string;
109
+ mimeType: string;
110
+ }): Promise<void>;
106
111
  addSettingsScreen(contribution: PluginSettingsScreenContribution): PluginCleanup;
107
112
  addScreen(contribution: PluginScreenContribution): PluginCleanup;
108
113
  addSidebarHeaderItem(contribution: PluginSidebarItemContribution): PluginCleanup;
@@ -68,6 +68,9 @@ export interface PluginLifecycleEvents {
68
68
  "agent.created": {
69
69
  agent: PluginHookAgent;
70
70
  };
71
+ "agent.closed": {
72
+ agent: PluginHookAgent;
73
+ };
71
74
  "workspace.created": {
72
75
  workspace: PluginHookWorkspace;
73
76
  };
@@ -1,4 +1,4 @@
1
- import type { ZodType } from "zod";
1
+ import { z, type ZodType } from "zod";
2
2
  import type { JsonValue } from "@getpaseo/protocol/agent-types";
3
3
  export interface UsageWindow {
4
4
  id: string;
@@ -33,26 +33,56 @@ export interface UsageDetail {
33
33
  value: string;
34
34
  tone?: UsageWindow["tone"];
35
35
  }
36
- export interface UsageReport {
37
- status: "available" | "unavailable" | "error";
36
+ export type UsageProblem = {
37
+ kind: "expired";
38
+ expiresAt: string;
39
+ refreshedBy?: string;
40
+ } | {
41
+ kind: "rejected";
42
+ status: number;
43
+ refreshedBy?: string;
44
+ } | {
45
+ kind: "no_quota";
46
+ detail: string;
47
+ };
48
+ export type UsageReport = {
49
+ status: "available";
38
50
  planLabel?: string;
39
51
  windows: UsageWindow[];
40
52
  balances?: UsageBalance[];
41
53
  details?: UsageDetail[];
42
- error?: string;
54
+ } | {
55
+ status: "unavailable";
56
+ problem: UsageProblem;
57
+ } | {
58
+ status: "error";
59
+ error: string;
60
+ };
61
+ export interface UsageAccount {
62
+ /** Stable across token rotation; [A-Za-z0-9._-]{1,128}. Never a credential or raw email. */
63
+ key: string;
64
+ label?: string;
65
+ /** Store locator, opaque to the daemon. */
66
+ input: JsonValue;
43
67
  }
68
+ export declare const UsageScopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
69
+ kind: z.ZodLiteral<"global">;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ kind: z.ZodLiteral<"session">;
72
+ provider: z.ZodString;
73
+ model: z.ZodOptional<z.ZodString>;
74
+ env: z.ZodRecord<z.ZodString, z.ZodString>;
75
+ }, z.core.$strip>], "kind">;
76
+ export type UsageScope = z.infer<typeof UsageScopeSchema>;
44
77
  export interface UsageSourceRegistration {
45
78
  id: string;
46
79
  label: string;
47
80
  icon?: string;
48
81
  input: ZodType;
49
- /** Stable account identity, resolved without fetching usage. */
50
- identify(input: unknown): Promise<{
51
- key: string;
52
- label?: string;
53
- } | null>;
82
+ /** Accounts for this scope only. The same key in any scope identifies the same account. */
83
+ discover(scope: UsageScope): Promise<UsageAccount[]>;
84
+ /** Re-reads the login store; never writes it. */
54
85
  fetch(input: unknown): Promise<UsageReport>;
55
- discover(): Promise<JsonValue[]>;
56
86
  }
57
87
  export declare function windowFromUsedPct(input: {
58
88
  id: string;
@@ -63,6 +93,29 @@ export declare function windowFromUsedPct(input: {
63
93
  resetsAt?: string | null;
64
94
  tone?: UsageWindow["tone"];
65
95
  }): UsageWindow;
96
+ /**
97
+ * Numeric provider windows have one identity and vocabulary, independent of response slots.
98
+ * Pass null when the provider omits the duration; reset countdowns are not window lengths.
99
+ * Named API fields (weekly, monthly, etc.) use windowFromUsedPct instead.
100
+ */
101
+ export declare function windowFromReportedDuration(input: {
102
+ durationSeconds: number | null;
103
+ /** Stable quota identity and provider name for a model- or feature-scoped limit. */
104
+ scope?: {
105
+ id: string;
106
+ label: string;
107
+ };
108
+ /** Neutral identity and names when the provider does not report a positive duration. */
109
+ unknown: {
110
+ id: string;
111
+ label: string;
112
+ shortLabel: string;
113
+ };
114
+ utilizationPct: number | null | undefined;
115
+ resetsAt?: string | null;
116
+ summary?: boolean;
117
+ tone?: UsageWindow["tone"];
118
+ }): UsageWindow;
66
119
  /**
67
120
  * The tone scale for anything measured against a known limit, windows and balances alike.
68
121
  *
@@ -81,5 +134,5 @@ export declare function balanceToneFromRemaining(remaining: number | null | unde
81
134
  /** Percentage of a limit consumed, or null when either side is unknown. */
82
135
  export declare function usedPctOf(used: number | null | undefined, limit: number | null | undefined): number | null;
83
136
  export declare function hashAccountKey(value: string): string;
84
- export declare function unavailableUsage(): UsageReport;
137
+ export declare function unavailable(problem: UsageProblem): UsageReport;
85
138
  //# sourceMappingURL=usage.d.ts.map
@@ -1,4 +1,14 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { z } from "zod";
3
+ export const UsageScopeSchema = z.discriminatedUnion("kind", [
4
+ z.object({ kind: z.literal("global") }),
5
+ z.object({
6
+ kind: z.literal("session"),
7
+ provider: z.string(),
8
+ model: z.string().optional(),
9
+ env: z.record(z.string(), z.string()),
10
+ }),
11
+ ]);
2
12
  export function windowFromUsedPct(input) {
3
13
  const usedPct = typeof input.utilizationPct === "number" ? input.utilizationPct : null;
4
14
  const window = {
@@ -16,6 +26,43 @@ export function windowFromUsedPct(input) {
16
26
  window.tone = input.tone;
17
27
  return window;
18
28
  }
29
+ /**
30
+ * Numeric provider windows have one identity and vocabulary, independent of response slots.
31
+ * Pass null when the provider omits the duration; reset countdowns are not window lengths.
32
+ * Named API fields (weekly, monthly, etc.) use windowFromUsedPct instead.
33
+ */
34
+ export function windowFromReportedDuration(input) {
35
+ const duration = input.durationSeconds;
36
+ const name = duration !== null && Number.isFinite(duration) && duration > 0
37
+ ? durationWindowName(duration)
38
+ : input.unknown;
39
+ const scope = input.scope;
40
+ return windowFromUsedPct({
41
+ id: scope ? `${scope.id}:${name.id}` : name.id,
42
+ label: scope ? `${scope.label} · ${name.label}` : name.label,
43
+ shortLabel: scope
44
+ ? `${scope.label}${name.shortLabel ? ` ${name.shortLabel}` : ""}`
45
+ : name.shortLabel,
46
+ utilizationPct: input.utilizationPct,
47
+ resetsAt: input.resetsAt,
48
+ summary: input.summary,
49
+ tone: input.tone,
50
+ });
51
+ }
52
+ function durationWindowName(seconds) {
53
+ if (seconds === 604800)
54
+ return { id: "weekly", label: "Weekly", shortLabel: "wk" };
55
+ const id = seconds === 18000 ? "five_hour" : `${seconds}s`;
56
+ const units = [
57
+ [86400, "day", "d"],
58
+ [3600, "hour", "h"],
59
+ [60, "minute", "m"],
60
+ [1, "second", "s"],
61
+ ];
62
+ const unit = units.find(([size]) => seconds % size === 0) ?? units[units.length - 1];
63
+ const amount = seconds / unit[0];
64
+ return { id, label: `${amount}-${unit[1]}`, shortLabel: `${amount}${unit[2]}` };
65
+ }
19
66
  /**
20
67
  * The tone scale for anything measured against a known limit, windows and balances alike.
21
68
  *
@@ -54,12 +101,7 @@ export function usedPctOf(used, limit) {
54
101
  export function hashAccountKey(value) {
55
102
  return createHash("sha256").update(value).digest("hex");
56
103
  }
57
- export function unavailableUsage() {
58
- return {
59
- status: "unavailable",
60
- windows: [],
61
- balances: [],
62
- details: [],
63
- };
104
+ export function unavailable(problem) {
105
+ return { status: "unavailable", problem };
64
106
  }
65
107
  //# sourceMappingURL=usage.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/plugin",
3
- "version": "0.11.0-beta.2",
3
+ "version": "0.11.0-beta.4",
4
4
  "description": "Paseo plugin SDK package",
5
5
  "files": [
6
6
  "dist",
@@ -70,8 +70,8 @@
70
70
  "use-sync-external-store": "^1.6.0"
71
71
  },
72
72
  "devDependencies": {
73
- "@getpaseo/client": "0.11.0-beta.2",
74
- "@getpaseo/protocol": "0.11.0-beta.2",
73
+ "@getpaseo/client": "0.11.0-beta.4",
74
+ "@getpaseo/protocol": "0.11.0-beta.4",
75
75
  "@types/node": "^20.9.0",
76
76
  "@types/react": "~19.2.0",
77
77
  "react": "19.1.0",
@@ -81,8 +81,8 @@
81
81
  "zod": "^4.4.3"
82
82
  },
83
83
  "peerDependencies": {
84
- "@getpaseo/client": "0.11.0-beta.2",
85
- "@getpaseo/protocol": "0.11.0-beta.2",
84
+ "@getpaseo/client": "0.11.0-beta.4",
85
+ "@getpaseo/protocol": "0.11.0-beta.4",
86
86
  "react": "~19.1.0",
87
87
  "react-native": ">=0.81.5",
88
88
  "zod": "^4.4.3"