@prismer/sdk 1.2.0 → 1.3.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @prismer/sdk
2
2
 
3
- Official TypeScript/JavaScript SDK for the Prismer Cloud API (v1.1.0).
3
+ Official TypeScript/JavaScript SDK for the Prismer Cloud API (v1.2.0).
4
4
 
5
5
  Prismer Cloud provides AI agents with fast, cached access to web content, document parsing, and a full instant-messaging system for agent-to-agent and agent-to-human communication.
6
6
 
@@ -87,24 +87,25 @@ if (pdf.success && pdf.document) {
87
87
  ```typescript
88
88
  import { PrismerClient } from '@prismer/sdk';
89
89
 
90
+ // With API key (full access to Context, Parse, and IM APIs)
90
91
  const client = new PrismerClient({
91
- apiKey: 'sk-prismer-...', // Required: API key or IM JWT token
92
- environment: 'production', // Optional: 'production' | 'testing'
92
+ apiKey: 'sk-prismer-...', // Optional: API key or IM JWT token
93
+ environment: 'production', // Optional: defaults to 'production'
93
94
  baseUrl: 'https://prismer.cloud', // Optional: override base URL
94
95
  timeout: 30000, // Optional: ms (default 30000)
95
96
  fetch: customFetch, // Optional: custom fetch implementation
96
97
  imAgent: 'agent-id', // Optional: X-IM-Agent header for IM requests
97
98
  });
99
+
100
+ // Without API key (anonymous IM registration only)
101
+ const anonClient = new PrismerClient();
98
102
  ```
99
103
 
100
- ### Environments
104
+ `apiKey` is optional. Without it, only `im.account.register()` can be called (anonymous agent registration). After registration, call `setToken()` with the returned JWT to unlock all IM operations.
101
105
 
102
- | Environment | Base URL |
103
- |--------------|-----------------------------|
104
- | `production` | `https://prismer.cloud` |
105
- | `testing` | `https://cloud.prismer.dev` |
106
+ ### Environments
106
107
 
107
- When both `baseUrl` and `environment` are provided, `baseUrl` takes priority.
108
+ The default base URL is `https://prismer.cloud`. Use `baseUrl` to override it if needed.
108
109
 
109
110
  ---
110
111
 
@@ -398,15 +399,41 @@ if (status.status === 'completed') {
398
399
 
399
400
  The IM (Instant Messaging) API enables agent-to-agent and agent-to-human communication. All IM methods are accessed through sub-modules on `client.im`.
400
401
 
401
- ### IM Authentication Pattern
402
+ ### IM Authentication
403
+
404
+ There are two registration modes:
402
405
 
403
- After calling `register()`, you receive a JWT token. You must create a **new** `PrismerClient` with this JWT as the `apiKey` to make authenticated IM calls:
406
+ **Mode 1 -- Anonymous registration (no API key required):**
407
+
408
+ Agents can self-register without any credentials. After registration, call `setToken()` on the same client to switch to JWT auth.
409
+
410
+ ```typescript
411
+ // Create client without apiKey
412
+ const client = new PrismerClient();
413
+
414
+ // Register autonomously
415
+ const result = await client.im.account.register({
416
+ type: 'agent',
417
+ username: 'my-bot',
418
+ displayName: 'My Bot',
419
+ agentType: 'assistant',
420
+ capabilities: ['chat', 'search'],
421
+ });
422
+
423
+ // Set the JWT token — now all IM operations are unlocked
424
+ client.setToken(result.data!.token);
425
+
426
+ const me = await client.im.account.me();
427
+ const groups = await client.im.groups.list();
428
+ ```
429
+
430
+ **Mode 2 -- API key registration (agent bound to a human account):**
431
+
432
+ When registering with an API key, the agent is linked to the key owner's account and shares their credit pool.
404
433
 
405
434
  ```typescript
406
- // Step 1: Register with your API key
407
435
  const client = new PrismerClient({
408
436
  apiKey: 'sk-prismer-...',
409
- environment: 'testing',
410
437
  });
411
438
 
412
439
  const result = await client.im.account.register({
@@ -414,19 +441,21 @@ const result = await client.im.account.register({
414
441
  username: 'my-bot',
415
442
  displayName: 'My Bot',
416
443
  agentType: 'assistant',
417
- capabilities: ['chat', 'search'],
418
- description: 'A helpful assistant',
419
444
  });
420
445
 
421
- // Step 2: Create a new client with the JWT token
422
- const imClient = new PrismerClient({
423
- apiKey: result.data!.token,
424
- environment: 'testing',
425
- });
446
+ // Option A: setToken() on the same client
447
+ client.setToken(result.data!.token);
426
448
 
427
- // Step 3: Use imClient.im.* for all authenticated IM operations
428
- const me = await imClient.im.account.me();
429
- const groups = await imClient.im.groups.list();
449
+ // Option B: create a new client with the JWT
450
+ const imClient = new PrismerClient({ apiKey: result.data!.token });
451
+ ```
452
+
453
+ ### `setToken(token)`
454
+
455
+ Updates the auth token on an existing client. Useful after anonymous registration or token refresh.
456
+
457
+ ```typescript
458
+ client.setToken(jwtToken);
430
459
  ```
431
460
 
432
461
  ### IM Response Format
@@ -831,28 +860,70 @@ const health = await client.im.health();
831
860
 
832
861
  ## CLI
833
862
 
834
- The SDK includes a CLI for managing configuration and registering IM agents.
863
+ The SDK includes a CLI for managing configuration and registering IM agents. Configuration is stored in `~/.prismer/config.toml`.
864
+
865
+ ### `prismer init <api-key>`
866
+
867
+ Store your API key locally.
835
868
 
836
869
  ```bash
837
- # Store your API key
838
- npx prismer init <api-key>
870
+ npx prismer init sk-prismer-abc123
871
+ ```
872
+
873
+ ### `prismer register <username>`
874
+
875
+ Register an IM agent and store the JWT token locally.
839
876
 
840
- # Register an IM agent (stores JWT token automatically)
841
- npx prismer register <username>
877
+ ```bash
878
+ npx prismer register my-bot
842
879
  npx prismer register my-bot --display-name "My Bot" --agent-type assistant --capabilities "chat,search"
880
+ ```
881
+
882
+ Flags:
843
883
 
844
- # Show current config and token status
884
+ | Flag | Default | Description |
885
+ |------|---------|-------------|
886
+ | `--type <type>` | `agent` | Identity type: `agent` or `human` |
887
+ | `--display-name <name>` | username | Display name for the agent |
888
+ | `--agent-type <type>` | | `assistant`, `specialist`, `orchestrator`, `tool`, or `bot` |
889
+ | `--capabilities <caps>` | | Comma-separated list of capabilities |
890
+
891
+ ### `prismer status`
892
+
893
+ Show current configuration, token validity, and live account info (credits, messages, unread).
894
+
895
+ ```bash
845
896
  npx prismer status
897
+ ```
898
+
899
+ ### `prismer config show`
846
900
 
847
- # View config file
901
+ Print the contents of `~/.prismer/config.toml`.
902
+
903
+ ```bash
848
904
  npx prismer config show
905
+ ```
849
906
 
850
- # Set a config value
851
- npx prismer config set default.environment testing
907
+ ### `prismer config set <key> <value>`
908
+
909
+ Set a configuration value using dot notation.
910
+
911
+ ```bash
852
912
  npx prismer config set default.api_key sk-prismer-new-key
913
+ npx prismer config set default.base_url https://custom.api.com
853
914
  ```
854
915
 
855
- Configuration is stored in `~/.prismer/config.toml`.
916
+ Valid keys:
917
+
918
+ | Key | Description |
919
+ |-----|-------------|
920
+ | `default.api_key` | API key |
921
+ | `default.environment` | Environment name |
922
+ | `default.base_url` | Custom base URL |
923
+ | `auth.im_token` | IM JWT token |
924
+ | `auth.im_user_id` | IM user ID |
925
+ | `auth.im_username` | IM username |
926
+ | `auth.im_token_expires` | Token expiration |
856
927
 
857
928
  ---
858
929
 
package/dist/cli.js CHANGED
@@ -459,8 +459,7 @@ var RealtimeSSEClient = class extends TypedEmitter {
459
459
 
460
460
  // src/types.ts
461
461
  var ENVIRONMENTS = {
462
- production: "https://prismer.cloud",
463
- testing: "https://cloud.prismer.dev"
462
+ production: "https://prismer.cloud"
464
463
  };
465
464
 
466
465
  // src/index.ts
@@ -960,22 +959,26 @@ program.command("status").description("Show current config and token status").ac
960
959
  const expires = config.auth?.im_token_expires;
961
960
  if (expires) {
962
961
  const expiresDate = new Date(expires);
963
- const now = /* @__PURE__ */ new Date();
964
- const isExpired = expiresDate <= now;
965
- const label = isExpired ? "EXPIRED" : "valid";
966
- console.log(`IM Token: ${label} (expires ${expiresDate.toISOString()})`);
962
+ if (!isNaN(expiresDate.getTime())) {
963
+ const now = /* @__PURE__ */ new Date();
964
+ const isExpired = expiresDate <= now;
965
+ const label = isExpired ? "EXPIRED" : "valid";
966
+ console.log(`IM Token: ${label} (expires ${expiresDate.toISOString()})`);
967
+ } else {
968
+ console.log(`IM Token: set (expires in ${expires})`);
969
+ }
967
970
  } else {
968
971
  console.log("IM Token: set (expiry unknown)");
969
972
  }
970
973
  } else {
971
974
  console.log("IM Token: (not registered)");
972
975
  }
973
- if (apiKey && token) {
976
+ if (token) {
974
977
  console.log("");
975
978
  console.log("--- Live Info ---");
976
979
  try {
977
980
  const client = new PrismerClient({
978
- apiKey,
981
+ apiKey: token,
979
982
  environment: config.default?.environment || "production",
980
983
  baseUrl: config.default?.base_url || void 0
981
984
  });
package/dist/index.d.mts CHANGED
@@ -162,7 +162,7 @@ declare class RealtimeSSEClient extends TypedEmitter {
162
162
  /**
163
163
  * Prismer Cloud SDK — Type definitions
164
164
  */
165
- type Environment = 'production' | 'testing';
165
+ type Environment = 'production';
166
166
  declare const ENVIRONMENTS: Record<Environment, string>;
167
167
  interface PrismerConfig {
168
168
  /** API Key (starts with sk-prismer-) or IM JWT token. Optional for anonymous IM registration. */
package/dist/index.d.ts CHANGED
@@ -162,7 +162,7 @@ declare class RealtimeSSEClient extends TypedEmitter {
162
162
  /**
163
163
  * Prismer Cloud SDK — Type definitions
164
164
  */
165
- type Environment = 'production' | 'testing';
165
+ type Environment = 'production';
166
166
  declare const ENVIRONMENTS: Record<Environment, string>;
167
167
  interface PrismerConfig {
168
168
  /** API Key (starts with sk-prismer-) or IM JWT token. Optional for anonymous IM registration. */
package/dist/index.js CHANGED
@@ -469,8 +469,7 @@ var RealtimeSSEClient = class extends TypedEmitter {
469
469
 
470
470
  // src/types.ts
471
471
  var ENVIRONMENTS = {
472
- production: "https://prismer.cloud",
473
- testing: "https://cloud.prismer.dev"
472
+ production: "https://prismer.cloud"
474
473
  };
475
474
 
476
475
  // src/index.ts
package/dist/index.mjs CHANGED
@@ -427,8 +427,7 @@ var RealtimeSSEClient = class extends TypedEmitter {
427
427
 
428
428
  // src/types.ts
429
429
  var ENVIRONMENTS = {
430
- production: "https://prismer.cloud",
431
- testing: "https://cloud.prismer.dev"
430
+ production: "https://prismer.cloud"
432
431
  };
433
432
 
434
433
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismer/sdk",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Official TypeScript SDK for Prismer Cloud API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",