@tokentop/plugin-sdk 1.0.0 → 1.0.2

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.
@@ -1,6 +1,5 @@
1
- import {
2
- CURRENT_API_VERSION
3
- } from "../index-y0tp0jk5.js";
1
+ // src/types/plugin.ts
2
+ var CURRENT_API_VERSION = 2;
4
3
 
5
4
  // src/helpers/create.ts
6
5
  function validateBase(plugin) {
@@ -82,7 +81,7 @@ function isTokenExpired(expiresAt, bufferMs = 5 * 60 * 1000) {
82
81
  // package.json
83
82
  var package_default = {
84
83
  name: "@tokentop/plugin-sdk",
85
- version: "1.0.0",
84
+ version: "1.0.2",
86
85
  description: "SDK for building tokentop plugins — providers, agents, themes, and notifications",
87
86
  type: "module",
88
87
  main: "dist/index.js",
@@ -113,7 +112,7 @@ var package_default = {
113
112
  scripts: {
114
113
  build: "bun run build:types && bun run build:js",
115
114
  "build:types": "tsc --emitDeclarationOnly",
116
- "build:js": "bun build src/index.ts src/types/index.ts src/helpers/index.ts src/testing/index.ts --outdir dist --target node --format esm --splitting",
115
+ "build:js": "bun build src/index.ts --outdir dist --target node --format esm && bun build src/types/index.ts --outdir dist/types --target node --format esm && bun build src/helpers/index.ts --outdir dist/helpers --target node --format esm && bun build src/testing/index.ts --outdir dist/testing --target node --format esm",
117
116
  typecheck: "tsc --noEmit",
118
117
  test: "bun test",
119
118
  clean: "rm -rf dist",
@@ -179,4 +178,3 @@ export {
179
178
  SDK_VERSION,
180
179
  CURRENT_API_VERSION
181
180
  };
182
- export { createProviderPlugin, createAgentPlugin, createThemePlugin, createNotificationPlugin, apiKeyCredential, oauthCredential, credentialFound, credentialMissing, credentialExpired, credentialInvalid, credentialError, isTokenExpired, SDK_VERSION, isCompatible, assertCompatible };
package/dist/index.js CHANGED
@@ -1,25 +1,175 @@
1
- import {
2
- CURRENT_API_VERSION,
3
- PluginPermissionError
4
- } from "./index-y0tp0jk5.js";
5
- import"./types/index.js";
6
- import {
7
- SDK_VERSION,
8
- apiKeyCredential,
9
- assertCompatible,
10
- createAgentPlugin,
11
- createNotificationPlugin,
12
- createProviderPlugin,
13
- createThemePlugin,
14
- credentialError,
15
- credentialExpired,
16
- credentialFound,
17
- credentialInvalid,
18
- credentialMissing,
19
- isCompatible,
20
- isTokenExpired,
21
- oauthCredential
22
- } from "./helpers/index.js";
1
+ // src/types/plugin.ts
2
+ var CURRENT_API_VERSION = 2;
3
+
4
+ class PluginPermissionError extends Error {
5
+ pluginId;
6
+ permission;
7
+ constructor(pluginId, permission, message) {
8
+ super(`Plugin "${pluginId}" permission denied: ${message}`);
9
+ this.pluginId = pluginId;
10
+ this.permission = permission;
11
+ this.name = "PluginPermissionError";
12
+ }
13
+ }
14
+ // src/helpers/create.ts
15
+ function validateBase(plugin) {
16
+ if (!plugin.id || typeof plugin.id !== "string") {
17
+ throw new Error('Plugin must have a non-empty string "id"');
18
+ }
19
+ if (!/^[a-z][a-z0-9-]*$/.test(plugin.id)) {
20
+ throw new Error(`Plugin id "${plugin.id}" must be kebab-case (lowercase letters, numbers, hyphens)`);
21
+ }
22
+ if (!plugin.name || typeof plugin.name !== "string") {
23
+ throw new Error('Plugin must have a non-empty string "name"');
24
+ }
25
+ if (!plugin.version || !/^\d+\.\d+\.\d+/.test(plugin.version)) {
26
+ throw new Error('Plugin must have a valid semver version (e.g. "1.0.0")');
27
+ }
28
+ }
29
+ function createProviderPlugin(def) {
30
+ validateBase(def);
31
+ if (def.type !== "provider") {
32
+ throw new Error('createProviderPlugin requires type: "provider"');
33
+ }
34
+ return { ...def, apiVersion: CURRENT_API_VERSION };
35
+ }
36
+ function createAgentPlugin(def) {
37
+ validateBase(def);
38
+ if (def.type !== "agent") {
39
+ throw new Error('createAgentPlugin requires type: "agent"');
40
+ }
41
+ return { ...def, apiVersion: CURRENT_API_VERSION };
42
+ }
43
+ function createThemePlugin(def) {
44
+ validateBase(def);
45
+ if (def.type !== "theme") {
46
+ throw new Error('createThemePlugin requires type: "theme"');
47
+ }
48
+ return { ...def, apiVersion: CURRENT_API_VERSION };
49
+ }
50
+ function createNotificationPlugin(def) {
51
+ validateBase(def);
52
+ if (def.type !== "notification") {
53
+ throw new Error('createNotificationPlugin requires type: "notification"');
54
+ }
55
+ return { ...def, apiVersion: CURRENT_API_VERSION };
56
+ }
57
+ // src/helpers/auth.ts
58
+ function apiKeyCredential(key, source = "env") {
59
+ return { apiKey: key, source };
60
+ }
61
+ function oauthCredential(accessToken, options) {
62
+ const oauth = { accessToken };
63
+ if (options?.refreshToken !== undefined)
64
+ oauth.refreshToken = options.refreshToken;
65
+ if (options?.expiresAt !== undefined)
66
+ oauth.expiresAt = options.expiresAt;
67
+ if (options?.accountId !== undefined)
68
+ oauth.accountId = options.accountId;
69
+ return { oauth, source: options?.source ?? "external" };
70
+ }
71
+ function credentialFound(credentials) {
72
+ return { ok: true, credentials };
73
+ }
74
+ function credentialMissing(message) {
75
+ return { ok: false, reason: "missing", message };
76
+ }
77
+ function credentialExpired(message) {
78
+ return { ok: false, reason: "expired", message };
79
+ }
80
+ function credentialInvalid(message) {
81
+ return { ok: false, reason: "invalid", message };
82
+ }
83
+ function credentialError(message) {
84
+ return { ok: false, reason: "error", message };
85
+ }
86
+ function isTokenExpired(expiresAt, bufferMs = 5 * 60 * 1000) {
87
+ if (expiresAt === undefined)
88
+ return false;
89
+ return expiresAt <= Date.now() + bufferMs;
90
+ }
91
+ // package.json
92
+ var package_default = {
93
+ name: "@tokentop/plugin-sdk",
94
+ version: "1.0.2",
95
+ description: "SDK for building tokentop plugins — providers, agents, themes, and notifications",
96
+ type: "module",
97
+ main: "dist/index.js",
98
+ types: "dist/index.d.ts",
99
+ exports: {
100
+ ".": {
101
+ types: "./dist/index.d.ts",
102
+ import: "./dist/index.js"
103
+ },
104
+ "./types": {
105
+ types: "./dist/types/index.d.ts",
106
+ import: "./dist/types/index.js"
107
+ },
108
+ "./helpers": {
109
+ types: "./dist/helpers/index.d.ts",
110
+ import: "./dist/helpers/index.js"
111
+ },
112
+ "./testing": {
113
+ types: "./dist/testing/index.d.ts",
114
+ import: "./dist/testing/index.js"
115
+ }
116
+ },
117
+ files: [
118
+ "dist",
119
+ "LICENSE",
120
+ "README.md"
121
+ ],
122
+ scripts: {
123
+ build: "bun run build:types && bun run build:js",
124
+ "build:types": "tsc --emitDeclarationOnly",
125
+ "build:js": "bun build src/index.ts --outdir dist --target node --format esm && bun build src/types/index.ts --outdir dist/types --target node --format esm && bun build src/helpers/index.ts --outdir dist/helpers --target node --format esm && bun build src/testing/index.ts --outdir dist/testing --target node --format esm",
126
+ typecheck: "tsc --noEmit",
127
+ test: "bun test",
128
+ clean: "rm -rf dist",
129
+ prepublishOnly: "bun run clean && bun run build"
130
+ },
131
+ keywords: [
132
+ "tokentop",
133
+ "plugin",
134
+ "sdk",
135
+ "ai",
136
+ "llm",
137
+ "token-usage",
138
+ "cost-monitoring"
139
+ ],
140
+ author: "Nigel Bazzeghin <nbazzeghin@gmail.com>",
141
+ license: "MIT",
142
+ repository: {
143
+ type: "git",
144
+ url: "https://github.com/tokentopapp/plugin-sdk.git"
145
+ },
146
+ publishConfig: {
147
+ access: "public",
148
+ registry: "https://registry.npmjs.org/"
149
+ },
150
+ homepage: "https://github.com/tokentopapp/tokentop",
151
+ engines: {
152
+ bun: ">=1.0.0"
153
+ },
154
+ devDependencies: {
155
+ "@types/bun": "latest",
156
+ "semantic-release": "^25.0.3",
157
+ typescript: "^5.7.0"
158
+ },
159
+ peerDependencies: {},
160
+ dependencies: {}
161
+ };
162
+
163
+ // src/helpers/version.ts
164
+ var SDK_VERSION = package_default.version;
165
+ function isCompatible(pluginApiVersion) {
166
+ return pluginApiVersion === CURRENT_API_VERSION;
167
+ }
168
+ function assertCompatible(pluginId, pluginApiVersion) {
169
+ if (!isCompatible(pluginApiVersion)) {
170
+ throw new Error(`Plugin "${pluginId}" requires API version ${pluginApiVersion}, ` + `but this SDK supports version ${CURRENT_API_VERSION}. ` + (pluginApiVersion > CURRENT_API_VERSION ? "Update tokentop to use this plugin." : "Update the plugin to the latest SDK."));
171
+ }
172
+ }
23
173
  export {
24
174
  oauthCredential,
25
175
  isTokenExpired,
@@ -2,12 +2,16 @@ import type { BasePlugin, PluginLogger } from './plugin.ts';
2
2
  import type { PluginHttpClient, PluginContext } from './context.ts';
3
3
  import type { Credentials, CredentialResult } from './provider.ts';
4
4
  export interface AgentConfig {
5
- /** Display name for this coding agent (e.g. "Claude Code", "Cursor"). */
5
+ /** Display name for this coding agent (e.g. "OpenCode", "Cursor"). */
6
6
  name: string;
7
+ /** CLI command that launches the agent (for display/detection). */
8
+ command?: string;
7
9
  /** Path to the agent's config directory (for display/debugging). */
8
10
  configPath?: string;
9
11
  /** Path to the agent's session storage. */
10
12
  sessionPath?: string;
13
+ /** Path to the agent's auth file (for credential reading). */
14
+ authPath?: string;
11
15
  }
12
16
  export interface AgentCapabilities {
13
17
  sessionParsing: boolean;
@@ -28,6 +32,8 @@ export interface SessionParseOptions {
28
32
  sessionId?: string;
29
33
  timePeriod?: 'session' | 'daily' | 'weekly' | 'monthly';
30
34
  limit?: number;
35
+ /** Epoch ms — only return sessions updated after this timestamp. */
36
+ since?: number;
31
37
  }
32
38
  export interface SessionUsageData {
33
39
  sessionId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/types/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMnE,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAA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AM,EAAE,WAAW,CAAC;CAC9B;AAMD,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAC;IAEzC,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,CAAC,EAAE;QACd,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACxD,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC;KACjD,CAAC;IAEF,qEAAqE;IACrE,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAElD,yDAAyD;IACzD,eAAe,CAAC,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEpE,+DAA+D;IAC/D,aAAa,CAAC,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAEjG,kEAAkE;IAClE,YAAY,CAAC,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAEtE,qDAAqD;IACrD,kBAAkB,CAAC,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE1E,oDAAoD;IACpD,iBAAiB,CAAC,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAAC;CAC9C"}
@@ -1,7 +1,16 @@
1
- import {
2
- CURRENT_API_VERSION,
3
- PluginPermissionError
4
- } from "../index-y0tp0jk5.js";
1
+ // src/types/plugin.ts
2
+ var CURRENT_API_VERSION = 2;
3
+
4
+ class PluginPermissionError extends Error {
5
+ pluginId;
6
+ permission;
7
+ constructor(pluginId, permission, message) {
8
+ super(`Plugin "${pluginId}" permission denied: ${message}`);
9
+ this.pluginId = pluginId;
10
+ this.permission = permission;
11
+ this.name = "PluginPermissionError";
12
+ }
13
+ }
5
14
  export {
6
15
  PluginPermissionError,
7
16
  CURRENT_API_VERSION
@@ -59,6 +59,14 @@ export interface PluginMeta {
59
59
  * Example: `"◆"`, `"▲"`, `"⚡"`
60
60
  */
61
61
  icon?: string;
62
+ /**
63
+ * Additional provider IDs that should resolve to this plugin.
64
+ * Coding agents may tag sessions with provider IDs that differ from
65
+ * the plugin's `id` (e.g. OpenCode uses `"openai"` but the plugin
66
+ * registers as `"openai-api"`). List those alternate IDs here so the
67
+ * TUI can resolve brand colors and other metadata correctly.
68
+ */
69
+ providerAliases?: string[];
62
70
  }
63
71
  /** Describes a user-configurable setting that the plugin exposes. */
64
72
  export interface ConfigField {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,qEAAqE;AACrE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,oDAAoD;AACpD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAMrC,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,OAAO,CAAC,EAAE;QACR,OAAO,EAAE,OAAO,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;IACF,4DAA4D;IAC5D,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;IACF,2DAA2D;IAC3D,GAAG,CAAC,EAAE;QACJ,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,IAAI,CAAC,EAA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IAErD;;;OAGG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACrG;AAMD;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAMD,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC9D;AAMD,8EAA8E;AAC9E,qBAAa,qBAAsB,SAAQ,KAAK;aAE5B,QAAQ,EAAE,QAAQ;aAClB,UAAU,EAAE,MAAM,iBAAiB;gBADnC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,iBAAiB,EACnD,OAAO,EAAE,MAAM;CAKlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokentop/plugin-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "SDK for building tokentop plugins — providers, agents, themes, and notifications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "scripts": {
32
32
  "build": "bun run build:types && bun run build:js",
33
33
  "build:types": "tsc --emitDeclarationOnly",
34
- "build:js": "bun build src/index.ts src/types/index.ts src/helpers/index.ts src/testing/index.ts --outdir dist --target node --format esm --splitting",
34
+ "build:js": "bun build src/index.ts --outdir dist --target node --format esm && bun build src/types/index.ts --outdir dist/types --target node --format esm && bun build src/helpers/index.ts --outdir dist/helpers --target node --format esm && bun build src/testing/index.ts --outdir dist/testing --target node --format esm",
35
35
  "typecheck": "tsc --noEmit",
36
36
  "test": "bun test",
37
37
  "clean": "rm -rf dist",
@@ -1,15 +0,0 @@
1
- // src/types/plugin.ts
2
- var CURRENT_API_VERSION = 2;
3
-
4
- class PluginPermissionError extends Error {
5
- pluginId;
6
- permission;
7
- constructor(pluginId, permission, message) {
8
- super(`Plugin "${pluginId}" permission denied: ${message}`);
9
- this.pluginId = pluginId;
10
- this.permission = permission;
11
- this.name = "PluginPermissionError";
12
- }
13
- }
14
-
15
- export { CURRENT_API_VERSION, PluginPermissionError };